2 // File : SALOME_Actor.cxx
3 // Created : Wed Feb 20 17:24:59 2002
4 // Author : Nicolas REJNERI
7 // Copyright : Open CASCADE 2002
11 \class SALOME_Actor SALOME_Actor.h
12 \brief Abstract class of SALOME Objects in VTK.
15 #include "SALOME_Actor.h"
18 #include "utilities.h"
21 #include <vtkObjectFactory.h>
22 #include <vtkMergePoints.h>
25 void SALOME_Actor::ShallowCopy(vtkProp *prop)
28 this->vtkActor::ShallowCopy(prop);
31 void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper )
33 if (this->Mapper == NULL) {
34 MESSAGE ("No mapper for actor.")
38 vtkMapper *bestMapper;
39 bestMapper = this->Mapper;
41 /* render the property */
42 if (!this->Property) {
43 // force creation of a property
47 this->Property->Render(this, ren);
48 if (this->BackfaceProperty) {
49 this->BackfaceProperty->BackfaceRender(this, ren);
50 this->Device->SetBackfaceProperty(this->BackfaceProperty);
52 this->Device->SetProperty(this->Property);
55 /* render the texture */
57 this->Texture->Render(ren);
61 // Store information on time it takes to render.
62 // We might want to estimate time from the number of polygons in mapper.
63 this->Device->Render(ren,bestMapper);
64 this->EstimatedRenderTime = bestMapper->GetTimeToDraw();
67 int SALOME_Actor::RenderOpaqueGeometry(vtkViewport *vp)
69 int renderedSomething = 0;
70 vtkRenderer *ren = (vtkRenderer *)vp;
72 if ( ! this->Mapper ) {
76 // make sure we have a property
77 if (!this->Property) {
78 // force creation of a property
82 // is this actor opaque ?
83 if (this->GetIsOpaque()) {
84 this->Property->Render(this, ren);
86 // render the backface property
87 if (this->BackfaceProperty) {
88 this->BackfaceProperty->BackfaceRender(this, ren);
93 this->Texture->Render(ren);
95 this->Render(ren,this->Mapper);
97 renderedSomething = 1;
100 return renderedSomething;
103 void SALOME_Actor::ReleaseGraphicsResources(vtkWindow *renWin)
105 vtkActor::ReleaseGraphicsResources(renWin);
106 this->Mapper->ReleaseGraphicsResources(renWin);
109 // void SALOME_Actor::ApplyScaling ( vtkMapper* newMapper, bool recover = false )
111 // if ( recover && m_Isometric )
113 // SetMapper ( m_Isometric );
114 // m_Isometric = NULL;
117 // if ( m_Isometric == NULL )
119 // m_Isometric = GetMapper();
120 // SetMapper(newMapper);
124 void SALOME_Actor::SetMapper ( vtkMapper* newMapper )
126 if ( m_Initial == NULL && Mapper != NULL )
128 m_Initial = GetMapper();
130 vtkLODActor::SetMapper(newMapper);
133 SALOME_Actor::SALOME_Actor()
136 PreviewProperty = NULL;
138 SALOME_Actor::~SALOME_Actor()
140 if ( m_Initial != NULL )
142 if ( PreviewProperty != NULL )
143 PreviewProperty->Delete();