1 // File: NMTTools_PaveFiller_7.cxx
2 // Created: Thu Dec 18 15:14:55 2003
3 // Author: Peter KURNEV
7 #include <NMTTools_PaveFiller.ixx>
9 #include <TopoDS_Vertex.hxx>
10 #include <TopoDS_Edge.hxx>
13 #include <NMTDS_ShapesDataStructure.hxx>
14 #include <TopAbs_Orientation.hxx>
15 #include <BOPTools_ListOfPaveBlock.hxx>
16 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
17 #include <BOPTools_PaveBlock.hxx>
18 #include <BOPTools_Pave.hxx>
19 #include <BOPTools_Tools.hxx>
20 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
21 #include <BRep_Tool.hxx>
22 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
23 #include <BOPTools_SSInterference.hxx>
24 #include <BOPTools_CArray1OfSSInterference.hxx>
25 #include <TopExp_Explorer.hxx>
26 #include <TopoDS_Shape.hxx>
28 #include <TColStd_IndexedMapOfInteger.hxx>
30 //=======================================================================
31 // function: MakeSplitEdges
33 //=======================================================================
34 void NMTTools_PaveFiller::MakeSplitEdges()
36 myIsDone=Standard_False;
38 Standard_Boolean bIsNewVertex1, bIsNewVertex2;
39 Standard_Integer i, aNbS, nV1, nV2, aNbPaveBlocks, aNewShapeIndex;
41 TopAbs_Orientation anOri;
42 TopoDS_Edge aE, aESplit;
43 TopoDS_Vertex aV1, aV2;
45 aNbS=myDS->NumberOfShapesOfTheObject();
46 for (i=1; i<=aNbS; ++i) {
47 if (myDS->GetShapeType(i) != TopAbs_EDGE)
51 aE=TopoDS::Edge(myDS->Shape(i));
52 if (BRep_Tool::Degenerated(aE)){
56 anOri=aE.Orientation();
57 aE.Orientation(TopAbs_FORWARD);
61 // Split Set for the Original Edge i
62 BOPTools_ListOfPaveBlock& aSplitEdges=mySplitShapesPool(myDS->RefEdge(i));
63 BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges);
65 aNbPaveBlocks=aSplitEdges.Extent();
67 for (; aPBIt.More(); aPBIt.Next()) {
68 BOPTools_PaveBlock& aPB=aPBIt.Value();
70 const BOPTools_Pave& aPave1=aPB.Pave1();
73 aV1=TopoDS::Vertex(myDS->GetShape(nV1));
74 aV1.Orientation(TopAbs_FORWARD);
76 const BOPTools_Pave& aPave2=aPB.Pave2();
79 aV2=TopoDS::Vertex(myDS->GetShape(nV2));
80 aV2.Orientation(TopAbs_REVERSED);
82 if (aNbPaveBlocks==1) {
83 bIsNewVertex1=myDS->IsNewShape (nV1);
84 bIsNewVertex2=myDS->IsNewShape (nV2);
85 if (!bIsNewVertex1 && !bIsNewVertex2) {
91 BOPTools_Tools::MakeSplitEdge(aE, aV1, t1, aV2, t2, aESplit);
93 // Add Split Part of the Original Edge to the DS
94 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
96 anASSeq.SetNewSuccessor(nV1);
97 anASSeq.SetNewOrientation(aV1.Orientation());
99 anASSeq.SetNewSuccessor(nV2);
100 anASSeq.SetNewOrientation(aV2.Orientation());
102 if (anOri==TopAbs_INTERNAL) {
103 anASSeq.SetNewAncestor(i);
104 aESplit.Orientation(anOri);
107 myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq);
108 aNewShapeIndex=myDS->NumberOfInsertedShapes();
109 myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN);
111 // Fill Split Set for the Original Edge
112 aPB.SetEdge(aNewShapeIndex);
116 myIsDone=Standard_True;
118 //=======================================================================
119 // function: UpdateCommonBlocks
121 //=======================================================================
122 void NMTTools_PaveFiller::UpdateCommonBlocks()
124 myIsDone=Standard_False;
126 Standard_Integer nE, aNbS, nSp, nEx, nSpx;
127 NMTTools_ListIteratorOfListOfCommonBlock aCBIt;
128 BOPTools_ListIteratorOfListOfPaveBlock aPBIt;
130 aNbS=myDS->NumberOfShapesOfTheObject();
132 for (nE=1; nE<=aNbS; ++nE) {
133 if (myDS->GetShapeType(nE)!=TopAbs_EDGE){
136 if (BRep_Tool::Degenerated(TopoDS::Edge(myDS->Shape(nE)))){
140 NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE));
141 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool (myDS->RefEdge(nE));
143 aCBIt.Initialize(aLCB);
144 for (; aCBIt.More(); aCBIt.Next()) {
145 NMTTools_CommonBlock& aCB=aCBIt.Value();
146 BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE);
150 const BOPTools_ListOfPaveBlock& aCBLPB=aCB.PaveBlocks();
151 aPBIt.Initialize(aCBLPB);
152 for (; aPBIt.More(); aPBIt.Next()) {
153 BOPTools_PaveBlock& aPBx=aPBIt.Value();
154 nEx=aPBx.OriginalEdge();
159 nSpx=SplitIndex(aPBx);
166 //=======================================================================
167 // function: SplitIndex
169 //=======================================================================
170 Standard_Integer NMTTools_PaveFiller::SplitIndex(const BOPTools_PaveBlock& aPBx)const
172 Standard_Integer anOriginalEdge, anEdgeIndex=0;
174 anOriginalEdge=aPBx.OriginalEdge();
176 const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(anOriginalEdge));
178 BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
179 for (; anIt.More(); anIt.Next()) {
180 BOPTools_PaveBlock& aPB=anIt.Value();
181 if (aPB.IsEqual(aPBx)) {
182 anEdgeIndex=aPB.Edge();
188 //=======================================================================
189 // function: UpdatePaveBlocks
191 //=======================================================================
192 void NMTTools_PaveFiller::UpdatePaveBlocks()
194 myIsDone=Standard_False;
197 Standard_Integer i, aNbFFs, nF1, nF2, aNbF, nF, iRankF, nE, nV1, nV2, aNbPB;
198 Standard_Real aT1, aT2;
199 TColStd_IndexedMapOfInteger aMF, aME;
200 TopExp_Explorer aExp;
201 TopoDS_Vertex aV1, aV2;
203 BOPTools_Pave aPave1, aPave2;
204 BOPTools_PaveBlock aPB;
206 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
208 aNbFFs=aFFs.Extent();
209 for (i=1; i<=aNbFFs; ++i) {
210 BOPTools_SSInterference& aFFi=aFFs(i);
211 aFFi.Indices(nF1, nF2);
217 for(i=1; i<=aNbF; ++i) {
219 iRankF=myDS->Rank(nF);
220 const TopoDS_Shape& aF=myDS->Shape(nF);
221 aExp.Init(aF, TopAbs_EDGE);
222 for(; aExp.More(); aExp.Next()) {
223 aE=TopoDS::Edge(aExp.Current());
225 if (BRep_Tool::Degenerated(aE)) {
229 nE=myDS->ShapeIndex(aE, iRankF);
231 if (aME.Contains(nE)) {
236 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
241 TopExp::Vertices(aE, aV1, aV2);
243 nV1=myDS->ShapeIndex(aV1, iRankF);
244 aT1=BRep_Tool::Parameter(aV1, aE);
245 aPave1.SetIndex(nV1);
246 aPave1.SetParam(aT1);
248 nV2=myDS->ShapeIndex(aV2, iRankF);
249 aT2=BRep_Tool::Parameter(aV2, aE);
250 aPave2.SetIndex(nV2);
251 aPave2.SetParam(aT2);
254 aPB.SetOriginalEdge(nE);
255 aPB.SetPave1(aPave1);
256 aPB.SetPave2(aPave2);