[vtkusers] Activiz.Net System.AccessViolationException updating pipeline

Karl Smith bulkmailaddress at gmail.com
Tue Aug 2 16:16:29 EDT 2016


Hi,
I'm using Activiz.Net x64 5.8 from the nuget package.  We are looking to
replace WPF graphics with VTK.  What we are trying to do as a starting
point is convert some WPF MeshGeometry3D objects into vtkPolyData and
display them.  This is working fine and we could see and interact with the
models.

The only problem was that the models looked faceted (WPF calculated the
normals automatically and VTK did not).  We went back to add in the
vtkPolyDataNormals filter, but are consistently receiving
System.AccessVioloationExceptions when executing the pipeline.  I have put
together the following code snippet to demonstrate the problem.  If called
twice (with the same data), the second time results in the exception being
thrown on the normal.Update() call.

vtkPoints points = vtkPoints.New();
vtkCellArray polys = vtkCellArray.New();
... populate points and polys ...

vtkPolyData polyData = vtkPolyData.New();
polyData.SetPoints(points);
polyData.SetPolys(polys);
vtkPolyDataNormals normal = vtkPolyDataNormals.New();
normal.SetInput(polyData);
normal.Update();

Any ideas?

Could this behavior be from the way that we convert the MeshGeometry3D to
vtkPolyData?

                        MeshGeometry3D mesh = ...

                        vtkPoints points = vtkPoints.New();
                        points.SetNumberOfPoints(mesh.Positions.Count);
                        vtkCellArray polys = vtkCellArray.New();
                        polys.SetNumberOfCells(mesh.TriangleIndices.Count /
3);

                        for (int i = 0; i < mesh.Positions.Count; i++)
                        {
                            points.InsertPoint(i, mesh.Positions[i].X,
mesh.Positions[i].Y, mesh.Positions[i].Z);
                        }
                        for (int i = 0; i < mesh.TriangleIndices.Count; i++)
                        {
                            vtkIdList trianglePoints = vtkIdList.New();
                            trianglePoints.SetNumberOfIds(3);
                            trianglePoints.InsertId(0,
mesh.TriangleIndices[i++]);
                            trianglePoints.InsertId(1,
mesh.TriangleIndices[i++]);
                            trianglePoints.InsertId(2,
mesh.TriangleIndices[i]);
                            polys.InsertNextCell(trianglePoints);
                        }

                        vtkPolyData polyData = vtkPolyData.New();
                        polyData.SetPoints(points);
                        polyData.SetPolys(polys);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160802/6a3fb76b/attachment.html>


More information about the vtkusers mailing list