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
b46e23d6
Commit
b46e23d6
authored
Nov 29, 2020
by
Dennis Gläser
Browse files
[constraints][eval] provide labels for violations
parent
05f5d845
Changes
2
Hide whitespace changes
Inline
Side-by-side
frackit/entitynetwork/constraints.hh
View file @
b46e23d6
...
...
@@ -72,11 +72,33 @@ struct ConstraintsEvaluation
Violation
violation
()
const
{
return
violation_
;
}
//! return the violation label
std
::
string
violationLabel
()
const
{
return
violationLabel
(
violation_
);
}
//! returns true if evaluation was
//! positive, i.e. no violation was detected
explicit
operator
bool
()
const
{
return
violation_
==
Violation
::
none
;
}
//! return a label for the given violation
static
std
::
string
violationLabel
(
Violation
v
)
{
if
(
v
==
Violation
::
none
)
return
"no violation"
;
else
if
(
v
==
Violation
::
distance
)
return
"minimum distance violation"
;
else
if
(
v
==
Violation
::
intersectionAngle
)
return
"minimum intersection angle violation"
;
else
if
(
v
==
Violation
::
intersectionMagnitude
)
return
"minimum intersection magnitude violation"
;
else
if
(
v
==
Violation
::
intersectionDimension
)
return
"maximum intersection dimensionality violation"
;
else
if
(
v
==
Violation
::
intersectionDistance
)
return
"minimum intersection distance violation"
;
else
throw
std
::
runtime_error
(
"Unsupported violation flag"
);
}
private:
Violation
violation_
;
};
...
...
frackit/python/entitynetwork/constraints.hh
View file @
b46e23d6
...
...
@@ -148,8 +148,12 @@ void registerConstraints(py::module& module)
// define members of ConstraintsEvaluation
evalResult
.
def
(
py
::
init
<
Result
::
Violation
>
());
evalResult
.
def
(
"violation"
,
&
Result
::
violation
,
"return the type of detected violation"
);
evalResult
.
def
(
"__bool__"
,
&
Result
::
operator
bool
,
"returns true if no violation was detected"
);
evalResult
.
def
(
"violation"
,
&
Result
::
violation
,
"return the type of detected violation"
);
evalResult
.
def
(
"violationLabel"
,
py
::
overload_cast
<>
(
&
Result
::
violationLabel
,
py
::
const_
),
"return a label for the type of detected violation"
);
evalResult
.
def
(
"violationLabel"
,
py
::
overload_cast
<
Result
::
Violation
>
(
&
Result
::
violationLabel
),
"return a label for the given violation"
);
using
Constraints
=
Detail
::
EntityNetworkConstraintsWrapper
<
ctype
>
;
py
::
class_
<
Constraints
>
cls
(
module
,
"_EntityNetworkConstraints"
);
...
...
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