Commit 431f3597 authored by Sylvain Thery's avatar Sylvain Thery

begin of implementation of multi-attributes computing

parent 4fa2f232
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library 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 Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef MULTIATTRIBS_H_
#define MULTIATTRIBS_H_
namespace CGoGN
{
//forward
template <typename T1, typename T2>
struct RefCompo2Type;
template <typename T1, typename T2>
struct Compo2Type
{
T1 m_v1;
T2 m_v2;
Compo2Type(){}
Compo2Type(double z ): m_v1(z), m_v2(z) {}
Compo2Type<T1,T2> operator+(const Compo2Type<T1,T2>& v) const;
Compo2Type<T1,T2> operator+(const RefCompo2Type<T1,T2>& v) const;
Compo2Type<T1,T2> operator-(const Compo2Type<T1,T2>& v) const;
Compo2Type<T1,T2> operator-(const RefCompo2Type<T1,T2>& v) const;
Compo2Type<T1,T2> operator/(double d) const;
Compo2Type<T1,T2> operator*(double d) const;
Compo2Type<T1,T2>& operator+=(const Compo2Type<T1,T2>& v);
Compo2Type<T1,T2>& operator+=(const RefCompo2Type<T1,T2>& v);
Compo2Type<T1,T2>& operator-=(const Compo2Type<T1,T2>& v);
Compo2Type<T1,T2>& operator-=(const RefCompo2Type<T1,T2>& v);
Compo2Type<T1,T2>& operator*=(double d);
Compo2Type<T1,T2>& operator/=(double d);
};
template <typename T1, typename T2>
struct RefCompo2Type
{
T1& m_v1;
T2& m_v2;
RefCompo2Type(T1& v1, T2& v2): m_v1(v1), m_v2(v2) {}
RefCompo2Type& operator =(const Compo2Type<T1,T2>& comp)
{
m_v1 = comp.m_v1;
m_v2 = comp.m_v2;
return *this;
}
RefCompo2Type<T1,T2>& operator=(const RefCompo2Type<T1,T2>& v)
{
m_v1 = v.m_v1;
m_v2 = v.m_v2;
return *this;
}
Compo2Type<T1,T2> operator+(const RefCompo2Type<T1,T2>& v) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 + v.m_v1;
res.m_v2 = this->m_v2 + v.m_v2;
return res ;
}
Compo2Type<T1,T2> operator+(const Compo2Type<T1,T2>& v) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 + v.m_v1;
res.m_v2 = this->m_v2 + v.m_v2;
return res ;
}
Compo2Type<T1,T2> operator-(const RefCompo2Type<T1,T2>& v) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 - v.m_v1;
res.m_v2 = this->m_v2 - v.m_v2;
return res ;
}
Compo2Type<T1,T2> operator-(const Compo2Type<T1,T2>& v) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 - v.m_v1;
res.m_v2 = this->m_v2 - v.m_v2;
return res ;
}
Compo2Type<T1,T2> operator/(double d) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 / d;
res.m_v2 = this->m_v2 / d;
return res ;
}
Compo2Type<T1,T2> operator*(double d) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 * d;
res.m_v2 = this->m_v2 * d;
return res ;
}
RefCompo2Type<T1,T2>& operator+=(const RefCompo2Type<T1,T2>& v)
{
m_v1 += v.m_v1;
m_v2 += v.m_v2;
return *this;
}
RefCompo2Type<T1,T2>& operator-=(const RefCompo2Type<T1,T2>& v)
{
m_v1 += v.m_v1;
m_v2 += v.m_v2;
return *this;
}
RefCompo2Type<T1,T2>& operator*=(double d)
{
m_v1 *= d;
m_v2 *= d;
return *this;
}
RefCompo2Type<T1,T2>& operator/=(double d)
{
m_v1 /= d;
m_v2 /= d;
return *this;
}
};
template < typename T1, typename T2>
Compo2Type<T1,T2> Compo2Type<T1,T2>::operator+(const Compo2Type<T1,T2>& v) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 + v.m_v1;
res.m_v2 = this->m_v2 + v.m_v2;
return res ;
}
template < typename T1, typename T2>
Compo2Type<T1,T2> Compo2Type<T1,T2>::operator+(const RefCompo2Type<T1,T2>& v) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 + v.m_v1;
res.m_v2 = this->m_v2 + v.m_v2;
return res ;
}
template < typename T1, typename T2>
Compo2Type<T1,T2> Compo2Type<T1,T2>::operator-(const Compo2Type<T1,T2>& v) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 - v.m_v1;
res.m_v2 = this->m_v2 - v.m_v2;
return res ;
}
template < typename T1, typename T2>
Compo2Type<T1,T2> Compo2Type<T1,T2>::operator-(const RefCompo2Type<T1,T2>& v) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 - v.m_v1;
res.m_v2 = this->m_v2 - v.m_v2;
return res ;
}
template < typename T1, typename T2>
Compo2Type<T1,T2> Compo2Type<T1,T2>::operator/(double d) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 / d;
res.m_v2 = this->m_v2 / d;
return res ;
}
template < typename T1, typename T2>
Compo2Type<T1,T2> Compo2Type<T1,T2>::operator*(double d) const
{
Compo2Type<T1,T2> res ;
res.m_v1 = this->m_v1 * d;
res.m_v2 = this->m_v2 * d;
return res ;
}
template < typename T1, typename T2>
Compo2Type<T1,T2>& Compo2Type<T1,T2>::operator+=(const Compo2Type<T1,T2>& v)
{
m_v1 += v.m_v1;
m_v2 += v.m_v2;
return *this;
}
template < typename T1, typename T2>
Compo2Type<T1,T2>& Compo2Type<T1,T2>::operator+=(const RefCompo2Type<T1,T2>& v)
{
m_v1 += v.m_v1;
m_v2 += v.m_v2;
return *this;
}
template < typename T1, typename T2>
Compo2Type<T1,T2>& Compo2Type<T1,T2>::operator-=(const Compo2Type<T1,T2>& v)
{
m_v1 += v.m_v1;
m_v2 += v.m_v2;
return *this;
}
template < typename T1, typename T2>
Compo2Type<T1,T2>& Compo2Type<T1,T2>::operator-=(const RefCompo2Type<T1,T2>& v)
{
m_v1 += v.m_v1;
m_v2 += v.m_v2;
return *this;
}
template < typename T1, typename T2>
Compo2Type<T1,T2>& Compo2Type<T1,T2>::operator*=(double d)
{
m_v1 *= d;
m_v2 *= d;
return *this;
}
template < typename T1, typename T2>
Compo2Type<T1,T2>& Compo2Type<T1,T2>::operator/=(double d)
{
m_v1 /= d;
m_v2 /= d;
return *this;
}
template <typename T1, typename T2>
class VertexAttributes
{
VertexAttribute<T1>& m_h1;
VertexAttribute<T2>& m_h2;
public:
typedef Compo2Type<T1,T2> VALUE;
typedef RefCompo2Type<T1,T2> REF;
VertexAttributes(VertexAttribute<T1>& h1, VertexAttribute<T2>& h2):
m_h1(h1), m_h2(h2) {}
RefCompo2Type<T1,T2> operator[](unsigned int a)
{
return RefCompo2Type<T1,T2>(m_h1[a],m_h2[a]);
}
RefCompo2Type<T1,T2> operator[](Dart d)
{
return RefCompo2Type<T1,T2>(m_h1[d],m_h2[d]);
}
};
template <typename T1, typename T2>
class FaceAttributes
{
FaceAttribute<T1>& m_h1;
FaceAttribute<T2>& m_h2;
public:
typedef Compo2Type<T1,T2> VALUE;
typedef RefCompo2Type<T1,T2> REF;
FaceAttributes(FaceAttribute<T1>& h1, FaceAttribute<T2>& h2):
m_h1(h1), m_h2(h2) {}
RefCompo2Type<T1,T2> operator[](unsigned int a)
{
return RefCompo2Type<T1,T2>(m_h1[a],m_h2[a]);
}
RefCompo2Type<T1,T2> operator[](Dart d)
{
return RefCompo2Type<T1,T2>(m_h1[d],m_h2[d]);
}
};
template <typename T1, typename T2>
class VolumeAttributes
{
VolumeAttribute<T1>& m_h1;
VolumeAttribute<T2>& m_h2;
public:
typedef Compo2Type<T1,T2> VALUE;
typedef RefCompo2Type<T1,T2> REF;
VolumeAttributes(FaceAttribute<T1>& h1, FaceAttribute<T2>& h2):
m_h1(h1), m_h2(h2) {}
RefCompo2Type<T1,T2> operator[](unsigned int a)
{
return RefCompo2Type<T1,T2>(m_h1[a],m_h2[a]);
}
RefCompo2Type<T1,T2> operator[](Dart d)
{
return RefCompo2Type<T1,T2>(m_h1[d],m_h2[d]);
}
};
} // namespace CGoGN
#endif /* MULTIATTRIBS_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment