[vtkusers] c# port of VTK

Bob Palank bob at stlcc.org
Mon Aug 2 15:11:17 EDT 2004


What a great project.  I for one, look forward to your first release.
BR
  Bob Palank

-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org]On
Behalf Of Andy Somogyi
Sent: Sunday, August 01, 2004 8:35 PM
To: vtkusers at vtk.org
Subject: [vtkusers] c# port of VTK


Hello VTK users

I am in the process of completly porting VTK (4.2) to c#.
As this is c#, it can be used nativly from any .net language.

When finished, it will be freely availble under the existing VTL lisence.

My question is this:

The c++ version of VTK uses length 3 arrays to represent a vector in 3
space.
This is fine in c++ because you can create arrays on the stack.

It is not possible to create a managed array in c# on the stack, they are
allways
heap allocated and garbage collected. So using a large number of managed
arrays, or
creating large numbers of transitory arrays is very inefficient.

The use of a 'value type' or a 'struct' in other words is far more effcient
when
large numbers of objects are involved as they are created on the stack and
are not
garbage collected.

I have thought about using a raw double pointer (double*) instead of an
managed array
for all functions that use a vector (double[3]). This has the advantage of
being very
fast, but on the other hand, it is highly error prone, and a user of one of
these functions
must declare thier method 'unsafe'. I would suspsct that this would
discourage many users.

There are many good vector and matrix classes avaible for .net, such as the
standard vector and
matrix types that ship with directx 9.

So my question to any perspective vtk.net users is would you prefer all
existing methods
that currently accept a c++ style array (double[3]) accept the following in
the new
c# port:

1: managed array (new double[3])
     advantages:
     1.1 farmiliar syntax
     1.2 do not have to declare 'unsafe' code
     disadvanteges:
     1.2 very ineffcient both in terms of size and performance

2: unmanaged pointer (double*)
     advanteges:
     2.1 very effecient
     disadvantes:
     2.2 error prone
     2.3 need to pin a managed array or use 'stackalloc'

3: use a 'Vector3' value type
     advanteges
     3.1 very effcient
     3.2 very safe
     3.3 easy to convert to and from a 'double*'
     disadvantes:
     3.3 introduces unfarmiliair syntax

Any ides or oppinions would be greatly appcieated

thanks



_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers





More information about the vtkusers mailing list