HeartGeometryInformation.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 #ifndef HEARTGEOMETRYINFORMATION_HPP_
00029 #define HEARTGEOMETRYINFORMATION_HPP_
00030 
00031 #include <vector>
00032 #include <string>
00033 #include <set>
00034 #include "DistanceMapCalculator.hpp"
00035 #include "AbstractTetrahedralMesh.hpp"
00036 #include "ChasteCuboid.hpp"
00037 
00039 typedef enum HeartLayerType_
00040 {
00041     ENDO = 0,
00042     MID,
00043     EPI
00044 } HeartLayerType;
00045 
00047 typedef unsigned HeartRegionType;
00048 
00049 
00054 template<unsigned SPACE_DIM>
00055 class HeartGeometryInformation
00056 {
00057 private:
00058 
00060     static const double LEFT_SEPTUM_SIZE;
00062     static const double RIGHT_SEPTUM_SIZE;
00063 
00065     std::vector<unsigned> mEpiSurface;
00066 
00068     std::vector<unsigned> mEndoSurface;
00069 
00071     std::vector<unsigned> mLVSurface;
00072 
00074     std::vector<unsigned> mRVSurface;
00075 
00085     void GetNodesAtSurface(const std::string& surfaceFile, std::vector<unsigned>& rSurfaceNodes, bool indexFromZero=true) const;
00086 
00093     void ProcessLine(const std::string& line, std::set<unsigned>& rSurfaceNodeIndexSet, unsigned offset) const;
00094 
00102     double GetDistanceToEndo(unsigned nodeIndex);
00103 
00110     double GetDistanceToEpi(unsigned nodeIndex);
00111 
00113     AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>* mpMesh;
00114 
00116     std::vector<double> mDistMapEpicardium;
00117 
00119     std::vector<double> mDistMapEndocardium;
00120 
00122     std::vector<double> mDistMapRightVentricle;
00123 
00125     std::vector<double> mDistMapLeftVentricle;
00126 
00128     unsigned mNumberOfSurfacesProvided;
00129 
00131     std::vector<HeartLayerType> mLayerForEachNode;
00132 
00138     ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfSurface(const std::vector<unsigned>& rSurfaceNodes);
00139 
00140 public:
00142 
00143     static const HeartRegionType LEFT_VENTRICLE_WALL=1001;
00145     static const HeartRegionType RIGHT_VENTRICLE_WALL=1002;
00147     static const HeartRegionType LEFT_SEPTUM=1003;
00149     static const HeartRegionType RIGHT_SEPTUM=1004;
00151     static const HeartRegionType LEFT_VENTRICLE_SURFACE=1005;
00153     static const HeartRegionType RIGHT_VENTRICLE_SURFACE=1006;
00155     static const HeartRegionType UNKNOWN=1007;
00156 
00165     HeartGeometryInformation (AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>& rMesh,
00166                               const std::string& rEpiFile,
00167                               const std::string& rEndoFile,
00168                               bool indexFromZero);
00169 
00170 
00184     HeartGeometryInformation (AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>& rMesh,
00185                               const std::string& rEpiFile,
00186                               const std::string& rLVFile,
00187                               const std::string& rRVFile,
00188                               bool indexFromZero);
00189 
00199     HeartGeometryInformation (std::string nodeHeterogeneityFileName);
00200 
00205     HeartRegionType GetHeartRegion (unsigned nodeIndex) const;
00206 
00211     std::vector<double>& rGetDistanceMapEpicardium()
00212     {
00213         return mDistMapEpicardium;
00214     }
00215 
00220     std::vector<double>& rGetDistanceMapEndocardium()
00221     {
00222         assert(mNumberOfSurfacesProvided==2);
00223         return mDistMapEndocardium;
00224     }
00225 
00230     std::vector<double>& rGetDistanceMapRightVentricle()
00231     {
00232         assert(mNumberOfSurfacesProvided==3);
00233         return mDistMapRightVentricle;
00234     }
00235 
00240     std::vector<double>& rGetDistanceMapLeftVentricle()
00241     {
00242         assert(mNumberOfSurfacesProvided==3);
00243         return mDistMapLeftVentricle;
00244     }
00245 
00247     const std::vector<unsigned>& rGetNodesOnEpiSurface()
00248     {
00249         return mEpiSurface;
00250     }
00251 
00252 
00254     const std::vector<unsigned>& rGetNodesOnEndoSurface()
00255     {
00256         assert(mNumberOfSurfacesProvided==2);
00257         return mEndoSurface;
00258     }
00259 
00261     const std::vector<unsigned>& rGetNodesOnLVSurface()
00262     {
00263         assert(mNumberOfSurfacesProvided==3);
00264         return mLVSurface;
00265     }
00266 
00268     const std::vector<unsigned>& rGetNodesOnRVSurface()
00269     {
00270         assert(mNumberOfSurfacesProvided==3);
00271         return mRVSurface;
00272     }
00273 
00277     const std::vector<HeartLayerType>& rGetLayerForEachNode()
00278     {
00279         assert(mLayerForEachNode.size()>0);
00280         return mLayerForEachNode;
00281     }
00282 
00288     double CalculateRelativeWallPosition(unsigned nodeIndex);
00289 
00295     void DetermineLayerForEachNode(double epiFraction, double endoFraction);
00296 
00304     void WriteLayerForEachNode(std::string outputDir, std::string file);
00305 
00312     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfEpi()
00313     {
00314         return CalculateBoundingBoxOfSurface(mEpiSurface);
00315     }
00322     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfEndo()
00323     {
00324         return CalculateBoundingBoxOfSurface(mEndoSurface);
00325     }
00332     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfLV()
00333     {
00334         return CalculateBoundingBoxOfSurface(mLVSurface);
00335     }
00342      inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfRV()
00343     {
00344         return CalculateBoundingBoxOfSurface(mRVSurface);
00345     }
00346 };
00347 #endif //HEARTGEOMETRYINFORMATION_HPP_
00348 
Generated on Thu Dec 22 13:00:06 2011 for Chaste by  doxygen 1.6.3