[vtkusers] Curve / Equal Subdivision
Jerome Velut
jerome.velut at kitware.com
Thu Jul 12 10:53:35 EDT 2012
Hi,
Bill, your script solved Jean-Hugues' issue with vtk-5.10 and vtk-6.0.
Jean-Hugues, could it be a mistake in your c# translation?
Jerome
Le 12/07/2012 15:09, Jean-Hugues Royer a écrit :
> Hi,
>
> I converted it to Activiz/C#, I will let Jerome try exactly your code
> (since I can't).
>
> Regards.
>
> On 12/07/2012 14:49, Bill Lorensen wrote:
>> In the example I sent? I happen to be running VTK6, but there should
>> not have been changes.
>>
>> On Thu, Jul 12, 2012 at 8:35 AM, Jean-Hugues Royer <jhroyer at joher.com
>> <mailto:jhroyer at joher.com>> wrote:
>>
>> Hi,
>>
>> If I do that, the first ~30 points have a distance of 1 and the
>> rest 0.18648.
>>
>> Regards.
>>
>>
>> On 12/07/2012 14:12, Bill Lorensen wrote:
>>> The splines are parameterized by an approximation to the arc
>>> length. Also, the boundary conditions of the splines can affect
>>> the shape of the spline. Try this version of the script:
>>>
>>> #!/usr/bin/python
>>> import vtk
>>>
>>> lineSource = vtk.vtkLineSource( )
>>> lineSource.SetPoint1( 0, 0, 0 )
>>> lineSource.SetPoint2( 95, 0 ,0 )
>>> lineSource.Update( )
>>>
>>> mySpline = vtk.vtkCardinalSpline( )
>>> mySpline.SetLeftConstraint(2)
>>> mySpline.SetLeftValue(0.0)
>>> mySpline.SetRightConstraint(2)
>>> mySpline.SetRightValue(0.0)
>>>
>>> spline = vtk.vtkSplineFilter( )
>>> spline.SetSpline(mySpline)
>>> spline.SetInputConnection( lineSource.GetOutputPort( ))
>>> spline.SetSubdivideToLength( )
>>> spline.SetLength( 0.18648 )
>>> spline.Update( )
>>>
>>> points = spline.GetOutput().GetPoints()
>>>
>>> meanDist = 0
>>>
>>> for i in range( 1, points.GetNumberOfPoints() ):
>>> pt = points.GetPoint(i)
>>> ptPrec = points.GetPoint(i-1)
>>> meanDist += pt[0] - ptPrec[0]
>>> print 'pt[',i,'] X: ',pt[0],' | Distance with previous
>>> point:',pt[0] - ptPrec[0]
>>>
>>> print 'Mean distance: ', meanDist / points.GetNumberOfPoints()
>>> print 'Expected number of points: ', 95./0.18648
>>> print 'Effective number of points: ', points.GetNumberOfPoints()
>>>
>>>
>>>
>>> On Thu, Jul 12, 2012 at 3:06 AM, Jerome Velut
>>> <jerome.velut at kitware.com <mailto:jerome.velut at kitware.com>> wrote:
>>>
>>> Hi Bill and Jean-Hugues,
>>>
>>> I was able to reproduce the bug for a straight line with
>>> vtk-5.10 python (script attached). I also get the same
>>> spline from paraview by exposing the vtkSplineFilter
>>> (hopefully!).
>>>
>>> Jerome
>>>
>>> Le 10/07/2012 19:09, Bill Lorensen a écrit :
>>>> It is always possible that there is a bug.
>>>>
>>>> Can you provide a small, compilable example that
>>>> illustrates the problem?
>>>>
>>>> On Tue, Jul 10, 2012 at 10:50 AM, Jean-Hugues Royer
>>>> <jhroyer at joher.com <mailto:jhroyer at joher.com>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I also tried vtkSplineFIlter using
>>>> SetSubdivideToLength() and SetLength(distance).
>>>>
>>>> But the result is that the points are not equally
>>>> distributed.
>>>>
>>>> When you provide a curve the beginning and ending
>>>> points are not equally distributed while the center
>>>> points are.
>>>>
>>>> When you provide a straight line no points at all are
>>>> equally distributed.
>>>>
>>>> I get exact same result when using
>>>> vtkSplineFIlter/SetSubdivideToLength/SetLength and
>>>> vtkParametricSpline/SetParametricFunction/SetUResolution.
>>>>
>>>> May be I'm missing something ?
>>>>
>>>>
>>>> On 10/07/2012 16:21, Bill Lorensen wrote:
>>>>> Look at vtkSplineFIlter
>>>>> Here is one use:
>>>>> http://vtk.org/Wiki/VTK/Examples/Cxx/PolyData/FitSplineToCutterOutput
>>>>>
>>>>>
>>>>> On Tue, Jul 10, 2012 at 9:59 AM, Jean-Hugues Royer
>>>>> <jhroyer at joher.com <mailto:jhroyer at joher.com>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I have a curve which is a vtkPoints array.
>>>>>
>>>>> I would like to generate another vtkPoints array
>>>>> where every consecutive points have the same
>>>>> distance. (basically divide the curve to n equals
>>>>> segments)
>>>>>
>>>>> I tried to use
>>>>> vtkParametricSpline/vtkParametricFunctionSource
>>>>> but I was only able to change the number of points
>>>>> to another value but I didn't find how to specify
>>>>> that these new points should be equally distributed.
>>>>>
>>>>> Any idea ?
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com <http://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
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Unpaid intern in BillsBasement at noware dot com
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Unpaid intern in BillsBasement at noware dot com
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Powered bywww.kitware.com <http://www.kitware.com>
>>>>
>>>> Visit other Kitware open-source projects athttp://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the VTK FAQ at:http://www.vtk.org/Wiki/VTK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>> --
>>> Jérôme Velut
>>> R&D Engineer
>>> Kitware SAS
>>> 26 rue Louis Guérin
>>> 69100 Villeurbanne, France
>>> F:+33 (0)4.37.45.04.15 <tel:%2B33%20%280%294.37.45.04.15>
>>> http://www.kitware.fr
>>>
>>>
>>>
>>>
>>> --
>>> Unpaid intern in BillsBasement at noware dot com
>>>
>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com
>>
--
Jérôme Velut
R&D Engineer
Kitware SAS
26 rue Louis Guérin
69100 Villeurbanne, France
F: +33 (0)4.37.45.04.15
http://www.kitware.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120712/b5d992d1/attachment.htm>
More information about the vtkusers
mailing list