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
Snippets
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
Karsten Rink
ogs
Commits
5adc7184
Commit
5adc7184
authored
9 years ago
by
Karsten Rink
Browse files
Options
Downloads
Patches
Plain Diff
added functionality for flipping elements
parent
dd835eda
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeshLib/MeshEditing/FlipElements.cpp
+69
-0
69 additions, 0 deletions
MeshLib/MeshEditing/FlipElements.cpp
MeshLib/MeshEditing/FlipElements.h
+36
-0
36 additions, 0 deletions
MeshLib/MeshEditing/FlipElements.h
with
105 additions
and
0 deletions
MeshLib/MeshEditing/FlipElements.cpp
0 → 100644
+
69
−
0
View file @
5adc7184
/**
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include
"FlipElements.h"
#include
"MeshLib/Elements/Element.h"
#include
"MeshLib/Node.h"
#include
"MeshLib/Elements/Line.h"
#include
"MeshLib/Elements/Tri.h"
#include
"MeshLib/Elements/Quad.h"
#include
"DuplicateMeshComponents.h"
namespace
MeshLib
{
MeshLib
::
Element
*
flipElement
(
MeshLib
::
Element
const
&
elem
,
std
::
vector
<
MeshLib
::
Node
*>
const
&
nodes
)
{
if
(
elem
.
getDimension
()
>
2
)
return
nullptr
;
std
::
size_t
const
n_nodes
(
elem
.
getNNodes
());
MeshLib
::
Node
**
elem_nodes
=
new
MeshLib
::
Node
*
[
n_nodes
];
for
(
unsigned
i
=
0
;
i
<
n_nodes
;
++
i
)
elem_nodes
[
i
]
=
nodes
[
elem
.
getNode
(
i
)
->
getID
()];
MeshLib
::
Node
*
tmp
(
elem_nodes
[
0
]);
elem_nodes
[
0
]
=
elem_nodes
[
1
];
elem_nodes
[
1
]
=
tmp
;
if
(
elem
.
getGeomType
()
==
MeshElemType
::
LINE
)
return
new
MeshLib
::
Line
(
elem_nodes
,
elem
.
getID
());
else
if
(
elem
.
getGeomType
()
==
MeshElemType
::
TRIANGLE
)
return
new
MeshLib
::
Tri
(
elem_nodes
,
elem
.
getID
());
else
if
(
elem
.
getGeomType
()
==
MeshElemType
::
QUAD
)
{
tmp
=
elem_nodes
[
2
];
elem_nodes
[
2
]
=
elem_nodes
[
3
];
elem_nodes
[
3
]
=
tmp
;
return
new
MeshLib
::
Quad
(
elem_nodes
,
elem
.
getID
());
}
return
nullptr
;
}
MeshLib
::
Mesh
*
flipMeshElements
(
MeshLib
::
Mesh
const
&
mesh
)
{
if
(
mesh
.
getDimension
()
>
2
)
return
nullptr
;
std
::
vector
<
MeshLib
::
Node
*>
new_nodes
(
MeshLib
::
copyNodeVector
(
mesh
.
getNodes
()));
std
::
vector
<
MeshLib
::
Element
*>
const
&
elems
(
mesh
.
getElements
());
std
::
vector
<
MeshLib
::
Element
*>
new_elems
;
std
::
size_t
n_elems
(
mesh
.
getNElements
());
new_elems
.
reserve
(
n_elems
);
for
(
std
::
size_t
i
=
0
;
i
<
n_elems
;
++
i
)
new_elems
.
push_back
(
flipElement
(
*
elems
[
i
],
new_nodes
));
MeshLib
::
Properties
new_props
(
mesh
.
getProperties
());
return
new
MeshLib
::
Mesh
(
"FlippedElementMesh"
,
new_nodes
,
new_elems
,
new_props
);
}
}
// end namespace MeshLib
This diff is collapsed.
Click to expand it.
MeshLib/MeshEditing/FlipElements.h
0 → 100644
+
36
−
0
View file @
5adc7184
/**
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef FLIPELEMENTS_H_
#define FLIPELEMENTS_H_
#include
<vector>
#include
"MeshLib/Elements/Element.h"
namespace
MeshLib
{
class
Mesh
;
class
Node
;
/**
* Reverses the node order of a 1D / 2D element such that the direction
* of a line changes and normals of 2D elements changes its sign.
*/
MeshLib
::
Element
*
flipElement
(
MeshLib
::
Element
const
&
elem
,
std
::
vector
<
MeshLib
::
Node
*>
const
&
nodes
);
/**
* Reverses the node order of all elements in a 1D / 2D mesh such that
* the direction of lines changes and normals of 2D elements changes
* their sign.
*/
MeshLib
::
Mesh
*
flipMeshElements
(
MeshLib
::
Mesh
const
&
mesh
);
}
#endif //FLIPELEMENTS_H_
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