#include <itkTriangleCell.h>
#include <itkPolygonCell.h>
-#include <vtkActor.h>
-#include <vtkPolyDataNormals.h>
-#include <vtkPolyData.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkQuadricLODActor.h>
-#include <vtkStripper.h>
-
#define cpPlugins_Mesh_MAX_POLYS 65535
+// -------------------------------------------------------------------------
+void cpPlugins::Mesh::MeshActor::
+SetMesh( vtkPolyData* mesh )
+{
+ this->Normals = NULL;
+ this->Stripper = NULL;
+ this->Mapper = NULL;
+ this->LODActor = NULL;
+ this->Actor = NULL;
+ if( mesh != NULL )
+ {
+ unsigned long nPolys = mesh->GetNumberOfPolys( );
+ if( nPolys >= cpPlugins_Mesh_MAX_POLYS )
+ {
+ this->Normals = vtkSmartPointer< vtkPolyDataNormals >::New( );
+ this->Stripper = vtkSmartPointer< vtkStripper >::New( );
+ this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->LODActor = vtkSmartPointer< vtkQuadricLODActor >::New( );
+
+ double r[ 2 ];
+ mesh->GetScalarRange( r );
+
+ this->Normals->SetInputData( mesh );
+ this->Normals->SetFeatureAngle( 60.0 );
+ this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) );
+ this->Mapper->SetInputConnection( this->Stripper->GetOutputPort( ) );
+ this->Mapper->UseLookupTableScalarRangeOff( );
+ this->Mapper->SetScalarRange( r[ 0 ], r[ 1 ] );
+ this->LODActor->SetMapper( this->Mapper );
+ this->LODActor->DeferLODConstructionOff( );
+ }
+ else
+ {
+ this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->Actor = vtkSmartPointer< vtkActor >::New( );
+ this->Mapper->SetInputData( mesh );
+ this->Actor->SetMapper( this->Mapper );
+
+ } // fi
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
void cpPlugins::Mesh::
SetITK( itk::LightObject* o )
void cpPlugins::Mesh::
_CreateVTKActor( ) const
{
+ this->m_MeshActor.SetMesh(
+ const_cast< vtkPolyData* >( this->GetVTK< vtkPolyData >( ) )
+ );
+ if( this->m_MeshActor.LODActor.GetPointer( ) != NULL )
+ this->m_Actor = this->m_MeshActor.LODActor.GetPointer( );
+ else if( this->m_MeshActor.Actor.GetPointer( ) != NULL )
+ this->m_Actor = this->m_MeshActor.Actor.GetPointer( );
+ else
+ this->m_Actor = NULL;
+
+ /* TODO
vtkPolyData* mesh =
const_cast< vtkPolyData* >( this->GetVTK< vtkPolyData >( ) );
if( mesh != NULL )
} // fi
} // fi
+ */
}
// eof - $RCSfile$