1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: GEOMAlgo_Builder_4.cxx
25 // Author: Peter KURNEV
27 #include <GEOMAlgo_Builder.hxx>
29 #include <TopoDS_Iterator.hxx>
31 #include <TopTools_ListOfShape.hxx>
32 #include <TopTools_ListIteratorOfListOfShape.hxx>
33 #include <TopTools_MapOfShape.hxx>
34 #include <TopTools_MapIteratorOfMapOfShape.hxx>
36 #include <IntTools_Context.hxx>
38 #include <NMTDS_ShapesDataStructure.hxx>
40 #include <NMTTools_PaveFiller.hxx>
42 #include <GEOMAlgo_Tools3D.hxx>
45 void MapShapes(const TopoDS_Shape& aS,
46 TopTools_MapOfShape& aM);
48 //=======================================================================
49 //function : Generated
51 //=======================================================================
52 const TopTools_ListOfShape& GEOMAlgo_Builder::Generated(const TopoDS_Shape& theS)
54 /*const NMTDS_ShapesDataStructure& aDS=**/myPaveFiller->DS();
55 NMTTools_PaveFiller* pPF=myPaveFiller;
56 IntTools_Context& aCtx=pPF->ChangeContext();
58 Standard_Boolean bHasImage, bToReverse;
59 TopAbs_ShapeEnum aType;
60 TopTools_ListIteratorOfListOfShape aIt;
68 bHasImage=myImages.HasImage(theS);
73 aType=theS.ShapeType();
75 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
76 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
77 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
79 for (; aIt.More(); aIt.Next()) {
80 const TopoDS_Shape& aSp=aIt.Value();
81 if (mySameDomainShapes.Contains(aSp)) {
82 if (myMapShape.Contains(aSp)) {
83 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
85 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
86 aSpR.Orientation(theS.Orientation());
89 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSpR, theS, aCtx);
95 myHistShapes.Append(aSpR);
103 //=======================================================================
104 //function : Modified
106 //=======================================================================
107 const TopTools_ListOfShape& GEOMAlgo_Builder::Modified(const TopoDS_Shape& theS)
109 /*const NMTDS_ShapesDataStructure& aDS=**/myPaveFiller->DS();
110 NMTTools_PaveFiller* pPF=myPaveFiller;
111 IntTools_Context& aCtx=pPF->ChangeContext();
113 Standard_Boolean bHasImage, bToReverse;
114 TopAbs_ShapeEnum aType;
115 TopTools_ListIteratorOfListOfShape aIt;
117 myHistShapes.Clear();
123 bHasImage=myImages.HasImage(theS);
128 aType=theS.ShapeType();
130 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
131 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
132 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
133 aIt.Initialize(aLSp);
134 for (; aIt.More(); aIt.Next()) {
135 TopoDS_Shape aSp=aIt.Value();
136 if (!mySameDomainShapes.Contains(aSp)) {
137 if (myMapShape.Contains(aSp)) {
139 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
140 aSp.Orientation(theS.Orientation());
143 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx);
149 myHistShapes.Append(aSp);
157 //=======================================================================
158 //function : IsDeleted
160 //=======================================================================
161 Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
163 Standard_Boolean bRet, bHasImage, bContains;
164 TopAbs_ShapeEnum aType;
165 TopTools_ListIteratorOfListOfShape aIt;
173 bContains=myMapShape.Contains(theS);
178 bHasImage=myImages.HasImage(theS);
183 aType=theS.ShapeType();
184 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
185 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
186 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
187 aIt.Initialize(aLSp);
188 for (; aIt.More(); aIt.Next()) {
189 TopoDS_Shape aSp=aIt.Value();
191 if (!mySameDomainShapes.Contains(aSp)) {
192 if (myMapShape.Contains(aSp)) {
197 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
198 if (myMapShape.Contains(aSpR)) {
204 return !bRet; // true
206 //=======================================================================
207 //function : PrepareHistory
209 //=======================================================================
210 void GEOMAlgo_Builder::PrepareHistory()
212 if(myShape.IsNull()) {
216 Standard_Boolean bHasImage, bContainsSD;
217 TopAbs_ShapeEnum aType;
218 TopTools_MapOfShape aMS;
219 TopTools_ListIteratorOfListOfShape aIt;
220 TopTools_MapIteratorOfMapOfShape aItM;
223 GEOMAlgo_BuilderShape::PrepareHistory();
225 // 2. myMapShape - all shapes of result with theirs sub-shapes
226 MapShapes(myShape, myMapShape);
228 // 3. MS - all argument shapes with theirs sub-shapes
229 aIt.Initialize(myShapes);
230 for (; aIt.More(); aIt.Next()) {
231 const TopoDS_Shape& aSx=aIt.Value();
236 aItM.Initialize(aMS);
237 for (; aItM.More(); aItM.Next()) {
238 const TopoDS_Shape& aSx=aItM.Key();
239 aType=aSx.ShapeType();
240 //modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f
242 // 4.1 .myImagesResult
243 TopTools_ListOfShape aLSx;
245 bHasImage=myImages.HasImage(aSx);
247 if (myMapShape.Contains(aSx)) {
249 myImagesResult.Add(aSx, aLSx);
253 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
254 aIt.Initialize(aLSp);
255 for (; aIt.More(); aIt.Next()) {
256 const TopoDS_Shape& aSp=aIt.Value();
257 if (myMapShape.Contains(aSp)) {
261 myImagesResult.Add(aSx, aLSx);
264 //modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t
268 myHasDeleted=IsDeleted(aSx);//xx
271 if (!myHasGenerated || !myHasModified) {
272 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
273 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
274 //modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f
275 //bHasImage=myImages.HasImage(aSx);
276 //modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t
278 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
279 aIt.Initialize(aLSp);
280 for (; aIt.More(); aIt.Next()) {
281 const TopoDS_Shape& aSp=aIt.Value();
283 if (myMapShape.Contains(aSp)) {
284 bContainsSD=mySameDomainShapes.Contains(aSp);
286 if (!myHasGenerated) {
288 myHasGenerated=Standard_True;
291 if (!myHasModified) {
293 myHasModified=Standard_True;
296 } // if (myMapShape.Contains(aSp))
304 //=======================================================================
305 //function : MapShapes
307 //=======================================================================
308 void MapShapes(const TopoDS_Shape& theS,
309 TopTools_MapOfShape& theM)
312 TopoDS_Iterator anIt;
313 anIt.Initialize(theS);
314 for (; anIt.More(); anIt.Next()) {
315 const TopoDS_Shape& aSx=anIt.Value();
316 MapShapes(aSx, theM);