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
b387581d
Commit
b387581d
authored
Jun 17, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial refactoring
parent
0e90c0ff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
1 deletion
+75
-1
shapes.h
modules/viz/src/q/shapes.h
+10
-1
shapes.cpp
modules/viz/src/shapes.cpp
+65
-0
No files found.
modules/viz/src/q/shapes.h
View file @
b387581d
...
...
@@ -8,7 +8,16 @@ namespace temp_viz
{
CV_EXPORTS
vtkSmartPointer
<
vtkDataSet
>
createLine
(
const
cv
::
Point3f
&
pt1
,
const
cv
::
Point3f
&
pt2
);
CV_EXPORTS
vtkSmartPointer
<
vtkDataSet
>
createSphere
(
const
cv
::
Point3f
&
center
,
float
radius
,
int
sphere_resolution
=
10
);
CV_EXPORTS
vtkSmartPointer
<
vtkDataSet
>
createCylinder
(
const
Point3f
&
pt_on_axis
,
const
Point3f
&
axis_direction
,
double
radius
,
int
numsides
=
30
);
CV_EXPORTS
vtkSmartPointer
<
vtkDataSet
>
createPlane
(
const
Vec4f
&
coefs
);
CV_EXPORTS
vtkSmartPointer
<
vtkDataSet
>
createPlane
(
const
Vec4f
&
coefs
,
const
Point3f
&
pt
);
CV_EXPORTS
vtkSmartPointer
<
vtkDataSet
>
create2DCircle
(
const
Point3f
&
pt
,
double
radius
);
CV_EXPORTS
vtkSmartPointer
<
vtkDataSet
>
createCube
(
const
Point3f
&
pt_min
,
const
Point3f
&
pt_max
);
// CV_EXPORTS vtkSmartPointer<vtkDataSet> createCube (const Point3f& pt, const Quaternionf& qt, );
// CV_EXPORTS vtkSmartPointer<vtkDataSet> createCube (const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation, double width, double height, double depth);
// CV_EXPORTS vtkSmartPointer<vtkDataSet> createCube (double x_min, double x_max, double y_min, double y_max, double z_min, double z_max);
//
//
/** \brief Create a cylinder shape from a set of model coefficients.
* \param[in] coefficients the model coefficients (point_on_axis, axis_direction, radius)
* \param[in] numsides (optional) the number of sides used for rendering the cylinder
...
...
modules/viz/src/shapes.cpp
View file @
b387581d
...
...
@@ -5,6 +5,71 @@ inline float rad2deg (float alpha)
inline
double
rad2deg
(
double
alpha
){
return
(
alpha
*
57.29578
);}
vtkSmartPointer
<
vtkDataSet
>
temp_viz
::
createCylinder
(
const
cv
::
Point3f
&
pt_on_axis
,
const
cv
::
Point3f
&
axis_direction
,
double
radius
,
int
numsides
)
{
const
cv
::
Point3f
pt2
=
pt_on_axis
+
axis_direction
;
vtkSmartPointer
<
vtkLineSource
>
line
=
vtkSmartPointer
<
vtkLineSource
>::
New
();
line
->
SetPoint1
(
pt_on_axis
.
x
,
pt_on_axis
.
y
,
pt_on_axis
.
z
);
line
->
SetPoint2
(
pt2
.
x
,
pt2
.
y
,
pt2
.
z
);
vtkSmartPointer
<
vtkTubeFilter
>
tuber
=
vtkSmartPointer
<
vtkTubeFilter
>::
New
();
tuber
->
SetInputConnection
(
line
->
GetOutputPort
());
tuber
->
SetRadius
(
radius
);
tuber
->
SetNumberOfSides
(
numsides
);
return
(
tuber
->
GetOutput
());
}
vtkSmartPointer
<
vtkDataSet
>
temp_viz
::
createPlane
(
const
cv
::
Vec4f
&
coefs
)
{
vtkSmartPointer
<
vtkPlaneSource
>
plane
=
vtkSmartPointer
<
vtkPlaneSource
>::
New
();
plane
->
SetNormal
(
coefs
[
0
],
coefs
[
1
],
coefs
[
2
]);
double
norm
=
cv
::
norm
(
cv
::
Vec3f
(
coefs
[
0
],
coefs
[
1
],
coefs
[
2
]));
plane
->
Push
(
-
coefs
[
3
]
/
norm
);
return
(
plane
->
GetOutput
());
}
vtkSmartPointer
<
vtkDataSet
>
temp_viz
::
createPlane
(
const
cv
::
Vec4f
&
coefs
,
const
cv
::
Point3f
&
pt
)
{
vtkSmartPointer
<
vtkPlaneSource
>
plane
=
vtkSmartPointer
<
vtkPlaneSource
>::
New
();
cv
::
Point3f
coefs3
(
coefs
[
0
],
coefs
[
1
],
coefs
[
2
]);
double
norm_sqr
=
1.0
/
coefs3
.
dot
(
coefs3
);
plane
->
SetNormal
(
coefs
[
0
],
coefs
[
1
],
coefs
[
2
]);
double
t
=
coefs3
.
dot
(
pt
)
+
coefs
[
3
];
cv
::
Vec3f
p_center
;
p_center
=
pt
-
coefs3
*
t
*
norm_sqr
;
plane
->
SetCenter
(
p_center
[
0
],
p_center
[
1
],
p_center
[
2
]);
return
(
plane
->
GetOutput
());
}
vtkSmartPointer
<
vtkDataSet
>
temp_viz
::
create2DCircle
(
const
cv
::
Point3f
&
pt
,
double
radius
)
{
vtkSmartPointer
<
vtkDiskSource
>
disk
=
vtkSmartPointer
<
vtkDiskSource
>::
New
();
// Maybe the resolution should be lower e.g. 50 or 25
disk
->
SetCircumferentialResolution
(
100
);
disk
->
SetInnerRadius
(
radius
-
0.001
);
disk
->
SetOuterRadius
(
radius
+
0.001
);
disk
->
SetCircumferentialResolution
(
20
);
// Set the circle origin
vtkSmartPointer
<
vtkTransform
>
t
=
vtkSmartPointer
<
vtkTransform
>::
New
();
t
->
Identity
();
t
->
Translate
(
pt
.
x
,
pt
.
y
,
pt
.
z
);
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
tf
=
vtkSmartPointer
<
vtkTransformPolyDataFilter
>::
New
();
tf
->
SetTransform
(
t
);
tf
->
SetInputConnection
(
disk
->
GetOutputPort
());
return
(
tf
->
GetOutput
());
}
vtkSmartPointer
<
vtkDataSet
>
temp_viz
::
createCube
(
const
cv
::
Point3f
&
pt_min
,
const
cv
::
Point3f
&
pt_max
)
{
vtkSmartPointer
<
vtkCubeSource
>
cube
=
vtkSmartPointer
<
vtkCubeSource
>::
New
();
cube
->
SetBounds
(
pt_min
.
x
,
pt_max
.
x
,
pt_min
.
y
,
pt_max
.
y
,
pt_min
.
z
,
pt_max
.
z
);
return
(
cube
->
GetOutput
());
}
////////////////////////////////////////////////////////////////////////////////////////////
vtkSmartPointer
<
vtkDataSet
>
temp_viz
::
createCylinder
(
const
temp_viz
::
ModelCoefficients
&
coefficients
,
int
numsides
)
...
...
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