1 // File: NMTTools_PaveFiller_2.cxx
2 // Created: Mon Dec 8 12:02:56 2003
3 // Author: Peter KURNEV
7 #include <NMTTools_PaveFiller.ixx>
9 #include <Precision.hxx>
13 #include <Geom_Curve.hxx>
15 #include <TopAbs_Orientation.hxx>
18 #include <TopoDS_Edge.hxx>
19 #include <TopoDS_Vertex.hxx>
21 #include <BRep_Builder.hxx>
22 #include <BRep_Tool.hxx>
24 #include <BOPTools_Pave.hxx>
25 #include <BOPTools_PaveSet.hxx>
26 #include <BOPTools_CArray1OfVEInterference.hxx>
27 #include <BOPTools_VEInterference.hxx>
29 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
31 #include <NMTDS_ShapesDataStructure.hxx>
33 #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
34 #include <BOPTools_CoupleOfInteger.hxx>
36 //=======================================================================
37 // function: PrepareEdges
39 //=======================================================================
40 void NMTTools_PaveFiller::PrepareEdges()
42 Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject;
44 TopAbs_Orientation anOr;
48 aNbShapesObject=myDS->NumberOfShapesOfTheObject();
49 for (i=1; i<=myNbSources; ++i) {
50 if (myDS->GetShapeType(i)==TopAbs_EDGE) {
51 aE=TopoDS::Edge(myDS->Shape(i));
53 if (BRep_Tool::Degenerated(aE)){
57 BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
60 aNBSuc=myDS->NumberOfSuccessors(i);
61 for (ii=1; ii <=aNBSuc; ii++) {
62 nV=myDS->GetSuccessor(i, ii);
63 anOr=myDS->GetOrientation(i, ii);
64 aV=TopoDS::Vertex(myDS->Shape(nV));
66 aT=BRep_Tool::Parameter(aV, aE);
70 aV=TopoDS::Vertex(myDS->Shape(ip));
71 aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
75 BOPTools_Pave aPave(nV, aT);
76 aPaveSet.Append (aPave);
81 //=======================================================================
82 // function: PerformVE
84 //=======================================================================
85 void NMTTools_PaveFiller::PerformVE()
87 myIsDone=Standard_False;
89 Standard_Boolean bJustAddInterference;
90 Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVEs, aBlockLength, iSDV, nV1;
94 BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
95 BOPTools_CoupleOfInteger aCouple;
97 BOPTools_CArray1OfVEInterference& aVEs=myIntrPool->VEInterferences();
99 myDSIt.Initialize (TopAbs_VERTEX, TopAbs_EDGE);
101 // BlockLength correction
102 aNbVEs=ExpectedPoolLength();
103 aBlockLength=aVEs.BlockLength();
104 if (aNbVEs > aBlockLength) {
105 aVEs.SetBlockLength(aNbVEs);
108 for (; myDSIt.More(); myDSIt.Next()) {
109 myDSIt.Current(n1, n2, bJustAddInterference);
111 if (! myIntrPool->IsComputed(n1, n2)) {
112 if (! IsSuccesstorsComputed(n1, n2)) {
116 SortTypes(aWhat, aWith);
118 if(bJustAddInterference) {
119 myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
123 aE2=TopoDS::Edge(myDS->Shape(aWith));
125 if (BRep_Tool::Degenerated(aE2)){
130 aV1=TopoDS::Vertex(myDS->Shape(aWhat));
132 iSDV=FindSDVertex(aWhat);
135 aV1=TopoDS::Vertex(myDS->Shape(nV1));
138 aFlag=myContext.ComputeVE (aV1, aE2, aT);
142 // Add Interference to the Pool
143 BOPTools_VEInterference anInterf (aWhat, aWith, aT);
144 anIndexIn=aVEs.Append(anInterf);
146 // Add Pave to the Edge's myPavePool
147 aCouple.SetCouple(nV1, aWith);
148 if (!aSnareMap.Contains(aCouple)){
149 aSnareMap.Add(aCouple);
151 BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
152 aPave.SetInterference(anIndexIn);
153 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
154 aPaveSet.Append(aPave);
157 // State for the Vertex in DS;
158 myDS->SetState (aWhat, BooleanOperations_ON);
159 // Insert Vertex in Interference Object
160 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
161 aVE.SetNewShape(aWhat);
163 myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
167 myIsDone=Standard_True;
174 // Some of Edges can be [Semi] Infinite. Such Edges have no
175 // vertices on correspondant INF ends. So we must provide
176 // these vertices formally (to obtain Shrunk Ranges for e.g).
177 // In reality this vertex(-es) does not belong to the INF Edge.
178 // It just has reference in the DS.
179 // PKV Tue Apr 23 10:21:45 2002
181 Standard_Real aT1, aT2, aTolE;
182 Standard_Boolean bInf1, bInf2;
186 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
188 aTolE=BRep_Tool::Tolerance(aE);
189 Handle(Geom_Curve) aC3D=BRep_Tool::Curve (aE, aT1, aT2);
190 bInf1=Precision::IsNegativeInfinite(aT1);
191 bInf2=Precision::IsPositiveInfinite(aT2);
195 aBB.MakeVertex(aVx, aPx, aTolE);
196 myDS->InsertShapeAndAncestorsSuccessors(aVx, anASSeq);
197 nV=myDS->NumberOfInsertedShapes();
198 BOPTools_Pave aPave(nV, aT1);
199 aPaveSet.Append (aPave);
204 aBB.MakeVertex(aVx, aPx, aTolE);
205 myDS->InsertShapeAndAncestorsSuccessors(aVx, anASSeq);
206 nV=myDS->NumberOfInsertedShapes();
207 BOPTools_Pave aPave(nV, aT2);
208 aPaveSet.Append (aPave);