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
b64e6ccc
Commit
b64e6ccc
authored
Jul 29, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
static function for appending clouds in cloud collection widget
parent
42266b04
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
68 deletions
+40
-68
cloud_widgets.cpp
modules/viz/src/cloud_widgets.cpp
+40
-68
No files found.
modules/viz/src/cloud_widgets.cpp
View file @
b64e6ccc
...
...
@@ -271,6 +271,44 @@ struct cv::viz::CloudCollectionWidget::CreateCloudWidget
vertices
->
SetCells
(
nr_points
,
cells
);
return
polydata
;
}
static
void
createMapper
(
vtkSmartPointer
<
vtkLODActor
>
actor
,
vtkSmartPointer
<
vtkPolyData
>
poly_data
,
Vec3d
&
minmax
)
{
vtkDataSetMapper
*
mapper
=
vtkDataSetMapper
::
SafeDownCast
(
actor
->
GetMapper
());
if
(
!
mapper
)
{
// This is the first cloud
vtkSmartPointer
<
vtkDataSetMapper
>
mapper_new
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
mapper_new
->
SetInputConnection
(
poly_data
->
GetProducerPort
());
mapper_new
->
SetScalarRange
(
minmax
.
val
);
mapper_new
->
SetScalarModeToUsePointData
();
bool
interpolation
=
(
poly_data
&&
poly_data
->
GetNumberOfCells
()
!=
poly_data
->
GetNumberOfVerts
());
mapper_new
->
SetInterpolateScalarsBeforeMapping
(
interpolation
);
mapper_new
->
ScalarVisibilityOn
();
mapper_new
->
ImmediateModeRenderingOff
();
actor
->
SetNumberOfCloudPoints
(
int
(
std
::
max
<
vtkIdType
>
(
1
,
poly_data
->
GetNumberOfPoints
()
/
10
)));
actor
->
GetProperty
()
->
SetInterpolationToFlat
();
actor
->
GetProperty
()
->
BackfaceCullingOn
();
actor
->
SetMapper
(
mapper_new
);
return
;
}
vtkPolyData
*
data
=
vtkPolyData
::
SafeDownCast
(
mapper
->
GetInput
());
CV_Assert
(
data
);
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
appendFilter
->
AddInputConnection
(
mapper
->
GetInput
()
->
GetProducerPort
());
appendFilter
->
AddInputConnection
(
poly_data
->
GetProducerPort
());
mapper
->
SetInputConnection
(
appendFilter
->
GetOutputPort
());
// Update the number of cloud points
vtkIdType
old_cloud_points
=
actor
->
GetNumberOfCloudPoints
();
actor
->
SetNumberOfCloudPoints
(
int
(
std
::
max
<
vtkIdType
>
(
1
,
old_cloud_points
+
poly_data
->
GetNumberOfPoints
()
/
10
)));
}
};
cv
::
viz
::
CloudCollectionWidget
::
CloudCollectionWidget
()
...
...
@@ -321,41 +359,8 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, InputArray _col
vtkLODActor
*
actor
=
vtkLODActor
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
vtkDataSetMapper
*
mapper
=
vtkDataSetMapper
::
SafeDownCast
(
actor
->
GetMapper
());
if
(
!
mapper
)
{
// This is the first cloud
vtkSmartPointer
<
vtkDataSetMapper
>
mapper_new
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
mapper_new
->
SetInputConnection
(
transform_filter
->
GetOutputPort
());
Vec3d
minmax
(
scalars
->
GetRange
());
mapper_new
->
SetScalarRange
(
minmax
.
val
);
mapper_new
->
SetScalarModeToUsePointData
();
bool
interpolation
=
(
polydata
&&
polydata
->
GetNumberOfCells
()
!=
polydata
->
GetNumberOfVerts
());
mapper_new
->
SetInterpolateScalarsBeforeMapping
(
interpolation
);
mapper_new
->
ScalarVisibilityOn
();
mapper_new
->
ImmediateModeRenderingOff
();
actor
->
SetNumberOfCloudPoints
(
int
(
std
::
max
<
vtkIdType
>
(
1
,
polydata
->
GetNumberOfPoints
()
/
10
)));
actor
->
GetProperty
()
->
SetInterpolationToFlat
();
actor
->
GetProperty
()
->
BackfaceCullingOn
();
actor
->
SetMapper
(
mapper_new
);
return
;
}
vtkPolyData
*
data
=
vtkPolyData
::
SafeDownCast
(
mapper
->
GetInput
());
CV_Assert
(
data
);
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
appendFilter
->
AddInputConnection
(
mapper
->
GetInput
()
->
GetProducerPort
());
appendFilter
->
AddInputConnection
(
transform_filter
->
GetOutputPort
());
mapper
->
SetInputConnection
(
appendFilter
->
GetOutputPort
());
// Update the number of cloud points
vtkIdType
old_cloud_points
=
actor
->
GetNumberOfCloudPoints
();
actor
->
SetNumberOfCloudPoints
(
int
(
std
::
max
<
vtkIdType
>
(
1
,
old_cloud_points
+
polydata
->
GetNumberOfPoints
()
/
10
)));
CreateCloudWidget
::
createMapper
(
actor
,
transform_filter
->
GetOutput
(),
minmax
);
}
void
cv
::
viz
::
CloudCollectionWidget
::
addCloud
(
InputArray
_cloud
,
const
Color
&
color
,
const
Affine3f
&
pose
)
...
...
@@ -389,41 +394,8 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, const Color &co
vtkLODActor
*
actor
=
vtkLODActor
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
vtkDataSetMapper
*
mapper
=
vtkDataSetMapper
::
SafeDownCast
(
actor
->
GetMapper
());
if
(
!
mapper
)
{
// This is the first cloud
vtkSmartPointer
<
vtkDataSetMapper
>
mapper_new
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
mapper_new
->
SetInputConnection
(
transform_filter
->
GetOutputPort
());
Vec3d
minmax
(
scalars
->
GetRange
());
mapper_new
->
SetScalarRange
(
minmax
.
val
);
mapper_new
->
SetScalarModeToUsePointData
();
bool
interpolation
=
(
polydata
&&
polydata
->
GetNumberOfCells
()
!=
polydata
->
GetNumberOfVerts
());
mapper_new
->
SetInterpolateScalarsBeforeMapping
(
interpolation
);
mapper_new
->
ScalarVisibilityOn
();
mapper_new
->
ImmediateModeRenderingOff
();
actor
->
SetNumberOfCloudPoints
(
int
(
std
::
max
<
vtkIdType
>
(
1
,
polydata
->
GetNumberOfPoints
()
/
10
)));
actor
->
GetProperty
()
->
SetInterpolationToFlat
();
actor
->
GetProperty
()
->
BackfaceCullingOn
();
actor
->
SetMapper
(
mapper_new
);
return
;
}
vtkPolyData
*
data
=
vtkPolyData
::
SafeDownCast
(
mapper
->
GetInput
());
CV_Assert
(
data
);
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
appendFilter
->
AddInputConnection
(
mapper
->
GetInput
()
->
GetProducerPort
());
appendFilter
->
AddInputConnection
(
transform_filter
->
GetOutputPort
());
mapper
->
SetInputConnection
(
appendFilter
->
GetOutputPort
());
// Update the number of cloud points
vtkIdType
old_cloud_points
=
actor
->
GetNumberOfCloudPoints
();
actor
->
SetNumberOfCloudPoints
(
int
(
std
::
max
<
vtkIdType
>
(
1
,
old_cloud_points
+
polydata
->
GetNumberOfPoints
()
/
10
)));
CreateCloudWidget
::
createMapper
(
actor
,
transform_filter
->
GetOutput
(),
minmax
);
}
template
<>
cv
::
viz
::
CloudCollectionWidget
cv
::
viz
::
Widget
::
cast
<
cv
::
viz
::
CloudCollectionWidget
>
()
...
...
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