1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: GEOMAlgo_Builder_4.cxx
22 // Author: Peter KURNEV
24 #include <GEOMAlgo_Builder.hxx>
26 #include <TopoDS_Iterator.hxx>
28 #include <TopTools_ListOfShape.hxx>
29 #include <TopTools_ListIteratorOfListOfShape.hxx>
30 #include <TopTools_MapOfShape.hxx>
31 #include <TopTools_MapIteratorOfMapOfShape.hxx>
33 #include <IntTools_Context.hxx>
35 #include <NMTDS_ShapesDataStructure.hxx>
37 #include <NMTTools_PaveFiller.hxx>
39 #include <GEOMAlgo_Tools3D.hxx>
42 void MapShapes(const TopoDS_Shape& aS,
43 TopTools_MapOfShape& aM);
45 //=======================================================================
46 //function : Generated
48 //=======================================================================
49 const TopTools_ListOfShape& GEOMAlgo_Builder::Generated(const TopoDS_Shape& theS)
51 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
52 NMTTools_PaveFiller* pPF=myPaveFiller;
53 IntTools_Context& aCtx=pPF->ChangeContext();
55 Standard_Boolean bHasImage, bToReverse;
56 TopAbs_ShapeEnum aType;
57 TopTools_ListIteratorOfListOfShape aIt;
65 bHasImage=myImages.HasImage(theS);
70 aType=theS.ShapeType();
72 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
73 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
74 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
76 for (; aIt.More(); aIt.Next()) {
77 const TopoDS_Shape& aSp=aIt.Value();
78 if (mySameDomainShapes.Contains(aSp)) {
79 if (myMapShape.Contains(aSp)) {
80 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
82 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
83 aSpR.Orientation(theS.Orientation());
86 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSpR, theS, aCtx);
92 myHistShapes.Append(aSpR);
100 //=======================================================================
101 //function : Modified
103 //=======================================================================
104 const TopTools_ListOfShape& GEOMAlgo_Builder::Modified(const TopoDS_Shape& theS)
106 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
107 NMTTools_PaveFiller* pPF=myPaveFiller;
108 IntTools_Context& aCtx=pPF->ChangeContext();
110 Standard_Boolean bHasImage, bToReverse;
111 TopAbs_ShapeEnum aType;
112 TopTools_ListIteratorOfListOfShape aIt;
114 myHistShapes.Clear();
120 bHasImage=myImages.HasImage(theS);
125 aType=theS.ShapeType();
127 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
128 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
129 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
130 aIt.Initialize(aLSp);
131 for (; aIt.More(); aIt.Next()) {
132 TopoDS_Shape aSp=aIt.Value();
133 if (!mySameDomainShapes.Contains(aSp)) {
134 if (myMapShape.Contains(aSp)) {
136 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
137 aSp.Orientation(theS.Orientation());
140 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx);
146 myHistShapes.Append(aSp);
154 //=======================================================================
155 //function : IsDeleted
157 //=======================================================================
158 Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
160 Standard_Boolean bRet, bHasImage, bContains;
161 TopAbs_ShapeEnum aType;
162 TopTools_ListIteratorOfListOfShape aIt;
170 bContains=myMapShape.Contains(theS);
175 bHasImage=myImages.HasImage(theS);
180 aType=theS.ShapeType();
181 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
182 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
183 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
184 aIt.Initialize(aLSp);
185 for (; aIt.More(); aIt.Next()) {
186 TopoDS_Shape aSp=aIt.Value();
188 if (!mySameDomainShapes.Contains(aSp)) {
189 if (myMapShape.Contains(aSp)) {
194 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
195 if (myMapShape.Contains(aSpR)) {
201 return !bRet; // true
203 //=======================================================================
204 //function : PrepareHistory
206 //=======================================================================
207 void GEOMAlgo_Builder::PrepareHistory()
209 if(myShape.IsNull()) {
213 Standard_Boolean bHasImage, bContainsSD;
214 TopAbs_ShapeEnum aType;
215 TopTools_MapOfShape aMS;
216 TopTools_ListIteratorOfListOfShape aIt;
217 TopTools_MapIteratorOfMapOfShape aItM;
220 GEOMAlgo_BuilderShape::PrepareHistory();
222 // 2. myMapShape - all shapes of result with theirs sub-shapes
223 MapShapes(myShape, myMapShape);
225 // 3. MS - all argument shapes with theirs sub-shapes
226 aIt.Initialize(myShapes);
227 for (; aIt.More(); aIt.Next()) {
228 const TopoDS_Shape& aSx=aIt.Value();
233 aItM.Initialize(aMS);
234 for (; aItM.More(); aItM.Next()) {
235 const TopoDS_Shape& aSx=aItM.Key();
236 aType=aSx.ShapeType();
237 //modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f
239 // 4.1 .myImagesResult
240 TopTools_ListOfShape aLSx;
242 bHasImage=myImages.HasImage(aSx);
244 if (myMapShape.Contains(aSx)) {
246 myImagesResult.Add(aSx, aLSx);
250 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
251 aIt.Initialize(aLSp);
252 for (; aIt.More(); aIt.Next()) {
253 const TopoDS_Shape& aSp=aIt.Value();
254 if (myMapShape.Contains(aSp)) {
258 myImagesResult.Add(aSx, aLSx);
261 //modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t
265 myHasDeleted=IsDeleted(aSx);//xx
268 if (!myHasGenerated || !myHasModified) {
269 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
270 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
271 //modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f
272 //bHasImage=myImages.HasImage(aSx);
273 //modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t
275 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
276 aIt.Initialize(aLSp);
277 for (; aIt.More(); aIt.Next()) {
278 const TopoDS_Shape& aSp=aIt.Value();
280 if (myMapShape.Contains(aSp)) {
281 bContainsSD=mySameDomainShapes.Contains(aSp);
283 if (!myHasGenerated) {
285 myHasGenerated=Standard_True;
288 if (!myHasModified) {
290 myHasModified=Standard_True;
293 } // if (myMapShape.Contains(aSp))
301 //=======================================================================
302 //function : MapShapes
304 //=======================================================================
305 void MapShapes(const TopoDS_Shape& theS,
306 TopTools_MapOfShape& theM)
309 TopoDS_Iterator anIt;
310 anIt.Initialize(theS);
311 for (; anIt.More(); anIt.Next()) {
312 const TopoDS_Shape& aSx=anIt.Value();
313 MapShapes(aSx, theM);