1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 // NIZNHY-PKV Thu Apr 11 10:42:14 2002
20 #include <BOP_SolidClassifier.ixx>
22 #include <BRepClass3d_SolidClassifier.hxx>
24 //=======================================================================
27 //=======================================================================
28 BOP_SolidClassifier::BOP_SolidClassifier()
33 //=======================================================================
36 //=======================================================================
37 void BOP_SolidClassifier::Clear()
40 myClassifierMap.Clear();
41 myState = TopAbs_UNKNOWN;
46 //=======================================================================
47 //function : LoadSolid
49 //=======================================================================
50 void BOP_SolidClassifier::LoadSolid(const TopoDS_Solid& SOL)
52 Standard_Boolean found;
54 found = myClassifierMap.Contains(SOL);
56 myPClassifier = new BRepClass3d_SolidClassifier(SOL);
57 myClassifierMap.Add(SOL, myPClassifier);
60 myPClassifier = myClassifierMap.ChangeFromKey(SOL);
64 //=======================================================================
67 //=======================================================================
68 TopAbs_State BOP_SolidClassifier::Classify (const TopoDS_Solid& SOL,
70 const Standard_Real Tol)
73 myState = TopAbs_UNKNOWN;
77 if (myPClassifier == NULL) {
81 myPClassifier->Perform(P,Tol);
82 myState = myPClassifier->State();
83 const TopoDS_Shape& fres = myPClassifier->Face();
85 // NYI : in case of removal of EXTERNAL and INTERNAL faces by the
86 // classifier BRepClass3d_SolidClassifier, process these faces
87 // to generate state ON/Solid when the point is IN/face INTERNAL or EXTERNAL
91 TopAbs_Orientation ofres;
93 ofres = fres.Orientation();
95 if ( ofres == TopAbs_EXTERNAL ) {
96 if ( myState == TopAbs_IN ) {
99 else if ( myState == TopAbs_OUT ){
100 myState = TopAbs_OUT;
102 else if ( myState == TopAbs_ON ){
105 else if ( myState == TopAbs_UNKNOWN ){
106 myState = TopAbs_OUT;
110 else if ( ofres == TopAbs_INTERNAL ) {
111 if ( myState == TopAbs_IN ) {
114 else if ( myState == TopAbs_OUT) {
117 else if ( myState == TopAbs_ON ) {
120 else if ( myState == TopAbs_UNKNOWN ) {
128 //=======================================================================
129 //function : LoadShell
131 //=======================================================================
132 void BOP_SolidClassifier::LoadShell(const TopoDS_Shell& SHE)
134 Standard_Boolean found;
136 found = myClassifierMap.Contains (SHE);
139 myBuilder.MakeSolid(mySolid);
140 myBuilder.Add(mySolid,SHE);
141 TopoDS_Shell* pshe = (TopoDS_Shell*)&SHE;
142 (*pshe).Free(Standard_True);
144 myPClassifier = new BRepClass3d_SolidClassifier(mySolid);
145 myClassifierMap.Add(SHE, myPClassifier);
148 myPClassifier = myClassifierMap.ChangeFromKey(SHE);
152 //=======================================================================
153 //function : Classify
155 //=======================================================================
156 TopAbs_State BOP_SolidClassifier::Classify (const TopoDS_Shell& SHE,
158 const Standard_Real Tol)
160 myPClassifier = NULL;
161 myState = TopAbs_UNKNOWN;
165 if (myPClassifier == NULL) {
169 myPClassifier->Perform(P,Tol);
170 myState = myPClassifier->State();
174 //=======================================================================
177 //=======================================================================
178 TopAbs_State BOP_SolidClassifier::State() const
183 //=======================================================================
186 //=======================================================================
187 void BOP_SolidClassifier::Destroy()
189 Standard_Integer i, aNb;
191 aNb=myClassifierMap.Extent();
192 for (i=1; i<=aNb; ++i) {
193 BRepClass3d_SolidClassifier* pC=myClassifierMap(i);
196 myClassifierMap.Clear();