From 7014551383ab45eba65ea633af5c9ef0640e2782 Mon Sep 17 00:00:00 2001 From: Johannes Larsen Date: Sat, 16 Mar 2024 23:29:26 +0100 Subject: [PATCH 1/2] 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; } }; From eee3987cb8a1db2fe4ef8159ee77956b83827d6e Mon Sep 17 00:00:00 2001 From: "A. Craig West" Date: Wed, 3 Dec 2025 10:50:42 -0500 Subject: [PATCH 2/2] Make compatible with opencascade 1:7.9.2 This is the current stable version as of 2025-10-18 Cleaned up some usage of std namespace --- Makefile | 24 ++++------- explore-shape.cpp | 2 +- openscad-triangle-writer.cpp | 81 +++++++++++++++++------------------- 3 files changed, 49 insertions(+), 58 deletions(-) diff --git a/Makefile b/Makefile index 9f8c03c..9d4eff6 100644 --- a/Makefile +++ b/Makefile @@ -19,21 +19,15 @@ ## CPPFLAGS=-I/usr/include/opencascade -CXXFLAGS=-std=c++11 -g -O0 - -LDFLAGS=-lTKSTL -lTKXDESTEP -lTKBinXCAF -lTKXmlXCAF -lTKXDEIGES -lTKXCAF \ - -lTKIGES -lTKSTEP -lTKSTEP209 -lTKSTEPAttr -lTKSTEPBase -lTKXSBase \ - -lTKStd -lTKStdL -lTKXml -lTKBin -lTKXmlL -lTKBinL -lTKCAF -lTKXCAF \ - -lTKLCAF -lTKCDF -lTKMeshVS -lTKOpenGl -lTKV3d -lTKService \ - -lTKXMesh -lTKMesh -lTKOffset -lTKFeat -lTKFillet -lTKHLR -lTKBool \ - -lTKBO -lTKShHealing -lTKPrim -lTKTopAlgo -lTKGeomAlgo -lTKBRep \ - -lTKGeomBase -lTKG3d -lTKG2d -lTKIGES -lTKSTEP -lTKSTEP209 \ - -lTKSTEPAttr -lTKSTEPBase -lTKXSBase -lTKStd -lTKStdL -lTKXml \ - -lTKBin -lTKXmlL -lTKBinL -lTKCAF -lTKLCAF -lTKCDF -lTKMeshVS \ - -lTKOpenGl -lTKV3d -lTKService -lTKXMesh -lTKMesh -lTKOffset \ - -lTKFeat -lTKFillet -lTKHLR -lTKBool -lTKBO -lTKShHealing \ - -lTKPrim -lTKTopAlgo -lTKGeomAlgo -lTKBRep -lTKGeomBase \ - -lTKG3d -lTKG2d -lTKMath -lTKernel\ +CXXFLAGS=-std=c++17 -g -O0 + +LDFLAGS=-lTKBin -lTKBinL -lTKBinXCAF -lTKBO -lTKBool -lTKBRep \ + -lTKCAF -lTKCDF -lTKDEIGES -lTKDESTEP -lTKDESTL -lTKernel \ + -lTKFeat -lTKFillet -lTKG2d -lTKG3d -lTKGeomAlgo -lTKGeomBase \ + -lTKHLR -lTKLCAF -lTKMath -lTKMesh -lTKMeshVS -lTKOffset \ + -lTKOpenGl -lTKPrim -lTKService -lTKShHealing -lTKStd -lTKStdL \ + -lTKTopAlgo -lTKV3d -lTKXCAF -lTKXMesh -lTKXml -lTKXmlL \ + -lTKXmlXCAF -lTKXSBase \ \ -lfreetype -lpthread -lrt -lstdc++ -ldl -lm\ diff --git a/explore-shape.cpp b/explore-shape.cpp index 7b26e5f..211bfda 100644 --- a/explore-shape.cpp +++ b/explore-shape.cpp @@ -98,7 +98,7 @@ void get_vertex_points_test1 (const TopoDS_Shape& shape) TopTools_IndexedMapOfShape vertices; TopExp::MapShapes(shape,TopAbs_VERTEX,vertices); - Handle_TColgp_HArray1OfPnt result = new TColgp_HArray1OfPnt(1,vertices.Extent()); + Handle(TColgp_HArray1OfPnt) result = new TColgp_HArray1OfPnt(1,vertices.Extent()); for(Standard_Integer i = 1;i<=vertices.Extent();i++) { diff --git a/openscad-triangle-writer.cpp b/openscad-triangle-writer.cpp index 19a32cd..01b6f80 100644 --- a/openscad-triangle-writer.cpp +++ b/openscad-triangle-writer.cpp @@ -19,17 +19,14 @@ #include "triangle.h" -using namespace std; - - /* Write the faces/triangles as an ASCII stl file (with invalud 'normals' value - but these are ignored anyhow in OpenSCAD */ void write_triangles_ascii_stl(const Face_vector& faces) { - cout << "solid" << std::endl; + std::cout << "solid" << std::endl; for (auto &f : faces) - f.write_ascii_stl(cout); - cout << "endsolid" << std::endl; + f.write_ascii_stl(std::cout); + std::cout << "endsolid" << std::endl; } /* Write the faces/triangles as two vectors (one "POINTS", one "FACES") @@ -44,17 +41,17 @@ void write_triangle_scad(const Face_vector& faces) all.add_face(f); // Write vector of points and faces - cout << "points = " ; - all.write_points_vector(cout); - cout << "faces = "; - all.write_face_vector(cout); + std::cout << "points = " ; + all.write_points_vector(std::cout); + std::cout << "faces = "; + all.write_face_vector(std::cout); // Call Polyhedron - cout << "module solid_object() {" << std::endl; - cout << " polyhedron (points,faces);"<< std::endl; - cout << "}" << std::endl; - cout << std::endl; - cout << "solid_object();" << std::endl; + std::cout << "module solid_object() {" << std::endl; + std::cout << " polyhedron (points,faces);"<< std::endl; + std::cout << "}" << std::endl; + std::cout << std::endl; + std::cout << "solid_object();" << std::endl; } @@ -90,41 +87,41 @@ void write_faces_scad (const Face_vector& faces) { int i = 1; for (auto &f : faces) { - cout << "face_" << i << "_points = " ; - f.write_points_vector(cout); - cout << "face_" << i << "_faces = " ; - f.write_face_vector(cout); - cout << endl ; + std::cout << "face_" << i << "_points = " ; + f.write_points_vector(std::cout); + std::cout << "face_" << i << "_faces = " ; + f.write_face_vector(std::cout); + std::cout << std::endl ; ++i; } /* crazy colors version, draw each face by itself */ - cout << "module crazy_colors() {" << std::endl; + std::cout << "module crazy_colors() {" << std::endl; for (i=1;i<=faces.size();++i) { const char* color = colors[i%NUM_COLORS] ; - cout << "color(\"" << color << "\")" << std::endl; - cout << "polyhedron(face_" << i <<"_points, face_" << i << "_faces);" << endl ; + std::cout << "color(\"" << color << "\")" << std::endl; + std::cout << "polyhedron(face_" << i <<"_points, face_" << i << "_faces);" << std::endl ; } - cout << "}" << std::endl; + std::cout << "}" << std::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; + std::cout << "function add_offset(vec,ofs) = [for (x=vec) x + [ofs,ofs,ofs]];" << std::endl; + std::cout << "module solid_object() {" << std::endl; + std::cout << " tmp1_points = face_1_points;" << std::endl; + std::cout << " tmp1_faces = face_1_faces;" << std::endl; + std::cout << std::endl; for (i=2;i<=faces.size();++i) { - cout << " tmp"<