185 lines
3.5 KiB
C++
185 lines
3.5 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TADSGePointList 点列表类
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TADSGePointList 类定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TADSGePointList.h"
|
|
#include "TchPrivateGlobalFunc.h"
|
|
|
|
using namespace TchPrivate;
|
|
TADSGePointList::TADSGePointList()
|
|
{
|
|
|
|
}
|
|
|
|
TADSGePointList::TADSGePointList(const TADSGePointList &src)
|
|
{
|
|
*this = src;
|
|
}
|
|
|
|
TADSGePointList::~TADSGePointList()
|
|
{
|
|
|
|
}
|
|
|
|
TADSGePointList &TADSGePointList::operator = (const TADSGePointList &src)
|
|
{
|
|
Reset();
|
|
|
|
for (int i = 0; i < src.Length(); i++)
|
|
{
|
|
Append(new TADSGePoint3d(src[i]));
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
void TADSGePointList::TransUCS(const resbuf *pFrom, const resbuf *pTo)
|
|
{
|
|
int nLen = Length();
|
|
for (int i = 0; i < nLen; i++)
|
|
{
|
|
TADSGePoint3d pt = *(*this)[i];
|
|
ads_trans(pt, pFrom, pTo, 0, *(*this)[i]);
|
|
}
|
|
}
|
|
|
|
void TADSGePointList::TransUCS(ads_matrix mat)
|
|
{
|
|
int nLen = Length();
|
|
for (int i = 0; i < nLen; i++)
|
|
{
|
|
TADSGePoint3d pt = *(*this)[i];
|
|
PointTransformBy(mat, pt, *(*this)[i]);
|
|
}
|
|
}
|
|
|
|
int TADSGePointList::GetExtend(ads_point ptMin, ads_point ptMax)
|
|
{
|
|
if (!(*this))
|
|
{
|
|
return RTNONE;
|
|
}
|
|
|
|
TADSGePoint3d ptLow, ptUp;
|
|
TADSGePointList &lstPoints = *this;
|
|
ptLow = ptUp = *lstPoints[0];
|
|
|
|
for (int i = 1; i < lstPoints.Length(); i++)
|
|
{
|
|
TADSGePoint3d &ptCur = *lstPoints[i];
|
|
ptLow = Min(ptLow, ptCur);
|
|
ptUp = Max(ptUp, ptCur);
|
|
}
|
|
|
|
*(TADSGePoint3d *)ptMin = ptLow;
|
|
*(TADSGePoint3d *)ptMax = ptUp;
|
|
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
int TADSGePointList::GetExtend(ads_point ptMin, ads_point ptMax) const
|
|
{
|
|
if (!(*this))
|
|
{
|
|
return RTNONE;
|
|
}
|
|
|
|
TADSGePoint3d ptLow, ptUp;
|
|
const TADSGePointList &lstPoints = *this;
|
|
|
|
//ptLow = ptUp = *lstPoints[0];
|
|
ptLow = ptUp = lstPoints[0];
|
|
|
|
for (int i = 1; i < lstPoints.Length(); i++)
|
|
{
|
|
//const TADSGePoint3d &ptCur = *lstPoints[i];
|
|
const TADSGePoint3d &ptCur = lstPoints[i];
|
|
|
|
ptLow = Min(ptLow, ptCur);
|
|
ptUp = Max(ptUp, ptCur);
|
|
}
|
|
|
|
*(TADSGePoint3d *)ptMin = ptLow;
|
|
*(TADSGePoint3d *)ptMax = ptUp;
|
|
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
TADSGePoint3d* TADSGePointList::FindPoint(const TADSGePoint3d &ptSrc)
|
|
{
|
|
TADSGePointList &lstPoints = *this;
|
|
for (int i = 0; i < lstPoints.Length(); i++)
|
|
{
|
|
TADSGePoint3d &ptCur = *lstPoints[i];
|
|
if(ptCur == ptSrc)
|
|
{
|
|
return &ptCur;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void TADSGePointList::AppendNode(const TADSGePoint3d &pt, ads_real dBulge, AcDb::Visibility eVal)
|
|
{
|
|
Append(new TADSGePoint3d(pt));
|
|
}
|
|
|
|
void TADSGePointList::AsPoly2D(TADSGePointList &poly) const
|
|
{
|
|
for (int n = 0; n < Length(); n++)
|
|
{
|
|
poly.AppendNode((*this)[n]);
|
|
}
|
|
}
|
|
|
|
void TADSGePointList::Center(ads_point ptCen)
|
|
{
|
|
ads_real dTotalX = 0.0, dTotalY = 0.0, dTotalZ = 0.0;
|
|
|
|
int nLen = Length();
|
|
for (int i = 0; i < nLen; i++)
|
|
{
|
|
dTotalX += (*this)[i]->x;
|
|
dTotalY += (*this)[i]->y;
|
|
dTotalZ += (*this)[i]->z;
|
|
}
|
|
|
|
ptCen[X] = dTotalX / nLen;
|
|
ptCen[Y] = dTotalY / nLen;
|
|
ptCen[Z] = dTotalZ / nLen;
|
|
}
|
|
|
|
void TADSGePointList::SetElevation(ads_real dElev)
|
|
{
|
|
int nLen = Length();
|
|
for (int i = 0; i < nLen; i++)
|
|
{
|
|
(*this)[i]->z = dElev;
|
|
}
|
|
}
|
|
|
|
int TADSGePointList::NewAppend(const TADSGePoint3d &ptSrc)
|
|
{
|
|
int nPos;
|
|
if (!FindPoint(ptSrc))
|
|
{
|
|
Append(new TADSGePoint3d(ptSrc));
|
|
nPos = Length() - 1;
|
|
}
|
|
else
|
|
{
|
|
nPos = CurPosition();
|
|
}
|
|
|
|
return nPos;
|
|
} |