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
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
Yuhao Liu
ogs
Commits
73704771
Commit
73704771
authored
10 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[MeL] Introduce base class for PropertyVector for dynamic polymorphism.
parent
cda344c5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeshLib/Properties.h
+1
-0
1 addition, 0 deletions
MeshLib/Properties.h
MeshLib/PropertyVector.h
+44
-2
44 additions, 2 deletions
MeshLib/PropertyVector.h
with
45 additions
and
2 deletions
MeshLib/Properties.h
+
1
−
0
View file @
73704771
...
...
@@ -169,6 +169,7 @@ public:
name
.
c_str
());
return
;
}
delete
it
->
second
;
_properties
.
erase
(
it
);
}
...
...
This diff is collapsed.
Click to expand it.
MeshLib/PropertyVector.h
+
44
−
2
View file @
73704771
...
...
@@ -16,15 +16,30 @@
#include
<type_traits>
#include
<memory>
#include
"BaseLib/excludeObjectCopy.h"
namespace
MeshLib
{
template
<
typename
T
>
class
PropertyVector
;
class
PropertyVectorBase
{
public:
virtual
PropertyVectorBase
*
clone
(
std
::
vector
<
std
::
size_t
>
const
&
exclude_positions
)
const
=
0
;
virtual
~
PropertyVectorBase
()
=
default
;
};
/// Class template PropertyVector is a std::vector with template parameter
/// PROP_VAL_TYPE. The reason for the derivation of std::vector is
/// the template specialisation for pointer types below.
/// \tparam PROP_VAL_TYPE typical this is a scalar, a vector or a matrix
template
<
typename
PROP_VAL_TYPE
>
class
PropertyVector
:
public
std
::
vector
<
PROP_VAL_TYPE
>
class
PropertyVector
:
public
std
::
vector
<
PROP_VAL_TYPE
>
,
public
PropertyVectorBase
{
friend
class
Properties
;
...
...
@@ -33,6 +48,14 @@ public:
MeshItemType
getMeshItemType
()
const
{
return
_mesh_item_type
;
}
std
::
string
const
&
getPropertyName
()
const
{
return
_property_name
;
}
PropertyVectorBase
*
clone
(
std
::
vector
<
std
::
size_t
>
const
&
exclude_positions
)
const
{
PropertyVector
<
PROP_VAL_TYPE
>
*
t
(
new
PropertyVector
<
PROP_VAL_TYPE
>
(
_property_name
,
_mesh_item_type
,
_tuple_size
));
BaseLib
::
excludeObjectCopy
(
*
this
,
exclude_positions
,
*
t
);
return
t
;
}
protected
:
/// @brief The constructor taking meta information for the data.
/// @param property_name a string describing the property
...
...
@@ -77,7 +100,8 @@ protected:
/// \tparam T pointer type, the type the type points to is typical a scalar,
/// a vector or a matrix type
template
<
typename
T
>
class
PropertyVector
<
T
*>
:
public
std
::
vector
<
T
*>
class
PropertyVector
<
T
*>
:
public
std
::
vector
<
T
*>
,
public
PropertyVectorBase
{
friend
class
Properties
;
public:
...
...
@@ -96,10 +120,28 @@ public:
return
(
*
static_cast
<
std
::
vector
<
T
*>
const
*>
(
this
))[
_item2group_mapping
[
id
]];
}
T
*
&
operator
[](
std
::
size_t
id
)
{
return
(
*
static_cast
<
std
::
vector
<
T
*>*>
(
this
))[
_item2group_mapping
[
id
]];
}
std
::
size_t
getTupleSize
()
const
{
return
_tuple_size
;
}
MeshItemType
getMeshItemType
()
const
{
return
_mesh_item_type
;
}
std
::
string
const
&
getPropertyName
()
const
{
return
_property_name
;
}
PropertyVectorBase
*
clone
(
std
::
vector
<
std
::
size_t
>
const
&
exclude_positions
)
const
{
std
::
vector
<
std
::
size_t
>
item2group_mapping
(
BaseLib
::
excludeObjectCopy
(
_item2group_mapping
,
exclude_positions
)
);
PropertyVector
<
T
*>
*
t
(
new
PropertyVector
<
T
*>
(
this
->
size
()
/
_tuple_size
,
item2group_mapping
,
_property_name
,
_mesh_item_type
,
_tuple_size
));
for
(
std
::
size_t
j
(
0
);
j
<
item2group_mapping
.
size
();
j
++
)
{
t
->
operator
[](
j
)
=
(
*
static_cast
<
std
::
vector
<
T
*>
const
*>
(
this
))[
item2group_mapping
[
j
]];
}
return
t
;
}
protected
:
/// @brief The constructor taking meta information for the data.
/// @param n_prop_groups number of different property values
...
...
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