Salome HOME
Added help page and revert some changes for a better ergonomy
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller.cxx
1 // Copyright (C) 2007-2011  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
26 #include <NMTTools_PaveFiller.ixx>
27
28 #include <Basics_OCCTVersion.hxx>
29
30 #include <NMTTools_DEProcessor.hxx>
31
32 #include <NMTDS_ShapesDataStructure.hxx>
33 #include <NMTDS_Iterator.hxx>
34 #include <NMTDS_InterfPool.hxx>
35
36 #include <BOPTColStd_Failure.hxx>
37
38 //=======================================================================
39 // function: NMTTools_PaveFiller::NMTTools_PaveFiller
40 // purpose: 
41 //=======================================================================
42   NMTTools_PaveFiller::NMTTools_PaveFiller()
43 {
44   myDS=NULL;
45   myDSIt=NULL;
46   myIsDone=Standard_False;
47   myNbSources=0;
48   myNbEdges=0;
49   myIP=NULL;
50 }
51 //=======================================================================
52 // function: ~
53 // purpose: 
54 //=======================================================================
55   NMTTools_PaveFiller::~NMTTools_PaveFiller()
56 {
57   Clear();
58 }
59 //=======================================================================
60 // function: Clear
61 // purpose: 
62 //=======================================================================
63   void NMTTools_PaveFiller::Clear()
64 {
65   if (myDSIt) {
66     delete myDSIt;
67   } 
68   if (myDS) {
69     delete myDS;
70   }
71   myDSIt=NULL;
72   myDS=NULL;
73   
74   if (myIP) {
75     delete myIP;
76   }
77   myIP=NULL;
78 }
79 //=======================================================================
80 // function: SetCompositeShape
81 // purpose: 
82 //=======================================================================
83   void NMTTools_PaveFiller::SetCompositeShape(const TopoDS_Shape& aS)
84 {
85   myCompositeShape=aS;
86 }
87 //=======================================================================
88 // function: CompositeShape
89 // purpose: 
90 //=======================================================================
91   const TopoDS_Shape& NMTTools_PaveFiller::CompositeShape()const
92 {
93   return myCompositeShape;
94 }
95 //=======================================================================
96 // function:  DS
97 // purpose: 
98 //=======================================================================
99   NMTDS_PShapesDataStructure NMTTools_PaveFiller::DS()
100 {
101   return myDS;
102 }
103 //=======================================================================
104 // function: DSIt
105 // purpose: 
106 //=======================================================================
107   NMTDS_PIterator NMTTools_PaveFiller::DSIt()
108 {
109   return myDSIt;
110 }
111 //=======================================================================
112 // function:  IP
113 // purpose: 
114 //=======================================================================
115   NMTDS_PInterfPool NMTTools_PaveFiller::IP()
116 {
117   return myIP;
118 }
119 //=======================================================================
120 // function:IsDone
121 // purpose: 
122 //=======================================================================
123   Standard_Boolean NMTTools_PaveFiller::IsDone() const
124 {
125   return myIsDone;
126 }
127 //=======================================================================
128 // function: Context
129 // purpose: 
130 //=======================================================================
131 #if OCC_VERSION_LARGE > 0x06050200
132 const Handle(IntTools_Context)& NMTTools_PaveFiller::Context() const
133 #else
134 const IntTools_Context& NMTTools_PaveFiller::Context() const
135 #endif
136 {
137   return myContext;
138 }
139
140 #if OCC_VERSION_LARGE <= 0x06050200
141 //=======================================================================
142 // function: ChangeContext
143 // purpose: 
144 //=======================================================================
145 IntTools_Context& NMTTools_PaveFiller::ChangeContext() 
146 {
147   return myContext;
148 }
149 #endif
150
151 //=======================================================================
152 // function: PavePool
153 // purpose: 
154 //=======================================================================
155   const BOPTools_PavePool& NMTTools_PaveFiller::PavePool() const
156 {
157   return myPavePool;
158 }
159 //=======================================================================
160 // function: ChangePavePool
161 // purpose: 
162 //=======================================================================
163   BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePool()
164 {
165   return myPavePool;
166 }
167 //=======================================================================
168 // function: ChangePavePoolNew
169 // purpose: 
170 //=======================================================================
171   BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePoolNew()
172 {
173   return myPavePoolNew;
174 }
175 //=======================================================================
176 // function:  CommonBlockPool
177 // purpose: 
178 //=======================================================================
179   const NMTTools_CommonBlockPool& NMTTools_PaveFiller::CommonBlockPool() const
180 {
181   return myCommonBlockPool;
182 }
183 //=======================================================================
184 // function:  ChangeCommonBlockPool
185 // purpose: 
186 //=======================================================================
187   NMTTools_CommonBlockPool& NMTTools_PaveFiller::ChangeCommonBlockPool()
188 {
189   return myCommonBlockPool;
190 }
191 //=======================================================================
192 // function:  SplitShapesPool
193 // purpose: 
194 //=======================================================================
195   const BOPTools_SplitShapesPool& NMTTools_PaveFiller::SplitShapesPool() const
196 {
197   return mySplitShapesPool;
198 }
199 //=======================================================================
200 // function:  ChangeSplitShapesPool
201 // purpose: 
202 //=======================================================================
203   BOPTools_SplitShapesPool& NMTTools_PaveFiller::ChangeSplitShapesPool()
204 {
205   return mySplitShapesPool;
206 }
207 //=======================================================================
208 // function: Init
209 // purpose: 
210 //=======================================================================
211   void NMTTools_PaveFiller::Init()
212 {
213   myIsDone=Standard_False;
214   if (myCompositeShape.IsNull()) {
215     return;
216   }
217   //
218   Clear();
219   // 1.
220   myDS=new NMTDS_ShapesDataStructure;
221   myDS->SetCompositeShape(myCompositeShape);
222   myDS->Init();
223   //
224   // 2.
225   myDSIt=new NMTDS_Iterator;
226   myDSIt->SetDS(myDS);
227   myDSIt->Prepare();
228   //
229   // 3.
230   myNbSources=myDS->NumberOfShapesOfTheObject()+
231               myDS->NumberOfShapesOfTheTool();
232   myNbEdges=myDS->NbEdges();
233   //
234   // 4.
235   myIP=new NMTDS_InterfPool;
236 #if OCC_VERSION_LARGE > 0x06050200
237   //
238   // 5.
239   myContext=new IntTools_Context;
240 #endif
241 }
242
243 //=======================================================================
244 // function: Perform
245 // purpose: 
246 //=======================================================================
247   void NMTTools_PaveFiller::Perform()
248 {
249   myIsDone=Standard_False;
250   //
251   //----------------
252   try {
253     // 0.
254     Init();
255     //1.VV
256     //
257     PerformVV();
258     //
259     // 2.VE
260     myPavePool.Resize (myNbEdges);
261     
262     PrepareEdges();
263
264     PerformVE();
265     //
266     // 3.VF
267     PerformVF();
268     //
269     // 4.EE
270     myCommonBlockPool.Resize (myNbEdges);
271     mySplitShapesPool.Resize (myNbEdges);
272     myPavePoolNew    .Resize (myNbEdges);
273
274     PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
275     PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
276     //
277     PerformEE();
278     //
279     RefinePavePool ();
280     //
281     myPavePoolNew.Destroy();
282     myPavePoolNew.Resize (myNbEdges);
283     //
284     //modified by NIZNHY-PKV Mon Dec 12 09:13:53 2011f
285     UpdateCommonBlocks(0);
286     //modified by NIZNHY-PKV Mon Dec 12 09:13:56 2011t
287     //
288     // 5.EF
289     PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE);
290     PerformEF();
291     //
292     RefinePavePool();
293     //
294     myPavePoolNew.Destroy();
295     
296     MakeSplitEdges();
297
298     UpdateCommonBlocks();
299     //
300     // 6. FF
301     PerformFF ();
302     //
303     MakeBlocks();
304     //
305     MakePCurves();
306     //
307     // 7.Postprocessing 
308     UpdatePaveBlocks();
309     //
310     NMTTools_DEProcessor aDEP(*this);
311     aDEP.Do();
312     //
313     MakeAloneVertices();
314     //
315     //modified by NIZNHY-PKV Mon Dec 12 09:14:23 2011f
316     myIP->Purge();
317     //modified by NIZNHY-PKV Mon Dec 12 09:14:27 2011t
318     myIsDone=Standard_True;
319   }
320   catch (BOPTColStd_Failure& ) {
321   }
322 }