<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY>
Hi everybody, <BR>
i have a vtkUnstructuredGrid that comes from a terrestrial laserscanner aquisition.<BR>
I would like to form a vtkImageData object projecting the points onto a user defined plane, using some of the point data as scalar value.<BR>
<BR>
For doing that i think i can use something like this (in python):<BR>
<BR>
def Grid2vtkImageData(grid, delta = 1):<BR>
        #get infos on grid position/rotation<BR>
        x,y,z = grid.Getxyz().T # <--- Those are some additional methods i wrote for the vtkUnstructuredGridObjects<BR>
        normal = BestFitPlaneEig(x,y,z)<BR>
        <BR>
        #best view axis<BR>
        ax = np.abs(normal) == np.max(np.abs(normal)) * 1 <BR>
        <BR>
        #if it is not the x axis, rotate the cloud<BR>
        if (ax == [0,1,0]).any():<BR>
                grid.RotateZ(90) <BR>
                <BR>
        elif (ax == [0,0,1]).any():<BR>
                grid.RotateY(90)<BR>
                <BR>
        ### NOW the cloud is viewed from X-axis<BR>
        #infos on bounds etc<BR>
        minx, maxx, miny, maxy, minz, maxz = grid.GetBounds()<BR>
        deltay = maxy - miny<BR>
        y_dimension = int(np.fix(deltay/delta) + 1)<BR>
        <BR>
        deltaz = maxz - minz<BR>
        z_dimension = int(np.fix(deltaz/delta) + 1)<BR>
        <BR>
        #Create the imagedata object<BR>
        image = vtk.vtkImageData()<BR>
        image.SetScalarTypeToFloat()<BR>
        image.SetDimensions([y_dimension,z_dimension,1])<BR>
        image.SetOrigin(miny, minz, 0)<BR>
        image.SetSpacing(delta, delta, 1)<BR>
        image.AllocateScalars()<BR>
        return image<BR>
<BR>
<BR>
At this point i have encountered 2 problems:<BR>
<BR>
1. i need to fast-locate the points within the pixel/voxel. Is there any conveninet way for doing that? I could use a vtkKDTree, but i would need something like a "FindPointsWithinBox" function :-)<BR>
<BR>
2. I would cycle through all the pixels, but i think that for big datasets this will be too slow (in pure python....). Any other chance??<BR>
<BR>
I could use the ProjectPoint function of vtkPlane for projecting all points onto my specified plane. But the problem of structurating the dataset is not solved in this way, neither the problem of locating points inside pixels.<BR>
<BR>
same sage advice???<BR>
<BR>
<BR>
Thank you<BR>
<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
--
---------------------------
Luca Penasa
Student at Geosciences Dpt.
University of Padua (IT)
<A HREF="mailto:luca.penasa@email.it">luca.penasa@email.it</A>
---------------------------
</PRE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>