1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 // This file is part of Open CASCADE Technology software library.
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
19 #include <BOPAlgo_PaveFiller.hxx>
20 #include <BOPAlgo_SectionAttribute.hxx>
21 #include <BOPCol_MapOfInteger.hxx>
22 #include <BOPCol_NCVector.hxx>
23 #include <BOPCol_Parallel.hxx>
24 #include <BOPDS_Curve.hxx>
25 #include <BOPDS_DS.hxx>
26 #include <BOPDS_FaceInfo.hxx>
27 #include <BOPDS_Interf.hxx>
28 #include <BOPDS_Iterator.hxx>
29 #include <BOPDS_MapOfPaveBlock.hxx>
30 #include <BOPDS_PaveBlock.hxx>
31 #include <BOPDS_SubIterator.hxx>
32 #include <BOPDS_VectorOfInterfVF.hxx>
33 #include <BRep_Builder.hxx>
34 #include <BRep_Tool.hxx>
35 #include <BRepBndLib.hxx>
37 #include <IntTools_Context.hxx>
38 #include <TopoDS_Face.hxx>
39 #include <TopoDS_Vertex.hxx>
46 //=======================================================================
47 //class : BOPAlgo_VertexFace
49 //=======================================================================
50 class BOPAlgo_VertexFace : public BOPAlgo_Algo {
54 BOPAlgo_VertexFace() :
56 myIV(-1), myIF(-1), myIVx(-1),
57 myFlag(-1), myT1(-1.), myT2(-1.) {
60 virtual ~BOPAlgo_VertexFace(){
63 void SetIndices(const Standard_Integer nV,
64 const Standard_Integer nF,
65 const Standard_Integer nVx) {
71 void Indices(Standard_Integer& nV,
73 Standard_Integer& nVx) const {
79 void SetVertex(const TopoDS_Vertex& aV) {
83 const TopoDS_Vertex& Vertex()const {
87 void SetFace(const TopoDS_Face& aF) {
91 const TopoDS_Face& Face()const {
95 Standard_Integer Flag()const {
99 void Parameters(Standard_Real& aT1,
100 Standard_Real& aT2)const {
105 void SetContext(const Handle(IntTools_Context)& aContext) {
109 const Handle(IntTools_Context)& Context()const {
113 virtual void Perform() {
114 BOPAlgo_Algo::UserBreak();
115 myFlag=myContext->ComputeVF(myV, myF, myT1, myT2);
119 Standard_Integer myIV;
120 Standard_Integer myIF;
121 Standard_Integer myIVx;
122 Standard_Integer myFlag;
127 Handle(IntTools_Context) myContext;
129 //=======================================================================
130 typedef BOPCol_NCVector<BOPAlgo_VertexFace>
131 BOPAlgo_VectorOfVertexFace;
133 typedef BOPCol_ContextFunctor
135 BOPAlgo_VectorOfVertexFace,
136 Handle(IntTools_Context),
137 IntTools_Context> BOPAlgo_VertexFaceFunctor;
139 typedef BOPCol_ContextCnt
140 <BOPAlgo_VertexFaceFunctor,
141 BOPAlgo_VectorOfVertexFace,
142 Handle(IntTools_Context)> BOPAlgo_VertexFaceCnt;
144 //=======================================================================
145 // function: PerformVF
147 //=======================================================================
148 void BOPAlgo_PaveFiller::PerformVF()
150 Standard_Boolean bJustAdd;
151 Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, aNbVF, k;
152 Standard_Real aT1, aT2, aTolF, aTolV;
154 BOPAlgo_VectorOfVertexFace aVVF;
158 myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE);
159 iSize=myIterator->ExpectedLength();
162 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
163 aVFs.SetIncrement(iSize);
165 for (; myIterator->More(); myIterator->Next()) {
166 myIterator->Value(nV, nF, bJustAdd);
171 if (myDS->IsSubShape(nV, nF)) {
175 if (myDS->HasInterfShapeSubShapes(nV, nF)) {
176 myDS->ChangeFaceInfo(nF);
181 if (myDS->HasShapeSD(nV, nVSD)) {
185 if (myDS->HasInterf(nVx, nF)) {
189 myDS->ChangeFaceInfo(nF);// !
191 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
192 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
194 BOPAlgo_VertexFace& aVertexFace=aVVF.Append1();
196 aVertexFace.SetIndices(nV, nF, nVx);
197 aVertexFace.SetVertex(aV);
198 aVertexFace.SetFace(aF);
199 aVertexFace.SetProgressIndicator(myProgressIndicator);
200 }//for (; myIterator->More(); myIterator->Next()) {
203 //================================================================
204 BOPAlgo_VertexFaceCnt::Perform(myRunParallel, aVVF, myContext);
205 //================================================================
207 for (k=0; k < aNbVF; ++k) {
208 const BOPAlgo_VertexFace& aVertexFace=aVVF(k);
210 iFlag=aVertexFace.Flag();
215 aVertexFace.Indices(nV, nF, nVx);
216 aVertexFace.Parameters(aT1, aT2);
217 const TopoDS_Vertex& aV=aVertexFace.Vertex();
218 const TopoDS_Face& aF=aVertexFace.Face();
220 BOPDS_InterfVF& aVF=aVFs.Append1();
221 aVF.SetIndices(nVx, nF);
224 myDS->AddInterf(nVx, nF);
226 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
227 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
230 aTolV = BRep_Tool::Tolerance(aV);
231 aTolF = BRep_Tool::Tolerance(aF);
233 aBB.UpdateVertex(aV, aTolF);
234 BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVx);
235 Bnd_Box& aBoxV = aSIV.ChangeBox();
236 BRepBndLib::Add(aV, aBoxV);
238 }//for (k=0; k < aNbVF; ++k) {
242 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
243 aVFs.SetIncrement(iSize);
248 //=======================================================================
249 //function : TreatVerticesEE
251 //=======================================================================
252 void BOPAlgo_PaveFiller::TreatVerticesEE()
254 Standard_Integer i, aNbS,aNbEEs, nF, nV, iFlag;
255 Standard_Real aT1, aT2;
256 BOPCol_ListIteratorOfListOfInteger aItLI;
257 Handle(NCollection_BaseAllocator) aAllocator;
260 NCollection_BaseAllocator::CommonBaseAllocator();
261 BOPCol_ListOfInteger aLIV(aAllocator), aLIF(aAllocator);
262 BOPCol_MapOfInteger aMI(100, aAllocator);
263 BOPDS_MapOfPaveBlock aMPBF(100, aAllocator);
268 aNbS=myDS->NbSourceShapes();
270 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
271 aNbEEs=aEEs.Extent();
272 for (i=0; i<aNbEEs; ++i) {
273 BOPDS_InterfEE& aEE=aEEs(i);
274 if (aEE.HasIndexNew()) {
281 if (!aLIV.Extent()) {
282 aAllocator.Nullify();
286 aNbS=myDS->NbSourceShapes();
287 for (nF=0; nF<aNbS; ++nF) {
288 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(nF);
289 if (aSI.ShapeType()==TopAbs_FACE) {
293 if (!aLIF.Extent()) {
294 aAllocator.Nullify();
297 //-------------------------------------------------------------
298 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
300 BOPDS_SubIterator aIt(aAllocator);
303 aIt.SetSubSet1(aLIF);
304 aIt.SetSubSet2(aLIV);
307 for (; aIt.More(); aIt.Next()) {
310 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
311 const BOPCol_MapOfInteger& aMVOn=aFI.VerticesOn();
313 if (!aMVOn.Contains(nV)) {
314 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
315 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
316 iFlag=myContext->ComputeVF(aV, aF, aT1, aT2);
319 BOPDS_InterfVF& aVF=aVFs.Append1();
321 aVF.SetIndices(nV, nF);
324 myDS->AddInterf(nV, nF);
326 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();