40 #ifndef H_MESHCOMESH_H
41 #define H_MESHCOMESH_H
45 #include <exploragram/hexdom/polygon.h>
46 #include <exploragram/hexdom/intersect_tools.h>
58 if (m->facets.
vertex(f, c) != v)
continue;
59 org = m->facets.
vertex(f, (c + 1) % 3);
60 dest = m->facets.
vertex(f, (c + 2) % 3);
72 if (!v2f[v].size())
return;
74 FOR(i, v2f[v].size()) {
77 fan.push_back(
TrFanElt(m, v, f, chart[f]));
83 if (fan[i].org == fan[j].dest) {
90 std::swap(fan[0], fan[i]);
96 FOR(f, fan.size()-1) {
97 for (
index_t i = f+2; i<fan.size(); i++) {
98 if (fan[f].dest == fan[i].org) {
99 std::swap(fan[f + 1], fan[i]);
106 if (fan[f].dest == fan[(f+1) % fan.size()].org)
continue;
107 if (f+1==fan.size() && incomplete_)
continue;
108 GEO::Logger::out(
"HexDom") <<
"Fan around vertex " << v_ <<
" is not valid" << std::endl;
109 FOR(ff, fan.size())
GEO::Logger::out("HexDom") << "fan[ff].org = " << fan[ff].org << "\tfan[ff].dest = " << fan[ff].dest << std::endl;
116 if (fan[rotate].chart != fan[(rotate-1+fan.size())%fan.size()].chart)
break;
120 std::rotate(fan.begin(), fan.begin() +
int(rotate), fan.end());
123 chart_offset.push_back(0);
124 FOR(f, fan.size()-1) {
125 if (fan[f].chart == fan[f+1].chart)
continue;
126 chart_offset.push_back(
int(f + 1));
136 Attribute<bool> selection(m_->vertices.
attributes(),
"selection");
137 if (2<ncharts() || (incomplete_ && 1!=ncharts())) {
138 selection[v_] =
true;
143 FOR(ichart, ncharts()) {
144 vector<index_t> vidx;
145 int off1 = chart_offset[ichart];
146 int off2 = ichart+1 < ncharts() ? chart_offset[ichart+1] : int(fan.size());
147 for (
int ivert=off1; ivert<off2; ivert++) {
148 vidx.push_back(fan[ivert].org);
150 if (incomplete_ || 1<ncharts()) {
151 vidx.push_back(fan[off2-1].dest);
153 triangles.push_back(vector<index_t>());
154 if (3>vidx.size())
continue;
157 FOR(ivert, vidx.size()) {
158 pts3d.push_back(X(m_)[vidx[ivert]]);
161 pts3d.push_back(X(m_)[v_]);
163 vec3 nrm = Poly3d(pts3d).normal();
164 if (nrm.length()<1e-10) nrm =
vec3(0,0,1);
170 FOR(ivert, pts3d.size()) {
171 pts2d.push_back(b.project_xy(pts3d[ivert]));
174 vector<index_t> tri_local_indices;
175 if (!Poly2d(pts2d).try_triangulate_minweight(tri_local_indices)) {
176 error(
"was not able to triangulate");
181 FOR(ivert, tri_local_indices.size()) {
182 triangles.back().push_back(vidx[tri_local_indices[ivert]]);
190 TrFanElt& operator[](
int i) {
195 TrFanElt& operator[](
index_t i) {
204 vector<vector<index_t> > triangles;
205 vector<TrFanElt> fan;
206 vector<int> chart_offset;
213 vector<vector<index_t> > generate_v2f(Mesh *m);
214 bool find_self_intersections(Mesh* facets_with_quads_and_tri_only, vector<index_t> &intersections);
215 bool lock_self_intersecting_regions(Mesh* facets_with_quads_and_tri_only, vector<BBox>& regions_to_lock);
216 bool lock_self_intersecting_regions(Mesh* facets_with_quads_and_tri_only, Attribute<bool> &verts_to_remove, Attribute<index_t> &undo);
217 bool try_simplify(Mesh* m, Attribute<index_t> &chart, Attribute<bool> &verts_to_remove, Attribute<index_t> &undo);
#define geo_assert_not_reached
Sets a non reachable point in the program.
#define geo_assert(x)
Verifies that a condition is met.
static std::ostream & out(const std::string &feature)
Gets the stream to send information messages.
index_t vertex(index_t f, index_t lv) const
Gets a vertex by facet and local vertex index.
index_t nb_vertices(index_t f) const
Gets the number of vertices of a facet.
AttributesManager & attributes() const
Gets the attributes manager.
Vector with aligned memory allocation.
index_t size() const
Gets the number of elements.
Included by all headers in exploragram.
The class that represents a mesh.
Global Vorpaline namespace.
vecng< 3, Numeric::float64 > vec3
Represents points and vectors in 3d.
geo_index_t index_t
The type for storing and manipulating indices.