C:/cmcintos/defOrgs/source/geometrical/Geom_MeshSpatialObject.h

00001 #if !defined(_GEOM_MESHSPATIALOBJECT)
00002 #define _GEOM_MESHSPATIALOBJECT
00003 
00004 #include "Geometric.h"
00005 #include <itkMeshSpatialObject.h>
00006 #include <itkSpatialObjectReader.h>
00007 #include <itkSpatialObjectWriter.h>
00008 #include <itkSpatialObjectToImageFilter.h>
00009 #include <itkDefaultDynamicMeshTraits.h>
00010 #include "itkLineCell.h"
00011 #include "itkTriangleCell.h"
00012 #include "itkImage.h"
00013 #include <itkBinaryMask3DMeshSource.h>
00014 #include <itkMinimumMaximumImageFilter.h>
00015 #include "vnl/vnl_cross.h"
00016 #include "itkImageRegionConstIterator.h"
00017 #include "itkImageRegionIterator.h"
00018 #include "itkTriangleMeshToBinaryImageFilter.h"
00019 
00020 namespace mial{
00021 
00023 
00042         template < class dType, int nDims, class MType = vnl_matrix<dType>, class VType = vnl_vector<dType> >
00043         class Geom_MeshSpatialObject
00044                 : public Geometric< dType, nDims, MType, VType >
00045         {
00046                 /****************************************************
00047                 MEMBERS
00048                 *****************************************************/
00049         public:
00050 
00051                 //Smartpointer
00052                 typedef Geom_MeshSpatialObject Self;
00053                 typedef itk::SmartPointer<Self>  Pointer;
00054                 typedef itk::SmartPointer<const Self>  ConstPointer;
00055                 typedef itk::WeakPointer<const Self>  ConstWeakPointer;
00056                 itkNewMacro(Self);
00057 
00058 
00059                 typedef MType MatrixType;
00060                 typedef VType VectorType;
00061 
00062                 typedef itk::DefaultDynamicMeshTraits< dType, nDims, nDims >    MeshTrait;
00063                 typedef itk::Mesh< dType, nDims, MeshTrait >                    MeshType;
00064                 typedef typename MeshType::PointType                            PointType;
00065                 typedef typename itk::MeshSpatialObject< MeshType >             MeshSpatialObjectType;
00066                 typedef typename MeshSpatialObjectType::Pointer                 MeshSpatialObjectPointerType;
00067 
00068                 typename MeshSpatialObjectType::Pointer                         theMeshSpatialObject;
00069                 typename MeshType::Pointer                                      theMesh;
00070                 //Note you need to overwrite this whenever you overwrite the spatialobjects mesh
00071 
00072                 typedef typename MeshType::CellType                             CellType;
00073                 typedef typename CellType::CoordRepType                         CoordRepType;
00074                 //typedef itk::LineCell< CellType >                             LineType;
00075                 typedef itk::TriangleCell<CellType>                             TriangleType;
00076                 typedef typename CellType::CellAutoPointer                      CellAutoPointer;
00077                 typedef typename MeshType::CellsContainer::ConstIterator        CellIterator;
00078 
00079                 typedef itk::GroupSpatialObject< nDims >                        GroupType;
00080                 typedef itk::SpatialObjectReader<nDims,dType,MeshTrait>         ReaderType;
00081                 typedef itk::SpatialObjectWriter< nDims, dType, MeshTrait >     WriterType;
00082                 typename WriterType::Pointer                                    writer;
00083 
00084                 typedef typename Geometric< dType, nDims >::BinaryImageType     BinaryImageType;
00085                 typedef typename BinaryImageType::Pointer                       BinaryImageTypePointer;
00086 
00087                 /*****************************************************
00088                 METHODS
00089                 ******************************************************/
00090         public:
00091 
00092                 virtual MatrixType getMatrixNodePositions();
00093 
00094                 virtual void writeNodesToFile(std::string fileName);
00095 
00096                 virtual void readNodesFromFile(std::string fileName);
00097                 virtual bool readTopologyFromFile(std::string fileName);
00098 
00099                 virtual bool setMatrixNodePositions(MatrixType,int *);
00100 
00101                 virtual bool setMatrixNodePositions(MatrixType);
00102 
00103                 virtual void writeObjectToFile(std::string fileName);
00104 
00105 
00106                 //TODO Fix to use correct type
00107                 virtual typename itk::Image< unsigned char, nDims>::Pointer generateBinaryImageFromTopology( typename BinaryImageType::SizeType size);
00108 
00109                 virtual void generateTopologyFromBinaryImage( BinaryImageTypePointer binaryInputImage );
00110 
00111                 
00112                 // TODO fill in code for adding/removing nodes
00113                 virtual bool removeNode(int nodeNumber){return false;};
00114                 virtual bool addNodes(MatrixType node,VectorType classes);
00115                 virtual bool addConnection(int,int);
00116                 virtual MatrixType getMatrixConnections(){/* TODO fill in implmentation.*/ return this->mConnections;};
00117 
00118                 virtual bool isInside(VectorType p);
00119         private:
00120                 virtual void updateMatrixNodePositions();
00121                 virtual void updateMeshNodePositions();
00122                 virtual void updateMatrixConnections();
00123                 virtual bool intersectWithLine( VectorType L, VectorType P, TriangleType* tri);
00124 
00125                 dType m_IsInsidePrecision;
00126         
00127         protected:
00129 
00132                 Geom_MeshSpatialObject(dType p=0.001);
00133 
00134         };
00135 }//end mial
00136 #include "Geom_MeshSpatialObject.cxx"
00137 #endif
00138 

Generated on Wed Jul 19 13:05:17 2006 for IDO by  doxygen 1.4.7