1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : VISU_MeshAct.cxx
29 #include "VISU_MeshAct.h"
31 #include <vtkObjectFactory.h>
32 #include <vtkRenderer.h>
33 #include <vtkTexture.h>
35 #include <vtkFeatureEdges.h>
36 #include <vtkDataSetMapper.h>
37 #include <vtkDataSet.h>
38 #include <vtkMatrix4x4.h>
39 #include <vtkMapperCollection.h>
42 //----------------------------------------------------------------------------
43 vtkStandardNewMacro(VISU_MeshAct);
46 //----------------------------------------------------------------------------
51 m = vtkMatrix4x4::New();
53 mySurfaceActor = SVTK_DeviceActor::New();
54 mySurfaceActor->SetRepresentation(SVTK::Representation::Surface);
55 mySurfaceActor->SetUserMatrix(m);
57 myEdgeActor = SVTK_DeviceActor::New();
58 myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
59 myEdgeActor->SetUserMatrix(m);
61 myNodeActor = SVTK_DeviceActor::New();
62 myNodeActor->SetRepresentation(SVTK::Representation::Points);
63 myNodeActor->SetUserMatrix(m);
66 SetRepresentation(SVTK::Representation::Surface);
72 mySurfaceActor->Delete();
73 myEdgeActor->Delete();
74 myNodeActor->Delete();
78 //----------------------------------------------------------------------------
81 ::DeepCopy(VISU_Actor *theActor)
83 if(VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(theActor)){
84 Superclass::DeepCopy(theActor);
85 GetSurfaceProperty()->DeepCopy(anActor->GetSurfaceProperty());
86 GetEdgeProperty()->DeepCopy(anActor->GetEdgeProperty());
87 GetNodeProperty()->DeepCopy(anActor->GetNodeProperty());
92 //----------------------------------------------------------------------------
95 ::SetMapperInput(vtkDataSet* theDataSet)
97 Superclass::SetMapperInput(theDataSet);
99 mySurfaceActor->SetInput(theDataSet);
100 myEdgeActor->SetInput(theDataSet);
101 myNodeActor->SetInput(theDataSet);
105 //----------------------------------------------------------------------------
108 ::SetTransform(VTKViewer_Transform* theTransform)
110 Superclass::SetTransform(theTransform);
112 mySurfaceActor->SetTransform(theTransform);
113 myEdgeActor->SetTransform(theTransform);
114 myNodeActor->SetTransform(theTransform);
118 //----------------------------------------------------------------------------
121 ::SetShrinkable(bool theIsShrinkable)
123 Superclass::SetShrinkable(theIsShrinkable);
125 mySurfaceActor->SetShrinkable(theIsShrinkable);
126 myEdgeActor->SetShrinkable(theIsShrinkable);
131 ::SetShrinkFactor(vtkFloatingPointType theValue)
133 Superclass::SetShrinkFactor(theValue);
135 mySurfaceActor->SetShrinkFactor(theValue);
136 myEdgeActor->SetShrinkFactor(theValue);
140 //----------------------------------------------------------------------------
143 ::GetSurfaceProperty()
145 return mySurfaceActor->GetProperty();
152 return myEdgeActor->GetProperty();
159 return myNodeActor->GetProperty();
162 //----------------------------------------------------------------------------
165 ::SetOpacity(vtkFloatingPointType theValue)
167 GetSurfaceProperty()->SetOpacity(theValue);
174 return GetSurfaceProperty()->GetOpacity();
177 //----------------------------------------------------------------------------
180 ::SetLineWidth(vtkFloatingPointType theLineWidth)
182 GetEdgeProperty()->SetLineWidth(theLineWidth);
186 VISU_MeshAct::GetLineWidth()
188 return GetEdgeProperty()->GetLineWidth();
191 //----------------------------------------------------------------------------
196 if(myRepresentation == VTK_POINTS)
199 Superclass::SetShrink();
201 mySurfaceActor->SetShrink();
202 myEdgeActor->SetShrink();
209 Superclass::UnShrink();
211 mySurfaceActor->UnShrink();
212 myEdgeActor->UnShrink();
216 //----------------------------------------------------------------------------
219 ::SetRepresentation(int theMode)
221 Superclass::SetRepresentation(theMode);
223 if(theMode == SVTK::Representation::Insideframe)
224 myEdgeActor->SetRepresentation(SVTK::Representation::Insideframe);
226 myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
229 //----------------------------------------------------------------------------
234 vtkDataSet* aDataSet;
235 unsigned long int aSize = Superclass::GetMemorySize();
237 aDataSet = mySurfaceActor->GetInput();
238 aSize += aDataSet->GetActualMemorySize() * 1024;
240 aDataSet = mySurfaceActor->GetMapper()->GetInput();
241 aSize += aDataSet->GetActualMemorySize() * 1024 * 2;
244 aDataSet = myEdgeActor->GetInput();
245 aSize += aDataSet->GetActualMemorySize() * 1024;
247 aDataSet = myEdgeActor->GetMapper()->GetInput();
248 aSize += aDataSet->GetActualMemorySize() * 1024 * 2;
251 aDataSet = myNodeActor->GetInput();
252 aSize += aDataSet->GetActualMemorySize() * 1024;
254 aDataSet = myNodeActor->GetMapper()->GetInput();
255 aSize += aDataSet->GetActualMemorySize() * 1024 * 2;
260 //----------------------------------------------------------------------------
263 ::RenderOpaqueGeometry(vtkViewport *ren)
265 GetMatrix(myNodeActor->GetUserMatrix());
266 GetMatrix(myEdgeActor->GetUserMatrix());
267 GetMatrix(mySurfaceActor->GetUserMatrix());
269 using namespace SVTK::Representation;
270 switch(GetRepresentation()){
272 myNodeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
273 myNodeActor->RenderOpaqueGeometry(ren);
277 myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
278 myEdgeActor->RenderOpaqueGeometry(ren);
281 mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
282 mySurfaceActor->RenderOpaqueGeometry(ren);
285 mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
286 mySurfaceActor->RenderOpaqueGeometry(ren);
288 myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
289 myEdgeActor->RenderOpaqueGeometry(ren);
297 ::RenderTranslucentGeometry(vtkViewport *ren)
299 GetMatrix(myNodeActor->GetUserMatrix());
300 GetMatrix(myEdgeActor->GetUserMatrix());
301 GetMatrix(mySurfaceActor->GetUserMatrix());
303 using namespace SVTK::Representation;
304 switch(GetRepresentation()){
306 myNodeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
307 myNodeActor->RenderTranslucentGeometry(ren);
311 myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
312 myEdgeActor->RenderTranslucentGeometry(ren);
315 mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
316 mySurfaceActor->RenderTranslucentGeometry(ren);
319 mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
320 mySurfaceActor->RenderTranslucentGeometry(ren);
322 myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
323 myEdgeActor->RenderTranslucentGeometry(ren);