[vtkusers] Activiz.Net System.AccessViolationException updating pipeline
Tristan Coulange
tristan.coulange at kitware.com
Mon Aug 22 08:52:21 EDT 2016
Hello,
Maybe the problem comes from the polydata generation:
- When you use "SetNumberOfPoints" then you have to use the method
"SetPoint" instead of "InsertPoint".
- It is the same for "SetNumberOfIds".
- For the vtkCellArray I suggest you just replace "SetNumberOfCells" by
"Allocate".
I hope it helps.
Tristan
2016-08-08 10:59 GMT+02:00 mirko heuegger <mheuegger at gmail.com>:
> Hello!
>
> I don't now if this helps, but errors like '.AccessViolations' are mostly
> (at least for activiz.net) the result of missing references to
> VTK-objects (cause the .net garbage collector may clean up objects that are
> still used by VTK).
> See also <http://www.vtk.org/pipermail/vtkusers/2011-February/066096.html
> >.
>
>
> hth
>
> mirko
>
> On Tue, Aug 2, 2016 at 10:16 PM, Karl Smith <bulkmailaddress at gmail.com>
> wrote:
>
>> 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);
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
>
>
> --
> Real programmers don't document; if it was
> hard to write, it should be hard to understand.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160822/53b8cc5f/attachment.html>
More information about the vtkusers
mailing list