Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Yuhao Liu
ogs
Commits
be033bcf
Commit
be033bcf
authored
12 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
added method Polyline::removePoint()
parent
98535439
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GeoLib/Polyline.cpp
+32
-0
32 additions, 0 deletions
GeoLib/Polyline.cpp
GeoLib/Polyline.h
+7
-0
7 additions, 0 deletions
GeoLib/Polyline.h
with
39 additions
and
0 deletions
GeoLib/Polyline.cpp
+
32
−
0
View file @
be033bcf
...
...
@@ -105,6 +105,38 @@ void Polyline::insertPoint(size_t pos, size_t pnt_id)
}
}
void
Polyline
::
removePoint
(
std
::
size_t
pos
)
{
if
(
pos
>=
_ply_pnt_ids
.
size
())
return
;
_ply_pnt_ids
.
erase
(
_ply_pnt_ids
.
begin
()
+
pos
);
if
(
pos
==
_ply_pnt_ids
.
size
()
-
1
)
{
_length
.
erase
(
_length
.
begin
()
+
pos
);
return
;
}
const
size_t
n_ply_pnt_ids
(
_ply_pnt_ids
.
size
());
if
(
pos
==
0
)
{
double
seg_length
(
_length
[
0
]);
for
(
unsigned
k
(
0
);
k
<
n_ply_pnt_ids
;
k
++
)
{
_length
[
k
]
=
_length
[
k
+
1
]
-
seg_length
;
}
_length
.
pop_back
();
}
else
{
const
double
len_seg0
(
_length
[
pos
]
-
_length
[
pos
-
1
]);
const
double
len_seg1
(
_length
[
pos
+
1
]
-
_length
[
pos
]);
_length
.
erase
(
_length
.
begin
()
+
pos
);
const
double
len_new_seg
(
sqrt
(
MathLib
::
sqrDist
(
_ply_pnts
[
_ply_pnt_ids
[
pos
-
1
]],
_ply_pnts
[
pos
])));
double
seg_length_diff
(
len_new_seg
-
len_seg0
-
len_seg1
);
for
(
unsigned
k
(
pos
);
k
<
n_ply_pnt_ids
;
k
++
)
{
_length
[
k
]
+=
seg_length_diff
;
}
}
}
size_t
Polyline
::
getNumberOfPoints
()
const
{
return
_ply_pnt_ids
.
size
();
...
...
This diff is collapsed.
Click to expand it.
GeoLib/Polyline.h
+
7
−
0
View file @
be033bcf
...
...
@@ -80,6 +80,13 @@ public:
*/
virtual
void
insertPoint
(
std
::
size_t
pos
,
std
::
size_t
pnt_id
);
/**
* Method removes a point from the polyline. The connecting line segments will
* be removed and the length of the polyline will be changed.
* @param pos a valid position within the polyline
*/
virtual
void
removePoint
(
std
::
size_t
pos
);
/**
* Closes a polyline by adding a line segment that connects start- and end-point.
* \param ply A Polyline containing at least three points.
...
...
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