]> SALOME platform Git repositories - modules/geom.git/blob - src/NMTTools/NMTTools_PaveFiller.cxx
Salome HOME
9142b1a7bfb4a716d21f430e2cb7ad862d8d8efa
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File:        NMTTools_PaveFiller.cxx
23 // Created:     Fri Dec  5 14:58:54 2003
24 // Author:      Peter KURNEV
25 //              <pkv@irinox>
26 //
27 #include <NMTTools_PaveFiller.ixx>
28 //
29 #include <BOPTColStd_Failure.hxx>
30 #include <NMTDS_ShapesDataStructure.hxx>
31 #include <NMTTools_DEProcessor.hxx>
32 #include <NMTDS_Iterator.hxx>
33 #include <NMTDS_InterfPool.hxx>
34
35 //=======================================================================
36 // function: NMTTools_PaveFiller::NMTTools_PaveFiller
37 // purpose: 
38 //=======================================================================
39   NMTTools_PaveFiller::NMTTools_PaveFiller()
40 {
41   myDS=NULL;
42   myDSIt=NULL;
43   myIsDone=Standard_False;
44   myNbSources=0;
45   myNbEdges=0;
46   myIP=NULL;
47 }
48 //=======================================================================
49 // function: ~
50 // purpose: 
51 //=======================================================================
52   NMTTools_PaveFiller::~NMTTools_PaveFiller()
53 {
54   Clear();
55 }
56 //=======================================================================
57 // function: Clear
58 // purpose: 
59 //=======================================================================
60   void NMTTools_PaveFiller::Clear()
61 {
62   if (myDSIt) {
63     delete myDSIt;
64   } 
65   if (myDS) {
66     delete myDS;
67   }
68   myDSIt=NULL;
69   myDS=NULL;
70   
71   if (myIP) {
72     delete myIP;
73   }
74   myIP=NULL;
75 }
76 //=======================================================================
77 // function: SetCompositeShape
78 // purpose: 
79 //=======================================================================
80   void NMTTools_PaveFiller::SetCompositeShape(const TopoDS_Shape& aS)
81 {
82   myCompositeShape=aS;
83 }
84 //=======================================================================
85 // function: CompositeShape
86 // purpose: 
87 //=======================================================================
88   const TopoDS_Shape& NMTTools_PaveFiller::CompositeShape()const
89 {
90   return myCompositeShape;
91 }
92 //=======================================================================
93 // function:  DS
94 // purpose: 
95 //=======================================================================
96   NMTDS_PShapesDataStructure NMTTools_PaveFiller::DS()
97 {
98   return myDS;
99 }
100 //=======================================================================
101 // function: DSIt
102 // purpose: 
103 //=======================================================================
104   NMTDS_PIterator NMTTools_PaveFiller::DSIt()
105 {
106   return myDSIt;
107 }
108 //=======================================================================
109 // function:  IP
110 // purpose: 
111 //=======================================================================
112   NMTDS_PInterfPool NMTTools_PaveFiller::IP()
113 {
114   return myIP;
115 }
116 //=======================================================================
117 // function:IsDone
118 // purpose: 
119 //=======================================================================
120   Standard_Boolean NMTTools_PaveFiller::IsDone() const
121 {
122   return myIsDone;
123 }
124 //=======================================================================
125 // function: Context
126 // purpose: 
127 //=======================================================================
128   const IntTools_Context& NMTTools_PaveFiller::Context() const
129 {
130   return myContext;
131 }
132 //=======================================================================
133 // function: ChangeContext
134 // purpose: 
135 //=======================================================================
136   IntTools_Context& NMTTools_PaveFiller::ChangeContext() 
137 {
138   return myContext;
139 }
140 //=======================================================================
141 // function: PavePool
142 // purpose: 
143 //=======================================================================
144   const BOPTools_PavePool& NMTTools_PaveFiller::PavePool() const
145 {
146   return myPavePool;
147 }
148 //=======================================================================
149 // function: ChangePavePool
150 // purpose: 
151 //=======================================================================
152   BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePool()
153 {
154   return myPavePool;
155 }
156 //=======================================================================
157 // function: ChangePavePoolNew
158 // purpose: 
159 //=======================================================================
160   BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePoolNew()
161 {
162   return myPavePoolNew;
163 }
164 //=======================================================================
165 // function:  CommonBlockPool
166 // purpose: 
167 //=======================================================================
168   const NMTTools_CommonBlockPool& NMTTools_PaveFiller::CommonBlockPool() const
169 {
170   return myCommonBlockPool;
171 }
172 //=======================================================================
173 // function:  ChangeCommonBlockPool
174 // purpose: 
175 //=======================================================================
176   NMTTools_CommonBlockPool& NMTTools_PaveFiller::ChangeCommonBlockPool()
177 {
178   return myCommonBlockPool;
179 }
180 //=======================================================================
181 // function:  SplitShapesPool
182 // purpose: 
183 //=======================================================================
184   const BOPTools_SplitShapesPool& NMTTools_PaveFiller::SplitShapesPool() const
185 {
186   return mySplitShapesPool;
187 }
188 //=======================================================================
189 // function:  ChangeSplitShapesPool
190 // purpose: 
191 //=======================================================================
192   BOPTools_SplitShapesPool& NMTTools_PaveFiller::ChangeSplitShapesPool()
193 {
194   return mySplitShapesPool;
195 }
196 //=======================================================================
197 // function: Init
198 // purpose: 
199 //=======================================================================
200   void NMTTools_PaveFiller::Init()
201 {
202   myIsDone=Standard_False;
203   if (myCompositeShape.IsNull()) {
204     return;
205   }
206   //
207   Clear();
208   // 1.
209   myDS=new NMTDS_ShapesDataStructure;
210   myDS->SetCompositeShape(myCompositeShape);
211   myDS->Init();
212   //
213   // 2.
214   myDSIt=new NMTDS_Iterator;
215   myDSIt->SetDS(myDS);
216   myDSIt->Prepare();
217   //
218   // 3.
219   myNbSources=myDS->NumberOfShapesOfTheObject()+
220               myDS->NumberOfShapesOfTheTool();
221   myNbEdges=myDS->NbEdges();
222   //
223   // 4
224   myIP=new NMTDS_InterfPool;
225 }
226
227 //=======================================================================
228 // function: Perform
229 // purpose: 
230 //=======================================================================
231   void NMTTools_PaveFiller::Perform()
232 {
233   myIsDone=Standard_False;
234   //
235   //----------------
236   try {
237     // 0.
238     Init();
239     //1.VV
240     //
241     PerformVV();
242     //
243     // 2.VE
244     myPavePool.Resize (myNbEdges);
245     
246     PrepareEdges();
247
248     PerformVE();
249     //
250     // 3.VF
251     PerformVF();
252     //
253     // 4.EE
254     myCommonBlockPool.Resize (myNbEdges);
255     mySplitShapesPool.Resize (myNbEdges);
256     myPavePoolNew    .Resize (myNbEdges);
257
258     PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
259     PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
260     //
261     PerformEE();
262     //
263     RefinePavePool ();
264     //
265     myPavePoolNew.Destroy();
266     myPavePoolNew.Resize (myNbEdges);
267     //
268     // 5.EF
269     PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE);
270     PerformEF();
271     //
272     RefinePavePool();
273     //
274     myPavePoolNew.Destroy();
275     
276     MakeSplitEdges();
277
278     UpdateCommonBlocks();
279     //
280     // 6. FF
281     PerformFF ();
282     //
283     MakeBlocks();
284     //
285     MakePCurves();
286     //
287     // 7.Postprocessing 
288     UpdatePaveBlocks();
289     //
290     NMTTools_DEProcessor aDEP(*this);
291     aDEP.Do();
292     //
293     MakeAloneVertices();
294     //
295     myIsDone=Standard_True;
296   }
297   catch (BOPTColStd_Failure& ) {
298   }
299 }