Warnings on vc14 were eliminated
[occt.git] / src / Select3D / Select3D_SensitiveFace.cxx
1 // Created on: 1995-03-27
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 //Modif on jun-24-97 : introduction de CSLib_Class2d de LBR
18 //                     pour teste si on est dedans ou dehors...
19 //Modif on jul-21-97 : changement en harray1 pour eventuelles connexions ...
20
21 #include <Select3D_SensitiveFace.hxx>
22 #include <Select3D_SensitivePoly.hxx>
23 #include <Select3D_InteriorSensitivePointSet.hxx>
24
25 #include <gp_Pnt.hxx>
26 #include <Precision.hxx>
27
28
29 IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveFace,Select3D_SensitiveEntity)
30
31 //==================================================
32 // Function: Hide this constructor to the next version...
33 // Purpose : simply avoid interfering with the version update
34 //==================================================
35 Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
36                                                 const TColgp_Array1OfPnt& thePoints,
37                                                 const Select3D_TypeOfSensitivity theType)
38 : Select3D_SensitiveEntity (theOwnerId),
39   mySensType (theType)
40 {
41   if (mySensType == Select3D_TOS_INTERIOR)
42   {
43     myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints);
44   }
45   else
46   {
47     myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True);
48   }
49 }
50
51 //==================================================
52 // Function: Creation
53 // Purpose :
54 //==================================================
55 Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
56                                                 const Handle(TColgp_HArray1OfPnt)& thePoints,
57                                                 const Select3D_TypeOfSensitivity theType)
58 : Select3D_SensitiveEntity (theOwnerId),
59   mySensType (theType)
60 {
61   if (mySensType == Select3D_TOS_INTERIOR)
62   {
63     myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints->Array1());
64   }
65   else
66   {
67     myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints->Array1(), Standard_True);
68   }
69 }
70
71 //=======================================================================
72 // function : GetPoints
73 // purpose  : Initializes the given array theHArrayOfPnt by 3d
74 //            coordinates of vertices of the face
75 //=======================================================================
76 void Select3D_SensitiveFace::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
77 {
78   if (myFacePoints->IsKind(STANDARD_TYPE(Select3D_SensitivePoly)))
79   {
80     Handle(Select3D_SensitivePoly)::DownCast (myFacePoints)->Points3D (theHArrayOfPnt);
81   }
82   else
83   {
84     Handle(Select3D_InteriorSensitivePointSet)::DownCast (myFacePoints)->GetPoints (theHArrayOfPnt);
85   }
86
87 }
88
89 //=======================================================================
90 // function : BVH
91 // purpose  : Builds BVH tree for the face
92 //=======================================================================
93 void Select3D_SensitiveFace::BVH()
94 {
95   myFacePoints->BVH();
96 }
97
98 //=======================================================================
99 // function : Matches
100 // purpose  : Checks whether the face overlaps current selecting volume
101 //=======================================================================
102 Standard_Boolean Select3D_SensitiveFace::Matches (SelectBasics_SelectingVolumeManager& theMgr,
103                                                   SelectBasics_PickResult& thePickResult)
104 {
105   return myFacePoints->Matches (theMgr, thePickResult);
106 }
107
108 //=======================================================================
109 //function : GetConnected
110 //purpose  :
111 //=======================================================================
112 Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected()
113 {
114   // Create a copy of this
115   Handle(TColgp_HArray1OfPnt) aPoints;
116   GetPoints (aPoints);
117
118   Handle(Select3D_SensitiveEntity) aNewEntity =
119     new Select3D_SensitiveFace (myOwnerId, aPoints, mySensType);
120
121   return aNewEntity;
122 }
123
124 //=======================================================================
125 // function : BoundingBox
126 // purpose  : Returns bounding box of the face. If location transformation
127 //            is set, it will be applied
128 //=======================================================================
129 Select3D_BndBox3d Select3D_SensitiveFace::BoundingBox()
130 {
131   return myFacePoints->BoundingBox();
132 }
133
134 //=======================================================================
135 // function : CenterOfGeometry
136 // purpose  : Returns center of the face. If location transformation
137 //            is set, it will be applied
138 //=======================================================================
139 gp_Pnt Select3D_SensitiveFace::CenterOfGeometry() const
140 {
141   return myFacePoints->CenterOfGeometry();
142 }
143
144 //=======================================================================
145 // function : NbSubElements
146 // purpose  : Returns the amount of sub-entities (points or planar convex
147 //            polygons)
148 //=======================================================================
149 Standard_Integer Select3D_SensitiveFace::NbSubElements()
150 {
151   return myFacePoints->NbSubElements();
152 }