-
- vtkPoints points = new vtkPoints();
- for (int i = 0; i < mesh.getVertices().size(); i++) {
- Tuple3d p = mesh.getVertices().get(i);
- points.InsertPoint(i, p.x, p.y, p.z);
- }
-
- polyData.SetPoints(points);
- points.Delete();
-
- if (mesh.getColors() != null) {
- vtkUnsignedCharArray colors = new vtkUnsignedCharArray();
- colors.SetName("Colors");
- colors.SetNumberOfComponents(3);
- colors.SetNumberOfTuples(mesh.getColors().size());
- for (int i = 0; i < mesh.getColors().size(); i++) {
- Color4d c = mesh.getColors().get(i);
- colors.InsertTuple3(i, 255.0* c.x, 255.0 * c.y, 255.0 * c.z);
- }
- polyData.GetPointData().AddArray(colors);
- colors.Delete();
-
- }
- return polyData;
+ polyData.SetPoints(points);
+ points.Delete();
+
+ if (mesh.getNormals() != null) {
+ vtkFloatArray normals = new vtkFloatArray();
+ normals.SetNumberOfComponents(3);
+ normals.SetNumberOfTuples(mesh.getNormals().size());
+ for (int i = 0; i < mesh.getNormals().size(); i++) {
+ Tuple3d p = mesh.getNormals().get(i);
+ normals.InsertTuple3(i, p.x, p.y, p.z);
+ }
+ vtkPointData pointData = polyData.GetPointData();
+ pointData.SetNormals(normals);
+ normals.Delete();
+ pointData.Delete();
+ }
+ if (mesh.getColors() != null) {
+ vtkUnsignedCharArray colors = new vtkUnsignedCharArray();
+ colors.SetName("Colors");
+ colors.SetNumberOfComponents(3);
+ colors.SetNumberOfTuples(mesh.getColors().size());
+ for (int i = 0; i < mesh.getColors().size(); i++) {
+ Color4d c = mesh.getColors().get(i);
+ colors.InsertTuple3(i, 255.0* c.x, 255.0 * c.y, 255.0 * c.z);
+ }
+ polyData.GetPointData().AddArray(colors);
+ colors.Delete();
+
+ }
+ return polyData;