View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001629VTK(No Category)public2005-03-01 13:492016-08-12 09:54
ReporterMathieu Malaterre 
Assigned ToDave DeMarle 
PrioritylowSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001629: vtkOBBTree Inside
Descriptionhttp://public.kitware.com/pipermail/vtkusers/2003-May/067563.html [^]
import vtk.*;

// Program to test that vtkOBBTree.InserOrOutside has a bug, because when I create
// some points and test if they are inside a surface, sometimes it says that it is
// true, but if you draw the points then it seems not is true.

public class InsideOutsideTest {

    static {
        System.loadLibrary("vtkCommonJava");
        System.loadLibrary("vtkIOJava");
        System.loadLibrary("vtkGraphicsJava");
        System.loadLibrary("vtkRenderingJava");
    };

    public static void main(String[] args) {
        if (args.length > 0) {
            int n = 100;
            if (args.length > 1) {
                try {
                    n = Integer.valueOf(args[1]).intValue();
                } catch (NumberFormatException e) {}
            }

            // Read the surface
            vtkPolyDataReader reader = new vtkPolyDataReader();
            reader.SetFileName(args[0]);
            reader.Update();

            vtkPolyData surface = reader.GetOutput();

// vtkConeSource source = new vtkConeSource();
// vtkSphereSource source = new vtkSphereSource();
// vtkCubeSource source = new vtkCubeSource();
// vtkCylinderSource source = new vtkCylinderSource();
// source.Update();

// vtkPolyData surface = source.GetOutput();

            // Build the OBBTree to test random points
            vtkOBBTree obbTree = new vtkOBBTree();
            obbTree.SetDataSet(surface);
            obbTree.SetMaxLevel(10);
            obbTree.BuildLocator();

            // Create the points polydata
            vtkPolyData points = new vtkPolyData();
            points.SetPoints(new vtkPoints());
            points.SetVerts(new vtkCellArray());

            // Points are located inside surface bounds
            double[] bb = surface.GetBounds();
            for (int i = 0; i < n; i++) {

                // Get a new random point
                double[] point = new double[3];
                point[0] = bb[0] + Math.random() * (bb[1] - bb[0]);
                point[1] = bb[2] + Math.random() * (bb[3] - bb[2]);
                point[2] = bb[4] + Math.random() * (bb[5] - bb[4]);

                // Get new random points while they are not inside the surface
                while (obbTree.InsideOrOutside(point) != -1) {
                    point[0] = bb[0] + Math.random() * (bb[1] - bb[0]);
                    point[1] = bb[2] + Math.random() * (bb[3] - bb[2]);
                    point[2] = bb[4] + Math.random() * (bb[5] - bb[4]);
                }

                // Add the point to the polydata
                points.GetPoints().InsertNextPoint(point);
                points.GetVerts().InsertNextCell(1);
                points.GetVerts().InsertCellPoint(i);
            }

            // Create the surface actor
            vtkPolyDataMapper surfaceMapper = new vtkPolyDataMapper();
            surfaceMapper.SetInput(surface);
            vtkLODActor surfaceActor = new vtkLODActor();
            surfaceActor.SetMapper(surfaceMapper);

            // Create the OBBTree actor
            vtkPolyData obb = new vtkPolyData();
            obbTree.GenerateRepresentation(5, obb);
            vtkPolyDataMapper obbMapper = new vtkPolyDataMapper();
            obbMapper.SetInput(obb);
            vtkActor obbActor = new vtkActor();
            obbActor.SetMapper(obbMapper);
            obbActor.GetProperty().SetColor(1.0, 0.0, 0.0);
            obbActor.GetProperty().SetRepresentationToWireframe();

            // Create the points actor (using glyphs)
            vtkSphereSource glyph = new vtkSphereSource();
            glyph.SetRadius(0.1);
            glyph.SetPhiResolution(3);
            glyph.SetThetaResolution(3);

            vtkGlyph3D glyphs = new vtkGlyph3D();
            glyphs.SetInput(points);
            glyphs.SetSource(glyph.GetOutput());
            glyphs.Update();

            vtkPolyDataMapper pointsMapper = new vtkPolyDataMapper();
            pointsMapper.SetInput(points);
// pointsMapper.SetInput(glyphs.GetOutput());
            vtkLODActor pointsActor = new vtkLODActor();
            pointsActor.SetMapper(pointsMapper);
            pointsActor.GetProperty().SetColor(1.0, 1.0, 0.0);

            // Create the renderer and add the actors
            vtkRenderer renderer = new vtkRenderer();
            renderer.AddActor(surfaceActor);
            renderer.AddActor(obbActor);
            renderer.AddActor(pointsActor);

            // Create the window
            vtkRenderWindow window = new vtkRenderWindow();
            window.AddRenderer(renderer);
            window.SetSize(500, 500);

            // Create the interactor
            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow(window);
            iren.Initialize();
            iren.Start();
        } else {
            System.out.println("Error: \"InsideOutsideTest <filename (byu files)> [npoints]\"");
        }
    }
}
TagsNo tags attached.
Project
Type
Attached Files

 Relationships

  Notes
(0030937)
Jean-Christophe Fillion-Robin (manager)
2013-06-05 17:07

Does the problem still occur with VTK 5.10 ? VTK 6 ?
(0031209)
Dave DeMarle (administrator)
2013-07-22 19:05

If the bug is still present in 6.0, please reopen.
(0036772)
Kitware Robot (administrator)
2016-08-12 09:54

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2008-11-30 09:22 Mathieu Malaterre Assigned To Mathieu Malaterre => David Cole
2011-01-19 10:14 David Cole Assigned To David Cole =>
2011-06-16 13:11 Zack Galbreath Category => (No Category)
2013-06-05 17:07 Jean-Christophe Fillion-Robin Note Added: 0030937
2013-07-22 19:05 Dave DeMarle Note Added: 0031209
2013-07-22 19:05 Dave DeMarle Status backlog => expired
2013-07-22 19:05 Dave DeMarle Assigned To => Dave DeMarle
2016-08-12 09:54 Kitware Robot Note Added: 0036772
2016-08-12 09:54 Kitware Robot Status expired => closed
2016-08-12 09:54 Kitware Robot Resolution open => moved


Copyright © 2000 - 2018 MantisBT Team