b311480e |
1 | // Created on: 1993-12-15 |
2 | // Created by: Isabelle GRIGNON |
3 | // Copyright (c) 1993-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 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <Adaptor2d_HCurve2d.hxx> |
19 | #include <Adaptor3d_HSurface.hxx> |
20 | #include <Adaptor3d_TopolTool.hxx> |
21 | #include <AppBlend_Approx.hxx> |
22 | #include <Blend_CurvPointFuncInv.hxx> |
23 | #include <Blend_FuncInv.hxx> |
24 | #include <Blend_Function.hxx> |
25 | #include <Blend_RstRstFunction.hxx> |
26 | #include <Blend_SurfCurvFuncInv.hxx> |
27 | #include <Blend_SurfPointFuncInv.hxx> |
28 | #include <Blend_SurfRstFunction.hxx> |
29 | #include <BRep_Tool.hxx> |
7fd59977 |
30 | #include <BRepAdaptor_Curve.hxx> |
31 | #include <BRepAdaptor_HCurve.hxx> |
42cf5bc1 |
32 | #include <BRepAdaptor_HCurve2d.hxx> |
7fd59977 |
33 | #include <BRepAdaptor_HSurface.hxx> |
42cf5bc1 |
34 | #include <BRepAdaptor_Surface.hxx> |
35 | #include <BRepBlend_Line.hxx> |
36 | #include <BRepLib_MakeFace.hxx> |
7fd59977 |
37 | #include <BRepLProp_SLProps.hxx> |
7fd59977 |
38 | #include <BRepTools.hxx> |
39 | #include <BRepTools_WireExplorer.hxx> |
42cf5bc1 |
40 | #include <BRepTopAdaptor_TopolTool.hxx> |
41 | #include <ChFi3d.hxx> |
42 | #include <ChFi3d_Builder.hxx> |
43 | #include <ChFi3d_Builder_0.hxx> |
44 | #include <ChFiDS_ChamfSpine.hxx> |
7fd59977 |
45 | #include <ChFiDS_CommonPoint.hxx> |
42cf5bc1 |
46 | #include <ChFiDS_ElSpine.hxx> |
47 | #include <ChFiDS_ErrorStatus.hxx> |
7fd59977 |
48 | #include <ChFiDS_FaceInterference.hxx> |
7fd59977 |
49 | #include <ChFiDS_FilSpine.hxx> |
7fd59977 |
50 | #include <ChFiDS_HData.hxx> |
42cf5bc1 |
51 | #include <ChFiDS_HElSpine.hxx> |
7fd59977 |
52 | #include <ChFiDS_ListIteratorOfListOfHElSpine.hxx> |
42cf5bc1 |
53 | #include <ChFiDS_ListOfHElSpine.hxx> |
54 | #include <ChFiDS_SequenceOfSurfData.hxx> |
55 | #include <ChFiDS_Spine.hxx> |
56 | #include <ChFiDS_State.hxx> |
57 | #include <ChFiDS_Stripe.hxx> |
58 | #include <ChFiDS_SurfData.hxx> |
7fd59977 |
59 | #include <ChFiKPart_ComputeData.hxx> |
42cf5bc1 |
60 | #include <ElCLib.hxx> |
61 | #include <Extrema_ExtPC.hxx> |
62 | #include <Extrema_ExtPS.hxx> |
63 | #include <Extrema_LocateExtPC.hxx> |
64 | #include <Extrema_POnCurv.hxx> |
65 | #include <Geom2d_Curve.hxx> |
66 | #include <Geom_BSplineCurve.hxx> |
67 | #include <Geom_BSplineSurface.hxx> |
68 | #include <Geom_Line.hxx> |
69 | #include <Geom_Plane.hxx> |
70 | #include <Geom_Surface.hxx> |
71 | #include <GeomAdaptor_HCurve.hxx> |
72 | #include <GeomAdaptor_HSurface.hxx> |
73 | #include <GeomAdaptor_Surface.hxx> |
74 | #include <GeomAPI_ProjectPointOnCurve.hxx> |
75 | #include <gp_Pln.hxx> |
76 | #include <gp_Pnt.hxx> |
77 | #include <gp_Pnt2d.hxx> |
78 | #include <gp_Vec.hxx> |
79 | #include <gp_XYZ.hxx> |
80 | #include <math_Vector.hxx> |
81 | #include <Precision.hxx> |
82 | #include <Standard_ConstructionError.hxx> |
83 | #include <Standard_NoSuchObject.hxx> |
84 | #include <Standard_NotImplemented.hxx> |
85 | #include <Standard_OutOfRange.hxx> |
86 | #include <TColgp_Array1OfPnt.hxx> |
87 | #include <TColgp_Array1OfVec.hxx> |
88 | #include <TColStd_Array1OfInteger.hxx> |
89 | #include <TColStd_Array1OfReal.hxx> |
90 | #include <TColStd_ListOfInteger.hxx> |
91 | #include <TopAbs.hxx> |
92 | #include <TopAbs_Orientation.hxx> |
93 | #include <TopAbs_ShapeEnum.hxx> |
94 | #include <TopExp.hxx> |
95 | #include <TopExp_Explorer.hxx> |
96 | #include <TopoDS.hxx> |
97 | #include <TopoDS_Edge.hxx> |
98 | #include <TopoDS_Face.hxx> |
99 | #include <TopoDS_Shape.hxx> |
100 | #include <TopoDS_Vertex.hxx> |
101 | #include <TopoDS_Wire.hxx> |
102 | #include <TopOpeBRepBuild_HBuilder.hxx> |
103 | #include <TopOpeBRepDS_HDataStructure.hxx> |
104 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
7fd59977 |
105 | |
0797d9d3 |
106 | #ifdef OCCT_DEBUG |
7fd59977 |
107 | #ifdef DRAW |
108 | #include <DrawTrSurf.hxx> |
109 | #endif |
110 | #include <OSD_Chronometer.hxx> |
1d0a9d4d |
111 | extern Standard_Real t_perfsetofkpart,t_perfsetofkgen,t_makextremities,t_performsurf,t_startsol; |
112 | extern Standard_Boolean ChFi3d_GettraceCHRON(); |
113 | extern void ChFi3d_InitChron(OSD_Chronometer& ch); |
114 | extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time); |
7fd59977 |
115 | #endif |
116 | |
7fd59977 |
117 | |
118 | //=================================================================== |
81bba717 |
119 | // Definition by a plane |
7fd59977 |
120 | // |
81bba717 |
121 | // It is considered that P1 and P2 are points associated to commonpoints compoint1 and |
122 | // compoint2, while E1 and E2 are edges containing P1 and P2. |
123 | // The plane containing three directions D12 T1 T2 ou D12 represente la direction formee |
7fd59977 |
124 | // par les points P1 et P2, T1 la tangente de E1 en P1 et T2 la tangente de |
81bba717 |
125 | // E2 en P2 is found (if exists). |
126 | // Then fillet HConge is intersected by this plane |
127 | // to find associated curve 3d C3d and the curve 2d. |
7fd59977 |
128 | // |
129 | //==================================================================== |
130 | static void ChFi3d_CoupeParPlan (const ChFiDS_CommonPoint & compoint1, |
131 | const ChFiDS_CommonPoint & compoint2, |
132 | Handle(GeomAdaptor_HSurface)& HConge, |
133 | const gp_Pnt2d & UV1, |
134 | const gp_Pnt2d & UV2, |
135 | const Standard_Real tol3d, |
136 | const Standard_Real tol2d, |
137 | Handle(Geom_Curve) &C3d, |
138 | Handle(Geom2d_Curve) &pcurve, |
139 | Standard_Real & tolreached, |
140 | Standard_Real & Pardeb, |
141 | Standard_Real & Parfin, |
142 | Standard_Boolean & plane) |
143 | { plane=Standard_True; |
144 | if(compoint1.IsOnArc() && compoint2.IsOnArc() ) { |
145 | gp_Pnt P1,P2; |
146 | BRepAdaptor_Curve BCurv1(compoint1.Arc()); |
147 | BRepAdaptor_Curve BCurv2(compoint2.Arc()); |
148 | Standard_Real parE1,parE2; |
149 | parE1=compoint1.ParameterOnArc(); |
150 | parE2=compoint2.ParameterOnArc(); |
151 | gp_Vec t1,t2; |
152 | BCurv1.D1(parE1,P1,t1); |
153 | BCurv2.D1(parE2,P2,t2); |
154 | gp_Dir tgt1(t1); |
155 | gp_Dir tgt2(t2); |
156 | gp_Vec v12(P2.X()-P1.X(),P2.Y()-P1.Y(),P2.Z()-P1.Z()); |
157 | gp_Dir d12(v12); |
158 | gp_Dir nor =tgt1.Crossed(d12); |
159 | Handle (Geom_Plane) Plan=new Geom_Plane(P1,nor); |
160 | Standard_Real scal; |
161 | scal=Abs(nor.Dot(tgt2)); |
162 | if (scal<0.01) { |
163 | Handle(GeomAdaptor_HSurface) HPlan=new GeomAdaptor_HSurface(Plan); |
164 | Handle(Geom2d_Curve) C2dint2; |
165 | TColStd_Array1OfReal Pdeb(1,4),Pfin(1,4); |
166 | GeomAdaptor_Surface AS(Plan); |
167 | Extrema_ExtPS ext(P1,AS,1.e-3,1.e-3); |
168 | Extrema_ExtPS ext1 (P2,AS,1.e-3,1.e-3); |
169 | Standard_Real u1,v1; |
170 | ext.Point(1).Parameter(u1,v1); |
171 | Pdeb(1)= UV1.X();Pdeb(2) = UV1.Y(); |
172 | Pdeb(3)= u1;Pdeb(4) =v1; |
173 | ext1.Point(1).Parameter(u1,v1); |
174 | Pfin(1)= UV2.X();Pfin(2) = UV2.Y(); |
175 | Pfin(3)= u1;Pfin(4) = v1; |
176 | if (ChFi3d_ComputeCurves(HConge,HPlan,Pdeb,Pfin,C3d, |
177 | pcurve,C2dint2,tol3d,tol2d,tolreached)){ |
178 | Pardeb=C3d->FirstParameter(); |
179 | Parfin=C3d->LastParameter(); |
180 | } |
181 | else plane=Standard_False; |
182 | } |
183 | else plane=Standard_False; |
184 | } |
185 | else plane=Standard_False; |
186 | } |
187 | //======================================================================= |
188 | //function : SortieTangente |
189 | //purpose : |
190 | //======================================================================= |
191 | |
192 | static Standard_Boolean SortieTangente(const ChFiDS_CommonPoint& CP, |
193 | const TopoDS_Face& /*F*/, |
194 | const Handle(ChFiDS_SurfData)& /*SD*/, |
195 | const Standard_Integer /*OnS*/, |
196 | const Standard_Real TolAngular) |
197 | { |
198 | if(!CP.HasVector()) return Standard_False; |
199 | gp_Pnt P; |
200 | gp_Vec Darc, Dsurf; |
201 | Handle(Geom_Curve) C; |
202 | Standard_Real Uf, Ul; |
203 | C = BRep_Tool::Curve(CP.Arc(),Uf,Ul); |
204 | C->D1(CP.ParameterOnArc(), P, Darc); |
205 | Dsurf = CP.Vector(); |
206 | return Dsurf.IsParallel(Darc, TolAngular); |
207 | } |
208 | |
209 | //======================================================================= |
210 | //function : BonVoisin |
211 | //purpose : |
212 | //======================================================================= |
213 | |
214 | static Standard_Boolean BonVoisin(const gp_Pnt& Point, |
215 | Handle(BRepAdaptor_HSurface)& HS, |
216 | TopoDS_Face& F, |
217 | Handle(GeomAdaptor_HSurface)& plane, |
218 | const TopoDS_Edge& cured, |
219 | Standard_Real& XDep, |
220 | Standard_Real& YDep, |
221 | const ChFiDS_Map& EFMap, |
222 | const Standard_Real tolesp) |
223 | { |
224 | Standard_Boolean bonvoisin = 1; |
225 | Standard_Real winter, Uf, Ul; |
226 | gp_Pnt papp = HS->Value(XDep, YDep); |
227 | Standard_Real dist = RealLast(); |
228 | Handle(BRepAdaptor_HCurve) hc = new BRepAdaptor_HCurve(); |
229 | Handle(Geom2d_Curve) PC; |
230 | Standard_Boolean found = 0; |
231 | |
232 | TopExp_Explorer Ex; |
233 | for(Ex.Init(F,TopAbs_EDGE); Ex.More(); Ex.Next()){ |
234 | const TopoDS_Edge& ecur = TopoDS::Edge(Ex.Current()); |
235 | if(!ecur.IsSame(cured)){ |
236 | hc->ChangeCurve().Initialize(ecur); |
237 | Standard_Real tolc = hc->ChangeCurve().Resolution(tolesp); |
238 | if(ChFi3d_InterPlaneEdge(plane,hc,winter,1,tolc)){ |
239 | gp_Pnt np = hc->Value(winter); |
240 | Standard_Real ndist = np.SquareDistance(papp); |
241 | if(ndist<dist){ |
242 | TopTools_ListIteratorOfListOfShape It; |
243 | TopoDS_Face ff; |
244 | Standard_Boolean isclosed = BRep_Tool::IsClosed(ecur, F); |
245 | Standard_Boolean isreallyclosed = |
246 | BRepTools::IsReallyClosed(ecur, F); |
247 | for(It.Initialize(EFMap(ecur));It.More();It.Next()){ |
248 | ff = TopoDS::Face(It.Value()); |
249 | Standard_Boolean issame = ff.IsSame(F); |
250 | // Modified by Sergey KHROMOV - Fri Dec 21 17:12:48 2001 Begin |
251 | // Standard_Boolean istg = |
252 | // BRep_Tool::Continuity(ecur,ff,F) != GeomAbs_C0; |
3f54cc41 |
253 | Standard_Boolean istg = ChFi3d::IsTangentFaces(ecur,ff,F); |
7fd59977 |
254 | // Modified by Sergey KHROMOV - Fri Dec 21 17:12:51 2001 End |
255 | if((!issame || (issame && isreallyclosed)) && istg) { |
256 | found = 1; |
257 | TopoDS_Edge newe = ecur; |
258 | newe.Orientation(TopAbs_FORWARD); |
259 | dist = ndist; |
260 | HS->ChangeSurface().Initialize(ff); |
261 | if(isclosed && !isreallyclosed){ |
262 | TopoDS_Face fff = ff; |
263 | fff.Orientation(TopAbs_FORWARD); |
264 | TopExp_Explorer Ex2; |
265 | for(Ex2.Init(fff,TopAbs_EDGE); |
266 | Ex2.More(); Ex2.Next()){ |
267 | if(newe.IsSame(Ex2.Current())){ |
268 | newe = TopoDS::Edge(Ex2.Current()); |
269 | PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul); |
270 | break; |
271 | } |
272 | } |
273 | } |
274 | else PC = BRep_Tool::CurveOnSurface(newe,ff,Uf,Ul); |
275 | PC->Value(winter).Coord(XDep,YDep); |
276 | if(issame){ |
277 | gp_Pnt spt; gp_Vec sdu,sdv,nors; |
278 | HS->D1(XDep, YDep, spt, sdu, sdv); |
279 | nors = sdu.Crossed(sdv); |
280 | gp_Pnt cpt; gp_Vec cd; |
281 | hc->D1(winter,cpt,cd); |
282 | gp_Vec vref(Point, cpt); |
283 | TopoDS_Face fff = ff; |
284 | fff.Orientation(TopAbs_FORWARD); |
285 | if(vref.Dot(nors.Crossed(cd)) < 0.){ |
286 | newe.Orientation(TopAbs_REVERSED); |
287 | } |
288 | PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul); |
289 | PC->Value(winter).Coord(XDep, YDep); |
290 | } |
291 | break; |
292 | } |
293 | } |
294 | } |
295 | } |
296 | } |
297 | } |
298 | if(!found) bonvoisin = 0; |
299 | return bonvoisin; |
300 | } |
301 | |
302 | //======================================================================= |
303 | //function : Projection |
81bba717 |
304 | //purpose : Projects a point on a curve |
7fd59977 |
305 | //======================================================================= |
306 | |
307 | static Standard_Boolean Projection(Extrema_ExtPC& PExt, |
308 | const gp_Pnt& P, |
309 | const Adaptor3d_Curve& C, |
310 | Standard_Real& W, |
311 | Standard_Real Tol) |
312 | { |
313 | Standard_Real Dist2, daux2; |
314 | Dist2 = C.Value(W).SquareDistance(P); |
315 | |
81bba717 |
316 | // It is checked if it is not already a solution |
7fd59977 |
317 | if (Dist2 < Tol * Tol) |
318 | return Standard_True; |
319 | |
320 | Standard_Boolean Ok = Standard_False; |
321 | |
322 | // On essai une resolution initialise |
323 | Extrema_LocateExtPC ext(P,C,W,Tol/10); |
324 | if(ext.IsDone()) { |
325 | daux2 = C.Value(ext.Point().Parameter()).SquareDistance(P); |
326 | if (daux2 <Dist2 ) { |
327 | W = ext.Point().Parameter(); |
328 | Dist2 = daux2; |
329 | Ok = Standard_True; |
330 | if (Dist2 < Tol * Tol) |
331 | return Standard_True; |
332 | } |
333 | } |
334 | |
81bba717 |
335 | // Global resolution |
7fd59977 |
336 | PExt.Perform(P); |
337 | if ( PExt.IsDone() ) { |
338 | for (Standard_Integer ii=1; ii<= PExt.NbExt(); ii++) { |
339 | if (PExt.SquareDistance(ii) < Dist2) { |
340 | Dist2 = PExt.SquareDistance(ii); |
341 | W = PExt.Point(ii).Parameter(); |
342 | Ok = Standard_True; |
343 | } |
344 | } |
345 | } |
346 | return Ok; |
347 | } |
348 | |
349 | //======================================================================= |
350 | //function : TgtKP |
351 | //purpose : |
352 | //======================================================================= |
353 | |
354 | static void TgtKP(const Handle(ChFiDS_SurfData)& CD, |
355 | const Handle(ChFiDS_Spine)& Spine, |
356 | const Standard_Integer iedge, |
357 | const Standard_Boolean isfirst, |
358 | gp_Pnt& ped, |
359 | gp_Vec& ded) |
360 | { |
361 | Standard_Real wtg = CD->InterferenceOnS1().Parameter(isfirst); |
362 | const BRepAdaptor_Curve& bc = Spine->CurrentElementarySpine(iedge); |
363 | if(Spine->Edges(iedge).Orientation() == TopAbs_FORWARD) |
364 | bc.D1(wtg+bc.FirstParameter(),ped,ded); |
365 | else{ |
366 | bc.D1(-wtg+bc.LastParameter(),ped,ded); |
367 | ded.Reverse(); |
368 | } |
369 | ded.Normalize(); |
370 | } |
371 | |
372 | //======================================================================= |
373 | //function : IsInput |
81bba717 |
374 | //purpose : Checks if a vector belongs to a Face |
7fd59977 |
375 | //======================================================================= |
376 | |
377 | Standard_Boolean IsInput(const gp_Vec& Vec, |
378 | const TopoDS_Vertex& Ve, |
379 | const TopoDS_Face& Fa) |
380 | { |
381 | TopExp_Explorer FaceExp(Fa, TopAbs_WIRE); |
382 | BRepTools_WireExplorer WireExp; |
383 | Standard_Integer Trouve = 0; |
384 | TopoDS_Wire W; |
385 | TopoDS_Edge E; |
386 | TopoDS_Vertex Vf, Vl; |
387 | gp_Vec Vec3d[2]; |
388 | gp_Pnt Point; |
389 | |
81bba717 |
390 | // Find edges and compute 3D vectors |
7fd59977 |
391 | for ( ; (FaceExp.More() && (Trouve<2)); FaceExp.Next()) { |
392 | W = TopoDS::Wire(FaceExp.Current()); |
393 | for (Trouve=0, WireExp.Init(W) ; |
394 | WireExp.More() && (Trouve<2); WireExp.Next()) { |
395 | E = TopoDS::Edge(WireExp.Current()); |
396 | TopExp::Vertices(E, Vf, Vl); |
397 | if (Vf.IsSame(Ve)) { |
398 | BRepAdaptor_Curve Cb(E); |
399 | Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]); |
400 | Trouve++; |
401 | } |
402 | else if (Vl.IsSame(Ve)) { |
403 | BRepAdaptor_Curve Cb(E); |
404 | Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]); |
405 | Vec3d[Trouve].Reverse(); |
406 | Trouve++; |
407 | } |
408 | } |
409 | } |
410 | if (Trouve < 2) return Standard_False; |
81bba717 |
411 | // Calculate the normal and the angles in the asssociated vector plane |
7fd59977 |
412 | gp_Vec Normal; |
413 | Normal = Vec3d[0] ^ Vec3d[1]; |
81bba717 |
414 | if (Normal.SquareMagnitude() < Precision::Confusion()) {//Colinear case |
7fd59977 |
415 | return (Vec.IsParallel(Vec3d[0],Precision::Confusion())); |
416 | } |
417 | |
418 | Standard_Real amin, amax; |
419 | amax = Vec3d[1].AngleWithRef(Vec3d[0], Normal); |
420 | if (amax <0) { |
421 | amin = amax; |
422 | amax = 0; |
423 | } |
424 | else amin = 0; |
425 | |
81bba717 |
426 | // Projection of the vector |
7fd59977 |
427 | gp_Ax3 Axe(Point, Normal, Vec3d[0]); |
428 | gp_Trsf Transf; |
429 | Transf.SetTransformation (Axe); |
430 | gp_XYZ coord = Vec.XYZ(); |
431 | Transf.Transforms(coord); |
432 | coord.SetZ(0); |
433 | Transf.Invert(); |
434 | Transf.Transforms(coord); |
435 | gp_Vec theProj(coord); |
436 | |
81bba717 |
437 | // and finally... |
7fd59977 |
438 | Standard_Real Angle = theProj.AngleWithRef(Vec3d[0], Normal); |
439 | return ( (Angle >= amin) && (Angle<=amax)); |
440 | } |
441 | |
442 | //======================================================================= |
443 | //function : IsG1 |
81bba717 |
444 | //purpose : Find a neighbor G1 by an edge |
7fd59977 |
445 | //======================================================================= |
446 | |
447 | Standard_Boolean IsG1(const ChFiDS_Map& TheMap, |
448 | const TopoDS_Edge& E, |
449 | const TopoDS_Face& FRef, |
450 | TopoDS_Face& FVoi) |
451 | { |
452 | TopTools_ListIteratorOfListOfShape It; |
81bba717 |
453 | // Find a neighbor of E different from FRef (general case). |
7fd59977 |
454 | for(It.Initialize(TheMap(E));It.More();It.Next()) { |
455 | if (!TopoDS::Face(It.Value()).IsSame(FRef)) { |
456 | FVoi = TopoDS::Face(It.Value()); |
457 | // Modified by Sergey KHROMOV - Fri Dec 21 17:09:32 2001 Begin |
458 | // if (BRep_Tool::Continuity(E,FRef,FVoi) != GeomAbs_C0) { |
3f54cc41 |
459 | if (ChFi3d::IsTangentFaces(E,FRef,FVoi)) { |
7fd59977 |
460 | // Modified by Sergey KHROMOV - Fri Dec 21 17:09:33 2001 End |
461 | return Standard_True; |
462 | } |
463 | } |
464 | } |
81bba717 |
465 | // If is was not found it is checked if E is a cutting edge, |
466 | // in which case FVoi = FRef is returned (less frequent case). |
7fd59977 |
467 | TopExp_Explorer Ex; |
468 | Standard_Boolean orset = Standard_False; |
7fd59977 |
469 | TopAbs_Orientation orient = TopAbs_FORWARD ; |
7fd59977 |
470 | TopoDS_Edge ed; |
471 | for(Ex.Init(FRef,TopAbs_EDGE); Ex.More(); Ex.Next()){ |
472 | ed = TopoDS::Edge(Ex.Current()); |
473 | if(ed.IsSame(E)){ |
474 | if(!orset){ orient = ed.Orientation(); orset = Standard_True; } |
475 | else if(ed.Orientation() == TopAbs::Reverse(orient)){ |
476 | FVoi = FRef; |
477 | // Modified by Sergey KHROMOV - Fri Dec 21 17:15:12 2001 Begin |
478 | // if (BRep_Tool::Continuity(E,FRef,FRef) >= GeomAbs_G1) { |
3f54cc41 |
479 | if (ChFi3d::IsTangentFaces(E,FRef,FRef)) { |
7fd59977 |
480 | // Modified by Sergey KHROMOV - Fri Dec 21 17:15:16 2001 End |
481 | return Standard_True; |
482 | } |
483 | return Standard_False; |
484 | } |
485 | } |
486 | } |
487 | return Standard_False; |
488 | } |
489 | |
490 | //======================================================================= |
491 | //function : SearchFaceOnV |
81bba717 |
492 | //purpose : Finds the output face(s) of the path by a vertex |
493 | // The following criteria should be followed |
494 | // -1 : The face shares regular edges with FRef |
495 | // (too hard condition that should be reconsidered) |
496 | // -2 : The vector starting in CommonPoint "belongs" to the face |
7fd59977 |
497 | //======================================================================== |
498 | static Standard_Integer SearchFaceOnV(const ChFiDS_CommonPoint& Pc, |
499 | const TopoDS_Face& FRef, |
500 | const ChFiDS_Map& VEMap, |
501 | const ChFiDS_Map& EFMap, |
502 | TopoDS_Face& F1, |
503 | TopoDS_Face& F2) |
504 | { |
81bba717 |
505 | // it is checked that it leaves the current face. |
7fd59977 |
506 | Standard_Boolean FindFace = IsInput(Pc.Vector(), Pc.Vertex(), FRef); |
507 | if (FindFace) { |
508 | FindFace = IsInput(Pc.Vector().Reversed(), Pc.Vertex(), FRef); |
509 | } |
81bba717 |
510 | // If it does not leave, it is finished |
7fd59977 |
511 | if (FindFace) { |
512 | F1 = FRef; |
513 | return 1; |
514 | } |
515 | Standard_Integer Num = 0; |
516 | Standard_Boolean Trouve; |
517 | TopTools_ListIteratorOfListOfShape ItE, ItF; |
518 | TopoDS_Edge E; |
519 | TopoDS_Face FVoi; |
520 | |
521 | for(ItE.Initialize(VEMap(Pc.Vertex())); |
522 | ItE.More() && (Num < 2); ItE.Next()) { |
523 | E = TopoDS::Edge(ItE.Value()); |
524 | for(ItF.Initialize(EFMap(E)), Trouve=Standard_False; |
525 | ItF.More()&&(!Trouve); ItF.Next()) { |
526 | if (TopoDS::Face(ItF.Value()).IsSame(FRef)) { |
527 | Trouve = Standard_True; |
528 | } |
529 | } |
530 | if (Trouve) Trouve = IsG1(EFMap, E, FRef, FVoi); |
531 | if (Trouve) Trouve = IsInput(Pc.Vector(), Pc.Vertex(), FVoi); |
532 | if (Trouve) { |
533 | if (Num == 0) F1 = FVoi; |
534 | else F2 = FVoi; |
535 | Num++; |
536 | } |
537 | } |
538 | return Num; |
539 | } |
540 | |
541 | //======================================================================= |
542 | //function : ChangeTransition |
81bba717 |
543 | //purpose : Changes the transition of the second common Point, when the surface |
544 | // does not cross the arc |
545 | // As it is supposed that the support Faces are the same, it is enough |
546 | // to examine the cas of cutting edges. |
7fd59977 |
547 | //======================================================================== |
548 | static void ChangeTransition(const ChFiDS_CommonPoint& Precedant, |
549 | ChFiDS_CommonPoint& Courant, |
550 | Standard_Integer FaceIndex, |
551 | const Handle(TopOpeBRepDS_HDataStructure)& DS) |
552 | { |
553 | Standard_Boolean tochange = Standard_True; |
554 | Standard_Real f,l; |
555 | const TopoDS_Face& F = TopoDS::Face(DS->Shape(FaceIndex)); |
556 | const TopoDS_Edge& Arc = Precedant.Arc(); |
557 | Handle(Geom2d_Curve) PCurve1, PCurve2; |
558 | PCurve1 = BRep_Tool::CurveOnSurface(Arc, F, f, l); |
559 | TopoDS_Shape aLocalShape = Arc.Reversed(); |
560 | PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShape), F, f, l); |
561 | // PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Arc.Reversed()), F, f, l); |
562 | if (PCurve1 != PCurve2) { |
81bba717 |
563 | // This is a cutting edge, it is necessary to make a small Geometric test |
7fd59977 |
564 | gp_Vec tgarc; |
565 | gp_Pnt P; |
566 | BRepAdaptor_Curve AC(Arc); |
567 | AC.D1(Precedant.ParameterOnArc(), P, tgarc); |
568 | tochange = tgarc.IsParallel(Precedant.Vector(), Precision::Confusion()); |
569 | } |
570 | |
571 | if (tochange) |
572 | Courant.SetArc(Precision::Confusion(), |
573 | Arc, |
574 | Precedant.ParameterOnArc(), |
575 | TopAbs::Reverse(Precedant.TransitionOnArc())); |
576 | |
577 | } |
578 | |
579 | //======================================================================= |
580 | //function : CallPerformSurf |
81bba717 |
581 | //purpose : Encapsulates call to PerformSurf/SimulSurf |
7fd59977 |
582 | //======================================================================== |
583 | |
584 | void ChFi3d_Builder:: |
585 | CallPerformSurf(Handle(ChFiDS_Stripe)& Stripe, |
586 | const Standard_Boolean Simul, |
587 | ChFiDS_SequenceOfSurfData& SeqSD, |
588 | Handle(ChFiDS_SurfData)& SD, |
589 | const Handle(ChFiDS_HElSpine)& HGuide, |
590 | const Handle(ChFiDS_Spine)& Spine, |
591 | const Handle(BRepAdaptor_HSurface)& HS1, |
592 | const Handle(BRepAdaptor_HSurface)& HS3, |
593 | const gp_Pnt2d& pp1, |
594 | const gp_Pnt2d& pp3, |
543a9964 |
595 | const Handle(Adaptor3d_TopolTool)& It1, |
7fd59977 |
596 | const Handle(BRepAdaptor_HSurface)& HS2, |
597 | const Handle(BRepAdaptor_HSurface)& HS4, |
598 | const gp_Pnt2d& pp2, |
599 | const gp_Pnt2d& pp4, |
543a9964 |
600 | const Handle(Adaptor3d_TopolTool)& It2, |
7fd59977 |
601 | const Standard_Real MaxStep, |
602 | const Standard_Real Fleche, |
603 | const Standard_Real /*TolGuide*/, |
604 | Standard_Real& First, |
605 | Standard_Real& Last, |
606 | const Standard_Boolean Inside, |
607 | const Standard_Boolean /*Appro*/, |
608 | const Standard_Boolean forward, |
609 | const Standard_Boolean RecOnS1, |
610 | const Standard_Boolean RecOnS2, |
611 | math_Vector& Soldep, |
dde68833 |
612 | Standard_Integer& intf, |
613 | Standard_Integer& intl, |
7fd59977 |
614 | Handle(BRepAdaptor_HSurface)& Surf1, |
615 | Handle(BRepAdaptor_HSurface)& Surf2) |
616 | { |
0797d9d3 |
617 | #ifdef OCCT_DEBUG |
7fd59977 |
618 | OSD_Chronometer ch1; |
619 | #endif |
620 | Handle(BRepAdaptor_HSurface) HSon1, HSon2; |
621 | HSon1 = HS1; |
622 | HSon2 = HS2; |
81bba717 |
623 | // Definition of the domain of path It1, It2 |
543a9964 |
624 | It1->Initialize((const Handle(Adaptor3d_HSurface)&)HSon1); |
625 | It2->Initialize((const Handle(Adaptor3d_HSurface)&)HSon2); |
7fd59977 |
626 | |
627 | |
628 | TopAbs_Orientation Or1 = HS1->ChangeSurface().Face().Orientation(); |
629 | TopAbs_Orientation Or2 = HS2->ChangeSurface().Face().Orientation(); |
630 | Standard_Integer Choix = |
631 | ChFi3d::NextSide(Or1,Or2, |
632 | Stripe->OrientationOnFace1(), |
633 | Stripe->OrientationOnFace2(), |
634 | Stripe->Choix()); |
635 | Soldep(1) = pp1.X(); Soldep(2) = pp1.Y(); |
636 | Soldep(3) = pp2.X(); Soldep(4) = pp2.Y(); |
637 | |
638 | Standard_Real thef = First, thel = Last; |
639 | Standard_Boolean isdone; |
640 | |
641 | if(Simul){ |
642 | isdone = SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HS2,It2,tolesp,First,Last, |
643 | Inside,Inside,forward,RecOnS1,RecOnS2,Soldep,intf,intl); |
644 | } |
645 | else{ |
646 | |
0797d9d3 |
647 | #ifdef OCCT_DEBUG |
81bba717 |
648 | ChFi3d_InitChron(ch1);//initial perform for PerformSurf |
7fd59977 |
649 | #endif |
650 | |
651 | isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HS2,It2, |
652 | MaxStep,Fleche,tolesp, |
653 | First,Last,Inside,Inside,forward, |
654 | RecOnS1,RecOnS2,Soldep,intf,intl); |
0797d9d3 |
655 | #ifdef OCCT_DEBUG |
81bba717 |
656 | ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf |
7fd59977 |
657 | #endif |
658 | } |
659 | |
81bba717 |
660 | // Case of error |
7fd59977 |
661 | if (!isdone) { |
662 | First = thef; |
663 | Last = thel; |
664 | Standard_Boolean reprise = Standard_False; |
665 | if (! HS3.IsNull()) { |
666 | HSon1 = HS3; |
543a9964 |
667 | It1->Initialize((const Handle(Adaptor3d_HSurface)&)HS3); |
7fd59977 |
668 | Or1 = HS3->ChangeSurface().Face().Orientation(); |
669 | Soldep(1) = pp3.X(); Soldep(2) = pp3.Y(); |
670 | reprise = Standard_True; |
671 | } |
672 | else if (! HS4.IsNull()) { |
673 | HSon2 = HS4; |
543a9964 |
674 | It2->Initialize((const Handle(Adaptor3d_HSurface)&)HS4); |
7fd59977 |
675 | Or2 = HS4->ChangeSurface().Face().Orientation(); |
676 | Soldep(3) = pp4.X(); Soldep(4) = pp4.Y(); |
677 | reprise = Standard_True; |
678 | } |
679 | |
680 | if (reprise) { |
681 | Choix = ChFi3d::NextSide(Or1,Or2, |
682 | Stripe->OrientationOnFace1(), |
683 | Stripe->OrientationOnFace2(), |
684 | Stripe->Choix()); |
685 | if(Simul){ |
686 | isdone = SimulSurf(SD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2, |
687 | tolesp,First,Last, |
688 | Inside,Inside,forward,RecOnS1,RecOnS2, |
689 | Soldep,intf,intl); |
690 | } |
691 | else{ |
692 | |
0797d9d3 |
693 | #ifdef OCCT_DEBUG |
81bba717 |
694 | ChFi3d_InitChron(ch1);//init perf for PerformSurf |
7fd59977 |
695 | #endif |
696 | |
697 | isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2, |
698 | MaxStep,Fleche,tolesp, |
699 | First,Last,Inside,Inside,forward, |
700 | RecOnS1,RecOnS2,Soldep,intf,intl); |
0797d9d3 |
701 | #ifdef OCCT_DEBUG |
81bba717 |
702 | ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf |
7fd59977 |
703 | #endif |
704 | } |
705 | } |
706 | } |
707 | Surf1 = HSon1; |
708 | Surf2 = HSon2; |
709 | } |
710 | |
711 | //======================================================================= |
712 | //function : StripeOrientation |
81bba717 |
713 | //purpose : Calculates the reference orientation determining the |
714 | // concave face for construction of the fillet. |
7fd59977 |
715 | //======================================================================= |
716 | |
717 | Standard_Boolean ChFi3d_Builder::StripeOrientations |
718 | (const Handle(ChFiDS_Spine)& Spine, |
719 | TopAbs_Orientation& Or1, |
720 | TopAbs_Orientation& Or2, |
721 | Standard_Integer& ChoixConge) const |
722 | { |
723 | //TopTools_ListIteratorOfListOfShape It; |
724 | BRepAdaptor_Surface Sb1,Sb2; |
725 | TopAbs_Orientation Of1,Of2; |
726 | TopoDS_Face ff1,ff2; |
1d54b807 |
727 | TopoDS_Edge anEdge = Spine->Edges(1); |
728 | TopoDS_Face FirstFace = TopoDS::Face(myEdgeFirstFace(anEdge)); |
729 | ChFi3d_conexfaces(anEdge,ff1,ff2,myEFMap); |
730 | if (ff2.IsSame(FirstFace)) |
731 | { TopoDS_Face TmpFace = ff1; ff1 = ff2; ff2 = TmpFace; } |
7fd59977 |
732 | Of1 = ff1.Orientation(); |
733 | ff1.Orientation(TopAbs_FORWARD); |
734 | Sb1.Initialize(ff1); |
735 | Of2 = ff2.Orientation(); |
736 | ff2.Orientation(TopAbs_FORWARD); |
737 | Sb2.Initialize(ff2); |
738 | |
739 | ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(1), |
740 | Or1,Or2); |
741 | Or1 = TopAbs::Compose(Or1,Of1); |
742 | Or2 = TopAbs::Compose(Or2,Of2); |
743 | return Standard_True; |
744 | } |
745 | |
746 | |
747 | //======================================================================= |
748 | //function : ConexFaces |
749 | //purpose : |
750 | //======================================================================= |
751 | |
752 | void ChFi3d_Builder::ConexFaces (const Handle(ChFiDS_Spine)& Spine, |
753 | const Standard_Integer IEdge, |
7fd59977 |
754 | Handle(BRepAdaptor_HSurface)& HS1, |
755 | Handle(BRepAdaptor_HSurface)& HS2) const |
756 | { |
757 | if(HS1.IsNull()) HS1 = new BRepAdaptor_HSurface (); |
758 | if(HS2.IsNull()) HS2 = new BRepAdaptor_HSurface (); |
759 | BRepAdaptor_Surface& Sb1 = HS1->ChangeSurface(); |
760 | BRepAdaptor_Surface& Sb2 = HS2->ChangeSurface(); |
761 | |
1d54b807 |
762 | TopoDS_Face ff1,ff2; |
763 | TopoDS_Edge anEdge = Spine->Edges(IEdge); |
7fd59977 |
764 | ChFi3d_conexfaces(Spine->Edges(IEdge),ff1,ff2,myEFMap); |
765 | |
1d54b807 |
766 | TopoDS_Face FirstFace = TopoDS::Face(myEdgeFirstFace(anEdge)); |
767 | if (ff2.IsSame(FirstFace)) |
768 | { TopoDS_Face TmpFace = ff1; ff1 = ff2; ff2 = TmpFace; } |
769 | |
7fd59977 |
770 | Sb1.Initialize(ff1); |
771 | Sb2.Initialize(ff2); |
7fd59977 |
772 | } |
773 | |
774 | //======================================================================= |
775 | //function : StartSol |
81bba717 |
776 | //purpose : Calculates a starting solution : |
777 | // - one starts by parsing about ten points on the spine, |
778 | // - in case of fail one finds the solution on neighbor faces; |
779 | // section plane of edges of the adjacent face |
780 | // and identication of the face by connection to that edge. |
7fd59977 |
781 | //======================================================================= |
782 | |
783 | void ChFi3d_Builder::StartSol(const Handle(ChFiDS_Stripe)& Stripe, |
784 | const Handle(ChFiDS_HElSpine)& HGuide, |
785 | Handle(BRepAdaptor_HSurface)& HS1, |
786 | Handle(BRepAdaptor_HSurface)& HS2, |
787 | Handle(BRepTopAdaptor_TopolTool)& I1, |
788 | Handle(BRepTopAdaptor_TopolTool)& I2, |
789 | gp_Pnt2d& P1, |
790 | gp_Pnt2d& P2, |
791 | Standard_Real& First) const |
792 | { |
793 | Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine(); |
794 | ChFiDS_ElSpine& els = HGuide->ChangeCurve(); |
795 | Standard_Integer nbed = Spine->NbEdges(); |
796 | Standard_Integer nbessaimax = 3*nbed; |
797 | if (nbessaimax < 10) nbessaimax = 10; |
798 | Standard_Real unsurnbessaimax = 1./nbessaimax; |
7fd59977 |
799 | Standard_Real wf = 0.9981 * Spine->FirstParameter(1) + |
800 | 0.0019 * Spine->LastParameter(1); |
801 | Standard_Real wl = 0.9973 * Spine->LastParameter(nbed) + |
802 | 0.0027 * Spine->FirstParameter(nbed); |
803 | |
7fd59977 |
804 | Standard_Real TolE = 1.0e-7; |
7fd59977 |
805 | BRepAdaptor_Surface AS; |
806 | |
807 | Standard_Integer nbessai; |
808 | Standard_Integer iedge = 0; |
809 | Standard_Integer RC = Stripe->Choix(); |
810 | gp_Vec2d derive; |
811 | gp_Pnt2d P2d; |
812 | TopoDS_Edge cured; |
813 | TopoDS_Face f1,f2; |
814 | TopAbs_Orientation Or1,Or2; |
7fd59977 |
815 | Standard_Integer Choix = 0; |
7fd59977 |
816 | math_Vector SolDep(1,4); |
817 | Handle(Geom2d_Curve) PC; |
818 | Extrema_ExtPC PExt; |
819 | PExt.Initialize(els, |
820 | Spine->FirstParameter(1), |
821 | Spine->LastParameter(nbed), |
822 | Precision::Confusion()); |
823 | TopAbs_State Pos1,Pos2; |
824 | for(nbessai = 0; nbessai <= nbessaimax; nbessai++){ |
825 | Standard_Real t = nbessai*unsurnbessaimax; |
826 | Standard_Real w = wf * (1. -t) + wl * t; |
827 | Standard_Integer ie = Spine->Index(w); |
828 | if(iedge != ie){ |
829 | iedge = ie; |
830 | cured = Spine->Edges(iedge); |
831 | TolE = BRep_Tool::Tolerance(cured); |
1d54b807 |
832 | ConexFaces(Spine,iedge,HS1,HS2); |
7fd59977 |
833 | f1 = HS1->ChangeSurface().Face(); |
834 | f2 = HS2->ChangeSurface().Face(); |
835 | Or1 = f1.Orientation(); |
836 | Or2 = f2.Orientation(); |
837 | Choix = ChFi3d::NextSide(Or1,Or2, |
838 | Stripe->OrientationOnFace1(), |
839 | Stripe->OrientationOnFace2(), |
840 | RC); |
841 | } |
842 | |
843 | Standard_Real woned,Uf,Ul, ResU, ResV; |
844 | Spine->Parameter(iedge,w,woned,Standard_True); |
845 | cured.Orientation(TopAbs_FORWARD); |
846 | TopoDS_Face f1forward = f1, f2forward = f2; |
847 | f1forward.Orientation(TopAbs_FORWARD); |
848 | f2forward.Orientation(TopAbs_FORWARD); |
849 | PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul); |
543a9964 |
850 | I1->Initialize((const Handle(Adaptor3d_HSurface)&)HS1); |
7fd59977 |
851 | PC->D1(woned, P1, derive); |
81bba717 |
852 | // There are ponts on the border, and internal points are found |
7fd59977 |
853 | if (derive.Magnitude() > Precision::PConfusion()) { |
0be7dbe1 |
854 | derive.Normalize(); |
c6541a0c |
855 | derive.Rotate(M_PI/2); |
7fd59977 |
856 | AS.Initialize(f1); |
857 | ResU = AS.UResolution(TolE); |
858 | ResV = AS.VResolution(TolE); |
859 | derive *= 2*(Abs(derive.X())*ResU + Abs(derive.Y())*ResV); |
860 | P2d = P1.Translated(derive); |
861 | if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) { |
862 | P1 = P2d; |
863 | } |
864 | else { |
865 | P2d = P1.Translated(-derive); |
866 | if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) { |
867 | P1 = P2d; |
868 | } |
869 | } |
870 | } |
871 | if(f1.IsSame(f2)) cured.Orientation(TopAbs_REVERSED); |
872 | PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul); |
873 | P2 = PC->Value(woned); |
543a9964 |
874 | const Handle(Adaptor3d_HSurface)& HSon2 = HS2; // to avoid ambiguity |
875 | I2->Initialize(HSon2); |
7fd59977 |
876 | |
877 | SolDep(1) = P1.X(); SolDep(2) = P1.Y(); |
878 | SolDep(3) = P2.X(); SolDep(4) = P2.Y(); |
879 | const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge); |
880 | gp_Pnt pnt = Ced.Value(woned); |
881 | |
882 | if (Projection(PExt, pnt, els, w, tolesp) && |
883 | PerformFirstSection(Spine,HGuide,Choix,HS1,HS2, |
884 | I1,I2,w,SolDep,Pos1,Pos2)) { |
885 | P1.SetCoord(SolDep(1),SolDep(2)); |
886 | P2.SetCoord(SolDep(3),SolDep(4)); |
887 | First = w; |
888 | return; |
889 | } |
890 | } |
81bba717 |
891 | // No solution was found for the faces adjacent to the trajectory. |
892 | // Now one tries the neighbor faces. |
7fd59977 |
893 | iedge = 0; |
894 | for(nbessai = 0; nbessai <= nbessaimax; nbessai++){ |
895 | Standard_Real t = nbessai*unsurnbessaimax; |
896 | Standard_Real w = wf * (1. -t) + wl * t; |
897 | iedge = Spine->Index(w); |
898 | cured = Spine->Edges(iedge); |
1d54b807 |
899 | ConexFaces(Spine,iedge,HS1,HS2); |
7fd59977 |
900 | f1 = HS1->ChangeSurface().Face(); |
901 | f2 = HS2->ChangeSurface().Face(); |
902 | Or1 = f1.Orientation(); |
903 | Or2 = f2.Orientation(); |
904 | Choix = ChFi3d::NextSide(Or1,Or2, |
905 | Stripe->OrientationOnFace1(), |
906 | Stripe->OrientationOnFace2(), |
907 | RC); |
908 | Standard_Real woned,Uf,Ul; |
909 | Spine->Parameter(iedge,w,woned,Standard_True); |
910 | TopoDS_Face f1forward = f1, f2forward = f2; |
911 | f1forward.Orientation(TopAbs_FORWARD); |
912 | f2forward.Orientation(TopAbs_FORWARD); |
913 | PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul); |
914 | P1 = PC->Value(woned); |
915 | PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul); |
916 | P2 = PC->Value(woned); |
543a9964 |
917 | const Handle(Adaptor3d_HSurface)& HSon1 = HS1; // to avoid ambiguity |
918 | const Handle(Adaptor3d_HSurface)& HSon2 = HS2; // to avoid ambiguity |
919 | I1->Initialize(HSon1); |
920 | I2->Initialize(HSon2); |
7fd59977 |
921 | SolDep(1) = P1.X(); SolDep(2) = P1.Y(); |
922 | SolDep(3) = P2.X(); SolDep(4) = P2.Y(); |
923 | const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge); |
924 | gp_Pnt pnt = Ced.Value(woned); |
925 | // Extrema_LocateExtPC ext(pnt,els,w,1.e-8); |
926 | // if(ext.IsDone()){ |
927 | // w = ext.Point().Parameter(); |
928 | if (Projection(PExt, pnt, els, w, tolesp)) { |
929 | PerformFirstSection(Spine,HGuide,Choix,HS1,HS2, |
930 | I1,I2,w,SolDep,Pos1,Pos2); |
931 | gp_Pnt P; |
932 | gp_Vec V; |
933 | HGuide->D1(w,P,V); |
934 | Handle(Geom_Plane) pl = new Geom_Plane(P,V); |
935 | Handle(GeomAdaptor_HSurface) plane = new GeomAdaptor_HSurface(pl); |
936 | |
937 | Standard_Boolean bonvoisin = 1, found = 0; |
938 | Standard_Integer NbChangement; |
939 | for (NbChangement = 1; bonvoisin && (!found) && (NbChangement < 5); |
940 | NbChangement++) { |
941 | if(Pos1 != TopAbs_IN){ |
942 | bonvoisin = BonVoisin(P, HS1, f1, plane, cured, |
943 | SolDep(1),SolDep(2), myEFMap, tolesp); |
944 | } |
945 | if(Pos2 != TopAbs_IN && bonvoisin){ |
946 | bonvoisin = BonVoisin(P, HS2, f2, plane, cured, |
947 | SolDep(3),SolDep(4), myEFMap, tolesp); |
948 | } |
949 | if(bonvoisin){ |
950 | f1 = HS1->ChangeSurface().Face(); |
951 | f2 = HS2->ChangeSurface().Face(); |
952 | Or1 = f1.Orientation(); |
953 | Or2 = f2.Orientation(); |
954 | Choix = ChFi3d::NextSide(Or1,Or2, |
955 | Stripe->OrientationOnFace1(), |
956 | Stripe->OrientationOnFace2(), |
957 | RC); |
51740958 |
958 | const Handle(Adaptor3d_HSurface)& HSon1new = HS1; // to avoid ambiguity |
959 | const Handle(Adaptor3d_HSurface)& HSon2new = HS2; // to avoid ambiguity |
960 | I1->Initialize(HSon1new); |
961 | I2->Initialize(HSon2new); |
7fd59977 |
962 | if(PerformFirstSection(Spine,HGuide,Choix,HS1,HS2, |
963 | I1,I2,w,SolDep,Pos1,Pos2)){ |
964 | P1.SetCoord(SolDep(1),SolDep(2)); |
965 | P2.SetCoord(SolDep(3),SolDep(4)); |
966 | First = w; |
967 | found = Standard_True; |
968 | } |
969 | } |
970 | } |
971 | if (found) return; |
972 | } |
973 | } |
974 | Spine->SetErrorStatus(ChFiDS_StartsolFailure); |
9775fa61 |
975 | throw Standard_Failure("StartSol echec"); |
7fd59977 |
976 | } |
977 | |
978 | //======================================================================= |
979 | //function : ChFi3d_BuildPlane |
980 | //purpose : |
981 | //======================================================================= |
982 | |
983 | static void ChFi3d_BuildPlane (TopOpeBRepDS_DataStructure& DStr, |
984 | Handle(BRepAdaptor_HSurface)& HS, |
985 | gp_Pnt2d& pons, |
986 | const Handle(ChFiDS_SurfData)& SD, |
987 | const Standard_Boolean isfirst, |
988 | const Standard_Integer ons) |
989 | { |
990 | Handle(Geom2d_Curve) Hc; |
991 | TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons))); |
992 | Standard_Real u,v; |
993 | gp_Pnt P; |
994 | //gp_Vec V1,V2; |
995 | |
996 | if (SD->Vertex(isfirst,ons).IsOnArc()){ |
997 | Hc = BRep_Tool::CurveOnSurface |
998 | (SD->Vertex(isfirst,ons).Arc(),F,u,v); |
999 | Hc->Value(SD->Vertex(isfirst,ons).ParameterOnArc()).Coord(u,v); |
1000 | BRepLProp_SLProps theProp(HS->ChangeSurface(), u, v, 1, 1.e-12); |
1001 | if (theProp.IsNormalDefined()) { |
1002 | P = theProp.Value(); |
1003 | Handle(Geom_Plane) Pln = new Geom_Plane(P, theProp.Normal()); |
1c72dff6 |
1004 | TopoDS_Face NewF = BRepLib_MakeFace(Pln, Precision::Confusion()); |
7fd59977 |
1005 | NewF.Orientation(F.Orientation()); |
1006 | pons.SetCoord(0.,0.); |
1007 | HS->ChangeSurface().Initialize(NewF); |
81bba717 |
1008 | return; // everything is good ! |
7fd59977 |
1009 | } |
1010 | } |
9775fa61 |
1011 | throw Standard_Failure("ChFi3d_BuildPlane : echec ."); |
7fd59977 |
1012 | } |
1013 | |
1014 | //======================================================================= |
1015 | //function : StartSol |
81bba717 |
1016 | //purpose : If the commonpoint is not OnArc the input face |
1017 | // is returned and 2D point is updated, |
1018 | // if it is OnArc |
1019 | // if it is detached the input face |
1020 | // is returned and 2D point is updated, |
1021 | // otherwise |
1022 | // either there is a neighbor tangent face and it is returned |
1023 | // with recalculated 2D point |
1024 | // or if there is no face |
1025 | // if the reference arc is Vref (extremity of the spine) |
1026 | // this is the end and the input face is returned |
1027 | // otherwise this is an obstacle and HC is updated. |
7fd59977 |
1028 | //======================================================================= |
1029 | |
1030 | Standard_Boolean |
1031 | ChFi3d_Builder::StartSol(const Handle(ChFiDS_Spine)& Spine, |
81bba717 |
1032 | Handle(BRepAdaptor_HSurface)& HS, // New face |
1033 | gp_Pnt2d& pons,// " Localization |
1034 | Handle(BRepAdaptor_HCurve2d)& HC, // Representation of the obstacle |
7fd59977 |
1035 | Standard_Real& W, |
1036 | const Handle(ChFiDS_SurfData)& SD, |
1037 | const Standard_Boolean isfirst, |
1038 | const Standard_Integer ons, |
81bba717 |
1039 | Handle(BRepAdaptor_HSurface)& HSref, // The other representation |
1040 | Handle(BRepAdaptor_HCurve2d)& HCref, // of the obstacle |
7fd59977 |
1041 | Standard_Boolean& RecP, |
1042 | Standard_Boolean& RecS, |
1043 | Standard_Boolean& RecRst, |
1044 | Standard_Boolean& c1obstacle, |
81bba717 |
1045 | Handle(BRepAdaptor_HSurface)& HSBis, // Face of support |
1046 | gp_Pnt2d& PBis, // and its point |
7fd59977 |
1047 | const Standard_Boolean decroch, |
1048 | const TopoDS_Vertex& Vref) const |
1049 | { |
1050 | RecRst = RecS = RecP = c1obstacle = 0; |
1051 | TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); |
1052 | TopoDS_Face Fv,Fref; |
1053 | //gp_Pnt2d pp1,pp2; |
1054 | Handle(Geom2d_Curve) pc; |
1055 | Standard_Real Uf,Ul; |
1056 | |
1057 | TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons))); |
1058 | if(!HSref.IsNull()) Fref = HSref->ChangeSurface().Face(); |
1059 | const ChFiDS_CommonPoint& CP = SD->Vertex(isfirst,ons); |
1060 | HSBis.Nullify(); |
1061 | |
1062 | if (CP.IsOnArc()) { |
1063 | Standard_Integer notons; |
1064 | if (ons == 1) notons = 2; |
1065 | else notons = 1; |
1066 | const ChFiDS_CommonPoint& CPbis = SD->Vertex(isfirst,notons); |
81bba717 |
1067 | if (CPbis.IsOnArc()) { // It is checked if it is not the extension zone |
1068 | // In case CP is not at the end of surfdata and it is not necesary to take it into account |
1069 | // except for separate cases (ie pointus) ... |
1070 | //ts and tns were earlier CP.Parameter() and CPbis.Parameter, but sometimes they had no values. |
7fd59977 |
1071 | Standard_Real ts=SD->Interference(ons).Parameter(isfirst), tns=SD->Interference(notons).Parameter(isfirst); |
1072 | Standard_Boolean isExtend; |
81bba717 |
1073 | // Arbitrary test (to precise) |
7fd59977 |
1074 | if (isfirst) isExtend = (ts-tns > 100*tolesp); |
1075 | else isExtend = (tns-ts > 100*tolesp); |
1076 | if (isExtend && !CP.Point().IsEqual(CPbis.Point(), 0) ) { |
81bba717 |
1077 | // the state is preserved and False is returned (extension by the expected plane). |
7fd59977 |
1078 | HS->ChangeSurface().Initialize(F); |
1079 | pc = SD->Interference(ons).PCurveOnFace(); |
81bba717 |
1080 | // The 2nd point is given by its trace on the support surface |
7fd59977 |
1081 | RecS = Standard_False; |
1082 | pons = pc->Value(tns); |
1083 | return Standard_False; |
1084 | } |
1085 | } |
1086 | } |
1087 | |
1088 | if (CP.IsVertex() && !HC.IsNull() && !decroch){ |
81bba717 |
1089 | //The edge is changed, the parameter is updated and |
1090 | //eventually the support face and(or) the reference face. |
7fd59977 |
1091 | TopoDS_Vertex VCP = CP.Vertex(); |
1092 | TopoDS_Edge EHC = HC->ChangeCurve2d().Edge(); |
81bba717 |
1093 | //One starts by searching in Fref another edge referencing VCP. |
7fd59977 |
1094 | TopExp_Explorer ex1,ex2; |
1095 | TopoDS_Edge newedge, edgereg; |
1096 | TopoDS_Face bidface = Fref, facereg; |
1097 | bidface.Orientation(TopAbs_FORWARD); |
1098 | for(ex1.Init(bidface,TopAbs_EDGE); ex1.More(); ex1.Next()){ |
1099 | const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current()); |
1100 | Standard_Boolean found = 0; |
1101 | if(!cured.IsSame(EHC)){ |
1102 | for(ex2.Init(cured,TopAbs_VERTEX); ex2.More() && !found; ex2.Next()){ |
1103 | if(ex2.Current().IsSame(VCP)){ |
1104 | if(IsG1(myEFMap,cured,Fref,Fv)){ |
1105 | edgereg = cured; |
1106 | facereg = Fv; |
1107 | } |
1108 | else found = 1; |
1109 | } |
1110 | } |
1111 | } |
1112 | if(found) { |
1113 | newedge = cured; |
1114 | break; |
1115 | } |
1116 | } |
1117 | if(newedge.IsNull()){ |
81bba717 |
1118 | //It is checked if EHC is not a closed edge. |
7fd59977 |
1119 | TopoDS_Vertex V1,V2; |
1120 | TopExp::Vertices(EHC,V1,V2); |
1121 | if(V1.IsSame(V2)){ |
1122 | newedge = EHC; |
1123 | Standard_Real w1 = BRep_Tool::Parameter(V1,EHC); |
1124 | Standard_Real w2 = BRep_Tool::Parameter(V2,EHC); |
1125 | const ChFiDS_FaceInterference& fi = SD->Interference(ons); |
1126 | const Handle(Geom2d_Curve)& pcf = fi.PCurveOnFace(); |
1127 | Standard_Real ww = fi.Parameter(isfirst); |
1128 | |
1129 | gp_Pnt2d pww; |
1130 | if(!pcf.IsNull()) pww = pcf->Value(ww); |
1131 | else pww = SD->Get2dPoints(isfirst,ons); |
1132 | gp_Pnt2d p1 = HC->Value(w1); |
1133 | gp_Pnt2d p2 = HC->Value(w2); |
1134 | |
1135 | if(p1.Distance(pww) > p2.Distance(pww)){ |
1136 | W = w1; |
1137 | pons = p1; |
1138 | } |
1139 | else { |
1140 | W = w2; |
1141 | pons = p2; |
1142 | } |
1143 | RecP = c1obstacle = 1; |
1144 | return 1; |
1145 | } |
1146 | else if(!edgereg.IsNull()){ |
81bba717 |
1147 | // the reference edge and face are changed. |
7fd59977 |
1148 | Fref = facereg; |
1149 | HSref->ChangeSurface().Initialize(Fref); |
1150 | for(ex1.Init(facereg,TopAbs_EDGE); ex1.More() && newedge.IsNull(); ex1.Next()){ |
1151 | const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current()); |
1152 | if(!cured.IsSame(edgereg)){ |
1153 | for(ex2.Init(cured,TopAbs_VERTEX); ex2.More(); ex2.Next()){ |
1154 | if(ex2.Current().IsSame(VCP)){ |
1155 | if(!IsG1(myEFMap,cured,Fref,Fv)){ |
1156 | newedge = cured; |
1157 | } |
1158 | } |
1159 | } |
1160 | } |
1161 | } |
1162 | } |
1163 | } |
81bba717 |
1164 | // it is necessary to find the new support face of the fillet : |
1165 | // connected to FRef along the newedge. |
7fd59977 |
1166 | if(newedge.IsNull()) { |
9775fa61 |
1167 | throw Standard_Failure("StartSol : chain is not possible, new obstacle not found"); |
7fd59977 |
1168 | } |
1169 | if(IsG1(myEFMap,newedge,Fref,Fv)){ |
9775fa61 |
1170 | throw Standard_Failure("StartSol : chain is not possible, config non processed"); |
7fd59977 |
1171 | } |
1172 | else if(Fv.IsNull()){ |
9775fa61 |
1173 | throw Standard_Failure("StartSol : chain is not possible, new obstacle not found"); |
7fd59977 |
1174 | } |
1175 | else{ |
1176 | HS->ChangeSurface().Initialize(Fv); |
1177 | W = BRep_Tool::Parameter(VCP,newedge); |
1178 | HCref->ChangeCurve2d().Initialize(newedge,Fref); |
1179 | TopoDS_Face newface = Fv; |
1180 | newface.Orientation(TopAbs_FORWARD); |
1181 | TopExp_Explorer ex; |
1182 | for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){ |
1183 | if(ex.Current().IsSame(newedge)){ |
1184 | newedge = TopoDS::Edge(ex.Current()); |
1185 | break; |
1186 | } |
1187 | } |
1188 | HC->ChangeCurve2d().Initialize(newedge,Fv); |
1189 | pons = HC->Value(W); |
1190 | } |
1191 | RecP = c1obstacle = 1; |
1192 | return 1; |
81bba717 |
1193 | } // End of Case Vertex && Obstacle |
7fd59977 |
1194 | |
1195 | else if (CP.IsOnArc() && !HC.IsNull() && !decroch){ |
81bba717 |
1196 | //Nothing is changed, the parameter is only updated. |
7fd59977 |
1197 | W = CP.ParameterOnArc(); |
1198 | c1obstacle = 1; |
1199 | return 1; |
1200 | } |
1201 | |
1202 | HC.Nullify(); |
1203 | |
1204 | if (CP.IsOnArc()){ |
1205 | const TopoDS_Edge& E = CP.Arc(); |
1206 | if(decroch){ |
1207 | HS->ChangeSurface().Initialize(Fref); |
1208 | W = CP.ParameterOnArc(); |
1209 | pc = BRep_Tool::CurveOnSurface(E,Fref,Uf,Ul); |
1210 | pons = pc->Value(W); |
1211 | RecS = 1; |
1212 | return 1; |
1213 | } |
1214 | if (SearchFace(Spine,CP,F,Fv)){ |
1215 | HS->ChangeSurface().Initialize(Fv); |
1216 | RecS = 1; |
1217 | if (CP.IsVertex()) { |
81bba717 |
1218 | // One goes directly by the Vertex |
7fd59977 |
1219 | Standard_Integer Nb; |
1220 | TopoDS_Face aux; |
81bba717 |
1221 | // And it is checked that there are no other candidates |
7fd59977 |
1222 | Nb = SearchFaceOnV(CP, F, myVEMap, myEFMap, Fv, aux); |
1223 | |
1224 | pons = BRep_Tool::Parameters(CP.Vertex(), Fv); |
1225 | HS->ChangeSurface().Initialize(Fv); |
1226 | if (Nb >=2) { |
1227 | HSBis = new (BRepAdaptor_HSurface)(aux); |
1228 | PBis = BRep_Tool::Parameters(CP.Vertex(), aux); |
1229 | } |
1230 | return 1; |
1231 | } |
81bba717 |
1232 | // otherwise one passes by the arc... |
7fd59977 |
1233 | if(!Fv.IsSame(F)){ |
1234 | Fv.Orientation(TopAbs_FORWARD); |
1235 | TopoDS_Edge newedge; |
1236 | TopExp_Explorer ex; |
1237 | for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){ |
1238 | if(ex.Current().IsSame(E)){ |
1239 | newedge = TopoDS::Edge(ex.Current()); |
1240 | break; |
1241 | } |
1242 | } |
1243 | //gp_Vec Varc, VSurf; |
81bba717 |
1244 | // In cas of Tangent output, the current face becomes the support face |
7fd59977 |
1245 | if (SortieTangente(CP, F, SD, ons, 0.1)) { |
1246 | pc = BRep_Tool::CurveOnSurface(CP.Arc(),F,Uf,Ul); |
1247 | HSBis = new (BRepAdaptor_HSurface)(F); |
1248 | PBis = pc->Value(CP.ParameterOnArc()); |
1249 | } |
1250 | |
1251 | |
1252 | pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul); |
1253 | } |
1254 | else{ |
1255 | TopoDS_Edge newedge = E; |
1256 | newedge.Reverse(); |
1257 | Fv.Orientation(TopAbs_FORWARD); |
1258 | pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul); |
1259 | } |
1260 | pons = pc->Value(CP.ParameterOnArc()); |
1261 | return 1; |
1262 | } |
1263 | else if(!Fv.IsNull()){ |
1264 | c1obstacle = 1; |
1265 | if(!Vref.IsNull()){ |
1266 | TopExp_Explorer ex; |
1267 | for(ex.Init(E,TopAbs_VERTEX); ex.More(); ex.Next()){ |
1268 | if(ex.Current().IsSame(Vref)){ |
1269 | c1obstacle = 0; |
1270 | break; |
1271 | } |
1272 | } |
1273 | } |
1274 | if(c1obstacle){ |
1275 | HS->ChangeSurface().Initialize(Fv); |
1276 | HSref->ChangeSurface().Initialize(F); |
1277 | W = CP.ParameterOnArc(); |
1278 | HC = new BRepAdaptor_HCurve2d(); |
1279 | TopoDS_Edge newedge; |
1280 | TopoDS_Face newface = Fv; |
1281 | newface.Orientation(TopAbs_FORWARD); |
1282 | TopExp_Explorer ex; |
1283 | for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){ |
1284 | if(ex.Current().IsSame(E)){ |
1285 | newedge = TopoDS::Edge(ex.Current()); |
1286 | break; |
1287 | } |
1288 | } |
1289 | HC->ChangeCurve2d().Initialize(newedge,Fv); |
1290 | pons = HC->Value(W); |
1291 | HCref->ChangeCurve2d().Initialize(E,F); |
1292 | if(CP.IsVertex()) RecP = 1; |
1293 | else RecRst = 1; |
1294 | return 1; |
1295 | } |
1296 | else{ |
1297 | HS->ChangeSurface().Initialize(F); |
1298 | W = CP.ParameterOnArc(); |
1299 | pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul); |
1300 | pons = pc->Value(W); |
1301 | return Standard_False; |
1302 | } |
1303 | } |
81bba717 |
1304 | else{ // there is no neighbor face, the state is preserved and False is returned. |
7fd59977 |
1305 | HS->ChangeSurface().Initialize(F); |
1306 | W = CP.ParameterOnArc(); |
1307 | pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul); |
1308 | pons = pc->Value(W); |
1309 | return Standard_False; |
1310 | } |
1311 | } |
1312 | else{ |
1313 | HS->ChangeSurface().Initialize(F); |
1314 | const ChFiDS_FaceInterference& FI = SD->Interference(ons); |
1315 | if(FI.PCurveOnFace().IsNull()) pons = SD->Get2dPoints(isfirst,ons); |
1316 | else pons = FI.PCurveOnFace()->Value(FI.Parameter(isfirst)); |
1317 | } |
1318 | return Standard_True; |
1319 | } |
1320 | |
1321 | //======================================================================= |
1322 | //function : SearchFace |
1323 | //purpose : |
1324 | //======================================================================= |
1325 | |
1326 | Standard_Boolean ChFi3d_Builder::SearchFace |
1327 | (const Handle(ChFiDS_Spine)& Spine, |
1328 | const ChFiDS_CommonPoint& Pc, |
1329 | const TopoDS_Face& FRef, |
1330 | TopoDS_Face& FVoi) const |
1331 | { |
1332 | Standard_Boolean Trouve = Standard_False; |
1333 | if (! Pc.IsOnArc()) return Standard_False; |
1334 | FVoi.Nullify(); |
1335 | TopoDS_Edge E; |
1336 | if (Pc.IsVertex()){ |
81bba717 |
1337 | // attention it is necessary to analyze all faces that turn around of the vertex |
0797d9d3 |
1338 | #ifdef OCCT_DEBUG |
04232180 |
1339 | std::cout<<"Commonpoint on vertex, the process hangs up"<<std::endl; |
7fd59977 |
1340 | #endif |
81bba717 |
1341 | if (Pc.HasVector()) { //General processing |
7fd59977 |
1342 | TopoDS_Face Fbis; |
1343 | Standard_Integer nb_faces; |
1344 | nb_faces = SearchFaceOnV(Pc, FRef, myVEMap, myEFMap, FVoi, Fbis); |
1345 | return ( nb_faces > 0); |
1346 | } |
81bba717 |
1347 | else { // Processing using the spine |
7fd59977 |
1348 | Standard_Boolean FindFace=Standard_False; |
1349 | gp_Pnt Point; |
1350 | gp_Vec VecSpine; |
1351 | Spine->D1(Pc.Parameter(), Point, VecSpine); |
1352 | |
81bba717 |
1353 | // It is checked if one leaves from the current face. |
7fd59977 |
1354 | FindFace = IsInput(VecSpine, Pc.Vertex(), FRef); |
1355 | if (FindFace) { |
1356 | VecSpine.Reverse(); |
1357 | FindFace = IsInput(VecSpine, Pc.Vertex(), FRef); |
1358 | } |
81bba717 |
1359 | // If one does not leave, it is ended |
7fd59977 |
1360 | if (FindFace) { |
1361 | FVoi = FRef; |
1362 | return Standard_True; |
1363 | } |
1364 | |
81bba717 |
1365 | // Otherwise one finds the next among shared Faces |
1366 | // by a common edge G1 |
7fd59977 |
1367 | TopTools_ListIteratorOfListOfShape ItE, ItF; |
1368 | for(ItE.Initialize(myVEMap(Pc.Vertex())); |
1369 | ItE.More() && (!FindFace); ItE.Next()) { |
1370 | E = TopoDS::Edge(ItE.Value()); |
1371 | Trouve=Standard_False; |
1372 | for(ItF.Initialize(myEFMap(E));//, Trouve=Standard_False; 15.11.99 SVV |
1373 | ItF.More()&&(!Trouve); ItF.Next()) { |
1374 | if (TopoDS::Face(ItF.Value()).IsSame(FRef)) { |
1375 | Trouve = Standard_True; |
1376 | } |
1377 | } |
1378 | if (Trouve) FindFace = IsG1(myEFMap, E, FRef, FVoi); |
1379 | if (FindFace) { |
1380 | FindFace = Standard_False; |
1381 | if (Spine.IsNull()) { |
1382 | //La Spine peut etre nulle (ThreeCorner) |
0797d9d3 |
1383 | #ifdef OCCT_DEBUG |
04232180 |
1384 | std::cout << "FindFace sur vertex avec spine nulle! QUEZAKO ?" << std::endl; |
7fd59977 |
1385 | #endif |
1386 | return Standard_False; |
1387 | } |
1388 | |
81bba717 |
1389 | // It is checked if the selected face actually possesses edges of the spine |
1390 | // containing the vertex on its front |
1391 | // This processing should go only if the Vertex belongs to the spine |
1392 | // This is a single case, for other vertexes it is required to do other things |
7fd59977 |
1393 | Trouve=Standard_False; |
1394 | for (Standard_Integer IE=1;//, Trouve=Standard_False; 15.11.99 SVV |
1395 | (IE<=Spine->NbEdges()) && (!Trouve); IE++) { |
1396 | E = Spine->Edges(IE); |
1397 | if ( (TopExp::FirstVertex(E).IsSame(Pc.Vertex())) |
1398 | ||(TopExp::LastVertex(E) .IsSame(Pc.Vertex())) ) { |
1399 | for(ItF.Initialize(myEFMap(E)), Trouve=Standard_False; |
1400 | ItF.More()&&(!Trouve); ItF.Next()) { |
1401 | if (TopoDS::Face(ItF.Value()).IsSame(FVoi)) { |
1402 | Trouve = Standard_True; |
1403 | } |
1404 | } |
1405 | } |
1406 | } |
1407 | FindFace = Trouve; |
1408 | } |
1409 | } |
1410 | } |
1411 | } |
1412 | else { |
1413 | return IsG1(myEFMap, Pc.Arc(), FRef, FVoi); |
1414 | } |
1415 | return Standard_False; |
1416 | } |
1417 | |
1418 | |
1419 | //======================================================================= |
1420 | //function : ChFi3d_SingularExtremity |
81bba717 |
1421 | //purpose : load the vertex in the DS and calculate the pcurve |
1422 | // for an extremity in case of singular freeboundary |
1423 | // or periodic and singular at the cut. |
7fd59977 |
1424 | //======================================================================= |
1425 | static void ChFi3d_SingularExtremity( Handle(ChFiDS_Stripe)& stripe, |
1426 | TopOpeBRepDS_DataStructure& DStr, |
1427 | const TopoDS_Vertex& Vtx, |
1428 | const Standard_Real tol3d, |
1429 | const Standard_Real tol2d) |
1430 | { |
1431 | Handle(ChFiDS_SurfData) Fd; |
1432 | Standard_Real tolreached; |
1433 | Standard_Real Pardeb, Parfin; |
1434 | gp_Pnt2d VOnS1, VOnS2; |
1435 | Handle(Geom_Curve) C3d; |
1436 | Handle(Geom2d_Curve) PCurv; |
1437 | TopOpeBRepDS_Curve Crv; |
81bba717 |
1438 | // SurfData and its CommonPoints, |
7fd59977 |
1439 | Standard_Integer Ivtx, Icurv; |
1440 | Standard_Boolean isfirst; |
1441 | |
1442 | if (stripe->Spine()->IsPeriodic()) { |
1443 | isfirst = Standard_True; |
1444 | Fd = stripe->SetOfSurfData()->Sequence().First(); |
1445 | } |
1446 | else { |
1447 | Standard_Integer sens; |
1448 | Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens); |
1449 | Fd = stripe->SetOfSurfData()->Sequence().Value(num); |
1450 | isfirst = (sens == 1); |
1451 | } |
1452 | |
1453 | const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1); |
1454 | const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2); |
81bba717 |
1455 | // Is it always degenerated ? |
7fd59977 |
1456 | if ( CV1.Point().IsEqual( CV2.Point(), 0) ) { |
1457 | Ivtx = ChFi3d_IndexPointInDS(CV1, DStr); |
1458 | if (isfirst) { |
1459 | VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()-> |
1460 | Value(Fd->InterferenceOnS1().FirstParameter()); |
1461 | VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()-> |
1462 | Value(Fd->InterferenceOnS2().FirstParameter()); |
1463 | } |
1464 | else { |
1465 | VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()-> |
1466 | Value(Fd->InterferenceOnS1().LastParameter()); |
1467 | VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()-> |
1468 | Value(Fd->InterferenceOnS2().LastParameter()); |
1469 | } |
1470 | |
1471 | ChFi3d_ComputeArete(CV1, VOnS1, |
1472 | CV2, VOnS2, |
1473 | DStr.Surface(Fd->Surf()).Surface(), |
1474 | C3d, PCurv, |
1475 | Pardeb,Parfin, tol3d, tol2d, tolreached,0); |
1476 | Crv = TopOpeBRepDS_Curve(C3d,tolreached); |
1477 | Icurv = DStr.AddCurve(Crv); |
1478 | |
1479 | stripe->SetCurve(Icurv, isfirst); |
1480 | stripe->SetParameters(isfirst, Pardeb,Parfin); |
1481 | stripe->ChangePCurve(isfirst) = PCurv; |
1482 | stripe->SetIndexPoint(Ivtx, isfirst, 1); |
1483 | stripe->SetIndexPoint(Ivtx, isfirst, 2); |
1484 | |
1485 | if (stripe->Spine()->IsPeriodic()) { |
81bba717 |
1486 | // periodic case : The operation is renewed |
1487 | // the curve 3d is not shared. |
1488 | // 2 degenerated edges coinciding in 3d |
7fd59977 |
1489 | isfirst = Standard_False; |
1490 | Fd = stripe->SetOfSurfData()->Sequence().Last(); |
1491 | VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()-> |
1492 | Value(Fd->InterferenceOnS1().LastParameter()); |
1493 | VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()-> |
1494 | Value(Fd->InterferenceOnS2().LastParameter()); |
1495 | |
1496 | ChFi3d_ComputeArete(CV1, VOnS1, |
1497 | CV2, VOnS2, |
1498 | DStr.Surface(Fd->Surf()).Surface(), |
1499 | C3d, PCurv, |
1500 | Pardeb,Parfin, tol3d, tol2d, tolreached,0); |
1501 | Crv = TopOpeBRepDS_Curve(C3d,tolreached); |
1502 | Icurv = DStr.AddCurve(Crv); |
1503 | |
1504 | stripe->SetCurve(Icurv, isfirst); |
1505 | stripe->SetParameters(isfirst, Pardeb,Parfin); |
1506 | stripe->ChangePCurve(isfirst) = PCurv; |
1507 | stripe->SetIndexPoint(Ivtx, isfirst, 1); |
1508 | stripe->SetIndexPoint(Ivtx, isfirst, 2); |
1509 | } |
1510 | } |
1511 | } |
1512 | |
1513 | //======================================================================= |
1514 | //function : ChFi3d_MakeExtremities |
81bba717 |
1515 | //purpose : calculate Curves3d and pcurves of extremities in |
1516 | // periodic and freeboundary cases. |
7fd59977 |
1517 | //======================================================================= |
1518 | static Standard_Boolean IsFree(const TopoDS_Shape& E, |
1519 | const ChFiDS_Map& EFMap) |
1520 | { |
1521 | if(!EFMap.Contains(E)) return 0; |
1522 | TopTools_ListIteratorOfListOfShape It; |
1523 | TopoDS_Shape Fref; |
1524 | for(It.Initialize(EFMap(E)); It.More(); It.Next()){ |
1525 | if(Fref.IsNull()) Fref = It.Value(); |
1526 | else if(!Fref.IsSame(It.Value())) return 0; |
1527 | } |
1528 | return 1; |
1529 | } |
1530 | |
1531 | static void ChFi3d_MakeExtremities(Handle(ChFiDS_Stripe)& Stripe, |
1532 | TopOpeBRepDS_DataStructure& DStr, |
1533 | const ChFiDS_Map& EFMap, |
1534 | const Standard_Real tol3d, |
1535 | const Standard_Real tol2d) |
1536 | { |
1537 | Handle(ChFiDS_Spine)& sp = Stripe->ChangeSpine(); |
1538 | Standard_Real Pardeb,Parfin; |
1539 | Handle(Geom_Curve) C3d; |
1540 | Standard_Real tolreached; |
1541 | if(sp->IsPeriodic()){ |
1542 | Bnd_Box b1,b2; |
1543 | const Handle(ChFiDS_SurfData)& |
1544 | SDF = Stripe->SetOfSurfData()->Sequence().First(); |
1545 | const ChFiDS_CommonPoint& CV1 = SDF->VertexFirstOnS1(); |
1546 | const ChFiDS_CommonPoint& CV2 = SDF->VertexFirstOnS2(); |
1547 | if ( !CV1.Point().IsEqual(CV2.Point(), 0) ) { |
1548 | ChFi3d_ComputeArete(CV1, |
1549 | SDF->InterferenceOnS1().PCurveOnSurf()-> |
1550 | Value(SDF->InterferenceOnS1().FirstParameter()), |
1551 | CV2, |
1552 | SDF->InterferenceOnS2().PCurveOnSurf()-> |
1553 | Value(SDF->InterferenceOnS2().FirstParameter()), |
1554 | DStr.Surface(SDF->Surf()).Surface(),C3d, |
1555 | Stripe->ChangeFirstPCurve(),Pardeb,Parfin, |
1556 | tol3d,tol2d,tolreached,0); |
1557 | TopOpeBRepDS_Curve Crv(C3d,tolreached); |
1558 | Stripe->ChangeFirstCurve(DStr.AddCurve(Crv)); |
1559 | Stripe->ChangeFirstParameters(Pardeb,Parfin); |
1560 | Stripe->ChangeIndexFirstPointOnS1 |
1561 | (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS1(),DStr)); |
1562 | Stripe->ChangeIndexFirstPointOnS2 |
1563 | (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS2(),DStr)); |
1564 | Standard_Integer ICurv = Stripe->FirstCurve(); |
1565 | Stripe->ChangeLastParameters(Pardeb,Parfin); |
1566 | Stripe->ChangeLastCurve(ICurv); |
1567 | Stripe->ChangeIndexLastPointOnS1(Stripe->IndexFirstPointOnS1()); |
1568 | Stripe->ChangeIndexLastPointOnS2(Stripe->IndexFirstPointOnS2()); |
1569 | |
1570 | const Handle(ChFiDS_SurfData)& |
1571 | SDL = Stripe->SetOfSurfData()->Sequence().Last(); |
1572 | |
1573 | |
1574 | ChFi3d_ComputePCurv(C3d, |
1575 | SDL->InterferenceOnS1().PCurveOnSurf()-> |
1576 | Value(SDL->InterferenceOnS1().LastParameter()), |
1577 | SDL->InterferenceOnS2().PCurveOnSurf()-> |
1578 | Value(SDL->InterferenceOnS2().LastParameter()), |
1579 | Stripe->ChangeLastPCurve(), |
1580 | DStr.Surface(SDL->Surf()).Surface(), |
1581 | Pardeb,Parfin,tol3d,tolreached); |
1582 | Standard_Real oldtol = DStr.ChangeCurve(ICurv).Tolerance(); |
1583 | DStr.ChangeCurve(ICurv).Tolerance(Max(oldtol,tolreached)); |
1584 | if(CV1.IsOnArc()){ |
1585 | ChFi3d_EnlargeBox(CV1.Arc(),EFMap(CV1.Arc()),CV1.ParameterOnArc(),b1); |
1586 | } |
1587 | |
1588 | if(CV2.IsOnArc()){ |
1589 | ChFi3d_EnlargeBox(CV2.Arc(),EFMap(CV2.Arc()),CV2.ParameterOnArc(),b2); |
1590 | } |
1591 | ChFi3d_EnlargeBox(DStr,Stripe,SDF,b1,b2,1); |
1592 | ChFi3d_EnlargeBox(DStr,Stripe,SDL,b1,b2,0); |
1593 | if (!CV1.IsVertex()) |
1594 | ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1()); |
1595 | if (!CV2.IsVertex()) |
1596 | ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2()); |
1597 | } |
1598 | else { |
81bba717 |
1599 | // Case of the single extremity |
7fd59977 |
1600 | if (CV1.IsVertex()) { |
1601 | ChFi3d_SingularExtremity(Stripe, DStr, CV1.Vertex(), tol3d, tol2d); |
1602 | } |
63c629aa |
1603 | # if CHFI3D_DEB |
04232180 |
1604 | else { std::cout << "MakeExtremities : Singularity out of Vertex !!" << std::endl; } |
7fd59977 |
1605 | # endif |
1606 | } |
1607 | return; |
1608 | } |
1609 | |
1610 | const Handle(ChFiDS_SurfData)& |
1611 | SDdeb = Stripe->SetOfSurfData()->Sequence().First(); |
1612 | |
1613 | const ChFiDS_CommonPoint& cpdeb1 = SDdeb->VertexFirstOnS1(); |
1614 | const ChFiDS_CommonPoint& cpdeb2 = SDdeb->VertexFirstOnS2(); |
1615 | Standard_Boolean freedeb = sp->FirstStatus() == ChFiDS_FreeBoundary; |
1616 | if(!freedeb && cpdeb1.IsOnArc() && cpdeb2.IsOnArc()){ |
1617 | freedeb = (IsFree(cpdeb1.Arc(),EFMap) && IsFree(cpdeb2.Arc(),EFMap)); |
1618 | } |
1619 | if(freedeb){ |
1620 | sp->SetFirstStatus(ChFiDS_FreeBoundary); |
1621 | Bnd_Box b1,b2; |
1622 | if ( !cpdeb1.Point().IsEqual(cpdeb2.Point(), 0) ) { |
1623 | Standard_Boolean plane; |
1624 | gp_Pnt2d UV1,UV2; |
1625 | UV1=SDdeb->InterferenceOnS1().PCurveOnSurf()-> |
1626 | Value(SDdeb->InterferenceOnS1().FirstParameter()); |
1627 | UV2=SDdeb->InterferenceOnS2().PCurveOnSurf()-> |
1628 | Value(SDdeb->InterferenceOnS2().FirstParameter()); |
81bba717 |
1629 | // The intersection of the fillet by a plane is attempted |
7fd59977 |
1630 | |
1631 | Handle(GeomAdaptor_HSurface) HConge=ChFi3d_BoundSurf(DStr,SDdeb,1,2); |
1632 | ChFi3d_CoupeParPlan(cpdeb1,cpdeb2,HConge,UV1,UV2, |
1633 | tol3d,tol2d,C3d,Stripe->ChangeFirstPCurve(),tolreached, |
1634 | Pardeb,Parfin,plane); |
1635 | if (!plane) |
1636 | ChFi3d_ComputeArete(cpdeb1, |
1637 | SDdeb->InterferenceOnS1().PCurveOnSurf()-> |
1638 | Value(SDdeb->InterferenceOnS1().FirstParameter()), |
1639 | cpdeb2, |
1640 | SDdeb->InterferenceOnS2().PCurveOnSurf()-> |
1641 | Value(SDdeb->InterferenceOnS2().FirstParameter()), |
1642 | DStr.Surface(SDdeb->Surf()).Surface(),C3d, |
1643 | Stripe->ChangeFirstPCurve(),Pardeb,Parfin, |
1644 | tol3d,tol2d,tolreached,0); |
1645 | TopOpeBRepDS_Curve Crv(C3d,tolreached); |
1646 | Stripe->ChangeFirstCurve(DStr.AddCurve(Crv)); |
1647 | Stripe->ChangeFirstParameters(Pardeb,Parfin); |
1648 | Stripe->ChangeIndexFirstPointOnS1 |
1649 | (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS1(),DStr)); |
1650 | Stripe->ChangeIndexFirstPointOnS2 |
1651 | (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS2(),DStr)); |
1652 | if(cpdeb1.IsOnArc()){ |
1653 | ChFi3d_EnlargeBox(cpdeb1.Arc(),EFMap(cpdeb1.Arc()),cpdeb1.ParameterOnArc(),b1); |
1654 | } |
1655 | if(cpdeb2.IsOnArc()){ |
1656 | ChFi3d_EnlargeBox(cpdeb2.Arc(),EFMap(cpdeb2.Arc()),cpdeb2.ParameterOnArc(),b2); |
1657 | } |
1658 | ChFi3d_EnlargeBox(DStr,Stripe,SDdeb,b1,b2,1); |
1659 | if (!cpdeb1.IsVertex()) |
1660 | ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1()); |
1661 | if (!cpdeb2.IsVertex()) |
1662 | ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2()); |
1663 | } |
81bba717 |
1664 | else { // Case of a singular extremity |
7fd59977 |
1665 | if (cpdeb1.IsVertex()) { |
1666 | ChFi3d_SingularExtremity(Stripe, DStr, cpdeb1.Vertex(), tol3d, tol2d); |
1667 | } |
63c629aa |
1668 | # if CHFI3D_DEB |
04232180 |
1669 | else { std::cout << "MakeExtremities : Singularity out of Vertex !!" << std::endl; } |
7fd59977 |
1670 | # endif |
1671 | } |
1672 | } |
1673 | const Handle(ChFiDS_SurfData)& |
1674 | SDfin = Stripe->SetOfSurfData()->Sequence().Last(); |
1675 | const ChFiDS_CommonPoint& cpfin1 = SDfin->VertexLastOnS1(); |
1676 | const ChFiDS_CommonPoint& cpfin2 = SDfin->VertexLastOnS2(); |
1677 | Standard_Boolean freefin = sp->LastStatus() == ChFiDS_FreeBoundary; |
1678 | if(!freefin && cpfin1.IsOnArc() && cpfin2.IsOnArc()){ |
1679 | freefin = (IsFree(cpfin1.Arc(),EFMap) && IsFree(cpfin2.Arc(),EFMap)); |
1680 | } |
1681 | if(freefin){ |
1682 | sp->SetLastStatus(ChFiDS_FreeBoundary); |
1683 | Bnd_Box b1,b2; |
1684 | if ( !cpfin1.Point().IsEqual(cpfin2.Point(), 0) ) { |
1685 | Standard_Boolean plane; |
1686 | gp_Pnt2d UV1,UV2; |
1687 | UV1=SDfin->InterferenceOnS1().PCurveOnSurf()-> |
1688 | Value(SDfin->InterferenceOnS1().LastParameter()); |
1689 | UV2=SDfin->InterferenceOnS2().PCurveOnSurf()-> |
1690 | Value(SDfin->InterferenceOnS2().LastParameter()); |
81bba717 |
1691 | // Intersection of the fillet by a plane is attempted |
7fd59977 |
1692 | |
1693 | Handle(GeomAdaptor_HSurface) HConge=ChFi3d_BoundSurf(DStr,SDfin,1,2); |
1694 | ChFi3d_CoupeParPlan(cpfin1,cpfin2,HConge,UV1,UV2, |
1695 | tol3d,tol2d,C3d,Stripe->ChangeLastPCurve(),tolreached, |
1696 | Pardeb,Parfin,plane); |
1697 | if (!plane) |
1698 | ChFi3d_ComputeArete(cpfin1, |
1699 | SDfin->InterferenceOnS1().PCurveOnSurf()-> |
1700 | Value(SDfin->InterferenceOnS1().LastParameter()), |
1701 | cpfin2, |
1702 | SDfin->InterferenceOnS2().PCurveOnSurf()-> |
1703 | Value(SDfin->InterferenceOnS2().LastParameter()), |
1704 | DStr.Surface(SDfin->Surf()).Surface(),C3d, |
1705 | Stripe->ChangeLastPCurve(),Pardeb,Parfin, |
1706 | tol3d,tol2d,tolreached,0); |
1707 | TopOpeBRepDS_Curve Crv(C3d,tolreached); |
1708 | Stripe->ChangeLastCurve(DStr.AddCurve(Crv)); |
1709 | Stripe->ChangeLastParameters(Pardeb,Parfin); |
1710 | Stripe->ChangeIndexLastPointOnS1 |
1711 | (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS1(),DStr)); |
1712 | Stripe->ChangeIndexLastPointOnS2 |
1713 | (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS2(),DStr)); |
1714 | if(cpfin1.IsOnArc()){ |
1715 | ChFi3d_EnlargeBox(cpfin1.Arc(),EFMap(cpfin1.Arc()),cpfin1.ParameterOnArc(),b1); |
1716 | } |
1717 | if(cpfin2.IsOnArc()){ |
1718 | ChFi3d_EnlargeBox(cpfin2.Arc(),EFMap(cpfin2.Arc()),cpfin2.ParameterOnArc(),b2); |
1719 | } |
1720 | ChFi3d_EnlargeBox(DStr,Stripe,SDfin,b1,b2,0); |
1721 | if (!cpfin1.IsVertex()) |
1722 | ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexLastPointOnS1()); |
1723 | if (!cpfin2.IsVertex()) |
1724 | ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexLastPointOnS2()); |
1725 | } |
81bba717 |
1726 | else { // Case of the single extremity |
7fd59977 |
1727 | if (cpfin1.IsVertex()) { |
1728 | ChFi3d_SingularExtremity(Stripe, DStr, cpfin1.Vertex(), tol3d, tol2d); |
1729 | } |
63c629aa |
1730 | # if CHFI3D_DEB |
04232180 |
1731 | else { std::cout << "MakeExtremities : Singularity out of Vertex !!" << std::endl; } |
7fd59977 |
1732 | # endif |
1733 | } |
1734 | } |
1735 | } |
1736 | |
1737 | //======================================================================= |
1738 | //function : ChFi3d_Purge |
1739 | //purpose : |
1740 | //======================================================================= |
1741 | |
1742 | static void ChFi3d_Purge (Handle(ChFiDS_Stripe)& Stripe, |
1743 | Handle(ChFiDS_SurfData)& SD, |
1744 | const ChFiDS_CommonPoint& VRef, |
1745 | const Standard_Boolean isfirst, |
1746 | const Standard_Integer ons, |
dde68833 |
1747 | Standard_Integer& intf, |
1748 | Standard_Integer& intl) |
7fd59977 |
1749 | { |
81bba717 |
1750 | if (isfirst) intf = 1; else intl = 1; // End. |
7fd59977 |
1751 | Standard_Integer opp = 3-ons; |
1752 | if (!SD->Vertex(isfirst,opp).IsOnArc() || |
1753 | SD->TwistOnS1() || SD->TwistOnS2() ) { |
0797d9d3 |
1754 | #ifdef OCCT_DEBUG |
04232180 |
1755 | std::cout<<"ChFi3d_Purge : No output on extension."<<std::endl; |
7fd59977 |
1756 | #endif |
1757 | ChFiDS_SequenceOfSurfData& Seq = |
1758 | Stripe->ChangeSetOfSurfData()->ChangeSequence(); |
1759 | if(isfirst) Seq.Remove(1); |
1760 | else Seq.Remove(Seq.Length()); |
1761 | return; |
1762 | } |
1763 | if (ons == 1) SD->ChangeIndexOfS1(0); |
1764 | else SD->ChangeIndexOfS2(0); |
1765 | |
1766 | SD->ChangeVertex(!isfirst,ons) = VRef; |
1767 | SD->ChangeVertex(isfirst,ons) = VRef; |
1768 | |
1769 | ChFiDS_FaceInterference& fi = SD->ChangeInterference(ons); |
1770 | if(isfirst) fi.SetFirstParameter(fi.LastParameter()); |
1771 | else fi.SetLastParameter(fi.FirstParameter()); |
1772 | fi.SetLineIndex(0); |
1773 | } |
1774 | |
1775 | //======================================================================= |
1776 | //function : InsertAfter |
81bba717 |
1777 | //purpose : insert Item after ref in Seq. If ref is null, the item is |
1778 | // inserted at the beginning. |
7fd59977 |
1779 | //======================================================================= |
1780 | |
1781 | static void InsertAfter (Handle(ChFiDS_Stripe)& Stripe, |
1782 | Handle(ChFiDS_SurfData)& Ref, |
1783 | Handle(ChFiDS_SurfData)& Item) |
1784 | { |
1785 | if (Ref == Item) |
9775fa61 |
1786 | throw Standard_Failure("InsertAfter : twice the same surfdata."); |
7fd59977 |
1787 | |
1788 | ChFiDS_SequenceOfSurfData& Seq = |
1789 | Stripe->ChangeSetOfSurfData()->ChangeSequence(); |
1790 | |
1791 | if (Seq.IsEmpty() || Ref.IsNull()) { |
1792 | Seq.Prepend(Item); |
1793 | } |
1794 | for (Standard_Integer i = 1; i <= Seq.Length(); i++) { |
1795 | if (Seq.Value(i) == Ref) { |
1796 | Seq.InsertAfter(i,Item); |
1797 | break; |
1798 | } |
1799 | } |
1800 | } |
1801 | |
1802 | //======================================================================= |
1803 | //function : RemoveSD |
1804 | //purpose : |
1805 | //======================================================================= |
1806 | |
1807 | static void RemoveSD (Handle(ChFiDS_Stripe)& Stripe, |
1808 | Handle(ChFiDS_SurfData)& Prev, |
1809 | Handle(ChFiDS_SurfData)& Next) |
1810 | { |
1811 | ChFiDS_SequenceOfSurfData& Seq = |
1812 | Stripe->ChangeSetOfSurfData()->ChangeSequence(); |
1813 | if(Seq.IsEmpty()) return; |
1814 | Standard_Integer iprev = 0, inext = 0; |
1815 | for (Standard_Integer i = 1; i <= Seq.Length(); i++) { |
1816 | if (Seq.Value(i) == Prev) iprev = i + 1; |
1817 | if (Seq.Value(i) == Next) { inext = i - 1; break; } |
1818 | } |
1819 | if(Prev.IsNull()) iprev = 1; |
1820 | if(Next.IsNull()) inext = Seq.Length(); |
1821 | if(iprev <= inext) Seq.Remove(iprev,inext); |
1822 | } |
1823 | |
1824 | //======================================================================= |
1825 | //function : InsertBefore |
81bba717 |
1826 | //purpose : Insert item before ref in Seq. If ref is null, the item is |
1827 | // inserted in the queue. |
7fd59977 |
1828 | //======================================================================= |
1829 | |
1830 | static void InsertBefore (Handle(ChFiDS_Stripe)& Stripe, |
1831 | Handle(ChFiDS_SurfData)& Ref, |
1832 | Handle(ChFiDS_SurfData)& Item) |
1833 | { |
1834 | if (Ref == Item) |
9775fa61 |
1835 | throw Standard_Failure("InsertBefore : twice the same surfdata."); |
7fd59977 |
1836 | |
1837 | ChFiDS_SequenceOfSurfData& Seq = |
1838 | Stripe->ChangeSetOfSurfData()->ChangeSequence(); |
1839 | |
1840 | if (Seq.IsEmpty() || Ref.IsNull()) { |
1841 | Seq.Append(Item); |
1842 | } |
1843 | for (Standard_Integer i = 1; i <= Seq.Length(); i++) { |
1844 | if (Seq.Value(i) == Ref) { |
1845 | Seq.InsertBefore(i,Item); |
1846 | break; |
1847 | } |
1848 | } |
1849 | } |
1850 | |
1851 | |
1852 | //======================================================================= |
1853 | //function : PerformSetOfSurfOnElSpine |
1854 | //purpose : |
1855 | //======================================================================= |
1856 | |
1857 | void ChFi3d_Builder::PerformSetOfSurfOnElSpine |
1858 | (const Handle(ChFiDS_HElSpine)& HGuide, |
1859 | Handle(ChFiDS_Stripe)& Stripe, |
1860 | Handle(BRepTopAdaptor_TopolTool)& It1, |
1861 | Handle(BRepTopAdaptor_TopolTool)& It2, |
1862 | const Standard_Boolean Simul) |
1863 | { |
0797d9d3 |
1864 | #ifdef OCCT_DEBUG |
7fd59977 |
1865 | OSD_Chronometer ch1; |
1866 | #endif |
1d54b807 |
1867 | |
1868 | //Temporary |
1869 | //gp_Pnt ptgui; |
1870 | //gp_Vec d1gui; |
1871 | //( HGuide->Curve() ).D1(HGuide->FirstParameter(),ptgui,d1gui); |
7fd59977 |
1872 | |
1873 | ChFiDS_ElSpine& Guide = HGuide->ChangeCurve(); |
1d54b807 |
1874 | |
1875 | Handle(ChFiDS_HElSpine) OffsetHGuide; |
1876 | Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine(); |
1877 | if (Spine->Mode() == ChFiDS_ConstThroatWithPenetrationChamfer) |
1878 | { |
1879 | ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines(); |
1880 | ChFiDS_ListOfHElSpine& ll_offset = Spine->ChangeOffsetElSpines(); |
1881 | ChFiDS_ListIteratorOfListOfHElSpine ILES(ll), ILES_offset(ll_offset); |
1882 | for ( ; ILES.More(); ILES.Next(),ILES_offset.Next()) |
1883 | { |
1884 | const Handle(ChFiDS_HElSpine)& aHElSpine = ILES.Value(); |
1885 | if (aHElSpine == HGuide) |
1886 | OffsetHGuide = ILES_offset.Value(); |
1887 | } |
1888 | } |
1889 | |
7fd59977 |
1890 | Standard_Real wf = Guide.FirstParameter(); |
1891 | Standard_Real wl = Guide.LastParameter(); |
1892 | Standard_Real locfleche = (wl - wf) * fleche; |
1893 | Standard_Real wfsav = wf, wlsav = wl; |
73d0a668 |
1894 | if (!Guide.IsPeriodic()) |
1895 | { |
1896 | //Now the ElSpine is artificially extended to help rsnld. |
1897 | Standard_Real prab = 0.01; |
1898 | Guide.FirstParameter(wf-prab*(wl-wf)); |
1899 | Guide.LastParameter (wl+prab*(wl-wf)); |
1d54b807 |
1900 | if (!OffsetHGuide.IsNull()) |
1901 | { |
1902 | OffsetHGuide->ChangeCurve().FirstParameter(wf-prab*(wl-wf)); |
1903 | OffsetHGuide->ChangeCurve().LastParameter (wl+prab*(wl-wf)); |
1904 | } |
73d0a668 |
1905 | } |
1d54b807 |
1906 | //Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine(); |
7fd59977 |
1907 | Standard_Integer ii, nbed = Spine->NbEdges(); |
1908 | Standard_Real lastedlastp = Spine->LastParameter(nbed); |
1909 | |
1910 | TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); |
1911 | |
1912 | Handle(ChFiDS_SurfData) ref = Guide.Previous(); |
1913 | Handle(ChFiDS_SurfData) refbis, SD; |
1914 | Handle(ChFiDS_SurfData) raf = Guide.Next(); |
1915 | RemoveSD(Stripe,ref,raf); |
1916 | |
1917 | Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(); |
1918 | Handle(BRepAdaptor_HSurface) HS2 = new BRepAdaptor_HSurface(); |
1919 | Handle(BRepAdaptor_HSurface) HS3, HS4; |
1920 | Handle(BRepAdaptor_HSurface) HSref1 = new BRepAdaptor_HSurface(); |
1921 | Handle(BRepAdaptor_HSurface) HSref2 = new BRepAdaptor_HSurface(); |
1922 | Handle(BRepAdaptor_HCurve2d) HC1,HC2; |
1923 | Handle(BRepAdaptor_HCurve2d) HCref1 = new BRepAdaptor_HCurve2d(); |
1924 | Handle(BRepAdaptor_HCurve2d) HCref2 = new BRepAdaptor_HCurve2d(); |
1d47d8d0 |
1925 | Standard_Boolean decroch1 = Standard_False, decroch2 = Standard_False; |
1926 | Standard_Boolean RecP1 = Standard_False, RecS1 = Standard_False, RecRst1 = Standard_False, obstacleon1 = Standard_False; |
1927 | Standard_Boolean RecP2 = Standard_False, RecS2 = Standard_False, RecRst2 = Standard_False, obstacleon2 = Standard_False; |
7fd59977 |
1928 | gp_Pnt2d pp1,pp2,pp3,pp4; |
1d47d8d0 |
1929 | Standard_Real w1 = 0.,w2 = 0.; |
7fd59977 |
1930 | math_Vector Soldep(1,4); |
1931 | math_Vector SoldepCS(1,3); |
1932 | math_Vector SoldepCC(1,2); |
1933 | |
81bba717 |
1934 | // Restore a neighboring KPart. |
1935 | // If no neighbor calculation start point. |
7fd59977 |
1936 | Standard_Boolean forward = Standard_True; |
1937 | Standard_Boolean Inside = Standard_False; |
1938 | Standard_Real First = wf; |
1939 | Standard_Real Last = wl; |
1940 | Standard_Boolean Ok1 = 1,Ok2 = 1; |
81bba717 |
1941 | // Restore the next KPart if it exists |
7fd59977 |
1942 | TopoDS_Vertex Vref; |
1943 | if(ref.IsNull() && raf.IsNull()){ |
1944 | //sinon solution approchee. |
1945 | Inside = Standard_True; |
1946 | |
0797d9d3 |
1947 | #ifdef OCCT_DEBUG |
81bba717 |
1948 | ChFi3d_InitChron(ch1);// init perf for StartSol |
7fd59977 |
1949 | #endif |
1950 | |
1951 | StartSol(Stripe,HGuide,HS1,HS2,It1,It2,pp1,pp2,First); |
1952 | |
0797d9d3 |
1953 | #ifdef OCCT_DEBUG |
81bba717 |
1954 | ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol |
7fd59977 |
1955 | #endif |
1956 | |
1957 | Last = wf; |
1958 | if(Guide.IsPeriodic()) { |
1959 | Last = First - Guide.Period(); |
73d0a668 |
1960 | Guide.SaveFirstParameter(); |
7fd59977 |
1961 | Guide.FirstParameter(Last); |
73d0a668 |
1962 | Guide.SaveLastParameter(); |
81bba717 |
1963 | Guide.LastParameter (First * 1.1);//Extension to help rsnld. |
1d54b807 |
1964 | if (!OffsetHGuide.IsNull()) |
1965 | { |
1966 | OffsetHGuide->ChangeCurve().SaveFirstParameter(); |
1967 | OffsetHGuide->ChangeCurve().FirstParameter(Last); |
1968 | OffsetHGuide->ChangeCurve().SaveLastParameter(); |
1969 | OffsetHGuide->ChangeCurve().LastParameter (First * 1.1);//Extension to help rsnld. |
1970 | } |
7fd59977 |
1971 | } |
1972 | } |
1973 | else{ |
1974 | if(!Spine->IsPeriodic() && (wl - lastedlastp > -tolesp)){ |
1975 | Vref = Spine->LastVertex(); |
1976 | } |
1977 | if (ref.IsNull()) { |
1978 | if(!Spine->IsPeriodic() && (wf < tolesp)){ |
1979 | Vref = Spine->FirstVertex(); |
1980 | } |
1981 | ref = raf; |
1982 | forward = Standard_False; |
1983 | First = wl; Last = Guide.FirstParameter(); |
1984 | } |
1985 | |
0797d9d3 |
1986 | #ifdef OCCT_DEBUG |
81bba717 |
1987 | ChFi3d_InitChron(ch1);// init perf for startsol |
7fd59977 |
1988 | #endif |
1989 | |
1990 | |
1991 | Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1, |
1992 | HSref1,HCref1,RecP1,RecS1,RecRst1,obstacleon1, |
1993 | HS3,pp3,decroch1,Vref); |
1994 | Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2, |
1995 | HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2, |
1996 | HS4,pp4,decroch2,Vref); |
1997 | HC1.Nullify(); |
1998 | HC2.Nullify(); |
1999 | |
0797d9d3 |
2000 | #ifdef OCCT_DEBUG |
81bba717 |
2001 | ChFi3d_ResultChron(ch1,t_startsol); // result perf for startsol |
7fd59977 |
2002 | #endif |
2003 | |
2004 | |
2005 | if(Ok1 == 1 && Ok2 == 1) { |
1d54b807 |
2006 | if(forward) |
2007 | { |
2008 | Guide.FirstParameter(wf); |
2009 | if (!OffsetHGuide.IsNull()) |
2010 | OffsetHGuide->ChangeCurve().FirstParameter(wf); |
2011 | } |
2012 | else |
2013 | { |
2014 | Guide.LastParameter(wl); |
2015 | if (!OffsetHGuide.IsNull()) |
2016 | OffsetHGuide->ChangeCurve().LastParameter(wl); |
2017 | } |
7fd59977 |
2018 | } |
2019 | } |
2020 | Standard_Boolean fini = Standard_False; |
2021 | Standard_Boolean complete = Inside; |
2022 | if(!Guide.IsPeriodic()){ |
2023 | Standard_Integer indf = Spine->Index(wf); |
2024 | Standard_Integer indl = Spine->Index(wl,0); |
2025 | if(Spine->IsPeriodic() && (indl < indf)) indl += nbed; |
2026 | nbed = indl-indf+1; |
2027 | } |
81bba717 |
2028 | // No Max at the touch : 20 points by edge at average without |
2029 | // counting the extensions. |
7fd59977 |
2030 | |
2031 | Standard_Real bidf = wf, bidl = wl; |
2032 | if(!Spine->IsPeriodic()) { |
2033 | bidf = Max(0.,wf); |
2034 | bidl = Min(wl,Spine->LastParameter(Spine->NbEdges())); |
81bba717 |
2035 | // PMN 20/07/98 : Attention in case if there is only extension |
7fd59977 |
2036 | if ((bidl-bidf) < 0.01 * Spine->LastParameter(Spine->NbEdges())) { |
2037 | bidf = wf; |
2038 | bidl = wl; |
2039 | } |
2040 | } |
2041 | Standard_Real MaxStep = (bidl-bidf)*0.05/nbed; |
7fd59977 |
2042 | Standard_Real Firstsov = 0.; |
dde68833 |
2043 | Standard_Integer intf = 0, intl = 0; |
7fd59977 |
2044 | while(!fini){ |
81bba717 |
2045 | // are these the ends (no extension on periodic). |
7fd59977 |
2046 | Ok1 = 1,Ok2 = 1; |
2047 | if(!Spine->IsPeriodic()){ |
2048 | if(wf < tolesp && (complete == Inside)){ |
2049 | if(Spine->FirstStatus() == ChFiDS_OnSame) intf = 2; |
2050 | else intf = 1; |
2051 | } |
2052 | if(Spine->IsTangencyExtremity(Standard_True)){ |
2053 | intf = 4; |
2054 | Guide.FirstParameter(wfsav); |
1d54b807 |
2055 | if (!OffsetHGuide.IsNull()) |
2056 | OffsetHGuide->ChangeCurve().FirstParameter(wfsav); |
7fd59977 |
2057 | } |
2058 | if(wl - lastedlastp > -tolesp){ |
2059 | if(Spine->LastStatus() == ChFiDS_OnSame) intl = 2; |
2060 | else intl = 1; |
2061 | } |
2062 | if(Spine->IsTangencyExtremity(Standard_False)){ |
2063 | intl = 4; |
2064 | Guide.LastParameter(wlsav); |
1d54b807 |
2065 | if (!OffsetHGuide.IsNull()) |
2066 | OffsetHGuide->ChangeCurve().LastParameter(wlsav); |
7fd59977 |
2067 | } |
2068 | } |
2069 | if(intf && !forward) Vref = Spine->FirstVertex(); |
2070 | if(intl && forward) Vref = Spine->LastVertex(); |
2071 | if(!ref.IsNull()){ |
2072 | |
0797d9d3 |
2073 | #ifdef OCCT_DEBUG |
81bba717 |
2074 | ChFi3d_InitChron(ch1);// init perf for StartSol |
7fd59977 |
2075 | #endif |
2076 | |
2077 | Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1, |
2078 | HSref1,HCref1, RecP1,RecS1,RecRst1,obstacleon1, |
2079 | HS3,pp3,decroch1,Vref); |
2080 | Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2, |
2081 | HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2, |
2082 | HS4,pp4,decroch2,Vref); |
2083 | |
0797d9d3 |
2084 | #ifdef OCCT_DEBUG |
81bba717 |
2085 | ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol |
7fd59977 |
2086 | #endif |
2087 | |
2088 | } |
2089 | |
81bba717 |
2090 | // No more connected faces. Construction of the tangent plane to continue the path |
2091 | // till the output on the other face. |
7fd59977 |
2092 | if ((!Ok1 && HC1.IsNull()) || (!Ok2 && HC2.IsNull())) { |
2093 | if ((intf && !forward) || (intl && forward)) { |
2094 | if (!Ok1) ChFi3d_BuildPlane (DStr,HS1,pp1,ref,!forward,1); |
2095 | if (!Ok2) ChFi3d_BuildPlane (DStr,HS2,pp2,ref,!forward,2); |
2096 | if(intf) intf = 5; |
2097 | else if(intl) intl = 5; |
1d54b807 |
2098 | if(forward) |
2099 | { |
2100 | Guide.FirstParameter(wf); |
2101 | if (!OffsetHGuide.IsNull()) |
2102 | OffsetHGuide->ChangeCurve().FirstParameter(wf); |
2103 | } |
2104 | else |
2105 | { |
2106 | Guide.LastParameter(wl); |
2107 | if (!OffsetHGuide.IsNull()) |
2108 | OffsetHGuide->ChangeCurve().LastParameter(wl); |
2109 | } |
7fd59977 |
2110 | } |
9775fa61 |
2111 | else throw Standard_Failure("PerformSetOfSurfOnElSpine : Chaining is impossible."); |
7fd59977 |
2112 | } |
2113 | |
543a9964 |
2114 | // Definition of the domain of patch It1, It2 |
2115 | const Handle(Adaptor3d_HSurface)& HSon1 = HS1; // to avoid ambiguity |
2116 | const Handle(Adaptor3d_HSurface)& HSon2 = HS2; // to avoid ambiguity |
2117 | It1->Initialize(HSon1); |
2118 | It2->Initialize(HSon2); |
7fd59977 |
2119 | |
81bba717 |
2120 | // Calculate one (several if singularity) SurfaData |
7fd59977 |
2121 | SD = new ChFiDS_SurfData(); |
2122 | ChFiDS_SequenceOfSurfData SeqSD; |
2123 | SeqSD.Append(SD); |
2124 | |
2125 | if(obstacleon1 && obstacleon2){ |
2126 | TopAbs_Orientation Or1 = HSref1->ChangeSurface().Face().Orientation(); |
2127 | TopAbs_Orientation Or2 = HSref2->ChangeSurface().Face().Orientation(); |
2128 | Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2, |
2129 | Stripe->OrientationOnFace1(), |
2130 | Stripe->OrientationOnFace2(), |
2131 | Stripe->Choix()); |
2132 | |
2133 | |
81bba717 |
2134 | // Calculate the criterion of Choice edge / edge |
7fd59977 |
2135 | if (Choix%2 == 0) Choix = 4; |
2136 | else Choix = 1; |
2137 | |
2138 | SoldepCC(1) = w1; SoldepCC(2) = w2; |
2139 | if(Simul){ |
2140 | SimulSurf(SD,HGuide,Spine,Choix, |
2141 | HS1,It1,HC1,HSref1,HCref1,decroch1,Or1, |
2142 | HS2,It2,HC2,HSref2,HCref2,decroch2,Or2, |
2143 | locfleche,tolesp,First,Last,Inside,Inside,forward, |
2144 | RecP1,RecRst1,RecP2,RecRst2,SoldepCC); |
2145 | } |
2146 | else{ |
0797d9d3 |
2147 | #ifdef OCCT_DEBUG |
81bba717 |
2148 | ChFi3d_InitChron(ch1); // init perf for PerformSurf |
7fd59977 |
2149 | #endif |
2150 | PerformSurf(SeqSD,HGuide,Spine,Choix, |
2151 | HS1,It1,HC1,HSref1,HCref1,decroch1,Or1, |
2152 | HS2,It2,HC2,HSref2,HCref2,decroch2,Or2, |
2153 | MaxStep,locfleche,tolesp,First,Last,Inside,Inside,forward, |
2154 | RecP1,RecRst1,RecP2,RecRst2,SoldepCC); |
0797d9d3 |
2155 | #ifdef OCCT_DEBUG |
81bba717 |
2156 | ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf |
7fd59977 |
2157 | #endif |
2158 | } |
2159 | SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face())); |
2160 | SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face())); |
2161 | } |
2162 | else if (obstacleon1){ |
2163 | TopAbs_Orientation Or1 = HSref1->ChangeSurface().Face().Orientation(); |
2164 | TopAbs_Orientation Or2 = HS2->ChangeSurface().Face().Orientation(); |
2165 | Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2, |
2166 | Stripe->OrientationOnFace1(), |
2167 | Stripe->OrientationOnFace2(), |
2168 | -Stripe->Choix()); |
2169 | if(Choix%2 == 1) Choix++; |
2170 | else Choix--; |
2171 | SoldepCS(3) = w1; SoldepCS(1) = pp2.X(); SoldepCS(2) = pp2.Y(); |
2172 | if(Simul){ |
2173 | SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1, |
2174 | HS2,It2,Or2,locfleche,tolesp,First,Last, |
2175 | Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS); |
2176 | } |
2177 | else{ |
0797d9d3 |
2178 | #ifdef OCCT_DEBUG |
81bba717 |
2179 | ChFi3d_InitChron(ch1); // init perf for PerformSurf |
7fd59977 |
2180 | #endif |
2181 | PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1, |
2182 | HS2,It2,Or2,MaxStep,locfleche,tolesp,First,Last, |
2183 | Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS); |
0797d9d3 |
2184 | #ifdef OCCT_DEBUG |
81bba717 |
2185 | ChFi3d_ResultChron(ch1,t_performsurf);//result perf for PerformSurf |
7fd59977 |
2186 | #endif |
2187 | } |
2188 | SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face())); |
2189 | SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face())); |
2190 | decroch2 = 0; |
2191 | } |
2192 | else if (obstacleon2){ |
2193 | TopAbs_Orientation Or1 = HS1->ChangeSurface().Face().Orientation(); |
2194 | TopAbs_Orientation Or2 = HSref2->ChangeSurface().Face().Orientation(); |
2195 | Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2, |
2196 | Stripe->OrientationOnFace1(), |
2197 | Stripe->OrientationOnFace2(), |
2198 | Stripe->Choix()); |
2199 | SoldepCS(3) = w2; SoldepCS(1) = pp1.X(); SoldepCS(2) = pp1.Y(); |
2200 | if(Simul){ |
2201 | SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,Or1, |
2202 | HS2,It2,HC2,HSref2,HCref2,decroch2,locfleche,tolesp, |
2203 | First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS); |
2204 | } |
2205 | else{ |
0797d9d3 |
2206 | #ifdef OCCT_DEBUG |
81bba717 |
2207 | ChFi3d_InitChron(ch1); // init perf for PerformSurf |
7fd59977 |
2208 | #endif |
2209 | PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,Or1, |
2210 | HS2,It2,HC2,HSref2,HCref2,decroch2,MaxStep,locfleche,tolesp, |
2211 | First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS); |
0797d9d3 |
2212 | #ifdef OCCT_DEBUG |
81bba717 |
2213 | ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf |
7fd59977 |
2214 | #endif |
2215 | } |
2216 | SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face())); |
2217 | SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face())); |
2218 | decroch1 = 0; |
2219 | } |
543a9964 |
2220 | else{ |
2221 | const Handle(Adaptor3d_TopolTool)& aTT1 = It1; // to avoid ambiguity |
2222 | const Handle(Adaptor3d_TopolTool)& aTT2 = It2; // to avoid ambiguity |
7fd59977 |
2223 | CallPerformSurf(Stripe, Simul, SeqSD, SD, |
2224 | HGuide,Spine, |
543a9964 |
2225 | HS1, HS3, pp1, pp3, aTT1, |
2226 | HS2, HS4, pp2, pp4, aTT2, |
7fd59977 |
2227 | MaxStep,locfleche,tolesp, |
2228 | First,Last,Inside,Inside,forward, |
2229 | RecS1,RecS2,Soldep,intf,intl, |
2230 | HS1, HS2); |
2231 | decroch1 = decroch2 = 0; |
2232 | } |
2233 | |
81bba717 |
2234 | if(!done) { // Case of fail |
7fd59977 |
2235 | if ((!Ok1 && !obstacleon1) || (!Ok2 && !obstacleon2)) { |
81bba717 |
2236 | //Fail in a part of extension is not serious |
2237 | //Here one stops. |
7fd59977 |
2238 | done = Standard_True; |
2239 | Inside = Standard_False; |
2240 | if (forward) intl = 1; |
2241 | else intf = 1; |
2242 | } |
81bba717 |
2243 | else { // Otherwise invalidation of the stripe. |
7fd59977 |
2244 | Spine->SetErrorStatus(ChFiDS_WalkingFailure); |
9775fa61 |
2245 | throw Standard_Failure("CallPerformSurf : Path failed!"); |
7fd59977 |
2246 | } |
2247 | } |
2248 | |
2249 | else { |
2250 | refbis = ref; |
2251 | if(forward) { |
2252 | for (ii=1; ii<=SeqSD.Length(); ii++) { |
2253 | SD = SeqSD(ii); |
2254 | SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face())); |
2255 | if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->ChangeCurve2d().Edge())); |
2256 | SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face())); |
2257 | if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->ChangeCurve2d().Edge())); |
2258 | InsertAfter (Stripe, refbis, SD); |
2259 | refbis = SD; |
2260 | } |
2261 | } |
2262 | else { |
2263 | for (ii=SeqSD.Length(); ii>=1; ii--) { |
2264 | SD = SeqSD(ii); |
2265 | SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face())); |
2266 | if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->ChangeCurve2d().Edge())); |
2267 | SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face())); |
2268 | if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->ChangeCurve2d().Edge())); |
2269 | InsertBefore(Stripe,refbis,SD); |
2270 | refbis = SD; |
2271 | } |
2272 | } |
2273 | |
2274 | if (!Ok1 && !obstacleon1) |
81bba717 |
2275 | // clean infos on the plane of extension. |
7fd59977 |
2276 | ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,1),!forward,1,intf,intl); |
2277 | |
2278 | if (!Ok2 && !obstacleon2) |
81bba717 |
2279 | // clean infos on the plane of extension. |
7fd59977 |
2280 | ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,2),!forward,2,intf,intl); |
2281 | |
81bba717 |
2282 | // The end. The reference is changed. |
7fd59977 |
2283 | ref = refbis; |
2284 | } |
2285 | |
81bba717 |
2286 | if(Inside){// There are starting solutions for the next. |
7fd59977 |
2287 | Inside = Standard_False; |
2288 | Firstsov = First; |
2289 | if(Guide.IsPeriodic()) { |
2290 | complete = Standard_False; |
2291 | wf = Guide.FirstParameter(); |
2292 | wl = Guide.LastParameter(); |
2293 | } |
2294 | } |
2295 | if(forward){ |
2296 | fini = ((wl - Last) <= 10.*tolesp || |
81bba717 |
2297 | (intl && !(obstacleon1 || obstacleon2))); //General case |
7fd59977 |
2298 | |
2299 | if (!fini && Guide.IsPeriodic() && |
2300 | ((wl - Last)< Guide.Period()*1.e-3)) { |
81bba717 |
2301 | // It is tested if reframing of extremes is done at the same edge |
2302 | // Loop Condition |
7fd59977 |
2303 | Handle(ChFiDS_SurfData) thefirst, thelast; |
2304 | thefirst = Stripe->SetOfSurfData()->Sequence().First(); |
2305 | thelast = Stripe->SetOfSurfData()->Sequence().Last(); |
2306 | |
2307 | if (thefirst->VertexFirstOnS1().IsOnArc() && |
2308 | thelast->VertexLastOnS1().IsOnArc()) |
2309 | fini = thefirst->VertexFirstOnS1().Arc().IsSame |
2310 | (thelast->VertexLastOnS1().Arc()); |
2311 | if (!fini && |
2312 | thefirst->VertexFirstOnS2().IsOnArc() && |
2313 | thelast->VertexLastOnS2().IsOnArc()) |
2314 | fini = thefirst->VertexFirstOnS2().Arc().IsSame |
2315 | (thelast->VertexLastOnS2().Arc()); |
2316 | |
2317 | if (fini) |
81bba717 |
2318 | return; //It is ended! |
7fd59977 |
2319 | } |
2320 | |
2321 | if(fini && complete) { |
81bba717 |
2322 | // restart in the opposite direction. |
7fd59977 |
2323 | ref = Stripe->SetOfSurfData()->Sequence().First(); |
2324 | forward = Standard_False; |
2325 | fini = Standard_False; |
2326 | First = Firstsov; |
2327 | } |
2328 | else { |
2329 | First = Last; |
2330 | Last = wl; |
2331 | } |
2332 | } |
2333 | if(!forward){ |
2334 | fini = ((First - wf) <= 10.*tolesp || |
2335 | (intf && !(obstacleon1 || obstacleon2))); |
2336 | complete = Standard_False; |
2337 | Last = wf; |
2338 | } |
2339 | } |
81bba717 |
2340 | // The initial state is restored |
7fd59977 |
2341 | if(!Guide.IsPeriodic()){ |
2342 | Guide.FirstParameter(wfsav); |
2343 | Guide.LastParameter (wlsav); |
1d54b807 |
2344 | if (!OffsetHGuide.IsNull()) |
2345 | { |
2346 | OffsetHGuide->ChangeCurve().FirstParameter(wfsav); |
2347 | OffsetHGuide->ChangeCurve().LastParameter (wlsav); |
2348 | } |
7fd59977 |
2349 | } |
2350 | |
2351 | } |
2352 | |
2353 | //======================================================================= |
2354 | //function : PerformSetOfKPart |
2355 | //purpose : |
2356 | //======================================================================= |
2357 | |
2358 | void ChFi3d_Builder::PerformSetOfKPart(Handle(ChFiDS_Stripe)& Stripe, |
2359 | const Standard_Boolean Simul) |
2360 | { |
2361 | TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); |
2362 | Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine(); |
2363 | Handle(BRepAdaptor_HSurface) HS1,HS2; |
2364 | TopAbs_Orientation Or1,Or2,RefOr1,RefOr2; |
96a95605 |
2365 | Standard_Integer RefChoix; |
7fd59977 |
2366 | |
81bba717 |
2367 | // initialization of the stripe. |
7fd59977 |
2368 | Stripe->Reset(); |
2369 | Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData(); |
2370 | HData = new ChFiDS_HData(); |
2371 | ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence(); |
2372 | |
2373 | StripeOrientations(Spine,RefOr1,RefOr2,RefChoix); |
2374 | Stripe->OrientationOnFace1(RefOr1); |
2375 | Stripe->OrientationOnFace2(RefOr2); |
2376 | Stripe->Choix(RefChoix); |
2377 | |
2378 | Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool(); |
2379 | Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool(); |
2380 | |
2381 | Standard_Real WFirst,WLast = 0.; |
2382 | gp_Vec TFirst,TLast,TEndPeriodic; |
2383 | gp_Pnt PFirst,PLast,PEndPeriodic; |
dde68833 |
2384 | Standard_Boolean intf = Standard_False, intl = Standard_False; |
7fd59977 |
2385 | |
1d54b807 |
2386 | ChFiDS_ElSpine anElSpine, anOffsetElSpine; |
2387 | Handle(ChFiDS_HElSpine) CurrentHE = new ChFiDS_HElSpine(anElSpine); |
2388 | Handle(ChFiDS_HElSpine) CurrentOffsetHE = new ChFiDS_HElSpine(anOffsetElSpine); |
7fd59977 |
2389 | Spine->D1(Spine->FirstParameter(),PFirst,TFirst); |
2390 | CurrentHE->ChangeCurve().FirstParameter(Spine->FirstParameter()); |
2391 | CurrentHE->ChangeCurve().SetFirstPointAndTgt(PFirst,TFirst); |
1d54b807 |
2392 | CurrentOffsetHE->ChangeCurve().FirstParameter(Spine->FirstParameter()); |
2393 | CurrentOffsetHE->ChangeCurve().SetFirstPointAndTgt(PFirst,TFirst); |
7fd59977 |
2394 | |
2395 | Standard_Boolean YaKPart = Standard_False; |
2396 | Standard_Integer iedgelastkpart = 0; |
2397 | |
2398 | Standard_Real WStartPeriodic = 0.; |
2399 | Standard_Real WEndPeriodic = Spine->LastParameter(Spine->NbEdges()); |
2400 | Spine->D1(WEndPeriodic,PEndPeriodic,TEndPeriodic); |
2401 | |
81bba717 |
2402 | // Construction of particular cases. |
7fd59977 |
2403 | |
2404 | for (Standard_Integer iedge = 1; iedge <= Spine->NbEdges(); iedge++){ |
2405 | |
1d54b807 |
2406 | ConexFaces(Spine,iedge,HS1,HS2); |
7fd59977 |
2407 | |
2408 | if (ChFi3d_KParticular(Spine,iedge,HS1->ChangeSurface(),HS2->ChangeSurface())) { |
2409 | intf = ((iedge == 1) && !Spine->IsPeriodic()); |
2410 | intl = ((iedge == Spine->NbEdges()) && !Spine->IsPeriodic()); |
2411 | Or1 = HS1->ChangeSurface().Face().Orientation(); |
2412 | Or2 = HS2->ChangeSurface().Face().Orientation(); |
96a95605 |
2413 | ChFi3d::NextSide(Or1,Or2,RefOr1,RefOr2,RefChoix); |
543a9964 |
2414 | const Handle(Adaptor3d_HSurface)& HSon1 = HS1; // to avoid ambiguity |
2415 | const Handle(Adaptor3d_HSurface)& HSon2 = HS2; // to avoid ambiguity |
2416 | It1->Initialize(HSon1); |
2417 | It2->Initialize(HSon2); |
7fd59977 |
2418 | |
2419 | Handle(ChFiDS_SurfData) SD = new ChFiDS_SurfData(); |
2420 | ChFiDS_SequenceOfSurfData LSD; |
2421 | |
2422 | if(!ChFiKPart_ComputeData::Compute(DStr,SD,HS1,HS2,Or1,Or2,Spine,iedge)){ |
0797d9d3 |
2423 | #ifdef OCCT_DEBUG |
04232180 |
2424 | std::cout<<"failed calculation KPart"<<std::endl; |
7fd59977 |
2425 | #endif |
2426 | } |
2427 | else if(!SplitKPart(SD,LSD,Spine,iedge,HS1,It1,HS2,It2,intf,intl)){ |
0797d9d3 |
2428 | #ifdef OCCT_DEBUG |
04232180 |
2429 | std::cout<<"failed calculation KPart"<<std::endl; |
7fd59977 |
2430 | #endif |
2431 | LSD.Clear(); |
2432 | } |
2433 | else iedgelastkpart = iedge; |
81bba717 |
2434 | if(Spine->IsPeriodic()){//debug provisory for SD that arrive in desorder. |
7fd59977 |
2435 | Standard_Integer nbsd = LSD.Length(); |
2436 | Standard_Real period = Spine->Period(); |
2437 | Standard_Real wfp = WStartPeriodic, wlp = WEndPeriodic; |
2438 | // modified by NIZHNY-EAP Thu Nov 25 12:57:53 1999 ___BEGIN___ |
2439 | if(!YaKPart && nbsd>0){ |
2440 | // if(!YaKPart){ |
2441 | // modified by NIZHNY-EAP Thu Nov 25 12:57:57 1999 ___END___ |
2442 | Handle(ChFiDS_SurfData) firstSD = LSD.ChangeValue(1); |
2443 | Standard_Real wwf = firstSD->FirstSpineParam(); |
2444 | Standard_Real wwl = firstSD->LastSpineParam(); |
2445 | wwf = ChFi3d_InPeriod(wwf,wfp,wlp,tolesp); |
2446 | wwl = ChFi3d_InPeriod(wwl,wfp,wlp,tolesp); |
2447 | if (wwl <= wwf + tolesp) wwl += period; |
2448 | wfp = wwf; |
2449 | wlp = wfp + period; |
2450 | } |
2451 | for(Standard_Integer j = 1; j < nbsd; j++){ |
2452 | Handle(ChFiDS_SurfData) jSD = LSD.Value(j); |
2453 | for(Standard_Integer k = j+1; k <= nbsd; k++){ |
2454 | Handle(ChFiDS_SurfData) kSD = LSD.Value(k); |
2455 | Standard_Real jwf = jSD->FirstSpineParam(); |
2456 | jwf = ChFi3d_InPeriod(jwf,wfp,wlp,tolesp); |
2457 | Standard_Real kwf = kSD->FirstSpineParam(); |
2458 | kwf = ChFi3d_InPeriod(kwf,wfp,wlp,tolesp); |
2459 | if(kwf < jwf){ |
2460 | LSD.SetValue(j,kSD); |
2461 | LSD.SetValue(k,jSD); |
2462 | } |
2463 | } |
2464 | } |
2465 | } |
2466 | TColStd_ListOfInteger li; |
2467 | for(Standard_Integer j = 1; j <= LSD.Length(); j++){ |
2468 | Handle(ChFiDS_SurfData)& curSD = LSD.ChangeValue(j); |
2469 | if(Simul) SimulKPart(curSD); |
2470 | SeqSurf.Append(curSD); |
2471 | if(!Simul) li.Append(curSD->Surf()); |
2472 | WFirst = LSD.Value(j)->FirstSpineParam(); |
2473 | WLast = LSD.Value(j)->LastSpineParam(); |
2474 | if(Spine->IsPeriodic()){ |
2475 | WFirst = ChFi3d_InPeriod(WFirst,WStartPeriodic,WEndPeriodic,tolesp); |
2476 | WLast = ChFi3d_InPeriod(WLast ,WStartPeriodic,WEndPeriodic,tolesp); |
2477 | if (WLast <= WFirst + tolesp) WLast+= Spine->Period(); |
2478 | } |
2479 | TgtKP(LSD.Value(j),Spine,iedge,1,PFirst,TFirst); |
2480 | TgtKP(LSD.Value(j),Spine,iedge,0,PLast,TLast); |
2481 | |
81bba717 |
2482 | // Determine the sections to approximate |
7fd59977 |
2483 | if(!YaKPart){ |
2484 | if(Spine->IsPeriodic()){ |
2485 | WStartPeriodic = WFirst; |
2486 | WEndPeriodic = WStartPeriodic + Spine->Period(); |
2487 | WLast = ElCLib::InPeriod(WLast,WStartPeriodic,WEndPeriodic); |
2488 | if (WLast <= WFirst + tolesp) WLast+= Spine->Period(); |
2489 | PEndPeriodic = PFirst; |
2490 | TEndPeriodic = TFirst; |
2491 | Spine->SetFirstParameter(WStartPeriodic); |
2492 | Spine->SetLastParameter(WEndPeriodic); |
2493 | } |
2494 | else if(!intf || (iedge > 1)){ |
81bba717 |
2495 | // start section -> first KPart |
2496 | // update of extension. |
7fd59977 |
2497 | Spine->SetFirstTgt(Min(0.,WFirst)); |
2498 | CurrentHE->ChangeCurve().LastParameter (WFirst); |
2499 | CurrentHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst); |
2500 | Spine->AppendElSpine(CurrentHE); |
2501 | CurrentHE->ChangeCurve().ChangeNext() = LSD.Value(j); |
2502 | CurrentHE = new ChFiDS_HElSpine(); |
1d54b807 |
2503 | |
2504 | CurrentOffsetHE->ChangeCurve().LastParameter (WFirst); |
2505 | CurrentOffsetHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst); |
2506 | Spine->AppendOffsetElSpine(CurrentOffsetHE); |
2507 | CurrentOffsetHE->ChangeCurve().ChangeNext() = LSD.Value(j); |
2508 | CurrentOffsetHE = new ChFiDS_HElSpine(); |
7fd59977 |
2509 | } |
2510 | CurrentHE->ChangeCurve().FirstParameter(WLast); |
2511 | CurrentHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast); |
2512 | CurrentHE->ChangeCurve().ChangePrevious() = LSD.Value(j); |
1d54b807 |
2513 | CurrentOffsetHE->ChangeCurve().FirstParameter(WLast); |
2514 | CurrentOffsetHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast); |
2515 | CurrentOffsetHE->ChangeCurve().ChangePrevious() = LSD.Value(j); |
7fd59977 |
2516 | YaKPart = Standard_True; |
2517 | } |
2518 | else { |
2519 | if (WFirst - CurrentHE->FirstParameter() > tolesp) { |
81bba717 |
2520 | // section between two KPart |
7fd59977 |
2521 | CurrentHE->ChangeCurve().LastParameter(WFirst); |
2522 | CurrentHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst); |
2523 | Spine->AppendElSpine(CurrentHE); |
2524 | CurrentHE->ChangeCurve().ChangeNext() = LSD.Value(j); |
2525 | CurrentHE = new ChFiDS_HElSpine(); |
1d54b807 |
2526 | |
2527 | CurrentOffsetHE->ChangeCurve().LastParameter(WFirst); |
2528 | CurrentOffsetHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst); |
2529 | Spine->AppendOffsetElSpine(CurrentOffsetHE); |
2530 | CurrentOffsetHE->ChangeCurve().ChangeNext() = LSD.Value(j); |
2531 | CurrentOffsetHE = new ChFiDS_HElSpine(); |
7fd59977 |
2532 | } |
2533 | CurrentHE->ChangeCurve().FirstParameter(WLast); |
2534 | CurrentHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast); |
2535 | CurrentHE->ChangeCurve().ChangePrevious() = LSD.Value(j); |
1d54b807 |
2536 | CurrentOffsetHE->ChangeCurve().FirstParameter(WLast); |
2537 | CurrentOffsetHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast); |
2538 | CurrentOffsetHE->ChangeCurve().ChangePrevious() = LSD.Value(j); |
7fd59977 |
2539 | } |
2540 | } |
2541 | if(!li.IsEmpty()) myEVIMap.Bind(Spine->Edges(iedge),li); |
2542 | } |
2543 | } |
2544 | |
2545 | if (!intl || (iedgelastkpart < Spine->NbEdges())) { |
81bba717 |
2546 | // section last KPart(or start of the spine) -> End of the spine. |
2547 | // update of the extension. |
7fd59977 |
2548 | |
2549 | if(Spine->IsPeriodic()){ |
2550 | if(WEndPeriodic - WLast > tolesp){ |
2551 | CurrentHE->ChangeCurve().LastParameter(WEndPeriodic); |
2552 | CurrentHE->ChangeCurve().SetLastPointAndTgt(PEndPeriodic,TEndPeriodic); |
2553 | if(!YaKPart) CurrentHE->ChangeCurve().SetPeriodic(Standard_True); |
2554 | Spine->AppendElSpine(CurrentHE); |
1d54b807 |
2555 | |
2556 | CurrentOffsetHE->ChangeCurve().LastParameter(WEndPeriodic); |
2557 | CurrentOffsetHE->ChangeCurve().SetLastPointAndTgt(PEndPeriodic,TEndPeriodic); |
2558 | if(!YaKPart) CurrentOffsetHE->ChangeCurve().SetPeriodic(Standard_True); |
2559 | Spine->AppendOffsetElSpine(CurrentOffsetHE); |
7fd59977 |
2560 | } |
2561 | } |
2562 | else{ |
2563 | Spine->D1(Spine->LastParameter(),PLast,TLast); |
2564 | Spine->SetLastTgt(Max(Spine->LastParameter(Spine->NbEdges()), |
2565 | WLast)); |
2566 | if (Spine->LastParameter() - WLast > tolesp) { |
2567 | CurrentHE->ChangeCurve().LastParameter(Spine->LastParameter()); |
2568 | CurrentHE->ChangeCurve().SetLastPointAndTgt(PLast,TLast); |
2569 | Spine->AppendElSpine(CurrentHE); |
1d54b807 |
2570 | |
2571 | CurrentOffsetHE->ChangeCurve().LastParameter(Spine->LastParameter()); |
2572 | CurrentOffsetHE->ChangeCurve().SetLastPointAndTgt(PLast,TLast); |
2573 | Spine->AppendOffsetElSpine(CurrentOffsetHE); |
7fd59977 |
2574 | } |
2575 | } |
2576 | } |
2577 | |
2578 | ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines(); |
2579 | ChFiDS_ListIteratorOfListOfHElSpine ILES(ll); |
2580 | for ( ; ILES.More(); ILES.Next()) { |
0797d9d3 |
2581 | #ifdef OCCT_DEBUG |
7fd59977 |
2582 | if(ChFi3d_GettraceCHRON()) elspine.Start(); |
2583 | #endif |
2584 | ChFi3d_PerformElSpine(ILES.Value(),Spine,myConti,tolesp); |
0797d9d3 |
2585 | #ifdef OCCT_DEBUG |
7fd59977 |
2586 | if(ChFi3d_GettraceCHRON()) { elspine.Stop(); } |
2587 | #endif |
2588 | } |
1d54b807 |
2589 | if (Spine->Mode() == ChFiDS_ConstThroatWithPenetrationChamfer) |
2590 | { |
2591 | ChFiDS_ListOfHElSpine& offsetll = Spine->ChangeOffsetElSpines(); |
2592 | for (ILES.Initialize(offsetll); ILES.More(); ILES.Next()) |
2593 | ChFi3d_PerformElSpine(ILES.Value(),Spine,myConti,tolesp,Standard_True); |
2594 | } |
7fd59977 |
2595 | Spine->SplitDone(Standard_True); |
2596 | } |
2597 | |
2598 | static Standard_Real ChFi3d_BoxDiag(const Bnd_Box& box) |
2599 | { |
2600 | Standard_Real a,b,c,d,e,f; |
2601 | box.Get(a,b,c,d,e,f); |
2602 | d-=a; e-=b; f-=c; |
2603 | d*=d; e*=e; f*=f; |
2604 | Standard_Real diag = sqrt(d + e + f); |
2605 | return diag; |
2606 | } |
2607 | |
2608 | //======================================================================= |
2609 | //function : PerformSetOfKGen |
2610 | //purpose : |
2611 | //======================================================================= |
2612 | |
2613 | void ChFi3d_Builder::PerformSetOfKGen(Handle(ChFiDS_Stripe)& Stripe, |
2614 | const Standard_Boolean Simul) |
2615 | { |
2616 | Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool(); |
2617 | Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool(); |
2618 | Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine(); |
2619 | ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines(); |
2620 | ChFiDS_ListIteratorOfListOfHElSpine ILES(ll); |
2621 | for ( ; ILES.More(); ILES.Next()) { |
0797d9d3 |
2622 | #ifdef OCCT_DEBUG |
7fd59977 |
2623 | if(ChFi3d_GettraceCHRON()) { chemine.Start(); } |
2624 | #endif |
2625 | PerformSetOfSurfOnElSpine(ILES.Value(),Stripe,It1,It2,Simul); |
0797d9d3 |
2626 | #ifdef OCCT_DEBUG |
7fd59977 |
2627 | if(ChFi3d_GettraceCHRON()) chemine.Stop(); |
2628 | #endif |
2629 | } |
2630 | if(!Simul){ |
2631 | TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); |
2632 | Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData(); |
2633 | ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence(); |
2634 | Standard_Integer len = SeqSurf.Length(); |
2635 | Standard_Integer last = len, i; |
2636 | Standard_Boolean periodic = Spine->IsPeriodic(); |
2637 | if(periodic) last++; |
81bba717 |
2638 | // It is attempted to reprocess the squares that bore. |
7fd59977 |
2639 | for(i = 1; i <= len; i++){ |
2640 | Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i); |
2641 | Standard_Boolean tw1 = cursd->TwistOnS1(); |
2642 | Standard_Boolean tw2 = cursd->TwistOnS2(); |
2643 | Handle(ChFiDS_SurfData) prevsd, nextsd; |
2644 | Standard_Integer iprev = i-1; |
2645 | if(iprev == 0) { |
2646 | if(periodic) iprev = len; |
2647 | } |
2648 | Standard_Integer inext = i + 1; |
2649 | if(inext > len) { |
2650 | if(periodic) inext = 1; |
2651 | else inext = 0; |
2652 | } |
2653 | |
81bba717 |
2654 | // For the moment only the surfaces where the twist is |
2655 | // detected at the path are corrected, it is necessary to control |
2656 | // more subtly the ugly traces (size, curvature, inflexion... ) |
7fd59977 |
2657 | if(!tw1 && !tw2) continue; |
2658 | |
81bba717 |
2659 | // It is decided (fairly at random) if the extended surface is ready for the filling. |
7fd59977 |
2660 | ChFiDS_FaceInterference& intf1 = cursd->ChangeInterferenceOnS1(); |
2661 | ChFiDS_FaceInterference& intf2 = cursd->ChangeInterferenceOnS2(); |
2662 | Standard_Integer cursurf1 = cursd->IndexOfS1(); |
2663 | Standard_Integer cursurf2 = cursd->IndexOfS2(); |
2664 | ChFiDS_CommonPoint& cpd1 = cursd->ChangeVertexFirstOnS1(); |
2665 | ChFiDS_CommonPoint& cpd2 = cursd->ChangeVertexFirstOnS2(); |
2666 | ChFiDS_CommonPoint& cpf1 = cursd->ChangeVertexLastOnS1(); |
2667 | ChFiDS_CommonPoint& cpf2 = cursd->ChangeVertexLastOnS2(); |
2668 | const gp_Pnt& pd1 = cpd1.Point(); |
2669 | const gp_Pnt& pd2 = cpd2.Point(); |
2670 | const gp_Pnt& pf1 = cpf1.Point(); |
2671 | const gp_Pnt& pf2 = cpf2.Point(); |
2672 | Standard_Real ddeb = pd1.Distance(pd2); |
2673 | Standard_Real dfin = pf1.Distance(pf2); |
2674 | Standard_Real don1 = pd1.Distance(pf1); |
2675 | Standard_Real don2 = pd2.Distance(pf2); |
2676 | Standard_Boolean possibleon1 = (don1 < 2*(ddeb + dfin)); |
2677 | Standard_Boolean possibleon2 = (don2 < 2*(ddeb + dfin)); |
2678 | if((tw1 && !possibleon1) || (tw2 && !possibleon2)) { |
2679 | Spine->SetErrorStatus(ChFiDS_TwistedSurface); |
9775fa61 |
2680 | throw Standard_Failure("adjustment by reprocessing the non-written points"); |
7fd59977 |
2681 | } |
2682 | |
81bba717 |
2683 | // It is checked if there are presentable neighbors |
7fd59977 |
2684 | Standard_Boolean yaprevon1 = 0, yaprevon2 = 0; |
2685 | Standard_Boolean samesurfon1 = 0, samesurfon2 = 0; |
2686 | if(iprev){ |
2687 | prevsd = SeqSurf.ChangeValue(iprev); |
2688 | yaprevon1 = !prevsd->TwistOnS1(); |
2689 | samesurfon1 = (prevsd->IndexOfS1() == cursurf1); |
2690 | yaprevon2 = !prevsd->TwistOnS2(); |
2691 | samesurfon2 = (prevsd->IndexOfS2() == cursurf2); |
2692 | } |
2693 | Standard_Boolean yanexton1 = 0, yanexton2 = 0; |
2694 | if(inext){ |
2695 | nextsd = SeqSurf.ChangeValue(inext); |
2696 | yanexton1 = !nextsd->TwistOnS1(); |
2697 | if(samesurfon1) samesurfon1 = (nextsd->IndexOfS1() == cursurf1); |
2698 | yanexton2 = !nextsd->TwistOnS2(); |
2699 | if(samesurfon2) samesurfon2 = (nextsd->IndexOfS2() == cursurf2); |
2700 | } |
81bba717 |
2701 | // A contour of filling is constructed |
7fd59977 |
2702 | Handle(Geom2d_Curve) PC1 = intf1.PCurveOnFace(); |
2703 | Handle(Geom2d_Curve) PC2 = intf2.PCurveOnFace(); |
2704 | Handle(BRepAdaptor_HSurface) S1 = new BRepAdaptor_HSurface(); |
2705 | TopoDS_Face F1 = TopoDS::Face(DStr.Shape(cursurf1)); |
2706 | S1->ChangeSurface().Initialize(F1); |
2707 | Handle(BRepAdaptor_HSurface) S2 = new BRepAdaptor_HSurface(); |
2708 | TopoDS_Face F2 = TopoDS::Face(DStr.Shape(cursurf2)); |
2709 | S2->ChangeSurface().Initialize(F2); |
2710 | Handle(GeomFill_Boundary) Bdeb,Bfin,Bon1,Bon2; |
2711 | Standard_Boolean pointuon1 = 0, pointuon2 = 0; |
2712 | if(tw1){ |
2713 | if(!yaprevon1 || !yanexton1){ |
2714 | Spine->SetErrorStatus(ChFiDS_TwistedSurface); |
9775fa61 |
2715 | throw Standard_Failure("adjustment by reprocessing the non-written points: no neighbor"); |
7fd59977 |
2716 | } |
2717 | ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1(); |
2718 | ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1(); |
2719 | Standard_Real prevpar1 = previntf1.LastParameter(); |
2720 | Standard_Real nextpar1 = nextintf1.FirstParameter(); |
2721 | if(samesurfon1){ |
81bba717 |
2722 | // It is checked if it is possible to intersect traces of neighbors |
2723 | // to create a sharp end. |
7fd59977 |
2724 | Handle(Geom2d_Curve) pcprev1 = previntf1.PCurveOnFace(); |
2725 | Handle(Geom2d_Curve) pcnext1 = nextintf1.PCurveOnFace(); |
2726 | Standard_Real nprevpar1,nnextpar1; |
2727 | gp_Pnt2d p2d; |
2728 | // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin |
2729 | // if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1, |
2730 | // nextsd,nextpar1,nnextpar1,1,-1,p2d)){ |
2731 | if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1, |
2732 | nextsd,nextpar1,nnextpar1,1,-1,p2d, |
2733 | Standard_False, Standard_True)){ |
2734 | // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End |
2735 | previntf1.SetLastParameter(nprevpar1); |
2736 | nextintf1.SetFirstParameter(nnextpar1); |
2737 | pointuon1 = 1; |
2738 | PC1.Nullify(); |
2739 | } |
2740 | else{ |
2741 | gp_Pnt2d pdeb1,pfin1; |
2742 | gp_Vec2d vdeb1,vfin1; |
2743 | pcprev1->D1(prevpar1,pdeb1,vdeb1); |
2744 | pcnext1->D1(nextpar1,pfin1,vfin1); |
2745 | Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,vdeb1,1, |
2746 | pfin1,vfin1,tolesp,2.e-4); |
2747 | } |
2748 | } |
2749 | else{ |
81bba717 |
2750 | //here the base is on 3D tangents of neighbors. |
7fd59977 |
2751 | const Handle(Geom_Curve)& c3dprev1 = |
2752 | DStr.Curve(previntf1.LineIndex()).Curve(); |
2753 | const Handle(Geom_Curve)& c3dnext1 = |
2754 | DStr.Curve(nextintf1.LineIndex()).Curve(); |
2755 | gp_Pnt Pdeb1, Pfin1; |
2756 | gp_Vec Vdeb1, Vfin1; |
2757 | c3dprev1->D1(prevpar1,Pdeb1,Vdeb1); |
2758 | c3dnext1->D1(nextpar1,Pfin1,Vfin1); |
2759 | gp_Pnt2d pdeb1,pfin1; |
2760 | Standard_Real pardeb1 = intf1.FirstParameter(); |
2761 | Standard_Real parfin1 = intf1.LastParameter(); |
2762 | pdeb1 = PC1->Value(pardeb1); |
2763 | pfin1 = PC1->Value(parfin1); |
2764 | Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,Vdeb1,1, |
2765 | pfin1,Vfin1,tolesp,2.e-4); |
2766 | } |
2767 | } |
2768 | else{ |
2769 | Bon1 = ChFi3d_mkbound(S1,PC1,tolesp,2.e-4); |
2770 | } |
2771 | if(tw2){ |
2772 | if(!yaprevon2 || !yanexton2){ |
9775fa61 |
2773 | throw Standard_Failure("adjustment by reprocessing the non-written points: no neighbor"); |
7fd59977 |
2774 | } |
2775 | ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2(); |
2776 | ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2(); |
2777 | Standard_Real prevpar2 = previntf2.LastParameter(); |
2778 | Standard_Real nextpar2 = nextintf2.FirstParameter(); |
2779 | if(samesurfon2){ |
81bba717 |
2780 | // It is checked if it is possible to intersect traces of neighbors |
2781 | // to create a sharp end. |
7fd59977 |
2782 | Handle(Geom2d_Curve) pcprev2 = previntf2.PCurveOnFace(); |
2783 | Handle(Geom2d_Curve) pcnext2 = nextintf2.PCurveOnFace(); |
2784 | Standard_Real nprevpar2,nnextpar2; |
2785 | gp_Pnt2d p2d; |
2786 | // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin |
2787 | // if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1, |
2788 | // nextsd,nextpar2,nnextpar2,2,-1,p2d)){ |
2789 | if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1, |
2790 | nextsd,nextpar2,nnextpar2,2,-1,p2d, |
2791 | Standard_False, Standard_True)){ |
2792 | // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End |
2793 | previntf2.SetLastParameter(nprevpar2); |
2794 | nextintf2.SetFirstParameter(nnextpar2); |
2795 | pointuon2 = 1; |
2796 | PC2.Nullify(); |
2797 | } |
2798 | else{ |
2799 | gp_Pnt2d pdeb2,pfin2; |
2800 | gp_Vec2d vdeb2,vfin2; |
2801 | pcprev2->D1(prevpar2,pdeb2,vdeb2); |
2802 | pcnext2->D1(nextpar2,pfin2,vfin2); |
2803 | Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,vdeb2,1, |
2804 | pfin2,vfin2,tolesp,2.e-4); |
2805 | } |
2806 | } |
2807 | else{ |
81bba717 |
2808 | //here the base is on 3D tangents of neighbors. |
7fd59977 |
2809 | const Handle(Geom_Curve)& c3dprev2 = |
2810 | DStr.Curve(previntf2.LineIndex()).Curve(); |
2811 | const Handle(Geom_Curve)& c3dnext2 = |
2812 | DStr.Curve(nextintf2.LineIndex()).Curve(); |
2813 | gp_Pnt Pdeb2, Pfin2; |
2814 | gp_Vec Vdeb2, Vfin2; |
2815 | c3dprev2->D1(prevpar2,Pdeb2,Vdeb2); |
2816 | c3dnext2->D1(nextpar2,Pfin2,Vfin2); |
2817 | gp_Pnt2d pdeb2,pfin2; |
2818 | Standard_Real pardeb2 = intf2.FirstParameter(); |
2819 | Standard_Real parfin2 = intf2.LastParameter(); |
2820 | pdeb2 = PC2->Value(pardeb2); |
2821 | pfin2 = PC2->Value(parfin2); |
2822 | Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,Vdeb2,1, |
2823 | pfin2,Vfin2,tolesp,2.e-4); |
2824 | } |
2825 | } |
2826 | else{ |
2827 | Bon2 = ChFi3d_mkbound(S2,PC2,tolesp,2.e-4); |
2828 | } |
81bba717 |
2829 | // The parameters of neighbor traces are updated, so |
2830 | // straight lines uv are pulled. |
7fd59977 |
2831 | const Handle(Geom_Surface)& |
2832 | sprev = DStr.Surface(prevsd->Surf()).Surface(); |
2833 | const Handle(Geom_Surface)& |
2834 | snext = DStr.Surface(nextsd->Surf()).Surface(); |
2835 | ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1(); |
2836 | ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1(); |
2837 | ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2(); |
2838 | ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2(); |
2839 | Handle(Geom2d_Curve) pcsprev1 = previntf1.PCurveOnSurf(); |
2840 | Handle(Geom2d_Curve) pcsnext1 = nextintf1.PCurveOnSurf(); |
2841 | Standard_Real prevpar1 = previntf1.LastParameter(); |
2842 | Standard_Real nextpar1 = nextintf1.FirstParameter(); |
2843 | Handle(Geom2d_Curve) pcsprev2 = previntf2.PCurveOnSurf(); |
2844 | Handle(Geom2d_Curve) pcsnext2 = nextintf2.PCurveOnSurf(); |
2845 | Standard_Real prevpar2 = previntf2.LastParameter(); |
2846 | Standard_Real nextpar2 = nextintf2.FirstParameter(); |
2847 | gp_Pnt2d pdebs1 = pcsprev1->Value(prevpar1); |
2848 | gp_Pnt2d pdebs2 = pcsprev2->Value(prevpar2); |
2849 | gp_Pnt2d pfins1 = pcsnext1->Value(nextpar1); |
2850 | gp_Pnt2d pfins2 = pcsnext2->Value(nextpar2); |
2851 | Bdeb = ChFi3d_mkbound(sprev,pdebs1,pdebs2,tolesp,2.e-4); |
2852 | Bfin = ChFi3d_mkbound(snext,pfins1,pfins2,tolesp,2.e-4); |
2853 | |
2854 | GeomFill_ConstrainedFilling fil(11,20); |
2855 | if(pointuon1) fil.Init(Bon2,Bfin,Bdeb,1); |
2856 | else if(pointuon2) fil.Init(Bon1,Bfin,Bdeb,1); |
2857 | else fil.Init(Bon1,Bfin,Bon2,Bdeb,1); |
2858 | |
2859 | ChFi3d_ReparamPcurv(0.,1.,PC1); |
2860 | ChFi3d_ReparamPcurv(0.,1.,PC2); |
2861 | Handle(Geom_Surface) newsurf = fil.Surface(); |
0797d9d3 |
2862 | #ifdef OCCT_DEBUG |
7fd59977 |
2863 | #ifdef DRAW |
81bba717 |
2864 | //POP for NT |
7fd59977 |
2865 | char* pops = "newsurf"; |
2866 | DrawTrSurf::Set(pops,newsurf); |
2867 | #endif |
2868 | #endif |
2869 | if(pointuon1) { |
81bba717 |
2870 | newsurf->VReverse(); // we return to direction 1 from 2; |
7fd59977 |
2871 | done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2, |
2872 | F2.Orientation(),0,0,0,0,0); |
2873 | cursd->ChangeIndexOfS1(0); |
2874 | } |
2875 | else{ |
2876 | done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2, |
2877 | F1.Orientation(),1,0,0,0,0); |
2878 | if(pointuon2) cursd->ChangeIndexOfS2(0); |
2879 | } |
2880 | if(tw1){ |
2881 | prevsd->ChangeVertexLastOnS1().SetPoint(cpd1.Point()); |
2882 | nextsd->ChangeVertexFirstOnS1().SetPoint(cpf1.Point()); |
2883 | } |
2884 | if(tw2){ |
2885 | prevsd->ChangeVertexLastOnS2().SetPoint(cpd2.Point()); |
2886 | nextsd->ChangeVertexFirstOnS2().SetPoint(cpf2.Point()); |
2887 | } |
2888 | } |
81bba717 |
2889 | // The tolerance of points is updated. |
7fd59977 |
2890 | for(i = 1; i < last; i++){ |
2891 | Standard_Integer j = i%len + 1; |
2892 | Standard_Integer curs1, curs2; |
2893 | Standard_Integer nexts1, nexts2; |
2894 | Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i); |
2895 | Handle(ChFiDS_SurfData)& nextsd = SeqSurf.ChangeValue(j); |
2896 | ChFiDS_CommonPoint& curp1 = cursd->ChangeVertexLastOnS1(); |
2897 | ChFiDS_CommonPoint& nextp1 = nextsd->ChangeVertexFirstOnS1(); |
2898 | if (cursd->IsOnCurve1()) curs1 = cursd->IndexOfC1(); |
2899 | else curs1 = cursd->IndexOfS1(); |
2900 | if (cursd->IsOnCurve2()) curs2 = cursd->IndexOfC2(); |
2901 | else curs2 = cursd->IndexOfS2(); |
2902 | Standard_Real tol1 = Max(curp1.Tolerance(),nextp1.Tolerance()); |
2903 | ChFiDS_CommonPoint& curp2 = cursd->ChangeVertexLastOnS2(); |
2904 | ChFiDS_CommonPoint& nextp2 = nextsd->ChangeVertexFirstOnS2(); |
2905 | Standard_Real tol2 = Max(curp2.Tolerance(),nextp2.Tolerance()); |
2906 | if (nextsd->IsOnCurve1()) nexts1 = nextsd->IndexOfC1(); |
2907 | else nexts1 = nextsd->IndexOfS1(); |
2908 | if (nextsd->IsOnCurve2()) nexts2 = nextsd->IndexOfC2(); |
2909 | else nexts2 = nextsd->IndexOfS2(); |
2910 | |
2911 | if(!curp1.IsOnArc() && nextp1.IsOnArc()){ |
2912 | curp1 = nextp1; |
2913 | if ( (curs1 == nexts1) && !nextsd->IsOnCurve1()) |
81bba717 |
2914 | // Case when it is not possible to pass along the border without leaving |
7fd59977 |
2915 | ChangeTransition(nextp1, curp1, nexts1, myDS); |
2916 | } |
2917 | else if(curp1.IsOnArc() && !nextp1.IsOnArc()) { |
2918 | nextp1 = curp1; |
2919 | if ( (curs1 == nexts1) && !cursd->IsOnCurve1()) |
2920 | ChangeTransition(curp1, nextp1, curs1, myDS); |
2921 | } |
2922 | |
2923 | if(!curp2.IsOnArc() && nextp2.IsOnArc()) { |
2924 | curp2 = nextp2; |
2925 | if ( (curs2 == nexts2) && !nextsd->IsOnCurve2()) |
2926 | ChangeTransition(nextp2, curp2, curs2, myDS); |
2927 | } |
2928 | else if(curp2.IsOnArc() && !nextp2.IsOnArc()){ |
2929 | nextp2 = curp2; |
2930 | if ( (curs2 == nexts2) && !cursd->IsOnCurve2()) |
2931 | ChangeTransition(curp2, nextp2, curs2, myDS); |
2932 | } |
2933 | |
2934 | curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1); |
2935 | curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2); |
2936 | |
2937 | Bnd_Box b1,b2; |
2938 | if(curp1.IsOnArc()){ |
2939 | ChFi3d_EnlargeBox(curp1.Arc(),myEFMap(curp1.Arc()),curp1.ParameterOnArc(),b1); |
2940 | } |
2941 | if(curp2.IsOnArc()){ |
2942 | ChFi3d_EnlargeBox(curp2.Arc(),myEFMap(curp2.Arc()),curp2.ParameterOnArc(),b2); |
2943 | } |
2944 | Handle(ChFiDS_Stripe) bidst; |
2945 | ChFi3d_EnlargeBox(DStr,bidst,cursd,b1,b2,0); |
2946 | ChFi3d_EnlargeBox(DStr,bidst,nextsd,b1,b2,1); |
2947 | tol1 = ChFi3d_BoxDiag(b1); |
2948 | tol2 = ChFi3d_BoxDiag(b2); |
2949 | curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1); |
2950 | curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2); |
2951 | } |
81bba717 |
2952 | // The connections edge/new faces are updated. |
7fd59977 |
2953 | for (ILES.Initialize(ll) ; ILES.More(); ILES.Next()) { |
2954 | const Handle(ChFiDS_HElSpine)& curhels = ILES.Value(); |
2955 | const ChFiDS_ElSpine& curels = curhels->ChangeCurve(); |
2956 | Standard_Real WF = curels.FirstParameter(); |
2957 | Standard_Real WL = curels.LastParameter(); |
2958 | Standard_Integer IF,IL; |
2959 | Standard_Real nwf = WF, nwl = WL; |
2960 | Standard_Real period = 0.; |
2961 | Standard_Integer nbed = Spine->NbEdges(); |
2962 | if(periodic){ |
2963 | period = Spine->Period(); |
2964 | nwf = ElCLib::InPeriod(WF,-tolesp,period-tolesp); |
2965 | IF = Spine->Index(nwf,1); |
2966 | nwl = ElCLib::InPeriod(WL,tolesp,period+tolesp); |
2967 | IL = Spine->Index(nwl,0); |
2968 | if(nwl<nwf+tolesp) IL += nbed; |
2969 | } |
2970 | else{ |
2971 | IF = Spine->Index(WF,1); |
2972 | IL = Spine->Index(WL,0); |
2973 | } |
2974 | if(IF == IL) { |
81bba717 |
2975 | //fast processing |
7fd59977 |
2976 | Standard_Integer IFloc = IF; |
2977 | if(periodic) IFloc = (IF - 1)%nbed + 1; |
2978 | const TopoDS_Edge& Ej = Spine->Edges(IFloc); |
2979 | for(i = 1; i <= len; i++){ |
2980 | Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i); |
2981 | Standard_Real fp = cursd->FirstSpineParam(); |
2982 | Standard_Real lp = cursd->LastSpineParam(); |
2983 | if(lp < WF+tolesp || fp > WL-tolesp) continue; |
2984 | if(!myEVIMap.IsBound(Ej)) { |
2985 | TColStd_ListOfInteger li; |
2986 | myEVIMap.Bind(Ej,li); |
2987 | } |
2988 | myEVIMap.ChangeFind(Ej).Append(cursd->Surf()); |
2989 | } |
2990 | } |
2991 | else if(IF < IL){ |
2992 | TColStd_Array1OfReal wv(IF,IL - 1); |
0797d9d3 |
2993 | #ifdef OCCT_DEBUG |
04232180 |
2994 | std::cout<<"length of the trajectory : "<<(WL-WF)<<std::endl; |
7fd59977 |
2995 | #endif |
2996 | for(i = IF; i < IL; i++){ |
2997 | Standard_Integer iloc = i; |
2998 | if(periodic) iloc = (i - 1)%nbed + 1; |
2999 | Standard_Real wi = Spine->LastParameter(iloc); |
3000 | if(periodic) wi = ElCLib::InPeriod(wi,WF,WF+period); |
3001 | gp_Pnt pv = Spine->Value(wi); |
0797d9d3 |
3002 | #ifdef OCCT_DEBUG |
7fd59977 |
3003 | gp_Pnt pelsapp = curels.Value(wi); |
3004 | Standard_Real distinit = pv.Distance(pelsapp); |
04232180 |
3005 | std::cout<<"distance psp/papp : "<<distinit<<std::endl; |
7fd59977 |
3006 | #endif |
3007 | Extrema_LocateExtPC ext(pv,curels,wi,1.e-8); |
3008 | wv(i) = wi; |
3009 | if(ext.IsDone()){ |
3010 | wv(i) = ext.Point().Parameter(); |
3011 | } |
3012 | else { |
0797d9d3 |
3013 | #ifdef OCCT_DEBUG |
04232180 |
3014 | std::cout<<"fail of projection vertex ElSpine!!!"<<std::endl; |
7fd59977 |
3015 | #endif |
3016 | } |
3017 | } |
3018 | for(i = 1; i <= len; i++){ |
3019 | Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i); |
3020 | Standard_Real fp = cursd->FirstSpineParam(); |
3021 | Standard_Real lp = cursd->LastSpineParam(); |
3022 | Standard_Integer j; |
7fd59977 |
3023 | Standard_Integer jf = 0, jl = 0; |
7fd59977 |
3024 | if(lp < WF+tolesp || fp > WL-tolesp) continue; |
3025 | for(j = IF; j < IL; j++){ |
3026 | jf = j; |
3027 | if(fp < wv(j) - tolesp) break; |
3028 | } |
3029 | for(j = IF; j < IL; j++){ |
3030 | jl = j; |
3031 | if(lp < wv(j) + tolesp) break; |
3032 | } |
3033 | for(j = jf; j <= jl; j++){ |
3034 | Standard_Integer jloc = j; |
3035 | if(periodic) jloc = (j - 1)%nbed + 1; |
3036 | const TopoDS_Edge& Ej = Spine->Edges(jloc); |
3037 | if(!myEVIMap.IsBound(Ej)) { |
3038 | TColStd_ListOfInteger li; |
3039 | myEVIMap.Bind(Ej,li); |
3040 | } |
3041 | myEVIMap.ChangeFind(Ej).Append(cursd->Surf()); |
3042 | } |
3043 | } |
3044 | } |
3045 | } |
3046 | } |
3047 | } |
3048 | |
3049 | //======================================================================= |
3050 | //function : PerformSetOfSurf |
3051 | //purpose : |
3052 | //======================================================================= |
3053 | |
3054 | void ChFi3d_Builder::PerformSetOfSurf(Handle(ChFiDS_Stripe)& Stripe, |
3055 | const Standard_Boolean Simul) |
3056 | { |
3057 | TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); |
3058 | |
0797d9d3 |
3059 | #ifdef OCCT_DEBUG |
7fd59977 |
3060 | OSD_Chronometer ch; |
81bba717 |
3061 | ChFi3d_InitChron(ch);// init perf for PerformSetOfKPart |
7fd59977 |
3062 | #endif |
3063 | |
3064 | const Handle(ChFiDS_Spine)& sp = Stripe->Spine(); |
3065 | Standard_Integer SI = ChFi3d_SolidIndex(sp,DStr,myESoMap,myEShMap); |
3066 | Stripe->SetSolidIndex(SI); |
3067 | if(!sp->SplitDone()) PerformSetOfKPart(Stripe,Simul); |
3068 | |
0797d9d3 |
3069 | #ifdef OCCT_DEBUG |
7fd59977 |
3070 | ChFi3d_ResultChron(ch ,t_perfsetofkpart); // result perf PerformSetOfKPart( |
81bba717 |
3071 | ChFi3d_InitChron(ch); // init perf for PerformSetOfKGen |
7fd59977 |
3072 | #endif |
3073 | |
3074 | PerformSetOfKGen(Stripe,Simul); |
3075 | |
0797d9d3 |
3076 | #ifdef OCCT_DEBUG |
7fd59977 |
3077 | ChFi3d_ResultChron(ch, t_perfsetofkgen);//result perf PerformSetOfKGen |
81bba717 |
3078 | ChFi3d_InitChron(ch); // init perf for ChFi3d_MakeExtremities |
7fd59977 |
3079 | #endif |
3080 | |
3081 | if(!Simul) ChFi3d_MakeExtremities(Stripe,DStr,myEFMap,tolesp,tol2d); |
3082 | |
0797d9d3 |
3083 | #ifdef OCCT_DEBUG |
7fd59977 |
3084 | ChFi3d_ResultChron(ch, t_makextremities); // result perf t_makextremities |
3085 | #endif |
3086 | } |