Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:01

0001 // Created on: 1995-03-08
0002 // Created by: Mister rmi
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _StdSelect_BRepSelectionTool_HeaderFile
0018 #define _StdSelect_BRepSelectionTool_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <SelectMgr_Selection.hxx>
0025 #include <Standard_Real.hxx>
0026 #include <Standard_Boolean.hxx>
0027 #include <Standard_Integer.hxx>
0028 #include <Select3D_SensitiveEntity.hxx>
0029 #include <Select3D_EntitySequence.hxx>
0030 #include <StdSelect_BRepOwner.hxx>
0031 #include <TopTools_IndexedMapOfShape.hxx>
0032 class SelectMgr_SelectableObject;
0033 class TopoDS_Face;
0034 
0035 
0036 //! Tool to create specific selections (sets of primitives)
0037 //! for Shapes from Topology.
0038 //! These Selections may be used  in dynamic selection
0039 //! Mechanism
0040 //! Given a Shape and a mode of selection
0041 //! (selection of vertices,
0042 //! edges,faces ...) , This Tool Computes corresponding sensitive primitives,
0043 //! puts them in an entity called Selection (see package SelectMgr) and returns it.
0044 //!
0045 //! A Priority for the decomposed pickable objects can be given ;
0046 //! by default There is A Preset Hierarchy:
0047 //! Vertex             priority : 5
0048 //! Edge               priority : 4
0049 //! Wire               priority : 3
0050 //! Face               priority : 2
0051 //! Shell,solid,shape  priority : 1
0052 //! the default priority in the following methods has no sense - it's only taken in account
0053 //! when the user gives a value between 0 and 10.
0054 //! IMPORTANT : This decomposition creates BRepEntityOwner instances (from StdSelect).
0055 //! which are stored in the Sensitive Entities coming from The Decomposition.
0056 //!
0057 //! the result of picking in a ViewerSelector return EntityOwner from SelectMgr;
0058 //! to know what kind of object was picked :
0059 //!
0060 //! ENTITY_OWNER -> Selectable() gives the selectableobject which
0061 //! was decomposed into pickable elements.
0062 //! Handle(StdSelect_BRepOwner)::DownCast(ENTITY_OWNER) -> Shape()
0063 //! gives the real picked shape (edge,vertex,shape...)
0064 class StdSelect_BRepSelectionTool 
0065 {
0066 public:
0067   DEFINE_STANDARD_ALLOC
0068 
0069   //! Decomposition of <aShape> into sensitive entities following
0070   //! a mode of decomposition <aType>. These entities are stored in <aSelection>.
0071   //! BrepOwners are created to store the identity of the picked shapes
0072   //! during the selection process.
0073   //! In those BRepOwners is also stored the original shape.
0074   //! But One can't get the selectable object which was decomposed to give
0075   //! the sensitive entities.
0076   //! maximal parameter is used for infinite objects, to limit the sensitive Domain....
0077   //! If AutoTriangulation = True, a Triangulation will be
0078   //! computed for faces which have no existing one.
0079   //! if AutoTriangulation = False the old algorithm will be
0080   //! called to compute sensitive entities on faces.
0081   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);
0082   
0083   //! Same  functionalities  ; the  only
0084   //! difference is that  the selectable object from which the
0085   //! selection comes is stored in each Sensitive EntityOwner;
0086   //! decomposition of <aShape> into sensitive entities following
0087   //! a mode of decomposition <aType>. These entities are stored in <aSelection>
0088   //! The Major difference is that the known users are first inserted in the
0089   //! BRepOwners. the original shape is the last user...
0090   //! (see EntityOwner from SelectBasics and BrepOwner)...
0091   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);
0092   
0093   //! Returns the standard priority of the shape aShap having the type aType.
0094   //! This priority is passed to a StdSelect_BRepOwner object.
0095   //! You can use the function Load to modify the
0096   //! selection priority of an owner to make one entity
0097   //! more selectable than another one.
0098   static Standard_Integer GetStandardPriority (const TopoDS_Shape&    theShape,
0099                                                const TopAbs_ShapeEnum theType)
0100   {
0101     switch (theType)
0102     {
0103       case TopAbs_VERTEX: return 8;
0104       case TopAbs_EDGE:   return 7;
0105       case TopAbs_WIRE:   return 6;
0106       case TopAbs_FACE:   return 5;
0107       case TopAbs_SHAPE:
0108       default: break;
0109     }
0110 
0111     switch (theShape.ShapeType())
0112     {
0113       case TopAbs_VERTEX:    return 9;
0114       case TopAbs_EDGE:      return 8;
0115       case TopAbs_WIRE:      return 7;
0116       case TopAbs_FACE:      return 6;
0117       case TopAbs_SHELL:     return 5;
0118       case TopAbs_COMPOUND:
0119       case TopAbs_COMPSOLID:
0120       case TopAbs_SOLID:
0121       case TopAbs_SHAPE:
0122       default:
0123         return 4;
0124     }
0125   }
0126 
0127   //! Computes the sensitive primitives, stores them in the SelectMgr_Selection object, and returns this object.
0128   //! @param[in] theShape        shape to compute sensitive entities
0129   //! @param[in] theOwner        selectable owner object
0130   //! @param[in] theSelection    selection to append new sensitive entities
0131   //! @param[in] theDeflection   linear deflection
0132   //! @param[in] theDeflAngle    angular deflection
0133   //! @param[in] theNbPOnEdge    sensitivity parameters for edges and wires
0134   //! @param[in] theMaxiParam    sensitivity parameters for infinite objects (the default value is 500)
0135   //! @param[in] theAutoTriang   flag to compute triangulation for the faces which have none
0136   Standard_EXPORT static void ComputeSensitive (const TopoDS_Shape& theShape,
0137                                                 const Handle(SelectMgr_EntityOwner)& theOwner,
0138                                                 const Handle(SelectMgr_Selection)& theSelection,
0139                                                 const Standard_Real theDeflection,
0140                                                 const Standard_Real theDeflAngle,
0141                                                 const Standard_Integer theNbPOnEdge,
0142                                                 const Standard_Real theMaxiParam,
0143                                                 const Standard_Boolean theAutoTriang = Standard_True);
0144 
0145   //! Creates the 3D sensitive entities for Face selection.
0146   //! @param[in]  theFace         face to compute sensitive entities
0147   //! @param[in]  theOwner        selectable owner object
0148   //! @param[out] theOutList     output result list to append created entities
0149   //! @param[in]  theAutoTriang   obsolete flag (has no effect)
0150   //! @param[in]  theNbPOnEdge    sensitivity parameters
0151   //! @param[in]  theMaxiParam    sensitivity parameters
0152   //! @param[in]  theInteriorFlag flag indicating that face interior (TRUE) or face boundary (FALSE) should be selectable
0153   Standard_EXPORT static Standard_Boolean GetSensitiveForFace (const TopoDS_Face& theFace,
0154                                                                const Handle(SelectMgr_EntityOwner)& theOwner,
0155                                                                Select3D_EntitySequence& theOutList,
0156                                                                const Standard_Boolean theAutoTriang = Standard_True,
0157                                                                const Standard_Integer theNbPOnEdge = 9,
0158                                                                const Standard_Real theMaxiParam = 500,
0159                                                                const Standard_Boolean theInteriorFlag = Standard_True);
0160 
0161   //! Creates a sensitive cylinder.
0162   //! @param[in] theSubfacesMap map of cylinder faces
0163   //! @param[in] theOwner       selectable owner object
0164   //! @param[in] theSelection   selection to append new sensitive entities
0165   Standard_EXPORT static Standard_Boolean GetSensitiveForCylinder (const TopTools_IndexedMapOfShape& theSubfacesMap,
0166                                                                    const Handle(SelectMgr_EntityOwner)& theOwner,
0167                                                                    const Handle(SelectMgr_Selection)& theSelection);
0168 
0169   //! Create a sensitive edge or sensitive wire.
0170   //! @param[in]  theShape          either TopoDS_Edge or TopoDS_Wire to compute sensitive entities
0171   //! @param[in]  theOwner          selectable owner object
0172   //! @param[in]  theSelection      selection to append new sensitive entities
0173   //! @param[in]  theDeflection     linear deflection
0174   //! @param[in]  theDeviationAngle angular deflection
0175   //! @param[in]  theNbPOnEdge      sensitivity parameters
0176   //! @param[out] theMaxiParam      sensitivity parameters
0177   Standard_EXPORT static void GetEdgeSensitive (const TopoDS_Shape& theShape,
0178                                                 const Handle(SelectMgr_EntityOwner)& theOwner,
0179                                                 const Handle(SelectMgr_Selection)& theSelection,
0180                                                 const Standard_Real theDeflection,
0181                                                 const Standard_Real theDeviationAngle,
0182                                                 const Standard_Integer theNbPOnEdge,
0183                                                 const Standard_Real theMaxiParam,
0184                                                 Handle(Select3D_SensitiveEntity)& theSensitive);
0185 
0186   //! Traverses the selection given and pre-builds BVH trees for heavyweight
0187   //! sensitive entities containing more than BVH_PRIMITIVE_LIMIT (defined in .cxx file) sub-elements.
0188   Standard_EXPORT static void PreBuildBVH (const Handle(SelectMgr_Selection)& theSelection);
0189 
0190 };
0191 
0192 #endif // _StdSelect_BRepSelectionTool_HeaderFile