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>
119 #include <DrawTrSurf.hxx>
121 static Standard_Boolean AffichGeom = Standard_False;
122 static Standard_Boolean AffichEdge = Standard_False;
123 static Standard_Integer NbFACES = 0;
124 static Standard_Integer NbTRIMFACES = 0;
125 static Standard_Integer NbVEVOS = 0;
126 static Standard_Integer NbPROFILS = 0;
127 static Standard_Integer NbEDGES = 0;
130 static Standard_Real BRepFill_Confusion()
132 Standard_Real Tol = 1.e-6;
136 static const TopoDS_Wire PutProfilAt (const TopoDS_Wire& ProfRef,
137 const gp_Ax3& AxeRef,
138 const TopoDS_Edge& E,
139 const TopoDS_Face& F,
140 const Standard_Boolean AtStart);
142 static void TrimFace(const TopoDS_Face& Face,
143 TopTools_SequenceOfShape& TheEdges,
144 TopTools_SequenceOfShape& S);
146 static void TrimEdge (const TopoDS_Edge& Edge,
147 const TopTools_SequenceOfShape& TheEdgesControle,
148 TopTools_SequenceOfShape& TheVer,
149 TColStd_SequenceOfReal& ThePar,
150 TopTools_SequenceOfShape& S);
152 static Standard_Integer PosOnFace (Standard_Real d1,
156 static void ComputeIntervals (const TopTools_SequenceOfShape& VonF,
157 const TopTools_SequenceOfShape& VOnL,
158 const TColgp_SequenceOfPnt& ParOnF,
159 const TColgp_SequenceOfPnt& ParOnL,
160 const BRepFill_TrimSurfaceTool& Trim,
161 const Handle(Geom2d_Curve)& Bis,
162 const TopoDS_Vertex& VS,
163 const TopoDS_Vertex& VE,
164 TColStd_SequenceOfReal& FirstPar,
165 TColStd_SequenceOfReal& LastPar,
166 TopTools_SequenceOfShape& FirstV,
167 TopTools_SequenceOfShape& LastV );
169 static Standard_Real DistanceToOZ (const TopoDS_Vertex& V);
171 static Standard_Real Altitud (const TopoDS_Vertex& V);
173 static Standard_Boolean DoubleOrNotInFace (const TopTools_SequenceOfShape& EC,
174 const TopoDS_Vertex& V);
176 static void SimpleExpression (const Bisector_Bisec& B,
177 Handle(Geom2d_Curve)& Bis);
179 static TopAbs_Orientation Relative (const TopoDS_Wire& W1,
180 const TopoDS_Wire& W2,
181 const TopoDS_Vertex& V,
182 Standard_Boolean& Commun);
184 static void CutEdge (const TopoDS_Edge& E,
185 const TopoDS_Face& F,TopTools_ListOfShape& Cuts);
187 static void CutEdgeProf (const TopoDS_Edge& E,
188 const Handle(Geom_Plane)& Plane,
189 const Handle(Geom2d_Line)& Line,
190 TopTools_ListOfShape& Cuts,
191 TopTools_DataMapOfShapeShape& MapVerRefMoved);
193 static Standard_Integer VertexFromNode
194 (const Handle(MAT_Node)& aNode,
195 const TopoDS_Edge& E,
196 const TopoDS_Vertex& VF,
197 const TopoDS_Vertex& VL,
198 BRepFill_DataMapOfNodeDataMapOfShapeShape& MapNodeVertex,
201 //=======================================================================
202 //function : EdgeVertices
204 //=======================================================================
206 static void EdgeVertices (const TopoDS_Edge& E,
210 if (E.Orientation() == TopAbs_REVERSED) {
211 TopExp::Vertices(E,V2,V1);
214 TopExp::Vertices(E,V1,V2);
218 //=======================================================================
219 //function : BRepFill_Evolved
221 //=======================================================================
223 BRepFill_Evolved::BRepFill_Evolved()
225 myIsDone (Standard_False),
226 mySpineType(Standard_True)
231 //=======================================================================
232 //function : BRepFill_Evolved
234 //=======================================================================
236 BRepFill_Evolved::BRepFill_Evolved(const TopoDS_Wire& Spine,
237 const TopoDS_Wire& Profile,
238 const gp_Ax3& AxeProf,
239 const GeomAbs_JoinType Join,
240 const Standard_Boolean Solid)
242 : myIsDone(Standard_False)
244 Perform( Spine, Profile, AxeProf, Join, Solid);
248 //=======================================================================
249 //function : BRepFill_Evolved
251 //=======================================================================
253 BRepFill_Evolved::BRepFill_Evolved(const TopoDS_Face& Spine,
254 const TopoDS_Wire& Profile,
255 const gp_Ax3& AxeProf,
256 const GeomAbs_JoinType Join,
257 const Standard_Boolean Solid)
258 : myIsDone(Standard_False)
260 Perform( Spine, Profile, AxeProf, Join, Solid);
263 //=======================================================================
264 //function : IsVertical
266 //=======================================================================
268 static Standard_Boolean IsVertical(const TopoDS_Edge& E)
271 TopExp::Vertices(E,V1,V2);
272 gp_Pnt P1 = BRep_Tool::Pnt(V1);
273 gp_Pnt P2 = BRep_Tool::Pnt(V2);
275 if ( Abs(P1.Y() - P2.Y()) < BRepFill_Confusion()) {
279 Handle(Geom_Curve) GC = BRep_Tool::Curve(E,Loc,f,l);
280 if ( GC->DynamicType() == STANDARD_TYPE(Geom_Line))
281 return Standard_True;
283 return Standard_False;
286 //=======================================================================
287 //function : IsPlanar
289 //=======================================================================
291 static Standard_Boolean IsPlanar(const TopoDS_Edge& E)
294 TopExp::Vertices(E,V1,V2);
295 gp_Pnt P1 = BRep_Tool::Pnt(V1);
296 gp_Pnt P2 = BRep_Tool::Pnt(V2);
298 if ( Abs(P1.Z() - P2.Z()) < BRepFill_Confusion()) {
302 Handle(Geom_Curve) GC = BRep_Tool::Curve(E,Loc,f,l);
303 if ( GC->DynamicType() == STANDARD_TYPE(Geom_Line))
304 return Standard_True;
306 return Standard_False;
310 //=======================================================================
312 //purpose : determine the position of the profil correspondingly to plane XOZ.
313 // Return 1 : MAT_Left.
314 // Return 2 : MAT_Left and Planar.
315 // Return 3 : MAT_Left and Vertical.
316 // Return 4 : MAT_Right.
317 // Return 5 : MAT_Right and Planar.
318 // Return 6 : MAT_Right and Vertical.
319 //=======================================================================
321 static Standard_Integer Side(const TopoDS_Wire& Profil,
322 const Standard_Real Tol)
325 // Rem : it is enough to test the first edge of the Wire.
326 // ( Correctly cut in PrepareProfil)
327 TopExp_Explorer Explo(Profil,TopAbs_EDGE);
329 Standard_Integer TheSide;
330 const TopoDS_Edge& E = TopoDS::Edge(Explo.Current());
332 TopExp::Vertices(E,V1,V2);
333 gp_Pnt P1 = BRep_Tool::Pnt(V1);
334 gp_Pnt P2 = BRep_Tool::Pnt(V2);
336 if ( P1.Y() < -Tol || P2.Y() < -Tol) TheSide = 4;
338 if (IsVertical(E)) TheSide+=2;
339 else if (IsPlanar(E)) TheSide++;
344 //=======================================================================
347 //=======================================================================
349 void BRepFill_Evolved::Perform(const TopoDS_Wire& Spine,
350 const TopoDS_Wire& Profile,
351 const gp_Ax3& AxeProf,
352 const GeomAbs_JoinType Join,
353 const Standard_Boolean Solid)
355 mySpineType = Standard_False;
356 TopoDS_Face aFace = BRepLib_MakeFace(Spine,Standard_True);
357 PrivatePerform( aFace, Profile, AxeProf, Join, Solid);
360 //=======================================================================
363 //=======================================================================
365 void BRepFill_Evolved::Perform(const TopoDS_Face& Spine,
366 const TopoDS_Wire& Profile,
367 const gp_Ax3& AxeProf,
368 const GeomAbs_JoinType Join,
369 const Standard_Boolean Solid)
371 mySpineType = Standard_True;
372 PrivatePerform( Spine, Profile, AxeProf, Join, Solid);
375 //=======================================================================
376 //function : PrivatePerform
378 //=======================================================================
380 void BRepFill_Evolved::PrivatePerform(const TopoDS_Face& Spine,
381 const TopoDS_Wire& Profile,
382 const gp_Ax3& AxeProf,
383 const GeomAbs_JoinType Join,
384 const Standard_Boolean Solid)
386 TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
387 mySpine = TopoDS::Face(aLocalShape);
388 // mySpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
389 aLocalShape = Profile.Oriented(TopAbs_FORWARD);
390 myProfile = TopoDS::Wire(aLocalShape);
391 // myProfile = TopoDS::Wire(Profile.Oriented(TopAbs_FORWARD));
395 if (myJoinType > GeomAbs_Arc) {
396 throw Standard_NotImplemented();
399 TopTools_ListOfShape WorkProf;
400 TopoDS_Face WorkSpine;
401 TopTools_ListIteratorOfListOfShape WPIte;
403 //-------------------------------------------------------------------
404 // Positioning of mySpine and myProfil in the workspace.
405 //-------------------------------------------------------------------
406 TopLoc_Location LSpine = FindLocation(mySpine);
408 T.SetTransformation(AxeProf);
409 TopLoc_Location LProfile (T);
410 TopLoc_Location InitLS = mySpine .Location();
411 TopLoc_Location InitLP = myProfile.Location();
412 TransformInitWork(LSpine,LProfile);
414 //------------------------------------------------------------------
415 // projection of the profile and cut of the spine.
416 //------------------------------------------------------------------
417 TopTools_DataMapOfShapeShape MapProf, MapSpine;
419 PrepareProfile(WorkProf , MapProf);
420 PrepareSpine (WorkSpine, MapSpine);
422 Standard_Real Tol = BRepFill_Confusion();
423 Standard_Boolean YaLeft = Standard_False;
424 Standard_Boolean YaRight = Standard_False;
427 for (WPIte.Initialize(WorkProf); WPIte.More(); WPIte.Next()) {
428 SP = TopoDS::Wire(WPIte.Value());
429 if ( Side(SP,Tol) < 4) YaLeft = Standard_True;
430 else YaRight = Standard_True;
431 if (YaLeft && YaRight) break;
435 BRepMAT2d_BisectingLocus Locus;
437 //----------------------------------------------------------
438 // Initialisation of cut volevo.
439 // For each part of the profile create a volevo added to CutVevo
440 //----------------------------------------------------------
441 BRepFill_Evolved CutVevo;
444 BRepTools_WireExplorer WExp;
448 for (WPIte.Initialize(WorkProf); WPIte.More(); WPIte.Next()) {
449 for (WExp.Init(TopoDS::Wire(WPIte.Value())); WExp.More(); WExp.Next()) {
450 BB.Add(WP,WExp.Current());
453 CutVevo.SetWork(WorkSpine,WP);
455 BRepTools_Quilt Glue;
456 Standard_Integer CSide;
458 //---------------------------------
459 // Construction of vevos to the left.
460 //---------------------------------
462 //-----------------------------------------------------
463 // Calculate the map of bisector locations at the left.
464 // and links Topology -> base elements of the map.
465 //-----------------------------------------------------
466 BRepMAT2d_Explorer Exp(WorkSpine);
467 Locus.Compute(Exp,1,MAT_Left);
468 BRepMAT2d_LinkTopoBilo Link(Exp,Locus);
470 for (WPIte.Initialize(WorkProf); WPIte.More(); WPIte.Next()) {
471 SP = TopoDS::Wire(WPIte.Value());
472 CSide = Side(SP,Tol);
473 //-----------------------------------------------
474 // Construction and adding of elementary volevo.
475 //-----------------------------------------------
476 BRepFill_Evolved Vevo;
478 Vevo.ElementaryPerform (WorkSpine, SP, Locus, Link, Join);
480 else if (CSide == 2) {
481 Vevo.PlanarPerform (WorkSpine, SP, Locus, Link, Join);
483 else if (CSide == 3) {
484 Vevo.VerticalPerform (WorkSpine, SP, Locus, Link, Join);
486 CutVevo.Add (Vevo, SP, Glue);
490 //---------------------------------
491 // Construction of vevos to the right.
492 //---------------------------------
494 //-----------------------------------
495 // Decomposition of the face into wires.
496 //-----------------------------------
497 TopExp_Explorer SpineExp (WorkSpine, TopAbs_WIRE);
498 for ( ; SpineExp.More(); SpineExp.Next()) {
499 //----------------------------------------------
500 // Calculate the map to the right of the current wire.
501 //----------------------------------------------
502 BRepLib_MakeFace B(gp_Pln(0.,0.,1.,0.));
503 TopoDS_Shape aLocalShapeRev = SpineExp.Current().Reversed();
504 B.Add(TopoDS::Wire(aLocalShapeRev));
505 // B.Add(TopoDS::Wire(SpineExp.Current().Reversed()));
507 BRepMAT2d_Explorer Exp(Face);
508 Locus.Compute(Exp,1,MAT_Left);
509 BRepMAT2d_LinkTopoBilo Link(Exp,Locus);
511 for (WPIte.Initialize(WorkProf); WPIte.More(); WPIte.Next()) {
512 SP = TopoDS::Wire(WPIte.Value());
513 CSide = Side(SP,Tol);
514 //-----------------------------------------------
515 // Construction and adding of an elementary volevo
516 //-----------------------------------------------
517 BRepFill_Evolved Vevo;
519 Vevo.ElementaryPerform (Face, SP, Locus, Link, Join);
521 else if (CSide == 5) {
522 Vevo.PlanarPerform (Face, SP, Locus, Link, Join);
524 else if (CSide == 6) {
525 Vevo.VerticalPerform (Face, SP, Locus, Link, Join);
527 CutVevo.Add (Vevo, SP, Glue);
532 if (Solid) CutVevo.AddTopAndBottom(Glue);
534 //-------------------------------------------------------------------------
535 // Gluing of regularites on parallel edges generate4d by vertices of the
536 // cut of the profile.
537 //-------------------------------------------------------------------------
538 CutVevo.ContinuityOnOffsetEdge(WorkProf);
540 //-----------------------------------------------------------------
541 // construction of the shape via the quilt, ie:
542 // - sharing of topologies of elementary added volevos.
543 // - Orientation of faces correspondingly to each other.
544 //-----------------------------------------------------------------
545 TopoDS_Shape& SCV = CutVevo.ChangeShape();
547 //------------------------------------------------------------------------
548 // Transfer of the map of generated elements and of the shape of Cutvevo
549 // in myMap and repositioning in the initial space.
550 //------------------------------------------------------------------------
551 Transfert (CutVevo, MapProf, MapSpine, LSpine.Inverted(), InitLS, InitLP);
553 //Orientation of the solid.
554 if (Solid) MakeSolid();
556 // modified by NIZHNY-EAP Mon Jan 24 11:26:48 2000 ___BEGIN___
557 BRepLib::UpdateTolerances(myShape,Standard_False);
558 // modified by NIZHNY-EAP Mon Jan 24 11:26:50 2000 ___END___
559 myIsDone = Standard_True;
564 //=======================================================================
565 //function : IsInversed
567 //=======================================================================
569 static void IsInversed(const TopoDS_Shape& S,
570 const TopoDS_Edge& E1,
571 const TopoDS_Edge& E2,
572 Standard_Boolean* Inverse)
575 Inverse[0] = Inverse[1] = 0;
576 if (S.ShapeType() != TopAbs_EDGE) return;
580 BRepAdaptor_Curve CS(TopoDS::Edge(S));
581 if (S.Orientation() == TopAbs_FORWARD) {
582 CS.D1(CS.FirstParameter(),P,DS);
585 CS.D1(CS.LastParameter(),P,DS);
590 if (!BRep_Tool::Degenerated(E1)) {
591 BRepAdaptor_Curve C1(TopoDS::Edge(E1));
592 if (E1.Orientation() == TopAbs_FORWARD) {
593 C1.D1(C1.FirstParameter(),P,DC1);
596 C1.D1(C1.LastParameter(),P,DC1);
599 Inverse[0] = (DS.Dot(DC1) < 0.);
603 if (!BRep_Tool::Degenerated(E2)) {
604 BRepAdaptor_Curve C2(TopoDS::Edge(E2));
605 if (E2.Orientation() == TopAbs_FORWARD) {
606 C2.D1(C2.FirstParameter(),P,DC2);
609 C2.D1(C2.LastParameter(),P,DC2);
612 Inverse[1] = (DS.Dot(DC2) < 0.);
617 //=======================================================================
620 //=======================================================================
622 void BRepFill_Evolved::SetWork(const TopoDS_Face& Sp,
623 const TopoDS_Wire& Pr)
629 //=======================================================================
630 //function : ConcaveSide
631 //purpose : Determine if the pipes were at the side of the
632 // concavity. In this case they can be closed.
633 // WARNING: Not finished. Done only for circles.
634 //=======================================================================
636 static Standard_Boolean ConcaveSide(const TopoDS_Shape& S,
637 const TopoDS_Face& F)
640 if (S.ShapeType() == TopAbs_VERTEX) return Standard_False;
642 if (S.ShapeType() == TopAbs_EDGE) {
644 Handle(Geom2d_Curve) G2d =
645 BRep_Tool::CurveOnSurface(TopoDS::Edge(S),F,f,l);
646 Handle(Geom2d_Curve) G2dOC;
648 Geom2dAdaptor_Curve AC(G2d,f,l);
649 if ( AC.GetType() == GeomAbs_Circle) {
650 Standard_Boolean Direct = AC.Circle().IsDirect();
651 if (S.Orientation() == TopAbs_REVERSED) Direct = (!Direct);
655 return Standard_False;
658 //=======================================================================
659 //function : ElementaryPerform
661 //=======================================================================
663 void BRepFill_Evolved::ElementaryPerform (const TopoDS_Face& Sp,
664 const TopoDS_Wire& Pr,
665 const BRepMAT2d_BisectingLocus& Locus,
666 BRepMAT2d_LinkTopoBilo& Link,
667 const GeomAbs_JoinType /*Join*/)
673 sprintf(name,"PROFIL_%d",++NbPROFILS);
677 TopoDS_Shape aLocalShape = Sp.Oriented(TopAbs_FORWARD);
678 mySpine = TopoDS::Face(aLocalShape);
679 // mySpine = TopoDS::Face(Sp.Oriented(TopAbs_FORWARD));
683 BRep_Builder myBuilder;
684 myBuilder.MakeCompound(TopoDS::Compound(myShape));
686 //---------------------------------------------------------------------
687 // MapNodeVertex : associate to each node of the map (key1) and
688 // to each element of the profile (key2) a vertex (item).
689 // MapBis : a set of edges or vertexes (item) generated by
690 // a bisectrice on a face or an edge (key) of
691 // tubes or revolutions.
692 // MapVerPar : Map of parameters of vertices on parallel edges
693 // the list contained in MapVerPar (E) corresponds
694 // to parameters on E of vertices contained in MapBis(E);
695 // MapBS : links BasicElt of the map => Topology of the spine.
696 //---------------------------------------------------------------------
699 BRepFill_DataMapOfNodeDataMapOfShapeShape MapNodeVertex;
700 TopTools_DataMapOfShapeSequenceOfShape MapBis;
701 BRepFill_DataMapOfShapeSequenceOfReal MapVerPar;
703 TopTools_DataMapOfShapeShape EmptyMap;
704 TopTools_SequenceOfShape EmptySeq;
705 TopTools_ListOfShape EmptyList;
706 TColStd_SequenceOfReal EmptySeqOfReal;
708 // mark of the profile.
709 gp_Ax3 AxeRef(gp_Pnt(0.,0.,0.),
713 //---------------------------------------------------------------
714 // Construction of revolutions and tubes.
715 //---------------------------------------------------------------
716 BRepTools_WireExplorer ProfExp;
717 TopExp_Explorer FaceExp;
718 BRepTools_WireExplorer WireExp;
720 for (FaceExp.Init(mySpine,TopAbs_WIRE); FaceExp.More(); FaceExp.Next()){
722 for (WireExp.Init(TopoDS::Wire(FaceExp.Current())); WireExp.More();
725 TopoDS_Edge CurrentEdge = WireExp.Current();
726 TopoDS_Vertex VFirst,VLast;
727 EdgeVertices(CurrentEdge,VFirst,VLast);
729 for (Link.Init(VLast); Link.More(); Link.Next()) {
730 //----------------------------.
731 //Construction of a Revolution
732 //----------------------------.
733 MakeRevol (CurrentEdge, VLast, AxeRef);
736 for (Link.Init(CurrentEdge); Link.More(); Link.Next()) {
737 //------------------------.
738 //Construction of a Tube
739 //-------------------------
740 MakePipe (CurrentEdge, AxeRef);
747 std::cout << " End Construction of geometric primitives"<<std::endl;
751 //---------------------------------------------------
752 // Construction of edges associated to bissectrices.
753 //---------------------------------------------------
754 Handle(MAT_Arc) CurrentArc;
755 Handle(Geom2d_Curve) Bis, PCurve1, PCurve2 ;
756 Handle(Geom_Curve) CBis;
757 Standard_Boolean Reverse;
758 TopoDS_Edge CurrentEdge;
765 for (Standard_Integer i = 1; i <= Locus.Graph()->NumberOfArcs(); i++) {
766 CurrentArc = Locus.Graph()->Arc(i);
767 SimpleExpression(Locus.GeomBis(CurrentArc,Reverse), Bis);
769 //------------------------------------------------------------------
770 // Return elements of the spine corresponding to separate basicElts.
771 //------------------------------------------------------------------
772 S [0] = Link.GeneratingShape(CurrentArc->FirstElement());
773 S [1] = Link.GeneratingShape(CurrentArc->SecondElement());
775 Standard_Boolean Concave0 = ConcaveSide(S[0],mySpine);
776 Standard_Boolean Concave1 = ConcaveSide(S[1],mySpine);
778 TopTools_SequenceOfShape VOnF,VOnL;
779 TColgp_SequenceOfPnt ParOnF,ParOnL;
781 TopTools_DataMapOfShapeSequenceOfShape MapSeqVer;
782 BRepFill_DataMapOfShapeSequenceOfPnt MapSeqPar;
784 Standard_Integer vv = 0;
785 for(ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()) {
787 //-----------------------------------------------
788 // Return two faces separated by the bissectrice.
789 //-----------------------------------------------
790 F [0] = TopoDS::Face(myMap(S[0])(ProfExp.Current()).First());
791 F [1] = TopoDS::Face(myMap(S[1])(ProfExp.Current()).First());
793 //------------------------------------
794 // Return parallel edges on each face.
795 //------------------------------------
798 EdgeVertices(ProfExp.Current(),VF,VL);
800 E [0] = TopoDS::Edge(myMap(S[0])(VF).First());
801 E [1] = TopoDS::Edge(myMap(S[0])(VL).First());
802 E [2] = TopoDS::Edge(myMap(S[1])(VF).First());
803 E [3] = TopoDS::Edge(myMap(S[1])(VL).First());
805 Standard_Boolean Inv0[2];
806 Standard_Boolean Inv1[2];
808 Inv0[0] = Inv0[1] = Inv1[0]= Inv1[1] = 0;
809 if (Concave0) IsInversed(S[0],E[0],E[1],Inv0);
810 if (Concave1) IsInversed(S[1],E[2],E[3],Inv1);
812 //---------------------------------------------
813 // Construction of geometries.
814 //---------------------------------------------
815 BRepFill_TrimSurfaceTool Trim (Bis,F[0],F[1],
816 E[0],E[2],Inv0[0],Inv1[0]);
817 //-----------------------------------------------------------
818 //Construction of vertices corresponding to the node of the map
819 //-----------------------------------------------------------
821 Handle(MAT_Node) Node1, Node2;
824 Node1 = CurrentArc->SecondNode();
825 Node2 = CurrentArc->FirstNode();
828 Node1 = CurrentArc->FirstNode();
829 Node2 = CurrentArc->SecondNode();
831 //--------------------------------------------------------
832 // Particular case when the node is on a vertex of the spine.
833 //--------------------------------------------------------
834 if (Node1->OnBasicElt()) {
835 if (S[0].ShapeType() == TopAbs_VERTEX) {
836 Node1 = CurrentArc->FirstElement()->StartArc()->FirstNode();
838 else if (S[1].ShapeType() == TopAbs_VERTEX) {
839 Node1 = CurrentArc->SecondElement()->StartArc()->FirstNode();
842 // End of particular case.
845 StartOnF = VertexFromNode(Node1,
846 TopoDS::Edge(ProfExp.Current()),
851 EndOnF = VertexFromNode(Node2,
852 TopoDS::Edge(ProfExp.Current()),
856 //-----------------------------------------------------------
857 // Construction of vertices on edges parallel to the spine.
858 //-----------------------------------------------------------
859 if (!MapSeqVer.IsBound(VF)) {
860 if (Inv0 [0] || Inv1 [0]) {
865 Trim.IntersectWith(E [0], E [2], ParOnF);
867 for (Standard_Integer s = 1; s <= ParOnF.Length(); s++) {
869 myBuilder.MakeVertex (VC);
873 VOnF .SetValue(1,VS);
876 VOnF .SetValue(ParOnF.Length(),VE);
881 ParOnF = MapSeqPar(VF);
882 VOnF = MapSeqVer(VF);
885 if (!MapSeqVer.IsBound(VL)) {
886 if (Inv0 [1] || Inv1 [1]) {
891 Trim.IntersectWith(E [1], E [3], ParOnL);
893 for (Standard_Integer s = 1; s <= ParOnL.Length(); s++) {
895 myBuilder.MakeVertex (VC);
899 VOnL .SetValue(1,VS);
902 VOnL .SetValue(ParOnL.Length(),VE);
907 ParOnL = MapSeqPar(VL);
908 VOnL = MapSeqVer(VL);
911 //------------------------------------------------------
912 // Test if the Bissectrice is not projected on the face
913 //------------------------------------------------------
914 if ((StartOnF == 0) && (EndOnF == 0) &&
915 VOnL.IsEmpty() && VOnF.IsEmpty())
916 // No trace of the bisectrice on the face.
919 if ((StartOnF == 0) && (EndOnF == 0) &&
920 (VOnL.Length() + VOnF.Length() == 1))
921 // the first or last node of the arc is on the edge
922 // but the arc is not on the face.
925 //---------------------------------------------------------
926 // determine the intervals of the bissectrice that are
927 // projected on F[0] and F[1].
928 //---------------------------------------------------------
929 TColStd_SequenceOfReal LastPar,FirstPar;
930 TopTools_SequenceOfShape FirstV,LastV;
932 ComputeIntervals (VOnF,VOnL,ParOnF,ParOnL,Trim,Bis,
933 VS,VE,FirstPar,LastPar,FirstV,LastV);
935 for (Standard_Integer Ti = 1; Ti <= FirstPar.Length(); Ti++) {
936 TopoDS_Vertex V1 = TopoDS::Vertex(FirstV.Value(Ti));
937 TopoDS_Vertex V2 = TopoDS::Vertex(LastV .Value(Ti));
939 GeomAbs_Shape Continuity;
941 Trim.Project(FirstPar.Value(Ti),LastPar.Value(Ti),
942 CBis,PCurve1,PCurve2,Continuity);
944 //-------------------------------------
945 // Coding of the edge.
946 //-------------------------------------
947 myBuilder.MakeEdge(CurrentEdge, CBis,
948 BRepFill_Confusion());
950 myBuilder.UpdateVertex(V1,CBis->Value(CBis->FirstParameter()),
951 BRepFill_Confusion());
952 myBuilder.UpdateVertex(V2,CBis->Value(CBis->LastParameter()),
953 BRepFill_Confusion());
955 myBuilder.Add(CurrentEdge,V1.Oriented(TopAbs_FORWARD));
956 myBuilder.Add(CurrentEdge,V2.Oriented(TopAbs_REVERSED));
958 myBuilder.Range(CurrentEdge,
959 CBis->FirstParameter(),
960 CBis->LastParameter());
961 myBuilder.UpdateEdge(CurrentEdge,PCurve1,F[0],BRepFill_Confusion());
962 myBuilder.UpdateEdge(CurrentEdge,PCurve2,F[1],BRepFill_Confusion());
964 myBuilder.Continuity(CurrentEdge,F[0],F[1],Continuity);
969 sprintf(name,"ARCEDGE_%d_%d_%d",i,vv,Ti);
970 DBRep::Set(name,CurrentEdge);
973 //-------------------------------------------
974 // Storage of the edge for each of faces.
975 //-------------------------------------------
976 for (k = 0; k <= 1;k++) {
977 if (!MapBis.IsBound(F[k])) {
978 MapBis.Bind(F[k],EmptySeq);
981 //---------------------------------------------------------------
982 // orientation of the edge depends on the direction of the skin.
983 // skin => same orientation E[0] , inverted orientation E[2]
984 // if contreskin it is inverted.
985 //--------------------------------------------------------------
986 E[0].Orientation(BRepTools::OriEdgeInFace(E[0],F[0]));
987 E[2].Orientation(BRepTools::OriEdgeInFace(E[2],F[1]));
989 if (DistanceToOZ(VF) < DistanceToOZ(VL) ) {
991 MapBis(F[0]).Append(CurrentEdge.Oriented (E[0].Orientation()));
992 CurrentEdge.Orientation(TopAbs::Complement(E[2].Orientation()));
993 MapBis(F[1]).Append(CurrentEdge);
997 MapBis(F[1]).Append(CurrentEdge.Oriented (E[2].Orientation()));
998 CurrentEdge.Orientation(TopAbs::Complement(E[0].Orientation()));
999 MapBis(F[0]).Append(CurrentEdge);
1003 //----------------------------------------------
1004 // Storage of vertices on parallel edges.
1005 // fill MapBis and MapVerPar.
1006 // VOnF for E[0] and E[2].
1007 // VOnL for E[1] and E[3].
1008 //----------------------------------------------
1009 for (k = 0; k <= 2; k = k+2) {
1010 if ( !MapSeqVer.IsBound(VF)) {
1011 if (!VOnF.IsEmpty()) {
1012 if (!MapBis.IsBound(E[k])) {
1013 MapBis .Bind(E[k],EmptySeq);
1014 MapVerPar.Bind(E[k],EmptySeqOfReal);
1016 for (Standard_Integer ii = 1; ii <= VOnF.Length(); ii++) {
1017 MapBis (E[k]).Append(VOnF.Value(ii));
1018 if (k == 0) MapVerPar (E[k]).Append(ParOnF.Value(ii).Y());
1019 else MapVerPar (E[k]).Append(ParOnF.Value(ii).Z());
1025 for (k = 1; k <= 3; k = k+2) {
1026 if ( !MapSeqVer.IsBound(VL)) {
1027 if (!VOnL.IsEmpty()) {
1028 if (!MapBis.IsBound(E[k])) {
1029 MapBis .Bind(E[k],EmptySeq);
1030 MapVerPar.Bind(E[k],EmptySeqOfReal);
1032 for (Standard_Integer ii = 1; ii <= VOnL.Length(); ii++) {
1033 MapBis(E[k]).Append(VOnL.Value(ii));
1034 if (k == 1) MapVerPar (E[k]).Append(ParOnL.Value(ii).Y());
1035 else MapVerPar (E[k]).Append(ParOnL.Value(ii).Z());
1041 //----------------------------------------------------------------
1042 // Edge [1] of the current face will be Edge [0] of the next face.
1043 // => copy of VonL in VonF. To avoid creating the same vertices twice.
1044 //-----------------------------------------------------------------
1046 MapSeqPar.Bind(VF,ParOnF);
1047 MapSeqVer.Bind(VF,VOnF);
1048 MapSeqPar.Bind(VL,ParOnL);
1049 MapSeqVer.Bind(VL,VOnL);
1056 std::cout << " End of Construction of edges and vertices on bissectrices"<<std::endl;
1060 //----------------------------------
1061 // Construction of parallel edges.
1062 //----------------------------------
1063 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape ite1;
1064 TopoDS_Shape CurrentProf,PrecProf;
1065 TopoDS_Face CurrentFace;
1066 TopoDS_Shape CurrentSpine;
1067 TopoDS_Vertex VCF,VCL;
1069 for (ite1.Initialize(myMap); ite1.More(); ite1.Next()) {
1070 CurrentSpine = ite1.Key();
1072 for (ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()){
1073 CurrentProf = ProfExp.Current();
1074 EdgeVertices(TopoDS::Edge(CurrentProf),VCF,VCL);
1075 CurrentEdge = TopoDS::Edge(myMap(CurrentSpine)(VCF).First());
1077 //-------------------------------------------------------------
1078 //RQ : Current Edge is oriented relatively to the face (oriented forward)
1079 // generated by edge CurrentProf .
1080 //-------------------------------------------------------------
1081 if (MapBis.IsBound(CurrentEdge)) {
1083 //--------------------------------------------------------
1084 // Find if one of two faces connected to the edge
1085 // belongs to volevo. The edges on this face serve
1086 // to eliminate certain vertices that can appear twice
1087 // on the parallel edge. These Vertices corespond to the
1088 // nodes of the map.
1089 //---------------------------------------------------------
1090 TopoDS_Shape FaceControle;
1091 Standard_Boolean YaFace = Standard_True;
1093 FaceControle = myMap(CurrentSpine)(CurrentProf).First();
1094 if (!MapBis.IsBound(FaceControle)){
1095 YaFace = Standard_False;
1096 if (!PrecProf.IsNull()) {
1097 FaceControle = myMap(CurrentSpine)(PrecProf).First();
1098 if (MapBis.IsBound(FaceControle)){
1099 YaFace = Standard_True;
1105 //------------------------------------------------------------
1106 // No connected face in the volevo => no parallel edge.
1107 //------------------------------------------------------------
1108 TopTools_SequenceOfShape aSeqOfShape;
1109 TrimEdge (CurrentEdge,
1110 MapBis (FaceControle),
1111 MapBis (CurrentEdge) ,
1112 MapVerPar(CurrentEdge) , aSeqOfShape);
1114 for ( k = 1; k <= aSeqOfShape.Length(); k++) {
1115 myMap(CurrentSpine)(VCF).Append(aSeqOfShape.Value(k));
1120 sprintf(name,"PAREDGE_%d_%d",++NbEDGES,k);
1121 DBRep::Set(name,aSeqOfShape.Value(k));
1127 PrecProf = CurrentProf;
1130 //------------------------------------------------------------
1131 // Construction of the parallel edge from the last vertex of myProfile.
1132 //------------------------------------------------------------
1133 CurrentEdge = TopoDS::Edge(myMap(CurrentSpine)(VCL).First());
1135 if (MapBis.IsBound(CurrentEdge)) {
1136 Standard_Boolean YaFace = Standard_True;
1137 TopoDS_Shape FaceControle;
1139 FaceControle = myMap(CurrentSpine)(CurrentProf).First();
1140 if (!MapBis.IsBound(FaceControle)){
1141 YaFace = Standard_False;
1143 // the number of element of the list allows to know
1144 // if the edges have already been done (closed profile) .
1145 if (YaFace && myMap(CurrentSpine)(VCL).Extent()<= 1) {
1146 TopTools_SequenceOfShape aSeqOfShape;
1147 TrimEdge (CurrentEdge,
1148 MapBis (FaceControle),
1149 MapBis (CurrentEdge) ,
1150 MapVerPar(CurrentEdge) , aSeqOfShape);
1152 for ( k = 1; k <= aSeqOfShape.Length(); k++) {
1153 myMap(CurrentSpine)(VCL).Append(aSeqOfShape.Value(k));
1158 sprintf(name,"PAREDGE_%d_%d",++NbEDGES,k);
1159 DBRep::Set(name,aSeqOfShape.Value(k));
1169 std::cout <<" End Construction of parallel edges "<<std::endl;
1173 //-------------------------------------------------------------------
1174 // Cut faces by edges.
1175 //-------------------------------------------------------------------
1176 for (ite1.Initialize(myMap); ite1.More(); ite1.Next()) {
1177 CurrentSpine = ite1.Key();
1179 for (ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()){
1180 CurrentProf = ProfExp.Current();
1181 CurrentFace = TopoDS::Face(myMap(CurrentSpine)(CurrentProf).First());
1182 myMap(CurrentSpine)(CurrentProf).Clear();
1184 if (MapBis.IsBound(CurrentFace)) {
1185 //----------------------------------------------------------
1186 // If the face does not contain edges that can limit it
1187 // it does not appear in volevo.
1188 // cut of face by edges can generate many faces.
1190 // Add edges generated on the edges parallel to the set
1191 // of edges that limit the face.
1193 //------------------------------------------------------------
1194 EdgeVertices(TopoDS::Edge(CurrentProf),VCF,VCL);
1196 TopTools_ListIteratorOfListOfShape itl;
1197 const TopTools_ListOfShape& LF = myMap(CurrentSpine)(VCF);
1199 TopAbs_Orientation Ori = BRepTools::OriEdgeInFace(TopoDS::Edge(LF.First()),
1201 for (itl.Initialize(LF), itl.Next(); itl.More(); itl.Next()) {
1202 TopoDS_Edge RE = TopoDS::Edge(itl.Value());
1203 MapBis(CurrentFace).Append(RE.Oriented(Ori));
1205 const TopTools_ListOfShape& LL = myMap(CurrentSpine)(VCL);
1206 Ori = BRepTools::OriEdgeInFace(TopoDS::Edge(LL.First()),CurrentFace);
1207 for (itl.Initialize(LL), itl.Next() ; itl.More(); itl.Next()) {
1208 TopoDS_Edge RE = TopoDS::Edge(itl.Value());
1209 MapBis(CurrentFace).Append(RE.Oriented(Ori));
1213 TopTools_SequenceOfShape aSeqOfShape;
1215 TrimFace (CurrentFace, MapBis(CurrentFace), aSeqOfShape);
1217 for (Standard_Integer ii = 1; ii <= aSeqOfShape.Length(); ii++) {
1218 myBuilder.Add (myShape, aSeqOfShape.Value(ii));
1219 myMap(CurrentSpine)(CurrentProf).Append(aSeqOfShape.Value(ii));
1223 //-----------------------------------------------------------------
1224 // Removal of first edge (edge of origin) from lists of myMap
1225 // corresponding to vertices of the profile.
1226 //-----------------------------------------------------------------
1227 TopExp_Explorer Explo(myProfile,TopAbs_VERTEX);
1228 TopTools_MapOfShape vmap;
1230 for ( ; Explo.More(); Explo.Next()){
1231 if (vmap.Add(Explo.Current())) {
1232 myMap(CurrentSpine)(Explo.Current()).RemoveFirst();
1236 myIsDone = Standard_True;
1240 std::cout <<" End of construction of an elementary volevo."<<std::endl;
1242 sprintf(name,"VEVO_%d",++NbVEVOS);
1243 DBRep::Set(name,myShape);
1248 //=======================================================================
1249 //function : PlanarPerform
1251 //=======================================================================
1253 void BRepFill_Evolved::PlanarPerform (const TopoDS_Face& Sp,
1254 const TopoDS_Wire& Pr,
1255 const BRepMAT2d_BisectingLocus& Locus,
1256 BRepMAT2d_LinkTopoBilo& Link,
1257 const GeomAbs_JoinType Join)
1259 TopoDS_Shape aLocalShapeOriented = Sp.Oriented(TopAbs_FORWARD);
1260 mySpine = TopoDS::Face(aLocalShapeOriented);
1261 // mySpine = TopoDS::Face(Sp.Oriented(TopAbs_FORWARD));
1266 B.MakeCompound(TopoDS::Compound(myShape));
1268 BRepTools_WireExplorer ProfExp;
1269 TopExp_Explorer Exp,exp1,exp2;
1270 TopTools_DataMapOfShapeListOfShape EmptyMap;
1271 TopTools_ListOfShape EmptyList;
1272 TopTools_DataMapOfShapeShape MapVP;
1273 BRepFill_OffsetWire Paral;
1275 for (ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()){
1276 const TopoDS_Edge& E = ProfExp.Current();
1277 BRepAlgo_FaceRestrictor FR;
1278 BRepFill_OffsetAncestors OffAnc;
1281 EdgeVertices(E,V[0],V[1]);
1282 Standard_Real Alt = Altitud(V[0]);
1283 Standard_Real Offset[2];
1284 Offset[0] = DistanceToOZ(V[0]);
1285 Offset[1] = DistanceToOZ(V[1]);
1286 Standard_Boolean IsMinV1 = ( Offset[0] < Offset[1]);
1288 for (Standard_Integer i = 0; i <= 1; i++) {
1289 if (!MapVP.IsBound(V[i])) {
1290 //------------------------------------------------
1291 // Calculate parallel lines corresponding to vertices.
1292 //------------------------------------------------
1293 Paral.PerformWithBiLo(mySpine,Offset[i],Locus,Link,Join,Alt);
1294 OffAnc.Perform(Paral);
1295 MapVP.Bind(V[i],Paral.Shape());
1297 //-----------------------------
1298 // Update myMap (.)(V[i])
1299 //-----------------------------
1300 for (Exp.Init(Paral.Shape(),TopAbs_EDGE);
1303 const TopoDS_Edge& WC = TopoDS::Edge(Exp.Current());
1304 const TopoDS_Shape& GS = OffAnc.Ancestor(WC);
1305 if ( !myMap.IsBound(GS))
1306 myMap.Bind(GS, EmptyMap);
1307 if ( !myMap(GS).IsBound(V[i]))
1308 myMap(GS).Bind(V[i],Paral.GeneratedShapes(GS));
1311 TopoDS_Shape Rest = MapVP(V[i]);
1313 Standard_Boolean ToReverse = Standard_False;
1314 if ( ( IsMinV1 && (i==1)) || (!IsMinV1 && (i==0)) )
1315 ToReverse = Standard_True;
1317 if (!Rest.IsNull()) {
1318 if (Rest.ShapeType() == TopAbs_WIRE) {
1320 TopoDS_Shape aLocalShape = Rest.Reversed();
1321 TopoDS_Wire aWire = TopoDS::Wire(aLocalShape);
1325 FR.Add(TopoDS::Wire(Rest));
1328 for (Exp.Init(Rest,TopAbs_WIRE);Exp.More();Exp.Next()) {
1329 TopoDS_Wire WCop = TopoDS::Wire(Exp.Current());
1331 TopoDS_Shape aLocalShape = WCop.Reversed();
1332 TopoDS_Wire bWire = TopoDS::Wire(aLocalShape);
1333 // TopoDS_Wire bWire = TopoDS::Wire(WCop.Reversed());
1344 TopTools_DataMapIteratorOfDataMapOfShapeShape it(MapVP);
1345 Standard_Integer k = 0;
1346 for (; it.More(); it.Next()) {
1348 sprintf(name,"PARALI_%d",++k);
1349 DBRep::Set(name,it.Value());
1354 //----------------------------------------------------
1355 // Construction of faces limited by parallels.
1356 // - set to the height of the support face.
1357 //----------------------------------------------------
1358 gp_Trsf T; T.SetTranslation(gp_Vec(0,0,Alt));
1359 TopLoc_Location LT(T);
1360 TopoDS_Shape aLocalShape = mySpine.Moved(LT);
1361 FR.Init(TopoDS::Face(aLocalShape));
1362 // FR.Init(TopoDS::Face(mySpine.Moved(LT)));
1365 for ( ;FR.More(); FR.Next()) {
1366 const TopoDS_Face& F = FR.Current();
1368 //---------------------------------------
1369 // Update myMap(.)(E)
1370 //---------------------------------------
1371 for ( Exp.Init(F,TopAbs_EDGE); Exp.More(); Exp.Next()) {
1372 const TopoDS_Edge& CE = TopoDS::Edge(Exp.Current());
1373 if (OffAnc.HasAncestor(CE)) {
1374 const TopoDS_Shape& InitE = OffAnc.Ancestor(CE);
1375 if ( !myMap.IsBound(InitE))
1376 myMap.Bind(InitE, EmptyMap);
1377 if ( !myMap(InitE).IsBound(E))
1378 myMap(InitE).Bind(E,EmptyList);
1379 myMap(InitE)(E).Append(F);
1383 } // End loop on profile.
1387 //=======================================================================
1388 //function : VerticalPerform
1390 //=======================================================================
1392 void BRepFill_Evolved::VerticalPerform (const TopoDS_Face& Sp,
1393 const TopoDS_Wire& Pr,
1394 const BRepMAT2d_BisectingLocus& Locus,
1395 BRepMAT2d_LinkTopoBilo& Link,
1396 const GeomAbs_JoinType Join)
1398 TopoDS_Shape aLocalShape = Sp.Oriented(TopAbs_FORWARD);
1399 mySpine = TopoDS::Face(aLocalShape);
1400 // mySpine = TopoDS::Face(Sp.Oriented(TopAbs_FORWARD));
1405 B.MakeCompound(TopoDS::Compound(myShape));
1407 BRepTools_WireExplorer ProfExp;
1408 TopExp_Explorer Exp;
1409 BRepFill_OffsetWire Paral;
1410 BRepFill_OffsetAncestors OffAnc;
1411 TopoDS_Vertex V1,V2;
1413 Standard_Boolean First = Standard_True;
1415 TopTools_DataMapOfShapeListOfShape EmptyMap;
1417 for (ProfExp.Init(myProfile); ProfExp.More(); ProfExp.Next()){
1418 const TopoDS_Edge& E = ProfExp.Current();
1419 EdgeVertices(E,V1,V2);
1420 Standard_Real Alt1 = Altitud(V1);
1421 Standard_Real Alt2 = Altitud(V2);
1424 Standard_Real Offset = DistanceToOZ(V1);
1425 if (Abs(Offset) < BRepFill_Confusion()) {
1428 Paral.PerformWithBiLo(mySpine,Offset,Locus,Link,Join,Alt1);
1429 OffAnc.Perform(Paral);
1430 Base = Paral.Shape();
1433 for (Exp.Init(Base,TopAbs_EDGE); Exp.More(); Exp.Next()) {
1434 const TopoDS_Edge& anEdge = TopoDS::Edge(Exp.Current());
1435 const TopoDS_Shape& AE = OffAnc.Ancestor(anEdge);
1436 if (!myMap.IsBound(AE)) {
1437 myMap.Bind(AE,EmptyMap);
1439 if (!myMap(AE).IsBound(V1)) {
1440 TopTools_ListOfShape L;
1441 myMap(AE).Bind(V1,L);
1443 myMap(AE)(V1).Append(anEdge);
1445 First = Standard_False;
1452 sprintf(name,"PARALI_%d",++NbVEVOS);
1453 DBRep::Set(name,Base);
1457 BRepSweep_Prism PS(Base,gp_Vec(0,0,Alt2 - Alt1),Standard_False);
1461 sprintf(name,"PRISM_%d",NbVEVOS);
1462 DBRep::Set(name,PS.Shape());
1466 Base = PS.LastShape();
1468 for (Exp.Init(PS.Shape(),TopAbs_FACE); Exp.More(); Exp.Next()) {
1469 B.Add(myShape,Exp.Current());
1473 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape
1476 for (; it.More(); it.Next()) {
1477 const TopTools_ListOfShape& LOF = it.Value()(V1);
1478 TopTools_ListIteratorOfListOfShape itLOF(LOF);
1479 if (!myMap(it.Key()).IsBound(V2)) {
1480 TopTools_ListOfShape L;
1481 myMap(it.Key()).Bind(V2,L);
1484 if (!myMap(it.Key()).IsBound(E)) {
1485 TopTools_ListOfShape L;
1486 myMap(it.Key()).Bind(E,L);
1489 for (; itLOF.More(); itLOF.Next()) {
1490 const TopoDS_Shape& OS = itLOF.Value();
1491 myMap(it.Key())(V2).Append(PS.LastShape(OS));
1492 myMap(it.Key())(E).Append(PS.Shape(OS));
1498 //=======================================================================
1500 //purpose : Order the sequence of points by growing x.
1501 //=======================================================================
1503 static void Bubble(TColStd_SequenceOfReal& Seq)
1505 Standard_Boolean Invert = Standard_True;
1506 Standard_Integer NbPoints = Seq.Length();
1509 Invert = Standard_False;
1510 for ( Standard_Integer i = 1; i < NbPoints; i++) {
1511 if ( Seq.Value(i+1) < Seq.Value(i)) {
1512 Seq.Exchange(i,i+1);
1513 Invert = Standard_True;
1520 //=======================================================================
1521 //function : PrepareProfile
1522 //purpose : - Projection of the profile on the working plane.
1523 // - Cut of the profile at the extrema of distance from profile to axis Oz.
1524 // - Isolate vertical and horizontal parts.
1525 // - Reconstruction of wires starting from cut edges.
1526 // New wires stored in <WorkProf> are always at the same
1527 // side of axis OZ or mixed with it.
1528 //=======================================================================
1530 void BRepFill_Evolved::PrepareProfile(TopTools_ListOfShape& WorkProf,
1531 TopTools_DataMapOfShapeShape& MapProf )
1534 // Supposedly the profile is located so that the only transformation
1535 // to be carried out is a projection on plane yOz.
1537 // initialise the projection Plane and the Line to evaluate the extrema.
1538 Handle(Geom_Plane) Plane = new Geom_Plane(gp_Ax3(gp::YOZ()));
1539 Handle(Geom2d_Line) Line = new Geom2d_Line(gp::OY2d());
1541 // Map initial vertex -> projected vertex.
1542 TopTools_DataMapOfShapeShape MapVerRefMoved;
1544 TopoDS_Vertex V1,V2,VRef1,VRef2;
1547 TopTools_ListOfShape WP;
1551 BRepTools_WireExplorer Exp(myProfile) ;
1553 while (Exp.More()) {
1554 TopTools_ListOfShape Cuts;
1555 Standard_Boolean NewWire = Standard_False;
1556 const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
1559 CutEdgeProf (E ,Plane ,Line ,Cuts ,MapVerRefMoved);
1561 EdgeVertices(E,VRef1,VRef2);
1563 if ( Cuts.IsEmpty()) {
1564 // Neither extrema nor intersections nor vertices on the axis.
1569 while (!Cuts.IsEmpty()) {
1570 const TopoDS_Edge& NE = TopoDS::Edge(Cuts.First());
1572 EdgeVertices(NE,V1,V2);
1573 if (!MapProf.IsBound(V1)) MapProf.Bind(V1,E);
1574 if (!MapProf.IsBound(V2)) MapProf.Bind(V2,E);
1579 if (DistanceToOZ(V2) < BRepFill_Confusion() &&
1580 DistanceToOZ(V1) > BRepFill_Confusion()) {
1581 // NE ends on axis OZ => new wire
1582 if (Cuts.IsEmpty()) {
1583 // last part of the current edge
1584 // If it is not the last edge of myProfile
1585 // create a new wire.
1586 NewWire = Standard_True;
1597 if (Exp.More() && NewWire) {
1603 // In the list of Wires, find edges generating plane or vertical vevo.
1604 TopTools_ListIteratorOfListOfShape ite;
1605 TopoDS_Wire CurW,NW;
1609 for (ite.Initialize(WP); ite.More(); ite.Next()) {
1610 CurW = TopoDS::Wire(ite.Value());
1611 Standard_Boolean YaModif = Standard_False;
1612 for (EW.Init(CurW,TopAbs_EDGE); EW.More(); EW.Next()) {
1613 const TopoDS_Edge& EE = TopoDS::Edge(EW.Current());
1614 if (IsVertical(EE) || IsPlanar(EE)) {
1615 YaModif = Standard_True;
1621 //Status = 0 for the begining
1625 Standard_Integer Status = 0;
1627 for (EW.Init(CurW,TopAbs_EDGE); EW.More(); EW.Next()) {
1628 const TopoDS_Edge& EE = TopoDS::Edge(EW.Current());
1629 if (IsVertical(EE)) {
1632 WorkProf.Append(NW);
1636 else if (IsPlanar(EE)) {
1639 WorkProf.Append(NW);
1643 else if ( Status != 1) {
1645 WorkProf.Append(NW);
1652 WorkProf.Append(CurW);
1656 //connect vertices modified in MapProf;
1657 TopTools_DataMapIteratorOfDataMapOfShapeShape gilbert(MapVerRefMoved);
1658 for ( ;gilbert.More() ;gilbert.Next()) {
1659 MapProf.Bind(gilbert.Value(),gilbert.Key());
1664 //=======================================================================
1665 //function : PrepareSpine
1667 //=======================================================================
1669 void BRepFill_Evolved::PrepareSpine(TopoDS_Face& WorkSpine,
1670 TopTools_DataMapOfShapeShape& MapSpine)
1674 TopTools_ListOfShape Cuts;
1675 TopTools_ListIteratorOfListOfShape IteCuts;
1676 TopoDS_Vertex V1,V2;
1679 const Handle(Geom_Surface)& S = BRep_Tool::Surface (mySpine,L);
1680 Standard_Real TolF = BRep_Tool::Tolerance(mySpine);
1681 B.MakeFace(WorkSpine,S,L,TolF);
1683 for (TopoDS_Iterator IteF(mySpine) ; IteF.More(); IteF.Next()) {
1687 Standard_Boolean IsClosed = IteF.Value().Closed();
1689 for (TopoDS_Iterator IteW(IteF.Value()); IteW.More(); IteW.Next()) {
1691 TopoDS_Edge E = TopoDS::Edge(IteW.Value());
1692 EdgeVertices(E,V1,V2);
1693 MapSpine.Bind(V1,V1);
1694 MapSpine.Bind(V2,V2);
1698 CutEdge (E, mySpine, Cuts);
1700 if (Cuts.IsEmpty()) {
1705 for (IteCuts.Initialize(Cuts); IteCuts.More(); IteCuts.Next()) {
1706 const TopoDS_Edge& NE = TopoDS::Edge(IteCuts.Value());
1708 MapSpine.Bind(NE,E);
1709 EdgeVertices(NE,V1,V2);
1710 if (!MapSpine.IsBound(V1)) MapSpine.Bind(V1,E);
1711 if (!MapSpine.IsBound(V2)) MapSpine.Bind(V2,E);
1715 NW.Closed(IsClosed);
1716 B.Add(WorkSpine, NW);
1719 // Construct curves 3D of the spine
1720 BRepLib::BuildCurves3d(WorkSpine);
1725 sprintf(name,"workspine");
1726 DBRep::Set(name,WorkSpine);
1731 //=======================================================================
1732 //function : GeneratedShapes
1734 //=======================================================================
1736 const TopoDS_Shape& BRepFill_Evolved::Top() const
1741 //=======================================================================
1742 //function : GeneratedShapes
1744 //=======================================================================
1746 const TopoDS_Shape& BRepFill_Evolved::Bottom() const
1751 //=======================================================================
1752 //function : GeneratedShapes
1754 //=======================================================================
1756 const TopTools_ListOfShape& BRepFill_Evolved::GeneratedShapes (
1757 const TopoDS_Shape& SpineShape,
1758 const TopoDS_Shape& ProfShape )
1761 if (myMap .IsBound(SpineShape) &&
1762 myMap(SpineShape).IsBound(ProfShape) ) {
1763 return myMap(SpineShape)(ProfShape);
1766 static TopTools_ListOfShape Empty;
1771 //=======================================================================
1772 //function : Generated
1774 //=================================================================== ====
1776 BRepFill_DataMapOfShapeDataMapOfShapeListOfShape& BRepFill_Evolved::Generated()
1781 //=======================================================================
1782 //function : Compare
1784 //=======================================================================
1786 static TopAbs_Orientation Compare (const TopoDS_Edge& E1,
1787 const TopoDS_Edge& E2)
1789 TopAbs_Orientation OO = TopAbs_FORWARD;
1790 TopoDS_Vertex V1[2],V2[2];
1791 TopExp::Vertices (E1,V1[0],V1[1]);
1792 TopExp::Vertices (E2,V2[0],V2[1]);
1793 gp_Pnt P1 = BRep_Tool::Pnt(V1[0]);
1794 gp_Pnt P2 =BRep_Tool::Pnt(V2[0]);
1795 gp_Pnt P3 =BRep_Tool::Pnt(V2[1]);
1796 if (P1.Distance(P3) < P1.Distance(P2)) OO = TopAbs_REVERSED;
1801 //=======================================================================
1804 //=======================================================================
1806 void BRepFill_Evolved::Add( BRepFill_Evolved& Vevo,
1807 const TopoDS_Wire& Prof,
1808 BRepTools_Quilt& Glue)
1811 BRepFill_DataMapOfShapeDataMapOfShapeListOfShape& MapVevo = Vevo.Generated();
1812 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iteP;
1813 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape iteS;
1814 TopoDS_Shape CurrentSpine, CurrentProf;
1816 if (Vevo.Shape().IsNull()) return;
1818 //-------------------------------------------------
1819 // Find wires common to <me> and <Vevo>.
1820 //-------------------------------------------------
1822 TopExp_Explorer ExProf;
1823 for (ExProf.Init(Prof,TopAbs_VERTEX); ExProf.More(); ExProf.Next()) {
1824 const TopoDS_Shape& VV = ExProf.Current();
1825 //---------------------------------------------------------------
1826 // Parse edges generated by VV in myMap if they existent
1828 //---------------------------------------------------------------
1830 //------------------------------------------------- -------------
1831 // Note: the curves of of reinforced edges are in the same direction
1832 // if one remains on the same edge.
1833 // if one passes from left to the right they are inverted.
1834 //------------------------------------------------- -------------
1835 Standard_Boolean Commun = Standard_False;
1836 Relative(myProfile,Prof,
1841 for (iteS.Initialize(myMap); iteS.More(); iteS.Next()) {
1842 const TopoDS_Shape& SP = iteS.Key();
1843 if (iteS.Value().IsBound(VV) &&
1844 MapVevo.IsBound(SP) && MapVevo(SP).IsBound(VV)) {
1846 const TopTools_ListOfShape& MyList = myMap(SP)(VV);
1847 const TopTools_ListOfShape& VevoList = Vevo.GeneratedShapes(SP,VV);
1848 TopTools_ListIteratorOfListOfShape MyIte (MyList);
1849 TopTools_ListIteratorOfListOfShape VevoIte(VevoList);
1850 for (; MyIte.More(); MyIte.Next(), VevoIte.Next()) {
1851 const TopoDS_Edge& ME = TopoDS::Edge(MyIte .Value());
1852 const TopoDS_Edge& VE = TopoDS::Edge(VevoIte.Value());
1853 TopAbs_Orientation OG = Compare(ME,VE);
1854 TopoDS_Shape aLocalShape = VE.Oriented (TopAbs_FORWARD);
1855 TopoDS_Shape aLocalShape2 = ME.Oriented (OG);
1856 Glue.Bind(TopoDS::Edge(aLocalShape),TopoDS::Edge(aLocalShape2));
1857 // Glue.Bind(TopoDS::Edge(VE.Oriented (TopAbs_FORWARD)),
1858 // TopoDS::Edge(ME.Oriented (OG)));
1864 Glue.Add(Vevo.Shape());
1866 //----------------------------------------------------------
1867 // Add map of elements generate in Vevo in myMap.
1868 //----------------------------------------------------------
1869 TopTools_DataMapOfShapeListOfShape EmptyMap;
1870 TopTools_ListOfShape EmptyList;
1872 for (iteS.Initialize(MapVevo); iteS.More() ; iteS.Next()) {
1873 CurrentSpine = iteS.Key();
1874 for (iteP.Initialize(MapVevo(CurrentSpine)); iteP.More(); iteP.Next()) {
1875 CurrentProf = iteP.Key();
1876 if (!myMap.IsBound(CurrentSpine)) {
1877 //------------------------------------------------
1878 // The element of spine is not yet present .
1879 // => previous profile not on the border.
1880 //-------------------------------------------------
1881 myMap.Bind(CurrentSpine,EmptyMap);
1883 if (!myMap(CurrentSpine).IsBound(CurrentProf)) {
1884 myMap(CurrentSpine).Bind(CurrentProf,EmptyList);
1885 const TopTools_ListOfShape& GenShapes
1886 = MapVevo (CurrentSpine)(CurrentProf);
1887 TopTools_ListIteratorOfListOfShape itl (GenShapes);
1888 for (; itl.More(); itl.Next()) {
1889 // during Glue.Add the shared shapes are recreated.
1890 if (Glue.IsCopied(itl.Value()))
1891 myMap(CurrentSpine)(CurrentProf).Append(Glue.Copy(itl.Value()));
1893 myMap(CurrentSpine)(CurrentProf).Append(itl.Value());
1900 //=======================================================================
1901 //function : ChangeShape
1903 //=======================================================================
1905 TopoDS_Shape& BRepFill_Evolved::ChangeShape()
1910 //=======================================================================
1911 //function : Transfert
1913 //=======================================================================
1915 void BRepFill_Evolved::Transfert( BRepFill_Evolved& Vevo,
1916 const TopTools_DataMapOfShapeShape& MapProf,
1917 const TopTools_DataMapOfShapeShape& MapSpine,
1918 const TopLoc_Location& LS,
1919 const TopLoc_Location& InitLS,
1920 const TopLoc_Location& InitLP)
1922 //----------------------------------------------------------------
1923 // Transfer the shape from Vevo in myShape and Reposition shapes.
1924 //----------------------------------------------------------------
1925 myShape = Vevo.Shape();
1926 mySpine .Location(InitLS);
1927 myProfile.Location(InitLP);
1931 // Expecting for better, the Same Parameter is forced here
1932 // ( Pb Sameparameter between YaPlanar and Tuyaux
1935 TopExp_Explorer ex(myShape,TopAbs_EDGE);
1937 B.SameRange(TopoDS::Edge(ex.Current()), Standard_False);
1938 B.SameParameter(TopoDS::Edge(ex.Current()), Standard_False);
1939 BRepLib::SameParameter(TopoDS::Edge(ex.Current()));
1944 //--------------------------------------------------------------
1945 // Transfer of myMap of Vevo into myMap.
1946 //--------------------------------------------------------------
1947 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape iteS;
1948 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iteP;
1949 TopTools_DataMapOfShapeListOfShape EmptyMap;
1950 TopTools_ListOfShape EmptyList;
1951 TopoDS_Shape InitialSpine, InitialProf;
1953 BRepFill_DataMapOfShapeDataMapOfShapeListOfShape& MapVevo
1956 for (iteS.Initialize(MapVevo); iteS.More(); iteS.Next()) {
1957 InitialSpine = MapSpine(iteS.Key());
1958 InitialSpine.Move(LS);
1960 for (iteP.Initialize(MapVevo(iteS.Key())); iteP.More(); iteP.Next()) {
1961 InitialProf = MapProf (iteP.Key());
1962 InitialProf.Location(InitLP);
1964 TopTools_ListOfShape& GenShapes =
1965 MapVevo.ChangeFind(iteS.Key()).ChangeFind(iteP.Key());
1967 TopTools_ListIteratorOfListOfShape itl;
1968 for (itl.Initialize(GenShapes); itl.More(); itl.Next()) {
1969 itl.Value().Move(LS);
1972 if (!myMap.IsBound(InitialSpine)) {
1973 myMap.Bind(InitialSpine,EmptyMap);
1976 if (!myMap(InitialSpine).IsBound(InitialProf)) {
1977 myMap(InitialSpine).Bind(InitialProf,EmptyList);
1979 myMap(InitialSpine)(InitialProf).Append(GenShapes);
1982 //--------------------------------------------------------------
1983 // Transfer of Top and Bottom of Vevo in myTop and myBottom.
1984 //--------------------------------------------------------------
1985 myTop = Vevo.Top() ; myTop.Move(LS);
1986 myBottom = Vevo.Bottom(); myBottom.Move(LS);
1989 //=======================================================================
1992 //=======================================================================
1994 Standard_Boolean BRepFill_Evolved::IsDone() const
1999 //=======================================================================
2002 //=======================================================================
2004 const TopoDS_Shape& BRepFill_Evolved::Shape() const
2009 //=======================================================================
2010 //function : JoinType
2012 //=======================================================================
2014 GeomAbs_JoinType BRepFill_Evolved::JoinType() const
2019 //=======================================================================
2020 //function : AddTopAndBottom
2022 //=======================================================================
2024 void BRepFill_Evolved::AddTopAndBottom(BRepTools_Quilt& Glue)
2026 // return first and last vertex of the profile.
2028 TopExp::Vertices (myProfile,V[0],V[1]);
2029 if (V[0].IsSame(V[1])) return;
2031 TopTools_ListIteratorOfListOfShape itL;
2032 Standard_Boolean ToReverse=Standard_False;
2033 for (Standard_Integer i = 0; i<=1; i++) {
2036 // Construction of supports.
2037 gp_Pln S (0.,0.,1.,- Altitud(V[i]));
2038 TopoDS_Face F = BRepLib_MakeFace(S);
2041 TopExp_Explorer ExpSpine(mySpine,TopAbs_EDGE);
2042 TopTools_MapOfShape View;
2044 for (; ExpSpine.More(); ExpSpine.Next()) {
2045 const TopoDS_Edge& ES = TopoDS::Edge(ExpSpine.Current());
2046 const TopTools_ListOfShape& L = GeneratedShapes(ES,V[i]);
2047 Standard_Boolean ComputeOrientation = 0;
2049 for (itL.Initialize(L); itL.More(); itL.Next()) {
2050 const TopoDS_Edge& E = TopoDS::Edge(itL.Value());
2052 if (!ComputeOrientation) {
2053 BRepAdaptor_Curve C1(ES);
2054 BRepAdaptor_Curve C2(E);
2055 Standard_Real f,l,fs,ls;
2056 BRep_Tool::Range(E ,f ,l);
2057 BRep_Tool::Range(ES,fs,ls);
2058 Standard_Real u = 0.3*f + 0.7*l;
2059 Standard_Real us = 0.3*fs + 0.7*ls;
2062 C1.D1(us,P,V1); C2.D1(u,P,V2);
2063 ToReverse = (V1.Dot(V2) < 0.);
2064 ComputeOrientation = 1;
2067 TopAbs_Orientation Or = ES.Orientation();
2068 if (ToReverse) Or = TopAbs::Reverse(Or);
2069 TopoDS_Shape aLocalShape = E.Oriented(Or);
2070 Loop.AddConstEdge(TopoDS::Edge(aLocalShape));
2071 // Loop.AddConstEdge(TopoDS::Edge(E.Oriented(Or)));
2075 gp_Pnt PV = BRep_Tool::Pnt(V[i]);
2076 Standard_Boolean IsOut = PV.Y() < 0;
2078 for (ExpSpine.Init(mySpine,TopAbs_VERTEX); ExpSpine.More(); ExpSpine.Next()) {
2079 const TopoDS_Vertex& ES = TopoDS::Vertex(ExpSpine.Current());
2081 const TopTools_ListOfShape& L = GeneratedShapes(ES,V[i]);
2082 for (itL.Initialize(L); itL.More(); itL.Next()) {
2083 const TopoDS_Edge& E = TopoDS::Edge(itL.Value());
2084 if (!BRep_Tool::Degenerated(E)){
2085 // the center of circle (ie vertex) is IN the cap if vertex IsOut
2087 BRepAdaptor_Curve C(E);
2089 BRep_Tool::Range(E,f,l);
2090 Standard_Real u = 0.3*f + 0.7*l;
2091 gp_Pnt P = BRep_Tool::Pnt(ES);
2096 gp_Vec Prod = aPPC.Crossed(VC);
2098 ToReverse = Prod.Z() < 0.;
2101 ToReverse = Prod.Z() > 0.;
2103 TopAbs_Orientation Or = TopAbs_FORWARD;
2104 if (ToReverse) Or = TopAbs_REVERSED;
2105 TopoDS_Shape aLocalShape = E.Oriented(Or);
2106 Loop.AddConstEdge(TopoDS::Edge(aLocalShape));
2107 // Loop.AddConstEdge(TopoDS::Edge(E.Oriented(Or)));
2114 Loop.WiresToFaces();
2115 const TopTools_ListOfShape& L = Loop.NewFaces();
2116 TopTools_ListIteratorOfListOfShape anIterL(L);
2118 // Maj of myTop and myBottom for the history
2119 // and addition of constructed faces.
2120 TopoDS_Compound Bouchon;
2122 B.MakeCompound(Bouchon);
2123 Standard_Integer j = 0;
2125 for (anIterL.Initialize(L); anIterL.More(); anIterL.Next()) {
2127 Glue.Add(anIterL.Value());
2128 if (j ==1 && i == 0) myTop = anIterL.Value();
2129 if (j ==1 && i == 1) myBottom = anIterL.Value();
2130 B.Add(Bouchon,anIterL.Value());
2132 if (i == 0 && j > 1) myTop = Bouchon;
2133 if (i == 1 && j > 1) myBottom = Bouchon;
2137 //================================================================== =====
2138 //function : MakePipe
2140 //=======================================================================
2142 void BRepFill_Evolved::MakeSolid()
2145 TopExp_Explorer exp(myShape,TopAbs_SHELL);
2146 Standard_Integer ish=0;
2147 TopoDS_Compound Res;
2150 B.MakeCompound(Res);
2152 for (; exp.More(); exp.Next()) {
2153 TopoDS_Shape Sh = exp.Current();
2156 BRepClass3d_SolidClassifier SC(Sol);
2157 SC.PerformInfinitePoint(BRepFill_Confusion());
2158 if (SC.State() == TopAbs_IN) {
2160 B.Add(Sol,Sh.Reversed());
2165 if (ish == 1) { myShape = Sol;}
2166 else { myShape = Res;}
2170 //=======================================================================
2171 //function : MakePipe
2173 //=======================================================================
2175 void BRepFill_Evolved::MakePipe(const TopoDS_Edge& SE,
2176 const gp_Ax3& AxeRef)
2178 BRepTools_WireExplorer ProfExp;
2179 TopExp_Explorer FaceExp;
2182 if (Side(myProfile,BRepFill_Confusion()) > 3) { // side right
2183 trsf.SetRotation(gp::OZ(),M_PI);
2185 TopLoc_Location DumLoc (trsf);
2186 TopoDS_Shape aLocalShape = myProfile.Moved(DumLoc);
2187 TopoDS_Wire DummyProf =
2188 PutProfilAt (TopoDS::Wire(aLocalShape),
2190 mySpine,Standard_True);
2191 // TopoDS_Wire DummyProf =
2192 // PutProfilAt (TopoDS::Wire(myProfile.Moved(DumLoc)),
2194 // mySpine,Standard_True);
2196 // Copy of the profile to avoid the accumulation of
2197 // locations on the Edges of myProfile!
2199 Handle(BRepTools_TrsfModification) TrsfMod
2200 = new BRepTools_TrsfModification(gp_Trsf());
2201 BRepTools_Modifier Modif(DummyProf,TrsfMod);
2203 TopoDS_Wire GenProf = TopoDS::Wire(Modif.ModifiedShape(DummyProf));
2208 sprintf(name,"EVOLBASE_%d",++NbFACES);
2209 DBRep::Set(name,SE);
2210 sprintf(name,"EVOLPROF_%d",NbFACES);
2211 DBRep::Set(name,GenProf);
2215 BRepFill_Pipe Pipe(BRepLib_MakeWire(SE), GenProf);
2216 //BRepFill_Pipe Pipe = BRepFill_Pipe(BRepLib_MakeWire(SE),GenProf);
2221 sprintf(name,"EVOL_%d",++NbFACES);
2222 DBRep::Set(name,Pipe.Shape());
2225 //---------------------------------------------
2226 // Arrangement of Tubes in myMap.
2227 //---------------------------------------------
2229 BRepTools_WireExplorer GenProfExp;
2230 TopTools_ListOfShape L;
2231 TopoDS_Vertex VF,VL,VFG,VLG;
2232 Standard_Boolean FirstVertex = Standard_True;
2233 TopTools_DataMapOfShapeListOfShape P;
2237 for (ProfExp.Init(myProfile),GenProfExp.Init(GenProf);
2239 ProfExp.Next(),GenProfExp.Next()) {
2241 EdgeVertices(ProfExp .Current(),VF ,VL);
2242 EdgeVertices(GenProfExp.Current(),VFG,VLG);
2245 myMap(SE).Bind(VF,L);
2246 myMap(SE)(VF).Append(Pipe.Edge(SE,VFG));
2247 FirstVertex = Standard_False;
2249 myMap(SE).Bind(VL,L);
2250 myMap(SE)(VL).Append(Pipe.Edge(SE,VLG));
2251 myMap(SE).Bind(ProfExp.Current(),L);
2252 myMap(SE)(ProfExp.Current()).Append
2253 (Pipe.Face(SE,GenProfExp.Current()));
2258 //=======================================================================
2259 //function : MakeRevol
2261 //=======================================================================
2263 void BRepFill_Evolved::MakeRevol(const TopoDS_Edge& SE,
2264 const TopoDS_Vertex& VLast,
2265 const gp_Ax3& AxeRef)
2267 BRepTools_WireExplorer ProfExp;
2268 TopExp_Explorer FaceExp;
2271 if (Side(myProfile,BRepFill_Confusion()) > 3) { // side right
2272 trsf.SetRotation(gp::OZ(),M_PI);
2274 TopLoc_Location DumLoc (trsf);
2275 TopoDS_Shape aLocalShape = myProfile.Moved(DumLoc);
2276 TopoDS_Wire GenProf =
2277 PutProfilAt (TopoDS::Wire(aLocalShape),
2279 mySpine,Standard_False);
2280 // TopoDS_Wire GenProf =
2281 // PutProfilAt (TopoDS::Wire(myProfile.Moved(DumLoc)),
2283 // mySpine,Standard_False);
2285 gp_Ax1 AxeRev( BRep_Tool::Pnt(VLast), -gp::DZ());
2287 // Position of the sewing on the edge of the spine
2288 // so that the bissectrices didn't cross the sewings.
2290 dummy.SetRotation(AxeRev, 1.5*M_PI);
2291 TopLoc_Location DummyLoc(dummy);
2292 GenProf.Move(DummyLoc);
2294 BRepSweep_Revol Rev(GenProf,AxeRev,Standard_True);
2299 sprintf(name,"EVOLBASE_%d",++NbFACES);
2300 DrawTrSurf::Set(name,new Geom_Line(AxeRev));
2301 // DrawTrSurf::Set(name,new Geom_Line(AxeRev));
2302 sprintf(name,"EVOLPROF_%d",NbFACES);
2303 DBRep::Set(name,GenProf);
2305 sprintf(name,"EVOL_%d",NbFACES);
2306 DBRep::Set(name,Rev.Shape());
2309 //--------------------------------------------
2310 // Arrangement of revolutions in myMap.
2311 //---------------------------------------------
2312 BRepTools_WireExplorer GenProfExp;
2313 TopTools_ListOfShape L;
2314 TopoDS_Vertex VF,VL,VFG,VLG;
2315 Standard_Boolean FirstVertex = Standard_True;
2316 TopTools_DataMapOfShapeListOfShape R;
2318 myMap.Bind(VLast,R);
2320 for (ProfExp.Init(myProfile),GenProfExp.Init(GenProf);
2322 ProfExp.Next(),GenProfExp.Next()) {
2324 EdgeVertices(ProfExp .Current(),VF ,VL);
2325 EdgeVertices(GenProfExp.Current(),VFG,VLG);
2327 TopAbs_Orientation Or = GenProfExp.Current().Orientation();
2330 myMap(VLast).Bind(VF,L);
2331 const TopoDS_Shape& RV = Rev.Shape(VFG);
2332 // TopAbs_Orientation OO = TopAbs::Compose(RV.Orientation(),Or);
2333 TopAbs_Orientation OO = RV.Orientation();
2334 myMap(VLast)(VF).Append(RV.Oriented(OO));
2335 FirstVertex = Standard_False;
2337 myMap(VLast).Bind(ProfExp.Current(),L);
2338 const TopoDS_Shape& RF = Rev.Shape(GenProfExp.Current());
2339 TopAbs_Orientation OO = TopAbs::Compose(RF.Orientation(),Or);
2341 myMap(VLast)(ProfExp.Current()).Append(RF.Oriented(OO));
2342 myMap(VLast).Bind(VL,L);
2343 const TopoDS_Shape& RV = Rev.Shape(VLG);
2344 // OO = TopAbs::Compose(RV.Orientation(),Or);
2345 OO = RV.Orientation();
2346 myMap(VLast)(VL).Append(RV.Oriented(OO));
2350 //=======================================================================
2351 //function : FindLocation
2353 //=======================================================================
2355 TopLoc_Location BRepFill_Evolved::FindLocation(const TopoDS_Face& Face)
2359 Handle(Geom_Surface) S;
2360 S = BRep_Tool::Surface(Face, L);
2362 if ( !S->IsKind(STANDARD_TYPE(Geom_Plane))) {
2363 BRepLib_FindSurface FS( Face, -1, Standard_True);
2369 throw Standard_NoSuchObject("BRepFill_Evolved : The Face is not planar");
2372 if (!L.IsIdentity())
2373 S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
2375 Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(S);
2376 gp_Ax3 Axis = P->Position();
2379 gp_Ax3 AxeRef(gp_Pnt(0.,0.,0.),
2382 T.SetTransformation(AxeRef,Axis);
2384 return TopLoc_Location(T);
2388 //=======================================================================
2389 //function : TransformInitWork
2391 //=======================================================================
2393 void BRepFill_Evolved::TransformInitWork(const TopLoc_Location& LS,
2394 const TopLoc_Location& LP)
2402 sprintf(name,"movedspine");
2403 TopoDS_Face SL = mySpine;
2404 DBRep::Set(name,SL);
2405 sprintf(name,"movedprofile");
2406 TopoDS_Wire PL = myProfile;
2407 DBRep::Set(name,PL);
2413 //=======================================================================
2414 //function : ContinuityOnOffsetEdge
2415 //purpose : Coding of regularities on edges parallel to CutVevo
2416 // common to left and right parts of volevo.
2417 //=======================================================================
2418 void BRepFill_Evolved::ContinuityOnOffsetEdge (const TopTools_ListOfShape&)
2420 BRepTools_WireExplorer WExp ;
2421 BRepFill_DataMapIteratorOfDataMapOfShapeDataMapOfShapeListOfShape iteS;
2422 TopoDS_Vertex VF,VL,V;
2423 TopoDS_Edge PrecE,CurE,FirstE;
2427 WExp.Init(myProfile);
2428 FirstE = WExp.Current();
2430 EdgeVertices (FirstE, VF, V);
2431 if (WExp.More()) WExp.Next();
2433 for (; WExp.More(); WExp.Next()) {
2434 CurE = WExp.Current();
2435 V = WExp.CurrentVertex();
2437 if (DistanceToOZ(V) <= BRepFill_Confusion()) {
2438 // the regularities are already coded on the edges of elementary volevos
2439 Standard_Real U1 = BRep_Tool::Parameter(V,CurE);
2440 Standard_Real U2 = BRep_Tool::Parameter(V,PrecE);
2441 BRepAdaptor_Curve Curve1(CurE);
2442 BRepAdaptor_Curve Curve2(PrecE);
2443 GeomAbs_Shape Continuity = BRepLProp::Continuity(Curve1,Curve2,U1,U2);
2445 if (Continuity >=1) {
2446 //-----------------------------------------------------
2447 //Code continuity for all edges generated by V.
2448 //-----------------------------------------------------
2449 for (iteS.Initialize(myMap); iteS.More(); iteS.Next()) {
2450 const TopoDS_Shape& SP = iteS.Key();
2451 if (myMap (SP).IsBound(V)
2452 && myMap (SP).IsBound(CurE) && myMap (SP).IsBound(PrecE)){
2453 if (!myMap(SP)(V) .IsEmpty() &&
2454 !myMap(SP)(CurE) .IsEmpty() &&
2455 !myMap(SP)(PrecE).IsEmpty() )
2456 B.Continuity (TopoDS::Edge(myMap(SP)(V) .First()),
2457 TopoDS::Face(myMap(SP)(CurE) .First()),
2458 TopoDS::Face(myMap(SP)(PrecE).First()),
2467 EdgeVertices (PrecE, V, VL);
2469 if (VF.IsSame(VL)) {
2471 Standard_Real U1 = BRep_Tool::Parameter(VF,CurE);
2472 Standard_Real U2 = BRep_Tool::Parameter(VF,FirstE);
2473 BRepAdaptor_Curve Curve1(CurE);
2474 BRepAdaptor_Curve Curve2(FirstE);
2475 GeomAbs_Shape Continuity = BRepLProp::Continuity(Curve1,Curve2,U1,U2);
2477 if (Continuity >=1) {
2478 //---------------------------------------------
2479 //Code continuity for all edges generated by V.
2480 //---------------------------------------------
2481 for (iteS.Initialize(myMap); iteS.More(); iteS.Next()) {
2482 const TopoDS_Shape& SP = iteS.Key();
2483 if (myMap (SP).IsBound(VF)
2484 && myMap (SP).IsBound(CurE) && myMap (SP).IsBound(FirstE)){
2485 if (!myMap(SP)(VF) .IsEmpty() &&
2486 !myMap(SP)(CurE) .IsEmpty() &&
2487 !myMap(SP)(FirstE).IsEmpty() )
2488 B.Continuity (TopoDS::Edge(myMap(SP)(VF) .First()),
2489 TopoDS::Face(myMap(SP)(CurE) .First()),
2490 TopoDS::Face(myMap(SP)(FirstE).First()),
2498 //=======================================================================
2499 //function : AddDegeneratedEdge
2500 //purpose : degenerated edges can be missing in some face
2501 // the missing degenerated edges have vertices corresponding
2502 // to node of the map.
2503 // Now it is enough to compare points UV of vertices
2504 // on edges with a certain tolerance.
2505 //=======================================================================
2507 static void AddDegeneratedEdge(TopoDS_Face& F,
2511 Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
2512 if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
2513 Handle(Geom_Surface) SB = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
2514 if (SB->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
2519 if (S->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
2525 Standard_Real TolConf = 1.e-4;
2527 Standard_Boolean Change = Standard_True;
2530 Change = Standard_False;
2531 BRepTools_WireExplorer WE(W,F);
2532 gp_Pnt2d PF,PrevP,P1,P2;
2533 TopoDS_Vertex VF,V1,V2;
2535 for (; WE.More(); WE.Next()) {
2536 const TopoDS_Edge& CE = WE.Current();
2537 EdgeVertices (CE,V1,V2);
2538 if (CE.Orientation() == TopAbs_REVERSED)
2539 BRep_Tool::UVPoints(CE, F, P2, P1);
2541 BRep_Tool::UVPoints(CE, F, P1, P2);
2547 if (!P1.IsEqual(PrevP,TolConf)) {
2548 // degenerated edge to be inserted.
2549 Change = Standard_True;
2550 gp_Vec2d V(PrevP,P1);
2551 Handle(Geom2d_Line) C2d = new Geom2d_Line(PrevP,gp_Dir2d(V));
2552 Standard_Real f = 0, l = PrevP.Distance(P1);
2553 Handle(Geom2d_TrimmedCurve) CT = new Geom2d_TrimmedCurve(C2d,f,l);
2554 TopoDS_Edge NE = BRepLib_MakeEdge(C2d,S);
2555 B.Degenerated(NE,Standard_True);
2556 B.Add(NE,V1.Oriented(TopAbs_FORWARD));
2557 B.Add(NE,V1.Oriented(TopAbs_REVERSED));
2565 if (!Change && VF.IsSame(V2)) { // closed
2566 if (!PF.IsEqual(P2,TolConf)) {
2567 // Degenerated edge to be inserted.
2568 Change = Standard_True;
2570 Handle(Geom2d_Line) C2d = new Geom2d_Line(P2,gp_Dir2d(V));
2571 Standard_Real f = 0, l = P2.Distance(PF);
2572 Handle(Geom2d_TrimmedCurve) CT = new Geom2d_TrimmedCurve(C2d,f,l);
2573 TopoDS_Edge NE = BRepLib_MakeEdge(C2d,S);
2574 B.Degenerated(NE,Standard_True);
2575 B.Add(NE,VF.Oriented(TopAbs_FORWARD));
2576 B.Add(NE,VF.Oriented(TopAbs_REVERSED));
2584 //=======================================================================
2585 //function : TrimFace
2587 //=======================================================================
2589 void TrimFace(const TopoDS_Face& Face,
2590 TopTools_SequenceOfShape& TheEdges,
2591 TopTools_SequenceOfShape& S)
2595 Standard_Integer NB = TheEdges.Length();
2598 std::cout << " TrimFace " << ++NbTRIMFACES;
2599 std::cout << " : " << NB << " edges within the restriction" << std::endl;
2600 for ( Standard_Integer j = 1; j <= NB; j++) {
2601 sprintf(name,"TRIMEDGE_%d_%d",NbTRIMFACES,j);
2602 DBRep::Set(name,TopoDS::Edge(TheEdges.Value(j)));
2608 //--------------------------------------
2609 // Creation of wires limiting faces.
2610 //--------------------------------------
2611 BRep_Builder TheBuilder;
2613 Standard_Integer NbEdges;
2614 Standard_Boolean NewWire = Standard_True;
2615 Standard_Boolean AddEdge = Standard_False;
2616 TopoDS_Wire GoodWire;
2619 while ( !TheEdges.IsEmpty()) {
2621 BRepLib_MakeWire MWire(TopoDS::Edge(TheEdges.First()));
2622 GoodWire = MWire.Wire();
2624 NbEdges = TheEdges.Length();
2625 NewWire = Standard_False;
2628 AddEdge = Standard_False;
2630 for ( Standard_Integer i = 1; i <= NbEdges && !AddEdge; i++) {
2631 const TopoDS_Edge& E = TopoDS::Edge(TheEdges.Value(i));
2632 if ( BRep_Tool::Degenerated(E)) {
2634 AddEdge = Standard_True;
2635 NbEdges = TheEdges.Length();
2636 GoodWire = MWire.Wire();
2640 if ( MWire.Error() == BRepLib_WireDone) {
2641 // the connection is successful
2642 // it is removed from the sequence and one restarts from the beginning.
2644 AddEdge = Standard_True;
2645 NbEdges = TheEdges.Length();
2646 GoodWire = MWire.Wire();
2650 NewWire = (!AddEdge);
2652 TopoDS_Shape aLocalShape = Face.EmptyCopied();
2653 TopoDS_Face FaceCut = TopoDS::Face(aLocalShape);
2654 // TopoDS_Face FaceCut = TopoDS::Face(Face.EmptyCopied());
2655 FaceCut.Orientation(TopAbs_FORWARD);
2656 BRepTools::Update (FaceCut);
2657 AddDegeneratedEdge (FaceCut,GoodWire);
2658 TheBuilder.Add (FaceCut,GoodWire);
2659 FaceCut.Orientation(Face.Orientation());
2666 //=======================================================================
2667 //function : PutProfilAt
2669 //=======================================================================
2671 const TopoDS_Wire PutProfilAt (const TopoDS_Wire& ProfRef,
2672 const gp_Ax3& AxeRef,
2673 const TopoDS_Edge& E,
2674 const TopoDS_Face& F,
2675 const Standard_Boolean AtStart)
2680 Handle(Geom2d_Curve) C2d;
2681 Standard_Real First,Last;
2683 C2d = BRep_Tool::CurveOnSurface(E,F,First,Last);
2685 throw Standard_ConstructionError("ConstructionError in PutProfilAt");
2688 if (E.Orientation() == TopAbs_REVERSED) {
2689 if (!AtStart) C2d->D1(First,P,D1);else C2d->D1(Last,P,D1);
2693 if (!AtStart) C2d->D1(Last,P,D1) ;else C2d->D1(First,P,D1);
2695 gp_Pnt P3d(P.X() ,P.Y() ,0.);
2696 gp_Vec V3d(D1.X(),D1.Y(),0.);
2698 gp_Ax3 Ax( P3d, gp::DZ(), V3d);
2700 Trans.SetTransformation(Ax,AxeRef);
2701 TopoDS_Shape aLocalShape = ProfRef.Moved(TopLoc_Location(Trans));
2702 Prof = TopoDS::Wire(aLocalShape);
2703 // Prof = TopoDS::Wire(ProfRef.Moved(TopLoc_Location(Trans)));
2708 //=======================================================================
2709 //function : TrimEdge
2711 //=======================================================================
2713 void TrimEdge (const TopoDS_Edge& Edge,
2714 const TopTools_SequenceOfShape& TheEdgesControle,
2715 TopTools_SequenceOfShape& TheVer,
2716 TColStd_SequenceOfReal& ThePar,
2717 TopTools_SequenceOfShape& S)
2719 Standard_Boolean Change = Standard_True;
2720 BRep_Builder TheBuilder;
2722 //------------------------------------------------------------
2723 // Parse two sequences depending on the parameter on the edge.
2724 //------------------------------------------------------------
2726 Change = Standard_False;
2727 for (Standard_Integer i = 1; i < ThePar.Length(); i++) {
2728 if (ThePar.Value(i) > ThePar.Value(i+1)) {
2729 ThePar.Exchange(i,i+1);
2730 TheVer.Exchange(i,i+1);
2731 Change = Standard_True;
2736 //----------------------------------------------------------
2737 // If a vertex is not in the proofing point, it is removed.
2738 //----------------------------------------------------------
2739 if (!BRep_Tool::Degenerated(Edge)) {
2740 for (Standard_Integer k = 1; k <= TheVer.Length(); k ++) {
2741 if ( DoubleOrNotInFace (TheEdgesControle,
2742 TopoDS::Vertex(TheVer.Value(k)))) {
2750 //-------------------------------------------------------------------
2751 // Processing of double vertices for non-degenerated edges.
2752 // If a vertex_double appears twice in the edges of control,
2753 // the vertex is eliminated .
2754 // otherwise its only representation is preserved.
2755 //-------------------------------------------------------------------
2756 if (!BRep_Tool::Degenerated(Edge)) {
2757 for (Standard_Integer k = 1; k < TheVer.Length(); k ++) {
2758 if (TheVer.Value(k).IsSame(TheVer.Value(k+1))) {
2761 if ( DoubleOrNotInFace (TheEdgesControle,
2762 TopoDS::Vertex(TheVer.Value(k)))) {
2772 //-----------------------------------------------------------
2773 // Creation of edges.
2774 // the number of vertices should be even. The edges to be created leave
2775 // from a vertex with uneven index i to vertex i+1;
2776 //-----------------------------------------------------------
2777 for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) {
2778 TopoDS_Shape aLocalShape = Edge.EmptyCopied();
2779 TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape);
2780 // TopoDS_Edge NewEdge = TopoDS::Edge(Edge.EmptyCopied());
2782 if (NewEdge.Orientation() == TopAbs_REVERSED) {
2783 TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_REVERSED));
2784 TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD));
2787 TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_FORWARD));
2788 TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED));
2790 TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1));
2791 // modified by NIZHNY-EAP Wed Dec 22 12:09:48 1999 ___BEGIN___
2792 BRepLib::UpdateTolerances(NewEdge,Standard_False);
2793 // modified by NIZHNY-EAP Wed Dec 22 13:34:19 1999 ___END___
2798 //=======================================================================
2799 //function : ComputeIntervals
2801 //=======================================================================
2803 void ComputeIntervals (const TopTools_SequenceOfShape& VOnF,
2804 const TopTools_SequenceOfShape& VOnL,
2805 const TColgp_SequenceOfPnt& ParOnF,
2806 const TColgp_SequenceOfPnt& ParOnL,
2807 const BRepFill_TrimSurfaceTool& Trim,
2808 const Handle(Geom2d_Curve)& Bis,
2809 const TopoDS_Vertex& VS,
2810 const TopoDS_Vertex& VE,
2811 TColStd_SequenceOfReal& FirstPar,
2812 TColStd_SequenceOfReal& LastPar,
2813 TopTools_SequenceOfShape& FirstV,
2814 TopTools_SequenceOfShape& LastV )
2816 Standard_Integer IOnF = 1,IOnL = 1;
2817 Standard_Real U1 = 0.,U2;
2821 U1 = Bis->FirstParameter();
2824 while ( IOnF <= VOnF.Length() || IOnL <= VOnL.Length()) {
2825 //---------------------------------------------------------
2826 // Return the smallest parameter on the bissectrice
2827 // correponding to the current positions IOnF,IOnL.
2828 //---------------------------------------------------------
2829 if ( IOnL > VOnL.Length() ||
2830 (IOnF <= VOnF.Length() &&
2831 ParOnF.Value(IOnF).X() < ParOnL.Value(IOnL).X())) {
2833 U2 = ParOnF.Value(IOnF).X();
2834 V2 = VOnF .Value(IOnF);
2838 U2 = ParOnL.Value(IOnL).X();
2839 V2 = VOnL .Value(IOnL);
2842 //---------------------------------------------------------------------
2843 // When V2 and V1 are different the medium point P of the
2844 // interval is tested compared to the face. If P is in the face the interval
2846 //---------------------------------------------------------------------
2847 if (!V1.IsNull() && !V2.IsSame(V1)) {
2848 gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
2849 if (Trim.IsOnFace(P)) {
2850 FirstPar.Append(U1); LastPar .Append(U2);
2851 FirstV. Append(V1); LastV .Append(V2);
2859 U2 = Bis->LastParameter();
2861 if (!V2.IsSame(V1)) {
2862 gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
2863 if (Trim.IsOnFace(P)) {
2864 FirstPar.Append(U1); LastPar .Append(U2);
2865 FirstV.Append (V1); LastV .Append(V2);
2872 //=======================================================================
2873 //function : Relative
2874 //purpose : Commun is true if two wires have V in common
2875 // return FORWARD if the wires near the vertex are at
2876 // the same side. otherwise REVERSED.
2877 //=======================================================================
2878 static TopAbs_Orientation Relative (const TopoDS_Wire& W1,
2879 const TopoDS_Wire& W2,
2880 const TopoDS_Vertex& V,
2881 Standard_Boolean& Commun)
2883 TopExp_Explorer Exp;
2885 TopoDS_Vertex V1,V2;
2887 for (Exp.Init(W1,TopAbs_EDGE); Exp.More(); Exp.Next()) {
2888 const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
2889 TopExp::Vertices(E,V1,V2);
2890 if (V1.IsSame(V) || V2.IsSame(V)) {
2895 for (Exp.Init(W2,TopAbs_EDGE); Exp.More(); Exp.Next()) {
2896 const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
2897 TopExp::Vertices(E,V1,V2);
2898 if (V1.IsSame(V) || V2.IsSame(V)) {
2904 if (E1.IsNull() || E2.IsNull()) {
2905 Commun = Standard_False;
2906 return TopAbs_FORWARD;
2908 Commun = Standard_True;
2910 TopoDS_Wire WW1 = BRepLib_MakeWire(E1);
2911 TopoDS_Wire WW2 = BRepLib_MakeWire(E2);
2912 Standard_Real Tol = BRepFill_Confusion();
2913 if (Side(WW1,Tol) < 4 && Side(WW2,Tol) < 4) // two to the left
2914 return TopAbs_FORWARD;
2915 if (Side(WW1,Tol) > 4 && Side(WW2,Tol) > 4) // two to the right
2916 return TopAbs_FORWARD;
2918 return TopAbs_REVERSED;
2921 //=======================================================================
2922 //function : IsOnFace
2923 //purpose : Return the position of the point defined by d1
2924 // in the face defined by d2 d3.
2926 // 0 : the point is out of the face.
2927 // 1 : the point is on edge corresponding to d2.
2928 // 2 : the point is inside the face.
2929 // 3 : the point is on edge corresponding to d3.
2930 //=======================================================================
2932 Standard_Integer PosOnFace (Standard_Real d1,
2936 if (Abs(d1 - d2) <= BRepFill_Confusion())
2938 if (Abs(d1 - d3) <= BRepFill_Confusion())
2942 if (d1 > (d2 + BRepFill_Confusion()) &&
2943 d1 < (d3 - BRepFill_Confusion()) )
2947 if (d1 > (d3 + BRepFill_Confusion()) &&
2948 d1 < (d2 - BRepFill_Confusion()) )
2954 //=======================================================================
2955 //function : DoubleOrNotInFace
2956 //purpose : Return True if V appears zero or two times in the sequence
2958 //=======================================================================
2960 Standard_Boolean DoubleOrNotInFace(const TopTools_SequenceOfShape& EC,
2961 const TopoDS_Vertex& V)
2963 Standard_Boolean Vu = Standard_False;
2965 for (Standard_Integer i = 1; i <= EC.Length(); i++) {
2966 TopoDS_Vertex V1,V2;
2967 TopExp::Vertices(TopoDS::Edge(EC.Value(i)),V1,V2);
2969 if (Vu) return Standard_True;
2970 else Vu = Standard_True;
2973 if (Vu) return Standard_True;
2974 else Vu = Standard_True;
2977 if (Vu) return Standard_False;
2978 else return Standard_True;
2982 //=======================================================================
2983 //function : DistanceToOZ
2985 //=======================================================================
2987 Standard_Real DistanceToOZ (const TopoDS_Vertex& V)
2989 gp_Pnt PV3d = BRep_Tool::Pnt(V);
2990 return Abs(PV3d.Y());
2993 //=======================================================================
2994 //function : Altitud
2996 //=======================================================================
2998 Standard_Real Altitud (const TopoDS_Vertex& V)
3000 gp_Pnt PV3d = BRep_Tool::Pnt(V);
3004 //=======================================================================
3005 //function : SimpleExpression
3007 //=======================================================================
3009 void SimpleExpression (const Bisector_Bisec& B,
3010 Handle(Geom2d_Curve)& Bis)
3014 Handle(Standard_Type) BT = Bis->DynamicType();
3015 if (BT == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
3016 Handle(Geom2d_TrimmedCurve) TrBis
3017 = Handle(Geom2d_TrimmedCurve)::DownCast(Bis);
3018 Handle(Geom2d_Curve) BasBis = TrBis->BasisCurve();
3019 BT = BasBis->DynamicType();
3020 if (BT == STANDARD_TYPE(Bisector_BisecAna)) {
3021 Bis = Handle(Bisector_BisecAna)::DownCast(BasBis)->Geom2dCurve();
3022 Bis = new Geom2d_TrimmedCurve (Bis,
3023 TrBis->FirstParameter(),
3024 TrBis->LastParameter());
3029 //=======================================================================
3030 //function : CutEdgeProf
3031 //purpose : Projection and Cut of an edge at extrema of distance to axis OZ.
3032 //=======================================================================
3034 void CutEdgeProf (const TopoDS_Edge& E,
3035 const Handle(Geom_Plane)& Plane,
3036 const Handle(Geom2d_Line)& Line,
3037 TopTools_ListOfShape& Cuts,
3038 TopTools_DataMapOfShapeShape& MapVerRefMoved)
3043 Handle(Geom_Curve) C;
3044 Handle(Geom_TrimmedCurve) CT;
3045 Handle(Geom2d_Curve) C2d;
3048 // Return the curve associated to each Edge
3049 C = BRep_Tool::Curve(E,L,f,l);
3050 CT = new Geom_TrimmedCurve(C,f,l);
3051 CT->Transform(L.Transformation());
3053 // project it in the plane and return the associated PCurve
3054 gp_Dir Normal = Plane->Pln().Axis().Direction();
3055 C = GeomProjLib::ProjectOnPlane (CT, Plane, Normal, Standard_False);
3056 C2d = GeomProjLib::Curve2d(C,Plane);
3058 // Calculate the extrema with the straight line
3059 TColStd_SequenceOfReal Seq;
3061 Standard_Real U1 = -Precision::Infinite();
3062 Standard_Real U2 = Precision::Infinite();
3063 f= C2d->FirstParameter();
3064 l= C2d->LastParameter();
3067 Geom2dAdaptor_Curve AC2d(C2d);
3068 BndLib_Add2dCurve::Add(AC2d,BRepFill_Confusion(),B);
3069 Standard_Real xmin,xmax;
3070 B.Get(xmin,U1,xmax,U2);
3072 // modified by NIZHNY-EAP Wed Feb 2 16:32:37 2000 ___BEGIN___
3073 // no sense if C2 is normal to Line or really is a point
3075 Geom2dAPI_ExtremaCurveCurve Extrema(Line,C2d,U1-1.,U2+1.,f,l);
3077 Standard_Integer i, Nb = Extrema.NbExtrema();
3078 for ( i = 1; i <= Nb; i++) {
3079 Extrema.Parameters(i,U1,U2);
3083 // modified by NIZHNY-EAP Wed Feb 2 16:33:05 2000 ___END___
3085 // On calcule les intersection avec Oy.
3086 Geom2dAdaptor_Curve ALine(Line);
3087 Standard_Real Tol = Precision::Intersection();
3088 Standard_Real TolC = 0.;
3090 Geom2dInt_GInter Intersector(ALine,AC2d,TolC,Tol);
3091 Standard_Integer i, Nb = Intersector.NbPoints();
3093 for ( i = 1; i <= Nb; i++) {
3094 Seq.Append(Intersector.Point(i).ParamOnSecond());
3097 // Compute the new edges.
3098 BRep_Builder Builder;
3099 TopoDS_Vertex VV,Vf,Vl,VRf,VRl;
3100 TopExp::Vertices(E,VRf,VRl);
3102 if (!MapVerRefMoved.IsBound(VRf)) {
3103 Builder.MakeVertex(Vf,C->Value(f),BRep_Tool::Tolerance(VRf));
3104 MapVerRefMoved.Bind(VRf,Vf);
3107 Vf = TopoDS::Vertex(MapVerRefMoved(VRf));
3110 if (!MapVerRefMoved.IsBound(VRl)) {
3111 Builder.MakeVertex(Vl,C->Value(l),BRep_Tool::Tolerance(VRl));
3112 MapVerRefMoved.Bind(VRl,Vl);
3115 Vl = TopoDS::Vertex(MapVerRefMoved(VRl));
3118 if ( !Seq.IsEmpty()) {
3122 Standard_Boolean Empty = Standard_False;
3124 Standard_Real CurParam = f;
3125 Standard_Real Param;
3128 Param = Seq.First();
3130 Empty = Seq.IsEmpty();
3131 if (Abs( Param - CurParam) > BRepFill_Confusion() &&
3132 Abs( Param - l) > BRepFill_Confusion() ) {
3134 VV = BRepLib_MakeVertex( C->Value(Param));
3136 TopoDS_Edge EE = BRepLib_MakeEdge(C,Vf,VV);
3137 EE.Orientation(E.Orientation());
3138 if ( EE.Orientation() == TopAbs_FORWARD)
3150 TopoDS_Edge EE = BRepLib_MakeEdge(C,Vf,Vl);
3151 EE.Orientation(E.Orientation());
3152 if ( EE.Orientation() == TopAbs_FORWARD)
3158 //=======================================================================
3159 //function : CutEdge
3160 //purpose : Cut an edge at thw extrema of curves and at points of inflexion.
3161 // Closed circles are also cut in two.
3162 // If <Cuts> are empty the edge is not modified.
3163 // The first and the last vertex of the original edge
3164 // belong to the first and last parts respectively.
3165 //=======================================================================
3166 void CutEdge (const TopoDS_Edge& E,
3167 const TopoDS_Face& F,
3168 TopTools_ListOfShape& Cuts)
3171 MAT2d_CutCurve Cuter;
3173 Handle(Geom2d_Curve) C2d;
3174 Handle(Geom2d_TrimmedCurve) CT2d;
3176 TopoDS_Vertex V1,V2,VF,VL;
3177 TopExp::Vertices (E,V1,V2);
3180 C2d = BRep_Tool::CurveOnSurface (E,F,f,l);
3181 CT2d = new Geom2d_TrimmedCurve(C2d,f,l);
3183 if (CT2d->BasisCurve()->IsKind(STANDARD_TYPE(Geom2d_Circle)) &&
3184 BRep_Tool::IsClosed(E)) {
3185 //---------------------------
3186 // Cut closed circle.
3187 //---------------------------
3188 Standard_Real m1 = (2*f + l)/3.;
3189 Standard_Real m2 = ( f + 2*l)/3.;
3190 gp_Pnt2d P1 = CT2d->Value(m1);
3191 gp_Pnt2d P2 = CT2d->Value(m2);
3193 TopoDS_Vertex VL1 = BRepLib_MakeVertex(gp_Pnt(P1.X(), P1.Y(), 0.));
3194 TopoDS_Vertex VL2 = BRepLib_MakeVertex(gp_Pnt(P2.X(), P2.Y(), 0.));
3195 TopoDS_Shape aLocalShape1 = E.EmptyCopied();
3196 TopoDS_Shape aLocalShape2 = E.EmptyCopied();
3197 TopoDS_Shape aLocalShape3 = E.EmptyCopied();
3198 TopoDS_Edge FE = TopoDS::Edge(aLocalShape1);
3199 TopoDS_Edge ME = TopoDS::Edge(aLocalShape2);
3200 TopoDS_Edge LE = TopoDS::Edge(aLocalShape3);
3201 // TopoDS_Edge FE = TopoDS::Edge(E.EmptyCopied());
3202 // TopoDS_Edge ME = TopoDS::Edge(E.EmptyCopied());
3203 // TopoDS_Edge LE = TopoDS::Edge(E.EmptyCopied());
3205 FE.Orientation(TopAbs_FORWARD);
3206 ME.Orientation(TopAbs_FORWARD);
3207 LE.Orientation(TopAbs_FORWARD );
3210 B.Add (FE,VL1.Oriented(TopAbs_REVERSED));
3213 B.Add (ME,VL1.Oriented(TopAbs_FORWARD));
3214 B.Add (ME,VL2.Oriented(TopAbs_REVERSED));
3215 B.Range(ME, m1, m2);
3217 B.Add (LE,VL2.Oriented(TopAbs_FORWARD));
3221 Cuts.Append(FE.Oriented(E.Orientation()));
3222 Cuts.Append(ME.Oriented(E.Orientation()));
3223 Cuts.Append(LE.Oriented(E.Orientation()));
3230 //-------------------------
3231 // Cut of the curve.
3232 //-------------------------
3233 Cuter.Perform(CT2d);
3235 if (Cuter.UnModified()) {
3236 //-----------------------------
3237 // edge not modified => return.
3238 //-----------------------------
3242 //------------------------
3243 // Creation of cut edges.
3244 //------------------------
3247 for ( Standard_Integer k = 1; k <= Cuter.NbCurves(); k++) {
3248 Handle(Geom2d_TrimmedCurve)CC = Cuter.Value(k);
3249 if (k == Cuter.NbCurves()) {VL = V2;}
3251 gp_Pnt2d P = CC->Value(CC->LastParameter());
3252 VL = BRepLib_MakeVertex(gp_Pnt(P.X(), P.Y(), 0.));
3254 TopoDS_Shape aLocalShape = E.EmptyCopied();
3255 TopoDS_Edge NE = TopoDS::Edge(aLocalShape);
3256 // TopoDS_Edge NE = TopoDS::Edge(E.EmptyCopied());
3257 NE.Orientation(TopAbs_FORWARD);
3258 B.Add (NE,VF.Oriented(TopAbs_FORWARD));
3259 B.Add (NE,VL.Oriented(TopAbs_REVERSED));
3260 B.Range(NE,CC->FirstParameter(),CC->LastParameter());
3261 Cuts.Append(NE.Oriented(E.Orientation()));
3267 //=======================================================================
3268 //function : VertexFromNode
3269 //purpose : Test if the position of aNode correspondingly to the distance to OZ
3270 // of vertices VF and VL. returns Status.
3271 // if Status is different from 0 Returned
3272 // the vertex corresponding to aNode is created.
3273 //=======================================================================
3275 Standard_Integer VertexFromNode
3276 (const Handle(MAT_Node)& aNode,
3277 const TopoDS_Edge& E,
3278 const TopoDS_Vertex& VF,
3279 const TopoDS_Vertex& VL,
3280 BRepFill_DataMapOfNodeDataMapOfShapeShape& MapNodeVertex,
3283 TopoDS_Shape ShapeOnNode;
3284 TopTools_DataMapOfShapeShape EmptyMap;
3285 Standard_Integer Status = 0;
3288 if (!aNode->Infinite()) {
3289 Status = PosOnFace(aNode->Distance(),
3290 DistanceToOZ(VF) , DistanceToOZ(VL));
3292 if (Status == 2) ShapeOnNode = E;
3293 else if (Status == 1) ShapeOnNode = VF;
3294 else if (Status == 3) ShapeOnNode = VL;
3296 if (!ShapeOnNode.IsNull()) {
3297 //-------------------------------------------------
3298 // the vertex will correspond to a node of the map
3299 //-------------------------------------------------
3300 if (MapNodeVertex.IsBound(aNode) &&
3301 MapNodeVertex(aNode).IsBound(ShapeOnNode)) {
3303 (MapNodeVertex(aNode)(ShapeOnNode));
3307 if (!MapNodeVertex.IsBound(aNode)) {
3308 MapNodeVertex.Bind(aNode,EmptyMap);
3310 MapNodeVertex(aNode).Bind(ShapeOnNode,VN);