您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 国内外标准规范 > Open-Mesh简介
OpenMeshReferenceOpenMeshReferenceOpen Mesh ReferenceOpen Mesh ReferenceOpenMeshOpenMesh•ACG–RWTHAachenACG RWTH Aachen•C++ library lhlfdd•Implements half‐edge data structure•Integrated basic geometric operations•3‐D model file reader/writerOpenMeshOpenMesh•FlexibleFlexible–Random access to vertices, edges, and faces–Arbitrary scalar typesyyp–Arrays or lists as underlying kernels•EfficientinspaceandtimeEfficient in space and time–Dynamic memory management for array‐based meshes–Extendable to specialized kernels for non‐manifold meshesExercise1Exercise 1•ValenceViewerValence ViewerExercise1Exercise 1•MicrosoftVisualStudio2008Microsoft Visual Studio 2008Slifilhj•Solution file has two projects:–OpenMeshlibrary•compile it once•never need to editGLUTbdhi–GLUT based mesh viewer•extend with your code Exercise1Exercise 1•ClassesClassesGlutViewerGLUTwindow,popupmenuGlutExaminerGlutViewerGLUT window, popup menuTrackball, basic rendering of teapotMeshViewerLoading and rendering meshCustom processing and rendering modeValenceViewerExercise1Exercise 1•ComputevalencesinacustommeshpropertyCompute valences in a custom mesh propertyClfld•Compute colors out of valences and store them in the predefined propertyExercise1Exercise 1•SendzipofyoursourcefilesprojectfilesandSend zip of your source files, project files and solution files•Describeyoursolutioninreadmetxt•Describe your solution in readme.txt.•Don’t send binaries and other intermediary filfiles•Can use the clearSolution.bat–! deletes recursively all debug and release directories and intermediary solution filesOpenMeshOpenMesh•GeometricOperationsGeometric OperationsOpenMesh::Vec3fxyncrossproductXY;OpenMesh::Vec3f x,y,n,crossproductXY;...l = (x‐y).length();n = x.normalize();l(|)scalarProductXY= (x | y);crossProductXY= x % y;...OpenMeshOpenMesh•MeshdefinitionMesh definition#include OpenMesh/Core/IO/MeshIO.hh#include OpenMesh/Core/Mesh/Types/TriMesh_ArrayKernelT.hhtypedefOpenmesh::TriMesh_ArrayKernelT Mesh;hmesh type:–triangle mesh–array kerneldefaulttraitsnamespace–default traitsname spaceOpenMeshOpenMesh•Loading/WritingaMeshLoading/Writing a MeshMesh * myMesh;OpenMesh::IO::Options readOptions;OpenMesh::IO::read_mesh(*myMesh,”/path/to/bunny.off”,readOptions)reader/writer settings:enablevertexnormals/colors/texturecoordinates?–enable vertex normals/colors / texture coordinates?–enable face normals/colors?OpenMesh•AddingAttributesOpenMeshAdding AttributesMesh * myMesh;OMhIOOtidOtiOpenMesh::IO::Options readOptions;OpenMesh::IO::read_mesh(*myMesh, ”/path/to/bunny.off”, readOptions)if(!readOptionscheck(OpenMesh::IO::Options::FaceNormal))if(!readOptions.check(OpenMesh::IO::Options::FaceNormal)){myMesh‐update_face_normals();}}if(! readOptions.check(OpenMesh::IO::Options::VertexNormal)){myMesh‐update_vertex_normals();}OpenMeshOpenMesh•IteratingoververticesIterating over verticestypedefOpenmesh::TriMesh_ArrayKernelT Mesh;Mh*MhMesh * myMesh;Mesh::VertexItervIt,vBegin,vEnd;vBegin= myMesh‐vertices_begin();vEnd= myMesh‐vertices_end();for( vIt= vBegin; vIt!= vEnd; ++vIt){doSomethingWithVertex(vIt.handle());g(())}OpenMeshOpenMesh•IteratingoverfacesIterating over facesMesh::VertexIter→ Mesh::FaceItervertices_begin() → faces_begin()verticesend()→facesend()vertices_end() → faces_end()OpenMeshOpenMesh•CirculatingoverfacesaroundavertexMesh::VertexItervIt,vBegin,vEnd;Circulating over faces around a vertexvBegin= myMesh‐vertices_begin();vEnd= myMesh‐vertices_end();for( vIt= vBegin; vIt!= vEnd; ++vIt){Mesh::VertexFaceItervfIt,vfBegin;vfBegin=myMesh‐vfiter(vIt);vfBegin myMeshvf_iter(vIt);for( vfIt= vfBegin; vfIt; ++vfIt){dSthiWithF(fIthdl())doSomethingWithFace(vfIt.handle());}}OpenMeshOpenMesh•Verticesperimeterareaofatrianglevoid analyzeTriangle(OpenMesh::FaceHandle& _fh){Vertices, perimeter, area of a triangle{OpenMesh::Vec3f pointA,pointB,pointC;Mesh::ConstFaceVertexItercfvIt;cfvIt= myMesh‐cfv_iter(_fh);pointA= myMesh‐point(cfvIt.handle());pointB= myMesh‐point((++cfvIt).handle());pointC=myMesh‐point((++cfvIt).handle());pointC myMeshpoint((cfvIt).handle());perimeter(pointA,pointB,pointC);area(pointA,pointB,pointC)}}OpenMeshOpenMeshOpenMesh::VertexHandleendVH; OpenMesh::HalfEdgeHandlestartHEHtwinHEHnextHEH;•Neighbor Access in O(1)OpenMesh::HalfEdgeHandle, startHEH,twinHEH,nextHEH;startHEH= hehIt.handle();twinHEH = myMesh‐opposite_halfedge_handle(startHEH);nextHEH= myMesh‐next_halfedge_handle(twinHEH);endVH= myMesh‐to_vertex_handle(nextHEH);startendVH twinnextstart twinOpenMeshOpenMeshfor( vIt= vBegin; vIt!= vEnd; ++vIt){•Modifying the geometry{scale(vIt.handle(),2.0);}void scale(OpenMesh::VertexHandle& _vh,double _alpha){OpenMesh::Vec3fnewCoordinate;OpenMesh::Vec3f newCoordinate;newCoordinate= myMesh‐point(_vh);myMesh‐set_point(_vh,newCoordinate* _alpha);}}OpenMeshOpenMeshmyMesh‐request_vertex_status();myMeshrequestedgestatus();•Modifying the topologymyMesh‐request_edge_status();myMesh‐request_face_status();OpenMesh::HalfedgeHandlecurrentHEH=heIt.handle();OpenMesh::Ha
本文标题:Open-Mesh简介
链接地址:https://www.777doc.com/doc-4633674 .html