void ccFastMarchingForNormsDirection::initTrialCells() { //we expect at most one 'ACTIVE' cell (i.e. the current seed) size_t seedCount = m_activeCells.size(); assert(seedCount <= 1); if (seedCount == 1) { unsigned index = m_activeCells.front(); DirectionCell* seedCell = static_cast<DirectionCell*>(m_theGrid[index]); assert(seedCell != NULL); assert(seedCell->T == 0); assert(seedCell->signConfidence == 1); //add all its neighbour cells to the TRIAL set for (unsigned i=0; i<m_numberOfNeighbours; ++i) { unsigned nIndex = index + m_neighboursIndexShift[i]; DirectionCell* nCell = static_cast<DirectionCell*>(m_theGrid[nIndex]); //if the neighbor exists (it shouldn't be in the TRIAL or ACTIVE sets) if (nCell/* && nCell->state == DirectionCell::FAR_CELL*/) { assert(nCell->state == DirectionCell::FAR_CELL); addTrialCell(nIndex); //compute its approximate arrival time nCell->T = seedCell->T + m_neighboursDistance[i] * computeTCoefApprox(seedCell,nCell); } } } }
void ccFastMarchingForNormsDirection::initTrialCells() { DirectionCell *aCell,*nCell; unsigned i,j,index,nIndex; for (j=0;j<activeCells.size();++j) { index = activeCells[j]; aCell = (DirectionCell*)theGrid[index]; assert(aCell != NULL); aCell->v = 1.0; for (i=0;i<CC_FM_NUMBER_OF_NEIGHBOURS;++i) { nIndex = index + neighboursIndexShift[i]; //pointeur vers la cellule voisine nCell = (DirectionCell*)theGrid[nIndex]; //si elle est définie if (nCell) { //et si elle n'est pas encore dans un groupe if (nCell->state==CCLib::FastMarching::Cell::FAR_CELL) { nCell->state = CCLib::FastMarching::Cell::TRIAL_CELL; nCell->T = neighboursDistance[i]*computeTCoefApprox(aCell,nCell); //on doit s'occuper de leur normales !!! float ps = CCVector3::vdot(aCell->N,nCell->N); if (ps<0.0) { nCell->N[0]=-nCell->N[0]; nCell->N[1]=-nCell->N[1]; nCell->N[2]=-nCell->N[2]; } nCell->v = 1.0; nCell->treated = true; addTrialCell(nIndex,nCell->T); //Console::print("cell %i added to TRIAL\n",nIndex); } } } } }