From 7014551383ab45eba65ea633af5c9ef0640e2782 Mon Sep 17 00:00:00 2001 From: Johannes Larsen Date: Sat, 16 Mar 2024 23:29:26 +0100 Subject: [PATCH] Make it compatible with opencascade 1:7.7.2-5 Which is the current version available on archlinux. Also add some missing includes and std:: qualification. --- Makefile | 5 +--- explore-shape.cpp | 2 ++ openscad-step-reader.cpp | 2 +- openscad-triangle-writer.cpp | 56 ++++++++++++++++++------------------ tessellation.cpp | 12 +++----- triangle.h | 8 +++--- 6 files changed, 40 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 6192851..9f8c03c 100644 --- a/Makefile +++ b/Makefile @@ -33,10 +33,7 @@ LDFLAGS=-lTKSTL -lTKXDESTEP -lTKBinXCAF -lTKXmlXCAF -lTKXDEIGES -lTKXCAF \ -lTKOpenGl -lTKV3d -lTKService -lTKXMesh -lTKMesh -lTKOffset \ -lTKFeat -lTKFillet -lTKHLR -lTKBool -lTKBO -lTKShHealing \ -lTKPrim -lTKTopAlgo -lTKGeomAlgo -lTKBRep -lTKGeomBase \ - -lTKG3d -lTKG2d \ - \ - /usr/lib/x86_64-linux-gnu/libTKMath.so.7.3.0 \ - /usr/lib/x86_64-linux-gnu/libTKernel.so.7.3.0 \ + -lTKG3d -lTKG2d -lTKMath -lTKernel\ \ -lfreetype -lpthread -lrt -lstdc++ -ldl -lm\ diff --git a/explore-shape.cpp b/explore-shape.cpp index 0ae5a41..7b26e5f 100644 --- a/explore-shape.cpp +++ b/explore-shape.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include /* good resources: diff --git a/openscad-step-reader.cpp b/openscad-step-reader.cpp index a0d8d29..b8c6a33 100644 --- a/openscad-step-reader.cpp +++ b/openscad-step-reader.cpp @@ -82,7 +82,7 @@ void show_help() void show_version() { - std::cout << 42 << endl; + std::cout << 42 << std::endl; exit(0); } diff --git a/openscad-triangle-writer.cpp b/openscad-triangle-writer.cpp index 177b73d..19a32cd 100644 --- a/openscad-triangle-writer.cpp +++ b/openscad-triangle-writer.cpp @@ -26,10 +26,10 @@ using namespace std; (with invalud 'normals' value - but these are ignored anyhow in OpenSCAD */ void write_triangles_ascii_stl(const Face_vector& faces) { - cout << "solid" << endl; + cout << "solid" << std::endl; for (auto &f : faces) f.write_ascii_stl(cout); - cout << "endsolid" << endl; + cout << "endsolid" << std::endl; } /* Write the faces/triangles as two vectors (one "POINTS", one "FACES") @@ -50,11 +50,11 @@ void write_triangle_scad(const Face_vector& faces) all.write_face_vector(cout); // Call Polyhedron - cout << "module solid_object() {" << endl; - cout << " polyhedron (points,faces);"<< endl; - cout << "}" << endl; - cout << endl; - cout << "solid_object();" << endl; + cout << "module solid_object() {" << std::endl; + cout << " polyhedron (points,faces);"<< std::endl; + cout << "}" << std::endl; + cout << std::endl; + cout << "solid_object();" << std::endl; } @@ -99,32 +99,32 @@ void write_faces_scad (const Face_vector& faces) } /* crazy colors version, draw each face by itself */ - cout << "module crazy_colors() {" << endl; + cout << "module crazy_colors() {" << std::endl; for (i=1;i<=faces.size();++i) { const char* color = colors[i%NUM_COLORS] ; - cout << "color(\"" << color << "\")" << endl; + cout << "color(\"" << color << "\")" << std::endl; cout << "polyhedron(face_" << i <<"_points, face_" << i << "_faces);" << endl ; } - cout << "}" << endl; + cout << "}" << std::endl; - cout << "function add_offset(vec,ofs) = [for (x=vec) x + [ofs,ofs,ofs]];" << endl; - cout << "module solid_object() {" << endl; - cout << " tmp1_points = face_1_points;" << endl; - cout << " tmp1_faces = face_1_faces;" << endl; - cout << endl; + cout << "function add_offset(vec,ofs) = [for (x=vec) x + [ofs,ofs,ofs]];" << std::endl; + cout << "module solid_object() {" << std::endl; + cout << " tmp1_points = face_1_points;" << std::endl; + cout << " tmp1_faces = face_1_faces;" << std::endl; + cout << std::endl; for (i=2;i<=faces.size();++i) { - cout << " tmp"<Nodes(); - const Poly_Array1OfTriangle& triangles = aTr->Triangles(); - const TColgp_Array1OfPnt2d & uvNodes = aTr->UVNodes(); - - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for(Standard_Integer i = 1; i < aNodes.Length()+1; i++) - aPoints(i) = aNodes(i).Transformed(aLocation); + TColgp_Array1OfPnt aPoints(1, aTr->NbNodes()); + for(Standard_Integer i = 1; i < aPoints.Size()+1; i++) + aPoints(i) = aTr->Node(i).Transformed(aLocation); Standard_Integer nnn = aTr->NbTriangles(); Standard_Integer nt,n1,n2,n3; for( nt = 1 ; nt < nnn+1 ; nt++) { - triangles(nt).Get(n1,n2,n3); + aTr->Triangle(nt).Get(n1,n2,n3); if (faceOrientation != TopAbs_Orientation::TopAbs_FORWARD) { diff --git a/triangle.h b/triangle.h index 79c18da..d2a477a 100644 --- a/triangle.h +++ b/triangle.h @@ -30,7 +30,7 @@ class Point { } }; -static ostream & operator << (ostream &out, const Point &p) +static std::ostream & operator << (std::ostream &out, const Point &p) { out << "[" << p.x() << "," << p.y() << "," << p.z() << "]"; return out; @@ -52,15 +52,15 @@ class Triangle { { ostrm << " " ; _p1.write_ascii_stl(ostrm); - ostrm << endl; + ostrm << std::endl; ostrm << " " ; _p2.write_ascii_stl(ostrm); - ostrm << endl; + ostrm << std::endl; ostrm << " " ; _p3.write_ascii_stl(ostrm); - ostrm << endl; + ostrm << std::endl; } };