HeartGeometryInformation.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 "HeartRegionCodes.hpp"
00037 #include "ChasteCuboid.hpp"
00038 
00040 typedef enum HeartLayerType_
00041 {
00042     ENDO = 0,
00043     MID,
00044     EPI
00045 } HeartLayerType;
00046 
00047 
00052 template<unsigned SPACE_DIM>
00053 class HeartGeometryInformation
00054 {
00055 private:
00056 
00058     static const double LEFT_SEPTUM_SIZE;
00060     static const double RIGHT_SEPTUM_SIZE;
00061 
00063     std::vector<unsigned> mEpiSurface;
00064 
00066     std::vector<unsigned> mEndoSurface;
00067 
00069     std::vector<unsigned> mLVSurface;
00070 
00072     std::vector<unsigned> mRVSurface;
00073 
00083     void GetNodesAtSurface(const std::string& surfaceFile, std::vector<unsigned>& rSurfaceNodes, bool indexFromZero=true) const;
00084 
00091     void ProcessLine(const std::string& line, std::set<unsigned>& rSurfaceNodeIndexSet, unsigned offset) const;
00092 
00100     double GetDistanceToEndo(unsigned nodeIndex);
00101 
00108     double GetDistanceToEpi(unsigned nodeIndex);
00109 
00111     AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>* mpMesh;
00112 
00114     std::vector<double> mDistMapEpicardium;
00115 
00117     std::vector<double> mDistMapEndocardium;
00118 
00120     std::vector<double> mDistMapRightVentricle;
00121 
00123     std::vector<double> mDistMapLeftVentricle;
00124 
00126     unsigned mNumberOfSurfacesProvided;
00127 
00129     std::vector<HeartLayerType> mLayerForEachNode;
00130 
00136     ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfSurface(const std::vector<unsigned>& rSurfaceNodes);
00137 
00138 public:
00147     HeartGeometryInformation (AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>& rMesh,
00148                               const std::string& rEpiFile,
00149                               const std::string& rEndoFile,
00150                               bool indexFromZero);
00151 
00152 
00162     HeartGeometryInformation (AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>& rMesh,
00163                               const std::string& rEpiFile,
00164                               const std::string& rLVFile,
00165                               const std::string& rRVFile,
00166                               bool indexFromZero);
00167 
00177     HeartGeometryInformation (std::string nodeHeterogeneityFileName);
00178 
00183     HeartRegionType GetHeartRegion (unsigned nodeIndex) const;
00184 
00189     std::vector<double>& rGetDistanceMapEpicardium()
00190     {
00191         return mDistMapEpicardium;
00192     }
00193 
00198     std::vector<double>& rGetDistanceMapEndocardium()
00199     {
00200         assert(mNumberOfSurfacesProvided==2);
00201         return mDistMapEndocardium;
00202     }
00203 
00208     std::vector<double>& rGetDistanceMapRightVentricle()
00209     {
00210         assert(mNumberOfSurfacesProvided==3);
00211         return mDistMapRightVentricle;
00212     }
00213 
00218     std::vector<double>& rGetDistanceMapLeftVentricle()
00219     {
00220         assert(mNumberOfSurfacesProvided==3);
00221         return mDistMapLeftVentricle;
00222     }
00223 
00225     const std::vector<unsigned>& rGetNodesOnEpiSurface()
00226     {
00227         return mEpiSurface;
00228     }
00229 
00230 
00232     const std::vector<unsigned>& rGetNodesOnEndoSurface()
00233     {
00234         assert(mNumberOfSurfacesProvided==2);
00235         return mEndoSurface;
00236     }
00237 
00239     const std::vector<unsigned>& rGetNodesOnLVSurface()
00240     {
00241         assert(mNumberOfSurfacesProvided==3);
00242         return mLVSurface;
00243     }
00244 
00246     const std::vector<unsigned>& rGetNodesOnRVSurface()
00247     {
00248         assert(mNumberOfSurfacesProvided==3);
00249         return mRVSurface;
00250     }
00251 
00255     const std::vector<HeartLayerType>& rGetLayerForEachNode()
00256     {
00257         assert(mLayerForEachNode.size()>0);
00258         return mLayerForEachNode;
00259     }
00260 
00266     double CalculateRelativeWallPosition(unsigned nodeIndex);
00267 
00273     void DetermineLayerForEachNode(double epiFraction, double endoFraction);
00274 
00282     void WriteLayerForEachNode(std::string outputDir, std::string file);
00283 
00290     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfEpi()
00291     {
00292         return CalculateBoundingBoxOfSurface(mEpiSurface);
00293     }
00300     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfEndo()
00301     {
00302         return CalculateBoundingBoxOfSurface(mEndoSurface);
00303     }
00310     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfLV()
00311     {
00312         return CalculateBoundingBoxOfSurface(mLVSurface);
00313     }
00320      inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfRV()
00321     {
00322         return CalculateBoundingBoxOfSurface(mRVSurface);
00323     }
00324 };
00325 #endif //HEARTGEOMETRYINFORMATION_HPP_
00326 

Generated on Mon Nov 1 12:35:17 2010 for Chaste by  doxygen 1.5.5