Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Feliks Kiszkurno
ogs-feliks
Commits
eda987f4
Commit
eda987f4
authored
10 years ago
by
Karsten Rink
Browse files
Options
Downloads
Patches
Plain Diff
changed array to vector and handled re-ordering more elegantly
parent
d6c9ad68
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GeoLib/BoundingSphere.cpp
+13
-14
13 additions, 14 deletions
GeoLib/BoundingSphere.cpp
GeoLib/BoundingSphere.h
+1
-1
1 addition, 1 deletion
GeoLib/BoundingSphere.h
with
14 additions
and
15 deletions
GeoLib/BoundingSphere.cpp
+
13
−
14
View file @
eda987f4
...
@@ -137,14 +137,14 @@ BoundingSphere::BoundingSphere(const std::vector<GeoLib::Point*> &points)
...
@@ -137,14 +137,14 @@ BoundingSphere::BoundingSphere(const std::vector<GeoLib::Point*> &points)
for
(
unsigned
int
i
=
0
;
i
<
n_points
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
n_points
;
i
++
)
sphere_points
[
i
]
=
points
[
i
];
sphere_points
[
i
]
=
points
[
i
];
const
BoundingSphere
bounding_sphere
=
recurseCalculation
(
sphere_
points
,
n_
points
,
0
);
const
BoundingSphere
bounding_sphere
=
recurseCalculation
(
points
,
0
,
points
.
size
()
,
0
);
delete
[]
sphere_points
;
delete
[]
sphere_points
;
this
->
_center
=
bounding_sphere
.
getCenter
();
this
->
_center
=
bounding_sphere
.
getCenter
();
this
->
_radius
=
bounding_sphere
.
getRadius
();
this
->
_radius
=
bounding_sphere
.
getRadius
();
}
}
BoundingSphere
BoundingSphere
::
recurseCalculation
(
GeoLib
::
Point
*
sphere_points
[]
,
std
::
size_t
n_points
,
std
::
size_t
n_boundary_points
)
BoundingSphere
BoundingSphere
::
recurseCalculation
(
std
::
vector
<
GeoLib
::
Point
*
>
sphere_points
,
std
::
size_t
current_index
,
std
::
size_t
n_points
,
std
::
size_t
n_boundary_points
)
{
{
BoundingSphere
sphere
;
BoundingSphere
sphere
;
switch
(
n_boundary_points
)
switch
(
n_boundary_points
)
...
@@ -153,30 +153,29 @@ BoundingSphere BoundingSphere::recurseCalculation(GeoLib::Point* sphere_points[]
...
@@ -153,30 +153,29 @@ BoundingSphere BoundingSphere::recurseCalculation(GeoLib::Point* sphere_points[]
sphere
=
BoundingSphere
();
sphere
=
BoundingSphere
();
break
;
break
;
case
1
:
case
1
:
sphere
=
BoundingSphere
(
*
sphere_points
[
-
1
]);
sphere
=
BoundingSphere
(
*
sphere_points
[
current_index
-
1
]);
break
;
break
;
case
2
:
case
2
:
sphere
=
BoundingSphere
(
*
sphere_points
[
-
1
],
*
sphere_points
[
-
2
]);
sphere
=
BoundingSphere
(
*
sphere_points
[
current_index
-
1
],
*
sphere_points
[
current_index
-
2
]);
break
;
break
;
case
3
:
case
3
:
sphere
=
BoundingSphere
(
*
sphere_points
[
-
1
],
*
sphere_points
[
-
2
],
*
sphere_points
[
-
3
]);
sphere
=
BoundingSphere
(
*
sphere_points
[
current_index
-
1
],
*
sphere_points
[
current_index
-
2
],
*
sphere_points
[
current_index
-
3
]);
break
;
break
;
case
4
:
case
4
:
sphere
=
BoundingSphere
(
*
sphere_points
[
-
1
],
*
sphere_points
[
-
2
],
*
sphere_points
[
-
3
],
*
sphere_points
[
-
4
]);
sphere
=
BoundingSphere
(
*
sphere_points
[
current_index
-
1
],
*
sphere_points
[
current_index
-
2
],
*
sphere_points
[
current_index
-
3
],
*
sphere_points
[
current_index
-
4
]);
return
sphere
;
return
sphere
;
}
}
for
(
std
::
size_t
i
=
0
;
i
<
n_points
;
++
i
)
for
(
std
::
size_t
i
=
current_index
;
i
<
n_points
;
++
i
)
{
{
// current point is located outside of sphere
if
(
sphere
.
sqrPointDist
(
*
sphere_points
[
i
])
>
0
)
if
(
sphere
.
sqrPointDist
(
*
sphere_points
[
i
])
>
0
)
{
{
for
(
unsigned
int
j
=
i
;
j
>
0
;
--
j
)
GeoLib
::
Point
*
tmp
=
sphere_points
[
i
];
{
std
::
copy
(
sphere_points
.
begin
(),
sphere_points
.
begin
()
+
i
,
sphere_points
.
begin
()
+
1
);
GeoLib
::
Point
*
tmp
=
sphere_points
[
j
];
sphere_points
[
0
]
=
tmp
;
sphere_points
[
j
]
=
sphere_points
[
j
-
1
];
sphere_points
[
j
-
1
]
=
tmp
;
sphere
=
recurseCalculation
(
sphere_points
,
current_index
+
1
,
i
,
n_boundary_points
+
1
);
}
sphere
=
recurseCalculation
(
sphere_points
+
1
,
i
,
n_boundary_points
+
1
);
}
}
}
}
return
sphere
;
return
sphere
;
...
...
This diff is collapsed.
Click to expand it.
GeoLib/BoundingSphere.h
+
1
−
1
View file @
eda987f4
...
@@ -63,7 +63,7 @@ private:
...
@@ -63,7 +63,7 @@ private:
* Algorithm based on Bernd Gärtner: Fast and Robust Smallest Enclosing Balls. ESA99, pages 325-338, 1999.
* Algorithm based on Bernd Gärtner: Fast and Robust Smallest Enclosing Balls. ESA99, pages 325-338, 1999.
* Code based on "Smallest Enclosing Spheres" implementation by Nicolas Capens on flipcode's Developer Toolbox (www.flipcode.com)
* Code based on "Smallest Enclosing Spheres" implementation by Nicolas Capens on flipcode's Developer Toolbox (www.flipcode.com)
*/
*/
static
BoundingSphere
recurseCalculation
(
GeoLib
::
Point
*
sphere_points
[]
,
std
::
size_t
n_points
,
std
::
size_t
n_boundary_points
);
static
BoundingSphere
recurseCalculation
(
std
::
vector
<
GeoLib
::
Point
*
>
sphere_points
,
std
::
size_t
current_index
,
std
::
size_t
n_points
,
std
::
size_t
n_boundary_points
);
double
_radius
;
double
_radius
;
MathLib
::
Vector3
_center
;
MathLib
::
Vector3
_center
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment