Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VTK
VTK
Commits
6dee6fde
Commit
6dee6fde
authored
Nov 25, 2014
by
Dan Lipsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix KdTree::GenerateRepresentation and add test.
Change-Id: I15c9ecb05fc32bca7b4fd14bd0d88e76cf904929
parent
aec1c0b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
143 additions
and
3 deletions
+143
-3
Common/DataModel/Testing/Cxx/CMakeLists.txt
Common/DataModel/Testing/Cxx/CMakeLists.txt
+4
-0
Common/DataModel/Testing/Cxx/TestKdTreeRepresentation.cxx
Common/DataModel/Testing/Cxx/TestKdTreeRepresentation.cxx
+134
-0
Common/DataModel/Testing/Data/Baseline/TestKdTreeRepresentation.png.md5
...el/Testing/Data/Baseline/TestKdTreeRepresentation.png.md5
+1
-0
Common/DataModel/vtkKdTree.cxx
Common/DataModel/vtkKdTree.cxx
+4
-3
No files found.
Common/DataModel/Testing/Cxx/CMakeLists.txt
View file @
6dee6fde
...
@@ -50,8 +50,12 @@ vtk_add_test_cxx(${vtk-module}CxxTests data_tests
...
@@ -50,8 +50,12 @@ vtk_add_test_cxx(${vtk-module}CxxTests data_tests
TestCellIterators.cxx,NO_VALID,NO_OUTPUT
TestCellIterators.cxx,NO_VALID,NO_OUTPUT
TestQuadraticPolygonFilters.cxx
TestQuadraticPolygonFilters.cxx
)
)
vtk_add_test_cxx
(
${
vtk-module
}
CxxTests output_tests
TestKdTreeRepresentation.cxx,NO_DATA
)
set
(
all_tests
set
(
all_tests
${
tests
}
${
tests
}
${
data_tests
}
${
data_tests
}
${
output_tests
}
)
)
vtk_test_cxx_executable
(
${
vtk-module
}
CxxTests all_tests
)
vtk_test_cxx_executable
(
${
vtk-module
}
CxxTests all_tests
)
Common/DataModel/Testing/Cxx/TestKdTreeRepresentation.cxx
0 → 100644
View file @
6dee6fde
/*=========================================================================
Program: Visualization Toolkit
Module: TestKdTreeBoxSelection.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkGlyph3D.h"
#include "vtkInteractorStyleRubberBandPick.h"
#include "vtkKdTree.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkSphereSource.h"
#define VTK_CREATE(type,name) \
vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
int
TestKdTreeRepresentation
(
int
argc
,
char
*
argv
[])
{
double
glyphSize
=
0.05
;
const
vtkIdType
num_points
=
10
;
// random points generated on Linux (rand does not work the same on different
// platforms)
double
p
[
num_points
][
3
]
=
{
{
0.840188
,
0.394383
,
0.783099
},
{
0.79844
,
0.911647
,
0.197551
},
{
0.335223
,
0.76823
,
0.277775
},
{
0.55397
,
0.477397
,
0.628871
},
{
0.364784
,
0.513401
,
0.95223
},
{
0.916195
,
0.635712
,
0.717297
},
{
0.141603
,
0.606969
,
0.0163006
},
{
0.242887
,
0.137232
,
0.804177
},
{
0.156679
,
0.400944
,
0.12979
},
{
0.108809
,
0.998925
,
0.218257
}
};
// generate random points
VTK_CREATE
(
vtkPolyData
,
pointData
);
VTK_CREATE
(
vtkPoints
,
points
);
points
->
SetDataTypeToDouble
();
points
->
SetNumberOfPoints
(
num_points
);
pointData
->
Allocate
(
num_points
);
for
(
vtkIdType
i
=
0
;
i
<
num_points
;
++
i
)
{
points
->
SetPoint
(
i
,
p
[
i
]
);
pointData
->
InsertNextCell
(
VTK_VERTEX
,
1
,
&
i
);
}
pointData
->
SetPoints
(
points
);
// create a kdtree
VTK_CREATE
(
vtkKdTree
,
kdTree
);
kdTree
->
SetMinCells
(
1
);
kdTree
->
BuildLocatorFromPoints
(
points
);
// generate a kdtree representation
VTK_CREATE
(
vtkPolyData
,
kdTreeRepr
);
kdTree
->
GenerateRepresentation
(
/*kdTree->GetLevel()*/
2
,
kdTreeRepr
);
VTK_CREATE
(
vtkPolyDataMapper
,
kdTreeReprMapper
);
kdTreeReprMapper
->
SetInputData
(
kdTreeRepr
);
VTK_CREATE
(
vtkActor
,
kdTreeReprActor
);
kdTreeReprActor
->
SetMapper
(
kdTreeReprMapper
);
kdTreeReprActor
->
GetProperty
()
->
SetColor
(
1.0
,
1.0
,
1.0
);
kdTreeReprActor
->
GetProperty
()
->
SetRepresentationToWireframe
();
kdTreeReprActor
->
GetProperty
()
->
SetLineWidth
(
4
);
kdTreeReprActor
->
GetProperty
()
->
LightingOff
();
//
// Create vertex glyphs
//
VTK_CREATE
(
vtkSphereSource
,
sphere
);
sphere
->
SetRadius
(
glyphSize
);
VTK_CREATE
(
vtkGlyph3D
,
glyph
);
glyph
->
SetInputData
(
0
,
pointData
);
glyph
->
SetInputConnection
(
1
,
sphere
->
GetOutputPort
());
VTK_CREATE
(
vtkPolyDataMapper
,
glyphMapper
);
glyphMapper
->
SetInputConnection
(
glyph
->
GetOutputPort
());
VTK_CREATE
(
vtkActor
,
glyphActor
);
glyphActor
->
SetMapper
(
glyphMapper
);
//
// Set up render window
//
VTK_CREATE
(
vtkCamera
,
camera
);
vtkSmartPointer
<
vtkCamera
>::
New
();
camera
->
SetPosition
(
-
10
,
10
,
20
);
camera
->
SetFocalPoint
(
0
,
0
,
0
);
VTK_CREATE
(
vtkRenderer
,
ren
);
ren
->
AddActor
(
glyphActor
);
ren
->
AddActor
(
kdTreeReprActor
);
ren
->
SetActiveCamera
(
camera
);
ren
->
ResetCamera
();
VTK_CREATE
(
vtkRenderWindow
,
win
);
win
->
AddRenderer
(
ren
);
VTK_CREATE
(
vtkRenderWindowInteractor
,
iren
);
iren
->
SetRenderWindow
(
win
);
iren
->
Initialize
();
VTK_CREATE
(
vtkInteractorStyleRubberBandPick
,
interact
);
iren
->
SetInteractorStyle
(
interact
);
int
retVal
=
vtkRegressionTestImage
(
win
);
if
(
retVal
==
vtkRegressionTester
::
DO_INTERACTOR
)
{
iren
->
Start
();
retVal
=
vtkRegressionTester
::
PASSED
;
}
return
(
!
retVal
);
}
Common/DataModel/Testing/Data/Baseline/TestKdTreeRepresentation.png.md5
0 → 100644
View file @
6dee6fde
02da91d14495841c2bbed0a69dd35bc0
Common/DataModel/vtkKdTree.cxx
View file @
6dee6fde
...
@@ -3180,10 +3180,11 @@ void vtkKdTree::GenerateRepresentationWholeSpace(int level, vtkPolyData *pd)
...
@@ -3180,10 +3180,11 @@ void vtkKdTree::GenerateRepresentationWholeSpace(int level, vtkPolyData *pd)
level
=
this
->
Level
;
level
=
this
->
Level
;
}
}
int
npoints
=
0
;
// points and quads for level 0 bounding box
int
npolys
=
0
;
int
npoints
=
8
;
int
npolys
=
6
;
for
(
i
=
0
;
i
<
level
;
i
++
)
for
(
i
=
1
;
i
<
level
;
i
++
)
{
{
int
levelPolys
=
1
<<
(
i
-
1
);
int
levelPolys
=
1
<<
(
i
-
1
);
npoints
+=
(
4
*
levelPolys
);
npoints
+=
(
4
*
levelPolys
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment