Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +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 \
\
/usr/lib/x86_64-linux-gnu/libTKMath.so.7.3.0 \
/usr/lib/x86_64-linux-gnu/libTKernel.so.7.3.0 \
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\

Expand Down
4 changes: 3 additions & 1 deletion 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 Expand Up @@ -96,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++)
{
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
81 changes: 39 additions & 42 deletions openscad-triangle-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" << endl;
std::cout << "solid" << std::endl;
for (auto &f : faces)
f.write_ascii_stl(cout);
cout << "endsolid" << endl;
f.write_ascii_stl(std::cout);
std::cout << "endsolid" << std::endl;
}

/* Write the faces/triangles as two vectors (one "POINTS", one "FACES")
Expand All @@ -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() {" << endl;
cout << " polyhedron (points,faces);"<< endl;
cout << "}" << endl;
cout << endl;
cout << "solid_object();" << 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;
}


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

std::cout << "if ($preview) {;" << std::endl;
std::cout << " crazy_colors();" << std::endl;
std::cout << "} else {" << std::endl;
std::cout << " solid_object();" << std::endl;
std::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