Salome HOME
3887362848e959a510bd051b31a5c09f070105f2
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller.cxx
1 //  Copyright (C) 2007-2010  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.ixx>
29 //
30 #include <BOPTColStd_Failure.hxx>
31 #include <NMTDS_ShapesDataStructure.hxx>
32 #include <NMTTools_DEProcessor.hxx>
33 #include <NMTDS_Iterator.hxx>
34 #include <NMTDS_InterfPool.hxx>
35
36 //=======================================================================
37 // function: NMTTools_PaveFiller::NMTTools_PaveFiller
38 // purpose: 
39 //=======================================================================
40   NMTTools_PaveFiller::NMTTools_PaveFiller()
41 {
42   myDS=NULL;
43   myDSIt=NULL;
44   myIsDone=Standard_False;
45   myNbSources=0;
46   myNbEdges=0;
47   myIP=NULL;
48 }
49 //=======================================================================
50 // function: ~
51 // purpose: 
52 //=======================================================================
53   NMTTools_PaveFiller::~NMTTools_PaveFiller()
54 {
55   Clear();
56 }
57 //=======================================================================
58 // function: Clear
59 // purpose: 
60 //=======================================================================
61   void NMTTools_PaveFiller::Clear()
62 {
63   if (myDSIt) {
64     delete myDSIt;
65   } 
66   if (myDS) {
67     delete myDS;
68   }
69   myDSIt=NULL;
70   myDS=NULL;
71   
72   if (myIP) {
73     delete myIP;
74   }
75   myIP=NULL;
76 }
77 //=======================================================================
78 // function: SetCompositeShape
79 // purpose: 
80 //=======================================================================
81   void NMTTools_PaveFiller::SetCompositeShape(const TopoDS_Shape& aS)
82 {
83   myCompositeShape=aS;
84 }
85 //=======================================================================
86 // function: CompositeShape
87 // purpose: 
88 //=======================================================================
89   const TopoDS_Shape& NMTTools_PaveFiller::CompositeShape()const
90 {
91   return myCompositeShape;
92 }
93 //=======================================================================
94 // function:  DS
95 // purpose: 
96 //=======================================================================
97   NMTDS_PShapesDataStructure NMTTools_PaveFiller::DS()
98 {
99   return myDS;
100 }
101 //=======================================================================
102 // function: DSIt
103 // purpose: 
104 //=======================================================================
105   NMTDS_PIterator NMTTools_PaveFiller::DSIt()
106 {
107   return myDSIt;
108 }
109 //=======================================================================
110 // function:  IP
111 // purpose: 
112 //=======================================================================
113   NMTDS_PInterfPool NMTTools_PaveFiller::IP()
114 {
115   return myIP;
116 }
117 //=======================================================================
118 // function:IsDone
119 // purpose: 
120 //=======================================================================
121   Standard_Boolean NMTTools_PaveFiller::IsDone() const
122 {
123   return myIsDone;
124 }
125 //=======================================================================
126 // function: Context
127 // purpose: 
128 //=======================================================================
129   const IntTools_Context& NMTTools_PaveFiller::Context() const
130 {
131   return myContext;
132 }
133 //=======================================================================
134 // function: ChangeContext
135 // purpose: 
136 //=======================================================================
137   IntTools_Context& NMTTools_PaveFiller::ChangeContext() 
138 {
139   return myContext;
140 }
141 //=======================================================================
142 // function: PavePool
143 // purpose: 
144 //=======================================================================
145   const BOPTools_PavePool& NMTTools_PaveFiller::PavePool() const
146 {
147   return myPavePool;
148 }
149 //=======================================================================
150 // function: ChangePavePool
151 // purpose: 
152 //=======================================================================
153   BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePool()
154 {
155   return myPavePool;
156 }
157 //=======================================================================
158 // function: ChangePavePoolNew
159 // purpose: 
160 //=======================================================================
161   BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePoolNew()
162 {
163   return myPavePoolNew;
164 }
165 //=======================================================================
166 // function:  CommonBlockPool
167 // purpose: 
168 //=======================================================================
169   const NMTTools_CommonBlockPool& NMTTools_PaveFiller::CommonBlockPool() const
170 {
171   return myCommonBlockPool;
172 }
173 //=======================================================================
174 // function:  ChangeCommonBlockPool
175 // purpose: 
176 //=======================================================================
177   NMTTools_CommonBlockPool& NMTTools_PaveFiller::ChangeCommonBlockPool()
178 {
179   return myCommonBlockPool;
180 }
181 //=======================================================================
182 // function:  SplitShapesPool
183 // purpose: 
184 //=======================================================================
185   const BOPTools_SplitShapesPool& NMTTools_PaveFiller::SplitShapesPool() const
186 {
187   return mySplitShapesPool;
188 }
189 //=======================================================================
190 // function:  ChangeSplitShapesPool
191 // purpose: 
192 //=======================================================================
193   BOPTools_SplitShapesPool& NMTTools_PaveFiller::ChangeSplitShapesPool()
194 {
195   return mySplitShapesPool;
196 }
197 //=======================================================================
198 // function: Init
199 // purpose: 
200 //=======================================================================
201   void NMTTools_PaveFiller::Init()
202 {
203   myIsDone=Standard_False;
204   if (myCompositeShape.IsNull()) {
205     return;
206   }
207   //
208   Clear();
209   // 1.
210   myDS=new NMTDS_ShapesDataStructure;
211   myDS->SetCompositeShape(myCompositeShape);
212   myDS->Init();
213   //
214   // 2.
215   myDSIt=new NMTDS_Iterator;
216   myDSIt->SetDS(myDS);
217   myDSIt->Prepare();
218   //
219   // 3.
220   myNbSources=myDS->NumberOfShapesOfTheObject()+
221               myDS->NumberOfShapesOfTheTool();
222   myNbEdges=myDS->NbEdges();
223   //
224   // 4
225   myIP=new NMTDS_InterfPool;
226 }
227
228 //=======================================================================
229 // function: Perform
230 // purpose: 
231 //=======================================================================
232   void NMTTools_PaveFiller::Perform()
233 {
234   myIsDone=Standard_False;
235   //
236   //----------------
237   try {
238     // 0.
239     Init();
240     //1.VV
241     //
242     PerformVV();
243     //
244     // 2.VE
245     myPavePool.Resize (myNbEdges);
246     
247     PrepareEdges();
248
249     PerformVE();
250     //
251     // 3.VF
252     PerformVF();
253     //
254     // 4.EE
255     myCommonBlockPool.Resize (myNbEdges);
256     mySplitShapesPool.Resize (myNbEdges);
257     myPavePoolNew    .Resize (myNbEdges);
258
259     PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
260     PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
261     //
262     PerformEE();
263     //
264     RefinePavePool ();
265     //
266     myPavePoolNew.Destroy();
267     myPavePoolNew.Resize (myNbEdges);
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     myIsDone=Standard_True;
297   }
298   catch (BOPTColStd_Failure& ) {
299   }
300 }