1637 lines
38 KiB
C++
1637 lines
38 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbColumn.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
#include "_cgal.h"
|
|
#include "simpleproperty.h"
|
|
#include "CoreTools.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "KTCADSysVar.h"
|
|
#include "KTCadUtility.h"
|
|
#include "KTSetting.h"
|
|
#include "KTCADUtilityEx.h"
|
|
|
|
extern double PixelToWcs(int nPixel);
|
|
extern BOOL Is2DView();
|
|
extern AcGeVector3d GetUcsZvt();
|
|
extern void PushGripMessage(GripMessage&);
|
|
|
|
extern void transfromRegion(AcDbRegion *pRegion, const AcGePoint3d &ptOnRegion, const AcGeVector3d &vtNormal, const AcGePoint3d &ptOnPlan);
|
|
extern AcGePoint3d GetArcMidPoint(AcDbArc* pArc);
|
|
//extern convex_hull2d(arPt2ds,arPt2dPoly);
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1, const AcGePoint3d& pt2);
|
|
extern BOOL DLLIMPEXP GetDimGripOff();
|
|
static void FreeBuffer(int n,AcDbVoidPtrArray& arEntPtrs)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
while(arEntPtrs.length() > n )
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.last();
|
|
if (pEnt != NULL)
|
|
{
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
arEntPtrs.removeLast();
|
|
DELETE_PTR(pEnt);
|
|
}
|
|
}
|
|
}
|
|
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
static const Adesk::UInt16 kRed = 1;
|
|
static const Adesk::UInt16 kYellow = 2;
|
|
static const Adesk::UInt16 kGreen = 3;
|
|
static const Adesk::UInt16 kCyan = 4;
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
static const Adesk::UInt16 kMagenta = 6;
|
|
static const Adesk::UInt16 kWhite = 7;
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
Adesk::UInt32 AecDbColumn::kCurrentVersionNumber = 1;
|
|
const CString AecDbColumn::KEY_COL_MODEL = _T("KEY_COL_MODEL");
|
|
const CString AecDbColumn::_JZ_PT_INNER = _T("_JZ_PT_INNER");
|
|
const CString AecDbColumn::_JZ_PT_A = _T("_JZ_PT_A");
|
|
const CString AecDbColumn::_JZ_PT_B = _T("_JZ_PT_B");
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbColumn, AecDbBDPipeBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DBCOLMN,
|
|
"AecDbColumn"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
AecDbColumn::AecDbColumn(void)
|
|
{
|
|
m_mapSpecXData.SetAt(KEY_2DSTYLE,2);
|
|
m_mapSpecXData.SetAt(KEY_CENNODRAW,1);
|
|
m_mapSpecXData.SetAt(KEY_NAME,_T("柱"));
|
|
|
|
}
|
|
|
|
AecDbColumn::~AecDbColumn(void)
|
|
{
|
|
|
|
}
|
|
|
|
void AecDbColumn::SetColumnData(const AcGePoint3d& ptBom,double dL,double dW,double dH,double dRotate)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
m_pBaseCurve = new AcDbLine;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setStartPoint(ptBom);
|
|
|
|
AcGePoint3d ptEnd = ptBom;
|
|
ptEnd.z += dH;
|
|
pLine->setEndPoint(ptEnd);
|
|
|
|
SetSection(dL,dW,0.0);
|
|
SetSectionRotation(dRotate);
|
|
}
|
|
}
|
|
|
|
void AecDbColumn::GetColumnData(ColumnParam& data) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
data.m_dBomEl = GetPosition().z;
|
|
data.m_dH = GetHeight();
|
|
m_mapSpecXData.GetAt(KEY_SHAPE,data.m_nShape);
|
|
|
|
CString sTmp;
|
|
m_mapSpecXData.GetAt(KEY_MATERIAL,sTmp);
|
|
_tcscpy(data.m_sMaterial,(LPCTSTR)sTmp);
|
|
|
|
m_mapSpecXData.GetAt(KEY_BLOCKNAME,sTmp);
|
|
_tcscpy(data.m_sBlockName,(LPCTSTR)sTmp);
|
|
|
|
m_mapSpecXData.GetAt(KEY_NO,data.m_szNo);
|
|
|
|
//m_mapSpecXData.GetAt(KEY_ROTATION,data.m_dRotAngle);
|
|
m_mapSpecXData.GetAt(KEY_ROTATIONBK,data.m_dRotAngle);
|
|
|
|
memset(data.m_dSizes,0,sizeof(double) * 4);
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,data.m_dSizes[0]);
|
|
m_mapSpecXData.GetAt(KEY_SIZE2,data.m_dSizes[1]);
|
|
m_mapSpecXData.GetAt(KEY_SIZE3,data.m_dSizes[2]);
|
|
m_mapSpecXData.GetAt(KEY_SIZE4,data.m_dSizes[3]);
|
|
|
|
m_mapSpecXData.GetAt(KEY_XE,data.m_dXExtend);
|
|
m_mapSpecXData.GetAt(KEY_YE,data.m_dYExtend);
|
|
m_mapSpecXData.GetAt(KEY_XS,data.m_dXScale);
|
|
m_mapSpecXData.GetAt(KEY_YS,data.m_dYScale);
|
|
m_mapSpecXData.GetAt(AecDbColumn::KEY_COL_MODEL, data.m_sModel);
|
|
m_mapSpecXData.GetAt(KEY_SECTION_HATCH, data.m_sHatch);
|
|
}
|
|
|
|
void AecDbColumn::SetPosition(const AcGePoint3d& ptPos)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
bool bDefault = false;
|
|
if (m_pBaseCurve == NULL)
|
|
{
|
|
m_pBaseCurve = new AcDbLine;
|
|
bDefault = true;
|
|
}
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setStartPoint(ptPos);
|
|
|
|
//默认3米
|
|
if (bDefault)
|
|
{
|
|
AcGePoint3d ptEnd = ptPos;
|
|
ptEnd.z += 3000.0;
|
|
pLine->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
}
|
|
|
|
AcGePoint3d AecDbColumn::GetPosition() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
{
|
|
return AcGePoint3d::kOrigin;
|
|
}
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
return pLine->startPoint();
|
|
}
|
|
return AcGePoint3d::kOrigin;
|
|
}
|
|
|
|
void AecDbColumn::SetHeight(double dH)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
bool bDefault = false;
|
|
if (m_pBaseCurve == NULL)
|
|
{
|
|
m_pBaseCurve = new AcDbLine;
|
|
bDefault = true;
|
|
}
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLine->startPoint();
|
|
AcGePoint3d ptEnd = ptSta;
|
|
ptEnd.z += dH;
|
|
|
|
pLine->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
|
|
double AecDbColumn::GetHeight() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
{
|
|
return 0.0;
|
|
}
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
return pLine->endPoint().distanceTo(pLine->startPoint());
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
void AecDbColumn::SetRotation(double dRot)
|
|
{
|
|
AssertWriteEnabled();
|
|
SetSectionRotation(dRot);
|
|
}
|
|
|
|
double AecDbColumn::GetRotation() const
|
|
{
|
|
assertReadEnabled();
|
|
return GetSectionRotation();
|
|
}
|
|
|
|
void AecDbColumn::SetRect(double dL,double dW)
|
|
{
|
|
AssertWriteEnabled();
|
|
SetSection( dL,dW,0.0);
|
|
}
|
|
|
|
AcGePoint2d AecDbColumn::GetRect() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
double dL = 0.0,dW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,dL);
|
|
m_mapSpecXData.GetAt(KEY_SIZE2,dW);
|
|
|
|
return AcGePoint2d(dL,dW);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
AcDbObjectId idCurLay = dc.GetLayerId();
|
|
AcDbObjectId idCurLty = dc.GetLineTypeId();
|
|
Adesk::UInt16 nCrBk = colorIndex();
|
|
|
|
int nColor = nCrBk;
|
|
if ( m_mapSpecXData.GetAt(_T("COLOR"),nColor) )
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
DrawDTYG2D(dc);
|
|
|
|
//二维缓存
|
|
if (Has2DBuffer())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
dc.SetColor(nCrBk);
|
|
dc.SetLayer(idCurLay);
|
|
dc.SetLineType(idCurLty);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbRegion* pRegion = GetSection();
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
AcGeVector3d vtZ = ptEnd - ptSta;
|
|
transfromRegion(pRegion,AcGePoint3d::kOrigin,vtZ,ptSta);
|
|
|
|
AcDbVoidPtrArray arPtrs;
|
|
pRegion->explode(arPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arPtrs.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
pEnt->setColorIndex(nColor);
|
|
dc.DrawEntity(pEnt);
|
|
Add2DBuffer(pEnt);
|
|
}
|
|
}
|
|
}
|
|
delete pRegion;
|
|
}
|
|
dc.SetColor(nCrBk);
|
|
dc.SetLayer(idCurLay);
|
|
dc.SetLineType(idCurLty);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbColumn::GetDraw2dables(AecComplexCurve& draw2d) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecEqui::AecCurveElement el;
|
|
memset(&el,0,sizeof(AecEqui::AecCurveElement));
|
|
|
|
AcDbRegion* pRegion = GetSection();
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
AcGeVector3d vtZ = ptEnd - ptSta;
|
|
transfromRegion(pRegion,AcGePoint3d::kOrigin,vtZ,ptSta);
|
|
|
|
AcDbVoidPtrArray arPtrs,arPtrsAll;
|
|
pRegion->explode(arPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int j = 0;j < arPtrs.length();j++)
|
|
{
|
|
pEnt = (AcDbEntity*)arPtrs.at(j);
|
|
if (pEnt != NULL)
|
|
{
|
|
AcDbRegion* pSubReg = AcDbRegion::cast(pEnt);
|
|
if (pSubReg != NULL)
|
|
{
|
|
arPtrs.removeAt(j);
|
|
j -= 1;
|
|
|
|
pSubReg->explode(arPtrsAll);
|
|
delete pSubReg;
|
|
}
|
|
else
|
|
{
|
|
arPtrs.removeAt(j);
|
|
j -= 1;
|
|
|
|
arPtrsAll.append(pEnt);
|
|
}
|
|
}
|
|
}
|
|
|
|
AcDbLine* pLn = NULL;
|
|
for (int i = 0;i < arPtrsAll.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arPtrsAll.at(i);
|
|
|
|
//只提取line 实体
|
|
pLn = AcDbLine::cast(pEnt);
|
|
if (pLn != NULL)
|
|
{
|
|
el.ptGe[0] = pLn->startPoint();
|
|
el.ptGe[0].z = 0.0;
|
|
el.ptGe[1] = pLn->endPoint();
|
|
el.ptGe[1].z = 0.0;
|
|
el.ptGe[2] = el.ptGe[1];
|
|
draw2d.append(el);
|
|
}
|
|
|
|
AcDbCircle* pCir = AcDbCircle::cast(pEnt);
|
|
if (pCir != NULL)
|
|
{
|
|
el.ptGe[0] = pCir->center();
|
|
el.ptGe[0].z = 0.0;
|
|
el.ptGe[0].x += pCir->radius();
|
|
|
|
el.ptGe[1] = pCir->center();
|
|
el.ptGe[1].z = 0.0;
|
|
el.ptGe[1].y += pCir->radius();
|
|
|
|
el.ptGe[2] = pCir->center();
|
|
el.ptGe[2].z = 0.0;
|
|
el.ptGe[2].x -= pCir->radius();
|
|
draw2d.append(el);
|
|
|
|
|
|
el.ptGe[0] = pCir->center();
|
|
el.ptGe[0].z = 0.0;
|
|
el.ptGe[0].x -= pCir->radius();
|
|
|
|
el.ptGe[1] = pCir->center();
|
|
el.ptGe[1].z = 0.0;
|
|
el.ptGe[1].y -= pCir->radius();
|
|
|
|
el.ptGe[2] = pCir->center();
|
|
el.ptGe[2].z = 0.0;
|
|
el.ptGe[2].x += pCir->radius();
|
|
draw2d.append(el);
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pEnt);
|
|
if (pArc != NULL)
|
|
{
|
|
pArc->getStartPoint(el.ptGe[0]);
|
|
el.ptGe[0].z = 0.0;
|
|
|
|
pArc->getEndPoint(el.ptGe[2]);
|
|
el.ptGe[2].z = 0.0;
|
|
|
|
el.ptGe[2] = GetArcMidPoint(pArc);
|
|
el.ptGe[2].z = 0.0;
|
|
|
|
draw2d.append(el);
|
|
}
|
|
}
|
|
|
|
FreeBuffer(0,arPtrsAll);
|
|
}
|
|
delete pRegion;
|
|
}
|
|
}
|
|
|
|
AcDbPolyline* AecDbColumn::GetDraw2dables() const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbPolyline *pPl = NULL;
|
|
|
|
AecComplexCurve draw2d;
|
|
GetDraw2dables(draw2d);
|
|
|
|
pPl = draw2d.MakePoly();
|
|
|
|
return pPl;
|
|
}
|
|
|
|
AcDbPolyline* AecDbColumn::GetConvexhull2d() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbPolyline* pPl = NULL;
|
|
AcDbRegion* pRegion = GetSection();
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
AcGeVector3d vtZ = ptEnd - ptSta;
|
|
transfromRegion(pRegion,AcGePoint3d::kOrigin,vtZ,ptSta);
|
|
|
|
AcDbVoidPtrArray arPtrs,arPtrsAll;
|
|
pRegion->explode(arPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int j = 0;j < arPtrs.length();j++)
|
|
{
|
|
pEnt = (AcDbEntity*)arPtrs.at(j);
|
|
if (pEnt != NULL)
|
|
{
|
|
AcDbRegion* pSubReg = AcDbRegion::cast(pEnt);
|
|
if (pSubReg != NULL)
|
|
{
|
|
arPtrs.removeAt(j);
|
|
j -= 1;
|
|
pSubReg->explode(arPtrsAll);
|
|
delete pSubReg;
|
|
}
|
|
else
|
|
{
|
|
arPtrs.removeAt(j);
|
|
j -= 1;
|
|
arPtrsAll.append(pEnt);
|
|
}
|
|
}
|
|
}
|
|
arPtrs.removeAll();
|
|
|
|
//求二维凸包线
|
|
std::vector<AcGePoint2d> arPt2ds, arPt2dsOut;
|
|
AcGePoint2d pt2d;
|
|
|
|
AcGePoint3d ptS,ptE,ptM;
|
|
for (int i = 0;i < arPtrsAll.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arPtrsAll.at(i);
|
|
|
|
AcDbLine* pLnT = AcDbLine::cast(pEnt);
|
|
if (pLnT != NULL)
|
|
{
|
|
pt2d.set(pLnT->startPoint().x,pLnT->startPoint().y);
|
|
arPt2ds.push_back(pt2d);
|
|
|
|
pt2d.set(pLnT->endPoint().x,pLnT->endPoint().y);
|
|
arPt2ds.push_back(pt2d);
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pEnt);
|
|
if (pArc != NULL)
|
|
{
|
|
pArc->getStartPoint(ptS);
|
|
pArc->getEndPoint(ptE);
|
|
ptM = GetArcMidPoint(pArc);
|
|
|
|
arPt2ds.push_back(AcGePoint2d(ptS.x,ptS.y));
|
|
arPt2ds.push_back(AcGePoint2d(ptE.x,ptE.y));
|
|
arPt2ds.push_back(AcGePoint2d(ptM.x,ptM.y));
|
|
}
|
|
}
|
|
|
|
Geometry::calcConvexHull2D(arPt2ds,arPt2dsOut);
|
|
|
|
pPl = new AcDbPolyline;
|
|
for (int j = 0;j < arPt2dsOut.size();j++)
|
|
{
|
|
pPl->addVertexAt(j,arPt2dsOut.at(j));
|
|
}
|
|
pPl->setClosed(Adesk::kTrue);
|
|
}
|
|
delete pRegion;
|
|
}
|
|
return pPl;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
return AecDbBDPipeBase::Draw3d(dc);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::subGetGripPoints(AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
|
|
//夹点设计
|
|
//reg的夹点+中心夹点+改高度夹点(上下)+ 标高夹点(下)
|
|
|
|
AcGePoint3dArray gripPoints;
|
|
ImpGetGripPoints(gripPoints,bitflags);
|
|
|
|
int nColor = kWhite;
|
|
AcDbGripData* pGripData = NULL;
|
|
if ( bitflags >= 1394)//节点
|
|
{
|
|
memset(&m_pGripAppData[0],0,sizeof(AecGripData));
|
|
m_pGripAppData[0].nIndex = 0;
|
|
m_pGripAppData[0].ePos = eFlag;
|
|
m_pGripAppData[0].nColor = nColor;
|
|
m_pGripAppData[0].ptGrip = gripPoints.at(0);
|
|
m_pGripAppData[0].pOwner = (AcDbEntity*)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(gripPoints.at(0));
|
|
pGripData->setAppData((void*)&m_pGripAppData[0]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
_tcscpy(m_pGripAppData[0].szTip,_T("点击定位造族<柱子>记录"));
|
|
_tcscpy(m_pGripAppData[0].szID,m_sGUID);
|
|
grips.append(pGripData);
|
|
return Acad::eOk;
|
|
}
|
|
else
|
|
{
|
|
EPosition ePos;
|
|
CString sTip;
|
|
for (int i = 0;i < gripPoints.length();i++)
|
|
{
|
|
ePos = ExplainGripIndex(i,sTip);
|
|
memset(&m_pGripAppData[i],0,sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = ePos;
|
|
m_pGripAppData[i].nColor = kBlue;
|
|
m_pGripAppData[i].ptGrip = gripPoints.at(i);
|
|
_tcscpy(m_pGripAppData[i].szTip,sTip);
|
|
_tcscpy(m_pGripAppData[i].szID,m_sGUID);
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(gripPoints.at(i));
|
|
pGripData->setAppData((void*)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
grips.append(pGripData);
|
|
}
|
|
}
|
|
|
|
//调用基类加入单击修改
|
|
SubAddHitEditGrip(grips);
|
|
|
|
//动态标注
|
|
//直线,半径 标注风格
|
|
if (!grips.isEmpty())
|
|
{
|
|
SubAddDimPoints(grips,curViewDir);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::subGetStretchPoints(AcGePoint3dArray& stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
extern BOOL IsFrontView();
|
|
if (IsFrontView())
|
|
{
|
|
AcGePoint3d ptS,ptE;
|
|
m_pBaseCurve->getStartPoint(ptS);
|
|
m_pBaseCurve->getEndPoint(ptE);
|
|
|
|
stretchPoints.append(ptS);
|
|
stretchPoints.append(ptE);
|
|
}
|
|
else
|
|
{
|
|
if (Is2DView())
|
|
{
|
|
AcDbRegion* pRegion = GetSection();
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
AcGeVector3d vtZ = ptEnd - ptSta;
|
|
transfromRegion(pRegion,AcGePoint3d::kOrigin,vtZ,ptSta);
|
|
|
|
pRegion->getStretchPoints(stretchPoints);
|
|
}
|
|
delete pRegion;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::subMoveStretchPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
|
|
{
|
|
extern BOOL IsFrontView();
|
|
if (IsFrontView())
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcGeVector3d vtZ;
|
|
vtZ = offset.orthoProject(AcGeVector3d::kYAxis);
|
|
|
|
AcGePoint3d ptS,ptE;
|
|
m_pBaseCurve->getStartPoint(ptS);
|
|
m_pBaseCurve->getEndPoint(ptE);
|
|
|
|
if (indices.length() == 1)
|
|
{
|
|
if (indices.find(0) != -1)
|
|
{
|
|
ptS += vtZ;
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setStartPoint(ptS);
|
|
}
|
|
}
|
|
else if (indices.find(1) != -1)
|
|
{
|
|
ptE += vtZ;
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setEndPoint(ptE);
|
|
}
|
|
}
|
|
}
|
|
else if (indices.length() == 2)
|
|
{
|
|
ptS += vtZ;
|
|
ptE += vtZ;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setStartPoint(ptS);
|
|
pLine->setEndPoint(ptE);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Is2DView())
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(offset);
|
|
m_pBaseCurve->transformBy(xform);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::SubAddDimPoints(AcDbGripDataPtrArray& grips,const AcGeVector3d& curViewDir) const
|
|
{
|
|
if (GetDimGripOff())
|
|
return Acad::eOk;
|
|
|
|
//柱子素线统一为直线段
|
|
AcDbRegion* pRegion = GetSection();
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
AcGePoint3d ptMid,ptPos = ptSta;
|
|
AcGeVector3d vtZ = ptEnd - ptSta;
|
|
transfromRegion(pRegion,AcGePoint3d::kOrigin,vtZ,ptSta);
|
|
|
|
ptMid = MidPoint(ptSta,ptEnd);
|
|
vtZ = ptMid - ptPos;
|
|
vtZ.normalize();
|
|
|
|
AcGeVector3d vtV = AcGeVector3d::kXAxis;
|
|
vtV *= 10.0 * 100;
|
|
ptMid += vtV;
|
|
|
|
AddDimPoints(grips,curViewDir,ptSta,ptEnd,ptMid,0);
|
|
|
|
AcDbVoidPtrArray arPtrs;
|
|
pRegion->explode(arPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arPtrs.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
AcDbLine* pLnT = AcDbLine::cast(pEnt);
|
|
if (pLnT != NULL)
|
|
{
|
|
ptSta = pLnT->startPoint();
|
|
ptEnd = pLnT->endPoint();
|
|
ptMid = MidPoint(ptSta,ptEnd);
|
|
vtZ = ptMid - ptPos;
|
|
vtZ.normalize();
|
|
vtZ *= 10.0 * 100;
|
|
ptMid += vtZ;
|
|
AddDimPoints(grips,curViewDir,ptSta,ptEnd,ptMid,0);
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pEnt);
|
|
if (pArc != NULL)
|
|
{
|
|
pArc->getStartPoint(ptSta);
|
|
|
|
AcGeVector3d vtL;
|
|
pArc->getFirstDeriv(ptSta,vtL);
|
|
vtL.normalize();
|
|
vtL.negate();
|
|
|
|
//半径标注
|
|
ptEnd = pArc->center();
|
|
AcGePoint3d ptAMid = GetArcMidPoint(pArc);
|
|
ptMid = MidPoint(ptAMid,ptEnd);
|
|
AddDimPoints(grips,curViewDir,ptAMid,ptEnd,ptMid,1,pArc->radius());
|
|
|
|
//角度
|
|
pArc->getStartPoint(ptSta);
|
|
pArc->getEndPoint(ptEnd);
|
|
ptMid = pArc->center();
|
|
double dAngle = pArc->endAngle() - pArc->startAngle();
|
|
AddDimPoints(grips,curViewDir,ptSta,ptEnd,ptMid,3);
|
|
}
|
|
|
|
AcDbCircle* pCir = AcDbCircle::cast(pEnt);
|
|
if (pCir != NULL)
|
|
{
|
|
pCir->getStartPoint(ptSta);
|
|
|
|
AcGeVector3d vtL;
|
|
pCir->getFirstDeriv(ptSta,vtL);
|
|
vtL.normalize();
|
|
vtL.negate();
|
|
|
|
//半径标注
|
|
ptEnd = pCir->center();
|
|
ptMid = MidPoint(ptSta,ptEnd);
|
|
AddDimPoints(grips,curViewDir,ptSta,ptEnd,ptMid,1,pCir->radius());
|
|
}
|
|
|
|
delete pEnt;
|
|
}
|
|
}
|
|
}
|
|
delete pRegion;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
EPosition AecDbColumn::ExplainGripIndex(int nIndex,CString& sTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
EPosition ePos = eStart;
|
|
|
|
switch(nIndex)
|
|
{
|
|
case 0://上 改高度
|
|
{
|
|
ePos = eEnd;
|
|
sTip = _T("修改柱子高度夹点");
|
|
break;
|
|
}
|
|
case 1://底 改位置
|
|
{
|
|
ePos = eStart;
|
|
sTip = _T("修改柱子位置夹点");
|
|
break;
|
|
}
|
|
case 2://下 改标高
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("修改柱子标高夹点");
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return ePos;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::ImpGetGripPoints(AcGePoint3dArray& gripPoints,const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//柱子素线统一为直线段
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
double dCmd = PixelToWcs(10);
|
|
|
|
//sta 底部
|
|
//end 顶部
|
|
|
|
AcGePoint3d ptGeT,ptOrg;
|
|
ptOrg = pLn->startPoint();
|
|
ptGeT = pLn->endPoint();
|
|
|
|
//上 改高度
|
|
gripPoints.append(ptGeT);
|
|
|
|
//底 改位置
|
|
gripPoints.append(ptOrg);
|
|
|
|
//下 改标高
|
|
ptGeT = ptOrg - dCmd * AcGeVector3d::kZAxis;
|
|
gripPoints.append(ptGeT);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::subMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if ( gripAppData.isEmpty() )
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
if (HitOnGripEdit(gripAppData))
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
arIndex.append(pAppData->nIndex);
|
|
|
|
AcGeVector3d vtOffset = offset;
|
|
|
|
AcGeVector3d vtXYOffset;
|
|
vtXYOffset = vtOffset.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtZOffset;
|
|
vtZOffset = vtOffset.orthoProject(AcGeVector3d::kXAxis);
|
|
|
|
double dLen = offset.length();
|
|
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
AcGePoint3d ptGeT;
|
|
|
|
double dH = ptEnd.distanceTo(ptSta);
|
|
AcGeVector3d vtH = ptEnd - ptSta;
|
|
vtH.normalize();
|
|
|
|
switch(pAppData->nIndex)
|
|
{
|
|
case 0://改高度
|
|
{
|
|
if (vtZOffset.isCodirectionalTo(AcGeVector3d::kZAxis))//增厚
|
|
{
|
|
dH += dLen;
|
|
}
|
|
else//减去厚度
|
|
{
|
|
dH -= dLen;
|
|
}
|
|
|
|
if (dH > 1.0)
|
|
{
|
|
vtH *= dH;
|
|
ptEnd = ptSta + vtH;
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
break;
|
|
}
|
|
case 1://改位置
|
|
{
|
|
ptSta = pLn->startPoint();
|
|
ptEnd = pLn->endPoint();
|
|
|
|
ptSta += offset;
|
|
ptEnd += offset;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
break;
|
|
}
|
|
case 2://改标高
|
|
{
|
|
vtZOffset.normalize();
|
|
|
|
vtZOffset *= dLen;
|
|
ptSta += vtZOffset;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbColumn::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
acutPrintf(_T("\n柱子:"));
|
|
acutPrintf(_T("\n体积:%g 立方"),GetVolume() / 1.e9);
|
|
AecDbBDPipeBase::subList();
|
|
}
|
|
|
|
bool AecDbColumn::GetBimInfoTip(CString& sInfoTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
ColumnParam data;
|
|
memset(&data,0,sizeof(ColumnParam));
|
|
|
|
GetColumnData(data);
|
|
CString sField,sFmt;
|
|
|
|
//矩形;圆形;正六边形;工字钢柱;槽钢柱;
|
|
switch(data.m_nShape)
|
|
{
|
|
case 0://矩形
|
|
{
|
|
sField = _T("矩形柱子:\n");
|
|
sInfoTip += sField;
|
|
|
|
MAKEFIELD(_T("高度"),_T("%.1f 毫米"),data.m_dH,sInfoTip);
|
|
|
|
MAKEFIELD(_T("横向"),_T("%.1f 毫米"),data.m_dSizes[0],sInfoTip);
|
|
MAKEFIELD(_T("纵向"),_T("%.1f 毫米"),data.m_dSizes[1],sInfoTip);
|
|
|
|
MAKEFIELD(_T("底标高"),_T("%.1f 毫米"),data.m_dBomEl,sInfoTip);
|
|
|
|
MAKEFIELD(_T("旋转角度"),_T("%.1f 度"),data.m_dRotAngle,sInfoTip);
|
|
|
|
MAKEFIELD(_T("体积"),_T("%.1f 立方米"),GetVolume() / 1.e9,sInfoTip);
|
|
MAKEFIELD(_T("面积"),_T("%.1f 平方米"),GetArea() / 1.e6,sInfoTip);
|
|
|
|
MAKEFIELD(_T("材质"),_T("%s"),data.m_sMaterial,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),data.m_szNo,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
case 1://圆形
|
|
{
|
|
sField = _T("圆形柱子:\n");
|
|
sInfoTip += sField;
|
|
|
|
MAKEFIELD(_T("高度"),_T("%.1f 毫米"),data.m_dH,sInfoTip);
|
|
|
|
MAKEFIELD(_T("直径"),_T("%.1f 毫米"),data.m_dSizes[0],sInfoTip);
|
|
|
|
MAKEFIELD(_T("底标高"),_T("%.1f 毫米"),data.m_dBomEl,sInfoTip);
|
|
|
|
MAKEFIELD(_T("体积"),_T("%.1f 立方米"),GetVolume() / 1.e9,sInfoTip);
|
|
MAKEFIELD(_T("面积"),_T("%.1f 平方米"),GetArea() / 1.e6,sInfoTip);
|
|
|
|
MAKEFIELD(_T("材质"),_T("%s"),data.m_sMaterial,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),data.m_szNo,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
sField = _T("正六边形柱子:\n");
|
|
sInfoTip += sField;
|
|
|
|
MAKEFIELD(_T("高度"),_T("%.1f 毫米"),data.m_dH,sInfoTip);
|
|
|
|
MAKEFIELD(_T("边长"),_T("%.1f 毫米"),data.m_dSizes[0],sInfoTip);
|
|
|
|
MAKEFIELD(_T("底标高"),_T("%.1f 毫米"),data.m_dBomEl,sInfoTip);
|
|
|
|
MAKEFIELD(_T("体积"),_T("%.1f 立方米"),GetVolume() / 1.e9,sInfoTip);
|
|
MAKEFIELD(_T("面积"),_T("%.1f 平方米"),GetArea() / 1.e6,sInfoTip);
|
|
|
|
MAKEFIELD(_T("材质"),_T("%s"),data.m_sMaterial,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),data.m_szNo,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
sField = _T("工字钢柱子:\n");
|
|
sInfoTip += sField;
|
|
|
|
MAKEFIELD(_T("高度"),_T("%.1f 毫米"),data.m_dH,sInfoTip);
|
|
|
|
MAKEFIELD(_T("A"),_T("%.1f 毫米"),data.m_dSizes[0],sInfoTip);
|
|
MAKEFIELD(_T("B"),_T("%.1f 毫米"),data.m_dSizes[1],sInfoTip);
|
|
MAKEFIELD(_T("C"),_T("%.1f 毫米"),data.m_dSizes[2],sInfoTip);
|
|
MAKEFIELD(_T("D"),_T("%.1f 毫米"),data.m_dSizes[3],sInfoTip);
|
|
|
|
MAKEFIELD(_T("底标高"),_T("%.1f 毫米"),data.m_dBomEl,sInfoTip);
|
|
|
|
MAKEFIELD(_T("体积"),_T("%.1f 立方米"),GetVolume() / 1.e9,sInfoTip);
|
|
MAKEFIELD(_T("面积"),_T("%.1f 平方米"),GetArea() / 1.e6,sInfoTip);
|
|
|
|
MAKEFIELD(_T("材质"),_T("%s"),data.m_sMaterial,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),data.m_szNo,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
sField = _T("槽钢柱:\n");
|
|
sInfoTip += sField;
|
|
|
|
MAKEFIELD(_T("高度"),_T("%.1f 毫米"),data.m_dH,sInfoTip);
|
|
|
|
MAKEFIELD(_T("A"),_T("%.1f 毫米"),data.m_dSizes[0],sInfoTip);
|
|
MAKEFIELD(_T("B"),_T("%.1f 毫米"),data.m_dSizes[1],sInfoTip);
|
|
MAKEFIELD(_T("C"),_T("%.1f 毫米"),data.m_dSizes[2],sInfoTip);
|
|
MAKEFIELD(_T("D"),_T("%.1f 毫米"),data.m_dSizes[3],sInfoTip);
|
|
|
|
MAKEFIELD(_T("底标高"),_T("%.1f 毫米"),data.m_dBomEl,sInfoTip);
|
|
|
|
MAKEFIELD(_T("体积"),_T("%.1f 立方米"),GetVolume() / 1.e9,sInfoTip);
|
|
MAKEFIELD(_T("面积"),_T("%.1f 平方米"),GetArea() / 1.e6,sInfoTip);
|
|
|
|
MAKEFIELD(_T("材质"),_T("%s"),data.m_sMaterial,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),data.m_szNo,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = AecDbBDPipeBase::dwgInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
//----- Object version number needs to be read first
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es =pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
if ( version > AecDbColumn::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = AecDbBDPipeBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbColumn::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbColumn::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbColumn::ComparedTo(AecDbCurveBase* pCurOther) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbColumn* pColOther = AecDbColumn::cast(pCurOther);
|
|
if (pCurOther != NULL)
|
|
{
|
|
ColumnParam data;
|
|
GetColumnData(data);
|
|
|
|
ColumnParam data2;
|
|
pColOther->GetColumnData(data2);
|
|
|
|
if ( fabs(data.m_dH - data2.m_dH) > 1.e-1)
|
|
return 1;
|
|
|
|
if ( fabs(data.m_dBomEl - data2.m_dBomEl) > 1.e-1)
|
|
return 1;
|
|
|
|
if (data.m_nShape != data2.m_nShape)
|
|
return 1;
|
|
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
if ( fabs(data.m_dSizes[i] - data2.m_dSizes[i]) > 1.e-1)
|
|
return 1;
|
|
}
|
|
|
|
if ( fabs(data.m_dXScale - data2.m_dXScale) > 1.e-1)
|
|
return 1;
|
|
|
|
if ( fabs(data.m_dYScale - data2.m_dYScale) > 1.e-1)
|
|
return 1;
|
|
|
|
AcGePoint3d ptSta,ptEnd;
|
|
getStartPoint(ptSta);
|
|
getEndPoint(ptEnd);
|
|
|
|
AcGePoint3d ptSta2,ptEnd2;
|
|
pColOther->getStartPoint(ptSta2);
|
|
pColOther->getEndPoint(ptEnd2);
|
|
|
|
if (ptSta.distanceTo(ptSta2) > 3.0)//误差3毫米
|
|
return 1;
|
|
|
|
if (ptEnd.distanceTo(ptEnd2) > 3.0)//误差3毫米
|
|
return 1;
|
|
|
|
//如果体积不同
|
|
//double dVol1 = GetVolume();
|
|
//double dVol2 = pColOther->GetVolume();
|
|
|
|
//if ( fabs(dVol1 - dVol2) > 9.0)
|
|
// return 1;
|
|
|
|
return 0;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
SHJson::WValue& AecDbColumn::ToJson(bool bExprotGeo) const
|
|
{
|
|
assertReadEnabled();
|
|
return AecDbBDPipeBase::ToJson(bExprotGeo);
|
|
}
|
|
|
|
bool AecDbColumn::ByJson(const SHJson::WValue &v)
|
|
{
|
|
AssertWriteEnabled();
|
|
return AecDbBDPipeBase::ByJson(v);
|
|
}
|
|
|
|
#include "hlrcutoption.h"
|
|
void AecDbColumn::ProcessHlrResult(const AcArray<AcDbEntity *> &ar, const std::map<AcDbEntity *, AcArray<AcDbEntity *>> &preAr, AcArray<AcDbEntity *> &output) const
|
|
{
|
|
double dW(.0);
|
|
BOOL bBold = HlrCutOption::getEnvCutLW(this, dW);
|
|
|
|
HlrCutOption::ProcessHlrResult(this
|
|
, bBold
|
|
, dW
|
|
, FALSE
|
|
, ar
|
|
, preAr
|
|
, output);
|
|
}
|
|
|
|
void AecDbColumn::PreprocessForHlr(const AcGePoint3d &ptPlnO
|
|
, const AcGeVector3d &vtPlnN
|
|
, AcArray<AcDbEntity*> &ar) const
|
|
{
|
|
// 如果实体和剖面相交,标记
|
|
HlrCutOption::setIntersectWithSection(this, AcGePlane(ptPlnO, vtPlnN));
|
|
}
|
|
|
|
bool AecDbColumn::GetProperties(SimpleProperty::PropertySetByIndex & properties) const
|
|
{
|
|
/* 形状 尺寸 偏心 底标高 柱高 材质 */
|
|
|
|
AecDbBDPipeBase::GetProperties(properties);
|
|
CoreTools::setLayerPorperty(properties);
|
|
CoreTools::setSubSystemPorperty(properties);
|
|
|
|
ColumnParam data;
|
|
::memset(&data, 0, sizeof(ColumnParam));
|
|
GetColumnData(data);
|
|
|
|
CString sShape(_T("无"));
|
|
|
|
switch (data.m_nShape)
|
|
{
|
|
case 0:
|
|
SimpleProperty::makeAndInsert(properties, _T("形状"), _T("矩形"), false);
|
|
SimpleProperty::makeAndInsert(properties, _T("横向尺寸"), data.m_dXScale, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("纵向尺寸"), data.m_dYScale, true);
|
|
break;
|
|
case 1:
|
|
SimpleProperty::makeAndInsert(properties, _T("形状"), _T("圆形"), false);
|
|
SimpleProperty::makeAndInsert(properties, _T("直径"), data.m_dXScale, true);
|
|
break;
|
|
case 2:
|
|
SimpleProperty::makeAndInsert(properties, _T("形状"), _T("正六边形"), false);
|
|
SimpleProperty::makeAndInsert(properties, _T("边长"), data.m_dXScale, true);
|
|
break;
|
|
case 3:
|
|
SimpleProperty::makeAndInsert(properties, _T("形状"), _T("工字钢柱"), false);
|
|
SimpleProperty::makeAndInsert(properties, _T("型号"), data.m_sModel, false);
|
|
SimpleProperty::makeAndInsert(properties, _T("A"), data.m_dSizes[0], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("B"), data.m_dSizes[1], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("C"), data.m_dSizes[2], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("D"), data.m_dSizes[3], true);
|
|
break;
|
|
case 4:
|
|
SimpleProperty::makeAndInsert(properties, _T("形状"), _T("槽钢柱"), false);
|
|
SimpleProperty::makeAndInsert(properties, _T("型号"), data.m_sModel, false);
|
|
SimpleProperty::makeAndInsert(properties, _T("A"), data.m_dSizes[0], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("B"), data.m_dSizes[1], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("C"), data.m_dSizes[2], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("D"), data.m_dSizes[3], true);
|
|
break;
|
|
case 6: // 角柱
|
|
SimpleProperty::makeAndInsert(properties, _T("形状"), _T("构造柱"), false);
|
|
SimpleProperty::makeAndInsert(properties, _T("长度A"), data.m_dSizes[0], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("宽度A"), data.m_dSizes[2], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("长度B"), data.m_dSizes[1], true);
|
|
SimpleProperty::makeAndInsert(properties, _T("宽度B"), data.m_dSizes[3], true);
|
|
break;
|
|
case 7: // 构造柱
|
|
SimpleProperty::makeAndInsert(properties, _T("形状"), _T("角柱"), false);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
SimpleProperty::makeAndInsert(properties, _T("底标高"), data.m_dBomEl, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("柱高"), data.m_dH, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("材质"), data.m_sMaterial, true);
|
|
|
|
if (data.m_nShape != 6 && data.m_nShape != 7)
|
|
{
|
|
SimpleProperty::makeAndInsert(properties, _T("横轴偏心"), data.m_dXExtend, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("纵轴偏心"), data.m_dYExtend, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("转角"), data.m_dRotAngle, true);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void AecDbColumn::SetElev(const double & dElev)
|
|
{
|
|
AssertWriteEnabled();
|
|
ColumnParam data;
|
|
::memset(&data, 0, sizeof(ColumnParam));
|
|
GetColumnData(data);
|
|
|
|
AcDbCurve *pCur = GetBaseCurve();
|
|
if (!pCur) return;
|
|
|
|
AcDbLine *pLn = AcDbLine::cast(pCur);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
ptSta.z = dElev;
|
|
ptEnd.z = ptSta.z + data.m_dH;
|
|
|
|
AcGeVector3d vtOff(data.m_dXExtend, data.m_dXExtend, 0);
|
|
ptSta += vtOff;
|
|
ptEnd += vtOff;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
SetBaseCurve(ptSta, ptEnd);
|
|
}
|
|
delete pCur;
|
|
}
|
|
|
|
extern "C" AcDbRegion *GetColumnRegion(const ColumnParam &ColParam);
|
|
bool AecDbColumn::SetProperties(SimpleProperty::PropertySetByName & properties)
|
|
{
|
|
if (properties.m_set.empty())
|
|
return false;
|
|
|
|
AecDbBDPipeBase::SetProperties(properties);
|
|
|
|
AecDbObjXDataMap *pData = GetSpecialtyData(AcDb::kForWrite);
|
|
if (!pData) return false;
|
|
|
|
double dVal(.0);
|
|
|
|
if (properties.findAndSet(_T("底标高"), dVal))
|
|
SetElev(dVal);
|
|
if (properties.findAndSet(_T("柱高"), dVal))
|
|
SetHeight(dVal);
|
|
properties.findAndSet<CString>(_T("材质"), pData, KEY_MATERIAL);
|
|
properties.findAndSet<double>(_T("横轴偏心"), pData, KEY_XE);
|
|
properties.findAndSet<double>(_T("纵轴偏心"), pData, KEY_YE);
|
|
properties.findAndSet<double>(_T("转角"), pData, KEY_ROTATIONBK);
|
|
|
|
properties.findAndSet<double>(_T("横向尺寸"), pData, KEY_XS);
|
|
properties.findAndSet<double>(_T("纵向尺寸"), pData, KEY_YS);
|
|
|
|
|
|
if (properties.findAndSet(_T("直径"), dVal))
|
|
{
|
|
pData->SetAt(KEY_XS, dVal);
|
|
pData->SetAt(KEY_YS, dVal);
|
|
}
|
|
if (properties.findAndSet<double>(_T("边长"), dVal))
|
|
{
|
|
pData->SetAt(KEY_XS, dVal);
|
|
pData->SetAt(KEY_YS, dVal);
|
|
}
|
|
|
|
properties.findAndSet<double>(_T("A"), pData, KEY_SIZE1);
|
|
properties.findAndSet<double>(_T("B"), pData, KEY_SIZE2);
|
|
properties.findAndSet<double>(_T("C"), pData, KEY_SIZE3);
|
|
properties.findAndSet<double>(_T("D"), pData, KEY_SIZE4);
|
|
properties.findAndSet<double>(_T("长度A"), pData, KEY_SIZE1);
|
|
properties.findAndSet<double>(_T("长度B"), pData , KEY_SIZE2);
|
|
properties.findAndSet<double>(_T("宽度A"), pData , KEY_SIZE3);
|
|
properties.findAndSet<double>(_T("宽度B"), pData , KEY_SIZE4);
|
|
|
|
|
|
ColumnParam data;
|
|
::memset(&data, 0, sizeof(ColumnParam));
|
|
GetColumnData(data);
|
|
|
|
if (data.m_nShape == 6) // 角柱
|
|
{
|
|
AcGePoint3d ptGe[3];
|
|
AcGePoint3d ptA, ptB, ptInner;
|
|
double dA, dB;
|
|
GetAt(AecDbColumn::_JZ_PT_INNER, ptInner);
|
|
GetAt(AecDbColumn::_JZ_PT_A, ptA);
|
|
GetAt(AecDbColumn::_JZ_PT_B, ptB);
|
|
GetAt(KEY_SIZE1, dA);
|
|
GetAt(KEY_SIZE2, dB);
|
|
|
|
AcGeVector3d vt(ptA - ptInner);
|
|
vt.normalize();
|
|
vt *= dA;
|
|
ptA = ptInner + vt;
|
|
|
|
vt = ptB - ptInner;
|
|
vt.normalize();
|
|
vt *= dB;
|
|
ptB = ptInner + vt;
|
|
|
|
SetAt(AecDbColumn::_JZ_PT_INNER, ptInner);
|
|
SetAt(AecDbColumn::_JZ_PT_A, ptA);
|
|
SetAt(AecDbColumn::_JZ_PT_B, ptB);
|
|
|
|
AcDbRegion *pRegNew = makeJZRegion();
|
|
if (pRegNew)
|
|
SetSection(pRegNew, AcGePoint3d::kOrigin);
|
|
}
|
|
else
|
|
{
|
|
AcDbRegion *pRegAll = GetColumnRegion(data);
|
|
if (pRegAll)
|
|
SetSection(pRegAll, AcGePoint3d::kOrigin);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
extern AcDbPolyline *FormatPolyline(AcGePoint3d *ppPts, int nCount);
|
|
namespace
|
|
{
|
|
AcDbCurve* makeOffsetCurveByDir(AcDbPolyline* pCurve
|
|
, const double& dOffset
|
|
, const AcGeVector3d& vtDir)
|
|
{
|
|
if (!pCurve) return NULL;
|
|
int len(pCurve->numVerts());
|
|
if (len < 2) return NULL;
|
|
|
|
AcGeVector3d vt(vtDir);
|
|
vt.normalize();
|
|
|
|
AcGePoint3d ptS;
|
|
pCurve->getStartPoint(ptS);
|
|
|
|
AcDbRay ray;
|
|
ray.setUnitDir(vt);
|
|
ray.setBasePoint(ptS);
|
|
|
|
AcDbVoidPtrArray ar, ar2;
|
|
ar.removeAll();
|
|
pCurve->getOffsetCurves(dOffset, ar);
|
|
pCurve->getOffsetCurves(-dOffset, ar2);
|
|
|
|
// 没有都成功,那么,哪个成功用哪个。
|
|
if (!(!ar2.isEmpty() && !ar.isEmpty()))
|
|
{
|
|
AcDbVoidPtrArray &arr(ar.isEmpty() ? ar2 : ar);
|
|
if (arr.isEmpty()) return NULL;
|
|
AcDbCurve *pNew((AcDbCurve *)((AcDbCurve *)arr.first())->clone());
|
|
deleteArrayVoidPtrs< AcDbEntity>(arr);
|
|
return pNew;
|
|
}
|
|
|
|
AcDbCurve *pFir0 = (AcDbCurve *)ar.first();
|
|
AcDbCurve *pFir1 = (AcDbCurve *)ar2.first();
|
|
|
|
AcGePoint3dArray pts1, pts2;
|
|
pFir0->intersectWith(&ray, AcDb::kOnBothOperands, pts1);
|
|
pFir1->intersectWith(&ray, AcDb::kOnBothOperands, pts2);
|
|
|
|
AcDbPolyline *pNewCurve = NULL;
|
|
if (!pts1.isEmpty())
|
|
{
|
|
pNewCurve = (AcDbPolyline *)pFir0->clone();
|
|
deleteArrayVoidPtrs< AcDbEntity>(ar);
|
|
deleteArrayVoidPtrs< AcDbEntity>(ar2);
|
|
return pNewCurve;
|
|
}
|
|
|
|
if (!pts2.isEmpty())
|
|
{
|
|
pNewCurve = (AcDbPolyline *)pFir1->clone();
|
|
deleteArrayVoidPtrs< AcDbEntity>(ar);
|
|
deleteArrayVoidPtrs< AcDbEntity>(ar2);
|
|
return pNewCurve;
|
|
}
|
|
return pNewCurve;
|
|
}
|
|
|
|
AcDbCurve* makeCurve(AcDbPolyline* pPline, const std::vector<double>& arOffset, const AcGeVector3d& vtDir)
|
|
{
|
|
if (!pPline) return NULL;
|
|
|
|
if (!pPline->isOnlyLines()) return NULL;
|
|
|
|
int nSeg(pPline->numVerts() - 1);
|
|
|
|
if (nSeg > arOffset.size()) return NULL;
|
|
|
|
AcDbVoidPtrArray arCurves;
|
|
std::vector<AcGeLineSeg3d> segs;
|
|
AcGeLineSeg3d seg;
|
|
for (int i(0); i < nSeg; ++i)
|
|
{
|
|
AcDbPolyline* pCurve = (AcDbPolyline*)makeOffsetCurveByDir(pPline, arOffset[i], vtDir);
|
|
// 是第几个 polyline 就把自己的第几段seg取出来
|
|
if (pCurve)
|
|
{
|
|
pCurve->getLineSegAt(i, seg);
|
|
segs.push_back(seg);
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
}
|
|
|
|
if (segs.empty()) return NULL;
|
|
|
|
AcGePoint3dArray arpts, ar;
|
|
AcGeLineSeg3d seg1, seg2;
|
|
AcDbLine line1, line2;
|
|
for (int i(0); i < segs.size() - 1; ++i)
|
|
{
|
|
ar.removeAll();
|
|
line1.setStartPoint(segs[i].startPoint());
|
|
line1.setEndPoint(segs[i].endPoint());
|
|
line2.setStartPoint(segs[i + 1].startPoint());
|
|
line2.setEndPoint(segs[i + 1].endPoint());
|
|
if (line1.intersectWith(&line2, AcDb::kExtendBoth, ar) == Acad::eOk && !ar.isEmpty())
|
|
arpts.append(ar.first());
|
|
}
|
|
|
|
arpts.insertAt(0, segs[0].startPoint());
|
|
arpts.append(segs.rbegin()->endPoint());
|
|
|
|
return FormatPolyline(arpts.asArrayPtr(), arpts.length());
|
|
}
|
|
|
|
AcDbRegion* makeRegByPoly(AcDbPolyline* pPlS , AcDbPolyline* pPlE)
|
|
{
|
|
if (!pPlS)
|
|
{
|
|
return NULL;
|
|
}
|
|
if (!pPlE)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
AcGePoint3d pt;
|
|
AcGePoint3dArray ptAr;
|
|
ptAr.removeAll();
|
|
for (int i(0); i < pPlS->numVerts(); ++i)
|
|
{
|
|
pPlS->getPointAt(i, pt);
|
|
ptAr.append(pt);
|
|
}
|
|
|
|
for (int i(pPlS->numVerts() - 1); i >= 0; --i)
|
|
{
|
|
pPlE->getPointAt(i, pt);
|
|
ptAr.append(pt);
|
|
}
|
|
|
|
ptAr.append(ptAr.first());
|
|
|
|
return AecDbEarthWorm::CreatePolygonRegionOnly(ptAr.asArrayPtr(), ptAr.length());
|
|
}
|
|
|
|
AcDbRegion *makeRegion(const AcGePoint3d &ptInner
|
|
, const AcGePoint3d &ptA
|
|
, const AcGePoint3d &ptB
|
|
, const double &dThickA
|
|
, const double &dThickB )
|
|
{
|
|
AcGePoint3d ptGe[3] = { ptA, ptInner, ptB };
|
|
|
|
AcDbPolyline *pPoly = FormatPolyline(ptGe, 3);
|
|
if (!pPoly) return NULL;
|
|
|
|
|
|
AcGeVector3d vtA, vtB, vtAB;
|
|
vtA = (ptGe[1] - ptGe[0]).normalize();
|
|
vtB = (ptGe[1] - ptGe[2]).normalize();
|
|
vtAB = vtA + vtB;
|
|
vtAB.normalize();
|
|
std::vector<double> arDoubles;
|
|
arDoubles.clear();
|
|
arDoubles.push_back(dThickA);
|
|
arDoubles.push_back(dThickB);
|
|
AcDbPolyline *pPolyOff = (AcDbPolyline *)makeCurve(pPoly, arDoubles, vtAB);
|
|
if (pPolyOff)
|
|
{
|
|
AcDbRegion *pReg = makeRegByPoly(pPoly, pPolyOff);
|
|
DELETE_PTR(pPoly);
|
|
DELETE_PTR(pPolyOff);
|
|
|
|
AcGeVector3d vtMove = ptGe[1].asVector();
|
|
vtMove.negate();
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(vtMove);
|
|
pReg->transformBy(xform);
|
|
|
|
return pReg;
|
|
}
|
|
|
|
DELETE_PTR(pPoly);
|
|
return NULL;
|
|
}
|
|
|
|
}
|
|
|
|
AcDbRegion* AecDbColumn::makeJZRegion()
|
|
{
|
|
AcGePoint3d ptA, ptB, ptInner;
|
|
double dAW, dBW;
|
|
GetAt(_JZ_PT_INNER, ptInner);
|
|
GetAt(_JZ_PT_A, ptA);
|
|
GetAt(_JZ_PT_B, ptB);
|
|
GetAt(KEY_SIZE3, dAW);
|
|
GetAt(KEY_SIZE4, dBW);
|
|
|
|
AcDbRegion *pRegNew = makeRegion(ptInner, ptA, ptB, dAW, dBW);
|
|
if (!pRegNew) return NULL;
|
|
return pRegNew;
|
|
}
|