32#define PLOT_PRECISION 12
39void writeSingleBasisMesh3D(
const gsMesh<T> & sl,
40 std::string
const & fn)
42 const unsigned numVer = sl.numVertices();
43 const unsigned numEl = numVer / 8;
46 std::ofstream file(mfn.c_str());
47 if ( ! file.is_open() )
48 gsWarn<<
"writeSingleBasisMesh3D: Problem opening file \""<<fn<<
"\""<<std::endl;
50 file << std::setprecision (PLOT_PRECISION);
52 file <<
"<?xml version=\"1.0\"?>\n";
53 file <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
54 file <<
"<UnstructuredGrid>\n";
57 file <<
"<Piece NumberOfPoints=\""<< numVer <<
"\" NumberOfCells=\""<<numEl<<
"\">\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)
64 const gsVertex<T>& vertex = **it;
65 file << vertex[0] <<
" " << vertex[1] <<
" " << vertex[2] <<
" \n";
68 file <<
"</DataArray>\n";
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)
76 file << (*it)->data <<
" ";
79 file <<
"</DataArray>\n";
80 file <<
"</PointData>\n";
86 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
87 for (
unsigned i = 0; i!= numVer;++i)
92 file <<
"</DataArray>\n";
95 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
96 for (
unsigned i = 1; i<= numEl;++i)
101 file <<
"</DataArray>\n";
104 file <<
"<DataArray type=\"Int32\" Name=\"types\" format=\"ascii\">\n";
105 for (
unsigned i = 1; i<= numEl;++i)
110 file <<
"</DataArray>\n";
113 file <<
"</Piece>\n";
114 file <<
"</UnstructuredGrid>\n";
115 file <<
"</VTKFile>\n";
125void writeSingleBasisMesh2D(
const gsMesh<T> & sl,
126 std::string
const & fn)
128 const unsigned numVer = sl.numVertices();
129 const unsigned numEl = numVer / 4;
132 std::ofstream file(mfn.c_str());
133 if ( ! file.is_open() )
134 gsWarn<<
"writeSingleBasisMesh2D: Problem opening file \""<<fn<<
"\""<<std::endl;
136 file << std::setprecision (PLOT_PRECISION);
138 file <<
"<?xml version=\"1.0\"?>\n";
139 file <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
140 file <<
"<UnstructuredGrid>\n";
143 file <<
"<Piece NumberOfPoints=\""<< numVer <<
"\" NumberOfCells=\""<<numEl<<
"\">\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)
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";
161 file <<
"</DataArray>\n";
162 file <<
"</Points>\n";
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)
169 file << (*it)->data <<
" ";
172 file <<
"</DataArray>\n";
173 file <<
"</PointData>\n";
179 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
180 for (
unsigned i = 0; i!= numVer;++i)
185 file <<
"</DataArray>\n";
188 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
189 for (
unsigned i = 1; i<= numEl;++i)
194 file <<
"</DataArray>\n";
197 file <<
"<DataArray type=\"Int32\" Name=\"types\" format=\"ascii\">\n";
198 for (
unsigned i = 1; i<= numEl;++i)
203 file <<
"</DataArray>\n";
206 file <<
"</Piece>\n";
207 file <<
"</UnstructuredGrid>\n";
208 file <<
"</VTKFile>\n";
219 std::string
const & fn)
222 if ( basis.dim() == 3)
223 writeSingleBasisMesh3D(msh,fn);
224 else if ( basis.dim() == 2)
225 writeSingleBasisMesh2D(msh,fn);
227 gsWriteParaview(msh, fn,
false);
233 std::string
const & fn,
unsigned resolution)
243 gsWriteParaview(msh, fn,
false);
249 std::string
const & fn)
251 const int d = Geo.
parDim();
254 const unsigned n = Geo.
geoDim();
259 for (
size_t i = 0; i!= msh.numVertices(); ++i)
261 msh.vertex(i)[d] = msh.vertex(i)[0];
262 msh.vertex(i).topRows(d) = anch.col(i);
267 gsDebug<<
"Writing 4th coordinate\n";
269 gsWriteParaviewPoints<T>(cp.transpose(), fn );
273 gsWriteParaview(msh, fn,
false);
277void gsWriteParaviewTPgrid(
const gsMatrix<T> & eval_geo ,
278 const gsMatrix<T> & eval_field,
279 const gsVector<index_t> & np,
280 std::string
const & fn)
282 const int n = eval_geo.rows();
284 &&
static_cast<index_t>(np.prod())==eval_geo.cols(),
285 "Data do not match");
289 std::ofstream file(mfn.c_str());
291 file << std::setprecision (PLOT_PRECISION);
293 index_t np1 = (np.size()>1 ? np(1)-1 : 0);
294 index_t np2 = (np.size()>2 ? np(2)-1 : 0);
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 "
300 file <<
"<Piece Extent=\"0 "<< np(0)-1<<
" 0 "<<np1<<
" 0 "
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) <<
" ";
309 for (
index_t j=0; j<eval_field.cols(); ++j)
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)
317 file <<
"</DataArray>\n";
318 file <<
"</PointData>\n";
320 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\">\n";
321 for (
index_t j=0; j<eval_geo.cols(); ++j)
324 file<< eval_geo(i,j) <<
" ";
328 file <<
"</DataArray>\n";
329 file <<
"</Points>\n";
331 file <<
"</StructuredGrid>\n";
332 file <<
"</VTKFile>\n";
338void writeSinglePatchField(
const gsFunction<T> & geometry,
339 const gsFunction<T> & parField,
341 std::string
const & fn,
unsigned npts)
343 const int n = geometry.targetDim();
344 const int d = geometry.domainDim();
346 gsMatrix<T> ab = geometry.support();
347 gsVector<T> a = ab.col(0);
348 gsVector<T> b = ab.col(1);
350 gsVector<unsigned> np = uniformSampleCount(a, b, npts);
353 gsMatrix<T> eval_geo = geometry.eval(pts);
354 gsMatrix<T> eval_field = isParam ? parField.eval(pts) : parField.eval(eval_geo);
358 np.conservativeResize(3);
359 np.bottomRows(3-d).setOnes();
363 gsWarn<<
"Cannot plot 4D data.\n";
369 eval_geo.conservativeResize(3,eval_geo.cols() );
370 eval_geo.bottomRows(3-n).setZero();
374 gsWarn<<
"Data is more than 3 dimensions.\n";
377 if ( eval_field.rows() == 2)
379 eval_field.conservativeResize(3,eval_geo.cols() );
380 eval_field.bottomRows(1).setZero();
383 gsWriteParaviewTPgrid(eval_geo, eval_field, np.template cast<index_t>(), fn);
388void writeSinglePatchField(
const gsField<T> & field,
int patchNr,
389 std::string
const & fn,
unsigned npts)
471 std::string
const & fn,
unsigned npts)
485 np.conservativeResize(3);
486 np.bottomRows(3-d).setOnes();
491 eval_func.conservativeResize(3,eval_func.cols() );
492 eval_func.bottomRows(3-n).setZero();
499 eval_func.conservativeResize(4,eval_func.cols() );
503 eval_func.row(d) = eval_func.row(0);
504 eval_func.topRows(d) = pts;
510 std::ofstream file(mfn.c_str());
511 if ( ! file.is_open() )
512 gsWarn<<
"writeSingleGeometry: Problem opening file \""<<fn<<
"\""<<std::endl;
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";
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";
542 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\">\n";
543 for (
index_t j=0; j<eval_func.cols(); ++j)
545 file<< eval_func(i,j) <<
" ";
546 file <<
"</DataArray>\n";
547 file <<
"</Points>\n";
549 file <<
"</StructuredGrid>\n";
550 file <<
"</VTKFile>\n";
558 std::string
const & fn,
unsigned npts)
571 np.conservativeResize(3);
572 np.bottomRows(2).setOnes();
576 eval_func.conservativeResize(3,eval_func.cols() );
577 eval_func.bottomRows(3-n).setZero();
582 eval_func.row(d) = eval_func.row(0);
583 eval_func.topRows(d) = pts;
589 std::ofstream file(mfn.c_str());
590 if ( ! file.is_open() )
591 gsWarn<<
"writeSingleCurve: Problem opening file \""<<fn<<
"\""<<std::endl;
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";
598 file <<
"<Piece NumberOfPoints=\""<< npts
599 <<
"\" NumberOfVerts=\"0\" NumberOfLines=\""<< npts-1
600 <<
"\" NumberOfStrips=\"0\" NumberOfPolys=\"0\">\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";
610 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<npts-1<<
"\">\n";
611 for (
unsigned i=0; i< npts-1; ++i )
613 file << i <<
" " << i+1 <<
" ";
616 file <<
"\n</DataArray>\n";
618 file <<
"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\" RangeMin=\"0\" RangeMax=\""<<npts-1<<
"\">\n";
619 for (
unsigned i=0; i< npts-1; ++i )
622 file << offset <<
" ";
624 file <<
"\n</DataArray>\n";
628 file <<
"</PolyData>\n";
629 file <<
"</VTKFile>\n";
634void writeSingleCurve(
const gsGeometry<T> & Geo, std::string
const & fn,
unsigned npts)
636 gsMatrix<T> ab = Geo.parameterRange();
649 gsMatrix<T> ab = Geo.parameterRange();
654void writeSingleTrimSurface(
const gsTrimSurface<T> & surf,
655 std::string
const & fn,
658 typename gsMesh<T>::uPtr msh = surf.toMesh(npts);
659 gsWriteParaview( *msh, fn);
665 std::string
const & fn,
666 unsigned npts,
bool mesh,
667 const std::string pDelim)
677 const unsigned n = field.
nPieces();
679 std::string fileName, fileName_nopath;
681 for (
unsigned i=0; i < n; ++i )
688 writeSinglePatchField( field, i, fileName, npts );
689 collection.
addPart(fileName_nopath +
".vts");
696 collection.
addPart(fileName_nopath +
".vtp");
707 std::string
const & fn,
708 unsigned npts,
const std::string pDelim)
720 const unsigned n = geo.
nPieces();
722 std::string fileName, fileName_nopath;
724 for (
unsigned i=0; i < n; ++i )
728 writeSinglePatchField( geo.
function(i), func.
function(i),
true, fileName, npts );
729 collection.
addPart(fileName_nopath +
".vts");
736void gsWriteParaview(gsMappedSpline<2,T>
const& mspline,
737 std::string
const & fn,
741 std::string fileName, fileName_nopath;
742 for (
index_t p=0; p < mspline.nPieces(); ++p )
748 collection.
addPart(fileName_nopath +
".vts",-1,
"",p);
756 gsMappedBasis<2,T>
const& mbasis,
757 std::string
const & fn,
759 const bool fullsupport,
760 const std::vector<index_t> indices)
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());
770 std::vector<index_t> plotIndices;
771 if (indices.size()==0)
773 plotIndices.resize(mbasis.globalSize());
774 std::generate(plotIndices.begin(), plotIndices.end(), [n = 0] ()
mutable { return n++; });
777 plotIndices = indices;
780 std::string fileName, fileName_nopath;
789 ab = geom.
piece(p).support();
793 if (a.prod() == 0 && b.prod()==0)
796 np = uniformSampleCount(a, b, npts);
802 for (std::vector<index_t>::const_iterator i = plotIndices.begin(); i!=plotIndices.end(); i++)
807 ab = mbasis.piece(p).support(*i);
811 if (a.prod() == 0 && b.prod()==0)
814 np = uniformSampleCount(a, b, npts);
823 eval_basis = mbasis.piece(p).evalSingle(*i,pts);
824 gsWriteParaviewTPgrid(eval_geo, eval_basis, np.template cast<index_t>(), fileName);
826 collection.
addPart(fileName_nopath +
".vts",*i,
"",p);
845 unsigned npts,
bool mesh,
bool ctrlNet)
847 const bool curve = ( Geo.
domainDim() == 1 );
854 collection.
addPart(fn_nopath +
".vtp");
859 collection.
addPart(fn_nopath +
".vts");
864 const std::string fileName = fn +
"_mesh";
872 const T evalPtsPerElem = npts * (1.0 / Geo.
basis().numElements());
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())) );
887 collection.
addPart(fileName_nopath +
".vtp");
892 const std::string fileName = fn +
"_cnet";
895 collection.
addPart(fileName_nopath +
".vtp");
905 std::string
const & fn,
unsigned npts)
911 for (
size_t i = 0; i != domain.
nPatches(); ++i)
916 collection.
addPart(fileName_nopath +
".vtp");
926 std::string
const & fn,
939 std::string
const & fn,
940 unsigned npts,
bool mesh,
bool ctrlNet,
const std::string pDelim)
942 const size_t n = Geo.size();
945 std::string fnBase, fnBase_nopath;
947 for (
size_t i=0; i<n ; i++)
952 if ( Geo.at(i)->domainDim() == 1 )
955 collection.
addPart(fnBase_nopath +
".vtp");
960 collection.
addPart(fnBase_nopath +
".vts");
965 const std::string fileName = fnBase +
"_mesh";
968 collection.
addPart(fileName_nopath +
".vtp");
973 const std::string fileName = fnBase +
"_cnet";
976 collection.
addPart(fileName_nopath +
".vtp");
989 std::ofstream file(filename +
".vtu");
990 file << BezierVTK(mPatch);
997 for (
size_t patch=0; patch<mPatch.
nPatches();++patch)
999 const std::string fileName = filename +
"_" +
util::to_string(patch) +
"_cnet";
1003 collection.
addPart(fileName_nopath +
".vtp");
1024 gsMatrix<T> eval_geo = basis.evalSingle ( i, pts ) ;
1027 np.conservativeResize(3);
1028 np.bottomRows(3-d).setOnes();
1033 pts.conservativeResize(2,eval_geo.cols());
1034 pts.bottomRows(2-d).setZero();
1041 pts.conservativeResize(2,eval_geo.cols());
1046 eval_geo.conservativeResize(3,eval_geo.cols() );
1047 eval_geo.bottomRows(3-n).setZero();
1050 std::string mfn(fn);
1052 std::ofstream file(mfn.c_str());
1053 if ( ! file.is_open() )
1054 gsWarn<<
"gsWriteParaview_basisFnct: Problem opening file \""<<fn<<
"\""<<std::endl;
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";
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";
1069 file <<
"<Points>\n";
1070 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\""<<3<<
"\">\n";
1071 for (
index_t j=0; j<eval_geo.cols(); ++j)
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) <<
" ";
1079 file <<
"</DataArray>\n";
1080 file <<
"</Points>\n";
1081 file <<
"</Piece>\n";
1082 file <<
"</StructuredGrid>\n";
1083 file <<
"</VTKFile>\n";
1099 gsWriteParaview(func.
function(i), func.
function(i).support(), fileName, npts,
false);
1100 collection.
addPart(fileName_nopath +
".vts");
1123 np.conservativeResize(3);
1124 np.bottomRows(3-d).setOnes();
1127 std::string mfn(fn);
1129 std::ofstream file(mfn.c_str());
1130 if ( ! file.is_open() )
1131 gsWarn<<
"gsWriteParaview: Problem opening file \""<<fn<<
"\""<<std::endl;
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";
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";
1146 file <<
"<Points>\n";
1147 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\""<<3<<
"\">\n";
1150 for (
index_t j=0; j<ev.cols(); ++j)
1152 for (
int i=0; i< d; ++i)
1153 file<< pts(i,j) <<
" ";
1154 file<< ev(0,j) <<
" ";
1159 for (
index_t j=0; j<ev.cols(); ++j)
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)
1167 file <<
"</DataArray>\n";
1168 file <<
"</Points>\n";
1169 file <<
"</Piece>\n";
1170 file <<
"</StructuredGrid>\n";
1171 file <<
"</VTKFile>\n";
1178void gsWriteParaview(
gsBasis<T> const& basis, std::string
const & fn,
1179 unsigned npts,
bool mesh)
1181 const index_t n = basis.size();
1188 gsWriteParaview_basisFnct<T>(i, basis, fileName, npts ) ;
1189 collection.
addPart(fileName_nopath +
".vts");
1194 std::string fileName = fn +
"_mesh";
1198 collection.
addPart(fileName_nopath +
".vtu");
1207 const std::vector<index_t> & indices,
1208 std::string
const & fn,
1209 unsigned npts,
bool mesh)
1213 for (
typename std::vector<index_t>::const_iterator idx = indices.cbegin();
1214 idx != indices.cend();
1219 gsWriteParaview_basisFnct<T>(*idx, basis, fileName, npts ) ;
1220 collection.
addPart(fileName_nopath +
".vts");
1225 std::string fileName = fn +
"_mesh";
1229 collection.
addPart(fileName_nopath +
".vtu");
1242 points = gsPointGrid<T>(box.col(0),box.col(1),np);
1249 values.setConstant(value);
1250 gsWriteParaviewTPgrid(points,values,np2,fn);
1255void gsWriteParaview(
const gsMatrix<T> & boxes, std::string
const & fn, T value)
1259 std::string fileName;
1260 for (
index_t k=0; k!=boxes.cols()/2; k++)
1266 collection.
addPart(fileName +
".vts");
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++)
1287 collection.
addPart(fileName +
".vts");
1303 values.row(0).setConstant(box.
level());
1304 values.row(1).setConstant(box.
error());
1306 gsWriteParaviewTPgrid(points,values,np,fn);
1316 collection.
addPart(fn +
".vts");
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++)
1334 writeSingleHBox<T>(*Cit,fileName);
1336 collection.
addPart(fileName +
".vts",-1,
"",i);
1346 std::string
const & fn,
unsigned npts)
1348 GISMO_ENSURE(mp.nPatches()==mb.nBases(),
"Number of bases and patches do not correspond");
1356 for (
size_t p=0; p!=mp.nPatches(); p++)
1357 for (
index_t i=0; i< mb.basis(p).size(); i++, k++)
1360 ab = mb.basis(p).support(i);
1367 eval_geo = mp.patch(p).eval(pts);
1372 eval_basis = mb.basis(p).evalSingle(i,pts);
1373 gsWriteParaviewTPgrid(eval_geo, eval_basis, np.template cast<index_t>(), fileName);
1376 collection.
addPart(fileName_nopath +
".vts",k);
1385 assert( X.cols() == Y.cols() );
1386 assert( X.rows() == 1 && Y.rows() == 1 );
1389 std::string mfn(fn);
1391 std::ofstream file(mfn.c_str());
1392 if ( ! file.is_open() )
1393 gsWarn<<
"gsWriteParaviewPoints: Problem opening file \""<<fn<<
"\""<<std::endl;
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";
1411 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<
"\" RangeMax=\""<<np-1<<
"\">\n";
1412 for (
index_t i=0; i< np; ++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";
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";
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";
1448 std::string
const & fn)
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!");
1456 std::string mfn(fn);
1458 std::ofstream file(mfn.c_str());
1460 if (!file.is_open())
1462 gsWarn <<
"Problem opening " << fn <<
" Aborting..." << std::endl;
1467 file << std::setprecision (PLOT_PRECISION);
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";
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";
1480 for (
index_t i = 0; i < np; ++i)
1482 file << X(0, i) <<
" " << Y(0, i) <<
" " << Z(0, i) <<
"\n";
1485 file <<
"\n</DataArray>\n";
1486 file <<
"</Points>\n";
1488 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<
"\" RangeMax=\""<<np-1<<
"\">\n";
1490 for (
index_t i=0; i< np; ++i )
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";
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";
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";
1530 std::string
const & fn)
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!");
1538 std::string mfn(fn);
1540 std::ofstream file(mfn.c_str());
1542 if (!file.is_open())
1544 gsWarn <<
"Problem opening " << fn <<
" Aborting..." << std::endl;
1549 file << std::setprecision (PLOT_PRECISION);
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";
1556 file <<
"<PointData "<<
"Scalars=\"PointInfo\">\n";
1557 file <<
"<DataArray type=\"Float32\" Name=\"PointInfo\" format=\"ascii\" NumberOfComponents=\"1\">\n";
1559 file<< V(0,j) <<
" ";
1560 file <<
"</DataArray>\n";
1561 file <<
"</PointData>\n";
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";
1568 for (
index_t i = 0; i < np; ++i)
1570 file << X(0, i) <<
" " << Y(0, i) <<
" " << Z(0, i) <<
"\n";
1573 file <<
"\n</DataArray>\n";
1574 file <<
"</Points>\n";
1576 file <<
"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\" RangeMin=\""<<0<<
"\" RangeMax=\""<<np-1<<
"\">\n";
1578 for (
index_t i=0; i< np; ++i )
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";
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";
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";
1616 const index_t rows = points.rows();
1620 gsWriteParaviewPoints<T>(points.row(0),
gsMatrix<T>::Zero(1, points.cols()), fn);
1623 gsWriteParaviewPoints<T>(points.row(0), points.row(1), fn);
1626 gsWriteParaviewPoints<T>(points.row(0), points.row(1), points.row(2), fn);
1629 gsWriteParaviewPoints<T>(points.row(0), points.row(1), points.row(2), points.row(3), fn);
1632 GISMO_ERROR(
"Point plotting is implemented just for 2D and 3D (rows== 1, 2 or 3).");
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)
1645 int color=color_convex;
1647 gsSolidHalfFace<T>* face;
1649 int numOfPoints = numPoints_for_eachCurve;
1651 T faceThick = edgeThick;
1656 std::string mfn(fn);
1658 std::ofstream file(mfn.c_str());
1659 if ( ! file.is_open() )
1660 gsWarn<<
"gsWriteParaview: Problem opening file \""<<fn<<
"\""<<std::endl;
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";
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++)
1676 source = sl.vertex[eloop[iedge]];
1677 target = sl.vertex[eloop[(iedge+1)%numOfCurves]];
1678 he = source->getHalfEdge(target);
1679 heSet.push_back(he);
1685 for (
int iface=0;iface!= sl.nHalfFaces();iface++)
1687 face = sl.getHalfFaceFromID(iface);
1690 if (face->vol->getId()==vol_Num)
1692 numOfCurves=face->nCurvesOfOneLoop(0);
1695 for (
int iedge=0; iedge!= numOfCurves; iedge++)
1697 he = face->getHalfEdgeFromBoundaryOrder(iedge);
1699 bool isMember(
false);
1700 for (
size_t iheSet=0;iheSet<heSet.size();iheSet++)
1702 if ( he->isEquiv(heSet.at(iheSet))==
true || he->mate->isEquiv(heSet.at(iheSet))==
true)
1706 gsMatrix<T> curvePoints = face->surf->sampleBoundaryCurve(iedge, numPoints_for_eachCurve);
1707 if (iedge==0) assert( numOfPoints == curvePoints.cols());
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";
1716 file <<
"<Points>\n";
1717 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
1719 for (
index_t iCol = 0;iCol!=curvePoints.cols();iCol++)
1721 file << curvePoints(0,iCol) + translate(0) <<
" " << curvePoints(1,iCol) + translate(1) <<
" " << curvePoints(2,iCol) + translate(2) <<
" \n";
1723 file << curvePoints(0,iCol) + faceThick + translate(0) <<
" " << curvePoints(1,iCol) + faceThick + translate(1)
1724 <<
" " << curvePoints(2,iCol) +faceThick + translate(2) <<
" \n";
1727 file <<
"</DataArray>\n";
1728 file <<
"</Points>\n";
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++)
1736 file << color <<
" ";
1739 file <<
"</DataArray>\n";
1740 file <<
"</CellData>\n";
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++)
1748 file << 2*iCol <<
" " << 2*iCol+1 <<
" "<< 2*iCol+3 <<
" " << 2*iCol+2 <<
" ";
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++)
1758 file << offsets <<
" ";
1761 file <<
"</DataArray>\n";
1762 file <<
"</Polys>\n";
1764 file <<
"</Piece>\n";
1773 file <<
"</PolyData>\n";
1774 file <<
"</VTKFile>\n";
1782 std::string
const & fn,
1783 unsigned numSamples)
1785 const size_t n = sl.numHalfFaces;
1791 for (
size_t i=0; i<n ; i++)
1795 writeSingleTrimSurface(*sl.face[i]->surf, fnBase, numSamples);
1796 collection.
addPart(fnBase_nopath +
".vtp");
1806void gsWriteParaview(
gsMesh<T> const& sl, std::string
const & fn,
bool pvd)
1808 std::string mfn(fn);
1810 std::ofstream file(mfn.c_str());
1811 if ( ! file.is_open() )
1812 gsWarn<<
"gsWriteParaview: Problem opening file \""<<fn<<
"\""<<std::endl;
1814 file << std::setprecision (PLOT_PRECISION);
1816 file <<
"<?xml version=\"1.0\"?>\n";
1817 file <<
"<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
1818 file <<
"<PolyData>\n";
1821 file <<
"<Piece NumberOfPoints=\""<< sl.numVertices() <<
"\" NumberOfVerts=\"0\" NumberOfLines=\""
1822 << sl.numEdges()<<
"\" NumberOfStrips=\"0\" NumberOfPolys=\""<< sl.numFaces() <<
"\">\n";
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)
1830 file << vertex[0] <<
" ";
1831 file << vertex[1] <<
" ";
1832 file << vertex[2] <<
" \n";
1836 file <<
"</DataArray>\n";
1837 file <<
"</Points>\n";
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)
1857 file << it->source->getId() <<
" " << it->target->getId() <<
"\n";
1859 file <<
"</DataArray>\n";
1860 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
1862 for (
typename std::vector< gsEdge<T> >::const_iterator it=sl.edges().begin();
1863 it!=sl.edges().end(); ++it)
1866 file << count <<
" ";
1869 file <<
"</DataArray>\n";
1870 file <<
"</Lines>\n";
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)
1890 for (
typename std::vector<
gsVertex<T>* >::const_iterator vit= (*it)->vertices.begin();
1891 vit!=(*it)->vertices.end(); ++vit)
1893 file << (*vit)->getId() <<
" ";
1897 file <<
"</DataArray>\n";
1898 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
1900 for (
typename std::vector< gsFace<T>* >::const_iterator it=sl.faces().begin();
1901 it!=sl.faces().end(); ++it)
1903 count += (*it)->vertices.size();
1904 file << count <<
" ";
1907 file <<
"</DataArray>\n";
1908 file <<
"</Polys>\n";
1910 file <<
"</Piece>\n";
1911 file <<
"</PolyData>\n";
1912 file <<
"</VTKFile>\n";
1923 "Incorrect number of data: "<< params.cols() <<
" != "<< sl.numVertices() );
1925 std::string mfn(fn);
1927 std::ofstream file(mfn.c_str());
1928 if ( ! file.is_open() )
1929 gsWarn<<
"gsWriteParaview: Problem opening file \""<<fn<<
"\""<<std::endl;
1931 file << std::setprecision (PLOT_PRECISION);
1933 file <<
"# vtk DataFile Version 4.2\n";
1934 file <<
"vtk output\n";
1936 file <<
"DATASET POLYDATA\n";
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)
1943 file << vertex[0] <<
" ";
1944 file << vertex[1] <<
" ";
1945 file << vertex[2] <<
" \n";
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)
1955 file << (*it)->vertices.size() <<
" ";
1956 for (
typename std::vector<
gsVertex<T>* >::const_iterator vit=
1957 (*it)->vertices.begin(); vit!=(*it)->vertices.end(); ++vit)
1959 file << (*vit)->getId() <<
" ";
1966 file <<
"POINT_DATA " << sl.numVertices() << std::endl;
1968 if ( 3 == params.rows() )
1969 file <<
"VECTORS Data float\n";
1971 file <<
"SCALARS Data float "<<params.rows()<<
"\nLOOKUP_TABLE default\n";
1973 for(
index_t j=0; j<params.cols(); j++)
1975 for(
index_t i=0; i<params.rows(); i++)
1976 file << params(i,j) <<
" ";
1983template <
typename T>
1985 const std::string& fn)
1987 for (
unsigned index = 0; index < meshes.size(); index++)
1990 gsWriteParaview(meshes[index], file,
false);
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)) );
2002 gsWriteParaview( all_curves, fn, npts);
2007 unsigned npts,
bool trimCurves)
2011 writeSingleTrimSurface(surf, fn, npts);
2013 collection.
addPart(fn_nopath +
".vtp");
2017 gsWarn<<
"trimCurves: To do.\n";
2025void gsWriteParaview(
const gsVolumeBlock<T>& volBlock,
2026 std::string
const & fn,
2034 for (
unsigned idFace = 0; idFace != volBlock.face.size(); idFace++)
2036 typename gsVolumeBlock<T>::HalfFace* face = volBlock.face[idFace];
2040 unsigned numLoops =
static_cast<unsigned>(domain.numLoops());
2041 for (
unsigned idLoop = 0; idLoop < numLoops; idLoop++)
2045 unsigned clSize =
static_cast<unsigned>(curveLoop.size());
2048 for (
unsigned idCurve = 0; idCurve < clSize; idCurve++)
2051 std::string fileName = fn +
"_curve_F";
2053 fileName += to_string(idFace) +
"_L" +
2054 to_string(idLoop) +
"_C" +
2060 collection.
addPart(fileName_nopath +
".vts");
2071 std::string
const & fn,
2072 unsigned npts,
bool ctrlNet)
2074 typename gsMultiPatch<T>::BoundaryRep
const & brep = patches.boundaryRep();
2075 GISMO_ENSURE(brep.
size()!=0,
"Boundary representation is empty. Call gsMultiPatch::constructBoundaryRep first!");
2077 for (
auto it = brep.
begin(); it!=brep.
end(); ++it)
2079 gsWriteParaview<T>(bnd_net,fn,npts,
false,ctrlNet);
2084 std::string
const & fn,
2085 unsigned npts,
bool ctrlNet)
2088 typename gsMultiPatch<T>::InterfaceRep
const & irep = patches.interfaceRep();
2089 GISMO_ENSURE(irep.
size()!=0,
"Interface representation is empty. Call gsMultiPatch::constructInterfaceRep first!");
2091 for (
auto it = irep.
begin(); it!=irep.
end(); ++it)
2093 gsWriteParaview<T>(iface_net,fn,npts,
false,ctrlNet);
2098 typename gsBoundaryConditions<T>::bcContainer
const & bcs,
2099 std::string
const & fn,
unsigned npts,
bool ctrlNet)
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);
2109 const unsigned idLoop,
2110 const unsigned idCurve,
2111 const std::string fn,
2116 int idL =
static_cast<int>(idLoop);
2117 int idC =
static_cast<int>(idCurve);
2131 np.conservativeResize(3);
2132 np.bottomRows(3 - 1).setOnes();
2137 std::string myFile(fn);
2138 myFile.append(
".vts");
2140 std::ofstream file(myFile.c_str());
2141 if (!file.is_open())
2143 gsWarn <<
"Problem opening " << fn <<
" Aborting..." << std::endl;
2148 file << std::setprecision (PLOT_PRECISION);
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";
2155 file <<
"<Piece Extent=\"0 " << np(0) - 1 <<
" 0 " << np(1) - 1 <<
" 0 "
2156 << np(2) - 1 <<
"\">\n";
2158 file <<
"<Points>\n";
2159 file <<
"<DataArray type=\"Float32\" NumberOfComponents=\"" << points.rows()
2162 for (
index_t j = 0; j < points.cols(); ++j)
2164 for (
index_t i = 0; i < points.rows(); ++i)
2166 file << points(i, j) <<
" ";
2171 file <<
"</DataArray>\n";
2172 file <<
"</Points>\n";
2173 file <<
"</Piece>\n";
2174 file <<
"</StructuredGrid>\n";
2175 file <<
"</VTKFile>\n";
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