本文整理汇总了C++中NormsIndexesTableType::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NormsIndexesTableType::getValue方法的具体用法?C++ NormsIndexesTableType::getValue怎么用?C++ NormsIndexesTableType::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NormsIndexesTableType
的用法示例。
在下文中一共展示了NormsIndexesTableType::getValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyGLTransformation
void ccGenericMesh::applyGLTransformation(const ccGLMatrix& trans)
{
//vertices should be handled another way!
//we must take care of the triangle normals!
if (m_triNormals && (!getParent() || !getParent()->isKindOf(CC_MESH)))
{
bool recoded = false;
//if there is more triangle normals than the size of the compressed
//normals array, we recompress the array instead of recompressing each normal
unsigned i,numTriNormals = m_triNormals->currentSize();
if (numTriNormals>ccNormalVectors::GetNumberOfVectors())
{
NormsIndexesTableType* newNorms = new NormsIndexesTableType;
if (newNorms->reserve(ccNormalVectors::GetNumberOfVectors()))
{
for (i=0; i<ccNormalVectors::GetNumberOfVectors(); i++)
{
CCVector3 new_n(ccNormalVectors::GetNormal(i));
trans.applyRotation(new_n);
normsType newNormIndex = ccNormalVectors::GetNormIndex(new_n.u);
newNorms->addElement(newNormIndex);
}
m_triNormals->placeIteratorAtBegining();
for (i=0; i<numTriNormals; i++)
{
m_triNormals->setValue(i,newNorms->getValue(m_triNormals->getCurrentValue()));
m_triNormals->forwardIterator();
}
recoded=true;
}
newNorms->clear();
newNorms->release();
newNorms=0;
}
//if there is less triangle normals than the compressed normals array size
//(or if there is not enough memory to instantiate the temporary array),
//we recompress each normal ...
if (!recoded)
{
//on recode direct chaque normale
m_triNormals->placeIteratorAtBegining();
for (i=0; i<numTriNormals; i++)
{
normsType* _theNormIndex = m_triNormals->getCurrentValuePtr();
CCVector3 new_n(ccNormalVectors::GetNormal(*_theNormIndex));
trans.applyRotation(new_n.u);
*_theNormIndex = ccNormalVectors::GetNormIndex(new_n.u);
m_triNormals->forwardIterator();
}
}
}
else
{
//TODO: process failed!
}
}
示例2: drawMeOnly
//.........这里部分代码省略.........
}
//we can scan and process each chunk separately in an optimized way
//we mimic the way ccMesh beahves by using virtual chunks!
unsigned chunks = static_cast<unsigned>(ceil((double)displayedTriNum/(double)MAX_NUMBER_OF_ELEMENTS_PER_CHUNK));
unsigned chunkStart = 0;
const colorType* col = 0;
for (unsigned k=0; k<chunks; ++k, chunkStart += MAX_NUMBER_OF_ELEMENTS_PER_CHUNK)
{
//virtual chunk size
const unsigned chunkSize = k+1 < chunks ? MAX_NUMBER_OF_ELEMENTS_PER_CHUNK : (displayedTriNum % MAX_NUMBER_OF_ELEMENTS_PER_CHUNK);
//vertices
PointCoordinateType* _vertices = GetVertexBuffer();
for (unsigned n=0; n<chunkSize; n+=decimStep)
{
const CCLib::TriangleSummitsIndexes* ti = getTriangleIndexes(chunkStart + n);
memcpy(_vertices,vertices->getPoint(ti->i1)->u,sizeof(PointCoordinateType)*3);
_vertices+=3;
memcpy(_vertices,vertices->getPoint(ti->i2)->u,sizeof(PointCoordinateType)*3);
_vertices+=3;
memcpy(_vertices,vertices->getPoint(ti->i3)->u,sizeof(PointCoordinateType)*3);
_vertices+=3;
}
//scalar field
if (glParams.showSF)
{
colorType* _rgbColors = GetColorsBuffer();
assert(colorScale);
for (unsigned n=0; n<chunkSize; n+=decimStep)
{
const CCLib::TriangleSummitsIndexes* ti = getTriangleIndexes(chunkStart + n);
col = currentDisplayedScalarField->getValueColor(ti->i1);
memcpy(_rgbColors,col,sizeof(colorType)*3);
_rgbColors += 3;
col = currentDisplayedScalarField->getValueColor(ti->i2);
memcpy(_rgbColors,col,sizeof(colorType)*3);
_rgbColors += 3;
col = currentDisplayedScalarField->getValueColor(ti->i3);
memcpy(_rgbColors,col,sizeof(colorType)*3);
_rgbColors += 3;
}
}
//colors
else if (glParams.showColors)
{
colorType* _rgbColors = GetColorsBuffer();
for (unsigned n=0; n<chunkSize; n+=decimStep)
{
const CCLib::TriangleSummitsIndexes* ti = getTriangleIndexes(chunkStart + n);
memcpy(_rgbColors,rgbColorsTable->getValue(ti->i1),sizeof(colorType)*3);
_rgbColors += 3;
memcpy(_rgbColors,rgbColorsTable->getValue(ti->i2),sizeof(colorType)*3);
_rgbColors += 3;
memcpy(_rgbColors,rgbColorsTable->getValue(ti->i3),sizeof(colorType)*3);
_rgbColors += 3;
}
}
//normals
if (glParams.showNorms)
{
PointCoordinateType* _normals = GetNormalsBuffer();
if (showTriNormals)
示例3: ToFbxMesh
// Converts a CC mesh to an FBX mesh
static FbxNode* ToFbxMesh(ccGenericMesh* mesh, FbxScene* pScene)
{
if (!mesh)
return 0;
FbxMesh* lMesh = FbxMesh::Create(pScene, qPrintable(mesh->getName()));
ccGenericPointCloud* cloud = mesh->getAssociatedCloud();
if (!cloud)
return 0;
unsigned vertCount = cloud->size();
unsigned faceCount = mesh->size();
// Create control points.
{
lMesh->InitControlPoints(vertCount);
FbxVector4* lControlPoints = lMesh->GetControlPoints();
for (unsigned i=0; i<vertCount; ++i)
{
const CCVector3* P = cloud->getPoint(i);
lControlPoints[i] = FbxVector4(P->x,P->y,P->z);
}
}
ccMesh* asCCMesh = 0;
if (mesh->isA(CC_MESH))
asCCMesh = static_cast<ccMesh*>(mesh);
// normals
if (mesh->hasNormals())
{
FbxGeometryElementNormal* lGeometryElementNormal = lMesh->CreateElementNormal();
if (mesh->hasTriNormals())
{
// We want to have one normal per vertex of each polygon,
// so we set the mapping mode to eByPolygonVertex.
lGeometryElementNormal->SetMappingMode(FbxGeometryElement::eByPolygonVertex);
lGeometryElementNormal->SetReferenceMode(FbxGeometryElement::eIndexToDirect);
lGeometryElementNormal->GetIndexArray().SetCount(faceCount*3);
if (asCCMesh)
{
NormsIndexesTableType* triNorms = asCCMesh->getTriNormsTable();
assert(triNorms);
for (unsigned i=0; i<triNorms->currentSize(); ++i)
{
const PointCoordinateType* N = ccNormalVectors::GetNormal(triNorms->getValue(i));
FbxVector4 Nfbx(N[0],N[1],N[2]);
lGeometryElementNormal->GetDirectArray().Add(Nfbx);
}
for (unsigned j=0; j<faceCount; ++j)
{
int i1,i2,i3;
asCCMesh->getTriangleNormalIndexes(j,i1,i2,i3);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+0, i1);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+1, i2);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+2, i3);
}
}
else
{
for (unsigned j=0; j<faceCount; ++j)
{
//we can't use the 'NormsIndexesTable' so we save all the normals of all the vertices
CCVector3 Na,Nb,Nc;
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(Na.x,Na.y,Na.z));
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(Nb.x,Nb.y,Nb.z));
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(Nc.x,Nc.y,Nc.z));
mesh->getTriangleNormals(j,Na,Nb,Nc);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+0, static_cast<int>(j)*3+0);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+1, static_cast<int>(j)*3+1);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+2, static_cast<int>(j)*3+2);
}
}
}
else
{
// We want to have one normal for each vertex (or control point),
// so we set the mapping mode to eByControlPoint.
lGeometryElementNormal->SetMappingMode(FbxGeometryElement::eByControlPoint);
// The first method is to set the actual normal value
// for every control point.
lGeometryElementNormal->SetReferenceMode(FbxGeometryElement::eDirect);
for (unsigned i=0; i<vertCount; ++i)
{
const PointCoordinateType* N = cloud->getPointNormal(i);
FbxVector4 Nfbx(N[0],N[1],N[2]);
lGeometryElementNormal->GetDirectArray().Add(Nfbx);
}
}
}
else
{
ccLog::Warning("[FBX] Mesh has no normal! You can manually compute them (select it then call \"Edit > Normals > Compute\")");
}
// colors
//.........这里部分代码省略.........
示例4: saveToFile
CC_FILE_ERROR ObjFilter::saveToFile(ccHObject* entity, QString filename, SaveParameters& parameters)
{
if (!entity)
return CC_FERR_BAD_ARGUMENT;
if (!entity->isKindOf(CC_TYPES::MESH))
{
ccLog::Warning("[OBJ] This filter can only save one mesh (optionally with sub-meshes) at a time!");
return CC_FERR_BAD_ENTITY_TYPE;
}
//mesh
ccGenericMesh* mesh = ccHObjectCaster::ToGenericMesh(entity);
if (!mesh || mesh->size() == 0)
{
ccLog::Warning("[OBJ] Input mesh is empty!");
return CC_FERR_NO_SAVE;
}
//vertices
ccGenericPointCloud* vertices = mesh->getAssociatedCloud();
if (!vertices || vertices->size() == 0)
{
ccLog::Warning("[OBJ] Input mesh has no vertices?!");
return CC_FERR_NO_SAVE;
}
unsigned nbPoints = vertices->size();
//try to open file for saving
QFile file(filename);
if (!file.open(QFile::Text | QFile::WriteOnly))
return CC_FERR_WRITING;
//progress
ccProgressDialog pdlg(true);
unsigned numberOfTriangles = mesh->size();
CCLib::NormalizedProgress nprogress(&pdlg,numberOfTriangles);
pdlg.setMethodTitle(qPrintable(QString("Saving mesh [%1]").arg(mesh->getName())));
pdlg.setInfo(qPrintable(QString("Triangles: %1").arg(numberOfTriangles)));
pdlg.start();
QTextStream stream(&file);
stream.setRealNumberPrecision(sizeof(PointCoordinateType) == 4 ? 8 : 12);
stream << "#OBJ Generated by CloudCompare (TELECOM PARISTECH/EDF R&D)" << endl;
if (file.error() != QFile::NoError)
return CC_FERR_WRITING;
for (unsigned i=0; i<nbPoints; ++i)
{
const CCVector3* P = vertices->getPoint(i);
CCVector3d Pglobal = vertices->toGlobal3d<PointCoordinateType>(*P);
stream << "v " << Pglobal.x << " " << Pglobal.y << " " << Pglobal.z << endl;
if (file.error() != QFile::NoError)
return CC_FERR_WRITING;
}
//normals
bool withTriNormals = mesh->hasTriNormals();
bool withVertNormals = vertices->hasNormals();
bool withNormals = withTriNormals || withVertNormals;
if (withNormals)
{
//per-triangle normals
if (withTriNormals)
{
NormsIndexesTableType* normsTable = mesh->getTriNormsTable();
if (normsTable)
{
for (unsigned i=0; i<normsTable->currentSize(); ++i)
{
const CCVector3& normalVec = ccNormalVectors::GetNormal(normsTable->getValue(i));
stream << "vn " << normalVec.x << " " << normalVec.y << " " << normalVec.z << endl;
if (file.error() != QFile::NoError)
return CC_FERR_WRITING;
}
}
else
{
assert(false);
withTriNormals = false;
}
}
//per-vertices normals
else //if (withVertNormals)
{
for (unsigned i=0; i<nbPoints; ++i)
{
const CCVector3& normalVec = vertices->getPointNormal(i);
stream << "vn " << normalVec.x << " " << normalVec.y << " " << normalVec.z << endl;
if (file.error() != QFile::NoError)
return CC_FERR_WRITING;
}
}
}
//materials
const ccMaterialSet* materials = mesh->getMaterialSet();
bool withMaterials = (materials && mesh->hasMaterials());
if (withMaterials)
//.........这里部分代码省略.........
示例5: ToFbxMesh
// Converts a CC mesh to an FBX mesh
static FbxNode* ToFbxMesh(ccGenericMesh* mesh, FbxScene* pScene, QString filename, size_t meshIndex)
{
if (!mesh)
return 0;
FbxNode* lNode = FbxNode::Create(pScene,qPrintable(mesh->getName()));
FbxMesh* lMesh = FbxMesh::Create(pScene, qPrintable(mesh->getName()));
lNode->SetNodeAttribute(lMesh);
ccGenericPointCloud* cloud = mesh->getAssociatedCloud();
if (!cloud)
return 0;
unsigned vertCount = cloud->size();
unsigned faceCount = mesh->size();
// Create control points.
{
lMesh->InitControlPoints(vertCount);
FbxVector4* lControlPoints = lMesh->GetControlPoints();
for (unsigned i=0; i<vertCount; ++i)
{
const CCVector3* P = cloud->getPoint(i);
lControlPoints[i] = FbxVector4(P->x,P->y,P->z);
//lControlPoints[i] = FbxVector4(P->x,P->z,-P->y); //DGM: see loadFile (Y and Z are inverted)
}
}
ccMesh* asCCMesh = 0;
if (mesh->isA(CC_TYPES::MESH))
asCCMesh = static_cast<ccMesh*>(mesh);
// normals
if (mesh->hasNormals())
{
FbxGeometryElementNormal* lGeometryElementNormal = lMesh->CreateElementNormal();
if (mesh->hasTriNormals())
{
// We want to have one normal per vertex of each polygon,
// so we set the mapping mode to eByPolygonVertex.
lGeometryElementNormal->SetMappingMode(FbxGeometryElement::eByPolygonVertex);
lGeometryElementNormal->SetReferenceMode(FbxGeometryElement::eIndexToDirect);
lGeometryElementNormal->GetIndexArray().SetCount(faceCount*3);
if (asCCMesh)
{
NormsIndexesTableType* triNorms = asCCMesh->getTriNormsTable();
assert(triNorms);
for (unsigned i=0; i<triNorms->currentSize(); ++i)
{
const CCVector3& N = ccNormalVectors::GetNormal(triNorms->getValue(i));
FbxVector4 Nfbx(N.x,N.y,N.z);
lGeometryElementNormal->GetDirectArray().Add(Nfbx);
}
for (unsigned j=0; j<faceCount; ++j)
{
int i1,i2,i3;
asCCMesh->getTriangleNormalIndexes(j,i1,i2,i3);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+0, i1);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+1, i2);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+2, i3);
}
}
else
{
for (unsigned j=0; j<faceCount; ++j)
{
//we can't use the 'NormsIndexesTable' so we save all the normals of all the vertices
CCVector3 Na,Nb,Nc;
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(Na.x,Na.y,Na.z));
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(Nb.x,Nb.y,Nb.z));
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(Nc.x,Nc.y,Nc.z));
mesh->getTriangleNormals(j,Na,Nb,Nc);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+0, static_cast<int>(j)*3+0);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+1, static_cast<int>(j)*3+1);
lGeometryElementNormal->GetIndexArray().SetAt(static_cast<int>(j)*3+2, static_cast<int>(j)*3+2);
}
}
}
else
{
// We want to have one normal for each vertex (or control point),
// so we set the mapping mode to eByControlPoint.
lGeometryElementNormal->SetMappingMode(FbxGeometryElement::eByControlPoint);
// The first method is to set the actual normal value
// for every control point.
lGeometryElementNormal->SetReferenceMode(FbxGeometryElement::eDirect);
for (unsigned i=0; i<vertCount; ++i)
{
const CCVector3& N = cloud->getPointNormal(i);
FbxVector4 Nfbx(N.x,N.y,N.z);
lGeometryElementNormal->GetDirectArray().Add(Nfbx);
}
}
}
else
{
//.........这里部分代码省略.........