admesh refactoring: Removed the shared_vertices counter as it is now
contained inside v_shared std::vector
This commit is contained in:
parent
a1c38794fb
commit
65238a89b1
@ -33,7 +33,6 @@ void stl_invalidate_shared_vertices(stl_file *stl)
|
||||
{
|
||||
stl->v_indices.clear();
|
||||
stl->v_shared.clear();
|
||||
stl->stats.shared_vertices = 0;
|
||||
}
|
||||
|
||||
void stl_generate_shared_vertices(stl_file *stl)
|
||||
@ -43,7 +42,6 @@ void stl_generate_shared_vertices(stl_file *stl)
|
||||
// Shared vertices (3D coordinates)
|
||||
stl->v_shared.clear();
|
||||
stl->v_shared.reserve(stl->stats.number_of_facets / 2);
|
||||
stl->stats.shared_vertices = 0;
|
||||
|
||||
// A degenerate mesh may contain loops: Traversing a fan will end up in an endless loop
|
||||
// while never reaching the starting face. To avoid these endless loops, traversed faces at each fan traversal
|
||||
@ -91,7 +89,7 @@ void stl_generate_shared_vertices(stl_file *stl)
|
||||
next_edge = pivot_vertex;
|
||||
}
|
||||
}
|
||||
stl->v_indices[facet_in_fan_idx].vertex[pivot_vertex] = stl->stats.shared_vertices;
|
||||
stl->v_indices[facet_in_fan_idx].vertex[pivot_vertex] = stl->v_shared.size() - 1;
|
||||
fan_traversal_facet_visited[facet_in_fan_idx] = fan_traversal_stamp;
|
||||
|
||||
// next_edge is an index of the starting vertex of the edge, not an index of the opposite vertex to the edge!
|
||||
@ -128,8 +126,6 @@ void stl_generate_shared_vertices(stl_file *stl)
|
||||
facet_in_fan_idx = next_facet;
|
||||
}
|
||||
}
|
||||
|
||||
++ stl->stats.shared_vertices;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,8 +143,8 @@ bool stl_write_off(stl_file *stl, const char *file)
|
||||
}
|
||||
|
||||
fprintf(fp, "OFF\n");
|
||||
fprintf(fp, "%d %d 0\n", stl->stats.shared_vertices, stl->stats.number_of_facets);
|
||||
for (int i = 0; i < stl->stats.shared_vertices; ++ i)
|
||||
fprintf(fp, "%d %d 0\n", stl->v_shared.size(), stl->stats.number_of_facets);
|
||||
for (int i = 0; i < stl->v_shared.size(); ++ i)
|
||||
fprintf(fp, "\t%f %f %f\n", stl->v_shared[i](0), stl->v_shared[i](1), stl->v_shared[i](2));
|
||||
for (uint32_t i = 0; i < stl->stats.number_of_facets; ++ i)
|
||||
fprintf(fp, "\t3 %d %d %d\n", stl->v_indices[i].vertex[0], stl->v_indices[i].vertex[1], stl->v_indices[i].vertex[2]);
|
||||
@ -184,7 +180,7 @@ bool stl_write_vrml(stl_file *stl, const char *file)
|
||||
fprintf(fp, "\t\t\tpoint [\n");
|
||||
|
||||
int i = 0;
|
||||
for (; i < (stl->stats.shared_vertices - 1); i++)
|
||||
for (; i + 1 < stl->v_shared.size(); ++ i)
|
||||
fprintf(fp, "\t\t\t\t%f %f %f,\n", stl->v_shared[i](0), stl->v_shared[i](1), stl->v_shared[i](2));
|
||||
fprintf(fp, "\t\t\t\t%f %f %f]\n", stl->v_shared[i](0), stl->v_shared[i](1), stl->v_shared[i](2));
|
||||
fprintf(fp, "\t\t}\n");
|
||||
@ -213,7 +209,7 @@ bool stl_write_obj(stl_file *stl, const char *file)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < stl->stats.shared_vertices; ++ i)
|
||||
for (size_t i = 0; i < stl->v_shared.size(); ++ i)
|
||||
fprintf(fp, "v %f %f %f\n", stl->v_shared[i](0), stl->v_shared[i](1), stl->v_shared[i](2));
|
||||
for (uint32_t i = 0; i < stl->stats.number_of_facets; ++ i)
|
||||
fprintf(fp, "f %d %d %d\n", stl->v_indices[i].vertex[0]+1, stl->v_indices[i].vertex[1]+1, stl->v_indices[i].vertex[2]+1);
|
||||
|
@ -109,7 +109,6 @@ struct stl_stats {
|
||||
float bounding_diameter;
|
||||
float shortest_edge;
|
||||
float volume;
|
||||
unsigned number_of_blocks;
|
||||
int connected_edges;
|
||||
int connected_facets_1_edge;
|
||||
int connected_facets_2_edge;
|
||||
@ -126,7 +125,6 @@ struct stl_stats {
|
||||
int backwards_edges;
|
||||
int normals_fixed;
|
||||
int number_of_parts;
|
||||
int shared_vertices;
|
||||
};
|
||||
|
||||
struct stl_file {
|
||||
|
@ -425,7 +425,6 @@ bool stl_validate(stl_file *stl)
|
||||
assert(! stl->neighbors_start.empty());
|
||||
assert((stl->v_indices.empty()) == (stl->v_shared.empty()));
|
||||
assert(stl->stats.number_of_facets > 0);
|
||||
assert(stl->v_shared.size() == stl->stats.shared_vertices);
|
||||
assert(stl->v_shared.empty() || stl->v_indices.size() == stl->stats.number_of_facets);
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
@ -1888,17 +1888,17 @@ namespace Slic3r {
|
||||
if (stl.v_shared.empty())
|
||||
stl_generate_shared_vertices(&stl);
|
||||
|
||||
if (stl.stats.shared_vertices == 0)
|
||||
if (stl.v_shared.empty())
|
||||
{
|
||||
add_error("Found invalid mesh");
|
||||
return false;
|
||||
}
|
||||
|
||||
vertices_count += stl.stats.shared_vertices;
|
||||
vertices_count += stl.v_shared.size();
|
||||
|
||||
const Transform3d& matrix = volume->get_matrix();
|
||||
|
||||
for (int i = 0; i < stl.stats.shared_vertices; ++i)
|
||||
for (size_t i = 0; i < stl.v_shared.size(); ++i)
|
||||
{
|
||||
stream << " <" << VERTEX_TAG << " ";
|
||||
Vec3f v = (matrix * stl.v_shared[i].cast<double>()).cast<float>();
|
||||
|
@ -929,7 +929,7 @@ bool store_amf(const char *path, Model *model, const DynamicPrintConfig *config)
|
||||
if (stl.v_shared.empty())
|
||||
stl_generate_shared_vertices(&stl);
|
||||
const Transform3d& matrix = volume->get_matrix();
|
||||
for (size_t i = 0; i < stl.stats.shared_vertices; ++i) {
|
||||
for (size_t i = 0; i < stl.v_shared.size(); ++i) {
|
||||
stream << " <vertex>\n";
|
||||
stream << " <coordinates>\n";
|
||||
Vec3f v = (matrix * stl.v_shared[i].cast<double>()).cast<float>();
|
||||
@ -939,7 +939,7 @@ bool store_amf(const char *path, Model *model, const DynamicPrintConfig *config)
|
||||
stream << " </coordinates>\n";
|
||||
stream << " </vertex>\n";
|
||||
}
|
||||
num_vertices += stl.stats.shared_vertices;
|
||||
num_vertices += stl.v_shared.size();
|
||||
}
|
||||
stream << " </vertices>\n";
|
||||
for (size_t i_volume = 0; i_volume < object->volumes.size(); ++i_volume) {
|
||||
|
@ -919,7 +919,7 @@ Polygon ModelObject::convex_hull_2d(const Transform3d &trafo_instance) const
|
||||
}
|
||||
} else {
|
||||
// Using the shared vertices should be a bit quicker than using the STL faces.
|
||||
for (int i = 0; i < stl.stats.shared_vertices; ++ i) {
|
||||
for (size_t i = 0; i < stl.v_shared.size(); ++ i) {
|
||||
Vec3d p = trafo * stl.v_shared[i].cast<double>();
|
||||
pts.emplace_back(coord_t(scale_(p.x())), coord_t(scale_(p.y())));
|
||||
}
|
||||
|
@ -484,8 +484,8 @@ Polygon TriangleMesh::convex_hull()
|
||||
{
|
||||
this->require_shared_vertices();
|
||||
Points pp;
|
||||
pp.reserve(this->stl.stats.shared_vertices);
|
||||
for (int i = 0; i < this->stl.stats.shared_vertices; ++ i) {
|
||||
pp.reserve(this->stl.v_shared.size());
|
||||
for (size_t i = 0; i < this->stl.v_shared.size(); ++ i) {
|
||||
const stl_vertex &v = this->stl.v_shared[i];
|
||||
pp.emplace_back(Point::new_scale(v(0), v(1)));
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ TriangleMesh::vertices()
|
||||
|
||||
// vertices
|
||||
AV* vertices = newAV();
|
||||
av_extend(vertices, THIS->stl.stats.shared_vertices);
|
||||
for (int i = 0; i < THIS->stl.stats.shared_vertices; i++) {
|
||||
av_extend(vertices, THIS->stl.v_shared.size());
|
||||
for (size_t i = 0; i < THIS->stl.v_shared.size(); i++) {
|
||||
AV* vertex = newAV();
|
||||
av_store(vertices, i, newRV_noinc((SV*)vertex));
|
||||
av_extend(vertex, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user