0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / TopClass / TopClass_Classifier3d.gxx
CommitLineData
b311480e 1// Created on: 1994-03-30
2// Created by: Laurent BUCHARD
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17//======================================================================
18TopClass_Classifier3d::TopClass_Classifier3d() : isSet(Standard_False)
19{
20}
21
22//======================================================================
23void TopClass_Classifier3d::Reset(const gp_Lin& L,
498ce76b 24 const Standard_Real,
7fd59977 25 const Standard_Real Tol) {
26 myLin = L;
27 myParam = RealLast();
28 myTolerance = Tol;
29 myState = TopAbs_UNKNOWN;
30 isSet = Standard_True;
31}
32//======================================================================
33#include <IntCurveSurface_IntersectionPoint.hxx>
34#include <IntCurveSurface_TransitionOnCurve.hxx>
35
36void TopClass_Classifier3d::Compare(const TopoDS_Face& Face,
498ce76b 37 const TopAbs_Orientation) {
7fd59977 38 if(!isSet) {
0797d9d3 39#ifdef OCCT_DEBUG
7fd59977 40 cout<<" Call to TopClass_Classifier3d::Compare without a Reset ! ";
63c629aa 41#endif
7fd59977 42 return;
43 }
44
45 hasIntersect = Standard_False;
46 myIntersector.Perform(myLin,myParam,myTolerance,Face);
47 if(myIntersector.IsDone()) {
48 if(myIntersector.HasAPoint()) {
49 hasIntersect = Standard_True;
50 if(myIntersector.WParameter() < myParam) {
51 myParam = myIntersector.WParameter();
52 myFace = myIntersector.Face();
53 if(Abs(myParam)<=myTolerance) {
54 //-- #########################################
0797d9d3 55#ifdef OCCT_DEBUG
7fd59977 56 cout<<" myParam = "<<myParam<<" ds TopClass_Classifier3d.gxx "<<endl;
63c629aa 57#endif
7fd59977 58 //-- #########################################
59 myState = TopAbs_ON;
60 }
61 else {
62 //-- The intersection point between the line and a face F of the solid
63 //-- is in the face F or On a boundary of the face
64 if(myIntersector.Transition() == IntCurveSurface_Out) {
65 //-- The line is going from inside the solid to outside the solid.
66 myState = TopAbs_IN;
67 }
68 else if(myIntersector.Transition() == IntCurveSurface_In) {
69 myState = TopAbs_OUT;
70 }
0797d9d3 71#ifdef OCCT_DEBUG
63c629aa 72 else {
7fd59977 73 cout<<" -------- Probleme ds TopClass_Classifier3d.gxx "<<endl;
63c629aa 74 }
75#endif
7fd59977 76 }
77 }
78 else {
79 //-- No point has been found by the myIntersector.
80 //-- Or a Point has been found with a greater parameter.
81 }
82 } //-- myIntersector Has a point
83 else {
84 //-- The myIntersector failed.
85 }
86 } //-- Face has not been rejected
87}