Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenVolumeMesh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenVolumeMesh
OpenVolumeMesh
Commits
b8e6f3d7
Commit
b8e6f3d7
authored
May 21, 2019
by
Jan Möbius
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-mh-assign' into 'master'
Implement/improve mesh assignment/copying See merge request
!56
parents
d13e0db0
f2f59897
Pipeline
#10428
passed with stage
in 3 minutes and 42 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
119 additions
and
60 deletions
+119
-60
src/OpenVolumeMesh/Core/BaseProperty.cc
src/OpenVolumeMesh/Core/BaseProperty.cc
+3
-10
src/OpenVolumeMesh/Core/BaseProperty.hh
src/OpenVolumeMesh/Core/BaseProperty.hh
+12
-1
src/OpenVolumeMesh/Core/GeometryKernel.hh
src/OpenVolumeMesh/Core/GeometryKernel.hh
+8
-2
src/OpenVolumeMesh/Core/OpenVolumeMeshProperty.hh
src/OpenVolumeMesh/Core/OpenVolumeMeshProperty.hh
+3
-0
src/OpenVolumeMesh/Core/PropertyPtr.hh
src/OpenVolumeMesh/Core/PropertyPtr.hh
+4
-0
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
+14
-0
src/OpenVolumeMesh/Core/ResourceManager.cc
src/OpenVolumeMesh/Core/ResourceManager.cc
+54
-26
src/OpenVolumeMesh/Core/ResourceManager.hh
src/OpenVolumeMesh/Core/ResourceManager.hh
+7
-0
src/OpenVolumeMesh/Core/TopologyKernel.cc
src/OpenVolumeMesh/Core/TopologyKernel.cc
+0
-13
src/OpenVolumeMesh/Core/TopologyKernel.hh
src/OpenVolumeMesh/Core/TopologyKernel.hh
+14
-8
No files found.
src/OpenVolumeMesh/Core/BaseProperty.cc
View file @
b8e6f3d7
...
...
@@ -32,18 +32,11 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 36 $ *
* $Date: 2012-01-10 18:00:06 +0100 (Di, 10 Jan 2012) $ *
* $LastChangedBy: kremer $ *
* *
\*===========================================================================*/
#include "BaseProperty.hh"
#include "ResourceManager.hh"
namespace
OpenVolumeMesh
{
// define this here to emit a vtable only in this translation unit
BaseProperty
::~
BaseProperty
()
=
default
;
}
// Namespace OpenVolumeMesh
src/OpenVolumeMesh/Core/BaseProperty.hh
View file @
b8e6f3d7
...
...
@@ -62,7 +62,8 @@ public:
BaseProperty
&
operator
=
(
const
BaseProperty
&
_cpy
)
=
delete
;
virtual
~
BaseProperty
()
{}
virtual
~
BaseProperty
();
virtual
const
std
::
string
&
name
()
const
=
0
;
...
...
@@ -88,8 +89,18 @@ public:
virtual
const
std
::
string
typeNameWrapper
()
const
=
0
;
virtual
size_t
size
()
const
=
0
;
protected:
/// Copy data from other property. `other` MUST point to an object with the same type as `this`!
/// Currently no type check is performed.
virtual
void
assign_values_from
(
const
BaseProperty
*
other
)
=
0
;
/// Move data from other property. `other` MUST point to an object with the same type as `this`!
/// Currently no type check is performed.
virtual
void
move_values_from
(
BaseProperty
*
other
)
=
0
;
virtual
void
delete_multiple_entries
(
const
std
::
vector
<
bool
>&
_tags
)
=
0
;
virtual
void
resize
(
size_t
/*_size*/
)
=
0
;
...
...
src/OpenVolumeMesh/Core/GeometryKernel.hh
View file @
b8e6f3d7
...
...
@@ -59,10 +59,16 @@ public:
typedef
TopologyKernelT
KernelT
;
/// Constructor
GeometryKernel
()
{}
GeometryKernel
()
=
default
;
/// Destructor
~
GeometryKernel
()
{}
~
GeometryKernel
()
=
default
;
template
<
class
OtherTopoKernel
>
void
assign
(
const
GeometryKernel
<
VecT
,
OtherTopoKernel
>
*
other
)
{
TopologyKernelT
::
assign
(
other
);
other
->
clone_vertices
(
vertices_
);
}
/// Override of empty add_vertex function
virtual
VertexHandle
add_vertex
()
{
return
add_vertex
(
VecT
());
}
...
...
src/OpenVolumeMesh/Core/OpenVolumeMeshProperty.hh
View file @
b8e6f3d7
...
...
@@ -88,6 +88,9 @@ public:
virtual
void
resize
(
size_t
_n
)
{
data_
.
resize
(
_n
,
def_
);
}
virtual
size_t
size
()
const
{
return
data_
.
size
();
}
virtual
void
clear
()
{
data_
.
clear
();
vector_type
().
swap
(
data_
);
...
...
src/OpenVolumeMesh/Core/PropertyPtr.hh
View file @
b8e6f3d7
...
...
@@ -91,6 +91,7 @@ public:
const_iterator
begin
()
const
{
return
ptr
::
shared_ptr
<
PropT
>::
get
()
->
begin
();
}
iterator
begin
()
{
return
ptr
::
shared_ptr
<
PropT
>::
get
()
->
begin
();
}
size_t
size
()
const
{
return
ptr
::
shared_ptr
<
PropT
>::
get
()
->
size
();
}
const_iterator
end
()
const
{
return
ptr
::
shared_ptr
<
PropT
>::
get
()
->
end
();
}
iterator
end
()
{
return
ptr
::
shared_ptr
<
PropT
>::
get
()
->
end
();
}
...
...
@@ -114,6 +115,9 @@ public:
protected:
void
assign_values_from
(
const
BaseProperty
*
other
)
override
;
void
move_values_from
(
BaseProperty
*
other
)
override
;
virtual
void
delete_multiple_entries
(
const
std
::
vector
<
bool
>&
_tags
);
virtual
void
resize
(
size_t
_size
);
...
...
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
View file @
b8e6f3d7
...
...
@@ -59,6 +59,20 @@ PropertyPtr<PropT,Entity>::~PropertyPtr() {
}
}
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
assign_values_from
(
const
BaseProperty
*
other
)
{
auto
_other
=
static_cast
<
const
PropertyPtr
<
PropT
,
Entity
>*>
(
other
);
// FIXME: would be nice to perform a type check here
ptr
::
shared_ptr
<
PropT
>::
get
()
->
data_vector
()
=
_other
->
get
()
->
data_vector
();
}
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
move_values_from
(
BaseProperty
*
other
)
{
auto
_other
=
static_cast
<
PropertyPtr
<
PropT
,
Entity
>*>
(
other
);
// FIXME: would be nice to perform a type check here
ptr
::
shared_ptr
<
PropT
>::
get
()
->
data_vector
()
=
std
::
move
(
_other
->
get
()
->
data_vector
());
}
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
resize
(
size_t
_size
)
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
resize
(
_size
);
...
...
src/OpenVolumeMesh/Core/ResourceManager.cc
View file @
b8e6f3d7
...
...
@@ -51,19 +51,8 @@ ResourceManager& ResourceManager::operator=(const ResourceManager &other)
if
(
this
==
&
other
)
return
*
this
;
auto
cloneProps
=
[
this
](
const
Properties
&
src
,
Properties
&
dest
)
{
dest
.
reserve
(
src
.
size
());
for
(
BaseProperty
*
bp
:
src
)
{
dest
.
push_back
(
bp
->
clone
(
*
this
,
bp
->
handle
()));
}
};
cloneProps
(
other
.
vertex_props_
,
vertex_props_
);
cloneProps
(
other
.
edge_props_
,
edge_props_
);
cloneProps
(
other
.
halfedge_props_
,
halfedge_props_
);
cloneProps
(
other
.
face_props_
,
face_props_
);
cloneProps
(
other
.
halfface_props_
,
halfface_props_
);
cloneProps
(
other
.
cell_props_
,
cell_props_
);
cloneProps
(
other
.
mesh_props_
,
mesh_props_
);
assignAllPropertiesFrom
<
false
>
(
&
other
);
return
*
this
;
}
...
...
@@ -72,19 +61,8 @@ ResourceManager& ResourceManager::operator=(ResourceManager &&other)
if
(
this
==
&
other
)
return
*
this
;
auto
moveProps
=
[
this
](
Properties
&&
src
,
Properties
&
dest
)
{
dest
=
std
::
move
(
src
);
for
(
auto
prop
:
dest
)
{
prop
->
setResMan
(
this
);
}
};
moveProps
(
std
::
move
(
other
.
vertex_props_
),
vertex_props_
);
moveProps
(
std
::
move
(
other
.
edge_props_
),
edge_props_
);
moveProps
(
std
::
move
(
other
.
halfedge_props_
),
halfedge_props_
);
moveProps
(
std
::
move
(
other
.
face_props_
),
face_props_
);
moveProps
(
std
::
move
(
other
.
halfface_props_
),
halfface_props_
);
moveProps
(
std
::
move
(
other
.
cell_props_
),
cell_props_
);
moveProps
(
std
::
move
(
other
.
mesh_props_
),
mesh_props_
);
assignAllPropertiesFrom
<
true
>
(
&
other
);
return
*
this
;
}
...
...
@@ -271,4 +249,54 @@ void ResourceManager::delete_multiple_cell_props(const std::vector<bool>& _tags)
}
}
template
<
bool
Move
>
void
ResourceManager
::
assignProperties
(
typename
std
::
conditional
<
Move
,
Properties
&
,
const
Properties
&>::
type
src
,
Properties
&
dest
)
{
// If possible, re-use existing properties instead of copying
// everything blindly.
Properties
out
;
out
.
reserve
(
src
.
size
());
for
(
BaseProperty
*
srcprop
:
src
)
{
bool
found
=
false
;
for
(
auto
it
=
dest
.
begin
();
it
!=
dest
.
end
();
++
it
)
{
auto
dstprop
=
*
it
;
if
(
dstprop
->
name
()
==
srcprop
->
name
())
{
// TODO: type check
out
.
push_back
(
dstprop
);
dest
.
erase
(
it
);
if
(
Move
)
{
dstprop
->
move_values_from
(
srcprop
);
}
else
{
dstprop
->
assign_values_from
(
srcprop
);
}
found
=
true
;
break
;
}
}
if
(
!
found
)
{
if
(
Move
)
{
out
.
push_back
(
srcprop
);
}
else
{
out
.
push_back
(
srcprop
->
clone
(
*
this
,
OpenVolumeMeshHandle
(
-
1
)));
}
}
}
updatePropHandles
(
out
);
dest
=
std
::
move
(
out
);
}
template
<
bool
Move
>
void
ResourceManager
::
assignAllPropertiesFrom
(
typename
std
::
conditional
<
Move
,
ResourceManager
*
,
const
ResourceManager
*>::
type
other
)
{
assignProperties
<
Move
>
(
other
->
vertex_props_
,
vertex_props_
);
assignProperties
<
Move
>
(
other
->
edge_props_
,
edge_props_
);
assignProperties
<
Move
>
(
other
->
halfedge_props_
,
halfedge_props_
);
assignProperties
<
Move
>
(
other
->
face_props_
,
face_props_
);
assignProperties
<
Move
>
(
other
->
halfface_props_
,
halfface_props_
);
assignProperties
<
Move
>
(
other
->
cell_props_
,
cell_props_
);
assignProperties
<
Move
>
(
other
->
mesh_props_
,
mesh_props_
);
}
}
// Namespace OpenVolumeMesh
src/OpenVolumeMesh/Core/ResourceManager.hh
View file @
b8e6f3d7
...
...
@@ -39,6 +39,7 @@
#endif
#include <string>
#include <vector>
#include <type_traits>
#include "OpenVolumeMeshProperty.hh"
#include "PropertyHandles.hh"
...
...
@@ -316,6 +317,12 @@ private:
template
<
class
StdVecT
>
void
updatePropHandles
(
StdVecT
&
_vec
);
template
<
bool
Move
>
void
assignProperties
(
typename
std
::
conditional
<
Move
,
Properties
&
,
const
Properties
&>::
type
src
,
Properties
&
dest
);
template
<
bool
Move
>
void
assignAllPropertiesFrom
(
typename
std
::
conditional
<
Move
,
ResourceManager
*
,
const
ResourceManager
*>::
type
src
);
Properties
vertex_props_
;
Properties
edge_props_
;
...
...
src/OpenVolumeMesh/Core/TopologyKernel.cc
View file @
b8e6f3d7
...
...
@@ -58,19 +58,6 @@ const FaceHandle TopologyKernel::InvalidFaceHandle = FaceHandle(-1);
const
HalfFaceHandle
TopologyKernel
::
InvalidHalfFaceHandle
=
HalfFaceHandle
(
-
1
);
const
CellHandle
TopologyKernel
::
InvalidCellHandle
=
CellHandle
(
-
1
);
TopologyKernel
::
TopologyKernel
()
:
n_vertices_
(
0u
),
v_bottom_up_
(
true
),
e_bottom_up_
(
true
),
f_bottom_up_
(
true
),
deferred_deletion
(
true
),
fast_deletion
(
true
)
{
}
TopologyKernel
::~
TopologyKernel
()
{
}
//========================================================================================
VertexHandle
TopologyKernel
::
add_vertex
()
{
...
...
src/OpenVolumeMesh/Core/TopologyKernel.hh
View file @
b8e6f3d7
...
...
@@ -57,8 +57,14 @@ namespace OpenVolumeMesh {
class
TopologyKernel
:
public
ResourceManager
{
public:
TopologyKernel
();
virtual
~
TopologyKernel
();
TopologyKernel
()
=
default
;
virtual
~
TopologyKernel
()
=
default
;
TopologyKernel
&
operator
=
(
const
TopologyKernel
&
)
=
default
;
void
assign
(
const
TopologyKernel
*
other
)
{
*
this
=
*
other
;
}
/*
* Defines and constants
...
...
@@ -361,7 +367,7 @@ public:
private:
// Cache total vertex number
size_t
n_vertices_
;
size_t
n_vertices_
=
0u
;
public:
...
...
@@ -793,15 +799,15 @@ protected:
std
::
vector
<
CellHandle
>
incident_cell_per_hf_
;
private:
bool
v_bottom_up_
;
bool
v_bottom_up_
=
true
;
bool
e_bottom_up_
;
bool
e_bottom_up_
=
true
;
bool
f_bottom_up_
;
bool
f_bottom_up_
=
true
;
bool
deferred_deletion
;
bool
deferred_deletion
=
true
;
bool
fast_deletion
;
bool
fast_deletion
=
true
;
//=====================================================================
// Connectivity
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment