913a4c4a |
1 | // Created on: 2011-10-14 |
2 | // Created by: Roman KOZLOV |
3 | // Copyright (c) 2011-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef __IVTKOCC_SHAPE_H__ |
17 | #define __IVTKOCC_SHAPE_H__ |
18 | |
19 | #include <IVtk_IShape.hxx> |
20 | #include <TopoDS_Shape.hxx> |
21 | #include <TopTools_IndexedMapOfShape.hxx> |
22 | #include <SelectMgr_SelectableObject.hxx> |
23 | |
c04c30b3 |
24 | class IVtkOCC_Shape; |
913a4c4a |
25 | DEFINE_STANDARD_HANDLE( IVtkOCC_Shape, IVtk_IShape ) |
26 | |
27 | //! @class IVtkOCC_Shape |
28 | //! @brief OCC implementation of IShape interface. |
29 | class IVtkOCC_Shape : public IVtk_IShape |
30 | { |
31 | public: |
32 | |
33 | typedef Handle(IVtkOCC_Shape) Handle; |
34 | |
35 | //! Constructor for OCC IShape implementation |
36 | Standard_EXPORT IVtkOCC_Shape (const TopoDS_Shape& theShape); |
37 | |
38 | //! Destructor |
39 | Standard_EXPORT virtual ~IVtkOCC_Shape(); |
40 | |
41 | IVtk_IdType GetSubShapeId (const IVtk_IShape::Handle&) const; |
42 | |
ec357c5c |
43 | DEFINE_STANDARD_RTTI(IVtkOCC_Shape, IVtk_IShape) |
913a4c4a |
44 | |
45 | //! Get the wrapped original OCCT shape |
46 | //! @return TopoDS_Shape the wrapped original OCCT shape |
47 | TopoDS_Shape GetShape() const |
48 | { |
49 | return myTopoDSShape; |
50 | } |
51 | |
52 | //! @brief Get local ID of a sub-shape. |
53 | //! |
54 | //! Returns unique ID of the given sub-shape within the top-level shape. |
55 | //! Note that the sub-shape ID remains unchanged until the top-level is |
56 | //! modified by some operation. |
57 | //! @param [in] subShape sub-shape whose ID is returned |
58 | //! @return local ID of the sub-shape. |
59 | IVtk_IdType GetSubShapeId (const TopoDS_Shape& theSubShape) const; |
60 | |
61 | //! Get ids of sub-shapes composing a sub-shape with the given id |
62 | Standard_EXPORT IVtk_ShapeIdList GetSubIds (const IVtk_IdType) const; |
63 | |
64 | //! @brief Get a sub-shape by its local ID. |
65 | //! |
66 | //! @param [in] id local ID of a sub-shape |
67 | //! @return TopoDS_Shape& a sub-shape |
68 | Standard_EXPORT const TopoDS_Shape& GetSubShape (const IVtk_IdType theId) const; |
69 | |
70 | //! Stores a handle to selectable object used by OCCT selection algorithm |
71 | //! in a data field. This object internally caches selection data |
72 | //! so it should be stored until the shape is no longer selectable. |
73 | //! Note that the selectable object keeps a pointer to OccShape. |
74 | //! @param [in] selObj Handle to the selectable object |
75 | void SetSelectableObject (const Handle(SelectMgr_SelectableObject)& theSelObj) |
76 | { |
77 | mySelectable = theSelObj; |
78 | } |
79 | |
80 | //! @return Handle to the selectable object for this shape. |
81 | Handle(SelectMgr_SelectableObject) GetSelectableObject() const |
82 | { |
83 | return mySelectable; |
84 | } |
85 | |
86 | private: |
87 | //! @brief Build a map of sub-shapes by their IDs |
88 | //! |
89 | //! Private method, assigns IDs to all sub-shapes of the |
90 | //! top-level shape. |
91 | //! @see IVtkOCC_Shape::GetSubShapeId |
92 | void buildSubShapeIdMap(); |
93 | |
94 | private: |
95 | TopTools_IndexedMapOfShape mySubShapeIds; //!< Map of sub-shapes by their IDs |
96 | TopoDS_Shape myTopoDSShape; //!< The wrapped main OCCT shape |
97 | Handle(SelectMgr_SelectableObject) mySelectable; //!< Link to a holder of selection primitives |
98 | }; |
99 | |
100 | #endif // __IVTKOCC_SHAPE_H__ |