1 // File: MeshVS_SensitiveSegment.cxx
2 // Created: Mon Sep 29 2003
3 // Author: Alexander SOLOVYOV and Sergey LITONIN
4 // Copyright: Open CASCADE 2003
6 #include <MeshVS_SensitiveSegment.ixx>
7 #include <Select3D_Projector.hxx>
8 #include <Bnd_Box2d.hxx>
9 #include <CSLib_Class2d.hxx>
10 #include <TopLoc_Location.hxx>
12 //=======================================================================
13 // name : MeshVS_SensitiveSegment::MeshVS_SensitiveSegment
15 //=======================================================================
16 MeshVS_SensitiveSegment::MeshVS_SensitiveSegment (
17 const Handle(SelectBasics_EntityOwner)& theOwnerId,
18 const gp_Pnt& theFirstP,
19 const gp_Pnt& theLastP,
20 const Standard_Integer theMaxRect )
21 : Select3D_SensitiveSegment( theOwnerId, theFirstP, theLastP, theMaxRect )
23 myCentre.SetXYZ( ( theFirstP.XYZ() + theLastP.XYZ() ) / 2 );
26 //=======================================================================
27 // name : MeshVS_SensitiveSegment::Project
29 //=======================================================================
30 void MeshVS_SensitiveSegment::Project( const Handle(Select3D_Projector)& aProj )
32 Select3D_SensitiveSegment::Project( aProj );
34 aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
36 aProj->Project( myCentre, myProjCentre );
39 //=======================================================================
40 // name : MeshVS_SensitiveSegment::Matches
42 //=======================================================================
43 Standard_Boolean MeshVS_SensitiveSegment::Matches( const Standard_Real XMin,
44 const Standard_Real YMin,
45 const Standard_Real XMax,
46 const Standard_Real YMax,
47 const Standard_Real aTol )
50 aBox.Update( XMin-aTol, YMin-aTol, XMax+aTol, YMax+aTol );
51 return !aBox.IsOut( myProjCentre );
54 //=======================================================================
55 // name : MeshVS_SensitiveSegment::Matches
57 //=======================================================================
58 Standard_Boolean MeshVS_SensitiveSegment::Matches( const TColgp_Array1OfPnt2d& Polyline,
59 const Bnd_Box2d& aBox,
60 const Standard_Real aTol )
62 Standard_Real Umin, Vmin, Umax, Vmax;
63 aBox.Get ( Umin,Vmin,Umax,Vmax );
64 CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
65 Standard_Integer aRes = aClassifier2d.SiDans( myProjCentre );