Chaste  Build::
RegularGrid.hpp
1 /*
2 
3 Copyright (c) 2005-2016, 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 
36 #ifndef REGULARGRID_HPP_
37 #define REGULARGRID_HPP_
38 
39 #include <vector>
40 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the vtk deprecated warning for now (gcc4.3)
41 #include <vtkImageData.h>
42 #include <vtkSmartPointer.h>
43 #include "UblasIncludes.hpp"
44 #include "SmartPointers.hpp"
45 #include "VesselNetwork.hpp"
46 #include "VesselSegment.hpp"
47 #include "VesselNode.hpp"
48 #include "AbstractCellPopulation.hpp"
49 #include "CaBasedCellPopulation.hpp"
50 #include "Part.hpp"
51 #include "UnitCollection.hpp"
52 #include "DimensionalChastePoint.hpp"
53 
58 template<unsigned DIM>
60 {
64  units::quantity<unit::length> mSpacing;
65 
69  std::vector<unsigned> mExtents;
70 
75 
79  boost::shared_ptr<VesselNetwork<DIM> > mpNetwork;
80 
84  AbstractCellPopulation<DIM>* mpCellPopulation;
85 
89  units::quantity<unit::length> mCellPopulationReferenceLength;
90 
94  std::vector<std::vector<CellPtr> > mPointCellMap;
95 
99  std::vector<std::vector<boost::shared_ptr<VesselNode<DIM> > > > mPointNodeMap;
100 
104  std::vector<std::vector<boost::shared_ptr<VesselSegment<DIM> > > > mPointSegmentMap;
105 
109  std::vector<double> mPointSolution;
110 
114  vtkSmartPointer<vtkImageData> mpVtkGrid;
115 
120 
124  std::vector<std::vector<unsigned> > mNeighbourData;
125 
130 
134  units::quantity<unit::length> mReferenceLength;
135 
136 public:
137 
141  RegularGrid();
142 
147  static boost::shared_ptr<RegularGrid<DIM> > Create();
148 
152  ~RegularGrid();
153 
157  void CalculateNeighbourData();
158 
164  void GenerateFromPart(boost::shared_ptr<Part<DIM> > pPart, units::quantity<unit::length> gridSize);
165 
173  unsigned Get1dGridIndex(unsigned xIndex, unsigned yIndex, unsigned zIndex);
174 
180  unsigned GetNearestGridIndex(const DimensionalChastePoint<DIM>& rLocation);
181 
186  const std::vector<std::vector<unsigned> >& GetNeighbourData();
187 
192  std::vector<unsigned> GetExtents();
193 
201  DimensionalChastePoint<DIM> GetLocation(unsigned xIndex, unsigned yIndex, unsigned zIndex);
202 
209 
214  std::vector<DimensionalChastePoint<DIM> > GetLocations();
215 
220  unsigned GetNumberOfPoints();
221 
227 
233  std::vector<std::vector<unsigned> > GetPointPointMap(std::vector<DimensionalChastePoint<DIM> > inputPoints);
234 
240  const std::vector<std::vector<CellPtr> >& GetPointCellMap(bool update = true);
241 
247  const std::vector<std::vector<boost::shared_ptr<VesselNode<DIM> > > >& GetPointNodeMap(bool update = true);
248 
255  std::vector<std::vector<boost::shared_ptr<VesselSegment<DIM> > > > GetPointSegmentMap(bool update = true, bool useVesselSurface = false);
256 
263  bool IsSegmentAtLatticeSite(unsigned index, bool update);
264 
270  units::quantity<unit::length> GetSpacing();
271 
277  units::quantity<unit::length> GetReferenceLengthScale();
278 
284  vtkSmartPointer<vtkImageData> GetVtkGrid();
285 
293  std::vector<double> InterpolateGridValues(std::vector<DimensionalChastePoint<DIM> > locations,
294  std::vector<double> values, bool useVtk = false);
295 
302  bool IsLocationInPointVolume(DimensionalChastePoint<DIM> point, unsigned gridIndex);
303 
309  bool IsOnBoundary(unsigned gridIndex);
310 
318  bool IsOnBoundary(unsigned xIndex, unsigned yIndex, unsigned zIndex);
319 
324  void SetCellPopulation(AbstractCellPopulation<DIM>& rCellPopulation, units::quantity<unit::length> cellPopulationLengthScale);
325 
330  void SetExtents(std::vector<unsigned> extents);
331 
337 
342  void SetPointValues(std::vector<double> pointSolution);
343 
348  void SetSpacing(units::quantity<unit::length> spacing);
349 
353  void SetUpVtkGrid();
354 
359  void SetVesselNetwork(boost::shared_ptr<VesselNetwork<DIM> > pNetwork);
360 
365  void Write(boost::shared_ptr<OutputFileHandler> pFileHandler);
366 };
367 
368 #endif /* REGULARGRID_HPP_*/
boost::shared_ptr< VesselNetwork< DIM > > mpNetwork
Definition: RegularGrid.hpp:79
AbstractCellPopulation< DIM > * mpCellPopulation
Definition: RegularGrid.hpp:84
void Write(boost::shared_ptr< OutputFileHandler > pFileHandler)
std::vector< unsigned > GetExtents()
std::vector< unsigned > mExtents
Definition: RegularGrid.hpp:69
units::quantity< unit::length > mCellPopulationReferenceLength
Definition: RegularGrid.hpp:89
const std::vector< std::vector< CellPtr > > & GetPointCellMap(bool update=true)
unsigned GetNumberOfPoints()
void SetOrigin(DimensionalChastePoint< DIM > origin)
bool mHasCellPopulation
const std::vector< std::vector< boost::shared_ptr< VesselNode< DIM > > > > & GetPointNodeMap(bool update=true)
vtkSmartPointer< vtkImageData > mpVtkGrid
void SetCellPopulation(AbstractCellPopulation< DIM > &rCellPopulation, units::quantity< unit::length > cellPopulationLengthScale)
DimensionalChastePoint< DIM > mOrigin
Definition: RegularGrid.hpp:74
units::quantity< unit::length > mReferenceLength
void SetPointValues(std::vector< double > pointSolution)
std::vector< double > InterpolateGridValues(std::vector< DimensionalChastePoint< DIM > > locations, std::vector< double > values, bool useVtk=false)
const std::vector< std::vector< unsigned > > & GetNeighbourData()
std::vector< std::vector< boost::shared_ptr< VesselSegment< DIM > > > > GetPointSegmentMap(bool update=true, bool useVesselSurface=false)
std::vector< DimensionalChastePoint< DIM > > GetLocations()
DimensionalChastePoint< DIM > GetLocation(unsigned xIndex, unsigned yIndex, unsigned zIndex)
std::vector< std::vector< unsigned > > GetPointPointMap(std::vector< DimensionalChastePoint< DIM > > inputPoints)
void CalculateNeighbourData()
Definition: RegularGrid.cpp:86
void SetSpacing(units::quantity< unit::length > spacing)
static boost::shared_ptr< RegularGrid< DIM > > Create()
Definition: RegularGrid.cpp:72
void SetExtents(std::vector< unsigned > extents)
std::vector< std::vector< CellPtr > > mPointCellMap
Definition: RegularGrid.hpp:94
unsigned Get1dGridIndex(unsigned xIndex, unsigned yIndex, unsigned zIndex)
DimensionalChastePoint< DIM > GetLocationOf1dIndex(unsigned gridIndex)
void SetUpVtkGrid()
std::vector< double > mPointSolution
vtkSmartPointer< vtkImageData > GetVtkGrid()
std::vector< std::vector< unsigned > > mNeighbourData
std::vector< std::vector< boost::shared_ptr< VesselSegment< DIM > > > > mPointSegmentMap
bool IsSegmentAtLatticeSite(unsigned index, bool update)
bool mVtkGridIsSetUp
std::vector< std::vector< boost::shared_ptr< VesselNode< DIM > > > > mPointNodeMap
Definition: RegularGrid.hpp:99
units::quantity< unit::length > mSpacing
Definition: RegularGrid.hpp:64
bool IsLocationInPointVolume(DimensionalChastePoint< DIM > point, unsigned gridIndex)
DimensionalChastePoint< DIM > GetOrigin()
units::quantity< unit::length > GetSpacing()
bool IsOnBoundary(unsigned gridIndex)
void GenerateFromPart(boost::shared_ptr< Part< DIM > > pPart, units::quantity< unit::length > gridSize)
units::quantity< unit::length > GetReferenceLengthScale()
unsigned GetNearestGridIndex(const DimensionalChastePoint< DIM > &rLocation)
void SetVesselNetwork(boost::shared_ptr< VesselNetwork< DIM > > pNetwork)
Definition: Part.hpp:60