SV: [vtkusers] c# port of VTK

Lars Overgaard lov at mikrofyn.com
Tue Aug 3 02:59:10 EDT 2004


Hi Andy,

I will stay out of the discussion of why you should do (or not do) your
project and just answer your initial question.

I have experienced the huge overhead introduced by garbage collection
and
managed code. I write embedded applications and need both speed and
(close to)
real-time response.

My preference would definitely be choice no. 3: use a 'Vector3' value
type.
I wouldn't hardly notice the slightly changed syntax - and the
alternative
choices would simply kill my applications.

So, Andy, I encourage you to continue your interesting project using a
'Vector3' value type.

Good luck! Please let us know how your work is progressing.

Best regards,

Lars Overgaard
Software Engineer, Ph.D.
MIKROFYN A/S
* E-mail: lov at mikrofyn.com
: Web:     www.mikrofyn.com
( Phone: +45 66170784
( Direct: +45 63170510
h Fax:     +45 66170785
 


-----Oprindelig meddelelse-----
Fra: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] På vegne
af Andy Somogyi
Sendt: 2. august 2004 02:35
Til: vtkusers at vtk.org
Emne: [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