本文整理汇总了C++中ccHObject类的典型用法代码示例。如果您正苦于以下问题:C++ ccHObject类的具体用法?C++ ccHObject怎么用?C++ ccHObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ccHObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: transferChildren
void ccHObject::transferChildren(ccHObject& newParent, bool forceFatherDependent/*=false*/)
{
for (Container::iterator it = m_children.begin(); it != m_children.end(); ++it)
{
//remove link from old parent
bool fatherDependent = (*it)->getFlagState(CC_FATHER_DEPENDANT) || forceFatherDependent;
if (fatherDependent)
(*it)->setFlagState(CC_FATHER_DEPENDANT,false);
newParent.addChild(*it,fatherDependent);
}
m_children.clear();
}
开发者ID:vivzqs,项目名称:trunk,代码行数:13,代码来源:ccHObject.cpp
示例2: loadFile
CC_FILE_ERROR DxfFilter::loadFile(const char* filename, ccHObject& container, bool alwaysDisplayLoadDialog/*=true*/, bool* coordinatesShiftEnabled/*=0*/, double* coordinatesShift/*=0*/)
{
#ifdef CC_DXF_SUPPORT
DxfImporter importer(&container);
if (!DL_Dxf().in(qPrintable(filename), &importer))
{
return CC_FERR_READING;
}
#else
ccLog::Error("[DXF] Not supported in this version!");
#endif
return container.getChildrenNumber() == 0 ? CC_FERR_NO_LOAD : CC_FERR_NO_ERROR;
}
开发者ID:kod3r,项目名称:trunk,代码行数:14,代码来源:DxfFilter.cpp
示例3: loadFile
CC_FILE_ERROR ImageFileFilter::loadFile(QString filename, ccHObject& container, LoadParameters& parameters)
{
QImage qImage;
if (!qImage.load(filename))
{
ccLog::Warning(QString("[IMAGE] Failed to load image '%1").arg(filename));
return CC_FERR_CONSOLE_ERROR;
}
//create corresponding ccImage
ccImage* image = new ccImage(qImage,QFileInfo(filename).baseName());
container.addChild(image);
return CC_FERR_NO_ERROR;
}
开发者ID:coolshahabaz,项目名称:trunk,代码行数:16,代码来源:ImageFileFilter.cpp
示例4: getChild
void ccHObject::transferChild(unsigned index, ccHObject& newParent)
{
ccHObject* child = getChild(index);
if (!child)
{
assert(false);
return;
}
//remove link from old parent
bool fatherDependent = child->getFlagState(CC_FATHER_DEPENDANT);
if (fatherDependent)
child->setFlagState(CC_FATHER_DEPENDANT,false);
removeChild(index);
newParent.addChild(child,fatherDependent);
}
开发者ID:vivzqs,项目名称:trunk,代码行数:16,代码来源:ccHObject.cpp
示例5: handler
CC_FILE_ERROR X3DFilter::loadFile(QString filename, ccHObject& container, LoadParameters& parameters)
{
XIOT::X3DLoader loader;
X3DXIOTNodeHandler handler(&container);
loader.setNodeHandler(&handler);
try
{
loader.load(qPrintable(filename));
}
catch (XIOT::X3DParseException& e)
{
ccLog::Error("[X3DFilter] Error: '%s' (line: %i, col.: %i)\n",e.getMessage().c_str(),e.getLineNumber(),e.getColumnNumber());
return CC_FERR_READING;
}
if (container.getChildrenNumber() == 0)
return CC_FERR_NO_LOAD;
return CC_FERR_NO_ERROR;
}
开发者ID:AmineVisionic,项目名称:trunk,代码行数:20,代码来源:X3DFilter.cpp
示例6: transferChild
//=====================================transferChild===============================================================//
void ccHObject::transferChild(ccHObject* child, ccHObject& newParent)
{
assert(child);
//remove link from old parent //从原先的父亲物体中删除依赖关系
int childDependencyFlags = child->getDependencyFlagsWith(this); //获取子物体对父物体的依赖关系
int parentDependencyFlags = getDependencyFlagsWith(child); //获取父亲物体对子物体的依赖关系
//automatically removes any dependency with this object //只是删除与该物体的依赖关系//两两之间
detachChild(child);
//新的父物体添加孩子物体 //依赖关系也同时转移
newParent.addChild(child,parentDependencyFlags);
//子物体添加依赖关系
child->addDependency(&newParent,childDependencyFlags);
//after a successful transfer, either the parent is 'newParent' or a null pointer
assert(child->getParent() == &newParent || child->getParent() == 0);
}
开发者ID:swayfreeda,项目名称:IGITLandscapeViewer,代码行数:21,代码来源:ccHObject.cpp
示例7: assert
CC_FILE_ERROR BinFilter::loadFileV2(QFile& in, ccHObject& container)
{
assert(in.isOpen());
uint32_t binVersion = 20;
if (in.read((char*)&binVersion,4)<0)
return CC_FERR_READING;
if (binVersion<20) //should be superior to 2.0!
return CC_FERR_MALFORMED_FILE;
ccLog::Print(QString("[BIN] Version %1.%2").arg(binVersion/10).arg(binVersion%10));
ccProgressDialog pdlg(true);
pdlg.setMethodTitle(qPrintable(QString("Open Bin file (V%1.%2)").arg(binVersion/10).arg(binVersion%10)));
//we keep track of the last unique ID before load
unsigned lastUniqueIDBeforeLoad = ccObject::GetLastUniqueID();
//we read first entity type
unsigned classID=0;
if (!ccObject::ReadClassIDFromFile(classID, in, binVersion))
return CC_FERR_CONSOLE_ERROR;
ccHObject* root = ccHObject::New(classID);
if (!root)
return CC_FERR_MALFORMED_FILE;
if (!root->fromFile(in,binVersion))
{
//DGM: can't delete it, too dangerous (bad pointers ;)
//delete root;
return CC_FERR_CONSOLE_ERROR;
}
CC_FILE_ERROR result = CC_FERR_NO_ERROR;
//re-link objects
ccHObject::Container toCheck;
toCheck.push_back(root);
while (!toCheck.empty())
{
ccHObject* currentObject = toCheck.back();
toCheck.pop_back();
assert(currentObject);
//we check objects that have links to other entities (meshes, polylines, etc.)
if (currentObject->isKindOf(CC_MESH))
{
ccGenericMesh* mesh = static_cast<ccGenericMesh*>(currentObject);
//vertices
//special case: if the parent is a mesh group, then the job has already be done once and for all!
if (!mesh->getParent() || !mesh->getParent()->isA(CC_MESH_GROUP))
{
intptr_t cloudID = (intptr_t)mesh->getAssociatedCloud();
if (cloudID>0)
{
ccHObject* cloud = root->find(cloudID);
if (cloud && cloud->isKindOf(CC_POINT_CLOUD))
mesh->setAssociatedCloud(static_cast<ccGenericPointCloud*>(cloud));
else
{
//we have a problem here ;)
mesh->setAssociatedCloud(0);
if (mesh->getMaterialSet())
mesh->setMaterialSet(0,false);
//DGM: can't delete it, too dangerous (bad pointers ;)
//delete root;
ccLog::Warning(QString("[BinFilter::loadFileV2] Couldn't find vertices (ID=%1) for mesh '%2' in the file!").arg(cloudID).arg(mesh->getName()));
return CC_FERR_MALFORMED_FILE;
}
}
}
//materials
intptr_t matSetID = (intptr_t)mesh->getMaterialSet();
if (matSetID>0)
{
ccHObject* materials = root->find(matSetID);
if (materials && materials->isA(CC_MATERIAL_SET))
mesh->setMaterialSet(static_cast<ccMaterialSet*>(materials),false);
else
{
//we have a (less severe) problem here ;)
mesh->setMaterialSet(0,false);
mesh->showMaterials(false);
ccLog::Warning(QString("[BinFilter::loadFileV2] Couldn't find shared materials set (ID=%1) for mesh '%2' in the file!").arg(matSetID).arg(mesh->getName()));
result = CC_FERR_BROKEN_DEPENDENCY_ERROR;
}
}
//per-triangle normals
intptr_t triNormsTableID = (intptr_t)mesh->getTriNormsTable();
if (triNormsTableID>0)
{
ccHObject* triNormsTable = root->find(triNormsTableID);
if (triNormsTable && triNormsTable->isA(CC_NORMAL_INDEXES_ARRAY))
mesh->setTriNormsTable(static_cast<NormsIndexesTableType*>(triNormsTable),false);
else
{
//we have a (less severe) problem here ;)
mesh->setTriNormsTable(0,false);
//.........这里部分代码省略.........
开发者ID:jebd,项目名称:trunk,代码行数:101,代码来源:BinFilter.cpp
示例8: loadFile
CC_FILE_ERROR VTKFilter::loadFile(const char* filename, ccHObject& container, bool alwaysDisplayLoadDialog/*=true*/, bool* coordinatesShiftEnabled/*=0*/, CCVector3d* coordinatesShift/*=0*/)
{
//open ASCII file for reading
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return CC_FERR_READING;
QTextStream inFile(&file);
//read header
QString nextline = inFile.readLine();
if (!nextline.startsWith("# vtk"))
return CC_FERR_MALFORMED_FILE;
//comment
nextline = inFile.readLine();
ccLog::Print(QString("[VTK] ")+nextline);
ccMesh* mesh = 0;
ccPointCloud* vertices = 0;
std::vector<int> indexes; //global so as to avoid unnecessary mem. allocations
QString lastSfName;
bool acceptLookupTables = true;
QString fileType = inFile.readLine().toUpper();
if (fileType.startsWith("BINARY"))
{
//binary not supported yet!
ccLog::Error("VTK binary format not supported yet!");
return CC_FERR_WRONG_FILE_TYPE;
}
else if (fileType.startsWith("ASCII"))
{
//allow blank lines
QString dataType;
if (!GetNextNonEmptyLine(inFile,dataType))
return CC_FERR_MALFORMED_FILE;
if (!dataType.startsWith("DATASET"))
return CC_FERR_MALFORMED_FILE;
dataType.remove(0,8);
if (dataType.startsWith("POLYDATA"))
{
vertices = new ccPointCloud("vertices");
mesh = new ccMesh(vertices);
}
else if (dataType.startsWith("UNSTRUCTURED_GRID"))
{
vertices = new ccPointCloud("unnamed - VTK unstructured grid");
}
else
{
ccLog::Error(QString("VTK entity '%1' is not supported!").arg(dataType));
return CC_FERR_WRONG_FILE_TYPE;
}
}
//loop on keywords/data
CC_FILE_ERROR error = CC_FERR_NO_ERROR;
CCVector3d Pshift(0,0,0);
while (error == CC_FERR_NO_ERROR)
{
if (!GetNextNonEmptyLine(inFile,nextline))
break; //end of file
assert(!nextline.isEmpty());
if (nextline.startsWith("POINTS"))
{
QStringList parts = nextline.split(" ",QString::SkipEmptyParts);
if (parts.size() != 3)
{
error=CC_FERR_MALFORMED_FILE;
break;
}
bool ok = false;
unsigned ptsCount = parts[1].toInt(&ok);
if (!ok)
{
error = CC_FERR_MALFORMED_FILE;
break;
}
//QString dataFormat = parts[3].toUpper();
//char buffer[8];
//unsigned char datSize = 4;
//if (dataFormat == "DOUBLE")
//{
// datSize = 8;
//}
//else if (dataFormat != "FLOAT")
//{
// ccLog::Error(QString("Non floating point data (%1) is not supported!").arg(dataFormat));
// error = CC_FERR_WRONG_FILE_TYPE;
// break;
//}
if (!vertices->reserve(ptsCount))
{
//.........这里部分代码省略.........
开发者ID:Aerochip7,项目名称:trunk,代码行数:101,代码来源:VTKFilter.cpp
示例9: loadFile
CC_FILE_ERROR LASFilter::loadFile(const char* filename, ccHObject& container, bool alwaysDisplayLoadDialog/*=true*/, bool* coordinatesShiftEnabled/*=0*/, double* coordinatesShift/*=0*/)
{
//opening file
std::ifstream ifs;
ifs.open(filename, std::ios::in | std::ios::binary);
if (ifs.fail())
return CC_FERR_READING;
liblas::Reader* reader = 0;
unsigned nbOfPoints = 0;
std::vector<std::string> dimensions;
try
{
reader = new liblas::Reader(liblas::ReaderFactory().CreateWithStream(ifs)); //using factory for automatic and transparent
//handling of compressed/uncompressed files
liblas::Header const& header = reader->GetHeader();
#ifdef _DEBUG
//ccConsole::Print("[LAS FILE] %s - signature: %s",filename,header.GetFileSignature().c_str());
#endif
//get fields present in file
dimensions = header.GetSchema().GetDimensionNames();
//and of course the number of points
nbOfPoints = header.GetPointRecordsCount();
}
catch (...)
{
delete reader;
ifs.close();
return CC_FERR_READING;
}
if (nbOfPoints==0)
{
//strange file ;)
delete reader;
ifs.close();
return CC_FERR_NO_LOAD;
}
liblas::Color rgbColorMask; //(0,0,0) on construction
bool hasClassif = false;
bool hasIntensity = false;
bool hasTime = false;
bool hasReturnNumber = false;
for (unsigned k=0;k<dimensions.size();++k)
{
QString dim = QString(dimensions[k].c_str()).toUpper();
bool handled = true;
if (dim == "RED")
rgbColorMask.SetRed(~0);
else if (dim == "BLUE")
rgbColorMask.SetBlue(~0);
else if (dim == "GREEN")
rgbColorMask.SetGreen(~0);
else if (dim == "CLASSIFICATION")
hasClassif = true;
else if (dim == "TIME")
hasTime = true;
else if (dim == "INTENSITY")
hasIntensity = true;
else if (dim == "RETURN NUMBER")
hasReturnNumber = true;
else if (dim != "X" && dim != "Y" && dim != "Z")
handled = false;
ccConsole::Print(QString("[LAS FILE] Found dimension '%1' (%2)").arg(dimensions[k].c_str()).arg(handled ? "handled" : "not handled"));
}
bool hasColor = (rgbColorMask[0] || rgbColorMask[1] || rgbColorMask[2]);
//progress dialog
ccProgressDialog pdlg(true); //cancel available
CCLib::NormalizedProgress nprogress(&pdlg,nbOfPoints);
pdlg.setMethodTitle("Open LAS file");
pdlg.setInfo(qPrintable(QString("Points: %1").arg(nbOfPoints)));
pdlg.start();
//number of points read from the begining of the current cloud part
unsigned pointsRead = 0;
double Pshift[3] = {0.0,0.0,0.0};
//by default we read color as 8 bits integers and we will change this to 16 bits if it's not (16 bits is the standard!)
unsigned char colorCompBitDec = 0;
colorType rgb[3] = {0,0,0};
ccPointCloud* loadedCloud = 0;
ccScalarField* classifSF = 0;
uint8_t firstClassifValue = 0;
ccScalarField* timeSF = 0;
double firstTime = 0.0;
ccScalarField* intensitySF = 0;
uint16_t firstIntensity = 0;
//.........这里部分代码省略.........
开发者ID:vivzqs,项目名称:trunk,代码行数:101,代码来源:LASFilter.cpp
示例10: loadFile
CC_FILE_ERROR PNFilter::loadFile(const char* filename, ccHObject& container, bool alwaysDisplayLoadDialog/*=true*/, bool* coordinatesShiftEnabled/*=0*/, double* coordinatesShift/*=0*/)
{
//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 = 6*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 = (unsigned) (fileSize / singlePointSize);
//progress dialog
ccProgressDialog pdlg(true); //cancel available
CCLib::NormalizedProgress nprogress(&pdlg,numberOfPoints);
pdlg.setMethodTitle("Open PN 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)
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->reserveTheNormsTable())
{
result = CC_FERR_NOT_ENOUGH_MEMORY;
if (loadedCloud)
delete loadedCloud;
loadedCloud=0;
break;
}
loadedCloud->showNormals(true);
}
//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 3 components of the normal vector
if (in.read((char*)rBuff,3*sizeof(float))>=0)
{
//conversion to PointCoordinateType[3]
PointCoordinateType N[3] = {(PointCoordinateType)rBuff[0],
(PointCoordinateType)rBuff[1],
(PointCoordinateType)rBuff[2]};
loadedCloud->addNorm(N);
}
else
{
//add fake normal for consistency then break
loadedCloud->addNorm(s_defaultNorm);
result = CC_FERR_READING;
break;
}
++pointsRead;
if (!nprogress.oneStep())
{
result = CC_FERR_CANCELED_BY_USER;
break;
}
}
in.close();
if (loadedCloud)
{
//.........这里部分代码省略.........
开发者ID:kod3r,项目名称:trunk,代码行数:101,代码来源:PNFilter.cpp
示例11: loadCloudFromFormatedAsciiFile
CC_FILE_ERROR AsciiFilter::loadCloudFromFormatedAsciiFile( const QString& filename,
ccHObject& container,
const AsciiOpenDlg::Sequence& openSequence,
char separator,
unsigned approximateNumberOfLines,
qint64 fileSize,
unsigned maxCloudSize,
unsigned skipLines,
LoadParameters& parameters)
{
//we may have to "slice" clouds when opening them if they are too big!
maxCloudSize = std::min(maxCloudSize,CC_MAX_NUMBER_OF_POINTS_PER_CLOUD);
unsigned cloudChunkSize = std::min(maxCloudSize,approximateNumberOfLines);
unsigned cloudChunkPos = 0;
unsigned chunkRank = 1;
//we initialize the loading accelerator structure and point cloud
int maxPartIndex = -1;
cloudAttributesDescriptor cloudDesc = prepareCloud(openSequence, cloudChunkSize, maxPartIndex, separator, chunkRank);
if (!cloudDesc.cloud)
return CC_FERR_NOT_ENOUGH_MEMORY;
//we re-open the file (ASCII mode)
QFile file(filename);
if (!file.open(QFile::ReadOnly))
{
//we clear already initialized data
clearStructure(cloudDesc);
return CC_FERR_READING;
}
QTextStream stream(&file);
//we skip lines as defined on input
{
for (unsigned i=0; i<skipLines; ++i)
{
stream.readLine();
}
}
//progress indicator
ccProgressDialog pdlg(true);
CCLib::NormalizedProgress nprogress(&pdlg,approximateNumberOfLines);
pdlg.setMethodTitle(qPrintable(QString("Open ASCII file [%1]").arg(filename)));
pdlg.setInfo(qPrintable(QString("Approximate number of points: %1").arg(approximateNumberOfLines)));
pdlg.start();
//buffers
ScalarType D = 0;
CCVector3d P(0,0,0);
CCVector3d Pshift(0,0,0);
CCVector3 N(0,0,0);
ccColor::Rgb col;
//other useful variables
unsigned linesRead = 0;
unsigned pointsRead = 0;
CC_FILE_ERROR result = CC_FERR_NO_ERROR;
//main process
unsigned nextLimit = /*cloudChunkPos+*/cloudChunkSize;
QString currentLine = stream.readLine();
while (!currentLine.isNull())
{
++linesRead;
//comment
if (currentLine.startsWith("//"))
{
currentLine = stream.readLine();
continue;
}
if (currentLine.size() == 0)
{
ccLog::Warning("[AsciiFilter::Load] Line %i is corrupted (empty)!",linesRead);
currentLine = stream.readLine();
continue;
}
//if we have reached the max. number of points per cloud
if (pointsRead == nextLimit)
{
ccLog::PrintDebug("[ASCII] Point %i -> end of chunk (%i points)",pointsRead,cloudChunkSize);
//we re-evaluate the average line size
{
double averageLineSize = static_cast<double>(file.pos())/(pointsRead+skipLines);
double newNbOfLinesApproximation = std::max(1.0, static_cast<double>(fileSize)/averageLineSize - static_cast<double>(skipLines));
//if approximation is smaller than actual one, we add 2% by default
if (newNbOfLinesApproximation <= pointsRead)
{
newNbOfLinesApproximation = std::max(static_cast<double>(cloudChunkPos+cloudChunkSize)+1.0,static_cast<double>(pointsRead) * 1.02);
}
approximateNumberOfLines = static_cast<unsigned>(ceil(newNbOfLinesApproximation));
ccLog::PrintDebug("[ASCII] New approximate nb of lines: %i",approximateNumberOfLines);
}
//.........这里部分代码省略.........
开发者ID:johnjsb,项目名称:trunk,代码行数:101,代码来源:AsciiFilter.cpp
示例12: if
CC_FILE_ERROR BinFilter::LoadFileV1(QFile& in, ccHObject& container, unsigned nbScansTotal, const LoadParameters& parameters)
{
ccLog::Print("[BIN] Version 1.0");
if (nbScansTotal > 99)
{
if (QMessageBox::question(0, QString("Oups"), QString("Hum, do you really expect %1 point clouds?").arg(nbScansTotal), QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
return CC_FERR_WRONG_FILE_TYPE;
}
else if (nbScansTotal == 0)
{
return CC_FERR_NO_LOAD;
}
ccProgressDialog pdlg(true, parameters.parentWidget);
pdlg.setMethodTitle(QObject::tr("Open Bin file (old style)"));
for (unsigned k=0; k<nbScansTotal; k++)
{
HeaderFlags header;
unsigned nbOfPoints = 0;
if (ReadEntityHeader(in, nbOfPoints, header) < 0)
{
return CC_FERR_READING;
}
//Console::print("[BinFilter::loadModelFromBinaryFile] Entity %i : %i points, color=%i, norms=%i, dists=%i\n",k,nbOfPoints,color,norms,distances);
if (nbOfPoints == 0)
{
//Console::print("[BinFilter::loadModelFromBinaryFile] rien a faire !\n");
continue;
}
//progress for this cloud
CCLib::NormalizedProgress nprogress(&pdlg, nbOfPoints);
if (parameters.alwaysDisplayLoadDialog)
{
pdlg.reset();
pdlg.setInfo(QObject::tr("cloud %1/%2 (%3 points)").arg(k + 1).arg(nbScansTotal).arg(nbOfPoints));
pdlg.start();
QApplication::processEvents();
}
//Cloud name
char cloudName[256] = "unnamed";
if (header.name)
{
for (int i=0; i<256; ++i)
{
if (in.read(cloudName+i,1) < 0)
{
//Console::print("[BinFilter::loadModelFromBinaryFile] Error reading the cloud name!\n");
return CC_FERR_READING;
}
if (cloudName[i] == 0)
{
break;
}
}
//we force the end of the name in case it is too long!
cloudName[255] = 0;
}
else
{
sprintf(cloudName,"unnamed - Cloud #%u",k);
}
//Cloud name
char sfName[1024] = "unnamed";
if (header.sfName)
{
for (int i=0; i<1024; ++i)
{
if (in.read(sfName+i,1) < 0)
{
//Console::print("[BinFilter::loadModelFromBinaryFile] Error reading the cloud name!\n");
return CC_FERR_READING;
}
if (sfName[i] == 0)
break;
}
//we force the end of the name in case it is too long!
sfName[1023] = 0;
}
else
{
strcpy(sfName,"Loaded scalar field");
}
//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)
//.........这里部分代码省略.........
开发者ID:FrankHXW,项目名称:trunk,代码行数:101,代码来源:BinFilter.cpp
示例13: fopen
CC_FILE_ERROR IcmFilter::loadFile(QString filename, ccHObject& container, LoadParameters& parameters)
{
//ouverture du fichier
FILE *fp = fopen(qPrintable(filename), "rt");
if (!fp)
return CC_FERR_READING;
//buffer
char line[MAX_ASCII_FILE_LINE_LENGTH];
//lecture du header
if (!fgets(line, MAX_ASCII_FILE_LINE_LENGTH , fp))
{
fclose(fp);
return CC_FERR_READING;
}
if (strncmp(line,"#CC_ICM_FILE",12)!=0)
{
fclose(fp);
return CC_FERR_WRONG_FILE_TYPE;
}
//on extrait le chemin relatif
QString path = QFileInfo(filename).absolutePath();
char cloudFileName[MAX_ASCII_FILE_LINE_LENGTH];
if (!fgets(line, MAX_ASCII_FILE_LINE_LENGTH , fp))
{
fclose(fp);
return CC_FERR_READING;
}
if (strncmp(line,"FILE_NAME=",10)!=0)
{
fclose(fp);
return CC_FERR_WRONG_FILE_TYPE;
}
sscanf(line,"FILE_NAME=%s",cloudFileName);
char subFileType[12];
if (!fgets(line, MAX_ASCII_FILE_LINE_LENGTH , fp))
{
fclose(fp);
return CC_FERR_READING;
}
if (strncmp(line,"FILE_TYPE=",10)!=0)
{
fclose(fp);
return CC_FERR_WRONG_FILE_TYPE;
}
sscanf(line,"FILE_TYPE=%s",subFileType);
FileIOFilter::Shared filter = FileIOFilter::FindBestFilterForExtension(subFileType);
if (!filter)
{
ccLog::Warning(QString("[ICM] No I/O filter found for loading file '%1' (type = '%2')").arg(cloudFileName).arg(subFileType));
fclose(fp);
return CC_FERR_UNKNOWN_FILE;
}
//load the corresponding file (potentially containing several clouds)
CC_FILE_ERROR result = CC_FERR_NO_ERROR;
ccHObject* entities = FileIOFilter::LoadFromFile(QString("%0/%1").arg(path).arg(cloudFileName), parameters, filter, result);
if (!entities)
{
fclose(fp);
return CC_FERR_READING;
}
container.addChild(entities);
//chargement des images
if (!fgets(line, MAX_ASCII_FILE_LINE_LENGTH , fp))
{
ccLog::Error("[ICM] Read error (IMAGES_DESCRIPTOR)! No image loaded");
fclose(fp);
return CC_FERR_READING;
}
else
{
if (strncmp(line,"IMAGES_DESCRIPTOR=",18)!=0)
{
fclose(fp);
return CC_FERR_WRONG_FILE_TYPE;
}
char imagesDescriptorFileName[MAX_ASCII_FILE_LINE_LENGTH];
sscanf(line,"IMAGES_DESCRIPTOR=%s",imagesDescriptorFileName);
int n = LoadCalibratedImages(entities,path,imagesDescriptorFileName,entities->getBB_recursive());
ccLog::Print("[ICM] %i image(s) loaded ...",n);
}
fclose(fp);
return CC_FERR_NO_ERROR;
}
开发者ID:coolshahabaz,项目名称:trunk,代码行数:95,代码来源:IcmFilter.cpp
示例14: loadFile
CC_FILE_ERROR VTKFilter::loadFile(QString filename, ccHObject& container, LoadParameters& parameters)
{
//open ASCII file for reading
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return CC_FERR_READING;
QTextStream inFile(&file);
//read header
QString nextline = inFile.readLine();
if (!nextline.startsWith("# vtk"))
return CC_FERR_MALFORMED_FILE;
//comment
nextline = inFile.readLine();
ccLog::Print(QString("[VTK] ")+nextline);
ccMesh* mesh = 0;
ccPointCloud* vertices = 0;
std::vector<int> indexes; //global so as to avoid unnecessary mem. allocations
QString lastSfName;
bool acceptLookupTables = true;
unsigned lastDataSize = 0;
QString fileType = inFile.readLine().toUpper();
if (fileType.startsWith("BINARY"))
{
//binary not supported yet!
ccLog::Error("VTK binary format not supported yet!");
return CC_FERR_WRONG_FILE_TYPE;
}
else if (fileType.startsWith("ASCII"))
{
//allow blank lines
QString dataType;
if (!GetNextNonEmptyLine(inFile,dataType))
return CC_FERR_MALFORMED_FILE;
if (!dataType.startsWith("DATASET"))
return CC_FERR_MALFORMED_FILE;
dataType.remove(0,8);
if (dataType.startsWith("POLYDATA"))
{
vertices = new ccPointCloud("vertices");
mesh = new ccMesh(vertices);
}
else if (dataType.startsWith("UNSTRUCTURED_GRID"))
{
vertices = new ccPointCloud("unnamed - VTK unstructured grid");
}
else
{
ccLog::Error(QString("VTK entity '%1' is not supported!").arg(dataType));
return CC_FERR_WRONG_FILE_TYPE;
}
}
//loop on keywords/data
CC_FILE_ERROR error = CC_FERR_NO_ERROR;
CCVector3d Pshift(0,0,0);
bool skipReadLine = false;
while (error == CC_FERR_NO_ERROR)
{
if (!skipReadLine && !GetNextNonEmptyLine(inFile,nextline))
break; //end of file
skipReadLine = false;
assert(!nextline.isEmpty());
if (nextline.startsWith("POINTS"))
{
QStringList parts = nextline.split(" ",QString::SkipEmptyParts);
if (parts.size() != 3)
{
error=CC_FERR_MALFORMED_FILE;
break;
}
bool ok = false;
unsigned ptsCount = parts[1].toInt(&ok);
if (!ok)
{
error = CC_FERR_MALFORMED_FILE;
break;
}
//QString dataFormat = parts[3].toUpper();
//char buffer[8];
//unsigned char datSize = 4;
//if (dataFormat == "DOUBLE")
//{
// datSize = 8;
//}
//else if (dataFormat != "FLOAT")
//{
// ccLog::Error(QString("Non floating point data (%1) is not supported!").arg(dataFormat));
// error = CC_FERR_WRONG_FILE_TYPE;
// break;
//}
//.........这里部分代码省略.........
开发者ID:abdullah38rcc,项目名称:trunk,代码行数:101,代码来源:VTKFilter.cpp
示例15: loadFile
CC_FILE_ERROR LASFilter::loadFile(const char* filename, ccHObject& container, bool alwaysDisplayLoadDialog/*=true*/, bool* coordinatesShiftEnabled/*=0*/, CCVector3d* coordinatesShift/*=0*/)
{
//opening file
std::ifstream ifs;
ifs.open(filename, std::ios::in | std::ios::binary);
if (ifs.fail())
return CC_FERR_READING;
liblas::Reader* reader = 0;
unsigned nbOfPoints = 0;
std::vector<std::string> dimensions;
try
{
reader = new liblas::Reader(liblas::ReaderFactory().CreateWithStream(ifs)); //using factory for automatic and transparent
//handling of compressed/uncompressed files
liblas::Header const& header = reader->GetHeader();
ccLog::PrintDebug(QString("[LAS FILE] %1 - signature: %2").arg(filename).arg(header.GetFileSignature().c_str()));
//get fields present in file
dimensions = header.GetSchema().GetDimensionNames();
//and of course the number of points
nbOfPoints = header.GetPointRecordsCount();
}
catch (...)
{
delete reader;
ifs.close();
return CC_FERR_READING;
}
if (nbOfPoints==0)
{
//strange file ;)
delete reader;
ifs.close();
return CC_FERR_NO_LOAD;
}
//dialog to choose the fields to load
if (!s_lasOpenDlg)
s_lasOpenDlg = QSharedPointer<LASOpenDlg>(new LASOpenDlg());
s_lasOpenDlg->setDimensions(dimensions);
if (alwaysDisplayLoadDialog && !s_lasOpenDlg->autoSkipMode() && !s_lasOpenDlg->exec())
{
delete reader;
ifs.close();
return CC_FERR_CANCELED_BY_USER;
}
bool ignoreDefaultFields = s_lasOpenDlg->ignoreDefaultFieldsCheckBox->isChecked();
//RGB color
liblas::Color rgbColorMask; //(0,0,0) on construction
if (s_lasOpenDlg->doLoad(LAS_RED))
rgbColorMask.SetRed(~0);
if (s_lasOpenDlg->doLoad(LAS_GREEN))
rgbColorMask.SetGreen(~0);
if (s_lasOpenDlg->doLoad(LAS_BLUE))
rgbColorMask.SetBlue(~0);
bool loadColor = (rgbColorMask[0] || rgbColorMask[1] || rgbColorMask[2]);
//progress dialog
ccProgressDialog pdlg(true); //cancel available
CCLib::NormalizedProgress nprogress(&pdlg,nbOfPoints);
pdlg.setMethodTitle("Open LAS file");
pdlg.setInfo(qPrintable(QString("Points: %1").arg(nbOfPoints)));
pdlg.start();
//number of points read from the begining of the current cloud part
unsigned pointsRead = 0;
CCVector3d Pshift(0,0,0);
//by default we read color as 8 bits integers and we will change this to 16 bits if it's not (16 bits is the standard!)
unsigned char colorCompBitDec = 0;
colorType rgb[3] = {0,0,0};
ccPointCloud* loadedCloud = 0;
std::vector<LasField> fieldsToLoad;
//if the file is too big, we will chunck it in multiple parts
unsigned int fileChunkPos = 0;
unsigned int fileChunkSize = 0;
while (true)
{
//if we reach the end of the file, or the max. cloud size limit (in which case we cerate a new chunk)
bool newPointAvailable = (nprogress.oneStep() && reader->ReadNextPoint());
if (!newPointAvailable || pointsRead == fileChunkPos+fileChunkSize)
{
if (loadedCloud)
{
if (loadedCloud->size())
{
bool thisChunkHasColors = loadedCloud->hasColors();
loadedCloud->showColors(thisChunkHasColors);
if (loadColor && !thisChunkHasColors)
//.........这里部分代码省略.........
开发者ID:imight,项目名称:trunk,代码行数:101,代码来源:LASFilter.cpp
示例16: loadFile
CC_FILE_ERROR PlyFilter::loadFile(const char* filename, ccHObject& container, bool alwaysDisplayLoadDialog/*=true*/, bool* coordinatesShiftEnabled/*=0*/, double* coordinatesShift/*=0*/)
{
//reset statics!
s_triCount = 0;
s_unsupportedPolygonType = false;
s_scalarCount=0;
s_IntensityCount=0;
s_ColorCount=0;
s_NormalCount=0;
s_PointCount=0;
s_PointDataCorrupted=false;
s_AlwaysDisplayLoadDialog=alwaysDisplayLoadDialog;
s_ShiftApplyAll=false;
s_ShiftAlreadyEnabled = (coordinatesShiftEnabled && *coordinatesShiftEnabled && coordinatesShift);
if (s_ShiftAlreadyEnabled)
memcpy(s_Pshift,coordinatesShift,sizeof(double)*3);
else
memset(s_Pshift,0,sizeof(double)*3);
/****************/
/*** Header ***/
/****************/
//open a PLY file for reading
p_ply ply = ply_open(filename,NULL, 0, NULL);
if (!ply)
return CC_FERR_READING;
ccConsole::PrintDebug("[PLY] Opening file '%s' ...",filename);
if (!ply_read_header(ply))
{
ply_close(ply);
return CC_FERR_WRONG_FILE_TYPE;
}
//storage mode: little/big endian
e_ply_storage_mode storage_mode;
get_plystorage_mode(ply,&storage_mode);
/******************/
/*** Comments ***/
/******************/
//display comments
const char* lastComment = NULL;
while ((lastComment = ply_get_next_comment(ply, lastComment)))
ccConsole::Print("[PLY][Comment] %s",lastComment);
/*******************************/
/*** Elements & properties ***/
/*******************************/
//Point-based elements (points, colors, normals, etc.)
std::vector<plyElement> pointElements;
//Mesh-based elements (vertices, etc.)
std::vector<plyElement> meshElements;
//Point-based element properties (coordinates, color components, etc.)
std::vector<plyProperty> stdProperties;
//Mesh-based element properties (vertex indexes, etc.)
std::vector<plyProperty> listProperties;
unsigned i=0;
//last read element
plyElement lastElement;
lastElement.elem = 0;
while ((lastElement.elem = ply_get_next_element(ply, lastElement.elem)))
{
//we get next element info
ply_get_element_info(lastElement.elem, &lastElement.elementName, &lastElement.elementInstances);
if (lastElement.elementInstances == 0)
{
ccConsole::Warning("[PLY] Element '%s' was ignored as it has 0 instance!",lastElement.elementName);
continue;
}
lastElement.properties.clear();
lastElement.propertiesCount=0;
lastElement.isList=false;
//printf("Element: %s\n",lastElement.elementName);
//last read property
plyProperty lastProperty;
lastProperty.prop = 0;
lastProperty.elemIndex = 0;
while ((lastProperty.prop = ply_get_next_property(lastElement.elem,lastProperty.prop)))
{
//we get next property info
ply_get_property_info(lastProperty.prop, &lastProperty.propName, &lastProperty.type, &lastProperty.length_type, &lastProperty.value_type);
//printf("\tProperty: %s (%s)\n",lastProperty.propName,e_ply_type_names[lastProperty.type]);
if (lastProperty.type == 16) //PLY_LIST
lastElement.isList = true;
lastElement.properties.push_back(lastProperty);
++lastElement.propertiesCount;
//.........这里部分代码省略.........
开发者ID:whatnick,项目名称:CloudCompare,代码行数:101,代码来源:PlyFilter.cpp
示例17: 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;
}
}
//.........这里部分代码省略.........
开发者ID:fredericoal,项目名称:trunk,代码行数:101,代码来源:PVFilter.cpp
示例18: loadFile
CC_FILE_ERROR SoiFilter::loadFile(QString filename, ccHObject& container, LoadParameters& parameters)
{
//open the file
FILE *fp = fopen(qPrintable(filename), "rt");
if (!fp)
return CC_FERR_READING;
std::string line;
line.resize(MAX_ASCII_FILE_LINE_LENGTH);
unsigned nbScansTotal = 0;
unsigned nbPointsTotal = 0;
//we read the first line
char* eof = fgets ((char*)line.c_str(), MAX_ASCII_FILE_LINE_LENGTH , fp);
char* pEnd;
//header
while ((strcmp((char*)line.substr(0,4).c_str(),"#CC#") != 0)&&(eof != NULL))
{
if (strcmp(line.substr(0,4).c_str(),"#NP#")==0)
{
std::string numPoints (line,4,line.size()-4);
nbPointsTotal=strtol(numPoints.c_str(),&pEnd,0);
//ccLog::Print("[SoiFilter::loadFile] Total number of points: %i",nbPointsTotal);
}
else if (strcmp(line.substr(0,4).c_str(),"#NS#")==0)
{
std::string numScans (line,4,line.size()-4);
nbScansTotal=strtol(numScans.c_str(),&pEnd,0);
//ccLog::Print("[SoiFilter::loadFile] Total number of scans: %i",nbScansTotal);
}
eof = fgets ((char*)line.c_str(), MAX_ASCII_FILE_LINE_LENGTH , fp);
}
if ((nbScansTotal == 0)||(nbPointsTotal == 0))
{
ccLog::Warning("[SoiFilter::loadFile] No points or scans defined in this file!");
fclose(fp);
return CC_FERR_NO_LOAD;
}
//Progress dialog
ccProgressDialog pdlg(false); //cancel is not supported
pdlg.setMethodTitle("Open SOI file");
char buffer[256];
sprintf(buffer,"%u scans / %u points\n",nbScansTotal,nbPointsTotal);
CCLib::NormalizedProgress nprogress(&pdlg,nbPointsTotal);
pdlg.setInfo(buffer);
pdlg.start();
//Scan by scan
for (unsigned k=0; k<nbScansTotal; k++)
{
char* eof = fgets ((char*)line.c_str(), MAX_ASCII_FILE_LINE_LENGTH , fp);
//we only look for points (we ignore the rest)
while ((strcmp(line.substr(0,4).c_str(),"#pt#")!=0)&&(eof != NULL))
eof = fgets ((char*)line.c_str(), MAX_ASCII_FILE_LINE_LENGTH , fp);
unsigned nbOfPoints = 0;
if (strcmp(line.substr(0,4).c_str(),"#pt#")==0)
{
std::string numPoints(line,4,line.size()-4);
nbOfPoints = strtol(numPoints.c_str(),&pEnd,0);
//ccLog::Print("[SoiFilter::loadFile] Scan %i - points: %i",k+1,nbOfPoints);
}
else
{
ccLog::Warning("[SoiFilter::loadFile] Can't find marker '#pt#'!");
fclose(fp);
return CC_FERR_WRONG_FILE_TYPE;
}
if (nbOfPoints == 0)
{
ccLog::Warning("[SoiFi
|
请发表评论