115 lines
2.1 KiB
C++
115 lines
2.1 KiB
C++
//-------------------------------------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TPGeDscEdge3D Àà
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TPGeDscEdge3D ¶¨Òå
|
|
// = Maintainers:
|
|
//
|
|
//-------------------------------------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TPGeDscEdge3D.h"
|
|
#include "TPGeDscPoint3D.h"
|
|
|
|
TPGeDscEdge3D::TPGeDscEdge3D(TPGeDscPoint3D *p0, TPGeDscPoint3D *p1)
|
|
: pPt0(p0),pPt1(p1),pPtFit(NULL)
|
|
{
|
|
pPt0->AppendEdge(this);
|
|
pPt1->AppendEdge(this);
|
|
}
|
|
|
|
TPGeDscEdge3D::~TPGeDscEdge3D()
|
|
{
|
|
|
|
}
|
|
|
|
TPGeDscPoint3D* TPGeDscEdge3D::GetNextPoint(TPGeDscPoint3D*pPt) const
|
|
{
|
|
return pPt0 == pPt?pPt1:pPt0;
|
|
}
|
|
|
|
double TPGeDscEdge3D::GetMinValue()
|
|
{
|
|
return Min2(pPt0->GetValue(),pPt1->GetValue());
|
|
}
|
|
|
|
bool TPGeDscEdge3D::operator > (const TPGeDscEdge&e) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool TPGeDscEdge3D::operator < (const TPGeDscEdge&e) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void TPGeDscEdge3D::ConnectPath(TPGeFitPath3D&path)
|
|
{
|
|
AddFlag(VISITED);
|
|
path << pPt0 << pPt1;
|
|
TPGeDscPoint3D*pPtFrom = pPt1;
|
|
TPGeDscEdge3D *pEdge = this;
|
|
while(true)
|
|
{
|
|
TPGeDscPoint3D*pPt = pPtFrom->FindNext(pEdge);
|
|
if(pPt != NULL)
|
|
{
|
|
if(pPt == pPt0)
|
|
{
|
|
path.SetClosed();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
path << pPt;
|
|
pPtFrom = pPt;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
pPtFrom = pPt0;
|
|
pEdge = this;
|
|
while(true)
|
|
{
|
|
TPGeDscPoint3D*pPt = pPtFrom->FindNext(pEdge);
|
|
if(pPt != NULL)
|
|
{
|
|
path.InsertHead(pPt);
|
|
pPtFrom = pPt;
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
TPGeDscPoint3D* TPGeDscEdge3D::GetFitPoint(double value)
|
|
{
|
|
double dv = pPt1->GetValue() - pPt0->GetValue();
|
|
if(EQUAL_ZERO(dv))
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
if(pPtFit != NULL)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
double s = (value - pPt0->GetValue()) / dv;
|
|
if(DOWN_ZERO(s) || UP_ZERO(s - 1))
|
|
{
|
|
return pPtFit = NULL;
|
|
}
|
|
|
|
double dx = pPt1->x-pPt0->x;
|
|
double dy = pPt1->y-pPt0->y;
|
|
double dz = pPt1->z-pPt0->z;
|
|
|
|
return pPtFit = new TPGeDscPoint3D(pPt0->x + s * dx, pPt0->y + s * dy, pPt0->z + s * dz, value);
|
|
} |