b311480e |
1 | -- Created on: 1994-02-18 |
2 | -- Created by: Remi LEQUETTE |
3 | -- Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
7 | -- |
d5f74e42 |
8 | -- This library is free software; you can redistribute it and/or modify it under |
9 | -- the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | -- by the Free Software Foundation, with special exception defined in the file |
11 | -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | -- distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | -- modified by Michael KLOKOV Wed Mar 6 15:01:25 2002 |
7fd59977 |
18 | |
b1d15f53 |
19 | class Section from BRepAlgoAPI |
20 | inherits BooleanOperation from BRepAlgoAPI |
7fd59977 |
21 | |
b1d15f53 |
22 | ---Purpose: Computes the intersection of two shapes or geometries. |
23 | -- Geometries can be surfaces of planes. |
24 | -- Geometries are converted to faces |
25 | -- When a geometry has been converted to |
26 | -- topology the created shape can be found using |
27 | -- the methods Shape1 and Shape2 inherited from the class BooleanOperation. |
28 | -- The result (Shape() method) is a compound containing |
29 | -- edges built on intersection curves. |
30 | -- By default, the section is performed immediatly in |
31 | -- class constructors, with default values : |
32 | -- - geometries built are NOT approximated. |
33 | -- - PCurves are NOT computed on both parts. |
34 | -- Example : giving two shapes S1,S2 accessing faces, |
35 | -- let compute the section edges R on S1,S2, |
36 | -- performing approximation on new curves, |
37 | -- performing PCurve on part 1 but not on part 2 : |
38 | -- Standard_Boolean PerformNow = Standard_False; |
39 | -- BRepBoolAPI_Section S(S1,S2,PerformNow); |
40 | -- S.ComputePCurveOn1(Standard_True); |
41 | -- S.Approximation(Standard_True); |
42 | -- S.Build(); |
43 | -- TopoDS_Shape R = S.Shape(); |
44 | -- On Null Shapes of geometries, NotDone() is called. |
7fd59977 |
45 | |
46 | uses |
47 | Pln from gp, |
48 | Shape from TopoDS, |
49 | Surface from Geom, |
50 | Curve from Geom2d, |
4e57c75e |
51 | PaveFiller from BOPAlgo, |
7fd59977 |
52 | ListOfShape from TopTools |
53 | |
54 | is |
b1d15f53 |
55 | Create |
56 | returns Section from BRepAlgoAPI; |
57 | ---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Section();" |
58 | --- Purpose: Empty constructor |
59 | |
60 | |
61 | Create (S1,S2 : Shape from TopoDS; |
62 | aDSF:PaveFiller from BOPAlgo; |
63 | PerformNow : Boolean = Standard_True) |
64 | returns Section from BRepAlgoAPI; |
65 | |
7fd59977 |
66 | |
67 | Create(Sh1,Sh2 : Shape from TopoDS; |
b1d15f53 |
68 | PerformNow : Boolean = Standard_True) |
69 | returns Section from BRepAlgoAPI; |
70 | ---Purpose: see upper |
71 | ---Level: Public |
72 | |
7fd59977 |
73 | |
b1d15f53 |
74 | Create(Sh : Shape from TopoDS; |
75 | Pl : Pln from gp; |
76 | PerformNow : Boolean = Standard_True) |
77 | returns Section from BRepAlgoAPI; |
78 | ---Purpose: see upper |
79 | ---Level: Public |
80 | |
7fd59977 |
81 | |
b1d15f53 |
82 | Create(Sh : Shape from TopoDS; |
83 | Sf : Surface from Geom; |
84 | PerformNow : Boolean = Standard_True) |
85 | returns Section from BRepAlgoAPI; |
86 | ---Purpose: see upper |
87 | ---Level: Public |
88 | |
7fd59977 |
89 | |
b1d15f53 |
90 | Create(Sf : Surface from Geom; |
91 | Sh : Shape from TopoDS; |
92 | PerformNow : Boolean = Standard_True) |
93 | returns Section from BRepAlgoAPI; |
94 | ---Purpose: see upper |
95 | ---Level: Public |
96 | |
97 | Create(Sf1 : Surface from Geom; |
98 | Sf2 : Surface from Geom; |
99 | PerformNow : Boolean = Standard_True) |
100 | returns Section from BRepAlgoAPI; |
101 | ---Purpose: This and the above classes construct a framework for |
102 | -- computing the section lines of: |
103 | -- - two shapes Sh1 and Sh2, or |
104 | -- - shape Sh and plane Pl, or |
105 | -- - shape Sh and surface Sf, or |
106 | -- - surface Sf and shape Sh, or |
107 | -- - two surfaces Sf1 and Sf2, |
108 | -- and builds a result if PerformNow equals true, its |
109 | -- default value. If PerformNow equals false, the intersection |
110 | -- will be computed later by the function Build. |
111 | -- The constructed shape will be returned by the function Shape. |
112 | -- This is a compound object composed of edges. These |
113 | -- intersection edges may be built: |
114 | -- - on new intersection lines, or |
115 | -- - on coincident portions of edges in the two intersected shapes. |
116 | -- These intersection edges are independent: they are not |
117 | -- chained or grouped in wires. If no intersection edge exists, the |
118 | -- result is an empty compound object. |
119 | -- Note that other objects than TopoDS_Shape shapes involved in |
120 | -- these syntaxes are converted into faces or shells before |
121 | -- performing the computation of the intersection. A shape |
122 | -- resulting from this conversion can be retrieved with the |
123 | -- function Shape1 or Shape2. |
124 | -- Parametric 2D curves on intersection edges |
125 | -- No parametric 2D curve (pcurve) is defined for each elementary |
126 | -- edge of the result. To attach such parametric curves to the |
127 | -- constructed edges you may use a constructor with the PerformNow |
128 | -- flag equal to false; then you use: |
129 | -- - the function ComputePCurveOn1 to ask for |
130 | -- the additional computation of a pcurve in the parametric |
131 | -- space of the first shape, |
132 | -- - the function ComputePCurveOn2 to ask for |
133 | -- the additional computation of a pcurve in the parametric |
134 | -- space of the second shape, in the end, |
135 | -- - the function Build to construct the result. |
136 | -- Approximation of intersection edges |
137 | -- The underlying 3D geometry attached to each elementary edge |
138 | -- of the result is: |
139 | -- - analytic where possible, provided the corresponding |
140 | -- geometry corresponds to a type of analytic curve |
141 | -- defined in the Geom package; for example, the intersection |
142 | -- of a cylindrical shape with a plane gives an ellipse or a circle; |
143 | -- - or elsewhere, given as a succession of points grouped |
144 | -- together in a BSpline curve of degree 1. |
145 | -- If you prefer to have an attached 3D geometry which is a |
146 | -- BSpline approximation of the computed set of points on |
147 | -- computed elementary intersection edges whose underlying geometry |
148 | -- is not analytic, you may use a constructor with the PerformNow |
149 | -- flag equal to false. Then you use: |
150 | -- - the function Approximation to ask for this |
151 | -- computation option, and |
152 | -- - the function Build to construct the result. |
153 | -- - Note that as a result, approximations will only be |
154 | -- computed on edges built on new intersection lines. |
155 | -- - Example |
156 | -- You may also combine these computation options. In the following example: |
157 | -- - each elementary edge of the computed intersection, |
158 | -- built on a new intersection line, which does not |
159 | -- correspond to an analytic Geom curve, will be approximated by |
160 | -- a BSpline curve whose degree is not greater than 8. |
161 | -- - each elementary edge built on a new intersection line, will have: |
162 | -- - a pcurve in the parametric space of the intersected face of shape S1, |
163 | -- - no pcurve in the parametric space of the intersected face of shape S2. |
164 | -- // TopoDS_Shape S1 = ... , S2 = ... ; |
165 | -- Standard_Boolean PerformNow = Standard_False; |
166 | -- BRepAlgoAPI_Section S ( S1, S2, PerformNow ); |
167 | -- S.ComputePCurveOn1 (Standard_True); |
168 | -- S.Approximation (Standard_True); |
169 | -- S.Build(); |
170 | -- TopoDS_Shape R = S.Shape(); |
171 | |
7fd59977 |
172 | |
b1d15f53 |
173 | Init1(me : out; |
174 | S1 : Shape from TopoDS); |
175 | ---Purpose: initialize first part |
176 | ---Level: Public |
7fd59977 |
177 | |
b1d15f53 |
178 | Init1(me : out; |
179 | Pl : Pln from gp); |
180 | ---Purpose: initialize first part |
181 | ---Level: Public |
7fd59977 |
182 | |
b1d15f53 |
183 | Init1(me : out; |
184 | Sf : Surface from Geom); |
185 | ---Purpose: initialize first part |
186 | ---Level: Public |
7fd59977 |
187 | |
b1d15f53 |
188 | Init2(me : out; |
189 | S2 : Shape from TopoDS); |
190 | ---Purpose: initialize second part |
191 | ---Level: Public |
7fd59977 |
192 | |
b1d15f53 |
193 | Init2(me : out; |
194 | Pl : Pln from gp); |
195 | ---Purpose: initialize second part |
196 | ---Level: Public |
7fd59977 |
197 | |
b1d15f53 |
198 | Init2(me : out; |
199 | Sf : Surface from Geom); |
200 | ---Purpose: Reinitializes the first and the |
201 | -- second parts on which this algorithm is going to perform |
202 | -- the intersection computation. This is done with either: the |
203 | -- surface Sf, the plane Pl or the shape Sh. |
204 | -- You use the function Build to construct the result. |
7fd59977 |
205 | |
b1d15f53 |
206 | Approximation(me : out; |
207 | B : Boolean from Standard); |
208 | ---Level: Public |
209 | ---Purpose: Defines an option for computation |
210 | -- of further intersections. This computation will be performed by |
211 | -- the function Build in this framework. |
212 | -- By default, the underlying 3D geometry attached to each |
213 | -- elementary edge of the result of a computed intersection is: |
214 | -- - analytic where possible, provided the corresponding |
215 | -- geometry corresponds to a type of analytic curve defined in |
216 | -- the Geom package; for example the intersection of a |
217 | -- cylindrical shape with a plane gives an ellipse or a circle; |
218 | -- - or elsewhere, given as a succession of points grouped |
219 | -- together in a BSpline curve of degree 1. If Approx equals |
220 | -- true, when further computations are performed in this framework |
221 | -- with the function Build, these edges will have an attached 3D |
222 | -- geometry which is a BSpline approximation of the computed |
223 | -- set of points. |
224 | -- Note that as a result, approximations will be computed |
225 | -- on edges built only on new intersection lines. |
7fd59977 |
226 | |
b1d15f53 |
227 | ComputePCurveOn1(me : out; |
228 | B : Boolean from Standard); |
229 | ---Level: Public |
230 | ---Purpose: |
231 | -- Indicates if the Pcurve must be (or not) performed on first part. |
7fd59977 |
232 | |
b1d15f53 |
233 | ComputePCurveOn2(me : out; |
234 | B : Boolean from Standard); |
235 | ---Level: Public |
236 | ---Purpose: Define options for the computation of further |
237 | -- intersections, which will be performed by the function Build |
238 | -- in this framework. |
239 | -- By default, no parametric 2D curve (pcurve) is defined for the |
240 | -- elementary edges of the result. If ComputePCurve1 equals true, |
241 | -- further computations performed in this framework with the function |
242 | -- Build will attach an additional pcurve in the parametric space of |
243 | -- the first shape to the constructed edges. |
244 | -- If ComputePCurve2 equals true, the additional pcurve will be |
245 | -- attached to the constructed edges in the parametric space of the |
246 | -- second shape. |
247 | -- These two functions may be used together. |
7fd59977 |
248 | |
b1d15f53 |
249 | Build(me : in out) |
250 | is redefined; |
251 | ---Purpose: Performs the computation of |
252 | -- section lines between two parts defined at the time of |
253 | -- construction of this framework or reinitialized with the Init1 and |
254 | -- Init2 functions. |
255 | -- The constructed shape will be returned by the function Shape. |
256 | -- This is a compound object composed of edges. These |
257 | -- intersection edges may be built: |
258 | -- - on new intersection lines, or |
259 | -- - on coincident portions of edges in the two intersected shapes. |
260 | -- These intersection edges are independent: they are not chained |
261 | -- or grouped into wires. |
262 | -- If no intersection edge exists, the result is an empty compound object. |
263 | -- The shapes involved in the construction of section lines can |
264 | -- be retrieved with the function Shape1 or Shape2. Note that other |
265 | -- objects than TopoDS_Shape shapes given as arguments at the |
266 | -- construction time of this framework, or to the Init1 or |
267 | -- Init2 function, are converted into faces or shells before |
268 | -- performing the computation of the intersection. |
269 | -- Parametric 2D curves on intersection edges |
270 | -- No parametric 2D curve (pcurve) is defined for the elementary |
271 | -- edges of the result. To attach parametric curves like this to |
272 | -- the constructed edges you have to use: |
273 | -- - the function |
274 | -- ComputePCurveOn1 to ask for the additional computation of a |
275 | -- pcurve in the parametric space of the first shape, |
276 | -- - the function |
277 | -- ComputePCurveOn2 to ask for the additional computation of a |
278 | -- pcurve in the parametric space of the second shape. |
279 | -- This must be done before calling this function. |
280 | -- Approximation of intersection edges |
281 | -- The underlying 3D geometry attached to each elementary edge of the result is: |
282 | -- - analytic (where possible) provided the corresponding |
283 | -- geometry corresponds to a type of analytic curve defined in |
284 | -- the Geom package; for example, the intersection of a |
285 | -- cylindrical shape with a plane gives an ellipse or a circle; or |
286 | -- - elsewhere, given as a succession of points grouped |
287 | -- together in a BSpline curve of degree 1. |
288 | -- If, on computed elementary intersection edges whose |
289 | -- underlying geometry is not analytic, you prefer to have an |
290 | -- attached 3D geometry which is a Bspline approximation of the |
291 | -- computed set of points, you have to use the function Approximation |
292 | -- to ask for this computation option before calling this function. |
293 | -- You may also have combined these computation options: look at the |
294 | -- example given above to illustrate the use of the constructors. |
295 | |
7fd59977 |
296 | |
b1d15f53 |
297 | HasAncestorFaceOn1(me; |
298 | E : Shape from TopoDS; |
299 | F : out Shape from TopoDS) |
300 | returns Boolean from Standard; |
301 | ---Level: Public |
302 | ---Purpose: |
303 | -- get the face of the first part giving section edge <E>. |
304 | -- Returns True on the 3 following conditions : |
305 | -- 1/ <E> is an edge returned by the Shape() method. |
306 | -- 2/ First part of section performed is a shape. |
307 | -- 3/ <E> is built on a intersection curve (i.e <E> |
308 | -- is not the result of common edges) |
309 | -- When False, F remains untouched. |
7fd59977 |
310 | |
b1d15f53 |
311 | HasAncestorFaceOn2(me; |
312 | E : Shape from TopoDS; |
313 | F : out Shape from TopoDS) |
314 | returns Boolean from Standard; |
315 | ---Purpose: Identifies the ancestor faces of |
316 | -- the intersection edge E resulting from the last |
317 | -- computation performed in this framework, that is, the faces of |
318 | -- the two original shapes on which the edge E lies: |
319 | -- - HasAncestorFaceOn1 gives the ancestor face in the first shape, and |
320 | -- - HasAncestorFaceOn2 gives the ancestor face in the second shape. |
321 | -- These functions return true if an ancestor face F is found, or false if not. |
322 | -- An ancestor face is identifiable for the edge E if the following |
323 | -- conditions are satisfied: |
324 | -- - the first part on which this algorithm performed its |
325 | -- last computation is a shape, that is, it was not given as |
326 | -- a surface or a plane at the time of construction of this |
327 | -- algorithm or at a later time by the Init1 function, |
328 | -- - E is one of the elementary edges built by the |
329 | -- last computation of this section algorithm. |
330 | -- To use these functions properly, you have to test the returned |
331 | -- Boolean value before using the ancestor face: F is significant |
332 | -- only if the returned Boolean value equals true. |
7fd59977 |
333 | |
b1d15f53 |
334 | InitParameters(me: out) |
335 | is private; |
336 | ---Level: Private |
337 | |
7fd59977 |
338 | |
339 | fields |
340 | myshapeisnull : Boolean from Standard; |
341 | myparameterschanged : Boolean from Standard; |
342 | myApprox : Boolean from Standard; |
343 | myComputePCurve1 : Boolean from Standard; |
344 | myComputePCurve2 : Boolean from Standard; |
345 | |
346 | end Section from BRepAlgoAPI; |