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
Snippets
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
Özgür Ozan Sen
ogs
Commits
aa472555
Commit
aa472555
authored
9 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[MGTL] Use unique_ptr in GeoMapper for geoobjects.
parent
2ee61819
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MeshGeoToolsLib/GeoMapper.cpp
+23
-14
23 additions, 14 deletions
MeshGeoToolsLib/GeoMapper.cpp
with
23 additions
and
14 deletions
MeshGeoToolsLib/GeoMapper.cpp
+
23
−
14
View file @
aa472555
...
...
@@ -185,22 +185,27 @@ double GeoMapper::getMeshElevation(
return
(
*
(
_surface_mesh
->
getNode
(
pnt
->
getID
())))[
2
];
}
unsigned
getIndexInPntVec
(
GeoLib
::
Point
const
*
const
pnt
,
std
::
vector
<
GeoLib
::
Point
*>
const
*
const
points
)
unsigned
getIndexInPntVec
(
GeoLib
::
Point
const
*
const
pnt
,
std
::
vector
<
GeoLib
::
Point
*>
const
&
points
)
{
auto
it
(
std
::
find
(
points
->
begin
(),
points
->
end
(),
pnt
));
return
static_cast
<
unsigned
>
(
std
::
distance
(
points
->
begin
(),
it
));
auto
it
(
std
::
find
(
points
.
begin
(),
points
.
end
(),
pnt
));
return
static_cast
<
unsigned
>
(
std
::
distance
(
points
.
begin
(),
it
));
}
std
::
vector
<
GeoLib
::
Polyline
*>*
copyPolylinesVector
(
const
std
::
vector
<
GeoLib
::
Polyline
*>
*
polylines
,
std
::
vector
<
GeoLib
::
Point
*>
*
points
)
std
::
unique_ptr
<
std
::
vector
<
GeoLib
::
Polyline
*>>
copyPolylinesVector
(
std
::
vector
<
GeoLib
::
Polyline
*>
const
&
polylines
,
std
::
vector
<
GeoLib
::
Point
*>
const
&
points
)
{
std
::
size_t
nLines
=
polylines
->
size
();
std
::
vector
<
GeoLib
::
Polyline
*>
*
new_lines
=
new
std
::
vector
<
GeoLib
::
Polyline
*>
(
nLines
);
std
::
size_t
nLines
=
polylines
.
size
();
auto
new_lines
=
std
::
unique_ptr
<
std
::
vector
<
GeoLib
::
Polyline
*>>
(
new
std
::
vector
<
GeoLib
::
Polyline
*>
(
nLines
));
for
(
std
::
size_t
i
=
0
;
i
<
nLines
;
++
i
)
{
(
*
new_lines
)[
i
]
=
new
GeoLib
::
Polyline
(
*
points
);
std
::
size_t
nLinePnts
(
(
*
polylines
)
[
i
]
->
getNumberOfPoints
());
(
*
new_lines
)[
i
]
=
new
GeoLib
::
Polyline
(
points
);
std
::
size_t
nLinePnts
(
polylines
[
i
]
->
getNumberOfPoints
());
for
(
std
::
size_t
j
=
0
;
j
<
nLinePnts
;
++
j
)
(
*
new_lines
)[
i
]
->
addPoint
(
(
*
polylines
)
[
i
]
->
getPointID
(
j
));
(
*
new_lines
)[
i
]
->
addPoint
(
polylines
[
i
]
->
getPointID
(
j
));
}
return
new_lines
;
}
...
...
@@ -218,10 +223,12 @@ void GeoMapper::advancedMapOnMesh(
// copy geometry (and set z=0 for all points)
unsigned
nGeoPoints
(
points
->
size
()
);
std
::
vector
<
GeoLib
::
Point
*>
*
new_points
=
new
std
::
vector
<
GeoLib
::
Point
*>
(
nGeoPoints
);
auto
new_points
=
std
::
unique_ptr
<
std
::
vector
<
GeoLib
::
Point
*>>
(
new
std
::
vector
<
GeoLib
::
Point
*>
);
for
(
std
::
size_t
i
=
0
;
i
<
nGeoPoints
;
++
i
)
(
*
new_points
)[
i
]
=
new
GeoLib
::
Point
((
*
(
*
points
)[
i
])[
0
],(
*
(
*
points
)[
i
])[
1
],
0.0
);
std
::
vector
<
GeoLib
::
Polyline
*>
*
new_lines
(
copyPolylinesVector
(
this
->
_geo_objects
.
getPolylineVec
(
this
->
_geo_name
),
new_points
));
auto
new_lines
=
copyPolylinesVector
(
*
_geo_objects
.
getPolylineVec
(
this
->
_geo_name
),
*
new_points
);
GeoLib
::
Grid
<
GeoLib
::
Point
>
grid
(
new_points
->
begin
(),
new_points
->
end
());
double
max_segment_length
(
this
->
getMaxSegmentLength
(
*
new_lines
));
...
...
@@ -239,7 +246,9 @@ void GeoMapper::advancedMapOnMesh(
(
*
mesh
->
getNode
(
i
))[
1
],
0.0
,
mesh
->
getNode
(
i
)
->
getID
());
GeoLib
::
Point
*
pnt
=
grid
.
getNearestPoint
(
zero_coords
);
dist
[
i
]
=
MathLib
::
sqrDist
(
*
pnt
,
zero_coords
);
closest_geo_point
[
i
]
=
(
dist
[
i
]
<=
max_segment_length
)
?
getIndexInPntVec
(
pnt
,
new_points
)
:
-
1
;
closest_geo_point
[
i
]
=
(
dist
[
i
]
<=
max_segment_length
)
?
getIndexInPntVec
(
pnt
,
*
new_points
)
:
-
1
;
}
// store for each point the line segment to which it was added.
...
...
@@ -313,11 +322,11 @@ void GeoMapper::advancedMapOnMesh(
}
}
this
->
_geo_objects
.
addPointVec
(
new_points
,
const_cast
<
std
::
string
&>
(
new_geo_name
));
this
->
_geo_objects
.
addPointVec
(
std
::
move
(
new_points
)
,
const_cast
<
std
::
string
&>
(
new_geo_name
));
std
::
vector
<
std
::
size_t
>
pnt_id_map
=
this
->
_geo_objects
.
getPointVecObj
(
new_geo_name
)
->
getIDMap
();
for
(
std
::
size_t
i
=
0
;
i
<
new_lines
->
size
();
++
i
)
(
*
new_lines
)[
i
]
->
updatePointIDs
(
pnt_id_map
);
this
->
_geo_objects
.
addPolylineVec
(
new_lines
,
new_geo_name
);
_geo_objects
.
addPolylineVec
(
std
::
move
(
new_lines
)
,
new_geo_name
);
// map new geometry incl. additional point using the normal mapping method
this
->
_geo_name
=
new_geo_name
;
...
...
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