MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() { QSettings settings; QString filename = QFileDialog::getSaveFileName(this, "Write TetGen input file to", settings.value("lastOpenedTetgenFileDirectory").toString(), "TetGen Geometry (*.smesh)"); if (filename.isEmpty()) return nullptr; const unsigned nLayers = _layerEdit->text().toInt(); MeshLib::Mesh* tg_mesh(nullptr); QTime myTimer0; myTimer0.start(); if (_use_rasters) { float minimum_thickness (_minThicknessEdit->text().toFloat()); if (minimum_thickness <= 0) minimum_thickness = std::numeric_limits<float>::epsilon(); std::vector<std::string> raster_paths; for (int i=nLayers; i>=0; --i) raster_paths.push_back(this->_edits[i]->text().toStdString()); LayeredVolume lv; auto const rasters = FileIO::readRasters(raster_paths); if (rasters && lv.createLayers(*_msh, *rasters, minimum_thickness)) tg_mesh = lv.getMesh("SubsurfaceMesh").release(); if (tg_mesh) { std::vector<MeshLib::Node> tg_attr (lv.getAttributePoints()); FileIO::TetGenInterface tetgen_interface; tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, tg_attr); } } else { std::vector<float> layer_thickness; for (unsigned i=0; i<nLayers; ++i) layer_thickness.push_back(this->_edits[i]->text().toFloat()); tg_mesh = MeshLib::MeshLayerMapper::createStaticLayers(*_msh, layer_thickness); std::vector<MeshLib::Node> tg_attr; FileIO::TetGenInterface tetgen_interface; tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, tg_attr); } INFO("Mesh construction time: %d ms.", myTimer0.elapsed()); return tg_mesh; }
MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() { QSettings settings; QString filename = QFileDialog::getSaveFileName(this, "Write TetGen input file to", settings.value("lastOpenedTetgenFileDirectory").toString(), "TetGen Geometry (*.smesh)"); if (filename.isEmpty()) return nullptr; const unsigned nLayers = _layerEdit->text().toInt(); MeshLib::Mesh* tg_mesh (nullptr); if (_use_rasters) { std::vector<std::string> raster_paths(nLayers+1); for (unsigned i=0; i<=nLayers; ++i) raster_paths[i] = this->_edits[i+1]->text().toStdString(); LayeredVolume lv; lv.createGeoVolumes(*_msh, raster_paths); tg_mesh = lv.getMesh(); QString file_path(""); if (tg_mesh) { std::vector<MeshLib::Node> tg_attr (lv.getAttributePoints()); FileIO::TetGenInterface tetgen_interface; tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, tg_attr); } } else { std::vector<float> layer_thickness; for (unsigned i=0; i<nLayers; ++i) layer_thickness.push_back(this->_edits[i]->text().toFloat()); tg_mesh = MeshLayerMapper::CreateLayers(*_msh, layer_thickness); std::vector<MeshLib::Node> tg_attr; FileIO::TetGenInterface tetgen_interface; tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, tg_attr); } return tg_mesh; }