138 lines
2.8 KiB
C++
138 lines
2.8 KiB
C++
//-----------------------------------------------------------------------------+
|
|||
|
|
// Copyright (C), 1998-2007, SH Software Co. Ltd.
|
||
|
|
// = FileName : XCurveSegInters 类
|
||
|
|
// = Version : ver2.0
|
||
|
|
// = Author : zjq
|
||
|
|
// = CreateDate : 2002-09-09
|
||
|
|
// = Description: XCurveSegInters 定义
|
||
|
|
// = Maintainers:
|
||
|
|
//
|
||
|
|
//-----------------------------------------------------------------------------+
|
||
|
|
#include "StdAfx.h"
|
||
|
|
#include "XCurveSegInters.h"
|
||
|
|
#include "XPushPrec.h"
|
||
|
|
#include "DList.h"
|
||
|
|
#include "XGlobalCurveFunc.h"
|
||
|
|
#include "XCurveInline.h"
|
||
|
|
|
||
|
|
ads_real XCurveSegInters::minLen = 100.0;
|
||
|
|
DList<XCurveSegInters> XCurveSegInters::GlobalCurveList;
|
||
|
|
|
||
|
|
XCurveSegInters::XCurveSegInters(Entity &entLine)
|
||
|
|
: XCurveSegment(entLine, LS_FINITE), segments(GetStartPoint(), GetEndPoint(), GetBulge())
|
||
|
|
{
|
||
|
|
if (GetLength() < XCurveSegInters::minLen)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
acadEnt = entLine;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
XCurveSegInters::~XCurveSegInters()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
// 圆的相交有错误
|
||
|
|
void XCurveSegInters::DivideToSegments()
|
||
|
|
{
|
||
|
|
XPoint &ptHead = *segments.Head();
|
||
|
|
XPoint &ptTail = *segments.Tail();
|
||
|
|
XPoint ptNewHead = ptHead, ptNewTail = ptTail;
|
||
|
|
int bHeadOnOtherCurve = 0, bTailOnOtherCurve = 0;
|
||
|
|
|
||
|
|
for (int i = 0; i < XCurveSegInters::GlobalCurveList.Length(); i++)
|
||
|
|
{
|
||
|
|
|
||
|
|
XCurveSegInters *pSeg = XCurveSegInters::GlobalCurveList[i];
|
||
|
|
if (this == pSeg)
|
||
|
|
{
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
XCurveSegment &ln = *pSeg;
|
||
|
|
if (!ln || ln.GetLength() < XCurveSegInters::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;
|
||
|
|
}
|
||
|
|
|
||
|
|
XPoint inPt[2];
|
||
|
|
int num = 0;
|
||
|
|
{
|
||
|
|
XPushPrec tempVar(_AS_SYS_UNIT(XCurveSegInters::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]) < XCurveSegInters::minLen)
|
||
|
|
{
|
||
|
|
if (!bHeadOnOtherCurve)
|
||
|
|
{
|
||
|
|
ptNewHead = inPt[n];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (ads_distance(ptTail,inPt[n]) < XCurveSegInters::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 XCurveSegInters::Update()
|
||
|
|
{
|
||
|
|
ads_name ent;
|
||
|
|
acadEnt > ent;
|
||
|
|
|
||
|
|
return segments.Update(ent);
|
||
|
|
}
|
||
|
|
|
||
|
|
int XCurveSegInters::operator !()
|
||
|
|
{
|
||
|
|
return (!acadEnt || XCurveSegment::operator !());
|
||
|
|
}
|