1 #include <cpm/VTK/MeshMapper.h>
3 #include <vtkInformation.h>
6 #include <cpm/VTK/OpenGLMeshMapper.h>
8 // -------------------------------------------------------------------------
10 typename cpm::VTK::MeshMapper< M >::
11 Self* cpm::VTK::MeshMapper< M >::
14 return( cpm::VTK::OpenGLMeshMapper< M >::New( ) );
17 // -------------------------------------------------------------------------
19 void cpm::VTK::MeshMapper< M >::
20 ShallowCopy( vtkAbstractMapper* m )
22 Self* mapper = Self::SafeDownCast( m );
24 this->SetInputData( mapper->GetInput( ) );
25 this->vtkMapper::ShallowCopy( m );
28 // -------------------------------------------------------------------------
30 void cpm::VTK::MeshMapper< M >::
33 if( this->Mesh != in )
41 // -------------------------------------------------------------------------
43 M* cpm::VTK::MeshMapper< M >::
49 // -------------------------------------------------------------------------
51 const M* cpm::VTK::MeshMapper< M >::
57 // -------------------------------------------------------------------------
59 double* cpm::VTK::MeshMapper< M >::
62 // do we have an input
63 if( this->Mesh.IsNull( ) )
65 vtkMath::UninitializeBounds( this->Bounds );
66 return( this->Bounds );
70 this->Mesh->Update( );
71 this->ComputeBounds( );
73 if( !vtkMath::AreBoundsInitialized( this->Bounds ) )
75 return( this->Bounds );
80 // -------------------------------------------------------------------------
82 void cpm::VTK::MeshMapper< M >::
83 GetBounds( double bounds[ 6 ] )
85 this->Superclass::GetBounds( bounds );
88 // -------------------------------------------------------------------------
90 void cpm::VTK::MeshMapper< M >::
91 Render( vtkRenderer* aren, vtkActor* act )
93 if( this->Mesh.IsNull( ) )
95 vtkErrorMacro( "Mapper has no input." );
99 this->RenderPiece( aren, act );
102 // -------------------------------------------------------------------------
104 void cpm::VTK::MeshMapper< M >::
108 std::cout << "Update( )" << std::endl;
111 // -------------------------------------------------------------------------
113 void cpm::VTK::MeshMapper< M >::
117 std::cout << "Update( port = " << port << " ) "<< std::endl;
120 // -------------------------------------------------------------------------
122 void cpm::VTK::MeshMapper< M >::
123 MapDataArrayToVertexAttribute(
124 const char* vertexAttributeName,
125 const char* dataArrayName,
126 int fieldAssociation,
130 vtkErrorMacro( "Not implemented at this level..." );
133 // -------------------------------------------------------------------------
135 void cpm::VTK::MeshMapper< M >::
136 MapDataArrayToMultiTextureAttribute(
138 const char* dataArrayName,
139 int fieldAssociation,
143 vtkErrorMacro( "Not implemented at this level..." );
146 // -------------------------------------------------------------------------
148 void cpm::VTK::MeshMapper< M >::
149 RemoveVertexAttributeMapping( const char* vertexAttributeName )
151 vtkErrorMacro( "Not implemented at this level..." );
154 // -------------------------------------------------------------------------
156 void cpm::VTK::MeshMapper< M >::
157 RemoveAllVertexAttributeMappings( )
159 vtkErrorMacro( "Not implemented at this level..." );
162 // -------------------------------------------------------------------------
164 cpm::VTK::MeshMapper< M >::
170 // -------------------------------------------------------------------------
172 cpm::VTK::MeshMapper< M >::
177 // -------------------------------------------------------------------------
179 void cpm::VTK::MeshMapper< M >::
182 static const TScalar _0 = TScalar( 0 );
183 if( this->Mesh.IsNotNull( ) )
185 const typename M::BoundingBoxType* bb = this->Mesh->GetBoundingBox( );
186 TPoint minP = bb->GetMinimum( );
187 TPoint maxP = bb->GetMaximum( );
188 this->Bounds[ 0 ] = double( ( Self::Dimension >= 1 )? minP[ 0 ]: _0 );
189 this->Bounds[ 1 ] = double( ( Self::Dimension >= 1 )? maxP[ 0 ]: _0 );
190 this->Bounds[ 2 ] = double( ( Self::Dimension >= 2 )? minP[ 1 ]: _0 );
191 this->Bounds[ 3 ] = double( ( Self::Dimension >= 2 )? maxP[ 1 ]: _0 );
192 this->Bounds[ 4 ] = double( ( Self::Dimension >= 3 )? minP[ 2 ]: _0 );
193 this->Bounds[ 5 ] = double( ( Self::Dimension >= 3 )? maxP[ 2 ]: _0 );
208 // -------------------------------------------------------------------------
210 int cpm::VTK::MeshMapper< M >::
211 FillInputPortInformation( int port, vtkInformation* info )
213 info->Set( vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE( ), "itk::Mesh" );
217 // -------------------------------------------------------------------------
218 #include <cpm/DataStructures/QuadEdgeMesh.h>
219 #include <cpm/DataStructures/SimplexMesh.h>
221 using namespace cpm::DataStructures;
222 using namespace cpm::VTK;
224 template class MeshMapper< QuadEdgeMesh< float, 2 > >;
225 template class MeshMapper< QuadEdgeMesh< float, 3 > >;
226 template class MeshMapper< QuadEdgeMesh< double, 2 > >;
227 template class MeshMapper< QuadEdgeMesh< double, 3 > >;
229 template class MeshMapper< SimplexMesh< float, 2 > >;
230 template class MeshMapper< SimplexMesh< float, 3 > >;
231 template class MeshMapper< SimplexMesh< double, 2 > >;
232 template class MeshMapper< SimplexMesh< double, 3 > >;