b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | #ifndef _Graphic3d_CStructure_HeaderFile |
16 | #define _Graphic3d_CStructure_HeaderFile |
17 | |
7c3ef2f7 |
18 | #include <Graphic3d_BndBox3d.hxx> |
b64d84be |
19 | #include <Graphic3d_Group.hxx> |
f838dac4 |
20 | #include <Graphic3d_PresentationAttributes.hxx> |
b64d84be |
21 | #include <Graphic3d_SequenceOfGroup.hxx> |
51b10cd4 |
22 | #include <Graphic3d_SequenceOfHClipPlane.hxx> |
63bcc448 |
23 | #include <Graphic3d_TypeOfComposition.hxx> |
a272ed94 |
24 | #include <Graphic3d_ViewAffinity.hxx> |
825aa485 |
25 | #include <Graphic3d_TransformPers.hxx> |
63bcc448 |
26 | #include <Graphic3d_Vec3.hxx> |
a1954302 |
27 | #include <Graphic3d_ZLayerId.hxx> |
1f7f5a90 |
28 | #include <Geom_Transformation.hxx> |
d325cb7f |
29 | #include <NCollection_IndexedMap.hxx> |
bf75be98 |
30 | |
c04c30b3 |
31 | class Graphic3d_GraphicDriver; |
32 | class Graphic3d_StructureManager; |
63bcc448 |
33 | |
34 | //! Low-level graphic structure interface |
35 | class Graphic3d_CStructure : public Standard_Transient |
bf75be98 |
36 | { |
d325cb7f |
37 | protected: |
38 | |
39 | //! Auxiliary wrapper to iterate through structure list. |
40 | template<class Struct_t> |
41 | class SubclassStructIterator |
42 | { |
43 | public: |
44 | SubclassStructIterator (const NCollection_IndexedMap<const Graphic3d_CStructure*>& theStructs) : myIter (theStructs) {} |
45 | Standard_Boolean More() const { return myIter.More(); } |
46 | void Next() { myIter.Next(); } |
47 | const Struct_t* Value() const { return (const Struct_t* )(myIter.Value()); } |
48 | Struct_t* ChangeValue() { return (Struct_t* )(myIter.Value()); } |
49 | private: |
50 | NCollection_IndexedMap<const Graphic3d_CStructure*>::Iterator myIter; |
51 | }; |
52 | |
53 | //! Auxiliary wrapper to iterate through group sequence. |
54 | template<class Group_t> |
55 | class SubclassGroupIterator |
56 | { |
57 | public: |
58 | SubclassGroupIterator (const Graphic3d_SequenceOfGroup& theGroups) : myIter (theGroups) {} |
59 | Standard_Boolean More() const { return myIter.More(); } |
60 | void Next() { myIter.Next(); } |
61 | const Group_t* Value() const { return (const Group_t* )(myIter.Value().get()); } |
62 | Group_t* ChangeValue() { return (Group_t* )(myIter.ChangeValue().get()); } |
63 | private: |
64 | Graphic3d_SequenceOfGroup::Iterator myIter; |
65 | }; |
bf75be98 |
66 | |
67 | public: |
68 | |
63bcc448 |
69 | //! @return graphic driver created this structure |
70 | const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const |
71 | { |
72 | return myGraphicDriver; |
73 | } |
74 | |
b64d84be |
75 | //! @return graphic groups |
76 | const Graphic3d_SequenceOfGroup& Groups() const |
77 | { |
78 | return myGroups; |
79 | } |
80 | |
1f7f5a90 |
81 | //! Return transformation. |
82 | const Handle(Geom_Transformation)& Transformation() const { return myTrsf; } |
83 | |
84 | //! Assign transformation. |
85 | virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) { myTrsf = theTrsf; } |
86 | |
778cd667 |
87 | //! Return transformation persistence. |
88 | const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; } |
89 | |
90 | //! Set transformation persistence. |
7c3ef2f7 |
91 | virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; } |
778cd667 |
92 | |
63bcc448 |
93 | //! @return associated clip planes |
3202bf1e |
94 | const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const |
63bcc448 |
95 | { |
96 | return myClipPlanes; |
97 | } |
98 | |
99 | //! Pass clip planes to the associated graphic driver structure |
3202bf1e |
100 | void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { myClipPlanes = thePlanes; } |
63bcc448 |
101 | |
b7cd4ba7 |
102 | //! @return bounding box of this presentation |
7c3ef2f7 |
103 | const Graphic3d_BndBox3d& BoundingBox() const |
b7cd4ba7 |
104 | { |
105 | return myBndBox; |
106 | } |
107 | |
108 | //! @return bounding box of this presentation |
109 | //! without transformation matrix applied |
7c3ef2f7 |
110 | Graphic3d_BndBox3d& ChangeBoundingBox() |
b7cd4ba7 |
111 | { |
112 | return myBndBox; |
113 | } |
114 | |
a1954302 |
115 | //! Return structure visibility flag |
116 | bool IsVisible() const { return visible != 0; } |
117 | |
3fe9ce0e |
118 | //! Return structure visibility considering both View Affinity and global visibility state. |
119 | bool IsVisible (const Standard_Integer theViewId) const |
120 | { |
121 | return visible != 0 |
122 | && (ViewAffinity.IsNull() |
123 | || ViewAffinity->IsVisible (theViewId)); |
124 | } |
125 | |
a1954302 |
126 | //! Set z layer ID to display the structure in specified layer |
7c3ef2f7 |
127 | virtual void SetZLayer (const Graphic3d_ZLayerId theLayerIndex) { myZLayer = theLayerIndex; } |
a1954302 |
128 | |
129 | //! Get z layer ID |
130 | Graphic3d_ZLayerId ZLayer() const { return myZLayer; } |
131 | |
8e5fb5ea |
132 | //! Returns valid handle to highlight style of the structure in case if |
133 | //! highlight flag is set to true |
f838dac4 |
134 | const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myHighlightStyle; } |
8e5fb5ea |
135 | |
d325cb7f |
136 | public: |
137 | |
138 | //! Returns FALSE if the structure hits the current view volume, otherwise returns TRUE. |
139 | Standard_Boolean IsCulled() const { return myIsCulled; } |
140 | |
141 | //! Marks structure as culled/not culled - note that IsAlwaysRendered() is ignored here! |
142 | void SetCulled (Standard_Boolean theIsCulled) const { myIsCulled = theIsCulled; } |
143 | |
144 | //! Marks structure as overlapping the current view volume one. |
145 | //! The method is called during traverse of BVH tree. |
146 | void MarkAsNotCulled() const { myIsCulled = Standard_False; } |
147 | |
8e6ce38c |
148 | //! Returns whether check of object's bounding box clipping is enabled before drawing of object; TRUE by default. |
149 | Standard_Boolean BndBoxClipCheck() const { return myBndBoxClipCheck; } |
150 | |
151 | //! Enable/disable check of object's bounding box clipping before drawing of object. |
152 | void SetBndBoxClipCheck(Standard_Boolean theBndBoxClipCheck) { myBndBoxClipCheck = theBndBoxClipCheck; } |
153 | |
d325cb7f |
154 | //! Checks if the structure should be included into BVH tree or not. |
155 | Standard_Boolean IsAlwaysRendered() const |
156 | { |
157 | return IsInfinite |
158 | || IsForHighlight |
159 | || IsMutable |
160 | || Is2dText |
161 | || (!myTrsfPers.IsNull() && myTrsfPers->IsTrihedronOr2d()); |
162 | } |
163 | |
63bcc448 |
164 | public: |
165 | |
166 | //! Update structure visibility state |
a1954302 |
167 | virtual void OnVisibilityChanged() = 0; |
63bcc448 |
168 | |
169 | //! Clear graphic data |
170 | virtual void Clear() = 0; |
171 | |
172 | //! Connect other structure to this one |
173 | virtual void Connect (Graphic3d_CStructure& theStructure) = 0; |
174 | |
175 | //! Disconnect other structure to this one |
176 | virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0; |
177 | |
8e5fb5ea |
178 | //! Highlights structure with the given style |
98b15dbf |
179 | virtual void GraphicHighlight (const Handle(Graphic3d_PresentationAttributes)& theStyle) = 0; |
63bcc448 |
180 | |
8e5fb5ea |
181 | //! Unhighlights the structure and invalidates pointer to structure's highlight |
182 | //! style |
183 | virtual void GraphicUnhighlight() = 0; |
63bcc448 |
184 | |
679ecdee |
185 | //! Create shadow link to this structure |
186 | virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const = 0; |
187 | |
b64d84be |
188 | //! Create new group within this structure |
189 | virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) = 0; |
190 | |
191 | //! Remove group from this structure |
192 | virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0; |
193 | |
d325cb7f |
194 | //! Update render transformation matrix. |
195 | virtual void updateLayerTransformation() {} |
196 | |
63bcc448 |
197 | public: |
198 | |
a1954302 |
199 | int Id; |
200 | Graphic3d_ZLayerId myZLayer; |
201 | int Priority; |
202 | int PreviousPriority; |
bf75be98 |
203 | |
bf75be98 |
204 | int ContainsFacet; |
205 | |
a272ed94 |
206 | Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask |
207 | |
b7cd4ba7 |
208 | unsigned IsInfinite : 1; |
a1954302 |
209 | unsigned stick : 1; //!< displaying state - should be set when structure has been added to scene graph (but can be in hidden state) |
b7cd4ba7 |
210 | unsigned highlight : 1; |
a1954302 |
211 | unsigned visible : 1; //!< visibility flag - can be used to suppress structure while leaving it in the scene graph |
b7cd4ba7 |
212 | unsigned HLRValidation : 1; |
213 | unsigned IsForHighlight : 1; |
214 | unsigned IsMutable : 1; |
215 | unsigned Is2dText : 1; |
bf75be98 |
216 | |
63bcc448 |
217 | protected: |
7fd59977 |
218 | |
63bcc448 |
219 | //! Create empty structure. |
220 | Standard_EXPORT Graphic3d_CStructure (const Handle(Graphic3d_StructureManager)& theManager); |
7fd59977 |
221 | |
63bcc448 |
222 | protected: |
223 | |
224 | Handle(Graphic3d_GraphicDriver) myGraphicDriver; |
b64d84be |
225 | Graphic3d_SequenceOfGroup myGroups; |
7c3ef2f7 |
226 | Graphic3d_BndBox3d myBndBox; |
1f7f5a90 |
227 | Handle(Geom_Transformation) myTrsf; |
778cd667 |
228 | Handle(Graphic3d_TransformPers) myTrsfPers; |
3202bf1e |
229 | Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; |
f838dac4 |
230 | Handle(Graphic3d_PresentationAttributes) myHighlightStyle; //! Current highlight style; is set only if highlight flag is true |
63bcc448 |
231 | |
d325cb7f |
232 | mutable Standard_Boolean myIsCulled; //!< A status specifying is structure needs to be rendered after BVH tree traverse |
8e6ce38c |
233 | Standard_Boolean myBndBoxClipCheck; //!< Flag responsible for checking of bounding box clipping before drawing of object |
d325cb7f |
234 | |
63bcc448 |
235 | public: |
236 | |
92efcf78 |
237 | DEFINE_STANDARD_RTTIEXT(Graphic3d_CStructure,Standard_Transient) // Type definition |
63bcc448 |
238 | |
239 | }; |
7fd59977 |
240 | |
494782f6 |
241 | DEFINE_STANDARD_HANDLE (Graphic3d_CStructure, Standard_Transient) |
242 | |
63bcc448 |
243 | #endif // _Graphic3d_CStructure_HeaderFile |