Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tools
frackit
Commits
d66dd09c
Commit
d66dd09c
authored
Jan 18, 2020
by
Dennis Gläser
Browse files
[isection][empty] provide free function to query if isection is empty
parent
8b161c90
Changes
2
Hide whitespace changes
Inline
Side-by-side
frackit/entitynetwork/constraints.hh
View file @
d66dd09c
...
...
@@ -31,6 +31,7 @@
#include
<frackit/distance/distance.hh>
#include
<frackit/magnitude/magnitude.hh>
#include
<frackit/intersection/intersect.hh>
#include
<frackit/intersection/emptyintersection.hh>
#include
<frackit/intersection/intersectionpredicates.hh>
#include
"impl_admissibledimension.hh"
...
...
@@ -176,7 +177,7 @@ public:
const
auto
isection
=
!
useIntersectionEps_
?
intersect
(
geo1
,
geo2
)
:
intersect
(
geo1
,
geo2
,
intersectionEps_
);
if
(
!
Intersection
Predicates
::
isEmpty
(
isection
)
)
if
(
!
isEmpty
Intersection
(
isection
)
)
{
// check if dimensionality constraint is violated
if
(
!
allowEquiDimIS_
&&
!
ConstraintImpl
::
isAdmissibleDimension
(
isection
,
dim
-
1
))
...
...
frackit/intersection/emptyintersection.hh
View file @
d66dd09c
...
...
@@ -24,6 +24,7 @@
#define FRACKIT_EMPTY_INTERSECTION_HH
#include
<string>
#include
<variant>
namespace
Frackit
{
...
...
@@ -61,6 +62,33 @@ template<int wd>
struct
IsEmptyIntersection
<
EmptyIntersection
<
wd
>>
{
static
constexpr
bool
value
=
true
;
};
/*!
* \brief Returns true if a geometry describes an empty intersection.
* \tparam IsGeometry the geometry of an intersection
*/
template
<
class
IsGeometry
>
constexpr
bool
isEmptyIntersection
(
const
IsGeometry
&
is
)
{
return
IsEmptyIntersection
<
IsGeometry
>::
value
;
}
/*!
* \brief Overload for intersection variant
*/
template
<
class
...
T
>
bool
isEmptyIntersection
(
const
std
::
variant
<
T
...
>&
intersection
)
{
return
std
::
visit
([
&
]
(
auto
&&
is
)
{
return
isEmptyIntersection
(
is
);
},
intersection
);
}
/*!
* \brief Overload for general intersections possibly
* containing possibly various types.
*/
template
<
class
Geo
>
bool
isEmptyIntersection
(
const
std
::
vector
<
Geo
>&
intersections
)
{
return
std
::
all_of
(
intersections
.
begin
(),
intersections
.
end
(),
[
&
]
(
const
auto
&
is
)
{
return
isEmptyIntersection
(
is
);
}
);
}
}
// end namespace Frackit
#endif // FRACKIT_EMPTY_INTERSECTION_HH
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