Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65685160
paraview_helper.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jun 5, 12:59
Size
5 KB
Mime Type
text/x-c
Expires
Fri, Jun 7, 12:59 (2 d)
Engine
blob
Format
Raw Data
Handle
18112098
Attached To
rIOHELPER iohelper
paraview_helper.h
View Options
/*
Copyright 2008 Guillaume ANCIAUX (guillaume.anciaux@epfl.ch)
This file is part of ParaViewHelper.
ParaViewHelper is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ParaViewHelper is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ParaViewHelper. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PARAVIEWHELPER_H
#define PARAVIEWHELPER_H
#include "base64.h"
class
ParaviewHelper
{
public:
ParaviewHelper
(
File
&
f
){
file
=
f
;
setOutputFile
(
file
);
compteur
=
0
;
};
ParaviewHelper
(){
bflag
=
BASE64
;
compteur
=
0
;
};
virtual
~
ParaviewHelper
(){};
void
setOutputFile
(
File
&
file
);
void
write_header
(
int
nb_nodes
,
int
nb_elems
);
void
startDofList
(
int
dimension
);
void
endDofList
();
void
startCellsConnectivityList
();
void
endCellsConnectivityList
();
void
startCellsoffsetsList
();
void
endCellsoffsetsList
();
void
startCellstypesList
();
void
endCellstypesList
();
void
startPointDataList
();
void
endPointDataList
();
void
startCellDataList
();
void
endCellDataList
();
void
startData
(
const
char
*
name
,
int
nb_components
);
void
PDataArray
(
const
char
*
name
,
int
nb_components
);
void
endData
();
void
write_conclusion
();
void
pushDouble
(
double
x
);
void
pushInteger
(
int
i
);
void
SetMode
(
int
mode
){
bflag
=
BASE64
&
mode
;
}
protected:
Base64Writer
b64
;
int
bflag
;
File
file
;
long
header_offset
;
unsigned
int
compteur
;
};
inline
void
ParaviewHelper
::
setOutputFile
(
File
&
f
){
file
=
f
;
b64
.
SetOutputFile
(
file
);
}
inline
void
ParaviewHelper
::
write_header
(
int
nb_nodes
,
int
nb_elems
){
file
.
printf
(
"<VTKFile type=
\"
UnstructuredGrid
\"
version=
\"
0.1
\"
"
);
/* #ifdef BIG_ENDIAN */
/* file.printf("byte_order=\"BigEndian\">\n"); */
/* #else */
file
.
printf
(
"byte_order=
\"
LittleEndian
\"
>
\n
"
);
/* #endif */
file
.
printf
(
"<UnstructuredGrid>
\n
<Piece NumberOfPoints=
\"
%d
\"
NumberOfCells=
\"
%d
\"
>
\n
"
,
nb_nodes
,
nb_elems
);
}
inline
void
ParaviewHelper
::
startDofList
(
int
dimension
){
file
.
printf
(
"<Points><DataArray type =
\"
Float64
\"
NumberOfComponents=
\"
%d
\"
"
,
dimension
);
if
(
bflag
==
BASE64
)
file
.
printf
(
"format=
\"
binary
\"
>
\n
"
);
else
file
.
printf
(
"format=
\"
ascii
\"
>
\n
"
);
if
(
bflag
==
BASE64
)
b64
.
CreateHeader
();
}
inline
void
ParaviewHelper
::
endDofList
(){
if
(
bflag
==
BASE64
)
b64
.
WriteHeader
();
file
.
printf
(
"</DataArray>
\n
"
);
file
.
printf
(
"</Points>
\n
"
);
}
inline
void
ParaviewHelper
::
startCellsConnectivityList
(){
file
.
printf
(
"<Cells>
\n
"
);
file
.
printf
(
"<DataArray type=
\"
Int32
\"
Name=
\"
connectivity
\"
"
);
if
(
bflag
==
BASE64
)
file
.
printf
(
"format=
\"
binary
\"
>
\n
"
);
else
file
.
printf
(
"format=
\"
ascii
\"
>
\n
"
);
if
(
bflag
==
BASE64
)
b64
.
CreateHeader
();
}
inline
void
ParaviewHelper
::
endCellsConnectivityList
(){
if
(
bflag
==
BASE64
)
b64
.
WriteHeader
();
file
.
printf
(
"</DataArray>
\n
"
);
}
inline
void
ParaviewHelper
::
startCellsoffsetsList
(){
file
.
printf
(
"<DataArray type=
\"
Int32
\"
Name=
\"
offsets
\"
"
);
if
(
bflag
==
BASE64
)
file
.
printf
(
"format=
\"
binary
\"
>
\n
"
);
else
file
.
printf
(
"format=
\"
ascii
\"
>
\n
"
);
if
(
bflag
==
BASE64
)
b64
.
CreateHeader
();
}
inline
void
ParaviewHelper
::
endCellsoffsetsList
(){
if
(
bflag
==
BASE64
)
b64
.
WriteHeader
();
file
.
printf
(
"</DataArray>
\n
"
);
}
inline
void
ParaviewHelper
::
startCellstypesList
(){
file
.
printf
(
"<DataArray type=
\"
UInt32
\"
Name=
\"
types
\"
"
);
if
(
bflag
==
BASE64
)
file
.
printf
(
"format=
\"
binary
\"
>
\n
"
);
else
file
.
printf
(
"format=
\"
ascii
\"
>
\n
"
);
if
(
bflag
==
BASE64
)
b64
.
CreateHeader
();
}
inline
void
ParaviewHelper
::
endCellstypesList
(){
if
(
bflag
==
BASE64
)
b64
.
WriteHeader
();
file
.
printf
(
"</DataArray>
\n
"
);
file
.
printf
(
"</Cells>
\n
"
);
}
inline
void
ParaviewHelper
::
startPointDataList
(){
file
.
printf
(
"<PointData>
\n
"
);
}
inline
void
ParaviewHelper
::
endPointDataList
(){
file
.
printf
(
"</PointData>
\n
"
);
}
inline
void
ParaviewHelper
::
startCellDataList
(){
file
.
printf
(
"<CellData>
\n
"
);
}
inline
void
ParaviewHelper
::
endCellDataList
(){
file
.
printf
(
"</CellData>
\n
"
);
}
inline
void
ParaviewHelper
::
startData
(
const
char
*
name
,
int
nb_components
){
file
.
printf
(
"<DataArray type=
\"
Float64
\"
NumberOfComponents=
\"
%d
\"
Name=
\"
%s
\"
"
,
nb_components
,
name
);
if
(
bflag
==
BASE64
)
file
.
printf
(
"format=
\"
binary
\"
>
\n
"
);
else
file
.
printf
(
"format=
\"
ascii
\"
>
\n
"
);
if
(
bflag
==
BASE64
)
b64
.
CreateHeader
();
}
inline
void
ParaviewHelper
::
endData
(){
if
(
bflag
==
BASE64
)
b64
.
WriteHeader
();
file
.
printf
(
"</DataArray>
\n
"
);
}
inline
void
ParaviewHelper
::
PDataArray
(
const
char
*
name
,
int
nb_components
){
file
.
printf
(
"<PDataArray type=
\"
Float64
\"
NumberOfComponents=
\"
%d
\"
Name=
\"
%s
\"
"
,
nb_components
,
name
);
if
(
bflag
==
BASE64
)
file
.
printf
(
"format=
\"
binary
\"
></PDataArray>
\n
"
);
else
file
.
printf
(
"format=
\"
ascii
\"
></PDataArray>
\n
"
);
}
inline
void
ParaviewHelper
::
write_conclusion
(){
file
.
printf
(
"</Piece>
\n
"
);
file
.
printf
(
"</UnstructuredGrid></VTKFile>"
);
}
inline
void
ParaviewHelper
::
pushDouble
(
double
d
){
if
(
bflag
==
BASE64
)
b64
.
PushDoubleInBase64
(
d
);
else
{
file
.
printf
(
"%.15e "
,
d
);
++
compteur
;
if
(
compteur
%
3
==
0
)
file
.
printf
(
"
\n
"
);
}
}
inline
void
ParaviewHelper
::
pushInteger
(
int
i
){
if
(
bflag
==
BASE64
)
b64
.
PushIntegerInBase64
(
i
);
else
{
file
.
printf
(
"%d "
,
i
);
}
}
#endif
// PARAVIEWHELPER_H
Event Timeline
Log In to Comment