Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
Functions
inout.c File Reference

Input / Output Functions. More...

#include "mmgcommon_private.h"
Include dependency graph for inout.c:

Go to the source code of this file.

Functions

int MMG5_swapbin (int sbin)
 
MMG5_int MMG5_swapbin_int (MMG5_int sbin)
 
float MMG5_swapf (float sbin)
 
double MMG5_swapd (double sbin)
 
static int MMG5_countBinaryElts (FILE **inm, const int nelts, const int iswp, int *np, int *na, int *nt, int *nq, int *ne, int *npr)
 
int MMG5_loadMshMesh_part1 (MMG5_pMesh mesh, const char *filename, FILE **inm, long *posNodes, long *posElts, long **posNodeData, int *bin, int *iswp, MMG5_int *nelts, int *nsols)
 
int MMG5_check_readedMesh (MMG5_pMesh mesh, MMG5_int nref)
 
int MMG5_loadMshMesh_part2 (MMG5_pMesh mesh, MMG5_pSol *sol, FILE **inm, const long posNodes, const long posElts, const long *posNodeData, const int bin, const int iswp, const MMG5_int nelts, const int nsols)
 
void MMG5_build3DMetric (MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int ip, double dbuf[6])
 
int MMG5_saveMshMesh (MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename, int metricData)
 
int MMG5_loadSolHeader (const char *filename, int meshDim, FILE **inm, int *ver, int *bin, int *iswp, MMG5_int *np, int *dim, int *nsols, int **type, long *posnp, int imprim)
 
int MMG5_readFloatSol3D (MMG5_pSol sol, FILE *inm, int bin, int iswp, int pos)
 
int MMG5_readDoubleSol3D (MMG5_pSol sol, FILE *inm, int bin, int iswp, MMG5_int pos)
 
void MMG5_writeDoubleSol3D (MMG5_pMesh mesh, MMG5_pSol sol, FILE *inm, int bin, MMG5_int pos, int metricData)
 
int MMG5_saveSolHeader (MMG5_pMesh mesh, const char *filename, FILE **inm, int ver, int *bin, MMG5_int *bpos, MMG5_int np, int dim, int nsols, int *entities, int *type, int *size)
 
int MMG5_saveSolAtTrianglesHeader (MMG5_pMesh mesh, FILE *inm, int ver, int bin, MMG5_int *bpos, int nsols, int nsolsAtTriangles, int *entities, int *type, int *size)
 
int MMG5_saveSolAtTetrahedraHeader (MMG5_pMesh mesh, FILE *inm, int ver, int bin, MMG5_int *bpos, int nsols, int nsolsAtTetra, int *entities, int *type, int *size)
 
int MMG5_chkMetricType (MMG5_pMesh mesh, int *type, int *entities, FILE *inm)
 
void MMG5_printMetStats (MMG5_pMesh mesh, MMG5_pSol met)
 
void MMG5_printSolStats (MMG5_pMesh mesh, MMG5_pSol *sol)
 
int MMG5_saveNode (MMG5_pMesh mesh, const char *filename)
 
int MMG5_saveEdge (MMG5_pMesh mesh, const char *filename, const char *ext)
 

Detailed Description

Input / Output Functions.

Author
Charles Dapogny (UPMC)
Cécile Dobrzynski (Bx INP/Inria/UBordeaux)
Pascal Frey (UPMC)
Algiane Froehly (Inria/UBordeaux)
Version
5
Todo:
doxygen documentation.

Definition in file inout.c.

Function Documentation

◆ MMG5_build3DMetric()

void MMG5_build3DMetric ( MMG5_pMesh  mesh,
MMG5_pSol  sol,
MMG5_int  ip,
double  dbuf[6] 
)
Parameters
meshpointer toward the mesh structure
solpointer toward the sol structure.
indexof point in which we want to build the metric
dbufbuilded metric

Build the metric at point ip depending with its type (ridge/not ridge).

Definition at line 1528 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_check_readedMesh()

int MMG5_check_readedMesh ( MMG5_pMesh  mesh,
MMG5_int  nref 
)
Parameters
meshpointer toward an Mmg mesh
nrefpointer toward the number of negative refs (replaced by abolute values).
Returns
1 if success, 0 otherwise

Check the tetra orientation, print warning it negative refs have been detected, mark points as used and remove elt refs in iso mode.

Definition at line 526 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_chkMetricType()

int MMG5_chkMetricType ( MMG5_pMesh  mesh,
int *  type,
int *  entities,
FILE *  inm 
)
Parameters
meshpointer toward the mesh structure.
typetype of the metric
entitiesentities on which the metric applies (should be MMG5_Vertex)
inmmetric file
Returns
1 if success, -1 if fail

Check metric data:

  1. check that the metric applies on vertices;
  2. check that the type of the metric is compatible with the remeshing mode. If not, close the metric file (note that if type is an allocated array, you must unallocate it outside).

Definition at line 2661 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_countBinaryElts()

static int MMG5_countBinaryElts ( FILE **  inm,
const int  nelts,
const int  iswp,
int *  np,
int *  na,
int *  nt,
int *  nq,
int *  ne,
int *  npr 
)
static
Parameters
inmpointer toward file unit
neltsnumber of elements
iswap1 if we need to swap bites for little/big endian conversion
npnumber of points
nanumber of edges
ntnumber of tria
nqnumber of quads
nenumber of tetra
nprnumber of prisms

Count number of elts of each type. For now only int32 integers are supported.

Definition at line 127 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_loadMshMesh_part1()

int MMG5_loadMshMesh_part1 ( MMG5_pMesh  mesh,
const char *  filename,
FILE **  inm,
long *  posNodes,
long *  posElts,
long **  posNodeData,
int *  bin,
int *  iswp,
MMG5_int *  nelts,
int *  nsols 
)
Parameters
meshpointer toward the mesh
filenamepointer toward the name of file
inmpointer toward the file pointer
posNodespointer toward the position of nodes data in file
posEltspointer toward the position of elts data in file
posNodeDatapointer toward the list of the positions of data in file
bin1 if binary format
neltsnumber of elements in file
nsolnumber of data in file
Returns
1 if success, 0 if file is not found, -1 if fail.

Begin to read mesh at MSH file format. Read the mesh size informations.

Remarks
For now only intput files containing int32 integers are supported.

Definition at line 278 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_loadMshMesh_part2()

int MMG5_loadMshMesh_part2 ( MMG5_pMesh  mesh,
MMG5_pSol sol,
FILE **  inm,
const long  posNodes,
const long  posElts,
const long *  posNodeData,
const int  bin,
const int  iswp,
const MMG5_int  nelts,
const int  nsols 
)
Parameters
meshpointer toward the mesh
solpointer toward the solutions array
inmpointer toward the file pointer
posNodesposition of nodes data in file
posEltsposition of elts data in file
posNodeDataposition of solution data in file
bin1 if binary format
neltsnumber of elements in file
nsolsnumber of silutions in file
Returns
1 if success, -1 if fail.

End to read mesh and solution array at MSH file format after the mesh/solution array alloc.

Remarks
For now only intput files containing int32 integers are supported.

Second step: read the nodes and elements

Read the solution at nodes

Definition at line 668 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_loadSolHeader()

int MMG5_loadSolHeader ( const char *  filename,
int  meshDim,
FILE **  inm,
int *  ver,
int *  bin,
int *  iswp,
MMG5_int *  np,
int *  dim,
int *  nsols,
int **  type,
long *  posnp,
int  imprim 
)
Parameters
filenamename of file.
meshDimmesh dimenson.
inmallocatable pointer toward the FILE structure
verfile version (1=simple precision, 2=double)
bin1 if the file is a binary
iswp1 or 0 depending on the endianness (binary only)
npnumber of solutions of each type
dimsolution dimension
nsolsnumber of solutions of different types in the file
typetype of solutions
posnppointer toward the position of the point list in the file
imprimverbosity
Returns
-1 data invalid or we fail, 0 no file, 1 ok.

Open the "filename" solution file and read the file header.

Definition at line 2080 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_printMetStats()

void MMG5_printMetStats ( MMG5_pMesh  mesh,
MMG5_pSol  met 
)
Parameters
meshpointer toward the mesh structure.
metpointer toward the metric structure.

print metric statistics

Definition at line 2705 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_printSolStats()

void MMG5_printSolStats ( MMG5_pMesh  mesh,
MMG5_pSol sol 
)
Parameters
meshpointer toward the mesh structure.
solpointer toward the solutions array.

print solutions statistics

Definition at line 2723 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_readDoubleSol3D()

int MMG5_readDoubleSol3D ( MMG5_pSol  sol,
FILE *  inm,
int  bin,
int  iswp,
MMG5_int  pos 
)
Parameters
solpointer toward an allocatable sol structure.
inmpointer toward the solution file
bin1 if binary file
iswpEndianess
indexof the readed solution
Returns
1 if success, -1 if fail

Read the solution value for vertex of index pos in double precision.

Definition at line 2269 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_readFloatSol3D()

int MMG5_readFloatSol3D ( MMG5_pSol  sol,
FILE *  inm,
int  bin,
int  iswp,
int  pos 
)
Parameters
solpointer toward an allocatable sol structure.
inmpointer toward the solution file
bin1 if binary file
iswpEndianess
indexof the readed solution
Returns
1 if success, -1 if fail

Read the solution value for vertex of index pos in floating precision.

Definition at line 2220 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_saveEdge()

int MMG5_saveEdge ( MMG5_pMesh  mesh,
const char *  filename,
const char *  ext 
)
Parameters
meshpointer toward the mesh structure.
filenamename of file.
extfile extension (.poly or .edge)
Returns
1 if success, 0 if fail.

Save edge list at .edge file format (Tetgen/Triangle).

Definition at line 2816 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_saveMshMesh()

int MMG5_saveMshMesh ( MMG5_pMesh  mesh,
MMG5_pSol sol,
const char *  filename,
int  metricData 
)
Parameters
meshpointer toward the mesh structure.
solpointer toward an array of solutions.
filenamename of file.
metricData1 if the data saved is a metric (if only 1 data)
Returns
0 if failed, 1 otherwise.

Write mesh and a list of solutions at MSH file format (.msh extension). Write binary file for .mshb extension.and ASCII for .msh one.

First step: Count the number of elements of each type

Second step: save the elements at following format: "idx type tagNumber tag0 tag1... v0_elt v1_elt..."

Write solution

Save the solution at following format: "idx sol"

Definition at line 1587 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMG5_saveNode()

int MMG5_saveNode ( MMG5_pMesh  mesh,
const char *  filename 
)
Parameters
meshpointer toward the mesh structure.
filenamename of file.
Returns
1 if success, 0 if fail.

Save node list at .node file format (Tetgen/Triangle).

Definition at line 2741 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_saveSolAtTetrahedraHeader()

int MMG5_saveSolAtTetrahedraHeader ( MMG5_pMesh  mesh,
FILE *  inm,
int  ver,
int  bin,
MMG5_int *  bpos,
int  nsols,
int  nsolsAtTetra,
int *  entities,
int *  type,
int *  size 
)
Parameters
meshpointer toward the mesh structure.
inmpointer toward the opened file unit.
verfile version (1=simple precision, 2=double).
bin1 if the file is a binary.
bposcumulative field position for binary Medit format.
nsolsnumber of solutions of different types in the file.
nsolsAtTetranumber of solutions at tetra in the file.
entitieskind of entity on which the solution applies.
typetype of solutions.
sizesize of solutions.

Save the number and type of solutions at Tetrahedron (not used by Mmg).

Definition at line 2593 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_saveSolAtTrianglesHeader()

int MMG5_saveSolAtTrianglesHeader ( MMG5_pMesh  mesh,
FILE *  inm,
int  ver,
int  bin,
MMG5_int *  bpos,
int  nsols,
int  nsolsAtTriangles,
int *  entities,
int *  type,
int *  size 
)
Parameters
meshpointer toward the mesh structure.
inmpointer toward the opened file unit.
verfile version (1=simple precision, 2=double).
bin1 if the file is a binary.
bposcumulative field position for binary Medit format.
nsolsnumber of solutions of different types in the file.
nsolsAtTrianglesnumber of solutions at triangles in the file.
entitieskind of entity on which the solution applies.
typetype of solutions.
sizesize of solutions.

Save the number and type of solutions at Triangles (not used by Mmg).

Definition at line 2524 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_saveSolHeader()

int MMG5_saveSolHeader ( MMG5_pMesh  mesh,
const char *  filename,
FILE **  inm,
int  ver,
int *  bin,
MMG5_int *  bpos,
MMG5_int  np,
int  dim,
int  nsols,
int *  entities,
int *  type,
int *  size 
)
Parameters
meshpointer toward the mesh structure.
filenamename of file.
inmallocatable pointer toward the FILE structure.
verfile version (1=simple precision, 2=double).
bin1 if the file is a binary.
bposcumulative field position for binary Medit format.
npnumber of solutions of each type.
dimsolution dimension.
nsolsnumber of solutions of different types in the file.
entitieskind of entity on which the solution applies (Vertex or Tetra)
typetype of solutions.
sizesize of solutions.
Returns
0 if unable to open the file, 1 if success.

Open the "filename" solution file and save the file header and the number and type of solutions at vertices (Native solutions for Mmg).

Definition at line 2387 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_swapbin()

int MMG5_swapbin ( int  sbin)

swap bytes if needed (conversion from big/little endian toward little/big endian)

Definition at line 42 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_swapbin_int()

MMG5_int MMG5_swapbin_int ( MMG5_int  sbin)

swap bytes if needed (conversion from big/little endian toward little/big endian)

Definition at line 61 of file inout.c.

◆ MMG5_swapd()

double MMG5_swapd ( double  sbin)

swap bytes if needed (conversion from big/little endian toward little/big endian)

Definition at line 97 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_swapf()

float MMG5_swapf ( float  sbin)

swap bytes if needed (conversion from big/little endian toward little/big endian)

Definition at line 80 of file inout.c.

Here is the caller graph for this function:

◆ MMG5_writeDoubleSol3D()

void MMG5_writeDoubleSol3D ( MMG5_pMesh  mesh,
MMG5_pSol  sol,
FILE *  inm,
int  bin,
MMG5_int  pos,
int  metricData 
)
Parameters
meshpointer toward the mesh structure
solpointer toward an allocatable sol structure.
inmpointer toward the solution file
bin1 if binary file
posof the writted solution
metricData1 if the data saved is a metric (if only 1 data)

Write the solution value for vertex of index pos in double precision.

Definition at line 2318 of file inout.c.

Here is the call graph for this function:
Here is the caller graph for this function: