1370 lines
29 KiB
C++
1370 lines
29 KiB
C++
#include "stdafx.h"
|
|
#ifdef TASD
|
|
#include "TDbStruReinBar.h"
|
|
|
|
const Adesk::UInt8 TDbStruReinBar::g_nVersion = 1;
|
|
|
|
IMPLEMENT_TENTBASE(TDbStruReinBar);
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSStruReinBar, ATSStruEntityBase, AcDb::kDHL_CURRENT,
|
|
AcDb::kMReleaseCurrent, 1, ATS_STRUREINBAR,
|
|
"ATS_STRUREINBAR图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
|
|
TDbStruReinBar::TDbStruReinBar()
|
|
{
|
|
TDbStruEntityBase::SetAt(KEY_KIND, (int)TDbStruReinBar::kNormal);
|
|
SetStartHook(TStruHookInfo::kNone, 1);
|
|
SetEndHook(TStruHookInfo::kNone, 2);
|
|
m_dWidth = g_dReinbarWidth;
|
|
m_dLengthS = g_dReinbarLenS;
|
|
m_dLengthO = g_dReinbarLenO;
|
|
m_dLengthB = g_dReinbarLenB;
|
|
m_dDiaB = g_dReinbarDiaB;
|
|
}
|
|
|
|
TDbStruReinBar::~TDbStruReinBar()
|
|
{
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es;
|
|
es = TDbStruEntityBase::dwgInFields(pFiler);
|
|
if (Acad::eOk != es)
|
|
{
|
|
return es;
|
|
}
|
|
Adesk::UInt8 nVer;
|
|
pFiler->readItem(&nVer);
|
|
if(nVer>g_nVersion)
|
|
{
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
pFiler->readItem(&m_dWidth);
|
|
pFiler->readItem(&m_dLengthS);
|
|
pFiler->readItem(&m_dLengthO);
|
|
pFiler->readItem(&m_dLengthB);
|
|
pFiler->readItem(&m_dDiaB);
|
|
ReadPoly2D(pFiler, m_polyOutline);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es;
|
|
es = TDbStruEntityBase::dwgOutFields(pFiler);
|
|
if (Acad::eOk != es)
|
|
{
|
|
return es;
|
|
}
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeItem(m_dWidth);
|
|
pFiler->writeItem(m_dLengthS);
|
|
pFiler->writeItem(m_dLengthO);
|
|
pFiler->writeItem(m_dLengthB);
|
|
pFiler->writeItem(m_dDiaB);
|
|
WritePoly2D(pFiler, m_polyOutline);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
return TDbStruEntityBase::dxfInFields(pFiler);
|
|
}
|
|
Acad::ErrorStatus TDbStruReinBar::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
return TDbStruEntityBase::dxfOutFields(pFiler);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::GetGripText(int i, CString &cs) const
|
|
{
|
|
if (i >= 0 &&
|
|
i <= m_polyOutline.Length()-1)
|
|
{
|
|
cs = _T("移动钢筋对象或移动该路径点");
|
|
}
|
|
else
|
|
{
|
|
cs = _T("更改钩子方向");
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::ExplodeOrDraw2d(TGGiExplodeDrawBase &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
// 钢筋类别-点钢筋
|
|
EType type;
|
|
if (TDbStruEntityBase::GetAt(KEY_KIND, (int&)type) &&
|
|
type == kDot)
|
|
{
|
|
if (m_polyOutline.Length() >=1 )
|
|
{
|
|
AcGePoint3d ptCenter = m_polyOutline.GetPointListAt(0);
|
|
AcGePoint3d ptSolid1(ptCenter[X]-m_dWidth/2, ptCenter[Y], 0);
|
|
AcGePoint3d ptSolid2(ptCenter[X]+m_dWidth/2, ptCenter[Y], 0);
|
|
TGGePoly2D poly, polyDisperse;
|
|
poly.InsertNodeAt(0, ptSolid1, PI);
|
|
poly.InsertNodeAt(1, ptSolid2, PI);
|
|
poly.InsertNodeAt(2, ptSolid1);
|
|
poly.SetClosed();
|
|
poly.Disperse(polyDisperse);
|
|
dc << TGGeSolid(polyDisperse);
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 钢筋类别-普通钢筋
|
|
// 钢筋
|
|
AcDbPolyline plBar;
|
|
for (int i=0; i<m_polyOutline.Length(); i++)
|
|
{
|
|
plBar.addVertexAt(i, m_polyOutline.GetPointListAt(i),
|
|
tan(m_polyOutline.GetBulge(i)/4), m_dWidth, m_dWidth);
|
|
}
|
|
|
|
// 起始端钩子
|
|
AcDbPolyline plHook;
|
|
TStruHookInfo hook;
|
|
BOOL bRet;
|
|
double dBulge = 0;
|
|
bool bBent = false;
|
|
bRet = GetAt(KEY_HOOKS, hook);
|
|
if (bRet &&
|
|
GetHookOutLine(hook, plHook))
|
|
{
|
|
if (hook.eType == TStruHookInfo::kBent)
|
|
{
|
|
bBent = true;
|
|
}
|
|
AcGePoint3d ptTemp;
|
|
for (UINT j=1; j<plHook.numVerts(); j++)
|
|
{
|
|
plHook.getPointAt(j, ptTemp);
|
|
if(j==1 && bBent)
|
|
{
|
|
if (hook.nQuadrant == 1 || hook.nQuadrant ==3)
|
|
{
|
|
dBulge = PI*0.25;
|
|
}
|
|
else
|
|
{
|
|
dBulge = -PI*0.25;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dBulge = 0;
|
|
}
|
|
plBar.addVertexAt(0, AcGePoint2d(ptTemp[X], ptTemp[Y]),
|
|
dBulge, m_dWidth, m_dWidth);
|
|
}
|
|
}
|
|
|
|
// 终止端钩子
|
|
bRet = GetAt(KEY_HOOKE, hook);
|
|
if (bRet &&
|
|
GetHookOutLine(hook, plHook))
|
|
{
|
|
AcGePoint3d ptTemp;
|
|
|
|
// 修改路径最后一个点的凸度
|
|
if (hook.eType == TStruHookInfo::kBent)
|
|
{
|
|
if (hook.nQuadrant == 1 || hook.nQuadrant ==3)
|
|
{
|
|
dBulge = -PI*0.25;
|
|
}
|
|
else
|
|
{
|
|
dBulge = PI*0.25;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dBulge = 0;
|
|
}
|
|
plBar.setBulgeAt(plBar.numVerts()-1, dBulge);
|
|
|
|
for (UINT j=1; j<plHook.numVerts(); j++)
|
|
{
|
|
plHook.getPointAt(j, ptTemp);
|
|
plBar.addVertexAt(plBar.numVerts(), AcGePoint2d(ptTemp[X], ptTemp[Y]),
|
|
0, m_dWidth, m_dWidth);
|
|
}
|
|
}
|
|
dc.DrawEntity(plBar);
|
|
|
|
// 中间钩子
|
|
CArray<TStruHookInfo, TStruHookInfo&> arHooks;
|
|
if (GetAt(KEY_HOOK, arHooks))
|
|
{
|
|
for (int j=0; j<arHooks.GetSize(); j++)
|
|
{
|
|
GetHookOutLine(arHooks[j], plHook);
|
|
dc.DrawEntity(plHook);
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::ExplodeOrDraw3d(TGGiExplodeDrawBase &dc) const
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
// 钢筋路径
|
|
m_polyOutline.TransformBy(xform);
|
|
|
|
EType eType;
|
|
if (TDbStruEntityBase::GetAt(KEY_KIND, (int&)eType) &&
|
|
eType == kNormal)
|
|
{
|
|
// 起始端钩子
|
|
TStruHookInfo hook;
|
|
if (GetAt(KEY_HOOKS, hook))
|
|
{
|
|
hook.ptPos.transformBy(xform);
|
|
SetAt(KEY_HOOKS, hook);
|
|
}
|
|
|
|
// 终止端钩子
|
|
if (GetAt(KEY_HOOKE, hook))
|
|
{
|
|
hook.ptPos.transformBy(xform);
|
|
SetAt(KEY_HOOKE, hook);
|
|
}
|
|
|
|
// 中间钩子
|
|
CArray<TStruHookInfo, TStruHookInfo&> arHooks;
|
|
if (GetAt(KEY_HOOK, arHooks))
|
|
{
|
|
for (int i=0; i<arHooks.GetSize(); i++)
|
|
{
|
|
arHooks[i].ptPos.transformBy(xform);
|
|
}
|
|
SetAt(KEY_HOOK, arHooks);
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
// 点钢筋
|
|
EType type;
|
|
if (TDbStruEntityBase::GetAt(KEY_KIND, (int&)type) &&
|
|
type == kDot)
|
|
{
|
|
if (m_polyOutline.Length() >= 1)
|
|
{
|
|
gripPoints.append(m_polyOutline.GetPointListAt(0));
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 普通钢筋
|
|
// 钢筋路径
|
|
for (int i=0; i<m_polyOutline.Length(); i++)
|
|
{
|
|
gripPoints.append(m_polyOutline.GetPointListAt(i));
|
|
}
|
|
|
|
// 起始端钩子
|
|
TStruHookInfo hook;
|
|
if (GetAt(KEY_HOOKS, hook) &&
|
|
hook.eType != TStruHookInfo::kNone)
|
|
{
|
|
gripPoints.append(GetGripPoint(hook));
|
|
}
|
|
|
|
// 终止端钩子
|
|
if (GetAt(KEY_HOOKE, hook) &&
|
|
hook.eType != TStruHookInfo::kNone)
|
|
{
|
|
gripPoints.append(GetGripPoint(hook));
|
|
}
|
|
|
|
// 中间钩子
|
|
CArray<TStruHookInfo, TStruHookInfo&> arHooks;
|
|
if (GetAt(KEY_HOOK, arHooks))
|
|
{
|
|
for (int i=0; i<arHooks.GetSize(); i++)
|
|
{
|
|
if (arHooks[i].eType != TStruHookInfo::kNone)
|
|
{
|
|
gripPoints.append(GetGripPoint(arHooks[i]));
|
|
}
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subMoveGripPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
for (int i=0; i<indices.length(); i++)
|
|
{
|
|
if (indices[i] >= 0 &&
|
|
indices[i] <= m_polyOutline.Length()-1)
|
|
{
|
|
TADSGePoint3d ptMove;
|
|
if (indices[i] == 0)
|
|
{
|
|
if (GetNumsOfHooksAt(0) <= 0)
|
|
{
|
|
// 移动路径点
|
|
ptMove = *m_polyOutline.GetPointListAt(0);
|
|
ptMove += offset;
|
|
m_polyOutline.SetPointListAt(0, ptMove);
|
|
|
|
// 移动起始点钩子
|
|
TStruHookInfo hook;
|
|
if (GetAt(KEY_HOOKS, hook) &&
|
|
hook.eType != TStruHookInfo::kNone)
|
|
{
|
|
hook.ptPos += offset;
|
|
SetAt(KEY_HOOKS, hook);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (GetNumsOfHooksAt(indices[i]-1) <= 0 &&
|
|
GetNumsOfHooksAt(indices[i]) <= 0)
|
|
{
|
|
// 移动路径点
|
|
ptMove = *m_polyOutline.GetPointListAt(indices[i]);
|
|
ptMove += offset;
|
|
m_polyOutline.SetPointListAt(indices[i], ptMove);
|
|
|
|
if (indices[i] == m_polyOutline.Length()-1)
|
|
{
|
|
// 移动终止点钩子
|
|
TStruHookInfo hook;
|
|
if (GetAt(KEY_HOOKE, hook) &&
|
|
hook.eType != TStruHookInfo::kNone)
|
|
{
|
|
hook.ptPos += offset;
|
|
SetAt(KEY_HOOKE, hook);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(offset);
|
|
subTransformBy(xform);
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
// 改变钩子的象限
|
|
// 获得该夹点处的钩子
|
|
TStruHookInfo hook;
|
|
int index = indices[i] - m_polyOutline.Length();
|
|
hook = GetHookFromGripPt(index);
|
|
|
|
// 移动后的夹点位置
|
|
AcGePoint3d ptMoved = GetGripPoint(hook) + offset;
|
|
|
|
// 获得该钩子的方向向量
|
|
AcGeVector3d vtDir1, vtDir2;
|
|
GetAxisX(hook, vtDir1, vtDir2);
|
|
|
|
hook.nQuadrant = GetNewQuadrant(hook, ptMoved, vtDir1, vtDir2);
|
|
UpdateHookFromGripPt(index, hook);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subGetStretchPoints(AcGePoint3dArray& stretchPoints) const
|
|
{
|
|
return TDbStruEntityBase::subGetStretchPoints(stretchPoints);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subMoveStretchPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
return subMoveGripPointsAt(indices, offset);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subGetOsnapPoints(
|
|
AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
return TDbStruEntityBase::subGetOsnapPoints(osnapMode, gsSelectionMark, pickPoint, lastPoint,
|
|
viewXform, snapPoints, geomIds);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subGetTransformedCopy(
|
|
const AcGeMatrix3d& xform,
|
|
AcDbEntity*& pEnt) const
|
|
{
|
|
return TDbStruEntityBase::subGetTransformedCopy(xform, pEnt);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::copyFrom(const AcRxObject* pSrc)
|
|
{
|
|
assertWriteEnabled();
|
|
if (pSrc->isKindOf(TDbStruReinBar::desc()))
|
|
{
|
|
TDbStruReinBar* pSrcReinBar = (TDbStruReinBar*)pSrc;
|
|
|
|
GetSpecialtyData()->Empty();
|
|
GetSpecialtyData()->CopyFrom(pSrcReinBar->GetSpecialtyData());
|
|
|
|
m_polyOutline = pSrcReinBar->GetOutline(); // 钢筋路径
|
|
m_dWidth = pSrcReinBar->GetWidth(); // 宽度
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subGetClassID(CLSID* pClsid) const
|
|
{
|
|
#if (ADS >= 17)
|
|
assertReadEnabled();
|
|
#endif
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subWblockClone(
|
|
AcRxObject* pOwner,
|
|
AcDbObject*& pClonedObject,
|
|
AcDbIdMapping& idMap,
|
|
Adesk::Boolean isPrimary) const
|
|
{
|
|
return TDbStruEntityBase::subWblockClone(pOwner, pClonedObject, idMap, isPrimary);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::subDeepClone(
|
|
AcDbObject* pOwner,
|
|
AcDbObject*& pClonedObject,
|
|
AcDbIdMapping& idMap,
|
|
Adesk::Boolean isPrimary) const
|
|
{
|
|
return TDbStruEntityBase::subDeepClone(pOwner, pClonedObject, idMap, isPrimary);
|
|
}
|
|
|
|
// 获得二维包围盒
|
|
Acad::ErrorStatus TDbStruReinBar::GetExtents2d(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const
|
|
{
|
|
assertReadEnabled();
|
|
EType eType;
|
|
if (TDbStruEntityBase::GetAt(KEY_KIND, (int&)eType))
|
|
{
|
|
if (eType == kNormal)
|
|
{
|
|
m_polyOutline.GetExtend(ptLow, ptUp);
|
|
}
|
|
else
|
|
{
|
|
TADSGePoint3d ptCenter = m_polyOutline.GetPointListAt(0);
|
|
ptLow = TADSGePoint3d(ptCenter.x - m_dWidth / 2, ptCenter.y - m_dWidth / 2, 0);
|
|
ptUp = TADSGePoint3d(ptCenter.x + m_dWidth / 2, ptCenter.y + m_dWidth / 2, 0);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 获得三维包围盒
|
|
Acad::ErrorStatus TDbStruReinBar::GetExtents(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
//取动态属性显示数据
|
|
void TDbStruReinBar::GetTips(TDPtrList<TObjInfoUnit>& lstInfo) const
|
|
{
|
|
TDbStruEntityBase::GetTips(lstInfo);
|
|
}
|
|
|
|
const TCHAR* TDbStruReinBar::GetDefaultLayer() const
|
|
{
|
|
return LAY_S_BEAM_RBAR_LINE;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::IsValid() const
|
|
{
|
|
EType eType;
|
|
TDbStruEntityBase::GetAt(KEY_KIND, (int&)eType);
|
|
if (eType == kDot &&
|
|
m_polyOutline.Length() < 1)
|
|
{
|
|
return FALSE;
|
|
}
|
|
else if (eType == kNormal &&
|
|
m_polyOutline.Length() < 2)
|
|
{
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
// 支持夹点ctrl功能切换
|
|
int TDbStruReinBar::GetCtrlToggleIndex()const
|
|
{
|
|
return TDbStruEntityBase::GetCtrlToggleIndex();
|
|
}
|
|
|
|
// 属性匹配
|
|
void TDbStruReinBar::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbStruEntityBase::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
|
|
|
TDbStruReinBar* pSrc = TDbStruReinBar::cast(pSrcEntity);
|
|
if (pSrc != NULL)
|
|
{
|
|
m_dWidth = pSrc->m_dWidth;
|
|
}
|
|
}
|
|
|
|
// 获得标准三维面
|
|
bool TDbStruReinBar::GetStandardFaceBody(AcDbVoidPtrArray& arFacePtrs) const
|
|
{
|
|
return TDbStruEntityBase::GetStandardFaceBody(arFacePtrs);
|
|
}
|
|
|
|
// 获得安全保护区
|
|
bool TDbStruReinBar::GetSafeProtectedSpace(AcDbVoidPtrArray& arFacePtrs) const
|
|
{
|
|
return TDbStruEntityBase::GetSafeProtectedSpace(arFacePtrs);
|
|
}
|
|
|
|
// 获得剖面
|
|
bool TDbStruReinBar::GetSection(
|
|
const AcDbFace &face,
|
|
const AcGeVector3d& vtPlaneSecDir,
|
|
std::vector<TObjSectionRecord> §ionRecords,
|
|
AcDbVoidPtrArray& arFillPtrs) const
|
|
{
|
|
return TDbStruEntityBase::GetSection(face, vtPlaneSecDir, sectionRecords, arFillPtrs);
|
|
}
|
|
|
|
// 获得XML
|
|
CString TDbStruReinBar::GetXml(const AcGeMatrix3d& mat) const
|
|
{
|
|
return TDbStruEntityBase::GetXml(mat);
|
|
}
|
|
|
|
TStruHookInfo TDbStruReinBar::GetHookFromGripPt(int index)
|
|
{
|
|
assertWriteEnabled();
|
|
CArray<SHook, SHook&> arHooks;
|
|
GetHooksOrderByGrip(arHooks);
|
|
|
|
return arHooks[index].hook;
|
|
}
|
|
|
|
void TDbStruReinBar::GetHooksOrderByGrip(CArray<SHook, SHook&>& arHooks)
|
|
{
|
|
assertReadEnabled();
|
|
SHook sHook;
|
|
TStruHookInfo hook;
|
|
if (GetAt(KEY_HOOKS, hook) &&
|
|
hook.eType != TStruHookInfo::kNone)
|
|
{
|
|
sHook.hook = hook;
|
|
sHook.bIsStartOrEnd = 1;
|
|
arHooks.Add(sHook);
|
|
}
|
|
if (GetAt(KEY_HOOKE, hook) &&
|
|
hook.eType != TStruHookInfo::kNone)
|
|
{
|
|
sHook.hook = hook;
|
|
sHook.bIsStartOrEnd = -1;
|
|
arHooks.Add(sHook);
|
|
}
|
|
CArray<TStruHookInfo, TStruHookInfo&> arHooksMid;
|
|
if (GetAt(KEY_HOOK, arHooksMid))
|
|
{
|
|
for (int i=0; i<arHooksMid.GetSize(); i++)
|
|
{
|
|
if (arHooksMid[i].eType != TStruHookInfo::kNone)
|
|
{
|
|
sHook.hook = arHooksMid[i];
|
|
sHook.bIsStartOrEnd = FALSE;
|
|
sHook.nIndex = i;
|
|
arHooks.Add(sHook);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void TDbStruReinBar::UpdateHookFromGripPt(int index, TStruHookInfo hook)
|
|
{
|
|
assertWriteEnabled();
|
|
CArray<SHook, SHook&> arHooks;
|
|
GetHooksOrderByGrip(arHooks);
|
|
if (index >= arHooks.GetSize())
|
|
{
|
|
return;
|
|
}
|
|
SHook sHook = arHooks[index];
|
|
if (sHook.bIsStartOrEnd > 0)
|
|
{
|
|
SetAt(KEY_HOOKS, hook);
|
|
}
|
|
else if (sHook.bIsStartOrEnd < 0)
|
|
{
|
|
SetAt(KEY_HOOKE, hook);
|
|
}
|
|
else
|
|
{
|
|
CArray<TStruHookInfo, TStruHookInfo&> arHooksMid;
|
|
GetAt(KEY_HOOK, arHooksMid);
|
|
if (sHook.nIndex < arHooksMid.GetSize())
|
|
{
|
|
arHooksMid[sHook.nIndex] = hook;
|
|
SetAt(KEY_HOOK, arHooksMid);
|
|
}
|
|
}
|
|
}
|
|
|
|
int TDbStruReinBar::GetNewQuadrant(TStruHookInfo hook, AcGePoint3d ptMoved,
|
|
AcGeVector3d vtAxis)
|
|
{
|
|
int nRet = hook.nQuadrant;
|
|
|
|
// 钩子位置点到新夹点位置的向量
|
|
AcGeVector3d vtHookDir = ptMoved - hook.ptPos;
|
|
|
|
vtHookDir.rotateBy(-AcGeVector2d(vtAxis.x, vtAxis.y).angle(), AcGeVector3d(0, 0, 1));
|
|
if (vtHookDir[X] > 0 && vtHookDir[Y] > 0) // 第一象限
|
|
{
|
|
nRet = 1;
|
|
}
|
|
else if (vtHookDir[X] <=0 && vtHookDir[Y] > 0) // 第二象限
|
|
{
|
|
nRet = 2;
|
|
}
|
|
else if (vtHookDir[X] > 0 && vtHookDir[Y] < 0) // 第四象限
|
|
{
|
|
nRet = 4;
|
|
}
|
|
else // 第三象限
|
|
{
|
|
nRet = 3;
|
|
}
|
|
|
|
if (IsStartHook(hook.ptPos))
|
|
{
|
|
nRet = 4;
|
|
if (vtHookDir[Y] > 0)
|
|
{
|
|
nRet = 1;
|
|
}
|
|
}
|
|
else if (IsEndHook(hook.ptPos))
|
|
{
|
|
nRet = 3;
|
|
if (vtHookDir[Y] > 0)
|
|
{
|
|
nRet = 2;
|
|
}
|
|
}
|
|
|
|
return nRet;
|
|
}
|
|
|
|
int TDbStruReinBar::GetNewQuadrant(TStruHookInfo hook, AcGePoint3d ptMoved,
|
|
AcGeVector3d vtAxis1, AcGeVector3d vtAxis2)
|
|
{
|
|
int nRet = hook.nQuadrant;
|
|
vtAxis1.normalize();
|
|
vtAxis2.normalize();
|
|
|
|
if (vtAxis1 == vtAxis2)
|
|
{
|
|
return GetNewQuadrant(hook, ptMoved, vtAxis1);
|
|
}
|
|
|
|
int nQua2 = GetNewQuadrant(hook, ptMoved, vtAxis2); // 基于第二条方向向量的象限位置
|
|
switch (GetNewQuadrant(hook, ptMoved, vtAxis1))
|
|
{
|
|
case 1: // 第一象限
|
|
if (nQua2 == 1 ||
|
|
nQua2 == 4)
|
|
{
|
|
nRet = nQua2;
|
|
}
|
|
break;
|
|
case 2: // 第二象限
|
|
if (nQua2 != 1 &&
|
|
nQua2 != 4)
|
|
{
|
|
nRet = 2;
|
|
}
|
|
break;
|
|
case 3: // 第三象限
|
|
if (nQua2 != 1 &&
|
|
nQua2 != 4)
|
|
{
|
|
nRet = 3;
|
|
}
|
|
break;
|
|
case 4: // 第四象限
|
|
if (nQua2 == 1 ||
|
|
nQua2 == 4)
|
|
{
|
|
nRet = nQua2;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return nRet;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::SetAt(LPCTSTR pszKey, const TStruHookInfo& hook)
|
|
{
|
|
assertWriteEnabled();
|
|
if (TDbStruEntityBase::SetAt(CString(pszKey)+_T("1"), hook.ptPos) &&
|
|
TDbStruEntityBase::SetAt(CString(pszKey)+_T("2"), hook.nQuadrant) &&
|
|
TDbStruEntityBase::SetAt(CString(pszKey)+_T("3"), (int)hook.eType))
|
|
{
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::GetAt(LPCTSTR pszKey, TStruHookInfo& hook) const
|
|
{
|
|
assertReadEnabled();
|
|
if (TDbStruEntityBase::GetAt(CString(pszKey)+_T("1"), hook.ptPos) &&
|
|
TDbStruEntityBase::GetAt(CString(pszKey)+_T("2"), hook.nQuadrant) &&
|
|
TDbStruEntityBase::GetAt(CString(pszKey)+_T("3"), (int&)hook.eType))
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::SetAt(LPCTSTR pszKey, const CArray<TStruHookInfo, TStruHookInfo&>& hooks)
|
|
{
|
|
assertWriteEnabled();
|
|
if (!TDbStruEntityBase::SetAt(pszKey, (int)hooks.GetSize()))
|
|
{
|
|
return FALSE;
|
|
}
|
|
for (int i=0; i<hooks.GetSize(); i++)
|
|
{
|
|
CString sKey;
|
|
sKey.Format(_T("%s%d"), pszKey, i+1);
|
|
if (!SetAt(sKey, hooks[i]))
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::GetAt(LPCTSTR pszKey, CArray<TStruHookInfo, TStruHookInfo&>& hooks) const
|
|
{
|
|
assertReadEnabled();
|
|
int nSize;
|
|
if (!TDbStruEntityBase::GetAt(pszKey, nSize))
|
|
{
|
|
return FALSE;
|
|
}
|
|
TStruHookInfo hook;
|
|
for (int i=0; i<nSize; i++)
|
|
{
|
|
CString sKey;
|
|
sKey.Format(_T("%s%d"), pszKey, i+1);
|
|
if (!GetAt(sKey, hook))
|
|
{
|
|
return FALSE;
|
|
}
|
|
hooks.Add(hook);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
// 设置/获取线宽
|
|
void TDbStruReinBar::SetWidth(double dWidth)
|
|
{
|
|
assertWriteEnabled();
|
|
m_dWidth = dWidth;
|
|
}
|
|
double TDbStruReinBar::GetWidth() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dWidth;
|
|
}
|
|
|
|
// 点钢筋,设置点钢筋的位置
|
|
BOOL TDbStruReinBar::SetDotPos(AcGePoint3d ptPos)
|
|
{
|
|
assertWriteEnabled();
|
|
EType eType;
|
|
if (TDbStruEntityBase::GetAt(KEY_KIND, (int&)eType) &&
|
|
eType == kDot)
|
|
{
|
|
m_polyOutline.Reset();
|
|
m_polyOutline.InsertNodeAt(0, ptPos);
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
// 设置钢筋路径
|
|
BOOL TDbStruReinBar::SetOutline(const TGGePoly2D& outline)
|
|
{
|
|
assertWriteEnabled();
|
|
if (outline.Length() < 1)
|
|
{
|
|
return FALSE;
|
|
}
|
|
m_polyOutline = outline;
|
|
|
|
// 重新计算起始和终止端钩子的位置
|
|
ReCalcPointHook();
|
|
return TRUE;
|
|
}
|
|
|
|
TGGePoly2D TDbStruReinBar::GetOutline()
|
|
{
|
|
return m_polyOutline;
|
|
}
|
|
|
|
// 设置起始/终止钩子
|
|
BOOL TDbStruReinBar::SetStartHook(TStruHookInfo::EType eType,
|
|
int nQuadrant)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
TStruHookInfo hook;
|
|
hook.eType = eType;
|
|
hook.nQuadrant = nQuadrant;
|
|
hook.ptPos = AcGePoint3d(0, 0, 0);
|
|
BOOL bRet = SetStartHook(hook);
|
|
return bRet;
|
|
}
|
|
BOOL TDbStruReinBar::SetEndHook(TStruHookInfo::EType eType,
|
|
int nQuadrant)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
TStruHookInfo hook;
|
|
hook.eType = eType;
|
|
hook.nQuadrant = nQuadrant;
|
|
hook.ptPos = AcGePoint3d(0, 0, 0);
|
|
BOOL bRet = SetEndHook(hook);
|
|
return bRet;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::SetStartHook(TStruHookInfo hook)
|
|
{
|
|
assertWriteEnabled();
|
|
if (m_polyOutline.Length() > 0)
|
|
{
|
|
hook.ptPos = *m_polyOutline.GetPointListAt(0);
|
|
}
|
|
BOOL bRet = SetAt(KEY_HOOKS, hook);
|
|
return bRet;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::SetEndHook(TStruHookInfo hook)
|
|
{
|
|
assertWriteEnabled();
|
|
if (m_polyOutline.Length() > 1)
|
|
{
|
|
hook.ptPos = *m_polyOutline.GetPointListAt(m_polyOutline.Length()-1);
|
|
}
|
|
BOOL bRet = SetAt(KEY_HOOKE, hook);
|
|
return bRet;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::GetStartHook(TStruHookInfo& hookS)
|
|
{
|
|
assertReadEnabled();
|
|
return GetAt(KEY_HOOKS, hookS);
|
|
}
|
|
BOOL TDbStruReinBar::GetEndHook(TStruHookInfo& hookE)
|
|
{
|
|
return GetAt(KEY_HOOKE, hookE);
|
|
}
|
|
|
|
// 添加一个中间钩子
|
|
BOOL TDbStruReinBar::AddMidHook(const TStruHookInfo& hook)
|
|
{
|
|
assertWriteEnabled();
|
|
if (!IsValid())
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
if (!m_polyOutline.HitTestOnCurve(hook.ptPos))
|
|
{
|
|
return FALSE;
|
|
}
|
|
CArray<TStruHookInfo, TStruHookInfo&> arHooks;
|
|
GetAt(KEY_HOOK, arHooks);
|
|
|
|
// 检测是否含有相同位置的钩子
|
|
for (int i=0; i<arHooks.GetSize(); i++)
|
|
{
|
|
if (arHooks[i].ptPos == hook.ptPos)
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
// 检测是否是起始或终止位置
|
|
if (*m_polyOutline.GetPointListAt(0) == TADSGePoint3d(hook.ptPos) ||
|
|
*m_polyOutline.GetPointListAt(m_polyOutline.Length()-1) == TADSGePoint3d(hook.ptPos))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
arHooks.Add((TStruHookInfo)hook);
|
|
BOOL bRet = SetAt(KEY_HOOK, arHooks);
|
|
return bRet;
|
|
}
|
|
|
|
// 判断是否是起始或终止端钩子
|
|
BOOL TDbStruReinBar::IsStartOrEndHook(AcGePoint3d ptPos) const
|
|
{
|
|
if (IsStartHook(ptPos) ||
|
|
IsEndHook(ptPos))
|
|
{
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbStruReinBar::IsStartHook(AcGePoint3d ptPos) const
|
|
{
|
|
return TADSGePoint3d(ptPos) == m_polyOutline.GetPointListAt(0);
|
|
}
|
|
BOOL TDbStruReinBar::IsEndHook(AcGePoint3d ptPos) const
|
|
{
|
|
return TADSGePoint3d(ptPos) == m_polyOutline.GetPointListAt(m_polyOutline.Length()-1);
|
|
}
|
|
|
|
void TDbStruReinBar::GetStraightOutline(const TStruHookInfo& hook,
|
|
AcGeVector3d vtAxistX,
|
|
AcDbPolyline& plOutline) const
|
|
{
|
|
AcGeVector3d vtDir;
|
|
AcGePoint3d ptOutline;
|
|
|
|
// 将位置点添加到多段线
|
|
plOutline.addVertexAt(plOutline.numVerts(),
|
|
AcGePoint2d(hook.ptPos[X], hook.ptPos[Y]),
|
|
0, m_dWidth, m_dWidth);
|
|
|
|
vtDir = vtAxistX;
|
|
switch (hook.nQuadrant)
|
|
{
|
|
case 1:
|
|
case 2:
|
|
vtDir.rotateBy(PI/2, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
case 3:
|
|
case 4:
|
|
vtDir.rotateBy(-PI/2, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
vtDir.normalize();
|
|
//ptOutline = hook.ptPos + vtDir * 3.0f * m_dWidth;
|
|
ptOutline = hook.ptPos + vtDir * m_dLengthS;
|
|
plOutline.addVertexAt(plOutline.numVerts(), AcGePoint2d(ptOutline[X], ptOutline[Y]),
|
|
0, m_dWidth, m_dWidth);
|
|
}
|
|
|
|
void TDbStruReinBar::GetBentOutline(const TStruHookInfo& hook,
|
|
AcGeVector3d vtAxistX,
|
|
AcDbPolyline& plOutline) const
|
|
{
|
|
AcGeVector3d vtDir1, vtDir2;
|
|
AcGePoint3d ptOutline;
|
|
|
|
// 将位置点添加到多段线
|
|
plOutline.addVertexAt(plOutline.numVerts(),
|
|
AcGePoint2d(hook.ptPos[X], hook.ptPos[Y]),
|
|
0, m_dWidth, m_dWidth);
|
|
|
|
vtDir1 = vtDir2 = vtAxistX;
|
|
switch (hook.nQuadrant)
|
|
{
|
|
case 1:
|
|
vtDir1.rotateBy(PI/2.0f, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
case 2:
|
|
vtDir1.rotateBy(PI/2.0f, AcGeVector3d(0, 0, 1));
|
|
vtDir2.rotateBy(PI, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
case 3:
|
|
vtDir1.rotateBy(-PI/2.0f, AcGeVector3d(0, 0, 1));
|
|
vtDir2.rotateBy(PI, AcGeVector3d(0, 0, 0));
|
|
break;
|
|
case 4:
|
|
vtDir1.rotateBy(-PI/2.0f, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
vtDir1.normalize();
|
|
vtDir2.normalize();
|
|
//ptOutline = hook.ptPos + vtDir1 * 3.0f * m_dWidth;
|
|
ptOutline = hook.ptPos + vtDir1 * m_dDiaB;
|
|
plOutline.addVertexAt(plOutline.numVerts(), AcGePoint2d(ptOutline[X], ptOutline[Y]),
|
|
0, m_dWidth, m_dWidth);
|
|
//ptOutline += vtDir2 * 3.0f * m_dWidth;
|
|
ptOutline += vtDir2 * m_dLengthB;
|
|
plOutline.addVertexAt(plOutline.numVerts(), AcGePoint2d(ptOutline[X], ptOutline[Y]),
|
|
0, m_dWidth, m_dWidth);
|
|
}
|
|
|
|
void TDbStruReinBar::GetObliqueOutline(const TStruHookInfo& hook,
|
|
AcGeVector3d vtAxistX,
|
|
AcDbPolyline& plOutline) const
|
|
{
|
|
AcGeVector3d vtDir;
|
|
AcGePoint3d ptOutline;
|
|
|
|
// 将位置点添加到多段线
|
|
plOutline.addVertexAt(plOutline.numVerts(),
|
|
AcGePoint2d(hook.ptPos[X], hook.ptPos[Y]),
|
|
0, m_dWidth, m_dWidth);
|
|
|
|
vtDir = vtAxistX;
|
|
switch (hook.nQuadrant)
|
|
{
|
|
case 1:
|
|
vtDir.rotateBy(PI/4, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
case 2:
|
|
vtDir.rotateBy(PI/4*3, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
case 3:
|
|
vtDir.rotateBy(-PI/4*3, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
case 4:
|
|
vtDir.rotateBy(-PI/4, AcGeVector3d(0, 0, 1));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
vtDir.normalize();
|
|
//ptOutline = hook.ptPos + vtDir * 3.0f * m_dWidth;
|
|
ptOutline = hook.ptPos + vtDir * m_dLengthO;
|
|
plOutline.addVertexAt(plOutline.numVerts(), AcGePoint2d(ptOutline[X], ptOutline[Y]),
|
|
0, m_dWidth, m_dWidth);
|
|
}
|
|
|
|
// 获取钩子的轮廓线
|
|
BOOL TDbStruReinBar::GetHookOutLine(const TStruHookInfo& hook, AcDbPolyline& plOutline) const
|
|
{
|
|
// 将多段线置为空
|
|
plOutline.reset(Adesk::kFalse, 0);
|
|
|
|
// 获得局部坐标系的x轴
|
|
AcGeVector3d vtAxisX1, vtAxisX2, vtAxisX;
|
|
GetAxisX(hook, vtAxisX1, vtAxisX2);
|
|
vtAxisX = vtAxisX2;
|
|
if (hook.nQuadrant == 2 ||
|
|
hook.nQuadrant == 3)
|
|
{
|
|
vtAxisX = vtAxisX1;
|
|
}
|
|
|
|
// 获取各种类型钩子的轮廓线
|
|
switch (hook.eType)
|
|
{
|
|
case TStruHookInfo::kStraight:
|
|
GetStraightOutline(hook, vtAxisX, plOutline);
|
|
break;
|
|
case TStruHookInfo::kOblique:
|
|
GetObliqueOutline(hook, vtAxisX, plOutline);
|
|
break;
|
|
case TStruHookInfo::kBent:
|
|
GetBentOutline(hook, vtAxisX, plOutline);
|
|
break;
|
|
default:
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
// 获取用于确定象限的局部坐标系x轴,如果在两条线段的转折点上,存在两条x轴
|
|
void TDbStruReinBar::GetAxisX(const TStruHookInfo& hook, AcGeVector3d& vtAxis1,
|
|
AcGeVector3d& vtAxis2) const
|
|
{
|
|
int nPos = m_polyOutline.HitTestOnCurve(hook.ptPos);
|
|
AcGeVector3d vtDir(1, 0, 0);
|
|
if (nPos>0) // 在顶点上
|
|
{
|
|
if ((TADSGePoint3d)hook.ptPos == m_polyOutline.GetPointListAt(0))
|
|
{
|
|
TGGeCurveSegment curve;
|
|
m_polyOutline.Nth(nPos-1, curve);
|
|
|
|
vtAxis1 = vtDir;
|
|
vtAxis2 = vtAxis1.rotateBy(curve.Direction(hook.ptPos), AcGeVector3d(0, 0, 1));
|
|
|
|
if (m_polyOutline.GetBulge(nPos-1) < -_DIST_SNAP)
|
|
{
|
|
vtAxis1 = vtAxis2.rotateBy(PI, AcGeVector3d(0, 0, 1));
|
|
}
|
|
}
|
|
else if ((TADSGePoint3d)hook.ptPos ==
|
|
m_polyOutline.GetPointListAt(m_polyOutline.Length()-1))
|
|
{
|
|
TGGeCurveSegment curve;
|
|
m_polyOutline.Nth(nPos-2, curve);
|
|
|
|
vtAxis1 = vtDir;
|
|
vtAxis2 = vtAxis1.rotateBy(curve.Direction(hook.ptPos), AcGeVector3d(0, 0, 1));
|
|
|
|
if (m_polyOutline.GetBulge(nPos-2) < -_DIST_SNAP)
|
|
{
|
|
vtAxis1 = vtAxis2.rotateBy(PI, AcGeVector3d(0, 0, 1));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TGGeCurveSegment curve1, curve2;
|
|
m_polyOutline.Nth(nPos - 2, curve1);
|
|
m_polyOutline.Nth(nPos - 1, curve2);
|
|
double dAngle = curve1.Direction(hook.ptPos);
|
|
vtAxis1 = vtDir;
|
|
vtAxis1.rotateBy(dAngle, AcGeVector3d(0, 0, 1));
|
|
|
|
if (m_polyOutline.GetBulge(nPos-2) < -_DIST_SNAP)
|
|
{
|
|
vtAxis1.rotateBy(PI, AcGeVector3d(0, 0, 1));
|
|
}
|
|
|
|
dAngle = curve2.Direction(hook.ptPos);
|
|
vtAxis2 = vtDir;
|
|
vtAxis2.rotateBy(dAngle, AcGeVector3d(0, 0, 1));
|
|
|
|
if (m_polyOutline.GetBulge(nPos-1) < -_DIST_SNAP)
|
|
{
|
|
vtAxis2.rotateBy(PI, AcGeVector3d(0, 0, 1));
|
|
}
|
|
}
|
|
}
|
|
else if (nPos<0) // 在线上
|
|
{
|
|
nPos = abs(nPos);
|
|
TGGeCurveSegment curve;
|
|
m_polyOutline.Nth(nPos - 1, curve);
|
|
double dAngle = curve.Direction(hook.ptPos);
|
|
vtAxis1 = vtAxis2 = vtDir.rotateBy(dAngle, AcGeVector3d(0, 0, 1));
|
|
if (m_polyOutline.GetBulge(nPos-1) < -_DIST_SNAP)
|
|
{
|
|
vtAxis1 = vtAxis2 .rotateBy(PI, AcGeVector3d(0, 0, 1));
|
|
}
|
|
}
|
|
}
|
|
|
|
// 获取路径点处的切线
|
|
void TDbStruReinBar::GetAxisX(int nIndex, AcGeVector3d& vtAxis1, AcGeVector3d& vtAxis2) const
|
|
{
|
|
TStruHookInfo hookTemp = TStruHookInfo(m_polyOutline.GetPointListAt(nIndex),
|
|
TStruHookInfo::kNone, 1);
|
|
GetAxisX(hookTemp, vtAxis1, vtAxis2);
|
|
}
|
|
|
|
// 获取夹点位置
|
|
AcGePoint3d TDbStruReinBar::GetGripPoint(const TStruHookInfo& hook) const
|
|
{
|
|
AcDbPolyline plOutline;
|
|
GetHookOutLine(hook, plOutline);
|
|
AcGePoint3d ptRet;
|
|
plOutline.getPointAt(plOutline.numVerts()-1, ptRet);
|
|
return ptRet;
|
|
}
|
|
|
|
int TDbStruReinBar::GetNumsOfHooksAt(int nIndex)
|
|
{
|
|
int nNums = 0;
|
|
// 遍历中间钩子
|
|
CArray<TStruHookInfo, TStruHookInfo&> arHooks;
|
|
if (GetAt(KEY_HOOK, arHooks))
|
|
{
|
|
int nRet;
|
|
for (int i=0; i<arHooks.GetSize(); i++)
|
|
{
|
|
nRet = m_polyOutline.HitTestOnCurve(arHooks[i].ptPos);
|
|
nRet = abs(nRet);
|
|
if (nRet == 0)
|
|
{
|
|
continue;
|
|
}
|
|
nRet--;
|
|
if (nRet == nIndex)
|
|
{
|
|
nNums++;
|
|
}
|
|
}
|
|
}
|
|
return nNums;
|
|
}
|
|
|
|
// 颠倒钢筋路径点的顺序
|
|
void TDbStruReinBar::ReverseOutline()
|
|
{
|
|
assertWriteEnabled();
|
|
m_polyOutline.Reverse();
|
|
ReCalcPointHook();
|
|
}
|
|
|
|
// 清楚所有中间钩子
|
|
void TDbStruReinBar::ClearAllMidHook()
|
|
{
|
|
assertWriteEnabled();
|
|
CArray<TStruHookInfo, TStruHookInfo&> hooks;
|
|
if (GetAt(KEY_HOOK, hooks))
|
|
{
|
|
hooks.RemoveAll();
|
|
SetAt(KEY_HOOK, hooks);
|
|
}
|
|
}
|
|
|
|
// 重新设置起点和终点的钩子位置,使其始终和路径的起点和终点保持一致
|
|
void TDbStruReinBar::ReCalcPointHook()
|
|
{
|
|
assertWriteEnabled();
|
|
TStruHookInfo hook;
|
|
if (GetAt(KEY_HOOKS, hook))
|
|
{
|
|
hook.ptPos = *m_polyOutline.GetPointListAt(0);
|
|
SetAt(KEY_HOOKS, hook);
|
|
}
|
|
|
|
if (GetAt(KEY_HOOKE, hook))
|
|
{
|
|
hook.ptPos = *m_polyOutline.GetPointListAt(m_polyOutline.Length()-1);
|
|
SetAt(KEY_HOOKE, hook);
|
|
}
|
|
}
|
|
|
|
double TDbStruReinBar::GetLenS() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dLengthS;
|
|
}
|
|
void TDbStruReinBar::SetLenS(double dVal)
|
|
{
|
|
assertWriteEnabled();
|
|
m_dLengthS = dVal;
|
|
}
|
|
double TDbStruReinBar::GetLenO() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dLengthO;
|
|
}
|
|
void TDbStruReinBar::SetLenO(double dVal)
|
|
{
|
|
assertWriteEnabled();
|
|
m_dLengthO = dVal;
|
|
}
|
|
double TDbStruReinBar::GetLenB() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dLengthB;
|
|
}
|
|
void TDbStruReinBar::SetLenB(double dVal)
|
|
{
|
|
assertWriteEnabled();
|
|
m_dLengthB = dVal;
|
|
}
|
|
double TDbStruReinBar::GetDiaB() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dDiaB;
|
|
}
|
|
void TDbStruReinBar::SetDiaB(double dVal)
|
|
{
|
|
assertWriteEnabled();
|
|
m_dDiaB = dVal;
|
|
}
|
|
|
|
int TDbStruReinBar::GetFirstVersion()const
|
|
{
|
|
return 10;
|
|
}
|
|
bool TDbStruReinBar::IsModelEntity() const
|
|
{
|
|
return true;
|
|
}
|
|
AcDbCurve* TDbStruReinBar::GetBaseCurve()const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbCurve* pCurve = m_polyOutline.AsAcDbCurve();
|
|
|
|
return pCurve;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruReinBar::SetBaseCurve(AcDbCurve*pCurve)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AcDbCurve *pCurve1 = (AcDbCurve*)pCurve->clone();
|
|
if (m_polyOutline.SetAcDbCurve(pCurve1))
|
|
{
|
|
delete pCurve1;
|
|
return Acad::eOk;
|
|
}
|
|
else
|
|
{
|
|
delete pCurve1;
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
}
|
|
|
|
|
|
void InitDbStruReinBar(BOOL bInit)
|
|
{
|
|
if (bInit)
|
|
{
|
|
TDbStruReinBar::rxInit();
|
|
acrxBuildClassHierarchy();
|
|
TDbStruReinBar::InitMatchProtocol(TRUE);
|
|
}
|
|
else
|
|
{
|
|
TDbStruReinBar::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(TDbStruReinBar::desc());
|
|
}
|
|
}
|
|
#endif |