[vtk-developers] [VTK 0013714]: vtkModifiedBSPTree IntersectWithLine does not work when VTK built in RELEASE mode
Mantis Bug Tracker
mantis at public.kitware.com
Fri Dec 7 16:29:03 EST 2012
The following issue has been SUBMITTED.
======================================================================
http://vtk.org/Bug/view.php?id=13714
======================================================================
Reported By: David Doria
Assigned To:
======================================================================
Project: VTK
Issue ID: 13714
Category: (No Category)
Reproducibility: have not tried
Severity: minor
Priority: normal
Status: backlog
Project: TBD
Type: incorrect functionality
Resolution: open
Fixed in Version:
======================================================================
Date Submitted: 2012-12-07 16:29 EST
Last Modified: 2012-12-07 16:29 EST
======================================================================
Summary: vtkModifiedBSPTree IntersectWithLine does not work
when VTK built in RELEASE mode
Description:
The vtkModifiedBSPTree IntersectWithLine works if VTK is built in DEBUG mode,
but not RELEASE mode. I have attached a screenshot of the scenario to show that
the line clearly intersects the object. The demo code is:
#include <vtkSmartPointer.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
#include <vtkCellArray.h>
#include <vtkMath.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkModifiedBSPTree.h>
#include <fstream>
#include <limits>
#include <sstream>
int main(int, char *[])
{
// Read the scene geometry
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName("corner.vtp");
reader->Update();
double p0[3] = {0, 0, 0};
double p1[3] = {22.2073, -15.8678, -96.2032};
vtkSmartPointer<vtkModifiedBSPTree> tree =
vtkSmartPointer<vtkModifiedBSPTree>::New();
tree->SetDataSet(reader->GetOutput());
tree->BuildLocator();
float tolerance = .001;
double t;
double x[3];
double pcoords[3];
int subId = 0;
vtkIdType cellId = 0;
std::cout << "Casting ray between " << p0[0] << " " << p0[1] << " " << p0[2]
<< " and " << p1[0] << " " << p1[1] << " " << p1[2] << std::endl;
// Perform the intersection using the tree
int treeHit = tree->IntersectWithLine(p0, p1, tolerance, t, x, pcoords, subId,
cellId);
std::cout << "tree hit? " << treeHit << std::endl;
if(treeHit)
{
std::cout << "tree intersection " << x[0] << " " << x[1] << " " << x[2] <<
std::endl;
}
// Do the intersection manually (not using the tree)
unsigned int numberOfManualHits = 0;
bool manualHit = false;
for(vtkIdType cellIndex = 0; cellIndex <
reader->GetOutput()->GetNumberOfCells(); ++cellIndex)
{
vtkIdType intersect =
reader->GetOutput()->GetCell(cellIndex)->IntersectWithLine(p0, p1, tolerance, t,
x, pcoords, cellId);
if(intersect)
{
manualHit = true;
break;
}
}
if(manualHit)
{
std::cout << "manual intersection " << x[0] << " " << x[1] << " " << x[2] <<
std::endl;
numberOfManualHits++;
}
std::cout << "manual hit? " << manualHit << std::endl;
return EXIT_SUCCESS;
}
The output when VTK was built in DEBUG mode is (correctly):
Casting ray between 0 0 0 and 22.2073 -15.8678 -96.2032
tree hit? 1
tree intersection 0.279686 -0.199844 -1.21162
manual intersection 0.279686 -0.199844 -1.21162
manual hit? 1
However, the output when VTK was built in RELEASE mode is (incorrectly):
Casting ray between 0 0 0 and 22.2073 -15.8678 -96.2032
tree hit? 0
manual intersection 0.279686 -0.199844 -1.21162
manual hit? 1
We see here that the tree indicates that there was no intersection, when there
should have been one.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2012-12-07 16:29 David Doria New Issue
2012-12-07 16:29 David Doria File Added: demo.tar.gz
======================================================================
More information about the vtk-developers
mailing list