diff --git a/vcg/space/box2.h b/vcg/space/box2.h index b8f54e34..6c42e82a 100644 --- a/vcg/space/box2.h +++ b/vcg/space/box2.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.1 2004/02/15 23:34:04 cignoni +Initial commit + ****************************************************************************/ @@ -35,23 +38,24 @@ $Log: not supported by cvs2svn $ #include namespace vcg { +/** \addtogroup space */ +/*@{*/ -template -/** @name Box2 - Class Box2. - This is the class for definition of a bounding box in 2D space. - @param T (Templete Parameter) Specifies the scalar field. +/** + Templated class for a 2D bounding box. It is stored just as two Point2 + @param BoxScalarType (Template Parameter) Specifies the scalar field. */ +template class Box2 { public: /// The scalar type - typedef T scalar_type; + typedef BoxScalarType ScalarType; /// min coordinate point - Point2 min; + Point2 min; /// max coordinate point - Point2 max; + Point2 max; /// Standard constructor inline Box2() { min.x()= 1; max.x()= -1; min.y()= 1; max.y()= -1; } /// Copy constructor @@ -63,28 +67,13 @@ public: { return min==p.min && max==p.max; } - /** Varia le dimensioni del bounding box scalandole rispetto al parametro scalare. - @param s Valore scalare che indica di quanto deve variare il bounding box - */ - void Inflate( const T s ) - { - Inflate( (max-min)*s ); - } - /** Varia le dimensioni del bounding box del valore fornito attraverso il parametro. - @param delta Point in 2D space - */ - void Inflate( const Point2 & delta ) - { - min -= delta; - max += delta; - } - /// Initializing the bounding box with a point - void Set( const Point2 & p ) + /// Initializing the bounding box with a point + void Set( const Point2 & p ) { min = max = p; } // Initializing with the values - inline void Set( T minx, T miny, T maxx, T maxy ) + inline void Set( BoxScalarType minx, BoxScalarType miny, BoxScalarType maxx, BoxScalarType maxy ) { min[0] = minx; min[1] = miny; @@ -119,7 +108,7 @@ public: cade fuori da esso. @param p The point 2D */ - void Add( const Point2 & p ) + void Add( const Point2 & p ) { if(IsNull()) Set(p); else @@ -148,7 +137,7 @@ public: /** Trasla il bounding box di un valore definito dal parametro. @param p Il bounding box trasla sulla x e sulla y in base alle coordinate del parametro */ - void Translate( const Point2 & p ) + void Translate( const Point2 & p ) { min += p; max += p; @@ -157,7 +146,7 @@ public: @param p The point 2D @return True se p appartiene al bounding box, false altrimenti */ - bool IsIn( Point2 const & p ) const + bool IsIn( Point2 const & p ) const { return ( min.v[0] <= p.v[0] && p.v[0] <= max.v[0] && @@ -168,7 +157,7 @@ public: @param p The point 2D @return True se p appartiene al bounding box, false altrimenti */ - bool IsInEx( Point2 const & p ) const + bool IsInEx( Point2 const & p ) const { return ( min.v[0] <= p.v[0] && p.v[0] < max.v[0] && @@ -199,26 +188,26 @@ public: */ inline bool IsEmpty() const { return min==max; } /// Restituisce la lunghezza della diagonale del bounding box. - T Diag() const + BoxScalarType Diag() const { return Distance(min,max); } /// Calcola il centro del bounding box. - Point2 Center() const + Point2 Center() const { return (min+max)/2; } /// Calcola l'area del Bounding box. - inline T Area() const + inline BoxScalarType Area() const { return (max.v[0]-min.v[0])*(max.v[1]-min.v[1]); } /// Calcola la dimensione del bounding box sulla x. - inline T DimX() const { return max.v[0]-min.v[0]; } + inline BoxScalarType DimX() const { return max.v[0]-min.v[0]; } /// Calcola la dimensione del bounding box sulla y. - inline T DimY() const { return max.v[1]-min.v[1]; } + inline BoxScalarType DimY() const { return max.v[1]-min.v[1]; } - inline void Normalize( Point2 & p ) + inline void Normalize( Point2 & p ) { p -= min; p[0] /= max[0]-min[0]; @@ -227,17 +216,6 @@ public: }; // end class definition -#ifdef __GL_H__ - /// Funzione di utilita' per la visualizzazione in OpenGL (short) -inline void glBox( Box2 const & b ) { glRectsv(b.min.v,b.max.v); } - /// Funzione di utilita' per la visualizzazione in OpenGL (int) -inline void glBox( Box2 const & b ) { glRectiv(b.min.v,b.max.v); } - /// Funzione di utilita' per la visualizzazione in OpenGL (float) -inline void glBox( Box2 const & b ) { glRectfv(b.min.v,b.max.v); } - /// Funzione di utilita' per la visualizzazione in OpenGL (double) -inline void glBox( Box2 const & b ) { glRectdv(b.min.v,b.max.v); } -#endif - /// Specificazione di box of short typedef Box2 Box2s; /// Specificazione di box of int @@ -247,6 +225,7 @@ typedef Box2 Box2f; /// Specificazione di box of double typedef Box2 Box2d; +/*@}*/ } // end namespace diff --git a/vcg/space/color4.h b/vcg/space/color4.h index 721ef412..25579465 100644 --- a/vcg/space/color4.h +++ b/vcg/space/color4.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.2 2004/03/10 00:35:01 cignoni +Removed a wrong (?) copy constructor + Revision 1.1 2004/02/10 01:11:28 cignoni Edited Comments and GPL license @@ -35,6 +38,14 @@ Edited Comments and GPL license #include namespace vcg { + +/** \addtogroup space */ +/*@{*/ + /** + The templated class for representing 4 entity color. + The class is templated over the ScalarType. class that is used to represent color with float or with unsigned chars. All the usual + operator overloading (* + - ...) is present. + */ template class Color4 : public Point4 { @@ -134,12 +145,12 @@ inline void SetGrayShade(float f) } -// Given an integer returns a well ordering of colors +/** Given an integer returns a well ordering of colors // so that every color differs as much as possible form the previous one // params: // n is the maximum expected value (max of the range) // v is the requested position - +*/ inline static Color4 Scatter(int n, int a,float Sat=.3f,float Val=.9f) { int b, k, m=n; @@ -246,6 +257,9 @@ inline Color4::Color4(Color4::ColorConstant cc) typedef Color4 Color4b; typedef Color4 Color4f; +/*@}*/ + + } // end of NameSpace #endif diff --git a/vcg/space/point4.h b/vcg/space/point4.h index 0154c3c7..105b1f06 100644 --- a/vcg/space/point4.h +++ b/vcg/space/point4.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.2 2004/03/10 00:35:24 cignoni +added a math namespace reference + Revision 1.1 2004/02/10 01:11:28 cignoni Edited Comments and GPL license @@ -36,8 +39,13 @@ Edited Comments and GPL license namespace vcg { - - +/** \addtogroup space */ +/*@{*/ + /** + The templated class for representing a point in 4D space. + The class is templated over the ScalarType class that is used to represent coordinates. All the usual + operator overloading (* + - ...) is present. This class is also the base for vcg::Color4 + */ template class Point4 { protected: @@ -286,6 +294,7 @@ typedef Point4 Point4i; typedef Point4 Point4f; typedef Point4 Point4d; +/*@}*/ } // end namespace #endif diff --git a/vcg/space/tcoord2.h b/vcg/space/tcoord2.h index 2ee13648..cfe2a2c8 100644 --- a/vcg/space/tcoord2.h +++ b/vcg/space/tcoord2.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.1 2004/02/13 00:44:53 cignoni +First commit... + ****************************************************************************/ @@ -33,9 +36,16 @@ $Log: not supported by cvs2svn $ #include namespace vcg { +/** \addtogroup space */ +/*@{*/ +/** + Templated class for a set of 2D texture coord. It for each is templated over two parameters: + the type of the tex coord and the number of texcoord to be stored. This class is intended to be used when many textures + id are shared over the same surface, so for each coord the id of the texture is stored. If no id is needed see the vcg::TCoord2Simple class. +*/ -template +template class TCoord2 { private: @@ -73,9 +83,11 @@ public: enum { n_coords=N}; }; - +/** + Templated class for a set of 2D texture coord. It for each is templated over two +*/ template -class TCoordSimple +class TCoord2Simple { private: Point2 _t; @@ -118,15 +130,7 @@ public: }; -#ifdef __GL_H__ - - -//inline void glTexCoord(TCoord2 const & p) { glTexCoord3iv(p.v);} -//inline void glTexCoord(Point3 const & p) { glTexCoord3sv(p.v);} -//inline void glTexCoord(Point3 const & p) { glTexCoord3fv(p.v);} -//inline void glTexCoord(Point3 const & p){ glTexCoord3dv(p.v);} - -#endif +/*@}*/ }