]> Creatis software - cpPlugins.git/commitdiff
PolyLineParametricPath support added
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 6 Apr 2016 22:45:25 +0000 (17:45 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 6 Apr 2016 22:45:25 +0000 (17:45 -0500)
cmake/cpPluginsConfig.cmake.in
lib/cpExtensions/DataStructures/PolyLineParametricPath.h [new file with mode: 0644]
lib/cpExtensions/Visualization/PolyLineParametricPathToPolyData.hxx
lib/cpPlugins/Path.cxx [new file with mode: 0644]
lib/cpPlugins/Path.h [new file with mode: 0644]
lib/cpPlugins/Path.hxx [new file with mode: 0644]
lib/cpPlugins_Instances/CMakeLists.txt
lib/cpPlugins_Instances/Paths.i

index b46789024dea07b3c0796e9f8fdf5dbcbff439a1..b612b9d0e68b43277f6fee7678b99dff90083b5e 100644 (file)
@@ -99,25 +99,30 @@ SET(cpPipelineEditor_LIBRARY cpPipelineEditor)
 # ======================
 # -- Executable names --
 # ======================
-
-IF(MSVC)
-  FIND_PROGRAM(
-    cpPlugins_HostCreator_APP
-    NAMES cpPlugins_HostCreator
-    HINTS /usr /usr/local
-    PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/Debug @PROJECT_BINARY_DIR@/Release @PROJECT_BINARY_DIR@/MinSizeRel @PROJECT_BINARY_DIR@/RelWithDebInfo
-    PATH_SUFFIXES bin sbin
-    DOC "Where is cpPlugins_HostCreator?"
-    )
-ELSE(MSVC)
-  FIND_PROGRAM(
-    cpPlugins_HostCreator_APP
-    NAMES cpPlugins_HostCreator
-    HINTS /usr /usr/local
-    PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@
-    PATH_SUFFIXES bin sbin
-    DOC "Where is cpPlugins_HostCreator?"
-    )
-ENDIF(MSVC)
+SET(
+  exec_PROGRAMS
+  cpPlugins_CreateInstances
+  cpPlugins_HostCreator
+  )
+FOREACH(prog ${exec_PROGRAMS})
+  IF(MSVC)
+    FIND_PROGRAM(
+      NAMES ${prog}
+      HINTS /usr /usr/local
+      PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/Debug @PROJECT_BINARY_DIR@/Release @PROJECT_BINARY_DIR@/MinSizeRel @PROJECT_BINARY_DIR@/RelWithDebInfo
+      PATH_SUFFIXES bin sbin
+      DOC "Where is ${prog}?"
+      )
+  ELSE(MSVC)
+    FIND_PROGRAM(
+      ${prog}
+      NAMES ${prog}
+      HINTS /usr /usr/local
+      PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@
+      PATH_SUFFIXES bin sbin
+      DOC "Where is ${prog}?"
+      )
+  ENDIF(MSVC)
+ENDFOREACH(prog)
 
 ## eof - $RCSfile$
diff --git a/lib/cpExtensions/DataStructures/PolyLineParametricPath.h b/lib/cpExtensions/DataStructures/PolyLineParametricPath.h
new file mode 100644 (file)
index 0000000..77828ee
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef __CPEXTENSIONS__DATASTRUCTURES__POLYLINEPARAMETRICPATH__H__
+#define __CPEXTENSIONS__DATASTRUCTURES__POLYLINEPARAMETRICPATH__H__
+
+#include <itkPolyLineParametricPath.h>
+#include <itkImageBase.h>
+
+namespace cpExtensions
+{
+  namespace DataStructures
+  {
+    /**
+     */
+    template< unsigned int _NDim >
+    class PolyLineParametricPath
+      : public itk::PolyLineParametricPath< _NDim >
+    {
+    public:
+      typedef PolyLineParametricPath               Self;
+      typedef itk::PolyLineParametricPath< _NDim > Superclass;
+      typedef itk::SmartPointer< Self >            Pointer;
+      typedef itk::SmartPointer< const Self >      ConstPointer;
+
+      typedef itk::ImageBase< _NDim > TImageBase;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( PolyLineParametricPath, itk::PolyLineParametricPath );
+
+    public:
+      TImageBase* GetReferenceImage( )
+        { return( this->m_ReferenceImage ); }
+      const TImageBase* GetReferenceImage( ) const
+        { return( this->m_ReferenceImage ); }
+      void SetReferenceImage( const TImageBase* image )
+        {
+          this->m_ReferenceImage = TImageBase::New( );
+          this->m_ReferenceImage->SetDirection( image->GetDirection( ) );
+          this->m_ReferenceImage->SetOrigin( image->GetOrigin( ) );
+          this->m_ReferenceImage->SetSpacing( image->GetSpacing( ) );
+          this->Modified( );
+        }
+
+    protected:
+      PolyLineParametricPath( )          { }
+      virtual ~PolyLineParametricPath( ) { }
+
+    private:
+      // Purposely not implemented
+      PolyLineParametricPath( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      typename TImageBase::Pointer m_ReferenceImage;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPEXTENSIONS__DATASTRUCTURES__POLYLINEPARAMETRICPATH__H__
+
+// eof - $RCSfile$
index 131c32e89fe76a98ad95ae967f799707196d8889..1c1746315a9bd3c71eb978ab33006cdd143800ba 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <vtkInformation.h>
 #include <vtkInformationVector.h>
+#include <vtkSmartPointer.h>
 
 // -------------------------------------------------------------------------
 template< class _TPolyLine >
@@ -119,8 +120,10 @@ RequestData(
   points->SetNumberOfPoints( lst->Size( ) );
 
   // Prepare cells
-  vtkSmartPointer< vtkCellArray > verts =
-    vtkSmartPointer< vtkCellArray >::New( );
+  /* TODO
+     vtkSmartPointer< vtkCellArray > verts =
+     vtkSmartPointer< vtkCellArray >::New( );
+  */
   vtkSmartPointer< vtkCellArray > lines =
     vtkSmartPointer< vtkCellArray >::New( );
 
@@ -148,8 +151,10 @@ RequestData(
         points->SetPoint( i, idx[ 0 ], idx[ 1 ], idx[ 2 ] );
 
     } // fi
-    verts->InsertNextCell( 1 );
-    verts->InsertCellPoint( i );
+    /* TODO
+       verts->InsertNextCell( 1 );
+       verts->InsertCellPoint( i );
+    */
     if( i > 0 )
     {
       lines->InsertNextCell( 2 );
@@ -160,7 +165,7 @@ RequestData(
 
   } // rof
   out->SetPoints( points );
-  out->SetVerts( verts );
+  // TODO: out->SetVerts( verts );
   out->SetLines( lines );
   return( 1 );
 }
diff --git a/lib/cpPlugins/Path.cxx b/lib/cpPlugins/Path.cxx
new file mode 100644 (file)
index 0000000..5f58269
--- /dev/null
@@ -0,0 +1,39 @@
+#include <cpPlugins/Path.h>
+
+// -------------------------------------------------------------------------
+void cpPlugins::Path::
+SetITK( itk::LightObject* o )
+{
+  this->Superclass::SetITK( o );
+  bool     s = this->_ITK_2_VTK< 2 >( o );
+  if( !s ) s = this->_ITK_2_VTK< 3 >( o );
+  if( !s )
+  {
+    this->m_VTKObject = NULL;
+    this->m_ITKvVTK = NULL;
+
+  } // fi
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Path::
+SetVTK( vtkObjectBase* o )
+{
+  // Do nothing
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Path::
+Path( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Path::
+~Path( )
+{
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Path.h b/lib/cpPlugins/Path.h
new file mode 100644 (file)
index 0000000..d7aa111
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __CPPLUGINS__PATH__H__
+#define __CPPLUGINS__PATH__H__
+
+#include <cpPlugins/DataObject.h>
+
+#include <vtkPolyDataAlgorithm.h>
+#include <vtkSmartPointer.h>
+
+namespace cpPlugins
+{
+  /**
+   */
+  class cpPlugins_EXPORT Path
+    : public DataObject
+  {
+  public:
+    typedef Path                           Self;
+    typedef DataObject                      Superclass;
+    typedef itk::SmartPointer< Self >       Pointer;
+    typedef itk::SmartPointer< const Self > ConstPointer;
+
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro( Path, DataObject );
+    cpPlugins_Id_Macro( Path, Object );
+
+  public:
+    virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE;
+    virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE;
+
+  protected:
+    Path( );
+    virtual ~Path( );
+
+    template< unsigned int _NDim >
+      inline bool _ITK_2_VTK( itk::LightObject* o );
+
+  private:
+    // Purposely not implemented
+    Path( const Self& );
+    Self& operator=( const Self& );
+
+  protected:
+    vtkSmartPointer< vtkPolyDataAlgorithm > m_ITKvVTK;
+  };
+
+} // ecapseman
+
+#include <cpPlugins/Path.hxx>
+
+#endif // __CPPLUGINS__PATH__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Path.hxx b/lib/cpPlugins/Path.hxx
new file mode 100644 (file)
index 0000000..b6fb093
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __CPPLUGINS__PATH__HXX__
+#define __CPPLUGINS__PATH__HXX__
+
+#include <cpPlugins_Instances/Paths.h>
+
+// -------------------------------------------------------------------------
+template< unsigned int _NDim >
+bool cpPlugins::Path::
+_ITK_2_VTK( itk::LightObject* o )
+{
+  typedef
+    cpExtensions::DataStructures::PolyLineParametricPath< _NDim >
+    _TPath;
+  typedef
+    cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPath >
+    _TFilter;
+
+  auto path = dynamic_cast< _TPath* >( o );
+  if( path != NULL )
+  {
+    _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
+    if( f == NULL )
+    {
+      vtkSmartPointer< _TFilter > nf = _TFilter::New( );
+      this->m_ITKvVTK = nf.GetPointer( );
+      f = nf.GetPointer( );
+
+    } // fi
+    f->SetInput( path );
+    f->SetReferenceImage( path->GetReferenceImage( ) );
+    f->Update( );
+
+    // Keep object track
+    this->m_ITKObject = o;
+    this->m_VTKObject = f->GetOutput( );
+    return( true );
+  }
+  else
+    return( false );
+}
+
+#endif // __CPPLUGINS__PATH__HXX__
+
+// eof - $RCSfile$
index 2bbc988b5b8ed0930854eb015e570b18f2004af7..f040a22975d3f7e4d962b1e2a5a6e2b6e00902b0 100644 (file)
@@ -46,7 +46,7 @@ SET(
 ## Target links
 TARGET_LINK_LIBRARIES(cpPlugins_Base ${ITK_LIBRARIES})
 TARGET_LINK_LIBRARIES(cpPlugins_Transforms ${ITK_LIBRARIES} cpPlugins_Base)
-TARGET_LINK_LIBRARIES(cpPlugins_Paths cpPlugins_Base)
+TARGET_LINK_LIBRARIES(cpPlugins_Paths cpPlugins_Base ${VTK_LIBRARIES})
 TARGET_LINK_LIBRARIES(cpPlugins_Mesh cpPlugins_Base)
 TARGET_LINK_LIBRARIES(cpPlugins_Image cpPlugins_Base)
 TARGET_LINK_LIBRARIES(cpPlugins_ImageIterators ${ITK_LIBRARIES} cpPlugins_Image)
index 36f6ef4afc5e2b841898793475762e9e55df7433..03d83f9b7cd6bb4edc00d66cb61c9a1abc81727d 100644 (file)
@@ -1,10 +1,14 @@
 f cpPlugins_Instances/Base.h
 
+i cpExtensions/DataStructures/PolyLineParametricPath.h
 t itkPolyLineParametricPath.h
 t itkPath.h
 t itkParametricPath.h
 t itkVectorContainer.h
+t cpExtensions/Visualization/PolyLineParametricPathToPolyData.h
 
 d #dims=2;3
 
 c itk::PolyLineParametricPath< #dims >
+c cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< #dims > >
+