1 // Created on: 1994-10-03
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Bisector_Bisec.hxx>
19 #include <Bisector_BisecAna.hxx>
20 #include <Bnd_Box2d.hxx>
21 #include <BndLib_Add2dCurve.hxx>
22 #include <BRep_Builder.hxx>
23 #include <BRep_Tool.hxx>
24 #include <BRepAdaptor_Curve.hxx>
25 #include <BRepAlgo_FaceRestrictor.hxx>
26 #include <BRepAlgo_Loop.hxx>
27 #include <BRepClass3d_SolidClassifier.hxx>
28 #include <BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape.hxx>
29 #include <BRepFill_DataMapOfNodeDataMapOfShapeShape.hxx>
30 #include <BRepFill_DataMapOfShapeDataMapOfShapeListOfShape.hxx>
31 #include <BRepFill_DataMapOfShapeSequenceOfPnt.hxx>
32 #include <BRepFill_DataMapOfShapeSequenceOfReal.hxx>
33 #include <BRepFill_Evolved.hxx>
34 #include <BRepFill_OffsetAncestors.hxx>
35 #include <BRepFill_OffsetWire.hxx>
36 #include <BRepFill_Pipe.hxx>
37 #include <BRepFill_TrimSurfaceTool.hxx>
38 #include <BRepLib.hxx>
39 #include <BRepLib_FindSurface.hxx>
40 #include <BRepLib_MakeEdge.hxx>
41 #include <BRepLib_MakeFace.hxx>
42 #include <BRepLib_MakeVertex.hxx>
43 #include <BRepLib_MakeWire.hxx>
44 #include <BRepLProp.hxx>
45 #include <BRepMAT2d_BisectingLocus.hxx>
46 #include <BRepMAT2d_Explorer.hxx>
47 #include <BRepMAT2d_LinkTopoBilo.hxx>
48 #include <BRepSweep_Prism.hxx>
49 #include <BRepSweep_Revol.hxx>
50 #include <BRepTools.hxx>
51 #include <BRepTools_Modifier.hxx>
52 #include <BRepTools_Quilt.hxx>
53 #include <BRepTools_TrsfModification.hxx>
54 #include <BRepTools_WireExplorer.hxx>
55 #include <Geom2d_CartesianPoint.hxx>
56 #include <Geom2d_Circle.hxx>
57 #include <Geom2d_Curve.hxx>
58 #include <Geom2d_Geometry.hxx>
59 #include <Geom2d_Line.hxx>
60 #include <Geom2d_TrimmedCurve.hxx>
61 #include <Geom2dAdaptor_Curve.hxx>
62 #include <Geom2dAPI_ExtremaCurveCurve.hxx>
63 #include <Geom2dInt_GInter.hxx>
64 #include <Geom_Curve.hxx>
65 #include <Geom_Line.hxx>
66 #include <Geom_Plane.hxx>
67 #include <Geom_RectangularTrimmedSurface.hxx>
68 #include <Geom_Surface.hxx>
69 #include <Geom_TrimmedCurve.hxx>
70 #include <GeomAPI.hxx>
71 #include <GeomProjLib.hxx>
75 #include <gp_Circ2d.hxx>
79 #include <gp_Pnt2d.hxx>
80 #include <gp_Trsf.hxx>
82 #include <gp_Vec2d.hxx>
83 #include <IntRes2d_IntersectionPoint.hxx>
84 #include <MAT2d_CutCurve.hxx>
85 #include <MAT_Arc.hxx>
86 #include <MAT_BasicElt.hxx>
87 #include <MAT_Graph.hxx>
88 #include <MAT_Node.hxx>
89 #include <MAT_Side.hxx>
90 #include <Precision.hxx>
91 #include <Standard_ConstructionError.hxx>
92 #include <Standard_NoSuchObject.hxx>
93 #include <Standard_NotImplemented.hxx>
94 #include <TColgp_SequenceOfPnt.hxx>
95 #include <TColStd_SequenceOfReal.hxx>
98 #include <TopExp_Explorer.hxx>
99 #include <TopLoc_Location.hxx>
100 #include <TopoDS.hxx>
101 #include <TopoDS_Compound.hxx>
102 #include <TopoDS_Edge.hxx>
103 #include <TopoDS_Face.hxx>
104 #include <TopoDS_Iterator.hxx>
105 #include <TopoDS_Shape.hxx>
106 #include <TopoDS_Solid.hxx>
107 #include <TopoDS_Vertex.hxx>
108 #include <TopoDS_Wire.hxx>
109 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
110 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
111 #include <TopTools_DataMapOfShapeSequenceOfShape.hxx>
112 #include <TopTools_DataMapOfShapeShape.hxx>
113 #include <TopTools_ListIteratorOfListOfShape.hxx>
114 #include <TopTools_SequenceOfShape.hxx>
118 #include <DrawTrSurf.hxx>
120 static Standard_Boolean AffichGeom = Standard_False;
121 static Standard_Boolean AffichEdge = Standard_False;
122 static Standard_Integer NbFACES = 0;
123 static Standard_Integer NbTRIMFACES = 0;
124 static Standard_Integer NbVEVOS = 0;
125 static Standard_Integer NbPROFILS = 0;
126 static Standard_Integer NbEDGES = 0;
129 static const Standard_Real BRepFill_Confusion()
131 Standard_Real Tol = 1.e-6;
135 static const TopoDS_Wire PutProfilAt (const TopoDS_Wire& ProfRef,
136 const gp_Ax3& AxeRef,
137 const TopoDS_Edge& E,
138 const TopoDS_Face& F,
139 const Standard_Boolean AtStart);
141 static void TrimFace(const TopoDS_Face& Face,
142 TopTools_SequenceOfShape& TheEdges,
143 TopTools_SequenceOfShape& S);
145 static void TrimEdge (const TopoDS_Edge& Edge,
146 const TopTools_SequenceOfShape& TheEdgesControle,
147 TopTools_SequenceOfShape& TheVer,
148 TColStd_SequenceOfReal& ThePar,
149 TopTools_SequenceOfShape& S);
151 static TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E,
152 const TopoDS_Face& F);
154 static Standard_Integer PosOnFace (Standard_Real d1,
158 static void ComputeIntervals (const TopTools_SequenceOfShape& VonF,
159 const TopTools_SequenceOfShape& VOnL,
160 const TColgp_SequenceOfPnt& ParOnF,
161 const TColgp_SequenceOfPnt& ParOnL,
162 const BRepFill_TrimSurfaceTool& Trim,
163 const Handle(Geom2d_Curve)& Bis,
164 const TopoDS_Vertex& VS,
165 const TopoDS_Vertex& VE,
166 TColStd_SequenceOfReal& FirstPar,
167 TColStd_SequenceOfReal& LastPar,
168 TopTools_SequenceOfShape& FirstV,
169 TopTools_SequenceOfShape& LastV );
171 static Standard_Real DistanceToOZ (const TopoDS_Vertex& V);
173 static Standard_Real Altitud (const TopoDS_Vertex& V);
175 static Standard_Boolean DoubleOrNotInFace (const TopTools_SequenceOfShape& EC,
176 const TopoDS_Vertex& V);
178 static void SimpleExpression (const Bisector_Bisec& B,
179 Handle(Geom2d_Curve)& Bis);
181 static TopAbs_Orientation Relative (const TopoDS_Wire& W1,
182 const TopoDS_Wire& W2,
183 const TopoDS_Vertex& V,
184 Standard_Boolean& Commun);
186 static void CutEdge (const TopoDS_Edge& E,
187 const TopoDS_Face& F,TopTools_ListOfShape& Cuts);
189 static void CutEdgeProf (const TopoDS_Edge& E,
190 const Handle(Geom_Plane)& Plane,
191 const Handle(Geom2d_Line)& Line,
192 TopTools_ListOfShape& Cuts,
193 TopTools_DataMapOfShapeShape& MapVerRefMoved);
195 static Standard_Integer VertexFromNode
196 (const Handle(MAT_Node)& aNode,
197 const TopoDS_Edge& E,
198 const TopoDS_Vertex& VF,
199 const TopoDS_Vertex& VL,
200 BRepFill_DataMapOfNodeDataMapOfShapeShape& MapNodeVertex,
203 //=======================================================================
204 //function : EdgeVertices
206 //=======================================================================
208 static void EdgeVertices (const TopoDS_Edge& E,
212 if (E.Orientation() == TopAbs_REVERSED) {
213 TopExp::Vertices(E,V2,V1);
216 TopExp::Vertices(E,V1,V2);
220 //=======================================================================
221 //function : BRepFill_Evolved
223 //=======================================================================
225 BRepFill_Evolved::BRepFill_Evolved()
227 myIsDone (Standard_False),
228 mySpineType(Standard_True)
233 //=======================================================================
234 //function : BRepFill_Evolved
236 //=======================================================================
238 BRepFill_Evolved::BRepFill_Evolved(const TopoDS_Wire& Spine,
239 const TopoDS_Wire& Profile,
240 const gp_Ax3& AxeProf,
241 const GeomAbs_JoinType Join,
242 const Standard_Boolean Solid)
244 : myIsDone(Standard_False)
246 Perform( Spine, Profile, AxeProf, Join, Solid);
250 //=======================================================================
251 //function : BRepFill_Evolved
253 //=======================================================================
255 BRepFill_Evolved::BRepFill_Evolved(const TopoDS_Face& Spine,
256 const TopoDS_Wire& Profile,
257 const gp_Ax3& AxeProf,
258 const GeomAbs_JoinType Join,
259 const Standard_Boolean Solid)
260 : myIsDone(Standard_False)
262 Perform( Spine, Profile, AxeProf, Join, Solid);
265 //=======================================================================
266 //function : IsVertical
268 //=======================================================================
270 static Standard_Boolean IsVertical(const TopoDS_Edge& E)
273 TopExp::Vertices(E,V1,V2);
274 gp_Pnt P1 = BRep_Tool::Pnt(V1);
275 gp_Pnt P2 = BRep_Tool::Pnt(V2);
277 if ( Abs(P1.Y() - P2.Y()) < BRepFill_Confusion()) {
281 Handle(Geom_Curve) GC = BRep_Tool::Curve(E,Loc,f,l);
282 if ( GC->DynamicType() == STANDARD_TYPE(Geom_Line))
283 return Standard_True;
285 return Standard_False;
288 //=======================================================================
289 //function : IsPlanar
291 //=======================================================================
293 static Standard_Boolean IsPlanar(const TopoDS_Edge& E)
296 TopExp::Vertices(E,V1,V2);
297 gp_Pnt P1 = BRep_Tool::Pnt(V1);
298 gp_Pnt P2 = BRep_Tool::Pnt(V2);
300 if ( Abs(P1.Z() - P2.Z()) < BRepFill_Confusion()) {
304 Handle(Geom_Curve) GC = BRep_Tool::Curve(E,Loc,f,l);
305 if ( GC->DynamicType() == STANDARD_TYPE(Geom_Line))
306 return Standard_True;
308 return Standard_False;
312 //=======================================================================
314 //purpose : determine the position of the profil correspondingly to plane XOZ.
315 // Return 1 : MAT_Left.
316 // Return 2 : MAT_Left and Planar.
317 // Return 3 : MAT_Left and Vertical.
318 // Return 4 : MAT_Right.
319 // Return 5 : MAT_Right and Planar.
320 // Return 6 : MAT_Right and Vertical.
321 //=======================================================================
323 static Standard_Integer Side(const TopoDS_Wire& Profil,
324 const Standard_Real Tol)
327 // Rem : it is enough to test the first edge of the Wire.
328 // ( Correctly cut in PrepareProfil)
329 TopExp_Explorer Explo(Profil,TopAbs_EDGE);
331 Standard_Integer TheSide;
332 const TopoDS_Edge& E = TopoDS::Edge(Explo.Current());
334 TopExp::Vertices(E,V1,V2);
335 gp_Pnt P1 = BRep_Tool::Pnt(V1);
336 gp_Pnt P2 = BRep_Tool::Pnt(V2);
338 if ( P1.Y() < -Tol || P2.Y() < -Tol) TheSide = 4;
340 if (IsVertical(E)) TheSide+=2;
341 else if (IsPlanar(E)) TheSide++;
346 //=======================================================================
349 //=======================================================================
351 void BRepFill_Evolved::Perform(const TopoDS_Wire& Spine,
352 const TopoDS_Wire& Profile,
353 const gp_Ax3& AxeProf,
354 const GeomAbs_JoinType Join,
355 const Standard_Boolean Solid)
357 mySpineType = Standard_False;
358 TopoDS_Face aFace = BRepLib_MakeFace(Spine,Standard_True);
359 PrivatePerform( aFace, Profile, AxeProf, Join, Solid);
362 //=======================================================================
365 //=======================================================================
367 void BRepFill_Evolved::Perform(const TopoDS_Face& Spine,
368 const TopoDS_Wire& Profile,
369 const gp_Ax3& AxeProf,
370 const GeomAbs_JoinType Join,
371 const Standard_Boolean Solid)
373 mySpineType = Standard_True;
374 PrivatePerform( Spine, Profile, AxeProf, Join, Solid);
377 //=======================================================================
378 //function : PrivatePerform
380 //=======================================================================
382 void BRepFill_Evolved::PrivatePerform(const TopoDS_Face& Spine,
383 const TopoDS_Wire& Profile,
384 const gp_Ax3& AxeProf,
385 const GeomAbs_JoinType Join,
386 const Standard_Boolean Solid)
388 TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
389 mySpine = TopoDS::Face(aLocalShape);
390 // mySpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
391 aLocalShape = Profile.Oriented(TopAbs_FORWARD);
392 myProfile = TopoDS::Wire(aLocalShape);
393 // myProfile = TopoDS::Wire(Profile.Oriented(TopAbs_FORWARD));
397 if (myJoinType > GeomAbs_Arc) {
398 Standard_NotImplemented::Raise();
401 TopTools_ListOfShape WorkProf;
402 TopoDS_Face WorkSpine;
403 TopTools_ListIteratorOfListOfShape WPIte;
405 //-------------------------------------------------------------------
406 // Positioning of mySpine and myProfil in the workspace.
407 //-------------------------------------------------------------------
408 TopLoc_Location LSpine = FindLocation(mySpine);
410 T.SetTransformation(AxeProf);
411 TopLoc_Location LProfile (T);
412 TopLoc_Location InitLS = mySpine .Location();
413 TopLoc_Location InitLP = myProfile.Location();
414 TransformInitWork(LSpine,LProfile);
416 //------------------------------------------------------------------
417 // projection of the profile and cut of the spine.
418 //------------------------------------------------------------------
419 TopTools_DataMapOfShapeShape MapProf, MapSpine;
421 PrepareProfile(WorkProf , MapProf);
422 PrepareSpine (WorkSpine, MapSpine);
424 Standard_Real Tol = BRepFill_Confusion();
425 Standard_Boolean YaLeft = Standard_False;
426 Standard_Boolean YaRight = Standard_False;
429 for (WPIte.Initialize(WorkProf); WPIte.More(); WPIte.Next()) {
430 SP = TopoDS::Wire(WPIte.Value());
431 if ( Side(SP,Tol) < 4) YaLeft = Standard_True;
432 else YaRight = Standard_True;
433 if (YaLeft && YaRight) break;
437 BRepMAT2d_BisectingLocus Locus;
439 //----------------------------------------------------------
440 // Initialisation of cut volevo.
441 // For each part of the profile create a volevo added to CutVevo
442 //----------------------------------------------------------
443 BRepFill_Evolved CutVevo;
446 BRepTools_WireExplorer WExp;
450 for (WPIte.Initialize(WorkProf); WPIte.More(); WPIte.Next()) {
451 for (WExp.Init(TopoDS::Wire(WPIte.Value())); WExp.More(); WExp.Next()) {
452 BB.Add(WP,WExp.Current());
455 CutVevo.SetWork(WorkSpine,WP);
457 BRepTools_Quilt Glue;
458 Standard_Integer CSide;
460 //---------------------------------
461 // Construction of vevos to the left.
462 //---------------------------------
464 //-----------------------------------------------------
465 // Calculate the map of bisector locations at the left.
466 // and links Topology -> base elements of the map.
467 //-----------------------------------------------------
468 BRepMAT2d_Explorer Exp(WorkSpine);
469 Locus.Compute(Exp,1,MAT_Left);
470 BRepMAT2d_LinkTopoBilo Link(Exp,Locus);
472 for (WPIte.Initialize(WorkProf); WPIte.More(); WPIte.Next()) {
473 SP = TopoDS::Wire(WPIte.Value());
474 CSide = Side(SP,Tol);
475 //-----------------------------------------------
476 // Construction and adding of elementary volevo.
477 //-----------------------------------------------
478 BRepFill_Evolved Vevo;
480 Vevo.ElementaryPerform (WorkSpine, SP, Locus, Link, Join);
482 else if (CSide == 2) {
483 Vevo.PlanarPerform (WorkSpine, SP, Locus, Link, Join);
485 else if (CSide == 3) {
486 Vevo.VerticalPerform (WorkSpine, SP, Locus, Link, Join);
488 CutVevo.Add (Vevo, SP, Glue);
492 //---------------------------------
493 // Construction of vevos to the right.
494 //---------------------------------
496 //-----------------------------------
497 // Decomposition of the face into wires.
498 //-----------------------------------
499 TopExp_Explorer SpineExp (WorkSpine, TopAbs_WIRE);
500 for ( ; SpineExp.More(); SpineExp.Next()) {
501 //----------------------------------------------
502 // Calculate the map to the right of the current wire.
503 //----------------------------------------------
504 BRepLib_MakeFace B(gp_Pln(0.,0.,1.,0.));
505 TopoDS_Shape aLocalShape = SpineExp.Current().Reversed();
506 B.Add(TopoDS::Wire(aLocalShape));
507 // B.Add(TopoDS::Wire(SpineExp.Current().Reversed()));
509 BRepMAT2d_Explorer Exp(Face);
510 Locus.Compute(Exp,1,MAT_Left);
511 BRepMAT2d_LinkTopoBilo Link(Exp,Locus);
513 for (WPIte.Initialize(WorkProf); WPIte.More(); WPIte.Next()) {
514 SP = TopoDS::Wire(WPIte.Value());
515 CSide = Side(SP,Tol);
516 //-----------------------------------------------
517 // Construction and adding of an elementary volevo
518 //-----------------------------------------------
519 BRepFill_Evolved Vevo;
521 Vevo.ElementaryPerform (Face, SP, Locus, Link, Join);
523 else if (CSide == 5) {
524 Vevo.PlanarPerform (Face, SP, Locus, Link, Join);
526 else if (CSide == 6) {
527 Vevo.VerticalPerform (Face, SP, Locus, Link, Join);
529 CutVevo.Add (Vevo, SP, Glue);
534 if (Solid) CutVevo.AddTopAndBottom(Glue);
536 //-------------------------------------------------------------------------
537 // Gluing of regularites on parallel edges generate4d by vertices of the
538 // cut of the profile.
539 //-------------------------------------------------------------------------
540 CutVevo.ContinuityOnOffsetEdge(WorkProf);
542 //-----------------------------------------------------------------
543 // construction of the shape via the quilt, ie:
544 // - sharing of topologies of elementary added volevos.
545 // - Orientation of faces correspondingly to each other.
546 //-----------------------------------------------------------------
547 TopoDS_Shape& SCV = CutVevo.ChangeShape();
549 //------------------------------------------------------------------------
550 // Transfer of the map of generated elements and of the shape of Cutvevo
551 // in myMap and repositioning in the initial space.
552 //------------------------------------------------------------------------
553 Transfert (CutVevo, MapProf, MapSpine, LSpine.Inverted(), InitLS, InitLP);
555 //Orientation of the solid.
556 if (Solid) MakeSolid();
558 // modified by NIZHNY-EAP Mon Jan 24 11:26:48 2000 ___BEGIN___
559 BRepLib::UpdateTolerances(myShape,Standard_False);
560 // modified by NIZHNY-EAP Mon Jan 24 11:26:50 2000 ___END___
561 myIsDone = Standard_True;
566 //=======================================================================
567 //function : IsInversed
569 //=======================================================================
571 static void IsInversed(const TopoDS_Shape& S,
572 const TopoDS_Edge& E1,
573 const TopoDS_Edge& E2,
574 Standard_Boolean* Inverse)
577 Inverse[0] = Inverse[1] = 0;
578 if (S.ShapeType() != TopAbs_EDGE) return;
582 BRepAdaptor_Curve CS(TopoDS::Edge(S));
583 if (S.Orientation() == TopAbs_FORWARD) {
584 CS.D1(CS.FirstParameter(),P,DS);
587 CS.D1(CS.LastParameter(),P,DS);
592 if (!BRep_Tool::Degenerated(E1)) {
593 BRepAdaptor_Curve C1(TopoDS::Edge(E1));
594 if (E1.Orientation() == TopAbs_FORWARD) {
595 C1.D1(C1.FirstParameter(),P,DC1);
598 C1.D1(C1.LastParameter(),P,DC1);
601 Inverse[0] = (DS.Dot(DC1) < 0.);
605 if (!BRep_Tool::Degenerated(E2)) {
606 BRepAdaptor_Curve C2(TopoDS::Edge(E2));
607 if (E2.Orientation() == TopAbs_FORWARD) {
608 C2.D1(C2.FirstParameter(),P,DC2);
611 C2.D1(C2.LastParameter(),P,DC2);
614 Inverse[1] = (DS.Dot(DC2) < 0.);
619 //=======================================================================
622 //=======================================================================
624 void BRepFill_Evolved::SetWork(const TopoDS_Face& Sp,
625 const TopoDS_Wire& Pr)
631 //=======================================================================
632 //function : ConcaveSide
633 //purpose : Determine if the pipes were at the side of the
634 // concavity. In this case they can be closed.
635 // WARNING: Not finished. Done only for circles.
636 //=======================================================================
638 static Standard_Boolean ConcaveSide(const TopoDS_Shape& S,
639 const TopoDS_Face& F)
642 if (S.ShapeType() == TopAbs_VERTEX) return Standard_False;
644 if (S.ShapeType() == TopAbs_EDGE) {
646 Handle(Geom2d_Curve) G2d =
647 BRep_Tool::CurveOnSurface(TopoDS::Edge(S),F,f,l);
648 Handle(Geom2d_Curve) G2dOC;
650 Geom2dAdaptor_Curve AC(G2d,f,l);
651 if ( AC.GetType() == GeomAbs_Circle) {
652 Standard_Boolean Direct = AC.Circle().IsDirect();
653 if (S.Orientation() == TopAbs_REVERSED) Direct = (!Direct);
657 return Standard_False;
660 //=======================================================================
661 //function : ElementaryPerform
663 //=======================================================================
665 void BRepFill_Evolved::ElementaryPerform (const TopoDS_Face& Sp,
666 const TopoDS_Wire& Pr,
667 const BRepMAT2d_BisectingLocus& Locus,
668 BRepMAT2d_LinkTopoBilo& Link,
669 const GeomAbs_JoinType /*Join*/)
675 sprintf(name,"PROFIL_%d",++NbPROFILS);
679 TopoDS_Shape aLocalShape = Sp.Oriented(TopAbs_FORWARD);
680 mySpine = TopoDS::Face(aLocalShape);
681 // mySpine = TopoDS::Face(Sp.Oriented(TopAbs_FORWARD));
685 BRep_Builder myBuilder;
686 myBuilder.MakeCompound(TopoDS::Compound(myShape));
688 //---------------------------------------------------------------------
689 // MapNodeVertex : associate to each node of the map (key1) and
690 // to each element of the profile (key2) a vertex (item).
691 // MapBis : a set of edges or vertexes (item) generated by
692 // a bisectrice on a face or an edge (key) of
693 // tubes or revolutions.
694 // MapVerPar : Map of parameters of vertices on parallel edges
695 // the list contained in MapVerPar (E) corresponds
696 // to parameters on E of vertices contained in MapBis(E);
697 // MapBS : links BasicElt of the map => Topology of the spine.
698 //---------------------------------------------------------------------
701 BRepFill_DataMapOfNodeDataMapOfShapeShape MapNodeVertex;
702 TopTools_DataMapOfShapeSequenceOfShape MapBis;
703 BRepFill_DataMapOfShapeSequenceOfReal MapVerPar;
705 TopTools_DataMapOfShapeShape EmptyMap;
706 TopTools_SequenceOfShape EmptySeq;
707 TopTools_ListOfShape EmptyList;
708 TColStd_SequenceOfReal EmptySeqOfReal;
710 // mark of the profile.
711 gp_Ax3 AxeRef(gp_Pnt(0.,0.,0.),
715 //---------------------------------------------------------------
716 // Construction of revolutions and tubes.
717 //---------------------------------------------------------------
718 BRepTools_WireExplorer ProfExp;
719 TopExp_Explorer FaceExp;
720 BRepTools_WireExplorer WireExp;
722 for (FaceExp.Init(mySpine,TopAbs_WIRE); FaceExp.More(); FaceExp.Next()){
724 for (WireExp.Init(TopoDS::Wire(FaceExp.Current())); WireExp.More();
727 TopoDS_Edge CurrentEdge = WireExp.Current();
728 TopoDS_Vertex VFirst,VLast;
729 EdgeVertices(CurrentEdge,VFirst,VLast);
731 for (Link.Init(VLast); Link.More(); Link.Next()) {
732 //----------------------------.
733 //Construction of a Revolution
734 //----------------------------.
735 MakeRevol (CurrentEdge, VLast, AxeRef);
738 for (Link.Init(CurrentEdge); Link.More(); Link.Next()) {
739 //------------------------.
740 //Construction of a Tube
741 //-------------------------
742 MakePipe (CurrentEdge, AxeRef);
749 cout << " End Construction of geometric primitives"<<endl;
755 //---------------------------------------------------
756 // Construction of edges associated to bissectrices.
757 //---------------------------------------------------
758 Handle(MAT_Arc) CurrentArc;
759 Handle(Geom2d_Curve) Bis, PCurve1, PCurve2 ;
760 Handle(Geom_Curve) CBis;
761 Standard_Boolean Reverse;
762 TopoDS_Edge CurrentEdge;
769 for (Standard_Integer i = 1; i <= Locus.Graph()->NumberOfArcs(); i++) {
770 CurrentArc = Locus.Graph()->Arc(i);
771 SimpleExpression(Locus.GeomBis(CurrentArc,Reverse), Bis);
773 //------------------------------------------------------------------
774 // Return elements of the spine corresponding to separate basicElts.
775 //------------------------------------------------------------------
776 S [0] = Link.GeneratingShape(CurrentArc->FirstElement());
777 S [1] = Link.GeneratingShape(CurrentArc->SecondElement());
779 Standard_Boolean Concave0 = ConcaveSide(S[0],mySpine);
780 Standard_Boolean Concave1 = ConcaveSide(S[1],mySpine);
782 TopTools_SequenceOfShape VOnF,VOnL;
783 TColgp_SequenceOfPnt ParOnF,ParOnL;
785 TopTools_DataMapOfShapeSequenceOfShape MapSeqVer;
786 BRepFill_DataMapOfShapeSequenceOfPnt MapSeqPar;
788 Standard_Integer vv = 0;
789 for(ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()) {
791 //-----------------------------------------------
792 // Return two faces separated by the bissectrice.
793 //-----------------------------------------------
794 F [0] = TopoDS::Face(myMap(S[0])(ProfExp.Current()).First());
795 F [1] = TopoDS::Face(myMap(S[1])(ProfExp.Current()).First());
797 //------------------------------------
798 // Return parallel edges on each face.
799 //------------------------------------
802 EdgeVertices(ProfExp.Current(),VF,VL);
804 E [0] = TopoDS::Edge(myMap(S[0])(VF).First());
805 E [1] = TopoDS::Edge(myMap(S[0])(VL).First());
806 E [2] = TopoDS::Edge(myMap(S[1])(VF).First());
807 E [3] = TopoDS::Edge(myMap(S[1])(VL).First());
809 Standard_Boolean Inv0[2];
810 Standard_Boolean Inv1[2];
812 Inv0[0] = Inv0[1] = Inv1[0]= Inv1[1] = 0;
813 if (Concave0) IsInversed(S[0],E[0],E[1],Inv0);
814 if (Concave1) IsInversed(S[1],E[2],E[3],Inv1);
816 //---------------------------------------------
817 // Construction of geometries.
818 //---------------------------------------------
819 BRepFill_TrimSurfaceTool Trim (Bis,F[0],F[1],
820 E[0],E[2],Inv0[0],Inv1[0]);
821 //-----------------------------------------------------------
822 //Construction of vertices corresponding to the node of the map
823 //-----------------------------------------------------------
825 Handle(MAT_Node) Node1, Node2;
828 Node1 = CurrentArc->SecondNode();
829 Node2 = CurrentArc->FirstNode();
832 Node1 = CurrentArc->FirstNode();
833 Node2 = CurrentArc->SecondNode();
835 //--------------------------------------------------------
836 // Particular case when the node is on a vertex of the spine.
837 //--------------------------------------------------------
838 if (Node1->OnBasicElt()) {
839 if (S[0].ShapeType() == TopAbs_VERTEX) {
840 Node1 = CurrentArc->FirstElement()->StartArc()->FirstNode();
842 else if (S[1].ShapeType() == TopAbs_VERTEX) {
843 Node1 = CurrentArc->SecondElement()->StartArc()->FirstNode();
846 // End of particular case.
849 StartOnF = VertexFromNode(Node1,
850 TopoDS::Edge(ProfExp.Current()),
855 EndOnF = VertexFromNode(Node2,
856 TopoDS::Edge(ProfExp.Current()),
860 //-----------------------------------------------------------
861 // Construction of vertices on edges parallel to the spine.
862 //-----------------------------------------------------------
863 if (!MapSeqVer.IsBound(VF)) {
864 if (Inv0 [0] || Inv1 [0]) {
869 Trim.IntersectWith(E [0], E [2], ParOnF);
871 for (Standard_Integer s = 1; s <= ParOnF.Length(); s++) {
873 myBuilder.MakeVertex (VC);
877 VOnF .SetValue(1,VS);
880 VOnF .SetValue(ParOnF.Length(),VE);
885 ParOnF = MapSeqPar(VF);
886 VOnF = MapSeqVer(VF);
889 if (!MapSeqVer.IsBound(VL)) {
890 if (Inv0 [1] || Inv1 [1]) {
895 Trim.IntersectWith(E [1], E [3], ParOnL);
897 for (Standard_Integer s = 1; s <= ParOnL.Length(); s++) {
899 myBuilder.MakeVertex (VC);
903 VOnL .SetValue(1,VS);
906 VOnL .SetValue(ParOnL.Length(),VE);
911 ParOnL = MapSeqPar(VL);
912 VOnL = MapSeqVer(VL);
915 //------------------------------------------------------
916 // Test if the Bissectrice is not projected on the face
917 //------------------------------------------------------
918 if ((StartOnF == 0) && (EndOnF == 0) &&
919 VOnL.IsEmpty() && VOnF.IsEmpty())
920 // No trace of the bisectrice on the face.
923 if ((StartOnF == 0) && (EndOnF == 0) &&
924 (VOnL.Length() + VOnF.Length() == 1))
925 // the first or last node of the arc is on the edge
926 // but the arc is not on the face.
929 //---------------------------------------------------------
930 // determine the intervals of the bissectrice that are
931 // projected on F[0] and F[1].
932 //---------------------------------------------------------
933 TColStd_SequenceOfReal LastPar,FirstPar;
934 TopTools_SequenceOfShape FirstV,LastV;
936 ComputeIntervals (VOnF,VOnL,ParOnF,ParOnL,Trim,Bis,
937 VS,VE,FirstPar,LastPar,FirstV,LastV);
939 for (Standard_Integer Ti = 1; Ti <= FirstPar.Length(); Ti++) {
940 TopoDS_Vertex V1 = TopoDS::Vertex(FirstV.Value(Ti));
941 TopoDS_Vertex V2 = TopoDS::Vertex(LastV .Value(Ti));
943 GeomAbs_Shape Continuity;
945 Trim.Project(FirstPar.Value(Ti),LastPar.Value(Ti),
946 CBis,PCurve1,PCurve2,Continuity);
948 //-------------------------------------
949 // Coding of the edge.
950 //-------------------------------------
951 myBuilder.MakeEdge(CurrentEdge, CBis,
952 BRepFill_Confusion());
954 myBuilder.UpdateVertex(V1,CBis->Value(CBis->FirstParameter()),
955 BRepFill_Confusion());
956 myBuilder.UpdateVertex(V2,CBis->Value(CBis->LastParameter()),
957 BRepFill_Confusion());
959 myBuilder.Add(CurrentEdge,V1.Oriented(TopAbs_FORWARD));
960 myBuilder.Add(CurrentEdge,V2.Oriented(TopAbs_REVERSED));
962 myBuilder.Range(CurrentEdge,
963 CBis->FirstParameter(),
964 CBis->LastParameter());
965 myBuilder.UpdateEdge(CurrentEdge,PCurve1,F[0],BRepFill_Confusion());
966 myBuilder.UpdateEdge(CurrentEdge,PCurve2,F[1],BRepFill_Confusion());
968 myBuilder.Continuity(CurrentEdge,F[0],F[1],Continuity);
973 sprintf(name,"ARCEDGE_%d_%d_%d",i,vv,Ti);
974 DBRep::Set(name,CurrentEdge);
977 //-------------------------------------------
978 // Storage of the edge for each of faces.
979 //-------------------------------------------
980 for (k = 0; k <= 1;k++) {
981 if (!MapBis.IsBound(F[k])) {
982 MapBis.Bind(F[k],EmptySeq);
985 //---------------------------------------------------------------
986 // orientation of the edge depends on the direction of the skin.
987 // skin => same orientation E[0] , inverted orientation E[2]
988 // if contreskin it is inverted.
989 //--------------------------------------------------------------
990 E[0].Orientation(OriEdgeInFace(E[0],F[0]));
991 E[2].Orientation(OriEdgeInFace(E[2],F[1]));
993 if (DistanceToOZ(VF) < DistanceToOZ(VL) ) {
995 MapBis(F[0]).Append(CurrentEdge.Oriented (E[0].Orientation()));
996 CurrentEdge.Orientation(TopAbs::Complement(E[2].Orientation()));
997 MapBis(F[1]).Append(CurrentEdge);
1001 MapBis(F[1]).Append(CurrentEdge.Oriented (E[2].Orientation()));
1002 CurrentEdge.Orientation(TopAbs::Complement(E[0].Orientation()));
1003 MapBis(F[0]).Append(CurrentEdge);
1007 //----------------------------------------------
1008 // Storage of vertices on parallel edges.
1009 // fill MapBis and MapVerPar.
1010 // VOnF for E[0] and E[2].
1011 // VOnL for E[1] and E[3].
1012 //----------------------------------------------
1013 for (k = 0; k <= 2; k = k+2) {
1014 if ( !MapSeqVer.IsBound(VF)) {
1015 if (!VOnF.IsEmpty()) {
1016 if (!MapBis.IsBound(E[k])) {
1017 MapBis .Bind(E[k],EmptySeq);
1018 MapVerPar.Bind(E[k],EmptySeqOfReal);
1020 for (Standard_Integer ii = 1; ii <= VOnF.Length(); ii++) {
1021 MapBis (E[k]).Append(VOnF.Value(ii));
1022 if (k == 0) MapVerPar (E[k]).Append(ParOnF.Value(ii).Y());
1023 else MapVerPar (E[k]).Append(ParOnF.Value(ii).Z());
1029 for (k = 1; k <= 3; k = k+2) {
1030 if ( !MapSeqVer.IsBound(VL)) {
1031 if (!VOnL.IsEmpty()) {
1032 if (!MapBis.IsBound(E[k])) {
1033 MapBis .Bind(E[k],EmptySeq);
1034 MapVerPar.Bind(E[k],EmptySeqOfReal);
1036 for (Standard_Integer ii = 1; ii <= VOnL.Length(); ii++) {
1037 MapBis(E[k]).Append(VOnL.Value(ii));
1038 if (k == 1) MapVerPar (E[k]).Append(ParOnL.Value(ii).Y());
1039 else MapVerPar (E[k]).Append(ParOnL.Value(ii).Z());
1045 //----------------------------------------------------------------
1046 // Edge [1] of the current face will be Edge [0] of the next face.
1047 // => copy of VonL in VonF. To avoid creating the same vertices twice.
1048 //-----------------------------------------------------------------
1050 MapSeqPar.Bind(VF,ParOnF);
1051 MapSeqVer.Bind(VF,VOnF);
1052 MapSeqPar.Bind(VL,ParOnL);
1053 MapSeqVer.Bind(VL,VOnL);
1060 cout << " End of Construction of edges and vertices on bissectrices"<<endl;
1064 //----------------------------------
1065 // Construction of parallel edges.
1066 //----------------------------------
1067 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape ite1;
1068 TopoDS_Shape CurrentProf,PrecProf;
1069 TopoDS_Face CurrentFace;
1070 TopoDS_Shape CurrentSpine;
1071 TopoDS_Vertex VCF,VCL;
1073 for (ite1.Initialize(myMap); ite1.More(); ite1.Next()) {
1074 CurrentSpine = ite1.Key();
1076 for (ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()){
1077 CurrentProf = ProfExp.Current();
1078 EdgeVertices(TopoDS::Edge(CurrentProf),VCF,VCL);
1079 CurrentEdge = TopoDS::Edge(myMap(CurrentSpine)(VCF).First());
1081 //-------------------------------------------------------------
1082 //RQ : Current Edge is oriented relatively to the face (oriented forward)
1083 // generated by edge CurrentProf .
1084 //-------------------------------------------------------------
1085 if (MapBis.IsBound(CurrentEdge)) {
1087 //--------------------------------------------------------
1088 // Find if one of two faces connected to the edge
1089 // belongs to volevo. The edges on this face serve
1090 // to eliminate certain vertices that can appear twice
1091 // on the parallel edge. These Vertices corespond to the
1092 // nodes of the map.
1093 //---------------------------------------------------------
1094 TopoDS_Shape FaceControle;
1095 Standard_Boolean YaFace = Standard_True;
1097 FaceControle = myMap(CurrentSpine)(CurrentProf).First();
1098 if (!MapBis.IsBound(FaceControle)){
1099 YaFace = Standard_False;
1100 if (!PrecProf.IsNull()) {
1101 FaceControle = myMap(CurrentSpine)(PrecProf).First();
1102 if (MapBis.IsBound(FaceControle)){
1103 YaFace = Standard_True;
1109 //------------------------------------------------------------
1110 // No connected face in the volevo => no parallel edge.
1111 //------------------------------------------------------------
1112 TopTools_SequenceOfShape S;
1113 TrimEdge (CurrentEdge,
1114 MapBis (FaceControle),
1115 MapBis (CurrentEdge) ,
1116 MapVerPar(CurrentEdge) , S);
1118 for ( k = 1; k <= S.Length(); k++) {
1119 myMap(CurrentSpine)(VCF).Append(S.Value(k));
1124 sprintf(name,"PAREDGE_%d_%d",++NbEDGES,k);
1125 DBRep::Set(name,S.Value(k));
1131 PrecProf = CurrentProf;
1134 //------------------------------------------------------------
1135 // Construction of the parallel edge from the last vertex of myProfile.
1136 //------------------------------------------------------------
1137 CurrentEdge = TopoDS::Edge(myMap(CurrentSpine)(VCL).First());
1139 if (MapBis.IsBound(CurrentEdge)) {
1140 Standard_Boolean YaFace = Standard_True;
1141 TopoDS_Shape FaceControle;
1143 FaceControle = myMap(CurrentSpine)(CurrentProf).First();
1144 if (!MapBis.IsBound(FaceControle)){
1145 YaFace = Standard_False;
1147 // the number of element of the list allows to know
1148 // if the edges have already been done (closed profile) .
1149 if (YaFace && myMap(CurrentSpine)(VCL).Extent()<= 1) {
1150 TopTools_SequenceOfShape S;
1151 TrimEdge (CurrentEdge,
1152 MapBis (FaceControle),
1153 MapBis (CurrentEdge) ,
1154 MapVerPar(CurrentEdge) , S);
1156 for ( k = 1; k <= S.Length(); k++) {
1157 myMap(CurrentSpine)(VCL).Append(S.Value(k));
1162 sprintf(name,"PAREDGE_%d_%d",++NbEDGES,k);
1163 DBRep::Set(name,S.Value(k));
1173 cout <<" End Construction of parallel edges "<<endl;
1177 //-------------------------------------------------------------------
1178 // Cut faces by edges.
1179 //-------------------------------------------------------------------
1180 for (ite1.Initialize(myMap); ite1.More(); ite1.Next()) {
1181 CurrentSpine = ite1.Key();
1183 for (ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()){
1184 CurrentProf = ProfExp.Current();
1185 CurrentFace = TopoDS::Face(myMap(CurrentSpine)(CurrentProf).First());
1186 myMap(CurrentSpine)(CurrentProf).Clear();
1188 if (MapBis.IsBound(CurrentFace)) {
1189 //----------------------------------------------------------
1190 // If the face does not contain edges that can limit it
1191 // it does not appear in volevo.
1192 // cut of face by edges can generate many faces.
1194 // Add edges generated on the edges parallel to the set
1195 // of edges that limit the face.
1197 //------------------------------------------------------------
1198 EdgeVertices(TopoDS::Edge(CurrentProf),VCF,VCL);
1200 TopTools_ListIteratorOfListOfShape itl;
1201 const TopTools_ListOfShape& LF = myMap(CurrentSpine)(VCF);
1203 TopAbs_Orientation Ori = OriEdgeInFace(TopoDS::Edge(LF.First()),
1205 for (itl.Initialize(LF), itl.Next(); itl.More(); itl.Next()) {
1206 TopoDS_Edge RE = TopoDS::Edge(itl.Value());
1207 MapBis(CurrentFace).Append(RE.Oriented(Ori));
1209 const TopTools_ListOfShape& LL = myMap(CurrentSpine)(VCL);
1210 Ori = OriEdgeInFace(TopoDS::Edge(LL.First()),CurrentFace);
1211 for (itl.Initialize(LL), itl.Next() ; itl.More(); itl.Next()) {
1212 TopoDS_Edge RE = TopoDS::Edge(itl.Value());
1213 MapBis(CurrentFace).Append(RE.Oriented(Ori));
1217 TopTools_SequenceOfShape S;
1219 TrimFace (CurrentFace, MapBis(CurrentFace), S);
1221 for (Standard_Integer ii = 1; ii <= S.Length(); ii++) {
1222 myBuilder.Add (myShape,S.Value(ii));
1223 myMap(CurrentSpine)(CurrentProf).Append(S.Value(ii));
1227 //-----------------------------------------------------------------
1228 // Removal of first edge (edge of origin) from lists of myMap
1229 // corresponding to vertices of the profile.
1230 //-----------------------------------------------------------------
1231 TopExp_Explorer Explo(myProfile,TopAbs_VERTEX);
1232 TopTools_MapOfShape vmap;
1234 for ( ; Explo.More(); Explo.Next()){
1235 if (vmap.Add(Explo.Current())) {
1236 myMap(CurrentSpine)(Explo.Current()).RemoveFirst();
1240 myIsDone = Standard_True;
1244 cout <<" End of construction of an elementary volevo."<<endl;
1246 sprintf(name,"VEVO_%d",++NbVEVOS);
1247 DBRep::Set(name,myShape);
1252 //=======================================================================
1253 //function : PlanarPerform
1255 //=======================================================================
1257 void BRepFill_Evolved::PlanarPerform (const TopoDS_Face& Sp,
1258 const TopoDS_Wire& Pr,
1259 const BRepMAT2d_BisectingLocus& Locus,
1260 BRepMAT2d_LinkTopoBilo& Link,
1261 const GeomAbs_JoinType Join)
1263 TopoDS_Shape aLocalShape = Sp.Oriented(TopAbs_FORWARD);
1264 mySpine = TopoDS::Face(aLocalShape);
1265 // mySpine = TopoDS::Face(Sp.Oriented(TopAbs_FORWARD));
1270 B.MakeCompound(TopoDS::Compound(myShape));
1272 BRepTools_WireExplorer ProfExp;
1273 TopExp_Explorer Exp,exp1,exp2;
1275 TopTools_DataMapOfShapeListOfShape EmptyMap;
1276 TopTools_ListOfShape EmptyList;
1277 TopTools_DataMapOfShapeShape MapVP;
1278 BRepFill_OffsetWire Paral;
1280 for (ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()){
1281 const TopoDS_Edge& E = ProfExp.Current();
1282 BRepAlgo_FaceRestrictor FR;
1283 BRepFill_OffsetAncestors OffAnc;
1286 EdgeVertices(E,V[0],V[1]);
1287 Standard_Real Alt = Altitud(V[0]);
1288 Standard_Real Offset[2];
1289 Offset[0] = DistanceToOZ(V[0]);
1290 Offset[1] = DistanceToOZ(V[1]);
1291 Standard_Boolean IsMinV1 = ( Offset[0] < Offset[1]);
1293 for (Standard_Integer i = 0; i <= 1; i++) {
1294 if (!MapVP.IsBound(V[i])) {
1295 //------------------------------------------------
1296 // Calculate parallel lines corresponding to vertices.
1297 //------------------------------------------------
1298 Paral.PerformWithBiLo(mySpine,Offset[i],Locus,Link,Join,Alt);
1299 OffAnc.Perform(Paral);
1300 MapVP.Bind(V[i],Paral.Shape());
1302 //-----------------------------
1303 // Update myMap (.)(V[i])
1304 //-----------------------------
1305 for (Exp.Init(Paral.Shape(),TopAbs_EDGE);
1308 const TopoDS_Edge& WC = TopoDS::Edge(Exp.Current());
1309 const TopoDS_Shape& GS = OffAnc.Ancestor(WC);
1310 if ( !myMap.IsBound(GS))
1311 myMap.Bind(GS, EmptyMap);
1312 if ( !myMap(GS).IsBound(V[i]))
1313 myMap(GS).Bind(V[i],Paral.GeneratedShapes(GS));
1316 TopoDS_Shape Rest = MapVP(V[i]);
1318 Standard_Boolean ToReverse = Standard_False;
1319 if ( ( IsMinV1 && (i==1)) || (!IsMinV1 && (i==0)) )
1320 ToReverse = Standard_True;
1322 if (!Rest.IsNull()) {
1323 if (Rest.ShapeType() == TopAbs_WIRE) {
1325 TopoDS_Shape aLocalShape = Rest.Reversed();
1326 TopoDS_Wire aWire = TopoDS::Wire(aLocalShape);
1330 FR.Add(TopoDS::Wire(Rest));
1333 for (Exp.Init(Rest,TopAbs_WIRE);Exp.More();Exp.Next()) {
1334 TopoDS_Wire WCop = TopoDS::Wire(Exp.Current());
1336 TopoDS_Shape aLocalShape = WCop.Reversed();
1337 TopoDS_Wire bWire = TopoDS::Wire(aLocalShape);
1338 // TopoDS_Wire bWire = TopoDS::Wire(WCop.Reversed());
1349 TopTools_DataMapIteratorOfDataMapOfShapeShape it(MapVP);
1350 Standard_Integer k = 0;
1351 for (; it.More(); it.Next()) {
1353 sprintf(name,"PARALI_%d",++k);
1354 DBRep::Set(name,it.Value());
1359 //----------------------------------------------------
1360 // Construction of faces limited by parallels.
1361 // - set to the height of the support face.
1362 //----------------------------------------------------
1363 gp_Trsf T; T.SetTranslation(gp_Vec(0,0,Alt));
1364 TopLoc_Location LT(T);
1365 TopoDS_Shape aLocalShape = mySpine.Moved(LT);
1366 FR.Init(TopoDS::Face(aLocalShape));
1367 // FR.Init(TopoDS::Face(mySpine.Moved(LT)));
1370 for ( ;FR.More(); FR.Next()) {
1371 const TopoDS_Face& F = FR.Current();
1373 //---------------------------------------
1374 // Update myMap(.)(E)
1375 //---------------------------------------
1376 for ( Exp.Init(F,TopAbs_EDGE); Exp.More(); Exp.Next()) {
1377 const TopoDS_Edge& CE = TopoDS::Edge(Exp.Current());
1378 if (OffAnc.HasAncestor(CE)) {
1379 const TopoDS_Shape& InitE = OffAnc.Ancestor(CE);
1380 if ( !myMap.IsBound(InitE))
1381 myMap.Bind(InitE, EmptyMap);
1382 if ( !myMap(InitE).IsBound(E))
1383 myMap(InitE).Bind(E,EmptyList);
1384 myMap(InitE)(E).Append(F);
1388 } // End loop on profile.
1392 //=======================================================================
1393 //function : VerticalPerform
1395 //=======================================================================
1397 void BRepFill_Evolved::VerticalPerform (const TopoDS_Face& Sp,
1398 const TopoDS_Wire& Pr,
1399 const BRepMAT2d_BisectingLocus& Locus,
1400 BRepMAT2d_LinkTopoBilo& Link,
1401 const GeomAbs_JoinType Join)
1403 TopoDS_Shape aLocalShape = Sp.Oriented(TopAbs_FORWARD);
1404 mySpine = TopoDS::Face(aLocalShape);
1405 // mySpine = TopoDS::Face(Sp.Oriented(TopAbs_FORWARD));
1410 B.MakeCompound(TopoDS::Compound(myShape));
1412 BRepTools_WireExplorer ProfExp;
1413 TopExp_Explorer Exp;
1414 BRepFill_OffsetWire Paral;
1415 BRepFill_OffsetAncestors OffAnc;
1416 TopoDS_Vertex V1,V2;
1418 Standard_Boolean First = Standard_True;
1420 TopTools_DataMapOfShapeListOfShape EmptyMap;
1422 for (ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()){
1423 const TopoDS_Edge& E = ProfExp.Current();
1424 EdgeVertices(E,V1,V2);
1425 Standard_Real Alt1 = Altitud(V1);
1426 Standard_Real Alt2 = Altitud(V2);
1429 Standard_Real Offset = DistanceToOZ(V1);
1430 if (Abs(Offset) < BRepFill_Confusion()) {
1433 Paral.PerformWithBiLo(mySpine,Offset,Locus,Link,Join,Alt1);
1434 OffAnc.Perform(Paral);
1435 Base = Paral.Shape();
1438 for (Exp.Init(Base,TopAbs_EDGE); Exp.More(); Exp.Next()) {
1439 const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
1440 const TopoDS_Shape& AE = OffAnc.Ancestor(E);
1441 if (!myMap.IsBound(AE)) {
1442 myMap.Bind(AE,EmptyMap);
1444 if (!myMap(AE).IsBound(V1)) {
1445 TopTools_ListOfShape L;
1446 myMap(AE).Bind(V1,L);
1448 myMap(AE)(V1).Append(E);
1450 First = Standard_False;
1457 sprintf(name,"PARALI_%d",++NbVEVOS);
1458 DBRep::Set(name,Base);
1462 BRepSweep_Prism PS(Base,gp_Vec(0,0,Alt2 - Alt1),Standard_False);
1466 sprintf(name,"PRISM_%d",NbVEVOS);
1467 DBRep::Set(name,PS.Shape());
1471 Base = PS.LastShape();
1473 for (Exp.Init(PS.Shape(),TopAbs_FACE); Exp.More(); Exp.Next()) {
1474 B.Add(myShape,Exp.Current());
1478 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape
1481 for (; it.More(); it.Next()) {
1482 const TopTools_ListOfShape& LOF = it.Value()(V1);
1483 TopTools_ListIteratorOfListOfShape itLOF(LOF);
1484 if (!myMap(it.Key()).IsBound(V2)) {
1485 TopTools_ListOfShape L;
1486 myMap(it.Key()).Bind(V2,L);
1489 if (!myMap(it.Key()).IsBound(E)) {
1490 TopTools_ListOfShape L;
1491 myMap(it.Key()).Bind(E,L);
1494 for (; itLOF.More(); itLOF.Next()) {
1495 const TopoDS_Shape& OS = itLOF.Value();
1496 myMap(it.Key())(V2).Append(PS.LastShape(OS));
1497 myMap(it.Key())(E).Append(PS.Shape(OS));
1503 //=======================================================================
1505 //purpose : Order the sequence of points by growing x.
1506 //=======================================================================
1508 static void Bubble(TColStd_SequenceOfReal& Seq)
1510 Standard_Boolean Invert = Standard_True;
1511 Standard_Integer NbPoints = Seq.Length();
1514 Invert = Standard_False;
1515 for ( Standard_Integer i = 1; i < NbPoints; i++) {
1516 if ( Seq.Value(i+1) < Seq.Value(i)) {
1517 Seq.Exchange(i,i+1);
1518 Invert = Standard_True;
1525 //=======================================================================
1526 //function : PrepareProfile
1527 //purpose : - Projection of the profile on the working plane.
1528 // - Cut of the profile at the extrema of distance from profile to axis Oz.
1529 // - Isolate vertical and horizontal parts.
1530 // - Reconstruction of wires starting from cut edges.
1531 // New wires stored in <WorkProf> are always at the same
1532 // side of axis OZ or mixed with it.
1533 //=======================================================================
1535 void BRepFill_Evolved::PrepareProfile(TopTools_ListOfShape& WorkProf,
1536 TopTools_DataMapOfShapeShape& MapProf )
1539 // Supposedly the profile is located so that the only transformation
1540 // to be carried out is a projection on plane yOz.
1542 // initialise the projection Plane and the Line to evaluate the extrema.
1543 Handle(Geom_Plane) Plane = new Geom_Plane(gp_Ax3(gp::YOZ()));
1544 Handle(Geom2d_Line) Line = new Geom2d_Line(gp::OY2d());
1546 // Map initial vertex -> projected vertex.
1547 TopTools_DataMapOfShapeShape MapVerRefMoved;
1549 TopoDS_Vertex V1,V2,VRef1,VRef2;
1552 TopTools_ListOfShape WP;
1556 BRepTools_WireExplorer Exp(myProfile) ;
1558 while (Exp.More()) {
1559 TopTools_ListOfShape Cuts;
1560 Standard_Boolean NewWire = Standard_False;
1561 const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
1564 CutEdgeProf (E ,Plane ,Line ,Cuts ,MapVerRefMoved);
1566 EdgeVertices(E,VRef1,VRef2);
1568 if ( Cuts.IsEmpty()) {
1569 // Neither extrema nor intersections nor vertices on the axis.
1574 while (!Cuts.IsEmpty()) {
1575 const TopoDS_Edge& NE = TopoDS::Edge(Cuts.First());
1577 EdgeVertices(NE,V1,V2);
1578 if (!MapProf.IsBound(V1)) MapProf.Bind(V1,E);
1579 if (!MapProf.IsBound(V2)) MapProf.Bind(V2,E);
1584 if (DistanceToOZ(V2) < BRepFill_Confusion() &&
1585 DistanceToOZ(V1) > BRepFill_Confusion()) {
1586 // NE ends on axis OZ => new wire
1587 if (Cuts.IsEmpty()) {
1588 // last part of the current edge
1589 // If it is not the last edge of myProfile
1590 // create a new wire.
1591 NewWire = Standard_True;
1602 if (Exp.More() && NewWire) {
1608 // In the list of Wires, find edges generating plane or vertical vevo.
1609 TopTools_ListIteratorOfListOfShape ite;
1610 TopoDS_Wire CurW,NW;
1614 for (ite.Initialize(WP); ite.More(); ite.Next()) {
1615 CurW = TopoDS::Wire(ite.Value());
1616 Standard_Boolean YaModif = Standard_False;
1617 for (EW.Init(CurW,TopAbs_EDGE); EW.More(); EW.Next()) {
1618 const TopoDS_Edge& EE = TopoDS::Edge(EW.Current());
1619 if (IsVertical(EE) || IsPlanar(EE)) {
1620 YaModif = Standard_True;
1626 //Status = 0 for the begining
1630 Standard_Integer Status = 0;
1632 for (EW.Init(CurW,TopAbs_EDGE); EW.More(); EW.Next()) {
1633 const TopoDS_Edge& EE = TopoDS::Edge(EW.Current());
1634 if (IsVertical(EE)) {
1637 WorkProf.Append(NW);
1641 else if (IsPlanar(EE)) {
1644 WorkProf.Append(NW);
1648 else if ( Status != 1) {
1650 WorkProf.Append(NW);
1657 WorkProf.Append(CurW);
1661 //connect vertices modified in MapProf;
1662 TopTools_DataMapIteratorOfDataMapOfShapeShape gilbert(MapVerRefMoved);
1663 for ( ;gilbert.More() ;gilbert.Next()) {
1664 MapProf.Bind(gilbert.Value(),gilbert.Key());
1669 //=======================================================================
1670 //function : PrepareSpine
1672 //=======================================================================
1674 void BRepFill_Evolved::PrepareSpine(TopoDS_Face& WorkSpine,
1675 TopTools_DataMapOfShapeShape& MapSpine)
1679 TopTools_ListOfShape Cuts;
1680 TopTools_ListIteratorOfListOfShape IteCuts;
1681 TopoDS_Vertex V1,V2;
1684 const Handle(Geom_Surface)& S = BRep_Tool::Surface (mySpine,L);
1685 Standard_Real TolF = BRep_Tool::Tolerance(mySpine);
1686 B.MakeFace(WorkSpine,S,L,TolF);
1688 for (TopoDS_Iterator IteF(mySpine) ; IteF.More(); IteF.Next()) {
1693 for (TopoDS_Iterator IteW(IteF.Value()); IteW.More(); IteW.Next()) {
1695 TopoDS_Edge E = TopoDS::Edge(IteW.Value());
1696 EdgeVertices(E,V1,V2);
1697 MapSpine.Bind(V1,V1);
1698 MapSpine.Bind(V2,V2);
1702 CutEdge (E, mySpine, Cuts);
1704 if (Cuts.IsEmpty()) {
1709 for (IteCuts.Initialize(Cuts); IteCuts.More(); IteCuts.Next()) {
1710 const TopoDS_Edge& NE = TopoDS::Edge(IteCuts.Value());
1712 MapSpine.Bind(NE,E);
1713 EdgeVertices(NE,V1,V2);
1714 if (!MapSpine.IsBound(V1)) MapSpine.Bind(V1,E);
1715 if (!MapSpine.IsBound(V2)) MapSpine.Bind(V2,E);
1719 B.Add(WorkSpine, NW);
1722 // Construct curves 3D of the spine
1723 BRepLib::BuildCurves3d(WorkSpine);
1728 sprintf(name,"workspine");
1729 DBRep::Set(name,WorkSpine);
1734 //=======================================================================
1735 //function : GeneratedShapes
1737 //=======================================================================
1739 const TopoDS_Shape& BRepFill_Evolved::Top() const
1744 //=======================================================================
1745 //function : GeneratedShapes
1747 //=======================================================================
1749 const TopoDS_Shape& BRepFill_Evolved::Bottom() const
1754 //=======================================================================
1755 //function : GeneratedShapes
1757 //=======================================================================
1759 const TopTools_ListOfShape& BRepFill_Evolved::GeneratedShapes (
1760 const TopoDS_Shape& SpineShape,
1761 const TopoDS_Shape& ProfShape )
1764 if (myMap .IsBound(SpineShape) &&
1765 myMap(SpineShape).IsBound(ProfShape) ) {
1766 return myMap(SpineShape)(ProfShape);
1769 static TopTools_ListOfShape Empty;
1774 //=======================================================================
1775 //function : Generated
1777 //=================================================================== ====
1779 BRepFill_DataMapOfShapeDataMapOfShapeListOfShape& BRepFill_Evolved::Generated()
1784 //=======================================================================
1785 //function : Compare
1787 //=======================================================================
1789 static TopAbs_Orientation Compare (const TopoDS_Edge& E1,
1790 const TopoDS_Edge& E2)
1792 TopAbs_Orientation OO = TopAbs_FORWARD;
1793 TopoDS_Vertex V1[2],V2[2];
1794 TopExp::Vertices (E1,V1[0],V1[1]);
1795 TopExp::Vertices (E2,V2[0],V2[1]);
1796 gp_Pnt P1 = BRep_Tool::Pnt(V1[0]);
1797 gp_Pnt P2 =BRep_Tool::Pnt(V2[0]);
1798 gp_Pnt P3 =BRep_Tool::Pnt(V2[1]);
1799 if (P1.Distance(P3) < P1.Distance(P2)) OO = TopAbs_REVERSED;
1804 //=======================================================================
1807 //=======================================================================
1809 void BRepFill_Evolved::Add( BRepFill_Evolved& Vevo,
1810 const TopoDS_Wire& Prof,
1811 BRepTools_Quilt& Glue)
1814 BRepFill_DataMapOfShapeDataMapOfShapeListOfShape& MapVevo = Vevo.Generated();
1815 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iteP;
1816 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape iteS;
1817 TopoDS_Shape CurrentSpine, CurrentProf;
1819 if (Vevo.Shape().IsNull()) return;
1821 //-------------------------------------------------
1822 // Find wires common to <me> and <Vevo>.
1823 //-------------------------------------------------
1825 TopExp_Explorer ExProf;
1826 for (ExProf.Init(Prof,TopAbs_VERTEX); ExProf.More(); ExProf.Next()) {
1827 const TopoDS_Shape& VV = ExProf.Current();
1828 //---------------------------------------------------------------
1829 // Parse edges generated by VV in myMap if they existent
1831 //---------------------------------------------------------------
1833 //------------------------------------------------- -------------
1834 // Note: the curves of of reinforced edges are in the same direction
1835 // if one remains on the same edge.
1836 // if one passes from left to the right they are inverted.
1837 //------------------------------------------------- -------------
1838 Standard_Boolean Commun = Standard_False;
1839 Relative(myProfile,Prof,
1844 for (iteS.Initialize(myMap); iteS.More(); iteS.Next()) {
1845 const TopoDS_Shape& SP = iteS.Key();
1846 if (iteS.Value().IsBound(VV) &&
1847 MapVevo.IsBound(SP) && MapVevo(SP).IsBound(VV)) {
1849 const TopTools_ListOfShape& MyList = myMap(SP)(VV);
1850 const TopTools_ListOfShape& VevoList = Vevo.GeneratedShapes(SP,VV);
1851 TopTools_ListIteratorOfListOfShape MyIte (MyList);
1852 TopTools_ListIteratorOfListOfShape VevoIte(VevoList);
1853 for (; MyIte.More(); MyIte.Next(), VevoIte.Next()) {
1854 const TopoDS_Edge& ME = TopoDS::Edge(MyIte .Value());
1855 const TopoDS_Edge& VE = TopoDS::Edge(VevoIte.Value());
1856 TopAbs_Orientation OG = Compare(ME,VE);
1857 TopoDS_Shape aLocalShape = VE.Oriented (TopAbs_FORWARD);
1858 TopoDS_Shape aLocalShape2 = ME.Oriented (OG);
1859 Glue.Bind(TopoDS::Edge(aLocalShape),TopoDS::Edge(aLocalShape2));
1860 // Glue.Bind(TopoDS::Edge(VE.Oriented (TopAbs_FORWARD)),
1861 // TopoDS::Edge(ME.Oriented (OG)));
1867 Glue.Add(Vevo.Shape());
1869 //----------------------------------------------------------
1870 // Add map of elements generate in Vevo in myMap.
1871 //----------------------------------------------------------
1872 TopTools_DataMapOfShapeListOfShape EmptyMap;
1873 TopTools_ListOfShape EmptyList;
1875 for (iteS.Initialize(MapVevo); iteS.More() ; iteS.Next()) {
1876 CurrentSpine = iteS.Key();
1877 for (iteP.Initialize(MapVevo(CurrentSpine)); iteP.More(); iteP.Next()) {
1878 CurrentProf = iteP.Key();
1879 if (!myMap.IsBound(CurrentSpine)) {
1880 //------------------------------------------------
1881 // The element of spine is not yet present .
1882 // => previous profile not on the border.
1883 //-------------------------------------------------
1884 myMap.Bind(CurrentSpine,EmptyMap);
1886 if (!myMap(CurrentSpine).IsBound(CurrentProf)) {
1887 myMap(CurrentSpine).Bind(CurrentProf,EmptyList);
1888 const TopTools_ListOfShape& GenShapes
1889 = MapVevo (CurrentSpine)(CurrentProf);
1890 TopTools_ListIteratorOfListOfShape itl (GenShapes);
1891 for (; itl.More(); itl.Next()) {
1892 // during Glue.Add the shared shapes are recreated.
1893 if (Glue.IsCopied(itl.Value()))
1894 myMap(CurrentSpine)(CurrentProf).Append(Glue.Copy(itl.Value()));
1896 myMap(CurrentSpine)(CurrentProf).Append(itl.Value());
1903 //=======================================================================
1904 //function : ChangeShape
1906 //=======================================================================
1908 TopoDS_Shape& BRepFill_Evolved::ChangeShape()
1913 //=======================================================================
1914 //function : Transfert
1916 //=======================================================================
1918 void BRepFill_Evolved::Transfert( BRepFill_Evolved& Vevo,
1919 const TopTools_DataMapOfShapeShape& MapProf,
1920 const TopTools_DataMapOfShapeShape& MapSpine,
1921 const TopLoc_Location& LS,
1922 const TopLoc_Location& InitLS,
1923 const TopLoc_Location& InitLP)
1925 //----------------------------------------------------------------
1926 // Transfer the shape from Vevo in myShape and Reposition shapes.
1927 //----------------------------------------------------------------
1928 myShape = Vevo.Shape();
1929 mySpine .Location(InitLS);
1930 myProfile.Location(InitLP);
1934 // Expecting for better, the Same Parameter is forced here
1935 // ( Pb Sameparameter between YaPlanar and Tuyaux
1938 TopExp_Explorer ex(myShape,TopAbs_EDGE);
1940 B.SameRange(TopoDS::Edge(ex.Current()), Standard_False);
1941 B.SameParameter(TopoDS::Edge(ex.Current()), Standard_False);
1942 BRepLib::SameParameter(TopoDS::Edge(ex.Current()));
1947 //--------------------------------------------------------------
1948 // Transfer of myMap of Vevo into myMap.
1949 //--------------------------------------------------------------
1950 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape iteS;
1951 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iteP;
1952 TopTools_DataMapOfShapeListOfShape EmptyMap;
1953 TopTools_ListOfShape EmptyList;
1954 TopoDS_Shape InitialSpine, InitialProf;
1956 BRepFill_DataMapOfShapeDataMapOfShapeListOfShape& MapVevo
1959 for (iteS.Initialize(MapVevo); iteS.More(); iteS.Next()) {
1960 InitialSpine = MapSpine(iteS.Key());
1961 InitialSpine.Move(LS);
1963 for (iteP.Initialize(MapVevo(iteS.Key())); iteP.More(); iteP.Next()) {
1964 InitialProf = MapProf (iteP.Key());
1965 InitialProf.Location(InitLP);
1967 TopTools_ListOfShape& GenShapes =
1968 MapVevo.ChangeFind(iteS.Key()).ChangeFind(iteP.Key());
1970 TopTools_ListIteratorOfListOfShape itl;
1971 for (itl.Initialize(GenShapes); itl.More(); itl.Next()) {
1972 itl.Value().Move(LS);
1975 if (!myMap.IsBound(InitialSpine)) {
1976 myMap.Bind(InitialSpine,EmptyMap);
1979 if (!myMap(InitialSpine).IsBound(InitialProf)) {
1980 myMap(InitialSpine).Bind(InitialProf,EmptyList);
1982 myMap(InitialSpine)(InitialProf).Append(GenShapes);
1985 //--------------------------------------------------------------
1986 // Transfer of Top and Bottom of Vevo in myTop and myBottom.
1987 //--------------------------------------------------------------
1988 myTop = Vevo.Top() ; myTop.Move(LS);
1989 myBottom = Vevo.Bottom(); myBottom.Move(LS);
1992 //=======================================================================
1995 //=======================================================================
1997 Standard_Boolean BRepFill_Evolved::IsDone() const
2002 //=======================================================================
2005 //=======================================================================
2007 const TopoDS_Shape& BRepFill_Evolved::Shape() const
2012 //=======================================================================
2013 //function : JoinType
2015 //=======================================================================
2017 GeomAbs_JoinType BRepFill_Evolved::JoinType() const
2022 //=======================================================================
2023 //function : AddTopAndBottom
2025 //=======================================================================
2027 void BRepFill_Evolved::AddTopAndBottom(BRepTools_Quilt& Glue)
2029 // return first and last vertex of the profile.
2031 TopExp::Vertices (myProfile,V[0],V[1]);
2032 if (V[0].IsSame(V[1])) return;
2034 TopTools_ListIteratorOfListOfShape itL;
2035 Standard_Boolean ToReverse=Standard_False;
2036 for (Standard_Integer i = 0; i<=1; i++) {
2039 // Construction of supports.
2040 gp_Pln S (0.,0.,1.,- Altitud(V[i]));
2041 TopoDS_Face F = BRepLib_MakeFace(S);
2044 TopExp_Explorer ExpSpine(mySpine,TopAbs_EDGE);
2045 TopTools_MapOfShape View;
2047 for (; ExpSpine.More(); ExpSpine.Next()) {
2048 const TopoDS_Edge& ES = TopoDS::Edge(ExpSpine.Current());
2049 const TopTools_ListOfShape& L = GeneratedShapes(ES,V[i]);
2050 Standard_Boolean ComputeOrientation = 0;
2052 for (itL.Initialize(L); itL.More(); itL.Next()) {
2053 const TopoDS_Edge& E = TopoDS::Edge(itL.Value());
2055 if (!ComputeOrientation) {
2056 BRepAdaptor_Curve C1(ES);
2057 BRepAdaptor_Curve C2(E);
2058 Standard_Real f,l,fs,ls;
2059 BRep_Tool::Range(E ,f ,l);
2060 BRep_Tool::Range(ES,fs,ls);
2061 Standard_Real u = 0.3*f + 0.7*l;
2062 Standard_Real us = 0.3*fs + 0.7*ls;
2065 C1.D1(us,P,V1); C2.D1(u,P,V2);
2066 ToReverse = (V1.Dot(V2) < 0.);
2067 ComputeOrientation = 1;
2070 TopAbs_Orientation Or = ES.Orientation();
2071 if (ToReverse) Or = TopAbs::Reverse(Or);
2072 TopoDS_Shape aLocalShape = E.Oriented(Or);
2073 Loop.AddConstEdge(TopoDS::Edge(aLocalShape));
2074 // Loop.AddConstEdge(TopoDS::Edge(E.Oriented(Or)));
2078 gp_Pnt PV = BRep_Tool::Pnt(V[i]);
2079 Standard_Boolean IsOut = PV.Y() < 0;
2081 for (ExpSpine.Init(mySpine,TopAbs_VERTEX); ExpSpine.More(); ExpSpine.Next()) {
2082 const TopoDS_Vertex& ES = TopoDS::Vertex(ExpSpine.Current());
2084 const TopTools_ListOfShape& L = GeneratedShapes(ES,V[i]);
2085 for (itL.Initialize(L); itL.More(); itL.Next()) {
2086 const TopoDS_Edge& E = TopoDS::Edge(itL.Value());
2087 if (!BRep_Tool::Degenerated(E)){
2088 // the center of circle (ie vertex) is IN the cap if vertex IsOut
2090 BRepAdaptor_Curve C(E);
2092 BRep_Tool::Range(E,f,l);
2093 Standard_Real u = 0.3*f + 0.7*l;
2094 gp_Pnt P = BRep_Tool::Pnt(ES);
2099 gp_Vec Prod = PPC.Crossed(VC);
2101 ToReverse = Prod.Z() < 0.;
2104 ToReverse = Prod.Z() > 0.;
2106 TopAbs_Orientation Or = TopAbs_FORWARD;
2107 if (ToReverse) Or = TopAbs_REVERSED;
2108 TopoDS_Shape aLocalShape = E.Oriented(Or);
2109 Loop.AddConstEdge(TopoDS::Edge(aLocalShape));
2110 // Loop.AddConstEdge(TopoDS::Edge(E.Oriented(Or)));
2117 Loop.WiresToFaces();
2118 const TopTools_ListOfShape& L = Loop.NewFaces();
2119 TopTools_ListIteratorOfListOfShape itL(L);
2121 // Maj of myTop and myBottom for the history
2122 // and addition of constructed faces.
2123 TopoDS_Compound Bouchon;
2125 B.MakeCompound(Bouchon);
2126 Standard_Integer j = 0;
2128 for (itL.Initialize(L); itL.More(); itL.Next()) {
2130 Glue.Add(itL.Value());
2131 if (j ==1 && i == 0) myTop = itL.Value();
2132 if (j ==1 && i == 1) myBottom = itL.Value();
2133 B.Add(Bouchon,itL.Value());
2135 if (i == 0 && j > 1) myTop = Bouchon;
2136 if (i == 1 && j > 1) myBottom = Bouchon;
2140 //================================================================== =====
2141 //function : MakePipe
2143 //=======================================================================
2145 void BRepFill_Evolved::MakeSolid()
2148 TopExp_Explorer exp(myShape,TopAbs_SHELL);
2149 Standard_Integer ish=0;
2150 TopoDS_Compound Res;
2153 B.MakeCompound(Res);
2155 for (; exp.More(); exp.Next()) {
2156 TopoDS_Shape Sh = exp.Current();
2159 BRepClass3d_SolidClassifier SC(Sol);
2160 SC.PerformInfinitePoint(BRepFill_Confusion());
2161 if (SC.State() == TopAbs_IN) {
2163 B.Add(Sol,Sh.Reversed());
2168 if (ish == 1) { myShape = Sol;}
2169 else { myShape = Res;}
2173 //=======================================================================
2174 //function : MakePipe
2176 //=======================================================================
2178 void BRepFill_Evolved::MakePipe(const TopoDS_Edge& SE,
2179 const gp_Ax3& AxeRef)
2181 BRepTools_WireExplorer ProfExp;
2182 TopExp_Explorer FaceExp;
2185 if (Side(myProfile,BRepFill_Confusion()) > 3) { // side right
2186 trsf.SetRotation(gp::OZ(),M_PI);
2188 TopLoc_Location DumLoc (trsf);
2189 TopoDS_Shape aLocalShape = myProfile.Moved(DumLoc);
2190 TopoDS_Wire DummyProf =
2191 PutProfilAt (TopoDS::Wire(aLocalShape),
2193 mySpine,Standard_True);
2194 // TopoDS_Wire DummyProf =
2195 // PutProfilAt (TopoDS::Wire(myProfile.Moved(DumLoc)),
2197 // mySpine,Standard_True);
2199 // Copy of the profile to avoid the accumulation of
2200 // locations on the Edges of myProfile!
2202 Handle(BRepTools_TrsfModification) TrsfMod
2203 = new BRepTools_TrsfModification(gp_Trsf());
2204 BRepTools_Modifier Modif(DummyProf,TrsfMod);
2206 TopoDS_Wire GenProf = TopoDS::Wire(Modif.ModifiedShape(DummyProf));
2211 sprintf(name,"EVOLBASE_%d",++NbFACES);
2212 DBRep::Set(name,SE);
2213 sprintf(name,"EVOLPROF_%d",NbFACES);
2214 DBRep::Set(name,GenProf);
2218 BRepFill_Pipe Pipe(BRepLib_MakeWire(SE), GenProf);
2219 //BRepFill_Pipe Pipe = BRepFill_Pipe(BRepLib_MakeWire(SE),GenProf);
2224 sprintf(name,"EVOL_%d",++NbFACES);
2225 DBRep::Set(name,Pipe.Shape());
2228 //---------------------------------------------
2229 // Arrangement of Tubes in myMap.
2230 //---------------------------------------------
2232 BRepTools_WireExplorer GenProfExp;
2233 TopTools_ListOfShape L;
2234 TopoDS_Vertex VF,VL,VFG,VLG;
2235 Standard_Boolean FirstVertex = Standard_True;
2236 TopTools_DataMapOfShapeListOfShape P;
2240 for (ProfExp.Init(myProfile),GenProfExp.Init(GenProf);
2242 ProfExp.Next(),GenProfExp.Next()) {
2244 EdgeVertices(ProfExp .Current(),VF ,VL);
2245 EdgeVertices(GenProfExp.Current(),VFG,VLG);
2248 myMap(SE).Bind(VF,L);
2249 myMap(SE)(VF).Append(Pipe.Edge(SE,VFG));
2250 FirstVertex = Standard_False;
2252 myMap(SE).Bind(VL,L);
2253 myMap(SE)(VL).Append(Pipe.Edge(SE,VLG));
2254 myMap(SE).Bind(ProfExp.Current(),L);
2255 myMap(SE)(ProfExp.Current()).Append
2256 (Pipe.Face(SE,GenProfExp.Current()));
2261 //=======================================================================
2262 //function : MakeRevol
2264 //=======================================================================
2266 void BRepFill_Evolved::MakeRevol(const TopoDS_Edge& SE,
2267 const TopoDS_Vertex& VLast,
2268 const gp_Ax3& AxeRef)
2270 BRepTools_WireExplorer ProfExp;
2271 TopExp_Explorer FaceExp;
2274 if (Side(myProfile,BRepFill_Confusion()) > 3) { // side right
2275 trsf.SetRotation(gp::OZ(),M_PI);
2277 TopLoc_Location DumLoc (trsf);
2278 TopoDS_Shape aLocalShape = myProfile.Moved(DumLoc);
2279 TopoDS_Wire GenProf =
2280 PutProfilAt (TopoDS::Wire(aLocalShape),
2282 mySpine,Standard_False);
2283 // TopoDS_Wire GenProf =
2284 // PutProfilAt (TopoDS::Wire(myProfile.Moved(DumLoc)),
2286 // mySpine,Standard_False);
2288 gp_Ax1 AxeRev( BRep_Tool::Pnt(VLast), -gp::DZ());
2290 // Position of the sewing on the edge of the spine
2291 // so that the bissectrices didn't cross the sewings.
2293 dummy.SetRotation(AxeRev, 1.5*M_PI);
2294 TopLoc_Location DummyLoc(dummy);
2295 GenProf.Move(DummyLoc);
2297 BRepSweep_Revol Rev(GenProf,AxeRev,Standard_True);
2302 sprintf(name,"EVOLBASE_%d",++NbFACES);
2303 DrawTrSurf::Set(name,new Geom_Line(AxeRev));
2304 // DrawTrSurf::Set(name,new Geom_Line(AxeRev));
2305 sprintf(name,"EVOLPROF_%d",NbFACES);
2306 DBRep::Set(name,GenProf);
2308 sprintf(name,"EVOL_%d",NbFACES);
2309 DBRep::Set(name,Rev.Shape());
2312 //--------------------------------------------
2313 // Arrangement of revolutions in myMap.
2314 //---------------------------------------------
2315 BRepTools_WireExplorer GenProfExp;
2316 TopTools_ListOfShape L;
2317 TopoDS_Vertex VF,VL,VFG,VLG;
2318 Standard_Boolean FirstVertex = Standard_True;
2319 TopTools_DataMapOfShapeListOfShape R;
2321 myMap.Bind(VLast,R);
2323 for (ProfExp.Init(myProfile),GenProfExp.Init(GenProf);
2325 ProfExp.Next(),GenProfExp.Next()) {
2327 EdgeVertices(ProfExp .Current(),VF ,VL);
2328 EdgeVertices(GenProfExp.Current(),VFG,VLG);
2330 TopAbs_Orientation Or = GenProfExp.Current().Orientation();
2333 myMap(VLast).Bind(VF,L);
2334 const TopoDS_Shape& RV = Rev.Shape(VFG);
2335 // TopAbs_Orientation OO = TopAbs::Compose(RV.Orientation(),Or);
2336 TopAbs_Orientation OO = RV.Orientation();
2337 myMap(VLast)(VF).Append(RV.Oriented(OO));
2338 FirstVertex = Standard_False;
2340 myMap(VLast).Bind(ProfExp.Current(),L);
2341 const TopoDS_Shape& RF = Rev.Shape(GenProfExp.Current());
2342 TopAbs_Orientation OO = TopAbs::Compose(RF.Orientation(),Or);
2344 myMap(VLast)(ProfExp.Current()).Append(RF.Oriented(OO));
2345 myMap(VLast).Bind(VL,L);
2346 const TopoDS_Shape& RV = Rev.Shape(VLG);
2347 // OO = TopAbs::Compose(RV.Orientation(),Or);
2348 OO = RV.Orientation();
2349 myMap(VLast)(VL).Append(RV.Oriented(OO));
2353 //=======================================================================
2354 //function : FindLocation
2356 //=======================================================================
2358 TopLoc_Location BRepFill_Evolved::FindLocation(const TopoDS_Face& Face)
2362 Handle(Geom_Surface) S;
2363 S = BRep_Tool::Surface(Face, L);
2365 if ( !S->IsKind(STANDARD_TYPE(Geom_Plane))) {
2366 BRepLib_FindSurface FS( Face, -1, Standard_True);
2372 Standard_NoSuchObject::Raise
2373 ("BRepFill_Evolved : The Face is not planar");
2376 if (!L.IsIdentity())
2377 S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
2379 Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(S);
2380 gp_Ax3 Axis = P->Position();
2383 gp_Ax3 AxeRef(gp_Pnt(0.,0.,0.),
2386 T.SetTransformation(AxeRef,Axis);
2388 return TopLoc_Location(T);
2392 //=======================================================================
2393 //function : TransformInitWork
2395 //=======================================================================
2397 void BRepFill_Evolved::TransformInitWork(const TopLoc_Location& LS,
2398 const TopLoc_Location& LP)
2406 sprintf(name,"movedspine");
2407 TopoDS_Face SL = mySpine;
2408 DBRep::Set(name,SL);
2409 sprintf(name,"movedprofile");
2410 TopoDS_Wire PL = myProfile;
2411 DBRep::Set(name,PL);
2417 //=======================================================================
2418 //function : ContinuityOnOffsetEdge
2419 //purpose : Coding of regularities on edges parallel to CutVevo
2420 // common to left and right parts of volevo.
2421 //=======================================================================
2422 void BRepFill_Evolved::ContinuityOnOffsetEdge (const TopTools_ListOfShape&)
2424 BRepTools_WireExplorer WExp ;
2425 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape iteS;
2426 TopoDS_Vertex VF,VL,V;
2427 TopoDS_Edge PrecE,CurE,FirstE;
2431 WExp.Init(myProfile);
2432 FirstE = WExp.Current();
2434 EdgeVertices (FirstE, VF, V);
2435 if (WExp.More()) WExp.Next();
2437 for (; WExp.More(); WExp.Next()) {
2438 CurE = WExp.Current();
2439 V = WExp.CurrentVertex();
2441 if (DistanceToOZ(V) <= BRepFill_Confusion()) {
2442 // the regularities are already coded on the edges of elementary volevos
2443 Standard_Real U1 = BRep_Tool::Parameter(V,CurE);
2444 Standard_Real U2 = BRep_Tool::Parameter(V,PrecE);
2445 BRepAdaptor_Curve Curve1(CurE);
2446 BRepAdaptor_Curve Curve2(PrecE);
2447 GeomAbs_Shape Continuity = BRepLProp::Continuity(Curve1,Curve2,U1,U2);
2449 if (Continuity >=1) {
2450 //-----------------------------------------------------
2451 //Code continuity for all edges generated by V.
2452 //-----------------------------------------------------
2453 for (iteS.Initialize(myMap); iteS.More(); iteS.Next()) {
2454 const TopoDS_Shape& SP = iteS.Key();
2455 if (myMap (SP).IsBound(V)
2456 && myMap (SP).IsBound(CurE) && myMap (SP).IsBound(PrecE)){
2457 if (!myMap(SP)(V) .IsEmpty() &&
2458 !myMap(SP)(CurE) .IsEmpty() &&
2459 !myMap(SP)(PrecE).IsEmpty() )
2460 B.Continuity (TopoDS::Edge(myMap(SP)(V) .First()),
2461 TopoDS::Face(myMap(SP)(CurE) .First()),
2462 TopoDS::Face(myMap(SP)(PrecE).First()),
2471 EdgeVertices (PrecE, V, VL);
2473 if (VF.IsSame(VL)) {
2475 Standard_Real U1 = BRep_Tool::Parameter(VF,CurE);
2476 Standard_Real U2 = BRep_Tool::Parameter(VF,FirstE);
2477 BRepAdaptor_Curve Curve1(CurE);
2478 BRepAdaptor_Curve Curve2(FirstE);
2479 GeomAbs_Shape Continuity = BRepLProp::Continuity(Curve1,Curve2,U1,U2);
2481 if (Continuity >=1) {
2482 //---------------------------------------------
2483 //Code continuity for all edges generated by V.
2484 //---------------------------------------------
2485 for (iteS.Initialize(myMap); iteS.More(); iteS.Next()) {
2486 const TopoDS_Shape& SP = iteS.Key();
2487 if (myMap (SP).IsBound(VF)
2488 && myMap (SP).IsBound(CurE) && myMap (SP).IsBound(FirstE)){
2489 if (!myMap(SP)(VF) .IsEmpty() &&
2490 !myMap(SP)(CurE) .IsEmpty() &&
2491 !myMap(SP)(FirstE).IsEmpty() )
2492 B.Continuity (TopoDS::Edge(myMap(SP)(VF) .First()),
2493 TopoDS::Face(myMap(SP)(CurE) .First()),
2494 TopoDS::Face(myMap(SP)(FirstE).First()),
2502 //=======================================================================
2503 //function : AddDegeneratedEdge
2504 //purpose : degenerated edges can be missing in some face
2505 // the missing degenerated edges have vertices corresponding
2506 // to node of the map.
2507 // Now it is enough to compare points UV of vertices
2508 // on edges with a certain tolerance.
2509 //=======================================================================
2511 static void AddDegeneratedEdge(TopoDS_Face& F,
2515 Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
2516 if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
2517 Handle(Geom_Surface) SB = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
2518 if (SB->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
2523 if (S->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
2529 Standard_Real TolConf = 1.e-4;
2531 Standard_Boolean Change = Standard_True;
2534 Change = Standard_False;
2535 BRepTools_WireExplorer WE(W,F);
2536 gp_Pnt2d PF,PrevP,P1,P2;
2537 TopoDS_Vertex VF,V1,V2;
2539 for (; WE.More(); WE.Next()) {
2540 const TopoDS_Edge& CE = WE.Current();
2541 EdgeVertices (CE,V1,V2);
2542 if (CE.Orientation() == TopAbs_REVERSED)
2543 BRep_Tool::UVPoints(CE, F, P2, P1);
2545 BRep_Tool::UVPoints(CE, F, P1, P2);
2551 if (!P1.IsEqual(PrevP,TolConf)) {
2552 // degenerated edge to be inserted.
2553 Change = Standard_True;
2554 gp_Vec2d V(PrevP,P1);
2555 Handle(Geom2d_Line) C2d = new Geom2d_Line(PrevP,gp_Dir2d(V));
2556 Standard_Real f = 0, l = PrevP.Distance(P1);
2557 Handle(Geom2d_TrimmedCurve) CT = new Geom2d_TrimmedCurve(C2d,f,l);
2558 TopoDS_Edge NE = BRepLib_MakeEdge(C2d,S);
2559 B.Degenerated(NE,Standard_True);
2560 B.Add(NE,V1.Oriented(TopAbs_FORWARD));
2561 B.Add(NE,V1.Oriented(TopAbs_REVERSED));
2569 if (!Change && VF.IsSame(V2)) { // closed
2570 if (!PF.IsEqual(P2,TolConf)) {
2571 // Degenerated edge to be inserted.
2572 Change = Standard_True;
2574 Handle(Geom2d_Line) C2d = new Geom2d_Line(P2,gp_Dir2d(V));
2575 Standard_Real f = 0, l = P2.Distance(PF);
2576 Handle(Geom2d_TrimmedCurve) CT = new Geom2d_TrimmedCurve(C2d,f,l);
2577 TopoDS_Edge NE = BRepLib_MakeEdge(C2d,S);
2578 B.Degenerated(NE,Standard_True);
2579 B.Add(NE,VF.Oriented(TopAbs_FORWARD));
2580 B.Add(NE,VF.Oriented(TopAbs_REVERSED));
2588 //=======================================================================
2589 //function : TrimFace
2591 //=======================================================================
2593 void TrimFace(const TopoDS_Face& Face,
2594 TopTools_SequenceOfShape& TheEdges,
2595 TopTools_SequenceOfShape& S)
2599 Standard_Integer NB = TheEdges.Length();
2602 cout << " TrimFace " << ++NbTRIMFACES;
2603 cout << " : " << NB << " edges within the restriction" << endl;
2604 for ( Standard_Integer j = 1; j <= NB; j++) {
2605 sprintf(name,"TRIMEDGE_%d_%d",NbTRIMFACES,j);
2606 DBRep::Set(name,TopoDS::Edge(TheEdges.Value(j)));
2612 //--------------------------------------
2613 // Creation of wires limiting faces.
2614 //--------------------------------------
2615 BRep_Builder TheBuilder;
2617 Standard_Integer NbEdges;
2618 Standard_Boolean NewWire = Standard_True;
2619 Standard_Boolean AddEdge = Standard_False;
2620 TopoDS_Wire GoodWire;
2623 while ( !TheEdges.IsEmpty()) {
2625 BRepLib_MakeWire MWire(TopoDS::Edge(TheEdges.First()));
2626 GoodWire = MWire.Wire();
2628 NbEdges = TheEdges.Length();
2629 NewWire = Standard_False;
2632 AddEdge = Standard_False;
2634 for ( Standard_Integer i = 1; i <= NbEdges && !AddEdge; i++) {
2635 const TopoDS_Edge& E = TopoDS::Edge(TheEdges.Value(i));
2636 if ( BRep_Tool::Degenerated(E)) {
2638 AddEdge = Standard_True;
2639 NbEdges = TheEdges.Length();
2640 GoodWire = MWire.Wire();
2644 if ( MWire.Error() == BRepLib_WireDone) {
2645 // the connection is successful
2646 // it is removed from the sequence and one restarts from the beginning.
2648 AddEdge = Standard_True;
2649 NbEdges = TheEdges.Length();
2650 GoodWire = MWire.Wire();
2654 NewWire = (!AddEdge);
2656 TopoDS_Shape aLocalShape = Face.EmptyCopied();
2657 TopoDS_Face FaceCut = TopoDS::Face(aLocalShape);
2658 // TopoDS_Face FaceCut = TopoDS::Face(Face.EmptyCopied());
2659 FaceCut.Orientation(TopAbs_FORWARD);
2660 BRepTools::Update (FaceCut);
2661 AddDegeneratedEdge (FaceCut,GoodWire);
2662 TheBuilder.Add (FaceCut,GoodWire);
2663 FaceCut.Orientation(Face.Orientation());
2670 //=======================================================================
2671 //function : PutProfilAt
2673 //=======================================================================
2675 const TopoDS_Wire PutProfilAt (const TopoDS_Wire& ProfRef,
2676 const gp_Ax3& AxeRef,
2677 const TopoDS_Edge& E,
2678 const TopoDS_Face& F,
2679 const Standard_Boolean AtStart)
2684 Handle(Geom2d_Curve) C2d;
2685 Standard_Real First,Last;
2687 C2d = BRep_Tool::CurveOnSurface(E,F,First,Last);
2689 Standard_ConstructionError::Raise("ConstructionError in PutProfilAt");
2692 if (E.Orientation() == TopAbs_REVERSED) {
2693 if (!AtStart) C2d->D1(First,P,D1);else C2d->D1(Last,P,D1);
2697 if (!AtStart) C2d->D1(Last,P,D1) ;else C2d->D1(First,P,D1);
2699 gp_Pnt P3d(P.X() ,P.Y() ,0.);
2700 gp_Vec V3d(D1.X(),D1.Y(),0.);
2702 gp_Ax3 Ax( P3d, gp::DZ(), V3d);
2704 Trans.SetTransformation(Ax,AxeRef);
2705 TopoDS_Shape aLocalShape = ProfRef.Moved(TopLoc_Location(Trans));
2706 Prof = TopoDS::Wire(aLocalShape);
2707 // Prof = TopoDS::Wire(ProfRef.Moved(TopLoc_Location(Trans)));
2712 //=======================================================================
2713 //function : TrimEdge
2715 //=======================================================================
2717 void TrimEdge (const TopoDS_Edge& Edge,
2718 const TopTools_SequenceOfShape& TheEdgesControle,
2719 TopTools_SequenceOfShape& TheVer,
2720 TColStd_SequenceOfReal& ThePar,
2721 TopTools_SequenceOfShape& S)
2723 Standard_Boolean Change = Standard_True;
2724 BRep_Builder TheBuilder;
2726 //------------------------------------------------------------
2727 // Parse two sequences depending on the parameter on the edge.
2728 //------------------------------------------------------------
2730 Change = Standard_False;
2731 for (Standard_Integer i = 1; i < ThePar.Length(); i++) {
2732 if (ThePar.Value(i) > ThePar.Value(i+1)) {
2733 ThePar.Exchange(i,i+1);
2734 TheVer.Exchange(i,i+1);
2735 Change = Standard_True;
2740 //----------------------------------------------------------
2741 // If a vertex is not in the proofing point, it is removed.
2742 //----------------------------------------------------------
2743 if (!BRep_Tool::Degenerated(Edge)) {
2744 for (Standard_Integer k = 1; k <= TheVer.Length(); k ++) {
2745 if ( DoubleOrNotInFace (TheEdgesControle,
2746 TopoDS::Vertex(TheVer.Value(k)))) {
2754 //-------------------------------------------------------------------
2755 // Processing of double vertices for non-degenerated edges.
2756 // If a vertex_double appears twice in the edges of control,
2757 // the vertex is eliminated .
2758 // otherwise its only representation is preserved.
2759 //-------------------------------------------------------------------
2760 if (!BRep_Tool::Degenerated(Edge)) {
2761 for (Standard_Integer k = 1; k < TheVer.Length(); k ++) {
2762 if (TheVer.Value(k).IsSame(TheVer.Value(k+1))) {
2765 if ( DoubleOrNotInFace (TheEdgesControle,
2766 TopoDS::Vertex(TheVer.Value(k)))) {
2776 //-----------------------------------------------------------
2777 // Creation of edges.
2778 // the number of vertices should be even. The edges to be created leave
2779 // from a vertex with uneven index i to vertex i+1;
2780 //-----------------------------------------------------------
2781 for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) {
2782 TopoDS_Shape aLocalShape = Edge.EmptyCopied();
2783 TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape);
2784 // TopoDS_Edge NewEdge = TopoDS::Edge(Edge.EmptyCopied());
2786 if (NewEdge.Orientation() == TopAbs_REVERSED) {
2787 TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_REVERSED));
2788 TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD));
2791 TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_FORWARD));
2792 TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED));
2794 TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1));
2795 // modified by NIZHNY-EAP Wed Dec 22 12:09:48 1999 ___BEGIN___
2796 BRepLib::UpdateTolerances(NewEdge,Standard_False);
2797 // modified by NIZHNY-EAP Wed Dec 22 13:34:19 1999 ___END___
2802 //=======================================================================
2803 //function : ComputeIntervals
2805 //=======================================================================
2807 void ComputeIntervals (const TopTools_SequenceOfShape& VOnF,
2808 const TopTools_SequenceOfShape& VOnL,
2809 const TColgp_SequenceOfPnt& ParOnF,
2810 const TColgp_SequenceOfPnt& ParOnL,
2811 const BRepFill_TrimSurfaceTool& Trim,
2812 const Handle(Geom2d_Curve)& Bis,
2813 const TopoDS_Vertex& VS,
2814 const TopoDS_Vertex& VE,
2815 TColStd_SequenceOfReal& FirstPar,
2816 TColStd_SequenceOfReal& LastPar,
2817 TopTools_SequenceOfShape& FirstV,
2818 TopTools_SequenceOfShape& LastV )
2820 Standard_Integer IOnF = 1,IOnL = 1;
2821 Standard_Real U1 = 0.,U2;
2825 U1 = Bis->FirstParameter();
2828 while ( IOnF <= VOnF.Length() || IOnL <= VOnL.Length()) {
2829 //---------------------------------------------------------
2830 // Return the smallest parameter on the bissectrice
2831 // correponding to the current positions IOnF,IOnL.
2832 //---------------------------------------------------------
2833 if ( IOnL > VOnL.Length() ||
2834 (IOnF <= VOnF.Length() &&
2835 ParOnF.Value(IOnF).X() < ParOnL.Value(IOnL).X())) {
2837 U2 = ParOnF.Value(IOnF).X();
2838 V2 = VOnF .Value(IOnF);
2842 U2 = ParOnL.Value(IOnL).X();
2843 V2 = VOnL .Value(IOnL);
2846 //---------------------------------------------------------------------
2847 // When V2 and V1 are different the medium point P of the
2848 // interval is tested compared to the face. If P is in the face the interval
2850 //---------------------------------------------------------------------
2851 if (!V1.IsNull() && !V2.IsSame(V1)) {
2852 gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
2853 if (Trim.IsOnFace(P)) {
2854 FirstPar.Append(U1); LastPar .Append(U2);
2855 FirstV. Append(V1); LastV .Append(V2);
2863 U2 = Bis->LastParameter();
2865 if (!V2.IsSame(V1)) {
2866 gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
2867 if (Trim.IsOnFace(P)) {
2868 FirstPar.Append(U1); LastPar .Append(U2);
2869 FirstV.Append (V1); LastV .Append(V2);
2876 //=======================================================================
2877 //function : Relative
2878 //purpose : Commun is true if two wires have V in common
2879 // return FORWARD if the wires near the vertex are at
2880 // the same side. otherwise REVERSED.
2881 //=======================================================================
2882 static TopAbs_Orientation Relative (const TopoDS_Wire& W1,
2883 const TopoDS_Wire& W2,
2884 const TopoDS_Vertex& V,
2885 Standard_Boolean& Commun)
2887 TopExp_Explorer Exp;
2889 TopoDS_Vertex V1,V2;
2891 for (Exp.Init(W1,TopAbs_EDGE); Exp.More(); Exp.Next()) {
2892 const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
2893 TopExp::Vertices(E,V1,V2);
2894 if (V1.IsSame(V) || V2.IsSame(V)) {
2899 for (Exp.Init(W2,TopAbs_EDGE); Exp.More(); Exp.Next()) {
2900 const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
2901 TopExp::Vertices(E,V1,V2);
2902 if (V1.IsSame(V) || V2.IsSame(V)) {
2908 if (E1.IsNull() || E2.IsNull()) {
2909 Commun = Standard_False;
2910 return TopAbs_FORWARD;
2912 Commun = Standard_True;
2914 TopoDS_Wire WW1 = BRepLib_MakeWire(E1);
2915 TopoDS_Wire WW2 = BRepLib_MakeWire(E2);
2916 Standard_Real Tol = BRepFill_Confusion();
2917 if (Side(WW1,Tol) < 4 && Side(WW2,Tol) < 4) // two to the left
2918 return TopAbs_FORWARD;
2919 if (Side(WW1,Tol) > 4 && Side(WW2,Tol) > 4) // two to the right
2920 return TopAbs_FORWARD;
2922 return TopAbs_REVERSED;
2924 //=======================================================================
2925 //function : OriEdgeInFace
2927 //=======================================================================
2929 TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E,
2930 const TopoDS_Face& F )
2933 TopExp_Explorer Exp(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
2935 for (; Exp.More() ;Exp.Next()) {
2936 if (Exp.Current().IsSame(E)) {
2937 return Exp.Current().Orientation();
2940 Standard_ConstructionError::Raise("BRepFill_Evolved::OriEdgeInFace");
2941 return E.Orientation();
2946 //=======================================================================
2947 //function : IsOnFace
2948 //purpose : Return the position of the point defined by d1
2949 // in the face defined by d2 d3.
2951 // 0 : the point is out of the face.
2952 // 1 : the point is on edge corresponding to d2.
2953 // 2 : the point is inside the face.
2954 // 3 : the point is on edge corresponding to d3.
2955 //=======================================================================
2957 Standard_Integer PosOnFace (Standard_Real d1,
2961 if (Abs(d1 - d2) <= BRepFill_Confusion())
2963 if (Abs(d1 - d3) <= BRepFill_Confusion())
2967 if (d1 > (d2 + BRepFill_Confusion()) &&
2968 d1 < (d3 - BRepFill_Confusion()) )
2972 if (d1 > (d3 + BRepFill_Confusion()) &&
2973 d1 < (d2 - BRepFill_Confusion()) )
2979 //=======================================================================
2980 //function : DoubleOrNotInFace
2981 //purpose : Return True if V appears zero or two times in the sequence
2983 //=======================================================================
2985 Standard_Boolean DoubleOrNotInFace(const TopTools_SequenceOfShape& EC,
2986 const TopoDS_Vertex& V)
2988 Standard_Boolean Vu = Standard_False;
2990 for (Standard_Integer i = 1; i <= EC.Length(); i++) {
2991 TopoDS_Vertex V1,V2;
2992 TopExp::Vertices(TopoDS::Edge(EC.Value(i)),V1,V2);
2994 if (Vu) return Standard_True;
2995 else Vu = Standard_True;
2998 if (Vu) return Standard_True;
2999 else Vu = Standard_True;
3002 if (Vu) return Standard_False;
3003 else return Standard_True;
3007 //=======================================================================
3008 //function : DistanceToOZ
3010 //=======================================================================
3012 Standard_Real DistanceToOZ (const TopoDS_Vertex& V)
3014 gp_Pnt PV3d = BRep_Tool::Pnt(V);
3015 return Abs(PV3d.Y());
3018 //=======================================================================
3019 //function : Altitud
3021 //=======================================================================
3023 Standard_Real Altitud (const TopoDS_Vertex& V)
3025 gp_Pnt PV3d = BRep_Tool::Pnt(V);
3029 //=======================================================================
3030 //function : SimpleExpression
3032 //=======================================================================
3034 void SimpleExpression (const Bisector_Bisec& B,
3035 Handle(Geom2d_Curve)& Bis)
3039 Handle(Standard_Type) BT = Bis->DynamicType();
3040 if (BT == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
3041 Handle(Geom2d_TrimmedCurve) TrBis
3042 = Handle(Geom2d_TrimmedCurve)::DownCast(Bis);
3043 Handle(Geom2d_Curve) BasBis = TrBis->BasisCurve();
3044 BT = BasBis->DynamicType();
3045 if (BT == STANDARD_TYPE(Bisector_BisecAna)) {
3046 Bis = Handle(Bisector_BisecAna)::DownCast(BasBis)->Geom2dCurve();
3047 Bis = new Geom2d_TrimmedCurve (Bis,
3048 TrBis->FirstParameter(),
3049 TrBis->LastParameter());
3054 //=======================================================================
3055 //function : CutEdgeProf
3056 //purpose : Projection and Cut of an edge at extrema of distance to axis OZ.
3057 //=======================================================================
3059 void CutEdgeProf (const TopoDS_Edge& E,
3060 const Handle(Geom_Plane)& Plane,
3061 const Handle(Geom2d_Line)& Line,
3062 TopTools_ListOfShape& Cuts,
3063 TopTools_DataMapOfShapeShape& MapVerRefMoved)
3068 Handle(Geom_Curve) C;
3069 Handle(Geom_TrimmedCurve) CT;
3070 Handle(Geom2d_Curve) C2d;
3073 // Return the curve associated to each Edge
3074 C = BRep_Tool::Curve(E,L,f,l);
3075 CT = new Geom_TrimmedCurve(C,f,l);
3076 CT->Transform(L.Transformation());
3078 // project it in the plane and return the associated PCurve
3079 gp_Dir Normal = Plane->Pln().Axis().Direction();
3081 Handle(Geom_Curve)::DownCast(GeomProjLib::ProjectOnPlane(CT,Plane,
3084 C2d = GeomProjLib::Curve2d(C,Plane);
3086 // Calculate the extrema with the straight line
3087 TColStd_SequenceOfReal Seq;
3089 Standard_Real U1 = -Precision::Infinite();
3090 Standard_Real U2 = Precision::Infinite();
3091 f= C2d->FirstParameter();
3092 l= C2d->LastParameter();
3095 Geom2dAdaptor_Curve AC2d(C2d);
3096 BndLib_Add2dCurve::Add(AC2d,BRepFill_Confusion(),B);
3097 Standard_Real xmin,xmax;
3098 B.Get(xmin,U1,xmax,U2);
3100 // modified by NIZHNY-EAP Wed Feb 2 16:32:37 2000 ___BEGIN___
3101 // no sense if C2 is normal to Line or really is a point
3103 Geom2dAPI_ExtremaCurveCurve Extrema(Line,C2d,U1-1.,U2+1.,f,l);
3105 Standard_Integer i, Nb = Extrema.NbExtrema();
3106 for ( i = 1; i <= Nb; i++) {
3107 Extrema.Parameters(i,U1,U2);
3111 // modified by NIZHNY-EAP Wed Feb 2 16:33:05 2000 ___END___
3113 // On calcule les intersection avec Oy.
3114 Geom2dAdaptor_Curve ALine(Line);
3115 Standard_Real Tol = Precision::Intersection();
3116 Standard_Real TolC = 0.;
3118 Geom2dInt_GInter Intersector(ALine,AC2d,TolC,Tol);
3119 Standard_Integer i, Nb = Intersector.NbPoints();
3121 for ( i = 1; i <= Nb; i++) {
3122 Seq.Append(Intersector.Point(i).ParamOnSecond());
3125 // Compute the new edges.
3126 BRep_Builder Builder;
3127 TopoDS_Vertex VV,Vf,Vl,VRf,VRl;
3128 TopExp::Vertices(E,VRf,VRl);
3130 if (!MapVerRefMoved.IsBound(VRf)) {
3131 Builder.MakeVertex(Vf,C->Value(f),BRep_Tool::Tolerance(VRf));
3132 MapVerRefMoved.Bind(VRf,Vf);
3135 Vf = TopoDS::Vertex(MapVerRefMoved(VRf));
3138 if (!MapVerRefMoved.IsBound(VRl)) {
3139 Builder.MakeVertex(Vl,C->Value(l),BRep_Tool::Tolerance(VRl));
3140 MapVerRefMoved.Bind(VRl,Vl);
3143 Vl = TopoDS::Vertex(MapVerRefMoved(VRl));
3146 if ( !Seq.IsEmpty()) {
3150 Standard_Boolean Empty = Standard_False;
3152 Standard_Real CurParam = f;
3153 Standard_Real Param;
3156 Param = Seq.First();
3158 Empty = Seq.IsEmpty();
3159 if (Abs( Param - CurParam) > BRepFill_Confusion() &&
3160 Abs( Param - l) > BRepFill_Confusion() ) {
3162 VV = BRepLib_MakeVertex( C->Value(Param));
3164 TopoDS_Edge EE = BRepLib_MakeEdge(C,Vf,VV);
3165 EE.Orientation(E.Orientation());
3166 if ( EE.Orientation() == TopAbs_FORWARD)
3178 TopoDS_Edge EE = BRepLib_MakeEdge(C,Vf,Vl);
3179 EE.Orientation(E.Orientation());
3180 if ( EE.Orientation() == TopAbs_FORWARD)
3186 //=======================================================================
3187 //function : CutEdge
3188 //purpose : Cut an edge at thw extrema of curves and at points of inflexion.
3189 // Closed circles are also cut in two.
3190 // If <Cuts> are empty the edge is not modified.
3191 // The first and the last vertex of the original edge
3192 // belong to the first and last parts respectively.
3193 //=======================================================================
3194 void CutEdge (const TopoDS_Edge& E,
3195 const TopoDS_Face& F,
3196 TopTools_ListOfShape& Cuts)
3199 MAT2d_CutCurve Cuter;
3201 Handle(Geom2d_Curve) C2d;
3202 Handle(Geom2d_TrimmedCurve) CT2d;
3204 TopoDS_Vertex V1,V2,VF,VL;
3205 TopExp::Vertices (E,V1,V2);
3208 C2d = BRep_Tool::CurveOnSurface (E,F,f,l);
3209 CT2d = new Geom2d_TrimmedCurve(C2d,f,l);
3211 if (CT2d->BasisCurve()->IsKind(STANDARD_TYPE(Geom2d_Circle)) &&
3212 BRep_Tool::IsClosed(E)) {
3213 //---------------------------
3214 // Cut closed circle.
3215 //---------------------------
3216 Standard_Real m1 = (2*f + l)/3.;
3217 Standard_Real m2 = ( f + 2*l)/3.;
3218 gp_Pnt2d P1 = CT2d->Value(m1);
3219 gp_Pnt2d P2 = CT2d->Value(m2);
3221 TopoDS_Vertex VL1 = BRepLib_MakeVertex(gp_Pnt(P1.X(), P1.Y(), 0.));
3222 TopoDS_Vertex VL2 = BRepLib_MakeVertex(gp_Pnt(P2.X(), P2.Y(), 0.));
3223 TopoDS_Shape aLocalShape1 = E.EmptyCopied();
3224 TopoDS_Shape aLocalShape2 = E.EmptyCopied();
3225 TopoDS_Shape aLocalShape3 = E.EmptyCopied();
3226 TopoDS_Edge FE = TopoDS::Edge(aLocalShape1);
3227 TopoDS_Edge ME = TopoDS::Edge(aLocalShape2);
3228 TopoDS_Edge LE = TopoDS::Edge(aLocalShape3);
3229 // TopoDS_Edge FE = TopoDS::Edge(E.EmptyCopied());
3230 // TopoDS_Edge ME = TopoDS::Edge(E.EmptyCopied());
3231 // TopoDS_Edge LE = TopoDS::Edge(E.EmptyCopied());
3233 FE.Orientation(TopAbs_FORWARD);
3234 ME.Orientation(TopAbs_FORWARD);
3235 LE.Orientation(TopAbs_FORWARD );
3238 B.Add (FE,VL1.Oriented(TopAbs_REVERSED));
3241 B.Add (ME,VL1.Oriented(TopAbs_FORWARD));
3242 B.Add (ME,VL2.Oriented(TopAbs_REVERSED));
3243 B.Range(ME, m1, m2);
3245 B.Add (LE,VL2.Oriented(TopAbs_FORWARD));
3249 Cuts.Append(FE.Oriented(E.Orientation()));
3250 Cuts.Append(ME.Oriented(E.Orientation()));
3251 Cuts.Append(LE.Oriented(E.Orientation()));
3258 //-------------------------
3259 // Cut of the curve.
3260 //-------------------------
3261 Cuter.Perform(CT2d);
3263 if (Cuter.UnModified()) {
3264 //-----------------------------
3265 // edge not modified => return.
3266 //-----------------------------
3270 //------------------------
3271 // Creation of cut edges.
3272 //------------------------
3275 for ( Standard_Integer k = 1; k <= Cuter.NbCurves(); k++) {
3276 Handle(Geom2d_TrimmedCurve)CC = Cuter.Value(k);
3277 if (k == Cuter.NbCurves()) {VL = V2;}
3279 gp_Pnt2d P = CC->Value(CC->LastParameter());
3280 VL = BRepLib_MakeVertex(gp_Pnt(P.X(), P.Y(), 0.));
3282 TopoDS_Shape aLocalShape = E.EmptyCopied();
3283 TopoDS_Edge NE = TopoDS::Edge(aLocalShape);
3284 // TopoDS_Edge NE = TopoDS::Edge(E.EmptyCopied());
3285 NE.Orientation(TopAbs_FORWARD);
3286 B.Add (NE,VF.Oriented(TopAbs_FORWARD));
3287 B.Add (NE,VL.Oriented(TopAbs_REVERSED));
3288 B.Range(NE,CC->FirstParameter(),CC->LastParameter());
3289 Cuts.Append(NE.Oriented(E.Orientation()));
3295 //=======================================================================
3296 //function : VertexFromNode
3297 //purpose : Test if the position of aNode correspondingly to the distance to OZ
3298 // of vertices VF and VL. returns Status.
3299 // if Status is different from 0 Returned
3300 // the vertex corresponding to aNode is created.
3301 //=======================================================================
3303 Standard_Integer VertexFromNode
3304 (const Handle(MAT_Node)& aNode,
3305 const TopoDS_Edge& E,
3306 const TopoDS_Vertex& VF,
3307 const TopoDS_Vertex& VL,
3308 BRepFill_DataMapOfNodeDataMapOfShapeShape& MapNodeVertex,
3311 TopoDS_Shape ShapeOnNode;
3312 TopTools_DataMapOfShapeShape EmptyMap;
3313 Standard_Integer Status = 0;
3316 if (!aNode->Infinite()) {
3317 Status = PosOnFace(aNode->Distance(),
3318 DistanceToOZ(VF) , DistanceToOZ(VL));
3320 if (Status == 2) ShapeOnNode = E;
3321 else if (Status == 1) ShapeOnNode = VF;
3322 else if (Status == 3) ShapeOnNode = VL;
3324 if (!ShapeOnNode.IsNull()) {
3325 //-------------------------------------------------
3326 // the vertex will correspond to a node of the map
3327 //-------------------------------------------------
3328 if (MapNodeVertex.IsBound(aNode) &&
3329 MapNodeVertex(aNode).IsBound(ShapeOnNode)) {
3331 (MapNodeVertex(aNode)(ShapeOnNode));
3335 if (!MapNodeVertex.IsBound(aNode)) {
3336 MapNodeVertex.Bind(aNode,EmptyMap);
3338 MapNodeVertex(aNode).Bind(ShapeOnNode,VN);