int FastMarchingForPropagation::init(	GenericCloud* theCloud,
										DgmOctree* theOctree,
										unsigned char level,
										bool constantAcceleration/*=false*/)
{
	assert(theCloud && theOctree);

	int result = initGridWithOctree(theOctree,level);
	if (result < 0)
		return result;

	//on remplit la grille
	DgmOctree::cellCodesContainer cellCodes;
	theOctree->getCellCodes(level,cellCodes,true);

	ReferenceCloud Yk(theOctree->associatedCloud());

	while (!cellCodes.empty())
	{
		if (!theOctree->getPointsInCell(cellCodes.back(),level,&Yk,true))
		{
			//not enough memory?
			return -1;
		}
		
		//on transforme le code de cellule en position
		Tuple3i cellPos;
		theOctree->getCellPos(cellCodes.back(),level,cellPos,true);

		//on renseigne la grille
		unsigned gridPos = pos2index(cellPos);

		PropagationCell* aCell = new PropagationCell;
		aCell->cellCode = cellCodes.back();
		aCell->f = (constantAcceleration ? 1.0f : static_cast<float>(ScalarFieldTools::computeMeanScalarValue(&Yk)));

		m_theGrid[gridPos] = aCell;

		cellCodes.pop_back();
	}

	m_initialized = true;

	return 0;
}
Ejemplo n.º 2
0
int FastMarchingForPropagation::init(	GenericCloud* theCloud,
										DgmOctree* theOctree,
										uchar level,
										bool constantAcceleration/*=false*/)
{
	int result = initGridWithOctree(theOctree,level);
	if (result < 0)
		return result;

	//on remplit la grille
	DgmOctree::cellCodesContainer cellCodes;
	theOctree->getCellCodes(level,cellCodes,true);

	while (!cellCodes.empty())
	{
		ReferenceCloud* Yk = theOctree->getPointsInCell(cellCodes.back(),level,true);
		if (Yk)
		{
			//on transforme le code de cellule en position
			int cellPos[3];
			theOctree->getCellPos(cellCodes.back(),level,cellPos,true);

			//on renseigne la grille
			unsigned gridPos = FM_pos2index(cellPos);

			PropagationCell* aCell = new PropagationCell;
			aCell->cellCode = cellCodes.back();
			aCell->f = (constantAcceleration ? 1.0f : ScalarFieldTools::computeMeanScalarValue(Yk));

			m_theGrid[gridPos] = aCell;
		}

		cellCodes.pop_back();
	}

	m_initialized = true;

	return 0;
}