Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
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
Feliks Kiszkurno
ogs-feliks
Commits
34b4eedd
Commit
34b4eedd
authored
12 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Coping points within PointVec::makePntsUnique() is faster.
parent
f93bcffd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GeoLib/PointVec.cpp
+14
-24
14 additions, 24 deletions
GeoLib/PointVec.cpp
GeoLib/PointVec.h
+1
-1
1 addition, 1 deletion
GeoLib/PointVec.h
with
15 additions
and
25 deletions
GeoLib/PointVec.cpp
+
14
−
24
View file @
34b4eedd
...
@@ -41,7 +41,8 @@ PointVec::PointVec (const std::string& name, std::vector<Point*>* points,
...
@@ -41,7 +41,8 @@ PointVec::PointVec (const std::string& name, std::vector<Point*>* points,
makePntsUnique
(
_data_vec
,
_pnt_id_map
,
rel_eps
);
makePntsUnique
(
_data_vec
,
_pnt_id_map
,
rel_eps
);
if
(
number_of_all_input_pnts
-
_data_vec
->
size
()
>
0
)
if
(
number_of_all_input_pnts
-
_data_vec
->
size
()
>
0
)
WARN
(
"PointVec::PointVec(): there are %d double points."
,
number_of_all_input_pnts
-
_data_vec
->
size
());
WARN
(
"PointVec::PointVec(): there are %d double points."
,
number_of_all_input_pnts
-
_data_vec
->
size
());
}
}
PointVec
::~
PointVec
()
PointVec
::~
PointVec
()
...
@@ -114,7 +115,7 @@ double PointVec::getShortestPointDistance () const
...
@@ -114,7 +115,7 @@ double PointVec::getShortestPointDistance () const
return
sqrt
(
_sqr_shortest_dist
);
return
sqrt
(
_sqr_shortest_dist
);
}
}
void
PointVec
::
makePntsUnique
(
std
::
vector
<
GeoLib
::
Point
*>
*
pnt_vec
,
void
PointVec
::
makePntsUnique
(
std
::
vector
<
GeoLib
::
Point
*>
*&
pnt_vec
,
std
::
vector
<
size_t
>
&
pnt_id_map
,
double
eps
)
std
::
vector
<
size_t
>
&
pnt_id_map
,
double
eps
)
{
{
size_t
n_pnts_in_file
(
pnt_vec
->
size
());
size_t
n_pnts_in_file
(
pnt_vec
->
size
());
...
@@ -178,21 +179,24 @@ void PointVec::makePntsUnique (std::vector<GeoLib::Point*>* pnt_vec,
...
@@ -178,21 +179,24 @@ void PointVec::makePntsUnique (std::vector<GeoLib::Point*>* pnt_vec,
BaseLib
::
Quicksort
<
std
::
size_t
,
GeoLib
::
Point
*>
(
perm
,
0
,
n_pnts_in_file
,
*
pnt_vec
);
BaseLib
::
Quicksort
<
std
::
size_t
,
GeoLib
::
Point
*>
(
perm
,
0
,
n_pnts_in_file
,
*
pnt_vec
);
// remove the second, third, ... occurrence from vector
// remove the second, third, ... occurrence from vector
for
(
size_t
k
(
0
);
k
<
n_pnts_in_file
;
k
++
)
for
(
size_t
k
(
0
);
k
<
n_pnts_in_file
;
k
++
)
{
if
(
pnt_id_map
[
k
]
<
k
)
if
(
pnt_id_map
[
k
]
<
k
)
{
{
delete
(
*
pnt_vec
)[
k
];
delete
(
*
pnt_vec
)[
k
];
(
*
pnt_vec
)[
k
]
=
NULL
;
(
*
pnt_vec
)[
k
]
=
NULL
;
}
}
// remove NULL-ptr from vector
for
(
std
::
vector
<
GeoLib
::
Point
*>::
iterator
it
(
pnt_vec
->
begin
());
it
!=
pnt_vec
->
end
();
)
{
if
(
*
it
==
NULL
)
it
=
pnt_vec
->
erase
(
it
);
else
it
++
;
}
}
std
::
vector
<
GeoLib
::
Point
*>*
tmp_pnt_vec
(
new
std
::
vector
<
GeoLib
::
Point
*>
);
// erasing elements from a vector is expensive, for this reason copy non nullptr to new vector
for
(
std
::
vector
<
GeoLib
::
Point
*>::
iterator
it
(
pnt_vec
->
begin
());
it
!=
pnt_vec
->
end
();
)
{
if
(
*
it
!=
nullptr
)
tmp_pnt_vec
->
push_back
(
*
it
);
it
++
;
}
std
::
swap
(
tmp_pnt_vec
,
pnt_vec
);
delete
tmp_pnt_vec
;
// renumber id-mapping
// renumber id-mapping
size_t
cnt
(
0
);
size_t
cnt
(
0
);
for
(
size_t
k
(
0
);
k
<
n_pnts_in_file
;
k
++
)
for
(
size_t
k
(
0
);
k
<
n_pnts_in_file
;
k
++
)
...
@@ -205,18 +209,6 @@ void PointVec::makePntsUnique (std::vector<GeoLib::Point*>* pnt_vec,
...
@@ -205,18 +209,6 @@ void PointVec::makePntsUnique (std::vector<GeoLib::Point*>* pnt_vec,
else
else
pnt_id_map
[
k
]
=
pnt_id_map
[
pnt_id_map
[
k
]];
pnt_id_map
[
k
]
=
pnt_id_map
[
pnt_id_map
[
k
]];
}
}
// KR correct renumbering of indices
// size_t cnt(0);
// std::map<size_t, size_t> reg_ids;
// for (size_t k(0); k < n_pnts_in_file; k++) {
// if (pnt_id_map[k] == k) {
// reg_ids.insert(std::pair<size_t, size_t>(k, cnt));
// cnt++;
// } else reg_ids.insert(std::pair<size_t, size_t>(k, reg_ids[pnt_id_map[k]]));
// }
// for (size_t k(0); k < n_pnts_in_file; k++)
// pnt_id_map[k] = reg_ids[k];
}
}
void
PointVec
::
calculateShortestDistance
()
void
PointVec
::
calculateShortestDistance
()
...
@@ -236,6 +228,4 @@ std::vector<GeoLib::Point*>* PointVec::getSubset(const std::vector<size_t> &subs
...
@@ -236,6 +228,4 @@ std::vector<GeoLib::Point*>* PointVec::getSubset(const std::vector<size_t> &subs
return
new_points
;
return
new_points
;
}
}
}
// end namespace
}
// end namespace
This diff is collapsed.
Click to expand it.
GeoLib/PointVec.h
+
1
−
1
View file @
34b4eedd
...
@@ -108,7 +108,7 @@ public:
...
@@ -108,7 +108,7 @@ public:
std
::
vector
<
GeoLib
::
Point
*>*
getSubset
(
const
std
::
vector
<
std
::
size_t
>
&
subset
);
std
::
vector
<
GeoLib
::
Point
*>*
getSubset
(
const
std
::
vector
<
std
::
size_t
>
&
subset
);
private
:
private
:
void
makePntsUnique
(
std
::
vector
<
GeoLib
::
Point
*>*
pnt_vec
,
std
::
vector
<
std
::
size_t
>
&
pnt_id_map
,
double
eps
=
sqrt
(
std
::
numeric_limits
<
double
>::
min
()));
void
makePntsUnique
(
std
::
vector
<
GeoLib
::
Point
*>*
&
pnt_vec
,
std
::
vector
<
std
::
size_t
>
&
pnt_id_map
,
double
eps
=
sqrt
(
std
::
numeric_limits
<
double
>::
min
()));
/** copy constructor doesn't have an implementation */
/** copy constructor doesn't have an implementation */
// compiler does not create a (possible unwanted) copy constructor
// compiler does not create a (possible unwanted) copy constructor
...
...
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