Salome HOME
Fix regression: storeViewParameters() does not work for OCC view
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ClsfSolid.cxx
1 //  Copyright (C) 2007-2010  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.ixx>
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 //=======================================================================
34 //function : 
35 //purpose  : 
36 //=======================================================================
37   GEOMAlgo_ClsfSolid::GEOMAlgo_ClsfSolid()
38 :
39   GEOMAlgo_Clsf()
40 {
41   myPClsf=NULL;
42 }
43 //=======================================================================
44 //function : ~
45 //purpose  : 
46 //=======================================================================
47   GEOMAlgo_ClsfSolid::~GEOMAlgo_ClsfSolid()
48 {
49   if (myPClsf) {
50     BRepClass3d_SolidClassifier* pSC;
51     //
52     pSC=(BRepClass3d_SolidClassifier*)myPClsf;
53     delete pSC;
54   }
55 }
56 //=======================================================================
57 //function : SetShape
58 //purpose  : 
59 //=======================================================================
60   void GEOMAlgo_ClsfSolid::SetShape(const TopoDS_Shape& aS)
61 {
62   myShape=aS;
63 }
64 //=======================================================================
65 //function : Shape
66 //purpose  : 
67 //=======================================================================
68   const TopoDS_Shape& GEOMAlgo_ClsfSolid::Shape()const
69 {
70   return myShape;
71 }
72 //=======================================================================
73 //function : CheckData
74 //purpose  : 
75 //=======================================================================
76   void GEOMAlgo_ClsfSolid::CheckData()
77 {
78   myErrorStatus=0;
79   //
80   BRepClass3d_SolidClassifier* pSC;
81   TopAbs_ShapeEnum aType;
82   BRep_Builder aBB;
83   TopoDS_Solid aS;
84   //
85   if (myShape.IsNull()) {
86     myErrorStatus=10; // mySolid=NULL
87     return;
88   }
89   //
90   aType=myShape.ShapeType();
91   if (!(aType==TopAbs_SOLID || aType==TopAbs_SHELL)) {
92     myErrorStatus=12; 
93     return;
94   }
95   //
96   //===
97   if (aType==TopAbs_SOLID) {
98     aS=TopoDS::Solid(myShape);
99   }
100   else {
101     aBB.MakeSolid(aS);
102     aBB.Add(aS, myShape);
103   }
104   //
105   if (myPClsf) {
106     pSC=(BRepClass3d_SolidClassifier*)myPClsf;
107     delete pSC;
108   }
109   //
110   pSC=new BRepClass3d_SolidClassifier(aS);
111   myPClsf=pSC;
112 }
113 //=======================================================================
114 //function : Perform
115 //purpose  : 
116 //=======================================================================
117   void GEOMAlgo_ClsfSolid::Perform()
118 {
119   myErrorStatus=0;
120   //
121   if (!myPClsf) {
122     myErrorStatus=11;
123     return;
124   }
125   //
126   BRepClass3d_SolidClassifier* pSC;
127   //
128   pSC=(BRepClass3d_SolidClassifier*)myPClsf;
129   pSC->Perform(myPnt, myTolerance);
130   myState=pSC->State();
131 }
132 //
133 // myErrorStatus :
134 //
135 // 10 - mySolid=NULL
136 // 11 - myPClsf=NULL
137 // 12 - unallowed type of myShape
138