Clear some useless code
This commit is contained in:
parent
63f09aa04b
commit
73985fe506
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.14 2006/11/07 15:13:56 zifnab1974
|
||||
Necessary changes for compilation with gcc 3.4.6. Especially the hash function is a problem
|
||||
|
||||
Revision 1.13 2006/11/07 11:47:11 cignoni
|
||||
gcc compiling issues
|
||||
|
||||
|
@ -1131,189 +1134,6 @@ namespace vcg {
|
|||
(*fi).ClearUserBit(UBIT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Trivial Ear con preferred Normal
|
||||
*/
|
||||
template<class MSH_TYPE> class TrivialEarN : public TrivialEar<MSH_TYPE>
|
||||
{
|
||||
public:
|
||||
|
||||
using TrivialEar<MSH_TYPE>::e0;
|
||||
using TrivialEar<MSH_TYPE>::e1;
|
||||
using TrivialEar<MSH_TYPE>::quality;
|
||||
TrivialEarN(){}
|
||||
TrivialEarN(const face::Pos<typename MSH_TYPE::FaceType> & ep)
|
||||
{
|
||||
this->e0=ep;
|
||||
assert(this->e0.IsBorder());
|
||||
this->e1=this->e0;
|
||||
this->e1.NextB();
|
||||
ComputeQuality();
|
||||
}
|
||||
|
||||
|
||||
static typename MSH_TYPE::VertexType &PreferredNormal()
|
||||
{
|
||||
static typename MSH_TYPE::VertexType nn;
|
||||
return nn;
|
||||
}
|
||||
|
||||
void ComputeQuality(){
|
||||
Point3d nn= -Normal( this->e0.VFlip()->P(), this->e0.v->P(), this->e1.v->P());
|
||||
this->quality = Distance(this->e0.VFlip()->P(),this->e1.v->P());
|
||||
if(nn*PreferredNormal() < -0.1)
|
||||
this->quality*=1000000;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/* 2d Triangulation Code */
|
||||
class Triangulate2D
|
||||
{
|
||||
|
||||
static double Area(const std::vector<Point2d> &contour)
|
||||
{
|
||||
int n = contour.size();
|
||||
|
||||
double A=0.0f;
|
||||
|
||||
for(int p=n-1,q=0; q<n; p=q++) {
|
||||
A+= contour[p].X()*contour[q].Y() - contour[q].X()*contour[p].Y();
|
||||
}
|
||||
return A*0.5f;
|
||||
}
|
||||
|
||||
/*
|
||||
InsideTriangle decides if a point P is Inside of the triangle
|
||||
defined by A, B, C.
|
||||
*/
|
||||
static bool InsideTriangle(double Ax, double Ay,
|
||||
double Bx, double By,
|
||||
double Cx, double Cy,
|
||||
double Px, double Py)
|
||||
|
||||
{
|
||||
double ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
|
||||
double cCROSSap, bCROSScp, aCROSSbp;
|
||||
|
||||
ax = Cx - Bx; ay = Cy - By;
|
||||
bx = Ax - Cx; by = Ay - Cy;
|
||||
cx = Bx - Ax; cy = By - Ay;
|
||||
apx= Px - Ax; apy= Py - Ay;
|
||||
bpx= Px - Bx; bpy= Py - By;
|
||||
cpx= Px - Cx; cpy= Py - Cy;
|
||||
|
||||
aCROSSbp = ax*bpy - ay*bpx;
|
||||
cCROSSap = cx*apy - cy*apx;
|
||||
bCROSScp = bx*cpy - by*cpx;
|
||||
|
||||
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
|
||||
};
|
||||
|
||||
static bool Snip(const std::vector<Point2d> &contour,int u,int v,int w,int n,int *V)
|
||||
{
|
||||
int p;
|
||||
double Ax, Ay, Bx, By, Cx, Cy, Px, Py;
|
||||
const double epsilon =1e-2;
|
||||
|
||||
Ax = contour[V[u]].X();
|
||||
Ay = contour[V[u]].Y();
|
||||
|
||||
Bx = contour[V[v]].X();
|
||||
By = contour[V[v]].Y();
|
||||
|
||||
Cx = contour[V[w]].X();
|
||||
Cy = contour[V[w]].Y();
|
||||
|
||||
if ( epsilon> (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) ) return false;
|
||||
|
||||
for (p=0;p<n;p++)
|
||||
{
|
||||
if( (p == u) || (p == v) || (p == w) ) continue;
|
||||
Px = contour[V[p]].X();
|
||||
Py = contour[V[p]].Y();
|
||||
if (InsideTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
static bool Process(const std::vector<Point2d> &contour,std::vector<int> &result)
|
||||
{
|
||||
/* allocate and initialize list of Vertices in polygon */
|
||||
|
||||
int n = contour.size();
|
||||
double area=Area(contour);
|
||||
if ( n < 3 ) return false;
|
||||
|
||||
int *V = new int[n];
|
||||
|
||||
/* we want a counter-clockwise polygon in V */
|
||||
|
||||
if ( 0.0f < area ) for (int v=0; v<n; v++) V[v] = v;
|
||||
else{
|
||||
for(int v=0; v<n; v++) V[v] = (n-1)-v;
|
||||
area=-area;
|
||||
}
|
||||
|
||||
|
||||
int nv = n;
|
||||
|
||||
/* remove nv-2 Vertices, creating 1 triangle every time */
|
||||
int count = 2*nv; /* error detection */
|
||||
|
||||
double CurrBest= sqrt(area)/1000;
|
||||
|
||||
for(int m=0, v=nv-1; nv>2; )
|
||||
{
|
||||
count--;
|
||||
/* if we loop, it is probably a non-simple polygon */
|
||||
if( count<0)
|
||||
{
|
||||
CurrBest*=1.3;
|
||||
count = 2*nv;
|
||||
|
||||
if(CurrBest > sqrt(area)*2)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* three consecutive vertices in current polygon, <u,v,w> */
|
||||
int u = v ; if (nv <= u) u = 0; /* previous */
|
||||
v = u+1; if (nv <= v) v = 0; /* new v */
|
||||
int w = v+1; if (nv <= w) w = 0; /* next */
|
||||
|
||||
if(Distance(contour[u],contour[w]) < CurrBest)
|
||||
if ( Snip(contour,u,v,w,nv,V) )
|
||||
{
|
||||
int a,b,c,s,t;
|
||||
|
||||
/* true names of the vertices */
|
||||
a = V[u]; b = V[v]; c = V[w];
|
||||
|
||||
/* output Triangle */
|
||||
result.push_back( a );
|
||||
result.push_back( b );
|
||||
result.push_back( c );
|
||||
|
||||
m++;
|
||||
|
||||
/* remove v from remaining polygon */
|
||||
for(s=v,t=v+1;t<nv;s++,t++) V[s] = V[t];
|
||||
nv--;
|
||||
|
||||
/* resest error detection counter */
|
||||
count = 2*nv;
|
||||
}
|
||||
}
|
||||
|
||||
delete V;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
} // end namespace
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue