本文整理汇总了C++中GenericChunkedArray::placeIteratorAtBegining方法的典型用法代码示例。如果您正苦于以下问题:C++ GenericChunkedArray::placeIteratorAtBegining方法的具体用法?C++ GenericChunkedArray::placeIteratorAtBegining怎么用?C++ GenericChunkedArray::placeIteratorAtBegining使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericChunkedArray
的用法示例。
在下文中一共展示了GenericChunkedArray::placeIteratorAtBegining方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResolveNormsDirectionByFrontPropagation
int ccFastMarchingForNormsDirection::ResolveNormsDirectionByFrontPropagation(ccPointCloud* theCloud,
NormsIndexesTableType* theNorms,
uchar octreeLevel,
CCLib::GenericProgressCallback* progressCb,
CCLib::DgmOctree* _theOctree)
{
assert(theCloud);
int i,numberOfPoints = theCloud->size();
if (numberOfPoints<1)
return -2;
//on calcule l'octree si besoin
CCLib::DgmOctree* theOctree = _theOctree;
if (!theOctree)
{
theOctree = new CCLib::DgmOctree(theCloud);
if (theOctree->build(progressCb)<1)
{
delete theOctree;
return -3;
}
}
//temporaire
int oldSfIdx = theCloud->getCurrentInScalarFieldIndex();
int sfIdx = theCloud->getScalarFieldIndexByName("FM_Propagation");
if (sfIdx<0)
sfIdx=theCloud->addScalarField("FM_Propagation",true);
if (sfIdx>=0)
theCloud->setCurrentScalarField(sfIdx);
else
{
ccConsole::Warning("[ccFastMarchingForNormsDirection] Couldn't create temporary scalar field! Not enough memory?");
if (!_theOctree)
delete theOctree;
return -5;
}
theCloud->enableScalarField();
//vecteur indiquant si le point a été traité
GenericChunkedArray<1,uchar>* resolved = new GenericChunkedArray<1,uchar>();
resolved->resize(numberOfPoints,true,0); //defaultResolvedValue=0
//on va faire la propagation avec l'algorithme de Fast Marching
ccFastMarchingForNormsDirection* fm = new ccFastMarchingForNormsDirection();
int result = fm->init(theCloud,theNorms,theOctree,octreeLevel);
if (result<0)
{
ccConsole::Error("[ccFastMarchingForNormsDirection] Something went wrong during initialization ...\n");
theCloud->deleteScalarField(sfIdx);
theCloud->setCurrentScalarField(oldSfIdx);
if (!_theOctree)
delete theOctree;
delete fm;
return -4;
}
int resolvedPoints=0;
if (progressCb)
{
progressCb->reset();
progressCb->setMethodTitle("Norms direction");
char buffer[256];
sprintf(buffer,"Octree level: %i\nNumber of points: %i",octreeLevel,numberOfPoints);
progressCb->setInfo(buffer);
progressCb->start();
}
int octreeLength = (1<<octreeLevel)-1;
while (true)
{
//on cherche un point non encore traité
resolved->placeIteratorAtBegining();
for (i=0;i<numberOfPoints;++i)
{
if (resolved->getCurrentValue()==0)
break;
resolved->forwardIterator();
}
//si tous les points ont été traités, on peut arréter !
if (i==numberOfPoints)
break;
//on lance la propagation à partir du point trouvé
const CCVector3 *thePoint = theCloud->getPoint(i);
int pos[3];
theOctree->getTheCellPosWhichIncludesThePoint(thePoint,pos,octreeLevel);
//clipping (important !)
pos[0] = std::min(octreeLength,pos[0]);
pos[1] = std::min(octreeLength,pos[1]);
pos[2] = std::min(octreeLength,pos[2]);
fm->setSeedCell(pos);
int result = fm->propagate();
//.........这里部分代码省略.........
示例2: resampleCloudSpatially
ReferenceCloud* CloudSamplingTools::resampleCloudSpatially(GenericIndexedCloudPersist* theCloud,
PointCoordinateType minDistance,
DgmOctree* theOctree/*=0*/,
GenericProgressCallback* progressCb/*=0*/)
{
assert(theCloud);
unsigned cloudSize = theCloud->size();
DgmOctree *_theOctree=theOctree;
if (!_theOctree)
{
_theOctree = new DgmOctree(theCloud);
if (_theOctree->build()<(int)cloudSize)
{
delete _theOctree;
return 0;
}
}
ReferenceCloud* sampledCloud = new ReferenceCloud(theCloud);
if (!sampledCloud->reserve(cloudSize))
{
if (!theOctree)
delete _theOctree;
return 0;
}
GenericChunkedArray<1,bool>* markers = new GenericChunkedArray<1,bool>(); //DGM: upgraded from vector, as this can be quite huge!
if (!markers->resize(cloudSize,true,true))
{
markers->release();
if (!theOctree)
delete _theOctree;
delete sampledCloud;
return 0;
}
NormalizedProgress* normProgress=0;
if (progressCb)
{
progressCb->setInfo("Spatial resampling");
normProgress = new NormalizedProgress(progressCb,cloudSize);
progressCb->reset();
progressCb->start();
}
//for each point in the cloud that is still 'marked', we look
//for its neighbors and remove their own marks
DgmOctree::NearestNeighboursSphericalSearchStruct nss;
nss.level = _theOctree->findBestLevelForAGivenNeighbourhoodSizeExtraction(minDistance);
markers->placeIteratorAtBegining();
for (unsigned i=0; i<cloudSize; i++, markers->forwardIterator())
{
//progress indicator
if (normProgress && !normProgress->oneStep())
{
//cancel process
delete sampledCloud;
sampledCloud = 0;
break;
}
//no mark? we skip this point
if (!markers->getCurrentValue())
continue;
//init neighbor search structure
theCloud->getPoint(i,nss.queryPoint);
bool inbounds = false;
_theOctree->getTheCellPosWhichIncludesThePoint(&nss.queryPoint, nss.cellPos, nss.level, inbounds);
nss.truncatedCellCode = (inbounds ? _theOctree->generateTruncatedCellCode(nss.cellPos, nss.level) : DgmOctree::INVALID_CELL_CODE);
_theOctree->computeCellCenter(nss.cellPos, nss.level, nss.cellCenter);
//add the points that lie in the same cell (faster)
{
ReferenceCloud* Y = _theOctree->getPointsInCell(nss.truncatedCellCode, nss.level, true);
unsigned count = Y->size();
try
{
nss.pointsInNeighbourhood.resize(count);
}
catch (std::bad_alloc) //out of memory
{
//stop process
delete sampledCloud;
sampledCloud = 0;
break;
}
unsigned realCount = 0;
DgmOctree::NeighboursSet::iterator it = nss.pointsInNeighbourhood.begin();
for (unsigned j=0; j<count; ++j)
{
unsigned index = Y->getPointGlobalIndex(j);
if (index != i && markers->getValue(index)) //no need to add the point itself and those already flagged off
{
it->point = Y->getPointPersistentPtr(j);
it->pointIndex = index;
++it;
//.........这里部分代码省略.........
示例3: laplacianSmooth
bool ccGenericMesh::laplacianSmooth(unsigned nbIteration, float factor, CCLib::GenericProgressCallback* progressCb/*=0*/)
{
if (!m_associatedCloud)
return false;
//vertices
unsigned vertCount = m_associatedCloud->size();
//triangles
unsigned faceCount = size();
if (!vertCount || !faceCount)
return false;
GenericChunkedArray<3,PointCoordinateType>* verticesDisplacement = new GenericChunkedArray<3,PointCoordinateType>;
if (!verticesDisplacement->resize(vertCount))
{
//not enough memory
verticesDisplacement->release();
return false;
}
//compute the number of edges to which belong each vertex
unsigned* edgesCount = new unsigned[vertCount];
if (!edgesCount)
{
//not enough memory
verticesDisplacement->release();
return false;
}
memset(edgesCount, 0, sizeof(unsigned)*vertCount);
placeIteratorAtBegining();
for(unsigned j=0; j<faceCount; j++)
{
const CCLib::TriangleSummitsIndexes* tri = getNextTriangleIndexes();
edgesCount[tri->i1]+=2;
edgesCount[tri->i2]+=2;
edgesCount[tri->i3]+=2;
}
//progress dialog
CCLib::NormalizedProgress* nProgress = 0;
if (progressCb)
{
unsigned totalSteps = nbIteration;
nProgress = new CCLib::NormalizedProgress(progressCb,totalSteps);
progressCb->setMethodTitle("Laplacian smooth");
progressCb->setInfo(qPrintable(QString("Iterations: %1\nVertices: %2\nFaces: %3").arg(nbIteration).arg(vertCount).arg(faceCount)));
progressCb->start();
}
//repeat Laplacian smoothing iterations
for(unsigned iter = 0; iter < nbIteration; iter++)
{
verticesDisplacement->fill(0);
//for each triangle
placeIteratorAtBegining();
for(unsigned j=0; j<faceCount; j++)
{
const CCLib::TriangleSummitsIndexes* tri = getNextTriangleIndexes();
const CCVector3* A = m_associatedCloud->getPoint(tri->i1);
const CCVector3* B = m_associatedCloud->getPoint(tri->i2);
const CCVector3* C = m_associatedCloud->getPoint(tri->i3);
CCVector3 dAB = (*B-*A);
CCVector3 dAC = (*C-*A);
CCVector3 dBC = (*C-*B);
CCVector3* dA = (CCVector3*)verticesDisplacement->getValue(tri->i1);
(*dA) += dAB+dAC;
CCVector3* dB = (CCVector3*)verticesDisplacement->getValue(tri->i2);
(*dB) += dBC-dAB;
CCVector3* dC = (CCVector3*)verticesDisplacement->getValue(tri->i3);
(*dC) -= dAC+dBC;
}
if (nProgress && !nProgress->oneStep())
{
//cancelled by user
break;
}
//apply displacement
verticesDisplacement->placeIteratorAtBegining();
for (unsigned i=0; i<vertCount; i++)
{
//this is a "persistent" pointer and we know what type of cloud is behind ;)
CCVector3* P = const_cast<CCVector3*>(m_associatedCloud->getPointPersistentPtr(i));
const CCVector3* d = (const CCVector3*)verticesDisplacement->getValue(i);
(*P) += (*d)*(factor/(PointCoordinateType)edgesCount[i]);
}
}
m_associatedCloud->updateModificationTime();
if (hasNormals())
computeNormals();
if (verticesDisplacement)
verticesDisplacement->release();
//.........这里部分代码省略.........
示例4: resampleCloudSpatially
//.........这里部分代码省略.........
unsigned char defaultLevel = octree->findBestLevelForAGivenNeighbourhoodSizeExtraction(minDistance);
bestOctreeLevel.push_back(defaultLevel);
}
}
catch (const std::bad_alloc&)
{
//not enough memory
markers->release();
if (!inputOctree)
{
delete octree;
}
delete sampledCloud;
return 0;
}
//progress notification
NormalizedProgress normProgress(progressCb, cloudSize);
if (progressCb)
{
if (progressCb->textCanBeEdited())
{
progressCb->setMethodTitle("Spatial resampling");
char buffer[256];
sprintf(buffer, "Points: %u\nMin dist.: %f", cloudSize, minDistance);
progressCb->setInfo(buffer);
}
progressCb->update(0);
progressCb->start();
}
//for each point in the cloud that is still 'marked', we look
//for its neighbors and remove their own marks
markers->placeIteratorAtBegining();
bool error = false;
//default octree level
assert(!bestOctreeLevel.empty());
unsigned char octreeLevel = bestOctreeLevel.front();
//default distance between points
PointCoordinateType minDistBetweenPoints = minDistance;
for (unsigned i=0; i<cloudSize; i++, markers->forwardIterator())
{
//no mark? we skip this point
if (markers->getCurrentValue() != 0)
{
//init neighbor search structure
const CCVector3* P = inputCloud->getPoint(i);
//parameters modulation
if (modParamsEnabled)
{
ScalarType sfVal = inputCloud->getPointScalarValue(i);
if (ScalarField::ValidValue(sfVal))
{
//modulate minDistance
minDistBetweenPoints = static_cast<PointCoordinateType>(sfVal * modParams.a + modParams.b);
//get (approximate) best level
size_t levelIndex = static_cast<size_t>(bestOctreeLevel.size() * (sfVal / (sfMax-sfMin)));
if (levelIndex == bestOctreeLevel.size())
--levelIndex;
octreeLevel = bestOctreeLevel[levelIndex];
}
else
{
minDistBetweenPoints = minDistance;
octreeLevel = bestOctreeLevel.front();