本文整理汇总了C++中MeshModel::updateDataMask方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshModel::updateDataMask方法的具体用法?C++ MeshModel::updateDataMask怎么用?C++ MeshModel::updateDataMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshModel
的用法示例。
在下文中一共展示了MeshModel::updateDataMask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
typename ALIGNER_TYPE::Result FilterFeatureAlignment::RansacOperation(MeshModel& mFix, MeshModel& mMov, typename ALIGNER_TYPE::Parameters& param, CallBackPos *cb)
{
typedef ALIGNER_TYPE AlignerType;
typedef typename AlignerType::MeshType MeshType;
typedef typename AlignerType::FeatureType FeatureType;
typedef typename MeshType::ScalarType ScalarType;
typedef typename AlignerType::Result ResultType;
//enables needed attributes. MM_VERTMARK is used by the getClosest functor.
mFix.updateDataMask(MeshModel::MM_VERTMARK|FeatureType::getRequirements());
mMov.updateDataMask(MeshModel::MM_VERTMARK|FeatureType::getRequirements());
AlignerType aligner;
param.log = &mylogger; //set the callback used to print infos inside the procedure
ResultType res = aligner.init(mFix.cm, mMov.cm, param, cb);
if(res.exitCode==ResultType::FAILED) return res;
//perform RANSAC and get best transformation matrix
res = aligner.align(mFix.cm, mMov.cm, param, cb);
//apply transformation. If ransac don't find a good matrix, identity is returned; so nothing is wrong here...
mMov.cm.Tr = res.tr * mMov.cm.Tr;
return res;
}
示例2: fopen
typename ALIGNER_TYPE::Result FilterFeatureAlignment::RansacDiagramOperation(MeshModel& mFix, MeshModel& mMov, typename ALIGNER_TYPE::Parameters& param, int trials, int from, int to, int step, CallBackPos *cb)
{
typedef ALIGNER_TYPE AlignerType;
typedef typename AlignerType::MeshType MeshType;
typedef typename AlignerType::FeatureType FeatureType;
typedef typename MeshType::ScalarType ScalarType;
typedef typename AlignerType::Result ResultType;
//variables needed for progress bar callback
float progBar = 0.0f;
float offset = 100.0f/(trials);
//enables needed attributes. MM_VERTMARK is used by the getClosest functor.
mFix.updateDataMask(MeshModel::MM_VERTMARK|FeatureType::getRequirements());
mMov.updateDataMask(MeshModel::MM_VERTMARK|FeatureType::getRequirements());
ResultType res;
FILE* file = fopen("Diagram.txt","w+");
fprintf(file,"Fix Mesh#%s\nMove Mesh#%s\nFeature#%s\nNum. of vertices of Fix Mesh#%i\nNum. of vertices of Move Mesh#%i\nOverlap#%.2f%%\nFull consensus threshold#%.2f%% overlap#%.2f%% of Move Mesh#\nTrials#%i\n",mFix.fileName.c_str(),mMov.fileName.c_str(),FeatureType::getName(),mFix.cm.VertexNumber(),mMov.cm.VertexNumber(),param.overlap,param.consOffset,(param.consOffset*param.overlap/100.0f),trials); fflush(file);
fprintf(file,"Iterazioni#Tempo di inizializzazione#Tempo di esecuzione#Prob. Succ.#Prob. Fall. per Sec#Num. medio basi\n0#0#0#0#0\n"); fflush(file);
float probSucc = 0.0f, meanTime = 0.0f, meanInitTime = 0.0f, failPerSec = -1.0f;
int numWon = 0, trialsTotTime = 0, trialsInitTotTime = 0, numBases = 0;
param.ransacIter = from;
//param.log = &mylogger; //this is the way to assign a pointer to log function
//move res here
while(param.ransacIter<=to)
{
for(int i=0; i<trials; i++){
//callback handling
if(cb){ progBar+=offset; cb(int(progBar),"Computing diagram..."); }
AlignerType aligner;
res = aligner.init(mFix.cm, mMov.cm, param);
if(res.exitCode==ResultType::FAILED) return res;
trialsInitTotTime+=res.initTime;
res = aligner.align(mFix.cm, mMov.cm, param);
trialsTotTime+=res.totalTime;
numBases+=res.numBasesFound;
if(res.exitCode==ResultType::ALIGNED) numWon++;
if(res.exitCode==ResultType::FAILED) return res; //failure: stop everything and return error
}
probSucc = numWon/float(trials); //k = prob succ in 1 iteration
meanTime = trialsTotTime/float(trials); //t=sec elapsed to perform N ransac iterations
meanInitTime = trialsInitTotTime/float(trials);
failPerSec = std::pow(1-probSucc,1.0f/(meanTime/1000)); //fail rate per sec is: (1-k)^(1/t)
fprintf(file,"%i#=%.0f/1000#=%.0f/1000#=%.0f/100#=%.0f/100#%i\n", param.ransacIter, meanInitTime, meanTime, 100*probSucc, 100*failPerSec,numBases/trials); fflush(file);
numWon = 0; trialsTotTime = 0; trialsInitTotTime=0; progBar=0.0f; numBases=0;
param.ransacIter+=step;
}
fclose(file);
return res; //all right
}
示例3: applyFilter
//
// Apply filter
//
bool FilterTopoPlugin::applyFilter(QAction *filter, MeshModel &m, RichParameterSet & par, vcg::CallBackPos *cb)
{
// To run the retopology algorithm an istance of RetopoMeshBuilder is needed
RetopMeshBuilder rm;
// Load topology mesh
MeshModel *userMesh = par.getMesh("userMesh");
// Load (input) original mesh
MeshModel *inMesh = par.getMesh("inMesh");
// Load iterations value
int it = par.getInt("it");
// Load distance value
float dist = par.getAbsPerc("dist");
// Destination meshmodel: retopology mesh will replace flat topology mesh
MeshModel * outM = par.getMesh("userMesh");
// Prepare mesh
inMesh->updateDataMask(MeshModel::MM_FACEMARK);
tri::UpdateNormals<CMeshO>::PerFaceNormalized(inMesh->cm);
tri::UpdateFlags<CMeshO>::FaceProjection(inMesh->cm);
// Init the retopology builder with original input mesh and distance value
rm.init(inMesh, dist);
// Apply the algorithm
return rm.applyTopoMesh(*userMesh, *inMesh, it, dist, *outM);
}
示例4: setupMesh
void SdfGpuPlugin::setupMesh(MeshDocument& md, ONPRIMITIVE onPrimitive )
{
MeshModel* mm = md.mm();
CMeshO& m = mm->cm;
//If on vertices, do some cleaning first
if( onPrimitive == ON_VERTICES )
{
int dup = tri::Clean<CMeshO>::RemoveDuplicateVertex(m);
int unref = tri::Clean<CMeshO>::RemoveUnreferencedVertex(m);
if (dup > 0 || unref > 0) Log("Removed %i duplicate and %i unreferenced vertices\n",dup,unref);
}
//Updating mesh metadata
tri::UpdateBounding<CMeshO>::Box(m);
vcg::tri::Allocator<CMeshO>::CompactVertexVector(m);
vcg::tri::Allocator<CMeshO>::CompactFaceVector(m);
vcg::tri::UpdateNormals<CMeshO>::PerVertexAngleWeighted(m);
//Enable & Reset the necessary attributes
switch(onPrimitive)
{
case ON_VERTICES:
mm->updateDataMask(MeshModel::MM_VERTQUALITY);
tri::UpdateQuality<CMeshO>::VertexConstant(m,0);
break;
case ON_FACES:
mm->updateDataMask(MeshModel::MM_FACEQUALITY);
mm->updateDataMask(MeshModel::MM_FACENORMAL);
mm->updateDataMask(MeshModel::MM_FACECOLOR);
tri::UpdateQuality<CMeshO>::FaceConstant(m,0);
break;
}
if(!vcg::tri::HasPerVertexAttribute(m,"maxQualityDir") && onPrimitive == ON_VERTICES)
mMaxQualityDirPerVertex = vcg::tri::Allocator<CMeshO>::AddPerVertexAttribute<Point3f>(m,std::string("maxQualityDir"));
else if(!vcg::tri::HasPerFaceAttribute(m,"maxQualityDir") && onPrimitive == ON_FACES)
mMaxQualityDirPerFace = vcg::tri::Allocator<CMeshO>::AddPerFaceAttribute<Point3f>(m,std::string("maxQualityDir"));
}
示例5: ComputeFeature
template<class MESH_TYPE, class FEATURE_TYPE> bool FilterFeatureAlignment::ComputeFeatureOperation(MeshModel& m, typename FEATURE_TYPE::Parameters& param, CallBackPos *cb)
{
typedef MESH_TYPE MeshType;
typedef FEATURE_TYPE FeatureType;
//enables needed attributes
m.updateDataMask(FeatureType::getRequirements());
//compute feature for the given mesh
return FeatureType::ComputeFeature(m.cm, param, cb);
}
示例6: ConsensusOperation
float FilterFeatureAlignment::ConsensusOperation(MeshModel& mFix, MeshModel& mMov, typename CONSENSUS_TYPE::Parameters& param, CallBackPos *cb)
{
typedef CONSENSUS_TYPE ConsensusType;
typedef typename ConsensusType::MeshType MeshType;
typedef typename MeshType::ScalarType ScalarType;
typedef typename MeshType::VertexType VertexType;
typedef typename ConsensusType::Parameters ParamType;
//enables needed attributes. These are used by the getClosest functor.
mFix.updateDataMask(MeshModel::MM_VERTMARK);
mMov.updateDataMask(MeshModel::MM_VERTMARK);
ConsensusType cons;
cons.SetFix(mFix.cm);
cons.SetMove(mMov.cm);
if(!cons.Init(param)) return -1.0f;
return cons.Compute(param);
}
示例7: StartEdit
bool EditSelectPlugin::StartEdit(MeshModel &m, GLArea *gla )
{
gla->setCursor(QCursor(QPixmap(":/images/sel_rect.png"),1,1));
connect(this, SIGNAL(setSelectionRendering(bool)),gla,SLOT(setSelectFaceRendering(bool)) );
connect(this, SIGNAL(setSelectionRendering(bool)),gla,SLOT(setSelectVertRendering(bool)) );
setSelectionRendering(true);
if(selectionMode)
m.updateDataMask(MeshModel::MM_FACEFACETOPO);
return true;
}
示例8: save
bool IOMPlugin::save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask,const RichParameterSet & par, vcg::CallBackPos *cb, QWidget *parent)
{
QString errorMsgFormat = "Error encountered while exportering file %1:\n%2";
m.updateDataMask(MeshModel::MM_FACEFACETOPO);
int result = vcg::tri::io::ExporterM<CMeshO>::Save(m.cm,qPrintable(fileName),mask);
if(par.getBool("HtmlSnippet"))
{
vcg::tri::io::ExporterM<CMeshO>::WriteHtmlSnippet(qPrintable(fileName),qPrintable(QString(fileName)+".html"));
}
if(result!=0)
{
QMessageBox::warning(parent, tr("Saving Error"), errorMsgFormat.arg(qPrintable(fileName), vcg::tri::io::ExporterM<CMeshO>::ErrorMsg(result)));
return false;
}
return true;
}
示例9: applyFilter
bool FilterScreenedPoissonPlugin::applyFilter( const QString& filterName,MeshDocument& md,EnvWrap& env, vcg::CallBackPos* cb)
{
if (filterName == "Screened Poisson Surface Reconstruction")
{
MeshModel *mm =md.mm();
MeshModel *pm =md.addNewMesh("","Poisson mesh",false);
md.setVisible(pm->id(),false);
pm->updateDataMask(MeshModel::MM_VERTQUALITY);
PoissonParam<Scalarm> pp;
MeshModelPointStream<Scalarm> meshStream(mm->cm);
MeshDocumentPointStream<Scalarm> documentStream(md);
pp.MaxDepthVal = env.evalInt("depth");
pp.FullDepthVal = env.evalInt("fullDepth");
pp.CGDepthVal= env.evalInt("cgDepth");
pp.ScaleVal = env.evalFloat("scale");
pp.SamplesPerNodeVal = env.evalFloat("samplesPerNode");
pp.PointWeightVal = env.evalFloat("pointWeight");
pp.ItersVal = env.evalInt("iters");
pp.ConfidenceFlag = env.evalBool("confidence");
pp.NormalWeightsFlag = env.evalBool("nWeights");
pp.DensityFlag = true;
if(env.evalBool("visibleLayer"))
{
MeshModel *m=0;
while(m=md.nextVisibleMesh(m))
PoissonClean(m->cm, (pp.ConfidenceFlag || pp.NormalWeightsFlag));
Execute<Scalarm>(&documentStream,pm->cm,pp,cb);
}
else
{
PoissonClean(mm->cm, (pp.ConfidenceFlag || pp.NormalWeightsFlag));
Execute<Scalarm>(&meshStream,pm->cm,pp,cb);
}
pm->UpdateBoxAndNormals();
md.setVisible(pm->id(),true);
return true;
}
return false;
}
示例10: StartEdit
//
// Plugin init
//
bool edit_topo::StartEdit(MeshModel &m, GLArea *gla)
{
parentGla = gla;
gla->setCursor(QCursor(QPixmap(":/images/cursor_paint.png"),1,1));
// Init uniform grid
float dist = m.cm.bbox.Diag();
// Init data masks
m.updateDataMask(MeshModel::MM_FACEMARK);
tri::UpdateNormals<CMeshO>::PerFaceNormalized(m.cm);
tri::UpdateFlags<CMeshO>::FaceProjection(m.cm);
// Init retopology model builder object
rm.init(&m, dist);
// Init miminum visible distance param (used only for labels rendering)
_md = 0.03;
// Init ui
if (edit_topodialogobj == 0)
{
edit_topodialogobj = new edit_topodialog(gla->window());
dock = new QDockWidget(gla->window());
dock->setAllowedAreas(Qt::NoDockWidgetArea);
dock->setWidget(edit_topodialogobj);
QPoint p = gla->window()->mapToGlobal(QPoint(0,0));
dock->setGeometry(-5+p.x()+gla->window()->width()-edit_topodialogobj->width(),p.y(),edit_topodialogobj->width(),edit_topodialogobj->height());
dock->setFloating(true);
}
dock->setVisible(true);
dock->layout()->update();
gla->update();
gla->setMouseTracking(true);
// Connect slots
connect(edit_topodialogobj, SIGNAL( mesh_create() ),
this, SLOT( on_mesh_create() ) );
connect(edit_topodialogobj, SIGNAL( update_request() ),
this, SLOT( on_update_request() ) );
return true;
}
示例11: ExtractionOperation
bool FilterFeatureAlignment::ExtractionOperation(MeshModel& m, typename ALIGNER_TYPE::Parameters& param, CallBackPos *cb)
{
typedef ALIGNER_TYPE AlignerType;
typedef typename AlignerType::MeshType MeshType;
typedef typename AlignerType::FeatureType FeatureType;
//enables needed attributes
m.updateDataMask(FeatureType::getRequirements());
//extract features
vector<FeatureType*>* vecF = AlignerType::extractFeatures(param.numMovFeatureSelected, m.cm, param.samplingStrategy, cb);
if(!vecF) return false; //something wrong!
//clear old picked points, then, if requested, add all new points
AlignerType::ClearPickedPoints(m.cm);
if(param.pickPoints) AlignerType::AddPickedPoints(m.cm, *vecF); //add points
//clean up
vecF->clear(); delete vecF; vecF = NULL;
return true;
}
示例12: StartEdit
bool QualityMapperPlugin::StartEdit(MeshModel& m, GLArea *gla )
{
if(!m.hasDataMask(MeshModel::MM_VERTQUALITY))
{
QMessageBox::warning(gla, tr("Quality Mapper"), tr("The model has no vertex quality"), QMessageBox::Ok);
return false;
}
QMap<int,RenderMode>::iterator it = gla->rendermodemap.find(m.id());
m.updateDataMask(MeshModel::MM_VERTCOLOR | MeshModel::MM_VERTQUALITY);
if (it != gla->rendermodemap.end())
{
it.value().setColorMode(GLW::CMPerVert);
gla->update();
}
if(_qualityMapperDialog==0)
_qualityMapperDialog = new QualityMapperDialog(gla->window(), m, gla);
//drawing histogram
//bool ret = _qualityMapperDialog->initEqualizerHistogram();
if ( !_qualityMapperDialog->initEqualizerHistogram() )
{
//EndEdit(m, gla);
return false;
}
//drawing transferFunction
_qualityMapperDialog->drawTransferFunction();
//dialog ready to be displayed. Show it now!
_qualityMapperDialog->show();
connect(_qualityMapperDialog, SIGNAL(closingDialog()),gla,SLOT(endEdit()) );
return true;
}
示例13: applyFilter
bool SdfPlugin::applyFilter(MeshDocument& md, RichParameterSet& pars, vcg::CallBackPos* cb){
enum ONPRIMITIVE{ON_VERTICES, ON_FACES} onPrimitive;
MeshModel* mm = md.mm();
CMeshO& m = mm->cm;
//--- Retrieve parameters
float widenessRad = math::ToRad(pars.getFloat("coneWidth"));
int raysPerCone = pars.getInt("numberRays");
onPrimitive = (ONPRIMITIVE) pars.getEnum("onPrimitive");
qDebug() << "which primitive?" << onPrimitive;
float lo01pec = pars.getFloat("lowQuantile");
float hi01pec = pars.getFloat("hiQuantile");
assert( onPrimitive==ON_VERTICES && "Face mode not supported yet" );
//--- If on vertices, do some cleaning first
if( onPrimitive == ON_VERTICES ){
int dup = tri::Clean<CMeshO>::RemoveDuplicateVertex(m);
int unref = tri::Clean<CMeshO>::RemoveUnreferencedVertex(m);
if (dup > 0 || unref > 0) Log("Removed %i duplicate and %i unreferenced vertices\n",dup,unref);
}
//--- Updating mesh metadata
tri::UpdateBounding<CMeshO>::Box(m);
tri::UpdateNormals<CMeshO>::PerFaceNormalized(m);
tri::UpdateNormals<CMeshO>::PerVertexAngleWeighted(m);
tri::UpdateNormals<CMeshO>::NormalizeVertex(m);
tri::UpdateFlags<CMeshO>::FaceProjection(m);
//--- Enable & Reset the necessary attributes
switch(onPrimitive){
case ON_VERTICES:
// qDebug() << "initializing vert quality";
mm->updateDataMask(MeshModel::MM_VERTQUALITY);
tri::UpdateQuality<CMeshO>::VertexConstant(m,0);
break;
case ON_FACES:
mm->updateDataMask(MeshModel::MM_FACEQUALITY);
tri::UpdateQuality<CMeshO>::FaceConstant(m,0);
break;
}
//--- Add the mesh to an indexing structure (fast ray intersection)
Log("Initializing spatial accelleration...");
mm->updateDataMask(MeshModel::MM_FACEMARK);
TriMeshGrid static_grid; //TODO: rename spatial index
static_grid.Set(m.face.begin(), m.face.end());
Log("Initializing spatial accelleration... DONE!");
// since we are measuring the interior of the shape
// A ray should never go beyond this value
float maxDist=m.bbox.Diag();
// This is a small number to avoid self-intersection during ray
// casting. It's a very common trick
float epsilon = maxDist / 10000.0;
//--- Ray casting
vector<Ray3f> cone;
vector<float> coneSdf;
Ray3f ray;
float t;
for(unsigned int i=0; i<m.vert.size(); i++){
CVertexO& v = m.vert[i];
//--- Update progressbar
cb( i/m.vert.size(), "Casting rays into volume...");
//--- Generate the set of cones
ray.Set( v.P(), -v.N() );
ray.SetOrigin( ray.P(epsilon) );
generateRayCone( ray, widenessRad, raysPerCone, cone, coneSdf, (i==266) );
//--- Trace rays in cone
float mind = +numeric_limits<float>::max();
float maxd = -numeric_limits<float>::max();
for(unsigned int j=0; j<cone.size(); j++){
bool hasInt = tri::DoRay<CMeshO,TriMeshGrid>(m,static_grid,cone[j],maxDist,t);
coneSdf[j] = (hasInt==true) ? t : numeric_limits<float>::quiet_NaN();
mind = (hasInt && (t<mind)) ? t : mind;
maxd = (hasInt && (t>maxd)) ? t : maxd;
if( i==266 ){
qDebug() << " sampled: " << coneSdf[j]
<< " dir: " << toString(cone[j].Direction())
<< " hasInt: " << hasInt;
}
}
//--- Compute per-cone statistics
Histogram<float> H;
H.Clear();
H.SetRange( mind, maxd, 100);
for(unsigned int j=0; j<cone.size(); j++)
if(!math::IsNAN(coneSdf[j]))
H.Add(coneSdf[j]);
float loperc = H.Percentile(lo01pec);
float hiperc = H.Percentile(hi01pec);
if( i == 266){
qDebug() << "percentiles: " << loperc << " " << hiperc;
}
//.........这里部分代码省略.........
示例14: save
bool BaseMeshIOPlugin::save(const QString &formatName,const QString &fileName, MeshModel &m, const int mask, const RichParameterSet & par, CallBackPos *cb, QWidget */*parent*/)
{
QString errorMsgFormat = "Error encountered while exportering file %1:\n%2";
string filename = QFile::encodeName(fileName).constData ();
//string filename = fileName.toUtf8().data();
string ex = formatName.toUtf8().data();
bool binaryFlag = false;
if(formatName.toUpper() == tr("STL") || formatName.toUpper() == tr("PLY"))
binaryFlag = par.findParameter("Binary")->val->getBool();
if(formatName.toUpper() == tr("PLY"))
{
int result = tri::io::ExporterPLY<CMeshO>::Save(m.cm,filename.c_str(),mask,binaryFlag,cb);
if(result!=0)
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::ExporterPLY<CMeshO>::ErrorMsg(result));
return false;
}
return true;
}
if(formatName.toUpper() == tr("STL"))
{
int result = tri::io::ExporterSTL<CMeshO>::Save(m.cm,filename.c_str(),binaryFlag);
if(result!=0)
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::ExporterSTL<CMeshO>::ErrorMsg(result));
return false;
}
return true;
}
if(formatName.toUpper() == tr("WRL"))
{
int result = tri::io::ExporterWRL<CMeshO>::Save(m.cm,filename.c_str(),mask,cb);
if(result!=0)
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::ExporterWRL<CMeshO>::ErrorMsg(result));
return false;
}
return true;
}
if( formatName.toUpper() == tr("OFF"))
{
if(mask && tri::io::Mask::IOM_BITPOLYGONAL)
m.updateDataMask(MeshModel::MM_FACEFACETOPO);
int result = tri::io::Exporter<CMeshO>::Save(m.cm,filename.c_str(),mask,cb);
if(result!=0)
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::Exporter<CMeshO>::ErrorMsg(result));
return false;
}
return true;
}
if( formatName.toUpper() == tr("DXF") || formatName.toUpper() == tr("OBJ") )
{
int result = tri::io::Exporter<CMeshO>::Save(m.cm,filename.c_str(),mask,cb);
if(result!=0)
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::Exporter<CMeshO>::ErrorMsg(result));
return false;
}
return true;
}
assert(0); // unknown format
return false;
}
示例15: applyFilter
bool FilterIsoParametrization::applyFilter(QAction *filter, MeshDocument& md, RichParameterSet & par, vcg::CallBackPos *cb)
{
MeshModel* m = md.mm(); //get current mesh from document
CMeshO *mesh=&m->cm;
switch(ID(filter))
{
case ISOP_PARAM :
{
int targetAbstractMinFaceNum = par.getInt("targetAbstractMinFaceNum");
int targetAbstractMaxFaceNum = par.getInt("targetAbstractMaxFaceNum");
int convergenceSpeed = par.getInt("convergenceSpeed");
int stopCriteria=par.getEnum("stopCriteria");
bool doublestep=par.getBool("DoubleStep");
IsoParametrizator Parametrizator;
m->updateDataMask(MeshModel::MM_FACEFACETOPO);
bool isTXTenabled=m->hasDataMask(MeshModel::MM_VERTTEXCOORD);
if (!isTXTenabled)
m->updateDataMask(MeshModel::MM_VERTTEXCOORD);
bool isVMarkenabled=m->hasDataMask(MeshModel::MM_VERTMARK);
if (!isVMarkenabled)
m->updateDataMask(MeshModel::MM_VERTMARK);
bool isFMarkenabled=m->hasDataMask(MeshModel::MM_FACEMARK);
if (!isFMarkenabled)
m->updateDataMask(MeshModel::MM_FACEMARK);
bool isVColorenabled=m->hasDataMask(MeshModel::MM_VERTCOLOR);
if (!isVColorenabled)
m->updateDataMask(MeshModel::MM_VERTCOLOR);
bool isFColorenabled=m->hasDataMask(MeshModel::MM_FACECOLOR);
if (!isFColorenabled)
m->updateDataMask(MeshModel::MM_FACECOLOR);
int tolerance = targetAbstractMaxFaceNum-targetAbstractMinFaceNum;
switch (stopCriteria)
{
case 0:Parametrizator.SetParameters(cb,targetAbstractMinFaceNum,tolerance,IsoParametrizator::SM_Euristic,convergenceSpeed);break;
case 1:Parametrizator.SetParameters(cb,targetAbstractMinFaceNum,tolerance,IsoParametrizator::SM_Corr,convergenceSpeed);break;
case 2:Parametrizator.SetParameters(cb,targetAbstractMinFaceNum,tolerance,IsoParametrizator::SM_Reg,convergenceSpeed);break;
case 3:Parametrizator.SetParameters(cb,targetAbstractMinFaceNum,tolerance,IsoParametrizator::SM_L2,convergenceSpeed);break;
default:Parametrizator.SetParameters(cb,targetAbstractMinFaceNum,tolerance,IsoParametrizator::SM_Euristic,convergenceSpeed);break;
}
IsoParametrizator::ReturnCode ret=Parametrizator.Parametrize<CMeshO>(mesh,doublestep);
if (ret==IsoParametrizator::Done)
{
Parametrizator.PrintAttributes();
float aggregate,L2;
int n_faces;
Parametrizator.getValues(aggregate,L2,n_faces);
Log("Num Faces of Abstract Domain: %d, One way stretch efficiency: %.4f, Area+Angle Distorsion %.4f ",n_faces,L2,aggregate*100.f);
}
else
{
if (!isTXTenabled)
m->clearDataMask(MeshModel::MM_VERTTEXCOORD);
if (!isFMarkenabled)
m->clearDataMask(MeshModel::MM_FACEMARK);
if (!isVMarkenabled)
m->clearDataMask(MeshModel::MM_VERTMARK);
if (!isVColorenabled)
m->clearDataMask(MeshModel::MM_VERTCOLOR);
if (!isFColorenabled)
m->clearDataMask(MeshModel::MM_FACECOLOR);
if (ret==IsoParametrizator::NonPrecondition)
this->errorMessage="non possible parameterization because of violated preconditions";
else
if (ret==IsoParametrizator::FailParam)
this->errorMessage="non possible parameterization cause because missing the intepolation for some triangle of original the mesh (maybe due to topologycal noise)";
return false;
}
Parametrizator.ExportMeshes(para_mesh,abs_mesh);
isoPHandle=vcg::tri::Allocator<CMeshO>::AddPerMeshAttribute<IsoParametrization>(*mesh,"isoparametrization");
bool isOK=isoPHandle().Init(&abs_mesh,¶_mesh);
///copy back to original mesh
isoPHandle().CopyParametrization<CMeshO>(mesh);
if (!isOK)
{
Log("Problems gathering parameterization \n");
return false;
}
if (!isVMarkenabled)
m->clearDataMask(MeshModel::MM_VERTMARK);
if (!isFMarkenabled)
m->clearDataMask(MeshModel::MM_FACEMARK);
return true;
}
case ISOP_REMESHING :
{
bool b=vcg::tri::Allocator<CMeshO>::IsValidHandle<IsoParametrization>(*mesh,isoPHandle);
if (!b)
{
this->errorMessage="You must compute the Base domain before remeshing. Use the Isoparametrization command.";
return false;
//.........这里部分代码省略.........