*** empty log message ***
This commit is contained in:
parent
7d982c7cf5
commit
2328e5b1e4
|
@ -22,6 +22,9 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.13 2005/01/19 10:33:50 cignoni
|
||||||
|
Improved ClearHeap management
|
||||||
|
|
||||||
Revision 1.12 2004/12/10 01:02:48 cignoni
|
Revision 1.12 2004/12/10 01:02:48 cignoni
|
||||||
added an inline and removed loggng
|
added an inline and removed loggng
|
||||||
|
|
||||||
|
@ -272,7 +275,7 @@ public:
|
||||||
// Chiamata dalla do decimate ogni tanto quando lo heap diventa troppo grande (>fn*3)
|
// Chiamata dalla do decimate ogni tanto quando lo heap diventa troppo grande (>fn*3)
|
||||||
void ClearHeap()
|
void ClearHeap()
|
||||||
{
|
{
|
||||||
HeapType::iterator hi;
|
typename HeapType::iterator hi;
|
||||||
int sz=h.size();
|
int sz=h.size();
|
||||||
for(hi=h.begin();hi!=h.end();++hi)
|
for(hi=h.begin();hi!=h.end();++hi)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.6 2005/01/19 10:35:28 cignoni
|
||||||
|
Better management of symmetric/asymmetric edge collapses
|
||||||
|
|
||||||
Revision 1.5 2004/12/10 01:07:15 cignoni
|
Revision 1.5 2004/12/10 01:07:15 cignoni
|
||||||
Moved param classes inside; added support for optimal placement and symmetric; added update heap also here (not only in the base class)
|
Moved param classes inside; added support for optimal placement and symmetric; added update heap also here (not only in the base class)
|
||||||
|
|
||||||
|
@ -98,6 +101,7 @@ public:
|
||||||
typedef typename TriMeshType::ScalarType ScalarType;
|
typedef typename TriMeshType::ScalarType ScalarType;
|
||||||
typedef math::Quadric< double > QuadricType;
|
typedef math::Quadric< double > QuadricType;
|
||||||
typedef typename TriMeshType::FaceType FaceType;
|
typedef typename TriMeshType::FaceType FaceType;
|
||||||
|
typedef typename TriMeshType::VertexType VertexType;
|
||||||
|
|
||||||
class QParameter
|
class QParameter
|
||||||
{
|
{
|
||||||
|
@ -144,14 +148,14 @@ public:
|
||||||
inline TriEdgeCollapseQuadric(const EdgeType &p, int i)
|
inline TriEdgeCollapseQuadric(const EdgeType &p, int i)
|
||||||
//:TEC(p,i){}
|
//:TEC(p,i){}
|
||||||
{
|
{
|
||||||
localMark = i;
|
this->localMark = i;
|
||||||
pos=p;
|
this->pos=p;
|
||||||
_priority = ComputePriority();
|
this->_priority = ComputePriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool IsFeasible(){
|
inline bool IsFeasible(){
|
||||||
bool res = ( !Params().PreserveTopology || LinkConditions(pos) );
|
bool res = ( !Params().PreserveTopology || LinkConditions(this->pos) );
|
||||||
if(!res) ++( TriEdgeCollapse< TriMeshType,MYTYPE>::FailStat::LinkConditionEdge() );
|
if(!res) ++( TriEdgeCollapse< TriMeshType,MYTYPE>::FailStat::LinkConditionEdge() );
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -159,9 +163,9 @@ public:
|
||||||
void Execute(TriMeshType &m)
|
void Execute(TriMeshType &m)
|
||||||
{ CoordType newPos;
|
{ CoordType newPos;
|
||||||
if(Params().OptimalPlacement) newPos= ComputeMinimal();
|
if(Params().OptimalPlacement) newPos= ComputeMinimal();
|
||||||
else newPos=pos.V(1)->P();
|
else newPos=this->pos.V(1)->P();
|
||||||
pos.V(1)->q+=pos.V(0)->q;
|
this->pos.V(1)->q+=this->pos.V(0)->q;
|
||||||
int FaceDel=DoCollapse(pos, newPos); // v0 is deleted and v1 take the new position
|
int FaceDel=DoCollapse(this->pos, newPos); // v0 is deleted and v1 take the new position
|
||||||
m.fn-=FaceDel;
|
m.fn-=FaceDel;
|
||||||
--m.vn;
|
--m.vn;
|
||||||
}
|
}
|
||||||
|
@ -227,11 +231,11 @@ public:
|
||||||
assert(x.F()->V(x.I())==&(*vi));
|
assert(x.F()->V(x.I())==&(*vi));
|
||||||
if((x.V0()<x.V1()) && x.V1()->IsRW() && !x.V1()->IsV()){
|
if((x.V0()<x.V1()) && x.V1()->IsRW() && !x.V1()->IsV()){
|
||||||
x.V1()->SetV();
|
x.V1()->SetV();
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(EdgeType(x.V0(),x.V1()),GlobalMark() )));
|
h_ret.push_back(HeapElem(new MYTYPE(EdgeType(x.V0(),x.V1()),TriEdgeCollapse< TriMeshType,MYTYPE>::GlobalMark() )));
|
||||||
}
|
}
|
||||||
if((x.V0()<x.V2()) && x.V2()->IsRW()&& !x.V2()->IsV()){
|
if((x.V0()<x.V2()) && x.V2()->IsRW()&& !x.V2()->IsV()){
|
||||||
x.V2()->SetV();
|
x.V2()->SetV();
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(EdgeType(x.V0(),x.V2()),GlobalMark() )));
|
h_ret.push_back(HeapElem(new MYTYPE(EdgeType(x.V0(),x.V2()),TriEdgeCollapse< TriMeshType,MYTYPE>::GlobalMark() )));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,10 +250,10 @@ public:
|
||||||
{
|
{
|
||||||
assert(x.F()->V(x.I())==&(*vi));
|
assert(x.F()->V(x.I())==&(*vi));
|
||||||
if(x.V()->IsRW() && x.V1()->IsRW() && !m.IsMarked(x.F()->V1(x.I()))){
|
if(x.V()->IsRW() && x.V1()->IsRW() && !m.IsMarked(x.F()->V1(x.I()))){
|
||||||
h_ret.push_back( HeapElem( new MYTYPE( EdgeType (x.V(),x.V1()),GlobalMark())));
|
h_ret.push_back( HeapElem( new MYTYPE( EdgeType (x.V(),x.V1()),TriEdgeCollapse< TriMeshType,MYTYPE>::GlobalMark())));
|
||||||
}
|
}
|
||||||
if(x.V()->IsRW() && x.V2()->IsRW() && !m.IsMarked(x.F()->V2(x.I()))){
|
if(x.V()->IsRW() && x.V2()->IsRW() && !m.IsMarked(x.F()->V2(x.I()))){
|
||||||
h_ret.push_back( HeapElem( new MYTYPE( EdgeType (x.V(),x.V2()),GlobalMark())));
|
h_ret.push_back( HeapElem( new MYTYPE( EdgeType (x.V(),x.V2()),TriEdgeCollapse< TriMeshType,MYTYPE>::GlobalMark())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,8 +291,8 @@ public:
|
||||||
typename vcg::face::VFIterator<FaceType> x;
|
typename vcg::face::VFIterator<FaceType> x;
|
||||||
std::vector<CoordType> on; // original normals
|
std::vector<CoordType> on; // original normals
|
||||||
typename TriMeshType::VertexType * v[2];
|
typename TriMeshType::VertexType * v[2];
|
||||||
v[0] = pos.V(0);
|
v[0] = this->pos.V(0);
|
||||||
v[1] = pos.V(1);
|
v[1] = this->pos.V(1);
|
||||||
|
|
||||||
if(Params().NormalCheck){ // Compute maximal normal variation
|
if(Params().NormalCheck){ // Compute maximal normal variation
|
||||||
// store the old normals for non-collapsed face in v0
|
// store the old normals for non-collapsed face in v0
|
||||||
|
@ -367,8 +371,8 @@ public:
|
||||||
//Rrestore old position of v0 and v1
|
//Rrestore old position of v0 and v1
|
||||||
v[0]->P()=OldPos0;
|
v[0]->P()=OldPos0;
|
||||||
v[1]->P()=OldPos1;
|
v[1]->P()=OldPos1;
|
||||||
_priority = -error;
|
this->_priority = -error;
|
||||||
return _priority;
|
return this->_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -376,10 +380,11 @@ public:
|
||||||
//
|
//
|
||||||
inline void UpdateHeap(HeapType & h_ret)
|
inline void UpdateHeap(HeapType & h_ret)
|
||||||
{
|
{
|
||||||
GlobalMark()++;
|
this->GlobalMark()++;
|
||||||
VertexType *v[2];
|
VertexType *v[2];
|
||||||
v[0]= pos.V(0);v[1]=pos.V(1);
|
v[0]= this->pos.V(0);
|
||||||
v[1]->IMark() = GlobalMark();
|
v[1]= this->pos.V(1);
|
||||||
|
v[1]->IMark() = this->GlobalMark();
|
||||||
|
|
||||||
// First loop around the remaining vertex to unmark visited flags
|
// First loop around the remaining vertex to unmark visited flags
|
||||||
vcg::face::VFIterator<FaceType> vfi(v[1]);
|
vcg::face::VFIterator<FaceType> vfi(v[1]);
|
||||||
|
@ -399,29 +404,29 @@ public:
|
||||||
if( !(vfi.V1()->IsV()) && vfi.V1()->IsRW())
|
if( !(vfi.V1()->IsV()) && vfi.V1()->IsRW())
|
||||||
{
|
{
|
||||||
vfi.V1()->SetV();
|
vfi.V1()->SetV();
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V0(),vfi.V1()), GlobalMark())));
|
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V0(),vfi.V1()), this->GlobalMark())));
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
if(!IsSymmetric()){
|
if(!IsSymmetric()){
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V1(),vfi.V0()), GlobalMark())));
|
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V1(),vfi.V0()), this->GlobalMark())));
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !(vfi.V2()->IsV()) && vfi.V2()->IsRW())
|
if( !(vfi.V2()->IsV()) && vfi.V2()->IsRW())
|
||||||
{
|
{
|
||||||
vfi.V2()->SetV();
|
vfi.V2()->SetV();
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V0(),vfi.V2()),GlobalMark())));
|
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V0(),vfi.V2()),this->GlobalMark())));
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
if(!IsSymmetric()){
|
if(!IsSymmetric()){
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V2(),vfi.V0()), GlobalMark())));
|
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V2(),vfi.V0()), this->GlobalMark())));
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Params().SafeHeapUpdate && vfi.V1()->IsRW() && vfi.V2()->IsRW() )
|
if(Params().SafeHeapUpdate && vfi.V1()->IsRW() && vfi.V2()->IsRW() )
|
||||||
{
|
{
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V1(),vfi.V2()),GlobalMark())));
|
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V1(),vfi.V2()),this->GlobalMark())));
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
if(!IsSymmetric()){
|
if(!IsSymmetric()){
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V2(),vfi.V1()), GlobalMark())));
|
h_ret.push_back(HeapElem(new MYTYPE(EdgeType (vfi.V2(),vfi.V1()), this->GlobalMark())));
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -529,8 +534,8 @@ static void InitQuadric(TriMeshType &m)
|
||||||
CoordType ComputeMinimal()
|
CoordType ComputeMinimal()
|
||||||
{
|
{
|
||||||
typename TriMeshType::VertexType * v[2];
|
typename TriMeshType::VertexType * v[2];
|
||||||
v[0] = pos.V(0);
|
v[0] = this->pos.V(0);
|
||||||
v[1] = pos.V(1);
|
v[1] = this->pos.V(1);
|
||||||
QuadricType q=v[0]->q;
|
QuadricType q=v[0]->q;
|
||||||
q+=v[1]->q;
|
q+=v[1]->q;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.24 2005/03/18 00:14:39 cignoni
|
||||||
|
removed small gcc compiling issues
|
||||||
|
|
||||||
Revision 1.23 2005/03/15 11:40:56 cignoni
|
Revision 1.23 2005/03/15 11:40:56 cignoni
|
||||||
Added operator*=( std::vector<PointType> ...) to apply a matrix to a vector of vertexes (replacement of the old style mesh.Apply(tr).
|
Added operator*=( std::vector<PointType> ...) to apply a matrix to a vector of vertexes (replacement of the old style mesh.Apply(tr).
|
||||||
|
|
||||||
|
@ -538,7 +541,7 @@ template <class T> LinearSolve<T>::LinearSolve(const Matrix44<T> &m): Matrix44<T
|
||||||
if(!Decompose()) {
|
if(!Decompose()) {
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
index[i] = i;
|
index[i] = i;
|
||||||
SetZero();
|
Matrix44<T>::SetZero();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +549,7 @@ template <class T> LinearSolve<T>::LinearSolve(const Matrix44<T> &m): Matrix44<T
|
||||||
template <class T> T LinearSolve<T>::Determinant() const {
|
template <class T> T LinearSolve<T>::Determinant() const {
|
||||||
T det = d;
|
T det = d;
|
||||||
for(int j = 0; j < 4; j++)
|
for(int j = 0; j < 4; j++)
|
||||||
det *= ElementAt(j, j);
|
det *= this-> ElementAt(j, j);
|
||||||
return det;
|
return det;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,7 +620,7 @@ template <class T> bool LinearSolve<T>::Decompose() {
|
||||||
for(i = 0; i < 4; i++) {
|
for(i = 0; i < 4; i++) {
|
||||||
T largest = 0.0;
|
T largest = 0.0;
|
||||||
for(j = 0; j < 4; j++) {
|
for(j = 0; j < 4; j++) {
|
||||||
T t = math::Abs(ElementAt(i, j));
|
T t = math::Abs(this->ElementAt(i, j));
|
||||||
if (t > largest) largest = t;
|
if (t > largest) largest = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,17 +633,17 @@ template <class T> bool LinearSolve<T>::Decompose() {
|
||||||
int imax;
|
int imax;
|
||||||
for(j = 0; j < 4; j++) {
|
for(j = 0; j < 4; j++) {
|
||||||
for(i = 0; i < j; i++) {
|
for(i = 0; i < j; i++) {
|
||||||
T sum = ElementAt(i,j);
|
T sum = this->ElementAt(i,j);
|
||||||
for(int k = 0; k < i; k++)
|
for(int k = 0; k < i; k++)
|
||||||
sum -= ElementAt(i,k)*ElementAt(k,j);
|
sum -= this->ElementAt(i,k)*this->ElementAt(k,j);
|
||||||
ElementAt(i,j) = sum;
|
this->ElementAt(i,j) = sum;
|
||||||
}
|
}
|
||||||
T largest = 0.0;
|
T largest = 0.0;
|
||||||
for(i = j; i < 4; i++) {
|
for(i = j; i < 4; i++) {
|
||||||
T sum = ElementAt(i,j);
|
T sum = this->ElementAt(i,j);
|
||||||
for(k = 0; k < j; k++)
|
for(k = 0; k < j; k++)
|
||||||
sum -= ElementAt(i,k)*ElementAt(k,j);
|
sum -= this->ElementAt(i,k)*this->ElementAt(k,j);
|
||||||
ElementAt(i,j) = sum;
|
this->ElementAt(i,j) = sum;
|
||||||
T t = scaling[i] * math::Abs(sum);
|
T t = scaling[i] * math::Abs(sum);
|
||||||
if(t >= largest) {
|
if(t >= largest) {
|
||||||
largest = t;
|
largest = t;
|
||||||
|
@ -649,19 +652,19 @@ template <class T> bool LinearSolve<T>::Decompose() {
|
||||||
}
|
}
|
||||||
if (j != imax) {
|
if (j != imax) {
|
||||||
for (int k = 0; k < 4; k++) {
|
for (int k = 0; k < 4; k++) {
|
||||||
T dum = ElementAt(imax,k);
|
T dum = this->ElementAt(imax,k);
|
||||||
ElementAt(imax,k) = ElementAt(j,k);
|
this->ElementAt(imax,k) = this->ElementAt(j,k);
|
||||||
ElementAt(j,k) = dum;
|
this->ElementAt(j,k) = dum;
|
||||||
}
|
}
|
||||||
d = -(d);
|
d = -(d);
|
||||||
scaling[imax] = scaling[j];
|
scaling[imax] = scaling[j];
|
||||||
}
|
}
|
||||||
index[j]=imax;
|
index[j]=imax;
|
||||||
if (ElementAt(j,j) == 0.0) ElementAt(j,j) = (T)TINY;
|
if (this->ElementAt(j,j) == 0.0) this->ElementAt(j,j) = (T)TINY;
|
||||||
if (j != 3) {
|
if (j != 3) {
|
||||||
T dum = (T)1.0 / (ElementAt(j,j));
|
T dum = (T)1.0 / (this->ElementAt(j,j));
|
||||||
for (i = j+1; i < 4; i++)
|
for (i = j+1; i < 4; i++)
|
||||||
ElementAt(i,j) *= dum;
|
this->ElementAt(i,j) *= dum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -677,7 +680,7 @@ template <class T> Point4<T> LinearSolve<T>::Solve(const Point4<T> &b) {
|
||||||
x[ip] = x[i];
|
x[ip] = x[i];
|
||||||
if(first!= -1)
|
if(first!= -1)
|
||||||
for(int j = first; j <= i-1; j++)
|
for(int j = first; j <= i-1; j++)
|
||||||
sum -= ElementAt(i,j) * x[j];
|
sum -= this->ElementAt(i,j) * x[j];
|
||||||
else
|
else
|
||||||
if(sum) first = i;
|
if(sum) first = i;
|
||||||
x[i] = sum;
|
x[i] = sum;
|
||||||
|
@ -685,8 +688,8 @@ template <class T> Point4<T> LinearSolve<T>::Solve(const Point4<T> &b) {
|
||||||
for (int i = 3; i >= 0; i--) {
|
for (int i = 3; i >= 0; i--) {
|
||||||
T sum = x[i];
|
T sum = x[i];
|
||||||
for (int j = i+1; j < 4; j++)
|
for (int j = i+1; j < 4; j++)
|
||||||
sum -= ElementAt(i, j) * x[j];
|
sum -= this->ElementAt(i, j) * x[j];
|
||||||
x[i] = sum / ElementAt(i, i);
|
x[i] = sum / this->ElementAt(i, i);
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.10 2004/12/15 18:45:50 tommyfranken
|
||||||
|
*** empty log message ***
|
||||||
|
|
||||||
Revision 1.9 2004/10/22 14:35:42 ponchio
|
Revision 1.9 2004/10/22 14:35:42 ponchio
|
||||||
m.element(x, y) -> m[x][y]
|
m.element(x, y) -> m[x][y]
|
||||||
|
|
||||||
|
@ -35,6 +38,9 @@ updated access to matrix44 elements through V() instead simple []
|
||||||
|
|
||||||
Revision 1.6 2004/03/25 14:57:49 ponchio
|
Revision 1.6 2004/03/25 14:57:49 ponchio
|
||||||
Microerror. ($LOG$ -> $Log: not supported by cvs2svn $
|
Microerror. ($LOG$ -> $Log: not supported by cvs2svn $
|
||||||
|
Microerror. ($LOG$ -> Revision 1.10 2004/12/15 18:45:50 tommyfranken
|
||||||
|
Microerror. ($LOG$ -> *** empty log message ***
|
||||||
|
Microerror. ($LOG$ ->
|
||||||
Microerror. ($LOG$ -> Revision 1.9 2004/10/22 14:35:42 ponchio
|
Microerror. ($LOG$ -> Revision 1.9 2004/10/22 14:35:42 ponchio
|
||||||
Microerror. ($LOG$ -> m.element(x, y) -> m[x][y]
|
Microerror. ($LOG$ -> m.element(x, y) -> m[x][y]
|
||||||
Microerror. ($LOG$ ->
|
Microerror. ($LOG$ ->
|
||||||
|
@ -76,7 +82,7 @@ public:
|
||||||
Quaternion operator*(const Quaternion &q) const;
|
Quaternion operator*(const Quaternion &q) const;
|
||||||
Quaternion &operator*=(const Quaternion &q);
|
Quaternion &operator*=(const Quaternion &q);
|
||||||
void Invert();
|
void Invert();
|
||||||
|
|
||||||
|
|
||||||
void SetIdentity();
|
void SetIdentity();
|
||||||
|
|
||||||
|
@ -87,7 +93,11 @@ public:
|
||||||
void FromMatrix(Matrix44<S> &m);
|
void FromMatrix(Matrix44<S> &m);
|
||||||
void ToMatrix(Matrix44<S> &m) const;
|
void ToMatrix(Matrix44<S> &m) const;
|
||||||
|
|
||||||
Point3<S> Rotate(const Point3<S> vec) const;
|
Point3<S> Rotate(const Point3<S> vec) const;
|
||||||
|
//duplicated ... because of gcc new confoming to ISO template derived classes
|
||||||
|
//do no 'see' parent members (unless explicitly specified)
|
||||||
|
const S & V ( const int i ) const { assert(i>=0 && i<4); return Point3<S>::_v[i]; }
|
||||||
|
S & V ( const int i ) { assert(i>=0 && i<4); return Point3<S>::_v[i]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class S> Quaternion<S> Interpolate(const Quaternion<S> a, const Quaternion<S> b, double t);
|
template <class S> Quaternion<S> Interpolate(const Quaternion<S> a, const Quaternion<S> b, double t);
|
||||||
|
@ -286,10 +296,10 @@ template <class S> Quaternion<S> Inverse(const Quaternion<S> &m) {
|
||||||
|
|
||||||
template <class S> Quaternion<S> Interpolate(const Quaternion<S> a, const Quaternion<S> b, double t) {
|
template <class S> Quaternion<S> Interpolate(const Quaternion<S> a, const Quaternion<S> b, double t) {
|
||||||
double v = a.V(0) * b.V(0) + a.V(1) * b.V(1) + a.V(2) * b.V(2) + a.V(3) * b.V(3);
|
double v = a.V(0) * b.V(0) + a.V(1) * b.V(1) + a.V(2) * b.V(2) + a.V(3) * b.V(3);
|
||||||
double phi = Acos(v);
|
double phi = math::Acos(v);
|
||||||
if(phi > 0.01) {
|
if(phi > 0.01) {
|
||||||
a = a * (Sin(phi *(1-t))/Sin(phi));
|
a = a * (math::Sin(phi *(1-t))/math::Sin(phi));
|
||||||
b = b * (Sin(phi * t)/Sin(phi));
|
b = b * (math::Sin(phi * t)/math::Sin(phi));
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion<S> c;
|
Quaternion<S> c;
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.5 2004/10/25 16:25:12 ponchio
|
||||||
|
inline Set(...) -> inline void Set(...)
|
||||||
|
|
||||||
Revision 1.4 2004/10/25 08:21:17 ganovelli
|
Revision 1.4 2004/10/25 08:21:17 ganovelli
|
||||||
added: constructor,Set and some minor changes.
|
added: constructor,Set and some minor changes.
|
||||||
|
|
||||||
|
@ -756,12 +759,13 @@ public:
|
||||||
void ClearB(int i) {_flags &= (~(BORDER0<<i));}
|
void ClearB(int i) {_flags &= (~(BORDER0<<i));}
|
||||||
|
|
||||||
/// This function checks if the face is Crease on side i
|
/// This function checks if the face is Crease on side i
|
||||||
bool IsEE(int i) const {return (_flags & (FEATURE0<<i)) != 0;}
|
///Well it would if FEATURE0 was defined somewhere
|
||||||
|
/* bool IsEE(int i) const {return (_flags & (FEATURE0<<i)) != 0;}
|
||||||
/// This function select the face flag
|
/// This function select the face flag
|
||||||
void SetEE(int i) {_flags |=(FEATURE0<<i);}
|
void SetEE(int i) {_flags |=(FEATURE0<<i);}
|
||||||
/// This funcion execute the inverse operation of Set()
|
/// This funcion execute the inverse operation of Set()
|
||||||
void ClearEE(int i) {_flags &= (~(FEATURE0<<i));}
|
void ClearEE(int i) {_flags &= (~(FEATURE0<<i));} */
|
||||||
|
|
||||||
/// This function checks if the given user bit is true
|
/// This function checks if the given user bit is true
|
||||||
bool IsUserBit(int userBit){return (_flags & userBit) != 0;}
|
bool IsUserBit(int userBit){return (_flags & userBit) != 0;}
|
||||||
/// This function set the given user bit
|
/// This function set the given user bit
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.11 2004/09/09 12:51:28 fasano
|
||||||
|
corrected ColorRamp code (template specialization)
|
||||||
|
|
||||||
Revision 1.10 2004/09/09 08:39:33 cignoni
|
Revision 1.10 2004/09/09 08:39:33 cignoni
|
||||||
added a 'template<>' to the specialized constructors from a enum
|
added a 'template<>' to the specialized constructors from a enum
|
||||||
|
|
||||||
|
@ -108,10 +111,10 @@ public:
|
||||||
template <class Q>
|
template <class Q>
|
||||||
inline void Import(const Color4<Q> & b )
|
inline void Import(const Color4<Q> & b )
|
||||||
{
|
{
|
||||||
_v[0] = T(b[0]);
|
Point4<T>::_v[0] = T(b[0]);
|
||||||
_v[1] = T(b[1]);
|
Point4<T>::_v[1] = T(b[1]);
|
||||||
_v[2] = T(b[2]);
|
Point4<T>::_v[2] = T(b[2]);
|
||||||
_v[3] = T(b[3]);
|
Point4<T>::_v[3] = T(b[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//inline void Import(const Color4<float> &b);
|
//inline void Import(const Color4<float> &b);
|
||||||
|
@ -124,18 +127,20 @@ public:
|
||||||
|
|
||||||
inline void SetRGB( unsigned char r, unsigned char g, unsigned char b )
|
inline void SetRGB( unsigned char r, unsigned char g, unsigned char b )
|
||||||
{
|
{
|
||||||
_v[0] = r;
|
Point4<T>::_v[0] = r;
|
||||||
_v[1] = g;
|
Point4<T>::_v[1] = g;
|
||||||
_v[2] = b;
|
Point4<T>::_v[2] = b;
|
||||||
_v[3] = 0;
|
Point4<T>::_v[3] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetHSVColor( float h, float s, float v){
|
void SetHSVColor( float h, float s, float v){
|
||||||
float r,g,b;
|
float r,g,b;
|
||||||
if(s==0.0){ // gray color
|
if(s==0.0){ // gray color
|
||||||
r = g = b = v;
|
r = g = b = v;
|
||||||
_v[0]=(unsigned char)(255*r);_v[1]=(unsigned char)(255*g);_v[2]=(unsigned char)(255*b);
|
Point4<T>::_v[0]=(unsigned char)(255*r);
|
||||||
_v[3]=255;
|
Point4<T>::_v[1]=(unsigned char)(255*g);
|
||||||
|
Point4<T>::_v[2]=(unsigned char)(255*b);
|
||||||
|
Point4<T>::_v[3]=255;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(h==1.0) h = 0.0;
|
if(h==1.0) h = 0.0;
|
||||||
|
@ -155,8 +160,10 @@ public:
|
||||||
case 4: r=t; g=p; b=v; break;
|
case 4: r=t; g=p; b=v; break;
|
||||||
case 5: r=v; g=p; b=q; break;
|
case 5: r=v; g=p; b=q; break;
|
||||||
}
|
}
|
||||||
_v[0]=(unsigned char)(255*r);_v[1]=(unsigned char)(255*g);_v[2]=(unsigned char)(255*b);
|
Point4<T>::_v[0]=(unsigned char)(255*r);
|
||||||
_v[3]=255;
|
Point4<T>::_v[1]=(unsigned char)(255*g);
|
||||||
|
Point4<T>::_v[2]=(unsigned char)(255*b);
|
||||||
|
Point4<T>::_v[3]=255;
|
||||||
// _v[0]=r*256;_v[1]=g*256;_v[2]=b*256;
|
// _v[0]=r*256;_v[1]=g*256;_v[2]=b*256;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +212,10 @@ inline void Color4<T>::lerp(const Color4<T> &c0, const Color4<T> &c1, const floa
|
||||||
assert(x>=0);
|
assert(x>=0);
|
||||||
assert(x<=1);
|
assert(x<=1);
|
||||||
|
|
||||||
_v[0]=(T)(c1._v[0]*x + c0._v[0]*(1.0f-x));
|
Point4<T>::_v[0]=(T)(c1._v[0]*x + c0._v[0]*(1.0f-x));
|
||||||
_v[1]=(T)(c1._v[1]*x + c0._v[1]*(1.0f-x));
|
Point4<T>::_v[1]=(T)(c1._v[1]*x + c0._v[1]*(1.0f-x));
|
||||||
_v[2]=(T)(c1._v[2]*x + c0._v[2]*(1.0f-x));
|
Point4<T>::_v[2]=(T)(c1._v[2]*x + c0._v[2]*(1.0f-x));
|
||||||
_v[3]=(T)(c1._v[3]*x + c0._v[3]*(1.0f-x));
|
Point4<T>::_v[3]=(T)(c1._v[3]*x + c0._v[3]*(1.0f-x));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -216,10 +223,10 @@ inline void Color4<T>::lerp(const Color4<T> &c0, const Color4<T> &c1, const Colo
|
||||||
{
|
{
|
||||||
assert(fabs(ip[0]+ip[1]+ip[2]-1)<0.00001);
|
assert(fabs(ip[0]+ip[1]+ip[2]-1)<0.00001);
|
||||||
|
|
||||||
c[0]=(T)(c0.c[0]*ip[0] + c1.c[0]*ip[1]+ c2.c[0]*ip[2]);
|
Point4<T>::_v[0]=(T)(c0.c[0]*ip[0] + c1.c[0]*ip[1]+ c2.c[0]*ip[2]);
|
||||||
c[1]=(T)(c0.c[1]*ip[0] + c1.c[1]*ip[1]+ c2.c[1]*ip[2]);
|
Point4<T>::_v[1]=(T)(c0.c[1]*ip[0] + c1.c[1]*ip[1]+ c2.c[1]*ip[2]);
|
||||||
c[2]=(T)(c0.c[2]*ip[0] + c1.c[2]*ip[1]+ c2.c[2]*ip[2]);
|
Point4<T>::_v[2]=(T)(c0.c[2]*ip[0] + c1.c[2]*ip[1]+ c2.c[2]*ip[2]);
|
||||||
c[3]=(T)(c0.c[3]*ip[0] + c1.c[3]*ip[1]+ c2.c[3]*ip[2]);
|
Point4<T>::_v[3]=(T)(c0.c[3]*ip[0] + c1.c[3]*ip[1]+ c2.c[3]*ip[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,10 +257,10 @@ template <>
|
||||||
template <>
|
template <>
|
||||||
inline void Color4<float>::Import(const Color4<unsigned char> &b)
|
inline void Color4<float>::Import(const Color4<unsigned char> &b)
|
||||||
{
|
{
|
||||||
_v[0]=b[0]/255.0f;
|
this->_v[0]=b[0]/255.0f;
|
||||||
_v[1]=b[1]/255.0f;
|
this->_v[1]=b[1]/255.0f;
|
||||||
_v[2]=b[2]/255.0f;
|
this->_v[2]=b[2]/255.0f;
|
||||||
_v[3]=b[3]/255.0f;
|
this->_v[3]=b[3]/255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(__GNUC__)
|
#if !defined(__GNUC__)
|
||||||
|
@ -262,10 +269,10 @@ template <> // [Bug c++/14479] enum definition in template class with template m
|
||||||
template <>
|
template <>
|
||||||
inline void Color4<unsigned char>::Import(const Color4<float> &b)
|
inline void Color4<unsigned char>::Import(const Color4<float> &b)
|
||||||
{
|
{
|
||||||
_v[0]=(unsigned char)(b[0]*255.0f);
|
this->_v[0]=(unsigned char)(b[0]*255.0f);
|
||||||
_v[1]=(unsigned char)(b[1]*255.0f);
|
this->_v[1]=(unsigned char)(b[1]*255.0f);
|
||||||
_v[2]=(unsigned char)(b[2]*255.0f);
|
this->_v[2]=(unsigned char)(b[2]*255.0f);
|
||||||
_v[3]=(unsigned char)(b[3]*255.0f);
|
this->_v[3]=(unsigned char)(b[3]*255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.3 2004/07/15 13:22:37 cignoni
|
||||||
|
Added the standard P() access function instead of the shortcut P0()
|
||||||
|
|
||||||
Revision 1.2 2004/07/15 10:17:42 pietroni
|
Revision 1.2 2004/07/15 10:17:42 pietroni
|
||||||
correct access to point funtions call in usage of triangle3 (ex. t.P(0) in t.P0(0))
|
correct access to point funtions call in usage of triangle3 (ex. t.P(0) in t.P0(0))
|
||||||
|
|
||||||
|
@ -88,16 +91,15 @@ bool InterpolationParameters(const CoordType & bq, ScalarType &a, ScalarType &b,
|
||||||
{
|
{
|
||||||
const ScalarType EPSILON = ScalarType(0.000001);
|
const ScalarType EPSILON = ScalarType(0.000001);
|
||||||
|
|
||||||
|
#define x1 (cP0.x())
|
||||||
#define x1 (cP(0).x())
|
#define y1 (cP0.y())
|
||||||
#define y1 (cP(0).y())
|
#define z1 (cP0.z())
|
||||||
#define z1 (cP(0).z())
|
#define x2 (cP1.x())
|
||||||
#define x2 (cP(1).x())
|
#define y2 (cP1.y())
|
||||||
#define y2 (cP(1).y())
|
#define z2 (cP1.z())
|
||||||
#define z2 (cP(1).z())
|
#define x3 (cP2.x())
|
||||||
#define x3 (cP(2).x())
|
#define y3 (cP2.y())
|
||||||
#define y3 (cP(2).y())
|
#define z3 (cP2.z())
|
||||||
#define z3 (cP(2).z())
|
|
||||||
#define px (bq.x())
|
#define px (bq.x())
|
||||||
#define py (bq.y())
|
#define py (bq.y())
|
||||||
#define pz (bq.z())
|
#define pz (bq.z())
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.9 2005/03/02 15:13:45 ponchio
|
||||||
|
Minimal fix in remoteness (Bugged anyway)
|
||||||
|
|
||||||
Revision 1.8 2005/02/22 14:33:04 ponchio
|
Revision 1.8 2005/02/22 14:33:04 ponchio
|
||||||
small bugs
|
small bugs
|
||||||
|
|
||||||
|
@ -92,8 +95,8 @@ template <class T> T Frustum<T>::Resolution(float dist) {
|
||||||
|
|
||||||
template <class T> bool Frustum<T>::IsOutside(Point3<T> &point) {
|
template <class T> bool Frustum<T>::IsOutside(Point3<T> &point) {
|
||||||
Point3<T> r = Project(point);
|
Point3<T> r = Project(point);
|
||||||
if(r[0] < viewport[0] || r[0] > viewport[0]+viewport[2] ||
|
if(r[0] < View<T>::viewport[0] || r[0] > View<T>::viewport[0]+View<T>::viewport[2] ||
|
||||||
r[1] < viewport[1] || r[1] > viewport[1]+viewport[3])
|
r[1] < View<T>::viewport[1] || r[1] > View<T>::viewport[1]+View<T>::viewport[3])
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -105,18 +108,18 @@ template <class T> float Frustum<T>::Remoteness(Point3<T> &point, T radius) {
|
||||||
T rad = 1 + radius / (resolution * dist);
|
T rad = 1 + radius / (resolution * dist);
|
||||||
T mindist = 0;
|
T mindist = 0;
|
||||||
T tmp;
|
T tmp;
|
||||||
tmp = viewport[0] - r[0] - rad;
|
tmp = View<T>::viewport[0] - r[0] - rad;
|
||||||
if(tmp > mindist) mindist = tmp;
|
if(tmp > mindist) mindist = tmp;
|
||||||
tmp = r[0] - rad - (viewport[0] + viewport[2]);
|
tmp = r[0] - rad - (View<T>::viewport[0] + View<T>::viewport[2]);
|
||||||
if(tmp > mindist) mindist = tmp;
|
if(tmp > mindist) mindist = tmp;
|
||||||
|
|
||||||
tmp = viewport[1] - r[1] - rad;
|
tmp = View<T>::viewport[1] - r[1] - rad;
|
||||||
if(tmp > mindist) mindist = tmp;
|
if(tmp > mindist) mindist = tmp;
|
||||||
tmp = r[1] - rad - (viewport[1] + viewport[3]);
|
tmp = r[1] - rad - (View<T>::viewport[1] + View<T>::viewport[3]);
|
||||||
if(tmp > mindist) mindist = tmp;
|
if(tmp > mindist) mindist = tmp;
|
||||||
|
|
||||||
if(mindist == 0) return 0;
|
if(mindist == 0) return 0;
|
||||||
return 1 + (mindist / (viewport[0] + viewport[2]));
|
return 1 + (mindist / (View<T>::viewport[0] + View<T>::viewport[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool Frustum<T>::IsOutside(Point3<T> &point, T radius) {
|
template <class T> bool Frustum<T>::IsOutside(Point3<T> &point, T radius) {
|
||||||
|
@ -135,10 +138,10 @@ template <class T> T Frustum<T>::Distance(Point3<T> &point, int plane) {
|
||||||
template <class T> void Frustum<T>::GetView() {
|
template <class T> void Frustum<T>::GetView() {
|
||||||
View<T>::GetView();
|
View<T>::GetView();
|
||||||
|
|
||||||
float t = (float)(viewport[1] + viewport[3]);
|
float t = (float)(View<T>::viewport[1] +View<T>:: viewport[3]);
|
||||||
float b = (float)viewport[1];
|
float b = (float)View<T>::viewport[1];
|
||||||
float r = (float)(viewport[0] + viewport[2]);
|
float r = (float)(View<T>::viewport[0] + View<T>::viewport[2]);
|
||||||
float l = (float)viewport[0];
|
float l = (float)View<T>::viewport[0];
|
||||||
|
|
||||||
Point3<T> nw = UnProject(Point3<T>(l, b, 0.0f));
|
Point3<T> nw = UnProject(Point3<T>(l, b, 0.0f));
|
||||||
Point3<T> sw = UnProject(Point3<T>(l, t, 0.0f));
|
Point3<T> sw = UnProject(Point3<T>(l, t, 0.0f));
|
||||||
|
@ -160,7 +163,7 @@ template <class T> void Frustum<T>::GetView() {
|
||||||
|
|
||||||
//compute resolution: sizeo of a pixel unitary distance from view_point
|
//compute resolution: sizeo of a pixel unitary distance from view_point
|
||||||
resolution = ((ne + NE) - (nw + NW)).Norm() /
|
resolution = ((ne + NE) - (nw + NW)).Norm() /
|
||||||
(viewport[2] * ((ne + NE) - view_point).Norm());
|
(View<T>::viewport[2] * ((ne + NE) - view_point).Norm());
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace
|
}//namespace
|
||||||
|
|
Loading…
Reference in New Issue