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
3e03bdfb
Commit
3e03bdfb
authored
Mar 20, 2019
by
Jan Möbius
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mh_refactor' into 'master'
Cleanup and small features See merge request
!54
parents
bd7687fa
f69d1edd
Pipeline
#9315
passed with stage
in 3 minutes and 54 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
136 additions
and
110 deletions
+136
-110
src/OpenVolumeMesh/Core/BaseProperty.hh
src/OpenVolumeMesh/Core/BaseProperty.hh
+4
-10
src/OpenVolumeMesh/Core/ForwardDeclarations.hh
src/OpenVolumeMesh/Core/ForwardDeclarations.hh
+1
-1
src/OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh
src/OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh
+19
-5
src/OpenVolumeMesh/Core/PropertyDefines.hh
src/OpenVolumeMesh/Core/PropertyDefines.hh
+1
-3
src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh
src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh
+2
-20
src/OpenVolumeMesh/Core/PropertyPtr.hh
src/OpenVolumeMesh/Core/PropertyPtr.hh
+8
-4
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
+22
-23
src/OpenVolumeMesh/Core/ResourceManager.cc
src/OpenVolumeMesh/Core/ResourceManager.cc
+41
-16
src/OpenVolumeMesh/Core/ResourceManager.hh
src/OpenVolumeMesh/Core/ResourceManager.hh
+7
-3
src/OpenVolumeMesh/Core/ResourceManagerT_impl.hh
src/OpenVolumeMesh/Core/ResourceManagerT_impl.hh
+16
-20
src/OpenVolumeMesh/Core/TopologyKernel.cc
src/OpenVolumeMesh/Core/TopologyKernel.cc
+15
-5
No files found.
src/OpenVolumeMesh/Core/BaseProperty.hh
View file @
3e03bdfb
...
...
@@ -55,9 +55,9 @@ class BaseProperty {
public:
friend
class
ResourceManager
;
explicit
BaseProperty
(
ResourceManager
&
_resMan
)
:
resMan_
(
_resMan
),
lock_
(
false
)
{}
explicit
BaseProperty
(
ResourceManager
&
_resMan
)
:
resMan_
(
&
_resMan
)
{}
BaseProperty
(
const
BaseProperty
&
_cpy
)
:
resMan_
(
_cpy
.
resMan_
)
,
lock_
(
_cpy
.
lock_
)
{}
BaseProperty
(
const
BaseProperty
&
_cpy
)
:
resMan_
(
_cpy
.
resMan_
)
{}
BaseProperty
&
operator
=
(
const
BaseProperty
&
_cpy
)
=
delete
;
...
...
@@ -95,15 +95,9 @@ protected:
virtual
void
set_handle
(
const
OpenVolumeMeshHandle
&
/*_handle*/
)
=
0
;
void
lock
()
{
lock_
=
true
;
}
void
setResMan
(
ResourceManager
*
resMan
)
{
resMan_
=
resMan
;
}
void
unlock
()
{
lock_
=
false
;
}
bool
locked
()
const
{
return
lock_
;
}
ResourceManager
&
resMan_
;
bool
lock_
;
ResourceManager
*
resMan_
;
};
}
// Namespace OpenVolumeMesh
...
...
src/OpenVolumeMesh/Core/ForwardDeclarations.hh
View file @
3e03bdfb
...
...
@@ -11,7 +11,7 @@ class OpenVolumeMeshPropertyT;
template
<
class
E
,
typename
>
class
PropHandleT
;
template
<
class
PropT
,
class
HandleT
>
template
<
class
PropT
,
typename
Entity
>
class
PropertyPtr
;
template
<
typename
T
,
typename
Entity
>
...
...
src/OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh
View file @
3e03bdfb
...
...
@@ -37,6 +37,8 @@
#include <algorithm>
#include <iosfwd>
#include <vector>
#include <cassert>
#include <limits>
#include "Entities.hh"
#include "../System/FunctionalInclude.hh"
...
...
@@ -48,17 +50,15 @@ namespace OpenVolumeMesh {
class
OpenVolumeMeshHandle
{
public:
// Default constructor
explicit
OpenVolumeMeshHandle
(
int
_idx
)
:
idx_
(
_idx
)
{};
explicit
OpenVolumeMeshHandle
(
int
_idx
)
:
idx_
(
_idx
)
{}
OpenVolumeMeshHandle
&
operator
=
(
int
_idx
)
{
idx_
=
_idx
;
return
*
this
;
}
OpenVolumeMeshHandle
&
operator
=
(
const
OpenVolumeMeshHandle
&
_idx
)
{
idx_
=
_idx
.
idx_
;
return
*
this
;
}
OpenVolumeMeshHandle
(
const
OpenVolumeMeshHandle
&
_idx
)
=
default
;
OpenVolumeMeshHandle
&
operator
=
(
const
OpenVolumeMeshHandle
&
_idx
)
=
default
;
inline
bool
is_valid
()
const
{
return
idx_
!=
-
1
;
}
...
...
@@ -76,6 +76,9 @@ public:
inline
const
int
&
idx
()
const
{
return
idx_
;
}
/// return unsigned idx - handle must be valid
inline
size_t
uidx
()
const
{
assert
(
is_valid
());
return
static_cast
<
size_t
>
(
idx_
);
}
void
idx
(
const
int
&
_idx
)
{
idx_
=
_idx
;
}
OVM_DEPRECATED
(
"use explicit .idx() instead"
)
...
...
@@ -95,6 +98,17 @@ class HandleT : public OpenVolumeMeshHandle
public:
using
Entity
=
EntityTag
;
explicit
HandleT
(
int
_idx
=
-
1
)
:
OpenVolumeMeshHandle
(
_idx
)
{}
static
HandleT
<
EntityTag
>
from_unsigned
(
size_t
_idx
)
{
if
(
_idx
<=
std
::
numeric_limits
<
int
>::
max
())
{
return
HandleT
<
EntityTag
>
(
static_cast
<
int
>
(
_idx
));
}
else
{
assert
(
false
);
return
HandleT
<
EntityTag
>
(
-
1
);
}
}
};
// Default entity handles
...
...
src/OpenVolumeMesh/Core/PropertyDefines.hh
View file @
3e03bdfb
...
...
@@ -82,14 +82,12 @@ template <> const std::string entityTypeName<Entity::Cell>();
template
<
>
const
std
::
string
entityTypeName
<
Entity
::
Mesh
>
();
template
<
typename
T
,
typename
Entity
>
class
PropertyTT
:
public
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
PropHandleT
<
Entity
>
>
{
class
PropertyTT
:
public
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
Entity
>
{
public:
using
PropertyHandleT
=
OpenVolumeMesh
::
PropHandleT
<
Entity
>
;
PropertyTT
(
const
std
::
string
&
_name
,
ResourceManager
&
_resMan
,
PropertyHandleT
_handle
,
const
T
_def
=
T
());
virtual
~
PropertyTT
()
=
default
;
virtual
BaseProperty
*
clone
(
ResourceManager
&
_resMan
,
OpenVolumeMeshHandle
_handle
)
const
;
virtual
void
serialize
(
std
::
ostream
&
_ostr
)
const
;
virtual
void
deserialize
(
std
::
istream
&
_istr
);
virtual
const
std
::
string
entityType
()
const
{
return
entityTypeName
<
Entity
>
();
}
virtual
const
std
::
string
typeNameWrapper
()
const
{
return
typeName
<
T
>
();
}
private:
...
...
src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh
View file @
3e03bdfb
...
...
@@ -32,14 +32,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#define PROPERTYDEFINEST_CC
#include <istream>
...
...
@@ -51,13 +43,13 @@ namespace OpenVolumeMesh {
template
<
typename
T
,
typename
Entity
>
PropertyTT
<
T
,
Entity
>::
PropertyTT
(
const
std
::
string
&
_name
,
ResourceManager
&
_resMan
,
PropertyHandleT
_handle
,
const
T
_def
)
:
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
PropertyHandleT
>
(
new
OpenVolumeMeshPropertyT
<
T
>
(
_name
,
_def
),
_resMan
,
_handle
)
{
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
Entity
>
(
new
OpenVolumeMeshPropertyT
<
T
>
(
_name
,
_def
),
_resMan
,
_handle
)
{
}
template
<
typename
T
,
typename
Entity
>
PropertyTT
<
T
,
Entity
>::
PropertyTT
(
OpenVolumeMeshPropertyT
<
T
>
*
_prop
,
ResourceManager
&
_resMan
,
PropertyHandleT
_handle
)
:
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
PropertyHandleT
>
(
_prop
,
_resMan
,
_handle
)
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
Entity
>
(
_prop
,
_resMan
,
_handle
)
{
}
...
...
@@ -68,16 +60,6 @@ BaseProperty *PropertyTT<T,Entity>::clone(ResourceManager &_resMan, OpenVolumeMe
return
new
PropertyTT
<
T
,
Entity
>
(
prop_clone
,
_resMan
,
PropertyHandleT
(
_handle
.
idx
()));
}
template
<
typename
T
,
typename
Entity
>
void
PropertyTT
<
T
,
Entity
>::
serialize
(
std
::
ostream
&
_ostr
)
const
{
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
PropertyHandleT
>::
get
()
->
serialize
(
_ostr
);
}
template
<
typename
T
,
typename
Entity
>
void
PropertyTT
<
T
,
Entity
>::
deserialize
(
std
::
istream
&
_istr
)
{
PropertyPtr
<
OpenVolumeMeshPropertyT
<
T
>
,
PropertyHandleT
>::
get
()
->
deserialize
(
_istr
);
}
template
<
typename
T
>
const
std
::
string
typeName
()
{
throw
std
::
runtime_error
(
"Serialization is not supported for these data types!"
);
...
...
src/OpenVolumeMesh/Core/PropertyPtr.hh
View file @
3e03bdfb
...
...
@@ -37,6 +37,7 @@
#include <string>
#include "PropertyHandles.hh"
#include "BaseProperty.hh"
#include "OpenVolumeMeshHandle.hh"
#include "../System/MemoryInclude.hh"
...
...
@@ -54,7 +55,7 @@ class ResourceManager;
* as soon as the object is not used anymore.
*/
template
<
class
PropT
,
class
HandleT
>
template
<
class
PropT
,
typename
Entity
>
class
PropertyPtr
:
protected
ptr
::
shared_ptr
<
PropT
>
,
public
BaseProperty
{
public:
...
...
@@ -66,10 +67,10 @@ public:
typedef
typename
PropT
::
reference
reference
;
typedef
typename
PropT
::
const_reference
const_reference
;
typedef
OpenVolumeMesh
::
HandleT
<
typename
HandleT
::
Entity
>
EntityHandleT
;
using
EntityHandleT
=
HandleT
<
Entity
>
;
/// Constructor
PropertyPtr
(
PropT
*
_ptr
,
ResourceManager
&
_resMan
,
HandleT
_handle
);
PropertyPtr
(
PropT
*
_ptr
,
ResourceManager
&
_resMan
,
PropHandleT
<
Entity
>
_handle
);
/// Destructor
virtual
~
PropertyPtr
();
...
...
@@ -98,7 +99,10 @@ public:
const_reference
operator
[](
size_t
_idx
)
const
{
return
(
*
ptr
::
shared_ptr
<
PropT
>::
get
())[
_idx
];
}
reference
operator
[](
const
EntityHandleT
&
_h
)
{
return
(
*
ptr
::
shared_ptr
<
PropT
>::
get
())[
_h
.
idx
()];
}
const_reference
operator
[](
const
EntityHandleT
&
_h
)
const
{
return
(
*
ptr
::
shared_ptr
<
PropT
>::
get
())[
_h
.
idx
()];
}
const_reference
operator
[](
const
EntityHandleT
&
_h
)
const
{
return
(
*
ptr
::
shared_ptr
<
PropT
>::
get
())[
_h
.
uidx
()];
}
virtual
void
serialize
(
std
::
ostream
&
_ostr
)
const
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
serialize
(
_ostr
);
}
virtual
void
deserialize
(
std
::
istream
&
_istr
)
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
deserialize
(
_istr
);
}
virtual
OpenVolumeMeshHandle
handle
()
const
;
...
...
src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh
View file @
3e03bdfb
...
...
@@ -40,63 +40,62 @@
namespace
OpenVolumeMesh
{
template
<
class
PropT
,
class
HandleT
>
PropertyPtr
<
PropT
,
HandleT
>::
PropertyPtr
(
PropT
*
_ptr
,
ResourceManager
&
_resMan
,
HandleT
_handle
)
:
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
>::
get
()
->
set_handle
(
_handle
);
}
template
<
class
PropT
,
class
HandleT
>
PropertyPtr
<
PropT
,
HandleT
>::~
PropertyPtr
()
{
template
<
class
PropT
,
typename
Entity
>
PropertyPtr
<
PropT
,
Entity
>::~
PropertyPtr
()
{
/*
* If use count is 2 and prop is not set persistent,
* remove it, since the resource manager is the
* only one who stores the property.
*/
if
(
!
locked
()
&&
!
persistent
()
&&
ptr
::
shared_ptr
<
PropT
>::
use_count
()
==
2
)
{
resMan_
.
release_property
(
HandleT
(
handle
().
idx
()));
unlock
();
if
(
resMan_
&&
!
persistent
()
&&
ptr
::
shared_ptr
<
PropT
>::
use_count
()
==
2
)
{
resMan_
->
release_property
(
PropHandleT
<
Entity
>
(
handle
().
idx
()));
}
}
template
<
class
PropT
,
class
HandleT
>
void
PropertyPtr
<
PropT
,
HandleT
>::
resize
(
size_t
_size
)
{
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
resize
(
size_t
_size
)
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
resize
(
_size
);
}
template
<
class
PropT
,
class
HandleT
>
const
std
::
string
&
PropertyPtr
<
PropT
,
HandleT
>::
name
()
const
{
template
<
class
PropT
,
typename
Entity
>
const
std
::
string
&
PropertyPtr
<
PropT
,
Entity
>::
name
()
const
{
return
ptr
::
shared_ptr
<
PropT
>::
get
()
->
name
();
}
template
<
class
PropT
,
class
HandleT
>
void
PropertyPtr
<
PropT
,
HandleT
>::
delete_element
(
size_t
_idx
)
{
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
delete_element
(
size_t
_idx
)
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
delete_element
(
_idx
);
}
template
<
class
PropT
,
class
HandleT
>
void
PropertyPtr
<
PropT
,
HandleT
>::
swap_elements
(
size_t
_idx0
,
size_t
_idx1
)
{
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
swap_elements
(
size_t
_idx0
,
size_t
_idx1
)
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
swap
(
_idx0
,
_idx1
);
}
template
<
class
PropT
,
class
HandleT
>
void
PropertyPtr
<
PropT
,
HandleT
>::
copy
(
size_t
_src_idx
,
size_t
_dst_idx
)
{
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
copy
(
size_t
_src_idx
,
size_t
_dst_idx
)
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
copy
(
_src_idx
,
_dst_idx
);
}
template
<
class
PropT
,
class
HandleT
>
void
PropertyPtr
<
PropT
,
HandleT
>::
set_handle
(
const
OpenVolumeMeshHandle
&
_handle
)
{
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
set_handle
(
const
OpenVolumeMeshHandle
&
_handle
)
{
return
ptr
::
shared_ptr
<
PropT
>::
get
()
->
set_handle
(
_handle
);
}
template
<
class
PropT
,
class
HandleT
>
OpenVolumeMeshHandle
PropertyPtr
<
PropT
,
HandleT
>::
handle
()
const
{
template
<
class
PropT
,
typename
Entity
>
OpenVolumeMeshHandle
PropertyPtr
<
PropT
,
Entity
>::
handle
()
const
{
return
ptr
::
shared_ptr
<
PropT
>::
get
()
->
handle
();
}
template
<
class
PropT
,
class
HandleT
>
void
PropertyPtr
<
PropT
,
HandleT
>::
delete_multiple_entries
(
const
std
::
vector
<
bool
>&
_tags
)
{
template
<
class
PropT
,
typename
Entity
>
void
PropertyPtr
<
PropT
,
Entity
>::
delete_multiple_entries
(
const
std
::
vector
<
bool
>&
_tags
)
{
ptr
::
shared_ptr
<
PropT
>::
get
()
->
delete_multiple_entries
(
_tags
);
}
...
...
src/OpenVolumeMesh/Core/ResourceManager.cc
View file @
3e03bdfb
...
...
@@ -32,22 +32,25 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#include "ResourceManager.hh"
namespace
OpenVolumeMesh
{
ResourceManager
::
ResourceManager
()
{
ResourceManager
::
ResourceManager
(
const
ResourceManager
&
other
)
{
*
this
=
other
;
}
ResourceManager
::
ResourceManager
(
ResourceManager
&&
other
)
{
*
this
=
std
::
move
(
other
);
}
ResourceManager
::
ResourceManager
(
const
ResourceManager
&
other
)
{
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
)
{
...
...
@@ -61,6 +64,28 @@ ResourceManager::ResourceManager(const ResourceManager &other) {
cloneProps
(
other
.
halfface_props_
,
halfface_props_
);
cloneProps
(
other
.
cell_props_
,
cell_props_
);
cloneProps
(
other
.
mesh_props_
,
mesh_props_
);
return
*
this
;
}
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_
);
return
*
this
;
}
ResourceManager
::~
ResourceManager
()
{
...
...
@@ -153,32 +178,32 @@ void ResourceManager::swap_vertex_properties(VertexHandle _h1, VertexHandle _h2)
void
ResourceManager
::
release_property
(
VertexPropHandle
_handle
)
{
remove_property
(
vertex_props_
,
_handle
.
idx
());
remove_property
(
vertex_props_
,
_handle
.
u
idx
());
}
void
ResourceManager
::
release_property
(
EdgePropHandle
_handle
)
{
remove_property
(
edge_props_
,
_handle
.
idx
());
remove_property
(
edge_props_
,
_handle
.
u
idx
());
}
void
ResourceManager
::
release_property
(
HalfEdgePropHandle
_handle
)
{
remove_property
(
halfedge_props_
,
_handle
.
idx
());
remove_property
(
halfedge_props_
,
_handle
.
u
idx
());
}
void
ResourceManager
::
release_property
(
FacePropHandle
_handle
)
{
remove_property
(
face_props_
,
_handle
.
idx
());
remove_property
(
face_props_
,
_handle
.
u
idx
());
}
void
ResourceManager
::
release_property
(
HalfFacePropHandle
_handle
)
{
remove_property
(
halfface_props_
,
_handle
.
idx
());
remove_property
(
halfface_props_
,
_handle
.
u
idx
());
}
void
ResourceManager
::
release_property
(
CellPropHandle
_handle
)
{
remove_property
(
cell_props_
,
_handle
.
idx
());
remove_property
(
cell_props_
,
_handle
.
u
idx
());
}
void
ResourceManager
::
release_property
(
MeshPropHandle
_handle
)
{
...
...
src/OpenVolumeMesh/Core/ResourceManager.hh
View file @
3e03bdfb
...
...
@@ -51,10 +51,11 @@ class BaseProperty;
class
ResourceManager
{
public:
ResourceManager
();
ResourceManager
()
=
default
;
ResourceManager
(
const
ResourceManager
&
other
);
ResourceManager
&
operator
=
(
const
ResourceManager
&
other
)
=
delete
;
ResourceManager
(
ResourceManager
&&
other
);
ResourceManager
&
operator
=
(
const
ResourceManager
&
other
);
ResourceManager
&
operator
=
(
ResourceManager
&&
other
);
virtual
~
ResourceManager
();
template
<
class
PropT
,
class
HandleT
>
friend
class
PropertyPtr
;
...
...
@@ -319,6 +320,9 @@ private:
template
<
class
StdVecT
>
void
clearVec
(
StdVecT
&
_vec
);
template
<
class
StdVecT
>
void
updatePropHandles
(
StdVecT
&
_vec
);
Properties
vertex_props_
;
Properties
edge_props_
;
...
...
src/OpenVolumeMesh/Core/ResourceManagerT_impl.hh
View file @
3e03bdfb
...
...
@@ -170,13 +170,11 @@ void ResourceManager::set_persistentT(PropT& _prop, bool _flag) {
template
<
class
StdVecT
>
void
ResourceManager
::
remove_property
(
StdVecT
&
_vec
,
size_t
_idx
)
{
(
*
(
_vec
.
begin
()
+
_idx
))
->
lock
();
delete
*
(
_vec
.
begin
()
+
_idx
);
auto
prop_ptr
=
_vec
[
_idx
];
prop_ptr
->
setResMan
(
nullptr
);
delete
prop_ptr
;
_vec
.
erase
(
_vec
.
begin
()
+
_idx
);
size_t
n
=
_vec
.
size
();
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
_vec
[
i
]
->
set_handle
(
OpenVolumeMeshHandle
((
int
)
i
));
}
updatePropHandles
(
_vec
);
}
template
<
class
StdVecT
>
...
...
@@ -200,22 +198,20 @@ void ResourceManager::entity_deleted(StdVecT& _vec, const OpenVolumeMeshHandle&
template
<
class
StdVecT
>
void
ResourceManager
::
clearVec
(
StdVecT
&
_vec
)
{
StdVecT
newVec
;
for
(
typename
StdVecT
::
iterator
it
=
_vec
.
begin
();
it
!=
_vec
.
end
();
++
it
)
{
if
(
!
(
*
it
)
->
persistent
())
{
#ifndef NDEBUG
std
::
cerr
<<
"Keeping property
\"
"
<<
(
*
it
)
->
name
()
<<
"
\"
since it is still in use!"
<<
std
::
endl
;
#endif
(
*
it
)
->
resize
(
0
);
newVec
.
push_back
(
*
it
);
}
else
delete
*
it
;
for
(
auto
prop
:
_vec
)
{
prop
->
setResMan
(
nullptr
);
delete
prop
;
}
_vec
.
clear
();
}
_vec
=
newVec
;
template
<
class
StdVecT
>
void
ResourceManager
::
updatePropHandles
(
StdVecT
&
_vec
)
{
size_t
n
=
_vec
.
size
();
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
_vec
[
i
]
->
set_handle
(
OpenVolumeMeshHandle
((
int
)
i
));
}
}
}
// Namespace OpenVolumeMesh
src/OpenVolumeMesh/Core/TopologyKernel.cc
View file @
3e03bdfb
...
...
@@ -99,8 +99,8 @@ EdgeHandle TopologyKernel::add_edge(const VertexHandle& _fromVertex,
// If the conditions are not fulfilled, assert will fail (instead
// of returning an invalid handle)
assert
(
_fromVertex
.
is_valid
()
&&
(
size_t
)
_fromVertex
.
idx
()
<
n_vertices
());
assert
(
_toVertex
.
is_valid
()
&&
(
size_t
)
_toVertex
.
idx
()
<
n_vertices
());
assert
(
_fromVertex
.
is_valid
()
&&
(
size_t
)
_fromVertex
.
idx
()
<
n_vertices
()
&&
!
is_deleted
(
_fromVertex
)
);
assert
(
_toVertex
.
is_valid
()
&&
(
size_t
)
_toVertex
.
idx
()
<
n_vertices
()
&&
!
is_deleted
(
_toVertex
)
);
// Test if edge does not exist, yet
if
(
!
_allowDuplicates
)
{
...
...
@@ -164,7 +164,7 @@ FaceHandle TopologyKernel::add_face(const std::vector<HalfEdgeHandle>& _halfedge
// Assert that halfedges are valid
for
(
std
::
vector
<
HalfEdgeHandle
>::
const_iterator
it
=
_halfedges
.
begin
(),
end
=
_halfedges
.
end
();
it
!=
end
;
++
it
)
assert
(
it
->
is_valid
()
&&
(
size_t
)
it
->
idx
()
<
edges_
.
size
()
*
2u
);
assert
(
it
->
is_valid
()
&&
(
size_t
)
it
->
idx
()
<
edges_
.
size
()
*
2u
&&
!
is_deleted
(
*
it
)
);
#endif
// Perform topology check
...
...
@@ -253,7 +253,7 @@ FaceHandle TopologyKernel::add_face(const std::vector<VertexHandle>& _vertices)
// Assert that all vertices have valid indices
for
(
std
::
vector
<
VertexHandle
>::
const_iterator
it
=
_vertices
.
begin
(),
end
=
_vertices
.
end
();
it
!=
end
;
++
it
)
assert
(
it
->
is_valid
()
&&
(
size_t
)
it
->
idx
()
<
n_vertices
());
assert
(
it
->
is_valid
()
&&
(
size_t
)
it
->
idx
()
<
n_vertices
()
&&
!
is_deleted
(
*
it
)
);
#endif
// Add edge for each pair of vertices
...
...
@@ -381,7 +381,7 @@ CellHandle TopologyKernel::add_cell(const std::vector<HalfFaceHandle>& _halfface
// Assert that halffaces have valid indices
for
(
std
::
vector
<
HalfFaceHandle
>::
const_iterator
it
=
_halffaces
.
begin
(),
end
=
_halffaces
.
end
();
it
!=
end
;
++
it
)
assert
(
it
->
is_valid
()
&&
((
size_t
)
it
->
idx
()
<
faces_
.
size
()
*
2u
));
assert
(
it
->
is_valid
()
&&
((
size_t
)
it
->
idx
()
<
faces_
.
size
()
*
2u
)
&&
!
is_deleted
(
*
it
)
);
#endif
// Perform topology check
...
...
@@ -483,6 +483,9 @@ CellHandle TopologyKernel::add_cell(const std::vector<HalfFaceHandle>& _halfface
/// Set the vertices of an edge
void
TopologyKernel
::
set_edge
(
const
EdgeHandle
&
_eh
,
const
VertexHandle
&
_fromVertex
,
const
VertexHandle
&
_toVertex
)
{
assert
(
_fromVertex
.
is_valid
()
&&
(
size_t
)
_fromVertex
.
idx
()
<
n_vertices
()
&&
!
is_deleted
(
_fromVertex
));
assert
(
_toVertex
.
is_valid
()
&&
(
size_t
)
_toVertex
.
idx
()
<
n_vertices
()
&&
!
is_deleted
(
_toVertex
));
Edge
&
e
=
edge
(
_eh
);
// Update bottom-up entries
...
...
@@ -591,6 +594,8 @@ void TopologyKernel::set_cell(const CellHandle& _ch, const std::vector<HalfFaceH
*/
VertexIter
TopologyKernel
::
delete_vertex
(
const
VertexHandle
&
_h
)
{
assert
(
!
is_deleted
(
_h
));
std
::
vector
<
VertexHandle
>
vs
;
vs
.
push_back
(
_h
);
...
...
@@ -641,6 +646,8 @@ VertexIter TopologyKernel::delete_vertex(const VertexHandle& _h) {
*/
EdgeIter
TopologyKernel
::
delete_edge
(
const
EdgeHandle
&
_h
)
{
assert
(
!
is_deleted
(
_h
));
std
::
vector
<
EdgeHandle
>
es
;
es
.
push_back
(
_h
);
...
...
@@ -682,6 +689,8 @@ EdgeIter TopologyKernel::delete_edge(const EdgeHandle& _h) {
*/
FaceIter
TopologyKernel
::
delete_face
(
const
FaceHandle
&
_h
)
{
assert
(
!
is_deleted
(
_h
));
std
::
vector
<
FaceHandle
>
fs
;
fs
.
push_back
(
_h
);
...
...
@@ -711,6 +720,7 @@ FaceIter TopologyKernel::delete_face(const FaceHandle& _h) {
*/
CellIter
TopologyKernel
::
delete_cell
(
const
CellHandle
&
_h
)
{
assert
(
!
is_deleted
(
_h
));
return
delete_cell_core
(
_h
);
}
...
...
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