No subject


Wed May 9 12:08:04 EDT 2012


swapped = ((num>>24)&0xff) | // move byte 3 to byte 0
                    ((num<<8)&0xff0000) | // move byte 1 to byte 2
                    ((num>>8)&0xff00) | // move byte 2 to byte 1
                    ((num<<24)&0xff000000 // byte 0 to byte 3

Call something like this on each word in your buffer before or while
you write it to switch endians.

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Fri, Aug 17, 2012 at 12:16 PM, Hal Canary <hal at cs.unc.edu> wrote:
> The legacy VTK formats are agnostic with respect to endinaness, which is one
> reason why I almost never use the binary versions of them.
>
> If you can't link to VTK and use vtkXMLImageDataWriter, as David suggested,
> then another option is to write a small C++ or Python program to convert
> from legacy ASCII to XML binary.  For example:
>   http://www.paraview.org/Wiki/Convert_a_File_from_LegacyVTK_to_VTI
>
>
>
> On 08/17/2012 10:45 AM, Kharche, Sanjay wrote:
>>
>>
>> Thanks for the suggestion. However, I cannot incorporate any
>> dependencies into my code. Since posting my message, I have
>> discovered that I can put a text header (similar to VTK ASCII) and
>> then the data in binary into the output files. The problem (if there
>> a problem!) has now evolved to getting the binary fwrite to be big
>> endian - or is there another way?
>>
>>
>> On 17 August 2012 14:02, David Doria wrote:
>
>>
>>
>> > Why don't you construct VTK objects and use a VTK writer to write
>> > the file?
>> >
>> > Something like this:
>> > http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/XMLStructuredGridWriter
>> >
>> >  It seems like you are reinventing the wheel a little bit by
>> > actually formatting the file to VTK file format specifications
>> > manually.
>
>
> _______________________________________________
> Powered by 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 ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview


More information about the ParaView mailing list