1 // File: MeshVS_SensitiveFace.cxx
2 // Created: Mon Sep 29 2003
3 // Author: Alexander SOLOVYOV and Sergey LITONIN
4 // Copyright: Open CASCADE 2003
6 #include <MeshVS_SensitiveFace.ixx>
8 #include <TColgp_Array1OfPnt.hxx>
9 #include <Select3D_Projector.hxx>
10 #include <CSLib_Class2d.hxx>
11 #include <TopLoc_Location.hxx>
13 //=======================================================================
14 // name : MeshVS_SensitiveFace::MeshVS_SensitiveFace
16 //=======================================================================
17 MeshVS_SensitiveFace::MeshVS_SensitiveFace (
18 const Handle(SelectBasics_EntityOwner)& theOwnerId,
19 const TColgp_Array1OfPnt& thePnts,
20 const Select3D_TypeOfSensitivity theSensitivity )
21 : Select3D_SensitiveFace( theOwnerId, thePnts, theSensitivity )
24 Standard_Integer nbPnts = thePnts.Upper() - thePnts.Lower() + 1;
25 for ( Standard_Integer i = thePnts.Lower(); i <= thePnts.Upper(); i++ )
26 c += thePnts( i ).XYZ();
27 myCentre.SetXYZ( c / nbPnts );
30 //=======================================================================
31 // name : MeshVS_SensitiveFace::Project
33 //=======================================================================
34 void MeshVS_SensitiveFace::Project( const Select3D_Projector& aProj )
36 Select3D_SensitiveFace::Project( aProj );
38 aProj.Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
40 aProj.Project( myCentre, myProjCentre );
43 //=======================================================================
44 // name : MeshVS_SensitiveFace::Matches
46 //=======================================================================
47 Standard_Boolean MeshVS_SensitiveFace::Matches( const Standard_Real XMin,
48 const Standard_Real YMin,
49 const Standard_Real XMax,
50 const Standard_Real YMax,
51 const Standard_Real aTol )
54 aBox.Update( XMin-aTol, YMin-aTol, XMax+aTol, YMax+aTol );
55 return !aBox.IsOut( myProjCentre );
58 //=======================================================================
59 // name : MeshVS_SensitiveFace::Matches
61 //=======================================================================
62 Standard_Boolean MeshVS_SensitiveFace::Matches( const TColgp_Array1OfPnt2d& Polyline,
63 const Bnd_Box2d& aBox,
64 const Standard_Real aTol )
66 Standard_Real Umin, Vmin, Umax, Vmax;
67 aBox.Get ( Umin,Vmin,Umax,Vmax );
68 CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
69 Standard_Integer aRes = aClassifier2d.SiDans( myProjCentre );