1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 // File: GEOMAlgo_ClsfBox.cxx
24 // Created: Wed Nov 22 10:41:47 2006
25 // Author: Peter KURNEV
28 #include <GEOMAlgo_ClsfBox.hxx>
35 #include <GeomAbs_SurfaceType.hxx>
36 #include <Geom_Surface.hxx>
37 #include <Geom_Plane.hxx>
38 #include <TopAbs_ShapeEnum.hxx>
40 #include <TopoDS_Face.hxx>
43 #include <BRep_Tool.hxx>
46 #include <TopTools_IndexedMapOfShape.hxx>
48 #include <GEOMAlgo_SurfaceTools.hxx>
50 IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
52 //=======================================================================
55 //=======================================================================
56 GEOMAlgo_ClsfBox::GEOMAlgo_ClsfBox()
61 //=======================================================================
64 //=======================================================================
65 GEOMAlgo_ClsfBox::~GEOMAlgo_ClsfBox()
68 //=======================================================================
71 //=======================================================================
72 void GEOMAlgo_ClsfBox::SetBox(const TopoDS_Shape& aBox)
76 //=======================================================================
79 //=======================================================================
80 const TopoDS_Shape& GEOMAlgo_ClsfBox::Box() const
84 //=======================================================================
85 //function : CheckData
87 //=======================================================================
88 void GEOMAlgo_ClsfBox::CheckData()
90 Standard_Integer i, aNbF;
91 TopAbs_ShapeEnum aTypeShape;
92 TopAbs_Orientation aOr;
93 GeomAbs_SurfaceType aType;
94 Handle(Geom_Surface) aS;
95 TopTools_IndexedMapOfShape aMF;
100 myErrorStatus=10; // myBox=NULL
104 aTypeShape=myBox.ShapeType();
105 if (aTypeShape!=TopAbs_SOLID) {
106 myErrorStatus=11; // unallowed shape type
110 TopExp::MapShapes(myBox, TopAbs_FACE, aMF);
113 myErrorStatus=12; // wrong number of faces
117 for (i=1; i<=aNbF; ++i) {
118 const TopoDS_Face& aF=TopoDS::Face(aMF(i));
119 aOr=aF.Orientation();
120 if (!(aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED)) {
121 myErrorStatus=12; // unallowed orientation of face
125 aS=BRep_Tool::Surface(aF);
127 aType=myGAS[i-1].GetType();
128 if (!aType==GeomAbs_Plane) {
129 myErrorStatus=13; // unallowed surface type
133 if(aOr==TopAbs_REVERSED) {
138 Handle(Geom_Plane) aSR;
140 aPln=myGAS[i-1].Plane();
141 aPos=aPln.Position();
145 // Is aPos is not direct, aD is already a reversed direction.
150 aSR=new Geom_Plane(aP, aD);
151 myGAS[i-1].Load(aSR);
155 //=======================================================================
158 //=======================================================================
159 void GEOMAlgo_ClsfBox::Perform()
163 const Standard_Integer aNbS=6;
164 Standard_Integer i, aNbON, aNbIN, iNext;
175 for(i=0; i<aNbS && iNext; i++) {
176 GEOMAlgo_SurfaceTools::GetState(myPnt, myGAS[i], myTolerance, aSt);
190 myState=TopAbs_UNKNOWN;
197 myState=TopAbs_UNKNOWN;
199 if (aNbON && aNbIN) {
202 else if (aNbIN==aNbS){
207 //=======================================================================
210 //=======================================================================
211 Standard_Boolean GEOMAlgo_ClsfBox::CanBeON(const Handle(Geom_Curve)& aC) const
213 return GEOMAlgo_Clsf::CanBeON(aC);
215 //=======================================================================
218 //=======================================================================
219 Standard_Boolean GEOMAlgo_ClsfBox::CanBeON(const Handle(Geom_Surface)& aS1) const
221 Standard_Boolean bRet;
222 GeomAbs_SurfaceType aST1;
223 GeomAdaptor_Surface aGAS1;
226 aST1=aGAS1.GetType();
227 bRet=(aST1==GeomAbs_Plane);