本文整理汇总了C++中cclib::ScalarField::computeMinAndMax方法的典型用法代码示例。如果您正苦于以下问题:C++ ScalarField::computeMinAndMax方法的具体用法?C++ ScalarField::computeMinAndMax怎么用?C++ ScalarField::computeMinAndMax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cclib::ScalarField
的用法示例。
在下文中一共展示了ScalarField::computeMinAndMax方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refCloud
//.........这里部分代码省略.........
assert(exportedSFs.size() == exportedFields.size());
for (size_t i=0; i<exportedSFs.size(); ++i)
{
if (!exportedSFs[i])
{
continue;
}
if (exportedFields[i] == PER_CELL_HEIGHT)
{
//we set the point height to the default height
ScalarType s = static_cast<ScalarType>(emptyCellsHeight);
exportedSFs[i]->addElement(s);
}
else
{
exportedSFs[i]->addElement(NAN_VALUE);
}
}
}
Px += m_grid.gridStep;
}
Py += m_grid.gridStep;
}
assert(exportedSFs.size() == exportedFields.size());
for (size_t i=0; i<exportedSFs.size(); ++i)
{
CCLib::ScalarField* sf = exportedSFs[i];
if (sf)
{
sf->computeMinAndMax();
}
}
//take care of former scalar fields
if (!resampleInputCloud)
{
if (interpolateSF && inputCloud && inputCloud->isA(CC_TYPES::POINT_CLOUD))
{
ccPointCloud* pc = static_cast<ccPointCloud*>(inputCloud);
for (size_t k=0; k<m_grid.scalarFields.size(); ++k)
{
double* _sfGrid = m_grid.scalarFields[k];
if (_sfGrid) //valid SF grid
{
//the corresponding SF should exist on the input cloud
ccScalarField* formerSf = static_cast<ccScalarField*>(pc->getScalarField(static_cast<int>(k)));
assert(formerSf);
//we try to create an equivalent SF on the output grid
int sfIdx = cloudGrid->addScalarField(formerSf->getName());
if (sfIdx < 0) //if we aren't lucky, the input cloud already had a SF with CC_HEIGHT_GRID_FIELD_NAME as name
sfIdx = cloudGrid->addScalarField(qPrintable(QString(formerSf->getName()).append(".old")));
if (sfIdx < 0)
{
ccLog::Warning("[Rasterize] Couldn't allocate a new scalar field for storing SF '%s' values! Try to free some memory ...",formerSf->getName());
}
else
{
ccScalarField* sf = static_cast<ccScalarField*>(cloudGrid->getScalarField(sfIdx));
assert(sf);
//set sf values
示例2: if
//.........这里部分代码省略.........
//Creation
ccPointCloud* loadedCloud = new ccPointCloud(cloudName);
if (!loadedCloud)
return CC_FERR_NOT_ENOUGH_MEMORY;
unsigned fileChunkPos = 0;
unsigned fileChunkSize = std::min(nbOfPoints,CC_MAX_NUMBER_OF_POINTS_PER_CLOUD);
loadedCloud->reserveThePointsTable(fileChunkSize);
if (header.colors)
{
loadedCloud->reserveTheRGBTable();
loadedCloud->showColors(true);
}
if (header.normals)
{
loadedCloud->reserveTheNormsTable();
loadedCloud->showNormals(true);
}
if (header.scalarField)
loadedCloud->enableScalarField();
unsigned lineRead = 0;
int parts = 0;
const ScalarType FORMER_HIDDEN_POINTS = (ScalarType)-1.0;
//lecture du fichier
for (unsigned i=0; i<nbOfPoints; ++i)
{
if (lineRead == fileChunkPos+fileChunkSize)
{
if (header.scalarField)
loadedCloud->getCurrentInScalarField()->computeMinAndMax();
container.addChild(loadedCloud);
fileChunkPos = lineRead;
fileChunkSize = std::min(nbOfPoints-lineRead,CC_MAX_NUMBER_OF_POINTS_PER_CLOUD);
char partName[64];
++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));
示例3: loadFile
//.........这里部分代码省略.........
if (success<1)
{
if (mesh)
delete mesh;
delete cloud;
return CC_FERR_READING;
}
//we check mesh
if (mesh && mesh->size()==0)
{
if (s_unsupportedPolygonType)
ccConsole::Error("Mesh is not triangular! (unsupported)");
else
ccConsole::Error("Mesh is empty!");
delete mesh;
mesh=0;
}
//we save coordinates shift information
if (s_ShiftApplyAll && coordinatesShiftEnabled && coordinatesShift)
{
*coordinatesShiftEnabled = true;
coordinatesShift[0] = s_Pshift[0];
coordinatesShift[1] = s_Pshift[1];
coordinatesShift[2] = s_Pshift[2];
}
//we update scalar field
CCLib::ScalarField* sf = cloud->getCurrentInScalarField();
if (sf)
{
sf->setPositive(!s_negSF);
sf->computeMinAndMax();
int sfIdx = cloud->getCurrentInScalarFieldIndex();
cloud->setCurrentDisplayedScalarField(sfIdx);
cloud->showSF(sfIdx>=0);
}
if (mesh)
{
assert(s_triCount > 0);
//check number of loaded facets against 'theoretical' number
if (s_triCount<numberOfFacets)
{
mesh->resize(s_triCount);
ccConsole::Warning("[PLY] Missing vertex indexes!");
}
//check that vertex indices start at 0
unsigned minVertIndex=numberOfPoints,maxVertIndex=0;
for (unsigned i=0;i<s_triCount;++i)
{
const CCLib::TriangleSummitsIndexes* tri = mesh->getTriangleIndexes(i);
if (tri->i1 < minVertIndex)
minVertIndex = tri->i1;
else if (tri->i1 > maxVertIndex)
maxVertIndex = tri->i1;
if (tri->i2 < minVertIndex)
minVertIndex = tri->i2;
else if (tri->i2 > maxVertIndex)
maxVertIndex = tri->i2;
if (tri->i3 < minVertIndex)
minVertIndex = tri->i3;
else if (tri->i3 > maxVertIndex)
maxVertIndex = tri->i3;
示例4: loadFile
CC_FILE_ERROR PVFilter::loadFile(QString filename, ccHObject& container, LoadParameters& parameters)
{
//opening file
QFile in(filename);
if (!in.open(QIODevice::ReadOnly))
return CC_FERR_READING;
//we deduce the points number from the file size
qint64 fileSize = in.size();
qint64 singlePointSize = 4*sizeof(float);
//check that size is ok
if (fileSize == 0)
return CC_FERR_NO_LOAD;
if ((fileSize % singlePointSize) != 0)
return CC_FERR_MALFORMED_FILE;
unsigned numberOfPoints = static_cast<unsigned>(fileSize / singlePointSize);
//progress dialog
ccProgressDialog pdlg(true); //cancel available
CCLib::NormalizedProgress nprogress(&pdlg,numberOfPoints);
pdlg.setMethodTitle("Open PV file");
pdlg.setInfo(qPrintable(QString("Points: %1").arg(numberOfPoints)));
pdlg.start();
ccPointCloud* loadedCloud = 0;
//if the file is too big, it will be chuncked in multiple parts
unsigned chunkIndex = 0;
unsigned fileChunkPos = 0;
unsigned fileChunkSize = 0;
//number of points read for the current cloud part
unsigned pointsRead = 0;
CC_FILE_ERROR result = CC_FERR_NO_ERROR;
for (unsigned i=0;i<numberOfPoints;i++)
{
//if we reach the max. cloud size limit, we cerate a new chunk
if (pointsRead == fileChunkPos+fileChunkSize)
{
if (loadedCloud)
{
int sfIdx = loadedCloud->getCurrentInScalarFieldIndex();
if (sfIdx>=0)
{
CCLib::ScalarField* sf = loadedCloud->getScalarField(sfIdx);
sf->computeMinAndMax();
loadedCloud->setCurrentDisplayedScalarField(sfIdx);
loadedCloud->showSF(true);
}
container.addChild(loadedCloud);
}
fileChunkPos = pointsRead;
fileChunkSize = std::min<unsigned>(numberOfPoints-pointsRead,CC_MAX_NUMBER_OF_POINTS_PER_CLOUD);
loadedCloud = new ccPointCloud(QString("unnamed - Cloud #%1").arg(++chunkIndex));
if (!loadedCloud || !loadedCloud->reserveThePointsTable(fileChunkSize) || !loadedCloud->enableScalarField())
{
result = CC_FERR_NOT_ENOUGH_MEMORY;
if (loadedCloud)
delete loadedCloud;
loadedCloud=0;
break;
}
}
//we read the 3 coordinates of the point
float rBuff[3];
if (in.read((char*)rBuff,3*sizeof(float))>=0)
{
//conversion to CCVector3
CCVector3 P((PointCoordinateType)rBuff[0],
(PointCoordinateType)rBuff[1],
(PointCoordinateType)rBuff[2]);
loadedCloud->addPoint(P);
}
else
{
result = CC_FERR_READING;
break;
}
//then the scalar value
if (in.read((char*)rBuff,sizeof(float))>=0)
{
loadedCloud->setPointScalarValue(pointsRead,(ScalarType)rBuff[0]);
}
else
{
//add fake scalar value for consistency then break
loadedCloud->setPointScalarValue(pointsRead,0);
result = CC_FERR_READING;
break;
}
++pointsRead;
if (!nprogress.oneStep())
{
result = CC_FERR_CANCELED_BY_USER;
break;
}
}
//.........这里部分代码省略.........
示例5: loadFile
//.........这里部分代码省略.........
for (unsigned i=0; i<ptsCount; ++i)
{
nextline = inFile.readLine();
if (sf) //otherwise we simply skip the line
{
QStringList parts = nextline.split(" ",QString::SkipEmptyParts);
if (parts.size() != 1)
{
//get rid of the scalar field :(
vertices->deleteScalarField(newSFIndex);
sf = 0;
if (i == 0)
{
ccLog::Warning(QString("[VTK] %1 field with more than one element can't be imported as scalar fields!").arg(itemName));
}
else
{
error = CC_FERR_MALFORMED_FILE;
break;
}
}
else
{
bool ok;
ScalarType d = static_cast<ScalarType>(nextline.toDouble(&ok));
sf->setValue(i, ok ? d : NAN_VALUE);
}
}
}
if (sf)
{
sf->computeMinAndMax();
vertices->setCurrentDisplayedScalarField(newSFIndex);
vertices->showSF(true);
}
//end of SCALARS
}
else if (nextline.startsWith("POINT_DATA"))
{
//check that the number of 'point_data' match the number of points
QStringList parts = nextline.split(" ",QString::SkipEmptyParts);
acceptLookupTables = false;
if (parts.size() > 1)
{
bool ok;
unsigned dataCount = parts[1].toUInt(&ok);
if (ok && vertices && dataCount == vertices->size())
{
acceptLookupTables = true;
}
}
if (!acceptLookupTables)
{
ccLog::Warning("[VTK] The number of 'POINT_DATA' doesn't match the number of loaded points... lookup tables will be ignored");
}
}
else //unhandled property (CELLS, CELL_TYPES, etc.)
{
QStringList parts = nextline.split(" ",QString::SkipEmptyParts);
if (parts.size() < 2)
{
ccLog::Warning(QString("[VTK] Unhandled element: %1").arg(parts[0]));
error = CC_FERR_MALFORMED_FILE;
示例6: loadFile
//.........这里部分代码省略.........
{
return CC_FERR_NO_LOAD;
}
//load shapes
CC_FILE_ERROR error = CC_FERR_NO_ERROR;
ccPointCloud* singlePoints = 0;
qint64 pos = file.pos();
while (fileLength >= 12)
{
file.seek(pos);
assert(pos + fileLength == file.size());
//load shape record in main SHP file
{
file.read(header,8);
//Byte 0: Record Number
int32_t recordNumber = qFromBigEndian<int32_t>(*reinterpret_cast<const int32_t*>(header)); //Record numbers begin at 1
//Byte 4: Content Length
int32_t recordSize = qFromBigEndian<int32_t>(*reinterpret_cast<const int32_t*>(header+4)); //Record numbers begin at 1
recordSize *= 2; //recordSize is measured in 16-bit words
fileLength -= 8;
pos += 8;
if (fileLength < recordSize)
{
assert(false);
error = CC_FERR_MALFORMED_FILE;
break;
}
fileLength -= recordSize;
pos += recordSize;
//Record start (byte 0): Shape Type
if (recordSize < 4)
{
assert(false);
error = CC_FERR_MALFORMED_FILE;
break;
}
file.read(header,4);
recordSize -= 4;
int32_t shapeTypeInt = qToLittleEndian<int32_t>(*reinterpret_cast<const int32_t*>(header));
ccLog::Print(QString("[SHP] Record #%1 - type: %2 (%3 bytes)").arg(recordNumber).arg(ToString(static_cast<ESRI_SHAPE_TYPE>(shapeTypeInt))).arg(recordSize));
switch (shapeTypeInt)
{
case SHP_POLYLINE:
case SHP_POLYLINE_Z:
case SHP_POLYGON:
case SHP_POLYGON_Z:
error = LoadPolyline(file,container,recordNumber,static_cast<ESRI_SHAPE_TYPE>(shapeTypeInt),Pshift);
break;
case SHP_MULTI_POINT:
case SHP_MULTI_POINT_Z:
case SHP_MULTI_POINT_M:
error = LoadCloud(file,container,recordNumber,static_cast<ESRI_SHAPE_TYPE>(shapeTypeInt),Pshift);
break;
case SHP_POINT:
case SHP_POINT_Z:
case SHP_POINT_M:
error = LoadSinglePoint(file,singlePoints,static_cast<ESRI_SHAPE_TYPE>(shapeTypeInt),Pshift);
break;
//case SHP_MULTI_PATCH:
// error = LoadMesh(file,recordSize);
// break;
case SHP_NULL_SHAPE:
//ignored
break;
default:
//unhandled entity
ccLog::Warning("[SHP] Unhandled type!");
break;
}
}
if (error != CC_FERR_NO_ERROR)
break;
}
if (singlePoints)
{
if (singlePoints->size() == 0)
{
delete singlePoints;
singlePoints = 0;
}
else
{
CCLib::ScalarField* sf = singlePoints->getScalarField(0);
if (sf)
{
sf->computeMinAndMax();
singlePoints->showSF(true);
}
container.addChild(singlePoints);
}
}
return error;
}
示例7: loadFile
//.........这里部分代码省略.........
if ( size == 0 || ((size % sizeof(MarkersFrame)) != 0))
return CC_FERR_MALFORMED_FILE;
//number of transformations in file
long count = size / sizeof(MarkersFrame);
ccConsole::Print("[TransBuffer] Found %i trans. in file '%s'",count,filename);
if (count<1)
return CC_FERR_NO_LOAD;
ccPointCloud* cloud = new ccPointCloud();
if (!cloud->reserve(count) || !cloud->enableScalarField())
{
delete cloud;
return CC_FERR_NOT_ENOUGH_MEMORY;
}
ccProgressDialog pdlg(true);
pdlg.setMethodTitle("Open Ult File");
CCLib::NormalizedProgress nprogress(&pdlg,count);
pdlg.reset();
pdlg.setInfo(qPrintable(QString("Transformations: %1").arg(count)));
pdlg.start();
QApplication::processEvents();
FILE* fp = fopen(filename,"rb");
if (!fp)
{
delete cloud;
return CC_FERR_READING;
}
//which marker is the reference?
QMessageBox::StandardButton tibiaIsRef = QMessageBox::question(0, "Choose reference", "Tibia as reference (yes)? Or femur (no)? Or none (no to all)", QMessageBox::Yes | QMessageBox::No | QMessageBox::NoToAll, QMessageBox::Yes );
MARKER_ROLE referenceRole = MARKER_LOCALIZER;
if (tibiaIsRef == QMessageBox::Yes)
referenceRole = MARKER_TIBIA;
else if (tibiaIsRef == QMessageBox::No)
referenceRole = MARKER_FEMUR;
//To apply a predefined pointer tip
//CCVector3 tip(0,0,0);
CCVector3 tip(-90.07f, -17.68f, 18.29f);
MarkersFrame currentframe;
MarkerState& currentMarker = currentframe.states[MARKER_POINTER];
MarkerState* referenceMarker = 0;
if (referenceRole != MARKER_LOCALIZER)
referenceMarker = currentframe.states+referenceRole;
unsigned MarkersFrameSize = sizeof(MarkersFrame);
unsigned realCount=0;
for (long i=0;i<count;++i)
{
if (fread(¤tframe,MarkersFrameSize,1,fp)==0)
{
fclose(fp);
delete cloud;
return CC_FERR_READING;
}
if (currentMarker.visible && (!referenceMarker || referenceMarker->visible))
{
CCVector3 P(tip);
ccGLMatrix trans = currentMarker.pos;
if (referenceMarker)
trans = referenceMarker->pos.inverse() * trans;
trans.apply(P);
cloud->addPoint(P);
cloud->setPointScalarValue(realCount,currentMarker.pos.timestamp);
++realCount;
}
if (!nprogress.oneStep())
break;
}
fclose(fp);
if (realCount==0)
{
delete cloud;
return CC_FERR_NO_LOAD;
}
cloud->resize(realCount);
//we update scalar field
CCLib::ScalarField* sf = cloud->getCurrentInScalarField();
if (sf)
{
sf->setPositive(true);
sf->computeMinAndMax();
cloud->setCurrentDisplayedScalarField(cloud->getCurrentInScalarFieldIndex());
}
container.addChild(cloud);
return CC_FERR_NO_ERROR;
}
示例8: loadFile
//.........这里部分代码省略.........
if (mesh)
delete mesh;
delete cloud;
return CC_FERR_READING;
}
//we check mesh
if (mesh && mesh->size() == 0)
{
if (s_unsupportedPolygonType)
ccLog::Error("Mesh is not triangular! (unsupported)");
else
ccLog::Error("Mesh is empty!");
delete mesh;
mesh=0;
}
if (texCoords && (s_invalidTexCoordinates || s_texCoordCount != 3*mesh->size()))
{
ccLog::Error("Invalid texture coordinates! (they will be ignored)");
texCoords->release();
texCoords=0;
}
//we save parameters
parameters = s_loadParameters;
//we update scalar field(s)
{
for (unsigned i=0; i<cloud->getNumberOfScalarFields(); ++i)
{
CCLib::ScalarField* sf = cloud->getScalarField(i);
assert(sf);
sf->computeMinAndMax();
if (i == 0)
{
cloud->setCurrentDisplayedScalarField(0);
cloud->showSF(true);
}
}
}
if (mesh)
{
assert(s_triCount > 0);
//check number of loaded facets against 'theoretical' number
if (s_triCount<numberOfFacets)
{
mesh->resize(s_triCount);
ccLog::Warning("[PLY] Missing vertex indexes!");
}
//check that vertex indices start at 0
unsigned minVertIndex=numberOfPoints,maxVertIndex=0;
for (unsigned i=0;i<s_triCount;++i)
{
const CCLib::TriangleSummitsIndexes* tri = mesh->getTriangleIndexes(i);
if (tri->i1 < minVertIndex)
minVertIndex = tri->i1;
else if (tri->i1 > maxVertIndex)
maxVertIndex = tri->i1;
if (tri->i2 < minVertIndex)
minVertIndex = tri->i2;
else if (tri->i2 > maxVertIndex)
maxVertIndex = tri->i2;
if (tri->i3 < minVertIndex)
示例9: if
//.........这里部分代码省略.........
unsigned fileChunkPos = 0;
unsigned fileChunkSize = ccMin(nbOfPoints,CC_MAX_NUMBER_OF_POINTS_PER_CLOUD);
loadedCloud->reserveThePointsTable(fileChunkSize);
if (header.colors)
{
loadedCloud->reserveTheRGBTable();
loadedCloud->showColors(true);
}
if (header.normals)
{
loadedCloud->reserveTheNormsTable();
loadedCloud->showNormals(true);
}
if (header.scalarField)
loadedCloud->enableScalarField();
CCVector3 P;
unsigned char C[3];
double D;
//does the associated scalar field is negative?
bool negSF = false;
unsigned lineReaded=0;
int parts = 0;
//lecture du fichier
for (unsigned i=0;i<nbOfPoints;++i)
{
if (lineReaded == fileChunkPos+fileChunkSize)
{
if (header.scalarField)
loadedCloud->getCurrentInScalarField()->computeMinAndMax();
container.addChild(loadedCloud);
fileChunkPos = lineReaded;
fileChunkSize = ccMin(nbOfPoints-lineReaded,CC_MAX_NUMBER_OF_POINTS_PER_CLOUD);
char partName[64];
++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();
}
if (in.read((char*)P.u,sizeof(float)*3)<0)
{
//Console::print("[BinFilter::loadModelFromBinaryFile] Error reading the %ith entity point !\n",k);
return CC_FERR_READING;
}
loadedCloud->addPoint(P);
if (header.colors)