17 FILE *fp =
Fopen(fileName.c_str(),
"w");
19 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
31 fprintf(fp,
"solid Created by Gmsh\n");
37 if(N != 3 && N != 4)
continue;
38 double x[4], y[4],
z[4], n[3];
39 for(
int i = 0; i < N; i++)
getNode(step, ent, ele, i, x[i], y[i],
z[i]);
42 fprintf(fp,
"facet normal %g %g %g\n", n[0], n[1], n[2]);
43 fprintf(fp,
" outer loop\n");
44 fprintf(fp,
" vertex %g %g %g\n", x[0], y[0],
z[0]);
45 fprintf(fp,
" vertex %g %g %g\n", x[1], y[1],
z[1]);
46 fprintf(fp,
" vertex %g %g %g\n", x[2], y[2],
z[2]);
47 fprintf(fp,
" endloop\n");
48 fprintf(fp,
"endfacet\n");
51 fprintf(fp,
"facet normal %g %g %g\n", n[0], n[1], n[2]);
52 fprintf(fp,
" outer loop\n");
53 fprintf(fp,
" vertex %g %g %g\n", x[0], y[0],
z[0]);
54 fprintf(fp,
" vertex %g %g %g\n", x[1], y[1],
z[1]);
55 fprintf(fp,
" vertex %g %g %g\n", x[2], y[2],
z[2]);
56 fprintf(fp,
" endloop\n");
57 fprintf(fp,
"endfacet\n");
58 fprintf(fp,
"facet normal %g %g %g\n", n[0], n[1], n[2]);
59 fprintf(fp,
" outer loop\n");
60 fprintf(fp,
" vertex %g %g %g\n", x[0], y[0],
z[0]);
61 fprintf(fp,
" vertex %g %g %g\n", x[2], y[2],
z[2]);
62 fprintf(fp,
" vertex %g %g %g\n", x[3], y[3],
z[3]);
63 fprintf(fp,
" endloop\n");
64 fprintf(fp,
"endfacet\n");
68 fprintf(fp,
"endsolid Created by Gmsh\n");
76 FILE *fp =
Fopen(fileName.c_str(),
"w");
78 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
86 for(
int nod = 0; nod <
getNumNodes(step, ent, ele); nod++) {
88 getNode(step, ent, ele, nod, x, y,
z);
89 fprintf(fp,
"%d %.16g %d %d %.16g %.16g %.16g ", step,
getTime(step),
93 getValue(step, ent, ele, nod, comp, val);
94 fprintf(fp,
"%.16g ", val);
111 "Writing adapted dataset (will only export current time step)");
115 Msg::Error(
"Cannot export multi-mesh datasets in .pos format");
120 "Discarding interpolation matrices when saving in .pos format");
121 if(binary || !parsed)
122 Msg::Warning(
"Only parsed .pos files can be exported for this view type");
124 FILE *fp =
Fopen(fileName.c_str(), append ?
"a" :
"w");
126 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
130 fprintf(fp,
"View \"%s\" {\n",
getName().c_str());
133 for(
int ent = 0; ent <
getNumEntities(firstNonEmptyStep); ent++) {
134 for(
int ele = 0; ele <
getNumElements(firstNonEmptyStep, ent); ele++) {
135 if(
skipElement(firstNonEmptyStep, ent, ele))
continue;
136 int type =
getType(firstNonEmptyStep, ent, ele);
138 const char *s =
nullptr;
141 s = (numComp == 9) ?
"TP" : (numComp == 3) ?
"VP" :
"SP";
144 s = (numComp == 9) ?
"TL" : (numComp == 3) ?
"VL" :
"SL";
147 s = (numComp == 9) ?
"TT" : (numComp == 3) ?
"VT" :
"ST";
150 s = (numComp == 9) ?
"TQ" : (numComp == 3) ?
"VQ" :
"SQ";
153 s = (numComp == 9) ?
"TS" : (numComp == 3) ?
"VS" :
"SS";
156 s = (numComp == 9) ?
"TH" : (numComp == 3) ?
"VH" :
"SH";
159 s = (numComp == 9) ?
"TI" : (numComp == 3) ?
"VI" :
"SI";
162 s = (numComp == 9) ?
"TY" : (numComp == 3) ?
"VY" :
"SY";
166 fprintf(fp,
"%s(", s);
167 int numNod =
getNumNodes(firstNonEmptyStep, ent, ele);
168 for(
int nod = 0; nod < numNod; nod++) {
170 getNode(firstNonEmptyStep, ent, ele, nod, x, y,
z);
171 fprintf(fp,
"%.16g,%.16g,%.16g", x, y,
z);
172 if(nod != numNod - 1) fprintf(fp,
",");
177 for(
int nod = 0; nod < numNod; nod++) {
178 for(
int comp = 0; comp < numComp; comp++) {
180 getValue(step, ent, ele, nod, comp, val);
182 fprintf(fp,
"){%.16g", val);
186 fprintf(fp,
",%.16g", val);
203 bool binary,
bool saveMesh,
bool multipleView,
204 int partitionNum,
bool saveInterpolationMatrices,
205 bool forceNodeData,
bool forceElementData)
207 Msg::Error(
"MSH export not implemented for this view type");
213 Msg::Error(
"MED export only available for mesh-based post-processing views");
225 for(
int nod = 0; nod <
getNumNodes(step, ent, ele); nod++) {
228 getValue(step, ent, ele, nod, comp, val);
229 vec[step].push_back(val);
241 Msg::Warning(
"Cannot import vector in an empty view; skipping");
247 "Incompatible number of steps in vector for view import (%d!=%d)",
257 for(
int nod = 0; nod <
getNumNodes(step, ent, ele); nod++) {
259 getNode(step, ent, ele, nod, x, y,
z);
261 if(i < (
int)vec[step].size()) {
262 setValue(step, ent, ele, nod, comp, vec[step][i++]);
265 Msg::Error(
"Bad index (%d) in vector (%d) for view import", i,
266 (
int)vec[step].size());
279 Msg::Error(
"importLists not available for this view data type");
284 Msg::Error(
"getListPointers not available for this view data type");
290 std::vector<std::vector<double> > vec;
294 if(!ok)
Msg::Error(
"sendToServer: cannot vectorize PView");
298 Msg::Error(
"sendToServer: cannot send a PView with more than one step");
301 if(vec[0].size() != 1)
302 Msg::Error(
"sendToServer: cannot send a PView with more than one data");