unify positive and negative zeros in stl_check_facets_exact() and stl_check_facets_nearby()
New function stl_transform() by a 3x4 matrix.
Some constness improvements.
This commit is contained in:
bubnikv
2017-02-26 21:59:09 +01:00
parent b7aeeb968b
commit efb02f71f0
4 changed files with 43 additions and 27 deletions

View File

@@ -185,6 +185,24 @@ static void calculate_normals(stl_file *stl) {
}
}
void stl_transform(stl_file *stl, float *trafo3x4) {
int i_face, i_vertex, i, j;
if (stl->error)
return;
for (i_face = 0; i_face < stl->stats.number_of_facets; ++ i_face) {
stl_vertex *vertices = stl->facet_start[i_face].vertex;
for (i_vertex = 0; i_vertex < 3; ++ i_vertex) {
stl_vertex &v_dst = vertices[i_vertex];
stl_vertex v_src = v_dst;
v_dst.x = trafo3x4[0] * v_src.x + trafo3x4[1] * v_src.y + trafo3x4[2] * v_src.z + trafo3x4[3];
v_dst.y = trafo3x4[4] * v_src.x + trafo3x4[5] * v_src.y + trafo3x4[6] * v_src.z + trafo3x4[7];
v_dst.z = trafo3x4[8] * v_src.x + trafo3x4[9] * v_src.y + trafo3x4[10] * v_src.z + trafo3x4[11];
}
}
stl_get_size(stl);
calculate_normals(stl);
}
void
stl_rotate_x(stl_file *stl, float angle) {
int i;