bool TrisetObject::load(QString flnm) { if (StaticFunctions::checkExtension(flnm, ".triset")) return loadTriset(flnm); else return loadPLY(flnm); return false; }
QString MeshGenerator::start(VolumeFileManager *vfm, int nX, int nY, int nZ, Vec dataMin, Vec dataMax, QString prevDir, Vec voxelScaling, int samplingLevel, QList<Vec> clipPos, QList<Vec> clipNormal, QList<CropObject> crops, QList<PathObject> paths, uchar *lut, int pruneLod, int pruneX, int pruneY, int pruneZ, QVector<uchar> pruneData, QVector<uchar> tagColors) { m_vfm = vfm; m_voxelType = m_vfm->voxelType(); m_depth = nX; m_width = nY; m_height = nZ; m_dataMin = dataMin; m_dataMax = dataMax; m_dataSize = m_dataMax - m_dataMin + Vec(1,1,1); m_nX = qMin(int(m_dataSize.z), m_depth); m_nY = qMin(int(m_dataSize.y), m_width); m_nZ = qMin(int(m_dataSize.x), m_height); m_crops = crops; m_paths = paths; m_pruneLod = pruneLod; m_pruneX = pruneX; m_pruneY = pruneY; m_pruneZ = pruneZ; m_pruneData = pruneData; m_tagColors = tagColors; m_samplingLevel = samplingLevel; // pruneLod that we get is wrt the original sized volume. // set pruneLod to reflect the selected sampling level. m_pruneLod = qMax((float)m_nX/(float)m_pruneZ, qMax((float)m_nY/(float)m_pruneY, (float)m_nZ/(float)m_pruneX)); // QMessageBox::information(0, "", QString("%1 %2 %3\n%4 %5 %6\n%7").\ // arg(m_nX).arg(m_nY).arg(m_nZ).\ // arg(m_pruneZ).arg(m_pruneY).arg(m_pruneX).\ // arg(m_pruneLod)); bool doBorder = false; if (qRound(m_dataSize.x) < m_height || qRound(m_dataSize.y) < m_width || qRound(m_dataSize.z) < m_depth) doBorder = true; if (clipPos.count() > 0 || m_crops.count() > 0 || m_paths.count() > 0) doBorder = true; int depth, fillValue; bool checkForMore; bool lookInside; QGradientStops stops; int chan; bool avgColor; if (! getValues(depth, fillValue, checkForMore, lookInside, stops, doBorder, chan, avgColor)) return ""; m_meshLog = new QTextEdit; m_meshProgress = new QProgressBar; QVBoxLayout *meshLayout = new QVBoxLayout; meshLayout->addWidget(m_meshLog); meshLayout->addWidget(m_meshProgress); QWidget *meshWindow = new QWidget; meshWindow->setWindowTitle("Drishti - Mesh Repainting Using Voxel Values"); meshWindow->setLayout(meshLayout); meshWindow->show(); meshWindow->resize(700, 300); float memGb = 0.5; memGb = QInputDialog::getDouble(0, "Use memory", "Max memory we can use (GB)", memGb, 0.1, 1000, 2); qint64 gb = 1024*1024*1024; qint64 memsize = memGb*gb; // max memory we can use (in GB) qint64 canhandle = memsize/15; qint64 gsize = qPow((double)canhandle, 0.333); m_meshLog->insertPlainText(QString("Can handle data with total grid size of %1 : typically %2^3\nOtherwise slabs method will be used. Mesh is generated for each slab and then joined together.\n\n"). \ arg(canhandle).arg(gsize)); m_meshLog->insertPlainText("\n\n"); m_meshLog->insertPlainText(QString("Volume Size : %1 %2 %3\n").\ arg(m_depth). arg(m_width). arg(m_height)); m_meshLog->insertPlainText(QString("DataMin : %1 %2 %3\n").\ arg(m_dataMin.z). arg(m_dataMin.y). arg(m_dataMin.x)); m_meshLog->insertPlainText(QString("DataMax : %1 %2 %3\n").\ arg(m_dataMax.z). arg(m_dataMax.y). arg(m_dataMax.x)); m_meshLog->insertPlainText(QString("DataSize : %1 %2 %3\n").\ arg(m_dataSize.z). arg(m_dataSize.y). arg(m_dataSize.x)); m_meshLog->insertPlainText("\n\n"); m_meshLog->insertPlainText(QString("Grid size : %1 %2 %3\n").\ arg(m_nX).arg(m_nY).arg(m_nZ)); //---- import the mesh --- QString inflnm = QFileDialog::getOpenFileName(0, "Load mesh to repaint", prevDir, "*.ply"); if (inflnm.size() == 0) { meshWindow->close(); return ""; } if (!loadPLY(inflnm)) { meshWindow->close(); return ""; } //---------------------------- //---- export the mesh --- QString outflnm = QFileDialog::getSaveFileName(0, "Export mesh", prevDir, "*.ply"); if (outflnm.size() == 0) { meshWindow->close(); return ""; } //---------------------------- int nSlabs = 1; qint64 reqmem = m_nX; reqmem *= m_nY*m_nZ*20; nSlabs = qMax(qint64(1), reqmem/memsize + 1); // QMessageBox::information(0, "", QString("Number of Slabs : %1 : %2 %3").\ // arg(nSlabs).arg(reqmem).arg(memsize)); QStringList volumeFiles; #ifndef Q_OS_MACX volumeFiles = QFileDialog::getOpenFileNames(0, "Load volume files for timeseries data, otherwise give CANCEL", prevDir, "NetCDF Files (*.pvl.nc)", 0, QFileDialog::DontUseNativeDialog); #else volumeFiles = QFileDialog::getOpenFileNames(0, "Load volume files for timeseries data, otherwise give CANCEL", prevDir, "NetCDF Files (*.pvl.nc)", 0); #endif int nvols = volumeFiles.count(); if (nvols == 0) volumeFiles << m_vfm->fileName(); generateMesh(nSlabs, volumeFiles, outflnm, depth, stops, fillValue, checkForMore, lookInside, voxelScaling, clipPos, clipNormal, crops, paths, lut, chan, avgColor); meshWindow->close(); return outflnm; }
Model::Model(string filePath) { //loadOBJ(filePath.c_str(), vertices, uvs, normals); loadPLY(filePath.c_str(), vertices); m_fileName = filePath; }