0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / StdSelect / StdSelect_BRepSelectionTool.hxx
1 // Created on: 1995-03-08
2 // Created by: Mister rmi
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 #ifndef _StdSelect_BRepSelectionTool_HeaderFile
18 #define _StdSelect_BRepSelectionTool_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <SelectMgr_Selection.hxx>
25 #include <TopAbs_ShapeEnum.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Select3D_SensitiveEntity.hxx>
30 #include <Select3D_EntitySequence.hxx>
31 #include <StdSelect_BRepOwner.hxx>
32 class TopoDS_Shape;
33 class SelectMgr_SelectableObject;
34 class StdSelect_BRepOwner;
35 class TopoDS_Face;
36
37
38 //! Tool to create specific selections (sets of primitives)
39 //! for Shapes from Topology.
40 //! These Selections may be used  in dynamic selection
41 //! Mechanism
42 //! Given a Shape and a mode of selection
43 //! (selection of vertices,
44 //! edges,faces ...) , This Tool Computes corresponding sensitive primitives,
45 //! puts them in an entity called Selection (see package SelectMgr) and returns it.
46 //!
47 //! A Priority for the decomposed pickable objects can be given ;
48 //! by default There is A Preset Hierachy:
49 //! Vertex             priority : 5
50 //! Edge               priority : 4
51 //! Wire               priority : 3
52 //! Face               priority : 2
53 //! Shell,solid,shape  priority : 1
54 //! the default priority in the following methods has no sense - it's only taken in account
55 //! when the user gives a value between 0 and 10.
56 //! IMPORTANT : This decomposition creates BRepEntityOwner instances (from StdSelect).
57 //! which are stored in the Sensitive Entities coming from The Decomposition.
58 //!
59 //! the result of picking in a ViewerSelector return EntityOwner from SelectMgr;
60 //! to know what kind of object was picked :
61 //!
62 //! ENTITY_OWNER -> Selectable() gives the selectableobject which
63 //! was decomposed into pickable elements.
64 //! Handle(StdSelect_BRepOwner)::DownCast(ENTITY_OWNER) -> Shape()
65 //! gives the real picked shape (edge,vertex,shape...)
66 class StdSelect_BRepSelectionTool 
67 {
68 public:
69   DEFINE_STANDARD_ALLOC
70
71   //! Decomposition of <aShape> into sensitive entities following
72   //! a mode of decomposition <aType>. These entities are stored in <aSelection>.
73   //! BrepOwners are created to store the identity of the picked shapes
74   //! during the selection process.
75   //! In those BRepOwners is also stored the original shape.
76   //! But One can't get the selectable object which was decomposed to give
77   //! the sensitive entities.
78   //! maximal parameter is used for infinite objects, to limit the sensitive Domain....
79   //! If AutoTriangulation = True, a Triangulation will be
80   //! computed for faces which have no existing one.
81   //! if AutoTriangulation = False the old algorithm will be
82   //! called to compute sensitive entities on faces.
83   Standard_EXPORT static void Load (const Handle(SelectMgr_Selection)& aSelection, const TopoDS_Shape& aShape, const TopAbs_ShapeEnum aType, const Standard_Real theDeflection, const Standard_Real theDeviationAngle, const Standard_Boolean AutoTriangulation = Standard_True, const Standard_Integer aPriority = -1, const Standard_Integer NbPOnEdge = 9, const Standard_Real MaximalParameter = 500);
84   
85   //! Same  functionnalities  ; the  only
86   //! difference is that  the selectable object from which the
87   //! selection comes is stored in each Sensitive EntityOwner;
88   //! decomposition of <aShape> into sensitive entities following
89   //! a mode of decomposition <aType>. These entities are stored in <aSelection>
90   //! The Major difference is that the known users are first inserted in the
91   //! BRepOwners. the original shape is the last user...
92   //! (see EntityOwner from SelectBasics and BrepOwner)...
93   Standard_EXPORT static void Load (const Handle(SelectMgr_Selection)& aSelection, const Handle(SelectMgr_SelectableObject)& Origin, const TopoDS_Shape& aShape, const TopAbs_ShapeEnum aType, const Standard_Real theDeflection, const Standard_Real theDeviationAngle, const Standard_Boolean AutoTriangulation = Standard_True, const Standard_Integer aPriority = -1, const Standard_Integer NbPOnEdge = 9, const Standard_Real MaximalParameter = 500);
94   
95   //! Returns the standard priority of the shape aShap having the type aType.
96   //! This priority is passed to a StdSelect_BRepOwner object.
97   //! You can use the function Load to modify the
98   //! selection priority of an owner to make one entity
99   //! more selectable than another one.
100   static Standard_Integer GetStandardPriority (const TopoDS_Shape&    theShape,
101                                                const TopAbs_ShapeEnum theType)
102   {
103     switch (theType)
104     {
105       case TopAbs_VERTEX: return 8;
106       case TopAbs_EDGE:   return 7;
107       case TopAbs_WIRE:   return 6;
108       case TopAbs_FACE:   return 5;
109       case TopAbs_SHAPE:
110       default: break;
111     }
112
113     switch (theShape.ShapeType())
114     {
115       case TopAbs_VERTEX:    return 9;
116       case TopAbs_EDGE:      return 8;
117       case TopAbs_WIRE:      return 7;
118       case TopAbs_FACE:      return 6;
119       case TopAbs_SHELL:     return 5;
120       case TopAbs_COMPOUND:
121       case TopAbs_COMPSOLID:
122       case TopAbs_SOLID:
123       case TopAbs_SHAPE:
124       default:
125         return 4;
126     }
127   }
128
129   //! Computes the sensitive primitives, stores them in the SelectMgr_Selection object, and returns this object.
130   //! @param theShape        shape to compute sensitive entities
131   //! @param theOwner        selectable owner object
132   //! @param theSelection    selection to append new sensitive entities
133   //! @param theDeflection   linear deflection
134   //! @param theDeflAngle    angular deflection
135   //! @param theNbPOnEdge    sensitivity parameters for edges and wires
136   //! @param theMaxiParam    sensitivity parameters for infinite objects (the default value is 500)
137   //! @param theAutoTriang   flag to compute triangulation for the faces which have none
138   Standard_EXPORT static void ComputeSensitive (const TopoDS_Shape& theShape,
139                                                 const Handle(SelectMgr_EntityOwner)& theOwner,
140                                                 const Handle(SelectMgr_Selection)& theSelection,
141                                                 const Standard_Real theDeflection,
142                                                 const Standard_Real theDeflAngle,
143                                                 const Standard_Integer theNbPOnEdge,
144                                                 const Standard_Real theMaxiParam,
145                                                 const Standard_Boolean theAutoTriang = Standard_True);
146
147   //! Creates the 3D sensitive entities for Face selection.
148   //! @param theFace         face to compute sensitive entities
149   //! @param theOwner        selectable owner object
150   //! @param theOutList      output result list to append created entities
151   //! @param theAutoTriang   obsolete flag (has no effect)
152   //! @param theNbPOnEdge    sensitivity parameters
153   //! @param theMaxiParam    sensitivity parameters
154   //! @param theInteriorFlag flag indicating that face interior (TRUE) or face boundary (FALSE) should be selectable
155   Standard_EXPORT static Standard_Boolean GetSensitiveForFace (const TopoDS_Face& theFace,
156                                                                const Handle(SelectMgr_EntityOwner)& theOwner,
157                                                                Select3D_EntitySequence& theOutList,
158                                                                const Standard_Boolean theAutoTriang = Standard_True,
159                                                                const Standard_Integer theNbPOnEdge = 9,
160                                                                const Standard_Real theMaxiParam = 500,
161                                                                const Standard_Boolean theInteriorFlag = Standard_True);
162
163   //! Create a sensitive edge or sensitive wire.
164   //! @param theShape          either TopoDS_Edge or TopoDS_Wire to compute sensitive entities
165   //! @param theOwner          selectable owner object
166   //! @param theSelection      selection to append new sensitive entities
167   //! @param theDeflection     linear deflection
168   //! @param theDeviationAngle angular deflection
169   //! @param theNbPOnEdge      sensitivity parameters
170   //! @param theMaxiParam      sensitivity parameters
171   Standard_EXPORT static void GetEdgeSensitive (const TopoDS_Shape& theShape,
172                                                 const Handle(SelectMgr_EntityOwner)& theOwner,
173                                                 const Handle(SelectMgr_Selection)& theSelection,
174                                                 const Standard_Real theDeflection,
175                                                 const Standard_Real theDeviationAngle,
176                                                 const Standard_Integer theNbPOnEdge,
177                                                 const Standard_Real theMaxiParam,
178                                                 Handle(Select3D_SensitiveEntity)& theSensitive);
179
180   //! Traverses the selection given and pre-builds BVH trees for heavyweight
181   //! sensitive entities containing more than BVH_PRIMITIVE_LIMIT (defined in .cxx file) sub-elements.
182   Standard_EXPORT static void PreBuildBVH (const Handle(SelectMgr_Selection)& theSelection);
183
184 };
185
186 #endif // _StdSelect_BRepSelectionTool_HeaderFile