1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File: GEOMAlgo_WESScaler.cxx
25 #include <GEOMAlgo_WESScaler.hxx>
28 #include <gp_Trsf.hxx>
30 #include <TopoDS_Face.hxx>
31 #include <TopoDS_Iterator.hxx>
32 #include <TopoDS_Wire.hxx>
33 #include <BRep_Builder.hxx>
35 #include <TopTools_ListOfShape.hxx>
36 #include <TopTools_ListIteratorOfListOfShape.hxx>
38 #include <BRepBuilderAPI_Transform.hxx>
41 //=======================================================================
44 //=======================================================================
45 GEOMAlgo_WESScaler::GEOMAlgo_WESScaler()
51 //=======================================================================
54 //=======================================================================
55 GEOMAlgo_WESScaler::~GEOMAlgo_WESScaler()
58 //=======================================================================
61 //=======================================================================
62 void GEOMAlgo_WESScaler::SetScale (const Standard_Real aScale)
66 //=======================================================================
69 //=======================================================================
70 Standard_Real GEOMAlgo_WESScaler::Scale()const
74 //=======================================================================
77 //=======================================================================
78 void GEOMAlgo_WESScaler::SetFace(const TopoDS_Face& aF)
82 //=======================================================================
85 //=======================================================================
86 const TopoDS_Face& GEOMAlgo_WESScaler::Face()const
90 //=======================================================================
93 //=======================================================================
94 void GEOMAlgo_WESScaler::SetEdges(const TopTools_ListOfShape& aLE)
98 //=======================================================================
101 //=======================================================================
102 const TopTools_ListOfShape& GEOMAlgo_WESScaler::Edges()const
106 //=======================================================================
107 // function: FaceScaled
109 //=======================================================================
110 const TopoDS_Face& GEOMAlgo_WESScaler::FaceScaled()const
114 //=======================================================================
115 // function: EdgesScaled
117 //=======================================================================
118 const TopTools_ListOfShape& GEOMAlgo_WESScaler::EdgesScaled()const
120 return myEdgesScaled;
122 //=======================================================================
125 //=======================================================================
126 const TopoDS_Shape& GEOMAlgo_WESScaler::Image (const TopoDS_Shape& aS) const
128 if (myImages.IsBound(aS)) {
129 return myImages.Find(aS);
133 //=======================================================================
136 //=======================================================================
137 const TopoDS_Shape& GEOMAlgo_WESScaler::Origin (const TopoDS_Shape& aS) const
139 if (myOrigins.IsBound(aS)) {
140 return myOrigins.Find(aS);
144 //=======================================================================
147 //=======================================================================
148 const GEOMAlgo_DataMapOfOrientedShapeShape& GEOMAlgo_WESScaler::Images () const
152 //=======================================================================
155 //=======================================================================
156 const GEOMAlgo_DataMapOfOrientedShapeShape& GEOMAlgo_WESScaler::Origins () const
160 //=======================================================================
161 // function: CheckData
163 //=======================================================================
164 void GEOMAlgo_WESScaler::CheckData()
168 if(myFace.IsNull()) {
172 if(!myEdges.Extent()) {
180 //=======================================================================
183 //=======================================================================
184 void GEOMAlgo_WESScaler::Perform()
186 Standard_Boolean bIsDone;
190 TopAbs_Orientation aOr;
191 TopoDS_Shape aFC, aFR, aER;
193 TopoDS_Iterator aItS;
195 TopTools_ListIteratorOfListOfShape aIt;
205 myEdgesScaled.Clear();
208 aFC=myFace.EmptyCopied();
211 aIt.Initialize(myEdges);
212 for (; aIt.More(); aIt.Next()) {
213 const TopoDS_Shape& aE=aIt.Value();
218 aItS.Initialize(myFace);
219 for (; aItS.More(); aItS.Next()) {
220 const TopoDS_Shape& aW=aItS.Value();
225 aP.SetCoord(0.,0.,0.);
226 aTrsf.SetScale(aP, myScale);
228 BRepBuilderAPI_Transform aBT(aTrsf);
230 bIsDone=aBT.IsDone();
236 const TopoDS_Shape& aSR=aBT.Shape();
238 // Refined image face FR
239 aFR=aSR.EmptyCopied();
240 aItS.Initialize(aSR);
241 for (i=0; aItS.More(); aItS.Next(),++i) {
242 const TopoDS_Shape& aWR=aItS.Value();
247 myFaceScaled=*((TopoDS_Face*)&aFR);
249 // 3. Fill Images, Origins, EdgesScaled
250 aIt.Initialize(myEdges);
251 for (; aIt.More(); aIt.Next()) {
252 const TopoDS_Shape& aE=aIt.Value();
253 aOr=aE.Orientation();
255 aER=aBT.ModifiedShape(aE);
261 aER.Orientation(aOr);
262 myImages.Bind(aE, aER);
263 myOrigins.Bind(aER, aE);
265 myEdgesScaled.Append(aER);