1 // Created on: 2003-09-29
2 // Created by: Alexander SOLOVYOV and Sergey LITONIN
3 // Copyright (c) 2003-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #include <MeshVS_SensitiveSegment.ixx>
22 #include <Select3D_Projector.hxx>
23 #include <Bnd_Box2d.hxx>
24 #include <CSLib_Class2d.hxx>
25 #include <TopLoc_Location.hxx>
27 //=======================================================================
28 // name : MeshVS_SensitiveSegment::MeshVS_SensitiveSegment
30 //=======================================================================
31 MeshVS_SensitiveSegment::MeshVS_SensitiveSegment (
32 const Handle(SelectBasics_EntityOwner)& theOwnerId,
33 const gp_Pnt& theFirstP,
34 const gp_Pnt& theLastP,
35 const Standard_Integer theMaxRect )
36 : Select3D_SensitiveSegment( theOwnerId, theFirstP, theLastP, theMaxRect )
38 myCentre.SetXYZ( ( theFirstP.XYZ() + theLastP.XYZ() ) / 2 );
41 //=======================================================================
42 // name : MeshVS_SensitiveSegment::Project
44 //=======================================================================
45 void MeshVS_SensitiveSegment::Project( const Handle(Select3D_Projector)& aProj )
47 Select3D_SensitiveSegment::Project( aProj );
49 aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
51 aProj->Project( myCentre, myProjCentre );
54 //=======================================================================
55 // name : MeshVS_SensitiveSegment::Matches
57 //=======================================================================
58 Standard_Boolean MeshVS_SensitiveSegment::Matches( const Standard_Real XMin,
59 const Standard_Real YMin,
60 const Standard_Real XMax,
61 const Standard_Real YMax,
62 const Standard_Real aTol )
65 aBox.Update( XMin-aTol, YMin-aTol, XMax+aTol, YMax+aTol );
66 return !aBox.IsOut( myProjCentre );
69 //=======================================================================
70 // name : MeshVS_SensitiveSegment::Matches
72 //=======================================================================
73 Standard_Boolean MeshVS_SensitiveSegment::Matches( const TColgp_Array1OfPnt2d& Polyline,
74 const Bnd_Box2d& aBox,
75 const Standard_Real aTol )
77 Standard_Real Umin, Vmin, Umax, Vmax;
78 aBox.Get ( Umin,Vmin,Umax,Vmax );
79 CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
80 Standard_Integer aRes = aClassifier2d.SiDans( myProjCentre );