Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
inoutcpp_3d.cpp
Go to the documentation of this file.
1
2/* =============================================================================
3** This file is part of the mmg software package for the tetrahedral
4** mesh modification.
5** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004-
6**
7** mmg is free software: you can redistribute it and/or modify it
8** under the terms of the GNU Lesser General Public License as published
9** by the Free Software Foundation, either version 3 of the License, or
10** (at your option) any later version.
11**
12** mmg is distributed in the hope that it will be useful, but WITHOUT
13** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15** License for more details.
16**
17** You should have received a copy of the GNU Lesser General Public
18** License and of the GNU General Public License along with mmg (in
19** files COPYING.LESSER and COPYING). If not, see
20** <http://www.gnu.org/licenses/>. Please read their terms carefully and
21** use this copy of the mmg distribution only if you accept them.
22** =============================================================================
23*/
24
35#include "vtkparser.hpp"
36
37#include "libmmg3d.h"
38#include "libmmg3d_private.h"
39
40#ifdef USE_VTK
41
43 vtkDataSet **dataset, int8_t ptMeditRef,
44 int8_t eltMeditRef,int nsols ) {
45
46 int ier;
47
48 if ( !MMG3D_zaldy(mesh) ) {
49 return -1;
50 }
51 if (mesh->npmax < mesh->np || mesh->ntmax < mesh->nt || mesh->nemax < mesh->ne) {
52 return -1;
53 }
54 if ( !mesh->ne ) {
55 fprintf(stderr," ** MISSING DATA.\n");
56 fprintf(stderr," Check that your mesh contains tetrahedra.\n");
57 fprintf(stderr," Exit program.\n");
58 return -1;
59 }
60
61 ier = MMG5_loadVtkMesh_part2(mesh,sol,dataset,ptMeditRef,eltMeditRef,nsols);
62
63 if ( ier < 1 ) {
64 fprintf(stderr," ** ERROR WHEN PARSING THE INPUT FILE\n");
65 return ier;
66 }
67
68 return ier;
69}
70#endif
71
72
74
75#ifndef USE_VTK
76
77 fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
78 return -1;
79
80#else
81 int ier,nsols;
82 int8_t ptMeditRef,eltMeditRef,metricData;
83 vtkDataSet *dataset;
84
85 mesh->dim = 3;
86
87 ier = MMG5_loadVtuMesh_part1(mesh,filename,&dataset,&ptMeditRef,&eltMeditRef,
88 &nsols,&metricData);
89 if ( ier < 1 ) return ier;
90
91 /* Check data fields */
92 if ( nsols > metricData ) {
93 fprintf(stderr,"Error: %d UNEXPECTED DATA FIELD(S)\n",nsols);
94 return -1;
95 }
96
97 // Mesh alloc and transfer of the mesh from dataset toward the MMG5 Mesh Sol
98 ier = MMG3D_loadVtkMesh_part2(mesh,&sol,&dataset,ptMeditRef,eltMeditRef,nsols);
99 if ( ier < 1 ) {
100 fprintf(stderr," ** ERROR WHEN PARSING THE INPUT FILE\n");
101 return ier;
102 }
103
104 if ( sol ) {
105 /* Check the metric type */
106 ier = MMG5_chkMetricType(mesh,&sol->type,&sol->entities,NULL);
107 }
108
109 return ier;
110#endif
111}
112
114
115#ifndef USE_VTK
116
117 fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
118 return -1;
119
120#else
121 int ier,nsols;
122 int8_t ptMeditRef,eltMeditRef,metricData;
123 vtkDataSet *dataset;
124
125 mesh->dim = 3;
126
127 ier = MMG5_loadVtuMesh_part1(mesh,filename,&dataset,&ptMeditRef,&eltMeditRef,
128 &nsols,&metricData);
129 if ( ier < 1 ) return ier;
130
131 mesh->nsols = nsols;
132 if ( *sol ) MMG5_DEL_MEM(mesh,*sol);
133
134 MMG5_ADD_MEM(mesh,nsols*sizeof(MMG5_Sol),"solutions array",
135 printf(" Exit program.\n");
136 return -1);
137 MMG5_SAFE_CALLOC(*sol,nsols,MMG5_Sol,return -1);
138
139 // Mesh alloc and transfer of the mesh from dataset toward the MMG5 Mesh Sol
140 ier = MMG3D_loadVtkMesh_part2(mesh,sol,&dataset,ptMeditRef,eltMeditRef,nsols);
141
142 return ier;
143#endif
144}
145
147
148#ifndef USE_VTK
149
150 fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
151 return -1;
152
153#else
154 int ier,nsols;
155 int8_t ptMeditRef,eltMeditRef,metricData;
156 vtkDataSet *dataset;
157
158 mesh->dim = 3;
159
160 ier = MMG5_loadVtkMesh_part1(mesh,filename,&dataset,&ptMeditRef,&eltMeditRef,
161 &nsols,&metricData);
162 if ( ier < 1 ) return ier;
163
164 /* Check data fields */
165 if ( nsols > metricData ) {
166 fprintf(stderr,"Error: %d UNEXPECTED DATA FIELD(S)\n",nsols);
167 return -1;
168 }
169
170 // Mesh alloc and transfer of the mesh from dataset toward the MMG5 Mesh Sol
171 ier = MMG3D_loadVtkMesh_part2(mesh,&sol,&dataset,ptMeditRef,eltMeditRef,nsols);
172 if ( ier < 1 ) {
173 fprintf(stderr," ** ERROR WHEN PARSING THE INPUT FILE\n");
174 return ier;
175 }
176
177 if ( sol ) {
178 /* Check the metric type */
179 ier = MMG5_chkMetricType(mesh,&sol->type,&sol->entities,NULL);
180 }
181
182 return ier;
183#endif
184}
185
187
188#ifndef USE_VTK
189
190 fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
191 return -1;
192
193#else
194 int ier,nsols;
195 int8_t ptMeditRef,eltMeditRef,metricData;
196 vtkDataSet *dataset;
197
198 mesh->dim = 3;
199
200 ier = MMG5_loadVtkMesh_part1(mesh,filename,&dataset,&ptMeditRef,&eltMeditRef,
201 &nsols,&metricData);
202 if ( ier < 1 ) return ier;
203
204 mesh->nsols = nsols;
205 if ( *sol ) MMG5_DEL_MEM(mesh,*sol);
206
207 MMG5_ADD_MEM(mesh,nsols*sizeof(MMG5_Sol),"solutions array",
208 printf(" Exit program.\n");
209 return -1);
210 MMG5_SAFE_CALLOC(*sol,nsols,MMG5_Sol,return -1);
211
212 // Mesh alloc and transfer of the mesh from dataset toward the MMG5 Mesh Sol
213 ier = MMG3D_loadVtkMesh_part2(mesh,sol,&dataset,ptMeditRef,eltMeditRef,nsols);
214
215 return ier;
216#endif
217}
218
220
221#ifndef USE_VTK
222
223 fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
224 return -1;
225
226#else
227 return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkXMLUnstructuredGridWriter,
228 vtkXMLPUnstructuredGridWriter>(mesh,&sol,filename,1,1);
229
230#endif
231}
233
234#ifndef USE_VTK
235
236 fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
237 return -1;
238
239#else
240
241 return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkXMLUnstructuredGridWriter,
242 vtkXMLPUnstructuredGridWriter>(mesh,sol,filename,0,1);
243
244#endif
245}
246
247
249
250#ifndef USE_VTK
251
252 fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
253 return -1;
254
255#else
256
257 return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkDataSetWriter,
258 vtkPDataSetWriter>(mesh,&sol,filename,1,0);
259
260#endif
261}
262
264
265#ifndef USE_VTK
266
267 fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
268 return -1;
269
270#else
271
272 return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkDataSetWriter,
273 vtkPDataSetWriter>(mesh,sol,filename,0,0);
274
275#endif
276}
int ier
MMG5_pMesh MMG5_pSol * sol
MMG5_pMesh * mesh
MMG5_pMesh char * filename
int MMG5_chkMetricType(MMG5_pMesh mesh, int *type, int *entities, FILE *inm)
Definition: inout.c:2661
int MMG3D_loadVtuMesh_and_allData(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename)
int MMG3D_loadVtkMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
int MMG3D_saveVtuMesh_and_allData(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename)
int MMG3D_loadVtkMesh_and_allData(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename)
int MMG3D_loadVtuMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Definition: inoutcpp_3d.cpp:73
int MMG3D_saveVtkMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
int MMG3D_saveVtkMesh_and_allData(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename)
int MMG3D_saveVtuMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
static int MMG3D_loadVtkMesh_part2(MMG5_pMesh mesh, MMG5_pSol *sol, vtkDataSet **dataset, int8_t ptMeditRef, int8_t eltMeditRef, int nsols)
Input / Output Functions that needs cpp features.
Definition: inoutcpp_3d.cpp:42
API headers for the mmg3d library.
int MMG3D_zaldy(MMG5_pMesh mesh)
Definition: zaldy_3d.c:346
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MMG5_ADD_MEM(mesh, size, message, law)
#define MMG5_DEL_MEM(mesh, ptr)
MMG mesh structure.
Definition: libmmgtypes.h:605
MMG5_int ntmax
Definition: libmmgtypes.h:612
MMG5_int ne
Definition: libmmgtypes.h:612
MMG5_int nemax
Definition: libmmgtypes.h:612
MMG5_int npmax
Definition: libmmgtypes.h:612
MMG5_int nt
Definition: libmmgtypes.h:612
MMG5_int np
Definition: libmmgtypes.h:612
int MMG5_loadVtkMesh_part2(MMG5_pMesh mesh, MMG5_pSol *sol, vtkDataSet **dataset, int8_t ptMeditRef, int8_t eltMeditRef, int nsols)
Definition: vtkparser.cpp:346
int MMG5_loadVtuMesh_part1(MMG5_pMesh mesh, const char *filename, vtkDataSet **dataset, int8_t *ptMeditRef, int8_t *eltMeditRef, int *nsols, int8_t *metricData)
Definition: vtkparser.cpp:308
int MMG5_loadVtkMesh_part1(MMG5_pMesh mesh, const char *filename, vtkDataSet **dataset, int8_t *ptMeditRef, int8_t *eltMeditRef, int *nsols, int8_t *metricData)
Definition: vtkparser.cpp:269
int MMG5_saveVtkMesh(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename, int metricData, int binary)
Definition: vtkparser.hpp:516