Chaste  Release::2018.1
HeartGeometryInformation.hpp
1 /*
2 
3 Copyright (c) 2005-2018, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 #ifndef HEARTGEOMETRYINFORMATION_HPP_
36 #define HEARTGEOMETRYINFORMATION_HPP_
37 
38 #include <vector>
39 #include <string>
40 #include <set>
41 #include "DistanceMapCalculator.hpp"
42 #include "AbstractTetrahedralMesh.hpp"
43 #include "ChasteCuboid.hpp"
44 
46 typedef enum HeartLayerType_
47 {
48  ENDO = 0,
49  MID,
50  EPI
51 } HeartLayerType;
52 
54 typedef unsigned HeartRegionType;
55 
56 
61 template<unsigned SPACE_DIM>
63 {
64 private:
65 
67  static const double LEFT_SEPTUM_SIZE;
69  static const double RIGHT_SEPTUM_SIZE;
70 
72  std::vector<unsigned> mEpiSurface;
73 
75  std::vector<unsigned> mEndoSurface;
76 
78  std::vector<unsigned> mLVSurface;
79 
81  std::vector<unsigned> mRVSurface;
82 
96  void GetNodesAtSurface(const std::string& rSurfaceFileName,
97  std::vector<unsigned>& rSurfaceNodes,
98  bool indexFromZero=true) const;
99 
106  void ProcessLine(const std::string& rLineFromFile,
107  std::set<unsigned>& rSurfaceNodeIndexSet,
108  unsigned offset) const;
109 
117  double GetDistanceToEndo(unsigned nodeIndex);
118 
125  double GetDistanceToEpi(unsigned nodeIndex);
126 
129 
131  std::vector<double> mDistMapEpicardium;
132 
134  std::vector<double> mDistMapEndocardium;
135 
137  std::vector<double> mDistMapRightVentricle;
138 
140  std::vector<double> mDistMapLeftVentricle;
141 
144 
146  std::vector<HeartLayerType> mLayerForEachNode;
147 
153  ChasteCuboid<SPACE_DIM> CalculateBoundingBoxOfSurface(const std::vector<unsigned>& rSurfaceNodes);
154 
155 public:
157 
162  static const HeartRegionType LEFT_SEPTUM=1003;
164  static const HeartRegionType RIGHT_SEPTUM=1004;
170  static const HeartRegionType UNKNOWN=1007;
171 
182  const std::string& rEpiFile,
183  const std::string& rEndoFile,
184  bool indexFromZero);
185 
186 
202  const std::string& rEpiFile,
203  const std::string& rLVFile,
204  const std::string& rRVFile,
205  bool indexFromZero);
206 
216  HeartGeometryInformation (std::string nodeHeterogeneityFileName);
217 
222  HeartRegionType GetHeartRegion (unsigned nodeIndex) const;
223 
228  std::vector<double>& rGetDistanceMapEpicardium()
229  {
230  return mDistMapEpicardium;
231  }
232 
237  std::vector<double>& rGetDistanceMapEndocardium()
238  {
239  assert(mNumberOfSurfacesProvided==2);
240  return mDistMapEndocardium;
241  }
242 
247  std::vector<double>& rGetDistanceMapRightVentricle()
248  {
249  assert(mNumberOfSurfacesProvided==3);
250  return mDistMapRightVentricle;
251  }
252 
257  std::vector<double>& rGetDistanceMapLeftVentricle()
258  {
259  assert(mNumberOfSurfacesProvided==3);
260  return mDistMapLeftVentricle;
261  }
262 
264  const std::vector<unsigned>& rGetNodesOnEpiSurface()
265  {
266  return mEpiSurface;
267  }
268 
269 
271  const std::vector<unsigned>& rGetNodesOnEndoSurface()
272  {
273  assert(mNumberOfSurfacesProvided==2);
274  return mEndoSurface;
275  }
276 
278  const std::vector<unsigned>& rGetNodesOnLVSurface()
279  {
280  assert(mNumberOfSurfacesProvided==3);
281  return mLVSurface;
282  }
283 
285  const std::vector<unsigned>& rGetNodesOnRVSurface()
286  {
287  assert(mNumberOfSurfacesProvided==3);
288  return mRVSurface;
289  }
290 
294  const std::vector<HeartLayerType>& rGetLayerForEachNode()
295  {
296  assert(mLayerForEachNode.size()>0);
297  return mLayerForEachNode;
298  }
299 
305  double CalculateRelativeWallPosition(unsigned nodeIndex);
306 
312  void DetermineLayerForEachNode(double epiFraction, double endoFraction);
313 
321  void WriteLayerForEachNode(std::string outputDir, std::string file);
322 
331  {
333  }
342  {
344  }
353  {
355  }
364  {
366  }
367 };
368 #endif //HEARTGEOMETRYINFORMATION_HPP_
369 
std::vector< unsigned > mEndoSurface
ChasteCuboid< SPACE_DIM > CalculateBoundingBoxOfEpi()
const std::vector< HeartLayerType > & rGetLayerForEachNode()
static const HeartRegionType RIGHT_VENTRICLE_SURFACE
void DetermineLayerForEachNode(double epiFraction, double endoFraction)
std::vector< double > mDistMapEpicardium
std::vector< double > & rGetDistanceMapEndocardium()
const std::vector< unsigned > & rGetNodesOnEndoSurface()
std::vector< double > mDistMapRightVentricle
std::vector< HeartLayerType > mLayerForEachNode
static const HeartRegionType LEFT_SEPTUM
void WriteLayerForEachNode(std::string outputDir, std::string file)
void GetNodesAtSurface(const std::string &rSurfaceFileName, std::vector< unsigned > &rSurfaceNodes, bool indexFromZero=true) const
std::vector< unsigned > mRVSurface
static const HeartRegionType RIGHT_SEPTUM
static const HeartRegionType UNKNOWN
const std::vector< unsigned > & rGetNodesOnEpiSurface()
std::vector< double > & rGetDistanceMapEpicardium()
ChasteCuboid< SPACE_DIM > CalculateBoundingBoxOfLV()
double CalculateRelativeWallPosition(unsigned nodeIndex)
ChasteCuboid< SPACE_DIM > CalculateBoundingBoxOfSurface(const std::vector< unsigned > &rSurfaceNodes)
double GetDistanceToEpi(unsigned nodeIndex)
std::vector< double > & rGetDistanceMapLeftVentricle()
ChasteCuboid< SPACE_DIM > CalculateBoundingBoxOfRV()
std::vector< double > & rGetDistanceMapRightVentricle()
const std::vector< unsigned > & rGetNodesOnRVSurface()
HeartGeometryInformation(AbstractTetrahedralMesh< SPACE_DIM, SPACE_DIM > &rMesh, const std::string &rEpiFile, const std::string &rEndoFile, bool indexFromZero)
const std::vector< unsigned > & rGetNodesOnLVSurface()
ChasteCuboid< SPACE_DIM > CalculateBoundingBoxOfEndo()
void ProcessLine(const std::string &rLineFromFile, std::set< unsigned > &rSurfaceNodeIndexSet, unsigned offset) const
static const HeartRegionType LEFT_VENTRICLE_SURFACE
std::vector< double > mDistMapLeftVentricle
static const HeartRegionType RIGHT_VENTRICLE_WALL
HeartRegionType GetHeartRegion(unsigned nodeIndex) const
static const HeartRegionType LEFT_VENTRICLE_WALL
double GetDistanceToEndo(unsigned nodeIndex)
AbstractTetrahedralMesh< SPACE_DIM, SPACE_DIM > * mpMesh
std::vector< double > mDistMapEndocardium
std::vector< unsigned > mLVSurface
std::vector< unsigned > mEpiSurface