Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tg-samples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Philip Trettner
tg-samples
Commits
48f717c5
Commit
48f717c5
authored
4 years ago
by
Aaron Grabowy
Browse files
Options
Downloads
Patches
Plain Diff
Added visualization for project
parent
f8626d9b
No related branches found
No related tags found
1 merge request
!41
Visual demonstration of object properties
Pipeline
#16467
failed
4 years ago
Stage: Build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
samples/04-object-properties/main.cc
+30
-5
30 additions, 5 deletions
samples/04-object-properties/main.cc
with
30 additions
and
5 deletions
samples/04-object-properties/main.cc
+
30
−
5
View file @
48f717c5
...
@@ -7,8 +7,15 @@ template <class Obj>
...
@@ -7,8 +7,15 @@ template <class Obj>
void
test_obj
(
Obj
const
&
obj
)
void
test_obj
(
Obj
const
&
obj
)
{
{
tg
::
rng
rng
;
tg
::
rng
rng
;
const
int
domainD
=
tg
::
object_traits
<
Obj
>::
domain_dimension
;
auto
const
domainD
=
tg
::
object_traits
<
Obj
>::
domain_dimension
;
const
int
objectD
=
tg
::
object_traits
<
Obj
>::
object_dimension
;
auto
const
objectD
=
tg
::
object_traits
<
Obj
>::
object_dimension
;
auto
const
solidD
=
[
&
objectD
]
{
if
constexpr
(
tg
::
object_traits
<
Obj
>::
is_boundary
)
return
objectD
+
1
;
return
objectD
;
}();
using
TraitsT
=
typename
tg
::
object_traits
<
Obj
>::
tag_t
;
if
constexpr
(
tg
::
object_traits
<
Obj
>::
is_finite
)
if
constexpr
(
tg
::
object_traits
<
Obj
>::
is_finite
)
{
{
float
size
;
float
size
;
...
@@ -26,6 +33,7 @@ void test_obj(Obj const& obj)
...
@@ -26,6 +33,7 @@ void test_obj(Obj const& obj)
uniformPts
.
emplace_back
(
uniform
(
rng
,
obj
));
uniformPts
.
emplace_back
(
uniform
(
rng
,
obj
));
auto
const
aabb
=
aabb_of
(
obj
);
auto
const
aabb
=
aabb_of
(
obj
);
auto
const
aabbBigger
=
tg
::
aabb
(
aabb
.
min
-
0.25
f
,
aabb
.
max
+
0.25
f
);
tg
::
aabb3
aabb3
;
tg
::
aabb3
aabb3
;
if
constexpr
(
domainD
==
3
)
if
constexpr
(
domainD
==
3
)
aabb3
=
aabb
;
aabb3
=
aabb
;
...
@@ -53,11 +61,10 @@ void test_obj(Obj const& obj)
...
@@ -53,11 +61,10 @@ void test_obj(Obj const& obj)
gv
::
view
(
gv
::
lines
(
aabb3
));
gv
::
view
(
gv
::
lines
(
aabb3
));
// normal_of
// normal_of
if
constexpr
(
domainD
==
3
&&
((
objectD
==
2
&&
!
tg
::
object_traits
<
Obj
>::
is_boundary
)
||
(
objectD
==
1
&&
tg
::
object_traits
<
Obj
>::
is_boundary
))
)
if
constexpr
(
domainD
==
3
&&
solidD
==
2
)
gv
::
view
(
tg
::
segment3
(
centroid
,
centroid
+
normal_of
(
obj
)),
tg
::
color4
::
green
);
gv
::
view
(
tg
::
segment3
(
centroid
,
centroid
+
normal_of
(
obj
)),
tg
::
color4
::
green
);
}
}
{
{
auto
const
aabbBigger
=
tg
::
aabb
(
aabb
.
min
-
0.25
f
,
aabb
.
max
+
0.25
f
);
auto
pointsInside
=
std
::
vector
<
tg
::
pos3
>
();
auto
pointsInside
=
std
::
vector
<
tg
::
pos3
>
();
auto
pointsOutside
=
std
::
vector
<
tg
::
pos3
>
();
auto
pointsOutside
=
std
::
vector
<
tg
::
pos3
>
();
auto
const
numPts
=
tg
::
pow
(
20.
f
,
domainD
);
auto
const
numPts
=
tg
::
pow
(
20.
f
,
domainD
);
...
@@ -73,9 +80,27 @@ void test_obj(Obj const& obj)
...
@@ -73,9 +80,27 @@ void test_obj(Obj const& obj)
// contains
// contains
auto
v
=
gv
::
view
();
auto
v
=
gv
::
view
();
view
(
pointsInside
,
gv
::
maybe_empty
,
tg
::
color4
::
green
);
view
(
pointsInside
,
gv
::
maybe_empty
,
tg
::
color4
::
green
,
"contains (+-"
+
tg
::
to_string
(
tolerance
)
+
")"
);
gv
::
view
(
gv
::
points
(
pointsOutside
).
point_size_px
(
5.
f
));
gv
::
view
(
gv
::
points
(
pointsOutside
).
point_size_px
(
5.
f
));
}
}
if
constexpr
(
!
std
::
is_same_v
<
Obj
,
tg
::
ellipse
<
solidD
,
float
,
domainD
,
TraitsT
>>
)
{
auto
points
=
std
::
vector
<
tg
::
pos3
>
();
auto
lines
=
std
::
vector
<
tg
::
segment3
>
();
auto
const
numPts
=
tg
::
pow
(
20.
f
,
domainD
);
for
(
auto
i
=
0
;
i
<
numPts
;
++
i
)
{
auto
const
p
=
uniform
(
rng
,
aabbBigger
);
auto
const
pProj
=
tg
::
pos3
(
project
(
p
,
obj
));
points
.
emplace_back
(
pProj
);
if
(
!
contains
(
obj
,
p
))
lines
.
emplace_back
(
tg
::
pos3
(
p
),
pProj
);
}
// project
auto
v
=
gv
::
view
();
gv
::
view
(
points
,
"project"
);
gv
::
view
(
lines
);
}
}
}
}
}
...
...
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