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.
18 #include <BOPAlgo_PaveFiller.ixx>
20 #include <NCollection_IncAllocator.hxx>
22 #include <TopoDS_Vertex.hxx>
23 #include <TopoDS_Face.hxx>
24 #include <BRep_Tool.hxx>
25 #include <BRep_Builder.hxx>
26 #include <BRepBndLib.hxx>
28 #include <BOPCol_MapOfInteger.hxx>
29 #include <BOPCol_NCVector.hxx>
30 #include <BOPCol_Parallel.hxx>
32 #include <IntTools_Context.hxx>
34 #include <BOPDS_Iterator.hxx>
35 #include <BOPDS_VectorOfInterfVF.hxx>
36 #include <BOPDS_Interf.hxx>
37 #include <BOPDS_SubIterator.hxx>
38 #include <BOPDS_MapOfPaveBlock.hxx>
39 #include <BOPDS_FaceInfo.hxx>
41 //=======================================================================
42 //class : BOPAlgo_VertexFace
44 //=======================================================================
45 class BOPAlgo_VertexFace : public BOPAlgo_Algo {
49 BOPAlgo_VertexFace() :
51 myIV(-1), myIF(-1), myIVx(-1),
52 myFlag(-1), myT1(-1.), myT2(-1.) {
55 virtual ~BOPAlgo_VertexFace(){
58 void SetIndices(const Standard_Integer nV,
59 const Standard_Integer nF,
60 const Standard_Integer nVx) {
66 void Indices(Standard_Integer& nV,
68 Standard_Integer& nVx) const {
74 void SetVertex(const TopoDS_Vertex& aV) {
78 const TopoDS_Vertex& Vertex()const {
82 void SetFace(const TopoDS_Face& aF) {
86 const TopoDS_Face& Face()const {
90 Standard_Integer Flag()const {
94 void Parameters(Standard_Real& aT1,
95 Standard_Real& aT2)const {
100 void SetContext(const Handle(IntTools_Context)& aContext) {
104 const Handle(IntTools_Context)& Context()const {
108 virtual void Perform() {
109 BOPAlgo_Algo::UserBreak();
110 myFlag=myContext->ComputeVF(myV, myF, myT1, myT2);
114 Standard_Integer myIV;
115 Standard_Integer myIF;
116 Standard_Integer myIVx;
117 Standard_Integer myFlag;
122 Handle(IntTools_Context) myContext;
124 //=======================================================================
125 typedef BOPCol_NCVector<BOPAlgo_VertexFace>
126 BOPAlgo_VectorOfVertexFace;
128 typedef BOPCol_ContextFunctor
130 BOPAlgo_VectorOfVertexFace,
131 Handle(IntTools_Context),
132 IntTools_Context> BOPAlgo_VertexFaceFunctor;
134 typedef BOPCol_ContextCnt
135 <BOPAlgo_VertexFaceFunctor,
136 BOPAlgo_VectorOfVertexFace,
137 Handle(IntTools_Context)> BOPAlgo_VertexFaceCnt;
139 //=======================================================================
140 // function: PerformVF
142 //=======================================================================
143 void BOPAlgo_PaveFiller::PerformVF()
145 Standard_Boolean bJustAdd;
146 Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, aNbVF, k;
147 Standard_Real aT1, aT2, aTolF, aTolV;
149 BOPAlgo_VectorOfVertexFace aVVF;
153 myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE);
154 iSize=myIterator->ExpectedLength();
157 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
158 aVFs.SetIncrement(iSize);
160 for (; myIterator->More(); myIterator->Next()) {
161 myIterator->Value(nV, nF, bJustAdd);
166 if (myDS->IsSubShape(nV, nF)) {
170 if (myDS->HasInterfShapeSubShapes(nV, nF)) {
171 myDS->ChangeFaceInfo(nF);
176 if (myDS->HasShapeSD(nV, nVSD)) {
180 if (myDS->HasInterf(nVx, nF)) {
184 myDS->ChangeFaceInfo(nF);// !
186 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
187 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
189 BOPAlgo_VertexFace& aVertexFace=aVVF.Append1();
191 aVertexFace.SetIndices(nV, nF, nVx);
192 aVertexFace.SetVertex(aV);
193 aVertexFace.SetFace(aF);
194 aVertexFace.SetProgressIndicator(myProgressIndicator);
195 }//for (; myIterator->More(); myIterator->Next()) {
198 //================================================================
199 BOPAlgo_VertexFaceCnt::Perform(myRunParallel, aVVF, myContext);
200 //================================================================
202 for (k=0; k < aNbVF; ++k) {
203 const BOPAlgo_VertexFace& aVertexFace=aVVF(k);
205 iFlag=aVertexFace.Flag();
210 aVertexFace.Indices(nV, nF, nVx);
211 aVertexFace.Parameters(aT1, aT2);
212 const TopoDS_Vertex& aV=aVertexFace.Vertex();
213 const TopoDS_Face& aF=aVertexFace.Face();
215 BOPDS_InterfVF& aVF=aVFs.Append1();
216 aVF.SetIndices(nVx, nF);
219 myDS->AddInterf(nVx, nF);
221 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
222 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
225 aTolV = BRep_Tool::Tolerance(aV);
226 aTolF = BRep_Tool::Tolerance(aF);
228 aBB.UpdateVertex(aV, aTolF);
229 BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVx);
230 Bnd_Box& aBoxV = aSIV.ChangeBox();
231 BRepBndLib::Add(aV, aBoxV);
233 }//for (k=0; k < aNbVF; ++k) {
237 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
238 aVFs.SetIncrement(iSize);
243 //=======================================================================
244 //function : TreatVerticesEE
246 //=======================================================================
247 void BOPAlgo_PaveFiller::TreatVerticesEE()
249 Standard_Integer i, aNbS,aNbEEs, nF, nV, iFlag;
250 Standard_Real aT1, aT2;
251 BOPCol_ListIteratorOfListOfInteger aItLI;
252 Handle(NCollection_IncAllocator) aAllocator;
254 aAllocator=new NCollection_IncAllocator();
255 BOPCol_ListOfInteger aLIV(aAllocator), aLIF(aAllocator);
256 BOPCol_MapOfInteger aMI(100, aAllocator);
257 BOPDS_MapOfPaveBlock aMPBF(100, aAllocator);
262 aNbS=myDS->NbSourceShapes();
264 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
265 aNbEEs=aEEs.Extent();
266 for (i=0; i<aNbEEs; ++i) {
267 BOPDS_InterfEE& aEE=aEEs(i);
268 if (aEE.HasIndexNew()) {
275 if (!aLIV.Extent()) {
276 aAllocator.Nullify();
280 aNbS=myDS->NbSourceShapes();
281 for (nF=0; nF<aNbS; ++nF) {
282 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(nF);
283 if (aSI.ShapeType()==TopAbs_FACE) {
287 if (!aLIF.Extent()) {
288 aAllocator.Nullify();
291 //-------------------------------------------------------------
292 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
294 BOPDS_SubIterator aIt(aAllocator);
297 aIt.SetSubSet1(aLIF);
298 aIt.SetSubSet2(aLIV);
301 for (; aIt.More(); aIt.Next()) {
304 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
305 const BOPCol_MapOfInteger& aMVOn=aFI.VerticesOn();
307 if (!aMVOn.Contains(nV)) {
308 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
309 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
310 iFlag=myContext->ComputeVF(aV, aF, aT1, aT2);
313 BOPDS_InterfVF& aVF=aVFs.Append1();
315 aVF.SetIndices(nV, nF);
318 myDS->AddInterf(nV, nF);
320 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
326 aAllocator.Nullify();