2040 lines
46 KiB
C++
2040 lines
46 KiB
C++
#include "StdAfx.h"
|
|
#include "StdArx.h"
|
|
#include "CoreTools.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "KTModelLayoutXData.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "AecDbEwFlexiblePipe.h"
|
|
#include "AcPolylineJig.h"
|
|
#include "CSWGXDlg.h"
|
|
#include "KTSetting.h"
|
|
#include "SMLOBJDlg.h"
|
|
#include "AecDbAssembleWell.h"
|
|
#include "ZJCJDlg.h"
|
|
#include "HydrantCalcDlg.h"
|
|
#include "LayoutExtinguisher.h"
|
|
#include "CSXHDlg.h"
|
|
#include "AecDbEwEquipment.h"
|
|
#include <AecDbEarthWorm.h>
|
|
#include <EquInsDirJig.h>
|
|
#include <AecDbWall.h>
|
|
#include <AecDbColumn.h>
|
|
#include <KTCadUtility.h>
|
|
#include <dbobjptr.h>
|
|
#include "CPenLinSetDlg.h"
|
|
#include "CJXPTDlg.h"
|
|
#include "CHXPTDlg.h"
|
|
#include "CZXPTDlg.h"
|
|
#include "CRYPTDlg.h"
|
|
#include "gearc2d.h"
|
|
#include "geometry2json.h"
|
|
|
|
|
|
|
|
namespace
|
|
{
|
|
template <typename T>
|
|
void setData(AecEqui::XPrimData* pXPData, void* pData)
|
|
{
|
|
::Sleep(30);
|
|
pXPData->m_nID = ::GetTickCount();
|
|
switch (pXPData->m_eType)
|
|
{
|
|
case AecEqui::kExtrude:
|
|
case AecEqui::kRevolve:
|
|
pXPData->m_nSize = ((AecEqui::XBuffer*)pData)->nSize;
|
|
if (pXPData->m_nSize > 0)
|
|
{
|
|
pXPData->m_pData = new byte[pXPData->m_nSize];
|
|
::memcpy(pXPData->m_pData, ((AecEqui::XBuffer*)pData)->pData, pXPData->m_nSize);
|
|
}
|
|
break;
|
|
default:
|
|
pXPData->m_pData = new T;
|
|
::memcpy(pXPData->m_pData, pData, sizeof(T));
|
|
pXPData->m_nSize = sizeof(T);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void clearData(AecEqui::XPrimData& data)
|
|
{
|
|
switch (data.m_eType)
|
|
{
|
|
case AecEqui::kExtrude:
|
|
case AecEqui::kRevolve:
|
|
DELETE_ARR_(data.m_pData);
|
|
break;
|
|
default:
|
|
DELETE_PTR(data.m_pData);
|
|
break;
|
|
}
|
|
return;
|
|
}
|
|
|
|
AcDbRegion* makeRectRegion(const AcGePoint3d& ptOrg
|
|
, const double& dL
|
|
, const double& dW
|
|
, const AcGeVector3d& vecL
|
|
, const AcGeVector3d& vecW
|
|
)
|
|
{
|
|
AcGePoint3d ptGe[5];
|
|
|
|
ptGe[0] = ptOrg + vecW * dW * .5;
|
|
ptGe[0] += vecL * dL * .5;
|
|
ptGe[1] = ptGe[0] - vecW * dW;
|
|
ptGe[2] = ptGe[1] - vecL * dL;
|
|
ptGe[3] = ptGe[2] + vecW * dW;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
return AecDbEarthWorm::CreatePolygonRegionOnly(ptGe, 5);
|
|
}
|
|
|
|
AcDbRegion* makeCirReg(const AcGePoint3d& ptMid, const AcGeVector3d& vtZ, const double& dR)
|
|
{
|
|
AcDbCircle* pCir(new AcDbCircle(ptMid, vtZ, dR));
|
|
if (!pCir) return NULL;
|
|
return CoreTools::createRegion(pCir);
|
|
}
|
|
|
|
AcDbCurve* makeOffsetCurveByDir(AcDbCurve* pCurve, const double& dOffset)
|
|
{
|
|
if (!pCurve) return NULL;
|
|
|
|
AcDbVoidPtrArray ar;
|
|
ar.removeAll();
|
|
|
|
pCurve->getOffsetCurves(dOffset, ar);
|
|
if (ar.isEmpty()) return NULL;
|
|
|
|
AcDbCurve* pNewCurve = (AcDbCurve*)(((AcDbEntity*)ar.first())->clone());
|
|
deleteArrayVoidPtrs< AcDbEntity>(ar);
|
|
|
|
return pNewCurve;
|
|
}
|
|
|
|
double CurveInOut(AcDbCurve* pCurveTop
|
|
, AcDbCurve* pCurveBottom
|
|
, const AcGePoint3d& pt
|
|
, const double& dWallDist)
|
|
{
|
|
double dDist(.0);
|
|
|
|
if (!pCurveTop || !pCurveBottom)
|
|
{
|
|
return dDist;
|
|
}
|
|
|
|
AcGePoint3d ptCurveTop, ptCurveBottom;
|
|
double dDistTop(.0), dDistBottom(.0);
|
|
Acad::ErrorStatus es = pCurveTop->getClosestPointTo(pt, ptCurveTop);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return dDist;
|
|
}
|
|
es = pCurveBottom->getClosestPointTo(pt, ptCurveBottom);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return dDist;
|
|
}
|
|
dDistTop = pt.distanceTo(ptCurveTop);
|
|
dDistBottom = pt.distanceTo(ptCurveBottom);
|
|
|
|
if (dDistBottom < dDistTop)
|
|
{
|
|
// 点在基点下方
|
|
dDist = -dWallDist;
|
|
}
|
|
else
|
|
{
|
|
dDist = dWallDist;
|
|
}
|
|
|
|
return dDist;
|
|
}
|
|
|
|
double getDistByOffCurve(AcDbCurve* pCurve
|
|
, const double& dOffDist
|
|
, const AcGePoint3d& pt
|
|
, const double& dEquW)
|
|
{
|
|
double dDist(.0);
|
|
|
|
if (!pCurve)
|
|
{
|
|
return dDist;
|
|
}
|
|
|
|
AcDbCurve* pCurveCln = (AcDbCurve*)pCurve->clone();
|
|
if (!pCurveCln)
|
|
{
|
|
return dDist;
|
|
}
|
|
|
|
AcDbCurve* pLineOffTop = (AcDbCurve*)makeOffsetCurveByDir(pCurveCln, dOffDist);
|
|
if (!pLineOffTop)
|
|
{
|
|
DELETE_PTR(pCurveCln);
|
|
return dDist;
|
|
}
|
|
AcDbCurve* pLineOffBottom = (AcDbCurve*)makeOffsetCurveByDir(pCurveCln, -dOffDist);
|
|
if (!pLineOffBottom)
|
|
{
|
|
DELETE_PTR(pCurveCln);
|
|
DELETE_PTR(pLineOffTop);
|
|
return dDist;
|
|
}
|
|
|
|
dDist = CurveInOut(pLineOffTop, pLineOffBottom, pt, dEquW);
|
|
|
|
DELETE_PTR(pCurveCln);
|
|
DELETE_PTR(pLineOffTop);
|
|
DELETE_PTR(pLineOffBottom);
|
|
|
|
return dDist;
|
|
}
|
|
|
|
void creatXHSEqu(const AcGePoint3dArray& ptAr
|
|
, const AcGeVector3dArray& vtAr
|
|
, LPCTSTR pszBlkPath
|
|
, const BOOL& bType
|
|
, const double& dL
|
|
, const double& dW
|
|
, const double& dProtectR)
|
|
{
|
|
if (ptAr.length() < 1 || vtAr.length() < 1)
|
|
{
|
|
return;
|
|
}
|
|
if (ptAr.length() != vtAr.length())
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcGeVector3d X(AcGeVector3d::kXAxis), Y(AcGeVector3d::kYAxis), Z(AcGeVector3d::kZAxis);
|
|
AcGePoint3d pt0(AcGePoint3d::kOrigin);
|
|
|
|
AecDbEwEquipment* pEqu = new AecDbEwEquipment();
|
|
|
|
AcGePoint3d pt, ptNozz;
|
|
AcGeVector3d vt, vtDir;
|
|
for (int i(0); i < ptAr.length(); ++i)
|
|
{
|
|
pt = ptAr.at(i);
|
|
vt = vtAr.at(i);
|
|
|
|
AcDbCircle* pCirProtect = new AcDbCircle(pt, Z, dProtectR);
|
|
pCirProtect->setColorIndex(6);
|
|
CoreTools::AddToModelSpace(pCirProtect);
|
|
|
|
vtDir = vt;
|
|
vtDir.rotateBy(PI / 2.0, Z);
|
|
vtDir.normalize();
|
|
|
|
// 消火栓
|
|
AcDbRegion* pReg = makeRectRegion(pt, dL, dW, vt, vtDir);
|
|
if (!pReg)
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
return;
|
|
}
|
|
NewExtrude extrudeXHS(true, pReg, dW);
|
|
DELETE_PTR(pReg);
|
|
AecEqui::XPrimData dataXHS;
|
|
dataXHS.m_eType = AecEqui::kNewExtrude;
|
|
dataXHS.m_bBoolSubtract = false;
|
|
dataXHS.m_iClr = 100;
|
|
extrudeXHS.toData(dataXHS.m_pData, dataXHS.m_nSize);
|
|
pEqu->AddSubPrimObj(&dataXHS);
|
|
clearData(dataXHS);
|
|
|
|
if (!bType)
|
|
{
|
|
ptNozz = pt + Z * dW;
|
|
CoreTools::addNozzForEqu_Rect(pEqu
|
|
, Z
|
|
, ptNozz
|
|
, dL * .1
|
|
, dL * .15
|
|
, dW * .1
|
|
, dW * .1
|
|
, dW * .1
|
|
, 0
|
|
, true
|
|
, false);
|
|
}
|
|
}
|
|
|
|
// 设置一些基本数据
|
|
pEqu->GetSpecialtyData()->SetAt(AecDbEwEquipment::_DRAW_2D_BY_BLK_LENGTH_, .5);
|
|
pEqu->GetSpecialtyData()->SetAt(AecDbEwEquipment::_DRAW_2D_BY_BLK_WIDTH_, .5);
|
|
pEqu->GetSpecialtyData()->SetAt(AecDbEwEquipment::_DRAW_2D_BY_BLK_PATH_, pszBlkPath);
|
|
|
|
CoreTools::AddToModelSpace(pEqu);
|
|
|
|
return;
|
|
}
|
|
|
|
void creatExtEqu(const AecDbEwEquipment* pEqu
|
|
, LPCTSTR pszBlkPath
|
|
, const AcGePoint3d& ptBox
|
|
, const AcGePoint3dArray& ptAr
|
|
, const AcGePoint3dArray& ptProtectAr
|
|
, const AcGeVector3dArray& vtAr
|
|
, const double& dScale
|
|
, const BOOL& bDrawBox
|
|
, const double& dBoxL
|
|
, const double& dBoxW
|
|
, const BOOL& bShowProtectR
|
|
, const double& dProtectR)
|
|
{
|
|
if (ptAr.length() < 1 || ptProtectAr.length() < 1 || vtAr.length() < 1)
|
|
{
|
|
return;
|
|
}
|
|
if (ptAr.length() != vtAr.length() || ptAr.length() != ptProtectAr.length() || ptProtectAr.length() != vtAr.length())
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcGeVector3d X(AcGeVector3d::kXAxis), Y(AcGeVector3d::kYAxis), Z(AcGeVector3d::kZAxis);
|
|
AcGePoint3d pt0(AcGePoint3d::kOrigin);
|
|
|
|
AcGePoint3d pt, ptProtect;
|
|
AcGeVector3d vt, vtDir;
|
|
for (int i(0); i < ptAr.length(); ++i)
|
|
{
|
|
pt = ptAr.at(i);
|
|
ptProtect = ptProtectAr.at(i);
|
|
vt = vtAr.at(i);
|
|
|
|
if (bShowProtectR)
|
|
{
|
|
AcDbCircle* pCir = new AcDbCircle(ptProtect, Z, dProtectR);
|
|
pCir->setColorIndex(6);
|
|
CoreTools::AddToModelSpace(pCir);
|
|
}
|
|
|
|
AecDbEwEquipment* pEquCl = (AecDbEwEquipment*)pEqu->clone();
|
|
if (!pEquCl)
|
|
{
|
|
return;
|
|
}
|
|
|
|
pEquCl->SetInsert(pt, vt);
|
|
|
|
// 设置一些基本数据
|
|
pEquCl->GetSpecialtyData()->SetAt(AecDbEwEquipment::_DRAW_2D_BY_BLK_WIDTH_, dScale);
|
|
pEquCl->GetSpecialtyData()->SetAt(AecDbEwEquipment::_DRAW_2D_BY_BLK_LENGTH_, dScale);
|
|
pEquCl->GetSpecialtyData()->SetAt(AecDbEwEquipment::_DRAW_2D_BY_BLK_PATH_, pszBlkPath);
|
|
|
|
CoreTools::AddToModelSpace(pEquCl);
|
|
|
|
AcDbCircle* pCir = new AcDbCircle(pt, AcGeVector3d::kZAxis, 50);
|
|
pCir->setColorIndex(3);
|
|
CoreTools::AddToModelSpace(pCir);
|
|
}
|
|
|
|
if (bDrawBox)
|
|
{
|
|
// 灭火器箱体
|
|
AecDbEwEquipment* pEquBox = new AecDbEwEquipment();
|
|
AcDbRegion* pReg = makeRectRegion(ptBox, dBoxL, dBoxW, X, Y);
|
|
if (!pReg)
|
|
{
|
|
return;
|
|
}
|
|
NewExtrude extrudeBox(true, pReg, dBoxW);
|
|
DELETE_PTR(pReg);
|
|
AecEqui::XPrimData dataBox;
|
|
dataBox.m_eType = AecEqui::kNewExtrude;
|
|
dataBox.m_bBoolSubtract = false;
|
|
dataBox.m_iClr = 100;
|
|
extrudeBox.toData(dataBox.m_pData, dataBox.m_nSize);
|
|
pEquBox->AddSubPrimObj(&dataBox);
|
|
clearData(dataBox);
|
|
CoreTools::AddToModelSpace(pEquBox);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
void creatExtinguish(const AecDbEwEquipment* pEqu
|
|
, LPCTSTR pszBlkPath
|
|
, const AcDbCurve* pCurve
|
|
, const AcGePoint3d& ptOnCurveOut
|
|
, const AcGePoint3d& ptOnCurve
|
|
, const int& nNum
|
|
, const double& dScale
|
|
, const BOOL& bDrawBox
|
|
, const double& dBoxL
|
|
, const double& dBoxW
|
|
, const BOOL& bShowProtectR
|
|
, const double& dProtectR)
|
|
{
|
|
if (!pCurve || !pEqu)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcGeVector3d X(AcGeVector3d::kXAxis), Y(AcGeVector3d::kYAxis), Z(AcGeVector3d::kZAxis);
|
|
AcGePoint3d pt0(AcGePoint3d::kOrigin);
|
|
|
|
AecDbEwEquipment* _pEquClone = (AecDbEwEquipment*)pEqu->clone();
|
|
if (!_pEquClone)
|
|
{
|
|
return;
|
|
}
|
|
AcDbCurve* pCurveClone = (AcDbCurve*)pCurve->clone();
|
|
if (!pCurveClone)
|
|
{
|
|
DELETE_PTR(_pEquClone);
|
|
return;
|
|
}
|
|
|
|
std::shared_ptr<AecDbEwEquipment>pEquClone(_pEquClone);
|
|
|
|
AcGePoint3d ptEquInsert;
|
|
AcGeVector3d vtEquInsert;
|
|
pEquClone->GetInsert(ptEquInsert, vtEquInsert);
|
|
AcDbCircle* pCir1 = new AcDbCircle(ptEquInsert, AcGeVector3d::kZAxis, 50);
|
|
pCir1->setColorIndex(6);
|
|
CoreTools::AddToModelSpace(pCir1);
|
|
CoreTools::CloneAndAddToModelSpace(_pEquClone);
|
|
|
|
AcDbExtents exts;
|
|
pEquClone->getGeomExtents(exts);
|
|
double dEquL = exts.maxPoint().x - exts.minPoint().x;
|
|
double dEquW = exts.maxPoint().y - exts.minPoint().y;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(pCurveClone);
|
|
AcDbArc* pArc = AcDbArc::cast(pCurveClone);
|
|
AcDbCircle* pCir = AcDbCircle::cast(pCurveClone);
|
|
if (!pLine && !pArc && !pCir)
|
|
{
|
|
acutPrintf(_T("\n存在除直线、弧线、圆形之外的曲线类型!"));
|
|
DELETE_PTR(pCurveClone);
|
|
return;
|
|
}
|
|
|
|
AcGePoint3dArray ptAr, ptProtectAr;
|
|
AcGeVector3dArray vtAr;
|
|
ptAr.removeAll();
|
|
ptProtectAr.removeAll();
|
|
vtAr.removeAll();
|
|
|
|
AcGePoint3d ptBox;
|
|
if (pLine)
|
|
{
|
|
AcGePoint3d ptS, ptE, ptEqu, ptCurveOut, ptCurve;
|
|
pLine->getStartPoint(ptS);
|
|
pLine->getEndPoint(ptE);
|
|
AcGeVector3d vt = (ptE - ptS).normalize();
|
|
|
|
pLine->getClosestPointTo(ptOnCurveOut, ptCurveOut);
|
|
double dOutDist = ptOnCurveOut.distanceTo(ptCurveOut);
|
|
|
|
pLine->getClosestPointTo(ptOnCurve, ptCurve);
|
|
|
|
double dDistOff(.0);
|
|
AcDbLine* pLineOff(NULL);
|
|
if (dOutDist < 1e-6)
|
|
{
|
|
dDistOff = .0;
|
|
}
|
|
else
|
|
{
|
|
dDistOff = getDistByOffCurve(pLine, dOutDist, ptOnCurveOut, dEquW * .5);
|
|
}
|
|
pLineOff = (AcDbLine*)makeOffsetCurveByDir(pLine, dDistOff);
|
|
if (!pLineOff)
|
|
{
|
|
DELETE_PTR(pCurveClone);
|
|
return;
|
|
}
|
|
|
|
AcGePoint3d ptInsert, ptProtect;
|
|
pLineOff->getClosestPointTo(ptCurve, ptInsert);
|
|
|
|
ptInsert -= vt * (dEquL * nNum * .5);
|
|
ptProtect = ptInsert + vt * dEquL * .5;
|
|
for (int i(0); i < nNum; ++i)
|
|
{
|
|
ptAr.append(ptInsert);
|
|
ptProtectAr.append(ptProtect);
|
|
vtAr.append(vt);
|
|
|
|
ptInsert += vt * dEquL;
|
|
ptProtect += vt * dEquL;
|
|
}
|
|
|
|
DELETE_PTR(pLineOff);
|
|
}
|
|
if (pArc)
|
|
{
|
|
AcGePoint3d ptS, ptE, ptC, pt;
|
|
pArc->getStartPoint(ptS);
|
|
pArc->getEndPoint(ptE);
|
|
ptC = pArc->center();
|
|
double dLenSE(.0);
|
|
pArc->getDistAtPoint(ptE, dLenSE);
|
|
|
|
AcGePoint3d ptCurveOut, ptCurve;
|
|
ptC = pArc->center();
|
|
|
|
pArc->getClosestPointTo(ptOnCurveOut, ptCurveOut);
|
|
double dOutDist = ptOnCurveOut.distanceTo(ptCurveOut);
|
|
|
|
pArc->getClosestPointTo(ptOnCurve, ptCurve);
|
|
|
|
double dDistOff(.0);
|
|
AcDbArc* pArcOff(NULL);
|
|
if (dOutDist < 1e-6)
|
|
{
|
|
dDistOff = .0;
|
|
}
|
|
else
|
|
{
|
|
dDistOff = getDistByOffCurve(pArc, dOutDist, ptOnCurveOut, dEquW * .5);
|
|
}
|
|
pArcOff = (AcDbArc*)makeOffsetCurveByDir(pArc, dDistOff);
|
|
if (!pArcOff)
|
|
{
|
|
DELETE_PTR(pCurveClone);
|
|
return;
|
|
}
|
|
|
|
AcGePoint3d ptInsert, ptProtect;
|
|
pArcOff->getClosestPointTo(ptCurve, ptInsert);
|
|
|
|
AcGeVector3d vt = (ptC - ptCurve).normalize();
|
|
AcGeVector3d vtDir = vt;
|
|
vtDir.rotateBy(PI / 2.0, Z);
|
|
vtDir.normalize();
|
|
|
|
ptInsert -= vtDir * (dEquL * nNum * .5);
|
|
ptProtect = ptInsert + vtDir * dEquL * .5;
|
|
|
|
for (int i(0); i < nNum; ++i)
|
|
{
|
|
ptAr.append(ptInsert);
|
|
ptProtectAr.append(ptProtect);
|
|
vtAr.append(vtDir);
|
|
|
|
ptInsert += vtDir * dEquL;
|
|
ptProtect += vtDir * dEquL;
|
|
}
|
|
|
|
DELETE_PTR(pArcOff);
|
|
}
|
|
if (pCir)
|
|
{
|
|
}
|
|
|
|
DELETE_PTR(pCurveClone);
|
|
|
|
creatExtEqu(pEqu, pszBlkPath, ptBox, ptAr, ptProtectAr, vtAr, dScale, bDrawBox, dBoxL, dBoxW, bShowProtectR, dProtectR);
|
|
|
|
return;
|
|
}
|
|
|
|
void creatXHS(const AcDbCurve* pCurve
|
|
, const AcGePoint3d& ptOnCurveOut
|
|
, const AcGePoint3d& ptOnCurve
|
|
, LPCTSTR pszBlkPath
|
|
, const BOOL& bType
|
|
, const double& dL
|
|
, const double& dW
|
|
, const double& dProtectR
|
|
, const double& dEquOffDist)
|
|
{
|
|
if (!pCurve)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcGeVector3d X(AcGeVector3d::kXAxis), Y(AcGeVector3d::kYAxis), Z(AcGeVector3d::kZAxis);
|
|
AcGePoint3d pt0(AcGePoint3d::kOrigin);
|
|
|
|
AcDbCurve* pCurveClone = (AcDbCurve*)pCurve->clone();
|
|
if (!pCurveClone)
|
|
{
|
|
return;
|
|
}
|
|
AcDbLine* pLine = AcDbLine::cast(pCurveClone);
|
|
AcDbArc* pArc = AcDbArc::cast(pCurveClone);
|
|
AcDbCircle* pCir = AcDbCircle::cast(pCurveClone);
|
|
if (!pLine && !pArc && !pCir)
|
|
{
|
|
acutPrintf(_T("\n存在除直线、弧线、圆形之外的曲线类型!"));
|
|
DELETE_PTR(pCurveClone);
|
|
return;
|
|
}
|
|
|
|
AcGePoint3dArray ptAr;
|
|
AcGeVector3dArray vtAr;
|
|
ptAr.removeAll();
|
|
vtAr.removeAll();
|
|
|
|
if (pLine)
|
|
{
|
|
AcGePoint3d ptS, ptE, ptEqu, ptCurveOut, ptCurve;
|
|
pLine->getStartPoint(ptS);
|
|
pLine->getEndPoint(ptE);
|
|
AcGeVector3d vt = (ptS - ptE).normalize();
|
|
AcGeVector3d vtDir = vt;
|
|
vtDir.rotateBy(PI / 2.0, Z);
|
|
vtDir.normalize();
|
|
|
|
pLine->getClosestPointTo(ptOnCurveOut, ptCurveOut);
|
|
double dOutDist = ptOnCurveOut.distanceTo(ptCurveOut);
|
|
|
|
pLine->getClosestPointTo(ptOnCurve, ptCurve);
|
|
|
|
if (dOutDist < 1e-6)
|
|
{
|
|
ptEqu = ptCurve;
|
|
}
|
|
else
|
|
{
|
|
double dOffDist = getDistByOffCurve(pLine, dOutDist, ptOnCurveOut, dEquOffDist);
|
|
|
|
ptEqu = ptCurve - vtDir * dOffDist;
|
|
}
|
|
|
|
ptAr.append(ptEqu);
|
|
vtAr.append(vt);
|
|
|
|
}
|
|
if (pArc)
|
|
{
|
|
AcGePoint3d ptC, ptEqu, ptCurveOut, ptCurve;
|
|
ptC = pArc->center();
|
|
|
|
pArc->getClosestPointTo(ptOnCurveOut, ptCurveOut);
|
|
double dOutDist = ptOnCurveOut.distanceTo(ptCurveOut);
|
|
|
|
pArc->getClosestPointTo(ptOnCurve, ptCurve);
|
|
|
|
AcGeVector3d vt = (ptOnCurve - ptC).normalize();
|
|
AcGeVector3d vtDir = vt;
|
|
vtDir.rotateBy(PI / 2.0, Z);
|
|
vtDir.normalize();
|
|
|
|
if (dOutDist < 1e-6)
|
|
{
|
|
ptEqu = ptCurve;
|
|
}
|
|
else
|
|
{
|
|
double dOffDist = getDistByOffCurve(pArc, dOutDist, ptOnCurveOut, dEquOffDist);
|
|
|
|
ptEqu = ptCurve + vt * dOffDist;
|
|
}
|
|
|
|
ptAr.append(ptEqu);
|
|
vtAr.append(vtDir);
|
|
}
|
|
if (pCir)
|
|
{
|
|
AcGePoint3d ptC, ptEqu, ptCurveOut, ptCurve;
|
|
ptC = pCir->center();
|
|
|
|
pCir->getClosestPointTo(ptOnCurveOut, ptCurveOut);
|
|
double dOutDist = ptOnCurveOut.distanceTo(ptCurveOut);
|
|
|
|
pCir->getClosestPointTo(ptOnCurve, ptCurve);
|
|
|
|
AcGeVector3d vt = (ptOnCurve - ptC).normalize();
|
|
AcGeVector3d vtDir = vt;
|
|
vtDir.rotateBy(PI / 2.0, Z);
|
|
vtDir.normalize();
|
|
|
|
if (dOutDist < 1e-6)
|
|
{
|
|
ptEqu = ptCurve;
|
|
}
|
|
else
|
|
{
|
|
double dOffDist = getDistByOffCurve(pCir, dOutDist, ptOnCurveOut, dEquOffDist);
|
|
|
|
ptEqu = ptCurve + vt * dOffDist;
|
|
}
|
|
|
|
ptAr.append(ptEqu);
|
|
vtAr.append(vtDir);
|
|
}
|
|
|
|
creatXHSEqu(ptAr, vtAr, pszBlkPath, bType, dL, dW, dProtectR);
|
|
|
|
DELETE_PTR(pCurveClone);
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
#define DXF_PIPE_ONLY _T("AEC_EWPIPE")
|
|
|
|
void CR_SCGXCmdFnc()
|
|
{
|
|
}
|
|
|
|
//默认给排水设置
|
|
void WD_CSSZCmdFnc()
|
|
{
|
|
AecDbObjXDataMap xDataMap;
|
|
|
|
//读取上次
|
|
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap);
|
|
|
|
//设置成给排水要求
|
|
{
|
|
xDataMap.SetAt(DOC_TRADE, WPipe::eCivial); //市政
|
|
xDataMap.SetAt(DOC_SCALE, _T("1:100")); //出图比例
|
|
xDataMap.SetAt(DOC_PLOTWIDTH, 0.5); //最小打印线宽
|
|
xDataMap.SetAt(DOC_DPLOTWIDTH, 0.0); //双线打印线宽
|
|
|
|
xDataMap.SetAt(DOC_WELDDIA, 0.0); //焊点直径
|
|
xDataMap.SetAt(DOC_PIPEMINDIA, 1.0); //最小管道直径
|
|
xDataMap.SetAt(DOC_PIPEMAXDIA, 1000.0); //管子最小双线直径
|
|
xDataMap.SetAt(DOC_PERELBOWDIA,100.0); //直角弯头直径
|
|
|
|
xDataMap.SetAt(DOC_BREAKSPACE, 2.0); //交叉断线间距
|
|
xDataMap.SetAt(DOC_UNIT, 0); //单位
|
|
xDataMap.SetAt(DOC_DIMTERM, 0); //标注端符
|
|
|
|
xDataMap.SetAt(DOC_DIMTXTH, 2.0); //标注文字高度
|
|
xDataMap.SetAt(DOC_DIMTXTF, 0.7); //标注文字宽度系数
|
|
|
|
xDataMap.SetAt(DOC_EQPTXTH, 2.0); //设备标注文字高度
|
|
xDataMap.SetAt(DOC_EQPTXTF, 1.0); //设备标注文字宽度系数
|
|
|
|
xDataMap.SetAt(DOC_STRTXTH, 2.0); //结构标注文字高度
|
|
xDataMap.SetAt(DOC_STRTXTF, 0.7); //结构标注文字宽度系数
|
|
|
|
//公称直径-系统
|
|
xDataMap.SetAt(DOC_SCRIPTT, _T("{0}{-}{12}"));//上标脚本
|
|
|
|
//标高
|
|
xDataMap.SetAt(DOC_SCRIPTB, _T("{5}")); //下标脚本
|
|
|
|
xDataMap.SetAt(DOC_ELTYPE, 0); //标高设置
|
|
xDataMap.SetAt(DOC_ELDESCR, _T("--")); //标高文本
|
|
|
|
// pid
|
|
xDataMap.SetAt(DOC_PIDMPIPE1W, 1.0); //主管道线宽
|
|
xDataMap.SetAt(DOC_PIDSPIPE1W, 0.25); //次管道线宽
|
|
xDataMap.SetAt(DOC_PIDINSRDN, 12); //仪表泡直径
|
|
|
|
xDataMap.SetAt(DOC_CONSIGN, 30.0); //续接符号
|
|
xDataMap.SetAt(DOC_EQUSCALE, 6.0); //设备比例
|
|
xDataMap.SetAt(DOC_LINEARSCALE, 10.0); //线性比例
|
|
xDataMap.SetAt(DOC_VALVESCALE, 100.0); //阀门比例
|
|
xDataMap.SetAt(DOC_NODESCALE, 6.0); //管嘴比例
|
|
|
|
xDataMap.SetAt(DOC_PIDBARROW, 6.0); //大箭头
|
|
xDataMap.SetAt(DOC_PIDMARROW, 3.0); //中箭头
|
|
xDataMap.SetAt(DOC_PIDSARROW, 1.5); //小箭头
|
|
|
|
xDataMap.SetAt(DOC_PIDEWITHDIM, TRUE); //设备插入标注
|
|
xDataMap.SetAt(DOC_PIDVWITHDIM, TRUE); //阀门插入标注
|
|
xDataMap.SetAt(DOC_PIDBRKSTYLE, 1); //管线打断样式,0-断开 1-绕过
|
|
xDataMap.SetAt(PID_PIPE_DPRESS,1.0); //设计压力
|
|
}
|
|
|
|
//默认写入本次
|
|
KTModelLayoutXData::WriteModelXData(KT_PIPEINIT,xDataMap);
|
|
}
|
|
|
|
//绘制管线
|
|
void WD_HZGXCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_DHGD "));
|
|
}
|
|
|
|
//引出管线
|
|
void WD_YCGXCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_YCGX "));
|
|
}
|
|
|
|
//管径变更
|
|
void WD_GJBGCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_GJBG "));
|
|
}
|
|
|
|
//管线套管
|
|
void WD_GXTGCmdFnc()
|
|
{
|
|
//选择管线,弹出界面
|
|
}
|
|
|
|
//端加弯头
|
|
void WD_DJWTCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_DJWT "));
|
|
}
|
|
|
|
//弯头连管
|
|
void WD_WTLGCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_WTLG1 "));
|
|
}
|
|
|
|
//管线连接
|
|
void WD_GXLJCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_WTLG1 "));
|
|
}
|
|
|
|
//管线变径
|
|
void WD_GXBJCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_GXBJ "));
|
|
}
|
|
|
|
//三通连接
|
|
void WD_STLJCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_TJST1 "));
|
|
}
|
|
|
|
//添加三通
|
|
void WD_DJSTCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_DJST "));
|
|
}
|
|
|
|
//添加四通
|
|
void WD_TJSTCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_TJST2 "));
|
|
}
|
|
|
|
//添加堵头
|
|
void WD_TJDTCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_TJDT "));
|
|
}
|
|
|
|
//插入法兰
|
|
void WD_CRFLCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_CRFL "));
|
|
}
|
|
|
|
//插对法兰
|
|
void WD_CDFLCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_CDFL "));
|
|
}
|
|
|
|
//遮挡断开
|
|
void WD_ZDDKCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_wBreak "));
|
|
}
|
|
|
|
//去除断开
|
|
void WD_QCDKCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_wDelbrk "));
|
|
}
|
|
|
|
//管端断管
|
|
void WD_GDDGCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_wBreakt "));
|
|
}
|
|
|
|
//管线虚段
|
|
void WD_GXXDCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_GXXD "));
|
|
}
|
|
|
|
//去除虚段
|
|
void WD_QCXDCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_QCXD "));
|
|
}
|
|
|
|
//合并管线
|
|
void WD_HBGXCmdFnc()
|
|
{
|
|
acedPostCommand(_T("PL_wmerge "));
|
|
}
|
|
|
|
//放置水箱
|
|
void WD_FZSXCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//放置水泵
|
|
void WD_FZSBCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//放置洁具
|
|
void WD_FZJJCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//消火栓箱
|
|
void WD_XHSXCmdFnc()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CSXHDlg dlg;
|
|
if (dlg.DoModal() != IDOK) return;
|
|
|
|
CString str = dlg.m_sListBoxValue;
|
|
std::vector<CString> vec;
|
|
vec.clear();
|
|
CoreTools::SplitString(str, _T('*'), vec);
|
|
if (vec.size() < 1) return;
|
|
|
|
double dL = TypeConvert::s2d(vec[0]);
|
|
double dW = TypeConvert::s2d(vec[1]);
|
|
|
|
double dProtectR = dlg.m_dProtectR * 1000;
|
|
double dXHSDist = dlg.m_dDist * 1000;
|
|
|
|
AcGeVector3d X(AcGeVector3d::kXAxis), Y(AcGeVector3d::kYAxis), Z(AcGeVector3d::kZAxis);
|
|
AcGePoint3d pt0(AcGePoint3d::kOrigin);
|
|
|
|
if (dlg.m_iLayout == 0)
|
|
{
|
|
ads_name ent;
|
|
ads_point adsPt;
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, _T("AEC_DBWALL,LINE,ARC"), 0);
|
|
int nRes = CKTCadUtility::SelectEntity(_T("\n请选择墙体, 直线, 弧线:"), ent, pRb, adsPt);
|
|
acutRelRb(pRb);
|
|
if (nRes != RTNORM)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ads_point adsPt1;
|
|
nRes = acedGetPoint(adsPt, _T("\n请选择方向:"), adsPt1);
|
|
if (nRes != RTNORM) return;
|
|
AcGePoint3d pt, pt1;
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt), pt);
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt1), pt1);
|
|
|
|
AcDbObjectId idWall;
|
|
Acad::ErrorStatus es = acdbGetObjectId(idWall, ent);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcDbEntityPointer entPtr(idWall, AcDb::kForRead);
|
|
if (entPtr.openStatus() != Acad::eOk)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AecDbXWall* pWall = AecDbXWall::cast(entPtr);
|
|
AcDbLine* pLine = AcDbLine::cast(entPtr);
|
|
AcDbArc* pArc = AcDbArc::cast(entPtr);
|
|
if (!pWall && !pLine && !pArc)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (pWall)
|
|
{
|
|
WallData data;
|
|
memset(&data, 0, sizeof(WallData));
|
|
pWall->GetWallData(data);
|
|
|
|
AcDbCurve* pCurve = pWall->GetBaseCurve();
|
|
if (!pCurve)
|
|
{
|
|
return;
|
|
}
|
|
|
|
creatXHS(pCurve, pt1, pt, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR, (data.dThick + dW) * .5 + dlg.m_dWallDist);
|
|
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
if (pLine)
|
|
{
|
|
creatXHS(pLine, pt1, pt, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR, dW * .5);
|
|
}
|
|
if (pArc)
|
|
{
|
|
creatXHS(pArc, pt1, pt, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR, dW * .5);
|
|
}
|
|
}
|
|
else if (dlg.m_iLayout == 1)
|
|
{
|
|
ads_point adsPt, adsPt1;
|
|
if (acedGetPoint(NULL, _T("\n请选择插入点:"), adsPt) != RTNORM)
|
|
{
|
|
return;
|
|
}
|
|
int nRes = acedGetPoint(adsPt, _T("\n请选择方向:"), adsPt1);
|
|
if (nRes != RTNORM) return;
|
|
|
|
AcGePoint3d pt, pt1;
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt), pt);
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt1), pt1);
|
|
|
|
AcGeVector3d vt = (pt - pt1).normalize();
|
|
AcGeVector3d vtDir = vt;
|
|
vtDir.rotateBy(PI / 2.0, Z);
|
|
vtDir.normalize();
|
|
|
|
AcGePoint3dArray ptAr;
|
|
AcGeVector3dArray vtAr;
|
|
ptAr.removeAll();
|
|
vtAr.removeAll();
|
|
|
|
ptAr.append(pt);
|
|
vtAr.append(vt);
|
|
|
|
creatXHSEqu(ptAr, vtAr, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR);
|
|
}
|
|
else
|
|
{
|
|
ads_name ent;
|
|
ads_point adsPt;
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, _T("AEC_DBWALL,LINE,ARC"), 0);
|
|
int nRes = CKTCadUtility::SelectEntity(_T("\n请选择墙体, 直线, 弧线:"), ent, pRb, adsPt);
|
|
acutRelRb(pRb);
|
|
if (nRes != RTNORM)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ads_point adsPt1;
|
|
nRes = acedGetPoint(adsPt, _T("\n请选择方向:"), adsPt1);
|
|
if (nRes != RTNORM) return;
|
|
AcGePoint3d pt, pt1;
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt), pt);
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt1), pt1);
|
|
|
|
AcDbObjectId idWall;
|
|
Acad::ErrorStatus es = acdbGetObjectId(idWall, ent);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcDbEntityPointer entPtr(idWall, AcDb::kForRead);
|
|
if (entPtr.openStatus() != Acad::eOk)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AecDbXWall* pWall = AecDbXWall::cast(entPtr);
|
|
AcDbLine* pLine = AcDbLine::cast(entPtr);
|
|
AcDbArc* pArc = AcDbArc::cast(entPtr);
|
|
if (!pWall && !pLine && !pArc)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (pWall)
|
|
{
|
|
WallData data;
|
|
memset(&data, 0, sizeof(WallData));
|
|
pWall->GetWallData(data);
|
|
|
|
AcDbCurve* pCurve = pWall->GetBaseCurve();
|
|
if (!pCurve)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcDbLine* pLineWall = AcDbLine::cast(pCurve);
|
|
AcDbArc* pArcWall = AcDbArc::cast(pCurve);
|
|
AcDbCircle* pCirWall = AcDbCircle::cast(pCurve);
|
|
if (!pLineWall && !pArcWall && !pCirWall)
|
|
{
|
|
acutPrintf(_T("\n存在除直线、弧线、圆形之外的曲线类型!"));
|
|
DELETE_PTR(pCurve);
|
|
return;
|
|
}
|
|
|
|
pCurve->getClosestPointTo(pt, pt);
|
|
|
|
double dPtDist(.0);
|
|
pCurve->getDistAtPoint(pt, dPtDist);
|
|
|
|
if (pLineWall)
|
|
{
|
|
AcGePoint3d ptS, ptE;
|
|
pLineWall->getStartPoint(ptS);
|
|
pLineWall->getEndPoint(ptE);
|
|
double dLenSE(.0);
|
|
pLineWall->getDistAtPoint(ptE, dLenSE);
|
|
double dDist = dLenSE - dXHSDist;
|
|
|
|
if (dPtDist < dDist)
|
|
{
|
|
pLineWall->getPointAtDist(dPtDist + dXHSDist, pt);
|
|
}
|
|
else
|
|
{
|
|
pLineWall->getPointAtDist(dPtDist - dXHSDist, pt);
|
|
}
|
|
|
|
creatXHS(pLineWall, pt1, pt, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR, (data.dThick + dW) * .5 + dlg.m_dWallDist);
|
|
}
|
|
if (pArcWall)
|
|
{
|
|
AcGePoint3d ptS, ptE;
|
|
pArcWall->getStartPoint(ptS);
|
|
pArcWall->getEndPoint(ptE);
|
|
double dLenSE(.0);
|
|
pArcWall->getDistAtPoint(ptE, dLenSE);
|
|
double dDist = dLenSE - dXHSDist;
|
|
|
|
if (dPtDist < dDist)
|
|
{
|
|
pArcWall->getPointAtDist(dPtDist + dXHSDist, pt);
|
|
}
|
|
else
|
|
{
|
|
pArcWall->getPointAtDist(dPtDist - dXHSDist, pt);
|
|
}
|
|
|
|
creatXHS(pArcWall, pt1, pt, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR, (data.dThick + dW) * .5 + dlg.m_dWallDist);
|
|
}
|
|
if (pCirWall)
|
|
{
|
|
pCirWall->getPointAtDist(dPtDist + dXHSDist, pt);
|
|
|
|
creatXHS(pCirWall, pt1, pt, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR, (data.dThick + dW) * .5 + dlg.m_dWallDist);
|
|
}
|
|
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
if (pLine)
|
|
{
|
|
AcGePoint3d ptS, ptE, ptEqu;
|
|
pLine->getStartPoint(ptS);
|
|
pLine->getEndPoint(ptE);
|
|
AcGeVector3d vt = (ptS - ptE).normalize();
|
|
AcGeVector3d vtDir = vt;
|
|
vtDir.rotateBy(PI / 2.0, Z);
|
|
vtDir.normalize();
|
|
double dLenSE(.0);
|
|
pLine->getDistAtPoint(ptE, dLenSE);
|
|
double dDist = dLenSE - dXHSDist;
|
|
|
|
pLine->getClosestPointTo(pt, pt);
|
|
|
|
double dPtDist(.0);
|
|
pLine->getDistAtPoint(pt, dPtDist);
|
|
|
|
if (dPtDist < dDist)
|
|
{
|
|
pLine->getPointAtDist(dPtDist + dXHSDist, pt);
|
|
}
|
|
else
|
|
{
|
|
pLine->getPointAtDist(dPtDist - dXHSDist, pt);
|
|
}
|
|
|
|
creatXHS(pLine, pt1, pt, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR, dW * .5);
|
|
}
|
|
if (pArc)
|
|
{
|
|
AcGePoint3d ptC, ptS, ptE;
|
|
ptC = pArc->center();
|
|
pArc->getStartPoint(ptS);
|
|
pArc->getEndPoint(ptE);
|
|
double dLenSE(.0);
|
|
pArc->getDistAtPoint(ptE, dLenSE);
|
|
double dDist = dLenSE - dXHSDist;
|
|
|
|
pArc->getClosestPointTo(pt, pt);
|
|
|
|
double dPtDist(.0);
|
|
pArc->getDistAtPoint(pt, dPtDist);
|
|
|
|
if (dPtDist < dDist)
|
|
{
|
|
pArc->getPointAtDist(dPtDist + dXHSDist, pt);
|
|
}
|
|
else
|
|
{
|
|
pArc->getPointAtDist(dPtDist - dXHSDist, pt);
|
|
}
|
|
|
|
creatXHS(pArc, pt1, pt, dlg.m_s2DSel, dlg.m_iType, dL, dW, dProtectR, dW * .5);
|
|
}
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
//布置喷头
|
|
void WD_PZPTCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//布雨水斗
|
|
void WD_BYSDCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//置灭火器
|
|
void WD_ZMHQCmdFnc()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CLayoutExtinguisher dlg;
|
|
if (dlg.DoModal() != IDOK) return;
|
|
|
|
AcGeVector3d X(AcGeVector3d::kXAxis), Y(AcGeVector3d::kYAxis), Z(AcGeVector3d::kZAxis);
|
|
AcGePoint3d pt0(AcGePoint3d::kOrigin);
|
|
|
|
double dExtProtectR = dlg.m_dExtProtectR * 1000;
|
|
|
|
AecDbEwEquipment* pEqu = dlg.getEquPtr();
|
|
if (!pEqu) return;
|
|
|
|
if (dlg.m_iLayout == 0)
|
|
{
|
|
ads_point adsPt;
|
|
int nRes = acedGetPoint(NULL, _T("\n请选择灭火器的插入点:"), adsPt);
|
|
if (nRes != RTNORM) return;
|
|
AcGePoint3d pt;
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt), pt);
|
|
|
|
AcDbExtents exts;
|
|
pEqu->getGeomExtents(exts);
|
|
double dL = exts.maxPoint().x - exts.minPoint().x;
|
|
double dW = exts.maxPoint().y - exts.minPoint().y;
|
|
|
|
AcGePoint3dArray ptAr, ptProtectAr;
|
|
AcGeVector3dArray vtAr;
|
|
ptAr.removeAll();
|
|
ptProtectAr.removeAll();
|
|
vtAr.removeAll();
|
|
|
|
AcGePoint3d ptInsert = pt + X * dlg.m_iExtCount * dL * -.5;
|
|
AcGePoint3d ptProtect = pt + X * (dlg.m_iExtCount * dL * -.5 + dL * .5);
|
|
|
|
for (int i(0); i < dlg.m_iExtCount; ++i)
|
|
{
|
|
ptAr.append(ptInsert);
|
|
ptProtectAr.append(ptProtect);
|
|
vtAr.append(X);
|
|
|
|
ptInsert += X * dL;
|
|
ptProtect += X * dL;
|
|
}
|
|
|
|
AcGePoint3d ptEquInsert;
|
|
AcGeVector3d vtEquInsert;
|
|
pEqu->GetInsert(ptEquInsert, vtEquInsert);
|
|
AcDbCircle* pCir1 = new AcDbCircle(ptEquInsert, AcGeVector3d::kZAxis, 50);
|
|
pCir1->setColorIndex(6);
|
|
CoreTools::AddToModelSpace(pCir1);
|
|
CoreTools::CloneAndAddToModelSpace(pEqu);
|
|
|
|
creatExtEqu(pEqu, dlg.m_s2DSel, pt, ptAr, ptProtectAr, vtAr, dlg.m_dExtScale, dlg.m_bDrawBox, dlg.m_dBoxL, dlg.m_dBoxW, dlg.m_bShowProtectR, dExtProtectR);
|
|
}
|
|
else
|
|
{
|
|
ads_name ent;
|
|
ads_point adsPt, adsPt1;
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, _T("LINE,ARC"), 0);
|
|
int nRes = CKTCadUtility::SelectEntity(_T("\n请选择直线, 弧线:"), ent, pRb, adsPt);
|
|
acutRelRb(pRb);
|
|
if (nRes != RTNORM)
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
return;
|
|
}
|
|
nRes = acedGetPoint(adsPt, _T("\n请选择方向:"), adsPt1);
|
|
if (nRes != RTNORM)
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
return;
|
|
}
|
|
AcGePoint3d pt, pt1;
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt), pt);
|
|
CoreTools::UCS2WCS(asPnt3d(adsPt1), pt1);
|
|
|
|
AcDbObjectId idWall;
|
|
Acad::ErrorStatus es = acdbGetObjectId(idWall, ent);
|
|
if (es != Acad::eOk)
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
return;
|
|
}
|
|
|
|
AcDbEntityPointer entPtr(idWall, AcDb::kForRead);
|
|
if (entPtr.openStatus() != Acad::eOk)
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
return;
|
|
}
|
|
|
|
AcDbCurve* pCurve = AcDbCurve::cast(entPtr);
|
|
if (!pCurve)
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
return;
|
|
}
|
|
|
|
creatExtinguish(pEqu, dlg.m_s2DSel, pCurve, pt1, pt, dlg.m_iExtCount, dlg.m_dExtScale, dlg.m_bDrawBox, dlg.m_dBoxL, dlg.m_dBoxW, dlg.m_bShowProtectR, dExtProtectR);
|
|
}
|
|
|
|
DELETE_PTR(pEqu);
|
|
|
|
return;
|
|
}
|
|
|
|
//排水附件
|
|
void WD_PSFJCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//给水附件
|
|
void WD_GSFJCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//消防附件
|
|
void WD_XFFJCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//设备连管
|
|
void WD_SBLGCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//设备占位
|
|
void WD_SBZWCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//设备设计
|
|
void WD_SBSJCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//设备族库
|
|
void WD_SBZKCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//室外管线
|
|
void WD_SWGXCmdFnc()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CSWGXDlg dlg;
|
|
if (IDOK == dlg.DoModal())
|
|
{
|
|
WPipe::PipeParam param;
|
|
memset(¶m, 0, sizeof(WPipe::PipeParam));
|
|
dlg.GetPipeParam(¶m);
|
|
|
|
AcPolylineJig jig;
|
|
jig.InitStatusRecsFor3dRoadAxisLine();
|
|
if (jig.DoIt())
|
|
{
|
|
AcDbObjectId id = jig.GetRoadAxisLineId();
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
|
{
|
|
AecDb3dRoadAxisLine *pRoadAxLn = AecDb3dRoadAxisLine::cast(pEnt);
|
|
if (pRoadAxLn != NULL)
|
|
{
|
|
//TEST
|
|
//AecDb3dRoadAxisLine *pRoadAxLnCln2 = (AecDb3dRoadAxisLine *)pRoadAxLn->clone();
|
|
//pRoadAxLnCln2->setColorIndex(2);
|
|
//CoreTools::AddToModelSpace(pRoadAxLnCln2);
|
|
|
|
pRoadAxLn->SaveDandRatio(param.m_dD, param.m_dRRatio);
|
|
//pRoadAxLn->Create3dRoadAxisLine(param.m_dD, param.m_dRRatio);
|
|
|
|
AecDb3dRoadAxisLine *pRoadAxLnCln = (AecDb3dRoadAxisLine *)pRoadAxLn->clone();
|
|
if (pRoadAxLnCln != NULL)
|
|
{
|
|
AecDbEwFlexiblePipe *pFlexiblePipe = new AecDbEwFlexiblePipe;
|
|
pFlexiblePipe->SetBaseCurve(pRoadAxLnCln);
|
|
pFlexiblePipe->SetSection(param.m_dD, 0.0);
|
|
|
|
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_DRAWGRAD, 1);//坡度 0不显示 1显示
|
|
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_NAME, _T("管线"));
|
|
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_YS, param.szSys);
|
|
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_D, param.m_dD);
|
|
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_RATIO, param.m_dRRatio);
|
|
|
|
//其他参数设置,参考pipelinecmd
|
|
//...
|
|
|
|
//通过全局设置提取
|
|
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_2DSTYLE, 0);//0单线 2双线
|
|
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_SINGLEW, 0);//单线宽度, 单线打印线宽
|
|
|
|
// 示例
|
|
AcDbObjectId idPipe = KTSetting::InitLayer(LAY_PIPE_SINGLE);
|
|
pFlexiblePipe->setLayer(idPipe);
|
|
|
|
CoreTools::AddToModelSpace(pFlexiblePipe);
|
|
}
|
|
}
|
|
|
|
//TEST
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//置检查井
|
|
void WD_ZJCJCmdFnc()
|
|
{
|
|
//
|
|
CAcModuleResourceOverride myResources;
|
|
CZJCJDlg dlg;
|
|
if (IDOK == dlg.DoModal())
|
|
{
|
|
//选择一点
|
|
|
|
}
|
|
}
|
|
|
|
//管线接井
|
|
void WD_GXJJCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//置消火栓
|
|
void WD_ZXHSCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//栓连管线
|
|
void WD_SLGXCmdFnc()
|
|
{
|
|
|
|
}
|
|
|
|
//双击井
|
|
DLLIMPEXP bool GetDoubleClickEnt(LPCTSTR pszCmd, AcDbObjectId &id);
|
|
void DBL_AEC_ASMBLWELL()
|
|
{
|
|
AcDbObjectId id;
|
|
bool bIsOk = GetDoubleClickEnt(_T("DBL_AEC_ASMBLWELL"), id);
|
|
if (bIsOk && id.isValid())
|
|
{
|
|
OPENOBJ_BEGIN(id, AcDb::kForWrite, AecDbAssembleWell, pWell)
|
|
|
|
if (pWell != NULL)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CSMLOBJDlg dlg;
|
|
|
|
CStringArray arLines;
|
|
pWell->GetScriptLines(arLines);
|
|
dlg.AddCodeLines(arLines);
|
|
dlg.SetXDataMap(pWell->GetSpecialtyData());
|
|
|
|
if (dlg.DoModal())
|
|
{
|
|
AecDbObjXDataMap::It it = dlg.m_xData.Begin();
|
|
AecDbObjXDataMap::It end = dlg.m_xData.End();
|
|
|
|
CString sKey;
|
|
AecXData xdata;
|
|
memset(&xdata, 0, sizeof(AecXData));
|
|
|
|
AecDbObjXDataMap* pMap = pWell->GetSpecialtyData();
|
|
|
|
for (; it != end; )
|
|
{
|
|
if (!dlg.m_xData.GetNext(it, sKey, xdata))
|
|
break;
|
|
pMap->SetAt(sKey, xdata);
|
|
}
|
|
}
|
|
}
|
|
|
|
OPENOBJ_END()
|
|
}
|
|
}
|
|
|
|
void WD_SKJS()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CHydrantCalcDlg dlg;
|
|
dlg.DoModal();
|
|
}
|
|
|
|
void WD_PLSZ()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CPenLinSetDlg dlg;
|
|
if (!dlg.DoModal() != IDOK) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//插入模型空间函数
|
|
void Insert_Model_Space(AcDbEntity* pEnt)
|
|
{
|
|
AcDbBlockTable* pBlkTbl = NULL;
|
|
Acad::ErrorStatus es;
|
|
AcDbDatabase* pDb = NULL;
|
|
pDb = acdbHostApplicationServices()->workingDatabase();
|
|
es = pDb->getBlockTable(pBlkTbl, AcDb::kForRead);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\n块表打开失败,错误代码:%s"), acadErrorStatusText(es));
|
|
return;
|
|
}
|
|
AcDbBlockTableRecord* pBlkTblRcd = NULL;
|
|
es = pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\n模型空间块表记录打开失败,错误代码:%s"), acadErrorStatusText(es));
|
|
pBlkTbl->close();
|
|
return;
|
|
}
|
|
pBlkTbl->close();
|
|
AcDbObjectId outId;
|
|
es = pBlkTblRcd->appendAcDbEntity(outId, pEnt);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\n无法添加实体到模型空间,错误代码:%s"), acadErrorStatusText(es));
|
|
pBlkTblRcd->close();
|
|
return;
|
|
}
|
|
pEnt->close();
|
|
pBlkTblRcd->close();
|
|
|
|
}
|
|
|
|
// 任意布置
|
|
void WD_BZPT_RY()
|
|
{/*
|
|
AecDbObjXDataMap xDataMap;
|
|
if (!CPenLinSetDlg::getPLSZData(xDataMap))
|
|
{
|
|
acedAlert(_T("\n喷淋系统没有初始化!请运行\"喷淋设置\"命令!"));
|
|
acedPostCommand(_T("wd_plsz "));
|
|
return;
|
|
}
|
|
|
|
|
|
int iDN(0);
|
|
xDataMap.GetAt(CPenLinSetDlg::_WD_PLSZ_CONNECT_DN_, iDN);
|
|
*/
|
|
CAcModuleResourceOverride myResources;
|
|
CRYPTDlg dlg;
|
|
if (dlg.DoModal() == IDOK)
|
|
{
|
|
//装点数组
|
|
AcGePoint3dArray points_arr;
|
|
//统计点数
|
|
int ptnumber = 0;
|
|
while (TRUE)
|
|
{
|
|
ads_point pt1;
|
|
int rtn1 = acedGetPoint(NULL, _T("\n 请选取喷头插入点"), pt1);
|
|
if (rtn1 == RTNORM)
|
|
{
|
|
points_arr.append(asPnt3d(pt1));
|
|
ptnumber++;
|
|
}
|
|
|
|
else if(rtn1 != RTNORM)
|
|
|
|
{
|
|
//测试
|
|
for (int i = 0; i < ptnumber; i++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcDbCircle* pCir = new AcDbCircle(points_arr[i], vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// 矩形布置
|
|
void WD_BZPT_JX()
|
|
{/*
|
|
AecDbObjXDataMap xDataMap;
|
|
if (!CPenLinSetDlg::getPLSZData(xDataMap))
|
|
{
|
|
acedAlert(_T("\n喷淋系统没有初始化!请运行\"喷淋设置\"命令!"));
|
|
acedPostCommand(_T("wd_plsz "));
|
|
return;
|
|
}
|
|
*/
|
|
//对话框测试
|
|
CAcModuleResourceOverride myResources;
|
|
CJXPTDlg dlg;
|
|
if (dlg.DoModal() == IDOK)
|
|
{
|
|
int nRow, nColumn=0;
|
|
ads_point pt1, pt2;
|
|
int rtn1 = acedGetPoint(NULL, _T("\n 请指定起点"), pt1);
|
|
int rtn2 = acedGetPoint(NULL, _T("\n 请指定对角点"), pt2);
|
|
if (rtn1 != RTNORM || rtn2 != RTNORM)
|
|
{
|
|
acutPrintf(_T("\n获取起点或者对角点失败"));
|
|
return;
|
|
}
|
|
//根据对角点找出四个角的顶点
|
|
ads_real x1 = pt1[X];
|
|
ads_real x2 = pt2[X];
|
|
ads_real y1 = pt1[Y];
|
|
ads_real y2 = pt2[Y];
|
|
//得到矩形的四个角
|
|
AcGePoint2d ptLeftBottom(min(x1, x2), min(y1, y2));
|
|
AcGePoint2d ptRightBottom(max(x1, x2), min(y1, y2));
|
|
AcGePoint2d ptRightTop(max(x1, x2), max(y1, y2));
|
|
AcGePoint2d ptLeftTop(min(x1, x2), max(y1, y2));
|
|
ads_real nRow_Dist = (ptRightTop[X] - ptLeftTop[X]);
|
|
ads_real nColumn_Dist = (ptRightTop[Y] - ptRightBottom[Y]);
|
|
//行列已知
|
|
AcArray<AcGePoint2dArray> arrs_Row;
|
|
AcArray<AcGePoint2dArray> arrs_Column;
|
|
if (dlg.m_ihlyz == 0)
|
|
{
|
|
nRow = dlg.m_iRow;
|
|
nColumn = dlg.m_iColumn;
|
|
//将行列已知的点均匀分布在矩形中
|
|
nRow_Dist = (ptRightTop[X] - ptLeftTop[X]) / nColumn;
|
|
nColumn_Dist = (ptRightTop[Y] - ptRightBottom[Y]) / nRow;
|
|
//将点按行放进数组
|
|
for (int j = 0; j < nRow; j++)
|
|
{
|
|
//ptFist为左上角第一点
|
|
AcGePoint2d ptFist(ptLeftTop[X] + 0.5 * nRow_Dist, ptLeftTop[Y] - 0.5 * nColumn_Dist - j * nColumn_Dist);
|
|
AcGePoint2dArray points_Row;
|
|
for (int i = 0; i < nColumn; i++)
|
|
{
|
|
AcGePoint2d pt_temp(ptFist[X] + i * nRow_Dist, ptFist[Y]);
|
|
points_Row.append(pt_temp);
|
|
}
|
|
arrs_Row.append(points_Row);
|
|
}
|
|
//将点按列放进数组
|
|
for (int j = 0; j < nColumn; j++)
|
|
{
|
|
AcGePoint2d ptFist(ptLeftTop[X] + 0.5 * nRow_Dist+j* nRow_Dist, ptLeftTop[Y] - 0.5 * nColumn_Dist );
|
|
AcGePoint2dArray points_Column;
|
|
for (int i = 0; i < nRow; i++)
|
|
{
|
|
AcGePoint2d pt_temp(ptFist[X] , ptFist[Y]-i* nColumn_Dist);
|
|
points_Column.append(pt_temp);
|
|
}
|
|
arrs_Column.append(points_Column);
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************************************************************/
|
|
//测试
|
|
if (dlg.m_iJGWay == 0)
|
|
{
|
|
for (int i = 0; i < nRow; i++)
|
|
{
|
|
for (int j = 0; j < nColumn; j++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcGePoint3d temp(arrs_Row[i][j][X], arrs_Row[i][j][Y], 0);
|
|
AcDbCircle* pCir = new AcDbCircle(temp, vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < nRow; i++)
|
|
{
|
|
AcGePoint2dArray points = arrs_Row[i];
|
|
int numVerts = points.length();
|
|
AcDbPolyline* pPline = new AcDbPolyline(numVerts);
|
|
for (int i = 0; i < points.length(); i++)
|
|
{
|
|
pPline->addVertexAt(i, points.at(i));
|
|
}
|
|
pPline->setClosed(true);
|
|
Insert_Model_Space(pPline);
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < nColumn; i++)
|
|
{
|
|
for (int j = 0; j < nRow; j++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcGePoint3d temp(arrs_Column[i][j][X], arrs_Column[i][j][Y], 0);
|
|
AcDbCircle* pCir = new AcDbCircle(temp, vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < nColumn; i++)
|
|
{
|
|
AcGePoint2dArray points = arrs_Column[i];
|
|
int numVerts = points.length();
|
|
AcDbPolyline* pPline = new AcDbPolyline(numVerts);
|
|
for (int i = 0; i < points.length(); i++)
|
|
{
|
|
pPline->addVertexAt(i, points.at(i));
|
|
}
|
|
pPline->setClosed(true);
|
|
Insert_Model_Space(pPline);
|
|
}
|
|
|
|
}
|
|
/**********************************************************************************************************************************/
|
|
|
|
|
|
}
|
|
//行列未知
|
|
else
|
|
{
|
|
//确定好需要的行列数
|
|
nRow = (nColumn_Dist / dlg.m_dMaxColumnDistance)+1;
|
|
nColumn = (nRow_Dist / dlg.m_dMaxRowDistance)+1;
|
|
//确定好左上角第一点
|
|
double Row_Dist_Temp = 0.5 * ( nRow_Dist- (nColumn - 1)* dlg.m_dMaxRowDistance);
|
|
double Column_Dist_Temp = 0.5 * ( nColumn_Dist- (nRow - 1) * dlg.m_dMaxColumnDistance);
|
|
//将点按行放进数组
|
|
for (int j = 0; j < nRow; j++)
|
|
{
|
|
//ptFist为左上角第一点
|
|
AcGePoint2d ptFist(ptLeftTop[X] + Row_Dist_Temp, ptLeftTop[Y] - Column_Dist_Temp - j * dlg.m_dMaxColumnDistance);
|
|
AcGePoint2dArray points_Row;
|
|
for (int i = 0; i < nColumn; i++)
|
|
{
|
|
AcGePoint2d pt_temp(ptFist[X] + i * dlg.m_dMaxRowDistance, ptFist[Y]);
|
|
points_Row.append(pt_temp);
|
|
}
|
|
arrs_Row.append(points_Row);
|
|
}
|
|
//将点按列放进数组
|
|
for (int j = 0; j < nColumn; j++)
|
|
{
|
|
AcGePoint2d ptFist(ptLeftTop[X] + Row_Dist_Temp + j * dlg.m_dMaxRowDistance, ptLeftTop[Y] - Column_Dist_Temp);
|
|
AcGePoint2dArray points_Column;
|
|
for (int i = 0; i < nRow; i++)
|
|
{
|
|
AcGePoint2d pt_temp(ptFist[X], ptFist[Y] - i * dlg.m_dMaxColumnDistance);
|
|
points_Column.append(pt_temp);
|
|
}
|
|
arrs_Column.append(points_Column);
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************************************************/
|
|
//测试
|
|
if (dlg.m_iJGWay == 0)
|
|
{
|
|
for (int i = 0; i < nRow; i++)
|
|
{
|
|
for (int j = 0; j < nColumn; j++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcGePoint3d temp(arrs_Row[i][j][X], arrs_Row[i][j][Y], 0);
|
|
AcDbCircle* pCir = new AcDbCircle(temp, vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < nRow; i++)
|
|
{
|
|
AcGePoint2dArray points = arrs_Row[i];
|
|
int numVerts = points.length();
|
|
AcDbPolyline* pPline = new AcDbPolyline(numVerts);
|
|
for (int i = 0; i < points.length(); i++)
|
|
{
|
|
pPline->addVertexAt(i, points.at(i));
|
|
}
|
|
pPline->setClosed(true);
|
|
Insert_Model_Space(pPline);
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < nColumn; i++)
|
|
{
|
|
for (int j = 0; j < nRow; j++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcGePoint3d temp(arrs_Column[i][j][X], arrs_Column[i][j][Y], 0);
|
|
AcDbCircle* pCir = new AcDbCircle(temp, vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < nColumn; i++)
|
|
{
|
|
AcGePoint2dArray points = arrs_Column[i];
|
|
int numVerts = points.length();
|
|
AcDbPolyline* pPline = new AcDbPolyline(numVerts);
|
|
for (int i = 0; i < points.length(); i++)
|
|
{
|
|
pPline->addVertexAt(i, points.at(i));
|
|
}
|
|
pPline->setClosed(true);
|
|
Insert_Model_Space(pPline);
|
|
}
|
|
|
|
}
|
|
/**********************************************************************************************************************************/
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
// 直线布置
|
|
void WD_BZPT_ZX()
|
|
{/*
|
|
AecDbObjXDataMap xDataMap;
|
|
if (!CPenLinSetDlg::getPLSZData(xDataMap))
|
|
{
|
|
acedAlert(_T("\n喷淋系统没有初始化!请运行\"喷淋设置\"命令!"));
|
|
acedPostCommand(_T("wd_plsz "));
|
|
return;
|
|
}
|
|
*/
|
|
CAcModuleResourceOverride myResources;
|
|
CZXPTDlg dlg;
|
|
//dlg.DoModal();
|
|
if (dlg.DoModal() == IDOK)
|
|
{
|
|
Acad::ErrorStatus es;
|
|
double LineDist = 0;
|
|
ads_point pt1, pt2;
|
|
int rtn1 = acedGetPoint(NULL, _T("\n 请指定起点"), pt1);
|
|
int rtn2 = acedGetPoint(NULL, _T("\n 请指定终点"), pt2);
|
|
if (rtn1 != RTNORM || rtn2 != RTNORM)
|
|
{
|
|
acutPrintf(_T("\n获取起点或者终点失败"));
|
|
return;
|
|
}
|
|
AcDbLine* pLine = new AcDbLine(asPnt3d(pt1), asPnt3d(pt2));
|
|
//获取直线长度
|
|
pLine->getDistAtPoint(asPnt3d(pt2), LineDist);
|
|
AcGePoint3dArray points_arr;
|
|
//已知点之间距离不知数量
|
|
AcGePoint3d ptDist;
|
|
int ptNumber = (LineDist / dlg.m_dMaxPTDistance) + 1;
|
|
double DistTopt1 = (LineDist - (dlg.m_dMaxPTDistance) * (ptNumber - 1)) * 0.5;
|
|
for (int i = 0; i < ptNumber; i++)
|
|
{
|
|
es = pLine->getPointAtDist(DistTopt1 + (dlg.m_dMaxPTDistance * i), ptDist);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\n获取失败,错误代码:%s"), acadErrorStatusText(es));
|
|
return;
|
|
}
|
|
points_arr.append(ptDist);
|
|
|
|
}
|
|
//测试
|
|
for (int i = 0; i < ptNumber; i++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcDbCircle* pCir = new AcDbCircle(points_arr[i], vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
}
|
|
Insert_Model_Space(pLine);
|
|
|
|
|
|
|
|
|
|
|
|
//已知数量不知点的距离
|
|
|
|
|
|
}
|
|
}
|
|
|
|
// 弧线布置
|
|
void WD_BZPT_HX()
|
|
{/*
|
|
AecDbObjXDataMap xDataMap;
|
|
if (!CPenLinSetDlg::getPLSZData(xDataMap))
|
|
{
|
|
acedAlert(_T("\n喷淋系统没有初始化!请运行\"喷淋设置\"命令!"));
|
|
acedPostCommand(_T("wd_plsz "));
|
|
return;
|
|
}
|
|
*/
|
|
//测试
|
|
CAcModuleResourceOverride myResources;
|
|
CHXPTDlg dlg;
|
|
if (dlg.DoModal() == IDOK)
|
|
{
|
|
Acad::ErrorStatus es;
|
|
double CurveDist = 0;
|
|
ads_point pt1, pt2, pt3;
|
|
int rtn1 = acedGetPoint(NULL, _T("\n 请指定起点"), pt1);
|
|
int rtn2 = acedGetPoint(NULL, _T("\n 请指定终点"), pt2);
|
|
int rtn3 = acedGetPoint(NULL, _T("\n 请指定圆弧上的点"), pt3);
|
|
if (rtn1 != RTNORM || rtn2 != RTNORM|| rtn3!= RTNORM)
|
|
{
|
|
acutPrintf(_T("\n获取圆弧失败"));
|
|
return;
|
|
}
|
|
//创造圆弧
|
|
AcGeCircArc3d geArc(asPnt3d(pt1), asPnt3d(pt3), asPnt3d(pt2));
|
|
AcDbArc* pArc = CoreTools::geArc2DbArc(geArc);
|
|
//强制类型转化
|
|
AcDbCurve* pCure = AcDbCurve::cast(pArc);
|
|
//获得弧长
|
|
pCure->getDistAtPoint(asPnt3d(pt2), CurveDist);
|
|
AcGePoint3dArray points_arr;
|
|
AcGePoint3d ptDist;
|
|
if (dlg.m_iDistance == 0)
|
|
{
|
|
//距离已知
|
|
int ptNumber = (CurveDist / dlg.m_dDistanceEdit) + 1;
|
|
double DistTopt1 = (CurveDist - (dlg.m_dDistanceEdit) * (ptNumber - 1)) * 0.5;
|
|
for (int i = 0; i < ptNumber; i++)
|
|
{
|
|
es = pCure->getPointAtDist(DistTopt1 + (dlg.m_dDistanceEdit * i), ptDist);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\n获取失败,错误代码:%s"), acadErrorStatusText(es));
|
|
return;
|
|
}
|
|
points_arr.append(ptDist);
|
|
|
|
}
|
|
//测试代码
|
|
for (int i = 0; i < ptNumber; i++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcDbCircle* pCir = new AcDbCircle(points_arr[i], vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
}
|
|
Insert_Model_Space(pArc);
|
|
}
|
|
else
|
|
{
|
|
//数量已知
|
|
double CurveDistSeg = CurveDist / (dlg.m_dNumberEdit - 1);
|
|
for (int i = 0; i < dlg.m_dNumberEdit; i++)
|
|
{
|
|
es = pCure->getPointAtDist(CurveDistSeg * i, ptDist);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\n获取失败,错误代码:%s"), acadErrorStatusText(es));
|
|
return;
|
|
}
|
|
points_arr.append(ptDist);
|
|
|
|
}
|
|
//测试代码
|
|
for (int i = 0; i < dlg.m_dNumberEdit; i++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcDbCircle* pCir = new AcDbCircle(points_arr[i], vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
|
|
}
|
|
Insert_Model_Space(pArc);
|
|
//测试代码结束
|
|
}
|
|
}
|
|
}
|
|
|
|
// 交点布置
|
|
void WD_BZPT_JD()
|
|
{
|
|
ads_point pt1,pt2;
|
|
ads_name ssName;
|
|
Adesk::Int32 len = 0;
|
|
int rtn1 = acedGetPoint(NULL, _T("\n 请选取起点"), pt1);
|
|
int rtn2 = acedGetPoint(NULL, _T("\n 请选取终点"), pt2);
|
|
acedSSGet(_T("W"),pt1, pt2, NULL, ssName);//参数W选择从点pt1到点pt2的窗口中的实体
|
|
acedSSLength(ssName, &len);
|
|
ads_name entName;
|
|
AcDbObjectId id;
|
|
AcDbEntity* pEnt = NULL;
|
|
//实体ID数组
|
|
AcDbObjectIdArray arrLines;
|
|
for (int i = 0; i < len; i++)
|
|
{
|
|
if (acedSSName(ssName, i, entName) == RTNORM)
|
|
{
|
|
acdbGetObjectId(id, entName);
|
|
acdbOpenObject(pEnt, id, AcDb::OpenMode::kForRead);
|
|
if (pEnt->isKindOf(AcDbCurve::desc()))
|
|
{
|
|
arrLines.append(pEnt->objectId());
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
AcGePoint3dArray ptArr;
|
|
int temp = arrLines.length();
|
|
acdbTransactionManager->startTransaction();
|
|
for (int i = 0; i < arrLines.length() - 1; i++)
|
|
{
|
|
AcDbCurve* pLineA = NULL;
|
|
if (acdbTransactionManager->getObject((AcDbObject*&)pLineA, arrLines[i], AcDb::kForRead) == Acad::eOk);
|
|
{
|
|
for (int j = i + 1; j < arrLines.length(); j++)
|
|
{
|
|
AcDbCurve* pLineB = NULL;
|
|
if (acdbTransactionManager->getObject((AcDbObject*&)pLineB, arrLines[j], AcDb::kForRead) == Acad::eOk)
|
|
{
|
|
pLineA->intersectWith(pLineB, AcDb::kOnBothOperands, ptArr);
|
|
//画圆测试交点代码
|
|
for (int i = 0; i < ptArr.length(); i++)
|
|
{
|
|
AcGeVector3d vec(0, 0, 1);
|
|
AcDbCircle* pCir = new AcDbCircle(ptArr[i], vec, 50);
|
|
Insert_Model_Space(pCir);
|
|
}
|
|
//测试结束
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
acdbTransactionManager->endTransaction();
|
|
}
|