Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
KennethVanhoey
CGoGN
Commits
035fdf2f
Commit
035fdf2f
authored
May 16, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add export tetmesh format
parent
e6466e4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
include/Algo/Export/exportVol.h
include/Algo/Export/exportVol.h
+12
-0
include/Algo/Export/exportVol.hpp
include/Algo/Export/exportVol.hpp
+73
-0
No files found.
include/Algo/Export/exportVol.h
View file @
035fdf2f
...
...
@@ -113,6 +113,18 @@ bool exportNodeEle(typename PFP::MAP& map, const VertexAttribute<typename PFP::V
template
<
typename
PFP
>
bool
exportVolBinGz
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
char
*
filename
);
/**
* export tetmesh format
* @warning if macro _OPTIMIZED_FOR_TETRA_ONLY_ (before include) is define assume map contain only tetrahedrons
* @param the_map map to be exported
* @param position the position container
* @param filename filename of mesh file
*/
template
<
typename
PFP
>
bool
exportTetmesh
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
char
*
filename
);
}
// namespace Export
}
...
...
include/Algo/Export/exportVol.hpp
View file @
035fdf2f
...
...
@@ -757,6 +757,76 @@ bool exportVolBinGz(typename PFP::MAP& map, const VertexAttribute<typename PFP::
}
template
<
typename
PFP
>
bool
exportTetmesh
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
char
*
filename
)
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
// open file
std
::
ofstream
fout
;
fout
.
open
(
filename
,
std
::
ios
::
out
)
;
if
(
!
fout
.
good
())
{
CGoGNerr
<<
"Unable to open file "
<<
filename
<<
CGoGNendl
;
return
false
;
}
VertexAutoAttribute
<
unsigned
int
>
indices
(
map
,
"indices_vert"
);
fout
<<
" Vertices"
<<
std
::
endl
<<
position
.
nbElements
()
<<
std
::
endl
;
std
::
vector
<
unsigned
int
>
tetra
;
tetra
.
reserve
(
2048
);
unsigned
int
count
=
1
;
for
(
unsigned
int
i
=
position
.
begin
();
i
!=
position
.
end
();
position
.
next
(
i
))
{
const
VEC3
&
P
=
position
[
i
];
fout
<<
P
[
0
]
<<
" "
<<
P
[
1
]
<<
" "
<<
P
[
2
]
<<
std
::
endl
;
indices
[
i
]
=
count
++
;
}
TraversorW
<
MAP
>
trav
(
map
)
;
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
#ifndef _OPTIMIZED_FOR_TETRA_ONLY_
unsigned
int
degree
=
0
;
Traversor3WV
<
typename
PFP
::
MAP
>
twv
(
map
,
d
)
;
for
(
Dart
it
=
twv
.
begin
();
it
!=
twv
.
end
();
it
=
twv
.
next
())
{
degree
++
;
}
if
(
degree
==
4
)
#endif
{
Dart
e
=
d
;
tetra
.
push_back
(
indices
[
e
]);
e
=
map
.
phi_1
(
e
);
tetra
.
push_back
(
indices
[
e
]);
e
=
map
.
phi_1
(
e
);
tetra
.
push_back
(
indices
[
e
]);
e
=
map
.
template
phi
<
211
>(
e
);
tetra
.
push_back
(
indices
[
e
]);
}
}
unsigned
int
nbtetra
=
tetra
.
size
()
/
4
;
fout
<<
" Tetrahedra"
<<
std
::
endl
<<
nbtetra
<<
std
::
endl
;
for
(
unsigned
int
i
=
0
;
i
<
nbtetra
;
++
i
)
{
fout
<<
tetra
[
4
*
i
]
<<
" "
<<
tetra
[
4
*
i
+
1
]
<<
" "
<<
tetra
[
4
*
i
+
2
]
<<
" "
<<
tetra
[
4
*
i
+
3
]
<<
std
::
endl
;
}
fout
.
close
();
return
true
;
}
template
<
typename
PFP
>
bool
exportMesh
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
const
std
::
string
&
filename
)
{
...
...
@@ -783,6 +853,9 @@ bool exportMesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3
case
Import
::
VBGZ
:
return
exportVolBinGz
<
PFP
>
(
map
,
position
,
filename
.
c_str
());
break
;
case
Import
::
TETMESH
:
return
exportTetmesh
<
PFP
>
(
map
,
position
,
filename
.
c_str
());
break
;
default:
CGoGNerr
<<
"unknown file format for "
<<
filename
<<
CGoGNendl
;
break
;
...
...
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