1 // Copyright (C) 2007-2012 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 NMTTools_PaveFiller* pPF=myPaveFiller;
55 const Handle(IntTools_Context)& aCtx=pPF->Context();
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 NMTTools_PaveFiller* pPF=myPaveFiller;
109 const Handle(IntTools_Context)& aCtx=pPF->Context();
111 Standard_Boolean bHasImage, bToReverse;
112 TopAbs_ShapeEnum aType;
113 TopTools_ListIteratorOfListOfShape aIt;
115 myHistShapes.Clear();
121 bHasImage=myImages.HasImage(theS);
126 aType=theS.ShapeType();
128 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
129 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
130 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
131 aIt.Initialize(aLSp);
132 for (; aIt.More(); aIt.Next()) {
133 TopoDS_Shape aSp=aIt.Value();
134 if (!mySameDomainShapes.Contains(aSp)) {
135 if (myMapShape.Contains(aSp)) {
137 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
138 aSp.Orientation(theS.Orientation());
141 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx);
147 myHistShapes.Append(aSp);
155 //=======================================================================
156 //function : IsDeleted
158 //=======================================================================
159 Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
161 Standard_Boolean bRet, bHasImage, bContains;
162 TopAbs_ShapeEnum aType;
163 TopTools_ListIteratorOfListOfShape aIt;
171 bContains=myMapShape.Contains(theS);
176 bHasImage=myImages.HasImage(theS);
181 aType=theS.ShapeType();
182 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
183 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
184 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
185 aIt.Initialize(aLSp);
186 for (; aIt.More(); aIt.Next()) {
187 TopoDS_Shape aSp=aIt.Value();
189 if (!mySameDomainShapes.Contains(aSp)) {
190 if (myMapShape.Contains(aSp)) {
195 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
196 if (myMapShape.Contains(aSpR)) {
202 return !bRet; // true
204 //=======================================================================
205 //function : PrepareHistory
207 //=======================================================================
208 void GEOMAlgo_Builder::PrepareHistory()
210 if(myShape.IsNull()) {
214 Standard_Boolean bHasImage, bContainsSD;
215 TopAbs_ShapeEnum aType;
216 TopTools_MapOfShape aMS;
217 TopTools_ListIteratorOfListOfShape aIt;
218 TopTools_MapIteratorOfMapOfShape aItM;
221 GEOMAlgo_BuilderShape::PrepareHistory();
223 // 2. myMapShape - all shapes of result with theirs sub-shapes
224 MapShapes(myShape, myMapShape);
226 // 3. MS - all argument shapes with theirs sub-shapes
227 aIt.Initialize(myShapes);
228 for (; aIt.More(); aIt.Next()) {
229 const TopoDS_Shape& aSx=aIt.Value();
234 aItM.Initialize(aMS);
235 for (; aItM.More(); aItM.Next()) {
236 const TopoDS_Shape& aSx=aItM.Key();
237 aType=aSx.ShapeType();
238 //modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f
240 // 4.1 .myImagesResult
241 TopTools_ListOfShape aLSx;
243 bHasImage=myImages.HasImage(aSx);
245 if (myMapShape.Contains(aSx)) {
247 myImagesResult.Add(aSx, aLSx);
251 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
252 aIt.Initialize(aLSp);
253 for (; aIt.More(); aIt.Next()) {
254 const TopoDS_Shape& aSp=aIt.Value();
255 if (myMapShape.Contains(aSp)) {
259 myImagesResult.Add(aSx, aLSx);
262 //modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t
266 myHasDeleted=IsDeleted(aSx);//xx
269 if (!myHasGenerated || !myHasModified) {
270 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
271 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
272 //modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f
273 //bHasImage=myImages.HasImage(aSx);
274 //modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t
276 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
277 aIt.Initialize(aLSp);
278 for (; aIt.More(); aIt.Next()) {
279 const TopoDS_Shape& aSp=aIt.Value();
281 if (myMapShape.Contains(aSp)) {
282 bContainsSD=mySameDomainShapes.Contains(aSp);
284 if (!myHasGenerated) {
286 myHasGenerated=Standard_True;
289 if (!myHasModified) {
291 myHasModified=Standard_True;
294 } // if (myMapShape.Contains(aSp))
302 //=======================================================================
303 //function : MapShapes
305 //=======================================================================
306 void MapShapes(const TopoDS_Shape& theS,
307 TopTools_MapOfShape& theM)
310 TopoDS_Iterator anIt;
311 anIt.Initialize(theS);
312 for (; anIt.More(); anIt.Next()) {
313 const TopoDS_Shape& aSx=anIt.Value();
314 MapShapes(aSx, theM);