b311480e |
1 | // Created on: 1996-06-03 |
2 | // Created by: Laurent BUCHARD |
3 | // Copyright (c) 1996-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. |
7fd59977 |
16 | |
17 | #define OPTIMISATION 1 |
18 | |
42cf5bc1 |
19 | #include <Adaptor3d_HCurve.hxx> |
20 | #include <Adaptor3d_HSurfaceTool.hxx> |
7fd59977 |
21 | #include <Bnd_BoundSortBox.hxx> |
42cf5bc1 |
22 | #include <Bnd_Box.hxx> |
7fd59977 |
23 | #include <BRepAdaptor_HSurface.hxx> |
7fd59977 |
24 | #include <BRepClass_FaceClassifier.hxx> |
42cf5bc1 |
25 | #include <BRepTopAdaptor_TopolTool.hxx> |
26 | #include <Geom_Line.hxx> |
7fd59977 |
27 | #include <GeomAdaptor_Curve.hxx> |
7fd59977 |
28 | #include <GeomAdaptor_HCurve.hxx> |
42cf5bc1 |
29 | #include <gp_Lin.hxx> |
30 | #include <gp_Pnt.hxx> |
31 | #include <gp_Pnt2d.hxx> |
32 | #include <IntCurvesFace_Intersector.hxx> |
33 | #include <IntCurveSurface_HInter.hxx> |
34 | #include <IntCurveSurface_IntersectionPoint.hxx> |
35 | #include <IntCurveSurface_SequenceOfPnt.hxx> |
7fd59977 |
36 | #include <IntCurveSurface_TheHCurveTool.hxx> |
7fd59977 |
37 | #include <IntCurveSurface_ThePolygonOfHInter.hxx> |
42cf5bc1 |
38 | #include <IntCurveSurface_ThePolyhedronOfHInter.hxx> |
39 | #include <IntCurveSurface_ThePolyhedronToolOfHInter.hxx> |
40 | #include <Intf_Tool.hxx> |
41 | #include <TopAbs.hxx> |
42 | #include <TopoDS_Face.hxx> |
f85e7ddb |
43 | #include <BRep_Tool.hxx> |
44 | #include <TopoDS.hxx> |
3dd193aa |
45 | #include <GeomAPI_ProjectPointOnCurve.hxx> |
f24f5428 |
46 | // |
47 | static void ComputeSamplePars(const Handle(Adaptor3d_HSurface)& Hsurface, |
48 | const Standard_Integer nbsu, |
49 | const Standard_Integer nbsv, |
50 | Handle(TColStd_HArray1OfReal)& UPars, |
51 | Handle(TColStd_HArray1OfReal)& VPars) |
52 | { |
53 | Standard_Integer NbUInts = Hsurface->NbUIntervals(GeomAbs_C2); |
54 | Standard_Integer NbVInts = Hsurface->NbVIntervals(GeomAbs_C2); |
55 | TColStd_Array1OfReal UInts(1, NbUInts + 1); |
56 | TColStd_Array1OfReal VInts(1, NbVInts + 1); |
57 | Hsurface->UIntervals(UInts, GeomAbs_C2); |
58 | Hsurface->VIntervals(VInts, GeomAbs_C2); |
59 | // |
60 | TColStd_Array1OfInteger NbUSubInts(1, NbUInts); |
61 | TColStd_Array1OfInteger NbVSubInts(1, NbVInts); |
62 | // |
63 | Standard_Integer i, j, ind, NbU, NbV; |
64 | Standard_Real t, dt; |
65 | t = UInts(NbUInts + 1) - UInts(1); |
66 | t = 1. / t; |
67 | NbU = 0; |
68 | for(i = 1; i <= NbUInts; ++i) |
69 | { |
70 | dt = (UInts(i+1) - UInts(i)); |
71 | NbUSubInts(i) = RealToInt(nbsu * dt * t) + 1; |
72 | NbU += NbUSubInts(i); |
73 | } |
74 | t = VInts(NbVInts + 1) - VInts(1); |
75 | t = 1. / t; |
76 | NbV = 0; |
77 | for(i = 1; i <= NbVInts; ++i) |
78 | { |
79 | dt = (VInts(i+1) - VInts(i)); |
80 | NbVSubInts(i) = RealToInt(nbsv * dt * t) + 1; |
81 | NbV += NbVSubInts(i); |
82 | } |
83 | UPars = new TColStd_HArray1OfReal(1, NbU + 1); |
84 | VPars = new TColStd_HArray1OfReal(1, NbV + 1); |
85 | // |
86 | ind = 1; |
87 | for(i = 1; i <= NbUInts; ++i) |
88 | { |
89 | UPars->SetValue(ind++, UInts(i)); |
90 | dt = (UInts(i+1) - UInts(i)) / NbUSubInts(i); |
91 | t = UInts(i); |
92 | for(j = 1; j < NbUSubInts(i); ++j) |
93 | { |
94 | t += dt; |
95 | UPars->SetValue(ind++, t); |
96 | } |
97 | } |
98 | UPars->SetValue(ind, UInts(NbUInts + 1)); |
99 | // |
100 | ind = 1; |
101 | for(i = 1; i <= NbVInts; ++i) |
102 | { |
103 | VPars->SetValue(ind++, VInts(i)); |
104 | dt = (VInts(i+1) - VInts(i)) / NbVSubInts(i); |
105 | t = VInts(i); |
106 | for(j = 1; j < NbVSubInts(i); ++j) |
107 | { |
108 | t += dt; |
109 | VPars->SetValue(ind++, t); |
110 | } |
111 | } |
112 | VPars->SetValue(ind, VInts(NbVInts + 1)); |
113 | } |
114 | // |
7d9b843c |
115 | //======================================================================= |
116 | //function : SurfaceType |
117 | //purpose : |
118 | //======================================================================= |
119 | GeomAbs_SurfaceType IntCurvesFace_Intersector::SurfaceType() const |
120 | { |
7fd59977 |
121 | return(Adaptor3d_HSurfaceTool::GetType(Hsurface)); |
122 | } |
7d9b843c |
123 | //======================================================================= |
124 | //function : IntCurvesFace_Intersector |
125 | //purpose : |
126 | //======================================================================= |
7fd59977 |
127 | IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face, |
a0258acd |
128 | const Standard_Real aTol, |
58e14d59 |
129 | const Standard_Boolean aRestr, |
130 | const Standard_Boolean UseBToler) |
f85e7ddb |
131 | |
7fd59977 |
132 | : |
7d9b843c |
133 | Tol(aTol), |
134 | done(Standard_False), |
e8dec5e1 |
135 | myReady(Standard_False), |
7d9b843c |
136 | nbpnt(0), |
137 | PtrOnPolyhedron(NULL), |
58e14d59 |
138 | PtrOnBndBounding(NULL), |
f84edf58 |
139 | myUseBoundTol (UseBToler), |
140 | myIsParallel(Standard_False) |
7fd59977 |
141 | { |
142 | BRepAdaptor_Surface surface; |
143 | face = Face; |
a0258acd |
144 | surface.Initialize(Face, aRestr); |
7fd59977 |
145 | Hsurface = new BRepAdaptor_HSurface(surface); |
146 | myTopolTool = new BRepTopAdaptor_TopolTool(Hsurface); |
147 | |
148 | GeomAbs_SurfaceType SurfaceType = Adaptor3d_HSurfaceTool::GetType(Hsurface); |
149 | if( (SurfaceType != GeomAbs_Plane) |
150 | && (SurfaceType != GeomAbs_Cylinder) |
151 | && (SurfaceType != GeomAbs_Cone) |
152 | && (SurfaceType != GeomAbs_Sphere) |
153 | && (SurfaceType != GeomAbs_Torus)) { |
154 | Standard_Integer nbsu,nbsv; |
155 | Standard_Real U0,V0,U1,V1; |
156 | U0 = Hsurface->FirstUParameter(); |
157 | U1 = Hsurface->LastUParameter(); |
158 | V0 = Hsurface->FirstVParameter(); |
159 | V1 = Hsurface->LastVParameter(); |
f24f5428 |
160 | // |
161 | nbsu = myTopolTool->NbSamplesU(); |
162 | nbsv = myTopolTool->NbSamplesV(); |
163 | // |
6fb3418e |
164 | Standard_Real aURes = Hsurface->UResolution(1.0); |
165 | Standard_Real aVRes = Hsurface->VResolution(1.0); |
166 | |
167 | // Checking correlation between number of samples and length of the face along each axis |
168 | const Standard_Real aTresh = 100.0; |
f24f5428 |
169 | Standard_Integer aMinSamples = 20; |
6fb3418e |
170 | const Standard_Integer aMaxSamples = 40; |
171 | const Standard_Integer aMaxSamples2 = aMaxSamples * aMaxSamples; |
172 | Standard_Real dU = (U1 - U0) / aURes; |
173 | Standard_Real dV = (V1 - V0) / aVRes; |
f24f5428 |
174 | if (nbsu < aMinSamples) nbsu = aMinSamples; |
175 | if (nbsv < aMinSamples) nbsv = aMinSamples; |
6fb3418e |
176 | if (nbsu > aMaxSamples) nbsu = aMaxSamples; |
177 | if (nbsv > aMaxSamples) nbsv = aMaxSamples; |
178 | |
e8dec5e1 |
179 | if (dU > Precision::Confusion() && dV > Precision::Confusion()) { |
73375359 |
180 | if (Max(dU, dV) > Min(dU, dV) * aTresh) |
6fb3418e |
181 | { |
73375359 |
182 | aMinSamples = 10; |
183 | nbsu = (Standard_Integer)(Sqrt(dU / dV) * aMaxSamples); |
184 | if (nbsu < aMinSamples) nbsu = aMinSamples; |
185 | nbsv = aMaxSamples2 / nbsu; |
186 | if (nbsv < aMinSamples) |
187 | { |
188 | nbsv = aMinSamples; |
189 | nbsu = aMaxSamples2 / aMinSamples; |
190 | } |
191 | } |
192 | } |
193 | else { |
e8dec5e1 |
194 | return; // surface has no extension along one of directions |
7d9b843c |
195 | } |
f24f5428 |
196 | |
197 | Standard_Integer NbUOnS = Hsurface->NbUIntervals(GeomAbs_C2); |
198 | Standard_Integer NbVOnS = Hsurface->NbVIntervals(GeomAbs_C2); |
199 | |
200 | if(NbUOnS > 1 || NbVOnS > 1) |
201 | { |
202 | Handle(TColStd_HArray1OfReal) UPars, VPars; |
203 | ComputeSamplePars(Hsurface, nbsu, nbsv, UPars, VPars); |
204 | PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *) |
205 | new IntCurveSurface_ThePolyhedronOfHInter(Hsurface, UPars->ChangeArray1(), |
206 | VPars->ChangeArray1()); |
207 | } |
208 | else |
209 | { |
210 | PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *) |
6fb3418e |
211 | new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1); |
f24f5428 |
212 | } |
7fd59977 |
213 | } |
e8dec5e1 |
214 | myReady = Standard_True; |
7fd59977 |
215 | } |
7d9b843c |
216 | //======================================================================= |
217 | //function : InternalCall |
218 | //purpose : |
219 | //======================================================================= |
7fd59977 |
220 | void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS, |
7d9b843c |
221 | const Standard_Real parinf, |
222 | const Standard_Real parsup) |
223 | { |
f85e7ddb |
224 | if(HICS.IsDone() && HICS.NbPoints() > 0) { |
225 | //Calculate tolerance for 2d classifier |
226 | Standard_Real mintol3d = BRep_Tool::Tolerance(face); |
227 | Standard_Real maxtol3d = mintol3d; |
228 | Standard_Real mintol2d = Tol, maxtol2d = Tol; |
229 | TopExp_Explorer anExp(face, TopAbs_EDGE); |
230 | for(; anExp.More(); anExp.Next()) |
231 | { |
232 | Standard_Real curtol = BRep_Tool::Tolerance(TopoDS::Edge(anExp.Current())); |
233 | mintol3d = Min(mintol3d, curtol); |
234 | maxtol3d = Max(maxtol3d, curtol); |
235 | } |
236 | Standard_Real minres = Max(Hsurface->UResolution(mintol3d), Hsurface->VResolution(mintol3d)); |
237 | Standard_Real maxres = Max(Hsurface->UResolution(maxtol3d), Hsurface->VResolution(maxtol3d)); |
238 | mintol2d = Max(minres, Tol); |
239 | maxtol2d = Max(maxres, Tol); |
240 | // |
241 | Handle(BRepTopAdaptor_TopolTool) anAdditionalTool; |
7fd59977 |
242 | for(Standard_Integer index=HICS.NbPoints(); index>=1; index--) { |
243 | const IntCurveSurface_IntersectionPoint& HICSPointindex = HICS.Point(index); |
244 | gp_Pnt2d Puv(HICSPointindex.U(),HICSPointindex.V()); |
f85e7ddb |
245 | |
246 | //TopAbs_State currentstate = myTopolTool->Classify(Puv,Tol); |
58e14d59 |
247 | TopAbs_State currentstate = myTopolTool->Classify(Puv, !myUseBoundTol ? 0 : mintol2d); |
248 | if(myUseBoundTol && currentstate == TopAbs_OUT && maxtol2d > mintol2d) { |
f85e7ddb |
249 | if(anAdditionalTool.IsNull()) |
250 | { |
251 | anAdditionalTool = new BRepTopAdaptor_TopolTool(Hsurface); |
252 | } |
253 | currentstate = anAdditionalTool->Classify(Puv,maxtol2d); |
254 | if(currentstate == TopAbs_ON) |
255 | { |
256 | currentstate = TopAbs_OUT; |
257 | //Find out nearest edge and it's tolerance |
258 | anExp.Init(face, TopAbs_EDGE); |
259 | for(; anExp.More(); anExp.Next()) |
260 | { |
261 | TopoDS_Edge anE = TopoDS::Edge(anExp.Current()); |
f85e7ddb |
262 | Standard_Real f, l; |
3dd193aa |
263 | Handle(Geom_Curve) aPC = BRep_Tool::Curve (anE, f, l); |
264 | GeomAPI_ProjectPointOnCurve aProj (HICSPointindex.Pnt(), aPC, f, l); |
265 | if (aProj.NbPoints() > 0) |
f85e7ddb |
266 | { |
3dd193aa |
267 | if (aProj.LowerDistance() <= maxtol3d) |
f85e7ddb |
268 | { |
269 | //Nearest edge is found, state is really ON |
270 | currentstate = TopAbs_ON; |
271 | break; |
272 | } |
273 | } |
274 | } |
275 | } |
276 | } |
7fd59977 |
277 | if(currentstate==TopAbs_IN || currentstate==TopAbs_ON) { |
f85e7ddb |
278 | Standard_Real HICSW = HICSPointindex.W(); |
279 | if(HICSW >= parinf && HICSW <= parsup ) { |
280 | Standard_Real U = HICSPointindex.U(); |
281 | Standard_Real V = HICSPointindex.V(); |
282 | Standard_Real W = HICSW; |
283 | IntCurveSurface_TransitionOnCurve transition = HICSPointindex.Transition(); |
284 | gp_Pnt pnt = HICSPointindex.Pnt(); |
285 | // state = currentstate; |
286 | // Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin |
287 | Standard_Integer anIntState = (currentstate == TopAbs_IN) ? 0 : 1; |
288 | // Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End |
289 | |
290 | if(transition != IntCurveSurface_Tangent && face.Orientation()==TopAbs_REVERSED) { |
291 | if(transition == IntCurveSurface_In) |
292 | transition = IntCurveSurface_Out; |
293 | else |
294 | transition = IntCurveSurface_In; |
295 | } |
296 | //----- Insertion du point |
297 | if(nbpnt==0) { |
298 | IntCurveSurface_IntersectionPoint PPP(pnt,U,V,W,transition); |
299 | SeqPnt.Append(PPP); |
300 | // Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin |
301 | mySeqState.Append(anIntState); |
302 | // Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End |
303 | } |
304 | else { |
305 | Standard_Integer i = 1; |
306 | Standard_Integer b = nbpnt+1; |
307 | while(i<=nbpnt) { |
308 | const IntCurveSurface_IntersectionPoint& Pnti=SeqPnt.Value(i); |
309 | Standard_Real wi = Pnti.W(); |
310 | if(wi >= W) { b=i; i=nbpnt; } |
311 | i++; |
312 | } |
313 | IntCurveSurface_IntersectionPoint PPP(pnt,U,V,W,transition); |
314 | // Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin |
315 | // if(b>nbpnt) { SeqPnt.Append(PPP); } |
316 | // else if(b>0) { SeqPnt.InsertBefore(b,PPP); } |
317 | if(b>nbpnt) { |
318 | SeqPnt.Append(PPP); |
319 | mySeqState.Append(anIntState); |
320 | } else if(b>0) { |
321 | SeqPnt.InsertBefore(b,PPP); |
322 | mySeqState.InsertBefore(b, anIntState); |
323 | } |
324 | // Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End |
325 | } |
7fd59977 |
326 | |
7fd59977 |
327 | |
f85e7ddb |
328 | nbpnt++; |
329 | } |
7fd59977 |
330 | } //-- classifier state is IN or ON |
331 | } //-- Loop on Intersection points. |
332 | } //-- HICS.IsDone() |
f84edf58 |
333 | else if (HICS.IsDone()) |
334 | { |
335 | myIsParallel = HICS.IsParallel(); |
336 | } |
7fd59977 |
337 | } |
7d9b843c |
338 | //======================================================================= |
339 | //function : Perform |
340 | //purpose : |
341 | //======================================================================= |
342 | void IntCurvesFace_Intersector::Perform(const gp_Lin& L, |
343 | const Standard_Real ParMin, |
344 | const Standard_Real ParMax) |
345 | { |
e8dec5e1 |
346 | done = Standard_False; |
347 | if (!myReady) |
348 | { |
349 | return; |
350 | } |
7fd59977 |
351 | done = Standard_True; |
352 | SeqPnt.Clear(); |
7fd59977 |
353 | mySeqState.Clear(); |
7fd59977 |
354 | nbpnt = 0; |
7fd59977 |
355 | |
7d9b843c |
356 | IntCurveSurface_HInter HICS; |
7fd59977 |
357 | Handle(Geom_Line) geomline = new Geom_Line(L); |
358 | GeomAdaptor_Curve LL(geomline); |
7fd59977 |
359 | Handle(GeomAdaptor_HCurve) HLL = new GeomAdaptor_HCurve(LL); |
7fd59977 |
360 | Standard_Real parinf=ParMin; |
361 | Standard_Real parsup=ParMax; |
7d9b843c |
362 | // |
7fd59977 |
363 | if(PtrOnPolyhedron == NULL) { |
364 | HICS.Perform(HLL,Hsurface); |
365 | } |
366 | else { |
7d9b843c |
367 | Intf_Tool bndTool; |
368 | Bnd_Box boxLine; |
369 | bndTool.LinBox |
370 | (L, |
371 | ((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding(), |
372 | boxLine); |
7fd59977 |
373 | if(bndTool.NbSegments() == 0) |
374 | return; |
375 | for(Standard_Integer nbseg=1; nbseg<= bndTool.NbSegments(); nbseg++) { |
376 | Standard_Real pinf = bndTool.BeginParam(nbseg); |
377 | Standard_Real psup = bndTool.EndParam(nbseg); |
378 | Standard_Real pppp = 0.05*(psup-pinf); |
379 | pinf-=pppp; |
380 | psup+=pppp; |
381 | if((psup - pinf)<1e-10) { pinf-=1e-10; psup+=1e-10; } |
382 | if(nbseg==1) { parinf=pinf; parsup=psup; } |
383 | else { |
384 | if(parinf>pinf) parinf = pinf; |
385 | if(parsup<psup) parsup = psup; |
386 | } |
387 | } |
388 | if(parinf>ParMax) { return; } |
389 | if(parsup<ParMin) { return; } |
390 | if(parinf<ParMin) parinf=ParMin; |
391 | if(parsup>ParMax) parsup=ParMax; |
392 | if(parinf>(parsup-1e-9)) return; |
393 | IntCurveSurface_ThePolygonOfHInter polygon(HLL, |
394 | parinf, |
395 | parsup, |
396 | 2); |
397 | #if OPTIMISATION |
398 | if(PtrOnBndBounding==NULL) { |
399 | PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox(); |
7d9b843c |
400 | IntCurveSurface_ThePolyhedronOfHInter *thePolyh= |
401 | (IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron; |
402 | ((Bnd_BoundSortBox *)(PtrOnBndBounding))-> |
403 | Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh), |
404 | IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh)); |
7fd59977 |
405 | } |
406 | HICS.Perform(HLL, |
407 | polygon, |
408 | Hsurface, |
409 | *((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron), |
410 | *((Bnd_BoundSortBox *)PtrOnBndBounding)); |
411 | #else |
412 | HICS.Perform(HLL, |
413 | polygon, |
414 | Hsurface, |
415 | *((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)); |
416 | #endif |
417 | } |
418 | |
419 | InternalCall(HICS,parinf,parsup); |
7fd59977 |
420 | } |
7d9b843c |
421 | //======================================================================= |
422 | //function : Perform |
423 | //purpose : |
424 | //======================================================================= |
425 | void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_HCurve)& HCu, |
426 | const Standard_Real ParMin, |
427 | const Standard_Real ParMax) |
428 | { |
e8dec5e1 |
429 | done = Standard_False; |
430 | if (!myReady) |
431 | { |
432 | return; |
433 | } |
7fd59977 |
434 | done = Standard_True; |
435 | SeqPnt.Clear(); |
436 | // Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin |
437 | mySeqState.Clear(); |
438 | // Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End |
439 | nbpnt = 0; |
440 | IntCurveSurface_HInter HICS; |
441 | |
442 | //-- |
443 | Standard_Real parinf=ParMin; |
444 | Standard_Real parsup=ParMax; |
445 | |
446 | if(PtrOnPolyhedron == NULL) { |
447 | HICS.Perform(HCu,Hsurface); |
448 | } |
449 | else { |
450 | parinf = IntCurveSurface_TheHCurveTool::FirstParameter(HCu); |
451 | parsup = IntCurveSurface_TheHCurveTool::LastParameter(HCu); |
452 | if(parinf<ParMin) parinf = ParMin; |
453 | if(parsup>ParMax) parsup = ParMax; |
454 | if(parinf>(parsup-1e-9)) return; |
455 | Standard_Integer nbs; |
456 | nbs = IntCurveSurface_TheHCurveTool::NbSamples(HCu,parinf,parsup); |
457 | |
458 | IntCurveSurface_ThePolygonOfHInter polygon(HCu, |
459 | parinf, |
460 | parsup, |
461 | nbs); |
462 | #if OPTIMISATION |
463 | if(PtrOnBndBounding==NULL) { |
464 | PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox(); |
465 | IntCurveSurface_ThePolyhedronOfHInter *thePolyh=(IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron; |
466 | ((Bnd_BoundSortBox *)(PtrOnBndBounding))->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh), |
467 | IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh)); |
468 | } |
469 | HICS.Perform(HCu, |
470 | polygon, |
471 | Hsurface, |
472 | *((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron), |
473 | *((Bnd_BoundSortBox *)PtrOnBndBounding)); |
474 | #else |
475 | HICS.Perform(HCu, |
476 | polygon, |
477 | Hsurface, |
478 | *((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)); |
479 | #endif |
480 | } |
481 | InternalCall(HICS,parinf,parsup); |
482 | } |
483 | |
484 | //============================================================================ |
485 | Bnd_Box IntCurvesFace_Intersector::Bounding() const { |
486 | if(PtrOnPolyhedron !=NULL) { |
487 | return(((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding()); |
488 | } |
489 | else { |
490 | Bnd_Box B; |
491 | return(B); |
492 | } |
493 | } |
494 | TopAbs_State IntCurvesFace_Intersector::ClassifyUVPoint(const gp_Pnt2d& Puv) const { |
495 | TopAbs_State state = myTopolTool->Classify(Puv,1e-7); |
496 | return(state); |
497 | } |
498 | //============================================================================ |
499 | void IntCurvesFace_Intersector::Destroy() { |
500 | if(PtrOnPolyhedron !=NULL) { |
501 | delete (IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron; |
502 | PtrOnPolyhedron = NULL; |
503 | } |
504 | if(PtrOnBndBounding !=NULL) { |
505 | delete (Bnd_BoundSortBox *)PtrOnBndBounding; |
506 | PtrOnBndBounding=NULL; |
507 | } |
508 | } |
509 | |
58e14d59 |
510 | void IntCurvesFace_Intersector::SetUseBoundToler(Standard_Boolean UseBToler) |
511 | { |
512 | myUseBoundTol = UseBToler; |
513 | } |
7fd59977 |
514 | |
58e14d59 |
515 | Standard_Boolean IntCurvesFace_Intersector::GetUseBoundToler() const |
516 | { |
517 | return myUseBoundTol; |
518 | } |
7fd59977 |
519 | |