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
Dmitri Naumov
ogs
Commits
7b88b498
Commit
7b88b498
authored
9 years ago
by
Dmitri Naumov
Committed by
Tom Fischer
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[MeL] Use unique_ptr inside createRasterLayers().
This avoids memory leaks.
parent
b66e740e
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
MeshLib/MeshGenerators/LayeredVolume.cpp
+8
-15
8 additions, 15 deletions
MeshLib/MeshGenerators/LayeredVolume.cpp
with
8 additions
and
15 deletions
MeshLib/MeshGenerators/LayeredVolume.cpp
+
8
−
15
View file @
7b88b498
...
@@ -42,34 +42,28 @@ bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh,
...
@@ -42,34 +42,28 @@ bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh,
// remove line elements, only tri + quad remain
// remove line elements, only tri + quad remain
MeshLib
::
ElementSearch
ex
(
mesh
);
MeshLib
::
ElementSearch
ex
(
mesh
);
ex
.
searchByElementType
(
MeshLib
::
MeshElemType
::
LINE
);
ex
.
searchByElementType
(
MeshLib
::
MeshElemType
::
LINE
);
MeshLib
::
Mesh
*
top
(
removeElements
(
mesh
,
ex
.
getSearchedElementIDs
(),
"MeshLayer"
));
std
::
unique_ptr
<
MeshLib
::
Mesh
>
top
(
removeElements
(
mesh
,
ex
.
getSearchedElementIDs
(),
"MeshLayer"
));
if
(
top
==
nullptr
)
if
(
top
==
nullptr
)
top
=
new
MeshLib
::
Mesh
(
mesh
);
top
.
reset
(
new
MeshLib
::
Mesh
(
mesh
)
)
;
if
(
!
MeshLib
::
MeshLayerMapper
::
layerMapping
(
*
top
,
*
rasters
.
back
(),
noDataReplacementValue
))
{
if
(
!
MeshLib
::
MeshLayerMapper
::
layerMapping
(
delete
top
;
*
top
,
*
rasters
.
back
(),
noDataReplacementValue
))
return
false
;
return
false
;
}
MeshLib
::
Mesh
*
bottom
(
new
MeshLib
::
Mesh
(
*
top
));
std
::
unique_ptr
<
MeshLib
::
Mesh
>
bottom
(
new
MeshLib
::
Mesh
(
*
top
));
if
(
!
MeshLib
::
MeshLayerMapper
::
layerMapping
(
*
bottom
,
*
rasters
[
0
],
0
))
if
(
!
MeshLib
::
MeshLayerMapper
::
layerMapping
(
*
bottom
,
*
rasters
[
0
],
0
))
{
delete
top
;
delete
bottom
;
return
false
;
return
false
;
}
this
->
_minimum_thickness
=
minimum_thickness
;
this
->
_minimum_thickness
=
minimum_thickness
;
_nodes
=
MeshLib
::
copyNodeVector
(
bottom
->
getNodes
());
_nodes
=
MeshLib
::
copyNodeVector
(
bottom
->
getNodes
());
_elements
=
MeshLib
::
copyElementVector
(
bottom
->
getElements
(),
_nodes
);
_elements
=
MeshLib
::
copyElementVector
(
bottom
->
getElements
(),
_nodes
);
if
(
!
_materials
.
empty
())
{
if
(
!
_materials
.
empty
())
{
ERR
(
"The materials vector is not empty."
);
ERR
(
"The materials vector is not empty."
);
delete
top
;
delete
bottom
;
return
false
;
return
false
;
}
}
_materials
.
resize
(
_elements
.
size
(),
0
);
_materials
.
resize
(
_elements
.
size
(),
0
);
delete
bottom
;
// map each layer and attach to subsurface mesh
// map each layer and attach to subsurface mesh
const
std
::
size_t
nRasters
(
rasters
.
size
());
const
std
::
size_t
nRasters
(
rasters
.
size
());
...
@@ -80,7 +74,6 @@ bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh,
...
@@ -80,7 +74,6 @@ bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh,
this
->
addLayerBoundaries
(
*
top
,
nRasters
);
this
->
addLayerBoundaries
(
*
top
,
nRasters
);
this
->
removeCongruentElements
(
nRasters
,
top
->
getNElements
());
this
->
removeCongruentElements
(
nRasters
,
top
->
getNElements
());
delete
top
;
return
true
;
return
true
;
}
}
...
...
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