* vIt->second; --> this is the vertex's value <--
* }
*/
- typename TVertices::iterator BeginVertices( );
- typename TVertices::iterator EndVertices( );
- typename TVertices::const_iterator BeginVertices( ) const;
- typename TVertices::const_iterator EndVertices( ) const;
+ inline typename TVertices::iterator BeginVertices( )
+ { return( this->m_Vertices.begin( ) ); }
+ inline typename TVertices::iterator EndVertices( )
+ { return( this->m_Vertices.end( ) ); }
+ inline typename TVertices::const_iterator BeginVertices( ) const
+ { return( this->m_Vertices.begin( ) ); }
+ inline typename TVertices::const_iterator EndVertices( ) const
+ { return( this->m_Vertices.end( ) ); }
/*! \brief Iterators over edges.
* These allow you to iterate over all of graph's edges.
* }
* }
*/
- typename TMatrix::iterator BeginEdgesRows( );
- typename TMatrix::iterator EndEdgetsRows( );
- typename TMatrix::const_iterator BeginEdgesRows( ) const;
- typename TMatrix::const_iterator EndEdgesRows( ) const;
+ inline typename TMatrix::iterator BeginEdgesRows( )
+ { return( this->m_Matrix.begin( ) ); }
+ inline typename TMatrix::iterator EndEdgetsRows( )
+ { return( this->m_Matrix.end( ) ); }
+ inline typename TMatrix::const_iterator BeginEdgesRows( ) const
+ { return( this->m_Matrix.begin( ) ); }
+ inline typename TMatrix::const_iterator EndEdgesRows( ) const
+ { return( this->m_Matrix.end( ) ); }
/*! \brief Clear all vertices and edges.
*/
/*! \brief Clear all edges.
*/
- void ClearEdges( );
+ inline void ClearEdges( )
+ { this->m_Matrix.clear( ); }
/*! \brief Vertex manipulation methods.
* Names are self-explanatory.
*/
- bool HasVertexIndex( const I& index ) const;
- void SetVertex( const I& index, V& vertex );
+ inline bool HasVertexIndex( const I& i ) const
+ { return( this->m_Vertices.find( i ) != this->m_Vertices.end( ) ); }
+ inline void SetVertex( const I& index, V& vertex )
+ { this->m_Vertices[ index ] = vertex; }
+ inline V& GetVertex( const I& index )
+ { return( this->m_Vertices[ index ] ); }
+ inline const V& GetVertex( const I& index ) const
+ { return( this->m_Vertices[ index ] ); }
bool RenameVertex( const I& old_index, const I& new_index );
void RemoveVertex( const I& index );
- V& GetVertex( const I& index );
- const V& GetVertex( const I& index ) const;
/*! \brief Edge manipulation methods.
* Names are self-explanatory.
*/
+ inline void AddEdge( const I& orig, const I& dest, const C& cost )
+ { this->m_Matrix[ orig ][ dest ].push_back( cost ); }
+ inline TEdges& GetEdges( const I& orig, const I& dest )
+ { return( this->m_Matrix[ orig ][ dest ] ); }
+ inline const TEdges& GetEdges( const I& orig, const I& dest ) const
+ { return( this->m_Matrix[ orig ][ dest ] ); }
bool HasEdge( const I& orig, const I& dest ) const;
- void AddEdge( const I& orig, const I& dest, const C& cost );
void RemoveEdge( const I& orig, const I& dest, const C& cost );
void RemoveEdges( const I& orig, const I& dest );
- TEdges& GetEdges( const I& orig, const I& dest );
- const TEdges& GetEdges( const I& orig, const I& dest ) const;
/*! \brief Returns graph's sinks.
*
#ifndef __CPEXTENSIONS__DATASTRUCTURES__GRAPH__HXX__
#define __CPEXTENSIONS__DATASTRUCTURES__GRAPH__HXX__
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TVertices::iterator cpExtensions::DataStructures::Graph< V, C, I >::
-BeginVertices( )
-{
- return( this->m_Vertices.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TVertices::iterator cpExtensions::DataStructures::Graph< V, C, I >::
-EndVertices( )
-{
- return( this->m_Vertices.end( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TVertices::const_iterator cpExtensions::DataStructures::Graph< V, C, I >::
-BeginVertices( ) const
-{
- return( this->m_Vertices.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TVertices::const_iterator cpExtensions::DataStructures::Graph< V, C, I >::
-EndVertices( ) const
-{
- return( this->m_Vertices.end( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TMatrix::iterator cpExtensions::DataStructures::Graph< V, C, I >::
-BeginEdgesRows( )
-{
- return( this->m_Matrix.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TMatrix::iterator cpExtensions::DataStructures::Graph< V, C, I >::
-EndEdgetsRows( )
-{
- return( this->m_Matrix.end( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TMatrix::const_iterator cpExtensions::DataStructures::Graph< V, C, I >::
-BeginEdgesRows( ) const
-{
- return( this->m_Matrix.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TMatrix::const_iterator cpExtensions::DataStructures::Graph< V, C, I >::
-EndEdgesRows( ) const
-{
- return( this->m_Matrix.end( ) );
-}
-
// -------------------------------------------------------------------------
template< class V, class C, class I >
void cpExtensions::DataStructures::Graph< V, C, I >::
this->m_Matrix.clear( );
}
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-void cpExtensions::DataStructures::Graph< V, C, I >::
-ClearEdges( )
-{
- this->m_Matrix.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-bool cpExtensions::DataStructures::Graph< V, C, I >::
-HasVertexIndex( const I& index ) const
-{
- return( this->m_Vertices.find( index ) != this->m_Vertices.end( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-void cpExtensions::DataStructures::Graph< V, C, I >::
-SetVertex( const I& index, V& vertex )
-{
- this->m_Vertices[ index ] = vertex;
-}
-
// -------------------------------------------------------------------------
template< class V, class C, class I >
bool cpExtensions::DataStructures::Graph< V, C, I >::
return( false );
}
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-V& cpExtensions::DataStructures::Graph< V, C, I >::
-GetVertex( const I& index )
-{
- return( this->m_Vertices[ index ] );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-const V& cpExtensions::DataStructures::Graph< V, C, I >::
-GetVertex( const I& index ) const
-{
- return( this->m_Vertices[ index ] );
-}
-
// -------------------------------------------------------------------------
template< class V, class C, class I >
bool cpExtensions::DataStructures::Graph< V, C, I >::
return( false );
}
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-void cpExtensions::DataStructures::Graph< V, C, I >::
-AddEdge( const I& orig, const I& dest, const C& cost )
-{
- this->m_Matrix[ orig ][ dest ].push_back( cost );
-}
-
// -------------------------------------------------------------------------
template< class V, class C, class I >
void cpExtensions::DataStructures::Graph< V, C, I >::
}
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-typename cpExtensions::DataStructures::Graph< V, C, I >::
-TEdges& cpExtensions::DataStructures::Graph< V, C, I >::
-GetEdges( const I& orig, const I& dest )
-{
- return( this->m_Matrix[ orig ][ dest ] );
-}
-
-// -------------------------------------------------------------------------
-template< class V, class C, class I >
-const typename cpExtensions::DataStructures::Graph< V, C, I >::
-TEdges& cpExtensions::DataStructures::Graph< V, C, I >::
-GetEdges( const I& orig, const I& dest ) const
-{
- return( this->m_Matrix[ orig ][ dest ] );
-}
-
// -------------------------------------------------------------------------
template< class V, class C, class I >
std::set< I > cpExtensions::DataStructures::Graph< V, C, I >::
cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject::
GetSource( )
{
- return( this->m_Source );
+ auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source );
+ return( ptr->GetPointer( ) );
}
// -------------------------------------------------------------------------
const cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject::
GetSource( ) const
{
- return( this->m_Source );
+ auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source );
+ return( ptr->GetPointer( ) );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::DataObject::
SetSource( cpPlugins::Interface::ProcessObject* src )
{
- if( this->m_Source != src )
+ auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source );
+ if( ptr->GetPointer( ) != src )
{
- this->m_Source = src;
+ *ptr = src;
this->Modified( );
} // fi
// -------------------------------------------------------------------------
void cpPlugins::Interface::DataObject::
-DisconnectPipeline( )
+DisconnectFromPipeline( )
{
// Disconnect input pipelines (ITK)
itk::DataObject* itk_obj = this->GetITK< itk::DataObject >( );
} // fi
// Unbind source
- this->m_Source = NULL;
+ auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source );
+ *ptr = NULL;
this->Modified( );
}
// -------------------------------------------------------------------------
cpPlugins::Interface::DataObject::
DataObject( )
- : Superclass( ),
- m_Source( NULL )
+ : Superclass( )
{
+ this->m_Source = new ProcessObject::Pointer( );
}
// -------------------------------------------------------------------------
cpPlugins::Interface::DataObject::
~DataObject( )
{
+ auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source );
+ delete ptr;
}
// eof - $RCSfile$
const ProcessObject* GetSource( ) const;
void SetSource( ProcessObject* src );
- void DisconnectPipeline( );
+ void DisconnectFromPipeline( );
protected:
DataObject( );
Self& operator=( const Self& );
protected:
- ProcessObject* m_Source;
+ void* m_Source;
};
} // ecapseman
#include <itkObject.h>
#include <vtkObject.h>
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Object::
+SetViewCoords( float x, float y )
+{
+ this->m_ViewX = x;
+ this->m_ViewY = y;
+ // WARNING: do not call "this->Modified( )" -> It could lead to a
+ // re-execution of all pipeline
+}
+
+#ifdef cpPlugins_Interface_QT4
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Object::
+SetViewCoords( const QPointF& coords )
+{
+ this->SetViewCoords( coords.x( ), coords.y( ) );
+}
+
+// -------------------------------------------------------------------------
+QPointF cpPlugins::Interface::Object::
+GetViewCoords( ) const
+{
+ return( QPointF( this->m_ViewX, this->m_ViewY ) );
+}
+#endif // cpPlugins_Interface_QT4
+
// -------------------------------------------------------------------------
void cpPlugins::Interface::Object::
Modified( ) const
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::Object::
-SetViewCoords( float x, float y )
+itk::ModifiedTimeType cpPlugins::Interface::Object::
+GetMTime( ) const
{
- this->SetViewX( x );
- this->SetViewY( y );
+ unsigned long tTime = this->Superclass::GetMTime( );
+ unsigned long iTime = tTime;
+ unsigned long vTime = tTime;
+
+ const itk::Object* i = this->GetITK< itk::Object >( );
+ vtkObject* v = const_cast< vtkObject* >( this->GetVTK< vtkObject >( ) );
+ if( i != NULL ) iTime = i->GetMTime( );
+ if( v != NULL ) vTime = v->GetMTime( );
+
+ tTime = ( tTime < iTime )? tTime: iTime;
+ return( ( itk::ModifiedTimeType )( ( tTime < vTime )? tTime: vTime ) );
}
// -------------------------------------------------------------------------
: Superclass( ),
m_ITKObject( NULL ),
m_VTKObject( NULL ),
- m_Name( "" ),
m_ViewX( float( 0 ) ),
m_ViewY( float( 0 ) )
{
#include <vtkSmartPointer.h>
#include <vtkObjectBase.h>
+#ifdef cpPlugins_Interface_QT4
+#include <QPointF>
+#endif // cpPlugins_Interface_QT4
+
namespace cpPlugins
{
namespace Interface
itkTypeMacro( Object, itkObject );
cpPlugins_Id_Macro( Object, BaseObject );
- itkGetStringMacro( Name );
itkGetConstMacro( ViewX, float );
itkGetConstMacro( ViewY, float );
- itkSetStringMacro( Name );
- itkSetMacro( ViewX, float );
- itkSetMacro( ViewY, float );
-
public:
- virtual void Modified( ) const;
void SetViewCoords( float x, float y );
- void SetITK( itk::LightObject* o );
- void SetVTK( vtkObjectBase* o );
+#ifdef cpPlugins_Interface_QT4
+ void SetViewCoords( const QPointF& coords );
+ QPointF GetViewCoords( ) const;
+#endif // cpPlugins_Interface_QT4
+
+ virtual void Modified( ) const;
+ virtual itk::ModifiedTimeType GetMTime( ) const;
+
+ virtual void SetITK( itk::LightObject* o );
+ virtual void SetVTK( vtkObjectBase* o );
template< class T >
inline T* GetITK( );
protected:
itk::LightObject::Pointer m_ITKObject;
vtkSmartPointer< vtkObjectBase > m_VTKObject;
- std::string m_Name;
float m_ViewX;
float m_ViewY;
{
auto params_time = this->m_Parameters->GetMTime( );
auto filter_time = this->Superclass::GetMTime( );
- auto ipobj = this->GetITK< itk::ProcessObject >( );
- if( ipobj == NULL )
- {
- auto vpobj = this->GetVTK< vtkAlgorithm >( );
- if( vpobj != NULL )
- filter_time = ( const_cast< vtkAlgorithm* >( vpobj ) )->GetMTime( );
- }
- else
- filter_time = ipobj->GetMTime( );
- return( ( params_time < filter_time )? filter_time: params_time );
+ return( ( params_time < filter_time )? params_time: filter_time );
}
// -------------------------------------------------------------------------
std::string r = "";
// Force upstream updates
- _TDataContainer::iterator i = this->m_Inputs.begin( );
+ auto i = this->m_Inputs.begin( );
bool need_to_update = false;
for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
{
r = src->Update( );
} // fi
- }
- else
- r = "cpPlugins::Interface::ProcessObject: No input connected.";
+
+ } // fi
} // rof
ProcessObject( );
virtual ~ProcessObject( );
- void _AddInput( const std::string& name );
+ void _AddInput( const std::string& name, bool required );
template< class O >
inline void _AddOutput( const std::string& name );
template< class F >
this->m_Data = NULL;
}
-// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObjectPort::
-ProcessObjectPort( DataObject* obj )
-{
- this->m_Data = obj;
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObjectPort::
-ProcessObjectPort( const Self& other )
-{
- this->m_Data = other.m_Data.GetPointer( );
-}
-
// -------------------------------------------------------------------------
cpPlugins::Interface::ProcessObjectPort::
~ProcessObjectPort( )
return( this->m_Data.IsNotNull( ) );
}
+// -------------------------------------------------------------------------
+cpPlugins::Interface::InputProcessObjectPort::
+InputProcessObjectPort( bool required )
+ : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::InputProcessObjectPort::
+~InputProcessObjectPort( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::InputProcessObjectPort::
+Self& cpPlugins::Interface::InputProcessObjectPort::
+operator=( DataObject* obj )
+{
+ this->Superclass::operator=( obj );
+ return( *this );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::InputProcessObjectPort::
+Self& cpPlugins::Interface::InputProcessObjectPort::
+operator=( const Superclass& other )
+{
+ auto i = dynamic_cast< const InputProcessObjectPort* >( &other );
+ this->Superclass::operator=( other );
+ if( i != NULL )
+ this->m_Required = i->m_Required;
+ return( *this );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::InputProcessObjectPort::
+IsRequired( ) const
+{
+ return( this->m_Required );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::InputProcessObjectPort::
+RequiredOn( )
+{
+ this->SetRequired( true );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::InputProcessObjectPort::
+RequiredOff( )
+{
+ this->SetRequired( false );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::InputProcessObjectPort::
+SetRequired( bool required )
+{
+ this->m_Required = required;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::OutputProcessObjectPort::
+OutputProcessObjectPort( )
+ : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::OutputProcessObjectPort::
+~OutputProcessObjectPort( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::OutputProcessObjectPort::
+Self& cpPlugins::Interface::OutputProcessObjectPort::
+operator=( DataObject* obj )
+{
+ this->Superclass::operator=( obj );
+ return( *this );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::OutputProcessObjectPort::
+Self& cpPlugins::Interface::OutputProcessObjectPort::
+operator=( const Superclass& other )
+{
+ this->Superclass::operator=( other );
+ return( *this );
+}
+
// eof - $RCSfile$
public:
ProcessObjectPort( );
- ProcessObjectPort( DataObject* obj );
- ProcessObjectPort( const Self& other );
virtual ~ProcessObjectPort( );
Self& operator=( DataObject* obj );
Self& operator=( const Self& other );
bool IsValid( ) const;
// This could be seen as a pointer to DataObject's
- DataObject* GetPointer( )
+ inline DataObject* GetPointer( )
{ return( this->m_Data.GetPointer( ) ); }
- const DataObject* GetPointer( ) const
+ inline const DataObject* GetPointer( ) const
{ return( this->m_Data.GetPointer( ) ); }
- DataObject* operator->( ) const
+ inline DataObject* operator->( ) const
{ return( this->m_Data.GetPointer( ) ); }
protected:
cpPlugins::Interface::DataObject::Pointer m_Data;
+ };
+
+ /**
+ */
+ class cpPlugins_Interface_EXPORT InputProcessObjectPort
+ : public ProcessObjectPort
+ {
+ public:
+ typedef InputProcessObjectPort Self;
+ typedef ProcessObjectPort Superclass;
+
+ public:
+ InputProcessObjectPort( bool required = false );
+ virtual ~InputProcessObjectPort( );
+ Self& operator=( DataObject* obj );
+ Self& operator=( const Superclass& other );
+
+ bool IsRequired( ) const;
+ void RequiredOn( );
+ void RequiredOff( );
+ void SetRequired( bool required );
+ protected:
+ bool m_Required;
+ };
+
+ /**
+ */
+ class cpPlugins_Interface_EXPORT OutputProcessObjectPort
+ : public ProcessObjectPort
+ {
+ public:
+ typedef OutputProcessObjectPort Self;
+ typedef ProcessObjectPort Superclass;
+
+ public:
+ OutputProcessObjectPort( );
+ virtual ~OutputProcessObjectPort( );
+ Self& operator=( DataObject* obj );
+ Self& operator=( const Superclass& other );
};
} // ecapseman