0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_2.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
973c2be1 2// Copyright (c) 2010-2014 OPEN CASCADE SAS
4e57c75e 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
6//
973c2be1 7// This file is part of Open CASCADE Technology software library.
4e57c75e 8//
d5f74e42 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
973c2be1 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.
4e57c75e 14//
973c2be1 15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
4e57c75e 17
4e57c75e 18
42cf5bc1 19#include <BOPAlgo_PaveFiller.hxx>
20#include <BOPAlgo_SectionAttribute.hxx>
505abfb8 21#include <BOPCol_NCVector.hxx>
c7b59798 22#include <BOPCol_Parallel.hxx>
42cf5bc1 23#include <BOPDS_Curve.hxx>
24#include <BOPDS_DS.hxx>
4e57c75e 25#include <BOPDS_Interf.hxx>
42cf5bc1 26#include <BOPDS_Iterator.hxx>
4e57c75e 27#include <BOPDS_MapOfPassKey.hxx>
42cf5bc1 28#include <BOPDS_PassKey.hxx>
29#include <BOPDS_PaveBlock.hxx>
30#include <BOPDS_VectorOfInterfVE.hxx>
4e57c75e 31#include <BRep_Builder.hxx>
42cf5bc1 32#include <BRep_Tool.hxx>
33#include <BRepBndLib.hxx>
34#include <gp_Pnt.hxx>
35#include <IntTools_Context.hxx>
36#include <TopoDS_Edge.hxx>
37#include <TopoDS_Face.hxx>
38#include <TopoDS_Vertex.hxx>
4e57c75e 39
505abfb8 40//=======================================================================
41//class : BOPAlgo_VertexEdgeEdge
42//purpose :
43//=======================================================================
36f4947b 44class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
45
505abfb8 46 public:
36f4947b 47 DEFINE_STANDARD_ALLOC
48
49 BOPAlgo_VertexEdge() :
50 BOPAlgo_Algo(),
51 myIV(-1), myIE(-1), myIVx(-1), myFlag(-1), myT(-1.) {
505abfb8 52 };
53 //
36f4947b 54 virtual ~BOPAlgo_VertexEdge(){
505abfb8 55 };
56 //
57 void SetIndices(const Standard_Integer nV,
58 const Standard_Integer nE,
59 const Standard_Integer nVx) {
60 myIV=nV;
61 myIE=nE;
62 myIVx=nVx;
63 }
64 //
65 void Indices(Standard_Integer& nV,
66 Standard_Integer& nE,
67 Standard_Integer& nVx) const {
68 nV=myIV;
69 nE=myIE;
70 nVx=myIVx;
71 }
72 //
73 void SetVertex(const TopoDS_Vertex& aV) {
74 myV=aV;
75 }
76 //
77 const TopoDS_Vertex& Vertex()const {
78 return myV;
79 }
80 //
81 void SetEdge(const TopoDS_Edge& aE) {
82 myE=aE;
83 }
84 //
85 const TopoDS_Edge& Edge()const {
86 return myE;
87 }
88 //
89 Standard_Integer Flag()const {
90 return myFlag;
91 }
92 //
93 Standard_Real Parameter()const {
94 return myT;
95 }
96 //
1e143abb 97 void SetContext(const Handle(IntTools_Context)& aContext) {
505abfb8 98 myContext=aContext;
99 }
100 //
1e143abb 101 const Handle(IntTools_Context)& Context()const {
505abfb8 102 return myContext;
103 }
104 //
36f4947b 105 virtual void Perform() {
106 BOPAlgo_Algo::UserBreak();
505abfb8 107 myFlag=myContext->ComputeVE (myV, myE, myT);
108 };
109 //
110 protected:
111 Standard_Integer myIV;
112 Standard_Integer myIE;
113 Standard_Integer myIVx;
114 Standard_Integer myFlag;
115 Standard_Real myT;
116 TopoDS_Vertex myV;
117 TopoDS_Edge myE;
1e143abb 118 Handle(IntTools_Context) myContext;
505abfb8 119};
120//=======================================================================
121typedef BOPCol_NCVector
122 <BOPAlgo_VertexEdge> BOPAlgo_VectorOfVertexEdge;
123//
c7b59798 124typedef BOPCol_ContextFunctor
505abfb8 125 <BOPAlgo_VertexEdge,
126 BOPAlgo_VectorOfVertexEdge,
1e143abb 127 Handle(IntTools_Context),
128 IntTools_Context> BOPAlgo_VertexEdgeFunctor;
505abfb8 129//
c7b59798 130typedef BOPCol_ContextCnt
505abfb8 131 <BOPAlgo_VertexEdgeFunctor,
132 BOPAlgo_VectorOfVertexEdge,
1e143abb 133 Handle(IntTools_Context)> BOPAlgo_VertexEdgeCnt;
505abfb8 134//
4e57c75e 135//=======================================================================
136// function: PerformVE
137// purpose:
138//=======================================================================
505abfb8 139void BOPAlgo_PaveFiller::PerformVE()
4e57c75e 140{
141 Standard_Boolean bJustAdd;
402bfe81 142 Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, k, aNbVE;
4e57c75e 143 Standard_Real aT, aTolE, aTolV;
144 BOPDS_Pave aPave;
145 BOPDS_PassKey aPK;
146 BOPDS_MapOfPassKey aMPK;
147 BRep_Builder aBB;
505abfb8 148 BOPAlgo_VectorOfVertexEdge aVVE;
4e57c75e 149 //
150 myErrorStatus=0;
151 //
152 myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
153 iSize=myIterator->ExpectedLength();
154 if (!iSize) {
155 return;
156 }
157 //
158 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
4e57c75e 159 aVEs.SetIncrement(iSize);
4e57c75e 160 //
161 for (; myIterator->More(); myIterator->Next()) {
162 myIterator->Value(nV, nE, bJustAdd);
163 if(bJustAdd) {
164 continue;
165 }
166 //
167 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
168 if (aSIE.HasSubShape(nV)) {
169 continue;
170 }
171 //
172 if (aSIE.HasFlag()){
173 continue;
174 }
175 //
176 if (myDS->HasInterfShapeSubShapes(nV, nE)) {
c1746a0a 177 myDS->ChangePaveBlocks(nE);
4e57c75e 178 continue;
179 }
180 //
181 nVx=nV;
182 if (myDS->HasShapeSD(nV, nVSD)) {
183 nVx=nVSD;
184 }
185 //
186 aPK.SetIds(nVx, nE);
187 if (!aMPK.Add(aPK)) {
188 continue;
189 }
190 //
191 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
192 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
193 //
505abfb8 194 BOPAlgo_VertexEdge& aVESolver=aVVE.Append1();
195 //
196 aVESolver.SetIndices(nV, nE, nVx);
197 aVESolver.SetVertex(aV);
198 aVESolver.SetEdge(aE);
36f4947b 199 aVESolver.SetProgressIndicator(myProgressIndicator);
505abfb8 200 //
36f4947b 201 }// for (; myIterator->More(); myIterator->Next()) {
505abfb8 202 //
203 aNbVE=aVVE.Extent();
204 //=============================================================
205 BOPAlgo_VertexEdgeCnt::Perform(myRunParallel, aVVE, myContext);
206 //=============================================================
207 //
208 for (k=0; k < aNbVE; ++k) {
209 const BOPAlgo_VertexEdge& aVESolver=aVVE(k);
210 iFlag=aVESolver.Flag();
4e57c75e 211 if (!iFlag) {
505abfb8 212 aVESolver.Indices(nV, nE, nVx);
213 aT=aVESolver.Parameter();
214 const TopoDS_Vertex& aV=aVESolver.Vertex();
215 const TopoDS_Edge& aE=aVESolver.Edge();
4e57c75e 216 // 1
402bfe81 217 BOPDS_InterfVE& aVE=aVEs.Append1();
4e57c75e 218 aVE.SetIndices(nV, nE);
219 aVE.SetParameter(aT);
220 // 2
221 myDS->AddInterf(nV, nE);
222 // 3
223 BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
857ffd5e 224 Handle(BOPDS_PaveBlock)& aPB=*((Handle(BOPDS_PaveBlock)*)&aLPB.First());
4e57c75e 225 //
226 aPave.SetIndex(nVx);
227 aPave.SetParameter(aT);
228 aPB->AppendExtPave(aPave);
229 aTolV = BRep_Tool::Tolerance(aV);
230 aTolE = BRep_Tool::Tolerance(aE);
231 if ( aTolV < aTolE) {
232 aBB.UpdateVertex(aV, aTolE);
233 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVx);
234 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
235 BRepBndLib::Add(aV, aBoxDS);
236 }
237 }
505abfb8 238 }//for (k=0; k < aNbVE; ++k) {
4e57c75e 239}