25 #if GEOM_PSEUDO3D==GEOM_TRUE
26 namespace GEOM_FADE25D {
27 #elif GEOM_PSEUDO3D==GEOM_FALSE
28 namespace GEOM_FADE2D {
30 #error GEOM_PSEUDO3D is not defined
64 aVertexPointer[0]=NULL;
65 aVertexPointer[1]=NULL;
66 aVertexPointer[2]=NULL;
67 aOppTriangles[0]=NULL;
68 aOppTriangles[1]=NULL;
69 aOppTriangles[2]=NULL;
83 Point2* getCorner(
const int idx)
const;
96 std::pair<Point2,bool> getDual(
bool bForceExact=
false)
const;
136 #if GEOM_PSEUDO3D==GEOM_TRUE
144 Vector2 getNormalVector()
const;
162 #if GEOM_PSEUDO3D==GEOM_TRUE
170 double getInteriorAngle25D(
int idx)
const;
187 #if GEOM_PSEUDO3D==GEOM_TRUE
195 double getArea25D()
const;
209 Triangle2* getOppositeTriangle(
const int idx)
const;
224 int getIntraTriangleIndex(
const Point2* pCorner)
const;
238 int getIntraTriangleIndex(
const Triangle2* pNeig)
const;
254 int getIntraTriangleIndex(
const Point2* p0,
const Point2* p1)
const;
271 double getSquaredEdgeLength(
int idx)
const;
273 #if GEOM_PSEUDO3D==GEOM_TRUE
282 double getSquaredEdgeLength25D(
int idx)
const;
289 void setOppTriangle(
const int idx,
Triangle2* pTriangle);
299 void clearProperties();
311 void setVertexPointer(
const int idx,
Point2* pVtx);
385 void getCommonOffset(
double& x,
double& y)
const;
398 friend inline void registerTriangles(
Triangle2* fromTriangle,
int ith,
Triangle2* toTriangle,
int jth);
402 double computeArea(
double l0,
double l1,
double l2)
const;
404 bool getCC_inexact(
double avgOffX,
double avgOffY,
Point2& cc)
const;
406 Point2* aVertexPointer[3];
414 inline bool checkRange(
int ith)
416 return (ith==0 || ith==1 || ith==2);
420 inline Triangle2* Triangle2::getOppositeTriangle(
const int ith)
const
422 assert(checkRange(ith));
423 return aOppTriangles[ith];
426 inline void Triangle2::setOppTriangle(
const int ith,
Triangle2* pNeig)
428 assert(checkRange(ith));
429 aOppTriangles[ith]=pNeig;
433 inline int Triangle2::getIntraTriangleIndex(
const Point2* p0,
const Point2* p1)
const
439 if( (aVertexPointer[ici1]==p0 && aVertexPointer[ici2]==p1) ||
440 (aVertexPointer[ici1]==p1 && aVertexPointer[ici2]==p0) )
return i;
443 GCOUT<<
"BUG: Triangle2::getIntraTriangleIndex failed for"<<std::endl;
444 GCOUT<<*p0<<std::endl;
445 GCOUT<<*p1<<std::endl;
446 GCOUT<<*
this<<std::endl;
451 inline int Triangle2::getIntraTriangleIndex(
const Point2* pVtx)
const
456 if(aVertexPointer[i]==pVtx)
463 return ( (aVertexPointer[1]==pVtx) + 2*(aVertexPointer[2]==pVtx));
467 inline int Triangle2::getIntraTriangleIndex(
const Triangle2* pTriangle)
const
473 if(aOppTriangles[i]==pTriangle)
480 return ( (aOppTriangles[1]==pTriangle) + 2*(aOppTriangles[2]==pTriangle));
485 inline Point2* Triangle2::getCorner(
const int ith)
const
487 assert(checkRange(ith));
488 return aVertexPointer[ith];
493 p0=aVertexPointer[0];
494 p1=aVertexPointer[1];
495 p2=aVertexPointer[2];
498 inline void Triangle2::setVertexPointer(
const int ith,
Point2* pp)
500 aVertexPointer[ith]=pp;
505 assert((pI!=NULL && pJ!=NULL && pK!=NULL));
506 aVertexPointer[0]=pI;
507 aVertexPointer[1]=pJ;
508 aVertexPointer[2]=pK;
509 pI->setIncidentTriangle(
this);
510 pJ->setIncidentTriangle(
this);
511 pK->setIncidentTriangle(
this);
512 aOppTriangles[0]=NULL;
513 aOppTriangles[1]=NULL;
514 aOppTriangles[2]=NULL;
517 inline void Triangle2::clearProperties()
521 aVertexPointer[i]=NULL;
522 aOppTriangles[i]=NULL;
526 inline void Triangle2::setPropertiesAndOppT(
527 Point2* pI, Point2* pJ, Point2* pK,
528 Triangle2* pNeig0,Triangle2* pNeig1,Triangle2* pNeig2
531 assert((pI!=NULL && pJ!=NULL && pK!=NULL));
532 aVertexPointer[0]=pI;
533 aVertexPointer[1]=pJ;
534 aVertexPointer[2]=pK;
535 pI->setIncidentTriangle(
this);
536 pJ->setIncidentTriangle(
this);
537 pK->setIncidentTriangle(
this);
538 aOppTriangles[0]=pNeig0;
539 aOppTriangles[1]=pNeig1;
540 aOppTriangles[2]=pNeig2;
544 inline void registerTriangles(Triangle2* pFromT,
int ith,Triangle2* pToT,
int jth)
546 assert(checkRange(ith));
547 assert(checkRange(jth));
549 pFromT->aOppTriangles[ith]=pToT;
550 pToT->aOppTriangles[jth]=pFromT;
CircumcenterQuality
Enumeration for the quality of the circumcenter computation.
Definition: Triangle2.h:35
@ CCQ_INEXACT
Double precision computation, the result is accurate enough.
Definition: Triangle2.h:37
@ CCQ_OUT_OF_BOUNDS
Computation with multiple-precision arithmetic, but the result is not representable with double preci...
Definition: Triangle2.h:39
@ CCQ_INIT
Init value.
Definition: Triangle2.h:36
@ CCQ_EXACT
Computation with multiple-precision arithmetic, the result is exact (apart from tiny quantization err...
Definition: Triangle2.h:38
Represents a 2D point.
Definition: Point2.h:61
Represents a triangle in a triangulation.
Definition: Triangle2.h:59
Point2 getCircumcenter(CircumcenterQuality &ccq, bool bForceExact=false) const
Get the circumcenter of the triangle.
double getSquaredEdgeLength2D(int idx) const
Get the squared 2D length of the specified edge.
CLASS_DECLSPEC friend std::ostream & operator<<(std::ostream &stream, const Triangle2 &c)
Output operator for Triangle2.
bool hasVertex(const Point2 *pVtx) const
Check if the specified vertex is a corner of the triangle.
bool hasOn(const Point2 &q) const
Check if the triangle includes the specified point.
double getInteriorAngle2D(int idx) const
Get interior 2D angle.
bool hasVertex(const Point2 &q) const
Check if the specified point coincides with a corner of the triangle.
double getArea2D() const
Get the 2D area of the triangle.
int getMinIndex() const
Get the index of the smallest edge.
Triangle2()
Default constructor.
Definition: Triangle2.h:62
int getMaxIndex() const
Get the index of the largest edge.
bool hasOnEdge(int idx, const Point2 &q) const
Check if an edge includes the specified point.
Point2 getBarycenter() const
Get the barycenter of the triangle.
double getMaxSqEdgeLen2D() const
Get the maximum squared 2D edge length.
Vector.
Definition: Vector2.h:47