[vtkusers] Creating a .dll with VTK.
ferluduena
xpelaox at gmail.com
Tue Jul 15 18:33:02 EDT 2014
Never mind, thanks a lot!
I got a simple sphere example working, but i'm having issues with the code
that was working on c++, i translated it so it compiles, but i get a run
time error saying it's trying to access (0,0,0) which is out of bounds.
Is there something i should know about the transition between c++ and c#?
this is my code.... i'm sure it must be something silly.
vtkPoints points = vtkPoints.New();
points.InsertNextPoint(p0[0],p0[1],p0[2]);
points.InsertNextPoint(p1[0],p1[1],p1[2]);
points.InsertNextPoint(p2[0],p2[1],p2[2]);
points.InsertNextPoint(p3[0],p3[1],p3[2]);
points.InsertNextPoint(p4[0],p4[1],p4[2]);
points.InsertNextPoint(p5[0],p5[1],p5[2]);
points.InsertNextPoint(p6[0],p6[1],p6[2]);
points.InsertNextPoint(p7[0],p7[1],p7[2]);
vtkPolyData polydata = vtkPolyData.New();
polydata.SetPoints(points);
// Construct the surface and create isosurface.
vtkSurfaceReconstructionFilter surf = vtkSurfaceReconstructionFilter.New();
surf.SetInput(polydata);
vtkContourFilter cf = vtkContourFilter.New();
cf.SetInputConnection(surf.GetOutputPort());
cf.SetValue(0, 0.0);
// Sometimes the contouring algorithm can create a volume whose gradient
// vector and ordering of polygon (using the right hand rule) are
// inconsistent. vtkReverseSense cures this problem.
vtkReverseSense reverse = vtkReverseSense.New();
reverse.SetInputConnection(cf.GetOutputPort());
reverse.ReverseCellsOn();
reverse.ReverseNormalsOn();
vtkPolyDataMapper map =vtkPolyDataMapper.New();
map.SetInputConnection(reverse.GetOutputPort());
map.ScalarVisibilityOff();
vtkActor surfaceActor = vtkActor.New();
surfaceActor.SetMapper(map);
vtkRenderWindow RenderWindow = renderWindowControl1.RenderWindow;
// get a reference to the renderer
vtkRenderer Renderer = RenderWindow.GetRenderers().GetFirstRenderer();
// set background color
Renderer.SetBackground(0.2, 0.3, 0.4);
// add actor to the renderer
Renderer.AddActor(surfaceActor);
// ensure all actors are visible (in this example not necessarely
needed,
// but in case more than one actor needs to be shown it might be a good
idea)
Renderer.ResetCamera();
--
View this message in context: http://vtk.1045678.n5.nabble.com/Creating-a-dll-with-VTK-tp5727853p5727870.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list