[vtkusers] display oriented points?

Chen, Elvis anisotropic7 at yahoo.ca
Mon Apr 19 11:08:54 EDT 2004


hi,

thx.  After several hours of reading on-line manuals,
I came to a similar solution.  The following is my
code in python.  It parses a text file, and whenever
it encounters a line of 6-tuples (x, y, z, xv, yv,
zv), it  enters it into a vtkPolyData.

    # read some points.  Use a programmable filter to
read them
    pointSource = vtkProgrammableSource()

    def readPoints():
        output = pointSource.GetPolyDataOutput()
        points = vtkPoints()
        vectors = vtkDoubleArray()
        vectors.SetNumberOfComponents( 3 )
        output.SetPoints( points )
        output.GetPointData().SetVectors( vectors )
        
        fp = str( sys.argv[1] )
        file = open( fp )

        line = file.readline()

        
        while line:
            data = string.split(line)
            if ( len(data) == 6 ):
                x, y, z = float(data[0]),
float(data[1]), float(data[2])
                points.InsertNextPoint( x, y, z )
                x, y, z = float(data[3]),
float(data[4]), float(data[5])
                vectors.InsertNextTuple3( x, y, z )
            line = file.readline()
        print "Total number of points: "
        print points.GetNumberOfPoints()
        
    pointSource.SetExecuteMethod( readPoints )

 

--- ALIZIER Julien AUSY <julien.alizier-ausy at irsn.fr>
wrote: > Hi,
> 
> You can use vectorial point data to store your
> normal.
> 
> Try something like this :
> 
> vtkDoubleArray * normalArray =
> vtkDoubleArray::New();
> normalArray->SetName("Normals");
> normalArray->SetNumberOfComponents(3);
> normalArray->SetNumberOfTuples(nbPoints);
> for (int p = 0; p < nbPoints; p++)
> {
> 	double normal[3] = your_calculated_normal
> 	normalArray->SetTuple(p, normal);
> }
> yourPolyData->GetPointData()->AddArray(normalArray);
> 
> 
> HTH
> 
> -- Julien
> 
> 
> -----Message d'origine-----
> De : Chen, Elvis [mailto:anisotropic7 at yahoo.ca]
> Envoyé : jeudi 15 avril 2004 22:27
> À : vtkusers at vtk.org; anisotropic7 at yahoo.ca
> Objet : [vtkusers] display oriented points?
> 
> 
> hi,
> 
> feeling stupid today, so please take it easy if my
> question seem to be trivial.
> 
> I want to display a set of points and oriented them
> according to the point normal.  I have a file with
> each line of the format being:
> 
> x, y, z, xv, yv, zv
> 
> I know I should use Glyph3D for this, and use (say)
> vtkConeSource for the orientation.  Glyph3D uses
> vtkPolyData for the geometry, and I can enter the
> coordinate (x, y, z) using vtkPolyData->SetPoints.
> 
> But where do I put the normal (xv, yv, zv)
> information
> in vtkPolyData?
> 
> thx,
> 
>
______________________________________________________________________
> 
> Post your free ad now! http://personals.yahoo.ca
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers 

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca



More information about the vtkusers mailing list