[vtkusers] Possibly found a bug in vtkImplicitModeller.cxx

Roman Grothausmann roman.grothausmann at helmholtz-berlin.de
Mon Jul 16 05:13:26 EDT 2012


On 11.07.2012 19:12, Bill Lorensen wrote:
> The reason for expressing maximum distance as a percentage(fraction) of the
> bound box is to avoid specifying absolute distances.

I understand that. But then, what extend would I have to use to 
calculate the value for SetMaximumDistance to result in an absolute 
distance? Would it be the extent of the output in X or Y or Z? I could 
not find the position in the code where the transformation from relative 
to an absolute distance is done, which is, I belief, expected by both 
vtkCell->EvaluatePosition and 
vtkCellLocator->FindClosestPointWithinRadius. Could You point me to it? 
What value would I have to set with SetMaximumDistance if I wanted a 
result (32-bit real) which would correspond to a an absolute maximum 
distance of e.g. 0.5?

> Your patch should not be applied.

Disregarding the problem if MaximumDistance holds a relative or an 
absolute value, isn't maxDist *= this->MaximumDistance; in line 967 
causing maxDist to hold this->MaximumDistance squared?
In line 990 maxDist is assigned to this->InternalMaxDistance which in 
the end is squared again in  ConvertToDoubleDistance and then used in 
line 296 with cell->EvaluatePosition and in line 321 with 
locator->FindClosestPointWithinRadius, which I belief, both expect an 
absolute distance.

Anyway, if there is a way without my patch to make vtkImplicitModeller 
output a result  as if an absolute maximum distance were asked for (i.e. 
that the real-values in the output only reach up to e.g. 0.5 except the 
for the fill-value independent of the extent of the output), I'd be 
happy with that.

>
> On Wed, Jul 11, 2012 at 12:59 PM, Roman Grothausmann <
> roman.grothausmann at helmholtz-berlin.de> wrote:
>
>> On 11.07.2012 17:19, Bill Lorensen wrote:
>>
>>> The * should remain.
>>>
>>
>> But does that not lead to a MaximumDistance^4 in the actual calculation?
>> At least that is the maximum value I find in the output if stored in 32-bit
>> real.
>>
>>
>>   The value of MaximumDistance is clamped between 0 and
>>> 1. You can set it to 1000000 if you want, but internally it will be set to
>>> 1.0.
>>>
>>
>> I know, that's why  I changed vtkSetClampMacro(**
>> MaximumDistance,double,0.0,1.**0);
>> to
>> vtkSetMacro(MaximumDistance,**double);
>> (see patch below) and recompiled VTK. It works as I'd expect it, e.g. the
>> maximum value I find in the output is very close to 10 if stored in 32-bit
>> real and using SetMaximumDistance(10).
>>
>> -- VTK_orig/Hybrid/**vtkImplicitModeller.cxx     2012-05-12
>> 13:59:27.000000000 +0200
>> +++ VTK/Hybrid/**vtkImplicitModeller.cxx  2012-07-10 16:22:21.060066823
>> +0200
>>
>> @@ -967,7 +967,7 @@
>>         }
>>       }
>>
>> -  maxDist *= this->MaximumDistance;
>> +  maxDist = this->MaximumDistance;
>>
>>     // Set volume origin and data spacing
>>     output->SetOrigin(this->**ModelBounds[0],
>> --- VTK/Hybrid/**vtkImplicitModeller.h    2012-05-12 13:59:27.000000000
>> +0200
>> +++ /home/grothama/sda8/programme/**VTK/Hybrid/**vtkImplicitModeller.h
>> 2012-07-11 16:27:36.203103443 +0200
>> @@ -119,7 +119,8 @@
>>     // Description:
>>     // Set / get the distance away from surface of input geometry to
>>     // sample. Smaller values make large increases in performance.
>> -  vtkSetClampMacro(**MaximumDistance,double,0.0,1.**0);
>> +  //vtkSetClampMacro(**MaximumDistance,double,0.0,1.**0);
>> +  vtkSetMacro(MaximumDistance,**double);
>>     vtkGetMacro(MaximumDistance,**double);
>>
>>     // Description:
>>
>>   On Wed, Jul 11, 2012 at 10:38 AM, Roman Grothausmann <
>>> roman.grothausmann at helmholtz-**berlin.de<roman.grothausmann at helmholtz-berlin.de>>
>>> wrote:
>>>
>>>   Hello!
>>>>
>>>> It is clamped to be between 0 and 1 but in my tests does not behave as
>>>> being relative. If it were relative, it should surely not be squared.
>>>> Anyway, if You remove the '*' at line 967, the output contains only
>>>> values
>>>> up to the absolute value specified with SetMaximumDistance.
>>>> To my understanding, the value stored in MaximumDistance is used as an
>>>> absolute value in the code and corresponds to the units of the input.
>>>> I just tested removing the clamping and allowing any double value yields
>>>> an output reaching up to 10 if SetMaximumDistance(10) is used.
>>>> If You agree, I'd therefore suggest not only to remove the '*' but also
>>>> the clamping in the header file.
>>>>
>>>> Thanks for Your comments on this
>>>> Roman
>>>>
>>>>
>>>>
>>>> On 11.07.2012 14:37, Jothybasu Selvaraj wrote:
>>>>
>>>>   If the bounds are (for simplicity) equal on all side of 5.0, then if I
>>>>> set
>>>>> the MaxDistacne to 0.2 ; how it will be aclculated?
>>>>>
>>>>> Will it be 0.5+ (0.5*0.2)=0.6?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Jothy
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Jul 11, 2012 at 1:35 PM, Bill Lorensen <bill.lorensen at gmail.com
>>>>>> *
>>>>> *wrote:
>>>>>
>>>>>
>>>>>    The bounds of the model, either computed or supplied.
>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Jul 11, 2012 at 8:24 AM, Jothybasu Selvaraj <
>>>>>> jothybasu at gmail.com
>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>
>>>>>>    "MaximumDistance is a percentage"
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> % of what?
>>>>>>>
>>>>>>> Jothy
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Jul 11, 2012 at 1:10 PM, Bill Lorensen <
>>>>>>> bill.lorensen at gmail.com
>>>>>>>
>>>>>>>> **wrote:
>>>>>>>>
>>>>>>>
>>>>>>>    MaximumDistance is clamped to be within 0 and 1.
>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Jul 11, 2012 at 8:07 AM, Jothybasu Selvaraj <
>>>>>>>> jothybasu at gmail.com
>>>>>>>>
>>>>>>>>   wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>    So, for instance what does 10.0 mean?
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Is it multiplication of the bounds of vtkPolyData?
>>>>>>>>>
>>>>>>>>> with bounds [-5,5,-5,5,-5,5] the operation will be applied in
>>>>>>>>> [-50,50,-50,50,-50,50]
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>> Jothy
>>>>>>>>>
>>>>>>>>> On Wed, Jul 11, 2012 at 1:03 PM, Bill Lorensen <
>>>>>>>>> bill.lorensen at gmail.com
>>>>>>>>>
>>>>>>>>>   wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>    MaximumDistance is a percentage, not an absolute distance. The
>>>>>>>>>
>>>>>>>>>> documentation is not clear about this.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Wed, Jul 11, 2012 at 3:45 AM, Roman Grothausmann <
>>>>>>>>>> roman.grothausmann at helmholtz-****berlin.de<roman.grothausmann@**
>>>>>>>>>> helmholtz-berlin.de <roman.grothausmann at helmholtz-berlin.de>>>
>>>>>>>>>>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>    Dear mailing list members,
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Could it be that in vtkImplicitModeller.cxx there is a bug that
>>>>>>>>>>> causes the maximum distance (that is calculated and saved in the
>>>>>>>>>>> image) to
>>>>>>>>>>> be bigger than specified with SetMaximumDistance()?
>>>>>>>>>>>
>>>>>>>>>>>    From the description of the filter and its parameters and also
>>>>>>>>>>> from
>>>>>>>>>>> the comments in the source I would expect that the output stored
>>>>>>>>>>> in
>>>>>>>>>>> 32-bit
>>>>>>>>>>> real does not contain values above SetMaximumDistance() except for
>>>>>>>>>>> the
>>>>>>>>>>> "background" value.
>>>>>>>>>>>
>>>>>>>>>>> Having checked the source it seems to me that the squared distance
>>>>>>>>>>> was always very carefully assigned to a variable name ending with
>>>>>>>>>>> 2
>>>>>>>>>>> (e.g.
>>>>>>>>>>> maxDistance2). However at line 967 there is a *= assignment (see
>>>>>>>>>>> patch
>>>>>>>>>>> below). Removing the '*', the output image of the filter then
>>>>>>>>>>> fulfils my
>>>>>>>>>>> expectations mentioned above.
>>>>>>>>>>>
>>>>>>>>>>> Could the '*' be a bug?
>>>>>>>>>>>
>>>>>>>>>>> --- VTK_orig/Hybrid/******vtkImplicitModeller.cxx     2012-05-12
>>>>>>>>>>> 13:59:27.000000000 +0200
>>>>>>>>>>> +++ VTK/Hybrid/******vtkImplicitModeller.cxx  2012-07-10
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> 16:22:21.060066823 +0200
>>>>>>>>>>> @@ -967,7 +967,7 @@
>>>>>>>>>>>           }
>>>>>>>>>>>         }
>>>>>>>>>>>
>>>>>>>>>>> -  maxDist *= this->MaximumDistance;
>>>>>>>>>>> +  maxDist = this->MaximumDistance;
>>>>>>>>>>>
>>>>>>>>>>>       // Set volume origin and data spacing
>>>>>>>>>>>       output->SetOrigin(this->******ModelBounds[0],
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Happy coding
>>>>>>>>>>> Roman
>>>>>>>>>>>

-- 
Roman Grothausmann

Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
Bereich Funktionale Materialien
Institut für angewandte Materialforschung
Hahn-Meitner-Platz 1
D-14109 Berlin	

(früher Hahn-Meitner-Institut und BESSY)


Tel.: +49-(0)30-8062-42816
Fax.: +49-(0)30-8062-43059

Vorsitzender des Aufsichtsrats: Prof. Dr. Dr. h.c. mult. Joachim Treusch
Stellvertretende Vorsitzende: Dr. Beatrix Vierkorn-Rudolph
Geschäftsführer: Prof. Dr. Anke Rita Kaysser-Pyzalla, Dr. Ulrich Breuer
Sitz der Gesellschaft: Berlin
Handelsregister: AG Charlottenburg, 89 HRB 5583






More information about the vtkusers mailing list