Easy3D 2.5.3
poly_mesh.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_CORE_POLYHEDRAL_MESH_H
28#define EASY3D_CORE_POLYHEDRAL_MESH_H
29
30#include <easy3d/core/model.h>
31
32#include <set>
33
34#include <easy3d/core/types.h>
35#include <easy3d/core/property.h>
36
37
38namespace easy3d {
39
49 class PolyMesh : public virtual Model
50 {
51
52 public: //------------------------------------------------------ topology types
53
54
58 {
59 public:
60
62 explicit BaseHandle(int _idx=-1) : idx_(_idx) {}
63
65 int idx() const { return idx_; }
66
68 void reset() { idx_=-1; }
69
71 bool is_valid() const { return idx_ != -1; }
72
74 bool operator==(const BaseHandle& _rhs) const {
75 return idx_ == _rhs.idx_;
76 }
77
79 bool operator!=(const BaseHandle& _rhs) const {
80 return idx_ != _rhs.idx_;
81 }
82
84 bool operator<(const BaseHandle& _rhs) const {
85 return idx_ < _rhs.idx_;
86 }
87
89 struct Hash {
90 std::size_t operator()(const BaseHandle& h) const { return h.idx(); }
91 };
92
93 private:
94 friend class PolyMesh;
95 int idx_;
96 };
97
98
101 struct Vertex : public BaseHandle
102 {
104 explicit Vertex(int _idx=-1) : BaseHandle(_idx) {}
105 std::ostream& operator<<(std::ostream& os) const { return os << 'v' << idx(); }
106 };
107
110 struct Edge : public BaseHandle
111 {
113 explicit Edge(int _idx=-1) : BaseHandle(_idx) {}
114 std::ostream& operator<<(std::ostream& os) const { return os << 'e' << idx(); }
115 };
116
117
120 struct HalfFace : public BaseHandle
121 {
123 explicit HalfFace(int _idx=-1) : BaseHandle(_idx) {}
124 std::ostream& operator<<(std::ostream& os) const { return os << 'h' << idx(); }
125 };
126
129 struct Face : public BaseHandle
130 {
132 explicit Face(int _idx=-1) : BaseHandle(_idx) {}
133 std::ostream& operator<<(std::ostream& os) const { return os << 'f' << idx(); }
134 };
135
138 struct Cell : public BaseHandle
139 {
141 explicit Cell(int _idx=-1) : BaseHandle(_idx) {}
142 std::ostream& operator<<(std::ostream& os) const { return os << 'c' << idx(); }
143 };
144
145
146
147 public: //-------------------------------------------------- connectivity types
148
152 {
153 std::set<Vertex> vertices_;
154 std::set<Edge> edges_;
155 std::set<HalfFace> halffaces_;
156 std::set<Cell> cells_;
157
158 void read(std::istream& in);
159 void write(std::ostream& out) const;
160 };
161
162
166 {
167 std::vector<Vertex> vertices_;
168 std::set<HalfFace> halffaces_;
169 std::set<Cell> cells_;
170
171 void read(std::istream& in);
172 void write(std::ostream& out) const;
173 };
174
178 {
179 std::vector<Vertex> vertices_;
180 std::set<Edge> edges_;
181 Cell cell_;
182 HalfFace opposite_;
183
184 void read(std::istream& in);
185 void write(std::ostream& out) const;
186 };
187
191 {
192 std::set<Vertex> vertices_;
193 std::set<Edge> edges_;
194 std::vector<HalfFace> halffaces_;
195
196 void read(std::istream& in);
197 void write(std::ostream& out) const;
198 };
199
200
201
202 public: //------------------------------------------------------ property types
203
206 template <class T> class VertexProperty : public Property<T>
207 {
208 public:
209
211 VertexProperty() = default;
212 explicit VertexProperty(Property<T> p) : Property<T>(p) {}
213
215 typename Property<T>::reference operator[](Vertex v)
216 {
217 return Property<T>::operator[](v.idx());
218 }
219
221 typename Property<T>::const_reference operator[](Vertex v) const
222 {
223 return Property<T>::operator[](v.idx());
224 }
225 };
226
227
230 template <class T> class EdgeProperty : public Property<T>
231 {
232 public:
233
235 EdgeProperty() = default;
236 explicit EdgeProperty(Property<T> p) : Property<T>(p) {}
237
239 typename Property<T>::reference operator[](Edge e)
240 {
241 return Property<T>::operator[](e.idx());
242 }
243
245 typename Property<T>::const_reference operator[](Edge e) const
246 {
247 return Property<T>::operator[](e.idx());
248 }
249 };
250
251
254 template <class T> class HalfFaceProperty : public Property<T>
255 {
256 public:
257
259 HalfFaceProperty() = default;
260 explicit HalfFaceProperty(Property<T> p) : Property<T>(p) {}
261
263 typename Property<T>::reference operator[](HalfFace h)
264 {
265 return Property<T>::operator[](h.idx());
266 }
267
269 typename Property<T>::const_reference operator[](HalfFace h) const
270 {
271 return Property<T>::operator[](h.idx());
272 }
273 };
274
275
278 template <class T> class FaceProperty : public Property<T>
279 {
280 public:
281
283 FaceProperty() = default;
284 explicit FaceProperty(Property<T> p) : Property<T>(p) {}
285
287 typename Property<T>::reference operator[](Face f)
288 {
289 return Property<T>::operator[](f.idx());
290 }
291
293 typename Property<T>::const_reference operator[](Face f) const
294 {
295 return Property<T>::operator[](f.idx());
296 }
297 };
298
299
302 template <class T> class CellProperty : public Property<T>
303 {
304 public:
305
307 CellProperty() = default;
308 explicit CellProperty(Property<T> p) : Property<T>(p) {}
309
311 typename Property<T>::reference operator[](Cell c)
312 {
313 return Property<T>::operator[](c.idx());
314 }
315
317 typename Property<T>::const_reference operator[](Cell c) const
318 {
319 return Property<T>::operator[](c.idx());
320 }
321 };
322
323
326 template <class T> class ModelProperty : public Property<T>
327 {
328 public:
329
331 ModelProperty() = default;
332 explicit ModelProperty(Property<T> p) : Property<T>(p) {}
333
335 typename Property<T>::reference operator[](size_t idx)
336 {
337 return Property<T>::operator[](idx);
338 }
339
341 typename Property<T>::const_reference operator[](size_t idx) const
342 {
343 return Property<T>::operator[](idx);
344 }
345 };
346
347
348
349 public: //------------------------------------------------------ iterator types
350
355 {
356 public:
357
359 explicit VertexIterator(Vertex v=Vertex(), const PolyMesh* m=nullptr) : hnd_(v), mesh_(m)
360 {
361 }
362
364 Vertex operator*() const { return hnd_; }
365
367 bool operator==(const VertexIterator& rhs) const
368 {
369 return (hnd_==rhs.hnd_);
370 }
371
373 bool operator!=(const VertexIterator& rhs) const
374 {
375 return !operator==(rhs);
376 }
377
380 {
381 ++hnd_.idx_;
382 assert(mesh_);
383 return *this;
384 }
385
388 {
389 --hnd_.idx_;
390 assert(mesh_);
391 return *this;
392 }
393
394 private:
395 Vertex hnd_;
396 const PolyMesh* mesh_;
397 };
398
399
404 {
405 public:
406
408 explicit EdgeIterator(Edge e=Edge(), const PolyMesh* m=nullptr) : hnd_(e), mesh_(m)
409 {
410 }
411
413 Edge operator*() const { return hnd_; }
414
416 bool operator==(const EdgeIterator& rhs) const
417 {
418 return (hnd_==rhs.hnd_);
419 }
420
422 bool operator!=(const EdgeIterator& rhs) const
423 {
424 return !operator==(rhs);
425 }
426
429 {
430 ++hnd_.idx_;
431 assert(mesh_);
432 return *this;
433 }
434
437 {
438 --hnd_.idx_;
439 assert(mesh_);
440 return *this;
441 }
442
443 private:
444 Edge hnd_;
445 const PolyMesh* mesh_;
446 };
447
448
453 {
454 public:
455
457 explicit HalfFaceIterator(HalfFace h=HalfFace(), const PolyMesh* m=nullptr) : hnd_(h), mesh_(m)
458 {
459 }
460
462 HalfFace operator*() const { return hnd_; }
463
465 bool operator==(const HalfFaceIterator& rhs) const
466 {
467 return (hnd_==rhs.hnd_);
468 }
469
471 bool operator!=(const HalfFaceIterator& rhs) const
472 {
473 return !operator==(rhs);
474 }
475
478 {
479 ++hnd_.idx_;
480 assert(mesh_);
481 return *this;
482 }
483
486 {
487 --hnd_.idx_;
488 assert(mesh_);
489 return *this;
490 }
491
492 private:
493 HalfFace hnd_;
494 const PolyMesh* mesh_;
495 };
496
497
502 {
503 public:
504
506 explicit FaceIterator(Face f=Face(), const PolyMesh* m=nullptr) : hnd_(f), mesh_(m)
507 {
508 }
509
511 Face operator*() const { return hnd_; }
512
514 bool operator==(const FaceIterator& rhs) const
515 {
516 return (hnd_==rhs.hnd_);
517 }
518
520 bool operator!=(const FaceIterator& rhs) const
521 {
522 return !operator==(rhs);
523 }
524
527 {
528 ++hnd_.idx_;
529 assert(mesh_);
530 return *this;
531 }
532
535 {
536 --hnd_.idx_;
537 assert(mesh_);
538 return *this;
539 }
540
541 private:
542 Face hnd_;
543 const PolyMesh* mesh_;
544 };
545
546
551 {
552 public:
553
555 explicit CellIterator(Cell c=Cell(), const PolyMesh* m=nullptr) : hnd_(c), mesh_(m)
556 {
557 }
558
560 Cell operator*() const { return hnd_; }
561
563 bool operator==(const CellIterator& rhs) const
564 {
565 return (hnd_==rhs.hnd_);
566 }
567
569 bool operator!=(const CellIterator& rhs) const
570 {
571 return !operator==(rhs);
572 }
573
576 {
577 ++hnd_.idx_;
578 assert(mesh_);
579 return *this;
580 }
581
584 {
585 --hnd_.idx_;
586 assert(mesh_);
587 return *this;
588 }
589
590 private:
591 Cell hnd_;
592 const PolyMesh* mesh_;
593 };
594
595
596 public: //-------------------------- containers for C++11 range-based for loops
597
602 {
603 public:
604 VertexContainer(VertexIterator _begin, VertexIterator _end) : begin_(_begin), end_(_end) {}
605 VertexIterator begin() const { return begin_; }
606 VertexIterator end() const { return end_; }
607 private:
608 VertexIterator begin_, end_;
609 };
610
611
616 {
617 public:
618 EdgeContainer(EdgeIterator _begin, EdgeIterator _end) : begin_(_begin), end_(_end) {}
619 EdgeIterator begin() const { return begin_; }
620 EdgeIterator end() const { return end_; }
621 private:
622 EdgeIterator begin_, end_;
623 };
624
625
630 {
631 public:
632 HalffaceContainer(HalfFaceIterator _begin, HalfFaceIterator _end) : begin_(_begin), end_(_end) {}
633 HalfFaceIterator begin() const { return begin_; }
634 HalfFaceIterator end() const { return end_; }
635 private:
636 HalfFaceIterator begin_, end_;
637 };
638
639
644 {
645 public:
646 FaceContainer(FaceIterator _begin, FaceIterator _end) : begin_(_begin), end_(_end) {}
647 FaceIterator begin() const { return begin_; }
648 FaceIterator end() const { return end_; }
649 private:
650 FaceIterator begin_, end_;
651 };
652
653
658 {
659 public:
660 CellContainer(CellIterator _begin, CellIterator _end) : begin_(_begin), end_(_end) {}
661 CellIterator begin() const { return begin_; }
662 CellIterator end() const { return end_; }
663 private:
664 CellIterator begin_, end_;
665 };
666
667
668 public: //-------------------------------------------- constructor / destructor
669
671
672
674 PolyMesh();
675
676 // destructor
677 ~PolyMesh() override = default;
678
680 PolyMesh(const PolyMesh& rhs) { operator=(rhs); }
681
683 PolyMesh& operator=(const PolyMesh& rhs);
684
686 PolyMesh& assign(const PolyMesh& rhs);
688
691
695 bool read(const std::string& filename);
696
700 bool write(const std::string& filename) const;
702
703 public: //----------------------------------------------- add new vertex / face / cell
704
706
707
709 Vertex add_vertex(const vec3& p) { Vertex v = new_vertex(); vpoint_[v] = p; return v; }
710
714 Cell add_cell(const std::vector<HalfFace>& faces);
715
719 Cell add_tetra(HalfFace f0, HalfFace f1, HalfFace f2, HalfFace f3) { return add_cell({f0, f1, f2, f3}); }
720
725 Cell add_tetra(Vertex v0, Vertex v1, Vertex v2, Vertex v3);
726
743 Cell add_hexa(Vertex v0, Vertex v1, Vertex v2, Vertex v3, Vertex v4, Vertex v5, Vertex v6, Vertex v7);
744
748 HalfFace add_face(const std::vector<Vertex>& vertices);
749
753 HalfFace add_triangle(Vertex v0, Vertex v1, Vertex v2) { return add_face({ v0, v1, v2 }); }
754
758 HalfFace add_quad(Vertex v0, Vertex v1, Vertex v2, Vertex v3) { return add_face({ v0, v1, v2, v3}); }
759
761
762 public: //--------------------------------------------------- memory management
763
765
766
768 unsigned int n_vertices() const { return (unsigned int) vprops_.size(); }
770 unsigned int n_edges() const { return (unsigned int) eprops_.size(); }
772 unsigned int n_halffaces() const { return (unsigned int) hprops_.size(); }
774 unsigned int n_faces() const { return (unsigned int) fprops_.size(); }
776 unsigned int n_cells() const { return (unsigned int) cprops_.size(); }
777
781 void clear();
782
786 void resize(unsigned int nv, unsigned int ne, unsigned int nf, unsigned int nc) {
787 vprops_.resize(nv);
788 eprops_.resize(ne);
789 hprops_.resize(2 * nf);
790 fprops_.resize(nf);
791 cprops_.resize(nc);
792 }
793
795 bool is_valid(Vertex v) const
796 {
797 return (0 <= v.idx()) && (v.idx() < (int)n_vertices());
798 }
800 bool is_valid(Edge e) const
801 {
802 return (0 <= e.idx()) && (e.idx() < (int)n_edges());
803 }
805 bool is_valid(HalfFace h) const
806 {
807 return (0 <= h.idx()) && (h.idx() < (int)n_halffaces());
808 }
810 bool is_valid(Face f) const
811 {
812 return (0 <= f.idx()) && (f.idx() < (int)n_faces());
813 }
815 bool is_valid(Cell c) const
816 {
817 return (0 <= c.idx()) && (c.idx() < (int)n_cells());
818 }
819
821
822
823 public: //--------------------------------------------------- property handling
824
826
827
831 template <class T> VertexProperty<T> add_vertex_property(const std::string& name, const T t=T())
832 {
833 return VertexProperty<T>(vprops_.add<T>(name, t));
834 }
838 template <class T> EdgeProperty<T> add_edge_property(const std::string& name, const T t=T())
839 {
840 return EdgeProperty<T>(eprops_.add<T>(name, t));
841 }
845 template <class T> HalfFaceProperty<T> add_halfface_property(const std::string& name, const T t=T())
846 {
847 return HalfFaceProperty<T>(hprops_.add<T>(name, t));
848 }
852 template <class T> FaceProperty<T> add_face_property(const std::string& name, const T t=T())
853 {
854 return FaceProperty<T>(fprops_.add<T>(name, t));
855 }
859 template <class T> CellProperty<T> add_cell_property(const std::string& name, const T t=T())
860 {
861 return CellProperty<T>(cprops_.add<T>(name, t));
862 }
873 template <class T> ModelProperty<T> add_model_property(const std::string& name, const T t=T())
874 {
875 return ModelProperty<T>(mprops_.add<T>(name, t));
876 }
877
878
881 template <class T> VertexProperty<T> get_vertex_property(const std::string& name) const
882 {
883 return VertexProperty<T>(vprops_.get<T>(name));
884 }
887 template <class T> EdgeProperty<T> get_edge_property(const std::string& name) const
888 {
889 return EdgeProperty<T>(eprops_.get<T>(name));
890 }
893 template <class T> HalfFaceProperty<T> get_halfface_property(const std::string& name) const
894 {
895 return HalfFaceProperty<T>(hprops_.get<T>(name));
896 }
899 template <class T> FaceProperty<T> get_face_property(const std::string& name) const
900 {
901 return FaceProperty<T>(fprops_.get<T>(name));
902 }
905 template <class T> CellProperty<T> get_cell_property(const std::string& name) const
906 {
907 return CellProperty<T>(cprops_.get<T>(name));
908 }
919 template <class T> ModelProperty<T> get_model_property(const std::string& name) const
920 {
921 return ModelProperty<T>(mprops_.get<T>(name));
922 }
923
924
927 template <class T> VertexProperty<T> vertex_property(const std::string& name, const T t=T())
928 {
929 return VertexProperty<T>(vprops_.get_or_add<T>(name, t));
930 }
933 template <class T> EdgeProperty<T> edge_property(const std::string& name, const T t=T())
934 {
935 return EdgeProperty<T>(eprops_.get_or_add<T>(name, t));
936 }
939 template <class T> HalfFaceProperty<T> halfface_property(const std::string& name, const T t=T())
940 {
941 return HalfFaceProperty<T>(hprops_.get_or_add<T>(name, t));
942 }
945 template <class T> FaceProperty<T> face_property(const std::string& name, const T t=T())
946 {
947 return FaceProperty<T>(fprops_.get_or_add<T>(name, t));
948 }
951 template <class T> CellProperty<T> cell_property(const std::string& name, const T t=T())
952 {
953 return CellProperty<T>(cprops_.get_or_add<T>(name, t));
954 }
957 template <class T> ModelProperty<T> model_property(const std::string& name, const T t=T())
958 {
959 return ModelProperty<T>(mprops_.get_or_add<T>(name, t));
960 }
961
962
964 template<class T>
965 bool remove_vertex_property(VertexProperty<T> &p) { return vprops_.remove(p); }
966
968 bool remove_vertex_property(const std::string &n) { return vprops_.remove(n); }
969
971 template<class T>
972 bool remove_edge_property(EdgeProperty<T> &p) { return eprops_.remove(p); }
973
975 bool remove_edge_property(const std::string &n) { return eprops_.remove(n); }
976
978 template<class T>
979 bool remove_halfface_property(HalfFaceProperty<T> &p) { return hprops_.remove(p); }
980
982 bool remove_halfface_property(const std::string &n) { return hprops_.remove(n); }
983
985 template<class T>
986 bool remove_face_property(FaceProperty<T> &p) { return fprops_.remove(p); }
987
989 bool remove_face_property(const std::string &n) { return fprops_.remove(n); }
990
992 template<class T>
993 bool remove_cell_property(CellProperty<T> &p) { return cprops_.remove(p); }
994
996 bool remove_cell_property(const std::string &n) { return cprops_.remove(n); }
997
999 template<class T>
1000 bool remove_model_property(ModelProperty<T> &p) { return mprops_.remove(p); }
1001
1003 bool remove_model_property(const std::string &n) { return mprops_.remove(n); }
1004
1006 bool rename_vertex_property(const std::string &old_name, const std::string &new_name) {
1007 return vprops_.rename(old_name, new_name);
1008 }
1009
1011 bool rename_halfface_property(const std::string &old_name, const std::string &new_name) {
1012 return hprops_.rename(old_name, new_name);
1013 }
1014
1016 bool rename_face_property(const std::string &old_name, const std::string &new_name) {
1017 return fprops_.rename(old_name, new_name);
1018 }
1019
1021 bool rename_edge_property(const std::string &old_name, const std::string &new_name) {
1022 return eprops_.rename(old_name, new_name);
1023 }
1024
1026 bool rename_cell_property(const std::string &old_name, const std::string &new_name) {
1027 return cprops_.rename(old_name, new_name);
1028 }
1029
1031 bool rename_model_property(const std::string &old_name, const std::string &new_name) {
1032 return mprops_.rename(old_name, new_name);
1033 }
1034
1035
1038 const std::type_info& get_vertex_property_type(const std::string& name) const
1039 {
1040 return vprops_.get_type(name);
1041 }
1044 const std::type_info& get_edge_property_type(const std::string& name) const
1045 {
1046 return eprops_.get_type(name);
1047 }
1050 const std::type_info& get_halfface_property_type(const std::string& name) const
1051 {
1052 return hprops_.get_type(name);
1053 }
1056 const std::type_info& get_face_property_type(const std::string& name) const
1057 {
1058 return fprops_.get_type(name);
1059 }
1062 const std::type_info& get_cell_property_type(const std::string& name) const
1063 {
1064 return cprops_.get_type(name);
1065 }
1068 const std::type_info& get_model_property_type(const std::string& name) const
1069 {
1070 return mprops_.get_type(name);
1071 }
1072
1073
1075 std::vector<std::string> vertex_properties() const
1076 {
1077 return vprops_.properties();
1078 }
1080 std::vector<std::string> edge_properties() const
1081 {
1082 return eprops_.properties();
1083 }
1085 std::vector<std::string> halfface_properties() const
1086 {
1087 return hprops_.properties();
1088 }
1090 std::vector<std::string> face_properties() const
1091 {
1092 return fprops_.properties();
1093 }
1095 std::vector<std::string> cell_properties() const
1096 {
1097 return cprops_.properties();
1098 }
1100 std::vector<std::string> model_properties() const
1101 {
1102 return mprops_.properties();
1103 }
1104
1106 void property_stats(std::ostream &output) const override;
1107
1109
1110
1111 public: //--------------------------------------------- iterators & circulators
1112
1114
1115
1118 {
1119 return VertexIterator(Vertex(0), this);
1120 }
1121
1124 {
1125 return VertexIterator(Vertex(static_cast<int>(n_vertices())), this);
1126 }
1127
1130 {
1132 }
1133
1136 {
1137 return EdgeIterator(Edge(0), this);
1138 }
1139
1142 {
1143 return EdgeIterator(Edge(static_cast<int>(n_edges())), this);
1144 }
1145
1148 {
1149 return EdgeContainer(edges_begin(), edges_end());
1150 }
1151
1154 {
1155 return HalfFaceIterator(HalfFace(0), this);
1156 }
1157
1160 {
1161 return HalfFaceIterator(HalfFace(static_cast<int>(n_halffaces())), this);
1162 }
1163
1166 {
1168 }
1169
1172 {
1173 return FaceIterator(Face(0), this);
1174 }
1175
1178 {
1179 return FaceIterator(Face(static_cast<int>(n_faces())), this);
1180 }
1181
1184 {
1185 return FaceContainer(faces_begin(), faces_end());
1186 }
1187
1190 {
1191 return CellIterator(Cell(0), this);
1192 }
1193
1196 {
1197 return CellIterator(Cell(static_cast<int>(n_cells())), this);
1198 }
1199
1202 {
1203 return CellContainer(cells_begin(), cells_end());
1204 }
1206
1207 public: //--------------------------------------------- adjacency access
1208
1210
1211
1213 const std::set<Vertex>& vertices(Vertex v) const
1214 {
1215 return vconn_[v].vertices_;
1216 }
1217
1219 HalfFace halfface(Face f, unsigned int i) const
1220 {
1221 assert(i<=1);
1222 return HalfFace(static_cast<int>((f.idx() << 1) + i));
1223 }
1224
1226 Face face(HalfFace h) const {
1227 return Face((h.idx() >> 1));
1228 }
1229
1232 {
1233 return hconn_[h].opposite_;
1234 }
1235
1237 Vertex vertex(Edge e, unsigned int i) const
1238 {
1239 assert(i<=1);
1240 return econn_[e].vertices_[i];
1241 }
1242
1245 const std::vector<Vertex>& vertices(HalfFace h) const
1246 {
1247 return hconn_[h].vertices_;
1248 }
1249
1251 const std::vector<Vertex>& vertices(Face f) const
1252 {
1253 return vertices(halfface(f, 0));
1254 }
1255
1257 const std::set<Vertex>& vertices(Cell c) const
1258 {
1259 return cconn_[c].vertices_;
1260 }
1261
1263 const std::set<Edge>& edges(Vertex v) const
1264 {
1265 return vconn_[v].edges_;
1266 }
1267
1269 const std::set<Edge>& edges(HalfFace h) const
1270 {
1271 return hconn_[h].edges_;
1272 }
1273
1275 const std::set<Edge>& edges(Cell c) const
1276 {
1277 return cconn_[c].edges_;
1278 }
1279
1281 const std::set<HalfFace>& halffaces(Vertex v) const
1282 {
1283 return vconn_[v].halffaces_;
1284 }
1285
1287 const std::set<HalfFace>& halffaces(Edge e) const
1288 {
1289 return econn_[e].halffaces_;
1290 }
1291
1293 const std::vector<HalfFace>& halffaces(Cell c) const
1294 {
1295 return cconn_[c].halffaces_;
1296 }
1297
1299 const std::set<Cell>& cells(Vertex v) const
1300 {
1301 return vconn_[v].cells_;
1302 }
1303
1305 const std::set<Cell>& cells(Edge e) const
1306 {
1307 return econn_[e].cells_;
1308 }
1309
1312 {
1313 return hconn_[h].cell_;
1314 }
1316
1317 public: //--------------------------------------------- higher-level operations
1318
1320
1321
1323 bool is_tetraheral_mesh() const;
1324
1327 bool is_border(Vertex v) const {
1328 for (auto h : halffaces(v)) { if (is_border(h)) return true; }
1329 return false;
1330 }
1331
1334 bool is_border(Edge e) const {
1335 for (auto h : halffaces(e)) { if (is_border(h)) return true; }
1336 return false;
1337 }
1338
1340 bool is_border(HalfFace h) const {
1341 return (!cell(h).is_valid());
1342 }
1343
1345 bool is_border(Face f) const {
1346 return is_border(halfface(f, 0)) || is_border(halfface(f, 1));
1347 }
1348
1350 Edge find_edge(Vertex a, Vertex b) const;
1351
1353 HalfFace find_half_face(const std::vector<Vertex>& vertices) const;
1354
1356 bool is_degenerate(Face f) const;
1357
1359 void extract_boundary(std::vector< std::vector<Vertex> >& faces) const;
1361
1362 public: //------------------------------------------ geometry-related functions
1363
1365
1366
1368 const vec3& position(Vertex v) const { return vpoint_[v]; }
1369
1371 const std::vector<vec3>& points() const override { return vpoint_.vector(); }
1372
1374 std::vector<vec3>& points() override { return vpoint_.vector(); }
1375
1377 void update_face_normals();
1378
1380 vec3 compute_face_normal(Face f) const;
1381
1389 void update_vertex_normals();
1390
1392 float edge_length(Edge e) const;
1393
1395
1396
1397 private: //---------------------------------------------- allocate new elements
1398
1400 Vertex new_vertex()
1401 {
1402 vprops_.push_back();
1403 return Vertex(static_cast<int>(n_vertices()-1));
1404 }
1405
1407 Edge new_edge(Vertex s, Vertex t)
1408 {
1409 assert(s != t);
1410 eprops_.push_back();
1411 Edge e = Edge(static_cast<int>(n_edges() - 1));
1412 econn_[e].vertices_ = {s, t};
1413 vconn_[s].edges_.insert(e);
1414 vconn_[t].edges_.insert(e);
1415 vconn_[s].vertices_.insert(t);
1416 vconn_[t].vertices_.insert(s);
1417 return e;
1418 }
1419
1421 HalfFace new_face()
1422 {
1423 fprops_.push_back();
1424 hprops_.push_back();
1425 hprops_.push_back();
1426 HalfFace h0(static_cast<int>(n_halffaces()-2));
1427 HalfFace h1(static_cast<int>(n_halffaces()-1));
1428
1429 hconn_[h0].opposite_ = h1;
1430 hconn_[h1].opposite_ = h0;
1431
1432 return h0;
1433 }
1434
1436 Cell new_cell()
1437 {
1438 cprops_.push_back();
1439 return Cell(static_cast<int>(n_cells()-1));
1440 }
1441
1442 private: //------------------------------------------------------- private data
1443
1444 PropertyContainer vprops_;
1445 PropertyContainer eprops_;
1446 PropertyContainer hprops_;
1447 PropertyContainer fprops_;
1448 PropertyContainer cprops_;
1449 PropertyContainer mprops_;
1450
1451 VertexProperty<VertexConnectivity> vconn_;
1452 EdgeProperty<EdgeConnectivity> econn_;
1453 HalfFaceProperty<HalfFaceConnectivity> hconn_;
1454 CellProperty<CellConnectivity> cconn_;
1455
1456 VertexProperty<vec3> vpoint_;
1457 };
1458
1459
1460 //------------------------------------------------------------ output operators
1461
1463 inline std::ostream& operator<<(std::ostream& os, PolyMesh::Vertex v)
1464 {
1465 return (os << 'v' << v.idx());
1466 }
1467
1469 inline std::ostream& operator<<(std::ostream& os, PolyMesh::Edge e)
1470 {
1471 return (os << 'e' << e.idx());
1472 }
1473
1475 inline std::ostream& operator<<(std::ostream& os, PolyMesh::HalfFace h)
1476 {
1477 return (os << 'h' << h.idx());
1478 }
1479
1481 inline std::ostream& operator<<(std::ostream& os, PolyMesh::Face f)
1482 {
1483 return (os << 'f' << f.idx());
1484 }
1485
1487 inline std::ostream& operator<<(std::ostream& os, PolyMesh::Cell c)
1488 {
1489 return (os << 'c' << c.idx());
1490 }
1491
1492} // namespace easy3d
1493
1494#endif // EASY3D_CORE_POLYHEDRAL_MESH_H
The base class of renderable 3D models.
Definition: model.h:49
const std::string & name() const
The name of a model.
Definition: model.h:60
Definition: poly_mesh.h:58
bool operator!=(const BaseHandle &_rhs) const
are two handles different?
Definition: poly_mesh.h:79
bool is_valid() const
return whether the handle is valid, i.e., the index is not equal to -1.
Definition: poly_mesh.h:71
int idx() const
Get the underlying index of this handle.
Definition: poly_mesh.h:65
bool operator<(const BaseHandle &_rhs) const
compare operator useful for sorting handles
Definition: poly_mesh.h:84
bool operator==(const BaseHandle &_rhs) const
are two handles equal?
Definition: poly_mesh.h:74
void reset()
reset handle to be invalid (index=-1)
Definition: poly_mesh.h:68
BaseHandle(int _idx=-1)
constructor
Definition: poly_mesh.h:62
Definition: poly_mesh.h:658
Definition: poly_mesh.h:551
bool operator==(const CellIterator &rhs) const
are two iterators equal?
Definition: poly_mesh.h:563
bool operator!=(const CellIterator &rhs) const
are two iterators different?
Definition: poly_mesh.h:569
CellIterator & operator--()
pre-decrement iterator
Definition: poly_mesh.h:583
Cell operator*() const
get the cell the iterator refers to
Definition: poly_mesh.h:560
CellIterator & operator++()
pre-increment iterator
Definition: poly_mesh.h:575
CellIterator(Cell c=Cell(), const PolyMesh *m=nullptr)
Default constructor.
Definition: poly_mesh.h:555
Definition: poly_mesh.h:303
Property< T >::const_reference operator[](Cell c) const
access the data stored for Cell c
Definition: poly_mesh.h:317
Property< T >::reference operator[](Cell c)
access the data stored for Cell c
Definition: poly_mesh.h:311
CellProperty()=default
default constructor
Definition: poly_mesh.h:616
Definition: poly_mesh.h:404
bool operator!=(const EdgeIterator &rhs) const
are two iterators different?
Definition: poly_mesh.h:422
EdgeIterator & operator++()
pre-increment iterator
Definition: poly_mesh.h:428
Edge operator*() const
get the edge the iterator refers to
Definition: poly_mesh.h:413
bool operator==(const EdgeIterator &rhs) const
are two iterators equal?
Definition: poly_mesh.h:416
EdgeIterator(Edge e=Edge(), const PolyMesh *m=nullptr)
Default constructor.
Definition: poly_mesh.h:408
EdgeIterator & operator--()
pre-decrement iterator
Definition: poly_mesh.h:436
Definition: poly_mesh.h:231
EdgeProperty()=default
default constructor
Property< T >::reference operator[](Edge e)
access the data stored for edge e
Definition: poly_mesh.h:239
Property< T >::const_reference operator[](Edge e) const
access the data stored for edge e
Definition: poly_mesh.h:245
Definition: poly_mesh.h:644
Definition: poly_mesh.h:502
bool operator!=(const FaceIterator &rhs) const
are two iterators different?
Definition: poly_mesh.h:520
bool operator==(const FaceIterator &rhs) const
are two iterators equal?
Definition: poly_mesh.h:514
FaceIterator & operator--()
pre-decrement iterator
Definition: poly_mesh.h:534
FaceIterator(Face f=Face(), const PolyMesh *m=nullptr)
Default constructor.
Definition: poly_mesh.h:506
Face operator*() const
get the face the iterator refers to
Definition: poly_mesh.h:511
FaceIterator & operator++()
pre-increment iterator
Definition: poly_mesh.h:526
Definition: poly_mesh.h:279
Property< T >::reference operator[](Face f)
access the data stored for face f
Definition: poly_mesh.h:287
FaceProperty()=default
default constructor
Property< T >::const_reference operator[](Face f) const
access the data stored for face f
Definition: poly_mesh.h:293
Definition: poly_mesh.h:453
HalfFaceIterator & operator++()
pre-increment iterator
Definition: poly_mesh.h:477
HalfFaceIterator(HalfFace h=HalfFace(), const PolyMesh *m=nullptr)
Default constructor.
Definition: poly_mesh.h:457
HalfFaceIterator & operator--()
pre-decrement iterator
Definition: poly_mesh.h:485
bool operator!=(const HalfFaceIterator &rhs) const
are two iterators different?
Definition: poly_mesh.h:471
HalfFace operator*() const
get the halfface the iterator refers to
Definition: poly_mesh.h:462
bool operator==(const HalfFaceIterator &rhs) const
are two iterators equal?
Definition: poly_mesh.h:465
Definition: poly_mesh.h:255
Property< T >::const_reference operator[](HalfFace h) const
access the data stored for halfface h
Definition: poly_mesh.h:269
Property< T >::reference operator[](HalfFace h)
access the data stored for halfface h
Definition: poly_mesh.h:263
HalfFaceProperty()=default
default constructor
Definition: poly_mesh.h:630
Definition: poly_mesh.h:327
ModelProperty()=default
default constructor
Property< T >::const_reference operator[](size_t idx) const
access the data stored for the mesh
Definition: poly_mesh.h:341
Property< T >::reference operator[](size_t idx)
access the data stored for the mesh
Definition: poly_mesh.h:335
Definition: poly_mesh.h:602
Definition: poly_mesh.h:355
VertexIterator(Vertex v=Vertex(), const PolyMesh *m=nullptr)
Default constructor.
Definition: poly_mesh.h:359
Vertex operator*() const
get the vertex the iterator refers to
Definition: poly_mesh.h:364
bool operator==(const VertexIterator &rhs) const
are two iterators equal?
Definition: poly_mesh.h:367
VertexIterator & operator--()
pre-decrement iterator
Definition: poly_mesh.h:387
bool operator!=(const VertexIterator &rhs) const
are two iterators different?
Definition: poly_mesh.h:373
VertexIterator & operator++()
pre-increment iterator
Definition: poly_mesh.h:379
Definition: poly_mesh.h:207
Property< T >::const_reference operator[](Vertex v) const
access the data stored for vertex v
Definition: poly_mesh.h:221
Property< T >::reference operator[](Vertex v)
access the data stored for vertex v
Definition: poly_mesh.h:215
VertexProperty()=default
default constructor
Data structure representing a polyhedral mesh.
Definition: poly_mesh.h:50
const vec3 & position(Vertex v) const
position of a vertex (read only)
Definition: poly_mesh.h:1368
const std::set< HalfFace > & halffaces(Edge e) const
returns the set of halffaces around edge e
Definition: poly_mesh.h:1287
HalfFace opposite(HalfFace h) const
returns the twin halfface of halfface h.
Definition: poly_mesh.h:1231
bool is_border(Vertex v) const
Definition: poly_mesh.h:1327
EdgeContainer edges() const
returns edge container for C++11 range-based for-loops
Definition: poly_mesh.h:1147
HalfFace find_half_face(const std::vector< Vertex > &vertices) const
find the halfface defined by a sequence of vertices (orientation sensitive)
Definition: poly_mesh.cpp:417
const std::type_info & get_vertex_property_type(const std::string &name) const
Definition: poly_mesh.h:1038
unsigned int n_faces() const
returns number of faces in the mesh
Definition: poly_mesh.h:774
void extract_boundary(std::vector< std::vector< Vertex > > &faces) const
extracts the boundary surface and return its faces
Definition: poly_mesh.cpp:686
const std::vector< Vertex > & vertices(Face f) const
returns the set of vertices around face f
Definition: poly_mesh.h:1251
bool remove_vertex_property(const std::string &n)
remove the vertex property named n
Definition: poly_mesh.h:968
const std::set< Edge > & edges(Cell c) const
returns the set of edges around cell c
Definition: poly_mesh.h:1275
EdgeIterator edges_end() const
returns end iterator for edges
Definition: poly_mesh.h:1141
HalfFace add_triangle(Vertex v0, Vertex v1, Vertex v2)
Definition: poly_mesh.h:753
CellIterator cells_begin() const
returns start iterator for cells
Definition: poly_mesh.h:1189
unsigned int n_edges() const
returns number of edges in the mesh
Definition: poly_mesh.h:770
bool is_valid(Edge e) const
return whether edge e is valid, i.e. the index is stores it within the array bounds.
Definition: poly_mesh.h:800
bool rename_vertex_property(const std::string &old_name, const std::string &new_name)
rename a vertex property given its name
Definition: poly_mesh.h:1006
const std::vector< Vertex > & vertices(HalfFace h) const
Definition: poly_mesh.h:1245
std::vector< std::string > halfface_properties() const
returns the names of all halfface properties
Definition: poly_mesh.h:1085
HalfFaceProperty< T > add_halfface_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:845
const std::set< Cell > & cells(Vertex v) const
returns the set of cells around vertex v
Definition: poly_mesh.h:1299
PolyMesh()
default constructor
Definition: poly_mesh.cpp:133
HalfFaceIterator halffaces_begin() const
returns start iterator for halffaces
Definition: poly_mesh.h:1153
VertexContainer vertices() const
returns vertex container for C++11 range-based for-loops
Definition: poly_mesh.h:1129
FaceProperty< T > get_face_property(const std::string &name) const
Definition: poly_mesh.h:899
const std::set< Cell > & cells(Edge e) const
returns the set of cells around edge e
Definition: poly_mesh.h:1305
const std::type_info & get_edge_property_type(const std::string &name) const
Definition: poly_mesh.h:1044
bool remove_halfface_property(HalfFaceProperty< T > &p)
remove the halfface property p
Definition: poly_mesh.h:979
HalfFace add_quad(Vertex v0, Vertex v1, Vertex v2, Vertex v3)
Definition: poly_mesh.h:758
bool rename_face_property(const std::string &old_name, const std::string &new_name)
rename a face property given its name
Definition: poly_mesh.h:1016
const std::vector< HalfFace > & halffaces(Cell c) const
returns the set of halffaces around cell c
Definition: poly_mesh.h:1293
VertexProperty< T > vertex_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:927
const std::set< Vertex > & vertices(Vertex v) const
returns the vertices around vertex v
Definition: poly_mesh.h:1213
std::vector< std::string > face_properties() const
returns the names of all face properties
Definition: poly_mesh.h:1090
const std::set< Edge > & edges(HalfFace h) const
returns the set of edges around halfface h
Definition: poly_mesh.h:1269
const std::set< Vertex > & vertices(Cell c) const
returns the set of vertices around cell c
Definition: poly_mesh.h:1257
FaceContainer faces() const
returns face container for C++11 range-based for-loops
Definition: poly_mesh.h:1183
ModelProperty< T > get_model_property(const std::string &name) const
Gets the model property named name of type T.
Definition: poly_mesh.h:919
std::vector< std::string > vertex_properties() const
returns the names of all vertex properties
Definition: poly_mesh.h:1075
void update_face_normals()
compute face normals by calling compute_face_normal(HalfFace) for each face.
Definition: poly_mesh.cpp:549
vec3 compute_face_normal(Face f) const
compute normal vector of face f.
Definition: poly_mesh.cpp:572
EdgeProperty< T > get_edge_property(const std::string &name) const
Definition: poly_mesh.h:887
const std::type_info & get_face_property_type(const std::string &name) const
Definition: poly_mesh.h:1056
Cell add_hexa(Vertex v0, Vertex v1, Vertex v2, Vertex v3, Vertex v4, Vertex v5, Vertex v6, Vertex v7)
Definition: poly_mesh.cpp:519
EdgeIterator edges_begin() const
returns start iterator for edges
Definition: poly_mesh.h:1135
HalfFaceIterator halffaces_end() const
returns end iterator for halffaces
Definition: poly_mesh.h:1159
FaceIterator faces_begin() const
returns start iterator for faces
Definition: poly_mesh.h:1171
Cell add_cell(const std::vector< HalfFace > &faces)
Definition: poly_mesh.cpp:479
VertexProperty< T > get_vertex_property(const std::string &name) const
Definition: poly_mesh.h:881
bool remove_face_property(const std::string &n)
remove the face property named n
Definition: poly_mesh.h:989
void resize(unsigned int nv, unsigned int ne, unsigned int nf, unsigned int nc)
Definition: poly_mesh.h:786
const std::set< Edge > & edges(Vertex v) const
returns the set of edges around vertex v
Definition: poly_mesh.h:1263
Edge find_edge(Vertex a, Vertex b) const
find the edge (a,b)
Definition: poly_mesh.cpp:408
std::vector< std::string > edge_properties() const
returns the names of all edge properties
Definition: poly_mesh.h:1080
bool read(const std::string &filename)
Read mesh from a PM file filename. Mainly for quick debug purposes. Client code should use PolyMeshIO...
Definition: poly_mesh.cpp:220
std::vector< std::string > model_properties() const
returns the names of all model properties
Definition: poly_mesh.h:1100
bool is_tetraheral_mesh() const
returns whether the mesh a tetrahedral mesh, i.e., every cell is a tetrahedron.
Definition: poly_mesh.cpp:670
CellContainer cells() const
returns cell container for C++11 range-based for-loops
Definition: poly_mesh.h:1201
bool is_border(HalfFace h) const
returns whether f is a boundary face, i.e., it is not associated with a cell.
Definition: poly_mesh.h:1340
bool rename_edge_property(const std::string &old_name, const std::string &new_name)
rename an edge property given its name
Definition: poly_mesh.h:1021
HalffaceContainer halffaces() const
returns halfface container for C++11 range-based for-loops
Definition: poly_mesh.h:1165
bool remove_halfface_property(const std::string &n)
remove the halfface property named n
Definition: poly_mesh.h:982
const std::type_info & get_model_property_type(const std::string &name) const
Definition: poly_mesh.h:1068
std::vector< vec3 > & points() override
vector of vertex positions
Definition: poly_mesh.h:1374
CellProperty< T > cell_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:951
bool remove_face_property(FaceProperty< T > &p)
remove the face property p
Definition: poly_mesh.h:986
const std::type_info & get_halfface_property_type(const std::string &name) const
Definition: poly_mesh.h:1050
bool remove_edge_property(const std::string &n)
remove the edge property named n
Definition: poly_mesh.h:975
ModelProperty< T > model_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:957
bool remove_cell_property(const std::string &n)
remove the cell property named n
Definition: poly_mesh.h:996
Cell cell(HalfFace h) const
returns the cell associated with halfface h
Definition: poly_mesh.h:1311
VertexProperty< T > add_vertex_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:831
bool remove_model_property(ModelProperty< T > &p)
remove the model property p
Definition: poly_mesh.h:1000
PolyMesh & assign(const PolyMesh &rhs)
assign rhs to *this. does not copy custom properties.
Definition: poly_mesh.cpp:179
FaceProperty< T > face_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:945
PolyMesh & operator=(const PolyMesh &rhs)
assign rhs to *this. performs a deep copy of all properties.
Definition: poly_mesh.cpp:151
FaceProperty< T > add_face_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:852
bool is_valid(HalfFace h) const
return whether halfface h is valid, i.e. the index is stores it within the array bounds.
Definition: poly_mesh.h:805
bool remove_cell_property(CellProperty< T > &p)
remove the cell property p
Definition: poly_mesh.h:993
bool rename_model_property(const std::string &old_name, const std::string &new_name)
rename a model property given its name
Definition: poly_mesh.h:1031
unsigned int n_halffaces() const
returns number of halffaces in the mesh
Definition: poly_mesh.h:772
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: poly_mesh.h:873
HalfFace add_face(const std::vector< Vertex > &vertices)
Definition: poly_mesh.cpp:450
CellProperty< T > get_cell_property(const std::string &name) const
Definition: poly_mesh.h:905
CellProperty< T > add_cell_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:859
PolyMesh(const PolyMesh &rhs)
copy constructor: copies rhs to *this. performs a deep copy of all properties.
Definition: poly_mesh.h:680
HalfFaceProperty< T > get_halfface_property(const std::string &name) const
Definition: poly_mesh.h:893
bool write(const std::string &filename) const
Write mesh to a PM file filename. Mainly for quick debug purposes. Client code should use PolyMeshIO.
Definition: poly_mesh.cpp:263
Vertex add_vertex(const vec3 &p)
add a new vertex with position p
Definition: poly_mesh.h:709
bool is_valid(Face f) const
return whether face f is valid, i.e. the index is stores it within the array bounds.
Definition: poly_mesh.h:810
CellIterator cells_end() const
returns end iterator for cells
Definition: poly_mesh.h:1195
Face face(HalfFace h) const
returns the face of HalfFace h.
Definition: poly_mesh.h:1226
bool is_border(Face f) const
returns whether f is a boundary face, i.e., it is incident to only one cell.
Definition: poly_mesh.h:1345
EdgeProperty< T > edge_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:933
bool remove_edge_property(EdgeProperty< T > &p)
remove the edge property p
Definition: poly_mesh.h:972
HalfFaceProperty< T > halfface_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:939
void property_stats(std::ostream &output) const override
prints the names of all properties to an output stream (e.g., std::cout).
Definition: poly_mesh.cpp:343
void update_vertex_normals()
Definition: poly_mesh.cpp:599
FaceIterator faces_end() const
returns end iterator for faces
Definition: poly_mesh.h:1177
const std::type_info & get_cell_property_type(const std::string &name) const
Definition: poly_mesh.h:1062
HalfFace halfface(Face f, unsigned int i) const
returns the i'th halfface of face f. i has to be 0 or 1.
Definition: poly_mesh.h:1219
void clear()
Removes all vertices, edges, halffaces, faces, cells and properties.
Definition: poly_mesh.cpp:311
bool rename_halfface_property(const std::string &old_name, const std::string &new_name)
rename a halfface property given its name
Definition: poly_mesh.h:1011
bool rename_cell_property(const std::string &old_name, const std::string &new_name)
rename a cell property given its name
Definition: poly_mesh.h:1026
bool remove_model_property(const std::string &n)
remove the model property named n
Definition: poly_mesh.h:1003
float edge_length(Edge e) const
compute the length of edge e.
Definition: poly_mesh.cpp:633
EdgeProperty< T > add_edge_property(const std::string &name, const T t=T())
Definition: poly_mesh.h:838
bool is_border(Edge e) const
Definition: poly_mesh.h:1334
VertexIterator vertices_begin() const
returns start iterator for vertices
Definition: poly_mesh.h:1117
std::vector< std::string > cell_properties() const
returns the names of all cell properties
Definition: poly_mesh.h:1095
bool remove_vertex_property(VertexProperty< T > &p)
remove the vertex property p
Definition: poly_mesh.h:965
bool is_degenerate(Face f) const
returns whether face f is degenerate
Definition: poly_mesh.cpp:642
VertexIterator vertices_end() const
returns end iterator for vertices
Definition: poly_mesh.h:1123
bool is_valid(Vertex v) const
return whether vertex v is valid, i.e. the index is stores it within the array bounds.
Definition: poly_mesh.h:795
Vertex vertex(Edge e, unsigned int i) const
returns the i'th vertex of edge e. i has to be 0 or 1.
Definition: poly_mesh.h:1237
Cell add_tetra(HalfFace f0, HalfFace f1, HalfFace f2, HalfFace f3)
Definition: poly_mesh.h:719
unsigned int n_cells() const
returns number of cells in the mesh
Definition: poly_mesh.h:776
bool is_valid(Cell c) const
return whether cell h is valid, i.e. the index is stores it within the array bounds.
Definition: poly_mesh.h:815
const std::vector< vec3 > & points() const override
vector of vertex positions (read only)
Definition: poly_mesh.h:1371
unsigned int n_vertices() const
returns number of vertices in the mesh
Definition: poly_mesh.h:768
const std::set< HalfFace > & halffaces(Vertex v) const
returns the set of halffaces around vertex v
Definition: poly_mesh.h:1281
Implementation of a generic property.
Definition: property.h:253
Definition: collider.cpp:182
std::ostream & operator<<(std::ostream &os, Graph::Vertex v)
Definition: graph.h:920
helper structure to be able to use std::unordered_map
Definition: poly_mesh.h:89
Definition: poly_mesh.h:191
Definition: poly_mesh.h:139
Cell(int _idx=-1)
default constructor (with invalid index)
Definition: poly_mesh.h:141
Definition: poly_mesh.h:166
Definition: poly_mesh.h:111
Edge(int _idx=-1)
default constructor (with invalid index)
Definition: poly_mesh.h:113
Definition: poly_mesh.h:130
Face(int _idx=-1)
default constructor (with invalid index)
Definition: poly_mesh.h:132
Definition: poly_mesh.h:178
Definition: poly_mesh.h:121
HalfFace(int _idx=-1)
default constructor (with invalid index)
Definition: poly_mesh.h:123
Definition: poly_mesh.h:152
Definition: poly_mesh.h:102
Vertex(int _idx=-1)
default constructor (with invalid index)
Definition: poly_mesh.h:104