0026372: Meshing of surface of revolution fails in debug mode
[occt.git] / src / PrsMgr / PrsMgr_PresentableObject.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-01-25
2// Created by: Jean-Louis Frenkel
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 _PrsMgr_PresentableObject_HeaderFile
18#define _PrsMgr_PresentableObject_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <PrsMgr_Presentations.hxx>
24#include <PrsMgr_TypeOfPresentation3d.hxx>
25#include <Graphic3d_SequenceOfHClipPlane.hxx>
42cf5bc1 26#include <Standard_Boolean.hxx>
27#include <Graphic3d_ZLayerId.hxx>
28#include <PrsMgr_PresentableObjectPointer.hxx>
91d96372 29#include <gp_GTrsf.hxx>
42cf5bc1 30#include <gp_Trsf.hxx>
31#include <PrsMgr_ListOfPresentableObjects.hxx>
32#include <MMgt_TShared.hxx>
33#include <PrsMgr_Presentation.hxx>
34#include <PrsMgr_PresentationManager3d.hxx>
35#include <Standard_Integer.hxx>
825aa485 36#include <Graphic3d_TransformPers.hxx>
42cf5bc1 37#include <Graphic3d_TransModeFlags.hxx>
38#include <TColStd_ListOfInteger.hxx>
39#include <Graphic3d_ClipPlane.hxx>
40class Standard_NotImplemented;
41class PrsMgr_Presentation;
42class PrsMgr_PresentationManager;
43class Graphic3d_Structure;
44class Graphic3d_DataStructureManager;
45class Geom_Transformation;
46class Prs3d_Presentation;
47class Prs3d_Projector;
48class gp_Pnt;
49class gp_Trsf;
50
51
52class PrsMgr_PresentableObject;
53DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, MMgt_TShared)
54
55//! A framework to supply the Graphic3d
56//! structure of the object to be presented. On the first
57//! display request, this structure is created by calling the
58//! appropriate algorithm and retaining this frameworkfor
59//! further display.
60//! This abstract framework is inherited in Application
61//! Interactive Services (AIS), notably in:
62//! - AIS_InteractiveObject
63//! - AIS_ConnectedInteractive
64//! - AIS_MultipleConnectedInteractive
65//! - AIS_Shape
66//! Consequently, 3D presentation should be handled by
67//! the relevant daughter classes and their member
68//! functions in AIS. This is particularly true in the
69//! creation of new interactive objects.
70class PrsMgr_PresentableObject : public MMgt_TShared
71{
72
73public:
74
75
76 Standard_EXPORT PrsMgr_Presentations& Presentations();
be5c3602 77
42cf5bc1 78 //! Returns information on whether the object accepts display in HLR mode or not.
be5c3602 79 PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const;
80
42cf5bc1 81 //! Sets up Transform Persistence Mode for this object.
82 //! This function used to lock in object position, rotation and / or zooming relative to camera position.
83 //! Object will be drawn in the origin setted by APoint parameter (except Graphic3d_TMF_TriedronPers flag
84 //! - see description later). aFlag should be:
85 //! - Graphic3d_TMF_None - no persistence attributes (reset);
86 //! - Graphic3d_TMF_PanPers - object doesn't move;
87 //! - Graphic3d_TMF_ZoomPers - object doesn't resize;
88 //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
89 //! - Graphic3d_TMF_FullPers - pan, zoom and rotate transform persistence;
90 //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron;
91 //! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_ZoomPers);
92 //! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_RotatePers);
93 //! - combination (Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers).
94 //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected APoint coordinates X and Y means:
95 //! - X = 0.0, Y = 0.0 - center of view window;
96 //! - X > 0.0, Y > 0.0 - right upper corner of view window;
97 //! - X > 0.0, Y < 0.0 - right lower corner of view window;
98 //! - X < 0.0, Y > 0.0 - left upper corner of view window;
99 //! - X < 0.0, Y < 0.0 - left lower corner of view window.
100 //! And Z coordinate defines the gap from border of view window (except center position).
101 Standard_EXPORT virtual void SetTransformPersistence (const Graphic3d_TransModeFlags& aFlag, const gp_Pnt& APoint);
102
103 //! Calls previous method with point (0,0,0)
104 Standard_EXPORT void SetTransformPersistence (const Graphic3d_TransModeFlags& aFlag);
105
106 //! Gets Transform Persistence Mode for this object
107 Standard_EXPORT Graphic3d_TransModeFlags GetTransformPersistenceMode() const;
108
109 //! Gets point of transform persistence for this object
110 Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
825aa485 111
112 //! @return transform persistence of the presentable object.
113 const Graphic3d_TransformPers& TransformPersistence() const;
114
42cf5bc1 115 Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
116
117 //! flags the Prs of mode <AMode> to be Updated.
118 //! the Update will be done when needed.
119 Standard_EXPORT void SetToUpdate (const Standard_Integer aMode);
120
121 //! flags all the Presentations to be Updated.
122 Standard_EXPORT void SetToUpdate();
123
124 //! gives the list of modes which are flagged "to be updated".
125 Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
126
127 //! Sets local transformation to theTransformation.
128 Standard_EXPORT virtual void SetLocalTransformation (const gp_Trsf& theTransformation);
129
130 //! Returns true if object has a transformation that is different from the identity.
131 Standard_EXPORT Standard_Boolean HasTransformation() const;
132
133 const gp_Trsf& LocalTransformation() const;
134
135 const gp_Trsf& Transformation() const;
136
91d96372 137 const gp_GTrsf& InversedTransformation() const;
42cf5bc1 138
139 //! resets local transformation to identity.
140 Standard_EXPORT virtual void ResetTransformation();
141
142 Standard_EXPORT virtual void UpdateTransformation();
143
144 Standard_EXPORT virtual void UpdateTransformation (const Handle(Prs3d_Presentation)& P);
145
146 //! Set Z layer ID and update all presentations of the presentable object.
147 //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
148 Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
149
150 //! Get ID of Z layer.
151 Standard_EXPORT Graphic3d_ZLayerId ZLayer() const;
152
153 //! Adds clip plane for graphical clipping for all display mode
154 //! presentations. The composition of clip planes truncates the rendering
155 //! space to convex volume. Please be aware that number of supported
156 //! clip plane is limited. The planes which exceed the limit are ignored.
157 //! Besides of this, some planes can be already set in view where the object
158 //! is shown: the number of these planes should be substracted from limit
159 //! to predict the maximum possible number of object clipping planes.
160 //! @param thePlane [in] the clip plane to be appended to map of clip planes.
161 Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
162
163 //! Removes previously added clip plane.
164 //! @param thePlane [in] the clip plane to be removed from map of clip planes.
165 Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
166
167 //! Set clip planes for graphical clipping for all display mode presentations.
168 //! The composition of clip planes truncates the rendering space to convex
169 //! volume. Please be aware that number of supported clip plane is limited.
170 //! The planes which exceed the limit are ignored. Besides of this, some
171 //! planes can be already set in view where the object is shown: the number
172 //! of these planes should be substracted from limit to predict the maximum
173 //! possible number of object clipping planes.
174 Standard_EXPORT virtual void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes);
175
176 //! Get clip planes.
177 //! @return set of previously added clip planes for all display mode presentations.
178 const Graphic3d_SequenceOfHClipPlane& GetClipPlanes() const;
179
180 //! Sets if the object has mutable nature (content or location will be changed regularly).
181 //! This method should be called before object displaying to take effect.
182 Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
183
184 //! Returns true if object has mutable nature (content or location are be changed regularly).
185 //! Mutable object will be managed in different way than static onces (another optimizations).
487bf1ce 186 Standard_EXPORT Standard_Boolean IsMutable() const;
42cf5bc1 187
188 //! Makes theObject child of current object in scene hierarchy.
189 Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
190
191 //! Removes theObject from children of current object in scene hierarchy.
192 Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
193
194 //! Returns children of the current object.
be5c3602 195 const PrsMgr_ListOfPresentableObjects& Children() const;
196
42cf5bc1 197 //! Returns true if object should have own presentations.
be5c3602 198 Standard_Boolean HasOwnPresentations() const;
199
42cf5bc1 200 //! Returns parent of current object in scene hierarchy.
be5c3602 201 PrsMgr_PresentableObjectPointer Parent() const;
42cf5bc1 202
203
204friend class PrsMgr_Presentation;
205friend class PrsMgr_PresentationManager;
206friend
207 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector);
208friend
209 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Graphic3d_Structure)& theGivenStruct);
210friend
211 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf);
212friend
213 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Graphic3d_Structure)& theGivenStruct);
214
215
92efcf78 216 DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject,MMgt_TShared)
42cf5bc1 217
218protected:
219
220
221 Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
222Standard_EXPORT virtual ~PrsMgr_PresentableObject();
223
224 //! Calculates the 3D view aPresentation and its
225 //! updates. The latter are managed by aPresentationManager.
226 //! aPresentableObject has the display mode aMode;
227 //! this has the default value of 0, that is, the wireframe display mode.
8b9a309b 228 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode);
42cf5bc1 229
230 //! Calculates the 3D view aPresentation and its
231 //! updates. The latter are managed by
232 //! aPresentationManager. Each of the views in the
233 //! viewer and every modification such as rotation, for
234 //! example, entails recalculation.
235 //! It must be redefined to implement hidden line removal
236 //! for the object. The user never calls this method
237 //! himself. This is done via the InteractiveContext object
238 //! and is dependent on the point of view from which the
239 //! object is displayed.
240 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation);
241
242 //! Calculates the 3D view aPresentation and its
243 //! updates. The latter are managed by
244 //! aPresentationManager. A point of view is provided
245 //! by the projector aProjector, and the geometric
246 //! transformation which has transformed associated
247 //! presentable objects is specified by aTrsf.
248 //! This function is to be used in case where a hidden
249 //! line removal display cannot be calculated
250 //! automatically. This occurs when associated
251 //! presentable objects have been transformed
252 //! geometrically, but not translated.
253 //! Warning
254 //! The transformation aTrsf must be applied to the
255 //! object before computation.
256 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation);
257
258 //! recomputes all presentations of the object.
259 Standard_EXPORT void Update (const Standard_Boolean AllModes = Standard_False);
260
261 //! Recomputes the presentation in the given mode.
262 //! If ClearOther is true, other presentation will be cleared.
263 Standard_EXPORT void Update (const Standard_Integer aMode, const Standard_Boolean ClearOther);
264
265 //! High-level interface for controlling polygon offsets
8b9a309b 266 Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode);
42cf5bc1 267
268 //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
269 //! from parent node and able to derive its own.
270 Standard_EXPORT virtual void SetCombinedParentTransform (const gp_Trsf& theTransformation);
271
272 //! General virtual method for internal update of presentation state
273 //! when some modifications on list of clip planes occurs. Base
274 //! implementation propagate clip planes to every presentation.
275 Standard_EXPORT virtual void UpdateClipping();
276
277 PrsMgr_Presentations myPresentations;
278 PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d;
279 Graphic3d_SequenceOfHClipPlane myClipPlanes;
280 Standard_Boolean myIsMutable;
281 Graphic3d_ZLayerId myZLayer;
282 Standard_Boolean myHasOwnPresentations;
283
284
285private:
286
287
825aa485 288 Graphic3d_TransformPers myTransformPersistence;
42cf5bc1 289 PrsMgr_PresentableObjectPointer myParent;
290 gp_Trsf myLocalTransformation;
291 gp_Trsf myTransformation;
91d96372 292 gp_GTrsf myInvTransformation;
42cf5bc1 293 gp_Trsf myCombinedParentTransform;
294 PrsMgr_ListOfPresentableObjects myChildren;
295
296
297};
298
299
300#include <PrsMgr_PresentableObject.lxx>
301
302
303
304
305
306#endif // _PrsMgr_PresentableObject_HeaderFile