<div class="gmail_quote">On Mon, Mar 15, 2010 at 11:17 AM, Will Schroeder <span dir="ltr"><<a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi David-<div><br></div><div>I think we have to approach this in a series of steps, we may not be able to correctly solve the VTK_BIT problem immediately, but do something quick with an eye to fixing it longer term.</div>

<div>

<br></div><div>One option: since the writer doesn't work now let's do something quickly, documenting the fact (e.g. bug tracker, etc.) that long term we need to improve the support for VTK_BIT. (I would use VTK_UNSIGNED_CHAR myself which is half the size of VTK_SHORT assuming it works.)</div>



<div><br></div><div>Another option (and I am shooting from the hip here) is to do the minimal work in the reader/writer to get VTK_BIT "sort of" working meaning you may have to perform temporary conversions to and from VTK_BIT to another type, etc. which may cause temporary increases in memory.</div>



<div><br></div><div>I'm sure there are other opinions in the community about this...</div><div><br><font color="#888888">Will</font><div><div></div><div></div></div></div></blockquote></div><br><div>I tested vtkVoxelModeller using VTK_UNSIGNED_CHAR and it worked fine. I added the file to the bug report:</div>

<div><a href="http://public.kitware.com/Bug/view.php?id=10414" target="_blank">http://public.kitware.com/Bug/view.php?id=10414</a></div><div><br></div><div>I dug through the writer code for a while.</div><div><br></div><div>
In vtkXMLWriter.cxx I changed:</div><div><br></div><div><div>vtkXMLWriter::OffsetType vtkXMLWriter::GetWordTypeSize(int dataType)</div><div>{</div><div>  OffsetType size = 1;</div><div>  switch (dataType)</div><div>    {</div>
<div>    vtkTemplateMacro(</div><div>      size = vtkXMLWriterGetWordTypeSize(static_cast<VTK_TT*>(0))</div><div>      );</div><div>  case VTK_STRING:</div><div>    return sizeof(vtkStdString::value_type);</div><div>
  //case VTK_BIT: //doesn't work for some reason</div><div>  case 1: // VTK_BIT == 1</div><div>    return sizeof(bool);</div><div>  default:</div><div>      { vtkWarningMacro("Unsupported data type: " << dataType); } break;</div>
<div>    }</div><div>  return size;</div><div>}</div><div><br></div><div>in vtkXMLDataElement.cxx I changed:</div><div><br></div><div><div>int vtkXMLDataElement::GetWordTypeAttribute(const char* name, int& value)</div>
<div>{</div><div>  // These string values must match vtkXMLWriter::GetWordTypeName().</div><div>  const char* v = this->GetAttribute(name);</div><div>  if(!v)</div><div>    {</div><div>    vtkErrorMacro("Missing word type attribute \"" << name << "\".");</div>
<div>    return 0;</div><div>    }</div><div>  else if(strcmp(v, "Bit") == 0)</div><div>    {</div><div>    value = VTK_BIT;</div><div>    return 1;</div><div>    }</div></div></div><div><br></div><div>It seems to write the file without a problem now. However, when I try to read it, in vtkXMLDataReader.cxx </div>
<div><br></div><div><div>template <class iterT></div><div>int vtkXMLDataReaderReadArrayValues(vtkXMLDataElement* da,</div><div>  vtkXMLDataParser* xmlparser, vtkIdType arrayIndex,</div><div>  iterT* iter, vtkIdType startIndex, vtkIdType numValues)</div>
<div>{</div><div>  if (!iter)</div><div>    {</div><div>    return 0;</div><div>    }</div><div>  vtkAbstractArray* array = iter->GetArray();</div><div><br></div><div>'array' is null so then the code crashes. Maybe this could be a starting point for the next brave person?</div>
</div><div>
<br clear="all">Thanks,<br><br>David<br></div>