IGSTK
/build/buildd/igstk-4.4.0/Source/igstkMeshReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Image Guided Surgery Software Toolkit
00004   Module:    $RCSfile: igstkMeshReader.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-05-05 20:41:09 $
00007   Version:   $Revision: 1.13 $
00008 
00009   Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
00010   See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __igstkMeshReader_h
00018 #define __igstkMeshReader_h
00019 
00020 #include "igstkSpatialObjectReader.h"
00021 #include "igstkMeshObject.h"
00022 
00023 namespace igstk
00024 {
00025 
00026 namespace Friends 
00027 {
00028 
00038 class MeshReaderToMeshSpatialObject
00039 {
00040 public:
00041 
00042   template < class TReader, class TMeshSpatialObject >
00043   static void 
00044   ConnectMesh(  TReader * reader, 
00045                 TMeshSpatialObject * meshSpatialObject )
00046     {
00047     meshSpatialObject->SetMesh( reader->GetITKMesh() );  
00048     }
00049 
00050 }; // end of MeshReaderToMeshSpatialObject class
00051 
00052 } // end of Friend namespace
00053 
00054 
00070 class MeshReader : public SpatialObjectReader<3,float>
00071 {
00072 
00073 public:
00074 
00077   typedef SpatialObjectReader<3,float>       SuperclassType;
00078 
00080   igstkStandardClassTraitsMacro( MeshReader, SuperclassType )
00081 
00082 public:
00083 
00085   typedef Superclass::SpatialObjectType      SpatialObjectType;
00086   typedef Superclass::GroupSpatialObjectType GroupSpatialObjectType;
00087   typedef SpatialObjectType::ConstPointer    SpatialObjectTypeConstPointer;
00088   typedef igstk::MeshObject                  MeshObjectType;
00089 
00091   igstkEventMacro( MeshReaderEvent,ObjectReaderEvent )
00092   igstkEventMacro( MeshReadingErrorEvent, ObjectReadingErrorEvent )
00093   igstkLoadedObjectEventMacro( MeshModifiedEvent, MeshReaderEvent, 
00094                                                               MeshObjectType )
00095 
00096 protected:
00097 
00098   typedef MeshObjectType::MeshType           MeshType;
00099 
00100 public:
00101 
00104   igstkFriendClassMacro( igstk::Friends::MeshReaderToMeshSpatialObject );
00105 
00106 protected:
00107 
00108   MeshReader( void );
00109   ~MeshReader( void );
00110 
00112   void PrintSelf( std::ostream& os, itk::Indent indent ) const; 
00113 
00116   void AttemptReadObjectProcessing();
00117 
00119   void ReportObjectProcessing();
00120 
00122   void ConnectMesh();
00123 
00124 private:
00125 
00126   MeshReader(const Self&);         //purposely not implemented
00127   void operator=(const Self&);     //purposely not implemented
00128 
00129   // FIXME : This must be replaced with StateMachine logic
00130   virtual MeshType * GetITKMesh() const;
00131 
00132   MeshObjectType::Pointer   m_MeshObject;
00133   MeshType::Pointer         m_Mesh;
00134 
00135 };
00136 
00137 } // end namespace igstk
00138 
00139 
00140 #endif // __igstkMeshReader_h