Medusa  1.1
Coordinate Free Mehless Method implementation
STLShape_fwd.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_DOMAINS_STLSHAPE_FWD_HPP_
2 #define MEDUSA_BITS_DOMAINS_STLSHAPE_FWD_HPP_
3 
4 #include "DomainShape_fwd.hpp"
6 #include <utility>
7 
15 namespace mm {
16 
29 template <typename vec_t>
30 class STLShape : public DomainShape<vec_t> {
31  public:
32  using typename DomainShape<vec_t>::scalar_t;
34 
35  private:
36  static_assert(dim == 3, "STL files are for 3D models only.");
37  std::vector<vec_t> vertices_;
38  std::vector<std::array<int, 3>> faces_;
39  std::vector<vec_t> normals_;
40  std::pair<vec_t, vec_t> bbox_;
41 
42  public:
44  STLShape(const std::vector<STL::Triangle>& stl);
45 
51  bool contains(const vec_t& /* point */) const override { return true; }
52 
53  bool hasContains() const override { return false; }
54 
55  std::pair<vec_t, vec_t> bbox() const override { return bbox_; }
56 
59  const std::function<scalar_t(vec_t)>&, int) const override;
60 
61  std::ostream& print(std::ostream& ostream) const override {
62  return ostream << "STL shape with " << vertices_.size() << " vertices and "
63  << faces_.size() << " faces.";
64  }
65 
66  STLShape* clone() const override {
67  return new STLShape<vec_t>(*this);
68  }
69 
70  private:
72  static vec_t v(const STL::Point& p) {
73  return vec_t(p.x, p.y, p.z);
74  }
75 };
76 
77 } // namespace mm
78 
79 #endif // MEDUSA_BITS_DOMAINS_STLSHAPE_FWD_HPP_
mm::STLShape::v
static vec_t v(const STL::Point &p)
Convert STL point to Vec3d.
Definition: STLShape_fwd.hpp:72
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
mm::DomainDiscretization
Class representing domain discretization along with an associated shape.
Definition: DomainDiscretization_fwd.hpp:46
mm::STLShape::discretizeBoundaryWithDensity
DomainDiscretization< vec_t > discretizeBoundaryWithDensity(const std::function< scalar_t(vec_t)> &, int) const override
Discretizes boundary with given density and fill engine.
Definition: STLShape.hpp:60
mm::STLShape::print
std::ostream & print(std::ostream &ostream) const override
Output information about this shape to given output stream os.
Definition: STLShape_fwd.hpp:61
mm::STLShape::clone
STLShape * clone() const override
Polymorphic clone pattern.
Definition: STLShape_fwd.hpp:66
mm::DomainShape::dim
@ dim
Dimensionality of the domain.
Definition: DomainShape_fwd.hpp:57
mm::STLShape::bbox_
std::pair< vec_t, vec_t > bbox_
Bounding box.
Definition: STLShape_fwd.hpp:40
mm::STLShape::contains
bool contains(const vec_t &) const override
Contains method is not supported and is approximated with a discrete version, which can be wrong.
Definition: STLShape_fwd.hpp:51
mm::STLShape
Class representing an object given by the STL file.
Definition: STLShape_fwd.hpp:30
mm::DomainShape
Base class for geometric shapes of domains.
Definition: DomainShape_fwd.hpp:52
mm::STLShape::hasContains
bool hasContains() const override
Return true if shape has contains() method implemented.
Definition: STLShape_fwd.hpp:53
mm::STLShape::normals_
std::vector< vec_t > normals_
Normals for each face.
Definition: STLShape_fwd.hpp:39
mm::STLShape::faces_
std::vector< std::array< int, 3 > > faces_
Faces, described with three indices of vertices.
Definition: STLShape_fwd.hpp:38
mm::STL::Point::z
float z
z coordinate
Definition: STL_fwd.hpp:29
mm::STLShape::STLShape
STLShape(const std::vector< STL::Triangle > &stl)
Create STLShape from triangles read from STL file.
Definition: STLShape.hpp:20
mm::STL::Point
Holds one 3d Point in a STL file.
Definition: STL_fwd.hpp:29
mm::STLShape::vertices_
std::vector< vec_t > vertices_
3d vertices.
Definition: STLShape_fwd.hpp:36
mm::STLShape::bbox
std::pair< vec_t, vec_t > bbox() const override
Return the bounding box of the domain.
Definition: STLShape_fwd.hpp:55
STL_fwd.hpp
mm::STL::Point::y
float y
y coordinate
Definition: STL_fwd.hpp:29
mm::STL::Point::x
float x
x coordinate
Definition: STL_fwd.hpp:29
mm::DomainShape::scalar_t
vec_t::Scalar scalar_t
Scalar data type used in computation.
Definition: DomainShape_fwd.hpp:55
DomainShape_fwd.hpp