int ccFastMarchingForNormsDirection::init(ccGenericPointCloud* aList, NormsIndexesTableType* theNorms, CCLib::DgmOctree* _theOctree, uchar level) { //on commence par créer une grille 3D theOctree = _theOctree; gridLevel = level; int result = initGrid(); if (result<0) return result; //printf("cellSize=%f\n",cellSize); //on remplit la grille CCLib::DgmOctree::cellCodesContainer cellCodes; theOctree->getCellCodes(gridLevel,cellCodes,true); int cellPos[3]; while (!cellCodes.empty()) { //on transforme le code de cellule en position theOctree->getCellPos(cellCodes.back(),gridLevel,cellPos,true); //on renseigne la grille unsigned gridPos = FM_pos2index(cellPos); DirectionCell* aCell = new DirectionCell; aCell->state = CCLib::FastMarching::Cell::FAR_CELL; aCell->T = FM_INF; aCell->treated = false; aCell->v = 0.0; aCell->cellCode = cellCodes.back(); CCLib::ReferenceCloud* Yk = theOctree->getPointsInCell(cellCodes.back(),gridLevel,true); if (Yk) { ccOctree::ComputeRobustAverageNorm(Yk,aList,aCell->N); //Yk->clear(); //inutile //printf("code %i -> cell(%i,%i,%i) --> %i\n",cellCodes.back(),cellPos[0],cellPos[1],cellPos[2],gridPos); theGrid[gridPos] = (CCLib::FastMarching::Cell*)aCell; } cellCodes.pop_back(); } initialized = true; return 0; }
int ccFastMarchingForNormsDirection::init( ccGenericPointCloud* cloud, NormsIndexesTableType* theNorms, CCLib::DgmOctree* theOctree, uchar level) { int result = initGridWithOctree(theOctree, level); if (result < 0) return result; //fill the grid with the octree CCLib::DgmOctree::cellCodesContainer cellCodes; theOctree->getCellCodes(level,cellCodes,true); CCLib::ReferenceCloud Yk(theOctree->associatedCloud()); while (!cellCodes.empty()) { if (!theOctree->getPointsInCell(cellCodes.back(),level,&Yk,true)) { //not enough memory return -1; } //convert the octree cell code to grid position int cellPos[3]; theOctree->getCellPos(cellCodes.back(),level,cellPos,true); //convert it to FM cell pos index unsigned gridPos = FM_pos2index(cellPos); //create corresponding cell DirectionCell* aCell = new DirectionCell; { //aCell->signConfidence = 1; aCell->cellCode = cellCodes.back(); aCell->N = ComputeRobustAverageNorm(&Yk,cloud); aCell->C = *CCLib::Neighbourhood(&Yk).getGravityCenter(); } m_theGrid[gridPos] = aCell; cellCodes.pop_back(); } m_initialized = true; return 0; }