#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::
const_cast< vtkPolyData* >( this->GetVTK< vtkPolyData >( ) );
if( mesh != NULL )
{
- std::cout << "Mesh: " << mesh << std::endl;
- /* TODO
- vtkImageSliceMapper* mapper = vtkImageSliceMapper::New( );
- vtkImageActor* actor = vtkImageActor::New( );
- mapper->SetInputData( image );
- actor->SetMapper( mapper );
- this->m_Actor = actor;
- */
+ unsigned long nPolys = mesh->GetNumberOfPolys( );
+ if( nPolys >= cpPlugins_Mesh_MAX_POLYS )
+ {
+ auto normals = vtkPolyDataNormals::New( );
+ auto stripper = vtkStripper::New( );
+ auto mapper = vtkPolyDataMapper::New( );
+ auto actor = vtkQuadricLODActor::New( );
+
+ double r[ 2 ];
+ mesh->GetScalarRange( r );
+
+ normals->SetInputData( mesh );
+ normals->SetFeatureAngle( 60.0 );
+ stripper->SetInputConnection( normals->GetOutputPort( ) );
+ mapper->SetInputConnection( stripper->GetOutputPort( ) );
+ mapper->UseLookupTableScalarRangeOff( );
+ mapper->SetScalarRange( r[ 0 ], r[ 1 ] );
+ actor->SetMapper( mapper );
+ actor->DeferLODConstructionOff( );
+ this->m_Actor = actor;
+ mapper->Delete( );
+ stripper->Delete( );
+ normals->Delete( );
+ }
+ else
+ {
+ auto mapper = vtkPolyDataMapper::New( );
+ mapper->SetInputData( mesh );
+ auto actor = vtkActor::New( );
+ actor->SetMapper( mapper );
+ this->m_Actor = actor;
+ mapper->Delete( );
+
+ } // fi
} // fi
}
--- /dev/null
+#include <cpPlugins/OrthoNormalBase.h>
+#include <vtkMatrix4x4.h>
+
+// -------------------------------------------------------------------------
+void cpPlugins::OrthoNormalBase::
+SetITK( itk::LightObject* o )
+{
+ // Do nothing since itk::Matrix does not belong to LightObject hierarchy.
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::OrthoNormalBase::
+SetVTK( vtkObjectBase* o )
+{
+ auto matrix = dynamic_cast< vtkMatrix4x4* >( o );
+ if( matrix != NULL )
+ this->Superclass::SetVTK( matrix );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::OrthoNormalBase::
+OrthoNormalBase( )
+ : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::OrthoNormalBase::
+~OrthoNormalBase( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::OrthoNormalBase::
+_CreateVTKActor( ) const
+{
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__ORTHONORMALBASE__H__
+#define __CPPLUGINS__ORTHONORMALBASE__H__
+
+#include <cpPlugins/DataObject.h>
+
+namespace cpPlugins
+{
+ /**
+ */
+ class cpPlugins_EXPORT OrthoNormalBase
+ : public DataObject
+ {
+ public:
+ typedef OrthoNormalBase Self;
+ typedef DataObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( OrthoNormalBase, DataObject );
+ cpPlugins_Id_Macro( OrthoNormalBase, Object );
+
+ public:
+ virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE;
+ virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE;
+
+ template< class _TMatrix >
+ inline void SetITK( const _TMatrix& m );
+
+ protected:
+ OrthoNormalBase( );
+ virtual ~OrthoNormalBase( );
+
+ virtual void _CreateVTKActor( ) const ITK_OVERRIDE;
+
+ private:
+ // Purposely not implemented
+ OrthoNormalBase( const Self& );
+ Self& operator=( const Self& );
+ };
+
+} // ecapseman
+
+#include <cpPlugins/OrthoNormalBase.hxx>
+
+#endif // __CPPLUGINS__ORTHONORMALBASE__H__
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__ORTHONORMALBASE__HXX__
+#define __CPPLUGINS__ORTHONORMALBASE__HXX__
+
+#include <vtkMatrix4x4.h>
+
+// -------------------------------------------------------------------------
+template< class _TMatrix >
+void cpPlugins::OrthoNormalBase::
+SetITK( const _TMatrix& m )
+{
+ vtkMatrix4x4* matrix = vtkMatrix4x4::New( );
+ matrix->Identity( );
+ for( unsigned int i = 0; i < 4; ++i )
+ if( i < _TMatrix::RowDimensions )
+ for( unsigned int j = 0; j < 4; ++j )
+ if( j < _TMatrix::ColumnDimensions )
+ matrix->SetElement( i, j, m[ i ][ j ] );
+ this->m_VTKObject = matrix;
+}
+
+#endif // __CPPLUGINS__ORTHONORMALBASE__HXX__
+
+// eof - $RCSfile$