G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsWriteParaview.hpp
Go to the documentation of this file.
1
15#pragma once
16
18#include <gsIO/gsIOUtils.h>
19
20#include <gsCore/gsGeometry.h>
22#include <gsCore/gsField.h>
23#include <gsCore/gsDebug.h>
24
25#include <gsCore/gsMultiPatch.h>
26
28#include <gsModeling/gsSolid.h>
29
31
32#define PLOT_PRECISION 12
33
34namespace gismo
35{
36
37// Export a 3D parametric mesh
38template<class T>
39void writeSingleBasisMesh3D(const gsMesh<T> & sl,
40 std::string const & fn)
41{
42 const unsigned numVer = sl.numVertices();
43 const unsigned numEl = numVer / 8;
44 std::string mfn(fn);
45 mfn.append(".vtu");
46 std::ofstream file(mfn.c_str());
47 if ( ! file.is_open() )
48 gsWarn<<"writeSingleBasisMesh3D: Problem opening file \""<<fn<<"\""<<std::endl;
49 file << std::fixed; // no exponents
50 file << std::setprecision (PLOT_PRECISION);
51
52 file <<"<?xml version=\"1.0\"?>\n";
53 file <<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
54 file <<"<UnstructuredGrid>\n";
55
56 // Number of vertices and number of cells
57 file <<"<Piece NumberOfPoints=\""<< numVer <<"\" NumberOfCells=\""<<numEl<<"\">\n";
58
59 // Coordinates of vertices
60 file <<"<Points>\n";
61 file <<"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
62 for (typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
63 {
64 const gsVertex<T>& vertex = **it;
65 file << vertex[0] << " " << vertex[1] << " " << vertex[2] << " \n";
66 }
67 file << "\n";
68 file <<"</DataArray>\n";
69 file <<"</Points>\n";
70
71 // Point data
72 file <<"<PointData Scalars=\"CellVolume\">\n";
73 file <<"<DataArray type=\"Float32\" Name=\"CellVolume\" format=\"ascii\" NumberOfComponents=\"1\">\n";
74 for (typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
75 {
76 file << (*it)->data <<" ";
77 }
78 file << "\n";
79 file <<"</DataArray>\n";
80 file <<"</PointData>\n";
81
82 // Cells
83 file <<"<Cells>\n";
84
85 // Connectivity
86 file <<"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
87 for (unsigned i = 0; i!= numVer;++i)
88 {
89 file << i << " ";
90 }
91 file << "\n";
92 file <<"</DataArray>\n";
93
94 // Offsets
95 file << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
96 for (unsigned i = 1; i<= numEl;++i)
97 {
98 file << 8*i << " ";
99 }
100 file << "\n";
101 file << "</DataArray>\n";
102
103 // Type
104 file << "<DataArray type=\"Int32\" Name=\"types\" format=\"ascii\">\n";
105 for (unsigned i = 1; i<= numEl;++i)
106 {
107 file << "11 ";
108 }
109 file << "\n";
110 file << "</DataArray>\n";
111
112 file <<"</Cells>\n";
113 file << "</Piece>\n";
114 file <<"</UnstructuredGrid>\n";
115 file <<"</VTKFile>\n";
116 file.close();
117
118 //if( pvd ) // make a pvd file
119 // makeCollection(fn, ".vtp");
120}
121
122// Export a 2D parametric mesh -- note: duplicates code from writeSingleBasisMesh3D,
123//
124template<class T>
125void writeSingleBasisMesh2D(const gsMesh<T> & sl,
126 std::string const & fn)
127{
128 const unsigned numVer = sl.numVertices();
129 const unsigned numEl = numVer / 4; //(1<<dim)
130 std::string mfn(fn);
131 mfn.append(".vtu");
132 std::ofstream file(mfn.c_str());
133 if ( ! file.is_open() )
134 gsWarn<<"writeSingleBasisMesh2D: Problem opening file \""<<fn<<"\""<<std::endl;
135 file << std::fixed; // no exponents
136 file << std::setprecision (PLOT_PRECISION);
137
138 file <<"<?xml version=\"1.0\"?>\n";
139 file <<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
140 file <<"<UnstructuredGrid>\n";
141
142 // Number of vertices and number of cells
143 file <<"<Piece NumberOfPoints=\""<< numVer <<"\" NumberOfCells=\""<<numEl<<"\">\n";
144
145 // Coordinates of vertices
146 file <<"<Points>\n";
147 file <<"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
148 for (typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); it+=4)
149 {
150 // order is important!
151 const gsVertex<T>& vertex0 = **it;
152 const gsVertex<T>& vertex1 = **(it+1);
153 const gsVertex<T>& vertex3 = **(it+3);
154 const gsVertex<T>& vertex2 = **(it+2);
155 file << vertex0[0] << " " << vertex0[1] << " " << vertex0[2] << " \n";
156 file << vertex1[0] << " " << vertex1[1] << " " << vertex1[2] << " \n";
157 file << vertex3[0] << " " << vertex3[1] << " " << vertex3[2] << " \n";
158 file << vertex2[0] << " " << vertex2[1] << " " << vertex2[2] << " \n";
159 }
160 file << "\n";
161 file <<"</DataArray>\n";
162 file <<"</Points>\n";
163
164 // Point data
165 file <<"<PointData Scalars=\"CellArea\">\n";
166 file <<"<DataArray type=\"Float32\" Name=\"CellVolume\" format=\"ascii\" NumberOfComponents=\"1\">\n";
167 for (typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
168 {
169 file << (*it)->data <<" ";
170 }
171 file << "\n";
172 file <<"</DataArray>\n";
173 file <<"</PointData>\n";
174
175 // Cells
176 file <<"<Cells>\n";
177
178 // Connectivity
179 file <<"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
180 for (unsigned i = 0; i!= numVer;++i)
181 {
182 file << i << " ";
183 }
184 file << "\n";
185 file <<"</DataArray>\n";
186
187 // Offsets
188 file << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
189 for (unsigned i = 1; i<= numEl;++i)
190 {
191 file << 4*i << " "; //step: (1<<dim)
192 }
193 file << "\n";
194 file << "</DataArray>\n";
195
196 // Type
197 file << "<DataArray type=\"Int32\" Name=\"types\" format=\"ascii\">\n";
198 for (unsigned i = 1; i<= numEl;++i)
199 {
200 file << "9 ";// 11: 3D, 9: 2D
201 }
202 file << "\n";
203 file << "</DataArray>\n";
204
205 file <<"</Cells>\n";
206 file << "</Piece>\n";
207 file <<"</UnstructuredGrid>\n";
208 file <<"</VTKFile>\n";
209 file.close();
210
211 //if( pvd ) // make a pvd file
212 // makeCollection(fn, ".vtp");
213}
214
215
217template<class T>
219 std::string const & fn)
220{
221 gsMesh<T> msh(basis, 0);
222 if ( basis.dim() == 3)
223 writeSingleBasisMesh3D(msh,fn);
224 else if ( basis.dim() == 2)
225 writeSingleBasisMesh2D(msh,fn);
226 else
227 gsWriteParaview(msh, fn, false);
228}
229
231template<class T>
232void writeSingleCompMesh(const gsBasis<T> & basis, const gsGeometry<T> & Geo,
233 std::string const & fn, unsigned resolution)
234{
235 gsMesh<T> msh(basis, resolution);
236 Geo.evaluateMesh(msh);
237
238 // if ( basis.dim() == 3)
239 // writeSingleBasisMesh3D(msh,fn);
240 // else if ( basis.dim() == 2)
241 // writeSingleBasisMesh2D(msh,fn);
242 // else
243 gsWriteParaview(msh, fn, false);
244}
245
247template<class T>
249 std::string const & fn)
250{
251 const int d = Geo.parDim();
252 gsMesh<T> msh;
253 Geo.controlNet(msh);
254 const unsigned n = Geo.geoDim();
255 if ( n == 1 )
256 {
257 gsMatrix<T> anch = Geo.basis().anchors();
258 // Lift vertices at anchor positions
259 for (size_t i = 0; i!= msh.numVertices(); ++i)
260 {
261 msh.vertex(i)[d] = msh.vertex(i)[0];
262 msh.vertex(i).topRows(d) = anch.col(i);
263 }
264 }
265 else if (n>3)
266 {
267 gsDebug<<"Writing 4th coordinate\n";
268 const gsMatrix<T> & cp = Geo.coefs();
269 gsWriteParaviewPoints<T>(cp.transpose(), fn );
270 return;
271 }
272
273 gsWriteParaview(msh, fn, false);
274}
275
276template<class T>
277void gsWriteParaviewTPgrid(const gsMatrix<T> & eval_geo ,
278 const gsMatrix<T> & eval_field,
279 const gsVector<index_t> & np,
280 std::string const & fn)
281{
282 const int n = eval_geo.rows();
283 GISMO_ASSERT(eval_geo.cols()==eval_field.cols()
284 && static_cast<index_t>(np.prod())==eval_geo.cols(),
285 "Data do not match");
286
287 std::string mfn(fn);
288 mfn.append(".vts");
289 std::ofstream file(mfn.c_str());
290 file << std::fixed; // no exponents
291 file << std::setprecision (PLOT_PRECISION);
292
293 index_t np1 = (np.size()>1 ? np(1)-1 : 0);
294 index_t np2 = (np.size()>2 ? np(2)-1 : 0);
295
296 file <<"<?xml version=\"1.0\"?>\n";
297 file <<"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
298 file <<"<StructuredGrid WholeExtent=\"0 "<< np(0)-1<<" 0 "<< np1 <<" 0 "
299 << np2 <<"\">\n";
300 file <<"<Piece Extent=\"0 "<< np(0)-1<<" 0 "<<np1<<" 0 "
301 << np2 <<"\">\n";
302 file <<"<PointData "<< ( eval_field.rows()==1 ?"Scalars":(eval_field.rows()>3?"Tensors":"Vectors"))<<"=\"SolutionField\">\n";
303 file <<"<DataArray type=\"Float32\" Name=\"SolutionField\" format=\"ascii\" NumberOfComponents=\""<< eval_field.rows() <<"\">\n";
304 if ( eval_field.rows()==1 )
305 for ( index_t j=0; j<eval_field.cols(); ++j)
306 file<< eval_field.at(j) <<" ";
307 else
308 {
309 for ( index_t j=0; j<eval_field.cols(); ++j)
310 {
311 for ( index_t i=0; i!=eval_field.rows(); ++i)
312 file<< eval_field(i,j) <<" ";
313 for ( index_t i=eval_field.rows(); i<3; ++i)
314 file<<"0 ";
315 }
316 }
317 file <<"</DataArray>\n";
318 file <<"</PointData>\n";
319 file <<"<Points>\n";
320 file <<"<DataArray type=\"Float32\" NumberOfComponents=\"3\">\n";
321 for ( index_t j=0; j<eval_geo.cols(); ++j)
322 {
323 for ( index_t i=0; i!=n; ++i)
324 file<< eval_geo(i,j) <<" ";
325 for ( index_t i=n; i<3; ++i)
326 file<<"0 ";
327 }
328 file <<"</DataArray>\n";
329 file <<"</Points>\n";
330 file <<"</Piece>\n";
331 file <<"</StructuredGrid>\n";
332 file <<"</VTKFile>\n";
333
334 file.close();
335}
336
337template<class T>
338void writeSinglePatchField(const gsFunction<T> & geometry,
339 const gsFunction<T> & parField,
340 const bool isParam,
341 std::string const & fn, unsigned npts)
342{
343 const int n = geometry.targetDim();
344 const int d = geometry.domainDim();
345
346 gsMatrix<T> ab = geometry.support();
347 gsVector<T> a = ab.col(0);
348 gsVector<T> b = ab.col(1);
349
350 gsVector<unsigned> np = uniformSampleCount(a, b, npts);
351 gsMatrix<T> pts = gsPointGrid(a, b, np);
352
353 gsMatrix<T> eval_geo = geometry.eval(pts);//pts
354 gsMatrix<T> eval_field = isParam ? parField.eval(pts) : parField.eval(eval_geo);
355
356 if ( 3 - d > 0 )
357 {
358 np.conservativeResize(3);
359 np.bottomRows(3-d).setOnes();
360 }
361 else if (d > 3)
362 {
363 gsWarn<< "Cannot plot 4D data.\n";
364 return;
365 }
366
367 if ( 3 - n > 0 )
368 {
369 eval_geo.conservativeResize(3,eval_geo.cols() );
370 eval_geo.bottomRows(3-n).setZero();
371 }
372 else if (n > 3)
373 {
374 gsWarn<< "Data is more than 3 dimensions.\n";
375 }
376
377 if ( eval_field.rows() == 2)
378 {
379 eval_field.conservativeResize(3,eval_geo.cols() );
380 eval_field.bottomRows(1).setZero(); // 3-field.dim()
381 }
382
383 gsWriteParaviewTPgrid(eval_geo, eval_field, np.template cast<index_t>(), fn);
384}
385
387template<class T>
388void writeSinglePatchField(const gsField<T> & field, int patchNr,
389 std::string const & fn, unsigned npts)
390{
391 writeSinglePatchField(field.patch(patchNr), field.function(patchNr), field.isParametric(), fn, npts);
392/*
393 const int n = field.geoDim();
394 const int d = field.parDim();
395
396 gsMatrix<T> ab = field.patches().parameterRange(patchNr);
397 gsVector<T> a = ab.col(0);
398 gsVector<T> b = ab.col(1);
399
400 gsVector<unsigned> np = uniformSampleCount(a, b, npts);
401 gsMatrix<T> pts = gsPointGrid(a, b, np);
402
403 gsMatrix<T> eval_geo = field.point ( pts, patchNr );//pts
404
405 if ( 3 - d > 0 )
406 {
407 np.conservativeResize(3);
408 np.bottomRows(3-d).setOnes();
409 }
410 else if (d > 3)
411 {
412 gsWarn<< "Cannot plot 4D data.\n";
413 return;
414 }
415
416 if ( 3 - n > 0 )
417 {
418 eval_geo.conservativeResize(3,eval_geo.cols() );
419 eval_geo.bottomRows(3-n).setZero();
420 }
421 else if (d > 3)
422 {
423 gsWarn<< "Cannot plot 4D data.\n";
424 return;
425 }
426
427 gsMatrix<T> eval_field = field.value ( pts, patchNr );//values
428 GISMO_ASSERT( eval_field.rows() == field.dim(), "Error in field dimension");
429 if ( eval_field.rows() > 1 )
430 {
431 eval_field.conservativeResize(3,eval_geo.cols() );
432 eval_field.bottomRows( 3-field.dim() ).setZero();
433 }
434
435 std::string mfn(fn);
436 mfn.append(".vts");
437 std::ofstream file(mfn.c_str());
438 file << std::fixed; // no exponents
439 file << std::setprecision (PLOT_PRECISION);
440
441 file <<"<?xml version=\"1.0\"?>\n";
442 file <<"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
443 file <<"<StructuredGrid WholeExtent=\"0 "<< np(0)-1<<" 0 "<<np(1)-1<<" 0 "<<np(2)-1<<"\">\n";
444 file <<"<Piece Extent=\"0 "<< np(0)-1<<" 0 "<<np(1)-1<<" 0 "<<np(2)-1<<"\">\n";
445 file <<"<PointData "<< ( field.dim()==1 ?"Scalars":"Vectors")<<"=\"SolutionField\">\n";
446 file <<"<DataArray type=\"Float32\" Name=\"SolutionField\" format=\"ascii\" NumberOfComponents=\""<< eval_field.rows() <<"\">\n";
447 for ( index_t j=0; j<eval_field.cols(); ++j)
448 for ( index_t i=0; i<eval_field.rows(); ++i)
449 file<< eval_field(i,j) <<" ";
450 file <<"</DataArray>\n";
451 file <<"</PointData>\n";
452 file <<"<Points>\n";
453 file <<"<DataArray type=\"Float32\" NumberOfComponents=\""<<eval_geo.rows()<<"\">\n";
454 for ( index_t j=0; j<eval_geo.cols(); ++j)
455 for ( index_t i=0; i<eval_geo.rows(); ++i)
456 file<< eval_geo(i,j) <<" ";
457 file <<"</DataArray>\n";
458 file <<"</Points>\n";
459 file <<"</Piece>\n";
460 file <<"</StructuredGrid>\n";
461 file <<"</VTKFile>\n";
462
463 file.close();
464*/
465}
466
468template<class T>
470 gsMatrix<T> const& supp,
471 std::string const & fn, unsigned npts)
472{
473 int n = func.targetDim();
474 const int d = func.domainDim();
475
476 gsVector<T> a = supp.col(0);
477 gsVector<T> b = supp.col(1);
478 gsVector<unsigned> np = uniformSampleCount(a,b, npts );
479 gsMatrix<T> pts = gsPointGrid(a,b,np) ;
480
481 gsMatrix<T> eval_func = func.eval ( pts ) ;//pts
482
483 if ( 3 - d > 0 )
484 {
485 np.conservativeResize(3);
486 np.bottomRows(3-d).setOnes();
487 }
488
489 if ( 3 - n > 0 )
490 {
491 eval_func.conservativeResize(3,eval_func.cols() );
492 eval_func.bottomRows(3-n).setZero();
493
494 if ( n == 1 )
495 {
496 if (d==3)
497 {
498 n = 4;
499 eval_func.conservativeResize(4,eval_func.cols() );
500 }
501
502 //std::swap( eval_geo.row(d), eval_geo.row(0) );
503 eval_func.row(d) = eval_func.row(0);
504 eval_func.topRows(d) = pts;
505 }
506 }
507
508 std::string mfn(fn);
509 mfn.append(".vts");
510 std::ofstream file(mfn.c_str());
511 if ( ! file.is_open() )
512 gsWarn<<"writeSingleGeometry: Problem opening file \""<<fn<<"\""<<std::endl;
513 file << std::fixed; // no exponents
514 file << std::setprecision (PLOT_PRECISION);
515 file <<"<?xml version=\"1.0\"?>\n";
516 file <<"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
517 file <<"<StructuredGrid WholeExtent=\"0 "<<np(0)-1<<" 0 "<<np(1)-1<<" 0 "<<np(2)-1<<"\">\n";
518 file <<"<Piece Extent=\"0 "<< np(0)-1<<" 0 "<<np(1)-1<<" 0 "<<np(2)-1<<"\">\n";
519 // Add norm of the point as data
520 // file <<"<PointData Scalars =\"PointNorm\">\n";
521 // file <<"<DataArray type=\"Float32\" Name=\"PointNorm\" format=\"ascii\" NumberOfComponents=\""<< 1 <<"\">\n";
522 // for ( index_t j=0; j<eval_geo.cols(); ++j)
523 // file<< eval_geo.col(j).norm() <<" ";
524 // file <<"</DataArray>\n";
525 // file <<"</PointData>\n";
526 // end norm
527
528 //---------
529 if (n > 3)
530 {
531 //gsWarn<< "4th dimension as scalar data.\n";
532 file <<"<PointData "<< "Scalars=\"Coordinate4\">\n";
533 file <<"<DataArray type=\"Float32\" Name=\"Coordinate4\" format=\"ascii\" NumberOfComponents=\"1\">\n";
534 for ( index_t j=0; j!=eval_func.cols(); ++j)
535 file<< eval_func(3,j) <<" ";
536 file <<"</DataArray>\n";
537 file <<"</PointData>\n";
538 }
539 //---------
540
541 file <<"<Points>\n";
542 file <<"<DataArray type=\"Float32\" NumberOfComponents=\"3\">\n";
543 for ( index_t j=0; j<eval_func.cols(); ++j)
544 for ( index_t i=0; i!=3; ++i)
545 file<< eval_func(i,j) <<" ";
546 file <<"</DataArray>\n";
547 file <<"</Points>\n";
548 file <<"</Piece>\n";
549 file <<"</StructuredGrid>\n";
550 file <<"</VTKFile>\n";
551 file.close();
552}
553
555template<class T>
557 gsMatrix<T> const& supp,
558 std::string const & fn, unsigned npts)
559{
560 const unsigned n = func.targetDim();
561 const unsigned d = func.domainDim();
562 GISMO_ASSERT( d == 1, "Not a curve");
563
564 gsVector<T> a = supp.col(0);
565 gsVector<T> b = supp.col(1);
566 gsVector<unsigned> np = uniformSampleCount(a,b, npts );
567 gsMatrix<T> pts = gsPointGrid(a,b,np) ;
568
569 gsMatrix<T> eval_func = func.eval ( pts ) ;//pts
570
571 np.conservativeResize(3);
572 np.bottomRows(2).setOnes();
573
574 if ( 3 - n > 0 )
575 {
576 eval_func.conservativeResize(3,eval_func.cols() );
577 eval_func.bottomRows(3-n).setZero();
578
579 if ( n == 1 )
580 {
581 //std::swap( eval_geo.row(d), eval_geo.row(0) );
582 eval_func.row(d) = eval_func.row(0);
583 eval_func.topRows(d) = pts;
584 }
585 }
586
587 std::string mfn(fn);
588 mfn.append(".vtp");
589 std::ofstream file(mfn.c_str());
590 if ( ! file.is_open() )
591 gsWarn<<"writeSingleCurve: Problem opening file \""<<fn<<"\""<<std::endl;
592 file << std::fixed; // no exponents
593 file << std::setprecision (PLOT_PRECISION);
594 file <<"<?xml version=\"1.0\"?>\n";
595 file <<"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
596 file <<"<PolyData>\n";
597 // Accounting
598 file <<"<Piece NumberOfPoints=\""<< npts
599 <<"\" NumberOfVerts=\"0\" NumberOfLines=\""<< npts-1
600 <<"\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\n";
601 file <<"<Points>\n";
602 file <<"<DataArray type=\"Float32\" NumberOfComponents=\""<<eval_func.rows()<<"\">\n";
603 for ( index_t j=0; j<eval_func.cols(); ++j)
604 for ( index_t i=0; i<eval_func.rows(); ++i)
605 file<< eval_func(i,j) <<" ";
606 file <<"\n</DataArray>\n";
607 file <<"</Points>\n";
608 // Lines
609 file <<"<Lines>\n";
610 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<npts-1<<"\">\n";
611 for (unsigned i=0; i< npts-1; ++i )
612 {
613 file << i << " " << i+1 << " ";
614 }
615 // offsets
616 file <<"\n</DataArray>\n";
617 unsigned offset(0);
618 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<npts-1<<"\">\n";
619 for (unsigned i=0; i< npts-1; ++i )
620 {
621 offset +=2;
622 file << offset << " ";
623 }
624 file <<"\n</DataArray>\n";
625 file <<"</Lines>\n";
626 // Closing
627 file <<"</Piece>\n";
628 file <<"</PolyData>\n";
629 file <<"</VTKFile>\n";
630 file.close();
631}
632
633template<class T>
634void writeSingleCurve(const gsGeometry<T> & Geo, std::string const & fn, unsigned npts)
635{
636 gsMatrix<T> ab = Geo.parameterRange();
637 writeSingleCurve( Geo, ab, fn, npts);
638}
639
640template<class T>
641void writeSingleGeometry(const gsGeometry<T> & Geo, std::string const & fn, unsigned npts)
642{
643 /*
644 gsMesh<T> msh;
645 Geo.toMesh(msh, npts);
646 gsWriteParaview(msh, fn, false);
647 return;
648 */
649 gsMatrix<T> ab = Geo.parameterRange();
650 writeSingleGeometry( Geo, ab, fn, npts);
651}
652
653template<class T>
654void writeSingleTrimSurface(const gsTrimSurface<T> & surf,
655 std::string const & fn,
656 unsigned npts)
657{
658 typename gsMesh<T>::uPtr msh = surf.toMesh(npts);
659 gsWriteParaview( *msh, fn);
660}
661
663template<class T>
664void gsWriteParaview(const gsField<T> & field,
665 std::string const & fn,
666 unsigned npts, bool mesh,
667 const std::string pDelim)
668{
669 /*
670 if (mesh && (!field.isParametrized()) )
671 {
672 gsWarn<< "Cannot plot mesh from non-parametric field.";
673 mesh = false;
674 }
675 */
676
677 const unsigned n = field.nPieces();
678 gsParaviewCollection collection(fn);
679 std::string fileName, fileName_nopath;
680
681 for ( unsigned i=0; i < n; ++i )
682 {
683 const gsBasis<T> & dom = field.isParametrized() ?
684 field.igaFunction(i).basis() : field.patch(i).basis();
685
686 fileName = fn + pDelim + util::to_string(i);
687 fileName_nopath = gsFileManager::getFilename(fileName);
688 writeSinglePatchField( field, i, fileName, npts );
689 collection.addPart(fileName_nopath + ".vts");
690 if ( mesh )
691 {
692 fileName+= "_mesh";
693 fileName_nopath = gsFileManager::getFilename(fileName);
694 writeSingleCompMesh(dom, field.patch(i), fileName);
695
696 collection.addPart(fileName_nopath + ".vtp");
697 }
698
699 }
700 collection.save();
701}
702
704template<class T>
705void gsWriteParaview(gsFunctionSet<T> const& geo,
706 gsFunctionSet<T> const& func,
707 std::string const & fn,
708 unsigned npts, const std::string pDelim)
709{
710 /*
711 if (mesh && (!field.isParametrized()) )
712 {
713 gsWarn<< "Cannot plot mesh from non-parametric field.";
714 mesh = false;
715 }
716 */
717
718 GISMO_ASSERT(geo.nPieces()==func.nPieces(),"Function sets must have same number of pieces, but func has "<<func.nPieces()<<" and geo has "<<geo.nPieces());
719
720 const unsigned n = geo.nPieces();
721 gsParaviewCollection collection(fn);
722 std::string fileName, fileName_nopath;
723
724 for ( unsigned i=0; i < n; ++i )
725 {
726 fileName = fn + pDelim + util::to_string(i);
727 fileName_nopath = gsFileManager::getFilename(fileName);
728 writeSinglePatchField( geo.function(i), func.function(i), true, fileName, npts );
729 collection.addPart(fileName_nopath + ".vts");
730 }
731 collection.save();
732}
733
735template<class T>
736void gsWriteParaview(gsMappedSpline<2,T> const& mspline,
737 std::string const & fn,
738 unsigned npts)
739{
740 gsParaviewCollection collection(fn);
741 std::string fileName, fileName_nopath;
742 for ( index_t p=0; p < mspline.nPieces(); ++p )
743 {
744 // Compute the geometry
745 fileName = fn + "_" + util::to_string(p);
746 fileName_nopath = gsFileManager::getFilename(fileName);
747 writeSingleGeometry(mspline.piece(p),mspline.piece(p).support(),fileName,npts);
748 collection.addPart(fileName_nopath + ".vts",-1,"",p);
749 }
750 collection.save();
751}
752
754template<class T>
755void gsWriteParaview(gsFunctionSet<T> const& geom,
756 gsMappedBasis<2,T> const& mbasis,
757 std::string const & fn,
758 unsigned npts,
759 const bool fullsupport,
760 const std::vector<index_t> indices)
761{
762 /*
763 We loop over all global basis functions.
764 For each global basis function, we find the patches on which it is active
765 On the patches, we call evalSingle_into and construct a local Paraview file
766 Then, the paraview file is combined as part in a collection.
767 */
768 GISMO_ASSERT(geom.nPieces()==mbasis.nPieces(),"Function sets must have same number of pieces, but the basis has "<<mbasis.nPieces()<<" and the geometry has "<<geom.nPieces());
769
770 std::vector<index_t> plotIndices;
771 if (indices.size()==0)
772 {
773 plotIndices.resize(mbasis.globalSize());
774 std::generate(plotIndices.begin(), plotIndices.end(), [n = 0] () mutable { return n++; });
775 }
776 else
777 plotIndices = indices;
778
779 gsParaviewCollection collection(fn);
780 std::string fileName, fileName_nopath;
781 gsMatrix<T> eval_geo, eval_basis, pts, ab;
782 gsVector<T> a, b;
784 for ( index_t p=0; p < geom.nPieces(); ++p )
785 {
786 if (fullsupport)
787 {
788 // Compute the geometry
789 ab = geom.piece(p).support();
790 a = ab.col(0);
791 b = ab.col(1);
792
793 if (a.prod() == 0 && b.prod()==0)
794 continue;
795
796 np = uniformSampleCount(a, b, npts);
797 pts = gsPointGrid(a, b, np);
798
799 eval_geo = geom.piece(p).eval(pts);//pts
800 }
801
802 for (std::vector<index_t>::const_iterator i = plotIndices.begin(); i!=plotIndices.end(); i++)//, k++)
803 {
804 if (!fullsupport)
805 {
806 // Compute the geometry on the support of the basis function
807 ab = mbasis.piece(p).support(*i);
808 // ab = mbasis.piece(p).support();
809 a = ab.col(0);
810 b = ab.col(1);
811 if (a.prod() == 0 && b.prod()==0)
812 continue;
813
814 np = uniformSampleCount(a, b, npts);
815 pts = gsPointGrid(a, b, np);
816
817 eval_geo = geom.piece(p).eval(pts);//pts
818 }
819
820 fileName = fn + util::to_string(*i) + "_" + util::to_string(p);
821 fileName_nopath = gsFileManager::getFilename(fileName);
822
823 eval_basis = mbasis.piece(p).evalSingle(*i,pts);
824 gsWriteParaviewTPgrid(eval_geo, eval_basis, np.template cast<index_t>(), fileName);
825
826 collection.addPart(fileName_nopath + ".vts",*i,"",p);
827 }
828 // for (index_t k = 0; k < mbasis.globalSize(); k++)
829 // {
830 // fileName = fn + util::to_string(k) + "_" + util::to_string(p);
831 // fileName_nopath = gsFileManager::getFilename(fileName);
832
833 // eval_basis = mbasis.piece(p).evalSingle(k,pts);
834 // gsWriteParaviewTPgrid(eval_geo, eval_basis, np.template cast<index_t>(), fileName);
835
836 // collection.addPart(fileName_nopath + ".vts",k,"",p);
837 // }
838 }
839 collection.save();
840}
841
843template<class T>
844void gsWriteParaview(const gsGeometry<T> & Geo, std::string const & fn,
845 unsigned npts, bool mesh, bool ctrlNet)
846{
847 const bool curve = ( Geo.domainDim() == 1 );
848
849 gsParaviewCollection collection(fn);
850 std::string fn_nopath = gsFileManager::getFilename(fn);
851 if ( curve )
852 {
853 writeSingleCurve(Geo, fn, npts);
854 collection.addPart(fn_nopath + ".vtp");
855 }
856 else
857 {
858 writeSingleGeometry(Geo, fn, npts);
859 collection.addPart(fn_nopath + ".vts");
860 }
861
862 if ( mesh ) // Output the underlying mesh
863 {
864 const std::string fileName = fn + "_mesh";
865 std::string fileName_nopath = gsFileManager::getFilename(fileName);
866
867 int ptsPerEdge;
868
869 // If not using default, compute the resolution from npts.
870 if(npts!=8)
871 {
872 const T evalPtsPerElem = npts * (1.0 / Geo.basis().numElements());
873
874 // The following complicated formula should ensure similar
875 // resolution of the mesh edges and the surface. The
876 // additional multiplication by deg - 1 ensures quadratic
877 // elements to be approximated by at least two lines etc.
878 ptsPerEdge = cast<T,int>(
879 static_cast<T>(math::max(Geo.basis().maxDegree()-1, (short_t)1)) * math::pow(evalPtsPerElem, T(1.0)/static_cast<T>(Geo.domainDim())) );
880 }
881 else
882 {
883 ptsPerEdge = npts;
884 }
885
886 writeSingleCompMesh(Geo.basis(), Geo, fileName, ptsPerEdge);
887 collection.addPart(fileName_nopath + ".vtp");
888 }
889
890 if ( ctrlNet ) // Output the control net
891 {
892 const std::string fileName = fn + "_cnet";
893 std::string fileName_nopath = gsFileManager::getFilename(fileName);
894 writeSingleControlNet(Geo, fileName);
895 collection.addPart(fileName_nopath + ".vtp");
896 }
897
898 // Write out the collection file
899 collection.save();
900}
901
902// Export a multibasis mesh
903template<class T>
904void gsWriteParaview(const gsMultiBasis<T> & mb, const gsMultiPatch<T> & domain,
905 std::string const & fn, unsigned npts)
906{
907 // GISMO_ASSERT sizes
908
909 gsParaviewCollection collection(fn);
910
911 for (size_t i = 0; i != domain.nPatches(); ++i)
912 {
913 const std::string fileName = fn + util::to_string(i) + "_mesh";
914 const std::string fileName_nopath = gsFileManager::getFilename(fileName);
915 writeSingleCompMesh(mb[i], domain.patch(i), fileName, npts);
916 collection.addPart(fileName_nopath + ".vtp");
917 }
918
919 // Write out the collection file
920 collection.save();
921}
922
924template<class T>
925void gsWriteParaview(const gsGeometrySlice<T> & Geo,
926 std::string const & fn,
927 unsigned npts)
928{
929 const gsMatrix<T> supp = Geo.parameterRange();
930 writeSingleGeometry(Geo, supp, fn, npts);
931 // Write out a pvd file
932 makeCollection(fn, ".vts"); // make also a pvd file
933}
934
935
937template<class T>
938void gsWriteParaview( std::vector<gsGeometry<T> *> const & Geo,
939 std::string const & fn,
940 unsigned npts, bool mesh, bool ctrlNet, const std::string pDelim)
941{
942 const size_t n = Geo.size();
943
944 gsParaviewCollection collection(fn);
945 std::string fnBase, fnBase_nopath;
946
947 for ( size_t i=0; i<n ; i++)
948 {
949 fnBase = fn + pDelim + util::to_string(i);
950 fnBase_nopath = gsFileManager::getFilename(fnBase);
951
952 if ( Geo.at(i)->domainDim() == 1 )
953 {
954 writeSingleCurve(*Geo[i], fnBase, npts);
955 collection.addPart(fnBase_nopath + ".vtp");
956 }
957 else
958 {
959 writeSingleGeometry( *Geo[i], fnBase, npts ) ;
960 collection.addPart(fnBase_nopath + ".vts");
961 }
962
963 if ( mesh )
964 {
965 const std::string fileName = fnBase + "_mesh";
966 const std::string fileName_nopath = gsFileManager::getFilename(fileName);
967 writeSingleCompMesh(Geo[i]->basis(), *Geo[i], fileName);
968 collection.addPart(fileName_nopath + ".vtp");
969 }
970
971 if ( ctrlNet ) // Output the control net
972 {
973 const std::string fileName = fnBase + "_cnet";
974 const std::string fileName_nopath = gsFileManager::getFilename(fileName);
975 writeSingleControlNet(*Geo[i], fileName);
976 collection.addPart(fileName_nopath + ".vtp");
977 }
978 }
979 collection.save();
980}
981
983template <class T>
984void gsWriteParaviewBezier(const gsMultiPatch<T> & mPatch, std::string const & filename, bool ctrlNet)
985{
986 std::string fnBase;
987
988 // Write file contents to the respective file
989 std::ofstream file(filename + ".vtu");
990 file << BezierVTK(mPatch);
991 file.close();
992
993 if ( ctrlNet ) // Output the control net
994 {
995 gsParaviewCollection collection(filename);
996 collection.addPart(gsFileManager::getFilename(filename) + ".vtu");
997 for (size_t patch=0; patch<mPatch.nPatches();++patch)
998 {
999 const std::string fileName = filename + "_" + util::to_string(patch) + "_cnet";
1000 const std::string fileName_nopath = gsFileManager::getFilename(fileName);
1001
1002 writeSingleControlNet(mPatch.patch(patch), fileName);
1003 collection.addPart(fileName_nopath + ".vtp");
1004 }
1005 collection.save();
1006 }
1007}
1008
1010template<class T>
1011void gsWriteParaview_basisFnct(int i, gsBasis<T> const& basis, std::string const & fn, unsigned npts)
1012{
1013 // basis.support(i) --> returns a (tight) bounding box for the
1014 // supp. of i-th basis func.
1015 int d= basis.dim();
1016 int n= d+1;
1017
1018 gsMatrix<T> ab = basis.support(i) ;
1019 gsVector<T> a = ab.col(0);
1020 gsVector<T> b = ab.col(1);
1021 gsVector<unsigned> np = uniformSampleCount(a,b, npts );
1022 gsMatrix<T> pts = gsPointGrid(a,b,np) ;
1023
1024 gsMatrix<T> eval_geo = basis.evalSingle ( i, pts ) ;
1025 if ( 3 - d > 0 )
1026 {
1027 np.conservativeResize(3);
1028 np.bottomRows(3-d).setOnes();
1029 }
1030
1031 if ( 2 - d > 0 )
1032 {
1033 pts.conservativeResize(2,eval_geo.cols());
1034 pts.bottomRows(2-d).setZero();
1035 }
1036
1037 if ( d > 2 )
1038 {
1039// gsWarn<<"Info: The dimension is to big, projecting into first 2 coordinatess..\n";
1040 d=2;
1041 pts.conservativeResize(2,eval_geo.cols());
1042 }
1043
1044 if ( 3 - n > 0 )
1045 {
1046 eval_geo.conservativeResize(3,eval_geo.cols() );
1047 eval_geo.bottomRows(3-n).setZero();
1048 }
1049
1050 std::string mfn(fn);
1051 mfn.append(".vts");
1052 std::ofstream file(mfn.c_str());
1053 if ( ! file.is_open() )
1054 gsWarn<<"gsWriteParaview_basisFnct: Problem opening file \""<<fn<<"\""<<std::endl;
1055 file << std::fixed; // no exponents
1056 file << std::setprecision (PLOT_PRECISION);
1057 file <<"<?xml version=\"1.0\"?>\n";
1058 file <<"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
1059 file <<"<StructuredGrid WholeExtent=\"0 "<<np(0)-1<<" 0 "<<np(1)-1<<" 0 "<<np(2)-1<<"\">\n";
1060 file <<"<Piece Extent=\"0 "<< np(0)-1<<" 0 "<<np(1)-1<<" 0 "<<np(2)-1<<"\">\n";
1061 // Scalar information
1062 file <<"<PointData "<< "Scalars"<<"=\"SolutionField\">\n";
1063 file <<"<DataArray type=\"Float32\" Name=\"SolutionField\" format=\"ascii\" NumberOfComponents=\""<<1<<"\">\n";
1064 for ( index_t j=0; j<eval_geo.cols(); ++j)
1065 file<< eval_geo(0,j) <<" ";
1066 file <<"</DataArray>\n";
1067 file <<"</PointData>\n";
1068 //
1069 file <<"<Points>\n";
1070 file <<"<DataArray type=\"Float32\" NumberOfComponents=\""<<3<<"\">\n";
1071 for ( index_t j=0; j<eval_geo.cols(); ++j)
1072 {
1073 for ( int l=0; l!=d; ++l)
1074 file<< pts(l,j) <<" ";
1075 file<< eval_geo(0,j) <<" ";
1076 for ( index_t l=d; l!=pts.rows(); ++l)
1077 file<< pts(l,j) <<" ";
1078 }
1079 file <<"</DataArray>\n";
1080 file <<"</Points>\n";
1081 file <<"</Piece>\n";
1082 file <<"</StructuredGrid>\n";
1083 file <<"</VTKFile>\n";
1084 file.close();
1085}
1086
1087// Export a functionSet mesh
1088template<class T>
1089void gsWriteParaview(gsFunctionSet<T> const& func, std::string const & fn, unsigned npts)
1090{
1091 // GISMO_ASSERT sizes
1092
1093 gsParaviewCollection collection(fn);
1094
1095 for (index_t i = 0; i != func.size(); ++i)
1096 {
1097 const std::string fileName = fn + util::to_string(i);
1098 const std::string fileName_nopath = gsFileManager::getFilename(fileName);
1099 gsWriteParaview(func.function(i), func.function(i).support(), fileName, npts,false);
1100 collection.addPart(fileName_nopath + ".vts");
1101 }
1102
1103 // Write out the collection file
1104 collection.save();
1105}
1106
1108template<class T>
1109void gsWriteParaview(gsFunction<T> const& func, gsMatrix<T> const& supp, std::string const & fn, unsigned npts, bool graph)
1110{
1111 int d = func.domainDim(); // tested for d==2
1112
1113 gsVector<T> a = supp.col(0);
1114 gsVector<T> b = supp.col(1);
1115 gsVector<unsigned> np = uniformSampleCount(a,b, npts );
1116 gsMatrix<T> pts = gsPointGrid(a,b,np);
1117
1118 gsMatrix<T> ev;
1119 func.eval_into(pts, ev);
1120
1121 if ( 3 - d > 0 )
1122 {
1123 np.conservativeResize(3);
1124 np.bottomRows(3-d).setOnes();
1125 }
1126
1127 std::string mfn(fn);
1128 mfn.append(".vts");
1129 std::ofstream file(mfn.c_str());
1130 if ( ! file.is_open() )
1131 gsWarn<<"gsWriteParaview: Problem opening file \""<<fn<<"\""<<std::endl;
1132 file << std::fixed; // no exponents
1133 file << std::setprecision (PLOT_PRECISION);
1134 file <<"<?xml version=\"1.0\"?>\n";
1135 file <<"<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
1136 file <<"<StructuredGrid WholeExtent=\"0 "<<np(0)-1<<" 0 "<<np(1)-1<<" 0 "<<np(2)-1<<"\">\n";
1137 file <<"<Piece Extent=\"0 "<< np(0)-1<<" 0 "<<np(1)-1<<" 0 "<<np(2)-1<<"\">\n";
1138 // Scalar information (Not really used)
1139 file <<"<PointData "<< "Scalars"<<"=\"SolutionField\">\n";
1140 file <<"<DataArray type=\"Float32\" Name=\"SolutionField\" format=\"ascii\" NumberOfComponents=\""<< 1 <<"\">\n";
1141 for ( index_t j=0; j<ev.cols(); ++j)
1142 file<< ev(0,j) <<" ";
1143 file <<"</DataArray>\n";
1144 file <<"</PointData>\n";
1145 //
1146 file <<"<Points>\n";
1147 file <<"<DataArray type=\"Float32\" NumberOfComponents=\""<<3<<"\">\n";
1148 if (graph)
1149 {
1150 for ( index_t j=0; j<ev.cols(); ++j)
1151 {
1152 for ( int i=0; i< d; ++i)
1153 file<< pts(i,j) <<" ";
1154 file<< ev(0,j) <<" ";
1155 }
1156 }
1157 else
1158 {
1159 for ( index_t j=0; j<ev.cols(); ++j)
1160 {
1161 for ( index_t i=0; i!=ev.rows(); ++i)
1162 file<< ev(i,j) <<" ";
1163 for ( index_t i=ev.rows(); i<3; ++i)
1164 file<<"0 ";
1165 }
1166 }
1167 file <<"</DataArray>\n";
1168 file <<"</Points>\n";
1169 file <<"</Piece>\n";
1170 file <<"</StructuredGrid>\n";
1171 file <<"</VTKFile>\n";
1172 file.close();
1173}
1174
1175
1177template<class T>
1178void gsWriteParaview(gsBasis<T> const& basis, std::string const & fn,
1179 unsigned npts, bool mesh)
1180{
1181 const index_t n = basis.size();
1182 gsParaviewCollection collection(fn);
1183
1184 for ( index_t i=0; i< n; i++)
1185 {
1186 std::string fileName = fn + util::to_string(i);
1187 std::string fileName_nopath = gsFileManager::getFilename(fileName);
1188 gsWriteParaview_basisFnct<T>(i, basis, fileName, npts ) ;
1189 collection.addPart(fileName_nopath + ".vts");
1190 }
1191
1192 if ( mesh )
1193 {
1194 std::string fileName = fn + "_mesh";
1195 std::string fileName_nopath = gsFileManager::getFilename(fileName);
1196 writeSingleBasisMesh(basis, fileName);
1197 //collection.addPart(fileName, ".vtp");
1198 collection.addPart(fileName_nopath + ".vtu");
1199 }
1200
1201 collection.save();
1202}
1203
1205template<class T>
1206void gsWriteParaview(gsBasis<T> const& basis,
1207 const std::vector<index_t> & indices,
1208 std::string const & fn,
1209 unsigned npts, bool mesh)
1210{
1211 gsParaviewCollection collection(fn);
1212
1213 for (typename std::vector<index_t>::const_iterator idx = indices.cbegin();
1214 idx != indices.cend();
1215 idx++)
1216 {
1217 std::string fileName = fn + util::to_string(*idx);
1218 std::string fileName_nopath = gsFileManager::getFilename(fileName);
1219 gsWriteParaview_basisFnct<T>(*idx, basis, fileName, npts ) ;
1220 collection.addPart(fileName_nopath + ".vts");
1221 }
1222
1223 if ( mesh )
1224 {
1225 std::string fileName = fn + "_mesh";
1226 std::string fileName_nopath = gsFileManager::getFilename(fileName);
1227 writeSingleBasisMesh(basis, fileName);
1228 //collection.addPart(fileName, ".vtp");
1229 collection.addPart(fileName_nopath + ".vtu");
1230 }
1231
1232 collection.save();
1233}
1234
1236template<class T>
1237void writeSingleBox(const gsMatrix<T> & box, std::string const & fn, T value)
1238{
1239 gsMatrix<T> points;
1240 gsVector<unsigned> np(box.rows());
1241 np.setConstant(2);
1242 points = gsPointGrid<T>(box.col(0),box.col(1),np);
1243 // The following is needed since gsPointGrid uses gsVector<unsigned> and gsWriteParaviewTPgrid uses gsVector<index_t>...
1244 gsVector<index_t> np2(box.rows());
1245 np2.setConstant(2);
1246
1247
1248 gsMatrix<T> values(1,np.prod());
1249 values.setConstant(value);
1250 gsWriteParaviewTPgrid(points,values,np2,fn);
1251}
1252
1254template<class T>
1255void gsWriteParaview(const gsMatrix<T> & boxes, std::string const & fn, T value)
1256{
1257 gsParaviewCollection collection(fn);
1258
1259 std::string fileName;
1260 for (index_t k=0; k!=boxes.cols()/2; k++)
1261 {
1262 gsMatrix<> tmpbox = boxes.middleCols(2*k,2);
1263 fileName = fn + "_" + util::to_string(k);
1264 writeSingleBox(tmpbox,fileName,value);
1265 fileName = gsFileManager::getFilename(fileName);
1266 collection.addPart(fileName + ".vts");
1267 }
1268
1269 // Write out the collection file
1270 collection.save();
1271}
1272
1274template<class T>
1275void gsWriteParaview(const gsMatrix<T> & boxes, const gsVector<T> & values, std::string const & fn)
1276{
1277 gsParaviewCollection collection(fn);
1278
1279 std::string fileName;
1280 GISMO_ASSERT(boxes.cols()/2==values.rows(),"Number of boxes and values does not match!");
1281 for (index_t k=0; k!=boxes.cols()/2; k++)
1282 {
1283 gsMatrix<> tmpbox = boxes.middleCols(2*k,2);
1284 fileName = fn + "_" + util::to_string(k);
1285 writeSingleBox(tmpbox,fileName,values[k]);
1286 fileName = gsFileManager::getFilename(fileName);
1287 collection.addPart(fileName + ".vts");
1288 }
1289
1290 // Write out the collection file
1291 collection.save();
1292}
1293
1295template<class T>
1296void writeSingleHBox(const gsHBox<2,T> & box, std::string const & fn)
1297{
1298 gsMatrix<T> points, values(3,4),corners(2,2);
1299 gsVector<index_t> np(2);
1300 np<<2,2;
1301 box.computeCoordinates();
1302 points = gsPointGrid<T>(box.getCoordinates(),4);
1303 values.row(0).setConstant(box.level());
1304 values.row(1).setConstant(box.error());
1305 values.row(2).setConstant(box.projectedErrorRef());
1306 gsWriteParaviewTPgrid(points,values,np,fn);
1307}
1308
1310template<class T>
1311void gsWriteParaview(const gsHBox<2,T> & box, std::string const & fn)
1312{
1313 gsParaviewCollection collection(fn);
1314
1315 writeSingleHBox(box,fn);
1316 collection.addPart(fn + ".vts");
1317
1318 // Write out the collection file
1319 collection.save();
1320}
1321
1323template<class T>
1324void gsWriteParaview(const gsHBoxContainer<2,T> & boxes, std::string const & fn)
1325{
1326 gsParaviewCollection collection(fn);
1327
1328 index_t i=0;
1329 std::string fileName;
1330 for (typename gsHBoxContainer<2,T>::cHIterator Hit = boxes.cbegin(); Hit!=boxes.cend(); Hit++)
1331 for (typename gsHBoxContainer<2,T>::cIterator Cit = Hit->cbegin(); Cit!=Hit->cend(); Cit++, i++)
1332 {
1333 fileName = fn + util::to_string(i);
1334 writeSingleHBox<T>(*Cit,fileName);
1335 fileName = gsFileManager::getFilename(fileName);
1336 collection.addPart(fileName + ".vts",-1,"",i);
1337 }
1338
1339 // Write out the collection file
1340 collection.save();
1341}
1342
1344template<class T>
1345void gsWriteParaview(gsMultiPatch<T> const& mp, gsMultiBasis<T> const& mb,
1346 std::string const & fn, unsigned npts)
1347{
1348 GISMO_ENSURE(mp.nPatches()==mb.nBases(),"Number of bases and patches do not correspond");
1349
1350 gsParaviewCollection collection(fn);
1351
1352 gsMatrix<T> eval_geo, eval_basis, pts, ab;
1353 gsVector<T> a, b;
1354
1355 index_t k=0;
1356 for (size_t p=0; p!=mp.nPatches(); p++)
1357 for ( index_t i=0; i< mb.basis(p).size(); i++, k++)
1358 {
1359 // Compute the geometry on the support of the basis function
1360 ab = mb.basis(p).support(i);
1361 a = ab.col(0);
1362 b = ab.col(1);
1363
1364 gsVector<unsigned> np = uniformSampleCount(a, b, npts);
1365 pts = gsPointGrid(a, b, np);
1366
1367 eval_geo = mp.patch(p).eval(pts);//pts
1368
1369 std::string fileName = fn + "_" + util::to_string(k);
1370 std::string fileName_nopath = gsFileManager::getFilename(fileName);
1371
1372 eval_basis = mb.basis(p).evalSingle(i,pts);
1373 gsWriteParaviewTPgrid(eval_geo, eval_basis, np.template cast<index_t>(), fileName);
1374 // gsWriteParaview_basisFnct<T>(i, basis, fileName, npts ) ;
1375 // collection.addPart(fileName_nopath + ".vts",-1,"",k);
1376 collection.addPart(fileName_nopath + ".vts",k);
1377 }
1378 collection.save();
1379}
1380
1382template<class T>
1383void gsWriteParaviewPoints(gsMatrix<T> const& X, gsMatrix<T> const& Y, std::string const & fn)
1384{
1385 assert( X.cols() == Y.cols() );
1386 assert( X.rows() == 1 && Y.rows() == 1 );
1387 index_t np = X.cols();
1388
1389 std::string mfn(fn);
1390 mfn.append(".vtp");
1391 std::ofstream file(mfn.c_str());
1392 if ( ! file.is_open() )
1393 gsWarn<<"gsWriteParaviewPoints: Problem opening file \""<<fn<<"\""<<std::endl;
1394 file << std::fixed; // no exponents
1395 file << std::setprecision (PLOT_PRECISION);
1396 file <<"<?xml version=\"1.0\"?>\n";
1397 file <<"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1398 file <<"<PolyData>\n";
1399 file <<"<Piece NumberOfPoints=\""<<np<<"\" NumberOfVerts=\"1\" NumberOfLines=\"0\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\n";
1400 file <<"<PointData>\n";
1401 file <<"</PointData>\n";
1402 file <<"<CellData>\n";
1403 file <<"</CellData>\n";
1404 file <<"<Points>\n";
1405 file <<"<DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\" RangeMin=\""<<X.minCoeff()<<"\" RangeMax=\""<<X.maxCoeff()<<"\">\n";
1406 for (index_t i=0; i< np; ++i )
1407 file << X(0,i) <<" "<<Y(0,i)<<" "<< 0.0 <<"\n";
1408 file <<"\n</DataArray>\n";
1409 file <<"</Points>\n";
1410 file <<"<Verts>\n";
1411 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<"\" RangeMax=\""<<np-1<<"\">\n";
1412 for (index_t i=0; i< np; ++i )
1413 file << i<<" ";
1414 file <<"\n</DataArray>\n";
1415 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n"<<np<<"\n";
1416 file <<"</DataArray>\n";
1417 file <<"</Verts>\n";
1418 file <<"<Lines>\n";
1419 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1420 file <<"</DataArray>\n";
1421 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1422 file <<"</DataArray>\n";
1423 file <<"</Lines>\n";
1424 file <<"<Strips>\n";
1425 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1426 file <<"</DataArray>\n";
1427 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1428 file <<"</DataArray>\n";
1429 file <<"</Strips>\n";
1430 file <<"<Polys>\n";
1431 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1432 file <<"</DataArray>\n";
1433 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1434 file <<"</DataArray>\n";
1435 file <<"</Polys>\n";
1436 file <<"</Piece>\n";
1437 file <<"</PolyData>\n";
1438 file <<"</VTKFile>\n";
1439 file.close();
1440
1441 makeCollection(fn, ".vtp"); // make also a pvd file
1442}
1443
1444template<class T>
1446 gsMatrix<T> const& Y,
1447 gsMatrix<T> const& Z,
1448 std::string const & fn)
1449{
1450 GISMO_ASSERT(X.cols() == Y.cols() && X.cols() == Z.cols(),
1451 "X, Y and Z must have the same size of columns!");
1452 GISMO_ASSERT(X.rows() == 1 && Y.rows() == 1 && Z.cols(),
1453 "X, Y and Z must be row matrices!");
1454 index_t np = X.cols();
1455
1456 std::string mfn(fn);
1457 mfn.append(".vtp");
1458 std::ofstream file(mfn.c_str());
1459
1460 if (!file.is_open())
1461 {
1462 gsWarn << "Problem opening " << fn << " Aborting..." << std::endl;
1463 return;
1464 }
1465
1466 file << std::fixed; // no exponents
1467 file << std::setprecision (PLOT_PRECISION);
1468
1469 file <<"<?xml version=\"1.0\"?>\n";
1470 file <<"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1471 file <<"<PolyData>\n";
1472 file <<"<Piece NumberOfPoints=\""<<np<<"\" NumberOfVerts=\"1\" NumberOfLines=\"0\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\n";
1473 file <<"<PointData>\n"; //empty
1474 file <<"</PointData>\n";
1475 file <<"<CellData>\n";
1476 file <<"</CellData>\n";
1477 file <<"<Points>\n";
1478 file <<"<DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\" RangeMin=\""<<X.minCoeff()<<"\" RangeMax=\""<<X.maxCoeff()<<"\">\n";
1479
1480 for (index_t i = 0; i < np; ++i)
1481 {
1482 file << X(0, i) << " " << Y(0, i) << " " << Z(0, i) << "\n";
1483 }
1484
1485 file <<"\n</DataArray>\n";
1486 file <<"</Points>\n";
1487 file <<"<Verts>\n";
1488 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<"\" RangeMax=\""<<np-1<<"\">\n";
1489
1490 for (index_t i=0; i< np; ++i )
1491 {
1492 file << i << " ";
1493 }
1494
1495 file <<"\n</DataArray>\n";
1496 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n"<<np<<"\n";
1497 file <<"</DataArray>\n";
1498 file <<"</Verts>\n";
1499 file <<"<Lines>\n";
1500 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1501 file <<"</DataArray>\n";
1502 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1503 file <<"</DataArray>\n";
1504 file <<"</Lines>\n";
1505 file <<"<Strips>\n";
1506 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1507 file <<"</DataArray>\n";
1508 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1509 file <<"</DataArray>\n";
1510 file <<"</Strips>\n";
1511 file <<"<Polys>\n";
1512 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1513 file <<"</DataArray>\n";
1514 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1515 file <<"</DataArray>\n";
1516 file <<"</Polys>\n";
1517 file <<"</Piece>\n";
1518 file <<"</PolyData>\n";
1519 file <<"</VTKFile>\n";
1520 file.close();
1521
1522 makeCollection(fn, ".vtp"); // make also a pvd file
1523}
1524
1525template<class T>
1527 gsMatrix<T> const& Y,
1528 gsMatrix<T> const& Z,
1529 gsMatrix<T> const& V,
1530 std::string const & fn)
1531{
1532 GISMO_ASSERT(X.cols() == Y.cols() && X.cols() == Z.cols(),
1533 "X, Y and Z must have the same size of columns!");
1534 GISMO_ASSERT(X.rows() == 1 && Y.rows() == 1 && Z.cols(),
1535 "X, Y and Z must be row matrices!");
1536 index_t np = X.cols();
1537
1538 std::string mfn(fn);
1539 mfn.append(".vtp");
1540 std::ofstream file(mfn.c_str());
1541
1542 if (!file.is_open())
1543 {
1544 gsWarn << "Problem opening " << fn << " Aborting..." << std::endl;
1545 return;
1546 }
1547
1548 file << std::fixed; // no exponents
1549 file << std::setprecision (PLOT_PRECISION);
1550
1551 file <<"<?xml version=\"1.0\"?>\n";
1552 file <<"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1553 file <<"<PolyData>\n";
1554 file <<"<Piece NumberOfPoints=\""<<np<<"\" NumberOfVerts=\"1\" NumberOfLines=\"0\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\n";
1555 //---------
1556 file <<"<PointData "<< "Scalars=\"PointInfo\">\n";
1557 file <<"<DataArray type=\"Float32\" Name=\"PointInfo\" format=\"ascii\" NumberOfComponents=\"1\">\n";
1558 for ( index_t j=0; j<np; ++j)
1559 file<< V(0,j) <<" ";
1560 file <<"</DataArray>\n";
1561 file <<"</PointData>\n";
1562 //---------
1563 file <<"<CellData>\n";
1564 file <<"</CellData>\n";
1565 file <<"<Points>\n";
1566 file <<"<DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\" RangeMin=\""<<X.minCoeff()<<"\" RangeMax=\""<<X.maxCoeff()<<"\">\n";
1567
1568 for (index_t i = 0; i < np; ++i)
1569 {
1570 file << X(0, i) << " " << Y(0, i) << " " << Z(0, i) << "\n";
1571 }
1572
1573 file <<"\n</DataArray>\n";
1574 file <<"</Points>\n";
1575 file <<"<Verts>\n";
1576 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<"\" RangeMax=\""<<np-1<<"\">\n";
1577
1578 for (index_t i=0; i< np; ++i )
1579 {
1580 file << i << " ";
1581 }
1582
1583 file <<"\n</DataArray>\n";
1584 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n"<<np<<"\n";
1585 file <<"</DataArray>\n";
1586 file <<"</Verts>\n";
1587 file <<"<Lines>\n";
1588 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1589 file <<"</DataArray>\n";
1590 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1591 file <<"</DataArray>\n";
1592 file <<"</Lines>\n";
1593 file <<"<Strips>\n";
1594 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1595 file <<"</DataArray>\n";
1596 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1597 file <<"</DataArray>\n";
1598 file <<"</Strips>\n";
1599 file <<"<Polys>\n";
1600 file <<"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<np-1<<"\">\n";
1601 file <<"</DataArray>\n";
1602 file <<"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\""<<np<<"\" RangeMax=\""<<np<<"\">\n";
1603 file <<"</DataArray>\n";
1604 file <<"</Polys>\n";
1605 file <<"</Piece>\n";
1606 file <<"</PolyData>\n";
1607 file <<"</VTKFile>\n";
1608 file.close();
1609
1610 makeCollection(fn, ".vtp"); // make also a pvd file
1611}
1612
1613template<class T>
1614void gsWriteParaviewPoints(gsMatrix<T> const& points, std::string const & fn)
1615{
1616 const index_t rows = points.rows();
1617 switch (rows)
1618 {
1619 case 1:
1620 gsWriteParaviewPoints<T>(points.row(0), gsMatrix<T>::Zero(1, points.cols()), fn);
1621 break;
1622 case 2:
1623 gsWriteParaviewPoints<T>(points.row(0), points.row(1), fn);
1624 break;
1625 case 3:
1626 gsWriteParaviewPoints<T>(points.row(0), points.row(1), points.row(2), fn);
1627 break;
1628 case 4:
1629 gsWriteParaviewPoints<T>(points.row(0), points.row(1), points.row(2), points.row(3), fn);
1630 break;
1631 default:
1632 GISMO_ERROR("Point plotting is implemented just for 2D and 3D (rows== 1, 2 or 3).");
1633 }
1634}
1635
1636// Depicting edge graph of each volume of one gsSolid with a segmenting loop
1637// INPUTS:
1638// \param eloop: a vector of ID numbers of vertices, often for representing a segmenting loop
1639template <class T>
1640void gsWriteParaview(gsSolid<T> const& sl, std::string const & fn, unsigned numPoints_for_eachCurve, int vol_Num,
1641 T edgeThick, gsVector3d<T> const & translate, int color_convex,
1642 int color_nonconvex, int color_eloop, std::vector<unsigned> const & eloop)
1643{
1644 // options
1645 int color=color_convex;
1646
1647 gsSolidHalfFace<T>* face;
1648 int numOfCurves;
1649 int numOfPoints = numPoints_for_eachCurve;
1650
1651 T faceThick = edgeThick;
1652// T camera1 = 1;
1653// T camera2 = 1;
1654// T camera3 = 1;
1655
1656 std::string mfn(fn);
1657 mfn.append(".vtp");
1658 std::ofstream file(mfn.c_str());
1659 if ( ! file.is_open() )
1660 gsWarn<<"gsWriteParaview: Problem opening file \""<<fn<<"\""<<std::endl;
1661 file << std::fixed; // no exponents
1662 file << std::setprecision (PLOT_PRECISION);
1663 file <<"<?xml version=\"1.0\"?>\n";
1664 file <<"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1665 file <<"<PolyData>\n";
1666
1667
1668 // collect HEs representing the edge loop
1669 numOfCurves = eloop.size();
1670 gsSolidHalfEdge<T>* he;
1671 std::vector< typename gsSolid<T>::gsSolidHalfEdgeHandle > heSet;
1672 typename gsSolid<T>::gsSolidHeVertexHandle source,target;
1673 if (eloop.size()>0){
1674 for (int iedge=0; iedge!= numOfCurves; iedge++)
1675 {
1676 source = sl.vertex[eloop[iedge]];
1677 target = sl.vertex[eloop[(iedge+1)%numOfCurves]];
1678 he = source->getHalfEdge(target);
1679 heSet.push_back(he);
1680 face = he->face;
1681 }}
1682
1683
1684 //gsDebug<<"\n ------------------------------------- number of hafl faces: "<< sl.nHalfFaces();
1685 for (int iface=0;iface!= sl.nHalfFaces();iface++)
1686 {
1687 face = sl.getHalfFaceFromID(iface);
1688 //gsDebug<<"\n ------------------------------------- vol of face:"<< face->vol->getId()<< " :for face: "<< iface <<"\n";
1689 //gsDebug << std::flush;
1690 if (face->vol->getId()==vol_Num)
1691 {
1692 numOfCurves=face->nCurvesOfOneLoop(0);
1693 //gsDebug<<"\n -----------INSIDE-------------------- vol of face:"<< face->vol->getId()<< " :for face: "<< iface <<"\n";
1694
1695 for (int iedge=0; iedge!= numOfCurves; iedge++)
1696 {
1697 he = face->getHalfEdgeFromBoundaryOrder(iedge);
1698 // search if he is in heSet
1699 bool isMember(false);
1700 for (size_t iheSet=0;iheSet<heSet.size();iheSet++)
1701 {
1702 if ( he->isEquiv(heSet.at(iheSet))==true || he->mate->isEquiv(heSet.at(iheSet))==true)
1703 {isMember=true;
1704 break;}
1705 }
1706 gsMatrix<T> curvePoints = face->surf->sampleBoundaryCurve(iedge, numPoints_for_eachCurve);
1707 if (iedge==0) assert( numOfPoints == curvePoints.cols());
1708 color=color_convex;
1709 if (isMember==true) color=color_eloop;
1710 if (face->getHalfEdgeFromBoundaryOrder(iedge)->is_convex==false){color = color_nonconvex;}
1712 file <<"<Piece NumberOfPoints=\""<< 2*numOfPoints <<"\" NumberOfVerts=\"0\" NumberOfLines=\""<< 0
1713 <<"\" NumberOfStrips=\"0\" NumberOfPolys=\""<< numOfPoints-1 << "\">\n";
1714
1716 file <<"<Points>\n";
1717 file <<"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
1718 // translate the volume towards the *translate* vector
1719 for (index_t iCol = 0;iCol!=curvePoints.cols();iCol++)
1720 {
1721 file << curvePoints(0,iCol) + translate(0) << " " << curvePoints(1,iCol) + translate(1) << " " << curvePoints(2,iCol) + translate(2) << " \n";
1722 // translate the vertex about along the vector (faceThick,0,0)
1723 file << curvePoints(0,iCol) + faceThick + translate(0) << " " << curvePoints(1,iCol) + faceThick + translate(1)
1724 << " " << curvePoints(2,iCol) +faceThick + translate(2) << " \n";
1725 };
1726 file << "\n";
1727 file <<"</DataArray>\n";
1728 file <<"</Points>\n";
1729
1731 file << "<CellData Scalars=\"cell_scalars\">\n";
1732 file << "<DataArray type=\"Int32\" Name=\"cell_scalars\" format=\"ascii\">\n";
1734 for (index_t iCol = 0;iCol!=curvePoints.cols()-1;iCol++)
1735 {
1736 file << color << " ";
1737 }
1738 file << "\n";
1739 file << "</DataArray>\n";
1740 file << "</CellData>\n";
1741
1743 file << "<Polys>\n";
1744 file << "<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
1745 for (index_t iCol = 0;iCol<=curvePoints.cols()-2;iCol++)
1746 {
1747 //file << iCol << " " << iCol+1 << " "<< iCol+1 << " " << iCol << " ";
1748 file << 2*iCol << " " << 2*iCol+1 << " "<< 2*iCol+3 << " " << 2*iCol+2 << " ";
1749 }
1750 //file << curvePoints.cols()-1 << " " << 0 << " "<< 0 << " "<< curvePoints.cols()-1 << " ";
1751 file << "\n";
1752 file << "</DataArray>\n";
1753 file << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
1754 unsigned offsets(0);
1755 for (index_t iCol = 0;iCol!=curvePoints.cols()-1;iCol++)
1756 {
1757 offsets +=4;
1758 file << offsets << " ";
1759 }
1760 file << "\n";
1761 file << "</DataArray>\n";
1762 file << "</Polys>\n";
1763
1764 file << "</Piece>\n";
1765
1767 file << "\n";
1768 file << "\n";
1769 }
1770 }
1771 }
1772
1773 file <<"</PolyData>\n";
1774 file <<"</VTKFile>\n";
1775 file.close();
1776
1777 makeCollection(fn, ".vtp"); // make also a pvd file
1778}
1779
1780template <class T>
1782 std::string const & fn,
1783 unsigned numSamples)
1784{
1785 const size_t n = sl.numHalfFaces;
1786 gsParaviewCollection collection(fn);
1787
1788 // for( typename gsSolid<T>::const_face_iterator it = sl.begin();
1789 // it != sl.end(); ++it)
1790
1791 for ( size_t i=0; i<n ; i++)
1792 {
1793 std::string fnBase = fn + util::to_string(i);
1794 std::string fnBase_nopath = gsFileManager::getFilename(fnBase);
1795 writeSingleTrimSurface(*sl.face[i]->surf, fnBase, numSamples);
1796 collection.addPart(fnBase_nopath + ".vtp");
1797 }
1798
1799 // Write out the collection file
1800 collection.save();
1801}
1802
1803
1805template <class T>
1806void gsWriteParaview(gsMesh<T> const& sl, std::string const & fn, bool pvd)
1807{
1808 std::string mfn(fn);
1809 mfn.append(".vtp");
1810 std::ofstream file(mfn.c_str());
1811 if ( ! file.is_open() )
1812 gsWarn<<"gsWriteParaview: Problem opening file \""<<fn<<"\""<<std::endl;
1813 file << std::fixed; // no exponents
1814 file << std::setprecision (PLOT_PRECISION);
1815
1816 file <<"<?xml version=\"1.0\"?>\n";
1817 file <<"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1818 file <<"<PolyData>\n";
1819
1821 file <<"<Piece NumberOfPoints=\""<< sl.numVertices() <<"\" NumberOfVerts=\"0\" NumberOfLines=\""
1822 << sl.numEdges()<<"\" NumberOfStrips=\"0\" NumberOfPolys=\""<< sl.numFaces() << "\">\n";
1823
1825 file <<"<Points>\n";
1826 file <<"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
1827 for (typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
1828 {
1829 const gsVertex<T>& vertex = **it;
1830 file << vertex[0] << " ";
1831 file << vertex[1] << " ";
1832 file << vertex[2] << " \n";
1833 }
1834
1835 file << "\n";
1836 file <<"</DataArray>\n";
1837 file <<"</Points>\n";
1838
1839 // Scalar field attached to each face
1840 // file << "<PointData Scalars=\"point_scalars\">\n";
1841 // file << "<DataArray type=\"Int32\" Name=\"point_scalars\" format=\"ascii\">\n";
1842 // for (typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertex.begin();
1843 // it!=sl.vertex.end(); ++it)
1844 // {
1845 // file << 0 << " ";
1846 // }
1847 // file << "\n";
1848 // file << "</DataArray>\n";
1849 // file << "</PointData>\n";
1850
1851 // Write out edges
1852 file << "<Lines>\n";
1853 file << "<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
1854 for (typename std::vector< gsEdge<T> >::const_iterator it=sl.edges().begin();
1855 it!=sl.edges().end(); ++it)
1856 {
1857 file << it->source->getId() << " " << it->target->getId() << "\n";
1858 }
1859 file << "</DataArray>\n";
1860 file << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
1861 int count=0;
1862 for (typename std::vector< gsEdge<T> >::const_iterator it=sl.edges().begin();
1863 it!=sl.edges().end(); ++it)
1864 {
1865 count+=2;
1866 file << count << " ";
1867 }
1868 file << "\n";
1869 file << "</DataArray>\n";
1870 file << "</Lines>\n";
1871
1872 // Scalar field attached to each face (* if edges exists, this has a problem)
1873 // file << "<CellData Scalars=\"cell_scalars\">\n";
1874 // file << "<DataArray type=\"Int32\" Name=\"cell_scalars\" format=\"ascii\">\n";
1875 // for (typename std::vector< gsFace<T>* >::const_iterator it=sl.face.begin();
1876 // it!=sl.face.end(); ++it)
1877 // {
1878 // file << 1 << " ";
1879 // }
1880 // file << "\n";
1881 // file << "</DataArray>\n";
1882 // file << "</CellData>\n";
1883
1885 file << "<Polys>\n";
1886 file << "<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
1887 for (typename std::vector< gsFace<T>* >::const_iterator it=sl.faces().begin();
1888 it!=sl.faces().end(); ++it)
1889 {
1890 for (typename std::vector< gsVertex<T>* >::const_iterator vit= (*it)->vertices.begin();
1891 vit!=(*it)->vertices.end(); ++vit)
1892 {
1893 file << (*vit)->getId() << " ";
1894 }
1895 file << "\n";
1896 }
1897 file << "</DataArray>\n";
1898 file << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
1899 count=0;
1900 for (typename std::vector< gsFace<T>* >::const_iterator it=sl.faces().begin();
1901 it!=sl.faces().end(); ++it)
1902 {
1903 count += (*it)->vertices.size();
1904 file << count << " ";
1905 }
1906 file << "\n";
1907 file << "</DataArray>\n";
1908 file << "</Polys>\n";
1909
1910 file << "</Piece>\n";
1911 file <<"</PolyData>\n";
1912 file <<"</VTKFile>\n";
1913 file.close();
1914
1915 if( pvd ) // make also a pvd file
1916 makeCollection(fn, ".vtp");
1917}
1918
1919template <class T>
1920void gsWriteParaview(gsMesh<T> const& sl, std::string const & fn, const gsMatrix<T>& params)
1921{
1922 GISMO_ASSERT((index_t)sl.numVertices()==params.cols(),
1923 "Incorrect number of data: "<< params.cols() <<" != "<< sl.numVertices() );
1924
1925 std::string mfn(fn);
1926 mfn.append(".vtk");
1927 std::ofstream file(mfn.c_str());
1928 if ( ! file.is_open() )
1929 gsWarn<<"gsWriteParaview: Problem opening file \""<<fn<<"\""<<std::endl;
1930 file << std::fixed; // no exponents
1931 file << std::setprecision (PLOT_PRECISION);
1932
1933 file << "# vtk DataFile Version 4.2\n";
1934 file << "vtk output\n";
1935 file << "ASCII\n";
1936 file << "DATASET POLYDATA\n";
1937
1938 // Vertices
1939 file << "POINTS " << sl.numVertices() << " float\n";
1940 for (typename std::vector< gsVertex<T>* >::const_iterator it=sl.vertices().begin(); it!=sl.vertices().end(); ++it)
1941 {
1942 const gsVertex<T>& vertex = **it;
1943 file << vertex[0] << " ";
1944 file << vertex[1] << " ";
1945 file << vertex[2] << " \n";
1946 }
1947 file << "\n";
1948
1949 // Triangles or quads
1950 file << "POLYGONS " << sl.numFaces() << " " <<
1951 (sl.faces().front()->vertices.size()+1) * sl.numFaces() << std::endl;
1952 for (typename std::vector< gsFace<T>* >::const_iterator it=sl.faces().begin();
1953 it!=sl.faces().end(); ++it)
1954 {
1955 file << (*it)->vertices.size() <<" "; //3: triangles, 4: quads
1956 for (typename std::vector< gsVertex<T>* >::const_iterator vit=
1957 (*it)->vertices.begin(); vit!=(*it)->vertices.end(); ++vit)
1958 {
1959 file << (*vit)->getId() << " ";
1960 }
1961 file << "\n";
1962 }
1963 file << "\n";
1964
1965 // Data
1966 file << "POINT_DATA " << sl.numVertices() << std::endl;
1967 //file << "TEXTURE_COORDINATES parameters "<<params.rows()<<" float\n";
1968 if ( 3 == params.rows() )
1969 file << "VECTORS Data float\n";
1970 else
1971 file << "SCALARS Data float "<<params.rows()<<"\nLOOKUP_TABLE default\n";
1972
1973 for(index_t j=0; j<params.cols(); j++)
1974 {
1975 for(index_t i=0; i<params.rows(); i++)
1976 file << params(i,j) << " ";
1977 file << "\n";
1978 }
1979
1980 file.close();
1981}
1982
1983template <typename T>
1984void gsWriteParaview(const std::vector<gsMesh<T> >& meshes,
1985 const std::string& fn)
1986{
1987 for (unsigned index = 0; index < meshes.size(); index++)
1988 {
1989 std::string file = fn + "Level" + util::to_string(index);
1990 gsWriteParaview(meshes[index], file, false);
1991 }
1992}
1993
1994template<class T>
1995void gsWriteParaview(gsPlanarDomain<T> const & pdomain, std::string const & fn, unsigned npts)
1996{
1997 std::vector<gsGeometry<T> *> all_curves;
1998 for(index_t i =0; i<pdomain.numLoops();i++)
1999 for(index_t j =0; j< pdomain.loop(i).numCurves() ; j++)
2000 all_curves.push_back( const_cast<gsCurve<T> *>(&pdomain.loop(i).curve(j)) );
2001
2002 gsWriteParaview( all_curves, fn, npts);
2003}
2004
2005template<class T>
2006void gsWriteParaview(const gsTrimSurface<T> & surf, std::string const & fn,
2007 unsigned npts, bool trimCurves)
2008{
2009 gsParaviewCollection collection(fn);
2010
2011 writeSingleTrimSurface(surf, fn, npts);
2012 std::string fn_nopath = gsFileManager::getFilename(fn);
2013 collection.addPart(fn_nopath + ".vtp");
2014
2015 if ( trimCurves )
2016 {
2017 gsWarn<<"trimCurves: To do.\n";
2018 }
2019
2020 // Write out the collection file
2021 collection.save();
2022}
2023
2024template<typename T>
2025void gsWriteParaview(const gsVolumeBlock<T>& volBlock,
2026 std::string const & fn,
2027 unsigned npts)
2028{
2029 using util::to_string;
2030
2031 gsParaviewCollection collection(fn);
2032
2033 // for each face
2034 for (unsigned idFace = 0; idFace != volBlock.face.size(); idFace++)
2035 {
2036 typename gsVolumeBlock<T>::HalfFace* face = volBlock.face[idFace];
2037 gsPlanarDomain<T>& domain = face->surf->domain();
2038
2039 // for each curve loop (boundary + holes)
2040 unsigned numLoops = static_cast<unsigned>(domain.numLoops());
2041 for (unsigned idLoop = 0; idLoop < numLoops; idLoop++)
2042 {
2043 gsCurveLoop<T>& curveLoop = domain.loop(idLoop);
2044
2045 unsigned clSize = static_cast<unsigned>(curveLoop.size());
2046
2047 // for each curve in curve loop
2048 for (unsigned idCurve = 0; idCurve < clSize; idCurve++)
2049 {
2050 // file name is fn_curve_Fface_Lloop_Ccurve
2051 std::string fileName = fn + "_curve_F";
2052 std::string fileName_nopath = gsFileManager::getFilename(fileName);
2053 fileName += to_string(idFace) + "_L" +
2054 to_string(idLoop) + "_C" +
2055 to_string(idCurve);
2056
2057 gsWriteParaviewTrimmedCurve(*(face->surf), idLoop, idCurve,
2058 fileName, npts);
2059
2060 collection.addPart(fileName_nopath + ".vts");
2061
2062 } // for each curve
2063 } // for each curve loop
2064 } // for each face
2065
2066 collection.save();
2067}
2068
2069template<typename T>
2071 std::string const & fn,
2072 unsigned npts, bool ctrlNet)
2073{
2074 typename gsMultiPatch<T>::BoundaryRep const & brep = patches.boundaryRep();
2075 GISMO_ENSURE(brep.size()!=0,"Boundary representation is empty. Call gsMultiPatch::constructBoundaryRep first!");
2076 gsMultiPatch<T> bnd_net;
2077 for (auto it = brep.begin(); it!=brep.end(); ++it)
2078 bnd_net.addPatch((*it->second));
2079 gsWriteParaview<T>(bnd_net,fn,npts,false,ctrlNet);
2080}
2081
2082template<typename T>
2084 std::string const & fn,
2085 unsigned npts, bool ctrlNet)
2086{
2087
2088 typename gsMultiPatch<T>::InterfaceRep const & irep = patches.interfaceRep();
2089 GISMO_ENSURE(irep.size()!=0,"Interface representation is empty. Call gsMultiPatch::constructInterfaceRep first!");
2090 gsMultiPatch<T> iface_net;
2091 for (auto it = irep.begin(); it!=irep.end(); ++it)
2092 iface_net.addPatch((*it->second));
2093 gsWriteParaview<T>(iface_net,fn,npts,false,ctrlNet);
2094}
2095
2096template<typename T>
2097void gsWriteParaview(gsMultiPatch<T> const & patches,
2098 typename gsBoundaryConditions<T>::bcContainer const & bcs,
2099 std::string const & fn, unsigned npts, bool ctrlNet)
2100{
2101 gsMultiPatch<T> bc_net;
2102 for (typename gsBoundaryConditions<T>::const_iterator bc=bcs.begin(); bc!=bcs.end(); bc++)
2103 bc_net.addPatch(patches[bc->patch()].boundary(bc->side()));
2104 gsWriteParaview<T>(bc_net,fn,npts,false,ctrlNet);
2105}
2106
2107template<typename T>
2109 const unsigned idLoop,
2110 const unsigned idCurve,
2111 const std::string fn,
2112 unsigned npts)
2113{
2114 // computing parameters and points
2115
2116 int idL = static_cast<int>(idLoop);
2117 int idC = static_cast<int>(idCurve);
2118
2119 gsCurve<T>& curve = surf.getCurve(idL, idC);
2120
2121 gsMatrix<T> ab = curve.parameterRange() ;
2122 gsVector<T> a = ab.col(0);
2123 gsVector<T> b = ab.col(1);
2124
2125 gsVector<unsigned> np = uniformSampleCount(a, b, npts);
2126 gsMatrix<T> param = gsPointGrid(a, b, np);
2127
2128 gsMatrix<T> points;
2129 surf.evalCurve_into(idLoop, idCurve, param, points);
2130
2131 np.conservativeResize(3);
2132 np.bottomRows(3 - 1).setOnes();
2133
2134
2135 // writing to the file
2136
2137 std::string myFile(fn);
2138 myFile.append(".vts");
2139
2140 std::ofstream file(myFile.c_str());
2141 if (!file.is_open())
2142 {
2143 gsWarn << "Problem opening " << fn << " Aborting..." << std::endl;
2144 return;
2145 }
2146
2147 file << std::fixed; // no exponents
2148 file << std::setprecision (PLOT_PRECISION);
2149
2150 file << "<?xml version=\"1.0\"?>\n";
2151 file << "<VTKFile type=\"StructuredGrid\" version=\"0.1\">\n";
2152 file << "<StructuredGrid WholeExtent=\"0 "<< np(0) - 1 <<
2153 " 0 " << np(1) - 1 << " 0 " << np(2) - 1 << "\">\n";
2154
2155 file << "<Piece Extent=\"0 " << np(0) - 1 << " 0 " << np(1) - 1 << " 0 "
2156 << np(2) - 1 << "\">\n";
2157
2158 file << "<Points>\n";
2159 file << "<DataArray type=\"Float32\" NumberOfComponents=\"" << points.rows()
2160 << "\">\n";
2161
2162 for (index_t j = 0; j < points.cols(); ++j)
2163 {
2164 for (index_t i = 0; i < points.rows(); ++i)
2165 {
2166 file << points(i, j) << " ";
2167 }
2168 file << "\n";
2169 }
2170
2171 file << "</DataArray>\n";
2172 file << "</Points>\n";
2173 file << "</Piece>\n";
2174 file << "</StructuredGrid>\n";
2175 file << "</VTKFile>\n";
2176 file.close();
2177
2178}
2179
2180} // namespace gismo
2181
2182
2183#undef PLOT_PRECISION
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
A closed loop given by a collection of curves.
Definition gsCurveLoop.h:37
Abstract base class representing a curve.
Definition gsCurve.h:31
A scalar of vector field defined on a m_parametric geometry.
Definition gsField.h:55
const gsGeometry< T > & patch(int i=0) const
Returns the gsGeometry of patch i.
Definition gsField.h:221
const gsFunction< T > & function(int i=0) const
Returns the gsFunction of patch i.
Definition gsField.h:231
bool isParametric() const
Definition gsField.h:252
int nPieces() const
Returns the number of pieces.
Definition gsField.h:200
bool isParametrized() const
Definition gsField.h:257
const gsGeometry< T > & igaFunction(int i=0) const
Attempts to return an Isogeometric function for patch i.
Definition gsField.h:239
static std::string getFilename(std::string const &fn)
Returns the filename without the path of fn.
Definition gsFileManager.cpp:597
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition gsFunctionSet.h:219
virtual index_t nPieces() const
Number of pieces in the domain of definition.
Definition gsFunctionSet.h:619
const gsFunction< T > & function(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsFunction.
Definition gsFunctionSet.hpp:25
gsMatrix< T > eval(const gsMatrix< T > &u) const
Evaluate the function,.
Definition gsFunctionSet.hpp:120
virtual index_t size() const
size
Definition gsFunctionSet.h:613
virtual const gsFunctionSet & piece(const index_t) const
Returns the piece(s) of the function(s) at subdomain k.
Definition gsFunctionSet.h:239
A function from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
virtual short_t domainDim() const=0
Dimension of the (source) domain.
virtual short_t targetDim() const
Dimension of the target space.
Definition gsFunctionSet.h:595
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const =0
Evaluate the function at points u into result.
gsGeometrySlice is a class representing an iso parametric slice of a geometry object....
Definition gsGeometrySlice.h:28
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
gsMatrix< T > & coefs()
Definition gsGeometry.h:340
void evaluateMesh(gsMesh< T > &mesh) const
Definition gsGeometry.hpp:255
short_t geoDim() const
Dimension n of the absent physical space.
Definition gsGeometry.h:292
virtual short_t domainDim() const
Dimension d of the parameter domain (overriding gsFunction::domainDim()).
Definition gsGeometry.hpp:184
virtual const gsBasis< T > & basis() const =0
Returns a const reference to the basis of the geometry.
short_t parDim() const
Dimension d of the parameter domain (same as domainDim()).
Definition gsGeometry.hpp:190
void controlNet(gsMesh< T > &mesh) const
Return the control net of the geometry.
Definition gsGeometry.hpp:538
gsMatrix< T > parameterRange() const
Returns the range of parameters as a matrix with two columns, [lower upper].
Definition gsGeometry.hpp:198
The Hierarchical Box Container provides a container for gsHBox objects.
Definition gsHBoxContainer.h:40
This class provides a Hierarchical Box (gsHBox)
Definition gsHBox.h:55
T projectedErrorRef() const
The error contribution of *this when it is refined.
Definition gsHBox.hpp:307
index_t level() const
Gets the level of the object.
Definition gsHBox.hpp:287
void computeCoordinates() const
Computes the parametric coordinates of this.
Definition gsHBox.hpp:633
T error() const
Gets the error stored in the object.
Definition gsHBox.hpp:304
const gsMatrix< T > & getCoordinates() const
Gets the coordinates of the box (first column lower corner, second column higher corner).
Definition gsHBox.hpp:231
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class Representing a triangle mesh with 3D vertices.
Definition gsMesh.h:32
Holds a set of patch-wise bases and their topology information.
Definition gsMultiBasis.h:37
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
const_iterator begin() const
Definition gsMultiPatch.h:169
index_t size() const
size
Definition gsMultiPatch.h:195
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition gsMultiPatch.h:292
index_t addPatch(typename gsGeometry< T >::uPtr g)
Add a patch from a gsGeometry<T>::uPtr.
Definition gsMultiPatch.hpp:211
const_iterator end() const
Definition gsMultiPatch.h:174
size_t nPatches() const
Number of patches.
Definition gsMultiPatch.h:274
This class is used to create a Paraview .pvd (collection) file.
Definition gsParaviewCollection.h:77
void addPart(String const &fn, real_t tStep=-1, std::string name="", index_t part=-1)
Appends a file to the Paraview collection (.pvd file).
Definition gsParaviewCollection.h:114
void save()
Definition gsParaviewCollection.h:203
Class representing a Planar domain with an outer boundary and a number of holes.
Definition gsPlanarDomain.h:44
Class for representing a solid made up of vertices, edges, faces, and volumes.
Definition gsSolid.h:33
Class for a trim surface.
Definition gsTrimSurface.h:34
gsCurve< T > & getCurve(int loopNumber, int curveNumber) const
Returns curveNumber-th curve in loopNumber-th loop.
Definition gsTrimSurface.h:103
void evalCurve_into(int loopNumber, int curveNumber, const gsMatrix< T > &u, gsMatrix< T > &result) const
Definition gsTrimSurface.h:133
A fixed-size, statically allocated 3D vector.
Definition gsVector.h:219
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
gsVertex class that represents a 3D vertex for a gsMesh.
Definition gsVertex.h:27
std::string to_string(const C &value)
Converts value to string, assuming "operator<<" defined on C.
Definition gsUtils.h:56
gsMatrix< T > gsPointGrid(gsVector< T > const &a, gsVector< T > const &b, gsVector< unsigned > const &np)
Construct a Cartesian grid of uniform points in a hypercube, using np[i] points in direction i.
Definition gsPointGrid.hpp:82
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
This file contains the debugging and messaging system of G+Smo.
#define gsDebug
Definition gsDebug.h:61
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define gsWarn
Definition gsDebug.h:50
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of the Field class.
Provides declaration of the gsGeometrySlice class.
Provides declaration of Geometry abstract interface.
Provides a container for gsHBox.
Input and output Utilities.
Provides declaration of the MultiPatch class.
Provides a helper class to write Paraview collection (.pvd) files.
Provides declaration of gsSolid class, a boundary-represented solid.
Provides interface of gsTrimSurface class. Represents a trimmed surface (= spline "master surface" in...
The G+Smo namespace, containing all definitions for the library.
void writeSingleBasisMesh(const gsBasis< T > &basis, std::string const &fn)
Export a parametric mesh.
Definition gsWriteParaview.hpp:218
void writeSingleGeometry(gsFunction< T > const &func, gsMatrix< T > const &supp, std::string const &fn, unsigned npts)
Export a geometry represented by func.
Definition gsWriteParaview.hpp:469
void gsWriteParaviewSolid(gsSolid< T > const &sl, std::string const &fn, unsigned numSamples=NS)
Export a gsSolid to Paraview file.
Definition gsWriteParaview.hpp:1781
void writeSingleHBox(const gsHBox< 2, T > &box, std::string const &fn)
Export a gsHBox.
Definition gsWriteParaview.hpp:1296
void writeSingleCurve(gsFunction< T > const &func, gsMatrix< T > const &supp, std::string const &fn, unsigned npts)
Export a curve geometry represented by func.
Definition gsWriteParaview.hpp:556
void gsWriteParaview_basisFnct(int i, gsBasis< T > const &basis, std::string const &fn, unsigned npts=NS)
Export i-th Basis function to paraview file.
Definition gsWriteParaview.hpp:1011
void writeSingleCompMesh(const gsBasis< T > &basis, const gsGeometry< T > &Geo, std::string const &fn, unsigned resolution=8)
Export a computational mesh.
Definition gsWriteParaview.hpp:232
void makeCollection(std::string const &fn, std::string const &ext, int n=0)
Definition gsParaviewCollection.h:258
void writeSingleBox(const gsMatrix< T > &box, std::string const &fn, T value)
Export an element box.
Definition gsWriteParaview.hpp:1237
void writeSingleControlNet(const gsGeometry< T > &Geo, std::string const &fn)
Export a control net.
Definition gsWriteParaview.hpp:248
void gsWriteParaviewBdr(gsMultiPatch< T > const &patches, std::string const &fn, unsigned npts, bool ctrlNet)
Writes the boundaries of a multipatch to paraview.
Definition gsWriteParaview.hpp:2070
void gsWriteParaviewTrimmedCurve(const gsTrimSurface< T > &surf, const unsigned idLoop, const unsigned idCurve, const std::string fn, unsigned npts=NS)
Export a boundary/hole curve in trimmed surface.
Definition gsWriteParaview.hpp:2108
void gsWriteParaviewPoints(gsMatrix< T > const &X, gsMatrix< T > const &Y, std::string const &fn)
Export 2D Point set to Paraview file.
Definition gsWriteParaview.hpp:1383
void gsWriteParaviewIfc(gsMultiPatch< T > const &patches, std::string const &fn, unsigned npts, bool ctrlNet)
Writes the interfaces of a multipatch to paraview.
Definition gsWriteParaview.hpp:2083
void gsWriteParaviewBezier(const gsMultiPatch< T > &mPatch, std::string const &filename, bool ctrlNet=false)
Export a multipatch Geometry (without scalar information) to paraview file using Bezier elements.
Definition gsWriteParaview.hpp:984