#ifndef _INC_GEOMETRIC #define _INC_GEOMETRIC #include "stdafx.h" #include "itkImage.h" #include "itkSmartPointer.h" #include #define medialNode 0 #define boundaryNode 1 #define internalNode 2 namespace mial{ //! Topological characteristics of the organism /*! The geometrical layer of a deformable organism is responsible for managing the physical instantiation of the organisms body. Hence, the geometrical ABC serves as the storage point for the organisms topology. \param dType The data type used for numerical storage. \param nDims The number of dimensions. \param MType The matrix type used for internal matrix storage. Defaults to vnl_matrix. Only vnl is supported at this time. \param VType The vector type used for internal vector storage. Defaults to vnl_vector. Only vnl is supported at this time. */ template < class dType, int nDims, class MType = vnl_matrix, class VType = vnl_vector > class Geometric:public itk::LightObject { public: //Smartpointer typedef Geometric Self; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; typedef itk::WeakPointer ConstWeakPointer; //itkNewMacro(Self); //! The internal vector type typedef VType VectorType; //! The internal matrix type typedef MType MatrixType; //! The type of binary image typedef typename itk::Image< unsigned char, nDims> BinaryImageType; protected: //! Default constructor Geometric(){numNodes =0;numConnections=0; topologyChange = true;nodesChange = true;}; //! An numNodes by nDims matrix containing all the nodes of the organism. /*! This must be updated anytime a derived class changes its own representation of nodes. This ensures a consistent data representation is available to all classes. However, for greater efficiency one could override the accessors to this function and therefore avoid doing the update; as the variable would never be accessed. */ MatrixType mNodes; //! A vector containing classifiers for all nodes. /*! Numerous #defines are supported, and can be overridden at risk of breaking compatibility with existing functionality. 0 - medialNode 1 - boundaryNode 2 - internalNode */ VectorType nodeClass; //! A numConnections by 2 matrix containing connections between nodes as rows. /*! This must be updated anytime a derived class changes its own representation of the topology. This ensures a consistent data representation is available to all classes. However, for greater efficiency one could override the accessors to this function and therefore avoid doing the update; as the variable would never be accessed. */ MatrixType mConnections; //! A vector containing classifiers for all connections. /*! Numerous #defines are supported, and can be overridden at risk of breaking compatibility with existing functionality. 0 - medialNode 1 - boundaryNode 2 - internalNode */ VectorType connectionClass; //! The number of nodes. Must be updated by derived classes when new nodes are added. unsigned int numNodes; //! The number of connections between nodes. Must be updated by derived classes when new connections are added. unsigned int numConnections; //! A state variable denoting a change in topology. /*! Set this variable true whenever a change in topology occurs. Any objects keeping local copies of topology (physic layers, etc) should check this state before running. */ bool topologyChange; //! A state variable denoting a change in node positions. /*! Set this variable true whenever a change in position or count of the nodes occurs. Any objects keeping local copies of topology (physic layers, etc) should check this state before running. */ bool nodesChange; public: struct Error{ std::string msg; }; virtual VectorType getCentroid(){ VectorType pos = VectorType(nDims); pos.fill(0); for(int i=0;i::Pointer generateBinaryImageFromTopology( typename BinaryImageType::SizeType )=0; //! Accessor for the number of connections. unsigned int getNumConnections(){return numConnections;}; //! Accessor for topology change /*! TODO: Decide if should be smart enough to know who is asking. Keep a list of clients. */ bool didTopologyChange(){if(topologyChange){topologyChange = false;return true;}else{return false;}}; //! Accessor for node position change /*! TODO: Decide if should be smart enough to know who is asking. Keep a list of clients. */ bool didNodesChange(){if(nodesChange){nodesChange = false;return true;}else{return false;}}; private: //! Pure virtual member that updates the matrix node positions. virtual void updateMatrixNodePositions()=0; //! Pure virtual member that updates the matrix connections. virtual void updateMatrixConnections()=0; }; }//end mial #include "Geometric.cxx" #endif /*_INC_GEOMETRIC*/