HeartGeometryInformation.hpp

00001 /*
00002 
00003 Copyright (c) 2005-2015, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 #ifndef HEARTGEOMETRYINFORMATION_HPP_
00036 #define HEARTGEOMETRYINFORMATION_HPP_
00037 
00038 #include <vector>
00039 #include <string>
00040 #include <set>
00041 #include "DistanceMapCalculator.hpp"
00042 #include "AbstractTetrahedralMesh.hpp"
00043 #include "ChasteCuboid.hpp"
00044 
00046 typedef enum HeartLayerType_
00047 {
00048     ENDO = 0,
00049     MID,
00050     EPI
00051 } HeartLayerType;
00052 
00054 typedef unsigned HeartRegionType;
00055 
00056 
00061 template<unsigned SPACE_DIM>
00062 class HeartGeometryInformation
00063 {
00064 private:
00065 
00067     static const double LEFT_SEPTUM_SIZE;
00069     static const double RIGHT_SEPTUM_SIZE;
00070 
00072     std::vector<unsigned> mEpiSurface;
00073 
00075     std::vector<unsigned> mEndoSurface;
00076 
00078     std::vector<unsigned> mLVSurface;
00079 
00081     std::vector<unsigned> mRVSurface;
00082 
00096     void GetNodesAtSurface(const std::string& surfaceFile,
00097                            std::vector<unsigned>& rSurfaceNodes,
00098                            bool indexFromZero=true) const;
00099 
00106     void ProcessLine(const std::string& line,
00107                      std::set<unsigned>& rSurfaceNodeIndexSet,
00108                      unsigned offset) const;
00109 
00117     double GetDistanceToEndo(unsigned nodeIndex);
00118 
00125     double GetDistanceToEpi(unsigned nodeIndex);
00126 
00128     AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>* mpMesh;
00129 
00131     std::vector<double> mDistMapEpicardium;
00132 
00134     std::vector<double> mDistMapEndocardium;
00135 
00137     std::vector<double> mDistMapRightVentricle;
00138 
00140     std::vector<double> mDistMapLeftVentricle;
00141 
00143     unsigned mNumberOfSurfacesProvided;
00144 
00146     std::vector<HeartLayerType> mLayerForEachNode;
00147 
00153     ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfSurface(const std::vector<unsigned>& rSurfaceNodes);
00154 
00155 public:
00157 
00158     static const HeartRegionType LEFT_VENTRICLE_WALL=1001;
00160     static const HeartRegionType RIGHT_VENTRICLE_WALL=1002;
00162     static const HeartRegionType LEFT_SEPTUM=1003;
00164     static const HeartRegionType RIGHT_SEPTUM=1004;
00166     static const HeartRegionType LEFT_VENTRICLE_SURFACE=1005;
00168     static const HeartRegionType RIGHT_VENTRICLE_SURFACE=1006;
00170     static const HeartRegionType UNKNOWN=1007;
00171 
00181     HeartGeometryInformation (AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>& rMesh,
00182                               const std::string& rEpiFile,
00183                               const std::string& rEndoFile,
00184                               bool indexFromZero);
00185 
00186 
00201     HeartGeometryInformation (AbstractTetrahedralMesh<SPACE_DIM,SPACE_DIM>& rMesh,
00202                               const std::string& rEpiFile,
00203                               const std::string& rLVFile,
00204                               const std::string& rRVFile,
00205                               bool indexFromZero);
00206 
00216     HeartGeometryInformation (std::string nodeHeterogeneityFileName);
00217 
00222     HeartRegionType GetHeartRegion (unsigned nodeIndex) const;
00223 
00228     std::vector<double>& rGetDistanceMapEpicardium()
00229     {
00230         return mDistMapEpicardium;
00231     }
00232 
00237     std::vector<double>& rGetDistanceMapEndocardium()
00238     {
00239         assert(mNumberOfSurfacesProvided==2);
00240         return mDistMapEndocardium;
00241     }
00242 
00247     std::vector<double>& rGetDistanceMapRightVentricle()
00248     {
00249         assert(mNumberOfSurfacesProvided==3);
00250         return mDistMapRightVentricle;
00251     }
00252 
00257     std::vector<double>& rGetDistanceMapLeftVentricle()
00258     {
00259         assert(mNumberOfSurfacesProvided==3);
00260         return mDistMapLeftVentricle;
00261     }
00262 
00264     const std::vector<unsigned>& rGetNodesOnEpiSurface()
00265     {
00266         return mEpiSurface;
00267     }
00268 
00269 
00271     const std::vector<unsigned>& rGetNodesOnEndoSurface()
00272     {
00273         assert(mNumberOfSurfacesProvided==2);
00274         return mEndoSurface;
00275     }
00276 
00278     const std::vector<unsigned>& rGetNodesOnLVSurface()
00279     {
00280         assert(mNumberOfSurfacesProvided==3);
00281         return mLVSurface;
00282     }
00283 
00285     const std::vector<unsigned>& rGetNodesOnRVSurface()
00286     {
00287         assert(mNumberOfSurfacesProvided==3);
00288         return mRVSurface;
00289     }
00290 
00294     const std::vector<HeartLayerType>& rGetLayerForEachNode()
00295     {
00296         assert(mLayerForEachNode.size()>0);
00297         return mLayerForEachNode;
00298     }
00299 
00305     double CalculateRelativeWallPosition(unsigned nodeIndex);
00306 
00312     void DetermineLayerForEachNode(double epiFraction, double endoFraction);
00313 
00321     void WriteLayerForEachNode(std::string outputDir, std::string file);
00322 
00330     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfEpi()
00331     {
00332         return CalculateBoundingBoxOfSurface(mEpiSurface);
00333     }
00341     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfEndo()
00342     {
00343         return CalculateBoundingBoxOfSurface(mEndoSurface);
00344     }
00352     inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfLV()
00353     {
00354         return CalculateBoundingBoxOfSurface(mLVSurface);
00355     }
00363      inline ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfRV()
00364     {
00365         return CalculateBoundingBoxOfSurface(mRVSurface);
00366     }
00367 };
00368 #endif //HEARTGEOMETRYINFORMATION_HPP_
00369 

Generated by  doxygen 1.6.2