<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    El 30/03/11 12:46, David Doria escribió:
    <blockquote
      cite="mid:AANLkTi=1BSb72FOSetLoEgemsq9Y_FptJy6WBTd6-2F1@mail.gmail.com"
      type="cite">
      <div class="gmail_quote">On Wed, Mar 30, 2011 at 6:48 AM, Eduardo
        Suarez-Santana <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:esuarez@itccanarias.org">esuarez@itccanarias.org</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          In vtk-5.6.1/Graphics/MarchingCubes.cxx:<br>
          <br>
          499     vtkDoubleArray *image=vtkDoubleArray::New();<br>
          500    
          image->SetNumberOfComponents(inScalars->GetNumberOfComponents());<br>
          501    
          image->SetNumberOfTuples(image->GetNumberOfComponents()*dataSize);<br>
          502     inScalars->GetTuples(0,dataSize,image);<br>
          503<br>
          504     double *scalars = image->GetPointer(0);<br>
          <br>
          I think it should be:<br>
          <br>
          499     vtkDoubleArray *image=vtkDoubleArray::New();<br>
          500    
          image->SetNumberOfComponents(inScalars->GetNumberOfComponents());<br>
          501     image->SetNumberOfTuples(dataSize);       //changed<br>
          502     inScalars->GetTuples(0,dataSize-1,image);  //
          changed<br>
          503<br>
          504     double *scalars = image->GetPointer(0);<br>
          <br>
        </blockquote>
        <div> </div>
        <meta http-equiv="content-type" content="text/html;
          charset=ISO-8859-1">
        Why do you think that? Do you have a test that fails the old way
        and passes the new way?<br>
        <br>
        <div>David </div>
      </div>
    </blockquote>
    <br>
    IMHO it is a "semantic" bug.<br>
    <br>
    It makes no sense because:<br>
    <br>
    1) It reserves too much memory (501).<br>
    <br>
    dataSize*numComps tuples, that is, dataSize*numComps*numComps
    elements.<br>
    <br>
    However,<br>
    <br>
    dataSize tuples, that is, dataSize*numComps elements is enough.<br>
    <br>
    2) it is getting tuples beyond inScalars range (502).<br>
    <br>
    inScalars are the Scalars of the vtkImageData input, of size
    dataSize, so dataSize tuples are expected. Accessing vtkIdType
    number dataSize is out of range.<br>
    <br>
    Moreover:<br>
    <br>
    3) It does not fail the new way, at least in my cases.<br>
    <br>
    And anyway,<br>
    <br>
    4) (504) is providing weird input to marching cubes.<br>
    <br>
    GetPointer(0), for a multiple component image, provides a pointer to
    a mix of components and tuples. Getting the first dataSize elements
    of the array (coded in variable dims, call in line 505) is going to
    mix components and tuples making a nosense input:<br>
    <br>
    505    
vtkMarchingCubesComputeGradient(this,scalars,dims,origin,spacing,this->Locator,<br>
    506                   newScalars,newGradients,<br>
    507                   newNormals,newPolys,values,numContours);<br>
    <br>
    <br>
  </body>
</html>