[vtkusers] Problem of writing vtp file

Chenxi Zhang chenxizhang at fudan.edu.cn
Thu Aug 15 23:45:42 EDT 2013


HI
  
   Thanks,Bill.


Following http://vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataPointNormals, I can find normals in vtp, but the Range is too large:  
<DataArray type="Float64" Name="Normals_" NumberOfComponents="3" format="appended" RangeMin="1"                    RangeMax="1.0872842531e+067"    offset="0"  />


How can set the range small like "RangeMin="0.9999999539"         RangeMax="1.0000000487"" 


Besides, there is still no vtkOriginalPointIds like:
<DataArray type="Int32" Name="vtkOriginalPointIds" format="appended" RangeMin="0"                    RangeMax="128448"               offset="1541392"             />
      
 
My code is as following:   
 
     vtkSmartPointer<vtkPoints> pointsSource = 
  vtkSmartPointer<vtkPoints>::New();  
       ......


     vtkPolyData* pointsTemp=vtkPolyData::New();
     pointsTemp->SetPoints(pointsSource);


  //Set point normals
     vtkSmartPointer<vtkDoubleArray> pointNormalsArray = 
     vtkSmartPointer<vtkDoubleArray>::New();
     pointNormalsArray->SetNumberOfComponents(3); //3d normals (ie x,y,z)
     pointNormalsArray->SetNumberOfTuples(pointsTemp->GetNumberOfPoints());


  // Construct the normal vectors
    double pN1[3] = {1.0, 0.0, 0.0};
    double pN2[3] = {0.0, 1.0, 0.0};
    double pN3[3] = {0.0, 0.0, 1.0};
  
  // Add the data to the normals array
    pointNormalsArray->SetTuple(0, pN1) ;
    pointNormalsArray->SetTuple(1, pN2) ;
    pointNormalsArray->SetTuple(2, pN3) ;
  
  // Add the normals to the points in the polydata
    pointsTemp->GetPointData()->SetNormals(pointNormalsArray);


    vtkSmartPointer<vtkXMLPolyDataWriter> writerTemp3 =
    vtkSmartPointer<vtkXMLPolyDataWriter>::New();
  
    writerTemp3->SetInput(pointsTemp);
    writerTemp3->SetFileName("test3.vtp");
    writerTemp3->Write();


     Thank you very much!


Chenxi


-----原始邮件-----
发件人: "Bill Lorensen" <bill.lorensen at gmail.com>
发送时间: 2013年8月16日 星期五
收件人: "Chenxi Zhang" <chenxizhang at fudan.edu.cn>
抄送: "VTK Users" <vtkusers at vtk.org>
主题: Re: Re: [vtkusers] Problem of writing vtp file


See:
http://vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataPointNormals






On Thu, Aug 15, 2013 at 10:29 PM, Chenxi Zhang <chenxizhang at fudan.edu.cn> wrote:

HI,
 
   my result vtp file is as following:



<?xml version="1.0"?>
<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian" compressor="vtkZLibDataCompressor">
  <PolyData>
    <Piece NumberOfPoints="9617"                 NumberOfVerts="0"                    NumberOfLines="0"                    NumberOfStrips="0"                    NumberOfPolys="0"                   >
      <PointData>
      </PointData>
      <CellData>
      </CellData>
      <Points>
        <DataArray type="Float32" Name="Points" NumberOfComponents="3" format="appended" RangeMin="63.129833223"         RangeMax="85.854495209"         offset="0"                   />
      </Points>
      <Verts>
        <DataArray type="Int32" Name="connectivity" format="appended" RangeMin=""                     RangeMax=""                     offset="27368"               />
        <DataArray type="Int32" Name="offsets" format="appended" RangeMin=""                     RangeMax=""                     offset="27384"               />
      </Verts>
      <Lines>
        <DataArray type="Int32" Name="connectivity" format="appended" RangeMin=""                     RangeMax=""                     offset="27400"               />
        <DataArray type="Int32" Name="offsets" format="appended" RangeMin=""                     RangeMax=""                     offset="27416"               />
      </Lines>
      <Strips>
        <DataArray type="Int32" Name="connectivity" format="appended" RangeMin=""                     RangeMax=""                     offset="27432"               />
        <DataArray type="Int32" Name="offsets" format="appended" RangeMin=""                     RangeMax=""                     offset="27448"               />
      </Strips>
      <Polys>
        <DataArray type="Int32" Name="connectivity" format="appended" RangeMin=""                     RangeMax=""                     offset="27464"               />
        <DataArray type="Int32" Name="offsets" format="appended" RangeMin=""                     RangeMax=""                     offset="27480"               />
      </Polys>
    </Piece>
  </PolyData>
  <AppendedData encoding="base64">


my vtp file missed the information:
 
        <PointData Normals="Normals">
        <DataArray type="Float32" Name="Normals" NumberOfComponents="3" format="appended" RangeMin="0.9999999539"         RangeMax="1.0000000487"         offset="0"                   />
        <DataArray type="Int32" Name="vtkOriginalPointIds" format="appended" RangeMin="0"                    RangeMax="128448"               offset="1541392"             />
      


   How can I add the normal information?  In the example http://vtk.org/Wiki/VTK/Examples/Cxx/IO/WriteVTP, the method for adding normal is not mentioned. 


    Thanks


Chenxi
       





-----原始邮件-----
发件人: "Bill Lorensen" <bill.lorensen at gmail.com>
发送时间: 2013年8月16日 星期五
收件人: "Chenxi Zhang" <chenxizhang at fudan.edu.cn>
抄送: "VTK Users" <vtkusers at vtk.org>
主题: Re: [vtkusers] Problem of writing vtp file



What is wrong with the file create?





On Thu, Aug 15, 2013 at 12:43 PM, Chenxi Zhang <chenxizhang at fudan.edu.cn> wrote:
HI

   I have a set of points.I want to creat a vtp file like that:

 <VTKFile type="PolyData" version="0.1" byte_order="LittleEndian">
  <PolyData>
    <Piece NumberOfPoints="128449"               NumberOfVerts="128449"               NumberOfLines="0"                    NumberOfStrips="0"                    NumberOfPolys="0"                   >
      <PointData Normals="Normals">
        <DataArray type="Float32" Name="Normals" NumberOfComponents="3" format="appended" RangeMin="0.9999999539"         RangeMax="1.0000000487"         offset="0"                   />
        <DataArray type="Int32" Name="vtkOriginalPointIds" format="appended" RangeMin="0"                    RangeMax="128448"               offset="1541392"             />
      </PointData>
      <CellData>
      </CellData>
      <Points>
        <DataArray type="Float32" Name="Points" NumberOfComponents="3" format="appended" RangeMin="0.0080462906331"      RangeMax="0.11603941536"        offset="2055192"             />
      </Points>
      <Verts>
        <DataArray type="Int32" Name="connectivity" format="appended" RangeMin=""                     RangeMax=""                     offset="3596584"             />
        <DataArray type="Int32" Name="offsets" format="appended" RangeMin=""                     RangeMax=""                     offset="4110384"             />
      </Verts>
      <Lines>
        <DataArray type="Int32" Name="connectivity" format="appended" RangeMin=""                     RangeMax=""                     offset="4624184"             />
        <DataArray type="Int32" Name="offsets" format="appended" RangeMin=""                     RangeMax=""                     offset="4624188"             />
      </Lines>
      <Strips>
        <DataArray type="Int32" Name="connectivity" format="appended" RangeMin=""                     RangeMax=""                     offset="4624192"             />
        <DataArray type="Int32" Name="offsets" format="appended" RangeMin=""                     RangeMax=""                     offset="4624196"             />
      </Strips>
      <Polys>
        <DataArray type="Int32" Name="connectivity" format="appended" RangeMin=""                     RangeMax=""                     offset="4624200"             />
        <DataArray type="Int32" Name="offsets" format="appended" RangeMin=""                     RangeMax=""                     offset="4624204"             />
      </Polys>
    </Piece>
  </PolyData>
  <AppendedData encoding="raw">
    
   I followed the example:
   http://vtk.org/Wiki/VTK/Examples/Cxx/IO/WriteVTP,
   but I can't creat the vtp like the above.

   Could you please tell me what went wrong?

   Thanks a lot.

Chenxi



_______________________________________________
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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers





-- 
Unpaid intern in BillsBasement at noware dot com








-- 
Unpaid intern in BillsBasement at noware dot com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130816/586356d8/attachment.htm>


More information about the vtkusers mailing list