]> Creatis software - FrontAlgorithms.git/commitdiff
Simple point container to polydata added
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 21 Aug 2015 00:05:50 +0000 (19:05 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 21 Aug 2015 00:05:50 +0000 (19:05 -0500)
lib/fpa/VTK/ImageMPR.cxx
lib/fpa/VTK/PointPathToPolyDataFilter.h [new file with mode: 0644]
lib/fpa/VTK/PointPathToPolyDataFilter.hxx [new file with mode: 0644]
lib/fpa/VTK/UniqueVerticesToPolyDataFilter.h

index c3084535a168884b67b53816337935974c2476a9..b56568920608a98f91e779f20fc56298cdb9821c 100644 (file)
@@ -285,7 +285,6 @@ AddPolyData( vtkPolyData* pd, vtkLookupTable* lut, double opacity )
   this->m_Renderer->AddActor( this->m_Actors[ i ] );
 }
 
-
 // -------------------------------------------------------------------------
 unsigned int fpa::VTK::ImageMPR::
 GetNumberOfSeeds( ) const
diff --git a/lib/fpa/VTK/PointPathToPolyDataFilter.h b/lib/fpa/VTK/PointPathToPolyDataFilter.h
new file mode 100644 (file)
index 0000000..1184129
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef __FPA__VTK__POINTPATHTOPOLYDATAFILTER__H__
+#define __FPA__VTK__POINTPATHTOPOLYDATAFILTER__H__
+
+#include <vtkPolyDataAlgorithm.h>
+
+namespace fpa
+{
+  namespace VTK
+  {
+    /**
+     */
+    template< class C >
+    class PointPathToPolyDataFilter
+      : public vtkPolyDataAlgorithm
+    {
+    public:
+      typedef PointPathToPolyDataFilter Self;
+
+      typedef C                      TContainer;
+      typedef typename C::value_type TPoint;
+
+    public:
+      vtkTypeMacro( PointPathToPolyDataFilter, vtkPolyDataAlgorithm );
+
+    public:
+      static Self* New( );
+
+      const C* GetInput( ) const;
+      void SetInput( const C* c );
+
+    protected:
+      PointPathToPolyDataFilter( );
+      virtual ~PointPathToPolyDataFilter( );
+
+      int RequestData(
+        vtkInformation* information,
+        vtkInformationVector** input,
+        vtkInformationVector* output
+        );
+      int RequestInformation(
+        vtkInformation* information,
+        vtkInformationVector** input,
+        vtkInformationVector* output
+        );
+
+    private:
+      // Purposely not implemented
+      PointPathToPolyDataFilter( const Self& );
+      void operator=( const Self& );
+
+    protected:
+      const C* m_Container;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#include <fpa/VTK/PointPathToPolyDataFilter.hxx>
+
+#endif // __FPA__VTK__POINTPATHTOPOLYDATAFILTER__H__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/VTK/PointPathToPolyDataFilter.hxx b/lib/fpa/VTK/PointPathToPolyDataFilter.hxx
new file mode 100644 (file)
index 0000000..a79c763
--- /dev/null
@@ -0,0 +1,149 @@
+#ifndef __FPA__VTK__POINTPATHTOPOLYDATAFILTER__HXX__
+#define __FPA__VTK__POINTPATHTOPOLYDATAFILTER__HXX__
+
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+
+// -------------------------------------------------------------------------
+template< class C >
+typename fpa::VTK::PointPathToPolyDataFilter< C >::
+Self* fpa::VTK::PointPathToPolyDataFilter< C >::
+New( )
+{
+  return( new Self( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class C >
+const C* fpa::VTK::PointPathToPolyDataFilter< C >::
+GetInput( ) const
+{
+  return( this->m_Container );
+}
+
+// -------------------------------------------------------------------------
+template< class C >
+void fpa::VTK::PointPathToPolyDataFilter< C >::
+SetInput( const C* c )
+{
+  if( this->m_Container != c )
+  {
+    this->m_Container = c;
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class C >
+fpa::VTK::PointPathToPolyDataFilter< C >::
+PointPathToPolyDataFilter( )
+  : vtkPolyDataAlgorithm( ),
+    m_Container( NULL )
+{
+  this->SetNumberOfInputPorts( 0 );
+}
+
+// -------------------------------------------------------------------------
+template< class C >
+fpa::VTK::PointPathToPolyDataFilter< C >::
+~PointPathToPolyDataFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class C >
+int fpa::VTK::PointPathToPolyDataFilter< C >::
+RequestData(
+  vtkInformation* information,
+  vtkInformationVector** input,
+  vtkInformationVector* output
+  )
+{
+  if( this->m_Container == NULL )
+    return( 0 );
+
+  // Get output
+  vtkInformation* info = output->GetInformationObject( 0 );
+  vtkPolyData* out = vtkPolyData::SafeDownCast(
+    info->Get( vtkDataObject::DATA_OBJECT( ) )
+    );
+
+  // Prepare points
+  vtkPoints* points = out->GetPoints( );
+  if( points == NULL )
+  {
+    points = vtkPoints::New( );
+    out->SetPoints( points );
+    points->Delete( );
+
+  } // fi
+  points->SetNumberOfPoints( this->m_Container->size( ) );
+
+  // Prepare cells
+  vtkSmartPointer< vtkCellArray > cells =
+    vtkSmartPointer< vtkCellArray >::New( );
+
+  unsigned int pId = 0;
+  for(
+    typename C::const_iterator it = this->m_Container->begin( );
+    it != this->m_Container->end( );
+    ++it, ++pId
+    )
+  {
+    TPoint pnt = *it;
+    if( TPoint::Dimension == 1 )
+      points->SetPoint( pId, pnt[ 0 ], 0, 0 );
+    else if( TPoint::Dimension == 2 )
+      points->SetPoint( pId, pnt[ 0 ], pnt[ 1 ], 0 );
+    else
+      points->SetPoint( pId, pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
+
+    cells->InsertNextCell( 1 );
+    cells->InsertCellPoint( pId );
+
+  } // rof
+  out->SetPoints( points );
+  out->SetVerts( cells );
+  return( 1 );
+}
+
+// -------------------------------------------------------------------------
+template< class C >
+int fpa::VTK::PointPathToPolyDataFilter< C >::
+RequestInformation(
+  vtkInformation* information,
+  vtkInformationVector** input,
+  vtkInformationVector* output
+  )
+{
+  vtkInformation* info = output->GetInformationObject( 0 );
+  /* TODO
+     info->Set(
+     vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES( ), -1
+     );
+  */
+
+  if( this->m_Container != NULL )
+  {
+    /* TODO
+       typename C::TScalar len = this->m_RGC->GetTotalLength( );
+       typename C::TScalar s0 = this->m_RGC->Gets0( );
+       typename C::TPoint p0 = this->m_RGC->Axis( s0 );
+       typename C::TPoint p1 = this->m_RGC->Axis( s0 + len );
+
+       info->Set(
+       vtkStreamingDemandDrivenPipeline::WHOLE_BOUNDING_BOX( ),
+       double( p0[ 0 ] ), double( p1[ 0 ] ),
+       double( p0[ 1 ] ), double( p1[ 1 ] ),
+       double( p0[ 2 ] ), double( p1[ 2 ] )
+       );
+    */
+
+  } // fi
+  return( 1 );
+}
+
+#endif // __FPA__VTK__POINTPATHTOPOLYDATAFILTER__HXX__
+
+// eof - $RCSfile$
index ed9785f2525a310d139fbb613f7376d35a867fec..96d66cae29b69975be4440d6dcb0faa69bc6be1b 100644 (file)
@@ -17,7 +17,7 @@ namespace fpa
       typedef UniqueVerticesToPolyDataFilter Self;
 
     public:
-      vtkTypeMacro( UniqueVerticesToPolyDataFilter,vtkPolyDataAlgorithm );
+      vtkTypeMacro( UniqueVerticesToPolyDataFilter, vtkPolyDataAlgorithm );
 
     public:
       static Self* New( );