1 // Copyright (C) 2007-2011 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
23 // Author: Peter KURNEV
25 #include <GEOMAlgo_Builder.hxx>
27 #include <GEOMAlgo_Tools3D.hxx>
29 #include <NMTTools_PaveFiller.hxx>
31 #include <NMTDS_ShapesDataStructure.hxx>
33 #include <Basics_OCCTVersion.hxx>
35 #include <TopoDS_Iterator.hxx>
37 #include <TopTools_ListOfShape.hxx>
38 #include <TopTools_ListIteratorOfListOfShape.hxx>
39 #include <TopTools_MapOfShape.hxx>
40 #include <TopTools_MapIteratorOfMapOfShape.hxx>
42 #include <IntTools_Context.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 #if OCC_VERSION_LARGE > 0x06050200
56 const Handle(IntTools_Context)& aCtx=pPF->Context();
58 IntTools_Context& aCtx=pPF->ChangeContext();
61 Standard_Boolean bHasImage, bToReverse;
62 TopAbs_ShapeEnum aType;
63 TopTools_ListIteratorOfListOfShape aIt;
71 bHasImage=myImages.HasImage(theS);
76 aType=theS.ShapeType();
78 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
79 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
80 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
82 for (; aIt.More(); aIt.Next()) {
83 const TopoDS_Shape& aSp=aIt.Value();
84 if (mySameDomainShapes.Contains(aSp)) {
85 if (myMapShape.Contains(aSp)) {
86 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
88 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
89 aSpR.Orientation(theS.Orientation());
92 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSpR, theS, aCtx);
98 myHistShapes.Append(aSpR);
106 //=======================================================================
107 //function : Modified
109 //=======================================================================
110 const TopTools_ListOfShape& GEOMAlgo_Builder::Modified(const TopoDS_Shape& theS)
112 NMTTools_PaveFiller* pPF=myPaveFiller;
113 #if OCC_VERSION_LARGE > 0x06050200
114 const Handle(IntTools_Context)& aCtx=pPF->Context();
116 IntTools_Context& aCtx=pPF->ChangeContext();
119 Standard_Boolean bHasImage, bToReverse;
120 TopAbs_ShapeEnum aType;
121 TopTools_ListIteratorOfListOfShape aIt;
123 myHistShapes.Clear();
129 bHasImage=myImages.HasImage(theS);
134 aType=theS.ShapeType();
136 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
137 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
138 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
139 aIt.Initialize(aLSp);
140 for (; aIt.More(); aIt.Next()) {
141 TopoDS_Shape aSp=aIt.Value();
142 if (!mySameDomainShapes.Contains(aSp)) {
143 if (myMapShape.Contains(aSp)) {
145 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
146 aSp.Orientation(theS.Orientation());
149 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx);
155 myHistShapes.Append(aSp);
163 //=======================================================================
164 //function : IsDeleted
166 //=======================================================================
167 Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
169 Standard_Boolean bRet, bHasImage, bContains;
170 TopAbs_ShapeEnum aType;
171 TopTools_ListIteratorOfListOfShape aIt;
179 bContains=myMapShape.Contains(theS);
184 bHasImage=myImages.HasImage(theS);
189 aType=theS.ShapeType();
190 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
191 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
192 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
193 aIt.Initialize(aLSp);
194 for (; aIt.More(); aIt.Next()) {
195 TopoDS_Shape aSp=aIt.Value();
197 if (!mySameDomainShapes.Contains(aSp)) {
198 if (myMapShape.Contains(aSp)) {
203 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
204 if (myMapShape.Contains(aSpR)) {
210 return !bRet; // true
212 //=======================================================================
213 //function : PrepareHistory
215 //=======================================================================
216 void GEOMAlgo_Builder::PrepareHistory()
218 if(myShape.IsNull()) {
222 Standard_Boolean bHasImage, bContainsSD;
223 TopAbs_ShapeEnum aType;
224 TopTools_MapOfShape aMS;
225 TopTools_ListIteratorOfListOfShape aIt;
226 TopTools_MapIteratorOfMapOfShape aItM;
229 GEOMAlgo_BuilderShape::PrepareHistory();
231 // 2. myMapShape - all shapes of result with theirs sub-shapes
232 MapShapes(myShape, myMapShape);
234 // 3. MS - all argument shapes with theirs sub-shapes
235 aIt.Initialize(myShapes);
236 for (; aIt.More(); aIt.Next()) {
237 const TopoDS_Shape& aSx=aIt.Value();
242 aItM.Initialize(aMS);
243 for (; aItM.More(); aItM.Next()) {
244 const TopoDS_Shape& aSx=aItM.Key();
245 aType=aSx.ShapeType();
246 //modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f
248 // 4.1 .myImagesResult
249 TopTools_ListOfShape aLSx;
251 bHasImage=myImages.HasImage(aSx);
253 if (myMapShape.Contains(aSx)) {
255 myImagesResult.Add(aSx, aLSx);
259 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
260 aIt.Initialize(aLSp);
261 for (; aIt.More(); aIt.Next()) {
262 const TopoDS_Shape& aSp=aIt.Value();
263 if (myMapShape.Contains(aSp)) {
267 myImagesResult.Add(aSx, aLSx);
270 //modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t
274 myHasDeleted=IsDeleted(aSx);//xx
277 if (!myHasGenerated || !myHasModified) {
278 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
279 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
280 //modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f
281 //bHasImage=myImages.HasImage(aSx);
282 //modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t
284 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
285 aIt.Initialize(aLSp);
286 for (; aIt.More(); aIt.Next()) {
287 const TopoDS_Shape& aSp=aIt.Value();
289 if (myMapShape.Contains(aSp)) {
290 bContainsSD=mySameDomainShapes.Contains(aSp);
292 if (!myHasGenerated) {
294 myHasGenerated=Standard_True;
297 if (!myHasModified) {
299 myHasModified=Standard_True;
302 } // if (myMapShape.Contains(aSp))
309 //=======================================================================
310 //function : MapShapes
312 //=======================================================================
313 void MapShapes(const TopoDS_Shape& theS,
314 TopTools_MapOfShape& theM)
317 TopoDS_Iterator anIt;
318 anIt.Initialize(theS);
319 for (; anIt.More(); anIt.Next()) {
320 const TopoDS_Shape& aSx=anIt.Value();
321 MapShapes(aSx, theM);