Salome HOME
Mantis issue 0021541: EDF 2213 GEOM: Filling accuracy
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ClsfSolid.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File:        GEOMAlgo_ClsfSolid.cxx
21 // Created:     Mon Jan 29 10:35:46 2007
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24 //
25 #include <GEOMAlgo_ClsfSolid.hxx>
26
27 #include <TopAbs_ShapeEnum.hxx>
28 #include <TopoDS.hxx>
29 #include <TopoDS_Solid.hxx>
30 #include <BRep_Builder.hxx>
31 #include <BRepClass3d_SolidClassifier.hxx>
32
33 IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf)
34 IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf)
35
36 //=======================================================================
37 //function :
38 //purpose  :
39 //=======================================================================
40   GEOMAlgo_ClsfSolid::GEOMAlgo_ClsfSolid()
41 :
42   GEOMAlgo_Clsf()
43 {
44   myPClsf=NULL;
45 }
46 //=======================================================================
47 //function : ~
48 //purpose  :
49 //=======================================================================
50   GEOMAlgo_ClsfSolid::~GEOMAlgo_ClsfSolid()
51 {
52   if (myPClsf) {
53     BRepClass3d_SolidClassifier* pSC;
54     //
55     pSC=(BRepClass3d_SolidClassifier*)myPClsf;
56     delete pSC;
57   }
58 }
59 //=======================================================================
60 //function : SetShape
61 //purpose  :
62 //=======================================================================
63   void GEOMAlgo_ClsfSolid::SetShape(const TopoDS_Shape& aS)
64 {
65   myShape=aS;
66 }
67 //=======================================================================
68 //function : Shape
69 //purpose  :
70 //=======================================================================
71   const TopoDS_Shape& GEOMAlgo_ClsfSolid::Shape()const
72 {
73   return myShape;
74 }
75 //=======================================================================
76 //function : CheckData
77 //purpose  :
78 //=======================================================================
79   void GEOMAlgo_ClsfSolid::CheckData()
80 {
81   myErrorStatus=0;
82   //
83   BRepClass3d_SolidClassifier* pSC;
84   TopAbs_ShapeEnum aType;
85   BRep_Builder aBB;
86   TopoDS_Solid aS;
87   //
88   if (myShape.IsNull()) {
89     myErrorStatus=10; // mySolid=NULL
90     return;
91   }
92   //
93   aType=myShape.ShapeType();
94   if (!(aType==TopAbs_SOLID || aType==TopAbs_SHELL)) {
95     myErrorStatus=12;
96     return;
97   }
98   //
99   //===
100   if (aType==TopAbs_SOLID) {
101     aS=TopoDS::Solid(myShape);
102   }
103   else {
104     aBB.MakeSolid(aS);
105     aBB.Add(aS, myShape);
106   }
107   //
108   if (myPClsf) {
109     pSC=(BRepClass3d_SolidClassifier*)myPClsf;
110     delete pSC;
111   }
112   //
113   pSC=new BRepClass3d_SolidClassifier(aS);
114   myPClsf=pSC;
115 }
116 //=======================================================================
117 //function : Perform
118 //purpose  :
119 //=======================================================================
120   void GEOMAlgo_ClsfSolid::Perform()
121 {
122   myErrorStatus=0;
123   //
124   if (!myPClsf) {
125     myErrorStatus=11;
126     return;
127   }
128   //
129   BRepClass3d_SolidClassifier* pSC;
130   //
131   pSC=(BRepClass3d_SolidClassifier*)myPClsf;
132   pSC->Perform(myPnt, myTolerance);
133   myState=pSC->State();
134 }
135 //
136 // myErrorStatus :
137 //
138 // 10 - mySolid=NULL
139 // 11 - myPClsf=NULL
140 // 12 - unallowed type of myShape
141