G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsSurfMesh.h
Go to the documentation of this file.
1
14#pragma once
15
17#include <gsIO/gsXml.h>
18
19namespace gismo // typedefs
20{
21typedef gsEigen::Vector<real_t,3> Point;
22typedef gsEigen::Vector<float,2> Vec2f;
24typedef Point Normal;
26typedef Point Color;
28typedef Point Texture_coordinate;
29}
30
31#define Eigen gsEigen
32EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(gismo::Point)
33EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(gismo::Vec2f)
34#undef Eigen
35
36#include <gsMesh2/gsProperty.h>
37
38
39namespace gismo {
40
41//== CLASS DEFINITION =========================================================
42
43
45class GISMO_EXPORT gsSurfMesh
46{
47public:
49typedef real_t Scalar;
50typedef gismo::Point Point;
51
52private:
54typedef gsEigen::Vector<Scalar,3> Vec3;
55
56public: //------------------------------------------------------ topology types
57
61 {
62 public:
63
65 explicit Base_handle(int _idx=-1) : idx_(_idx) {}
66
68 int idx() const { return idx_; }
69
71 void reset() { idx_=-1; }
72
74 bool is_valid() const { return idx_ != -1; }
75
77 bool operator==(const Base_handle& _rhs) const {
78 return idx_ == _rhs.idx_;
79 }
80
82 bool operator!=(const Base_handle& _rhs) const {
83 return idx_ != _rhs.idx_;
84 }
85
87 bool operator<(const Base_handle& _rhs) const {
88 return idx_ < _rhs.idx_;
89 }
90
91 private:
92 friend class Vertex_iterator;
93 friend class Halfedge_iterator;
94 friend class Edge_iterator;
95 friend class Face_iterator;
96 friend class gsSurfMesh;
97 int idx_;
98 };
99
100
103 struct GISMO_EXPORT Vertex : public Base_handle
104 {
106 explicit Vertex(int _idx=-1) : Base_handle(_idx) {}
107 std::ostream& operator<<(std::ostream& os) const { return os << 'v' << idx(); }
108 };
109
110
113 struct GISMO_EXPORT Halfedge : public Base_handle
114 {
116 explicit Halfedge(int _idx=-1) : Base_handle(_idx) {}
117 };
118
119
122 struct Edge : public Base_handle
123 {
125 explicit Edge(int _idx=-1) : Base_handle(_idx) {}
126 };
127
128
131 struct Face : public Base_handle
132 {
134 explicit Face(int _idx=-1) : Base_handle(_idx) {}
135 };
136
137
138
139
140public: //-------------------------------------------------- connectivity types
141
149
150
164
165
173
174
175
176
177public: //------------------------------------------------------ property types
178
181 template <class T> class Vertex_property : public gsProperty<T>
182 {
183 public:
184
186 explicit Vertex_property() {}
187 explicit Vertex_property(gsProperty<T> p) : gsProperty<T>(p) {}
188
190 typename gsProperty<T>::reference operator[](Vertex v)
191 {
192 return gsProperty<T>::operator[](v.idx());
193 }
194
196 typename gsProperty<T>::const_reference operator[](Vertex v) const
197 {
198 return gsProperty<T>::operator[](v.idx());
199 }
200 };
201
202
205 template <class T> class Halfedge_property : public gsProperty<T>
206 {
207 public:
208
210 explicit Halfedge_property() {}
211 explicit Halfedge_property(gsProperty<T> p) : gsProperty<T>(p) {}
212
214 typename gsProperty<T>::reference operator[](Halfedge h)
215 {
216 return gsProperty<T>::operator[](h.idx());
217 }
218
220 typename gsProperty<T>::const_reference operator[](Halfedge h) const
221 {
222 return gsProperty<T>::operator[](h.idx());
223 }
224 };
225
226
229 template <class T> class Edge_property : public gsProperty<T>
230 {
231 public:
232
234 explicit Edge_property() {}
235 explicit Edge_property(gsProperty<T> p) : gsProperty<T>(p) {}
236
238 typename gsProperty<T>::reference operator[](Edge e)
239 {
240 return gsProperty<T>::operator[](e.idx());
241 }
242
244 typename gsProperty<T>::const_reference operator[](Edge e) const
245 {
246 return gsProperty<T>::operator[](e.idx());
247 }
248 };
249
250
253 template <class T> class Face_property : public gsProperty<T>
254 {
255 public:
256
258 explicit Face_property() {}
259 explicit Face_property(gsProperty<T> p) : gsProperty<T>(p) {}
260
262 typename gsProperty<T>::reference operator[](Face f)
263 {
264 return gsProperty<T>::operator[](f.idx());
265 }
266
268 typename gsProperty<T>::const_reference operator[](Face f) const
269 {
270 return gsProperty<T>::operator[](f.idx());
271 }
272 };
273
274
277 template <class T> class Mesh_property : public gsProperty<T>
278 {
279 public:
280
282 explicit Mesh_property() {}
283 explicit Mesh_property(gsProperty<T> p) : gsProperty<T>(p) {}
284
286 typename gsProperty<T>::reference operator[](size_t idx)
287 {
288 return gsProperty<T>::operator[](idx);
289 }
290
292 typename gsProperty<T>::const_reference operator[](size_t idx) const
293 {
294 return gsProperty<T>::operator[](idx);
295 }
296 };
297
298
299
300public: //------------------------------------------------------ iterator types
301
306 {
307 public:
308
310 Vertex_iterator(Vertex v=Vertex(), const gsSurfMesh* m=NULL) : hnd_(v), mesh_(m)
311 {
312 if (mesh_ && mesh_->garbage()) while (mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
313 }
314
316 Vertex operator*() const { return hnd_; }
317
318 const Vertex * operator->() const { return &hnd_; }
319
320 // (!)
321 size_t operator-(const Vertex_iterator& rhs) const
322 {
323 //assumes no deleted vertices..
324 return (hnd_.idx_ - rhs.hnd_.idx_);
325 }
326
327 // (!)
328 Vertex_iterator& operator+=(const size_t i)
329 {
330 //assumes no deleted vertices..
331 hnd_.idx_+= i;
332 return *this;
333 }
334
336 bool operator==(const Vertex_iterator& rhs) const
337 {
338 return (hnd_==rhs.hnd_);
339 }
340
342 bool operator<(const Vertex_iterator& rhs) const
343 {
344 return (hnd_<rhs.hnd_);
345 }
346
348 bool operator!=(const Vertex_iterator& rhs) const
349 {
350 return !operator==(rhs);
351 }
352
355 {
356 ++hnd_.idx_;
357 assert(mesh_);
358 while (mesh_->garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
359 return *this;
360 }
361
364 {
365 --hnd_.idx_;
366 assert(mesh_);
367 while (mesh_->garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) --hnd_.idx_;
368 return *this;
369 }
370
371 private:
372 Vertex hnd_;
373 const gsSurfMesh* mesh_;
374 };
375
376
381 {
382 public:
383
385 Halfedge_iterator(Halfedge h=Halfedge(), const gsSurfMesh* m=NULL) : hnd_(h), mesh_(m)
386 {
387 if (mesh_ && mesh_->garbage()) while (mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
388 }
389
391 Halfedge operator*() const { return hnd_; }
392
393 const Halfedge * operator->() const { return &hnd_; }
394
396 bool operator==(const Halfedge_iterator& rhs) const
397 {
398 return (hnd_==rhs.hnd_);
399 }
400
402 bool operator!=(const Halfedge_iterator& rhs) const
403 {
404 return !operator==(rhs);
405 }
406
409 {
410 ++hnd_.idx_;
411 assert(mesh_);
412 while (mesh_->garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
413 return *this;
414 }
415
418 {
419 --hnd_.idx_;
420 assert(mesh_);
421 while (mesh_->garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) --hnd_.idx_;
422 return *this;
423 }
424
425 private:
426 Halfedge hnd_;
427 const gsSurfMesh* mesh_;
428 };
429
430
435 {
436 public:
437
439 Edge_iterator(Edge e=Edge(), const gsSurfMesh* m=NULL) : hnd_(e), mesh_(m)
440 {
441 if (mesh_ && mesh_->garbage()) while (mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
442 }
443
445 Edge operator*() const { return hnd_; }
446
447 const Edge * operator->() const { return &hnd_; }
448
450 bool operator==(const Edge_iterator& rhs) const
451 {
452 return (hnd_==rhs.hnd_);
453 }
454
456 bool operator!=(const Edge_iterator& rhs) const
457 {
458 return !operator==(rhs);
459 }
460
463 {
464 ++hnd_.idx_;
465 assert(mesh_);
466 while (mesh_->garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
467 return *this;
468 }
469
472 {
473 --hnd_.idx_;
474 assert(mesh_);
475 while (mesh_->garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) --hnd_.idx_;
476 return *this;
477 }
478
479 private:
480 Edge hnd_;
481 const gsSurfMesh* mesh_;
482 };
483
484
489 {
490 public:
491
493 Face_iterator(Face f=Face(), const gsSurfMesh* m=NULL) : hnd_(f), mesh_(m)
494 {
495 if (mesh_ && mesh_->garbage()) while (mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
496 }
497
499 Face operator*() const { return hnd_; }
500
501 const Face * operator->() const { return &hnd_; }
502
503 // (!)
504 size_t operator-(const Face_iterator& rhs) const
505 {
506 //assumes no deleted faces..
507 return (hnd_.idx_ - rhs.hnd_.idx_);
508 }
509
510 // (!)
511 Face_iterator& operator+=(const size_t i)
512 {
513 //assumes no deleted faces..
514 hnd_.idx_+= i;
515 return *this;
516 }
517
519 bool operator==(const Face_iterator& rhs) const
520 {
521 return (hnd_==rhs.hnd_);
522 }
523
525 bool operator<(const Face_iterator& rhs) const
526 {
527 return (hnd_<rhs.hnd_);
528 }
529
531 bool operator!=(const Face_iterator& rhs) const
532 {
533 return !operator==(rhs);
534 }
535
538 {
539 ++hnd_.idx_;
540 assert(mesh_);
541 while (mesh_->garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) ++hnd_.idx_;
542 return *this;
543 }
544
547 {
548 --hnd_.idx_;
549 assert(mesh_);
550 while (mesh_->garbage() && mesh_->is_valid(hnd_) && mesh_->is_deleted(hnd_)) --hnd_.idx_;
551 return *this;
552 }
553
554 private:
555 Face hnd_;
556 const gsSurfMesh* mesh_;
557 };
558
559
560
561public: //-------------------------- containers for C++11 range-based for loops
562
567 {
568 public:
569 Vertex_container(Vertex_iterator _begin, Vertex_iterator _end) : begin_(_begin), end_(_end) {}
570 Vertex_iterator begin() const { return begin_; }
571 Vertex_iterator end() const { return end_; }
572 private:
573 Vertex_iterator begin_, end_;
574 };
575
576
577
582 {
583 public:
584 Halfedge_container(Halfedge_iterator _begin, Halfedge_iterator _end) : begin_(_begin), end_(_end) {}
585 Halfedge_iterator begin() const { return begin_; }
586 Halfedge_iterator end() const { return end_; }
587 private:
588 Halfedge_iterator begin_, end_;
589 };
590
591
592
597 {
598 public:
599 Edge_container(Edge_iterator _begin, Edge_iterator _end) : begin_(_begin), end_(_end) {}
600 Edge_iterator begin() const { return begin_; }
601 Edge_iterator end() const { return end_; }
602 private:
603 Edge_iterator begin_, end_;
604 };
605
606
607
612 {
613 public:
614 Face_container(Face_iterator _begin, Face_iterator _end) : begin_(_begin), end_(_end) {}
615 Face_iterator begin() const { return begin_; }
616 Face_iterator end() const { return end_; }
617 private:
618 Face_iterator begin_, end_;
619 };
620
621
622
623
624
625public: //---------------------------------------------------- circulator types
626
631 {
632 public:
633
636 : mesh_(m), active_(true)
637 {
638 if (mesh_) halfedge_ = mesh_->halfedge(v);
639 }
640
643 {
644 assert(mesh_);
645 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
646 }
647
650 {
651 return !operator==(rhs);
652 }
653
656 {
657 assert(mesh_);
658 halfedge_ = mesh_->ccw_rotated_halfedge(halfedge_);
659 active_ = true;
660 return *this;
661 }
662
665 {
666 assert(mesh_);
667 halfedge_ = mesh_->cw_rotated_halfedge(halfedge_);
668 return *this;
669 }
670
673 {
674 assert(mesh_);
675 return mesh_->to_vertex(halfedge_);
676 }
677
679 operator bool() const { return halfedge_.is_valid(); }
680
682 Halfedge halfedge() const { return halfedge_; }
683
684 // helper for C++11 range-based for-loops
685 Vertex_around_vertex_circulator& begin() { active_=!halfedge_.is_valid(); return *this; }
686 // helper for C++11 range-based for-loops
687 Vertex_around_vertex_circulator& end() { active_=true; return *this; }
688
689 private:
690 const gsSurfMesh* mesh_;
691 Halfedge halfedge_;
692 // helper for C++11 range-based for-loops
693 bool active_;
694 };
695
696
701 {
702 public:
703
706 : mesh_(m), active_(true)
707 {
708 if (mesh_) halfedge_ = mesh_->halfedge(v);
709 }
710
713 {
714 assert(mesh_);
715 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
716 }
717
720 {
721 return !operator==(rhs);
722 }
723
726 {
727 assert(mesh_);
728 halfedge_ = mesh_->ccw_rotated_halfedge(halfedge_);
729 active_ = true;
730 return *this;
731 }
732
735 {
736 assert(mesh_);
737 halfedge_ = mesh_->cw_rotated_halfedge(halfedge_);
738 return *this;
739 }
740
742 Halfedge operator*() const { return halfedge_; }
743
744 const Halfedge * operator->() const { return &halfedge_; }
745
747 operator bool() const { return halfedge_.is_valid(); }
748
749 // helper for C++11 range-based for-loops
750 Halfedge_around_vertex_circulator& begin() { active_=!halfedge_.is_valid(); return *this; }
751 // helper for C++11 range-based for-loops
752 Halfedge_around_vertex_circulator& end() { active_=true; return *this; }
753
754 private:
755 const gsSurfMesh* mesh_;
756 Halfedge halfedge_;
757 // helper for C++11 range-based for-loops
758 bool active_;
759 };
760
761
766 {
767 public:
768
771 : mesh_(m), active_(true)
772 {
773 if (mesh_)
774 {
775 halfedge_ = mesh_->halfedge(v);
776 if (halfedge_.is_valid() && mesh_->is_boundary(halfedge_))
777 operator++();
778 }
779 }
780
783 {
784 assert(mesh_);
785 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
786 }
787
790 {
791 return !operator==(rhs);
792 }
793
796 {
797 assert(mesh_ && halfedge_.is_valid());
798 do {
799 halfedge_ = mesh_->ccw_rotated_halfedge(halfedge_);
800 } while (mesh_->is_boundary(halfedge_));
801 active_ = true;
802 return *this;
803 }
804
807 {
808 assert(mesh_ && halfedge_.is_valid());
809 do
810 halfedge_ = mesh_->cw_rotated_halfedge(halfedge_);
811 while (mesh_->is_boundary(halfedge_));
812 return *this;
813 }
814
817 {
818 assert(mesh_ && halfedge_.is_valid());
819 return mesh_->face(halfedge_);
820 }
821
823 operator bool() const { return halfedge_.is_valid(); }
824
825 // helper for C++11 range-based for-loops
826 Face_around_vertex_circulator& begin() { active_=!halfedge_.is_valid(); return *this; }
827 // helper for C++11 range-based for-loops
828 Face_around_vertex_circulator& end() { active_=true; return *this; }
829
830 private:
831 const gsSurfMesh* mesh_;
832 Halfedge halfedge_;
833 // helper for C++11 range-based for-loops
834 bool active_;
835 };
836
837
842 {
843 public:
844
847 : mesh_(m), active_(true)
848 {
849 if (mesh_) halfedge_ = mesh_->halfedge(f);
850 }
851
854 {
855 assert(mesh_);
856 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
857 }
858
861 {
862 return !operator==(rhs);
863 }
864
867 {
868 assert(mesh_ && halfedge_.is_valid());
869 halfedge_ = mesh_->next_halfedge(halfedge_);
870 active_ = true;
871 return *this;
872 }
873
876 {
877 assert(mesh_ && halfedge_.is_valid());
878 halfedge_ = mesh_->prev_halfedge(halfedge_);
879 return *this;
880 }
881
884 {
885 assert(mesh_ && halfedge_.is_valid());
886 return mesh_->to_vertex(halfedge_);
887 }
888
890 Halfedge he() const
891 {
892 assert(mesh_ && halfedge_.is_valid());
893 return halfedge_;
894 }
895
896 // helper for C++11 range-based for-loops
897 Vertex_around_face_circulator& begin() { active_=false; return *this; }
898 // helper for C++11 range-based for-loops
899 Vertex_around_face_circulator& end() { active_=true; return *this; }
900
901 private:
902 const gsSurfMesh* mesh_;
903 Halfedge halfedge_;
904 // helper for C++11 range-based for-loops
905 bool active_;
906 };
907
908
913 {
914 public:
915
918 : mesh_(m), active_(true)
919 {
920 if (mesh_) halfedge_ = mesh_->halfedge(f);
921 }
922
925 {
926 assert(mesh_);
927 return (active_ && (mesh_==rhs.mesh_) && (halfedge_==rhs.halfedge_));
928 }
929
932 {
933 return !operator==(rhs);
934 }
935
938 {
939 assert(mesh_ && halfedge_.is_valid());
940 halfedge_ = mesh_->next_halfedge(halfedge_);
941 active_ = true;
942 return *this;
943 }
944
947 {
948 assert(mesh_ && halfedge_.is_valid());
949 halfedge_ = mesh_->prev_halfedge(halfedge_);
950 return *this;
951 }
952
954 Halfedge operator*() const { return halfedge_; }
955
956 const Halfedge * operator->() const { return &halfedge_; }
957
958 // helper for C++11 range-based for-loops
959 Halfedge_around_face_circulator& begin() { active_=false; return *this; }
960 // helper for C++11 range-based for-loops
961 Halfedge_around_face_circulator& end() { active_=true; return *this; }
962
963 private:
964 const gsSurfMesh* mesh_;
965 Halfedge halfedge_;
966 // helper for C++11 range-based for-loops
967 bool active_;
968 };
969
970
971
972public: //-------------------------------------------- constructor / destructor
973
975
976
978 gsSurfMesh();
979
981 gsSurfMesh(const gsMatrix<Scalar> & pts);
982
983 // destructor (is virtual, since we inherit from Geometry_representation)
984 virtual ~gsSurfMesh();
985
987 gsSurfMesh(const gsSurfMesh& rhs) { operator=(rhs); }
988
990 gsSurfMesh& operator=(const gsSurfMesh& rhs);
991
993 gsSurfMesh& assign(const gsSurfMesh& rhs);
994
996
997
998
999
1000public: //------------------------------------------------------------- file IO
1001
1003
1004
1007 bool read(const std::string& filename);
1008
1011 bool write(const std::string& filename) const;
1012
1014
1015
1016
1017
1018public: //----------------------------------------------- add new vertex / face
1019
1021
1022
1024 Vertex add_vertex(const Point& p);
1025
1028 Face add_face(const std::vector<Vertex>& vertices);
1029
1032 Face add_triangle(Vertex v1, Vertex v2, Vertex v3);
1033
1036 Face add_quad(Vertex v1, Vertex v2, Vertex v3, Vertex v4);
1037
1039
1040
1041
1042
1043public: //--------------------------------------------------- memory management
1044
1046
1047
1049 unsigned int vertices_size() const { return (unsigned int) vprops_.size(); }
1051 unsigned int halfedges_size() const { return (unsigned int) hprops_.size(); }
1053 unsigned int edges_size() const { return (unsigned int) eprops_.size(); }
1055 unsigned int faces_size() const { return (unsigned int) fprops_.size(); }
1056
1057
1059 unsigned int n_vertices() const { return vertices_size() - deleted_vertices_; }
1061 unsigned int n_halfedges() const { return halfedges_size() - 2*deleted_edges_; }
1063 unsigned int n_edges() const { return edges_size() - deleted_edges_; }
1065 unsigned int n_faces() const { return faces_size() - deleted_faces_; }
1066
1067
1069 unsigned int empty() const { return n_vertices() == 0; }
1070
1071
1073 void clear();
1074
1076 void free_memory();
1077
1079 void reserve(unsigned int nvertices,
1080 unsigned int nedges,
1081 unsigned int nfaces );
1082
1083
1085 void garbage_collection();
1086
1087
1090 bool is_deleted(Vertex v) const
1091 {
1092 return vdeleted_[v];
1093 }
1096 bool is_deleted(Halfedge h) const
1097 {
1098 return edeleted_[edge(h)];
1099 }
1102 bool is_deleted(Edge e) const
1103 {
1104 return edeleted_[e];
1105 }
1108 bool is_deleted(Face f) const
1109 {
1110 return fdeleted_[f];
1111 }
1112
1113
1115 bool is_valid(Vertex v) const
1116 {
1117 return (0 <= v.idx()) && (v.idx() < (int)vertices_size());
1118 }
1120 bool is_valid(Halfedge h) const
1121 {
1122 return (0 <= h.idx()) && (h.idx() < (int)halfedges_size());
1123 }
1125 bool is_valid(Edge e) const
1126 {
1127 return (0 <= e.idx()) && (e.idx() < (int)edges_size());
1128 }
1130 bool is_valid(Face f) const
1131 {
1132 return (0 <= f.idx()) && (f.idx() < (int)faces_size());
1133 }
1134
1136
1137
1138
1139
1140public: //---------------------------------------------- low-level connectivity
1141
1143
1144
1148 {
1149 return vconn_[v].halfedge_;
1150 }
1151
1154 {
1155 vconn_[v].halfedge_ = h;
1156 }
1157
1159 bool is_boundary(Vertex v) const
1160 {
1161 Halfedge h(halfedge(v));
1162 return (!(h.is_valid() && face(h).is_valid()));
1163 }
1164
1166 bool is_isolated(Vertex v) const
1167 {
1168 return !halfedge(v).is_valid();
1169 }
1170
1172 bool is_manifold(Vertex v) const
1173 {
1174 // The vertex is non-manifold if more than one gap exists, i.e.
1175 // more than one outgoing boundary halfedge.
1176 int n(0);
1177 Halfedge_around_vertex_circulator hit = halfedges(v), hend=hit;
1178 if (hit) do
1179 {
1180 if (is_boundary(*hit))
1181 ++n;
1182 }
1183 while (++hit!=hend);
1184 return n<2;
1185 }
1186
1189 {
1190 return hconn_[h].vertex_;
1191 }
1192
1195 {
1196 return to_vertex(opposite_halfedge(h));
1197 }
1198
1201 {
1202 hconn_[h].vertex_ = v;
1203 }
1204
1207 {
1208 return hconn_[h].face_;
1209 }
1210
1213 {
1214 hconn_[h].face_ = f;
1215 }
1216
1219 {
1220 return hconn_[h].next_halfedge_;
1221 }
1222
1225 {
1226 hconn_[h].next_halfedge_ = nh;
1227 hconn_[nh].prev_halfedge_ = h;
1228 }
1229
1232 {
1233 return hconn_[h].prev_halfedge_;
1234 }
1235
1238 {
1239 return Halfedge((h.idx() & 1) ? h.idx()-1 : h.idx()+1);
1240 }
1241
1245 {
1246 return opposite_halfedge(prev_halfedge(h));
1247 }
1248
1252 {
1253 return next_halfedge(opposite_halfedge(h));
1254 }
1255
1258 {
1259 return Edge(h.idx() >> 1);
1260 }
1261
1263 bool is_boundary(Halfedge h) const
1264 {
1265 return !face(h).is_valid();
1266 }
1267
1270 {
1271 return is_boundary(opposite_halfedge(h));
1272 }
1273
1275 Halfedge halfedge(Edge e, unsigned int i) const
1276 {
1277 assert(i<=1);
1278 return Halfedge((e.idx() << 1) + i);
1279 }
1280
1282 Vertex vertex(Edge e, unsigned int i) const
1283 {
1284 assert(i<=1);
1285 return to_vertex(halfedge(e, i));
1286 }
1287
1289 Face face(Edge e, unsigned int i) const
1290 {
1291 assert(i<=1);
1292 return face(halfedge(e, i));
1293 }
1294
1297 bool is_boundary(Edge e) const
1298 {
1299 return (is_boundary(halfedge(e, 0)) || is_boundary(halfedge(e, 1)));
1300 }
1301
1304 {
1305 return fconn_[f].halfedge_;
1306 }
1307
1310 {
1311 fconn_[f].halfedge_ = h;
1312 }
1313
1315 bool is_boundary(Face f) const
1316 {
1317 Halfedge h = halfedge(f);
1318 Halfedge hh = h;
1319 do
1320 {
1321 if (is_boundary(opposite_halfedge(h)))
1322 return true;
1323 h = next_halfedge(h);
1324 }
1325 while (h != hh);
1326 return false;
1327 }
1328
1330
1331
1332
1333
1334public: //--------------------------------------------------- property handling
1335
1337
1338
1342 template <class T> Vertex_property<T> add_vertex_property(const std::string& name, T t=T())
1343 {
1344 return Vertex_property<T>(vprops_.add<T>(name, give(t)));
1345 }
1349 template <class T> Halfedge_property<T> add_halfedge_property(const std::string& name, T t=T())
1350 {
1351 return Halfedge_property<T>(hprops_.add<T>(name, give(t)));
1352 }
1356 template <class T> Edge_property<T> add_edge_property(const std::string& name, T t=T())
1357 {
1358 return Edge_property<T>(eprops_.add<T>(name, t));
1359 }
1363 template <class T> Face_property<T> add_face_property(const std::string& name, const T t=T())
1364 {
1365 return Face_property<T>(fprops_.add<T>(name, t));
1366 }
1370 template <class T> Mesh_property<T> add_mesh_property(const std::string& name, const T t=T())
1371 {
1372 return Mesh_property<T>(mprops_.add<T>(name, t));
1373 }
1374
1377 template <class T> Vertex_property<T> get_vertex_property(const std::string& name) const
1378 {
1379 return Vertex_property<T>(vprops_.get<T>(name));
1380 }
1383 template <class T> Halfedge_property<T> get_halfedge_property(const std::string& name) const
1384 {
1385 return Halfedge_property<T>(hprops_.get<T>(name));
1386 }
1389 template <class T> Edge_property<T> get_edge_property(const std::string& name) const
1390 {
1391 return Edge_property<T>(eprops_.get<T>(name));
1392 }
1395 template <class T> Face_property<T> get_face_property(const std::string& name) const
1396 {
1397 return Face_property<T>(fprops_.get<T>(name));
1398 }
1401 template <class T> Mesh_property<T> get_mesh_property(const std::string& name) const
1402 {
1403 return Mesh_property<T>(mprops_.get<T>(name));
1404 }
1405
1406
1409 template <class T> Vertex_property<T> vertex_property(const std::string& name, const T t=T())
1410 {
1411 return Vertex_property<T>(vprops_.get_or_add<T>(name, give(t)));
1412 }
1415 template <class T> Halfedge_property<T> halfedge_property(const std::string& name, T t=T())
1416 {
1417 return Halfedge_property<T>(hprops_.get_or_add<T>(name, give(t)));
1418 }
1421 template <class T> Edge_property<T> edge_property(const std::string& name, const T t=T())
1422 {
1423 return Edge_property<T>(eprops_.get_or_add<T>(name, t));
1424 }
1427 template <class T> Face_property<T> face_property(const std::string& name, const T t=T())
1428 {
1429 return Face_property<T>(fprops_.get_or_add<T>(name, t));
1430 }
1431
1434 template <class T> Mesh_property<T> mesh_property(const std::string& name, const T t=T())
1435 {
1436 return Mesh_property<T>(mprops_.get_or_add<T>(name, t));
1437 }
1438
1440 template <class T> void rename_vertex_property(Vertex_property<T>& p,
1441 std::string newname)
1442 {
1443 vprops_.rename(p, give(newname));
1444 }
1445
1447 void swap_vertex_property(const std::string & name1,
1448 const std::string & name2)
1449 {
1450 vprops_.swap(name1,name2);
1451 }
1452
1454 template <class T> void remove_vertex_property(Vertex_property<T>& p)
1455 {
1456 vprops_.remove(p);
1457 }
1460 {
1461 hprops_.remove(p);
1462 }
1464 template <class T> void remove_edge_property(Edge_property<T>& p)
1465 {
1466 eprops_.remove(p);
1467 }
1469 template <class T> void remove_face_property(Face_property<T>& p)
1470 {
1471 fprops_.remove(p);
1472 }
1474 template <class T> void remove_mesh_property(Mesh_property<T>& p)
1475 {
1476 mprops_.remove(p);
1477 }
1478
1479
1482 const std::type_info& get_vertex_property_type(const std::string& name)
1483 {
1484 return vprops_.get_type(name);
1485 }
1488 const std::type_info& get_halfedge_property_type(const std::string& name)
1489 {
1490 return hprops_.get_type(name);
1491 }
1494 const std::type_info& get_edge_property_type(const std::string& name)
1495 {
1496 return eprops_.get_type(name);
1497 }
1500 const std::type_info& get_face_property_type(const std::string& name)
1501 {
1502 return fprops_.get_type(name);
1503 }
1506 const std::type_info& get_mesh_property_type(const std::string& name)
1507 {
1508 return mprops_.get_type(name);
1509 }
1510
1511
1513 std::vector<std::string> vertex_properties() const
1514 {
1515 return vprops_.properties();
1516 }
1518 std::vector<std::string> halfedge_properties() const
1519 {
1520 return hprops_.properties();
1521 }
1523 std::vector<std::string> edge_properties() const
1524 {
1525 return eprops_.properties();
1526 }
1528 std::vector<std::string> face_properties() const
1529 {
1530 return fprops_.properties();
1531 }
1533 std::vector<std::string> mesh_properties() const
1534 {
1535 return mprops_.properties();
1536 }
1537
1539 void property_stats() const;
1540
1542
1543
1544
1545
1546public: //--------------------------------------------- iterators & circulators
1547
1549
1550
1553 {
1554 return Vertex_iterator(Vertex(0), this);
1555 }
1556
1559 {
1560 return Vertex_iterator(Vertex(vertices_size()), this);
1561 }
1562
1565 {
1566 return Vertex_container(vertices_begin(), vertices_end());
1567 }
1568
1571 {
1572 return Halfedge_iterator(Halfedge(0), this);
1573 }
1574
1577 {
1578 return Halfedge_iterator(Halfedge(halfedges_size()), this);
1579 }
1580
1583 {
1584 return Halfedge_container(halfedges_begin(), halfedges_end());
1585 }
1586
1589 {
1590 return Edge_iterator(Edge(0), this);
1591 }
1592
1595 {
1596 return Edge_iterator(Edge(edges_size()), this);
1597 }
1598
1601 {
1602 return Edge_container(edges_begin(), edges_end());
1603 }
1604
1607 {
1608 return Face_iterator(Face(0), this);
1609 }
1610
1613 {
1614 return Face_iterator(Face(faces_size()), this);
1615 }
1616
1619 {
1620 return Face_container(faces_begin(), faces_end());
1621 }
1622
1628
1634
1637 {
1638 return Face_around_vertex_circulator(this, v);
1639 }
1640
1643 {
1644 return Vertex_around_face_circulator(this, f);
1645 }
1646
1652
1654
1655
1656
1657
1658
1659public: //--------------------------------------------- higher-level operations
1660
1662
1663
1667 bool is_triangle_mesh() const;
1668
1671 bool is_quad_mesh() const;
1672
1675 void triangulate();
1676
1679 void triangulate(Face f);
1680
1681
1684 bool is_collapse_ok(Halfedge h);
1685
1696 void collapse(Halfedge h);
1697
1698
1704 Vertex split(Face f, const Point& p) { Vertex v=add_vertex(p); split(f,v); return v; }
1705
1710 void split(Face f, Vertex v);
1711
1712
1716 void quad_split(Face f, Vertex v, Halfedge s);
1717 void quad_split();
1718
1727 Halfedge split(Edge e, const Point& p) { return split(e, add_vertex(p)); }
1728
1729
1738 Halfedge split(Edge e, Vertex v);
1739
1740
1748 Halfedge insert_vertex(Edge e, const Point& p)
1749 {
1750 return insert_vertex(halfedge(e,0), add_vertex(p));
1751 }
1752
1760 {
1761 return insert_vertex(halfedge(e,0), v);
1762 }
1763
1770 Halfedge insert_vertex(Halfedge h, Vertex v);
1771
1772
1776 Halfedge insert_edge(Halfedge h0, Halfedge h1);
1777
1778
1783 bool is_flip_ok(Edge e) const;
1784
1790 void flip(Edge e);
1791
1792
1795 unsigned int valence(Vertex v) const;
1796
1798 unsigned int valence(Face f) const;
1799
1801 unsigned int face_valence_sum() const;
1802
1804 Halfedge find_halfedge(Vertex start, Vertex end) const;
1805
1807 Edge find_edge(Vertex a, Vertex b) const;
1808
1810 void delete_vertex(Vertex v);
1811
1813 void delete_edge(Edge e);
1814
1816 void delete_face(Face f);
1817
1819
1820
1821public: //------------------------------------------ geometry-related functions
1822
1824
1825
1827 const Point& position(Vertex v) const { return vpoint_[v]; }
1828
1830 Point& position(Vertex v) { return vpoint_[v]; }
1831
1833 std::vector<Point>& points() { return vpoint_.vector(); }
1834
1836 void update_face_normals();
1837
1839 Normal compute_face_normal(Face f) const;
1840
1842 void update_vertex_normals();
1843
1845 Normal compute_vertex_normal(Vertex v) const;
1846
1848 Scalar edge_length(Edge e) const;
1849
1851
1852
1853
1854
1855private: //---------------------------------------------- allocate new elements
1856
1859 {
1860 vprops_.push_back();
1861 return Vertex(vertices_size()-1);
1862 }
1863
1866 {
1867 assert(start != end);
1868
1869 eprops_.push_back();
1870 hprops_.push_back();
1871 hprops_.push_back();
1872
1873 Halfedge h0(halfedges_size()-2);
1874 Halfedge h1(halfedges_size()-1);
1875
1876 set_vertex(h0, end); //to_vertex*
1877 set_vertex(h1, start); //to_vertex
1878
1879 return h0;
1880 }
1881
1884 {
1885 fprops_.push_back();
1886 return Face(faces_size()-1);
1887 }
1888
1889 friend std::ostream& operator<<(std::ostream& os, const gsSurfMesh & sm)
1890 {
1891 os<<"gsSurfMesh with "<<sm.n_vertices()<<" vertices, "<<sm.n_edges()<<
1892 " edges and "<<sm.n_faces()<<" faces.\n";
1893 return os;
1894 }
1895
1896public: // Catmull-Clark functions
1897
1899 void cc_subdivide();
1900
1902 Vertex_property<Point> cc_limit_points(std::string label = "v:limit");
1903
1905 Vertex_property<Point> cc_limit_normals(std::string label = "v:normal",
1906 bool normalize = true);
1907
1909 Vertex_property<Point> cc_limit_tangent_vec(std::string label = "v:tanvec",
1910 bool normalize = true);
1911
1913 gsMultiPatch<real_t> cc_acc3(bool comp_topology = false) const;
1914
1916 gsMultiPatch<real_t> linear_patches() const;
1917
1918private: //--------------------------------------------------- helper functions
1919
1922 void adjust_outgoing_halfedge(Vertex v);
1923
1925 void remove_edge(Halfedge h);
1926
1928 void remove_loop(Halfedge h);
1929
1931 bool garbage() const { return garbage_; }
1932
1933private: //------------------------------------------------------- private data
1934
1935 friend bool GISMO_EXPORT read_poly(gsSurfMesh& mesh, const std::string& filename);
1936
1937 gsProperty_container vprops_;
1938 gsProperty_container hprops_;
1939 gsProperty_container eprops_;
1940 gsProperty_container fprops_;
1941 gsProperty_container mprops_;
1942
1943 Vertex_property<Vertex_connectivity> vconn_;
1944 Halfedge_property<Halfedge_connectivity> hconn_;
1945 Face_property<Face_connectivity> fconn_;
1946
1947 Vertex_property<bool> vdeleted_;
1948 Edge_property<bool> edeleted_;
1949 Face_property<bool> fdeleted_;
1950
1951 Vertex_property<Point> vpoint_;
1952 Vertex_property<Normal> vnormal_;
1953 Face_property<Normal> fnormal_;
1954
1955 unsigned int deleted_vertices_;
1956 unsigned int deleted_edges_;
1957 unsigned int deleted_faces_;
1958 bool garbage_;
1959
1960 // helper data for add_face()
1961 typedef std::pair<Halfedge, Halfedge> NextCacheEntry;
1962 typedef std::vector<NextCacheEntry> NextCache;
1963 std::vector<Vertex> add_face_vertices_;
1964 std::vector<Halfedge> add_face_halfedges_;
1965 std::vector<bool> add_face_is_new_;
1966 std::vector<bool> add_face_needs_adjust_;
1967 NextCache add_face_next_cache_;
1968};
1969
1970
1971//------------------------------------------------------------ output operators
1972
1973
1974inline std::ostream& operator<<(std::ostream& os, gsSurfMesh::Vertex v)
1975{
1976 return (os << 'v' << v.idx());
1977}
1978
1979inline std::ostream& operator<<(std::ostream& os, gsSurfMesh::Halfedge h)
1980{
1981 return (os << 'h' << h.idx());
1982}
1983
1984inline std::ostream& operator<<(std::ostream& os, gsSurfMesh::Edge e)
1985{
1986 return (os << 'e' << e.idx());
1987}
1988
1989inline std::ostream& operator<<(std::ostream& os, gsSurfMesh::Face f)
1990{
1991 return (os << 'f' << f.idx());
1992}
1993
1994
1995
1996namespace internal
1997{
1998
1999template<>
2000class GISMO_EXPORT gsXml<gsSurfMesh>
2001{
2002private:
2003 gsXml();
2004public:
2005 GSXML_COMMON_FUNCTIONS(gsSurfMesh)
2006 GSXML_GET_POINTER(gsSurfMesh)
2007 static std::string tag () { return "Mesh"; }
2008 static std::string type() { return "off"; }
2009
2010 static void get_into(gsXmlNode * node, gsSurfMesh & result);
2011 static gsXmlNode * put (const gsSurfMesh & obj, gsXmlTree & data);
2012};
2013
2014}//namespace internal
2015
2016//=============================================================================
2017} // namespace gismo
2018//=============================================================================
Definition gsSurfMesh.h:61
bool operator<(const Base_handle &_rhs) const
compare operator useful for sorting handles
Definition gsSurfMesh.h:87
Base_handle(int _idx=-1)
constructor
Definition gsSurfMesh.h:65
bool operator!=(const Base_handle &_rhs) const
are two handles different?
Definition gsSurfMesh.h:82
bool is_valid() const
return whether the handle is valid, i.e., the index is not equal to -1.
Definition gsSurfMesh.h:74
int idx() const
Get the underlying index of this handle.
Definition gsSurfMesh.h:68
bool operator==(const Base_handle &_rhs) const
are two handles equal?
Definition gsSurfMesh.h:77
void reset()
reset handle to be invalid (index=-1)
Definition gsSurfMesh.h:71
Definition gsSurfMesh.h:597
Definition gsSurfMesh.h:435
Edge_iterator & operator--()
pre-decrement iterator
Definition gsSurfMesh.h:471
Edge_iterator(Edge e=Edge(), const gsSurfMesh *m=NULL)
Default constructor.
Definition gsSurfMesh.h:439
Edge operator*() const
get the edge the iterator refers to
Definition gsSurfMesh.h:445
Edge_iterator & operator++()
pre-increment iterator
Definition gsSurfMesh.h:462
bool operator==(const Edge_iterator &rhs) const
are two iterators equal?
Definition gsSurfMesh.h:450
bool operator!=(const Edge_iterator &rhs) const
are two iterators different?
Definition gsSurfMesh.h:456
Definition gsSurfMesh.h:230
gsProperty< T >::reference operator[](Edge e)
access the data stored for edge e
Definition gsSurfMesh.h:238
gsProperty< T >::const_reference operator[](Edge e) const
access the data stored for edge e
Definition gsSurfMesh.h:244
Edge_property()
default constructor
Definition gsSurfMesh.h:234
bool operator==(const Face_around_vertex_circulator &rhs) const
are two circulators equal?
Definition gsSurfMesh.h:782
bool operator!=(const Face_around_vertex_circulator &rhs) const
are two circulators different?
Definition gsSurfMesh.h:789
Face_around_vertex_circulator(const gsSurfMesh *m=NULL, Vertex v=Vertex())
construct with mesh and vertex (vertex should not be isolated!)
Definition gsSurfMesh.h:770
Face_around_vertex_circulator & operator++()
pre-increment (rotates counter-clockwise)
Definition gsSurfMesh.h:795
Face operator*() const
get the face the circulator refers to
Definition gsSurfMesh.h:816
Face_around_vertex_circulator & operator--()
pre-decrement (rotate clockwise)
Definition gsSurfMesh.h:806
Definition gsSurfMesh.h:612
Definition gsSurfMesh.h:489
Face_iterator & operator--()
pre-decrement iterator
Definition gsSurfMesh.h:546
bool operator<(const Face_iterator &rhs) const
how do two iterators compare?
Definition gsSurfMesh.h:525
Face_iterator & operator++()
pre-increment iterator
Definition gsSurfMesh.h:537
bool operator==(const Face_iterator &rhs) const
are two iterators equal?
Definition gsSurfMesh.h:519
Face operator*() const
get the face the iterator refers to
Definition gsSurfMesh.h:499
bool operator!=(const Face_iterator &rhs) const
are two iterators different?
Definition gsSurfMesh.h:531
Face_iterator(Face f=Face(), const gsSurfMesh *m=NULL)
Default constructor.
Definition gsSurfMesh.h:493
Definition gsSurfMesh.h:254
gsProperty< T >::const_reference operator[](Face f) const
access the data stored for face f
Definition gsSurfMesh.h:268
gsProperty< T >::reference operator[](Face f)
access the data stored for face f
Definition gsSurfMesh.h:262
Face_property()
default constructor
Definition gsSurfMesh.h:258
Halfedge_around_face_circulator & operator--()
pre-decrement (rotates clockwise)
Definition gsSurfMesh.h:946
Halfedge_around_face_circulator & operator++()
pre-increment (rotates counter-clockwise)
Definition gsSurfMesh.h:937
Halfedge_around_face_circulator(const gsSurfMesh *m=NULL, Face f=Face())
default constructur
Definition gsSurfMesh.h:917
Halfedge operator*() const
get the halfedge the circulator refers to
Definition gsSurfMesh.h:954
bool operator!=(const Halfedge_around_face_circulator &rhs) const
are two circulators different?
Definition gsSurfMesh.h:931
bool operator==(const Halfedge_around_face_circulator &rhs) const
are two circulators equal?
Definition gsSurfMesh.h:924
Halfedge_around_vertex_circulator & operator--()
pre-decrement (rotate clockwise)
Definition gsSurfMesh.h:734
Halfedge operator*() const
get the halfedge the circulator refers to
Definition gsSurfMesh.h:742
Halfedge_around_vertex_circulator & operator++()
pre-increment (rotate couter-clockwise)
Definition gsSurfMesh.h:725
bool operator==(const Halfedge_around_vertex_circulator &rhs) const
are two circulators equal?
Definition gsSurfMesh.h:712
Halfedge_around_vertex_circulator(const gsSurfMesh *m=NULL, Vertex v=Vertex())
default constructor
Definition gsSurfMesh.h:705
bool operator!=(const Halfedge_around_vertex_circulator &rhs) const
are two circulators different?
Definition gsSurfMesh.h:719
Definition gsSurfMesh.h:582
Definition gsSurfMesh.h:381
Halfedge_iterator & operator++()
pre-increment iterator
Definition gsSurfMesh.h:408
bool operator!=(const Halfedge_iterator &rhs) const
are two iterators different?
Definition gsSurfMesh.h:402
Halfedge_iterator(Halfedge h=Halfedge(), const gsSurfMesh *m=NULL)
Default constructor.
Definition gsSurfMesh.h:385
Halfedge operator*() const
get the halfedge the iterator refers to
Definition gsSurfMesh.h:391
bool operator==(const Halfedge_iterator &rhs) const
are two iterators equal?
Definition gsSurfMesh.h:396
Halfedge_iterator & operator--()
pre-decrement iterator
Definition gsSurfMesh.h:417
Definition gsSurfMesh.h:206
gsProperty< T >::reference operator[](Halfedge h)
access the data stored for halfedge h
Definition gsSurfMesh.h:214
Halfedge_property()
default constructor
Definition gsSurfMesh.h:210
gsProperty< T >::const_reference operator[](Halfedge h) const
access the data stored for halfedge h
Definition gsSurfMesh.h:220
Definition gsSurfMesh.h:278
gsProperty< T >::const_reference operator[](size_t idx) const
access the data stored for the mesh
Definition gsSurfMesh.h:292
gsProperty< T >::reference operator[](size_t idx)
access the data stored for the mesh
Definition gsSurfMesh.h:286
Mesh_property()
default constructor
Definition gsSurfMesh.h:282
Vertex_around_face_circulator & operator--()
pre-decrement (rotates clockwise)
Definition gsSurfMesh.h:875
Vertex_around_face_circulator & operator++()
pre-increment (rotates counter-clockwise)
Definition gsSurfMesh.h:866
Vertex operator*() const
get the vertex the circulator refers to
Definition gsSurfMesh.h:883
bool operator==(const Vertex_around_face_circulator &rhs) const
are two circulators equal?
Definition gsSurfMesh.h:853
Vertex_around_face_circulator(const gsSurfMesh *m=NULL, Face f=Face())
default constructor
Definition gsSurfMesh.h:846
bool operator!=(const Vertex_around_face_circulator &rhs) const
are two circulators different?
Definition gsSurfMesh.h:860
Halfedge he() const
get the halfedge the circulator refers to
Definition gsSurfMesh.h:890
Vertex_around_vertex_circulator & operator--()
pre-decrement (rotate clockwise)
Definition gsSurfMesh.h:664
bool operator!=(const Vertex_around_vertex_circulator &rhs) const
are two circulators different?
Definition gsSurfMesh.h:649
Vertex operator*() const
get the vertex the circulator refers to
Definition gsSurfMesh.h:672
Vertex_around_vertex_circulator(const gsSurfMesh *m=NULL, Vertex v=Vertex())
default constructor
Definition gsSurfMesh.h:635
bool operator==(const Vertex_around_vertex_circulator &rhs) const
are two circulators equal?
Definition gsSurfMesh.h:642
Vertex_around_vertex_circulator & operator++()
pre-increment (rotate couter-clockwise)
Definition gsSurfMesh.h:655
Halfedge halfedge() const
return current halfedge
Definition gsSurfMesh.h:682
Definition gsSurfMesh.h:567
Definition gsSurfMesh.h:306
Vertex_iterator & operator--()
pre-decrement iterator
Definition gsSurfMesh.h:363
bool operator==(const Vertex_iterator &rhs) const
are two iterators equal?
Definition gsSurfMesh.h:336
Vertex operator*() const
get the vertex the iterator refers to
Definition gsSurfMesh.h:316
bool operator!=(const Vertex_iterator &rhs) const
are two iterators different?
Definition gsSurfMesh.h:348
Vertex_iterator & operator++()
pre-increment iterator
Definition gsSurfMesh.h:354
bool operator<(const Vertex_iterator &rhs) const
how do two iterators compare?
Definition gsSurfMesh.h:342
Vertex_iterator(Vertex v=Vertex(), const gsSurfMesh *m=NULL)
Default constructor.
Definition gsSurfMesh.h:310
Definition gsSurfMesh.h:182
gsProperty< T >::reference operator[](Vertex v)
access the data stored for vertex v
Definition gsSurfMesh.h:190
Vertex_property()
default constructor
Definition gsSurfMesh.h:186
gsProperty< T >::const_reference operator[](Vertex v) const
access the data stored for vertex v
Definition gsSurfMesh.h:196
A halfedge data structure for polygonal meshes.
Definition gsSurfMesh.h:46
const std::type_info & get_mesh_property_type(const std::string &name)
Definition gsSurfMesh.h:1506
const std::type_info & get_edge_property_type(const std::string &name)
Definition gsSurfMesh.h:1494
std::vector< Point > & points()
vector of vertex positions
Definition gsSurfMesh.h:1833
Vertex_property< T > add_vertex_property(const std::string &name, T t=T())
Definition gsSurfMesh.h:1342
unsigned int n_faces() const
returns number of faces in the mesh
Definition gsSurfMesh.h:1065
unsigned int n_halfedges() const
returns number of halfedge in the mesh
Definition gsSurfMesh.h:1061
unsigned int halfedges_size() const
returns number of (deleted and valid)halfedge in the mesh
Definition gsSurfMesh.h:1051
bool is_valid(Halfedge h) const
return whether halfedge h is valid, i.e. the index it stores is within the array bounds.
Definition gsSurfMesh.h:1120
unsigned int n_edges() const
returns number of edges in the mesh
Definition gsSurfMesh.h:1063
Halfedge new_edge(Vertex start, Vertex end)
allocate a new edge, resize edge and halfedge properties accordingly.
Definition gsSurfMesh.h:1865
bool is_valid(Edge e) const
return whether edge e is valid, i.e. the index it stores is within the array bounds.
Definition gsSurfMesh.h:1125
Mesh_property< T > mesh_property(const std::string &name, const T t=T())
Definition gsSurfMesh.h:1434
bool touches_boundary(Halfedge h) const
returns whether h touches the boundary, i.e., its opposite is a boundary halfedge.
Definition gsSurfMesh.h:1269
std::vector< std::string > mesh_properties() const
returns the names of all mesh properties
Definition gsSurfMesh.h:1533
const std::type_info & get_vertex_property_type(const std::string &name)
Definition gsSurfMesh.h:1482
Vertex_around_face_circulator vertices(Face f) const
returns circulator for vertices of face f
Definition gsSurfMesh.h:1642
Point & position(Vertex v)
position of a vertex
Definition gsSurfMesh.h:1830
Edge_property< T > edge_property(const std::string &name, const T t=T())
Definition gsSurfMesh.h:1421
Mesh_property< T > get_mesh_property(const std::string &name) const
Definition gsSurfMesh.h:1401
Edge_iterator edges_begin() const
returns start iterator for edges
Definition gsSurfMesh.h:1588
Halfedge halfedge(Edge e, unsigned int i) const
returns the i'th halfedge of edge e. i has to be 0 or 1.
Definition gsSurfMesh.h:1275
Halfedge insert_vertex(Edge e, Vertex v)
Definition gsSurfMesh.h:1759
void set_halfedge(Vertex v, Halfedge h)
set the outgoing halfedge of vertex v to h
Definition gsSurfMesh.h:1153
unsigned int edges_size() const
returns number of (deleted and valid)edges in the mesh
Definition gsSurfMesh.h:1053
std::vector< std::string > face_properties() const
returns the names of all face properties
Definition gsSurfMesh.h:1528
Edge_container edges() const
returns edge container for C++11 range-based for-loops
Definition gsSurfMesh.h:1600
bool garbage() const
are there deleted vertices, edges or faces?
Definition gsSurfMesh.h:1931
void remove_face_property(Face_property< T > &p)
remove the face property p
Definition gsSurfMesh.h:1469
Halfedge split(Edge e, const Point &p)
Definition gsSurfMesh.h:1727
void set_next_halfedge(Halfedge h, Halfedge nh)
sets the next halfedge of h within the face to nh
Definition gsSurfMesh.h:1224
real_t Scalar
Scalar type.
Definition gsSurfMesh.h:49
gsSurfMesh(const gsSurfMesh &rhs)
copy constructor: copies rhs to *this. performs a deep copy of all properties.
Definition gsSurfMesh.h:987
Edge_property< T > get_edge_property(const std::string &name) const
Definition gsSurfMesh.h:1389
void swap_vertex_property(const std::string &name1, const std::string &name2)
swaps (the values of) two vertex properties of the same type
Definition gsSurfMesh.h:1447
std::vector< std::string > vertex_properties() const
returns the names of all vertex properties
Definition gsSurfMesh.h:1513
Vertex from_vertex(Halfedge h) const
returns the vertex the halfedge h emanates from
Definition gsSurfMesh.h:1194
void set_halfedge(Face f, Halfedge h)
sets the halfedge of face f to h
Definition gsSurfMesh.h:1309
Halfedge ccw_rotated_halfedge(Halfedge h) const
Definition gsSurfMesh.h:1244
Vertex new_vertex()
allocate a new vertex, resize vertex properties accordingly.
Definition gsSurfMesh.h:1858
bool is_boundary(Edge e) const
Definition gsSurfMesh.h:1297
const std::type_info & get_halfedge_property_type(const std::string &name)
Definition gsSurfMesh.h:1488
void remove_vertex_property(Vertex_property< T > &p)
remove the vertex property p
Definition gsSurfMesh.h:1454
gsEigen::Vector< Scalar, 3 > Vec3
3D vector type
Definition gsSurfMesh.h:54
const std::type_info & get_face_property_type(const std::string &name)
Definition gsSurfMesh.h:1500
void rename_vertex_property(Vertex_property< T > &p, std::string newname)
rename the vertex property p
Definition gsSurfMesh.h:1440
Vertex to_vertex(Halfedge h) const
returns the vertex the halfedge h points to
Definition gsSurfMesh.h:1188
Edge_iterator edges_end() const
returns end iterator for edges
Definition gsSurfMesh.h:1594
std::vector< std::string > edge_properties() const
returns the names of all edge properties
Definition gsSurfMesh.h:1523
bool is_deleted(Vertex v) const
Definition gsSurfMesh.h:1090
Halfedge next_halfedge(Halfedge h) const
returns the next halfedge within the incident face
Definition gsSurfMesh.h:1218
void set_face(Halfedge h, Face f)
sets the incident face to halfedge h to f
Definition gsSurfMesh.h:1212
Halfedge halfedge(Face f) const
returns a halfedge of face f
Definition gsSurfMesh.h:1303
Halfedge_property< T > halfedge_property(const std::string &name, T t=T())
Definition gsSurfMesh.h:1415
bool is_deleted(Face f) const
Definition gsSurfMesh.h:1108
bool is_deleted(Edge e) const
Definition gsSurfMesh.h:1102
Vertex_around_vertex_circulator vertices(Vertex v) const
returns circulator for vertices around vertex v
Definition gsSurfMesh.h:1624
Face_property< T > get_face_property(const std::string &name) const
Definition gsSurfMesh.h:1395
Vertex_container vertices() const
returns vertex container for C++11 range-based for-loops
Definition gsSurfMesh.h:1564
Halfedge insert_vertex(Edge e, const Point &p)
Definition gsSurfMesh.h:1748
Vertex_property< T > get_vertex_property(const std::string &name) const
Definition gsSurfMesh.h:1377
Face_property< T > face_property(const std::string &name, const T t=T())
Definition gsSurfMesh.h:1427
Halfedge opposite_halfedge(Halfedge h) const
returns the opposite halfedge of h
Definition gsSurfMesh.h:1237
Vertex split(Face f, const Point &p)
Definition gsSurfMesh.h:1704
const Point & position(Vertex v) const
position of a vertex (read only)
Definition gsSurfMesh.h:1827
Face_property< T > add_face_property(const std::string &name, const T t=T())
Definition gsSurfMesh.h:1363
std::vector< std::string > halfedge_properties() const
returns the names of all halfedge properties
Definition gsSurfMesh.h:1518
Halfedge_container halfedges() const
returns halfedge container for C++11 range-based for-loops
Definition gsSurfMesh.h:1582
Halfedge_around_face_circulator halfedges(Face f) const
returns circulator for halfedges of face f
Definition gsSurfMesh.h:1648
Vertex_property< T > vertex_property(const std::string &name, const T t=T())
Definition gsSurfMesh.h:1409
Face_iterator faces_end() const
returns end iterator for faces
Definition gsSurfMesh.h:1612
Edge_property< T > add_edge_property(const std::string &name, T t=T())
Definition gsSurfMesh.h:1356
bool is_valid(Face f) const
return whether face f is valid, i.e. the index it stores is within the array bounds.
Definition gsSurfMesh.h:1130
Face face(Halfedge h) const
returns the face incident to halfedge h
Definition gsSurfMesh.h:1206
Halfedge prev_halfedge(Halfedge h) const
returns the previous halfedge within the incident face
Definition gsSurfMesh.h:1231
void remove_mesh_property(Mesh_property< T > &p)
remove the mesh property p
Definition gsSurfMesh.h:1474
Vertex_iterator vertices_begin() const
returns start iterator for vertices
Definition gsSurfMesh.h:1552
Halfedge_around_vertex_circulator halfedges(Vertex v) const
returns circulator for outgoing halfedges around vertex v
Definition gsSurfMesh.h:1630
void remove_halfedge_property(Halfedge_property< T > &p)
remove the halfedge property p
Definition gsSurfMesh.h:1459
Halfedge_property< T > get_halfedge_property(const std::string &name) const
Definition gsSurfMesh.h:1383
unsigned int empty() const
returns true iff the mesh is empty, i.e., has no vertices
Definition gsSurfMesh.h:1069
Face_container faces() const
returns face container for C++11 range-based for-loops
Definition gsSurfMesh.h:1618
Face_around_vertex_circulator faces(Vertex v) const
returns circulator for faces around vertex v
Definition gsSurfMesh.h:1636
Halfedge_iterator halfedges_end() const
returns end iterator for halfedges
Definition gsSurfMesh.h:1576
Halfedge_iterator halfedges_begin() const
returns start iterator for halfedges
Definition gsSurfMesh.h:1570
Halfedge_property< T > add_halfedge_property(const std::string &name, T t=T())
Definition gsSurfMesh.h:1349
bool is_manifold(Vertex v) const
returns whether v is a manifold vertex (not incident to several patches)
Definition gsSurfMesh.h:1172
Mesh_property< T > add_mesh_property(const std::string &name, const T t=T())
Definition gsSurfMesh.h:1370
bool is_boundary(Face f) const
returns whether f is a boundary face, i.e., it one of its edges is a boundary edge.
Definition gsSurfMesh.h:1315
bool is_boundary(Vertex v) const
returns whether v is a boundary vertex
Definition gsSurfMesh.h:1159
bool is_isolated(Vertex v) const
returns whether v is isolated, i.e., not incident to any face
Definition gsSurfMesh.h:1166
bool is_deleted(Halfedge h) const
Definition gsSurfMesh.h:1096
unsigned int vertices_size() const
returns number of (deleted and valid) vertices in the mesh
Definition gsSurfMesh.h:1049
Edge edge(Halfedge h) const
return the edge that contains halfedge h as one of its two halfedges.
Definition gsSurfMesh.h:1257
bool is_boundary(Halfedge h) const
returns whether h is a boundary halfege, i.e., if its face does not exist.
Definition gsSurfMesh.h:1263
Halfedge cw_rotated_halfedge(Halfedge h) const
Definition gsSurfMesh.h:1251
Face new_face()
allocate a new face, resize face properties accordingly.
Definition gsSurfMesh.h:1883
void set_vertex(Halfedge h, Vertex v)
sets the vertex the halfedge h points to to v
Definition gsSurfMesh.h:1200
Face_iterator faces_begin() const
returns start iterator for faces
Definition gsSurfMesh.h:1606
Vertex_iterator vertices_end() const
returns end iterator for vertices
Definition gsSurfMesh.h:1558
unsigned int faces_size() const
returns number of (deleted and valid)faces in the mesh
Definition gsSurfMesh.h:1055
void remove_edge_property(Edge_property< T > &p)
remove the edge property p
Definition gsSurfMesh.h:1464
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 gsSurfMesh.h:1289
bool is_valid(Vertex v) const
return whether vertex v is valid, i.e. the index it stores is within the array bounds.
Definition gsSurfMesh.h:1115
Vertex vertex(Edge e, unsigned int i) const
returns the i'th vertex of edge e. i has to be 0 or 1.
Definition gsSurfMesh.h:1282
Halfedge halfedge(Vertex v) const
Definition gsSurfMesh.h:1147
unsigned int n_vertices() const
returns number of vertices in the mesh
Definition gsSurfMesh.h:1059
This is the main header file that collects wrappers of Eigen for linear algebra.
Provides declaration of input/output XML utilities struct.
std::ostream & operator<<(std::ostream &os, const _expr< E > &b)
Stream operator for expressions.
Definition gsExpressions.h:382
The G+Smo namespace, containing all definitions for the library.
Point Normal
Normal type.
Definition gsSurfMesh.h:24
Point Color
Color type.
Definition gsSurfMesh.h:26
Point Texture_coordinate
Texture coordinate type.
Definition gsSurfMesh.h:28
S give(S &x)
Definition gsMemory.h:266
Definition gsSurfMesh.h:123
Edge(int _idx=-1)
default constructor (with invalid index)
Definition gsSurfMesh.h:125
Definition gsSurfMesh.h:169
Halfedge halfedge_
a halfedge that is part of the face
Definition gsSurfMesh.h:171
Definition gsSurfMesh.h:132
Face(int _idx=-1)
default constructor (with invalid index)
Definition gsSurfMesh.h:134
Definition gsSurfMesh.h:154
Vertex vertex_
vertex the halfedge points to
Definition gsSurfMesh.h:158
Halfedge prev_halfedge_
previous halfedge within a face (or along a boundary)
Definition gsSurfMesh.h:162
Face face_
face incident to halfedge
Definition gsSurfMesh.h:156
Halfedge next_halfedge_
next halfedge within a face (or along a boundary)
Definition gsSurfMesh.h:160
Definition gsSurfMesh.h:114
Halfedge(int _idx=-1)
default constructor (with invalid index)
Definition gsSurfMesh.h:116
Definition gsSurfMesh.h:145
Halfedge halfedge_
an outgoing halfedge per vertex (it will be a bounday halfedge for boundary vertices)
Definition gsSurfMesh.h:147
Definition gsSurfMesh.h:104
Vertex(int _idx=-1)
default constructor (with invalid index)
Definition gsSurfMesh.h:106