void Surface_Radiance_Plugin::checkNbVerticesAndExport(Surface_Radiance_Plugin* p, const unsigned int* nbVertices) { if (!p->exportNbVert.empty()) { MapHandlerGen* mhg = p->currentlyDecimatedMap(); if (*nbVertices == p->exportNbVert[p->nextExportIndex]) { std::stringstream exportName; exportName << p->currentlyDecimatedMap()->getName().toStdString() << "_" << (p->currentDecimationHalf() ? "half_" : "full_") << (*nbVertices) << ".ply"; std::cout << "export : " << exportName.str() << std::endl; p->exportPLY(mhg->getName(), "position", "normal", QString::fromStdString(exportName.str())); p->nextExportIndex++; } } }
void Surface_DifferentialProperties_Plugin::attributeModified(unsigned int orbit, QString nameAttr) { if(orbit == VERTEX) { MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender()); if(computeNormalLastParameters.contains(map->getName())) { ComputeNormalParameters& params = computeNormalLastParameters[map->getName()]; if(params.autoUpdate && params.positionName == nameAttr) computeNormal(map->getName(), params.positionName, params.normalName, true); } if(computeCurvatureLastParameters.contains(map->getName())) { ComputeCurvatureParameters& params = computeCurvatureLastParameters[map->getName()]; if(params.autoUpdate && (params.positionName == nameAttr || params.normalName == nameAttr)) computeCurvature( map->getName(), params.positionName, params.normalName, params.KmaxName, params.kmaxName, params.KminName, params.kminName, params.KnormalName, true ); } } }
MapHandlerGen* Surface_Radiance_Plugin::importFromFile(const QString& fileName) { QFileInfo fi(fileName); if(fi.exists()) { MapHandlerGen* mhg = m_schnapps->addMap(fi.baseName(), 2); if(mhg) { MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg); PFP2::MAP* map = mh->getMap(); MeshTablesSurface_Radiance importer(*map); if (!importer.importPLY<Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3> >(fileName.toStdString())) { std::cout << "could not import " << fileName.toStdString() << std::endl; return NULL; } CGoGN::Algo::Surface::Import::importMesh<PFP2>(*map, importer); // get vertex position attribute VertexAttribute<PFP2::VEC3, PFP2::MAP> position = map->getAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>("position") ; VertexAttribute<PFP2::VEC3, PFP2::MAP> normal = map->getAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>("normal"); mh->registerAttribute(position); mh->registerAttribute(normal); MapParameters& mapParams = h_mapParameterSet[mhg]; mapParams.nbVertices = Algo::Topo::getNbOrbits<VERTEX>(*map); mapParams.radiance = map->getAttribute<Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>, VERTEX, PFP2::MAP>("radiance") ; mapParams.radianceTexture = new Utils::Texture<2, Geom::Vec3f>(GL_FLOAT); mapParams.param = map->checkAttribute<Geom::Vec2i, VERTEX, PFP2::MAP>("param"); // create texture unsigned int nbv_nbc = Algo::Topo::getNbOrbits<VERTEX>(*map) * Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>::get_nb_coefs(); unsigned int size = 1; while (size * size < nbv_nbc) size <<= 1; mapParams.radianceTexture->create(Geom::Vec2i(size, size)); // fill texture unsigned int count = 0; foreach_cell<VERTEX>(*map, [&] (Vertex v) { unsigned int i = count / size; unsigned int j = count % size; mapParams.param[v] = Geom::Vec2i(i, j) ; // first index for current vertex for (int l = 0 ; l <= Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>::get_resolution() ; ++l) { for (int m = -l ; m <= l ; ++m) { i = count / size; j = count % size; (*(mapParams.radianceTexture))(i,j) = mapParams.radiance[v].get_coef(l, m); ++count; } } }) ; // resulting texture : SH00_vx0, SH1-1_vx0, ..., SHlm_vx0, SH00_vx1, SH1-1_vx1, ..., SHlm_vx1, etc. // resulting param : param[vxI] points to SH00_vxI // the size of the texture is needed to know where to do the divisions and modulos. mapParams.radianceTexture->update(); // uncomment this line to be able to load multiple objects with different SH basis // (decimation will be unavailable) // map->removeAttribute(mapParams.radiance); mapParams.paramVBO = new Utils::VBO(); mapParams.paramVBO->updateData(mapParams.param); mapParams.radiancePerVertexShader = new Utils::ShaderRadiancePerVertex(Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>::get_resolution()); registerShader(mapParams.radiancePerVertexShader); } this->pythonRecording("importFile", mhg->getName(), fi.baseName()); return mhg; } else return NULL; }