Skip to content
Snippets Groups Projects
Commit 5b243b4d authored by Vladimír Ulman's avatar Vladimír Ulman
Browse files

Added ActiveMesh::ExportSTL().

parent a999f2d0
No related branches found
No related tags found
No related merge requests found
......@@ -181,6 +181,28 @@ int ActiveMesh::ImportSTL(const char *filename)
return(0);
}
int ActiveMesh::ExportSTL(const char *filename)
{
//try to open the file
std::ofstream file(filename);
if (!file.is_open()) return(1);
file << "solid Vladimir Ulman - meshSurface testing app\n";
for (unsigned int i=0; i < ID.size(); i+=3)
{
file << "facet normal " << norm[i/3].x << " " << norm[i/3].y << " " << norm[i/3].z << "\n";
file << "outer loop\n";
file << "vertex " << Pos[ID[i+0]].x << " " << Pos[ID[i+0]].y << " " << Pos[ID[i+0]].z << "\n";
file << "vertex " << Pos[ID[i+1]].x << " " << Pos[ID[i+1]].y << " " << Pos[ID[i+1]].z << "\n";
file << "vertex " << Pos[ID[i+2]].x << " " << Pos[ID[i+2]].y << " " << Pos[ID[i+2]].z << "\n";
file << "endloop\nendfacet\n";
}
file.close();
return(0);
}
int ActiveMesh::ImportVTK(const char *filename) //surface version
{
......
......@@ -96,6 +96,7 @@ class ActiveMesh
///input is filename
///returns 0 on success, otherwise non-zero
int ImportSTL(const char* filename);
int ExportSTL(const char* filename);
int ImportVTK(const char* filename);
int ImportVTK_Volumetric(const char* filename);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment