34 #include <vtkAppendFilter.h> 35 #include <vtkCellData.h> 36 #include <vtkCellIterator.h> 37 #include <vtkCellTypes.h> 38 #include <vtkDataSetReader.h> 39 #include <vtkDataSetSurfaceFilter.h> 40 #include <vtkDoubleArray.h> 41 #include <vtkExtractEdges.h> 42 #include <vtkFieldData.h> 43 #include <vtkGenericCell.h> 44 #include <vtkGenericDataObjectReader.h> 45 #include <vtkImageData.h> 46 #include <vtkPointData.h> 47 #include <vtkRectilinearGrid.h> 48 #include <vtkSTLReader.h> 49 #include <vtkSTLWriter.h> 50 #include <vtkStructuredGrid.h> 51 #include <vtkTriangleFilter.h> 52 #include <vtkUnstructuredGridWriter.h> 53 #include <vtkXMLImageDataReader.h> 54 #include <vtkXMLImageDataWriter.h> 55 #include <vtkXMLPolyDataReader.h> 56 #include <vtkXMLPolyDataWriter.h> 57 #include <vtkXMLRectilinearGridReader.h> 58 #include <vtkXMLRectilinearGridWriter.h> 59 #include <vtkXMLStructuredGridReader.h> 60 #include <vtkXMLStructuredGridWriter.h> 61 #include <vtkXMLUnstructuredGridReader.h> 62 #include <vtkXMLUnstructuredGridWriter.h> 63 #include <vtkXMLWriter.h> 64 #include <vtksys/SystemTools.hxx> 68 using nemAux::operator*;
69 using nemAux::operator+;
73 std::cout <<
"No dataSet to write!" << std::endl;
79 if (extension ==
".vtp")
80 writeVTFile<vtkXMLPolyDataWriter>(fname,
dataSet);
81 else if (extension ==
".vts")
82 writeVTFile<vtkXMLStructuredGridWriter>(fname,
dataSet);
83 else if (extension ==
".vtr")
84 writeVTFile<vtkXMLRectilinearGridWriter>(fname,
dataSet);
85 else if (extension ==
".vti")
86 writeVTFile<vtkXMLImageDataWriter>(fname,
dataSet);
87 else if (extension ==
".stl")
88 writeVTFile<vtkSTLWriter>(fname,
dataSet);
89 else if (extension ==
".vtk")
90 writeVTFile<vtkUnstructuredGridWriter>(fname,
95 writeVTFile<vtkXMLUnstructuredGridWriter>(fname_tmp,
dataSet);
100 const std::string &fname) {
106 std::cout <<
"vtkMesh constructed" << std::endl;
108 std::cerr <<
"Nothing to copy!" << std::endl;
114 const std::vector<double> &yCrds,
115 const std::vector<double> &zCrds,
116 const std::vector<nemId_t> &elemConn,
const int cellType,
117 const std::string &newname) {
118 if (!(xCrds.size() == yCrds.size() && xCrds.size() == zCrds.size())) {
119 std::cerr <<
"Length of coordinate arrays must match!" << std::endl;
126 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp =
132 points->SetPoint(i, xCrds[i], yCrds[i], zCrds[i]);
135 dataSet_tmp->SetPoints(points);
142 elmConn->SetNumberOfIds(4);
143 for (
nemId_t j = 0; j < 4; ++j) elmConn->SetId(j, elemConn[i * 4 + j]);
144 dataSet_tmp->InsertNextCell(VTK_TETRA, elmConn);
153 elmConn->SetNumberOfIds(3);
154 for (
nemId_t j = 0; j < 3; ++j) elmConn->SetId(j, elemConn[i * 3 + j]);
155 dataSet_tmp->InsertNextCell(VTK_TRIANGLE, elmConn);
160 std::cout <<
"Unknown element type " << cellType << std::endl;
166 std::cout <<
"vtkMesh constructed" << std::endl;
170 bool degenerate(
false);
171 std::string extension = vtksys::SystemTools::GetFilenameLastExtension(fname);
173 if (extension ==
".vtu")
175 ReadAnXMLOrSTLFile<vtkXMLUnstructuredGridReader>(fname));
176 else if (extension ==
".vtp")
177 dataSet.TakeReference(ReadAnXMLOrSTLFile<vtkXMLPolyDataReader>(fname));
178 else if (extension ==
".vts")
180 ReadAnXMLOrSTLFile<vtkXMLStructuredGridReader>(fname));
181 else if (extension ==
".vtr")
183 ReadAnXMLOrSTLFile<vtkXMLRectilinearGridReader>(fname));
184 else if (extension ==
".vti")
185 dataSet.TakeReference(ReadAnXMLOrSTLFile<vtkXMLImageDataReader>(fname));
186 else if (extension ==
".stl")
187 dataSet.TakeReference(ReadAnXMLOrSTLFile<vtkSTLReader>(fname));
188 else if (extension ==
".vtk") {
193 std::ifstream meshStream(fname);
194 if (!meshStream.good()) {
195 std::cout <<
"Error opening file " << fname << std::endl;
199 getline(meshStream, line);
200 getline(meshStream, line);
202 if (line.find(
"MFEM") != std::string::npos) {
212 vtkMesh_tmp,
this,
"Consistent Interpolation");
214 std::cout <<
"vtkMesh constructed" << std::endl;
217 vtkSmartPointer<vtkGenericDataObjectReader> reader =
221 reader->SetFileName(fname.c_str());
223 reader->GetOutput()->Register(reader);
225 dataSet.TakeReference(vtkDataSet::SafeDownCast(reader->GetOutput()));
228 std::cerr <<
"Unknown extension: " << extension << std::endl;
233 std::cout <<
"Error populating dataSet" << std::endl;
239 std::cout <<
"vtkMesh constructed" << std::endl;
246 std::string ext_in = vtksys::SystemTools::GetFilenameLastExtension(fname1);
247 std::string ext_out = vtksys::SystemTools::GetFilenameLastExtension(fname2);
250 if (!(ext_in ==
".vtu" && ext_out ==
".stl")) {
252 <<
"vtkMesh: Currently only support conversion between vtu and stl." 257 vtkSmartPointer<vtkXMLUnstructuredGridReader> reader =
259 reader->SetFileName(fname1.c_str());
261 reader->GetOutput()->Register(reader);
264 dataSet.TakeReference(vtkDataSet::SafeDownCast(reader->GetOutput()));
266 std::cout <<
"Error populating dataSet" << std::endl;
270 std::cout <<
"vtkMesh constructed" << std::endl;
275 vtkSmartPointer<vtkDataSetSurfaceFilter> surfFilt =
277 surfFilt->SetInputConnection(reader->GetOutputPort());
281 vtkSmartPointer<vtkTriangleFilter> triFilt =
283 triFilt->SetInputConnection(surfFilt->GetOutputPort());
287 vtkSmartPointer<vtkSTLWriter> stlWriter =
289 stlWriter->SetFileName(fname2.c_str());
290 stlWriter->SetInputConnection(triFilt->GetOutputPort());
295 if (line.find(
"DATASET") != -1) {
296 if (line.find(
"UNSTRUCTURED_GRID") == std::string::npos) {
297 std::cerr <<
"Reading a " << line <<
" is not supported" << std::endl;
306 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp) {
307 if (line.find(
"FIELD") != std::string::npos) {
308 if (getline(meshStream, line)) {
309 std::string arrname, type;
312 std::stringstream ss;
314 ss >> arrname >> numComponent >> numTuple >> type;
315 vtkSmartPointer<vtkDoubleArray> arr =
317 arr->SetName(arrname.c_str());
318 arr->SetNumberOfComponents(numComponent);
319 arr->SetNumberOfTuples(numTuple);
320 getline(meshStream, line);
323 for (
int i = 0; i < numTuple; ++i) {
325 arr->InsertTuple(i, &val);
327 dataSet_tmp->GetFieldData()->AddArray(arr);
336 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp) {
337 if (line.find(
"POINTS") != std::string::npos) {
338 std::istringstream ss(line);
341 points->SetNumberOfPoints(numPoints);
344 while (getline(meshStream, line) && i < numPoints) {
346 std::istringstream ss(line);
347 ss >> point[0] >> point[1] >> point[2];
348 points->SetPoint(i, point);
352 dataSet_tmp->SetPoints(points);
360 std::vector<vtkSmartPointer<vtkIdList>> &vtkCellIds,
361 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp) {
362 if (line.find(
"CELLS") != std::string::npos) {
363 std::istringstream ss(line);
366 vtkCellIds.resize(numCells);
369 while (i < numCells && getline(meshStream, line)) {
371 std::istringstream ss(line);
376 vtkCellIds[i]->SetNumberOfIds(numId);
377 for (
nemId_t j = 0; j < numId; ++j) {
379 vtkCellIds[i]->SetId(j,
id);
385 while (getline(meshStream, line)) {
386 if (line.find(
"CELL_TYPES") != std::string::npos) {
387 dataSet_tmp->Allocate(numCells);
389 while (i < numCells && getline(meshStream, line)) {
391 std::istringstream ss(line);
394 dataSet_tmp->InsertNextCell(cellType, vtkCellIds[i]);
407 const nemId_t numTuple,
const bool pointOrCell,
408 bool &hasPointOrCell,
409 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp) {
411 bool inProgress(
true);
415 std::string line, attribute, name, type;
416 vtkSmartPointer<vtkDoubleArray> arr =
418 while (getline(meshStream, line)) {
420 if (line.find(
"LOOKUP_TABLE default") != std::string::npos)
break;
422 size_t hasScalar = line.find(
"SCALARS");
423 size_t hasVector = line.find(
"VECTORS");
424 size_t hasNormal = line.find(
"NORMALS");
425 if (hasScalar == std::string::npos && hasVector == std::string::npos &&
426 hasNormal == std::string::npos) {
427 std::cerr <<
"attribute type in " << line <<
" not supported" 431 std::istringstream ss(line);
432 ss >> attribute >> name >> type >> numComponent;
433 if (hasScalar != std::string::npos)
435 numComponent > 4 || numComponent < 1 ? 1 : numComponent;
436 else if (hasVector != std::string::npos ||
437 hasNormal != std::string::npos)
439 arr->SetName(name.c_str());
440 arr->SetNumberOfComponents(numComponent);
441 arr->SetNumberOfTuples(numTuple);
450 while (i < numTuple && getline(meshStream, line)) {
451 if (!line.empty() && line.find(
"LOOKUP") == std::string::npos) {
452 std::istringstream ss(line);
454 std::vector<double> vals;
455 vals.resize(numComponent, 0.);
457 for (
int j = 0; j < numComponent; ++j) ss >> vals[j];
458 arr->InsertTuple(i, vals.data());
464 dataSet_tmp->GetPointData()->AddArray(arr);
466 dataSet_tmp->GetCellData()->AddArray(arr);
468 bool moreData(
false);
469 std::streampos curr = meshStream.tellg();
470 while (getline(meshStream, line)) {
473 if (line.find(
"POINT_DATA") != std::string::npos && !pointOrCell) {
474 curr = meshStream.tellg();
475 hasPointOrCell =
true;
480 if (line.find(
"CELL_DATA") != std::string::npos && pointOrCell) {
481 hasPointOrCell =
true;
482 curr = meshStream.tellg();
487 if (line.find(
"SCALARS") != std::string::npos ||
488 line.find(
"VECTORS") != std::string::npos ||
489 line.find(
"NORMALS") != std::string::npos) {
495 meshStream.seekg(curr);
497 if (!moreData) inProgress =
false;
503 const std::string &fileName) {
504 std::ifstream meshStream;
505 meshStream.open(fileName, std::ifstream::in);
506 if (!meshStream.good()) {
507 std::cerr <<
"Could not open file " << fileName << std::endl;
514 std::vector<vtkSmartPointer<vtkIdList>> vtkCellIds;
516 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp =
519 bool readHeader(
false), readPoints(
false), readCells(
false),
520 readFieldData(
false), readCellData(
false), readPointData(
false),
521 cellDataFirst(
false), pointDataFirst(
false), hasPointData(
false),
525 while (getline(meshStream, line)) {
528 std::cout <<
"read header" << std::endl;
533 std::cout <<
"read field data" << std::endl;
538 std::cout <<
"read points" << std::endl;
542 vtkCellIds, dataSet_tmp)))
543 std::cout <<
"read cells" << std::endl;
546 if (!readCellData && !readPointData) {
548 line.find(
"CELL_DATA") != std::string::npos && !pointDataFirst;
550 line.find(
"POINT_DATA") != std::string::npos && !cellDataFirst;
557 hasPointData, dataSet_tmp)))
558 std::cout <<
"read cell data" << std::endl;
560 if (!readPointData && hasPointData)
562 true, hasCellData, dataSet_tmp)))
563 std::cout <<
"read point data" << std::endl;
566 else if (pointDataFirst) {
569 true, hasCellData, dataSet_tmp)))
570 std::cout <<
"read point data" << std::endl;
572 if (!readCellData && hasCellData)
574 hasPointData, dataSet_tmp)))
575 std::cout <<
"read cell data" << std::endl;
582 const std::string &fileName) {
583 std::ifstream meshStream(fileName);
584 if (!meshStream.good()) {
585 std::cerr <<
"Error opening file " << fileName << std::endl;
590 std::map<std::vector<double>,
int> point_map;
591 std::map<int, int> duplicate_point_map;
592 std::pair<std::map<std::vector<double>,
int>::iterator,
bool> point_ret;
596 std::vector<vtkSmartPointer<vtkIdList>> vtkCellIds;
597 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp =
599 while (getline(meshStream, line)) {
600 if (line.find(
"POINTS") != std::string::npos) {
601 std::istringstream ss(line);
604 std::vector<double> point(3);
607 while (getline(meshStream, line) && pntId < numPoints) {
609 std::istringstream ss(line);
610 ss >> point[0] >> point[1] >> point[2];
611 point_ret = point_map.insert(
612 std::pair<std::vector<double>,
int>(point, realPntId));
613 if (point_ret.second) ++realPntId;
614 duplicate_point_map.insert(
615 std::pair<int, int>(pntId, point_ret.first->second));
621 if (line.find(
"CELLS") != std::string::npos) {
622 std::istringstream ss(line);
624 ss >> tmp >> numCells >> cellListSize;
627 vtkCellIds.resize(numCells);
628 while (cellId < numCells && getline(meshStream, line)) {
630 std::istringstream ss(line);
635 vtkCellIds[cellId]->SetNumberOfIds(numId);
637 for (
int j = 0; j < numId; ++j) {
639 vtkCellIds[cellId]->SetId(j, duplicate_point_map[
id]);
646 while (getline(meshStream, line)) {
647 if (line.find(
"CELL_TYPES") != std::string::npos) {
648 dataSet_tmp->Allocate(numCells);
651 while (cellId < numCells && getline(meshStream, line)) {
653 std::istringstream ss(line);
657 dataSet_tmp->InsertNextCell(cellType, vtkCellIds[cellId]);
667 std::multimap<int, std::vector<double>> flipped =
nemAux::flip_map(point_map);
668 auto flip_it = flipped.begin();
671 points->SetNumberOfPoints(point_map.size());
673 while (flip_it != flipped.end()) {
674 points->SetPoint(pnt, flip_it->second.data());
678 dataSet_tmp->SetPoints(points);
686 std::vector<double> result(coords, coords + 3);
692 std::vector<std::vector<double>> comp_crds(3);
693 for (
int i = 0; i < 3; ++i) comp_crds[i].resize(
numPoints);
698 comp_crds[0][i] = coords[0];
699 comp_crds[1][i] = coords[1];
700 comp_crds[2][i] = coords[2];
708 std::map<nemId_t, std::vector<double>> cell;
710 point_ids =
dataSet->GetCell(
id)->GetPointIds();
711 nemId_t num_ids = point_ids->GetNumberOfIds();
712 for (
nemId_t i = 0; i < num_ids; ++i) {
713 nemId_t pntId = point_ids->GetId(i);
714 std::vector<double> coord =
getPoint(pntId);
715 cell.insert(std::pair<
nemId_t, std::vector<double>>(pntId, coord));
719 std::cerr <<
"Cell ID is out of range!" << std::endl;
726 std::vector<std::vector<double>> cell;
728 point_ids =
dataSet->GetCell(
id)->GetPointIds();
729 nemId_t num_ids = point_ids->GetNumberOfIds();
730 cell.resize(num_ids);
731 for (
nemId_t i = 0; i < num_ids; ++i) {
732 nemId_t pntId = point_ids->GetId(i);
737 std::cerr <<
"Cell ID is out of range!" << std::endl;
743 std::ofstream outputStream(ofname);
744 if (!outputStream.good()) {
745 std::cerr <<
"error opening " << ofname << std::endl;
749 vtkSmartPointer<vtkExtractEdges> extractEdges =
751 extractEdges->SetInputData(
dataSet);
752 extractEdges->Update();
754 vtkSmartPointer<vtkGenericCell> genCell =
756 for (
nemId_t i = 0; i < extractEdges->GetOutput()->GetNumberOfCells(); ++i) {
757 extractEdges->GetOutput()->GetCell(i, genCell);
758 vtkPoints *
points = genCell->GetPoints();
760 points->GetPoint(0, p1);
761 points->GetPoint(1, p2);
762 double len = sqrt(pow(p1[0] - p2[0], 2) + pow(p1[1] - p2[1], 2) +
763 pow(p1[2] - p2[2], 2));
764 outputStream << len << std::endl;
769 std::vector<nemId_t> connectivities;
770 vtkSmartPointer<vtkCellIterator> it =
771 vtkSmartPointer<vtkCellIterator>::Take(
dataSet->NewCellIterator());
772 for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) {
773 vtkSmartPointer<vtkIdList> pointIds = it->GetPointIds();
774 for (
nemId_t i = 0; i < pointIds->GetNumberOfIds(); ++i)
775 connectivities.push_back(pointIds->GetId(i));
777 return connectivities;
782 std::cout <<
"dataSet has not been populated!" << std::endl;
786 using CellContainer = std::map<int, nemId_t>;
788 std::cout <<
"Processing the dataset generated from " <<
filename << std::endl
789 <<
" dataset contains a " <<
dataSet->GetClassName() <<
" that has " 793 CellContainer cellMap;
796 CellContainer::const_iterator it = cellMap.begin();
797 while (it != cellMap.end()) {
798 std::cout <<
"\tCell type " 799 << vtkCellTypes::GetClassNameFromTypeId(it->first) <<
" occurs " 800 << it->second <<
" times." << std::endl;
805 vtkPointData *pd =
dataSet->GetPointData();
807 std::cout <<
" contains point data with " << pd->GetNumberOfArrays()
808 <<
" arrays." << std::endl;
809 for (
int i = 0; i < pd->GetNumberOfArrays(); ++i) {
810 std::cout <<
"\tArray " << i <<
" is named " 811 << (pd->GetArrayName(i) ? pd->GetArrayName(i) :
"NULL");
812 vtkDataArray *da = pd->GetArray(i);
813 std::cout <<
" with " << da->GetNumberOfTuples() <<
" values. " 819 vtkCellData *cd =
dataSet->GetCellData();
821 std::cout <<
" contains cell data with " << cd->GetNumberOfArrays()
822 <<
" arrays." << std::endl;
823 for (
int i = 0; i < cd->GetNumberOfArrays(); ++i) {
824 std::cout <<
"\tArray " << i <<
" is named " 825 << (cd->GetArrayName(i) ? cd->GetArrayName(i) :
"NULL");
826 vtkDataArray *da = cd->GetArray(i);
827 std::cout <<
" with " << da->GetNumberOfTuples() <<
" values. " 834 std::cout <<
" contains field data with " 835 <<
dataSet->GetFieldData()->GetNumberOfArrays() <<
" arrays." 837 for (
int i = 0; i <
dataSet->GetFieldData()->GetNumberOfArrays(); ++i) {
838 std::cout <<
"\tArray " << i <<
" is named " 839 <<
dataSet->GetFieldData()->GetArray(i)->GetName();
840 vtkDataArray *da =
dataSet->GetFieldData()->GetArray(i);
841 std::cout <<
" with " << da->GetNumberOfTuples() <<
" values. " 849 vtkSmartPointer<vtkDataSetSurfaceFilter> surfFilt =
851 surfFilt->SetInputData(
dataSet);
855 vtkSmartPointer<vtkTriangleFilter> triFilt =
857 triFilt->SetInputData(surfFilt->GetOutput());
860 return triFilt->GetOutput();
865 std::vector<double> result;
868 result[i] = std::sqrt(
dataSet->GetCell(i)->GetLength2());
875 std::vector<double> center(3, 0.0);
876 std::vector<std::vector<double>> cell =
getCellVec(cellID);
878 for (
const auto &i : cell) center = center + i;
879 return 1. / cell.size() * center;
887 const std::vector<double> &
data) {
889 da->SetName(name.c_str());
890 da->SetNumberOfComponents(1);
892 dataSet->GetPointData()->AddArray(da);
897 const std::vector<std::vector<double>> &
data) {
899 da->SetName(name.c_str());
900 da->SetNumberOfComponents(
data[0].size());
902 dataSet->GetPointData()->AddArray(da);
908 std::vector<double> &
data) {
910 vtkSmartPointer<vtkDataArray> pd =
911 dataSet->GetPointData()->GetArray(name.c_str(), idx);
913 if (pd->GetNumberOfComponents() > 1) {
914 std::cerr << __func__
915 <<
" is only suitable for scalar data, i.e. 1 component" 919 data.resize(pd->GetNumberOfTuples());
921 for (
nemId_t i = 0; i < pd->GetNumberOfTuples(); ++i) {
926 std::cerr <<
"could not find data with name " << name << std::endl;
932 if (arrayId < dataSet->GetPointData()->GetNumberOfArrays()) {
933 vtkSmartPointer<vtkDataArray> pd =
934 dataSet->GetPointData()->GetArray(arrayId);
935 if (pd->GetNumberOfComponents() > 1) {
936 std::cerr << __func__
937 <<
" is only suitable for scalar data, i.e. 1 component" 941 data.resize(pd->GetNumberOfTuples());
943 for (
nemId_t i = 0; i < pd->GetNumberOfTuples(); ++i) {
948 std::cerr <<
"arrayId exceeds number of point data arrays " << std::endl;
956 dataSet->GetCellData()->GetArray(name.c_str(), idx);
961 std::vector<double> &
data) {
963 vtkSmartPointer<vtkDataArray> cd =
964 dataSet->GetCellData()->GetArray(name.c_str(), idx);
966 if (cd->GetNumberOfComponents() > 1) {
967 std::cerr << __func__
968 <<
" is only suitable for scalar data, i.e. 1 component" 972 data.resize(cd->GetNumberOfTuples());
974 for (
nemId_t i = 0; i < cd->GetNumberOfTuples(); ++i) {
979 std::cerr <<
"could not find data with name " << name << std::endl;
985 if (arrayId < dataSet->GetCellData()->GetNumberOfArrays()) {
986 vtkSmartPointer<vtkDataArray> cd =
987 dataSet->GetCellData()->GetArray(arrayId);
988 if (cd->GetNumberOfComponents() > 1) {
989 std::cerr << __func__
990 <<
" is only suitable for scalar data, i.e. 1 component" 994 data.resize(cd->GetNumberOfTuples());
996 for (
nemId_t i = 0; i < cd->GetNumberOfTuples(); ++i) {
1001 std::cerr <<
"arrayId exceeds number of cell data arrays " << std::endl;
1008 const std::vector<std::vector<double>> &
data) {
1010 da->SetName(name.c_str());
1011 da->SetNumberOfComponents(
data[0].size());
1013 dataSet->GetCellData()->AddArray(da);
1019 const std::vector<double> &
data) {
1021 da->SetName(name.c_str());
1022 da->SetNumberOfComponents(1);
1024 dataSet->GetCellData()->AddArray(da);
1031 dataSet->GetPointData()->RemoveArray(arrayID);
1035 dataSet->GetPointData()->RemoveArray(name.c_str());
1040 dataSet->GetCellData()->RemoveArray(arrayID);
1044 dataSet->GetCellData()->RemoveArray(name.c_str());
1049 dataSet->GetFieldData()->RemoveArray(name.c_str());
1054 vtkSmartPointer<vtkAppendFilter> appendFilter =
1056 appendFilter->AddInputData(
dataSet);
1057 appendFilter->AddInputData(dataSet_new);
1058 appendFilter->MergePointsOn();
1059 appendFilter->Update();
1060 dataSet = appendFilter->GetOutput();
void unsetCellDataArray(int arrayID) override
delete array with id from dataSet's cell data
void setPointDataArray(const std::string &name, const std::vector< std::vector< double >> &data) override
register data to dataSet's point data
vtkSmartPointer< vtkDataSet > extractSurface() override
extract the surface mesh
void getCellDataArray(const std::string &name, std::vector< double > &data) override
<>
std::map< nemId_t, std::vector< double > > getCell(nemId_t id) const override
get cell with id
data_type data
Edge/face with sorted point ids (a, b, c, ...) is located at some index i in data[b], with data[b][i].first == [a, c] (for edges, third point id treated as -1).
nemId_t numPoints
number of points in mesh
void unsetFieldDataArray(const std::string &name) override
delete array with id from dataSet's field data
std::multimap< B, A > flip_map(const std::map< A, B > &src)
void setFileName(const std::string &fname)
set the file name.
bool readLegacyVTKCells(std::istream &meshStream, std::string &line, nemId_t &numCells, std::vector< vtkSmartPointer< vtkIdList >> &vtkCellIds, vtkSmartPointer< vtkUnstructuredGrid > dataSet_tmp)
vtkSmartPointer< vtkDataSet > dataSet
mesh points, topology and data
void inspectEdges(const std::string &ofname) const override
get edge lengths of dataSet
bool readLegacyVTKPoints(std::istream &meshStream, std::string &line, nemId_t &numPoints, vtkSmartPointer< vtkPoints > points, vtkSmartPointer< vtkUnstructuredGrid > dataSet_tmp)
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
int getCellDataIdx(const std::string &name) override
<>
std::vector< std::vector< double > > getVertCrds() const override
get 3 vecs with x,y and z coords
void getPointDataArray(const std::string &name, std::vector< double > &data) override
get scalar point or cell data array.
std::string find_ext(const std::string &fname)
nemId_t numCells
number of cells in mesh
void setCellDataArray(const std::string &name, const std::vector< std::vector< double >> &data) override
register data to dataSet's cell data
int getCellType() const override
get cell type as an integer assumes all elements are the same type
vtkSmartPointer< vtkUnstructuredGrid > ReadALegacyVTKFile(const std::string &fileName)
std::string trim_fname(const std::string &name, const std::string &ext)
bool readLegacyVTKHeader(const std::string &line)
std::vector< double > getPoint(nemId_t id) const override
get point with id
vtkIdType id
id in .inp file
std::vector< std::vector< double > > getCellVec(nemId_t id) const override
get vector of coords of cell with id
std::vector< nemId_t > getConnectivities() const override
get connectivities.
std::vector< vtkIdType > points
points given by id in .inp file
std::string filename
name of mesh file
void unsetPointDataArray(int arrayID) override
delete array with id from dataSet's point data
std::vector< double > getCellCenter(nemId_t cellID) const override
get center of a cell
bool readLegacyVTKFieldData(std::istream &meshStream, std::string &line, vtkSmartPointer< vtkUnstructuredGrid > dataSet_tmp)
void merge(vtkSmartPointer< vtkDataSet > dataSet_new)
std::vector< std::string > getNewArrayNames()
get new array names for use in transfer
static std::shared_ptr< TransferBase > CreateTransferObject(meshBase *srcmsh, meshBase *trgmsh, const std::string &method)
bool readLegacyVTKData(std::ifstream &meshStream, std::string &line, const nemId_t numTuple, const bool pointOrCell, bool &hasPointOrCell, vtkSmartPointer< vtkUnstructuredGrid > dataSet_tmp)
vtkSmartPointer< vtkUnstructuredGrid > ReadDegenerateVTKFile(const std::string &fileName)
nemId_t getNumberOfCells() const
return the number of cells
std::vector< double > getCellLengths() const override
get diameter of circumsphere of each cell
void report() const override
generate a report of the mesh
void write() const override
write the mesh to file named after the private var 'filename'.