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

138 lines
3.0 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TGGeCurveSegUniqueEx 类
// = Version : ver2.0
// = Author : wlw
// = CreateDate : 2002-09-09
// = Description: TGGeCurveSegUniqueEx 定义
// = Maintainers:
//
//-----------------------------------------------------------------------------+
#include "StdAfx.h"
#include "TGGeCurveSegUniqueEx.h"
#include "TPushPrec.h"
#include "TDPtrList.h"
#include "TchGlobalCurveFunc.h"
#include "TGGeCurveInline.h"
ads_real TGGeCurveSegUniqueEx::minLen = 100.0;
TDPtrList<TGGeCurveSegUniqueEx> TGGeCurveSegUniqueEx::GlobalCurveList;
TGGeCurveSegUniqueEx::TGGeCurveSegUniqueEx(TEntitySet &entLine)
: TGGeCurveSegment(entLine, LS_FINITE), segments(GetStartPoint(), GetEndPoint(), GetBulge())
{
if (GetLength() < TGGeCurveSegUniqueEx::minLen)
{
return;
}
else
{
acadEnt = entLine;
}
}
TGGeCurveSegUniqueEx::~TGGeCurveSegUniqueEx()
{
}
// 圆的相交有错误
void TGGeCurveSegUniqueEx::DivideToSegments()
{
TADSGePoint3d &ptHead = *segments.Head();
TADSGePoint3d &ptTail = *segments.Tail();
TADSGePoint3d ptNewHead = ptHead, ptNewTail = ptTail;
int bHeadOnOtherCurve = 0, bTailOnOtherCurve = 0;
for (int i = 0; i < TGGeCurveSegUniqueEx::GlobalCurveList.Length(); i++)
{
TGGeCurveSegUniqueEx *pSeg = TGGeCurveSegUniqueEx::GlobalCurveList[i];
if (this == pSeg)
{
continue;
}
TGGeCurveSegment &ln = *pSeg;
if (!ln || ln.GetLength() < TGGeCurveSegUniqueEx::minLen)
{
continue; //不是墙或墙太短
}
// 判断当前线的端点是否位于其他线上
int nPrFlagHead = ptHead & ln;
int nPrFlagTail = ptTail & ln;
if(nPrFlagHead == PR_INSIDE || nPrFlagHead == PR_ONPT1 || nPrFlagHead == PR_ONPT2)
{
bHeadOnOtherCurve = 1;
}
if(nPrFlagTail == PR_INSIDE || nPrFlagTail == PR_ONPT1 || nPrFlagTail == PR_ONPT2)
{
bTailOnOtherCurve = 1;
}
TADSGePoint3d inPt[2];
int num = 0;
{
TPushPrec tempVar(_AS_SYS_UNIT(TGGeCurveSegUniqueEx::minLen), 5.0 / 180.0 * PI); //角度精度取5度? 角度精度不合适吧 Z
num = Intersection(ln, inPt[0], inPt[1]);
}
for (int n = 0; n < num; n++)
{
int ins = 0;
if (ads_distance(ptHead,inPt[n]) < TGGeCurveSegUniqueEx::minLen)
{
if (!bHeadOnOtherCurve)
{
ptNewHead = inPt[n];
}
}
else if (ads_distance(ptTail,inPt[n]) < TGGeCurveSegUniqueEx::minLen)
{
if (!bTailOnOtherCurve)
{
ptNewTail = inPt[n];
}
}
else
{
ins = 1; //交点位于中间
}
if (ins)
{
segments.Insert(inPt[n]);
}
}
}
if (!Is(CURVE_CIRCLE))
{
if (!bHeadOnOtherCurve)
{
ptHead = ptNewHead;
}
if (!bTailOnOtherCurve)
{
ptTail = ptNewTail;
}
}
}
int TGGeCurveSegUniqueEx::Update()
{
ads_name ent;
acadEnt > ent;
return segments.Update(ent);
}
int TGGeCurveSegUniqueEx::operator !()
{
return (!acadEnt || TGGeCurveSegment::operator !());
}