Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
56f9168a
Commit
56f9168a
authored
Sep 08, 2013
by
Ozan Tonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support VTK 6.0.0: cmakelist.txt might need to be refactored
parent
26005a19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
71 additions
and
4 deletions
+71
-4
creating_widgets.rst
doc/tutorials/viz/creating_widgets.rst
+4
-0
CMakeLists.txt
modules/viz/CMakeLists.txt
+8
-1
cloud_widgets.cpp
modules/viz/src/cloud_widgets.cpp
+33
-1
shape_widgets.cpp
modules/viz/src/shape_widgets.cpp
+0
-0
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+4
-0
viz3d_impl.hpp
modules/viz/src/viz3d_impl.hpp
+4
-0
widget.cpp
modules/viz/src/widget.cpp
+14
-2
creating_widgets.cpp
samples/cpp/tutorial_code/viz/creating_widgets.cpp
+4
-0
No files found.
doc/tutorials/viz/creating_widgets.rst
View file @
56f9168a
...
...
@@ -74,7 +74,11 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/
// Create mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(polyData);
#else
mapper->SetInputData(polyData);
#endif
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
...
...
modules/viz/CMakeLists.txt
View file @
56f9168a
...
...
@@ -13,6 +13,9 @@ endmacro()
macro
(
find_vtk
)
find_package
(
VTK 5.10.0 REQUIRED
)
if
(
NOT VTK_FOUND
)
find_package
(
VTK 6.0.0 REQUIRED
)
endif
()
if
(
VTK_FOUND
)
if
(
BUILD_SHARED_LIBS
OR
(
NOT BUILD_SHARED_LIBS AND NOT VTK_BUILD_SHARED_LIBS
))
find_qvtk
()
...
...
@@ -43,7 +46,11 @@ include_directories(src)
ocv_define_module
(
viz opencv_core
)
if
(
DEFINED BUILD_opencv_viz AND BUILD_opencv_viz AND DEFINED HAVE_VTK AND HAVE_VTK
)
target_link_libraries
(
opencv_viz vtkCommon vtkWidgets vtkFiltering vtkRendering
)
if
(
${
VTK_VERSION_MAJOR
}
EQUAL 5
)
target_link_libraries
(
opencv_viz vtkCommon vtkWidgets vtkFiltering vtkRendering
)
else
()
target_link_libraries
(
opencv_viz vtkViewsCore vtkRenderingLOD vtkIOPLY vtkRenderingFreeTypeOpenGL vtkRenderingVolumeOpenGL vtkFiltersTexture
)
endif
()
if
(
APPLE
)
target_link_libraries
(
opencv_viz
"-framework Cocoa"
)
endif
()
...
...
modules/viz/src/cloud_widgets.cpp
View file @
56f9168a
...
...
@@ -175,7 +175,11 @@ cv::viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors)
polydata
->
GetPointData
()
->
SetScalars
(
scalars
);
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
mapper
->
SetInput
(
polydata
);
#else
mapper
->
SetInputData
(
polydata
);
#endif
Vec3d
minmax
(
scalars
->
GetRange
());
mapper
->
SetScalarRange
(
minmax
.
val
);
...
...
@@ -206,7 +210,11 @@ cv::viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
vtkSmartPointer
<
vtkPolyData
>
polydata
=
CreateCloudWidget
::
create
(
cloud
,
nr_points
);
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
mapper
->
SetInput
(
polydata
);
#else
mapper
->
SetInputData
(
polydata
);
#endif
bool
interpolation
=
(
polydata
&&
polydata
->
GetNumberOfCells
()
!=
polydata
->
GetNumberOfVerts
());
...
...
@@ -327,7 +335,11 @@ struct cv::viz::CloudCollectionWidget::CreateCloudWidget
{
// This is the first cloud
vtkSmartPointer
<
vtkDataSetMapper
>
mapper_new
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
mapper_new
->
SetInputConnection
(
poly_data
->
GetProducerPort
());
#else
mapper_new
->
SetInputData
(
poly_data
);
#endif
mapper_new
->
SetScalarRange
(
minmax
.
val
);
mapper_new
->
SetScalarModeToUsePointData
();
...
...
@@ -349,8 +361,13 @@ struct cv::viz::CloudCollectionWidget::CreateCloudWidget
CV_Assert
(
"Cloud Widget without data"
&&
data
);
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
#if VTK_MAJOR_VERSION <= 5
appendFilter
->
AddInputConnection
(
mapper
->
GetInput
()
->
GetProducerPort
());
appendFilter
->
AddInputConnection
(
poly_data
->
GetProducerPort
());
#else
appendFilter
->
AddInputData
(
data
);
appendFilter
->
AddInputData
(
poly_data
);
#endif
mapper
->
SetInputConnection
(
appendFilter
->
GetOutputPort
());
// Update the number of cloud points
...
...
@@ -401,7 +418,11 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, InputArray _col
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
transform_filter
=
vtkSmartPointer
<
vtkTransformPolyDataFilter
>::
New
();
transform_filter
->
SetTransform
(
transform
);
#if VTK_MAJOR_VERSION <= 5
transform_filter
->
SetInputConnection
(
polydata
->
GetProducerPort
());
#else
transform_filter
->
SetInputData
(
polydata
);
#endif
transform_filter
->
Update
();
vtkLODActor
*
actor
=
vtkLODActor
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
...
...
@@ -436,7 +457,11 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, const Color &co
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
transform_filter
=
vtkSmartPointer
<
vtkTransformPolyDataFilter
>::
New
();
transform_filter
->
SetTransform
(
transform
);
#if VTK_MAJOR_VERSION <= 5
transform_filter
->
SetInputConnection
(
polydata
->
GetProducerPort
());
#else
transform_filter
->
SetInputData
(
polydata
);
#endif
transform_filter
->
Update
();
vtkLODActor
*
actor
=
vtkLODActor
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
...
...
@@ -571,7 +596,11 @@ cv::viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _n
polyData
->
SetLines
(
lines
);
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
mapper
->
SetInput
(
polyData
);
#else
mapper
->
SetInputData
(
polyData
);
#endif
mapper
->
SetColorModeToMapScalars
();
mapper
->
SetScalarModeToUsePointData
();
...
...
@@ -707,7 +736,6 @@ cv::viz::MeshWidget::MeshWidget(const Mesh3d &mesh)
poly_grid
->
Allocate
(
1
,
1
);
poly_grid
->
InsertNextCell
(
polygon
->
GetCellType
(),
polygon
->
GetPointIds
());
poly_grid
->
SetPoints
(
points
);
poly_grid
->
Update
();
if
(
scalars
)
poly_grid
->
GetPointData
()
->
SetScalars
(
scalars
);
...
...
@@ -724,7 +752,11 @@ cv::viz::MeshWidget::MeshWidget(const Mesh3d &mesh)
actor
->
GetProperty
()
->
ShadingOff
();
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
mapper
->
SetInput
(
data
);
#else
mapper
->
SetInputData
(
data
);
#endif
mapper
->
ImmediateModeRenderingOff
();
vtkIdType
numberOfCloudPoints
=
nr_points
*
0.1
;
...
...
modules/viz/src/shape_widgets.cpp
View file @
56f9168a
This diff is collapsed.
Click to expand it.
modules/viz/src/viz3d_impl.cpp
View file @
56f9168a
...
...
@@ -325,7 +325,11 @@ void cv::viz::Viz3d::VizImpl::createActorFromVTKDataSet(const vtkSmartPointer<vt
actor
=
vtkSmartPointer
<
vtkLODActor
>::
New
();
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
mapper
->
SetInput
(
data
);
#else
mapper
->
SetInputData
(
data
);
#endif
if
(
use_scalars
)
{
...
...
modules/viz/src/viz3d_impl.hpp
View file @
56f9168a
...
...
@@ -369,9 +369,13 @@ namespace cv
{
// Create the vtk image
output
->
SetDimensions
(
image
.
cols
,
image
.
rows
,
1
);
#if VTK_MAJOR_VERSION <= 5
output
->
SetNumberOfScalarComponents
(
image
.
channels
());
output
->
SetScalarTypeToUnsignedChar
();
output
->
AllocateScalars
();
#else
output
->
AllocateScalars
(
VTK_UNSIGNED_CHAR
,
image
.
channels
());
#endif
int
i_chs
=
image
.
channels
();
if
(
i_chs
>
1
)
...
...
modules/viz/src/widget.cpp
View file @
56f9168a
...
...
@@ -93,7 +93,11 @@ cv::viz::Widget cv::viz::Widget::fromPlyFile(const String &file_name)
vtkSmartPointer
<
vtkLODActor
>
actor
=
vtkSmartPointer
<
vtkLODActor
>::
New
();
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
mapper
->
SetInput
(
data
);
#else
mapper
->
SetInputData
(
data
);
#endif
vtkSmartPointer
<
vtkDataArray
>
scalars
=
data
->
GetPointData
()
->
GetScalars
();
if
(
scalars
)
...
...
@@ -183,9 +187,13 @@ void cv::viz::Widget::setRenderingProperty(int property, double value)
if
(
!
actor
->
GetMapper
()
->
GetInput
()
->
GetPointData
()
->
GetNormals
())
{
vtkSmartPointer
<
vtkPolyDataNormals
>
normals
=
vtkSmartPointer
<
vtkPolyDataNormals
>::
New
();
#if VTK_MAJOR_VERSION <= 5
normals
->
SetInput
(
actor
->
GetMapper
()
->
GetInput
());
#else
normals
->
SetInputData
(
actor
->
GetMapper
()
->
GetInput
());
#endif
normals
->
Update
();
vtkDataSetMapper
::
SafeDownCast
(
actor
->
GetMapper
())
->
SetInput
(
normals
->
GetOutpu
t
());
vtkDataSetMapper
::
SafeDownCast
(
actor
->
GetMapper
())
->
SetInput
Connection
(
normals
->
GetOutputPor
t
());
}
actor
->
GetProperty
()
->
SetInterpolationToGouraud
();
break
;
...
...
@@ -195,9 +203,13 @@ void cv::viz::Widget::setRenderingProperty(int property, double value)
if
(
!
actor
->
GetMapper
()
->
GetInput
()
->
GetPointData
()
->
GetNormals
())
{
vtkSmartPointer
<
vtkPolyDataNormals
>
normals
=
vtkSmartPointer
<
vtkPolyDataNormals
>::
New
();
#if VTK_MAJOR_VERSION <= 5
normals
->
SetInput
(
actor
->
GetMapper
()
->
GetInput
());
#else
normals
->
SetInputData
(
actor
->
GetMapper
()
->
GetInput
());
#endif
normals
->
Update
();
vtkDataSetMapper
::
SafeDownCast
(
actor
->
GetMapper
())
->
SetInput
(
normals
->
GetOutpu
t
());
vtkDataSetMapper
::
SafeDownCast
(
actor
->
GetMapper
())
->
SetInput
Connection
(
normals
->
GetOutputPor
t
());
}
actor
->
GetProperty
()
->
SetInterpolationToPhong
();
break
;
...
...
samples/cpp/tutorial_code/viz/creating_widgets.cpp
View file @
56f9168a
...
...
@@ -74,7 +74,11 @@ TriangleWidget::TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Poi
// Create mapper and actor
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
mapper
->
SetInput
(
polyData
);
#else
mapper
->
SetInputData
(
polyData
);
#endif
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor
->
SetMapper
(
mapper
);
...
...
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