First commit...

This commit is contained in:
Paolo Cignoni 2004-02-13 00:44:53 +00:00
parent 2e97012432
commit b2481bc732
5 changed files with 2185 additions and 0 deletions

24
vcg/simplex/face/A.h Normal file
View File

@ -0,0 +1,24 @@
/*#**************************************************************************
History
2000 Jan 31 First Working release
****************************************************************************/
#ifndef __VCGLIB_FACE_A___TYPE
#define __VCGLIB_FACE_A___TYPE
#ifdef FACE_TYPE
#pragma message("\nInternal Error 42\n")
#endif
#define FACE_TYPE FaceA
#define __VCGLIB_FACE_A
#include <vcg/Mesh/FaceBase.h>
#undef FACE_TYPE
#undef __VCGLIB_FACE_A
#endif

27
vcg/simplex/face/N.h Normal file
View File

@ -0,0 +1,27 @@
/*#**************************************************************************
History
2000 Jan 31 First Working release
****************************************************************************/
#ifndef __VCGLIB_VERTEX__N__TYPE
#define __VCGLIB_VERTEX__N__TYPE
#define VERTEX_TYPE VertexN
#define __VCGLIB_VERTEX_N
#include <vcg/simplex/vertex/base.h>
#undef VERTEX_TYPE
#undef __VCGLIB_VERTEX_N
using namespace vcg;
typedef VertexN<short> VertexNs;
typedef VertexN<int> VertexNi;
typedef VertexN<float> VertexNf;
typedef VertexN<double> VertexNd;
#endif

1724
vcg/simplex/face/base.h Normal file

File diff suppressed because it is too large Load Diff

277
vcg/space/point2.h Normal file
View File

@ -0,0 +1,277 @@
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
****************************************************************************/
#ifndef __VCGLIB_POINT2
#define __VCGLIB_POINT2
//#include <limits>
#include <assert.h>
#include <vcg/math/base.h>
namespace vcg {
template <class FLTYPE> class Point2
{
protected:
FLTYPE _v[2];
typedef FLTYPE scalar;
inline const FLTYPE &X() const {return v[0];}
inline const FLTYPE &Y() const {return v[1];}
inline FLTYPE &X() {return v[0];}
inline FLTYPE &Y() {return v[1];}
inline const FLTYPE & operator [] ( const int i ) const
{
assert(i>=0 && i<2);
return v[i];
}
inline FLTYPE & operator [] ( const int i )
{
assert(i>=0 && i<2);
return v[i];
}
inline Point2 () { }
inline Point2 ( const FLTYPE nx, const FLTYPE ny )
{
v[0] = nx; v[1] = ny;
}
inline Point2 ( Point2 const & p)
{
v[0]= p.v[0]; v[1]= p.v[1];
}
inline Point2 & operator =( Point2 const & p)
{
v[0]= p.v[0]; v[1]= p.v[1];
return *this;
}
inline void Zero()
{
v[0] = 0;
v[1] = 0;
}
inline Point2 operator + ( Point2 const & p) const
{
return Point2<FLTYPE>( v[0]+p.v[0], v[1]+p.v[1] );
}
inline Point2 operator - ( Point2 const & p) const
{
return Point2<FLTYPE>( v[0]-p.v[0], v[1]-p.v[1] );
}
inline Point2 operator * ( const FLTYPE s ) const
{
return Point2<FLTYPE>( v[0] * s, v[1] * s );
}
inline Point2 operator / ( const FLTYPE s ) const
{
return Point2<FLTYPE>( v[0] / s, v[1] / s );
}
inline FLTYPE operator * ( Point2 const & p ) const
{
return ( v[0]*p.v[0] + v[1]*p.v[1] );
}
inline FLTYPE operator ^ ( Point2 const & p ) const
{
return v[1]*p.v[0] - v[0]*p.v[1];
}
inline Point2 & operator += ( Point2 const & p)
{
v[0] += p.v[0]; v[1] += p.v[1];
return *this;
}
inline Point2 & operator -= ( Point2 const & p)
{
v[0] -= p.v[0]; v[1] -= p.v[1];
return *this;
}
inline Point2 & operator *= ( const FLTYPE s )
{
v[0] *= s; v[1] *= s;
return *this;
}
inline Point2 & operator /= ( const FLTYPE s )
{
v[0] /= s; v[1] /= s;
return *this;
}
inline FLTYPE Norm( void ) const
{
return Sqrt( v[0]*v[0] + v[1]*v[1] );
}
inline FLTYPE SquaredNorm( void ) const
{
return ( v[0]*v[0] + v[1]*v[1] );
}
inline Point2 & Scale( const FLTYPE sx, const FLTYPE sy );
inline Point2 & Normalize( void )
{
FLTYPE n = Sqrt(v[0]*v[0] + v[1]*v[1]);
if(n>0.0) { v[0] /= n; v[1] /= n; }
return *this;
}
inline bool operator == ( Point2 const & p ) const
{
return (v[0]==p.v[0] && v[1]==p.v[1]);
}
inline bool operator != ( Point2 const & p ) const
{
return ( (v[0]!=p.v[0]) || (v[1]!=p.v[1]) );
}
inline bool operator < ( Point2 const & p ) const
{
return (v[1]!=p.v[1])?(v[1]<p.v[1]):
(v[0]<p.v[0]);
}
inline bool operator > ( Point2 const & p ) const
{
return (v[1]!=p.v[1])?(v[1]>p.v[1]):
(v[0]>p.v[0]);
}
inline bool operator <= ( Point2 const & p ) const
{
return (v[1]!=p.v[1])?(v[1]< p.v[1]):
(v[0]<=p.v[0]);
}
inline bool operator >= ( Point2 const & p ) const
{
return (v[1]!=p.v[1])?(v[1]> p.v[1]):
(v[0]>=p.v[0]);
}
inline FLTYPE Distance( Point2 const & p ) const
{
return Norm(*this-p);
}
inline FLTYPE SquaredDistance( Point2 const & p ) const
{
return Norm2(*this-p);
}
inline Point2 & Cartesian2Polar()
{
FLTYPE t = (FLTYPE)atan2(v[1],v[0]);
v[0] = Sqrt(v[0]*v[0]+v[1]*v[1]);
v[1] = t;
return *this;
}
inline Point2 & Polar2Cartesian()
{
FLTYPE l = v[0];
v[0] = (FLTYPE)(l*cos(v[1]));
v[1] = (FLTYPE)(l*sin(v[1]));
return *this;
}
inline Point2 & rotate( const FLTYPE a )
{
FLTYPE t = v[0];
FLTYPE s = sin(a);
FLTYPE c = cos(a);
v[0] = v[0]*c - v[1]*s;
v[1] = t *s + v[1]*c;
return *this;
}
/// Questa funzione estende il vettore ad un qualsiasi numero di dimensioni
/// paddando gli elementi estesi con zeri
inline FLTYPE Ext( const int i ) const
{
if(i>=0 && i<2) return v[i];
else return 0;
}
}; // end class definition
template <class FLTYPE>
inline FLTYPE Angle( Point2<FLTYPE> const & p1, Point2<FLTYPE> const & p2 )
{
return atan2(p2[1],p2[0]) - atan2(p1[1],p1[0]);
}
template <class FLTYPE>
inline Point2<FLTYPE> operator - ( Point2<FLTYPE> const & p ){
return Point2<FLTYPE>( -p.v[0], -p.v[1] );
}
template <class FLTYPE>
inline Point2<FLTYPE> operator * ( const FLTYPE s, Point2<FLTYPE> const & p ){
return Point2<FLTYPE>( p.v[0] * s, p.v[1] * s );
}
template <class FLTYPE>
inline FLTYPE Norm( Point2<FLTYPE> const & p ){
return Sqrt( p.v[0]*p.v[0] + p.v[1]*p.v[1] );
}
template <class FLTYPE>
inline FLTYPE Norm2( Point2<FLTYPE> const & p ){
return ( p.v[0]*p.v[0] + p.v[1]*p.v[1] );
}
template <class FLTYPE>
inline Point2<FLTYPE> & Normalize( Point2<FLTYPE> & p ){
FLTYPE n = Sqrt( p.v[0]*p.v[0] + p.v[1]*p.v[1] );
if(n>0.0) p/=n;
return p;
}
template <class FLTYPE>
inline FLTYPE Distance( Point2<FLTYPE> const & p1,Point2<FLTYPE> const & p2 ){
return Norm(p1-p2);
}
template <class FLTYPE>
inline FLTYPE SquaredDistance( Point2<FLTYPE> const & p1,Point2<FLTYPE> const & p2 ){
return Norm2(p1-p2);
}
typedef Point2<short> Point2s;
typedef Point2<int> Point2i;
typedef Point2<float> Point2f;
typedef Point2<double> Point2d;
} // end namespace
#endif

133
vcg/space/tcoord2.h Normal file
View File

@ -0,0 +1,133 @@
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
****************************************************************************/
#ifndef __VCGLIB_TCOORD2__
#define __VCGLIB_TCOORD2__
#include <vcg/space/point2.h>
namespace vcg {
template<class T = float,int N = 1>
class TCoord2
{
private:
Point2<T> _t[N];
short _n[N];
public:
inline T & u() { return _t[0][0]; }
inline T & v() { return _t[0][1]; }
inline const T & u() const { return _t[0][0]; }
inline const T & v() const { return _t[0][1]; }
inline T & u(const int i) { return _t[i][0]; }
inline T & v(const int i) { return _t[i][1]; }
inline const T & u(const int i) const { return _t[i][0]; }
inline const T & v(const int i) const { return _t[i][1]; }
inline short & n() { return _n[0]; }
inline const short n() const { return _n[0]; }
inline short & n(const int i) { return _n[i]; }
inline const short n(const int i) const { return _n[i]; }
inline Point2<T> & t(const int i) { return _t[i]; }
inline Point2<T> t(const int i) const { return _t[i]; }
inline Point2<T> & t() { return _t[0]; }
inline Point2<T> t() const { return _t[0]; }
inline bool operator == ( TCoord2 const & p ) const
{
for(int i=0;i<N;++i)
if(p._t[i] != _t[i] || p._n[i] != _n[i]) return false;
return true;
}
enum { n_coords=N};
};
template<class T = float>
class TCoordSimple
{
private:
Point2<T> _t;
inline short & static_n() const
{
static short _n = 0;
return _n;
}
public:
inline T & u() { return _t[0]; }
inline T & v() { return _t[1]; }
inline const T & u() const { return _t[0]; }
inline const T & v() const { return _t[1]; }
inline T & u(const int i) { assert(i==0); return _t[0]; }
inline T & v(const int i) { assert(i==0); return _t[1]; }
inline const T & u(const int i) const { assert(i==0); return _t[0]; }
inline const T & v(const int i) const { assert(i==0); return _t[1]; }
inline bool operator == ( TCoordSimple const & p ) const
{
return _t==p._t;
}
inline Point2<T> & t(const int i) { assert(i==0); return _t; }
inline Point2<T> t(const int i) const { assert(i==0); return _t; }
inline Point2<T> & t() { return _t; }
inline Point2<T> t() const { return _t; }
inline short & n() { assert(static_n()==0); return static_n(); }
inline short n() const { assert(static_n()==0); return 0; }
inline short & n(const int i) { assert(i==0); return static_n(); }
inline short n(const int i) const { assert(i==0); return 0; }
enum { n_coords=1};
};
#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
}
#endif