0027232: Configuration - fix mblen missing building issue on Android
[occt.git] / src / Select3D / Select3D_SensitiveSegment.cxx
CommitLineData
b311480e 1// Created on: 1995-01-25
2// Created by: Mister rmi
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
f751596e 17#include <Select3D_SensitiveSegment.hxx>
7fd59977 18#include <gp_Vec.hxx>
f751596e 19#include <TopLoc_Location.hxx>
7fd59977 20#include <Precision.hxx>
7fd59977 21
7fd59977 22
92efcf78 23IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSegment,Select3D_SensitiveEntity)
24
7fd59977 25//=====================================================
26// Function : Create
f751596e 27// Purpose : Constructor
7fd59977 28//=====================================================
f751596e 29Select3D_SensitiveSegment::Select3D_SensitiveSegment (const Handle(SelectBasics_EntityOwner)& theOwnerId,
30 const gp_Pnt& theFirstPnt,
31 const gp_Pnt& theLastPnt)
32: Select3D_SensitiveEntity (theOwnerId)
7fd59977 33{
f751596e 34 myStart = theFirstPnt;
35 myEnd = theLastPnt;
7fd59977 36}
37
f751596e 38// =======================================================================
39// function : Matches
40// purpose : Checks whether the segment overlaps current selecting volume
41// =======================================================================
42Standard_Boolean Select3D_SensitiveSegment::Matches (SelectBasics_SelectingVolumeManager& theMgr,
43 SelectBasics_PickResult& thePickResult)
7fd59977 44{
2157d6ac 45 thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
aec37c15 46
2157d6ac 47 Standard_Real aDepth;
48 if (!theMgr.IsOverlapAllowed()) // check for inclusion
ac04d101 49 {
2157d6ac 50 return theMgr.Overlaps (myStart, aDepth) && theMgr.Overlaps (myEnd, aDepth);
7fd59977 51 }
4269bd1b 52
2157d6ac 53 if (!theMgr.Overlaps (myStart, myEnd, aDepth)) // check for overlap
54 {
55 return Standard_False;
56 }
57
58 thePickResult = SelectBasics_PickResult (aDepth,
59 theMgr.DistToGeometryCenter (CenterOfGeometry()));
ac04d101 60
2157d6ac 61 return Standard_True;
7fd59977 62}
63
7fd59977 64//=======================================================================
f751596e 65//function : GetConnected
aec37c15 66//purpose :
7fd59977 67//=======================================================================
f751596e 68Handle(Select3D_SensitiveEntity) Select3D_SensitiveSegment::GetConnected()
aec37c15 69{
f751596e 70 Handle(Select3D_SensitiveSegment) aNewEntity =
71 new Select3D_SensitiveSegment (myOwnerId, myStart, myEnd);
7fd59977 72
f751596e 73 return aNewEntity;
7fd59977 74}
75
7fd59977 76//=======================================================================
f751596e 77// function : CenterOfGeometry
78// purpose : Returns center of the segment. If location transformation
79// is set, it will be applied
7fd59977 80//=======================================================================
f751596e 81gp_Pnt Select3D_SensitiveSegment::CenterOfGeometry() const
7fd59977 82{
f751596e 83 return (myStart.XYZ() + myEnd.XYZ()) * 0.5;
7fd59977 84}
85
86//=======================================================================
f751596e 87// function : BoundingBox
88// purpose : Returns bounding box of the segment. If location
89// transformation is set, it will be applied
7fd59977 90//=======================================================================
f751596e 91Select3D_BndBox3d Select3D_SensitiveSegment::BoundingBox()
7fd59977 92{
f751596e 93 const SelectMgr_Vec3 aMinPnt (Min (myStart.X(), myEnd.X()),
94 Min (myStart.Y(), myEnd.Y()),
95 Min (myStart.Z(), myEnd.Z()));
96 const SelectMgr_Vec3 aMaxPnt (Max (myStart.X(), myEnd.X()),
97 Max (myStart.Y(), myEnd.Y()),
98 Max (myStart.Z(), myEnd.Z()));
99 return Select3D_BndBox3d (aMinPnt, aMaxPnt);
7fd59977 100}
f751596e 101
7fd59977 102//=======================================================================
f751596e 103// function : NbSubElements
104// purpose : Returns the amount of points
7fd59977 105//=======================================================================
f751596e 106Standard_Integer Select3D_SensitiveSegment::NbSubElements()
7fd59977 107{
f751596e 108 return 2;
7fd59977 109}