Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
tg-samples
Commits
f4fc2c64
Commit
f4fc2c64
authored
Feb 13, 2020
by
Philip Trettner
Browse files
updated implementation report
parent
a071a775
Pipeline
#13569
failed with stage
in 6 minutes and 11 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
typed-geometry
@
975139e5
Subproject commit
b12ec80542d08fbf917e2927696d53a53f9acf2c
Subproject commit
975139e586166d9893b05af72e8e46430b088f18
tests/impl-report.cc
View file @
f4fc2c64
...
...
@@ -39,6 +39,12 @@ using try_less = decltype(std::map<T, int>().find(std::declval<T>()));
template
<
class
T
>
using
try_hash
=
decltype
(
std
::
hash
<
T
>
()(
std
::
declval
<
T
const
&>
()));
template
<
class
T
>
using
try_project_pos2
=
decltype
(
project
(
tg
::
pos2
(),
std
::
declval
<
T
const
&>
()));
template
<
class
T
>
using
try_contains_pos2
=
decltype
(
contains
(
std
::
declval
<
T
const
&>
(),
tg
::
pos2
()));
template
<
class
T
>
using
try_project_pos3
=
decltype
(
project
(
tg
::
pos3
(),
std
::
declval
<
T
const
&>
()));
...
...
@@ -48,85 +54,134 @@ using try_contains_pos3 = decltype(contains(std::declval<T const&>(), tg::pos3()
template
<
class
T
>
using
try_uniform
=
decltype
(
uniform
(
detail
::
rng
,
std
::
declval
<
T
const
&>
()));
template
<
template
<
int
,
class
>
class
ObjT
>
struct
obj_tester
template
<
class
ObjT
>
void
test_single_object_type
(
std
::
string
name
)
{
static
void
test
(
std
::
string
name
)
auto
constexpr
D
=
tg
::
object_traits
<
ObjT
>::
domain_dimension
;
if
constexpr
(
!
std
::
is_default_constructible_v
<
ObjT
>
)
std
::
cerr
<<
"cannot default construct tg::"
<<
name
<<
std
::
endl
;
if
constexpr
(
can_apply
<
try_print
,
ObjT
>
)
{
using
obj3
=
ObjT
<
3
,
float
>
;
if
constexpr
(
!
std
::
is_default_constructible_v
<
obj3
>
)
std
::
cerr
<<
"cannot default construct tg::"
<<
name
<<
std
::
endl
;
if
constexpr
(
can_apply
<
try_print
,
obj3
>
)
{
std
::
stringstream
ss
;
ss
<<
obj3
{};
auto
s
=
ss
.
str
();
auto
test_name
=
name
;
if
(
name
==
"plane"
)
test_name
=
"plane"
;
// special case
if
(
s
.
find
(
test_name
)
==
std
::
string
::
npos
)
std
::
cerr
<<
"possible error in outputting tg::"
<<
name
<<
": '"
<<
s
<<
"'"
<<
std
::
endl
;
}
else
std
::
cerr
<<
"cannot print tg::"
<<
name
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_equal
,
obj3
>
)
std
::
cerr
<<
"equality not implemented for tg::"
<<
name
<<
std
::
endl
;
// TODO: somehow doesnt work?
if
constexpr
(
!
can_apply
<
try_less
,
obj3
>
)
std
::
cerr
<<
"std::less not specialized for tg::"
<<
name
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_hash
,
obj3
>
)
std
::
cerr
<<
"std::hash not specialized for tg::"
<<
name
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_project_pos3
,
obj3
>
)
std
::
cerr
<<
"no project(tg::pos, tg::"
<<
name
<<
")"
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_contains_pos3
,
obj3
>
)
std
::
cerr
<<
"no contains(tg::"
<<
name
<<
", tg::pos)"
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_uniform
,
obj3
>
)
std
::
cerr
<<
"no uniform(tg::rng, tg::"
<<
name
<<
")"
<<
std
::
endl
;
std
::
stringstream
ss
;
ss
<<
ObjT
{};
auto
s
=
ss
.
str
();
auto
test_name
=
name
;
if
(
name
==
"plane"
)
test_name
=
"plane"
;
// special case
if
(
s
.
find
(
test_name
)
==
std
::
string
::
npos
)
std
::
cerr
<<
"possible error in outputting tg::"
<<
name
<<
": '"
<<
s
<<
"'"
<<
std
::
endl
;
}
else
std
::
cerr
<<
"cannot print tg::"
<<
name
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_equal
,
ObjT
>
)
std
::
cerr
<<
"equality not implemented for tg::"
<<
name
<<
std
::
endl
;
// TODO:
// equality
// default ctor
// hash, less
// TODO: somehow doesnt work?
if
constexpr
(
!
can_apply
<
try_less
,
ObjT
>
)
std
::
cerr
<<
"std::less not specialized for tg::"
<<
name
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_hash
,
ObjT
>
)
std
::
cerr
<<
"std::hash not specialized for tg::"
<<
name
<<
std
::
endl
;
if
constexpr
(
D
==
2
)
{
if
constexpr
(
!
can_apply
<
try_project_pos2
,
ObjT
>
)
std
::
cerr
<<
"no project(tg::pos2, tg::"
<<
name
<<
")"
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_contains_pos2
,
ObjT
>
)
std
::
cerr
<<
"no contains(tg::"
<<
name
<<
", tg::pos2)"
<<
std
::
endl
;
}
};
else
if
constexpr
(
D
==
3
)
{
if
constexpr
(
!
can_apply
<
try_project_pos3
,
ObjT
>
)
std
::
cerr
<<
"no project(tg::pos3, tg::"
<<
name
<<
")"
<<
std
::
endl
;
if
constexpr
(
!
can_apply
<
try_contains_pos3
,
ObjT
>
)
std
::
cerr
<<
"no contains(tg::"
<<
name
<<
", tg::pos3)"
<<
std
::
endl
;
}
else
static_assert
(
tg
::
always_false
<
D
>
,
"not implemented"
);
// only finite objects can be sampled
if
constexpr
(
tg
::
object_traits
<
ObjT
>::
is_finite
)
if
constexpr
(
!
can_apply
<
try_uniform
,
ObjT
>
)
std
::
cerr
<<
"no uniform(tg::rng, tg::"
<<
name
<<
")"
<<
std
::
endl
;
}
TEST_CASE
(
"implementation report"
)
template
<
template
<
int
,
class
>
class
ObjT
>
void
test_object_type
(
std
::
string
basename
)
{
test_single_object_type
<
ObjT
<
2
,
float
>>
(
basename
+
"2"
);
test_single_object_type
<
ObjT
<
3
,
float
>>
(
basename
+
"3"
);
}
template
<
template
<
int
,
class
,
class
>
class
ObjT
>
void
test_object_type_boundary
(
std
::
string
basename
)
{
test_single_object_type
<
ObjT
<
2
,
float
,
tg
::
default_object_tag
>>
(
basename
+
"2"
);
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
default_object_tag
>>
(
basename
+
"3"
);
test_single_object_type
<
ObjT
<
2
,
float
,
tg
::
boundary_tag
>>
(
basename
+
"2_boundary"
);
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
boundary_tag
>>
(
basename
+
"3_boundary"
);
}
template
<
template
<
int
,
class
,
class
>
class
ObjT
>
void
test_object_type_3_boundary
(
std
::
string
basename
)
{
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
default_object_tag
>>
(
basename
+
"3"
);
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
boundary_tag
>>
(
basename
+
"3_boundary"
);
}
template
<
template
<
int
,
class
,
class
>
class
ObjT
>
void
test_object_type_boundary_caps
(
std
::
string
basename
)
{
test_single_object_type
<
ObjT
<
2
,
float
,
tg
::
default_object_tag
>>
(
basename
+
"2"
);
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
default_object_tag
>>
(
basename
+
"3"
);
test_single_object_type
<
ObjT
<
2
,
float
,
tg
::
boundary_tag
>>
(
basename
+
"2_boundary"
);
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
boundary_tag
>>
(
basename
+
"3_boundary"
);
test_single_object_type
<
ObjT
<
2
,
float
,
tg
::
boundary_no_caps_tag
>>
(
basename
+
"2_boundary_no_caps"
);
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
boundary_no_caps_tag
>>
(
basename
+
"3_boundary_no_caps"
);
}
template
<
template
<
int
,
class
,
class
>
class
ObjT
>
void
test_object_type_3_boundary_caps
(
std
::
string
basename
)
{
// std::less<tg::ray3> l;
// l(tg::ray3{}, tg::ray3{});
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
default_object_tag
>>
(
basename
+
"3"
);
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
boundary_tag
>>
(
basename
+
"3_boundary"
);
test_single_object_type
<
ObjT
<
3
,
float
,
tg
::
boundary_no_caps_tag
>>
(
basename
+
"3_boundary_no_caps"
);
}
template
<
template
<
int
,
class
,
int
,
class
>
class
ObjT
>
void
test_object_type_23_boundary
(
std
::
string
basename
)
{
test_single_object_type
<
ObjT
<
2
,
float
,
2
,
tg
::
default_object_tag
>>
(
basename
+
"2"
);
test_single_object_type
<
ObjT
<
2
,
float
,
3
,
tg
::
default_object_tag
>>
(
basename
+
"2in3"
);
test_single_object_type
<
ObjT
<
3
,
float
,
3
,
tg
::
default_object_tag
>>
(
basename
+
"3"
);
test_single_object_type
<
ObjT
<
2
,
float
,
2
,
tg
::
boundary_tag
>>
(
basename
+
"2_boundary"
);
test_single_object_type
<
ObjT
<
2
,
float
,
3
,
tg
::
boundary_tag
>>
(
basename
+
"2in3_boundary"
);
test_single_object_type
<
ObjT
<
3
,
float
,
3
,
tg
::
boundary_tag
>>
(
basename
+
"3_boundary"
);
}
}
TEST_CASE
(
"implementation report"
)
{
// objects
obj_tester
<
tg
::
aabb
>::
test
(
"aabb"
);
obj_tester
<
tg
::
ball
>::
test
(
"ball"
);
obj_tester
<
tg
::
box
>::
test
(
"box"
);
obj_tester
<
tg
::
capsule
>::
test
(
"capsule"
);
obj_tester
<
tg
::
circle
>::
test
(
"circle"
);
obj_tester
<
tg
::
cone
>::
test
(
"cone"
);
obj_tester
<
tg
::
cylinder
>::
test
(
"cylinder"
);
obj_tester
<
tg
::
disk
>::
test
(
"disk"
);
// obj_tester<tg::frustum>::test();
obj_tester
<
tg
::
halfspace
>::
test
(
"halfspace"
);
obj_tester
<
tg
::
hemisphere
>::
test
(
"hemisphere"
);
obj_tester
<
tg
::
plane
>::
test
(
"plane"
);
obj_tester
<
tg
::
inf_cone
>::
test
(
"inf_cone"
);
obj_tester
<
tg
::
inf_cylinder
>::
test
(
"inf_cylinder"
);
obj_tester
<
tg
::
line
>::
test
(
"line"
);
obj_tester
<
tg
::
pyramid
>::
test
(
"pyramid"
);
obj_tester
<
tg
::
ray
>::
test
(
"ray"
);
obj_tester
<
tg
::
rect
>::
test
(
"rect"
);
obj_tester
<
tg
::
segment
>::
test
(
"segment"
);
obj_tester
<
tg
::
sphere
>::
test
(
"sphere"
);
obj_tester
<
tg
::
triangle
>::
test
(
"triangle"
);
obj_tester
<
tg
::
tube
>::
test
(
"tube"
);
test_object_type
<
tg
::
line
>
(
"line"
);
test_object_type
<
tg
::
ray
>
(
"ray"
);
test_object_type
<
tg
::
segment
>
(
"segment"
);
test_object_type
<
tg
::
triangle
>
(
"triangle"
);
test_object_type
<
tg
::
quad
>
(
"quad"
);
test_object_type
<
tg
::
halfspace
>
(
"halfspace"
);
test_object_type
<
tg
::
plane
>
(
"plane"
);
test_object_type_boundary
<
tg
::
aabb
>
(
"aabb"
);
test_object_type_boundary
<
tg
::
inf_cone
>
(
"inf_cone"
);
test_object_type_boundary
<
tg
::
inf_cylinder
>
(
"inf_cylinder"
);
test_object_type_boundary_caps
<
tg
::
hemisphere
>
(
"hemisphere"
);
test_object_type_3_boundary
<
tg
::
capsule
>
(
"capsule"
);
test_object_type_3_boundary_caps
<
tg
::
cylinder
>
(
"cylinder"
);
test_object_type_23_boundary
<
tg
::
box
>
(
"box"
);
test_object_type_23_boundary
<
tg
::
sphere
>
(
"sphere"
);
}
#endif
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