Warning, /include/opencascade/TopClass_SolidClassifier.gxx is written in an unsupported language. File is not indexed.
0001 // Copyright (c) 1995-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014
0015 //-- TopClass_SolidClassifier.gxx
0016
0017 #ifdef OCCT_DEBUG
0018 Standard_EXPORT Standard_Boolean TopClass_GettraceFC();
0019 #endif
0020
0021 #include <gp_Lin.hxx>
0022
0023 //extern void DrawSegment(const gp_Pnt& P1,const gp_Lin& L,const Standard_Real par);
0024 //extern Standard_Boolean DebugDrawSegment;
0025
0026 TopClass_SolidClassifier::TopClass_SolidClassifier()
0027 {
0028 }
0029
0030
0031 TopClass_SolidClassifier::TopClass_SolidClassifier(TheSolidExplorer& S,
0032 const gp_Pnt& P,
0033 const Standard_Real Tol) {
0034 Perform(S,P,Tol);
0035 }
0036
0037
0038 void TopClass_SolidClassifier::Perform(TheSolidExplorer& SolidExplorer,
0039 const gp_Pnt& P,
0040 const Standard_Real Tol) {
0041 #ifdef OCCT_DEBUG
0042 Standard_Boolean trace = TopClass_GettraceFC();
0043 #endif
0044
0045 myState = 0;
0046 if(SolidExplorer.Reject(P) == Standard_False) {
0047
0048 //-- There is no rejection between the Shape loaded in the SolidExplorer
0049 //-- and the point P.
0050
0051 gp_Lin L;
0052 Standard_Real Par;
0053 //-- We compute the intersection betwwen the line builded in the Solid Explorer
0054 //-- and the shape.
0055
0056 SolidExplorer.Segment(P,L,Par);
0057
0058 TheIntersection3d Intersector;
0059
0060 Standard_Real parmin = RealLast();
0061
0062 for(SolidExplorer.InitShell();
0063 SolidExplorer.MoreShell();
0064 SolidExplorer.NextShell()) {
0065
0066 if(SolidExplorer.RejectShell(L) == Standard_False) {
0067
0068 for(SolidExplorer.InitFace();
0069 SolidExplorer.MoreFace();
0070 SolidExplorer.NextFace()) {
0071
0072 if(SolidExplorer.RejectFace(L) == Standard_False) {
0073
0074 Intersector.Perform(L,Par,Tol,SolidExplorer.CurrentFace());
0075
0076 if(Intersector.IsDone()) {
0077 if(Intersector.HasAPoint()) {
0078 if(Intersector.WParameter() < parmin) {
0079
0080 parmin = Intersector.WParameter();
0081 if(Abs(parmin)<=Tol) {
0082 #ifdef OCCT_DEBUG
0083 if (trace) {
0084 //-- #########################################
0085 std::cout<<" parmin = "<<parmin<< " avec Par = "<<Par;
0086 std::cout<<" ds TopClass_SolidClassifier.gxx "<<std::endl;
0087 //-- #########################################
0088 }
0089 #endif
0090 myState = 2;
0091 myFace = Intersector.Face();
0092 }
0093 else if(Intersector.State()==TopAbs_IN) {
0094
0095 //-- The intersection point between the line and a face F
0096 // -- of the solid is in the face F
0097
0098 if(Intersector.Transition() == IntCurveSurface_Out) {
0099 //-- The line is going from inside the solid to outside
0100 //-- the solid.
0101 myState = 3; //-- IN --
0102 }
0103 else if(Intersector.Transition() == IntCurveSurface_In) {
0104 myState = 4; //-- OUT --
0105 }
0106 else {
0107 #ifdef OCCT_DEBUG
0108 std::cout<<"*Probleme ds TopClass_SolidClassifier.gxx"<<std::endl;
0109 #endif
0110 }
0111 myFace = Intersector.Face();
0112 }
0113 else if(Intersector.State()==TopAbs_ON) {
0114 //-- The intersection point between the line and a face F
0115 //-- of the solid is in the face F
0116
0117 if(Intersector.Transition() == IntCurveSurface_Out) {
0118 //-- The line is going from inside the solid to outside
0119 //-- the solid.
0120 myState = 3; //-- IN --
0121 }
0122 else if(Intersector.Transition() == IntCurveSurface_In) {
0123 myState = 4; //-- OUT --
0124 }
0125 else {
0126 #ifdef OCCT_DEBUG
0127 std::cout<<"*Probleme ds TopClass_SolidClassifier.gxx "<<std::endl;
0128 #endif
0129 }
0130 #ifdef OCCT_DEBUG
0131 //-- #########################################
0132 // cout<<" Intersector.State() == TopAbs_ON";
0133 // cout<<" ds TopClass_SolidClassifier.gxx "<<endl;
0134 // cout<<" Transition : ";
0135 // if(myState==3) { cout<<" IN "; }
0136 // else if(myState==4) { cout<<" OUT "; }
0137 // else { cout<<" PB "; }
0138 // cout<<endl;
0139 //-- #########################################
0140 #endif
0141 //-- myState = 2;
0142 myFace = Intersector.Face();
0143 }
0144 }
0145 else {
0146 //-- No point has been found by the intersector.
0147 //-- Or a Point has been found with a greater parameter.
0148 }
0149 } //-- Intersector Has a point
0150 else {
0151 //-- The intersector failed.
0152 }
0153 } //-- Face has not been rejected
0154 else {
0155 myState = 1;
0156 }
0157 }
0158 } //-- Exploration of the faces
0159 } //-- Shell has not been rejected
0160 else {
0161 myState=1;
0162 }
0163 } //-- Exploration of the shells
0164
0165 #ifdef OCCT_DEBUG
0166 //#################################################
0167 SolidExplorer.DumpSegment(P,L,parmin,State());
0168 //#################################################
0169 #endif
0170
0171 } //-- Solid has not been rejected
0172 else {
0173 myState = 1;
0174 }
0175 }
0176
0177
0178 TopAbs_State TopClass_SolidClassifier::State() const {
0179 if(myState==2) return(TopAbs_ON);
0180 if(myState==4) return(TopAbs_OUT); //--
0181 else if(myState==3) return(TopAbs_IN); //--
0182 return(TopAbs_OUT);
0183 }
0184
0185 TopoDS_Face TopClass_SolidClassifier::Face() const {
0186 return(myFace);
0187 }
0188
0189 Standard_Boolean TopClass_SolidClassifier::Rejected() const {
0190 return(myState==1);
0191 }
0192
0193
0194 Standard_Boolean TopClass_SolidClassifier::IsOnAFace() const {
0195 return(myState==2);
0196 }