[vtkusers] How to get bounds of each bounding box in vtkOBBTree
    Jothy 
    jothybasu at gmail.com
       
    Fri Sep  9 07:57:51 EDT 2011
    
    
  
Hi David,
As you suggested I have sub classed vtkOBBTree and add a new method
GeneratePolygons2 and call this function on GenerateRepresentation. The
class works fine. But I am a bit confused to get the bounds of the
individual boxes correctly.
I used pts->GetBounds() in Generatepolygons2, it prints the same bounds for
all levels.
For instance in the picute attached I want to get the bounds of each red box
seperatly.
See the code below
void myOBBTree::GeneratePolygons2(vtkOBBNode *OBBptr, int level, int
repLevel,vtkPoints *pts, vtkCellArray *polys)
{
    if ( level == repLevel || (repLevel < 0 && OBBptr->Kids == NULL) )
        {
        double x[3];
        vtkIdType cubeIds[8];
        vtkIdType ptIds[4];
        x[0] = OBBptr->Corner[0];
        x[1] = OBBptr->Corner[1];
        x[2] = OBBptr->Corner[2];
        cubeIds[0] = pts->InsertNextPoint(x);
        x[0] = OBBptr->Corner[0] + OBBptr->Axes[0][0];
        x[1] = OBBptr->Corner[1] + OBBptr->Axes[0][1];
        x[2] = OBBptr->Corner[2] + OBBptr->Axes[0][2];
        cubeIds[1] = pts->InsertNextPoint(x);
        x[0] = OBBptr->Corner[0] + OBBptr->Axes[1][0];
        x[1] = OBBptr->Corner[1] + OBBptr->Axes[1][1];
        x[2] = OBBptr->Corner[2] + OBBptr->Axes[1][2];
        cubeIds[2] = pts->InsertNextPoint(x);
        x[0] = OBBptr->Corner[0] + OBBptr->Axes[0][0] + OBBptr->Axes[1][0];
        x[1] = OBBptr->Corner[1] + OBBptr->Axes[0][1] + OBBptr->Axes[1][1];
        x[2] = OBBptr->Corner[2] + OBBptr->Axes[0][2] + OBBptr->Axes[1][2];
        cubeIds[3] = pts->InsertNextPoint(x);
        x[0] = OBBptr->Corner[0] + OBBptr->Axes[2][0];
        x[1] = OBBptr->Corner[1] + OBBptr->Axes[2][1];
        x[2] = OBBptr->Corner[2] + OBBptr->Axes[2][2];
        cubeIds[4] = pts->InsertNextPoint(x);
        x[0] = OBBptr->Corner[0] + OBBptr->Axes[0][0] + OBBptr->Axes[2][0];
        x[1] = OBBptr->Corner[1] + OBBptr->Axes[0][1] + OBBptr->Axes[2][1];
        x[2] = OBBptr->Corner[2] + OBBptr->Axes[0][2] + OBBptr->Axes[2][2];
        cubeIds[5] = pts->InsertNextPoint(x);
        x[0] = OBBptr->Corner[0] + OBBptr->Axes[1][0] + OBBptr->Axes[2][0];
        x[1] = OBBptr->Corner[1] + OBBptr->Axes[1][1] + OBBptr->Axes[2][1];
        x[2] = OBBptr->Corner[2] + OBBptr->Axes[1][2] + OBBptr->Axes[2][2];
        cubeIds[6] = pts->InsertNextPoint(x);
        x[0] = OBBptr->Corner[0] + OBBptr->Axes[0][0] + OBBptr->Axes[1][0]
               + OBBptr->Axes[2][0];
        x[1] = OBBptr->Corner[1] + OBBptr->Axes[0][1] + OBBptr->Axes[1][1]
               + OBBptr->Axes[2][1];
        x[2] = OBBptr->Corner[2] + OBBptr->Axes[0][2] + OBBptr->Axes[1][2]
               + OBBptr->Axes[2][2];
        cubeIds[7] = pts->InsertNextPoint(x);
        ptIds[0] = cubeIds[0]; ptIds[1] = cubeIds[2];
        ptIds[2] = cubeIds[3]; ptIds[3] = cubeIds[1];
        polys->InsertNextCell(4,ptIds);
        ptIds[0] = cubeIds[0]; ptIds[1] = cubeIds[1];
        ptIds[2] = cubeIds[5]; ptIds[3] = cubeIds[4];
        polys->InsertNextCell(4,ptIds);
        ptIds[0] = cubeIds[0]; ptIds[1] = cubeIds[4];
        ptIds[2] = cubeIds[6]; ptIds[3] = cubeIds[2];
        polys->InsertNextCell(4,ptIds);
        ptIds[0] = cubeIds[1]; ptIds[1] = cubeIds[3];
        ptIds[2] = cubeIds[7]; ptIds[3] = cubeIds[5];
        polys->InsertNextCell(4,ptIds);
        ptIds[0] = cubeIds[4]; ptIds[1] = cubeIds[5];
        ptIds[2] = cubeIds[7]; ptIds[3] = cubeIds[6];
        polys->InsertNextCell(4,ptIds);
        ptIds[0] = cubeIds[2]; ptIds[1] = cubeIds[6];
        ptIds[2] = cubeIds[7]; ptIds[3] = cubeIds[3];
        polys->InsertNextCell(4,ptIds);
        double bds[6];
        pts->GetBounds(bds);
       qDebug()<<bds[0]<<bds[1]<<bds[2]<<bds[3]<<bds[4]<<bds[5]<<"Level
Bounds1";
        }
On Wed, Aug 31, 2011 at 2:53 PM, David Doria <daviddoria at gmail.com> wrote:
> On Wed, Aug 31, 2011 at 9:09 AM, Jothy <jothybasu at gmail.com> wrote:
> > Thanks David,
> >
> > But I couldn't figure out how to get the bounds of the individual boxes.
> >
> > Jothy
>
> It looks like the GenerateRepresentation calls a (unfortunately
> protected) GeneratePolygons function. I don't think there is a built
> in way to get each box, but you could subclass OBBTree and call that
> function on your subclass object.
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110909/27ced30f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: untitled.JPG
Type: image/jpeg
Size: 30082 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110909/27ced30f/attachment.jpeg>
    
    
More information about the vtkusers
mailing list