36 tuple<array<double, 3>, array<double, 3>> MeshGeometry::BoundingBox(shared_ptr<Mesh> mesh)
38 const auto& nodes = mesh->GetBoundaryPolygon()->GetNodes();
39 array<double, 3> lower_left = **(nodes.begin());
40 array<double, 3> upper_right(lower_left);
42 for (
auto const& node : nodes) {
43 array<double, 3> a(*node);
44 lower_left[0] = min(lower_left[0], a[0]);
45 lower_left[1] = min(lower_left[1], a[1]);
46 lower_left[2] = min(lower_left[2], a[2]);
47 upper_right[0] = max(upper_right[0], a[0]);
48 upper_right[1] = max(upper_right[1], a[1]);
49 upper_right[2] = max(upper_right[2], a[2]);
51 return make_tuple(lower_left, upper_right);
54 tuple<double, double, double> MeshGeometry::Compactness(
const Mesh* mesh)
60 std::vector<std::array<double, 2> > boundary;
62 for (
auto const& node : bp->
GetNodes()) {
63 boundary.push_back({ {(*node)[0], (*node)[1]} });
67 std::vector<std::array<double, 2> > hull = ChainHull::Compute(boundary);
70 double hull_area = 0.;
71 double hull_circumference = 0.;
72 for (
unsigned int i = 0; i < hull.size() - 1; i++) {
73 hull_area += hull[i][0] * hull[i + 1][1] - hull[i + 1][0] * hull[i][1];
74 double s_dx = (hull[i + 1][0] - hull[i][0]);
75 double s_dy = (hull[i + 1][1] - hull[i][1]);
76 double l = sqrt(s_dx * s_dx + s_dy * s_dy);
77 hull_circumference += l;
82 const double boundary_pol_area = bp->
GetArea();
84 return make_tuple(boundary_pol_area / hull_area, hull_area, hull_circumference);
A cell contains walls and nodes.
Namespace for miscellaneous utilities.
Interface for MeshGeometry.
Namespace for the core simulator.
const std::vector< Node * > & GetNodes() const
Access the nodes of cell's polygon.
Cell * GetBoundaryPolygon() const
Get the boundary polygon of the mesh.
Structure of cells; key data structure.
double GetArea() const
Return the area of the cell.