Skip to content

Commit

Permalink
Make it compatible with opencascade 1:7.7.2-5
Browse files Browse the repository at this point in the history
Which is the current version available on archlinux.

Also add some missing includes and std:: qualification.
  • Loading branch information
johslarsen committed Apr 16, 2024
1 parent 801da20 commit 7014551
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 45 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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\

Expand Down
2 changes: 2 additions & 0 deletions explore-shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <TColgp_HArray1OfPnt.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <math.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <BRepAdaptor_Surface.hxx>


/* good resources:
Expand Down
2 changes: 1 addition & 1 deletion openscad-step-reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void show_help()

void show_version()
{
std::cout << 42 << endl;
std::cout << 42 << std::endl;
exit(0);
}

Expand Down
56 changes: 28 additions & 28 deletions openscad-triangle-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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;
}


Expand Down Expand Up @@ -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"<<i<<"_points = concat(tmp"<<(i-1)<<"_points, face_"<<i<<"_points);" << endl;
cout << " tmp"<<i<<"_faces = concat(tmp"<<(i-1)<<"_faces,add_offset(face_"<<i<<"_faces,len(tmp"<<(i-1)<<"_points)));" << endl;
cout << endl;
cout << " tmp"<<i<<"_points = concat(tmp"<<(i-1)<<"_points, face_"<<i<<"_points);" << std::endl;
cout << " tmp"<<i<<"_faces = concat(tmp"<<(i-1)<<"_faces,add_offset(face_"<<i<<"_faces,len(tmp"<<(i-1)<<"_points)));" << std::endl;
cout << std::endl;
}
cout << " polyhedron (tmp"<<(faces.size())<<"_points, tmp"<<(faces.size())<<"_faces);"<< endl;
cout << "}" << endl;
cout << endl;
cout << endl;

cout << "if ($preview) {;" << endl;
cout << " crazy_colors();" << endl;
cout << "} else {" << endl;
cout << " solid_object();" << endl;
cout << "}" << endl;
cout << " polyhedron (tmp"<<(faces.size())<<"_points, tmp"<<(faces.size())<<"_faces);"<< std::endl;
cout << "}" << std::endl;
cout << std::endl;
cout << std::endl;

cout << "if ($preview) {;" << std::endl;
cout << " crazy_colors();" << std::endl;
cout << "} else {" << std::endl;
cout << " solid_object();" << std::endl;
cout << "}" << std::endl;
}
12 changes: 4 additions & 8 deletions tessellation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,16 @@ Face tessellate_face(const TopoDS_Face &aFace)

if(!aTr.IsNull())
{
const TColgp_Array1OfPnt& aNodes = aTr->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)
{
Expand Down
8 changes: 4 additions & 4 deletions triangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

};
Expand Down

0 comments on commit 7014551

Please sign in to comment.