1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 //-- TopClass_SolidClassifier.gxx
18 Standard_EXPORT Standard_Boolean TopClass_GettraceFC();
23 //extern void DrawSegment(const gp_Pnt& P1,const gp_Lin& L,const Standard_Real par);
24 //extern Standard_Boolean DebugDrawSegment;
26 TopClass_SolidClassifier::TopClass_SolidClassifier()
31 TopClass_SolidClassifier::TopClass_SolidClassifier(TheSolidExplorer& S,
33 const Standard_Real Tol) {
38 void TopClass_SolidClassifier::Perform(TheSolidExplorer& SolidExplorer,
40 const Standard_Real Tol) {
42 Standard_Boolean trace = TopClass_GettraceFC();
46 if(SolidExplorer.Reject(P) == Standard_False) {
48 //-- There is no rejection between the Shape loaded in the SolidExplorer
53 //-- We compute the intersection betwwen the line builded in the Solid Explorer
56 SolidExplorer.Segment(P,L,Par);
58 TheIntersection3d Intersector;
60 Standard_Real parmin = RealLast();
62 for(SolidExplorer.InitShell();
63 SolidExplorer.MoreShell();
64 SolidExplorer.NextShell()) {
66 if(SolidExplorer.RejectShell(L) == Standard_False) {
68 for(SolidExplorer.InitFace();
69 SolidExplorer.MoreFace();
70 SolidExplorer.NextFace()) {
72 if(SolidExplorer.RejectFace(L) == Standard_False) {
74 Intersector.Perform(L,Par,Tol,SolidExplorer.CurrentFace());
76 if(Intersector.IsDone()) {
77 if(Intersector.HasAPoint()) {
78 if(Intersector.WParameter() < parmin) {
80 parmin = Intersector.WParameter();
81 if(Abs(parmin)<=Tol) {
84 //-- #########################################
85 cout<<" parmin = "<<parmin<< " avec Par = "<<Par;
86 cout<<" ds TopClass_SolidClassifier.gxx "<<endl;
87 //-- #########################################
91 myFace = Intersector.Face();
93 else if(Intersector.State()==TopAbs_IN) {
95 //-- The intersection point between the line and a face F
96 // -- of the solid is in the face F
98 if(Intersector.Transition() == IntCurveSurface_Out) {
99 //-- The line is going from inside the solid to outside
101 myState = 3; //-- IN --
103 else if(Intersector.Transition() == IntCurveSurface_In) {
104 myState = 4; //-- OUT --
108 cout<<"*Probleme ds TopClass_SolidClassifier.gxx"<<endl;
111 myFace = Intersector.Face();
113 else if(Intersector.State()==TopAbs_ON) {
114 //-- The intersection point between the line and a face F
115 //-- of the solid is in the face F
117 if(Intersector.Transition() == IntCurveSurface_Out) {
118 //-- The line is going from inside the solid to outside
120 myState = 3; //-- IN --
122 else if(Intersector.Transition() == IntCurveSurface_In) {
123 myState = 4; //-- OUT --
127 cout<<"*Probleme ds TopClass_SolidClassifier.gxx "<<endl;
131 //-- #########################################
132 // cout<<" Intersector.State() == TopAbs_ON";
133 // cout<<" ds TopClass_SolidClassifier.gxx "<<endl;
134 // cout<<" Transition : ";
135 // if(myState==3) { cout<<" IN "; }
136 // else if(myState==4) { cout<<" OUT "; }
137 // else { cout<<" PB "; }
139 //-- #########################################
142 myFace = Intersector.Face();
146 //-- No point has been found by the intersector.
147 //-- Or a Point has been found with a greater parameter.
149 } //-- Intersector Has a point
151 //-- The intersector failed.
153 } //-- Face has not been rejected
158 } //-- Exploration of the faces
159 } //-- Shell has not been rejected
163 } //-- Exploration of the shells
166 //#################################################
167 SolidExplorer.DumpSegment(P,L,parmin,State());
168 //#################################################
171 } //-- Solid has not been rejected
178 TopAbs_State TopClass_SolidClassifier::State() const {
179 if(myState==2) return(TopAbs_ON);
180 if(myState==4) return(TopAbs_OUT); //--
181 else if(myState==3) return(TopAbs_IN); //--
185 TopoDS_Face TopClass_SolidClassifier::Face() const {
189 Standard_Boolean TopClass_SolidClassifier::Rejected() const {
194 Standard_Boolean TopClass_SolidClassifier::IsOnAFace() const {