209 lines
4.5 KiB
C++
209 lines
4.5 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TArcSection.cpp
|
|
// = Version : ver2.0
|
|
// = Author : xlc
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: 圆弧截面类的定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TArcSection.h"
|
|
#include "TchGlobalFunc.h"
|
|
#include "TchPrivateGlobalFunc.h"
|
|
|
|
TArcSection::TArcSection(const TGGeArc &a, ads_real ws, ads_real wh, BOOL bArc)
|
|
: TGGeArc(a), winSill(ws), winHeight(wh), m_bArcWin(bArc)
|
|
{
|
|
|
|
}
|
|
|
|
TArcSection::TArcSection(const TArcSection &src)
|
|
: TGGeArc(src), winSill(src.winSill), winHeight(src.winHeight), m_bArcWin(FALSE)
|
|
{
|
|
|
|
}
|
|
|
|
TArcSection::TArcSection():m_bArcWin(FALSE)
|
|
{
|
|
|
|
}
|
|
|
|
TArcSection::~TArcSection()
|
|
{
|
|
|
|
}
|
|
|
|
TArcSection & TArcSection::operator = (const TArcSection &src)
|
|
{
|
|
TGGeArc &ar = *this;
|
|
ar = (const TGGeArc &)src;
|
|
winSill = src.winSill;
|
|
winHeight = src.winHeight;
|
|
m_bArcWin = src.m_bArcWin;
|
|
return *this;
|
|
}
|
|
|
|
// 边界情况不正确,即洞口位于边界的时候
|
|
int TArcSection::MakeWall(TGGiExplodeDrawBase &dc, const TGGeArc &iArc, const TGGeArc &oArc,
|
|
ads_real iWidth, ads_real oWidth, ads_real height, int nDiv) const
|
|
{
|
|
if(iWidth >= GetRadius() || oWidth >= GetRadius())
|
|
{
|
|
return RTERROR;
|
|
}
|
|
|
|
ads_real intAng = fabs(Bulge());
|
|
int n = AS_INT(intAng / PI / 2.0 * nDiv);
|
|
if(n < 1)
|
|
{
|
|
n = 1;
|
|
}
|
|
ads_real ang = intAng / n;
|
|
|
|
TADSGePoint3d *ptI1 = new TADSGePoint3d[n + 1],
|
|
*ptI2 = new TADSGePoint3d[n + 1],
|
|
*ptO1 = new TADSGePoint3d[n + 1],
|
|
*ptO2 = new TADSGePoint3d[n + 1];
|
|
|
|
|
|
BOOL bOpenStart = FALSE; //起始边是否开口
|
|
BOOL bOpenEnd = FALSE; //终止边是否开口
|
|
|
|
for(int i = 0; i <= n; i++)
|
|
{
|
|
ads_real drt = AngleRangeTo2PI(GetStarAngle() + i * ang);
|
|
double iDrt = drt, oDrt = drt;
|
|
if(iArc.AngleFlag(iDrt) == PR_OUTSIDE || oArc.AngleFlag(oDrt) == PR_OUTSIDE)
|
|
{
|
|
iDrt = *((TGGeArc &)iArc).NearAngle(iDrt);
|
|
oDrt = *((TGGeArc &)oArc).NearAngle(oDrt);
|
|
if(i == 0)
|
|
{
|
|
bOpenStart = TRUE;
|
|
}
|
|
if(i == n)
|
|
{
|
|
bOpenEnd = TRUE;
|
|
}
|
|
}
|
|
|
|
ads_polar(GetCenterPt(), iDrt, GetRadius() - iWidth, ptI1[i]);
|
|
ads_polar(GetCenterPt(), oDrt, GetRadius() + oWidth, ptO1[i]);
|
|
ptI1[i].z += winSill;
|
|
ptI2[i] = ptI1[i];
|
|
ptI2[i].z += winHeight;
|
|
ptO1[i].z += winSill;
|
|
ptO2[i] = ptO1[i];
|
|
ptO2[i].z += winHeight;
|
|
}
|
|
// 显示矩形洞上下面
|
|
for( i = 0; i < 2; i++)
|
|
{
|
|
int nVertexNum = 2 * n + 2;
|
|
AcGePoint3d *ptArray = new AcGePoint3d [nVertexNum];
|
|
for(int j = 0; j < nVertexNum; j++)
|
|
{
|
|
if(i == 0)
|
|
{ //下面
|
|
if(j >= n + 1)
|
|
{
|
|
ptArray[j] = ptO1[j - n - 1];
|
|
}
|
|
else
|
|
{
|
|
ptArray[j] = ptI1[j];
|
|
}
|
|
}
|
|
else
|
|
{//上面
|
|
if(j >= n + 1)
|
|
{
|
|
ptArray[j] = ptO2[j - n - 1];
|
|
}
|
|
else
|
|
{
|
|
ptArray[j] = ptI2[j];
|
|
}
|
|
}
|
|
}
|
|
|
|
AcGiEdgeData edge;
|
|
Adesk::UInt8 *visibleData = new Adesk::UInt8[ 3 * n + 1];
|
|
|
|
for(j = 0; j < 2 * n; j++)
|
|
{
|
|
visibleData[j] = kAcGiVisible;
|
|
}
|
|
|
|
visibleData[2 * n] = visibleData[3 * n] = kAcGiVisible;
|
|
for(j = 2 * n + 1; j < 3 * n; j++)
|
|
{
|
|
visibleData[j] = kAcGiInvisible;
|
|
}
|
|
edge.setVisibility(visibleData);
|
|
dc.DrawMesh(2, n + 1, ptArray, &edge);
|
|
|
|
delete [] ptArray;
|
|
delete [] visibleData;
|
|
|
|
// 显示左右侧
|
|
AcGePoint3d ptSide[4];
|
|
if(i == 0)
|
|
{
|
|
ptSide[0] = ptI1[0];
|
|
ptSide[1] = ptI2[0];
|
|
ptSide[2] = ptO1[0];
|
|
ptSide[3] = ptO2[0];
|
|
if(!bOpenStart)
|
|
{
|
|
dc.DrawMesh(2,2,ptSide);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ptSide[0] = ptI1[n];
|
|
ptSide[1] = ptI2[n];
|
|
ptSide[2] = ptO1[n];
|
|
ptSide[3] = ptO2[n];
|
|
if(!bOpenEnd)
|
|
{
|
|
dc.DrawMesh(2,2,ptSide);
|
|
}
|
|
}
|
|
|
|
}
|
|
TGGeArc rArc[2], rArc1[2];
|
|
for(i = 0; i<2; i++)
|
|
{
|
|
rArc[i] = Offset(i ? oWidth : -iWidth);
|
|
rArc1[i] = i ? oArc : iArc;
|
|
}
|
|
|
|
if(rArc1[0].AngleFlag(rArc[0].GetStarAngle()) == PR_OUTSIDE
|
|
|| rArc1[1].AngleFlag(rArc[1].GetStarAngle()) == PR_OUTSIDE)
|
|
{
|
|
rArc[0].SetStarAngle(rArc1[0].GetStarAngle());
|
|
rArc[1].SetStarAngle(rArc1[1].GetStarAngle());
|
|
}
|
|
if(rArc1[0].AngleFlag(rArc[0].GetEndAngle()) == PR_OUTSIDE
|
|
|| rArc1[1].AngleFlag(rArc[1].GetEndAngle()) == PR_OUTSIDE)
|
|
{
|
|
rArc[0].SetEndAngle(rArc1[0].GetEndAngle());
|
|
rArc[1].SetEndAngle(rArc1[1].GetEndAngle());
|
|
}
|
|
|
|
TADSGePoint3d ptTemp;
|
|
for(i = 0; i < 2; i++)
|
|
{
|
|
DrawArcSeg(dc, rArc[i], winSill, 0, 0);
|
|
ptTemp = rArc[i].GetCenterPt();
|
|
ptTemp.z += winSill + winHeight;
|
|
rArc[i].SetCenterPt(ptTemp);
|
|
|
|
DrawArcSeg(dc, rArc[i], height - winSill - winHeight, 0, 0);
|
|
}
|
|
return RTNORM;
|
|
}
|