1 // Created on: 1995-04-13
2 // Created by: Robert COUBLANC
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_SensitiveBox.hxx>
19 IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveBox,Select3D_SensitiveEntity)
21 //==================================================
22 // Function: Select3D_SensitiveBox
24 //==================================================
25 Select3D_SensitiveBox::Select3D_SensitiveBox (const Handle(SelectMgr_EntityOwner)& theOwnerId,
26 const Bnd_Box& theBox)
27 : Select3D_SensitiveEntity (theOwnerId)
29 Standard_Real aXMax, aYMax, aZMax;
30 Standard_Real aXMin, aYMin, aZMin;
31 theBox.Get (aXMin, aYMin, aZMin, aXMax, aYMax, aZMax);
32 myBox = Select3D_BndBox3d (SelectMgr_Vec3 (aXMin, aYMin, aZMin),
33 SelectMgr_Vec3 (aXMax, aYMax, aZMax));
34 myCenter3d = (gp_XYZ (aXMin, aYMin, aZMin) + gp_XYZ (aXMax, aYMax, aZMax))
38 //==================================================
39 // Function: Select3D_SensitiveBox
41 //==================================================
43 Select3D_SensitiveBox::Select3D_SensitiveBox (const Handle(SelectMgr_EntityOwner)& theOwnerId,
44 const Standard_Real theXMin,
45 const Standard_Real theYMin,
46 const Standard_Real theZMin,
47 const Standard_Real theXMax,
48 const Standard_Real theYMax,
49 const Standard_Real theZMax)
50 : Select3D_SensitiveEntity (theOwnerId)
52 myBox = Select3D_BndBox3d (SelectMgr_Vec3 (theXMin, theYMin, theZMin),
53 SelectMgr_Vec3 (theXMax, theYMax, theZMax));
54 myCenter3d = (gp_XYZ (theXMin, theYMin, theZMin) + gp_XYZ (theXMax, theYMax, theZMax))
58 //=======================================================================
59 // function : NbSubElements
60 // purpose : Returns the amount of sub-entities in sensitive
61 //=======================================================================
62 Standard_Integer Select3D_SensitiveBox::NbSubElements() const
67 //=======================================================================
68 //function : GetConnected
70 //=======================================================================
72 Handle(Select3D_SensitiveEntity) Select3D_SensitiveBox::GetConnected()
75 aBox.Update (myBox.CornerMin().x(), myBox.CornerMin().y(), myBox.CornerMin().z(),
76 myBox.CornerMax().x(), myBox.CornerMax().y(), myBox.CornerMax().z());
77 Handle(Select3D_SensitiveBox) aNewEntity = new Select3D_SensitiveBox (myOwnerId, aBox);
82 //=======================================================================
84 // purpose : Checks whether the box overlaps current selecting volume
85 //=======================================================================
86 Standard_Boolean Select3D_SensitiveBox::Matches (SelectBasics_SelectingVolumeManager& theMgr,
87 SelectBasics_PickResult& thePickResult)
89 if (!theMgr.IsOverlapAllowed()) // check for inclusion
91 Standard_Boolean isInside = Standard_True;
92 return theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), &isInside) && isInside;
95 if (!theMgr.Overlaps (myBox.CornerMin(), myBox.CornerMax(), thePickResult)) // check for overlap
97 return Standard_False;
100 thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter(myCenter3d));
101 return Standard_True;
104 //=======================================================================
105 // function : CenterOfGeometry
106 // purpose : Returns center of the box. If location transformation
107 // is set, it will be applied
108 //=======================================================================
109 gp_Pnt Select3D_SensitiveBox::CenterOfGeometry() const
114 //=======================================================================
115 // function : BoundingBox
116 // purpose : Returns coordinates of the box. If location transformation
117 // is set, it will be applied
118 //=======================================================================
119 Select3D_BndBox3d Select3D_SensitiveBox::BoundingBox()
124 //=======================================================================
125 //function : DumpJson
127 //=======================================================================
128 void Select3D_SensitiveBox::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
130 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
131 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity)
133 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBox)