1 // Created on: 1995-01-25
2 // Created by: Mister rmi
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Select3D_SensitiveSegment.hxx>
19 #include <TopLoc_Location.hxx>
20 #include <Precision.hxx>
23 IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSegment,Select3D_SensitiveEntity)
25 //=====================================================
27 // Purpose : Constructor
28 //=====================================================
29 Select3D_SensitiveSegment::Select3D_SensitiveSegment (const Handle(SelectBasics_EntityOwner)& theOwnerId,
30 const gp_Pnt& theFirstPnt,
31 const gp_Pnt& theLastPnt)
32 : Select3D_SensitiveEntity (theOwnerId)
34 myStart = theFirstPnt;
38 // =======================================================================
40 // purpose : Checks whether the segment overlaps current selecting volume
41 // =======================================================================
42 Standard_Boolean Select3D_SensitiveSegment::Matches (SelectBasics_SelectingVolumeManager& theMgr,
43 SelectBasics_PickResult& thePickResult)
45 if (!theMgr.IsOverlapAllowed()) // check for inclusion
47 return theMgr.Overlaps (myStart, thePickResult) && theMgr.Overlaps (myEnd, thePickResult);
50 if (!theMgr.Overlaps (myStart, myEnd, thePickResult)) // check for overlap
52 return Standard_False;
55 thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(CenterOfGeometry()));
59 //=======================================================================
60 //function : GetConnected
62 //=======================================================================
63 Handle(Select3D_SensitiveEntity) Select3D_SensitiveSegment::GetConnected()
65 Handle(Select3D_SensitiveSegment) aNewEntity =
66 new Select3D_SensitiveSegment (myOwnerId, myStart, myEnd);
71 //=======================================================================
72 // function : CenterOfGeometry
73 // purpose : Returns center of the segment. If location transformation
74 // is set, it will be applied
75 //=======================================================================
76 gp_Pnt Select3D_SensitiveSegment::CenterOfGeometry() const
78 return (myStart.XYZ() + myEnd.XYZ()) * 0.5;
81 //=======================================================================
82 // function : BoundingBox
83 // purpose : Returns bounding box of the segment. If location
84 // transformation is set, it will be applied
85 //=======================================================================
86 Select3D_BndBox3d Select3D_SensitiveSegment::BoundingBox()
88 const SelectMgr_Vec3 aMinPnt (Min (myStart.X(), myEnd.X()),
89 Min (myStart.Y(), myEnd.Y()),
90 Min (myStart.Z(), myEnd.Z()));
91 const SelectMgr_Vec3 aMaxPnt (Max (myStart.X(), myEnd.X()),
92 Max (myStart.Y(), myEnd.Y()),
93 Max (myStart.Z(), myEnd.Z()));
94 return Select3D_BndBox3d (aMinPnt, aMaxPnt);
97 //=======================================================================
98 // function : NbSubElements
99 // purpose : Returns the amount of points
100 //=======================================================================
101 Standard_Integer Select3D_SensitiveSegment::NbSubElements()