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