Chaste  Build::
Part.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 PART_HPP_
37 #define PART_HPP_
38 
39 #include <vector>
40 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the vtk deprecated warning
41 #include <vtkPolyData.h>
42 #include <vtkSmartPointer.h>
43 #include "SmartPointers.hpp"
44 #include "ChastePoint.hpp"
45 #include "UblasVectorInclude.hpp"
46 #include "DimensionalChastePoint.hpp"
47 #include "Polygon.hpp"
48 #include "Facet.hpp"
49 #include "VesselNetwork.hpp"
50 #include "DimensionalChastePoint.hpp"
51 #include "UnitCollection.hpp"
52 #include "GeometryWriter.hpp"
53 
59 template<unsigned DIM>
60 class Part
61 {
65  std::vector<boost::shared_ptr<Facet<DIM> > > mFacets;
66 
70  vtkSmartPointer<vtkPolyData> mVtkPart;
71 
75  std::vector<DimensionalChastePoint<DIM> > mHoleMarkers;
76 
80  std::vector<DimensionalChastePoint<DIM> > mRegionMarkers;
81 
85  units::quantity<unit::length> mReferenceLength;
86 
91 
92 public:
93 
97  Part();
98 
103  static boost::shared_ptr<Part<DIM> > Create();
104 
108  ~Part();
109 
117  boost::shared_ptr<Polygon<DIM> > AddCircle(units::quantity<unit::length> radius,
119  unsigned numSegments = 24);
120 
128  void AddCylinder(units::quantity<unit::length> radius, units::quantity<unit::length> depth, DimensionalChastePoint<DIM> centre,
129  unsigned numSegments = 24);
130 
138  void AddCuboid(units::quantity<unit::length> sizeX,
139  units::quantity<unit::length> sizeY,
140  units::quantity<unit::length> sizeZ,
142 
148 
157  boost::shared_ptr<Polygon<DIM> > AddPolygon(std::vector<boost::shared_ptr<DimensionalChastePoint<DIM> > > vertices,
158  bool newFacet = false,
159  boost::shared_ptr<Facet<DIM> > pFacet = boost::shared_ptr<Facet<DIM> >());
160 
168  boost::shared_ptr<Polygon<DIM> > AddPolygon(boost::shared_ptr<Polygon<DIM> > pPolygon,
169  bool newFacet = false,
170  boost::shared_ptr<Facet<DIM> > pFacet = boost::shared_ptr<Facet<DIM> >());
171 
179  boost::shared_ptr<Polygon<DIM> > AddRectangle(units::quantity<unit::length> sizeX,
180  units::quantity<unit::length> sizeY,
182 
188  void AddVesselNetwork(boost::shared_ptr<VesselNetwork<DIM> > pVesselNetwork, bool surface = false);
189 
194  void BooleanWithNetwork(boost::shared_ptr<VesselNetwork<DIM> > pVesselNetwork);
195 
201  void Extrude(boost::shared_ptr<Polygon<DIM> > pPolygon, units::quantity<unit::length> distance);
202 
207  std::vector<units::quantity<unit::length> > GetBoundingBox();
208 
217  std::vector<unsigned> GetContainingGridIndices(unsigned num_x, unsigned num_y, unsigned num_z, units::quantity<unit::length> spacing);
218 
223  std::vector<DimensionalChastePoint<DIM> > GetHoleMarkers();
224 
229  std::vector<boost::shared_ptr<Facet<DIM> > > GetFacets();
230 
236  boost::shared_ptr<Facet<DIM> > GetFacet(const DimensionalChastePoint<DIM>& rLocation);
237 
242  std::vector<boost::shared_ptr<Polygon<DIM> > > GetPolygons();
243 
248  units::quantity<unit::length> GetReferenceLengthScale();
249 
254  std::vector<std::pair<unsigned, unsigned> > GetSegmentIndices();
255 
260  std::vector<boost::shared_ptr<DimensionalChastePoint<DIM> > > GetVertices();
261 
266  std::vector<DimensionalChastePoint<DIM> > GetVertexLocations();
267 
272  vtkSmartPointer<vtkPolyData> GetVtk();
273 
280 
286  std::vector<bool> IsPointInPart(const std::vector<DimensionalChastePoint<DIM> >& location);
287 
292 
297  void SetReferenceLengthScale(units::quantity<unit::length> referenceLength);
298 
304 
310  void Write(const std::string& rFilename, GeometryFormat::Value format = GeometryFormat::VTP);
311 
312 };
313 
314 #endif /*PART_HPP_*/
void SetReferenceLengthScale(units::quantity< unit::length > referenceLength)
Definition: Part.cpp:678
std::vector< unsigned > GetContainingGridIndices(unsigned num_x, unsigned num_y, unsigned num_z, units::quantity< unit::length > spacing)
Definition: Part.cpp:386
void MergeCoincidentVertices()
Definition: Part.cpp:644
vtkSmartPointer< vtkPolyData > GetVtk()
Definition: Part.cpp:511
std::vector< DimensionalChastePoint< DIM > > mRegionMarkers
Definition: Part.hpp:80
void BooleanWithNetwork(boost::shared_ptr< VesselNetwork< DIM > > pVesselNetwork)
Definition: Part.cpp:323
boost::shared_ptr< Facet< DIM > > GetFacet(const DimensionalChastePoint< DIM > &rLocation)
Definition: Part.cpp:351
bool IsPointInPart(DimensionalChastePoint< DIM > location)
Definition: Part.cpp:564
void AddCylinder(units::quantity< unit::length > radius, units::quantity< unit::length > depth, DimensionalChastePoint< DIM > centre, unsigned numSegments=24)
Definition: Part.cpp:100
boost::shared_ptr< Polygon< DIM > > AddRectangle(units::quantity< unit::length > sizeX, units::quantity< unit::length > sizeY, DimensionalChastePoint< DIM > origin)
Definition: Part.cpp:161
std::vector< DimensionalChastePoint< DIM > > GetVertexLocations()
Definition: Part.cpp:409
Part()
Definition: Part.cpp:52
std::vector< std::pair< unsigned, unsigned > > GetSegmentIndices()
Definition: Part.cpp:478
std::vector< DimensionalChastePoint< DIM > > GetHoleMarkers()
Definition: Part.cpp:339
std::vector< boost::shared_ptr< DimensionalChastePoint< DIM > > > GetVertices()
Definition: Part.cpp:364
std::vector< boost::shared_ptr< Facet< DIM > > > GetFacets()
Definition: Part.cpp:472
void Write(const std::string &rFilename, GeometryFormat::Value format=GeometryFormat::VTP)
Definition: Part.cpp:698
units::quantity< unit::length > mReferenceLength
Definition: Part.hpp:85
void Extrude(boost::shared_ptr< Polygon< DIM > > pPolygon, units::quantity< unit::length > distance)
Definition: Part.cpp:274
void AddCuboid(units::quantity< unit::length > sizeX, units::quantity< unit::length > sizeY, units::quantity< unit::length > sizeZ, DimensionalChastePoint< DIM > origin)
Definition: Part.cpp:111
std::vector< boost::shared_ptr< Facet< DIM > > > mFacets
Definition: Part.hpp:65
std::vector< DimensionalChastePoint< DIM > > mHoleMarkers
Definition: Part.hpp:75
void Translate(DimensionalChastePoint< DIM > vector)
Definition: Part.cpp:685
boost::shared_ptr< Polygon< DIM > > AddPolygon(std::vector< boost::shared_ptr< DimensionalChastePoint< DIM > > > vertices, bool newFacet=false, boost::shared_ptr< Facet< DIM > > pFacet=boost::shared_ptr< Facet< DIM > >())
Definition: Part.cpp:128
units::quantity< unit::length > GetReferenceLengthScale()
Definition: Part.cpp:345
bool mVtkIsUpToDate
Definition: Part.hpp:90
boost::shared_ptr< Polygon< DIM > > AddCircle(units::quantity< unit::length > radius, DimensionalChastePoint< DIM > centre, unsigned numSegments=24)
Definition: Part.cpp:76
Definition: Facet.hpp:54
vtkSmartPointer< vtkPolyData > mVtkPart
Definition: Part.hpp:70
std::vector< boost::shared_ptr< Polygon< DIM > > > GetPolygons()
Definition: Part.cpp:421
~Part()
Definition: Part.cpp:70
std::vector< units::quantity< unit::length > > GetBoundingBox()
Definition: Part.cpp:433
static boost::shared_ptr< Part< DIM > > Create()
Definition: Part.cpp:63
void AddVesselNetwork(boost::shared_ptr< VesselNetwork< DIM > > pVesselNetwork, bool surface=false)
Definition: Part.cpp:189
void AddHoleMarker(DimensionalChastePoint< DIM > location)
Definition: Part.cpp:122
Definition: Part.hpp:60