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