本文整理汇总了C++中MeshDocument::addOrGetMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshDocument::addOrGetMesh方法的具体用法?C++ MeshDocument::addOrGetMesh怎么用?C++ MeshDocument::addOrGetMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshDocument
的用法示例。
在下文中一共展示了MeshDocument::addOrGetMesh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyFilter
// The Real Core Function doing the actual mesh processing.
bool FilterAutoalign::applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & par, vcg::CallBackPos *cb)
{
switch(ID(filter)) {
case FP_ALIGN_4PCS :
{
MeshModel *fixMesh= par.getMesh("fixMesh");
MeshModel *movMesh= par.getMesh("movMesh");
MeshModel *sampleMesh= 0;
bool showSample = par.getBool("showSample");
if(showSample) sampleMesh = md.addOrGetMesh("sample","sample",false, RenderMode(vcg::GLW::DMPoints));
tri::UpdateNormal<CMeshO>::NormalizePerVertex(fixMesh->cm);
tri::UpdateNormal<CMeshO>::NormalizePerVertex(movMesh->cm);
tri::Clean<CMeshO>::RemoveUnreferencedVertex(fixMesh->cm);
tri::Clean<CMeshO>::RemoveUnreferencedVertex(movMesh->cm);
tri::Allocator<CMeshO>::CompactEveryVector(fixMesh->cm);
tri::Allocator<CMeshO>::CompactEveryVector(movMesh->cm);
fixMesh->updateDataMask(MeshModel::MM_VERTMARK);
movMesh->updateDataMask(MeshModel::MM_VERTMARK);
vcg::tri::FourPCS<CMeshO> fpcs;
fpcs.par.Default();
fpcs.par.overlap = par.getFloat("overlap");
fpcs.par.sampleNumP = par.getInt("sampleNum");
fpcs.par.deltaPerc = par.getFloat("tolerance");
fpcs.par.seed = par.getInt("randSeed");
fpcs.Init(movMesh->cm,fixMesh->cm);
Matrix44m Tr;
bool res = fpcs.Align(Tr,cb);
if(res)
{
Log("4PCS Completed, radius %f",fpcs.par.samplingRadius);
Log("Tested %i candidate, best score was %i\n",fpcs.U.size(),fpcs.U[fpcs.iwinner].score);
Log("Estimated overlap is now %f \n",fpcs.par.overlap);
Log("Init %5.0f Coplanar Search %5.0f",fpcs.stat.init(),fpcs.stat.select());
Log("findCongruent %5.0f testAlignment %5.0f",fpcs.stat.findCongruent(),fpcs.stat.testAlignment());
movMesh->cm.Tr = Tr;
if(showSample)
{
sampleMesh->cm.Clear();
for(size_t i=0;i<fpcs.subsetQ.size();++i)
tri::Allocator<CMeshO>::AddVertex(sampleMesh->cm, fpcs.subsetQ[i]->P(), fpcs.subsetQ[i]->N());
tri::UpdateBounding<CMeshO>::Box(sampleMesh->cm);
}
}
else Log("4PCS Failed");
} break;
case FP_BEST_ROTATION :
{
MeshModel *fixMesh= par.getMesh("fixMesh");
MeshModel *movMesh= par.getMesh("movMesh");
int searchRange = par.getInt("searchRange");
int rotNum = par.getInt("RotationNumber");
int gridSize = par.getInt("gridSize");
int sampleSize = par.getInt("sampleSize");
MeshModel *sample=md.addOrGetMesh("sample", "sample",false);
MeshModel *occ=md.addOrGetMesh("occ", "occ",false);
tri::Guess<Scalarm> GG;
std::vector<tri::Guess<Scalarm>::Result> ResultVec;
GG.pp.MatrixNum = rotNum;
GG.pp.GridSize =gridSize;
GG.pp.SampleNum = sampleSize;
GG.Init<CMeshO>(fixMesh->cm, movMesh->cm);
for(size_t i=0;i<GG.RotMVec.size();++i)
{
Point3m baseTran = GG.ComputeBaseTranslation(GG.RotMVec[i]);
Point3m bestTran;
int res = GG.SearchBestTranslation(GG.u[0],GG.RotMVec[i],searchRange,baseTran,bestTran);
ResultVec.push_back(tri::Guess<Scalarm>::Result(GG.BuildResult(GG.RotMVec[i],baseTran,bestTran), res, i, bestTran));
}
sort(ResultVec.begin(),ResultVec.end());
movMesh->cm.Tr.Import(ResultVec.back().m);
tri::Build(sample->cm,GG.movVertBase);
sample->cm.Tr.Import(ResultVec.back().m);
qDebug("Result %i",ResultVec.back().score);
GG.GenerateOccupancyMesh(occ->cm,0,ResultVec.back().m);
occ->UpdateBoxAndNormals();
Log("Automatic Rough Alignment Tested %i rotations, best err was %i",GG.RotMVec.size(), ResultVec.back().score);
} break;
default: assert (0);
}
return true;
}