Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAlgoImpl / GEOMAlgo_Gluer2_2.cxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File:        GEOMAlgo_Gluer2_2.cxx
23 // Created:
24 // Author:      Peter KURNEV
25 //              <peter@PREFEX>
26 //
27 #include <GEOMAlgo_Gluer2.hxx>
28
29 #include <TopAbs_ShapeEnum.hxx>
30
31 #include <TopoDS_Iterator.hxx>
32 #include <TopoDS_Shape.hxx>
33
34 #include <BOPTools_AlgoTools.hxx>
35
36 #include <GEOMAlgo_BuilderShape.hxx>
37
38
39 //=======================================================================
40 //function : PrepareHistory
41 //purpose  :
42 //=======================================================================
43 void GEOMAlgo_Gluer2::PrepareHistory()
44 {
45   //
46   // 1. Clearing
47   GEOMAlgo_BuilderShape::PrepareHistory();
48   //
49   if(myShape.IsNull()) {
50     return;
51   }
52   //
53   GEOMAlgo_Gluer2::MapShapes(myShape, myMapShape);
54   //
55 }
56
57 //=======================================================================
58 //function : Generated
59 //purpose  :
60 //=======================================================================
61 const TopTools_ListOfShape& GEOMAlgo_Gluer2::Generated(const TopoDS_Shape& )
62 {
63   myHistShapes.Clear();
64   return myHistShapes;
65 }
66
67 //=======================================================================
68 //function : Modified
69 //purpose  :
70 //=======================================================================
71 const TopTools_ListOfShape& GEOMAlgo_Gluer2::Modified(const TopoDS_Shape& theS)
72 {
73   Standard_Boolean bIsDeleted, bHasImage, bToReverse;
74   TopAbs_ShapeEnum aType;
75   TopoDS_Shape aSim;
76   //
77   myHistShapes.Clear();
78   //
79   aType=theS.ShapeType();
80   if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
81         aType==TopAbs_FACE || aType==TopAbs_SOLID)) {
82     return myHistShapes;
83   }
84   //
85   bIsDeleted=IsDeleted(theS);
86   if (bIsDeleted) {
87     return myHistShapes;
88   }
89   //
90   bHasImage=myOrigins.IsBound(theS);
91   if (!bHasImage) {
92     return myHistShapes;
93   }
94   //
95   aSim=myOrigins.Find(theS);
96   if (aSim.IsSame(theS)){
97     return myHistShapes;
98   }
99   //
100   if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
101     aSim.Orientation(theS.Orientation());
102   }
103   else {
104     bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSim, theS, myContext);
105     if (bToReverse) {
106       aSim.Reverse();
107     }
108   }
109   //
110   myHistShapes.Append(aSim);
111   //
112   return myHistShapes;
113 }
114
115 //=======================================================================
116 //function : IsDeleted
117 //purpose  :
118 //=======================================================================
119 Standard_Boolean GEOMAlgo_Gluer2::IsDeleted(const TopoDS_Shape& theS)
120 {
121   Standard_Boolean bRet, bContains, bHasImage;
122   //
123   bRet=Standard_False;
124   //
125   if (theS.IsNull()) {
126     return !bRet; //true
127   }
128   //
129   bContains=myMapShape.Contains(theS);
130   if (bContains) {
131     return bRet; //false
132   }
133   //
134   bHasImage=myOrigins.IsBound(theS);
135   if (bHasImage) {
136     const TopoDS_Shape& aSim=myOrigins.Find(theS);
137     bContains=myMapShape.Contains(aSim);
138     if (bContains) {
139       return bRet; //false
140     }
141   }
142   //
143   return !bRet; //true
144 }
145
146 //=======================================================================
147 //function : MapShapes
148 //purpose  :
149 //=======================================================================
150 void GEOMAlgo_Gluer2::MapShapes(const TopoDS_Shape& theS,
151                                 TopTools_MapOfShape& theM)
152 {
153   TopoDS_Iterator aIt;
154   //
155   theM.Add(theS);
156   aIt.Initialize(theS);
157   for (; aIt.More(); aIt.Next()) {
158     const TopoDS_Shape& aSx=aIt.Value();
159     GEOMAlgo_Gluer2::MapShapes(aSx, theM);
160   }
161 }