<转载>openmesh文档的非专业翻译by kidux(学习generative programming非常好的库)


openmesh文档的非专业翻译

版主: type_error, 水经石

openmesh文档的非专业翻译

帖子由 kidux » 周二 9月 19, 2006 16:04

算是一个笔记,由于对c++是初学,术语错误在所难免,见笑~。 
问题在于如何将c++翻译成c的某种polygon实现。openmesh大量使用模板,使用c++中熟悉的iterator和cg中熟悉的circulator,叠代器/循环器,作用是能够存取(access)mesh的下属项比如点/边/面,和查询点或者面的所有一圈的临近附属项。circulator倒是可以通过#define的方式在c中完成部分工作,不过c++可以数据跟操作分离,c也没有学多久也是个半生手~
最后由 kidux 编辑于 周二 9月 19, 2006 16:07,总共编辑了 1 次
头像
kidux
Site Admin
 
帖子: 1205
注册: 周一 12月 12, 2005 12:28
地址: 四川 宜宾

帖子由 kidux » 周二 9月 19, 2006 16:05

使用须知 

注意,openmesh广泛的应用了c++ 模版技术,通用编程技巧和所有事务(参考 关于c++模版的一些文字)。因此仔细的阅读这个章节(特别是你迷失在参考手册中的时候) 

openmesh的类是独一无二的 
库提供了一堆类(99%是模板),这些继承关系是通过模板的参数化来完成的。你会问,“TMD到底是撒?” .意思是,父类会通过模板申明给其他类。 

代码: 全选
class P1 { }
class P2 { }
template <typename Parent> class B : public Parent {}

typedef B<P1> fooB1;
typedef B<P2> fooB2;


乌拉!这样就创建了两个不同类型的b,与界面有关,公共成员由p1跟p2提供,foob1和foob2可以有不同行为或者不同界面接口!但是如果p1和p2有相同的界面,那么从编程的角度来看,foob1/2的使用是没有区别的。这就是全部。openmesh为kernel 定义了接口的概念,文章在openmesh::concepts::kernelT.只有kernel提供了控制多边形网格的类 openmesh::polymeshT,可以使用 kernel 。

因此,文档提供给两方面
1,作为结构/类的辅助
2,在概念类中,用到了什么类型的类,请参考:
OpenMesh::Concepts::KernelT, OpenMesh::PolyMeshT, OpenMesh::TriMeshT

Some words on the C++ implementation
If one takes a look at the goals and features section it soon becomes obvious that these goals cannot be achieved using trivial C++ features only. We make heavy use of templates, (partial) template specialization, generative and generic programming, and the STL. This may be a challenge for you as well as for your compiler, as these are quite late features of the C++ language.
While knowledge of generative programming is only necessary if you want to create your own mesh kernels or extend iterators or similar types, you will NOT need it for simply using these things. Nevertheless working knowledge of C++ and basic knowlege of templates is required. To get into this stuff we recommend the following books:

Bjarne Stroustrup, The C++ Programming Language , 
Matthew H. Austern, Generic Programming and the STL: Using and Extending the C++ Standard Template Library , 
Andrei Alexandrescu, Modern C++ Design: Generic Programming and Design Patterns Applied , 
Krzysztof Czarnecki, Ulrich Eisenecker, Generative Programming: Methods, Tools, and Applications . 

特征和目标
主要的在数据结构下的特征:
不特别的为三角mesh设计,可以处理任何多边形mesh
显含的表示点,半边,边和面
有效的查询顶点的周边邻接one-ring
可以很好的处理非流型点(比如两面相交于一点的情况)

c++实现的目标
可扩展性
选择适合的类型给缩放和坐标系(比如,浮点,双浮点,精确数值和 2/3维或者n维矢量点)
增强了所有项类型都可以你自己添加 属性/附属物,比如,加上法向量,或者一个面控制器给vertex类
效率
避免过度的虚拟继承和虚函数调用
解决很多类型/属性的从属,可以在编译时/运行时替换。
控制器的类型安全,没有类型投射的问题(*),Vertices, (Half-)Edges, Faces知道响应各自的控制器。

(*) Since version 0.10.0 the Microsoft VisualC++ compiler is supported. Due to the compilers inaptitude to process forwards on template functions correctly, the type-safety had to be given up to some extend. Though under the hood void pointers are used, the casting is done within the mesh, and the user transparently uses his handles as before.
As soon as the compiler adheres to the C++ standard the type-safe version will be restored. 


半边数据结构

打造你自己的mymesh

概念类的继承
因为openmesh的类是独特的,完全使用c++的模板,我们将给一幅OpenMesh::TriMesh_ArrayKernelT 的继承图可以作为所有mesh类型的代理。

记住,大多数继承关系可以通过模板的参数化来实现,因此大多数继承链没有表示在这个参考的图中。这个图显示了几乎所有的概念。

1,basekernel定义了对属性的基本操作比如 添加,移除,查询
2,然后attribkernelt添加了所有附属方法的标准属性
3,最后arraykernelt给予添加,删除,查询mesh附属物如vertices, (half-)edges, and faces。这个基本的类通过模板参数传递,就算所依附的存储类型attribkernel会改变。
1,polymesht继承了kernel提供了所有可能的方法来为多边形网格工作。
2,最后,我们驱动trimwsht自polymesht来指定一个特殊的三角网格。

简单的看看,这个复杂的例子,
代码: 全选
template <class Traits>
struct TriMesh_ArrayKernel_GeneratorT
{
  typedef FinalMeshItemsT<ArrayItems, Traits, true>  MeshItems;
  typedef AttribKernelT<MeshItems>                   AttribKernel;
  typedef ArrayKernelT<AttribKernel, MeshItems>      MeshKernel;
  typedef TriMeshT<MeshKernel>                       Mesh;
};


生成真实的mesh类型,用到了辅助的模板类 TriMesh_ArrayKernel_GeneratorT。将traits(压榨机)从一个模板声明中取出,然后传给FinalMeshItemsT来得到最终的mesh附属物类型MeshItems。meshitem定义了点,法线,颜色,贴图坐标,向量,和所有的mesh item。通过meshitem创建了attribkernel类型,定义了一个标准的属性域,最后用attribkernel和meshitems创建了 mesh kernel类型meshkernel。这是一种获得kernel的办法。由于创建kernel是通过概念kernel (Mesh Kernels),我们可以非常容易的创建mesh,在这个例子中,我们用trimesht来创建最终的mesh类型mesh。
头像
kidux
Site Admin
 
帖子: 1205
注册: 周一 12月 12, 2005 12:28
地址: 四川 宜宾

帖子由 kidux » 周二 1月 23, 2007 5:52

OpenMesh provides the following features: 
Representation of arbitrary polygonal (the general case) and pure triangle meshes (providing more efficient, specialized algorithms). 
Explicit representation of vertices, halfedges, edges and faces. 
Fast neighborhood access, especially the one-ring neighborhood (see below). 
Highly customizable : 
Choose your coordinate type (dimension and scalar type) 
Choose the type of containers the mesh items are stored in. 
Attach user-defined elements/functions to the mesh elements. 
Attach and check for attributes. 
Attach data at runtime using dynamic properties. 

In addition we provide some sample applications that demonstrate the usage of OpenMesh
Mesh Smoothing. 
Mesh Decimation. 
Qt integration. 
OpenSG integration. 
OpenInventor integration.
头像
kidux
Site Admin
 
帖子: 1205
注册: 周一 12月 12, 2005 12:28
地址: 四川 宜宾

帖子由 kidux » 周二 1月 23, 2007 6:05

Openmesh提供了以下一些特性: 
可以表示任意的多边形(普通意义上的),和纯三角面片(提供更有效的和特别的算法) 
显含的表示点 边 半边 面 
快速的邻接存取,特别是点环邻接查询 
高度的扩展性 
选择自己的坐标系统类型(维数和尺度) 
选择存储面片元素的容器的类型 
对属性的检查和附加 
将用户定义的元素/函数附加到面片 
在运行时添加动态的属性 

附加高级功能 
对qt的支持 
对opensg的支持 
光滑 细分 减面 
openinventor支持
头像
kidux
Site Admin
 
帖子: 1205
注册: 周一 12月 12, 2005 12:28
地址: 四川 宜宾

回到 BlenderCN Coding&CG

  

在线用户

正在浏览此版面的用户:Google [Bot] 和 0 位游客

原文地址:https://www.cnblogs.com/rocketfan/p/1577231.html