[vtkusers] SPAM-LOW: How to use vtkMath functions in ActiViz.NET for data of type double?

Mark DeArman mark at cascadeacoustic.com
Wed Nov 8 23:04:47 EST 2017


I looked into it, it appears no ActiViz wrapper was generated for the 
double overload.
 Most likely other functions which are overloaded for both float and double 
will have the same issue.  I would highly recommend building sections of 
code which are going to require significant passing of data between managed 
and unmanaged memory as a C++ DLL and use pinvoke to call the function on 
the pinned arrays.
  
   Mark DeArman
 Cascade Acoustic Research
 http://www.cascadeacoustic.com
 (253) 200-5353

  

----------------------------------------
 From: "csumushu" <csumushu at 126.com>
Sent: Wednesday, November 8, 2017 5:23 PM
To: vtkusers at vtk.org
Subject: SPAM-LOW: [vtkusers] How to use vtkMath functions in ActiViz.NET 
for data of type double?   
Hello, guys and ladies
Is there anybody using ActiViz.NET? I am confused about using vtkMath
functions in ActiViz.NET. Take Distance2BetweenPoints as an example, with
double type data can not get the correct result,but it is OK to use float
type.

The following code is from
http://lorensen.github.io/VTKExamples/site/CSharp/SimpleOperations/DistanceB
etweenPoints/
<http://lorensen.github.io/VTKExamples/site/CSharp/SimpleOperations/Distance
BetweenPoints/>

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Kitware.VTK;

void DistanceBetweenPoints() {
// Create two points.
double[] p0 = new double[] { 0.0, 0.0, 0.0 };
double[] p1 = new double[] { 1.0, 1.0, 1.0 };

IntPtr pP0 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double)) * 3);
IntPtr pP1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double)) * 3);
Marshal.Copy(p0, 0, pP0, 3);
Marshal.Copy(p1, 0, pP1, 3);

// Find the squared distance between the points.
double squaredDistance = vtkMath.Distance2BetweenPoints(pP0, pP1);

// Take the square root to get the Euclidean distance between the points.
double distance = Math.Sqrt(squaredDistance);

// Output the results.
Console.WriteLine("SquaredDistance = " + squaredDistance);
Console.WriteLine("Distance = " + distance);
Marshal.FreeHGlobal(pP0);
Marshal.FreeHGlobal(pP1);
}

The result is SquaredDistance = 3.515625, Distance = 1.875 with double 
type,
and SquaredDistance = 3, Distance = 1.73205080756888 for float.

Can anyone tell me where the problem is?

--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171108/5d1c6646/attachment.html>


More information about the vtkusers mailing list