Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Dmitri Naumov
ogs
Commits
5de5ecad
Commit
5de5ecad
authored
9 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[GL] AABB: class template -> "normal" class + templatized methods.
parent
4db16bf0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GeoLib/AABB.h
+15
-8
15 additions, 8 deletions
GeoLib/AABB.h
with
15 additions
and
8 deletions
GeoLib/AABB.h
+
15
−
8
View file @
5de5ecad
...
@@ -46,16 +46,16 @@ namespace GeoLib
...
@@ -46,16 +46,16 @@ namespace GeoLib
* available floating point number such that all input points are contained in
* available floating point number such that all input points are contained in
* the bounding box.
* the bounding box.
*
*
* @tparam PNT_TYPE a point type supporting accessing the coordinates via
* operator[]
*/
*/
template
<
typename
PNT_TYPE
>
class
AABB
class
AABB
{
{
public:
public:
/**
/**
* construction of object, initialization the axis aligned bounding box
* construction of object, initialization the axis aligned bounding box
* @tparam PNT_TYPE a point type supporting accessing the coordinates via
* operator[]
* */
* */
template
<
typename
PNT_TYPE
>
AABB
(
std
::
vector
<
PNT_TYPE
*>
const
&
pnts
,
std
::
vector
<
std
::
size_t
>
const
&
ids
)
AABB
(
std
::
vector
<
PNT_TYPE
*>
const
&
pnts
,
std
::
vector
<
std
::
size_t
>
const
&
ids
)
{
{
assert
(
!
ids
.
empty
());
assert
(
!
ids
.
empty
());
...
@@ -69,8 +69,8 @@ public:
...
@@ -69,8 +69,8 @@ public:
/**
/**
* copy constructor.
* copy constructor.
* @param src an axis aligned bounding box
* @param src an axis aligned bounding box
*/
*
*/
AABB
(
AABB
<
PNT_TYPE
>
const
&
src
)
:
AABB
(
AABB
const
&
src
)
:
_min_pnt
(
src
.
_min_pnt
),
_max_pnt
(
src
.
_max_pnt
)
_min_pnt
(
src
.
_min_pnt
),
_max_pnt
(
src
.
_max_pnt
)
{}
{}
...
@@ -102,6 +102,7 @@ public:
...
@@ -102,6 +102,7 @@ public:
/// Checks if the bounding box has to be updated.
/// Checks if the bounding box has to be updated.
/// @return true if AABB is updated.
/// @return true if AABB is updated.
template
<
typename
PNT_TYPE
>
bool
update
(
PNT_TYPE
const
&
p
)
bool
update
(
PNT_TYPE
const
&
p
)
{
{
// First component of the pair signals if the minimum point is changed
// First component of the pair signals if the minimum point is changed
...
@@ -164,7 +165,7 @@ public:
...
@@ -164,7 +165,7 @@ public:
* @return true if the other AABB is contained in the AABB
* @return true if the other AABB is contained in the AABB
* represented by this object
* represented by this object
*/
*/
bool
containsAABB
(
AABB
<
PNT_TYPE
>
const
&
other_aabb
)
const
bool
containsAABB
(
AABB
const
&
other_aabb
)
const
{
{
return
containsPoint
(
other_aabb
.
getMinPoint
())
&&
containsPoint
(
other_aabb
.
getMaxPoint
());
return
containsPoint
(
other_aabb
.
getMinPoint
())
&&
containsPoint
(
other_aabb
.
getMaxPoint
());
}
}
...
@@ -192,13 +193,16 @@ private:
...
@@ -192,13 +193,16 @@ private:
}
}
}
}
template
<
typename
PNT_TYPE
>
void
init
(
PNT_TYPE
const
&
pnt
)
void
init
(
PNT_TYPE
const
&
pnt
)
{
{
_min_pnt
[
0
]
=
_max_pnt
[
0
]
=
pnt
[
0
];
_min_pnt
[
0
]
=
_max_pnt
[
0
]
=
pnt
[
0
];
_min_pnt
[
1
]
=
_max_pnt
[
1
]
=
pnt
[
1
];
_min_pnt
[
1
]
=
_max_pnt
[
1
]
=
pnt
[
1
];
_min_pnt
[
2
]
=
_max_pnt
[
2
]
=
pnt
[
2
];
_min_pnt
[
2
]
=
_max_pnt
[
2
]
=
pnt
[
2
];
}
}
void
init
(
PNT_TYPE
const
*
pnt
)
template
<
typename
PNT_TYPE
>
void
init
(
PNT_TYPE
*
const
&
pnt
)
{
{
init
(
*
pnt
);
init
(
*
pnt
);
}
}
...
@@ -208,6 +212,7 @@ private:
...
@@ -208,6 +212,7 @@ private:
/// box. Using this method the bounding box of the initial point set is
/// box. Using this method the bounding box of the initial point set is
/// enlarged only once.
/// enlarged only once.
/// @param p point that will possibly change the bounding box points
/// @param p point that will possibly change the bounding box points
template
<
typename
PNT_TYPE
>
void
updateWithoutEnlarge
(
PNT_TYPE
const
&
p
)
void
updateWithoutEnlarge
(
PNT_TYPE
const
&
p
)
{
{
for
(
std
::
size_t
k
(
0
);
k
<
3
;
k
++
)
{
for
(
std
::
size_t
k
(
0
);
k
<
3
;
k
++
)
{
...
@@ -220,11 +225,13 @@ private:
...
@@ -220,11 +225,13 @@ private:
}
}
}
}
void
updateWithoutEnlarge
(
PNT_TYPE
const
*
pnt
)
template
<
typename
PNT_TYPE
>
void
updateWithoutEnlarge
(
PNT_TYPE
*
const
&
pnt
)
{
{
updateWithoutEnlarge
(
*
pnt
);
updateWithoutEnlarge
(
*
pnt
);
}
}
template
<
typename
PNT_TYPE
>
void
update
(
PNT_TYPE
const
*
pnt
)
void
update
(
PNT_TYPE
const
*
pnt
)
{
{
update
(
*
pnt
);
update
(
*
pnt
);
...
...
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