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