]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 18 Oct 2016 23:00:33 +0000 (18:00 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 18 Oct 2016 23:00:33 +0000 (18:00 -0500)
lib/cpExtensions/DataStructures/Graph.h
lib/cpExtensions/Visualization/SkeletonToPolyData.cxx
lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx
lib/cpPlugins/DataObjects/Skeleton.cxx [new file with mode: 0644]
lib/cpPlugins/DataObjects/Skeleton.h [new file with mode: 0644]

index ed2d6ae337086d941fa19909d9eea3720d2935cd..d9e913d579b326a535d2ebcc8cb59261cea9874f 100644 (file)
@@ -5,7 +5,7 @@
 #include <map>
 #include <set>
 #include <vector>
-#include <itkLightObject.h>
+#include <itkDataObject.h>
 #include <itkObjectFactory.h>
 
 namespace cpExtensions
@@ -20,11 +20,11 @@ namespace cpExtensions
      */
     template< class _TVertex, class _TCost, class _TIndex = unsigned long, class _TIndexCompare = std::less< _TIndex > >
     class Graph
-      : public itk::LightObject
+      : public itk::DataObject
     {
     public:
       typedef Graph                           Self;
-      typedef itk::LightObject                Superclass;
+      typedef itk::DataObject                 Superclass;
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
@@ -41,7 +41,7 @@ namespace cpExtensions
 
     public:
       itkNewMacro( Self );
-      itkTypeMacro( Graph, itk::LightObject );
+      itkTypeMacro( Graph, itk::DataObject );
 
     public:
       /*! \brief Iterators over vertices.
index 8f5f4dbac4ae54b82ea3eedae90d4e44adcd8114..5aa7d207de3730e7fd6a8a6a5874cbe4a57f012c 100644 (file)
@@ -109,8 +109,8 @@ RequestData(
           if( i > 0 )
           {
             lines->InsertNextCell( 2 );
+            lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
             lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
-            lines->InsertCellPoint( points->GetNumberOfPoints( ) );
 
           } // fi
 
index 82e995756a7832aaf029488b13d16a4050187768..cafafb99a9a7a2efa5fb076c61df59a640dc3a43 100644 (file)
@@ -5,11 +5,16 @@
 void cpPlugins::DataObjects::PolyLineParametricPath::
 SetITK( itk::LightObject* o )
 {
+  typedef cpExtensions::DataStructures::PolyLineParametricPath< 1 > _T1;
+  typedef cpExtensions::DataStructures::PolyLineParametricPath< 2 > _T2;
+  typedef cpExtensions::DataStructures::PolyLineParametricPath< 3 > _T3;
+  typedef cpExtensions::DataStructures::PolyLineParametricPath< 4 > _T4;
+
   this->Superclass::SetITK( o );
-  auto l1 = dynamic_cast< cpExtensions::DataStructures::PolyLineParametricPath< 1 >* >( o );
-  auto l2 = dynamic_cast< cpExtensions::DataStructures::PolyLineParametricPath< 2 >* >( o );
-  auto l3 = dynamic_cast< cpExtensions::DataStructures::PolyLineParametricPath< 3 >* >( o );
-  auto l4 = dynamic_cast< cpExtensions::DataStructures::PolyLineParametricPath< 4 >* >( o );
+  auto l1 = dynamic_cast< _T1* >( o );
+  auto l2 = dynamic_cast< _T2* >( o );
+  auto l3 = dynamic_cast< _T3* >( o );
+  auto l4 = dynamic_cast< _T4* >( o );
   if     ( l1 != NULL ) this->_ITK_2_VTK( l1 );
   else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
   else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
diff --git a/lib/cpPlugins/DataObjects/Skeleton.cxx b/lib/cpPlugins/DataObjects/Skeleton.cxx
new file mode 100644 (file)
index 0000000..52d3f3c
--- /dev/null
@@ -0,0 +1,77 @@
+#include <cpPlugins/DataObjects/Skeleton.h>
+#include <cpExtensions/Visualization/SkeletonToPolyData.h>
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjects::Skeleton::
+SetITK( itk::LightObject* o )
+{
+  typedef cpExtensions::DataStructures::Skeleton< 1 > _T1;
+  typedef cpExtensions::DataStructures::Skeleton< 2 > _T2;
+  typedef cpExtensions::DataStructures::Skeleton< 3 > _T3;
+  typedef cpExtensions::DataStructures::Skeleton< 4 > _T4;
+
+  this->Superclass::SetITK( o );
+  auto l1 = dynamic_cast< _T1* >( o );
+  auto l2 = dynamic_cast< _T2* >( o );
+  auto l3 = dynamic_cast< _T3* >( o );
+  auto l4 = dynamic_cast< _T4* >( o );
+  if     ( l1 != NULL ) this->_ITK_2_VTK( l1 );
+  else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
+  else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
+  else if( l4 != NULL ) this->_ITK_2_VTK( l4 );
+  else
+  {
+    this->m_VTK = NULL;
+    this->m_ITKvVTK = NULL;
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjects::Skeleton::
+SetVTK( vtkObjectBase* o )
+{
+  // Do nothing
+  this->m_ITK = NULL;
+  this->m_VTK = NULL;
+  this->m_ITKvVTK = NULL;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObjects::Skeleton::
+Skeleton( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObjects::Skeleton::
+~Skeleton( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+void cpPlugins::DataObjects::Skeleton::
+_ITK_2_VTK( _TSkeleton* sk )
+{
+  typedef
+    cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >
+    _TFilter;
+  _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
+  if( f == NULL )
+  {
+    _TFilter* nf = _TFilter::New( );
+    this->m_ITKvVTK = nf;
+    f = nf;
+
+  } // fi
+  f->SetInput( sk );
+  f->Update( );
+
+  // Keep object track
+  this->m_ITK = sk;
+  this->m_VTK = f->GetOutput( );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/DataObjects/Skeleton.h b/lib/cpPlugins/DataObjects/Skeleton.h
new file mode 100644 (file)
index 0000000..153635c
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef __cpPlugins__DataObjects__Skeleton__h__
+#define __cpPlugins__DataObjects__Skeleton__h__
+
+#include <cpPlugins/BaseObjects/DataObject.h>
+#include <cpPlugins_Paths.h>
+#include <vtkSmartPointer.h>
+
+// -------------------------------------------------------------------------
+class vtkPolyDataAlgorithm;
+
+// -------------------------------------------------------------------------
+namespace cpPlugins
+{
+  namespace DataObjects
+  {
+    /**
+     */
+    class cpPlugins_EXPORT Skeleton
+      : public cpPlugins::BaseObjects::DataObject
+    {
+    public:
+      typedef Skeleton                           Self;
+      typedef cpPlugins::BaseObjects::DataObject Superclass;
+      typedef itk::SmartPointer< Self >          Pointer;
+      typedef itk::SmartPointer< const Self >    ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro(
+        Skeleton, cpPlugins::BaseObjects::DataObject
+        );
+      cpPlugins_Id_Macro( Skeleton, Object );
+      cpPlugins_Compatibility_Macro;
+
+    public:
+      virtual void SetITK( itk::LightObject* o ) cpPlugins_OVERRIDE;
+      virtual void SetVTK( vtkObjectBase* o ) cpPlugins_OVERRIDE;
+
+    protected:
+      Skeleton( );
+      virtual ~Skeleton( );
+
+      template< class _TSkeleton >
+      inline void _ITK_2_VTK( _TSkeleton* sk );
+
+    private:
+      // Purposely not implemented
+      Skeleton( const Self& );
+      Self& operator=( const Self& );
+
+    protected:
+      vtkSmartPointer< vtkPolyDataAlgorithm > m_ITKvVTK;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __cpPlugins__DataObjects__Skeleton__h__
+
+// eof - $RCSfile$