[ Changes in definition of TriMesh: PART I ]

Note for the developers: the change to make to existing projects is very little 
but strictly necessary to compile. This change IS NOT backward compliant.


==== OLD ==== way to define a TriMesh:

// forward declarations
class MyVertex;
class MyEdge;
class MyFace;

class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};


==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;

// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
                                          vcg::Use<MyFace>::AsFaceType>{};

class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};

                                 
===== classes introduced          
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So 

<MyVertex, MyEdge, MyFace  becomes <MyUsedTypes<

and 

VertexSimp2 becomes Vertex

[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type

Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:

class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
                                         vcg::Use<MyEdge>::AsEdgeType,
                                         vcg::Use<MyFace>::AsFaceType>{};

is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
                                         vcg::Use<MyEdge>::AsEdgeType,
                                         vcg::Use<MyVertex>::AsVertexType>{};

Note 3: you only need to specify the type  you use. If you do not have edges you do not need 
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
This commit is contained in:
ganovelli 2010-03-15 10:43:27 +00:00
parent c40a6c3d97
commit 01bb1ff921
1 changed files with 36 additions and 36 deletions

View File

@ -28,97 +28,97 @@ namespace vcg{
/*------------------------------------------------------------------*/
// Metaprogramming Core
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, class BFT,class BTT,
template <
class Base,
template <typename> class A>
class Arity1: public A<Base<BVT,BET,BFT,BTT> > {
class Arity1: public A<Base > {
};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT, class BTT,
template <
class Base,
template <typename> class A, template <typename> class B>
class Arity2: public B<Arity1<Base,BVT,BET,BFT,BTT, A> > {};
class Arity2: public B<Arity1<Base, A> > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C >
class Arity3: public C<Arity2<Base,BVT,BET,BFT,BTT, A, B> > {};
class Arity3: public C<Arity2<Base, A, B> > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D>
class Arity4: public D<Arity3<Base,BVT,BET,BFT,BTT, A, B, C> > {};
class Arity4: public D<Arity3<Base, A, B, C> > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D,
template <typename> class E >
class Arity5: public E<Arity4<Base,BVT,BET,BFT,BTT, A, B, C, D> > {};
class Arity5: public E<Arity4<Base, A, B, C, D> > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D,
template <typename> class E, template <typename> class F >
class Arity6: public F<Arity5<Base,BVT,BET,BFT,BTT, A, B, C, D, E> > {};
class Arity6: public F<Arity5<Base, A, B, C, D, E> > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D,
template <typename> class E, template <typename> class F,
template <typename> class G>
class Arity7: public G<Arity6<Base,BVT,BET,BFT,BTT, A, B, C, D, E, F> > {};
class Arity7: public G<Arity6<Base, A, B, C, D, E, F> > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D,
template <typename> class E, template <typename> class F,
template <typename> class G, template <typename> class H>
class Arity8: public H<Arity7<Base,BVT,BET,BFT,BTT, A, B, C, D, E, F, G > > {};
class Arity8: public H<Arity7<Base, A, B, C, D, E, F, G > > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D,
template <typename> class E, template <typename> class F,
template <typename> class G, template <typename> class H,
template <typename> class I>
class Arity9: public I<Arity8<Base,BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H > > {};
class Arity9: public I<Arity8<Base, A, B, C, D, E, F, G, H > > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D,
template <typename> class E, template <typename> class F,
template <typename> class G, template <typename> class H,
template <typename> class I, template <typename> class J>
class Arity10: public J<Arity9<Base,BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H, I > > {};
class Arity10: public J<Arity9<Base, A, B, C, D, E, F, G, H, I > > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D,
template <typename> class E, template <typename> class F,
template <typename> class G, template <typename> class H,
template <typename> class I, template <typename> class J,
template <typename> class K>
class Arity11: public K<Arity10<Base,BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H, I, J> > {};
class Arity11: public K<Arity10<Base, A, B, C, D, E, F, G, H, I, J> > {};
template <template <typename,typename,typename,typename>
class Base,class BVT, class BET, typename BFT,class BTT,
template <
class Base,
template <typename> class A, template <typename> class B,
template <typename> class C, template <typename> class D,
template <typename> class E, template <typename> class F,
template <typename> class G, template <typename> class H,
template <typename> class I, template <typename> class J,
template <typename> class K, template <typename> class L>
class Arity12: public L<Arity11<Base,BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H, I, J, K> > {};
class Arity12: public L<Arity11<Base, A, B, C, D, E, F, G, H, I, J, K> > {};
template < typename T=int>
class DefaultDeriver : public T {};