Skip to content

Instantly share code, notes, and snippets.

@hb3p8
Created Dec 14, 2015
Embed
What would you like to do?
WriteMesh
void BRepMesh_RestoreOrientationTool::WriteMesh (const std::string& theFileName)
{
// write obj file
std::ofstream myfile;
myfile.open (theFileName);
const Handle(BRepMesh_TriangulatedPatch)& aPatch = myPatches.back();
for (int i = 0; i < aPatch->Vertices.size(); ++i) {
BVH_Vec3d aVert = aPatch->Vertices[i];
myfile << "v " << aVert.x() << " " << aVert.y() << " " << aVert.z() << "\n";
}
for (int i = 0; i < aPatch->Elements.size(); ++i) {
BVH_Vec4i aTriangle = aPatch->Elements[i];
if (aTriangle.w() >= 0) {
myfile << "f " << aTriangle.x() + 1 << " " << aTriangle.y() + 1 << " " << aTriangle.z() + 1 << "\n";
}
else {
myfile << "f " << aTriangle.z() + 1 << " " << aTriangle.y() + 1 << " " << aTriangle.x() + 1 << "\n";
}
}
myfile.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment