Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenVolumeMesh
OpenVolumeMesh
Commits
590f6066
Commit
590f6066
authored
May 13, 2019
by
Martin Heistermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement generic mesh::request_property templated on entity type.
parent
3e03bdfb
Pipeline
#10296
passed with stage
in 3 minutes and 32 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
54 deletions
+56
-54
src/OpenVolumeMesh/Core/BaseProperty.hh
src/OpenVolumeMesh/Core/BaseProperty.hh
+3
-2
src/OpenVolumeMesh/Core/PropertyDefines.hh
src/OpenVolumeMesh/Core/PropertyDefines.hh
+4
-0
src/OpenVolumeMesh/Core/PropertyPtr.hh
src/OpenVolumeMesh/Core/PropertyPtr.hh
+2
-0
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
+1
-1
src/OpenVolumeMesh/Core/ResourceManager.hh
src/OpenVolumeMesh/Core/ResourceManager.hh
+9
-16
src/OpenVolumeMesh/Core/ResourceManagerT_impl.hh
src/OpenVolumeMesh/Core/ResourceManagerT_impl.hh
+37
-35
No files found.
src/OpenVolumeMesh/Core/BaseProperty.hh
View file @
590f6066
...
...
@@ -55,9 +55,10 @@ class BaseProperty {
public:
friend
class
ResourceManager
;
explicit
BaseProperty
(
ResourceManager
&
_resMan
)
:
resMan_
(
&
_resMan
)
{}
explicit
BaseProperty
(
ResourceManager
*
_resMan
)
:
resMan_
(
_resMan
)
{}
BaseProperty
(
const
BaseProperty
&
_cpy
)
:
resMan_
(
_cpy
.
resMan_
)
{}
BaseProperty
(
BaseProperty
&&
_other
)
=
default
;
BaseProperty
(
const
BaseProperty
&
_other
)
=
default
;
BaseProperty
&
operator
=
(
const
BaseProperty
&
_cpy
)
=
delete
;
...
...
src/OpenVolumeMesh/Core/PropertyDefines.hh
View file @
590f6066
...
...
@@ -84,6 +84,10 @@ template <> const std::string entityTypeName<Entity::Mesh>();
template
<
typename
T
,
typename
Entity
>
class
PropertyTT
:
public
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
Entity
>
{
public:
template
<
typename
MeshT
>
PropertyTT
(
MeshT
*
mesh
,
const
std
::
string
&
_name
,
const
T
_def
=
T
())
:
PropertyTT
(
std
::
move
(
mesh
->
template
request_property
<
T
,
Entity
>(
_name
,
_def
)))
{}
using
PropertyHandleT
=
OpenVolumeMesh
::
PropHandleT
<
Entity
>
;
PropertyTT
(
const
std
::
string
&
_name
,
ResourceManager
&
_resMan
,
PropertyHandleT
_handle
,
const
T
_def
=
T
());
virtual
~
PropertyTT
()
=
default
;
...
...
src/OpenVolumeMesh/Core/PropertyPtr.hh
View file @
590f6066
...
...
@@ -69,6 +69,8 @@ public:
using
EntityHandleT
=
HandleT
<
Entity
>
;
/// Constructor
PropertyPtr
()
:
BaseProperty
(
nullptr
)
{}
/// Constructor
PropertyPtr
(
PropT
*
_ptr
,
ResourceManager
&
_resMan
,
PropHandleT
<
Entity
>
_handle
);
...
...
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
View file @
590f6066
...
...
@@ -42,7 +42,7 @@ namespace OpenVolumeMesh {
template
<
class
PropT
,
typename
Entity
>
PropertyPtr
<
PropT
,
Entity
>::
PropertyPtr
(
PropT
*
_ptr
,
ResourceManager
&
_resMan
,
PropHandleT
<
Entity
>
_handle
)
:
ptr
::
shared_ptr
<
PropT
>
(
_ptr
),
BaseProperty
(
_resMan
)
{
ptr
::
shared_ptr
<
PropT
>
(
_ptr
),
BaseProperty
(
&
_resMan
)
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
set_handle
(
_handle
);
}
...
...
src/OpenVolumeMesh/Core/ResourceManager.hh
View file @
590f6066
...
...
@@ -132,6 +132,12 @@ public:
/// Get number of cells in mesh
virtual
size_t
n_cells
()
const
=
0
;
template
<
typename
T
,
typename
EntityTag
>
PropertyTT
<
T
,
EntityTag
>
request_property
(
const
std
::
string
&
_name
=
std
::
string
(),
const
T
_def
=
T
());
template
<
class
T
>
VertexPropertyT
<
T
>
request_vertex_property
(
const
std
::
string
&
_name
=
std
::
string
(),
const
T
_def
=
T
());
template
<
class
T
>
EdgePropertyT
<
T
>
request_edge_property
(
const
std
::
string
&
_name
=
std
::
string
(),
const
T
_def
=
T
());
...
...
@@ -146,6 +152,7 @@ public:
template
<
class
T
>
MeshPropertyT
<
T
>
request_mesh_property
(
const
std
::
string
&
_name
=
std
::
string
(),
const
T
_def
=
T
());
private:
void
release_property
(
VertexPropHandle
_handle
);
...
...
@@ -178,19 +185,8 @@ public:
size_t
n_mesh_props
()
const
{
return
mesh_props_
.
size
();
}
template
<
class
T
>
void
set_persistent
(
VertexPropertyT
<
T
>&
_prop
,
bool
_flag
=
true
);
template
<
class
T
>
void
set_persistent
(
EdgePropertyT
<
T
>&
_prop
,
bool
_flag
=
true
);
template
<
class
T
>
void
set_persistent
(
HalfEdgePropertyT
<
T
>&
_prop
,
bool
_flag
=
true
);
template
<
class
T
>
void
set_persistent
(
FacePropertyT
<
T
>&
_prop
,
bool
_flag
=
true
);
template
<
class
T
>
void
set_persistent
(
HalfFacePropertyT
<
T
>&
_prop
,
bool
_flag
=
true
);
template
<
class
T
>
void
set_persistent
(
CellPropertyT
<
T
>&
_prop
,
bool
_flag
=
true
);
template
<
class
T
>
void
set_persistent
(
MeshPropertyT
<
T
>&
_prop
,
bool
_flag
=
true
);
template
<
typename
T
,
class
EntityTag
>
void
set_persistent
(
PropertyTT
<
T
,
EntityTag
>&
_prop
,
bool
_flag
=
true
);
typedef
std
::
vector
<
BaseProperty
*>
Properties
;
...
...
@@ -314,9 +310,6 @@ private:
template
<
class
StdVecT
,
class
PropT
,
class
HandleT
,
class
T
>
PropT
request_property
(
StdVecT
&
_vec
,
const
std
::
string
&
_name
,
size_t
_size
,
const
T
_def
=
T
());
template
<
class
PropT
>
void
set_persistentT
(
PropT
&
_prop
,
bool
_flag
);
template
<
class
StdVecT
>
void
clearVec
(
StdVecT
&
_vec
);
...
...
src/OpenVolumeMesh/Core/ResourceManagerT_impl.hh
View file @
590f6066
...
...
@@ -117,53 +117,55 @@ PropT ResourceManager::request_property(StdVecT& _vec, const std::string& _name,
return
*
prop
;
}
template
<
class
T
>
void
ResourceManager
::
set_persistent
(
VertexPropertyT
<
T
>&
_prop
,
bool
_flag
)
{
// request_property: work around C++ currently now allowing partial specialisation on functions by using structs:
set_persistentT
(
_prop
,
_flag
);
}
template
<
class
T
,
typename
EntityTag
>
struct
request_property_impl
{
static
PropertyTT
<
T
,
EntityTag
>
_
(
ResourceManager
*
/*resman*/
,
const
std
::
string
&
/*_name*/
,
const
T
/*_def*/
);
};
template
<
class
T
>
void
ResourceManager
::
set_persistent
(
EdgePropertyT
<
T
>&
_prop
,
bool
_flag
)
{
set_persistentT
(
_prop
,
_flag
);
}
template
<
class
T
>
void
ResourceManager
::
set_persistent
(
HalfEdgePropertyT
<
T
>&
_prop
,
bool
_flag
)
{
set_persistentT
(
_prop
,
_flag
);
}
struct
request_property_impl
<
T
,
Entity
::
Edge
>
{
static
PropertyTT
<
T
,
Entity
::
Edge
>
_
(
ResourceManager
*
resman
,
const
std
::
string
&
_name
,
const
T
_def
)
{
return
resman
->
request_edge_property
<
T
>
(
_name
,
_def
);
}
};
template
<
class
T
>
void
ResourceManager
::
set_persistent
(
FacePropertyT
<
T
>&
_prop
,
bool
_flag
)
{
set_persistentT
(
_prop
,
_flag
);
}
struct
request_property_impl
<
T
,
Entity
::
HalfEdge
>
{
static
PropertyTT
<
T
,
Entity
::
HalfEdge
>
_
(
ResourceManager
*
resman
,
const
std
::
string
&
_name
,
const
T
_def
)
{
return
resman
->
request_halfedge_property
<
T
>
(
_name
,
_def
);
}
};
template
<
class
T
>
void
ResourceManager
::
set_persistent
(
HalfFacePropertyT
<
T
>&
_prop
,
bool
_flag
)
{
set_persistentT
(
_prop
,
_flag
);
}
struct
request_property_impl
<
T
,
Entity
::
Face
>
{
static
PropertyTT
<
T
,
Entity
::
Face
>
_
(
ResourceManager
*
resman
,
const
std
::
string
&
_name
,
const
T
_def
)
{
return
resman
->
request_face_property
<
T
>
(
_name
,
_def
);
}
};
template
<
class
T
>
void
ResourceManager
::
set_persistent
(
CellPropertyT
<
T
>&
_prop
,
bool
_flag
)
{
set_persistentT
(
_prop
,
_flag
);
}
struct
request_property_impl
<
T
,
Entity
::
HalfFace
>
{
static
PropertyTT
<
T
,
Entity
::
HalfFace
>
_
(
ResourceManager
*
resman
,
const
std
::
string
&
_name
,
const
T
_def
)
{
return
resman
->
request_halfface_property
<
T
>
(
_name
,
_def
);
}
};
template
<
class
T
>
void
ResourceManager
::
set_persistent
(
MeshPropertyT
<
T
>&
_prop
,
bool
_flag
)
{
struct
request_property_impl
<
T
,
Entity
::
Cell
>
{
static
PropertyTT
<
T
,
Entity
::
Cell
>
_
(
ResourceManager
*
resman
,
const
std
::
string
&
_name
,
const
T
_def
)
{
return
resman
->
request_cell_property
<
T
>
(
_name
,
_def
);
}
};
set_persistentT
(
_prop
,
_flag
);
template
<
typename
T
,
typename
EntityTag
>
PropertyTT
<
T
,
EntityTag
>
ResourceManager
::
request_property
(
const
std
::
string
&
_name
,
const
T
_def
)
{
return
request_property_impl
<
T
,
EntityTag
>::
_
(
this
,
_name
,
_def
);
}
template
<
class
PropT
>
void
ResourceManager
::
set_persistentT
(
PropT
&
_prop
,
bool
_flag
)
{
template
<
typename
T
,
class
EntityTag
>
void
ResourceManager
::
set_persistent
(
PropertyTT
<
T
,
EntityTag
>&
_prop
,
bool
_flag
)
{
if
(
_flag
==
_prop
->
persistent
())
return
;
_prop
->
set_persistent
(
_flag
);
}
...
...
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