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
Dmitri Naumov
ogs
Commits
db0b23b5
Commit
db0b23b5
authored
9 years ago
by
Karsten Rink
Committed by
Dmitri Naumov
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
adjusted tetgen interface to use mesh properties
parent
765b79a4
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
FileIO/TetGenInterface.cpp
+20
-4
20 additions, 4 deletions
FileIO/TetGenInterface.cpp
FileIO/TetGenInterface.h
+4
-0
4 additions, 0 deletions
FileIO/TetGenInterface.h
with
24 additions
and
4 deletions
FileIO/TetGenInterface.cpp
+
20
−
4
View file @
db0b23b5
...
...
@@ -218,7 +218,8 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh (std::string const& nodes_fname,
}
std
::
vector
<
MeshLib
::
Element
*>
elements
;
if
(
!
readElementsFromStream
(
ins_ele
,
elements
,
nodes
))
{
std
::
vector
<
int
>
materials
;
if
(
!
readElementsFromStream
(
ins_ele
,
elements
,
materials
,
nodes
))
{
// remove elements read until now
for
(
std
::
size_t
k
(
0
);
k
<
elements
.
size
();
k
++
)
{
delete
elements
[
k
];
...
...
@@ -230,8 +231,18 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh (std::string const& nodes_fname,
return
nullptr
;
}
MeshLib
::
Properties
properties
;
// remove material vector again if all mat-ids are "0"
if
(
*
(
std
::
max_element
(
materials
.
cbegin
(),
materials
.
cend
()))
>
0
)
{
boost
::
optional
<
MeshLib
::
PropertyVector
<
int
>
&>
mat_props
=
properties
.
createNewPropertyVector
<
int
>
(
"MaterialIDs"
,
MeshLib
::
MeshItemType
::
Cell
);
mat_props
->
resize
(
elements
.
size
());
std
::
copy
(
materials
.
cbegin
(),
materials
.
cend
(),
mat_props
->
begin
());
}
const
std
::
string
mesh_name
(
BaseLib
::
extractBaseNameWithoutExtension
(
nodes_fname
));
return
new
MeshLib
::
Mesh
(
mesh_name
,
nodes
,
elements
);
return
new
MeshLib
::
Mesh
(
mesh_name
,
nodes
,
elements
,
properties
);
}
bool
TetGenInterface
::
readNodesFromStream
(
std
::
ifstream
&
ins
,
...
...
@@ -354,6 +365,7 @@ bool TetGenInterface::parseNodes(std::ifstream &ins,
bool
TetGenInterface
::
readElementsFromStream
(
std
::
ifstream
&
ins
,
std
::
vector
<
MeshLib
::
Element
*>
&
elements
,
std
::
vector
<
int
>
&
materials
,
const
std
::
vector
<
MeshLib
::
Node
*>
&
nodes
)
const
{
std
::
string
line
;
...
...
@@ -375,7 +387,7 @@ bool TetGenInterface::readElementsFromStream(std::ifstream &ins,
bool
header_okay
=
parseElementsFileHeader
(
line
,
n_tets
,
n_nodes_per_tet
,
region_attributes
);
if
(
!
header_okay
)
return
false
;
if
(
!
parseElements
(
ins
,
elements
,
nodes
,
n_tets
,
n_nodes_per_tet
,
region_attributes
))
if
(
!
parseElements
(
ins
,
elements
,
materials
,
nodes
,
n_tets
,
n_nodes_per_tet
,
region_attributes
))
return
false
;
return
true
;
}
...
...
@@ -417,6 +429,7 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line,
bool
TetGenInterface
::
parseElements
(
std
::
ifstream
&
ins
,
std
::
vector
<
MeshLib
::
Element
*>
&
elements
,
std
::
vector
<
int
>
&
materials
,
const
std
::
vector
<
MeshLib
::
Node
*>
&
nodes
,
std
::
size_t
n_tets
,
std
::
size_t
n_nodes_per_tet
,
...
...
@@ -425,6 +438,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins,
std
::
string
line
;
std
::
size_t
*
ids
(
static_cast
<
std
::
size_t
*>
(
alloca
(
sizeof
(
std
::
size_t
)
*
n_nodes_per_tet
)));
elements
.
reserve
(
n_tets
);
materials
.
reserve
(
n_tets
);
const
unsigned
offset
=
(
_zero_based_idx
)
?
0
:
1
;
for
(
std
::
size_t
k
(
0
);
k
<
n_tets
&&
!
ins
.
fail
();
k
++
)
...
...
@@ -486,8 +500,10 @@ bool TetGenInterface::parseElements(std::ifstream& ins,
for
(
unsigned
k
(
0
);
k
<
4
;
k
++
)
{
tet_nodes
[
k
]
=
nodes
[
ids
[
k
]];
}
elements
.
push_back
(
new
MeshLib
::
Tet
(
tet_nodes
,
region
));
elements
.
push_back
(
new
MeshLib
::
Tet
(
tet_nodes
));
materials
.
push_back
(
region
);
}
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
FileIO/TetGenInterface.h
+
4
−
0
View file @
db0b23b5
...
...
@@ -144,11 +144,13 @@ private:
* For this purpose it uses methods parseElementsFileHeader() and parseElements().
* @param input the input stream
* @param elements the elements vector to be filled
* @param materials the vector containing material ids to be filled
* @param nodes the node information needed for creating elements
* @return true, if all information is read, false if the method detects an error
*/
bool
readElementsFromStream
(
std
::
ifstream
&
input
,
std
::
vector
<
MeshLib
::
Element
*>
&
elements
,
std
::
vector
<
int
>
&
materials
,
const
std
::
vector
<
MeshLib
::
Node
*>
&
nodes
)
const
;
/**
* Method parses the header of the elements file created by TetGen
...
...
@@ -166,6 +168,7 @@ private:
* Method parses the tetrahedras and put them in the element vector of the mesh class.
* @param ins the input stream
* @param elements the elements vector to be filled
* @param materials the vector containing material ids to be filled
* @param nodes the node information needed for creating elements
* @param n_tets the number of tetrahedras that should be read
* @param n_nodes_per_tet the number of nodes per tetrahedron
...
...
@@ -174,6 +177,7 @@ private:
*/
bool
parseElements
(
std
::
ifstream
&
ins
,
std
::
vector
<
MeshLib
::
Element
*>
&
elements
,
std
::
vector
<
int
>
&
materials
,
const
std
::
vector
<
MeshLib
::
Node
*>
&
nodes
,
std
::
size_t
n_tets
,
std
::
size_t
n_nodes_per_tet
,
...
...
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