25#ifndef EASY3D_CORE_SURFACE_MESH_H
26#define EASY3D_CORE_SURFACE_MESH_H
28#include <easy3d/core/model.h>
29#include <easy3d/core/types.h>
30#include <easy3d/core/property.h>
72 int idx()
const {
return idx_; }
91 return idx_ == _rhs.idx_;
100 return idx_ != _rhs.idx_;
109 return idx_ < _rhs.idx_;
146 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'v' <<
idx(); }
166 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'h' <<
idx(); }
184 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'e' <<
idx(); }
202 std::ostream&
operator<<(std::ostream& os)
const {
return os <<
'f' <<
idx(); }
447 if (mesh_ && mesh_->has_garbage()) while (mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
462 return (hnd_==rhs.hnd_);
481 while (mesh_->has_garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
492 while (mesh_->has_garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) --hnd_.idx_;
516 if (mesh_ && mesh_->has_garbage()) while (mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
531 return (hnd_==rhs.hnd_);
550 while (mesh_->has_garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
561 while (mesh_->has_garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) --hnd_.idx_;
585 if (mesh_ && mesh_->has_garbage()) while (mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
600 return (hnd_==rhs.hnd_);
619 while (mesh_->has_garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
630 while (mesh_->has_garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) --hnd_.idx_;
654 if (mesh_ && mesh_->has_garbage()) while (mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
669 return (hnd_==rhs.hnd_);
688 while (mesh_->has_garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
699 while (mesh_->has_garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) --hnd_.idx_;
852 : mesh_(m), active_(true)
854 if (mesh_) halfedge_ = mesh_->out_halfedge(v);
864 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
882 halfedge_ = mesh_->prev_around_source(halfedge_);
893 halfedge_ = mesh_->next_around_source(halfedge_);
903 return mesh_->target(halfedge_);
910 operator bool()
const {
return halfedge_.is_valid(); }
962 : mesh_(m), active_(true)
964 if (mesh_) halfedge_ = mesh_->out_halfedge(v);
974 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
992 halfedge_ = mesh_->prev_around_source(halfedge_);
1003 halfedge_ = mesh_->next_around_source(halfedge_);
1063 : mesh_(m), active_(true)
1066 halfedge_ = mesh_->out_halfedge(v);
1067 if (halfedge_.is_valid() && mesh_->is_border(halfedge_))
1079 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
1096 assert(mesh_ && halfedge_.is_valid());
1098 halfedge_ = mesh_->prev_around_source(halfedge_);
1099 }
while (mesh_->is_border(halfedge_));
1109 assert(mesh_ && halfedge_.is_valid());
1111 halfedge_ = mesh_->next_around_source(halfedge_);
1112 while (mesh_->is_border(halfedge_));
1121 assert(mesh_ && halfedge_.is_valid());
1122 return mesh_->face(halfedge_);
1129 operator bool()
const {
return halfedge_.is_valid(); }
1175 : mesh_(m), active_(true)
1177 if (mesh_) halfedge_ = mesh_->halfedge(f);
1187 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
1204 assert(mesh_ && halfedge_.is_valid());
1205 halfedge_ = mesh_->next(halfedge_);
1215 assert(mesh_ && halfedge_.is_valid());
1216 halfedge_ = mesh_->prev(halfedge_);
1225 assert(mesh_ && halfedge_.is_valid());
1226 return mesh_->target(halfedge_);
1273 : mesh_(m), active_(true)
1275 if (mesh_) halfedge_ = mesh_->halfedge(f);
1285 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
1302 assert(mesh_ && halfedge_.is_valid());
1303 halfedge_ = mesh_->next(halfedge_);
1313 assert(mesh_ && halfedge_.is_valid());
1314 halfedge_ = mesh_->prev(halfedge_);
1389 bool read(
const std::string& filename);
1394 bool write(
const std::string& filename)
const;
1425 Face
add_quad(Vertex v1, Vertex v2, Vertex v3, Vertex v4);
1440 unsigned int edges_size()
const {
return (
unsigned int) eprops_.size(); }
1442 unsigned int faces_size()
const {
return (
unsigned int) fprops_.size(); }
1472 void resize(
unsigned int nv,
unsigned int ne,
unsigned int nf) {
1474 hprops_.resize(2 * ne);
1489 return vdeleted_[v];
1494 return edeleted_[
edge(h)];
1499 return edeleted_[e];
1504 return fdeleted_[f];
1537 return vconn_[v].halfedge_;
1542 vconn_[v].halfedge_ = h;
1571 while (++hit!=hend);
1580 return hconn_[h].vertex_;
1590 hconn_[h].vertex_ = v;
1595 return hconn_[h].face_;
1600 hconn_[h].face_ = f;
1605 return hconn_[h].next_;
1610 hconn_[h].next_ = nh;
1611 hconn_[nh].prev_ = h;
1616 return hconn_[h].prev_;
1662 return Halfedge(
static_cast<int>((e.
idx() << 1) + i));
1685 return fconn_[f].halfedge_;
1690 fconn_[f].halfedge_ = h;
1969 return vprops_.rename(old_name, new_name);
1979 return fprops_.rename(old_name, new_name);
1989 return eprops_.rename(old_name, new_name);
1999 return hprops_.rename(old_name, new_name);
2009 return mprops_.rename(old_name, new_name);
2019 return vprops_.get_type(
name);
2027 return hprops_.get_type(
name);
2035 return eprops_.get_type(
name);
2043 return fprops_.get_type(
name);
2051 return mprops_.get_type(
name);
2060 return vprops_.properties();
2067 return hprops_.properties();
2074 return eprops_.properties();
2081 return fprops_.properties();
2088 return mprops_.properties();
2307 void split(Face f, Vertex v);
2329 Halfedge
split(Edge e, Vertex v);
2414 void stitch(Halfedge h0, Halfedge h1);
2419 unsigned int valence(Vertex v)
const;
2422 unsigned int valence(Face f)
const;
2428 Edge
find_edge(Vertex a, Vertex b)
const;
2471 const std::vector<vec3>&
points()
const override {
return vpoint_.vector(); }
2477 std::vector<vec3>&
points()
override {
return vpoint_.vector(); }
2514 Halfedge new_edge(Vertex start, Vertex end)
2516 assert(start != end);
2534 fprops_.push_back();
2547 void adjust_outgoing_halfedges();
2551 void adjust_outgoing_halfedge(
Vertex v);
2565 PropertyContainer vprops_;
2566 PropertyContainer hprops_;
2567 PropertyContainer eprops_;
2568 PropertyContainer fprops_;
2569 PropertyContainer mprops_;
2583 unsigned int deleted_vertices_;
2584 unsigned int deleted_edges_;
2585 unsigned int deleted_faces_;
2589 typedef std::pair<Halfedge, Halfedge> NextCacheEntry;
2590 typedef std::vector<NextCacheEntry> NextCache;
2591 std::vector<Vertex> add_face_vertices_;
2592 std::vector<Halfedge> add_face_halfedges_;
2593 std::vector<bool> add_face_is_new_;
2594 std::vector<bool> add_face_needs_adjust_;
2595 NextCache add_face_next_cache_;
2597 friend class SurfaceMeshBuilder;
2606 return (os <<
'v' << v.
idx());
2612 return (os <<
'h' << h.
idx());
2618 return (os <<
'e' << e.
idx());
2624 return (os <<
'f' << f.
idx());
const std::string & name() const
The name of a model.
Definition model.h:61
Model(const std::string &name="unknown")
Default constructor. The parameter name is optional, but it is useful for handling multiple models wi...
Definition model.cpp:33
void push_back()
Adds a new element to each vector.
Definition property.h:771
PropertyArray< T >::const_reference const_reference
The const reference type of the property.
Definition property.h:329
virtual reference operator[](size_t i)
Accesses the i-th element.
Definition property.h:365
Property(PropertyArray< T > *p=nullptr)
Constructor.
Definition property.h:338
PropertyArray< T >::reference reference
The reference type of the property.
Definition property.h:328
bool operator!=(const BaseHandle &_rhs) const
Inequality operator.
Definition surface_mesh.h:99
bool is_valid() const
Return whether the handle is valid, i.e., the index is not equal to -1.
Definition surface_mesh.h:83
int idx() const
Get the underlying index of this handle.
Definition surface_mesh.h:72
bool operator<(const BaseHandle &_rhs) const
Compare operator useful for sorting handles.
Definition surface_mesh.h:108
bool operator==(const BaseHandle &_rhs) const
Equality operator.
Definition surface_mesh.h:90
void reset()
Reset handle to be invalid (index=-1).
Definition surface_mesh.h:77
BaseHandle(int _idx=-1)
Constructor.
Definition surface_mesh.h:66
This helper class is a container for iterating through all edges using C++11 range-based for-loops.
Definition surface_mesh.h:773
EdgeIterator begin() const
Get the beginning iterator.
Definition surface_mesh.h:785
EdgeIterator end() const
Get the ending iterator.
Definition surface_mesh.h:790
EdgeContainer(EdgeIterator _begin, EdgeIterator _end)
Constructor.
Definition surface_mesh.h:780
This class iterates linearly over all edges.
Definition surface_mesh.h:577
bool operator!=(const EdgeIterator &rhs) const
Inequality operator.
Definition surface_mesh.h:608
EdgeIterator & operator++()
Pre-increment iterator.
Definition surface_mesh.h:616
Edge operator*() const
Get the edge the iterator refers to.
Definition surface_mesh.h:592
bool operator==(const EdgeIterator &rhs) const
Equality operator.
Definition surface_mesh.h:599
EdgeIterator(Edge e=Edge(), const SurfaceMesh *m=nullptr)
Default constructor.
Definition surface_mesh.h:584
EdgeIterator & operator--()
Pre-decrement iterator.
Definition surface_mesh.h:627
Edge property of type T.
Definition surface_mesh.h:327
EdgeProperty()=default
default constructor
Property< T >::reference operator[](Edge e)
Access the data stored for edge e.
Definition surface_mesh.h:343
Property< T >::const_reference operator[](Edge e) const
Access the data stored for edge e.
Definition surface_mesh.h:352
EdgeProperty(Property< T > p)
Constructor with property.
Definition surface_mesh.h:336
Definition surface_mesh.h:1055
bool operator!=(const FaceAroundVertexCirculator &rhs) const
Inequality operator.
Definition surface_mesh.h:1087
bool operator==(const FaceAroundVertexCirculator &rhs) const
Equality operator.
Definition surface_mesh.h:1077
FaceAroundVertexCirculator & operator++()
Pre-increment operator (rotate counter-clockwise).
Definition surface_mesh.h:1095
FaceAroundVertexCirculator & begin()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:1135
Face operator*() const
Get the face the circulator refers to.
Definition surface_mesh.h:1120
FaceAroundVertexCirculator & end()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:1140
FaceAroundVertexCirculator(const SurfaceMesh *m=nullptr, Vertex v=Vertex())
Default constructor.
Definition surface_mesh.h:1062
FaceAroundVertexCirculator & operator--()
Pre-decrement operator (rotate clockwise).
Definition surface_mesh.h:1108
This helper class is a container for iterating through all faces using C++11 range-based for-loops.
Definition surface_mesh.h:801
FaceContainer(FaceIterator _begin, FaceIterator _end)
Constructor.
Definition surface_mesh.h:808
FaceIterator begin() const
Get the beginning iterator.
Definition surface_mesh.h:813
FaceIterator end() const
Get the ending iterator.
Definition surface_mesh.h:818
This class iterates linearly over all faces.
Definition surface_mesh.h:646
bool operator!=(const FaceIterator &rhs) const
Inequality operator.
Definition surface_mesh.h:677
bool operator==(const FaceIterator &rhs) const
Equality operator.
Definition surface_mesh.h:668
FaceIterator & operator--()
Pre-decrement iterator.
Definition surface_mesh.h:696
FaceIterator(Face f=Face(), const SurfaceMesh *m=nullptr)
Default constructor.
Definition surface_mesh.h:653
Face operator*() const
Get the face the iterator refers to.
Definition surface_mesh.h:661
FaceIterator & operator++()
Pre-increment iterator.
Definition surface_mesh.h:685
Face property of type T.
Definition surface_mesh.h:363
Property< T >::reference operator[](Face f)
Access the data stored for face f.
Definition surface_mesh.h:379
FaceProperty(Property< T > p)
Constructor with property.
Definition surface_mesh.h:372
FaceProperty()=default
default constructor
Property< T >::const_reference operator[](Face f) const
Access the data stored for face f.
Definition surface_mesh.h:388
Definition surface_mesh.h:1265
Halfedge operator*() const
Get the halfedge the circulator refers to.
Definition surface_mesh.h:1322
HalfedgeAroundFaceCirculator & operator--()
Pre-decrement operator (rotate clockwise).
Definition surface_mesh.h:1312
bool operator==(const HalfedgeAroundFaceCirculator &rhs) const
Equality operator.
Definition surface_mesh.h:1283
bool operator!=(const HalfedgeAroundFaceCirculator &rhs) const
Inequality operator.
Definition surface_mesh.h:1293
HalfedgeAroundFaceCirculator & end()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:1333
HalfedgeAroundFaceCirculator(const SurfaceMesh *m=nullptr, Face f=Face())
Default constructor.
Definition surface_mesh.h:1272
HalfedgeAroundFaceCirculator & begin()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:1328
HalfedgeAroundFaceCirculator & operator++()
Pre-increment operator (rotate counter-clockwise).
Definition surface_mesh.h:1301
Definition surface_mesh.h:954
HalfedgeAroundVertexCirculator & end()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:1028
bool operator==(const HalfedgeAroundVertexCirculator &rhs) const
Equality operator.
Definition surface_mesh.h:972
Halfedge operator*() const
Get the halfedge the circulator refers to.
Definition surface_mesh.h:1011
HalfedgeAroundVertexCirculator & begin()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:1023
HalfedgeAroundVertexCirculator & operator++()
Pre-increment operator (rotate counter-clockwise).
Definition surface_mesh.h:990
bool operator!=(const HalfedgeAroundVertexCirculator &rhs) const
Inequality operator.
Definition surface_mesh.h:982
HalfedgeAroundVertexCirculator & operator--()
Pre-decrement operator (rotate clockwise).
Definition surface_mesh.h:1001
HalfedgeAroundVertexCirculator(const SurfaceMesh *m=nullptr, Vertex v=Vertex())
Default constructor.
Definition surface_mesh.h:961
This helper class is a container for iterating through all halfedges using C++11 range-based for-loop...
Definition surface_mesh.h:745
HalfedgeIterator begin() const
Get the beginning iterator.
Definition surface_mesh.h:757
HalfedgeContainer(HalfedgeIterator _begin, HalfedgeIterator _end)
Constructor.
Definition surface_mesh.h:752
HalfedgeIterator end() const
Get the beginning iterator.
Definition surface_mesh.h:762
This class iterates linearly over all halfedges.
Definition surface_mesh.h:508
HalfedgeIterator & operator--()
Pre-decrement iterator.
Definition surface_mesh.h:558
Halfedge operator*() const
Get the halfedge the iterator refers to.
Definition surface_mesh.h:523
HalfedgeIterator(Halfedge h=Halfedge(), const SurfaceMesh *m=nullptr)
Default constructor.
Definition surface_mesh.h:515
HalfedgeIterator & operator++()
Pre-increment iterator.
Definition surface_mesh.h:547
bool operator==(const HalfedgeIterator &rhs) const
Equality operator.
Definition surface_mesh.h:530
bool operator!=(const HalfedgeIterator &rhs) const
Inequality operator.
Definition surface_mesh.h:539
Halfedge property of type T.
Definition surface_mesh.h:291
HalfedgeProperty(Property< T > p)
Constructor with property.
Definition surface_mesh.h:300
Property< T >::reference operator[](Halfedge h)
Access the data stored for halfedge h.
Definition surface_mesh.h:307
Property< T >::const_reference operator[](Halfedge h) const
Access the data stored for halfedge h.
Definition surface_mesh.h:316
HalfedgeProperty()=default
default constructor
Mesh property of type T.
Definition surface_mesh.h:399
ModelProperty()=default
default constructor
ModelProperty(Property< T > p)
Constructor with property.
Definition surface_mesh.h:408
Property< T >::const_reference operator[](size_t idx) const
Access the data stored for the mesh.
Definition surface_mesh.h:424
Property< T >::reference operator[](size_t idx)
Access the data stored for the mesh.
Definition surface_mesh.h:415
Definition surface_mesh.h:1167
VertexAroundFaceCirculator & end()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:1238
VertexAroundFaceCirculator(const SurfaceMesh *m=nullptr, Face f=Face())
Default constructor.
Definition surface_mesh.h:1174
bool operator!=(const VertexAroundFaceCirculator &rhs) const
Inequality operator.
Definition surface_mesh.h:1195
Vertex operator*() const
Get the vertex the circulator refers to.
Definition surface_mesh.h:1224
bool operator==(const VertexAroundFaceCirculator &rhs) const
Equality operator.
Definition surface_mesh.h:1185
VertexAroundFaceCirculator & operator--()
Pre-decrement operator (rotate clockwise).
Definition surface_mesh.h:1214
VertexAroundFaceCirculator & begin()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:1233
VertexAroundFaceCirculator & operator++()
Pre-increment operator (rotate counter-clockwise).
Definition surface_mesh.h:1203
Definition surface_mesh.h:844
bool operator!=(const VertexAroundVertexCirculator &rhs) const
Inequality operator.
Definition surface_mesh.h:872
VertexAroundVertexCirculator & operator++()
Pre-increment operator (rotate counter-clockwise).
Definition surface_mesh.h:880
VertexAroundVertexCirculator & begin()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:922
Vertex operator*() const
Get the vertex the circulator refers to.
Definition surface_mesh.h:901
VertexAroundVertexCirculator(const SurfaceMesh *m=nullptr, Vertex v=Vertex())
Default constructor.
Definition surface_mesh.h:851
bool operator==(const VertexAroundVertexCirculator &rhs) const
Equality operator.
Definition surface_mesh.h:862
VertexAroundVertexCirculator & operator--()
Pre-decrement operator (rotate clockwise).
Definition surface_mesh.h:891
VertexAroundVertexCirculator & end()
Helper for C++11 range-based for-loops.
Definition surface_mesh.h:927
Halfedge halfedge() const
Get the current halfedge.
Definition surface_mesh.h:916
This helper class is a container for iterating through all vertices using C++11 range-based for-loops...
Definition surface_mesh.h:717
VertexContainer(VertexIterator _begin, VertexIterator _end)
Constructor.
Definition surface_mesh.h:724
VertexIterator begin() const
Get the beginning iterator.
Definition surface_mesh.h:729
VertexIterator end() const
Get the ending iterator.
Definition surface_mesh.h:734
This class iterates linearly over all vertices.
Definition surface_mesh.h:439
Vertex operator*() const
Get the vertex the iterator refers to.
Definition surface_mesh.h:454
bool operator==(const VertexIterator &rhs) const
Equality operator.
Definition surface_mesh.h:461
VertexIterator & operator--()
Pre-decrement iterator.
Definition surface_mesh.h:489
bool operator!=(const VertexIterator &rhs) const
Inequality operator.
Definition surface_mesh.h:470
VertexIterator(Vertex v=Vertex(), const SurfaceMesh *m=nullptr)
Default constructor.
Definition surface_mesh.h:446
VertexIterator & operator++()
Pre-increment iterator.
Definition surface_mesh.h:478
Vertex property of type T.
Definition surface_mesh.h:255
VertexProperty(Property< T > p)
Constructor with property.
Definition surface_mesh.h:264
Property< T >::const_reference operator[](Vertex v) const
Access the data stored for vertex v.
Definition surface_mesh.h:280
Property< T >::reference operator[](Vertex v)
Access the data stored for vertex v.
Definition surface_mesh.h:271
VertexProperty()=default
default constructor
A halfedge data structure for polygonal meshes of 2-manifold.
Definition surface_mesh.h:51
const vec3 & position(Vertex v) const
Returns the position of a vertex.
Definition surface_mesh.h:2458
bool is_border(Vertex v) const
returns whether v is a boundary vertex
Definition surface_mesh.h:1546
bool is_quad_mesh() const
Definition surface_mesh.cpp:896
EdgeContainer edges() const
Returns a container for range-based iteration over edges.
Definition surface_mesh.h:2173
const std::type_info & get_vertex_property_type(const std::string &name) const
Get the type information of the vertex property name.
Definition surface_mesh.h:2018
Vertex source(Halfedge h) const
returns the vertex the halfedge h emanates from
Definition surface_mesh.h:1584
unsigned int n_faces() const
returns number of faces in the mesh
Definition surface_mesh.h:1452
bool remove_vertex_property(const std::string &n)
Remove the vertex property named n.
Definition surface_mesh.h:1900
EdgeIterator edges_end() const
Returns an iterator to the end of the edges.
Definition surface_mesh.h:2165
unsigned int n_halfedges() const
returns number of halfedge in the mesh
Definition surface_mesh.h:1448
unsigned int halfedges_size() const
returns number of (deleted and valid)halfedge in the mesh
Definition surface_mesh.h:1438
void set_next(Halfedge h, Halfedge nh)
sets the next halfedge of h within the face to nh
Definition surface_mesh.h:1609
VertexAroundVertexCirculator vertices(Vertex v) const
Returns circulator for the vertices around vertex v.
Definition surface_mesh.h:2206
bool is_valid(Halfedge h) const
return whether halfedge h is valid, i.e. the index is stores it within the array bounds.
Definition surface_mesh.h:1513
HalfedgeAroundFaceCirculator halfedges(Face f) const
Returns circulator for halfedges of face f.
Definition surface_mesh.h:2242
unsigned int n_edges() const
returns number of edges in the mesh
Definition surface_mesh.h:1450
bool is_valid(Edge e) const
return whether edge e is valid, i.e. the index is stores it within the array bounds.
Definition surface_mesh.h:1517
void triangulate()
Definition surface_mesh.cpp:908
bool rename_vertex_property(const std::string &old_name, const std::string &new_name)
Rename a vertex property given its name.
Definition surface_mesh.h:1968
unsigned int valence(Vertex v) const
Definition surface_mesh.cpp:834
HalfedgeProperty< T > add_halfedge_property(const std::string &name, const T t=T())
Add a halfedge property of type T with name name and default value t.
Definition surface_mesh.h:1736
Face add_face(const std::vector< Vertex > &vertices)
Adds a new face to the mesh.
Definition surface_mesh.cpp:518
bool remove_halfedge_property(HalfedgeProperty< T > &p)
Remove the halfedge property p.
Definition surface_mesh.h:1908
VertexContainer vertices() const
Returns a container for range-based iteration over vertices.
Definition surface_mesh.h:2125
void stitch(Halfedge h0, Halfedge h1)
Stitch two halfedges h0 and h1. Precondition: h0 and h1 are both on the border and point in reversed ...
Definition surface_mesh.cpp:1598
Halfedge opposite(Halfedge h) const
returns the opposite halfedge of h
Definition surface_mesh.h:1620
FaceProperty< T > get_face_property(const std::string &name) const
Get the face property with name name of type T.
Definition surface_mesh.h:1811
const std::type_info & get_edge_property_type(const std::string &name) const
Get the type information of the edge property name.
Definition surface_mesh.h:2034
bool is_collapse_ok(Halfedge h) const
Definition surface_mesh.cpp:1706
const std::type_info & get_halfedge_property_type(const std::string &name) const
Get the type information of the halfedge property name.
Definition surface_mesh.h:2026
void delete_face(Face f)
Definition surface_mesh.cpp:1946
bool has_garbage() const
are there deleted vertices, edges or faces?
Definition surface_mesh.h:1480
Halfedge halfedge(Edge e, unsigned int i) const
returns the i'th halfedge of edge e. i has to be 0 or 1.
Definition surface_mesh.h:1660
Halfedge insert_vertex(Edge e, Vertex v)
Definition surface_mesh.h:2352
bool rename_face_property(const std::string &old_name, const std::string &new_name)
Rename a face property given its name.
Definition surface_mesh.h:1978
Edge find_edge(Vertex a, Vertex b) const
find the edge (a, b)
Definition surface_mesh.cpp:436
void reserve(unsigned int n_vertices, unsigned int n_edges, unsigned int n_faces)
Reserves memory for the given number of vertices, edges, and faces.
Definition surface_mesh.cpp:339
VertexProperty< T > vertex_property(const std::string &name, const T t=T())
If a vertex property of type T with name name exists, it is returned. Otherwise, this property is add...
Definition surface_mesh.h:1837
unsigned int edges_size() const
returns number of (deleted and valid)edges in the mesh
Definition surface_mesh.h:1440
std::vector< std::string > face_properties() const
Get the names of all face properties.
Definition surface_mesh.h:2080
bool is_flip_ok(Edge e) const
Definition surface_mesh.cpp:1435
FaceContainer faces() const
Returns a container for range-based iteration over faces.
Definition surface_mesh.h:2197
ModelProperty< T > get_model_property(const std::string &name) const
Gets the model property named name of type T.
Definition surface_mesh.h:1825
~SurfaceMesh() override=default
destructor (is virtual, since we inherit from Geometry_representation)
std::vector< std::string > vertex_properties() const
Get the names of all vertex properties.
Definition surface_mesh.h:2059
void update_face_normals()
compute face normals by calling compute_face_normal(Face) for each face.
Definition surface_mesh.cpp:1011
vec3 compute_face_normal(Face f) const
Computes the normal vector of face f. This method is robust for concave and general polygonal faces.
Definition surface_mesh.cpp:1035
SurfaceMesh(const SurfaceMesh &rhs)
copy constructor: copies rhs to *this. performs a deep copy of all properties.
Definition surface_mesh.h:1358
Halfedge insert_vertex(Edge e, const vec3 &p)
Definition surface_mesh.h:2340
EdgeProperty< T > get_edge_property(const std::string &name) const
Get the edge property with name name of type T.
Definition surface_mesh.h:1802
void set_halfedge(Face f, Halfedge h)
sets the halfedge of face f to h
Definition surface_mesh.h:1689
const std::type_info & get_face_property_type(const std::string &name) const
Get the type information of the face property name.
Definition surface_mesh.h:2042
EdgeIterator edges_begin() const
Returns an iterator to the beginning of the edges.
Definition surface_mesh.h:2157
VertexAroundFaceCirculator vertices(Face f) const
Returns circulator for vertices of face f.
Definition surface_mesh.h:2233
FaceIterator faces_begin() const
Returns an iterator to the beginning of the faces.
Definition surface_mesh.h:2181
Halfedge find_halfedge(Vertex start, Vertex end) const
find the halfedge from start to end
Definition surface_mesh.cpp:411
VertexProperty< T > get_vertex_property(const std::string &name) const
Get the vertex property with name name of type T.
Definition surface_mesh.h:1784
bool remove_face_property(const std::string &n)
Remove the face property named n.
Definition surface_mesh.h:1945
bool is_stitch_ok(Halfedge h0, Halfedge h1)
Definition surface_mesh.cpp:1556
Vertex split(Face f, const vec3 &p)
Definition surface_mesh.h:2301
void reverse_orientation()
Reverses the orientation of the entire mesh.
Definition surface_mesh.cpp:923
std::vector< std::string > edge_properties() const
Get the names of all edge properties.
Definition surface_mesh.h:2073
bool read(const std::string &filename)
Read mesh from a SM file filename. Mainly for quick debug purposes. Client code should use SurfaceMes...
Definition surface_mesh.cpp:203
bool is_deleted(Vertex v) const
Definition surface_mesh.h:1488
void set_face(Halfedge h, Face f)
sets the incident face to halfedge h to f
Definition surface_mesh.h:1599
SurfaceMesh()
Default constructor. Initializes an empty surface mesh.
Definition surface_mesh.cpp:33
std::vector< std::string > model_properties() const
Get the names of all model properties.
Definition surface_mesh.h:2087
Vertex target(Halfedge h) const
returns the vertex the halfedge h points to
Definition surface_mesh.h:1579
Halfedge halfedge(Face f) const
returns a halfedge of face f
Definition surface_mesh.h:1684
bool is_deleted(Face f) const
Definition surface_mesh.h:1503
HalfedgeContainer halfedges() const
Returns a container for range-based iteration over halfedges.
Definition surface_mesh.h:2149
void collect_garbage()
remove deleted vertices/edges/faces
Definition surface_mesh.cpp:2060
SurfaceMesh & operator=(const SurfaceMesh &rhs)
assign rhs to *this. performs a deep copy of all properties.
Definition surface_mesh.cpp:55
bool rename_edge_property(const std::string &old_name, const std::string &new_name)
Rename an edge property given its name.
Definition surface_mesh.h:1988
void resize(unsigned int nv, unsigned int ne, unsigned int nf)
Definition surface_mesh.h:1472
bool is_deleted(Edge e) const
Definition surface_mesh.h:1498
Halfedge split(Edge e, const vec3 &p)
Definition surface_mesh.h:2318
Halfedge prev_around_source(Halfedge h) const
Definition surface_mesh.h:1626
Halfedge insert_edge(Halfedge h0, Halfedge h1)
Definition surface_mesh.cpp:1394
const std::type_info & get_model_property_type(const std::string &name) const
Get the type information of the model property name.
Definition surface_mesh.h:2050
Halfedge prev(Halfedge h) const
returns the previous halfedge within the incident face
Definition surface_mesh.h:1615
void set_target(Halfedge h, Vertex v)
sets the vertex the halfedge h points to to v
Definition surface_mesh.h:1589
Halfedge next_around_target(Halfedge h) const
Definition surface_mesh.h:1644
std::vector< vec3 > & points() override
Returns a modifiable vector of all vertex positions.
Definition surface_mesh.h:2477
SurfaceMesh & join(const SurfaceMesh &other)
Merges another surface mesh into the current one. Shifts the indices of vertices of the other mesh by...
Definition surface_mesh.cpp:93
bool is_closed() const
returns whether the mesh closed (i.e., no boundary edges)
Definition surface_mesh.cpp:869
bool remove_face_property(FaceProperty< T > &p)
Remove the face property p.
Definition surface_mesh.h:1938
bool remove_edge_property(const std::string &n)
Remove the edge property named n.
Definition surface_mesh.h:1930
ModelProperty< T > model_property(const std::string &name, const T t=T())
If a model property of type T with name name exists, it is returned. Otherwise, this property is adde...
Definition surface_mesh.h:1882
Face add_quad(Vertex v1, Vertex v2, Vertex v3, Vertex v4)
Definition surface_mesh.cpp:504
VertexProperty< T > add_vertex_property(const std::string &name, const T t=T())
Add a vertex property of type T with name name and default value t.
Definition surface_mesh.h:1725
bool remove_model_property(ModelProperty< T > &p)
Remove the model property p.
Definition surface_mesh.h:1953
FaceProperty< T > face_property(const std::string &name, const T t=T())
If a face property of type T with name name exists, it is returned. Otherwise, this property is added...
Definition surface_mesh.h:1870
FaceProperty< T > add_face_property(const std::string &name, const T t=T())
Add a face property of type T with name name and default value t.
Definition surface_mesh.h:1758
FaceAroundVertexCirculator faces(Vertex v) const
Returns circulator for faces around vertex v.
Definition surface_mesh.h:2224
std::vector< std::string > halfedge_properties() const
Get the names of all halfedge properties.
Definition surface_mesh.h:2066
Face add_triangle(Vertex v1, Vertex v2, Vertex v3)
Definition surface_mesh.cpp:491
bool rename_model_property(const std::string &old_name, const std::string &new_name)
Rename a model property given its name.
Definition surface_mesh.h:2008
bool is_triangle_mesh() const
Definition surface_mesh.cpp:882
ModelProperty< T > add_model_property(const std::string &name, const T t=T())
Adds a model property of type T with name name and default value t.
Definition surface_mesh.h:1773
bool can_join_edges(Vertex v) const
Definition surface_mesh.cpp:2271
HalfedgeIterator halfedges_begin() const
Returns an iterator to the beginning of the halfedges.
Definition surface_mesh.h:2133
vec3 compute_vertex_normal(Vertex v) const
Definition surface_mesh.cpp:1112
HalfedgeProperty< T > get_halfedge_property(const std::string &name) const
Get the halfedge property with name name of type T.
Definition surface_mesh.h:1793
bool write(const std::string &filename) const
Write mesh to a SM file filename. Mainly for quick debug purposes. Client code should use SurfaceMesh...
Definition surface_mesh.cpp:250
SurfaceMesh & operator+=(const SurfaceMesh &other)
Merges another surface mesh into the current one. Shifts the indices of vertices of the other mesh by...
Definition surface_mesh.h:1369
Vertex add_vertex(const vec3 &p)
Adds a new vertex to the mesh.
Definition surface_mesh.h:1407
bool is_valid(Face f) const
return whether face f is valid, i.e. the index is stores it within the array bounds.
Definition surface_mesh.h:1521
bool is_border(Face f) const
returns whether f is a boundary face, i.e., it one of its edges is a boundary edge.
Definition surface_mesh.h:1694
EdgeProperty< T > edge_property(const std::string &name, const T t=T())
If an edge property of type T with name name exists, it is returned. Otherwise, this property is adde...
Definition surface_mesh.h:1859
Halfedge prev_around_target(Halfedge h) const
Definition surface_mesh.h:1638
Face face(Halfedge h) const
returns the face incident to halfedge h
Definition surface_mesh.h:1594
bool remove_edge_property(EdgeProperty< T > &p)
Remove the edge property p.
Definition surface_mesh.h:1923
void property_stats(std::ostream &output) const override
Prints the names of all properties to an output stream (e.g., std::cout).
Definition surface_mesh.cpp:354
void delete_edge(Edge e)
Definition surface_mesh.cpp:1932
void update_vertex_normals()
compute vertex normals by calling compute_vertex_normal(Vertex) for each vertex.
Definition surface_mesh.cpp:1093
FaceIterator faces_end() const
Returns an iterator to the end of the faces.
Definition surface_mesh.h:2189
SurfaceMesh & assign(const SurfaceMesh &rhs)
assign rhs to *this. does not copy custom properties.
Definition surface_mesh.cpp:149
void collapse(Halfedge h)
Definition surface_mesh.cpp:1768
void flip(Edge e)
Definition surface_mesh.cpp:1461
HalfedgeProperty< T > halfedge_property(const std::string &name, const T t=T())
If a halfedge property of type T with name name exists, it is returned. Otherwise,...
Definition surface_mesh.h:1848
bool is_manifold(Vertex v) const
returns whether v is a manifold vertex (not incident to several patches)
Definition surface_mesh.h:1557
void clear()
Clears the mesh, removing all vertices, edges, faces, and properties (and resets garbage state).
Definition surface_mesh.cpp:302
Halfedge next_around_source(Halfedge h) const
Definition surface_mesh.h:1632
bool rename_halfedge_property(const std::string &old_name, const std::string &new_name)
Rename a halfedge property given its name.
Definition surface_mesh.h:1998
bool remove_halfedge_property(const std::string &n)
Remove the halfedge property named n.
Definition surface_mesh.h:1915
bool is_isolated(Vertex v) const
returns whether v is isolated, i.e., not incident to any face
Definition surface_mesh.h:1552
vec3 & position(Vertex v)
Returns the position of a vertex.
Definition surface_mesh.h:2465
bool is_deleted(Halfedge h) const
Definition surface_mesh.h:1493
HalfedgeAroundVertexCirculator halfedges(Vertex v) const
Returns circulator for outgoing halfedges around vertex v.
Definition surface_mesh.h:2215
unsigned int vertices_size() const
returns number of (deleted and valid) vertices in the mesh
Definition surface_mesh.h:1436
Edge edge(Halfedge h) const
return the edge that contains halfedge h as one of its two halfedges.
Definition surface_mesh.h:1649
bool remove_model_property(const std::string &n)
Remove the model property named n.
Definition surface_mesh.h:1960
float edge_length(Edge e) const
compute the length of edge e.
Definition surface_mesh.cpp:1175
EdgeProperty< T > add_edge_property(const std::string &name, const T t=T())
Add an edge property of type T with name name and default value t.
Definition surface_mesh.h:1747
unsigned int faces_size() const
returns number of (deleted and valid)faces in the mesh
Definition surface_mesh.h:1442
Halfedge next(Halfedge h) const
returns the next halfedge within the incident face
Definition surface_mesh.h:1604
Face face(Edge e, unsigned int i) const
returns the face incident to the i'th halfedge of edge e. i has to be 0 or 1.
Definition surface_mesh.h:1672
Halfedge out_halfedge(Vertex v) const
Definition surface_mesh.h:1536
void delete_vertex(Vertex v)
Definition surface_mesh.cpp:1898
bool is_border(Edge e) const
Definition surface_mesh.h:1679
VertexIterator vertices_begin() const
Returns an iterator to the beginning of the vertices.
Definition surface_mesh.h:2109
HalfedgeIterator halfedges_end() const
Returns an iterator to the end of the halfedges.
Definition surface_mesh.h:2141
bool remove_vertex_property(VertexProperty< T > &p)
Remove the vertex property p.
Definition surface_mesh.h:1893
bool is_degenerate(Face f) const
returns whether f is degenerate
Definition surface_mesh.cpp:2207
VertexIterator vertices_end() const
Returns an iterator to the end of the vertices.
Definition surface_mesh.h:2117
bool is_valid(Vertex v) const
return whether vertex v is valid, i.e. the index is stores it within the array bounds.
Definition surface_mesh.h:1509
Vertex vertex(Edge e, unsigned int i) const
returns the i'th vertex of edge e. i has to be 0 or 1.
Definition surface_mesh.h:1666
bool is_border(Halfedge h) const
returns whether h is a boundary halfedge, i.e., if its face does not exist.
Definition surface_mesh.h:1654
bool join_edges(Vertex v)
Definition surface_mesh.cpp:2287
const std::vector< vec3 > & points() const override
Returns a read-only vector of all vertex positions.
Definition surface_mesh.h:2471
unsigned int n_vertices() const
returns number of vertices in the mesh
Definition surface_mesh.h:1446
void set_out_halfedge(Vertex v, Halfedge h)
set the outgoing halfedge of vertex v to h
Definition surface_mesh.h:1541
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
std::ostream & operator<<(std::ostream &os, Graph::Vertex v)
Output stream support for Graph::Vertex.
Definition graph.h:1300
Helper structure to be able to use std::unordered_map.
Definition surface_mesh.h:115
std::size_t operator()(const BaseHandle &h) const
Hash function for BaseHandle.
Definition surface_mesh.h:121
Definition surface_mesh.h:173
std::ostream & operator<<(std::ostream &os) const
Output stream support for Edge.
Definition surface_mesh.h:184
Edge(int _idx=-1)
Default constructor (with invalid index).
Definition surface_mesh.h:178
This type stores the face connectivity.
Definition surface_mesh.h:241
Halfedge halfedge_
a halfedge that is part of the face
Definition surface_mesh.h:243
Definition surface_mesh.h:191
Face(int _idx=-1)
Default constructor (with invalid index).
Definition surface_mesh.h:196
std::ostream & operator<<(std::ostream &os) const
Output stream support for Face.
Definition surface_mesh.h:202
This type stores the halfedge connectivity.
Definition surface_mesh.h:224
Vertex vertex_
vertex the halfedge points to
Definition surface_mesh.h:228
Halfedge next_
next halfedge within a face (or along a boundary)
Definition surface_mesh.h:230
Face face_
face incident to halfedge
Definition surface_mesh.h:226
Halfedge prev_
previous halfedge within a face (or along a boundary)
Definition surface_mesh.h:232
This type represents a halfedge (internally it is basically an index).
Definition surface_mesh.h:155
std::ostream & operator<<(std::ostream &os) const
Output stream support for Halfedge.
Definition surface_mesh.h:166
Halfedge(int _idx=-1)
Default constructor (with invalid index).
Definition surface_mesh.h:160
This type stores the vertex connectivity.
Definition surface_mesh.h:213
Halfedge halfedge_
an outgoing halfedge per vertex (it will be a boundary halfedge for boundary vertices)
Definition surface_mesh.h:215
This type represents a vertex (internally it is basically an index).
Definition surface_mesh.h:135
std::ostream & operator<<(std::ostream &os) const
Output stream support for Vertex.
Definition surface_mesh.h:146
Vertex(int _idx=-1)
Default constructor (with invalid index).
Definition surface_mesh.h:140