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
4920a07d
Commit
4920a07d
authored
11 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
Add MeshSubsets meshes uniqueness precondition in ctor.
parent
e3c29cb1
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/MeshSubsets.h
+20
-0
20 additions, 0 deletions
MeshLib/MeshSubsets.h
with
20 additions
and
0 deletions
MeshLib/MeshSubsets.h
+
20
−
0
View file @
4920a07d
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include
<vector>
#include
<vector>
#include
<algorithm>
#include
<algorithm>
#include
<stdexcept>
#include
"MeshLib/MeshSubset.h"
#include
"MeshLib/MeshSubset.h"
...
@@ -35,10 +36,15 @@ public:
...
@@ -35,10 +36,15 @@ public:
/// Construct MeshSubsets from a range of MeshSubset. InputIterator must
/// Construct MeshSubsets from a range of MeshSubset. InputIterator must
/// dereference to MeshSubset*.
/// dereference to MeshSubset*.
/// \pre All meshes of each of the MeshSubset objects must unique,
/// an exception is thrown otherwise.
template
<
typename
InputIterator
>
template
<
typename
InputIterator
>
MeshSubsets
(
InputIterator
const
&
first
,
InputIterator
const
&
last
)
MeshSubsets
(
InputIterator
const
&
first
,
InputIterator
const
&
last
)
:
_mesh_subsets
(
first
,
last
)
:
_mesh_subsets
(
first
,
last
)
{
{
if
(
!
areMeshSubsetMeshesUnique
())
throw
std
::
logic_error
(
"Mesh ids of input mesh subsets are not unique."
);
_n_total_items
=
std
::
accumulate
(
first
,
last
,
0u
,
_n_total_items
=
std
::
accumulate
(
first
,
last
,
0u
,
[](
std
::
size_t
const
&
sum
,
MeshSubset
const
*
const
mesh_subset
)
[](
std
::
size_t
const
&
sum
,
MeshSubset
const
*
const
mesh_subset
)
{
{
...
@@ -64,6 +70,20 @@ public:
...
@@ -64,6 +70,20 @@ public:
return
*
_mesh_subsets
[
mesh_index
];
return
*
_mesh_subsets
[
mesh_index
];
}
}
private
:
/// returns true if all mesh ids of _mesh_subsets elements are different.
bool
areMeshSubsetMeshesUnique
()
const
{
std
::
vector
<
std
::
size_t
>
mesh_ids
;
std
::
transform
(
_mesh_subsets
.
cbegin
(),
_mesh_subsets
.
cend
(),
std
::
back_inserter
(
mesh_ids
),
std
::
mem_fun
(
&
MeshSubset
::
getMeshID
));
std
::
sort
(
mesh_ids
.
begin
(),
mesh_ids
.
end
());
auto
const
it
=
std
::
adjacent_find
(
mesh_ids
.
cbegin
(),
mesh_ids
.
cend
());
return
mesh_ids
.
cend
()
==
it
;
}
private
:
private
:
std
::
vector
<
const
MeshSubset
*>
_mesh_subsets
;
std
::
vector
<
const
MeshSubset
*>
_mesh_subsets
;
...
...
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