本文整理汇总了C++中MyMesh::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMesh::Clear方法的具体用法?C++ MyMesh::Clear怎么用?C++ MyMesh::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMesh
的用法示例。
在下文中一共展示了MyMesh::Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CapHole
void CapHole(MyMesh &m, MyMesh &capMesh, bool reverseFlag)
{
capMesh.Clear();
std::vector< std::vector<Point3f> > outlines;
std::vector<Point3f> outline;
tri::Allocator<MyMesh>::CompactVertexVector(m);
tri::Allocator<MyMesh>::CompactFaceVector(m);
tri::UpdateFlags<MyMesh>::FaceClearV(m);
tri::UpdateFlags<MyMesh>::VertexClearV(m);
tri::UpdateTopology<MyMesh>::FaceFace(m);
int nv=0;
for(size_t i=0; i<m.face.size(); i++)
{
for (int j=0; j<3; j++)
if (!m.face[i].IsV() && face::IsBorder(m.face[i],j))
{
MyFace* startB=&(m.face[i]);
vcg::face::Pos<MyFace> p(startB,j);
assert(p.IsBorder());
do
{
assert(p.IsManifold());
p.F()->SetV();
outline.push_back(p.V()->P());
p.NextB();
nv++;
}
while(!p.F()->IsV());
if (reverseFlag)
std::reverse(outline.begin(),outline.end());
outlines.push_back(outline);
outline.clear();
}
}
if (nv<2) return;
MyMesh::VertexIterator vi=vcg::tri::Allocator<MyMesh>::AddVertices(capMesh,nv);
for (size_t i=0; i<outlines.size(); i++)
{
for(size_t j=0; j<outlines[i].size(); ++j,++vi)
(&*vi)->P()=outlines[i][j];
}
std::vector<int> indices;
glu_tesselator::tesselate(outlines, indices);
std::vector<Point3f> points;
glu_tesselator::unroll(outlines, points);
MyMesh::FaceIterator fi=tri::Allocator<MyMesh>::AddFaces(capMesh,nv-2);
for (size_t i=0; i<indices.size(); i+=3,++fi)
{
(*&fi)->V(0)=&capMesh.vert[ indices[i+0] ];
(*&fi)->V(1)=&capMesh.vert[ indices[i+1] ];
(*&fi)->V(2)=&capMesh.vert[ indices[i+2] ];
}
tri::Clean<MyMesh>::RemoveDuplicateVertex(capMesh);
tri::UpdateBounding<MyMesh>::Box(capMesh);
}
示例2: Sampling
void MasterPly::Sampling (char* input, char* output) {
MyMesh m;
MyMesh subM;
float rad = 0.f;
if(tri::io::ImporterPLY<MyMesh>::Open(m,input)!=0)
{
cout << "Error reading file %s\n" << endl;
return;
}
MyMesh vcgMesh;
int verticeCount;
int triangleCount;
vcgMesh.Clear();
verticeCount=m.VN();
vcg::tri::Allocator<MyMesh>::AddVertices(vcgMesh,verticeCount);
for(int i=0;i<verticeCount;i++){
vcgMesh.vert[i].P()=vcg::Point3f(m.vert[i].P()[0],m.vert[i].P()[1],m.vert[i].P()[2]);
}
tri::UpdateBounding<MyMesh>::Box(vcgMesh);
// calculate radius
rad = tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::ComputePoissonDiskRadius(vcgMesh, 100000);
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::SamplingRandomGenerator().initialize((unsigned int)time(0));
//sample point cloud
std::vector<Point3f> sampleVec;
tri::TrivialSampler<MyMesh> mps(sampleVec);
// sampling
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskParam pp;
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskParam::Stat pds;
pp.preGenMesh = &subM;
//pp.pds=&pds;
pp.bestSampleChoiceFlag=false;
// start poisson disk prunning
sampleVec.clear();
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, vcgMesh, rad, pp);
tri::Build(subM,sampleVec);
// sample
std::stringstream sample;
sample << "sampled_" << output;
//Build surface
vcg::tri::UpdateBounding<MyMesh>::Box(subM);
vcg::tri::UpdateNormal<MyMesh>::PerVertex(subM);
//Initialization
tri::BallPivoting<MyMesh> pivot(subM);
//the main processing
pivot.BuildMesh();
tri::io::ExporterPLY<MyMesh>::Save(subM,output,true);
}
示例3: LoadMesh
static int LoadMesh (
const char * filename,
std::vector<Surfel<Real> >& pSurfel,vcg::CallBackPos *cb = 0)
{
MyMesh mesh;
int mask = 0;
mesh.Clear();
if (cb != NULL) (*cb)(0, "Loading Model...");
vcg::tri::io::PlyInfo info;
info.cb = cb;
vcg::tri::io::ImporterPLY<MyMesh>::LoadMask(filename, mask,info);
vcg::tri::io::ImporterPLY<MyMesh>::Open(mesh,filename,info);
bool normal_per_vertex = false;
if (mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
normal_per_vertex = true;
bool color_per_vertex = false;
if (mask & vcg::tri::io::Mask::IOM_VERTCOLOR)
color_per_vertex = true;
bool quality_per_vertex = false;
if (mask & vcg::tri::io::Mask::IOM_VERTQUALITY)
quality_per_vertex = true;
bool radius_per_vertex = false;
if (mask & vcg::tri::io::Mask::IOM_VERTRADIUS)
radius_per_vertex = true;
unsigned int pos = 0;
Surfel<Real> s;
for (MyMesh::VertexIterator vit = mesh.vert.begin(); vit != mesh.vert.end(); ++vit)
{
Point3f v = (*vit).P();
Point3f n = (*vit).N();
Color4b c (0.2, 0.2, 0.2, 1.0);
if (color_per_vertex) {
c = Color4b ((GLubyte)(*vit).C()[0], (GLubyte)(*vit).C()[1], (GLubyte)(*vit).C()[2], 1.0);
}
Real radius = 0.25;
if (radius_per_vertex)
{
radius = static_cast<Real> (((*vit).R()));
}
Real quality = 1.0;
if (quality_per_vertex)
quality = static_cast<Real> ((*vit).Q());
s = Surfel<Real> (v, n, c, radius, pos);
s.SetRadius(radius);
pSurfel.push_back (s);
++pos;
}
std::cout << "Surfel " << pSurfel.size() << std::endl;
if (cb != NULL) (*cb)(99, "Done");
mesh.Clear();
return 0;
}
示例4: Sampling
MyMesh* MasterPly::Sampling (string input) {
MyMesh m;
float rad = 0.f;
tri::io::ImporterPLY<MyMesh>::Open(m,input.c_str());
MyMesh vcgMesh;
int verticeCount;
int triangleCount;
/*MyMesh::VertexIterator vi = vcg::tri::Allocator<MyMesh>::AddVertices(vcgMesh,3);
MyMesh::FaceIterator fi = vcg::tri::Allocator<MyMesh>::AddFaces(vcgMesh,1);
MyMesh::VertexPointer ivp[4];
ivp[0]=&*vi; vi->P()=MyMesh::CoordType ( 0.0, 0.0, 0.0); ++vi;
ivp[1]=&*vi; vi->P()=MyMesh::CoordType ( 1.0, 0.0, 0.0); ++vi;
ivp[2]=&*vi; vi->P()=MyMesh::CoordType ( 0.0, 1.0, 0.0); ++vi;
fi->V(0)=ivp[0];
fi->V(1)=ivp[1];
fi->V(2)=ivp[2];*/
vcgMesh.Clear();
verticeCount=m.VN();
vcg::tri::Allocator<MyMesh>::AddVertices(vcgMesh,verticeCount);
for(int i=0;i<verticeCount;i++){
vcgMesh.vert[i].P()=vcg::Point3f(m.vert[i].P()[0],m.vert[i].P()[1],m.vert[i].P()[2]);
}
/*
triangleCount=m.FN();
vcg::tri::Allocator<MyMesh>::AddFaces(vcgMesh, triangleCount);
for(int i=0;i<triangleCount;i++){
vcgMesh.face[i].V(0)=m.face[i].V(0);
vcgMesh.face[i].V(1)=m.face[i].V(0);
vcgMesh.face[i].V(2)=m.face[i].V(0);
}*/
tri::UpdateBounding<MyMesh>::Box(vcgMesh);
// calculate radius
rad = tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::ComputePoissonDiskRadius(vcgMesh, 100000);
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::SamplingRandomGenerator().initialize((unsigned int)time(0));
//sample point cloud
std::vector<Point3f> sampleVec;
tri::TrivialSampler<MyMesh> mps(sampleVec);
// sampling
cout << "Subsampling a PointCloud" << endl;
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskParam pp;
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskParam::Stat pds;
pp.preGenMesh = &subM;
//pp.pds=&pds;
pp.bestSampleChoiceFlag=false;
// start poisson disk prunning
sampleVec.clear();
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, vcgMesh, rad, pp);
tri::Build(subM,sampleVec);
// sample
std::stringstream sample;
//Build surface
vcg::tri::UpdateBounding<MyMesh>::Box(subM);
vcg::tri::UpdateNormal<MyMesh>::PerVertex(subM);
//Initialization
tri::BallPivoting<MyMesh> pivot(subM);
cout << "Antes " << (unsigned int)time(0) <<endl;
//the main processing
pivot.BuildMesh();
//output the result
//tri::io::ExporterSTL<MyMesh>::Save(subM,output);
cout << "Despues " << subM.VN() <<endl;
tri::io::ExporterPLY<MyMesh>::Save(subM,"pruebaaaaaaa.ply",true);
cout << "Fin!!!!" << endl;
return &subM;
}