1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTTools_PaveFiller_7.cxx
21 // Created: Thu Dec 18 15:14:55 2003
22 // Author: Peter KURNEV
26 #include <NMTTools_PaveFiller.ixx>
28 #include <TopoDS_Vertex.hxx>
29 #include <TopoDS_Edge.hxx>
32 #include <NMTDS_ShapesDataStructure.hxx>
33 #include <TopAbs_Orientation.hxx>
34 #include <BOPTools_ListOfPaveBlock.hxx>
35 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
36 #include <BOPTools_PaveBlock.hxx>
37 #include <BOPTools_Pave.hxx>
38 #include <BOPTools_Tools.hxx>
39 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
40 #include <BRep_Tool.hxx>
41 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
42 #include <BOPTools_SSInterference.hxx>
43 #include <BOPTools_CArray1OfSSInterference.hxx>
44 #include <TopExp_Explorer.hxx>
45 #include <TopoDS_Shape.hxx>
47 #include <TColStd_IndexedMapOfInteger.hxx>
49 //=======================================================================
50 // function: MakeSplitEdges
52 //=======================================================================
53 void NMTTools_PaveFiller::MakeSplitEdges()
55 myIsDone=Standard_False;
57 Standard_Boolean bIsNewVertex1, bIsNewVertex2;
58 Standard_Integer i, aNbS, nV1, nV2, aNbPaveBlocks, aNewShapeIndex;
60 TopAbs_Orientation anOri;
61 TopoDS_Edge aE, aESplit;
62 TopoDS_Vertex aV1, aV2;
64 aNbS=myDS->NumberOfShapesOfTheObject();
65 for (i=1; i<=aNbS; ++i) {
66 if (myDS->GetShapeType(i) != TopAbs_EDGE)
70 aE=TopoDS::Edge(myDS->Shape(i));
71 if (BRep_Tool::Degenerated(aE)){
75 anOri=aE.Orientation();
76 aE.Orientation(TopAbs_FORWARD);
80 // Split Set for the Original Edge i
81 BOPTools_ListOfPaveBlock& aSplitEdges=mySplitShapesPool(myDS->RefEdge(i));
82 BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges);
84 aNbPaveBlocks=aSplitEdges.Extent();
86 for (; aPBIt.More(); aPBIt.Next()) {
87 BOPTools_PaveBlock& aPB=aPBIt.Value();
89 const BOPTools_Pave& aPave1=aPB.Pave1();
92 aV1=TopoDS::Vertex(myDS->GetShape(nV1));
93 aV1.Orientation(TopAbs_FORWARD);
95 const BOPTools_Pave& aPave2=aPB.Pave2();
98 aV2=TopoDS::Vertex(myDS->GetShape(nV2));
99 aV2.Orientation(TopAbs_REVERSED);
101 if (aNbPaveBlocks==1) {
102 bIsNewVertex1=myDS->IsNewShape (nV1);
103 bIsNewVertex2=myDS->IsNewShape (nV2);
104 if (!bIsNewVertex1 && !bIsNewVertex2) {
110 BOPTools_Tools::MakeSplitEdge(aE, aV1, t1, aV2, t2, aESplit);
112 // Add Split Part of the Original Edge to the DS
113 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
115 anASSeq.SetNewSuccessor(nV1);
116 anASSeq.SetNewOrientation(aV1.Orientation());
118 anASSeq.SetNewSuccessor(nV2);
119 anASSeq.SetNewOrientation(aV2.Orientation());
121 if (anOri==TopAbs_INTERNAL) {
122 anASSeq.SetNewAncestor(i);
123 aESplit.Orientation(anOri);
126 myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq);
127 aNewShapeIndex=myDS->NumberOfInsertedShapes();
128 myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN);
130 // Fill Split Set for the Original Edge
131 aPB.SetEdge(aNewShapeIndex);
135 myIsDone=Standard_True;
137 //=======================================================================
138 // function: UpdateCommonBlocks
140 //=======================================================================
141 void NMTTools_PaveFiller::UpdateCommonBlocks()
143 myIsDone=Standard_False;
145 Standard_Integer nE, aNbS, nSp, nEx, nSpx;
146 NMTTools_ListIteratorOfListOfCommonBlock aCBIt;
147 BOPTools_ListIteratorOfListOfPaveBlock aPBIt;
149 aNbS=myDS->NumberOfShapesOfTheObject();
151 for (nE=1; nE<=aNbS; ++nE) {
152 if (myDS->GetShapeType(nE)!=TopAbs_EDGE){
155 if (BRep_Tool::Degenerated(TopoDS::Edge(myDS->Shape(nE)))){
159 NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE));
160 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool (myDS->RefEdge(nE));
162 aCBIt.Initialize(aLCB);
163 for (; aCBIt.More(); aCBIt.Next()) {
164 NMTTools_CommonBlock& aCB=aCBIt.Value();
165 BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE);
169 const BOPTools_ListOfPaveBlock& aCBLPB=aCB.PaveBlocks();
170 aPBIt.Initialize(aCBLPB);
171 for (; aPBIt.More(); aPBIt.Next()) {
172 BOPTools_PaveBlock& aPBx=aPBIt.Value();
173 nEx=aPBx.OriginalEdge();
178 nSpx=SplitIndex(aPBx);
185 //=======================================================================
186 // function: SplitIndex
188 //=======================================================================
189 Standard_Integer NMTTools_PaveFiller::SplitIndex(const BOPTools_PaveBlock& aPBx)const
191 Standard_Integer anOriginalEdge, anEdgeIndex=0;
193 anOriginalEdge=aPBx.OriginalEdge();
195 const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(anOriginalEdge));
197 BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
198 for (; anIt.More(); anIt.Next()) {
199 BOPTools_PaveBlock& aPB=anIt.Value();
200 if (aPB.IsEqual(aPBx)) {
201 anEdgeIndex=aPB.Edge();
207 //=======================================================================
208 // function: UpdatePaveBlocks
210 //=======================================================================
211 void NMTTools_PaveFiller::UpdatePaveBlocks()
213 myIsDone=Standard_False;
216 Standard_Integer i, aNbFFs, nF1, nF2, aNbF, nF, iRankF, nE, nV1, nV2, aNbPB;
217 Standard_Real aT1, aT2;
218 TColStd_IndexedMapOfInteger aMF, aME;
219 TopExp_Explorer aExp;
220 TopoDS_Vertex aV1, aV2;
222 BOPTools_Pave aPave1, aPave2;
223 BOPTools_PaveBlock aPB;
225 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
227 aNbFFs=aFFs.Extent();
228 for (i=1; i<=aNbFFs; ++i) {
229 BOPTools_SSInterference& aFFi=aFFs(i);
230 aFFi.Indices(nF1, nF2);
236 for(i=1; i<=aNbF; ++i) {
238 iRankF=myDS->Rank(nF);
239 const TopoDS_Shape& aF=myDS->Shape(nF);
240 aExp.Init(aF, TopAbs_EDGE);
241 for(; aExp.More(); aExp.Next()) {
242 aE=TopoDS::Edge(aExp.Current());
244 if (BRep_Tool::Degenerated(aE)) {
248 nE=myDS->ShapeIndex(aE, iRankF);
250 if (aME.Contains(nE)) {
255 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
260 TopExp::Vertices(aE, aV1, aV2);
262 nV1=myDS->ShapeIndex(aV1, iRankF);
263 aT1=BRep_Tool::Parameter(aV1, aE);
264 aPave1.SetIndex(nV1);
265 aPave1.SetParam(aT1);
267 nV2=myDS->ShapeIndex(aV2, iRankF);
268 aT2=BRep_Tool::Parameter(aV2, aE);
269 aPave2.SetIndex(nV2);
270 aPave2.SetParam(aT2);
273 aPB.SetOriginalEdge(nE);
274 aPB.SetPave1(aPave1);
275 aPB.SetPave2(aPave2);