Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RBComb Sample Visualizer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Pascal Engeler
RBComb Sample Visualizer
Commits
1aedc2a0
Commit
1aedc2a0
authored
1 year ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug where several attachment modes are possible
parent
ed3160bf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data_generation/cpp/src/linestrip.cpp
+19
-1
19 additions, 1 deletion
data_generation/cpp/src/linestrip.cpp
with
19 additions
and
1 deletion
data_generation/cpp/src/linestrip.cpp
+
19
−
1
View file @
1aedc2a0
#include
<linestrip.hpp>
#include
<linestrip.hpp>
#include
<algorithm>
#include
<algorithm>
#ifndef NDEBUG
#include
<iostream>
#endif
bool
isEqual
(
const
double
x
,
const
double
y
,
const
double
tol
=
1e-8
){
bool
isEqual
(
const
double
x
,
const
double
y
,
const
double
tol
=
1e-8
){
return
(
x
-
y
<
tol
)
&&
(
y
-
x
<
tol
);
return
(
x
-
y
<
tol
)
&&
(
y
-
x
<
tol
);
...
@@ -15,6 +18,16 @@ void reverseNodes(std::vector<double>& nodes){
...
@@ -15,6 +18,16 @@ void reverseNodes(std::vector<double>& nodes){
LineStrip
::
LineStrip
(
std
::
vector
<
double
>
nodes
)
:
_nodes
(
nodes
),
_isClosed
(
false
),
_isActive
(
true
)
{}
LineStrip
::
LineStrip
(
std
::
vector
<
double
>
nodes
)
:
_nodes
(
nodes
),
_isClosed
(
false
),
_isActive
(
true
)
{}
void
LineStrip
::
attach
(
LineStrip
&
other
,
int
mode
){
void
LineStrip
::
attach
(
LineStrip
&
other
,
int
mode
){
#ifndef NDEBUG
std
::
cout
<<
"ATTACH
\n
"
;
std
::
cout
<<
"Mode: "
<<
mode
<<
std
::
endl
;
std
::
cout
<<
"This: ("
<<
_nodes
[
0
]
<<
", "
<<
_nodes
[
1
]
<<
") ... ("
<<
_nodes
[
_nodes
.
size
()
-
2
]
<<
", "
<<
_nodes
[
_nodes
.
size
()
-
1
]
<<
")
\n
"
;
std
::
cout
<<
"Other: "
;
for
(
int
i
=
0
;
i
<
other
.
_nodes
.
size
()
/
2
;
i
+=
2
){
std
::
cout
<<
"("
<<
other
.
_nodes
[
2
*
i
]
<<
", "
<<
other
.
_nodes
[
2
*
i
+
1
]
<<
"), "
;
}
std
::
cout
<<
std
::
endl
<<
std
::
endl
;
#endif
if
(
mode
==
1
){
//normal attach
if
(
mode
==
1
){
//normal attach
_nodes
.
reserve
(
_nodes
.
size
()
+
other
.
_nodes
.
size
());
//reserve
_nodes
.
reserve
(
_nodes
.
size
()
+
other
.
_nodes
.
size
());
//reserve
_nodes
.
insert
(
_nodes
.
end
(),
other
.
_nodes
.
begin
()
+
2
,
other
.
_nodes
.
end
());
_nodes
.
insert
(
_nodes
.
end
(),
other
.
_nodes
.
begin
()
+
2
,
other
.
_nodes
.
end
());
...
@@ -57,7 +70,12 @@ int LineStrip::canBeAttached(const LineStrip& other) const {
...
@@ -57,7 +70,12 @@ int LineStrip::canBeAttached(const LineStrip& other) const {
bool
endToEndAttach
=
isEqual
(
other
.
_nodes
[
other
.
_nodes
.
size
()
-
2
],
_nodes
[
_nodes
.
size
()
-
2
])
&&
isEqual
(
other
.
_nodes
[
other
.
_nodes
.
size
()
-
1
],
_nodes
[
_nodes
.
size
()
-
1
]);
bool
endToEndAttach
=
isEqual
(
other
.
_nodes
[
other
.
_nodes
.
size
()
-
2
],
_nodes
[
_nodes
.
size
()
-
2
])
&&
isEqual
(
other
.
_nodes
[
other
.
_nodes
.
size
()
-
1
],
_nodes
[
_nodes
.
size
()
-
1
]);
bool
startToStartAttach
=
isEqual
(
other
.
_nodes
[
0
],
_nodes
[
0
])
&&
isEqual
(
other
.
_nodes
[
1
],
_nodes
[
1
]);
bool
startToStartAttach
=
isEqual
(
other
.
_nodes
[
0
],
_nodes
[
0
])
&&
isEqual
(
other
.
_nodes
[
1
],
_nodes
[
1
]);
return
normalAttach
+
2
*
reverseAttach
+
3
*
endToEndAttach
+
4
*
startToStartAttach
;
if
(
normalAttach
&&
reverseAttach
){
return
normalAttach
;
}
else
{
return
normalAttach
+
2
*
reverseAttach
+
3
*
endToEndAttach
+
4
*
startToStartAttach
;
}
}
}
bool
LineStrip
::
isActive
()
const
{
bool
LineStrip
::
isActive
()
const
{
...
...
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