1 // Created on: 2003-09-29
2 // Created by: Alexander SOLOVYOV and Sergey LITONIN
3 // Copyright (c) 2003-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <MeshVS_SensitiveSegment.ixx>
17 #include <Select3D_Projector.hxx>
18 #include <Bnd_Box2d.hxx>
19 #include <CSLib_Class2d.hxx>
20 #include <TopLoc_Location.hxx>
22 //=======================================================================
23 // name : MeshVS_SensitiveSegment::MeshVS_SensitiveSegment
25 //=======================================================================
26 MeshVS_SensitiveSegment::MeshVS_SensitiveSegment (
27 const Handle(SelectBasics_EntityOwner)& theOwnerId,
28 const gp_Pnt& theFirstP,
29 const gp_Pnt& theLastP,
30 const Standard_Integer theMaxRect )
31 : Select3D_SensitiveSegment( theOwnerId, theFirstP, theLastP, theMaxRect )
33 myCentre.SetXYZ( ( theFirstP.XYZ() + theLastP.XYZ() ) / 2 );
36 //=======================================================================
37 // name : MeshVS_SensitiveSegment::Project
39 //=======================================================================
40 void MeshVS_SensitiveSegment::Project( const Handle(Select3D_Projector)& aProj )
42 Select3D_SensitiveSegment::Project( aProj );
44 aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
46 aProj->Project( myCentre, myProjCentre );
49 //=======================================================================
50 // name : MeshVS_SensitiveSegment::Matches
52 //=======================================================================
53 Standard_Boolean MeshVS_SensitiveSegment::Matches( const Standard_Real XMin,
54 const Standard_Real YMin,
55 const Standard_Real XMax,
56 const Standard_Real YMax,
57 const Standard_Real aTol )
60 aBox.Update( XMin-aTol, YMin-aTol, XMax+aTol, YMax+aTol );
61 return !aBox.IsOut( myProjCentre );
64 //=======================================================================
65 // name : MeshVS_SensitiveSegment::Matches
67 //=======================================================================
68 Standard_Boolean MeshVS_SensitiveSegment::Matches( const TColgp_Array1OfPnt2d& Polyline,
69 const Bnd_Box2d& aBox,
70 const Standard_Real aTol )
72 Standard_Real Umin, Vmin, Umax, Vmax;
73 aBox.Get ( Umin,Vmin,Umax,Vmax );
74 CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
75 Standard_Integer aRes = aClassifier2d.SiDans( myProjCentre );