Files
envi-code/SourceCode/Code2026/tg_shs/shs_subgeLib/TPGeDscPoint3D.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

204 lines
4.0 KiB
C++

//-------------------------------------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TPGeDscPoint3D 类
// = Version : ver2.0
// = Author : wlw
// = CreateDate : 2002-09-09
// = Description: TPGeDscPoint3D 定义
// = Maintainers:
//
//-------------------------------------------------------------------------------------------------------+
#include "StdAfx.h"
#include "TPGeDscPoint3D.h"
#include "TGPoint3D.h"
TPGeDscPoint3D::TPGeDscPoint3D(double X,double Y,double Z,double value)
: TGPoint(X,Y,Z),m_fValue(value),m_ptCount(1)
{
}
TPGeDscPoint3D::TPGeDscPoint3D(const TPGeDscPoint3D &pt)
: TGPoint(pt),m_fValue(pt.GetValue()),m_ptCount(1)
{
}
TPGeDscPoint3D::~TPGeDscPoint3D()
{
}
void TPGeDscPoint3D::SetValue(double value)
{
m_fValue = value;
}
double TPGeDscPoint3D::GetValue()const
{
return m_fValue;
}
long TPGeDscPoint3D::GetEdgeNum()const
{
return allEdge.GetLength();
}
void TPGeDscPoint3D::AppendEdge(TPGeDscEdge3D*p)
{
allEdge.AddTail(p);
}
void TPGeDscPoint3D::RemoveEdge(TPGeDscEdge3D*p)
{
allEdge.FindAndDel(p);
}
TGPoint3D* TPGeDscPoint3D::CreatePoint()
{
return new TGPoint3D(*this);
}
TPGeDscEdge3D* TPGeDscPoint3D::FindEdge(TPGeDscPoint3D*pPtTo)
{
for(allEdge.MoveToFirst();!allEdge.IsOut();allEdge.MoveToNext())
{
TPGeDscEdge3D*pEdge = allEdge.GetCurData();
if(pEdge->GetNextPoint(this) == pPtTo)
{
return pEdge;
}
}
return NULL;
}
void TPGeDscPoint3D::RemoveAllEdge()
{
for(allEdge.MoveToLast();!allEdge.IsOut();)
{
TPGeDscEdge3D*pEdge = allEdge.GetCurData();
allEdge.DelCur();
pEdge->GetNextPoint(this)->RemoveEdge(pEdge);
}
}
void TPGeDscPoint3D::GetConnectPoint(TTable<TPGeDscPoint3D*> &connectPoint)
{
for(allEdge.MoveToFirst();!allEdge.IsOut();allEdge.MoveToNext())
{
TPGeDscEdge3D*pEdge = allEdge.GetCurData();
connectPoint << pEdge->GetNextPoint(this);
}
}
TPGeDscPoint3D* TPGeDscPoint3D::GetFitPoint(double value,double vSnap)
{
if(allEdge.IsEmpty())
{
return NULL;
}
TPGeDscPoint3D *pPtFit = new TPGeDscPoint3D(x,y,z,value);
bool bUsed = false;
if(EQUAL_ZERO(m_fValue-value))
{
for(allEdge.MoveToFirst();!allEdge.IsOut();allEdge.MoveToNext())
{
TPGeDscEdge3D *pEdge = allEdge.GetCurData();
TPGeDscPoint3D *pOtherPt = pEdge->GetNextPoint(this);
if(!EQUAL_ZERO(pOtherPt->GetValue() - value))
{
if(!EQUAL_ZERO(pOtherPt->GetValue() - vSnap))
{
pEdge->pPtFit = pPtFit;
bUsed = true;
}
}
}
if(bUsed)
{
return pPtFit;
}
else
{
delete pPtFit;
return NULL;
}
}
if(EQUAL_ZERO(GetValue() - vSnap))
{
for(allEdge.MoveToFirst();!allEdge.IsOut();allEdge.MoveToNext())
{
TPGeDscEdge3D *pEdge = allEdge.GetCurData();
TPGeDscPoint3D *pOtherPt = pEdge->GetNextPoint(this);
if(!EQUAL_ZERO(pOtherPt->GetValue() - vSnap))
{
double dTotal = fabs(pOtherPt->GetValue() - GetValue());
double d1 = fabs(pOtherPt->GetValue() - value);
double d2 = fabs(GetValue() - value);
if(EQUAL_ZERO(dTotal - d1 - d2))
{
pEdge->pPtFit = pPtFit;
bUsed = true;
}
}
}
if(bUsed)
{
return pPtFit;
}
else
{
delete pPtFit;
return NULL;
}
}
return NULL;
}
TPGeDscPoint3D* TPGeDscPoint3D::FindNext(TPGeDscEdge3D*&pEdge)
{
allEdge.FindTo(pEdge);
long oldCur = allEdge.GetCur();
allEdge.MoveToNext();
if(allEdge.IsOut())
{
allEdge.MoveToFirst();
}
pEdge = allEdge.GetCurData();
if(pEdge->Is(VISITED))
{
if(allEdge.GetLength() > 2)
{
allEdge.MoveTo(oldCur);
allEdge.MoveToPre();
if(allEdge.IsOut())
{
allEdge.MoveToLast();
}
pEdge = allEdge.GetCurData();
if(pEdge->IsNot(VISITED))
{
pEdge->AddFlag(VISITED);
return pEdge->GetNextPoint(this);
}
}
return NULL;
}
else
{
pEdge->AddFlag(VISITED);
return pEdge->GetNextPoint(this);
}
}
void TPGeDscPoint3D::AppendValue(double value)
{
double total = m_ptCount * GetValue() + value;
m_ptCount++;
SetValue(total / m_ptCount);
}