void TaskStore::Scan() { Clear(); // scan files TaskFileVisitor tfv(store); VisitDataFiles(_T("*.tsk"), tfv); VisitDataFiles(_T("*.cup"), tfv); std::sort(store.begin(), store.end()); }
void Surface_Radiance_Plugin::exportPLY( const QString& mapName, const QString& positionAttributeName, const QString& normalAttributeName, const QString& filename) { typedef PFP2::MAP MAP; typedef PFP2::REAL REAL; typedef PFP2::VEC3 VEC3; MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName)); if(mh == NULL) return; VertexAttribute<VEC3, MAP> position = mh->getAttribute<VEC3, VERTEX>(positionAttributeName); if(!position.isValid()) return; VertexAttribute<VEC3, MAP> normal = mh->getAttribute<VEC3, VERTEX>(normalAttributeName); if(!normal.isValid()) return; VertexAttribute<Utils::SphericalHarmonics<REAL, VEC3>, MAP> radiance = h_mapParameterSet[mh].radiance; if(!radiance.isValid()) return; // open file std::ofstream out ; out.open(filename.toStdString(), std::ios::out | std::ios::binary) ; if (!out.good()) { CGoGNerr << "Unable to open file " << CGoGNendl ; return ; } MAP* map = mh->getMap(); unsigned int nbDarts = map->getNbDarts() ; std::vector<unsigned int> facesSize ; std::vector<std::vector<unsigned int> > facesIdx ; facesSize.reserve(nbDarts/3) ; facesIdx.reserve(nbDarts/3) ; std::map<unsigned int, unsigned int> vIndex ; unsigned int vCpt = 0 ; std::vector<unsigned int> vertices ; vertices.reserve(nbDarts/6) ; // Go over all faces CellMarker<MAP, VERTEX> markV(*map) ; TraversorF<MAP> t(*map) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) { std::vector<unsigned int> fidx ; fidx.reserve(8) ; unsigned int degree = 0 ; Traversor2FV<MAP> tfv(*map, d) ; for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next()) { ++degree ; unsigned int vNum = map->getEmbedding<VERTEX>(it) ; if(!markV.isMarked(it)) { markV.mark(it) ; vIndex[vNum] = vCpt++ ; vertices.push_back(vNum) ; } fidx.push_back(vIndex[vNum]) ; } facesSize.push_back(degree) ; facesIdx.push_back(fidx) ; } // Start writing the file out << "ply" << std::endl ; // test endianness union { uint32_t i ; char c[4] ; } bint = {0x01020304} ; if (bint.c[0] == 1) // big endian out << "format binary_big_endian 1.0" << std::endl ; else out << "format binary_little_endian 1.0" << std::endl ; out << "comment File generated by the CGoGN library" << std::endl ; out << "comment See : http://cgogn.unistra.fr/" << std::endl ; out << "comment or contact : [email protected]" << std::endl ; // Vertex elements out << "element vertex " << vertices.size() << std::endl ; std::string nameOfTypePly_REAL(nameOfTypePly(position[0][0])) ; out << "property " << nameOfTypePly_REAL << " x" << std::endl ; out << "property " << nameOfTypePly_REAL << " y" << std::endl ; out << "property " << nameOfTypePly_REAL << " z" << std::endl ; out << "property " << nameOfTypePly_REAL << " nx" << std::endl ; out << "property " << nameOfTypePly_REAL << " ny" << std::endl ; out << "property " << nameOfTypePly_REAL << " nz" << std::endl ; int res = Utils::SphericalHarmonics<REAL, VEC3>::get_resolution() ; for (int l = 0 ; l <= res ; ++l) { for (int m = -l ; m <= l ; ++m) { out << "property " << nameOfTypePly_REAL << " SHcoef_" << l << "_" << m << "_r" << std::endl ; out << "property " << nameOfTypePly_REAL << " SHcoef_" << l << "_" << m << "_g" << std::endl ; out << "property " << nameOfTypePly_REAL << " SHcoef_" << l << "_" << m << "_b" << std::endl ; } } // Face element out << "element face " << facesSize.size() << std::endl ; out << "property list uint8 " << nameOfTypePly(facesIdx[0][0]) << " vertex_indices" << std::endl ; out << "end_header" << std::endl ; // binary vertices for(unsigned int i = 0; i < vertices.size(); ++i) { const VEC3& p = position[vertices[i]] ; out.write((char*)(&(p[0])), sizeof(p)) ; const VEC3& n = normal[vertices[i]] ; out.write((char*)(&(n[0])), sizeof(n)) ; for (int l=0 ; l <= res ; ++l) { for (int m=-l ; m <= l ; ++m) { const VEC3& r = radiance[vertices[i]].get_coef(l,m) ; out.write((char*)(&(r[0])), sizeof(r)) ; } } } // binary faces for(unsigned int i = 0; i < facesSize.size(); ++i) { uint8_t nbe = facesSize[i] ; out.write((char*)(&nbe), sizeof(uint8_t)) ; out.write((char*)(&(facesIdx[i][0])), facesSize[i] * sizeof(facesIdx[i][0])) ; } out.close() ; this->pythonRecording("exportPLY", "", mapName, positionAttributeName, normalAttributeName, filename); }