本文整理汇总了C++中MeshModel::hasDataMask方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshModel::hasDataMask方法的具体用法?C++ MeshModel::hasDataMask怎么用?C++ MeshModel::hasDataMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshModel
的用法示例。
在下文中一共展示了MeshModel::hasDataMask方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initParameterSet
/* Initializes the list of parameters (called by the auto dialog framework) */
void GeometryAgingPlugin::initParameterSet(QAction *action, MeshModel &m, RichParameterSet ¶ms)
{
if( ID(action) != FP_ERODE)
{
assert (0);
return;
}
bool hasQ = m.hasDataMask(MeshModel::MM_VERTQUALITY);
std::pair<float,float> qRange(0.0, 0.0);; // mesh quality range
// retrieve mesh quality range
if(hasQ)
{
qRange = tri::Stat<CMeshO>::ComputePerVertexQualityMinMax(m.cm);
if(qRange.second <= qRange.first) hasQ=false;
}
params.addParam(new RichBool("ComputeCurvature", !hasQ, "ReCompute quality from curvature",
"Compute per vertex quality values using mesh mean curvature <br>"
"algorithm. In this way only the areas with higher curvature <br>"
"will be eroded. If not checked, the quality values already <br>"
"present over the mesh will be used."));
params.addParam(new RichBool("SmoothQuality", false, "Smooth vertex quality",
"Smooth per vertex quality values. This allows to extend the <br>"
"area affected by the erosion process."));
params.addParam(new RichAbsPerc("QualityThreshold", qRange.first+(qRange.second-qRange.first)*0.66,
qRange.first, qRange.second, "Min quality threshold",
"Represents the minimum quality value two vertexes must have <br>"
"to consider the edge they are sharing."));
params.addParam(new RichAbsPerc("EdgeLenThreshold", m.cm.bbox.Diag()*0.02, 0,m.cm.bbox.Diag()*0.5,
"Edge len threshold",
"The minimum length of an edge. Useful to avoid the creation of too many small faces."));
params.addParam(new RichAbsPerc("ChipDepth", m.cm.bbox.Diag()*0.05, 0, m.cm.bbox.Diag(),
"Max chip depth", "The maximum depth of a chip."));
params.addParam(new RichInt("Octaves", 3, "Fractal Octaves",
"The number of octaves that are used in the generation of the <br>"
"fractal noise using Perlin noise; reasonalble values are in the <br>"
"1..8 range. Setting it to 1 means using a simple Perlin Noise."));
params.addParam(new RichAbsPerc("NoiseFreqScale", m.cm.bbox.Diag()/10, 0, m.cm.bbox.Diag(), "Noise frequency scale",
"Changes the noise frequency scale: this affects chip dimensions and <br>"
"the distance between chips. The value denotes the average values <br>"
"between two dents. Smaller number means small and frequent chips."));
params.addParam(new RichFloat("NoiseClamp", 0.5, "Noise clamp threshold [0..1]",
"All the noise values smaller than this parameter will be <br> "
"considered as 0."));
params.addParam(new RichFloat("DisplacementSteps", 10, "Displacement steps",
"The whole displacement process is performed as a sequence of small <br>"
"offsets applyed on each vertex. This parameter represents the number <br>"
"of steps into which the displacement process will be splitted. <br>"
"Useful to avoid the introduction of self intersections. <br>"
"Bigger number means better accuracy."));
params.addParam(new RichBool("Selected", m.cm.sfn>0, "Affect only selected faces",
"The aging procedure will be applied to the selected faces only."));
params.addParam(new RichBool("StoreDisplacement", false, "Store erosion informations",
"Select this option if you want to store the erosion informations <br>"
"over the mesh. A new attribute will be added to each vertex <br>"
"to contain the displacement offset applied to that vertex."));
}
示例2: 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;
}
示例3: 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;
//.........这里部分代码省略.........
示例4: open
bool BaseMeshIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet &parlst, CallBackPos *cb, QWidget * /*parent*/)
{
bool normalsUpdated = false;
// initializing mask
mask = 0;
// initializing progress bar status
if (cb != NULL) (*cb)(0, "Loading...");
QString errorMsgFormat = "Error encountered while loading file:\n\"%1\"\n\nError details: %2";
//string filename = fileName.toUtf8().data();
string filename = QFile::encodeName(fileName).constData ();
if (formatName.toUpper() == tr("PLY"))
{
tri::io::ImporterPLY<CMeshO>::LoadMask(filename.c_str(), mask);
// small patch to allow the loading of per wedge color into faces.
if(mask & tri::io::Mask::IOM_WEDGCOLOR) mask |= tri::io::Mask::IOM_FACECOLOR;
m.Enable(mask);
int result = tri::io::ImporterPLY<CMeshO>::Open(m.cm, filename.c_str(), mask, cb);
if (result != 0) // all the importers return 0 on success
{
if(tri::io::ImporterPLY<CMeshO>::ErrorCritical(result) )
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::ImporterPLY<CMeshO>::ErrorMsg(result));
return false;
}
}
}
else if (formatName.toUpper() == tr("STL"))
{
int result = tri::io::ImporterSTL<CMeshO>::Open(m.cm, filename.c_str(), cb);
if (result != 0) // all the importers return 0 on success
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::ImporterSTL<CMeshO>::ErrorMsg(result));
return false;
}
}
else if( (formatName.toUpper() == tr("OBJ")) || (formatName.toUpper() == tr("QOBJ")) )
{
tri::io::ImporterOBJ<CMeshO>::Info oi;
oi.cb = cb;
if (!tri::io::ImporterOBJ<CMeshO>::LoadMask(filename.c_str(), oi))
return false;
m.Enable(oi.mask);
int result = tri::io::ImporterOBJ<CMeshO>::Open(m.cm, filename.c_str(), oi);
if (result != tri::io::ImporterOBJ<CMeshO>::E_NOERROR)
{
if (result & tri::io::ImporterOBJ<CMeshO>::E_NON_CRITICAL_ERROR)
errorMessage = errorMsgFormat.arg(fileName, tri::io::ImporterOBJ<CMeshO>::ErrorMsg(result));
else
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::ImporterOBJ<CMeshO>::ErrorMsg(result));
return false;
}
}
if(oi.mask & tri::io::Mask::IOM_WEDGNORMAL)
normalsUpdated = true;
m.Enable(oi.mask);
if(m.hasDataMask(MeshModel::MM_POLYGONAL)) qDebug("Mesh is Polygonal!");
mask = oi.mask;
}
else if (formatName.toUpper() == tr("PTX"))
{
tri::io::ImporterPTX<CMeshO>::Info importparams;
importparams.meshnum = parlst.getInt("meshindex");
importparams.anglecull =parlst.getBool("anglecull");
importparams.angle = parlst.getFloat("angle");
importparams.savecolor = parlst.getBool("usecolor");
importparams.pointcull = parlst.getBool("pointcull");
importparams.pointsonly = parlst.getBool("pointsonly");
importparams.switchside = parlst.getBool("switchside");
importparams.flipfaces = parlst.getBool("flipfaces");
// if color, add to mesh
if(importparams.savecolor)
importparams.mask |= tri::io::Mask::IOM_VERTCOLOR;
if(importparams.pointsonly)
importparams.mask |= tri::io::Mask::IOM_VERTRADIUS;
// reflectance is stored in quality
importparams.mask |= tri::io::Mask::IOM_VERTQUALITY;
m.Enable(importparams.mask);
int result = tri::io::ImporterPTX<CMeshO>::Open(m.cm, filename.c_str(), importparams, cb);
if (result == 1)
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::ImporterPTX<CMeshO>::ErrorMsg(result));
return false;
}
// update mask
//.........这里部分代码省略.........
示例5: applyFilter
bool SdfGpuPlugin::applyFilter(QAction */*filter*/, MeshDocument &md, RichParameterSet & pars, vcg::CallBackPos *cb)
{
MeshModel* mm = md.mm();
//RETRIEVE PARAMETERS
mOnPrimitive = (ONPRIMITIVE) pars.getEnum("onPrimitive");
// assert( mOnPrimitive==ON_VERTICES && "Face mode not supported yet" );
unsigned int numViews = pars.getInt("numberRays");
int peel = pars.getInt("peelingIteration");
mTolerance = pars.getFloat("peelingTolerance");
mPeelingTextureSize = pars.getInt("DepthTextureSize");
mUseVBO = pars.getBool("useVBO");
if(mAction != SDF_DEPTH_COMPLEXITY)
mMinCos = vcg::math::Cos(math::ToRad(pars.getFloat("coneAngle")/2.0));
std::vector<Point3f> coneDirVec;
if(mAction == SDF_OBSCURANCE)
mTau = pars.getFloat("obscuranceExponent");
else if(mAction==SDF_SDF)
{
mRemoveFalse = pars.getBool("removeFalse");
mRemoveOutliers = pars.getBool("removeOutliers");
}
//MESH CLEAN UP
setupMesh( md, mOnPrimitive );
//GL INIT
if(!initGL(*mm)) return false;
//
if(mOnPrimitive==ON_VERTICES)
vertexDataToTexture(*mm);
else
faceDataToTexture(*mm);
//Uniform sampling of directions over a sphere
std::vector<Point3f> unifDirVec;
GenNormal<float>::Uniform(numViews,unifDirVec);
Log(0, "Number of rays: %i ", unifDirVec.size() );
Log(0, "Number of rays for GPU outliers removal: %i ", coneDirVec.size() );
coneDirVec.clear();
vector<int> mDepthDistrib(peel,0);
//Do the actual calculation of sdf or obscurance for each ray
unsigned int tracedRays = 0;
for(vector<vcg::Point3f>::iterator vi = unifDirVec.begin(); vi != unifDirVec.end(); vi++)
{
(*vi).Normalize();
TraceRay(peel, (*vi), md.mm());
cb(100*((float)tracedRays/(float)unifDirVec.size()), "Tracing rays...");
this->glContext->makeCurrent();
++tracedRays;
mDepthComplexity = std::max(mDepthComplexity, mTempDepthComplexity);
mDepthDistrib[mTempDepthComplexity]++;
mTempDepthComplexity = 0;
}
//read back the result texture and store result in the mesh
if(mAction == SDF_OBSCURANCE)
{
if(mOnPrimitive == ON_VERTICES)
applyObscurancePerVertex(*mm,unifDirVec.size());
else
applyObscurancePerFace(*mm,unifDirVec.size());
}
else if(mAction == SDF_SDF)
{
if(mOnPrimitive == ON_VERTICES)
applySdfPerVertex(*mm);
else
applySdfPerFace(*mm);
}
// LP: save output
if(mOnPrimitive == ON_FACES)
{
CMeshO& cm=mm->cm;
if(!mm->hasDataMask(MeshModel::MM_VERTFACETOPO)) {
mm->updateDataMask(MeshModel::MM_VERTFACETOPO);
}
if(!mm->hasDataMask(MeshModel::MM_VERTCURV)) {
mm->updateDataMask(MeshModel::MM_VERTCURV);
// vcg::tri::UpdateCurvature<CMeshO>::VertexCurvature(cm);
}
//当前目录
QDir dir;
//dir.currentPath();
//设置输出文件
//.........这里部分代码省略.........
示例6: StartEdit
bool EditAreslpPlugin::StartEdit(MeshModel &mm, GLArea *gla)
{
qDebug()<<"EditAreslpPlugin StartEdit";
if(!mm.hasDataMask(MeshModel::MM_VERTQUALITY)) {
mm.updateDataMask(MeshModel::MM_VERTQUALITY);
}
if(!mm.hasDataMask(MeshModel::MM_FACEQUALITY)) {
mm.updateDataMask(MeshModel::MM_FACEQUALITY);
}
AreslpDialog dialog;
dialog.exec();
std::vector<int> pointset=dialog.pointset_;
std::vector<int> faceset=dialog.faceset_;
std::vector<int> patchset=dialog.patchset_;
//Debug the content of above two vector
for(int i = 0; i < pointset.size(); i++) {
qDebug()<<pointset[i];
}
for(int i = 0; i < faceset.size(); i++) {
qDebug()<<faceset[i];
}
for(int i = 0; i < patchset.size(); i++) {
qDebug()<<patchset[i];
}
CMeshO& cm = mm.cm;
int point_size = cm.vert.size();
if(pointset.size()!=0){
//先把之前设置的值清空
for(int i = 0; i < point_size; i++) {
cm.vert[i].Q() = 0;
}
for(int i = 0; i < pointset.size(); i++) {
cm.vert[pointset[i]].Q() = 1;
}
}
int face_size=cm.face.size();
if(faceset.size()!=0){
//先把之前设置的值清空
for(int i = 0; i < face_size; i++) {
cm.face[i].Q() = 0;
}
for(int i = 0; i < faceset.size(); i++) {
cm.face[faceset[i]].Q() = 1;
}
}
if(patchset.size()!=0){
//patch
std::map<int,double> qm;
for (int i = 0; i < patchset.size(); i++) {
std::string tstring="faceq";
tstring.append(boost::lexical_cast<std::string>(patchset[i]));
tstring.append(".txt");
qDebug()<<tstring.c_str();
std::ifstream ifile(tstring.c_str());
int ii;
double v;
while(ifile >> ii >> v) {
// qDebug()<<i<<" "<<v;
qm.insert(make_pair<int,double>(ii,v));
}
ifile.close();
}
for (int i = 0; i < face_size; i++) {
if (qm.find(i)!=qm.end()) {
cm.face[i].Q()=qm[i];
}else{
cm.face[i].Q()=0;
}
}
}
示例7: save
bool JSONIOPlugin::save(const QString & formatName,const QString & fileName, MeshModel & m, const int mask, const RichParameterSet & par, vcg::CallBackPos * cb, QWidget * parent)
{
(void)par;
(void)cb;
(void)parent;
vcg::tri::Allocator<CMeshO>::CompactVertexVector(m.cm);
vcg::tri::Allocator<CMeshO>::CompactFaceVector(m.cm);
const size_t maxValuesPerLine = 10; // must be > 0
if (formatName.toUpper() != tr("JSON")) return false;
const bool hasPerVertexPosition = true;
const bool hasPerVertexNormal = ((mask & vcg::tri::io::Mask::IOM_VERTNORMAL) != 0) && m.hasDataMask(MeshModel::MM_VERTNORMAL);
const bool hasPerVertexColor = ((mask & vcg::tri::io::Mask::IOM_VERTCOLOR) != 0) && m.hasDataMask(MeshModel::MM_VERTCOLOR);
const bool hasPerVertexTexCoord = ((mask & vcg::tri::io::Mask::IOM_VERTTEXCOORD) != 0) && m.hasDataMask(MeshModel::MM_VERTTEXCOORD);
const CMeshO & cm = m.cm;
const std::string filename = QFile::encodeName(fileName).constData();
std::ofstream os(filename.c_str());
if (!os.is_open()) return false;
os << "{" << std::endl;
os << " \"version\" : \"0.1.0\"," << std::endl;
os << std::endl;
os << " \"comment\" : \"Generated by MeshLab JSON Exporter\"," << std::endl;
os << std::endl;
os << " \"id\" : 1," << std::endl;
os << " \"name\" : \"mesh\"," << std::endl;
os << std::endl;
os << " \"vertices\" :" << std::endl;
os << " [" << std::endl;
bool prevDone = false;
if (hasPerVertexPosition)
{
os << " {" << std::endl;
os << " \"name\" : \"position_buffer\"," << std::endl;
os << " \"size\" : 3," << std::endl;
os << " \"type\" : \"float32\"," << std::endl;
os << " \"normalized\" : false," << std::endl;
os << " \"values\" :" << std::endl;
os << " [" << std::endl;
size_t it = 0;
const size_t sz = cm.vert.size();
while (it < sz)
{
const size_t n = std::min(it + maxValuesPerLine, sz);
if (n > 0)
{
os << " ";
{
const CMeshO::VertexType::CoordType & p = cm.vert[it].cP();
os << p[0] << ", " << p[1] << ", " << p[2];
it++;
}
for (; it<n; ++it)
{
const CMeshO::VertexType::CoordType & p = cm.vert[it].cP();
os << ", " << p[0] << ", " << p[1] << ", " << p[2];
}
if (it <= (sz - 1))
{
os << ",";
}
os << std::endl;
}
}
os << " ]" << std::endl;
os << " }";
prevDone = true;
}
if (hasPerVertexNormal)
{
if (prevDone)
{
os << "," << std::endl;
os << std::endl;
}
os << " {" << std::endl;
os << " \"name\" : \"normal_buffer\"," << std::endl;
os << " \"size\" : 3," << std::endl;
os << " \"type\" : \"float32\"," << std::endl;
os << " \"normalized\" : false," << std::endl;
os << " \"values\" :" << std::endl;
os << " [" << std::endl;
size_t it = 0;
const size_t sz = cm.vert.size();
//.........这里部分代码省略.........