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 
00180     HeartGeometryInformation (AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>& rMesh,
00181                               const std::string& rEpiFile,
00182                               const std::string& rLVFile,
00183                               const std::string& rRVFile,
00184                               bool indexFromZero);
00185 
00195     HeartGeometryInformation (std::string nodeHeterogeneityFileName);
00196 
00201     HeartRegionType GetHeartRegion (unsigned nodeIndex) const;
00202 
00207     std::vector<double>& rGetDistanceMapEpicardium()
00208     {
00209         return mDistMapEpicardium;
00210     }
00211 
00216     std::vector<double>& rGetDistanceMapEndocardium()
00217     {
00218         assert(mNumberOfSurfacesProvided==2);
00219         return mDistMapEndocardium;
00220     }
00221 
00226     std::vector<double>& rGetDistanceMapRightVentricle()
00227     {
00228         assert(mNumberOfSurfacesProvided==3);
00229         return mDistMapRightVentricle;
00230     }
00231 
00236     std::vector<double>& rGetDistanceMapLeftVentricle()
00237     {
00238         assert(mNumberOfSurfacesProvided==3);
00239         return mDistMapLeftVentricle;
00240     }
00241 
00243     const std::vector<unsigned>& rGetNodesOnEpiSurface()
00244     {
00245         return mEpiSurface;
00246     }
00247 
00248 
00250     const std::vector<unsigned>& rGetNodesOnEndoSurface()
00251     {
00252         assert(mNumberOfSurfacesProvided==2);
00253         return mEndoSurface;
00254     }
00255 
00257     const std::vector<unsigned>& rGetNodesOnLVSurface()
00258     {
00259         assert(mNumberOfSurfacesProvided==3);
00260         return mLVSurface;
00261     }
00262 
00264     const std::vector<unsigned>& rGetNodesOnRVSurface()
00265     {
00266         assert(mNumberOfSurfacesProvided==3);
00267         return mRVSurface;
00268     }
00269 
00273     const std::vector<HeartLayerType>& rGetLayerForEachNode()
00274     {
00275         assert(mLayerForEachNode.size()>0);
00276         return mLayerForEachNode;
00277     }
00278 
00284     double CalculateRelativeWallPosition(unsigned nodeIndex);
00285 
00291     void DetermineLayerForEachNode(double epiFraction, double endoFraction);
00292 
00300     void WriteLayerForEachNode(std::string outputDir, std::string file);
00301 
00308     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfEpi()
00309     {
00310         return CalculateBoundingBoxOfSurface(mEpiSurface);
00311     }
00318     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfEndo()
00319     {
00320         return CalculateBoundingBoxOfSurface(mEndoSurface);
00321     }
00328     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfLV()
00329     {
00330         return CalculateBoundingBoxOfSurface(mLVSurface);
00331     }
00338      inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfRV()
00339     {
00340         return CalculateBoundingBoxOfSurface(mRVSurface);
00341     }
00342 };
00343 #endif //HEARTGEOMETRYINFORMATION_HPP_
00344 

Generated on Mon Apr 18 11:35:28 2011 for Chaste by  doxygen 1.5.5