本文整理汇总了C++中ScalarField::release方法的典型用法代码示例。如果您正苦于以下问题:C++ ScalarField::release方法的具体用法?C++ ScalarField::release怎么用?C++ ScalarField::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScalarField
的用法示例。
在下文中一共展示了ScalarField::release方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addScalarField
int ChunkedPointCloud::addScalarField(const char* uniqueName)
{
//we don't accept two SF with the same name!
if (getScalarFieldIndexByName(uniqueName) >= 0)
return -1;
//create requested scalar field
ScalarField* sf = new ScalarField(uniqueName);
if (!sf || (size() && !sf->resize(size())))
{
//Not enough memory!
if (sf)
sf->release();
return -1;
}
try
{
//we don't want 'm_scalarFields' to grow by 50% each time! (default behavior of std::vector::push_back)
m_scalarFields.resize(m_scalarFields.size()+1);
}
catch (std::bad_alloc) //out of memory
{
sf->release();
return -1;
}
m_scalarFields.back() = sf;
sf->link();
return (int)m_scalarFields.size()-1;
}
示例2: addScalarField
int ChunkedPointCloud::addScalarField(const char* uniqueName, bool isStrictlyPositive)
{
//we don't accept two SF with the same name!
if (getScalarFieldIndexByName(uniqueName)>=0)
return -1;
//create requested scalar field
ScalarField* sf = new ScalarField(uniqueName,isStrictlyPositive);
if (!sf)
return -1;
//we don't want 'm_scalarFields' to grow by 50% each time! (default behavior of std::vector::push_back)
try
{
m_scalarFields.push_back(sf);
}
catch (.../*const std::bad_alloc&*/) //out of memory
{
sf->release();
return -1;
}
sf->link();
return (int)m_scalarFields.size()-1;
}
示例3: frontPropagationBasedSegmentation
//.........这里部分代码省略.........
unsigned maxDistIndex = 0, begin = 0;
CCVector3 startPoint;
while (true)
{
ScalarType maxDist = NAN_VALUE;
//on cherche la premiere distance superieure ou egale a "minSeedDist"
while (begin<numberOfPoints)
{
const CCVector3 *thePoint = theCloud->getPoint(begin);
const ScalarType& theDistance = theDists->getValue(begin);
++begin;
//FIXME DGM: what happens if SF is negative?!
if (theCloud->getPointScalarValue(begin) >= 0 && theDistance >= minSeedDist)
{
maxDist = theDistance;
startPoint = *thePoint;
maxDistIndex = begin;
break;
}
}
//il n'y a plus de point avec des distances suffisamment grandes !
if (maxDist<minSeedDist)
break;
//on finit la recherche du max
for (unsigned i=begin; i<numberOfPoints; ++i)
{
const CCVector3 *thePoint = theCloud->getPoint(i);
const ScalarType& theDistance = theDists->getValue(i);
if ((theCloud->getPointScalarValue(i)>=0.0)&&(theDistance > maxDist))
{
maxDist = theDistance;
startPoint = *thePoint;
maxDistIndex = i;
}
}
int pos[3];
theOctree->getTheCellPosWhichIncludesThePoint(&startPoint,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);
++seedPoints;
int result = fm->propagate();
//if the propagation was successful
if (result >= 0)
{
//we extract the corresponding points
ReferenceCloud* newCloud = new ReferenceCloud(theCloud);
if (fm->extractPropagatedPoints(newCloud) && newCloud->size() != 0)
{
theSegmentedLists.push_back(newCloud);
++numberOfSegmentedLists;
}
else
{
//not enough memory?!
delete newCloud;
newCloud = 0;
}
if (progressCb)
progressCb->update(float(numberOfSegmentedLists % 100));
fm->cleanLastPropagation();
//break;
}
if (maxDistIndex == begin)
++begin;
}
if (progressCb)
progressCb->stop();
for (unsigned i=0; i<numberOfPoints; ++i)
theCloud->setPointScalarValue(i,theDists->getValue(i));
delete fm;
fm = 0;
theDists->release();
theDists = 0;
if (!inputOctree)
delete theOctree;
return true;
}
示例4: RegisterClouds
ICPRegistrationTools::CC_ICP_RESULT ICPRegistrationTools::RegisterClouds(GenericIndexedCloudPersist* _modelCloud,
GenericIndexedCloudPersist* _dataCloud,
PointProjectionTools::Transformation& transform,
CC_ICP_CONVERGENCE_TYPE convType,
double minErrorDecrease,
unsigned nbMaxIterations,
double& finalError,
GenericProgressCallback* progressCb/*=0*/,
bool filterOutFarthestPoints/*=false*/,
unsigned samplingLimit/*=20000*/,
ScalarField* modelWeights/*=0*/,
ScalarField* dataWeights/*=0*/)
{
assert(_modelCloud && _dataCloud);
finalError = -1.0;
//MODEL CLOUD (reference, won't move)
GenericIndexedCloudPersist* modelCloud=_modelCloud;
ScalarField* _modelWeights=modelWeights;
{
if (_modelCloud->size()>samplingLimit) //shall we resample the clouds? (speed increase)
{
ReferenceCloud* subModelCloud = CloudSamplingTools::subsampleCloudRandomly(_modelCloud,samplingLimit);
if (subModelCloud && modelWeights)
{
_modelWeights = new ScalarField("ResampledModelWeights",modelWeights->isPositive());
unsigned realCount = subModelCloud->size();
if (_modelWeights->reserve(realCount))
{
for (unsigned i=0;i<realCount;++i)
_modelWeights->addElement(modelWeights->getValue(subModelCloud->getPointGlobalIndex(i)));
_modelWeights->computeMinAndMax();
}
else
{
//not enough memory
delete subModelCloud;
subModelCloud=0;
}
}
modelCloud = subModelCloud;
}
if (!modelCloud) //something bad happened
return ICP_ERROR_NOT_ENOUGH_MEMORY;
}
//DATA CLOUD (will move)
ReferenceCloud* dataCloud=0;
ScalarField* _dataWeights=dataWeights;
SimpleCloud* rotatedDataCloud=0; //temporary structure (rotated vertices)
{
if (_dataCloud->size()>samplingLimit) //shall we resample the clouds? (speed increase)
{
dataCloud = CloudSamplingTools::subsampleCloudRandomly(_dataCloud,samplingLimit);
if (dataCloud && dataWeights)
{
_dataWeights = new ScalarField("ResampledDataWeights",dataWeights->isPositive());
unsigned realCount = dataCloud->size();
if (_dataWeights->reserve(realCount))
{
for (unsigned i=0;i<realCount;++i)
_dataWeights->addElement(dataWeights->getValue(dataCloud->getPointGlobalIndex(i)));
_dataWeights->computeMinAndMax();
}
else
{
//not enough memory
delete dataCloud;
dataCloud=0;
}
}
}
else
{
//create a 'fake' reference cloud with all points
dataCloud = new ReferenceCloud(_dataCloud);
if (dataCloud->reserve(_dataCloud->size()))
{
dataCloud->addPointIndex(0,_dataCloud->size());
}
else //not enough memory
{
delete dataCloud;
dataCloud=0;
}
}
if (!dataCloud || !dataCloud->enableScalarField()) //something bad happened
{
if (dataCloud)
delete dataCloud;
if (modelCloud && modelCloud != _modelCloud)
delete modelCloud;
if (_modelWeights && _modelWeights!=modelWeights)
_modelWeights->release();
return ICP_ERROR_NOT_ENOUGH_MEMORY;
}
}
//.........这里部分代码省略.........
示例5: frontPropagationBasedSegmentation
//.........这里部分代码省略.........
progressCb->setMethodTitle("FM Propagation");
char buffer[256];
sprintf(buffer,"Octree level: %i\nNumber of points: %i",octreeLevel,numberOfPoints);
progressCb->setInfo(buffer);
progressCb->start();
}
unsigned maxDistIndex=0,begin = 0;
CCVector3 startPoint;
while (true)
{
maxDist = HIDDEN_VALUE;
//on cherche la première distance supérieure ou égale à "minSeedDist"
while (begin<numberOfPoints)
{
const CCVector3 *thePoint = theCloud->getPoint(begin);
const DistanceType& theDistance = theDists->getValue(begin);
++begin;
if ((theCloud->getPointScalarValue(begin)>=0.0)&&(theDistance >= minSeedDist))
{
maxDist = theDistance;
startPoint = *thePoint;
maxDistIndex = begin;
break;
}
}
//il n'y a plus de point avec des distances suffisamment grandes !
if (maxDist<minSeedDist)
break;
//on finit la recherche du max
for (unsigned i=begin;i<numberOfPoints;++i)
{
const CCVector3 *thePoint = theCloud->getPoint(i);
const DistanceType& theDistance = theDists->getValue(i);
if ((theCloud->getPointScalarValue(i)>=0.0)&&(theDistance > maxDist))
{
maxDist = theDistance;
startPoint = *thePoint;
maxDistIndex = i;
}
}
//on lance la propagation à partir du point de distance maximale
//propagateFromPoint(aList,_GradientNorms,maxDistIndex,octreeLevel,_gui);
int pos[3];
theOctree->getTheCellPosWhichIncludesThePoint(&startPoint,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);
++seedPoints;
int result = fm->propagate();
//si la propagation s'est bien passée
if (result>=0)
{
//on la termine (i.e. on extrait les points correspondant)
ReferenceCloud* newCloud = fm->extractPropagatedPoints();
//si la liste convient
//on la rajoute au groupe des listes segmentées
theSegmentedLists.push_back(newCloud);
++numberOfSegmentedLists;
if (progressCb)
progressCb->update(float(numberOfSegmentedLists % 100));
fm->endPropagation();
//break;
}
if (maxDistIndex == begin)
++begin;
}
if (progressCb)
progressCb->stop();
for (unsigned i=0;i<numberOfPoints;++i)
theCloud->setPointScalarValue(i,theDists->getValue(i));
delete fm;
theDists->release();
theDists=0;
if (!_theOctree)
delete theOctree;
return true;
}
示例6: computeScalarFieldGradient
int ScalarFieldTools::computeScalarFieldGradient( GenericIndexedCloudPersist* theCloud,
PointCoordinateType radius,
bool euclideanDistances,
bool sameInAndOutScalarField/*=false*/,
GenericProgressCallback* progressCb/*=0*/,
DgmOctree* theCloudOctree/*=0*/)
{
if (!theCloud)
return -1;
DgmOctree* theOctree = theCloudOctree;
if (!theOctree)
{
theOctree = new DgmOctree(theCloud);
if (theOctree->build(progressCb)<1)
{
delete theOctree;
return -2;
}
}
unsigned char octreeLevel = 0;
if (radius <= 0)
{
octreeLevel = theOctree->findBestLevelForAGivenPopulationPerCell(AVERAGE_NUMBER_OF_POINTS_FOR_GRADIENT_COMPUTATION);
radius = theOctree->getCellSize(octreeLevel);
}
else
{
octreeLevel = theOctree->findBestLevelForAGivenNeighbourhoodSizeExtraction(radius);
}
ScalarField* theGradientNorms = new ScalarField("gradient norms");
ScalarField* _theGradientNorms = 0;
//mode champ scalaire "IN" et "OUT" identique
if (sameInAndOutScalarField)
{
if (!theGradientNorms->reserve(theCloud->size())) //not enough memory
{
if (!theCloudOctree)
delete theOctree;
theGradientNorms->release();
return -3;
}
_theGradientNorms = theGradientNorms;
}
else
//mode champs scalaires "IN" et "OUT" dfferents (par defaut)
{
//on initialise les distances (IN - en ecriture) pour recevoir les normes du gradient
if (!theCloud->enableScalarField())
{
if (!theCloudOctree)
delete theOctree;
theGradientNorms->release();
return -4;
}
}
//structure contenant les parametres additionnels
void* additionalParameters[3] = { static_cast<void*>(&euclideanDistances),
static_cast<void*>(&radius),
static_cast<void*>(_theGradientNorms)
};
int result = 0;
if (theOctree->executeFunctionForAllCellsAtLevel( octreeLevel,
computeMeanGradientOnPatch,
additionalParameters,
true,
progressCb,
"Gradient Computation") == 0)
{
//something went wrong
result = -5;
}
if (!theCloudOctree)
delete theOctree;
theGradientNorms->release();
theGradientNorms=0;
return result;
}