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
OpenFlipper-Free
OpenFlipper-Free
Commits
0968ddc4
Commit
0968ddc4
authored
Oct 20, 2016
by
Jan Möbius
Browse files
Minor cleanup in triangulator:
- Fix Warning size_t int conversions - Use bool instead of int for success
parent
f2f417c5
Pipeline
#3238
passed with stage
in 37 minutes and 32 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ACG/Geometry/Triangulator.cc
View file @
0968ddc4
...
...
@@ -61,7 +61,7 @@ namespace ACG {
Triangulator
::
Triangulator
(
const
std
::
vector
<
Vec3f
>&
_pos
)
:
polySize_
(
_pos
.
size
()),
numRemaningVertices_
(
_pos
.
size
()),
numTris_
(
0
),
numReflexVertices_
(
0
),
status_
(
-
1
),
convex_
(
false
)
ok_
(
false
),
convex_
(
false
)
{
if
(
polySize_
<
3
)
return
;
...
...
@@ -77,7 +77,7 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
numRemaningVertices_
=
0
;
convex_
=
true
;
status_
=
0
;
ok_
=
true
;
}
else
{
...
...
@@ -89,9 +89,9 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
Vec3f
n
(
0.0
f
,
0.0
f
,
0.0
f
);
for
(
in
t
i
=
0
;
i
<
polySize_
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
polySize_
;
++
i
)
{
in
t
next
=
(
i
+
1
)
%
polySize_
;
const
size_
t
next
=
(
i
+
1
)
%
polySize_
;
Vec3f
a
=
_pos
[
i
]
-
_pos
[
next
];
Vec3f
b
=
_pos
[
i
]
+
_pos
[
next
];
...
...
@@ -124,7 +124,7 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
axis
[
1
]
=
axis
[
2
]
%
axis
[
0
];
for
(
in
t
i
=
0
;
i
<
polySize_
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
polySize_
;
++
i
)
{
// project onto polygon plane
pos_
[
i
][
0
]
=
axis
[
0
]
|
_pos
[
i
];
...
...
@@ -135,7 +135,7 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
// create triangle fans if there is at most one concave vertex
int
reflexVertexID
=
0
;
for
(
in
t
i
=
0
;
i
<
polySize_
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
polySize_
;
++
i
)
{
// test vertex (i+1)
if
(
isReflexVertex
(
pos_
[
i
],
pos_
[(
i
+
1
)
%
polySize_
],
pos_
[(
i
+
2
)
%
polySize_
]))
...
...
@@ -154,9 +154,9 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
numTris_
=
polySize_
-
2
;
tris_
.
resize
(
numTris_
*
3
);
numRemaningVertices_
=
0
;
status_
=
0
;
ok_
=
true
;
for
(
in
t
i
=
0
;
i
<
numTris_
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
numTris_
;
++
i
)
{
tris_
[
i
*
3
]
=
reflexVertexID
;
tris_
[
i
*
3
+
1
]
=
(
reflexVertexID
+
i
+
1
)
%
polySize_
;
...
...
@@ -282,10 +282,10 @@ void Triangulator::initVertexList()
{
vertices_
.
resize
(
polySize_
);
reflexVertices_
.
clear
();
for
(
in
t
i
=
0
;
i
<
polySize_
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
polySize_
;
++
i
)
{
in
t
p
=
(
i
+
polySize_
-
1
)
%
polySize_
;
in
t
n
=
(
i
+
1
)
%
polySize_
;
size_
t
p
=
(
i
+
polySize_
-
1
)
%
polySize_
;
size_
t
n
=
(
i
+
1
)
%
polySize_
;
vertices_
[
i
]
=
RingVertex
(
i
,
isReflexVertex
(
pos_
[
p
],
pos_
[
i
],
pos_
[
n
]),
pos_
[
i
],
&
vertices_
[
p
],
&
vertices_
[
n
]);
...
...
@@ -302,7 +302,7 @@ int Triangulator::earClippingN3()
// O(n^3)
numTris_
=
0
;
status_
=
0
;
ok_
=
true
;
initVertexList
();
...
...
@@ -386,13 +386,13 @@ int Triangulator::earClippingN2()
// O(n^2)
numTris_
=
0
;
status_
=
0
;
ok_
=
true
;
initVertexList
();
// triangulate
in
t
numTries
=
0
;
// # checked vertices per iteration that aren't ears
size_
t
numTries
=
0
;
// # checked vertices per iteration that aren't ears
numRemaningVertices_
=
polySize_
;
// size of currently remaining polygon
int
numIterations
=
0
;
...
...
@@ -439,7 +439,7 @@ int Triangulator::earClippingN2()
addEar
(
curVertex
);
numTries
=
0
;
status_
=
1
;
ok_
=
false
;
}
curVertex
=
curVertex
->
next
;
...
...
@@ -496,4 +496,4 @@ void Triangulator::addEar(RingVertex* _earTip)
}
\ No newline at end of file
}
ACG/Geometry/Triangulator.hh
View file @
0968ddc4
...
...
@@ -120,7 +120,7 @@ public:
*
* @return success true or false
*/
bool
success
()
const
{
return
!
status
_
;
}
bool
success
()
const
{
return
ok
_
;
}
private:
...
...
@@ -169,12 +169,12 @@ private:
void
addEar
(
RingVertex
*
_earTip
);
const
in
t
polySize_
;
in
t
numRemaningVertices_
;
in
t
numTris_
;
in
t
numReflexVertices_
;
const
size_
t
polySize_
;
size_
t
numRemaningVertices_
;
size_
t
numTris_
;
size_
t
numReflexVertices_
;
int
status
_
;
bool
ok
_
;
bool
convex_
;
...
...
@@ -196,4 +196,4 @@ private:
//=============================================================================
#endif // ACG_TRIANGULATOR_HH defined
//=============================================================================
\ No newline at end of file
//=============================================================================
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