/[libvob]/libvob/include/vob/Primitives.hxx
ViewVC logotype

Diff of /libvob/include/vob/Primitives.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by humppake, Mon Mar 17 10:07:36 2003 UTC revision 1.16 by tjl, Sun Mar 23 20:15:58 2003 UTC
# Line 33  Primitives.hxx Line 33  Primitives.hxx
33  #include <boost/type_traits.hpp>  #include <boost/type_traits.hpp>
34    
35  namespace Vob {  namespace Vob {
36    
37    /** Primitive transformations and templates to allow their use hierarchically.
38     * All classes whose name ends in PrimitiveTransform are empty tag classes
39     * which allow primitive transformations to declare that they provide
40     * certain features.
41     */
42  namespace Primitives {  namespace Primitives {
43    
44      /** A primitive transform, an interface  
45        /** A primitive transform, implying an interface
46       * used by the templates for building up       * used by the templates for building up
47       * transforms.       * transforms.
48       */       * Deriving from this class implies the following method:
49      class PrimitiveTransform {       * <pre>
50      public:          void tr(const ZPt &from, ZPt &to) const
         /*  
51          typedef InverseType ???;          typedef InverseType ???;
52          void inverse(InverseType &into) {          void inverse(InverseType &into) ;
53          }        </pre>
         */  
   
         void tr(const ZPt &from, ZPt &to) const { }  
   
         static const int X = 1;  
         static const int Y = 2;  
         static const int Z = 3;  
   
         /** Calculate the derivatives of this transformation.  
          * The default implementation uses a slow and inaccurate  
          * finite difference calculation.  
          */  
         void tr_d(const ZPt &at, ZPt *to_3, int which) const {  
             const float eps = .01;  
             ZPt tmp1, tmp2;  
             tr(at, tmp1);  
             if(which & X) {  
                 ZPt at2(at.x + eps, at.y, at.z);  
                 tr(at2, tmp2);  
                 to_3[0] = (tmp2-tmp1)/eps;  
             }  
             if(which & Y) {  
                 ZPt at2(at.x, at.y + eps, at.z);  
                 tr(at2, tmp2);  
                 to_3[1] = (tmp2-tmp1)/eps;  
             }  
             if(which & Z) {  
                 ZPt at2(at.x, at.y, at.z + eps);  
                 tr(at2, tmp2);  
                 to_3[2] = (tmp2-tmp1)/eps;  
             }  
         }  
     };  
   
     /** A tag interface, implying for a primitive  
      * transform that there is shouldBeDrawn() method.  
54       */       */
55      class DisablablePrimitiveTransform {      class PrimitiveTransform {
     public:  
       bool shouldBeDrawn() const { return true; }  
56      };      };
57    
58      /** A tag interface, implying for a primitive      /** A tag interface, implying that the primitive transform
59       * transform that there are parameters.       * may switch off rendering of the vobs in it.
60         * This interface implies for a primitive
61         * transform that there is shouldBeDrawn() method:
62         * <pre>
63            bool shouldBeDrawn() const;
64          </pre>
65         */
66        class DisablablePrimitiveTransform { };
67    
68        /** A tag interface, implying that the transform requires
69         * floating-point parameters.
70         * Implies the following interface in the inheriting class:
71         * <pre>
72            enum { NParams = ??? };
73            template<class Ptr> void setParams(Ptr p)
74            </pre>
75            Note that combining this with DependentPrimitiveTransform
76            adds more arguments to the setParams() call.
77       */       */
78      class ParametrizedPrimitiveTransform {      class ParametrizedPrimitiveTransform { };
   
         /** The number of floating-point parameters.  
         enum { NParams = 0  
         };  
         template<class Ptr> void setParams(Ptr p) ;  
          */  
     };  
79    
80    
81      /** A tag interface, for a transform which      /** A tag interface, for a transform which
82       * depends on the parent transform(s)       * depends on some transform(s).
83       */       * This class unfortunately shows some abstraction through,
84      class DependentPrimitiveTransform {       * because sometimes you want the transformation to depend
85          /*       * on the real parent (UnitSqBox, Nadir), and sometimes not (cull).
86          typedef ??? BaseTransform;       * Thus, this class will know about the "first parent".
87         * Implies the following interface:
88          template<class Ptr2>       * <pre>
89              void setParams(Transform *others, Ptr2 paramsOut) ;          enum { NDepends = ??? }; // Number of parent coordsyses
90          */          template<class SPtr> void setParams(SPtr depends) ;
91      };          </pre>
92            Note that combining this with ParametrizedPrimitiveTransform
93      class GLPerformablePrimitiveTransform {          adds more arguments to the setParams() call.
94      public:       */
95        class DependentPrimitiveTransform { };
96    
97        /** A tag interface for transformations which can be performed
98         * by manipulating the OpenGL fixed-function vertex pipeline.
99         * For instance rotations and transformations can be performed faster by
100         * just letting OpenGL combine the transformations into a matrix.
101         * Implies the following method:
102           <pre>
103          void performGL() { }          void performGL() { }
104      };         </pre>
105         *
106         */
107        class GLPerformablePrimitiveTransform { };
108    
109        /** A tag interface for transformations which may <em>sometimes</em>
110         * be performed using OpenGL but sometimes not.
111         * Implies the following methods:
112          <pre>
113            bool canPerformGL() ;
114            bool performGL() ;
115          </pre>
116          with the same semantics as in {@link Vob::Transform}.
117         *
118         * @link Vob::Transform
119         */
120      class PotentiallyGLPerformablePrimitiveTransform {      class PotentiallyGLPerformablePrimitiveTransform {
121      public:      public:
         bool canPerformGL() { return false; }  
         bool performGL() { return false; }  
122      };      };
123    
124      class NonlinearPrimitiveTransform {      /** A tag interface for transformations which may be nonlinear.
125      public:       * Implies
126          float nonlinearity(ZPt p, float radius) { return 0; }       * <pre>
127      };          float nonlinearity(ZPt p, float radius) ;
128            </pre>
129         */
130        class NonlinearPrimitiveTransform { };
131    
132      /** A tag for a primitive transform that sets a box size.      /** A tag for a primitive transform that sets a box size.
133       */       * Implies
134      class BoxPrimitiveTransform {       * <pre>
     public:  
135          Pt getSqSize() { return Pt(1,1); }          Pt getSqSize() { return Pt(1,1); }
136      };          </pre>
137         */
138        class BoxPrimitiveTransform { };
139    
140    
141    
# Line 235  namespace Primitives { Line 237  namespace Primitives {
237      /** A type of transform which exposes a vector of      /** A type of transform which exposes a vector of
238       * float parameters and parent transformations.       * float parameters and parent transformations.
239       */       */
240      struct HierarchicalTransform : public Transform {      class HierarchicalTransform : public Transform {
241        public:
242          virtual int getNParams() = 0;          virtual int getNParams() = 0;
243          virtual int getNDepends() = 0;          virtual int getNDepends() = 0;
244          virtual void setParams(const Transform **depends, float *p) = 0;          virtual void setParams(const Transform **depends, float *p) = 0;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26