当前位置: 首页>>代码示例>>C++>>正文


C++ MyMesh类代码示例

本文整理汇总了C++中MyMesh的典型用法代码示例。如果您正苦于以下问题:C++ MyMesh类的具体用法?C++ MyMesh怎么用?C++ MyMesh使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MyMesh类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: f_it

void KnotsViewer::draw_curvature_error_domain()
{

    if(surfacedata==NULL)
        return;
    if ((surfacedata->get_domain()).empty())
        return;
    MyMesh polymesh = surfacedata->get_polymesh();
    if (polymesh.edges_empty()==true)
        return;
    MyMesh::ConstFaceIter        f_it(polymesh.faces_begin()),f_end(polymesh.faces_end());
    MyMesh::ConstFaceVertexIter  fv_it;
    //glLineWidth(0.5);
    for (; f_it!=f_end; ++f_it)
    {

        glColor3ubv(polymesh.color(*f_it).data());
        glBegin(GL_POLYGON);
        fv_it = polymesh.cfv_iter(*f_it);
        glVertex3dv(&polymesh.point(fv_it)[0]);
        ++fv_it;
        glVertex3dv(&polymesh.point(fv_it)[0]);
        ++fv_it;
        glVertex3dv(&polymesh.point(fv_it)[0]);
        ++fv_it;
        glVertex3dv(&polymesh.point(fv_it)[0]);
        glEnd();
    }


}
开发者ID:xiamenwcy,项目名称:b_spline-fitting,代码行数:31,代码来源:KnotsViewer.cpp

示例2: refine

  char* refine(int num)
  {
    MyMesh m;
    int t0=clock();
    int loadmask;

    printf("Buffer ptr is '%i'\n",buf);
    printf("Buffer[0] is '%c'\n",buf[0]);

    int ret = tri::io::ImporterOFF<MyMesh>::OpenMem(m,buf,strlen(buf),loadmask);
    int t1=clock();
    if(ret != 0)
    {
      printf("Error in opening file\n");
      exit(-1);
    }
    int t2=clock();
    printf("Read mesh %i %i\n",m.FN(),m.VN());
    tri::UpdateTopology<MyMesh>::FaceFace(m);
    tri::EdgeLen<MyMesh,float> edgePred(0);
    tri::MidPoint<MyMesh> midFun(&m);
    tri::RefineE(m,midFun,edgePred);
    int t3=clock();
    printf("Refined mesh %i %i\n",m.FN(),m.VN());
    printf("Opening time %5.2f \n Refinement time %5.2f",float(t1-t0)/CLOCKS_PER_SEC,float(t3-t2)/CLOCKS_PER_SEC);
    char *bufMeshOut = tri::io::ExporterOFF<MyMesh>::SaveStream(m);
    return bufMeshOut;
  }
开发者ID:MarcoLoddo,项目名称:meshlabjs,代码行数:28,代码来源:refine.cpp

示例3: computeCurvature

void computeCurvature(TriMesh *&triMesh, MyMesh**tMesh)
{
	TriMesh *tmesh = new TriMesh(*triMesh);
	unsigned vNum = tmesh->vertices.size();
	tmesh->colors.resize(triMesh->vertices.size());
	colorbycurv(tmesh, "0.0", "0.1");

	unsigned i = 0; double maxAnis = 0;
	MyMesh* myMesh = *tMesh;
	for (MyMesh::VertexIter v_it = myMesh->getVertices().begin(); v_it != myMesh->getVertices().end(); v_it++)
	{
		v_it->normal() = AML::double3(tmesh->normals[i][0], tmesh->normals[i][1], tmesh->normals[i][2]);
		v_it->color() = AML::double3(tmesh->colors[i][0], tmesh->colors[i][1], tmesh->colors[i][2]);
		v_it->direction(0) = AML::double3(tmesh->pdir1[i][0], tmesh->pdir1[i][1], tmesh->pdir1[i][2]);
		v_it->direction(1) = AML::double3(tmesh->pdir2[i][0], tmesh->pdir2[i][1], tmesh->pdir2[i][2]);
		v_it->magnitude(0) = fabs(tmesh->curv1[i]);
		v_it->magnitude(1) = fabs(tmesh->curv2[i]);

		double& k1 = v_it->magnitude(0);
		double& k2 = v_it->magnitude(1);

		double diff = fabs(k1 - k2);

		if (maxAnis < diff)
		{
			maxAnis = diff;
		}
		i++;
	}
	AnisGeodesic::maxAnis = maxAnis;
	delete tmesh;
}
开发者ID:yixin26,项目名称:Mesh-Segmentation,代码行数:32,代码来源:main.cpp

示例4: SmoothPlugin

void SmoothPlugin(uintptr_t _m, int step)
{
    MyMesh *n = (MyMesh*) _m;
    int t2=clock();    
    tri::UpdateTopology<MyMesh>::VertexFace(*n);        
    tri::Smooth<MyMesh>::VertexCoordLaplacian(*n, step, false, true);
    tri::UpdateNormal<MyMesh>::PerVertexPerFace(*n);
    int t3=clock();
    printf("Smooth mesh %i vert - %i face \n",n->VN(),n->FN());
    printf("Smooth time %5.2f\n",float(t3-t2)/CLOCKS_PER_SEC);
}
开发者ID:MarcoLoddo,项目名称:meshlabjs,代码行数:11,代码来源:Smooth.cpp

示例5: openMesh

    int openMesh() {
        int loadmask;

        int ret = tri::io::ImporterOFF<MyMesh>::OpenMem(m,buf,strlen(buf),loadmask);
        if(ret != 0)
        {
            printf("Error in opening file\n");
            exit(-1);
        }
        printf("Read mesh %i %i\n",m.FN(),m.VN());
        return ret;
    }
开发者ID:vvidal,项目名称:meshlabjs,代码行数:12,代码来源:open.cpp

示例6: main

int main( int argc, char **argv )
{
  if(argc<3)
  {
    printf("Usage trimesh_base <meshfilename> radius (as perc) (\n");
    return -1;
  }

  MyMesh m;
  MyMesh subM;
  MyMesh cluM;
  MyMesh rndM;

  tri::MeshSampler<MyMesh> mps(subM);
  tri::MeshSampler<MyMesh> mrs(rndM);

  if(tri::io::Importer<MyMesh>::Open(m,argv[1])!=0)
  {
    printf("Error reading file  %s\n",argv[1]);
    exit(0);
  }
  tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::SamplingRandomGenerator().initialize(time(0));
  float perc = atof(argv[2]);

  float radius = m.bbox.Diag() * perc;
  printf("Subsampling a PointCloud of %i vert with %f radius\n",m.VN(),radius);
  tri::SurfaceSampling<MyMesh,tri::MeshSampler<MyMesh> >::PoissonDiskParam pp;
  tri::SurfaceSampling<MyMesh,tri::MeshSampler<MyMesh> >::PoissonDiskParam::Stat pds; pp.pds=&pds;
  pp.bestSampleChoiceFlag=false;
  tri::SurfaceSampling<MyMesh,tri::MeshSampler<MyMesh> >::PoissonDiskPruning(mps, m, radius, pp);
  tri::io::ExporterPLY<MyMesh>::Save(subM,"PoissonMesh.ply");
  printf("Sampled %i vertices in %5.2f\n",subM.VN(), float(pds.pruneTime+pds.gridTime)/float(CLOCKS_PER_SEC));

  int t0=clock();
  tri::Clustering<MyMesh, vcg::tri::AverageColorCell<MyMesh> > ClusteringGrid;
  ClusteringGrid.Init(m.bbox,100000,radius*sqrt(2.0f));
  ClusteringGrid.AddPointSet(m);
  ClusteringGrid.ExtractMesh(cluM);
  int t1=clock();
  tri::io::ExporterPLY<MyMesh>::Save(cluM,"ClusterMesh.ply");
  printf("Sampled %i vertices in %5.2f\n",cluM.VN(), float(t1-t0)/float(CLOCKS_PER_SEC));

  int t2=clock();
  int sampleNum = (cluM.VN()+subM.VN())/2;
  tri::SurfaceSampling<MyMesh,tri::MeshSampler<MyMesh> >::VertexUniform(m, mrs,sampleNum);
  int t3=clock();
  tri::io::ExporterPLY<MyMesh>::Save(rndM,"RandomMesh.ply");
  printf("Sampled %i vertices in %5.2f\n",rndM.VN(), float(t3-t2)/float(CLOCKS_PER_SEC));


  return 0;
}
开发者ID:Quantza,项目名称:opengl-base,代码行数:52,代码来源:trimesh_pointcloud_sampling.cpp

示例7: setMesh

void MyGL::setMesh(MyMesh mesh)
{
	
	petal_mesh = mesh;

	points.clear();


	//点
	for (auto it = mesh.vertices_begin(); it != mesh.vertices_end(); ++it){
		auto point = mesh.point(it.handle());
		coor t = { point.data()[0], point.data()[1], point.data()[2] };

		points.push_back(t);

	}

	//面
	face.clear();

	for (auto it = mesh.faces_begin(); it != mesh.faces_end(); ++it){
		OpenMesh::FaceHandle fh = it.handle();

		coor facet;//当前面索引
		int count = 0;//标记第几个点
		for (auto it1 = mesh.fv_begin(fh); it1 != mesh.fv_end(fh); ++it1){
			auto point = mesh.point(it1.handle());
			t = { point.data()[0], point.data()[1], point.data()[2] };

			//find
			vector<coor>::iterator itv;//记录该点对应Points中的位置
			itv = find_if(points.begin(), points.end(), [](coor const& obj){
				return (fabs(obj.x - t.x) < 0.01) && (fabs(obj.y - t.y) < 0.01) && (fabs(obj.z - t.z) < 0.01);
			});

			if (itv != points.end())//写入面facet
			{
				if (count == 0){
					facet.x = itv - points.begin();
				}
				else if (count == 1){
					facet.y = itv - points.begin();
				}
				else
					facet.z = itv - points.begin();
			}
			else
				break;
			count++;


		}
		face.push_back(facet);

	}

	return;
}
开发者ID:dcsuju13,项目名称:flowermodelling,代码行数:58,代码来源:MyGL.cpp

示例8: mySmooth

void mySmooth(int step)
{
    int t2=clock();
    
  tri::RequirePerVertexNormal(*n);
  tri::UpdateTopology<MyMesh>::VertexFace(*n);
    
    
  tri::Smooth<MyMesh>::VertexCoordLaplacian(*n, step, false, true);
  
  tri::UpdateNormal<MyMesh>::PerVertexPerFace(*n);
    int t3=clock();
    printf("Smooth mesh %i vert - %i face \n",n->VN(),n->FN());
    printf("Smooth time %5.2f\n",float(t3-t2)/CLOCKS_PER_SEC);

}
开发者ID:MarcoLoddo,项目名称:meshlabjs,代码行数:16,代码来源:Smooth.cpp

示例9: Load

bool Load(const char* filename, MyMesh& mesh)
{
  //Create the data descriport for the custom attributes
  nanoply::NanoPlyWrapper<MyMesh>::CustomAttributeDescriptor customAttrib;
  customAttrib.GetMeshAttrib(filename);
  int count = customAttrib.meshAttribCnt["material"];
  mesh.material().resize(count);
  customAttrib.AddVertexAttribDescriptor<int, int, 1>(std::string("materialId"), nanoply::NNP_INT32, NULL);
  customAttrib.AddFaceAttribDescriptor<vcg::Point3f, float, 3>(std::string("barycenter"), nanoply::NNP_LIST_UINT8_FLOAT32, NULL);
  customAttrib.AddMeshAttribDescriptor<Material, float, 3>(std::string("material"), std::string("kd"), nanoply::NNP_FLOAT32, mesh.material()[0].kd.V());
  customAttrib.AddMeshAttribDescriptor<Material, float, 3>(std::string("material"), std::string("ks"), nanoply::NNP_FLOAT32, mesh.material()[0].ks.V());
  customAttrib.AddMeshAttribDescriptor<Material, float, 1>(std::string("material"), std::string("rho"), nanoply::NNP_FLOAT32, &mesh.material()[0].rho);

  //Load the ply file
  unsigned int mask = 0;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTCOORD;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTNORMAL;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTCOLOR;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTRADIUS;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_VERTATTRIB;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACEINDEX;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACENORMAL;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_FACEATTRIB;
  mask |= nanoply::NanoPlyWrapper<MyMesh>::IO_MESHATTRIB;
  return (nanoply::NanoPlyWrapper<MyMesh>::LoadModel(filename, mesh, mask, customAttrib) != 0);
}
开发者ID:baceituno,项目名称:surface-reconstruction,代码行数:26,代码来源:main.cpp

示例10: 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);
}
开发者ID:bobbyblues,项目名称:Ren,代码行数:60,代码来源:trimesh_edge.cpp

示例11: main

int main(int argc, char* argv[])
{
	if (argc < 2){
		return 0;
	}
	float meshPrecision = 0.01;
	MyMesh mesh;
	//mesh.Read(argv[1]);
	//mesh.MergeVertices(meshPrecision);
	//mesh.ClearNonRegularFaces();
	//mesh.GenPerVertexNormal();
	mesh.Read("data\\lh.pial.DK.fusiform_trans.obj");
	//mesh.ReadAsc("data\\lh.pial.asc");
	mesh.MergeVertices(meshPrecision);
	//mesh.RemoveVertex(MyArrayi(1, 40969));
	mesh.GenPerVertexNormal();
	mesh.Write("data\\lh.pial.DK.fusiform_trans_normal.obj");
	//mesh.WriteNOFF("data\\lh.pial.off");
	//mesh.WriteAsc("data\\lh.sphere_v163841.asc");
	//mesh.WriteBIN("data\\lh.pial_v163841.bin");
	//mesh.WriteNOFF("data\\lh_trans_pial_noff.off");
	//mesh.WritePLY("data\\lh.pial.ply");
	//mesh.WriteSMFD("data\\lh.trans.pial.smfd");

	//MyTracks track;
	//track.Read("C:\\Users\\GuohaoZhang\\Desktop\\tmpdata\\dti.trk");
	//track.Save("C:\\Users\\GuohaoZhang\\Desktop\\tmpdata\\dti.data");

	/*
	MyTracks track;
	track.Read("C:\\Users\\GuohaoZhang\\Desktop\\tmpdata\\dti.trk");
	vector<int> idx;
	for (int i = 0; i < track.GetNumTracks(); i++){
		idx.push_back(i);
	}
	vector<int> filter1, filter2;
	float lengthLimit[] = { 20, FLT_MAX };
	track.FilterByIndexSkip(idx, 0.99, filter1);
	cout << filter1.size() << endl;
	track.FilterByTrackLength(filter1, lengthLimit, filter2);
	cout << filter2.size() << endl;
	track.SavePartial("dti_20_099.data", filter2);
	*/
}
开发者ID:edgeofmoon,项目名称:Rendering,代码行数:44,代码来源:converter.cpp

示例12: main

int main( int /*argc*/, char **/*argv*/ )
{
  MyMesh m;
  vcg::tri::Torus(m,30,10);
  vcg::tri::io::ExporterOFF<MyMesh>::Save(m,"torus.off");

  vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
//  vcg::tri::UpdateCurvature<MyMesh>::VertexCurvature(m);
  vcg::tri::UpdateCurvature<MyMesh>::MeanAndGaussian(m);
  vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirections(m);
  //vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirectionsNormalCycles(m);
  vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirectionsPCA(m,m.bbox.Diag()/100);

  vcg::tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
  printf("Input mesh  vn:%i fn:%i\n",m.VN(),m.FN());
  printf( "Mesh has %i vert and %i faces\n", m.VN(), m.FN() );

  return 0;
}
开发者ID:Quantza,项目名称:opengl-base,代码行数:19,代码来源:trimesh_curvature.cpp

示例13: initMesh

void initMesh( obj::ObjObject* pObj){
	vector<obj::POINT>* pts = pObj->getPoints();
	vector<obj::FACEINDEX>* fs = pObj->getFaces();

	MyMesh::VertexHandle* vhandler = new MyMesh::VertexHandle[pts->size()];
	for( size_t i = 0 ; i != pts->size() ; i++ ){
		vhandler[i] = mesh.add_vertex( MyMesh::Point( (*pts)[ i ].x , (*pts)[ i ].y , (*pts)[ i ].z ) );
	}

	vector<MyMesh::VertexHandle> face_handler;
	for( size_t i = 0 ; i != fs->size() ; i++ ){
		face_handler.clear();
		face_handler.push_back( vhandler[(*fs)[i].index[0]] );
		face_handler.push_back( vhandler[(*fs)[i].index[1]] );
		face_handler.push_back( vhandler[(*fs)[i].index[2]] );
		mesh.add_face( face_handler );
	}

	delete [] vhandler;
}
开发者ID:MarkRunWu,项目名称:Digital-Processing,代码行数:20,代码来源:use_openMesh.cpp

示例14: main

/** This function is the main program executed to test that libMesh is
 * properly linked and that my custom fem library MyMesh class is
 * functioning correctly.
 * 
 * The command-line arguments are parsed into the two input variables 
 * of this program:
 * \param argc The command-line argument count
 * \param argv An array of characters that contain the command-line text, 
 * this text is parsed with the initialization of libMesh
 */ 
int main(int argc, char** argv)
{   
    LibMeshInit init (argc, argv);

    MyMesh mesh;
    MeshTools::Generation::build_square(mesh, 3, 3); 
    mesh.find_neighbors();
    
	printf("\n\nBoundary id's generated by libMesh:\n");
    mesh.boundary_info->print_info();
   
	printf("\n\nBoundary id's generated by MyMesh class (+10):\n"); 
    mesh.boundary_info->clear();
    mesh.add_boundary_id(10,"y",0.); // bottom
    mesh.add_boundary_id(11,"x",1.); // right-side
    mesh.add_boundary_id(12,"y",1.); // top
    mesh.add_boundary_id(13,"x",0.); // left
    mesh.boundary_info->print_info();
   
}
开发者ID:aeslaughter,项目名称:postdoc,代码行数:30,代码来源:test_mymesh.cpp

示例15: centerDisplayCallback

void VRMeshEditor::centerDisplayCallback(Misc::CallbackData* cbData)
{
    /* Calculate bounding box of current mesh: */
    Vrui::Point bbMin,bbMax;
    MyVIt vIt=mesh->beginVertices();
    for(int i=0; i<3; ++i)
        bbMin[i]=bbMax[i]=(*vIt)[i];
    for(++vIt; vIt!=mesh->endVertices(); ++vIt)
    {
        for(int i=0; i<3; ++i)
        {
            if(bbMin[i]>(*vIt)[i])
                bbMin[i]=(*vIt)[i];
            else if(bbMax[i]<(*vIt)[i])
                bbMax[i]=(*vIt)[i];
        }
    }
    Vrui::Point modelCenter=Geometry::mid(bbMin,bbMax);
    Vrui::Scalar modelSize=Geometry::dist(modelCenter,bbMax);

    /* Calculate navigation transformation: */
    Vrui::NavTransform t=Vrui::NavTransform::translateFromOriginTo(Vrui::getDisplayCenter());
    t*=Vrui::NavTransform::scale(Vrui::Scalar(0.5)*Vrui::getDisplaySize()/modelSize);
    t*=Vrui::NavTransform::translateToOriginFrom(modelCenter);
    Vrui::setNavigationTransformation(t);
}
开发者ID:VisualIdeation,项目名称:Vrui,代码行数:26,代码来源:VRMeshEditor.cpp


注:本文中的MyMesh类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。