Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-08-08 04:10:34 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-08-08 04:10:34 +0400
commitb38cc2c2442dfc8abd5b24e2964246075b2b3a19 (patch)
tree99efc93e474098e9c7664b40dd36a43d36b96dd6 /xs/src/admesh
parentd881c5ab2f9c8f43ab72a2a5310962a89a8f9af6 (diff)
parent4438aec12ce3b90b6a4ffde680a0d2b6dc1ed7d1 (diff)
Merge branch 'master' into xsdata
Conflicts: lib/Slic3r.pm lib/Slic3r/ExPolygon.pm lib/Slic3r/Fill.pm lib/Slic3r/Fill/Rectilinear.pm lib/Slic3r/GCode.pm lib/Slic3r/GUI/Plater.pm lib/Slic3r/Geometry/Clipper.pm lib/Slic3r/Layer/Region.pm lib/Slic3r/Print.pm lib/Slic3r/Print/Object.pm lib/Slic3r/TriangleMesh.pm t/shells.t xs/MANIFEST
Diffstat (limited to 'xs/src/admesh')
-rw-r--r--xs/src/admesh/connect.c1
-rw-r--r--xs/src/admesh/normals.c17
-rw-r--r--xs/src/admesh/stl_io.c1
3 files changed, 15 insertions, 4 deletions
diff --git a/xs/src/admesh/connect.c b/xs/src/admesh/connect.c
index 18a137121..4582bf11f 100644
--- a/xs/src/admesh/connect.c
+++ b/xs/src/admesh/connect.c
@@ -82,6 +82,7 @@ stl_check_facets_exact(stl_file *stl)
{
facet = stl->facet_start[i];
+ //If any two of the three vertices are found to be exactally the same, call them degenerate and remove the facet.
if( !memcmp(&facet.vertex[0], &facet.vertex[1],
sizeof(stl_vertex))
|| !memcmp(&facet.vertex[1], &facet.vertex[2],
diff --git a/xs/src/admesh/normals.c b/xs/src/admesh/normals.c
index baaab36eb..f827a712c 100644
--- a/xs/src/admesh/normals.c
+++ b/xs/src/admesh/normals.c
@@ -121,9 +121,13 @@ stl_fix_normal_directions(stl_file *stl)
facet_num = 0;
+ //If normal vector is not within tolerance and backwards:
+ //Arbitrarily starts at face 0. If this one is wrong, we're screwed. Thankfully, the chances
+ // of it being wrong randomly are low if most of the triangles are right:
if(stl_check_normal_vector(stl, 0, 0) == 2)
stl_reverse_facet(stl, 0);
-
+
+ //Say that we've fixed this facet:
norm_sw[facet_num] = 1;
/* edge_num = 0;
vnot = stl->neighbors_start[0].which_vertex_not[0];
@@ -133,19 +137,24 @@ stl_fix_normal_directions(stl_file *stl)
for(;;)
{
/* Add neighbors_to_list. */
+ //Add unconnected neighbors to the list:a
for(j = 0; j < 3; j++)
{
/* Reverse the neighboring facets if necessary. */
if(stl->neighbors_start[facet_num].which_vertex_not[j] > 2)
{
+ // If the facet has a neighbor that is -1, it means that edge isn't shared by another
+ // facet.
if(stl->neighbors_start[facet_num].neighbor[j] != -1)
{
stl_reverse_facet
(stl, stl->neighbors_start[facet_num].neighbor[j]);
}
}
+ //If this edge of the facet is connected:
if(stl->neighbors_start[facet_num].neighbor[j] != -1)
{
+ //If we haven't fixed this facet yet, add it to the list:
if(norm_sw[stl->neighbors_start[facet_num].neighbor[j]] != 1)
{
/* Add node to beginning of list. */
@@ -170,14 +179,14 @@ stl_fix_normal_directions(stl_file *stl)
head->next = head->next->next;
free(temp);
}
- else
+ else //if we ran out of facets to fix:
{
/* All of the facets in this part have been fixed. */
stl->stats.number_of_parts += 1;
/* There are (checked-checked_before) facets */
/* in part stl->stats.number_of_parts */
checked_before = checked;
- if(checked == stl->stats.number_of_facets)
+ if(checked >= stl->stats.number_of_facets)
{
/* All of the facets have been checked. Bail out. */
break;
@@ -350,7 +359,7 @@ void stl_normalize_vector(float v[])
min_normal_length = 0.000000000001;
if(length < min_normal_length)
{
- v[0] = 1.0;
+ v[0] = 0.0;
v[1] = 0.0;
v[2] = 0.0;
return;
diff --git a/xs/src/admesh/stl_io.c b/xs/src/admesh/stl_io.c
index 1732bc4ae..1b2671ab2 100644
--- a/xs/src/admesh/stl_io.c
+++ b/xs/src/admesh/stl_io.c
@@ -198,6 +198,7 @@ stl_print_neighbors(stl_file *stl, char *file)
stl->neighbors_start[i].neighbor[2],
(int)stl->neighbors_start[i].which_vertex_not[2]);
}
+ fclose(fp);
}
static void