Skip to content
Snippets Groups Projects
Commit bc756d65 authored by Astrid Beyer's avatar Astrid Beyer
Browse files

better off reader, off files

parent ac6fa7a2
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "vtkPointData.h" #include "vtkPointData.h"
#include "vtkPolyData.h" #include "vtkPolyData.h"
#include "vtkTriangle.h" #include "vtkTriangle.h"
#include "vtkQuad.h"
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
...@@ -143,6 +144,44 @@ int vtkOFFReader::RequestData( ...@@ -143,6 +144,44 @@ int vtkOFFReader::RequestData(
do do
{ {
std::stringstream ssFace; std::stringstream ssFace;
ssFace << line;
unsigned int NumFaceVerts, Vert0, Vert1, Vert2, Vert3;
ssFace >> NumFaceVerts >> Vert0 >> Vert1 >> Vert2 >> Vert3;
if (NumFaceVerts == 3) {
std::cout << "adding triangle: " << Vert0 << " " << Vert1 << " " << Vert2 << std::endl;
vtkTriangle *triangle = vtkTriangle::New();
triangle->GetPointIds()->SetId(0, Vert0);
triangle->GetPointIds()->SetId(1, Vert1);
triangle->GetPointIds()->SetId(2, Vert2);
polys->InsertNextCell(triangle);
triangle->Delete();
FaceCounter++;
} else if (NumFaceVerts == 4) {
// ssFace >> Vert3;
std::cout << "adding quad: " << Vert0 << " " << Vert1 << " " << Vert2 << " " << Vert3 << std::endl;
vtkQuad *quad = vtkQuad::New();
quad->GetPointIds()->SetId(0, Vert0);
quad->GetPointIds()->SetId(1, Vert1);
quad->GetPointIds()->SetId(2, Vert2);
quad->GetPointIds()->SetId(3, Vert3);
polys->InsertNextCell(quad);
quad->Delete();
FaceCounter++;
}
/**
*
* std::stringstream ssFace;
ssFace << line; ssFace << line;
unsigned int NumFaceVerts, Vert0, Vert1, Vert2; unsigned int NumFaceVerts, Vert0, Vert1, Vert2;
ssFace >> NumFaceVerts >> Vert0 >> Vert1 >> Vert2; ssFace >> NumFaceVerts >> Vert0 >> Vert1 >> Vert2;
...@@ -165,6 +204,10 @@ int vtkOFFReader::RequestData( ...@@ -165,6 +204,10 @@ int vtkOFFReader::RequestData(
FaceCounter++; FaceCounter++;
*
*/
} while (getline(in, line) && FaceCounter < NumberOfFaces); } while (getline(in, line) && FaceCounter < NumberOfFaces);
// we have finished with the file // we have finished with the file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment