[vtk-developers] Mac java not returning zero-initialized objects

Dean Inglis dean.inglis at camris.ca
Thu Feb 24 11:40:17 EST 2011


Mark,

I have no idea about java but this will work:

double component_value = 0;
int nth_component = 0;
blankImage->GetPointData()->GetScalars()->FillComponent( nth_component , 
component_value );

Iterate over nth_component for multi-comps.

hth,
Dean



> I've found what I think is an interesting bug in the Java wrapping.
>
> According to the spec
> (http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.12.5),
> values in java should be initialized to zero.  However, when I create
> a new vtkImageData object, the contents are not zero.
>
> For instance, this method, used to make a mask on top of an existing
> vtkImageData object:
>
> public vtkImageData getBlankBinaryData(vtkImageData inImage){
>  vtkImageData blankImage = new vtkImageData();
>  int [] extent = inImage.GetWholeExtent();
>  double[] origin = inImage.GetOrigin();
>  double[] spacing = inimage.GetSpacing();
>  blankImage.SetExtent(extent);
>  blankImage.SetOrigin(origin);
>  blankImage.SetSpacing(spacing);
>  blankImage.SetScalarTypeToUnsignedChar();
>  blankImage.AllocateScalars();
>  return blankImage;
> }
>
> That above code returns an image that is set to zero on the PC, but
> contains a wide variety of values on the mac.
>
> This seems like an oversight in the wrapper.  What should I do to
> guarantee that a new vtkImageData contains only zeros?
>
> Thanks,
> Mark
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
> 




More information about the vtk-developers mailing list