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