0025328: Visualization, TKOpenGl - support text rendering within built-in GLSL programs
[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
18#include <BOPAlgo_PaveFiller.ixx>
19
20#include <TopoDS_Vertex.hxx>
21#include <TopoDS_Edge.hxx>
22#include <BRep_Tool.hxx>
23
505abfb8 24#include <BOPCol_NCVector.hxx>
25#include <BOPCol_TBB.hxx>
26
1e143abb 27#include <IntTools_Context.hxx>
4e57c75e 28
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>
36
505abfb8 37//=======================================================================
38//class : BOPAlgo_VertexEdgeEdge
39//purpose :
40//=======================================================================
36f4947b 41class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
42
505abfb8 43 public:
36f4947b 44 DEFINE_STANDARD_ALLOC
45
46 BOPAlgo_VertexEdge() :
47 BOPAlgo_Algo(),
48 myIV(-1), myIE(-1), myIVx(-1), myFlag(-1), myT(-1.) {
505abfb8 49 };
50 //
36f4947b 51 virtual ~BOPAlgo_VertexEdge(){
505abfb8 52 };
53 //
54 void SetIndices(const Standard_Integer nV,
55 const Standard_Integer nE,
56 const Standard_Integer nVx) {
57 myIV=nV;
58 myIE=nE;
59 myIVx=nVx;
60 }
61 //
62 void Indices(Standard_Integer& nV,
63 Standard_Integer& nE,
64 Standard_Integer& nVx) const {
65 nV=myIV;
66 nE=myIE;
67 nVx=myIVx;
68 }
69 //
70 void SetVertex(const TopoDS_Vertex& aV) {
71 myV=aV;
72 }
73 //
74 const TopoDS_Vertex& Vertex()const {
75 return myV;
76 }
77 //
78 void SetEdge(const TopoDS_Edge& aE) {
79 myE=aE;
80 }
81 //
82 const TopoDS_Edge& Edge()const {
83 return myE;
84 }
85 //
86 Standard_Integer Flag()const {
87 return myFlag;
88 }
89 //
90 Standard_Real Parameter()const {
91 return myT;
92 }
93 //
1e143abb 94 void SetContext(const Handle(IntTools_Context)& aContext) {
505abfb8 95 myContext=aContext;
96 }
97 //
1e143abb 98 const Handle(IntTools_Context)& Context()const {
505abfb8 99 return myContext;
100 }
101 //
36f4947b 102 virtual void Perform() {
103 BOPAlgo_Algo::UserBreak();
505abfb8 104 myFlag=myContext->ComputeVE (myV, myE, myT);
105 };
106 //
107 protected:
108 Standard_Integer myIV;
109 Standard_Integer myIE;
110 Standard_Integer myIVx;
111 Standard_Integer myFlag;
112 Standard_Real myT;
113 TopoDS_Vertex myV;
114 TopoDS_Edge myE;
1e143abb 115 Handle(IntTools_Context) myContext;
505abfb8 116};
117//=======================================================================
118typedef BOPCol_NCVector
119 <BOPAlgo_VertexEdge> BOPAlgo_VectorOfVertexEdge;
120//
121typedef BOPCol_TBBContextFunctor
122 <BOPAlgo_VertexEdge,
123 BOPAlgo_VectorOfVertexEdge,
1e143abb 124 Handle(IntTools_Context),
125 IntTools_Context> BOPAlgo_VertexEdgeFunctor;
505abfb8 126//
127typedef BOPCol_TBBContextCnt
128 <BOPAlgo_VertexEdgeFunctor,
129 BOPAlgo_VectorOfVertexEdge,
1e143abb 130 Handle(IntTools_Context)> BOPAlgo_VertexEdgeCnt;
505abfb8 131//
4e57c75e 132//=======================================================================
133// function: PerformVE
134// purpose:
135//=======================================================================
505abfb8 136void BOPAlgo_PaveFiller::PerformVE()
4e57c75e 137{
138 Standard_Boolean bJustAdd;
505abfb8 139 Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, i, k, aNbVE;;
4e57c75e 140 Standard_Real aT, aTolE, aTolV;
141 BOPDS_Pave aPave;
142 BOPDS_PassKey aPK;
143 BOPDS_MapOfPassKey aMPK;
144 BRep_Builder aBB;
505abfb8 145 BOPAlgo_VectorOfVertexEdge aVVE;
4e57c75e 146 //
147 myErrorStatus=0;
148 //
149 myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
150 iSize=myIterator->ExpectedLength();
151 if (!iSize) {
152 return;
153 }
154 //
155 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
156 aVEs.SetStartSize(iSize);
157 aVEs.SetIncrement(iSize);
158 aVEs.Init();
159 //
160 for (; myIterator->More(); myIterator->Next()) {
161 myIterator->Value(nV, nE, bJustAdd);
162 if(bJustAdd) {
163 continue;
164 }
165 //
166 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
167 if (aSIE.HasSubShape(nV)) {
168 continue;
169 }
170 //
171 if (aSIE.HasFlag()){
172 continue;
173 }
174 //
175 if (myDS->HasInterfShapeSubShapes(nV, nE)) {
c1746a0a 176 myDS->ChangePaveBlocks(nE);
4e57c75e 177 continue;
178 }
179 //
180 nVx=nV;
181 if (myDS->HasShapeSD(nV, nVSD)) {
182 nVx=nVSD;
183 }
184 //
185 aPK.SetIds(nVx, nE);
186 if (!aMPK.Add(aPK)) {
187 continue;
188 }
189 //
190 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
191 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
192 //
505abfb8 193 BOPAlgo_VertexEdge& aVESolver=aVVE.Append1();
194 //
195 aVESolver.SetIndices(nV, nE, nVx);
196 aVESolver.SetVertex(aV);
197 aVESolver.SetEdge(aE);
36f4947b 198 aVESolver.SetProgressIndicator(myProgressIndicator);
505abfb8 199 //
36f4947b 200 }// for (; myIterator->More(); myIterator->Next()) {
505abfb8 201 //
202 aNbVE=aVVE.Extent();
203 //=============================================================
204 BOPAlgo_VertexEdgeCnt::Perform(myRunParallel, aVVE, myContext);
205 //=============================================================
206 //
207 for (k=0; k < aNbVE; ++k) {
208 const BOPAlgo_VertexEdge& aVESolver=aVVE(k);
209 iFlag=aVESolver.Flag();
4e57c75e 210 if (!iFlag) {
505abfb8 211 aVESolver.Indices(nV, nE, nVx);
212 aT=aVESolver.Parameter();
213 const TopoDS_Vertex& aV=aVESolver.Vertex();
214 const TopoDS_Edge& aE=aVESolver.Edge();
4e57c75e 215 // 1
216 i=aVEs.Append()-1;
217 BOPDS_InterfVE& aVE=aVEs(i);
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}