Easy3D 2.5.3
surface_mesh_topology.h
1/********************************************************************
2 * Copyright (C) 2015-2021 by Liangliang Nan <liangliang.nan@gmail.com>
3 * Copyright (C) 2000-2005 INRIA - Project ALICE
4 *
5 * The code in this file is partly from OGF/Graphite (2.0 alpha-4) with
6 * modifications and enhancement:
7 * https://gforge.inria.fr/forum/forum.php?forum_id=11459
8 * The original code was distributed under the GNU GPL license.
9 ********************************************************************/
10
11#ifndef EASY3D_ALGO_SURFACE_MESH_TOPOLOGY_H
12#define EASY3D_ALGO_SURFACE_MESH_TOPOLOGY_H
13
14
15#include <cstddef>
16
17namespace easy3d {
18
19 class SurfaceMeshComponent;
20
24 public:
25 explicit SurfaceMeshTopology(const SurfaceMeshComponent *comp);
26
32 int euler_poincare() const;
33
35 std::size_t number_of_borders() const { return number_of_borders_; }
36
38 std::size_t largest_border_size() const { return largest_border_size_; }
39
41 bool is_closed() const { return number_of_borders_ == 0; }
42
44 bool is_sphere() const { return (number_of_borders() == 0) && (euler_poincare() == 2); }
45
47 bool is_disc() const { return (number_of_borders() == 1) && (euler_poincare() == 1); }
48
50 bool is_cylinder() const { return (number_of_borders() == 2) && (euler_poincare() == 0); }
51
53 bool is_torus() const { return (number_of_borders() == 0) && (euler_poincare() == 0); }
54
55 private:
56 const SurfaceMeshComponent *component_;
57
58 std::size_t number_of_borders_;
59 std::size_t largest_border_size_;
60 };
61
62}
63
64#endif // EASY3D_ALGO_SURFACE_MESH_TOPOLOGY_H
65
A connected component of a SurfaceMesh.
Definition: surface_mesh_components.h:27
Compute various topological characteristics of a surface mesh component.
Definition: surface_mesh_topology.h:23
bool is_disc() const
returns if the surface is topologically equivalent to a disk.
Definition: surface_mesh_topology.h:47
int euler_poincare() const
returns the Euler-Poincare characteristic, 1: a disc 2: a sphere
Definition: surface_mesh_topology.cpp:46
std::size_t largest_border_size() const
returns the number of edges in the largest border.
Definition: surface_mesh_topology.h:38
bool is_closed() const
returns if the surface is closed.
Definition: surface_mesh_topology.h:41
bool is_torus() const
returns if the surface is topologically equivalent to a torus.
Definition: surface_mesh_topology.h:53
bool is_cylinder() const
returns if the surface is topologically equivalent to a cylinder.
Definition: surface_mesh_topology.h:50
bool is_sphere() const
returns if the surface is topologically equivalent to a sphere.
Definition: surface_mesh_topology.h:44
std::size_t number_of_borders() const
returns 0 for a closed surface.
Definition: surface_mesh_topology.h:35
Definition: collider.cpp:182