[vtkusers] Weird vtkClipPolyData error when using an *.obj

agerlach agerlach at gmail.com
Wed May 18 19:56:14 EDT 2011


All, I have a problem that has been driving me nuts. I have an application
that allows the user to select and load *.ply and *.obj files at
vtkPolyData. The user can then use the vtkImageTracerWidget to circle
regions on the 3D model and then compute the area of that region. This works
fine when I load a *.ply file, but if I use an *.obj file of the same 3D
scene I get the following errors:
ERROR: In ..\..\..\..\VTK-GIT\Graphics\vtkClipPolyData.cxx, line 175
vtkClipPolyData (00000000034E21E0): Cannot clip without clip function or
input scalars

ERROR: In ..\..\..\..\VTK-GIT\Graphics\vtkMassProperties.cxx, line 81
vtkMassProperties (00000000034E5AB0): No data to measure...!

I have my method for loading the model and for computing area attached
below.
This is driving me nuts. Is it a bug or am I missing something. I am open to
any alternatives for calculating area of a user circled or highlighted
region that may be better. Thanks.

void vtkHelper::loadModel(QString fileLoc)
{
    if(fileLoc.endsWith("ply"))
    {
        this->plyReader->SetFileName(fileLoc.toAscii());
        this->plyReader->Update();
        this->polyData = this->plyReader->GetOutput();
    }
    else if(fileLoc.endsWith("obj"))
    {
        this->objReader->SetFileName(fileLoc.toAscii());
        this->objReader->Update();
        this->polyData = this->objReader->GetOutput();

    }
}

double vtkHelper::calcSurfaceArea(vtkImageTracerWidget *trace)
{
    vtkSmartPointer<vtkPolyData> tracePolyData =
vtkSmartPointer<vtkPolyData>::New();
    trace->GetPath(tracePolyData);

    if(tracePolyData->GetNumberOfPoints() < 10)
        return -1;
    vtkSmartPointer<vtkSelectPolyData> loop =
vtkSmartPointer<vtkSelectPolyData>::New();
    loop->SetInput(this->polyData);
    loop->SetLoop(tracePolyData->GetPoints());
    loop->SetSelectionModeToSmallestRegion();
    loop->Update();
    
    vtkSmartPointer<vtkClipPolyData> clip =
vtkSmartPointer<vtkClipPolyData>::New();
    clip->SetInput(loop->GetOutput());
    clip->Update();

    vtkSmartPointer<vtkMassProperties> mass =
vtkSmartPointer<vtkMassProperties>::New();
    mass->SetInput(clip->GetOutput());

    return mass->GetSurfaceArea();
}


--
View this message in context: http://vtk.1045678.n5.nabble.com/Weird-vtkClipPolyData-error-when-using-an-obj-tp4408314p4408314.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list