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
f8626d9b
Commit
f8626d9b
authored
4 years ago
by
Aaron Grabowy
Browse files
Options
Downloads
Patches
Plain Diff
Added visualization for contains
parent
ce608007
No related branches found
No related tags found
1 merge request
!41
Visual demonstration of object properties
Pipeline
#16466
passed
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
+49
-23
49 additions, 23 deletions
samples/04-object-properties/main.cc
with
49 additions
and
23 deletions
samples/04-object-properties/main.cc
+
49
−
23
View file @
f8626d9b
...
@@ -22,9 +22,18 @@ void test_obj(Obj const& obj)
...
@@ -22,9 +22,18 @@ void test_obj(Obj const& obj)
size
=
100.
f
+
length
(
obj
);
size
=
100.
f
+
length
(
obj
);
auto
uniformPts
=
std
::
vector
<
tg
::
pos3
>
();
auto
uniformPts
=
std
::
vector
<
tg
::
pos3
>
();
for
(
tg
::
u64
i
=
0
;
i
<
size
;
++
i
)
for
(
auto
i
=
0
;
i
<
size
;
++
i
)
uniformPts
.
emplace_back
(
uniform
(
rng
,
obj
));
uniformPts
.
emplace_back
(
uniform
(
rng
,
obj
));
auto
const
aabb
=
aabb_of
(
obj
);
tg
::
aabb3
aabb3
;
if
constexpr
(
domainD
==
3
)
aabb3
=
aabb
;
else
aabb3
=
tg
::
aabb3
(
tg
::
pos3
(
aabb
.
min
),
tg
::
pos3
(
aabb
.
max
));
auto
g
=
gv
::
grid
();
{
auto
v
=
gv
::
view
();
auto
v
=
gv
::
view
();
// uniform
// uniform
...
@@ -41,16 +50,33 @@ void test_obj(Obj const& obj)
...
@@ -41,16 +50,33 @@ void test_obj(Obj const& obj)
gv
::
view
(
gv
::
points
(
tg
::
pos3
(
centroid
)).
point_size_px
(
12.
f
),
tg
::
color4
::
green
);
gv
::
view
(
gv
::
points
(
tg
::
pos3
(
centroid
)).
point_size_px
(
12.
f
),
tg
::
color4
::
green
);
// aabb_of
// aabb_of
auto
const
aabb
=
aabb_of
(
obj
);
gv
::
view
(
gv
::
lines
(
aabb3
));
if
constexpr
(
domainD
==
3
)
gv
::
view
(
gv
::
lines
(
aabb
));
else
gv
::
view
(
gv
::
lines
(
tg
::
aabb3
(
tg
::
pos3
(
aabb
.
min
),
tg
::
pos3
(
aabb
.
max
))));
// 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
&&
((
objectD
==
2
&&
!
tg
::
object_traits
<
Obj
>::
is_boundary
)
||
(
objectD
==
1
&&
tg
::
object_traits
<
Obj
>::
is_boundary
)))
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
pointsOutside
=
std
::
vector
<
tg
::
pos3
>
();
auto
const
numPts
=
tg
::
pow
(
20.
f
,
domainD
);
auto
const
tolerance
=
objectD
<
domainD
?
0.1
f
:
0.
f
;
for
(
auto
i
=
0
;
i
<
numPts
;
++
i
)
{
auto
const
p
=
uniform
(
rng
,
aabbBigger
);
if
(
contains
(
obj
,
p
,
tolerance
))
pointsInside
.
emplace_back
(
p
);
else
pointsOutside
.
emplace_back
(
p
);
}
// contains
auto
v
=
gv
::
view
();
view
(
pointsInside
,
gv
::
maybe_empty
,
tg
::
color4
::
green
);
gv
::
view
(
gv
::
points
(
pointsOutside
).
point_size_px
(
5.
f
));
}
}
}
}
int
main
()
int
main
()
...
...
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