1 // Copyright (C) 2007-2008 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
22 // File: GEOMAlgo_Builder_4.cxx
24 // Author: Peter KURNEV
26 #include <GEOMAlgo_Builder.hxx>
28 #include <TopoDS_Iterator.hxx>
30 #include <TopTools_ListOfShape.hxx>
31 #include <TopTools_ListIteratorOfListOfShape.hxx>
32 #include <TopTools_MapOfShape.hxx>
33 #include <TopTools_MapIteratorOfMapOfShape.hxx>
35 #include <IntTools_Context.hxx>
37 #include <NMTDS_ShapesDataStructure.hxx>
39 #include <NMTTools_PaveFiller.hxx>
41 #include <GEOMAlgo_Tools3D.hxx>
44 void MapShapes(const TopoDS_Shape& aS,
45 TopTools_MapOfShape& aM);
47 //=======================================================================
48 //function : Generated
50 //=======================================================================
51 const TopTools_ListOfShape& GEOMAlgo_Builder::Generated(const TopoDS_Shape& theS)
53 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
54 NMTTools_PaveFiller* pPF=myPaveFiller;
55 IntTools_Context& aCtx=pPF->ChangeContext();
57 Standard_Boolean bHasImage, bToReverse;
58 TopAbs_ShapeEnum aType;
59 TopTools_ListIteratorOfListOfShape aIt;
67 bHasImage=myImages.HasImage(theS);
72 aType=theS.ShapeType();
74 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
75 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
76 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
78 for (; aIt.More(); aIt.Next()) {
79 const TopoDS_Shape& aSp=aIt.Value();
80 if (mySameDomainShapes.Contains(aSp)) {
81 if (myMapShape.Contains(aSp)) {
82 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
84 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
85 aSpR.Orientation(theS.Orientation());
88 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSpR, theS, aCtx);
94 myHistShapes.Append(aSpR);
102 //=======================================================================
103 //function : Modified
105 //=======================================================================
106 const TopTools_ListOfShape& GEOMAlgo_Builder::Modified(const TopoDS_Shape& theS)
108 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
109 NMTTools_PaveFiller* pPF=myPaveFiller;
110 IntTools_Context& aCtx=pPF->ChangeContext();
112 Standard_Boolean bHasImage, bToReverse;
113 TopAbs_ShapeEnum aType;
114 TopTools_ListIteratorOfListOfShape aIt;
116 myHistShapes.Clear();
122 bHasImage=myImages.HasImage(theS);
127 aType=theS.ShapeType();
129 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
130 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
131 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
132 aIt.Initialize(aLSp);
133 for (; aIt.More(); aIt.Next()) {
134 TopoDS_Shape aSp=aIt.Value();
135 if (!mySameDomainShapes.Contains(aSp)) {
136 if (myMapShape.Contains(aSp)) {
138 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
139 aSp.Orientation(theS.Orientation());
142 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx);
148 myHistShapes.Append(aSp);
156 //=======================================================================
157 //function : IsDeleted
159 //=======================================================================
160 Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
162 Standard_Boolean bRet, bHasImage, bContains;
163 TopAbs_ShapeEnum aType;
164 TopTools_ListIteratorOfListOfShape aIt;
172 bContains=myMapShape.Contains(theS);
177 bHasImage=myImages.HasImage(theS);
182 aType=theS.ShapeType();
183 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
184 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
185 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
186 aIt.Initialize(aLSp);
187 for (; aIt.More(); aIt.Next()) {
188 TopoDS_Shape aSp=aIt.Value();
190 if (!mySameDomainShapes.Contains(aSp)) {
191 if (myMapShape.Contains(aSp)) {
196 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
197 if (myMapShape.Contains(aSpR)) {
203 return !bRet; // true
205 //=======================================================================
206 //function : PrepareHistory
208 //=======================================================================
209 void GEOMAlgo_Builder::PrepareHistory()
211 if(myShape.IsNull()) {
215 Standard_Boolean bHasImage, bContainsSD;
216 TopAbs_ShapeEnum aType;
217 TopTools_MapOfShape aMS;
218 TopTools_ListIteratorOfListOfShape aIt;
219 TopTools_MapIteratorOfMapOfShape aItM;
222 GEOMAlgo_BuilderShape::PrepareHistory();
224 // 2. myMapShape - all shapes of result with theirs sub-shapes
225 MapShapes(myShape, myMapShape);
227 // 3. MS - all argument shapes with theirs sub-shapes
228 aIt.Initialize(myShapes);
229 for (; aIt.More(); aIt.Next()) {
230 const TopoDS_Shape& aSx=aIt.Value();
235 aItM.Initialize(aMS);
236 for (; aItM.More(); aItM.Next()) {
237 const TopoDS_Shape& aSx=aItM.Key();
238 aType=aSx.ShapeType();
239 //modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f
241 // 4.1 .myImagesResult
242 TopTools_ListOfShape aLSx;
244 bHasImage=myImages.HasImage(aSx);
246 if (myMapShape.Contains(aSx)) {
248 myImagesResult.Add(aSx, aLSx);
252 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
253 aIt.Initialize(aLSp);
254 for (; aIt.More(); aIt.Next()) {
255 const TopoDS_Shape& aSp=aIt.Value();
256 if (myMapShape.Contains(aSp)) {
260 myImagesResult.Add(aSx, aLSx);
263 //modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t
267 myHasDeleted=IsDeleted(aSx);//xx
270 if (!myHasGenerated || !myHasModified) {
271 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
272 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
273 //modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f
274 //bHasImage=myImages.HasImage(aSx);
275 //modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t
277 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
278 aIt.Initialize(aLSp);
279 for (; aIt.More(); aIt.Next()) {
280 const TopoDS_Shape& aSp=aIt.Value();
282 if (myMapShape.Contains(aSp)) {
283 bContainsSD=mySameDomainShapes.Contains(aSp);
285 if (!myHasGenerated) {
287 myHasGenerated=Standard_True;
290 if (!myHasModified) {
292 myHasModified=Standard_True;
295 } // if (myMapShape.Contains(aSp))
303 //=======================================================================
304 //function : MapShapes
306 //=======================================================================
307 void MapShapes(const TopoDS_Shape& theS,
308 TopTools_MapOfShape& theM)
311 TopoDS_Iterator anIt;
312 anIt.Initialize(theS);
313 for (; anIt.More(); anIt.Next()) {
314 const TopoDS_Shape& aSx=anIt.Value();
315 MapShapes(aSx, theM);