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_ClsfSurf.cxx
21 // Created: Wed Nov 22 10:41:47 2006
22 // Author: Peter KURNEV
26 #include <GEOMAlgo_ClsfBox.ixx>
27 #include <GeomAbs_SurfaceType.hxx>
28 #include <GEOMAlgo_SurfaceTools.hxx>
29 #include <TopAbs_ShapeEnum.hxx>
30 #include <TopTools_IndexedMapOfShape.hxx>
32 #include <TopoDS_Face.hxx>
34 #include <Geom_Surface.hxx>
35 #include <BRep_Tool.hxx>
36 #include <Geom_Plane.hxx>
41 #include <Geom_Plane.hxx>
43 //=======================================================================
46 //=======================================================================
47 GEOMAlgo_ClsfBox::GEOMAlgo_ClsfBox()
52 //=======================================================================
55 //=======================================================================
56 GEOMAlgo_ClsfBox::~GEOMAlgo_ClsfBox()
59 //=======================================================================
62 //=======================================================================
63 void GEOMAlgo_ClsfBox::SetBox(const TopoDS_Shape& aBox)
67 //=======================================================================
70 //=======================================================================
71 const TopoDS_Shape& GEOMAlgo_ClsfBox::Box() const
75 //=======================================================================
76 //function : CheckData
78 //=======================================================================
79 void GEOMAlgo_ClsfBox::CheckData()
81 Standard_Integer i, aNbF;
82 TopAbs_ShapeEnum aTypeShape;
83 TopAbs_Orientation aOr;
84 GeomAbs_SurfaceType aType;
85 Handle(Geom_Surface) aS;
86 TopTools_IndexedMapOfShape aMF;
91 myErrorStatus=10; // myBox=NULL
95 aTypeShape=myBox.ShapeType();
96 if (aTypeShape!=TopAbs_SOLID) {
97 myErrorStatus=11; // unallowed shape type
101 TopExp::MapShapes(myBox, TopAbs_FACE, aMF);
104 myErrorStatus=12; // wrong number of faces
108 for (i=1; i<=aNbF; ++i) {
109 const TopoDS_Face& aF=TopoDS::Face(aMF(i));
110 aOr=aF.Orientation();
111 if (!(aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED)) {
112 myErrorStatus=12; // unallowed orientation of face
116 aS=BRep_Tool::Surface(aF);
118 aType=myGAS[i-1].GetType();
119 if (!aType==GeomAbs_Plane) {
120 myErrorStatus=13; // unallowed surface type
124 if(aOr==TopAbs_REVERSED) {
129 Handle(Geom_Plane) aSR;
131 aPln=myGAS[i-1].Plane();
136 aSR=new Geom_Plane(aP, aD);
137 myGAS[i-1].Load(aSR);
141 //=======================================================================
144 //=======================================================================
145 void GEOMAlgo_ClsfBox::Perform()
149 const Standard_Integer aNbS=6;
150 Standard_Integer i, aNbON, aNbIN, iNext;
161 for(i=0; i<aNbS && iNext; i++) {
162 GEOMAlgo_SurfaceTools::GetState(myPnt, myGAS[i], myTolerance, aSt);
176 myState=TopAbs_UNKNOWN;
183 myState=TopAbs_UNKNOWN;
185 if (aNbON && aNbIN) {
188 else if (aNbIN==aNbS){
193 //=======================================================================
196 //=======================================================================
197 Standard_Boolean GEOMAlgo_ClsfBox::CanBeON(const Handle(Geom_Curve)& aC) const
199 return GEOMAlgo_Clsf::CanBeON(aC);
201 //=======================================================================
204 //=======================================================================
205 Standard_Boolean GEOMAlgo_ClsfBox::CanBeON(const Handle(Geom_Surface)& aS1) const
207 Standard_Boolean bRet;
208 GeomAbs_SurfaceType aST1;
209 GeomAdaptor_Surface aGAS1;
212 aST1=aGAS1.GetType();
213 bRet=(aST1==GeomAbs_Plane);