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.), myTolVNew(-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 Standard_Real VertexNewTolerance()const {
109 void SetContext(const Handle(IntTools_Context)& aContext) {
113 const Handle(IntTools_Context)& Context()const {
117 virtual void Perform() {
118 BOPAlgo_Algo::UserBreak();
119 myFlag=myContext->ComputeVF(myV, myF, myT1, myT2, myTolVNew);
123 Standard_Integer myIV;
124 Standard_Integer myIF;
125 Standard_Integer myIVx;
126 Standard_Integer myFlag;
129 Standard_Real myTolVNew;
132 Handle(IntTools_Context) myContext;
134 //=======================================================================
135 typedef BOPCol_NCVector<BOPAlgo_VertexFace>
136 BOPAlgo_VectorOfVertexFace;
138 typedef BOPCol_ContextFunctor
140 BOPAlgo_VectorOfVertexFace,
141 Handle(IntTools_Context),
142 IntTools_Context> BOPAlgo_VertexFaceFunctor;
144 typedef BOPCol_ContextCnt
145 <BOPAlgo_VertexFaceFunctor,
146 BOPAlgo_VectorOfVertexFace,
147 Handle(IntTools_Context)> BOPAlgo_VertexFaceCnt;
149 //=======================================================================
150 // function: PerformVF
152 //=======================================================================
153 void BOPAlgo_PaveFiller::PerformVF()
155 Standard_Boolean bJustAdd;
156 Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, aNbVF, k;
157 Standard_Real aT1, aT2;
158 BOPAlgo_VectorOfVertexFace aVVF;
162 myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE);
163 iSize=myIterator->ExpectedLength();
166 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
167 aVFs.SetIncrement(iSize);
169 for (; myIterator->More(); myIterator->Next()) {
170 myIterator->Value(nV, nF, bJustAdd);
175 if (myDS->IsSubShape(nV, nF)) {
179 if (myDS->HasInterfShapeSubShapes(nV, nF)) {
180 myDS->ChangeFaceInfo(nF);
185 if (myDS->HasShapeSD(nV, nVSD)) {
189 if (myDS->HasInterf(nVx, nF)) {
193 myDS->ChangeFaceInfo(nF);// !
195 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
196 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
198 BOPAlgo_VertexFace& aVertexFace=aVVF.Append1();
200 aVertexFace.SetIndices(nV, nF, nVx);
201 aVertexFace.SetVertex(aV);
202 aVertexFace.SetFace(aF);
203 aVertexFace.SetProgressIndicator(myProgressIndicator);
204 }//for (; myIterator->More(); myIterator->Next()) {
207 //================================================================
208 BOPAlgo_VertexFaceCnt::Perform(myRunParallel, aVVF, myContext);
209 //================================================================
211 for (k=0; k < aNbVF; ++k) {
212 const BOPAlgo_VertexFace& aVertexFace=aVVF(k);
214 iFlag=aVertexFace.Flag();
219 aVertexFace.Indices(nV, nF, nVx);
220 aVertexFace.Parameters(aT1, aT2);
222 BOPDS_InterfVF& aVF=aVFs.Append1();
223 aVF.SetIndices(nVx, nF);
226 myDS->AddInterf(nVx, nF);
228 // 3 update vertex V/F if necessary
229 Standard_Real aTolVNew = aVertexFace.VertexNewTolerance();
230 nVx=UpdateVertex(nVx, aTolVNew);
233 if (myDS->IsNewShape(nVx)) {
234 aVF.SetIndexNew(nVx);
237 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
238 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
240 }//for (k=0; k < aNbVF; ++k) {
244 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
245 aVFs.SetIncrement(iSize);
250 //=======================================================================
251 //function : TreatVerticesEE
253 //=======================================================================
254 void BOPAlgo_PaveFiller::TreatVerticesEE()
256 Standard_Integer i, aNbS,aNbEEs, nF, nV, iFlag;
257 Standard_Real aT1, aT2, dummy;
258 BOPCol_ListIteratorOfListOfInteger aItLI;
259 Handle(NCollection_BaseAllocator) aAllocator;
262 NCollection_BaseAllocator::CommonBaseAllocator();
263 BOPCol_ListOfInteger aLIV(aAllocator), aLIF(aAllocator);
264 BOPCol_MapOfInteger aMI(100, aAllocator);
265 BOPDS_MapOfPaveBlock aMPBF(100, aAllocator);
270 aNbS=myDS->NbSourceShapes();
272 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
273 aNbEEs=aEEs.Extent();
274 for (i=0; i<aNbEEs; ++i) {
275 BOPDS_InterfEE& aEE=aEEs(i);
276 if (aEE.HasIndexNew()) {
283 if (!aLIV.Extent()) {
284 aAllocator.Nullify();
288 aNbS=myDS->NbSourceShapes();
289 for (nF=0; nF<aNbS; ++nF) {
290 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(nF);
291 if (aSI.ShapeType()==TopAbs_FACE) {
295 if (!aLIF.Extent()) {
296 aAllocator.Nullify();
299 //-------------------------------------------------------------
300 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
302 BOPDS_SubIterator aIt(aAllocator);
305 aIt.SetSubSet1(aLIF);
306 aIt.SetSubSet2(aLIV);
309 for (; aIt.More(); aIt.Next()) {
312 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
313 const BOPCol_MapOfInteger& aMVOn=aFI.VerticesOn();
315 if (!aMVOn.Contains(nV)) {
316 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
317 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
318 iFlag = myContext->ComputeVF(aV, aF, aT1, aT2, dummy);
321 BOPDS_InterfVF& aVF=aVFs.Append1();
323 aVF.SetIndices(nV, nF);
326 myDS->AddInterf(nV, nF);
328 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();