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 <TopoDS_Vertex.hxx>
21 #include <TopoDS_Edge.hxx>
22 #include <BRep_Tool.hxx>
24 #include <BOPCol_NCVector.hxx>
25 #include <BOPCol_Parallel.hxx>
27 #include <IntTools_Context.hxx>
29 #include <BOPDS_Iterator.hxx>
30 #include <BOPDS_VectorOfInterfVE.hxx>
31 #include <BOPDS_Interf.hxx>
32 #include <BOPDS_PassKey.hxx>
33 #include <BOPDS_MapOfPassKey.hxx>
34 #include <BRepBndLib.hxx>
35 #include <BRep_Builder.hxx>
37 //=======================================================================
38 //class : BOPAlgo_VertexEdgeEdge
40 //=======================================================================
41 class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
46 BOPAlgo_VertexEdge() :
48 myIV(-1), myIE(-1), myIVx(-1), myFlag(-1), myT(-1.) {
51 virtual ~BOPAlgo_VertexEdge(){
54 void SetIndices(const Standard_Integer nV,
55 const Standard_Integer nE,
56 const Standard_Integer nVx) {
62 void Indices(Standard_Integer& nV,
64 Standard_Integer& nVx) const {
70 void SetVertex(const TopoDS_Vertex& aV) {
74 const TopoDS_Vertex& Vertex()const {
78 void SetEdge(const TopoDS_Edge& aE) {
82 const TopoDS_Edge& Edge()const {
86 Standard_Integer Flag()const {
90 Standard_Real Parameter()const {
94 void SetContext(const Handle(IntTools_Context)& aContext) {
98 const Handle(IntTools_Context)& Context()const {
102 virtual void Perform() {
103 BOPAlgo_Algo::UserBreak();
104 myFlag=myContext->ComputeVE (myV, myE, myT);
108 Standard_Integer myIV;
109 Standard_Integer myIE;
110 Standard_Integer myIVx;
111 Standard_Integer myFlag;
115 Handle(IntTools_Context) myContext;
117 //=======================================================================
118 typedef BOPCol_NCVector
119 <BOPAlgo_VertexEdge> BOPAlgo_VectorOfVertexEdge;
121 typedef BOPCol_ContextFunctor
123 BOPAlgo_VectorOfVertexEdge,
124 Handle(IntTools_Context),
125 IntTools_Context> BOPAlgo_VertexEdgeFunctor;
127 typedef BOPCol_ContextCnt
128 <BOPAlgo_VertexEdgeFunctor,
129 BOPAlgo_VectorOfVertexEdge,
130 Handle(IntTools_Context)> BOPAlgo_VertexEdgeCnt;
132 //=======================================================================
133 // function: PerformVE
135 //=======================================================================
136 void BOPAlgo_PaveFiller::PerformVE()
138 Standard_Boolean bJustAdd;
139 Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, k, aNbVE;
140 Standard_Real aT, aTolE, aTolV;
143 BOPDS_MapOfPassKey aMPK;
145 BOPAlgo_VectorOfVertexEdge aVVE;
149 myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
150 iSize=myIterator->ExpectedLength();
155 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
156 aVEs.SetIncrement(iSize);
158 for (; myIterator->More(); myIterator->Next()) {
159 myIterator->Value(nV, nE, bJustAdd);
164 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
165 if (aSIE.HasSubShape(nV)) {
173 if (myDS->HasInterfShapeSubShapes(nV, nE)) {
174 myDS->ChangePaveBlocks(nE);
179 if (myDS->HasShapeSD(nV, nVSD)) {
184 if (!aMPK.Add(aPK)) {
188 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
189 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
191 BOPAlgo_VertexEdge& aVESolver=aVVE.Append1();
193 aVESolver.SetIndices(nV, nE, nVx);
194 aVESolver.SetVertex(aV);
195 aVESolver.SetEdge(aE);
196 aVESolver.SetProgressIndicator(myProgressIndicator);
198 }// for (; myIterator->More(); myIterator->Next()) {
201 //=============================================================
202 BOPAlgo_VertexEdgeCnt::Perform(myRunParallel, aVVE, myContext);
203 //=============================================================
205 for (k=0; k < aNbVE; ++k) {
206 const BOPAlgo_VertexEdge& aVESolver=aVVE(k);
207 iFlag=aVESolver.Flag();
209 aVESolver.Indices(nV, nE, nVx);
210 aT=aVESolver.Parameter();
211 const TopoDS_Vertex& aV=aVESolver.Vertex();
212 const TopoDS_Edge& aE=aVESolver.Edge();
214 BOPDS_InterfVE& aVE=aVEs.Append1();
215 aVE.SetIndices(nV, nE);
216 aVE.SetParameter(aT);
218 myDS->AddInterf(nV, nE);
220 BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
221 Handle(BOPDS_PaveBlock)& aPB=*((Handle(BOPDS_PaveBlock)*)&aLPB.First());
224 aPave.SetParameter(aT);
225 aPB->AppendExtPave(aPave);
226 aTolV = BRep_Tool::Tolerance(aV);
227 aTolE = BRep_Tool::Tolerance(aE);
228 if ( aTolV < aTolE) {
229 aBB.UpdateVertex(aV, aTolE);
230 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVx);
231 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
232 BRepBndLib::Add(aV, aBoxDS);
235 }//for (k=0; k < aNbVE; ++k) {