Commit | Line | Data |
---|---|---|

b311480e | 1 | -- Created on: 1994-02-18 |

2 | -- Created by: Remi LEQUETTE | |

3 | -- Copyright (c) 1994-1999 Matra Datavision | |

4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS | |

5 | -- | |

6 | -- The content of this file is subject to the Open CASCADE Technology Public | |

7 | -- License Version 6.5 (the "License"). You may not use the content of this file | |

8 | -- except in compliance with the License. Please obtain a copy of the License | |

9 | -- at http://www.opencascade.org and read it completely before using this file. | |

10 | -- | |

11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |

12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |

13 | -- | |

14 | -- The Original Code and all software distributed under the License is | |

15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the | |

16 | -- Initial Developer hereby disclaims all such warranties, including without | |

17 | -- limitation, any warranties of merchantability, fitness for a particular | |

18 | -- purpose or non-infringement. Please see the License for the specific terms | |

19 | -- and conditions governing the rights and limitations under the License. | |

20 | ||

7fd59977 | 21 | -- modified by Michael KLOKOV Wed Mar 6 15:01:25 2002 |

7fd59977 | 22 | |

23 | class Section from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI | |

24 | ||

25 | ---Purpose: Computes the intersection of two shapes or geometries. | |

26 | -- Geometries can be surfaces of planes. | |

27 | -- Geometries are converted to faces | |

28 | -- When a geometry has been converted to | |

29 | -- topology the created shape can be found using | |

30 | -- the methods Shape1 and Shape2 inherited from the class BooleanOperation. | |

31 | -- The result (Shape() method) is a compound containing | |

32 | -- edges built on intersection curves. | |

33 | -- By default, the section is performed immediatly in | |

34 | -- class constructors, with default values : | |

35 | -- - geometries built are NOT approximated. | |

36 | -- - PCurves are NOT computed on both parts. | |

37 | -- Example : giving two shapes S1,S2 accessing faces, | |

38 | -- let compute the section edges R on S1,S2, | |

39 | -- performing approximation on new curves, | |

40 | -- performing PCurve on part 1 but not on part 2 : | |

41 | -- Standard_Boolean PerformNow = Standard_False; | |

42 | -- BRepBoolAPI_Section S(S1,S2,PerformNow); | |

43 | -- S.ComputePCurveOn1(Standard_True); | |

44 | -- S.Approximation(Standard_True); | |

45 | -- S.Build(); | |

46 | -- TopoDS_Shape R = S.Shape(); | |

47 | -- On Null Shapes of geometries, NotDone() is called. | |

48 | ||

49 | uses | |

50 | Pln from gp, | |

51 | Shape from TopoDS, | |

52 | Surface from Geom, | |

53 | Curve from Geom2d, | |

4e57c75e | 54 | PaveFiller from BOPAlgo, |

7fd59977 | 55 | ListOfShape from TopTools |

56 | ||

57 | is | |

58 | Create (S1,S2 : Shape from TopoDS; | |

4e57c75e | 59 | aDSF:PaveFiller from BOPAlgo; |

7fd59977 | 60 | PerformNow : Boolean = Standard_True) |

61 | returns Section from BRepAlgoAPI; | |

4e57c75e | 62 | ---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Section(){}" |

7fd59977 | 63 | |

64 | Create(Sh1,Sh2 : Shape from TopoDS; | |

65 | PerformNow : Boolean = Standard_True) | |

66 | ---Purpose: see upper | |

67 | ---Level: Public | |

68 | returns Section from BRepAlgoAPI; | |

69 | ||

70 | Create(Sh : Shape from TopoDS; Pl : Pln from gp; | |

71 | PerformNow : Boolean = Standard_True) | |

72 | ---Purpose: see upper | |

73 | ---Level: Public | |

74 | returns Section from BRepAlgoAPI; | |

75 | ||

76 | Create(Sh : Shape from TopoDS; Sf : Surface from Geom; | |

77 | PerformNow : Boolean = Standard_True) | |

78 | ---Purpose: see upper | |

79 | ---Level: Public | |

80 | returns Section from BRepAlgoAPI; | |

81 | ||

82 | Create(Sf : Surface from Geom; Sh : Shape from TopoDS; | |

83 | PerformNow : Boolean = Standard_True) | |

84 | ---Purpose: see upper | |

85 | ---Level: Public | |

86 | returns Section from BRepAlgoAPI; | |

87 | ||

88 | Create(Sf1 : Surface from Geom; Sf2 : Surface from Geom; | |

89 | PerformNow : Boolean = Standard_True) | |

90 | ---Purpose: This and the above classes construct a framework for | |

91 | -- computing the section lines of: | |

92 | -- - two shapes Sh1 and Sh2, or | |

93 | -- - shape Sh and plane Pl, or | |

94 | -- - shape Sh and surface Sf, or | |

95 | -- - surface Sf and shape Sh, or | |

96 | -- - two surfaces Sf1 and Sf2, | |

97 | -- and builds a result if PerformNow equals true, its | |

98 | -- default value. If PerformNow equals false, the intersection | |

99 | -- will be computed later by the function Build. | |

100 | -- The constructed shape will be returned by the function Shape. | |

101 | -- This is a compound object composed of edges. These | |

102 | -- intersection edges may be built: | |

103 | -- - on new intersection lines, or | |

104 | -- - on coincident portions of edges in the two intersected shapes. | |

105 | -- These intersection edges are independent: they are not | |

106 | -- chained or grouped in wires. If no intersection edge exists, the | |

107 | -- result is an empty compound object. | |

108 | -- Note that other objects than TopoDS_Shape shapes involved in | |

109 | -- these syntaxes are converted into faces or shells before | |

110 | -- performing the computation of the intersection. A shape | |

111 | -- resulting from this conversion can be retrieved with the | |

112 | -- function Shape1 or Shape2. | |

113 | -- Parametric 2D curves on intersection edges | |

114 | -- No parametric 2D curve (pcurve) is defined for each elementary | |

115 | -- edge of the result. To attach such parametric curves to the | |

116 | -- constructed edges you may use a constructor with the PerformNow | |

117 | -- flag equal to false; then you use: | |

118 | -- - the function ComputePCurveOn1 to ask for | |

119 | -- the additional computation of a pcurve in the parametric | |

120 | -- space of the first shape, | |

121 | -- - the function ComputePCurveOn2 to ask for | |

122 | -- the additional computation of a pcurve in the parametric | |

123 | -- space of the second shape, in the end, | |

124 | -- - the function Build to construct the result. | |

125 | -- Approximation of intersection edges | |

126 | -- The underlying 3D geometry attached to each elementary edge | |

127 | -- of the result is: | |

128 | -- - analytic where possible, provided the corresponding | |

129 | -- geometry corresponds to a type of analytic curve | |

130 | -- defined in the Geom package; for example, the intersection | |

131 | -- of a cylindrical shape with a plane gives an ellipse or a circle; | |

132 | -- - or elsewhere, given as a succession of points grouped | |

133 | -- together in a BSpline curve of degree 1. | |

134 | -- If you prefer to have an attached 3D geometry which is a | |

135 | -- BSpline approximation of the computed set of points on | |

136 | -- computed elementary intersection edges whose underlying geometry | |

137 | -- is not analytic, you may use a constructor with the PerformNow | |

138 | -- flag equal to false. Then you use: | |

139 | -- - the function Approximation to ask for this | |

140 | -- computation option, and | |

141 | -- - the function Build to construct the result. | |

142 | -- - Note that as a result, approximations will only be | |

143 | -- computed on edges built on new intersection lines. | |

144 | -- - Example | |

145 | -- You may also combine these computation options. In the following example: | |

146 | -- - each elementary edge of the computed intersection, | |

147 | -- built on a new intersection line, which does not | |

148 | -- correspond to an analytic Geom curve, will be approximated by | |

149 | -- a BSpline curve whose degree is not greater than 8. | |

150 | -- - each elementary edge built on a new intersection line, will have: | |

151 | -- - a pcurve in the parametric space of the intersected face of shape S1, | |

152 | -- - no pcurve in the parametric space of the intersected face of shape S2. | |

153 | -- // TopoDS_Shape S1 = ... , S2 = ... ; | |

154 | -- Standard_Boolean PerformNow = Standard_False; | |

155 | -- BRepAlgoAPI_Section S ( S1, S2, PerformNow ); | |

156 | -- S.ComputePCurveOn1 (Standard_True); | |

157 | -- S.Approximation (Standard_True); | |

158 | -- S.Build(); | |

159 | -- TopoDS_Shape R = S.Shape(); | |

160 | returns Section from BRepAlgoAPI; | |

161 | ||

162 | Init1(me : out;S1 : Shape from TopoDS); | |

163 | ---Purpose: initialize first part | |

164 | ---Level: Public | |

165 | ||

166 | Init1(me : out;Pl : Pln from gp); | |

167 | ---Purpose: initialize first part | |

168 | ---Level: Public | |

169 | ||

170 | Init1(me : out;Sf : Surface from Geom); | |

171 | ---Purpose: initialize first part | |

172 | ---Level: Public | |

173 | ||

174 | Init2(me : out;S2 : Shape from TopoDS); | |

175 | ---Purpose: initialize second part | |

176 | ---Level: Public | |

177 | ||

178 | Init2(me : out;Pl : Pln from gp); | |

179 | ---Purpose: initialize second part | |

180 | ---Level: Public | |

181 | ||

182 | Init2(me : out;Sf : Surface from Geom); | |

183 | ---Purpose: Reinitializes the first and the | |

184 | -- second parts on which this algorithm is going to perform | |

185 | -- the intersection computation. This is done with either: the | |

186 | -- surface Sf, the plane Pl or the shape Sh. | |

187 | -- You use the function Build to construct the result. | |

188 | ||

189 | Approximation(me : out;B : Boolean); | |

190 | ---Level: Public | |

191 | ---Purpose: Defines an option for computation | |

192 | -- of further intersections. This computation will be performed by | |

193 | -- the function Build in this framework. | |

194 | -- By default, the underlying 3D geometry attached to each | |

195 | -- elementary edge of the result of a computed intersection is: | |

196 | -- - analytic where possible, provided the corresponding | |

197 | -- geometry corresponds to a type of analytic curve defined in | |

198 | -- the Geom package; for example the intersection of a | |

199 | -- cylindrical shape with a plane gives an ellipse or a circle; | |

200 | -- - or elsewhere, given as a succession of points grouped | |

201 | -- together in a BSpline curve of degree 1. If Approx equals | |

202 | -- true, when further computations are performed in this framework | |

203 | -- with the function Build, these edges will have an attached 3D | |

204 | -- geometry which is a BSpline approximation of the computed | |

205 | -- set of points. | |

206 | -- Note that as a result, approximations will be computed | |

207 | -- on edges built only on new intersection lines. | |

208 | ||

209 | ComputePCurveOn1(me : out;B : Boolean); | |

210 | ---Level: Public | |

211 | ---Purpose: | |

212 | -- Indicates if the Pcurve must be (or not) performed on first part. | |

213 | ||

214 | ComputePCurveOn2(me : out;B : Boolean); | |

215 | ---Level: Public | |

216 | ---Purpose: Define options for the computation of further | |

217 | -- intersections, which will be performed by the function Build | |

218 | -- in this framework. | |

219 | -- By default, no parametric 2D curve (pcurve) is defined for the | |

220 | -- elementary edges of the result. If ComputePCurve1 equals true, | |

221 | -- further computations performed in this framework with the function | |

222 | -- Build will attach an additional pcurve in the parametric space of | |

223 | -- the first shape to the constructed edges. | |

224 | -- If ComputePCurve2 equals true, the additional pcurve will be | |

225 | -- attached to the constructed edges in the parametric space of the | |

226 | -- second shape. | |

227 | -- These two functions may be used together. | |

228 | ||

229 | Build(me : in out) | |

230 | ---Purpose: Performs the computation of | |

231 | -- section lines between two parts defined at the time of | |

232 | -- construction of this framework or reinitialized with the Init1 and | |

233 | -- Init2 functions. | |

234 | -- The constructed shape will be returned by the function Shape. | |

235 | -- This is a compound object composed of edges. These | |

236 | -- intersection edges may be built: | |

237 | -- - on new intersection lines, or | |

238 | -- - on coincident portions of edges in the two intersected shapes. | |

239 | -- These intersection edges are independent: they are not chained | |

240 | -- or grouped into wires. | |

241 | -- If no intersection edge exists, the result is an empty compound object. | |

242 | -- The shapes involved in the construction of section lines can | |

243 | -- be retrieved with the function Shape1 or Shape2. Note that other | |

244 | -- objects than TopoDS_Shape shapes given as arguments at the | |

245 | -- construction time of this framework, or to the Init1 or | |

246 | -- Init2 function, are converted into faces or shells before | |

247 | -- performing the computation of the intersection. | |

248 | -- Parametric 2D curves on intersection edges | |

249 | -- No parametric 2D curve (pcurve) is defined for the elementary | |

250 | -- edges of the result. To attach parametric curves like this to | |

251 | -- the constructed edges you have to use: | |

252 | -- - the function | |

253 | -- ComputePCurveOn1 to ask for the additional computation of a | |

254 | -- pcurve in the parametric space of the first shape, | |

255 | -- - the function | |

256 | -- ComputePCurveOn2 to ask for the additional computation of a | |

257 | -- pcurve in the parametric space of the second shape. | |

258 | -- This must be done before calling this function. | |

259 | -- Approximation of intersection edges | |

260 | -- The underlying 3D geometry attached to each elementary edge of the result is: | |

261 | -- - analytic (where possible) provided the corresponding | |

262 | -- geometry corresponds to a type of analytic curve defined in | |

263 | -- the Geom package; for example, the intersection of a | |

264 | -- cylindrical shape with a plane gives an ellipse or a circle; or | |

265 | -- - elsewhere, given as a succession of points grouped | |

266 | -- together in a BSpline curve of degree 1. | |

267 | -- If, on computed elementary intersection edges whose | |

268 | -- underlying geometry is not analytic, you prefer to have an | |

269 | -- attached 3D geometry which is a Bspline approximation of the | |

270 | -- computed set of points, you have to use the function Approximation | |

271 | -- to ask for this computation option before calling this function. | |

272 | -- You may also have combined these computation options: look at the | |

273 | -- example given above to illustrate the use of the constructors. | |

274 | is redefined static; | |

275 | ||

276 | HasAncestorFaceOn1(me; E : Shape from TopoDS; | |

277 | F : out Shape from TopoDS) | |

278 | returns Boolean; | |

279 | ---Level: Public | |

280 | ---Purpose: | |

281 | -- get the face of the first part giving section edge <E>. | |

282 | -- Returns True on the 3 following conditions : | |

283 | -- 1/ <E> is an edge returned by the Shape() method. | |

284 | -- 2/ First part of section performed is a shape. | |

285 | -- 3/ <E> is built on a intersection curve (i.e <E> | |

286 | -- is not the result of common edges) | |

287 | -- When False, F remains untouched. | |

288 | ||

289 | HasAncestorFaceOn2(me; E : Shape from TopoDS; | |

290 | F : out Shape from TopoDS) | |

291 | returns Boolean; | |

292 | ---Purpose: Identifies the ancestor faces of | |

293 | -- the intersection edge E resulting from the last | |

294 | -- computation performed in this framework, that is, the faces of | |

295 | -- the two original shapes on which the edge E lies: | |

296 | -- - HasAncestorFaceOn1 gives the ancestor face in the first shape, and | |

297 | -- - HasAncestorFaceOn2 gives the ancestor face in the second shape. | |

298 | -- These functions return true if an ancestor face F is found, or false if not. | |

299 | -- An ancestor face is identifiable for the edge E if the following | |

300 | -- conditions are satisfied: | |

301 | -- - the first part on which this algorithm performed its | |

302 | -- last computation is a shape, that is, it was not given as | |

303 | -- a surface or a plane at the time of construction of this | |

304 | -- algorithm or at a later time by the Init1 function, | |

305 | -- - E is one of the elementary edges built by the | |

306 | -- last computation of this section algorithm. | |

307 | -- To use these functions properly, you have to test the returned | |

308 | -- Boolean value before using the ancestor face: F is significant | |

309 | -- only if the returned Boolean value equals true. | |

310 | ||

7fd59977 | 311 | InitParameters(me: out) |

312 | ---Level: Private | |

313 | is private; | |

314 | ||

315 | fields | |

316 | myshapeisnull : Boolean from Standard; | |

317 | myparameterschanged : Boolean from Standard; | |

318 | myApprox : Boolean from Standard; | |

319 | myComputePCurve1 : Boolean from Standard; | |

320 | myComputePCurve2 : Boolean from Standard; | |

321 | ||

322 | end Section from BRepAlgoAPI; |