Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IP
elsa
Commits
d2a9be89
Commit
d2a9be89
authored
Jan 29, 2022
by
David Frank
Browse files
Enhance bounding box
parent
0facef56
Changes
2
Hide whitespace changes
Inline
Side-by-side
elsa/projectors/BoundingBox.cpp
View file @
d2a9be89
...
@@ -21,4 +21,31 @@ namespace elsa
...
@@ -21,4 +21,31 @@ namespace elsa
_voxelCoordToIndexVector
[
2
]
=
volumeDimensions
[
2
]
*
volumeDimensions
[
2
];
_voxelCoordToIndexVector
[
2
]
=
volumeDimensions
[
2
]
*
volumeDimensions
[
2
];
}
}
RealVector_t
BoundingBox
::
center
()
const
{
return
(
_max
-
_min
).
array
()
/
2
;
}
void
BoundingBox
::
recomputeBounds
()
{
RealVector_t
min
=
_min
.
cwiseMin
(
_max
);
RealVector_t
max
=
_min
.
cwiseMax
(
_max
);
_min
=
min
;
_max
=
max
;
}
bool
operator
==
(
const
BoundingBox
&
box1
,
const
BoundingBox
&
box2
)
{
return
box1
.
_min
==
box2
.
_min
&&
box1
.
_max
==
box2
.
_max
;
}
bool
operator
!=
(
const
BoundingBox
&
box1
,
const
BoundingBox
&
box2
)
{
return
!
(
box1
==
box2
);
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
const
BoundingBox
&
aabb
)
{
Eigen
::
IOFormat
fmt
(
4
,
0
,
", "
,
", "
,
""
,
""
,
"["
,
"]"
);
stream
<<
"AABB { min = "
<<
aabb
.
_min
.
format
(
fmt
)
<<
", max = "
<<
aabb
.
_max
.
format
(
fmt
)
<<
" }"
;
return
stream
;
}
}
// namespace elsa
}
// namespace elsa
elsa/projectors/BoundingBox.h
View file @
d2a9be89
...
@@ -19,6 +19,16 @@ namespace elsa
...
@@ -19,6 +19,16 @@ namespace elsa
*/
*/
BoundingBox
(
const
IndexVector_t
&
volumeDimensions
);
BoundingBox
(
const
IndexVector_t
&
volumeDimensions
);
RealVector_t
center
()
const
;
void
recomputeBounds
();
friend
bool
operator
==
(
const
BoundingBox
&
box1
,
const
BoundingBox
&
box2
);
friend
bool
operator
!=
(
const
BoundingBox
&
box1
,
const
BoundingBox
&
box2
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
const
BoundingBox
&
aabb
);
/// the number of dimensions (2 or 3)
/// the number of dimensions (2 or 3)
index_t
_dim
;
index_t
_dim
;
/// the front corner of the box
/// the front corner of the box
...
@@ -28,4 +38,5 @@ namespace elsa
...
@@ -28,4 +38,5 @@ namespace elsa
/// helper to convert coordinates to indices
/// helper to convert coordinates to indices
IndexVector_t
_voxelCoordToIndexVector
{
_dim
};
IndexVector_t
_voxelCoordToIndexVector
{
_dim
};
};
};
}
// namespace elsa
}
// namespace elsa
Write
Preview
Supports
Markdown
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