diff options
Diffstat (limited to 'dxftess.cc')
-rw-r--r-- | dxftess.cc | 40 |
1 files changed, 29 insertions, 11 deletions
@@ -22,6 +22,8 @@ #include "openscad.h" +#undef DEBUG_TRIANGLE_SPLITTING + struct tess_vdata { GLdouble v[3]; }; @@ -152,7 +154,7 @@ static bool point_on_line(double *p1, double *p2, double *p3) return true; } -void dxf_tesselate(PolySet *ps, DxfData *dxf, bool up, double h) +void dxf_tesselate(PolySet *ps, DxfData *dxf, double rot, bool up, double h) { GLUtesselator *tobj = gluNewTess(); @@ -233,7 +235,9 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, bool up, double h) while (added_triangles) { added_triangles = false; - // printf("*** Triangle splitting (%d) ***\n", tess_tri.count()+1); +#ifdef DEBUG_TRIANGLE_SPLITTING + printf("*** Triangle splitting (%d) ***\n", tess_tri.count()+1); +#endif for (int i = 0; i < tess_tri.count(); i++) for (int k = 0; k < 3; k++) { @@ -245,16 +249,20 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, bool up, double h) if (i != jl.first) possible_neigh[jl] = jl; } - // printf("%d/%d: %d\n", i, k, possible_neigh.count()); +#ifdef DEBUG_TRIANGLE_SPLITTING + printf("%d/%d: %d\n", i, k, possible_neigh.count()); +#endif foreach (QPair_ii jl, possible_neigh) { int j = jl.first; for (int l = jl.second; l != (jl.second + 2) % 3; l = (l + 1) % 3) if (point_on_line(tess_tri[i].p[k], tess_tri[j].p[l], tess_tri[i].p[(k+1)%3])) { - // printf("%% %f %f %f %f %f %f [%d %d]\n", - // tess_tri[i].p[k][0], tess_tri[i].p[k][1], - // tess_tri[j].p[l][0], tess_tri[j].p[l][1], - // tess_tri[i].p[(k+1)%3][0], tess_tri[i].p[(k+1)%3][1], - // i, j); +#ifdef DEBUG_TRIANGLE_SPLITTING + printf("%% %f %f %f %f %f %f [%d %d]\n", + tess_tri[i].p[k][0], tess_tri[i].p[k][1], + tess_tri[j].p[l][0], tess_tri[j].p[l][1], + tess_tri[i].p[(k+1)%3][0], tess_tri[i].p[(k+1)%3][1], + i, j); +#endif tess_tri.append(tess_triangle(tess_tri[j].p[l], tess_tri[i].p[(k+1)%3], tess_tri[i].p[(k+2)%3])); for (int m = 0; m < 2; m++) { @@ -283,10 +291,20 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, bool up, double h) printf(" %f %f %f\n", tess_tri[i].p[1][0], tess_tri[i].p[1][1], tess_tri[i].p[1][2]); printf(" %f %f %f\n", tess_tri[i].p[2][0], tess_tri[i].p[2][1], tess_tri[i].p[2][2]); #endif + double x, y; ps->append_poly(); - ps->insert_vertex(tess_tri[i].p[0][0], tess_tri[i].p[0][1], tess_tri[i].p[0][2]); - ps->insert_vertex(tess_tri[i].p[1][0], tess_tri[i].p[1][1], tess_tri[i].p[1][2]); - ps->insert_vertex(tess_tri[i].p[2][0], tess_tri[i].p[2][1], tess_tri[i].p[2][2]); + + x = tess_tri[i].p[0][0] * cos(rot*M_PI/180) + tess_tri[i].p[0][1] * sin(rot*M_PI/180); + y = tess_tri[i].p[0][0] * -sin(rot*M_PI/180) + tess_tri[i].p[0][1] * cos(rot*M_PI/180); + ps->insert_vertex(x, y, tess_tri[i].p[0][2]); + + x = tess_tri[i].p[1][0] * cos(rot*M_PI/180) + tess_tri[i].p[1][1] * sin(rot*M_PI/180); + y = tess_tri[i].p[1][0] * -sin(rot*M_PI/180) + tess_tri[i].p[1][1] * cos(rot*M_PI/180); + ps->insert_vertex(x, y, tess_tri[i].p[1][2]); + + x = tess_tri[i].p[2][0] * cos(rot*M_PI/180) + tess_tri[i].p[2][1] * sin(rot*M_PI/180); + y = tess_tri[i].p[2][0] * -sin(rot*M_PI/180) + tess_tri[i].p[2][1] * cos(rot*M_PI/180); + ps->insert_vertex(x, y, tess_tri[i].p[2][2]); int i0 = point_to_path.data(tess_tri[i].p[0][0], tess_tri[i].p[0][1], tess_tri[i].p[0][2]).first; int j0 = point_to_path.data(tess_tri[i].p[0][0], tess_tri[i].p[0][1], tess_tri[i].p[0][2]).second; |