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_NCVector.hxx>
22 #include <BOPCol_Parallel.hxx>
23 #include <BOPDS_Curve.hxx>
24 #include <BOPDS_DS.hxx>
25 #include <BOPDS_Interf.hxx>
26 #include <BOPDS_Iterator.hxx>
27 #include <BOPDS_MapOfPair.hxx>
28 #include <BOPDS_Pair.hxx>
29 #include <BOPDS_PaveBlock.hxx>
30 #include <BOPDS_VectorOfInterfVE.hxx>
31 #include <BOPTools_AlgoTools.hxx>
32 #include <BRep_Builder.hxx>
33 #include <BRep_Tool.hxx>
34 #include <BRepBndLib.hxx>
36 #include <IntTools_Context.hxx>
37 #include <IntTools_Tools.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Face.hxx>
40 #include <TopoDS_Vertex.hxx>
41 #include <Precision.hxx>
43 //=======================================================================
44 //class : BOPAlgo_VertexEdgeEdge
46 //=======================================================================
47 class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
52 BOPAlgo_VertexEdge() :
54 myIV(-1), myIE(-1), myFlag(-1), myT(-1.), myTolVNew(-1.) {
57 virtual ~BOPAlgo_VertexEdge(){
60 void SetIndices(const Standard_Integer nV,
61 const Standard_Integer nE) {
66 void Indices(Standard_Integer& nV,
67 Standard_Integer& nE) const {
72 void SetVertex(const TopoDS_Vertex& aV) {
76 void SetEdge(const TopoDS_Edge& aE) {
80 const TopoDS_Vertex& Vertex() const {
84 const TopoDS_Edge& Edge() const {
88 Standard_Integer Flag()const {
92 Standard_Real Parameter()const {
96 Standard_Real VertexNewTolerance()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->ComputeVE (myV, myE, myT, myTolVNew, myFuzzyValue);
114 Standard_Integer myIV;
115 Standard_Integer myIE;
116 Standard_Integer myFlag;
118 Standard_Real myTolVNew;
121 Handle(IntTools_Context) myContext;
123 //=======================================================================
124 typedef BOPCol_NCVector
125 <BOPAlgo_VertexEdge> BOPAlgo_VectorOfVertexEdge;
127 typedef BOPCol_ContextFunctor
129 BOPAlgo_VectorOfVertexEdge,
130 Handle(IntTools_Context),
131 IntTools_Context> BOPAlgo_VertexEdgeFunctor;
133 typedef BOPCol_ContextCnt
134 <BOPAlgo_VertexEdgeFunctor,
135 BOPAlgo_VectorOfVertexEdge,
136 Handle(IntTools_Context)> BOPAlgo_VertexEdgeCnt;
138 //=======================================================================
139 // function: PerformVE
141 //=======================================================================
142 void BOPAlgo_PaveFiller::PerformVE()
144 Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, k, aNbVE;
145 Standard_Real aT, aT1, aT2, aTS1, aTS2;
148 BOPDS_MapOfPair aMPK;
149 BOPAlgo_VectorOfVertexEdge aVVE;
153 FillShrunkData(TopAbs_VERTEX, TopAbs_EDGE);
155 myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
156 iSize=myIterator->ExpectedLength();
161 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
162 aVEs.SetIncrement(iSize);
164 for (; myIterator->More(); myIterator->Next()) {
165 myIterator->Value(nV, nE);
167 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
168 if (aSIE.HasSubShape(nV)) {
176 if (myDS->HasInterfShapeSubShapes(nV, nE)) {
177 myDS->ChangePaveBlocks(nE);
182 if (myDS->HasShapeSD(nV, nVSD)) {
186 aPK.SetIndices(nVx, nE);
187 if (!aMPK.Add(aPK)) {
191 const BOPDS_ListOfPaveBlock& aLPB = myDS->PaveBlocks(nE);
192 if (aLPB.IsEmpty()) {
196 const Handle(BOPDS_PaveBlock)& aPB = aLPB.First();
197 if (!aPB->IsSplittable()) {
198 // this is a micro edge, ignore it
202 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
203 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
205 BOPAlgo_VertexEdge& aVESolver=aVVE.Append1();
207 aVESolver.SetIndices(nV, nE);
208 aVESolver.SetVertex(aV);
209 aVESolver.SetEdge(aE);
210 aVESolver.SetFuzzyValue(myFuzzyValue);
211 aVESolver.SetProgressIndicator(myProgressIndicator);
213 }// for (; myIterator->More(); myIterator->Next()) {
216 //=============================================================
217 BOPAlgo_VertexEdgeCnt::Perform(myRunParallel, aVVE, myContext);
218 //=============================================================
220 for (k=0; k < aNbVE; ++k) {
221 const BOPAlgo_VertexEdge& aVESolver=aVVE(k);
222 iFlag=aVESolver.Flag();
224 aVESolver.Indices(nV, nE);
225 aT=aVESolver.Parameter();
227 // check if vertex hits beyond shrunk range, in such case create V-V interf
228 const BOPDS_ListOfPaveBlock& aLPB = myDS->PaveBlocks(nE);
229 const Handle(BOPDS_PaveBlock)& aPB = aLPB.First();
231 Standard_Boolean bIsPBSplittable;
232 aPB->Range(aT1, aT2);
233 aPB->ShrunkData(aTS1, aTS2, aBox, bIsPBSplittable);
234 IntTools_Range aPaveR[2] = { IntTools_Range(aT1, aTS1), IntTools_Range(aTS2, aT2) };
235 Standard_Real aTol = Precision::Confusion();
236 Standard_Boolean isOnPave = Standard_False;
237 for (Standard_Integer i = 0; i < 2; i++) {
238 if (!bIsPBSplittable || IntTools_Tools::IsOnPave1(aT, aPaveR[i], aTol)) {
239 Standard_Integer nV1 = (i == 0 ? aPB->Pave1().Index() : aPB->Pave2().Index());
240 if (!myDS->HasInterf(nV, nV1)) {
241 BOPCol_ListOfInteger aLI;
246 isOnPave = Standard_True;
254 BOPDS_InterfVE& aVE=aVEs.Append1();
255 aVE.SetIndices(nV, nE);
256 aVE.SetParameter(aT);
258 myDS->AddInterf(nV, nE);
260 // 3 update vertex V/E if necessary
261 Standard_Real aTolVNew = aVESolver.VertexNewTolerance();
262 nVx=UpdateVertex(nV, aTolVNew);
264 if (myDS->IsNewShape(nVx)) {
265 aVE.SetIndexNew(nVx);
267 //5 append ext pave to pave block
269 aPave.SetParameter(aT);
270 aPB->AppendExtPave(aPave);
272 }//for (k=0; k < aNbVE; ++k) {