95 lines
2.2 KiB
C++
95 lines
2.2 KiB
C++
//-------------------------------------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TPGeFitTriangle 类
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TPGeFitTriangle 定义
|
|
// = Maintainers:
|
|
//
|
|
//-------------------------------------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TPGeFitTriangle.h"
|
|
#include "TGTriangle2D.h"
|
|
|
|
TPGeFitTriangle::TPGeFitTriangle(TPGeDscEdge*p0,TPGeDscEdge*p1,TPGeDscEdge*p2)
|
|
: pEdge0(p0),pEdge1(p1),pEdge2(p2)
|
|
{
|
|
|
|
}
|
|
|
|
TPGeFitTriangle::~TPGeFitTriangle()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
bool TPGeFitTriangle::operator >(const TPGeFitTriangle&) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool TPGeFitTriangle::operator <(const TPGeFitTriangle&) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool TPGeFitTriangle::IsParentTriangle()
|
|
{
|
|
TGTriangle2D*pTrg2D = CreateTriangle();
|
|
TList<TPGeDscPoint*> otherPoint;
|
|
|
|
TPGeDscPoint *pPt0 = pEdge0->pPt0;
|
|
pPt0->GetConnectPoint(otherPoint);
|
|
|
|
for(otherPoint.MoveToFirst();!otherPoint.IsOut();otherPoint.MoveToNext())
|
|
{
|
|
GRelation r = pTrg2D->HitTest(*(otherPoint.GetCurData()));
|
|
if(r.Is(GR_IN) && r.IsNot(GR_EDGE))
|
|
{
|
|
delete pTrg2D;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
delete pTrg2D;
|
|
return false;
|
|
}
|
|
|
|
TGTriangle2D* TPGeFitTriangle::CreateTriangle()
|
|
{
|
|
TPGeDscPoint* pPt0 = pEdge0->pPt0, *pPt1 = pEdge0->pPt1,*pPt2;
|
|
if(pEdge1->pPt0 == pPt0 || pEdge1->pPt0 == pPt1)
|
|
{
|
|
pPt2 = pEdge1->pPt1;
|
|
}
|
|
else
|
|
{
|
|
pPt2 = pEdge1->pPt1;
|
|
}
|
|
return new TGTriangle2D(*pPt0,*pPt1,*pPt2);
|
|
}
|
|
|
|
void TPGeFitTriangle::GetFitEdge(double z,TPDList<TPGeDscEdge>&res)
|
|
{
|
|
if(UPEQUAL_ZERO(pEdge0->GetMinZ() - z) &&
|
|
UPEQUAL_ZERO(pEdge1->GetMinZ() - z) &&
|
|
UPEQUAL_ZERO(pEdge2->GetMinZ() - z))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(pEdge0->pPtFit != NULL && pEdge1->pPtFit != NULL && pEdge0->pPtFit != pEdge1->pPtFit)
|
|
{
|
|
res << new TPGeDscEdge(pEdge0->pPtFit,pEdge1->pPtFit);
|
|
}
|
|
else if(pEdge1->pPtFit != NULL && pEdge2->pPtFit != NULL && pEdge1->pPtFit != pEdge2->pPtFit)
|
|
{
|
|
res << new TPGeDscEdge(pEdge1->pPtFit,pEdge2->pPtFit);
|
|
}
|
|
else if(pEdge2->pPtFit != NULL && pEdge0->pPtFit != NULL && pEdge2->pPtFit != pEdge0->pPtFit)
|
|
{
|
|
res << new TPGeDscEdge(pEdge2->pPtFit,pEdge0->pPtFit);
|
|
}
|
|
}
|