1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #include <BOPAlgo_WireSplitter.ixx>
22 #include <TopoDS_Shape.hxx>
23 #include <TopoDS_Iterator.hxx>
24 #include <TopoDS_Edge.hxx>
26 #include <TopoDS_Wire.hxx>
28 #include <BRep_Tool.hxx>
29 #include <BRep_Builder.hxx>
31 #include <BOPCol_ListOfShape.hxx>
32 #include <BOPCol_IndexedMapOfShape.hxx>
33 #include <BOPCol_MapOfShape.hxx>
34 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
36 #include <BOPTools.hxx>
39 //=======================================================================
42 //=======================================================================
43 BOPAlgo_WireSplitter::BOPAlgo_WireSplitter()
50 //=======================================================================
53 //=======================================================================
54 BOPAlgo_WireSplitter::BOPAlgo_WireSplitter(const Handle(NCollection_BaseAllocator)& theAllocator)
56 BOPAlgo_Algo(theAllocator),
61 //=======================================================================
64 //=======================================================================
65 BOPAlgo_WireSplitter::~BOPAlgo_WireSplitter()
68 //=======================================================================
71 //=======================================================================
72 void BOPAlgo_WireSplitter::SetWES(const BOPAlgo_WireEdgeSet& theWES)
74 myWES=(BOPAlgo_WireEdgeSet*)&theWES;
76 //=======================================================================
79 //=======================================================================
80 BOPAlgo_WireEdgeSet& BOPAlgo_WireSplitter::WES()
84 //=======================================================================
85 // function: CheckData
87 //=======================================================================
88 void BOPAlgo_WireSplitter::CheckData()
96 //=======================================================================
99 //=======================================================================
100 void BOPAlgo_WireSplitter::Perform()
109 MakeConnexityBlocks();
112 //=======================================================================
113 //function : MakeWires
115 //=======================================================================
116 void BOPAlgo_WireSplitter::MakeWires()
118 Standard_Boolean bIsRegular;
120 BOPTools_ListIteratorOfListOfConnexityBlock aItCB;
121 BOPCol_ListIteratorOfListOfShape aIt;
123 aItCB.Initialize(myLCB);
124 for (; aItCB.More(); aItCB.Next()) {
125 BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
126 bIsRegular=aCB.IsRegular();
128 BOPCol_ListOfShape& aLE=aCB.ChangeShapes();
129 BOPAlgo_WireSplitter::MakeWire(aLE, aW);
135 const BOPCol_ListOfShape& aLW=aCB.Loops();
137 for (; aIt.More(); aIt.Next()) {
138 const TopoDS_Shape& aWx=aIt.Value();
139 myWES->AddShape(aWx);
144 //=======================================================================
145 //function : MakeConnexityBlocks
147 //=======================================================================
148 void BOPAlgo_WireSplitter::MakeConnexityBlocks()
150 Standard_Boolean bRegular, bClosed;
151 Standard_Integer i, j, aNbV, aNbVS, aNbVP, k;
152 TopoDS_Iterator aItE;
154 BOPCol_ListIteratorOfListOfShape aIt;
155 BOPCol_MapIteratorOfMapOfShape aItM;
157 BOPCol_IndexedDataMapOfShapeListOfShape aMVE(100, myAllocator);
158 BOPCol_IndexedMapOfShape aMVP(100, myAllocator);
159 BOPCol_IndexedMapOfShape aMEC(100, myAllocator);
160 BOPCol_MapOfShape aMER(100, myAllocator);
161 BOPCol_MapOfShape aMEP(100, myAllocator);
162 BOPCol_IndexedMapOfShape aMVAdd(100, myAllocator);
163 BOPCol_MapOfShape aMVS(100, myAllocator);
167 const BOPCol_ListOfShape& aLSE=myWES->StartElements();
168 aIt.Initialize(aLSE);
169 for (; aIt.More(); aIt.Next()) {
170 const TopoDS_Shape& aE=aIt.Value();
172 BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
181 for (i=1; i<=aNbV; ++i) {
187 const TopoDS_Shape& aV=aMVE.FindKey(i);
192 // aMVS - globally processed vertices
194 //------------------------------------- goal: aMEC
195 aMEC.Clear(); // aMEC - edges of CB
196 aMVP.Clear(); // aMVP - vertices to process right now
197 aMVAdd.Clear(); // aMVAdd vertices to process on next step of while(1)
203 for (k=1; k<=aNbVP; ++k) {
204 const TopoDS_Shape& aVP=aMVP(k);
205 const BOPCol_ListOfShape& aLE=aMVE.FindFromKey(aVP);
207 for (; aIt.More(); aIt.Next()) {
208 const TopoDS_Shape& aE=aIt.Value();
211 for (; aItE.More(); aItE.Next()) {
212 const TopoDS_Shape& aVE=aItE.Value();
219 }//for (; aItM.More(); aItM.Next()) {
221 aNbVP=aMVAdd.Extent();
223 break; // from while(1)
228 for (k=1; k<=aNbVP; ++k) {
229 const TopoDS_Shape& aVE=aMVAdd(k);
235 //-------------------------------------
236 BOPTools_ConnexityBlock aCB(myAllocator);
237 BOPCol_ListOfShape& aLEC=aCB.ChangeShapes();
239 BOPCol_IndexedDataMapOfShapeListOfShape aMVER(100, myAllocator);
241 bRegular=Standard_True;
242 Standard_Integer aNbCB = aMEC.Extent();
243 for (j = 1; j <= aNbCB; j++) {
246 if (aMER.Contains(aER)) {
247 aER.Orientation(TopAbs_FORWARD);
249 aER.Orientation(TopAbs_REVERSED);
251 bRegular=Standard_False;
258 BOPTools::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER);
263 Standard_Integer k, aNbVR, aNbER;
265 aNbVR=aMVER.Extent();
266 for (k=1; k<=aNbVR; ++k) {
267 const BOPCol_ListOfShape& aLER=aMVER(k);
270 const TopoDS_Edge& aEx=TopoDS::Edge(aER);
271 bClosed=BRep_Tool::IsClosed(aEx, myWES->Face());
284 aCB.SetRegular(bRegular);