Written some documentation and added to the space module
This commit is contained in:
parent
b84e4c7460
commit
c735627fae
|
@ -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 <vcg/space/point3>
|
||||
namespace vcg {
|
||||
|
||||
/** \addtogroup space */
|
||||
/*@{*/
|
||||
|
||||
template <class T>
|
||||
/** @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 BoxScalarType>
|
||||
class Box2
|
||||
{
|
||||
public:
|
||||
/// The scalar type
|
||||
typedef T scalar_type;
|
||||
typedef BoxScalarType ScalarType;
|
||||
|
||||
/// min coordinate point
|
||||
Point2<T> min;
|
||||
Point2<BoxScalarType> min;
|
||||
/// max coordinate point
|
||||
Point2<T> max;
|
||||
Point2<BoxScalarType> 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<T> & delta )
|
||||
{
|
||||
min -= delta;
|
||||
max += delta;
|
||||
}
|
||||
/// Initializing the bounding box with a point
|
||||
void Set( const Point2<T> & p )
|
||||
/// Initializing the bounding box with a point
|
||||
void Set( const Point2<BoxScalarType> & 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<T> & p )
|
||||
void Add( const Point2<BoxScalarType> & 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<T> & p )
|
||||
void Translate( const Point2<BoxScalarType> & 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<T> const & p ) const
|
||||
bool IsIn( Point2<BoxScalarType> 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<T> const & p ) const
|
||||
bool IsInEx( Point2<BoxScalarType> 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<T> Center() const
|
||||
Point2<BoxScalarType> 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<T> & p )
|
||||
inline void Normalize( Point2<BoxScalarType> & 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<short > const & b ) { glRectsv(b.min.v,b.max.v); }
|
||||
/// Funzione di utilita' per la visualizzazione in OpenGL (int)
|
||||
inline void glBox( Box2<int > const & b ) { glRectiv(b.min.v,b.max.v); }
|
||||
/// Funzione di utilita' per la visualizzazione in OpenGL (float)
|
||||
inline void glBox( Box2<float > const & b ) { glRectfv(b.min.v,b.max.v); }
|
||||
/// Funzione di utilita' per la visualizzazione in OpenGL (double)
|
||||
inline void glBox( Box2<double> const & b ) { glRectdv(b.min.v,b.max.v); }
|
||||
#endif
|
||||
|
||||
/// Specificazione di box of short
|
||||
typedef Box2<short> Box2s;
|
||||
/// Specificazione di box of int
|
||||
|
@ -247,6 +225,7 @@ typedef Box2<float> Box2f;
|
|||
/// Specificazione di box of double
|
||||
typedef Box2<double> Box2d;
|
||||
|
||||
/*@}*/
|
||||
} // end namespace
|
||||
|
||||
|
||||
|
|
|
@ -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 <vcg/space/point4.h>
|
||||
|
||||
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 T>
|
||||
class Color4 : public Point4<T>
|
||||
{
|
||||
|
@ -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<float>::Color4<float>(Color4<float>::ColorConstant cc)
|
|||
typedef Color4<unsigned char> Color4b;
|
||||
typedef Color4<float> Color4f;
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
} // end of NameSpace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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 T> class Point4
|
||||
{
|
||||
protected:
|
||||
|
@ -286,6 +294,7 @@ typedef Point4<int> Point4i;
|
|||
typedef Point4<float> Point4f;
|
||||
typedef Point4<double> Point4d;
|
||||
|
||||
/*@}*/
|
||||
|
||||
} // end namespace
|
||||
#endif
|
||||
|
|
|
@ -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 <vcg/space/point2.h>
|
||||
|
||||
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<class T = float,int N = 1>
|
||||
template<class T = float, int N = 1>
|
||||
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 T = float>
|
||||
class TCoordSimple
|
||||
class TCoord2Simple
|
||||
{
|
||||
private:
|
||||
Point2<T> _t;
|
||||
|
@ -118,15 +130,7 @@ public:
|
|||
|
||||
};
|
||||
|
||||
#ifdef __GL_H__
|
||||
|
||||
|
||||
//inline void glTexCoord(TCoord2<int> const & p) { glTexCoord3iv(p.v);}
|
||||
//inline void glTexCoord(Point3<short> const & p) { glTexCoord3sv(p.v);}
|
||||
//inline void glTexCoord(Point3<float> const & p) { glTexCoord3fv(p.v);}
|
||||
//inline void glTexCoord(Point3<double> const & p){ glTexCoord3dv(p.v);}
|
||||
|
||||
#endif
|
||||
/*@}*/
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue