本文整理汇总了C++中cclib::ScalarField::currentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ ScalarField::currentSize方法的具体用法?C++ ScalarField::currentSize怎么用?C++ ScalarField::currentSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cclib::ScalarField
的用法示例。
在下文中一共展示了ScalarField::currentSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
++parts;
sprintf(partName,"%s.part_%i",cloudName,parts);
loadedCloud = new ccPointCloud(partName);
loadedCloud->reserveThePointsTable(fileChunkSize);
if (header.colors)
{
loadedCloud->reserveTheRGBTable();
loadedCloud->showColors(true);
}
if (header.normals)
{
loadedCloud->reserveTheNormsTable();
loadedCloud->showNormals(true);
}
if (header.scalarField)
loadedCloud->enableScalarField();
}
float Pf[3];
if (in.read((char*)Pf,sizeof(float)*3) < 0)
{
//Console::print("[BinFilter::loadModelFromBinaryFile] Error reading the %ith entity point !\n",k);
return CC_FERR_READING;
}
loadedCloud->addPoint(CCVector3::fromArray(Pf));
if (header.colors)
{
unsigned char C[3];
if (in.read((char*)C,sizeof(ColorCompType)*3) < 0)
{
//Console::print("[BinFilter::loadModelFromBinaryFile] Error reading the %ith entity colors !\n",k);
return CC_FERR_READING;
}
loadedCloud->addRGBColor(C);
}
if (header.normals)
{
CCVector3 N;
if (in.read((char*)N.u,sizeof(float)*3) < 0)
{
//Console::print("[BinFilter::loadModelFromBinaryFile] Error reading the %ith entity norms !\n",k);
return CC_FERR_READING;
}
loadedCloud->addNorm(N);
}
if (header.scalarField)
{
double D;
if (in.read((char*)&D,sizeof(double)) < 0)
{
//Console::print("[BinFilter::loadModelFromBinaryFile] Error reading the %ith entity distance!\n",k);
return CC_FERR_READING;
}
ScalarType d = static_cast<ScalarType>(D);
loadedCloud->setPointScalarValue(i,d);
}
lineRead++;
if (parameters.alwaysDisplayLoadDialog && !nprogress.oneStep())
{
loadedCloud->resize(i+1-fileChunkPos);
k=nbScansTotal;
i=nbOfPoints;
}
}
if (parameters.alwaysDisplayLoadDialog)
{
pdlg.stop();
QApplication::processEvents();
}
if (header.scalarField)
{
CCLib::ScalarField* sf = loadedCloud->getCurrentInScalarField();
assert(sf);
sf->setName(sfName);
//replace HIDDEN_VALUES by NAN_VALUES
for (unsigned i=0; i<sf->currentSize(); ++i)
{
if (sf->getValue(i) == FORMER_HIDDEN_POINTS)
sf->setValue(i,NAN_VALUE);
}
sf->computeMinAndMax();
loadedCloud->setCurrentDisplayedScalarField(loadedCloud->getCurrentInScalarFieldIndex());
loadedCloud->showSF(true);
}
container.addChild(loadedCloud);
}
return CC_FERR_NO_ERROR;
}
示例2: saveToFile
CC_FILE_ERROR LASFilter::saveToFile(ccHObject* entity, const char* filename)
{
if (!entity || !filename)
return CC_FERR_BAD_ARGUMENT;
ccHObject::Container clouds;
if (entity->isKindOf(CC_POINT_CLOUD))
clouds.push_back(entity);
else
entity->filterChildren(clouds, true, CC_POINT_CLOUD);
if (clouds.empty())
{
ccConsole::Error("No point cloud in input selection!");
return CC_FERR_BAD_ENTITY_TYPE;
}
else if (clouds.size()>1)
{
ccConsole::Error("Can't save more than one cloud per LAS file!");
return CC_FERR_BAD_ENTITY_TYPE;
}
//the cloud to save
ccGenericPointCloud* theCloud = static_cast<ccGenericPointCloud*>(clouds[0]);
unsigned numberOfPoints = theCloud->size();
if (numberOfPoints==0)
{
ccConsole::Error("Cloud is empty!");
return CC_FERR_BAD_ENTITY_TYPE;
}
//colors
bool hasColor = theCloud->hasColors();
//classification (as a scalar field)
CCLib::ScalarField* classifSF = 0;
if (theCloud->isA(CC_POINT_CLOUD))
{
ccPointCloud* pc = static_cast<ccPointCloud*>(theCloud);
int sfIdx = pc->getScalarFieldIndexByName(CC_LAS_CLASSIFICATION_FIELD_NAME);
if (sfIdx>=0)
{
classifSF = pc->getScalarField(sfIdx);
if (/*classifSF->getMax()>(ScalarType)liblas::Classification::class_table_size ||*/ classifSF->getMin()<0)
{
ccConsole::Warning("[LASFilter] Found a 'classification' scalar field, but its values outbounds LAS specifications (0-255)...");
classifSF = 0;
}
else
{
//we check that it's only integer values!
unsigned i,count=classifSF->currentSize();
classifSF->placeIteratorAtBegining();
double integerPart = 0.0;
for (i=0;i<count;++i)
{
if (modf(classifSF->getCurrentValue(),&integerPart) != 0.0)
{
ccConsole::Warning("[LASFilter] Found a 'classification' scalar field, but its values are not pure integers...");
classifSF = 0;
break;
}
}
}
}
}
//open binary file for writing
std::ofstream ofs;
ofs.open(filename, std::ios::out | std::ios::binary);
if (ofs.fail())
return CC_FERR_WRITING;
const double* shift = theCloud->getOriginalShift();
liblas::Writer* writer = 0;
try
{
liblas::Header header;
//LAZ support based on extension!
if (QFileInfo(filename).suffix().toUpper() == "LAZ")
{
header.SetCompressed(true);
}
//header.SetDataFormatId(liblas::ePointFormat3);
ccBBox bBox = theCloud->getBB();
if (bBox.isValid())
{
header.SetMin(-shift[0]+(double)bBox.minCorner().x,-shift[1]+(double)bBox.minCorner().y,-shift[2]+(double)bBox.minCorner().z);
header.SetMax(-shift[0]+(double)bBox.maxCorner().x,-shift[1]+(double)bBox.maxCorner().y,-shift[2]+(double)bBox.maxCorner().z);
CCVector3 diag = bBox.getDiagVec();
//Set offset & scale, as points will be stored as boost::int32_t values (between 0 and 4294967296)
//int_value = (double_value-offset)/scale
header.SetOffset(-shift[0]+(double)bBox.minCorner().x,-shift[1]+(double)bBox.minCorner().y,-shift[2]+(double)bBox.minCorner().z);
header.SetScale(1.0e-9*std::max<double>(diag.x,ZERO_TOLERANCE), //result must fit in 32bits?!
//.........这里部分代码省略.........