Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

321 lines
9.5 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "stdafx.h"
#include "AecDbCableDoghouse.h"
#include "AecDbEarthWorm.h"
ACRX_DXF_DEFINE_MEMBERS (AecDbCableDoghouse, AecDbPortRoom,
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
AEC_CABLEDOGHOUSE,
"AecDbCableDoghouse"
"|Product Desc: shanghua earthworm app obj"
"|Company: shanghua inc"
"|WEB Address: www.shanghuasoft.com")
AecDbCableDoghouse::AecDbCableDoghouse(void)
{
//2.线缆类投料口
memset(&m_fncNode,0,sizeof(EWFnctNode));
m_fncNode.dDistFromPre = AS_MUNIT(13500.0);//13.5米位置
m_fncNode.eFnType = kCableDoghouse;
m_fncNode.nRoomIndex = 0;//舱0
m_fncNode.fNodeDef[0] = AS_MUNITF(1000.0f);//沿管廊方向内长
m_fncNode.fNodeDef[1] = AS_MUNITF(1000.0f);//管廊断面方向宽
m_fncNode.fNodeDef[2] = AS_MUNITF(1600.0f);//左室定位尺寸
_tcscpy(m_fncNode.szNodeSpec,_T("线缆类投料口"));
//房子描述尺寸
m_fncNode.fNodeDef[10] = AS_MUNITF(1350.0f);//房子左室定位尺寸
m_fncNode.fNodeDef[11] = AS_MUNITF(1500.0f);//房子横向宽
m_fncNode.fNodeDef[12] = AS_MUNITF(1750.0f);//房子纵向长
m_fncNode.fNodeDef[13] = AS_MUNITF(3000.0f);//房子高度
m_fncNode.fNodeDef[14] = AS_MUNITF(250.0f); //墙厚
m_fncNode.fNodeDef[15] = 1.0f; //钢筋混凝土活动盖板数量
m_fncNode.fNodeDef[16] = AS_MUNITF(1500.0f);//钢筋混凝土活动盖板宽
m_fncNode.fNodeDef[17] = AS_MUNITF(1750.0f);//钢筋混凝土活动盖板长
m_fncNode.fNodeDef[18] = AS_MUNITF(50.0f); //钢筋混凝土活动盖板厚
m_fncNode.fNodeDef[19] = AS_MUNITF(5050.f); //料口侧偏离管廊 X:
}
AecDbCableDoghouse::~AecDbCableDoghouse(void)
{
}
Acad::ErrorStatus AecDbCableDoghouse::dwgInFields (AcDbDwgFiler* pFiler)
{
assertWriteEnabled();
//----- Read parent class information first.
Acad::ErrorStatus es = AecDbPortRoom::dwgInFields (pFiler) ;
if ( es != Acad::eOk )
return (es) ;
return (pFiler->filerStatus ()) ;
}
Acad::ErrorStatus AecDbCableDoghouse::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled () ;
//----- Save parent class information first.
Acad::ErrorStatus es = AecDbPortRoom::dwgOutFields (pFiler) ;
if ( es != Acad::eOk )
return (es) ;
return (pFiler->filerStatus ()) ;
}
Acad::ErrorStatus AecDbCableDoghouse::dxfInFields (AcDbDxfFiler* pFiler)
{
assertWriteEnabled();
//----- Read parent class information first.
Acad::ErrorStatus es = AecDbPortRoom::dxfInFields (pFiler) ;
if ( es != Acad::eOk )
return (es) ;
return (pFiler->filerStatus ()) ;
}
Acad::ErrorStatus AecDbCableDoghouse::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled () ;
//----- Save parent class information first.
Acad::ErrorStatus es = AecDbPortRoom::dxfOutFields (pFiler) ;
if ( es != Acad::eOk )
return (es) ;
return (pFiler->filerStatus ()) ;
}
Acad::ErrorStatus AecDbCableDoghouse::Draw2d(AcGiDraw &dc) const
{
if ( Acad::eOk != AecDbPortRoom::Draw2d(dc))
{
//外部图块
}
return Acad::eOk;
}
Acad::ErrorStatus AecDbCableDoghouse::CreateDoghouse(ESection eSecType,const AcGePoint2dArray& arSizeDatas,AcGeLineSeg3d& ln,AecDbEarthWorm* pEW) const
{
if (pEW == NULL)
return Acad::eInvalidInput;
//ln和xy面的夹角
AcGeVector3d vtDir = ln.endPoint() - ln.startPoint();
vtDir.normalize();
AcGeVector3d vtDirXY = vtDir.orthoProject(AcGeVector3d::kZAxis);
double dAngle = vtDirXY.angleTo(vtDir);
//获取每个舱的三维位置
AcGePoint2d ptThick;
AcArray<ERoom> arRooms;
pEW->GetSectionRooms(eSecType,arSizeDatas,arRooms,ptThick,dAngle);
pEW->TransformRegionPerpToLine(arRooms,ln);
AcGePoint2d ptSize;
pEW->GetWidthAndHeight(eSecType,arSizeDatas,ln,ptSize,true);
/*
memset(&m_fncNode,0,sizeof(EWFnctNode));
m_fncNode.dDistFromPre = AS_MUNIT(13500.0);//13.5米位置
m_fncNode.eFnType = kCableDoghouse;
m_fncNode.nRoomIndex = 0;//舱0
m_fncNode.fNodeDef[0] = AS_MUNITF(1000.0f);//沿管廊方向内长
m_fncNode.fNodeDef[1] = AS_MUNITF(1000.0f);//管廊断面方向宽
m_fncNode.fNodeDef[2] = AS_MUNITF(1600.0f);//左室定位尺寸
_tcscpy(m_fncNode.szNodeSpec,_T("线缆类投料口"));
//房子描述尺寸
m_fncNode.fNodeDef[10] = AS_MUNITF(1350.0f);//房子左室定位尺寸
m_fncNode.fNodeDef[11] = AS_MUNITF(1500.0f);//房子横向宽
m_fncNode.fNodeDef[12] = AS_MUNITF(1750.0f);//房子纵向长
m_fncNode.fNodeDef[13] = AS_MUNITF(3000.0f);//房子高度
m_fncNode.fNodeDef[14] = AS_MUNITF(250.0f); //墙厚
m_fncNode.fNodeDef[15] = 1.0f; //钢筋混凝土活动盖板数量
m_fncNode.fNodeDef[16] = AS_MUNITF(1500.0f);//钢筋混凝土活动盖板宽
m_fncNode.fNodeDef[17] = AS_MUNITF(1750.0f);//钢筋混凝土活动盖板长
m_fncNode.fNodeDef[18] = AS_MUNITF(50.0f); //钢筋混凝土活动盖板厚
m_fncNode.fNodeDef[19] = AS_MUNITF(5050.0f);//房子伸出部分距离 X:
*/
double fNodef12 = m_fncNode.fNodeDef[12];
double fNodef20 = m_fncNode.fNodeDef[15] * m_fncNode.fNodeDef[16] + 4 * m_fncNode.fNodeDef[14];
if (fNodef20 - m_fncNode.fNodeDef[12] > 0.1)
{
fNodef12 = fNodef20;//???
}
const ERoom& room = arRooms.at(m_fncNode.nRoomIndex);
AcGeVector3d vtDirX = room.ptGe[1] - room.ptGe[0];
vtDirX.z = 0.0;
vtDirX.normalize();
if (m_fncNode.nRoomIndex == arRooms.length() - 1)
{
vtDirX.negate();
}
AcGePoint3d ptPos;
ptPos = room.ptGe[3]; //左上角点
if (m_fncNode.nRoomIndex == arRooms.length() - 1)
{
ptPos = room.ptGe[2]; //左上角点
}
ptPos.z += ptThick.x; //到顶面
ptPos += vtDir * m_fncNode.dDistFromPre;
ptPos += vtDirX * m_fncNode.fNodeDef[10];
AcGePoint3d ptGe[8],ptGeGB,ptGeFloor[8];
//
ptGe[0] = ptPos;
ptGe[1] = ptGe[0] + vtDirX * m_fncNode.fNodeDef[11];
ptGe[2] = ptGe[1] + vtDirXY * fNodef12;
ptGe[3] = ptGe[2] - vtDirX * (m_fncNode.fNodeDef[11] + m_fncNode.fNodeDef[19]);
ptGe[4] = ptGe[3] - vtDirXY * fNodef20;
ptGe[5] = ptGe[4] + vtDirX * m_fncNode.fNodeDef[19];
ptGe[6] = ptGe[5] - vtDirXY * (fNodef12 - fNodef20);
ptGeGB = ptGe[4];
memcpy(ptGeFloor,ptGe,sizeof(AcGePoint3d) * 8);
AcDbLine lnPath;
lnPath.setStartPoint(ptGe[0]);
lnPath.setEndPoint(ptGe[0] + m_fncNode.fNodeDef[13] * AcGeVector3d::kZAxis);
Acad::ErrorStatus es;
AcDbLine* pLn = NULL;
AcDbVoidPtrArray arLnPtrs,arRegPtrs;
for (int i = 0;i < 6;i++)
{
pLn = new AcDbLine(ptGe[i],ptGe[i+1]);
arLnPtrs.append(pLn);
}
es = AcDbRegion::createFromCurves(arLnPtrs,arRegPtrs);
if (arRegPtrs.length() == 0)
{
return Acad::eOk;
}
AcDbRegion* pRegOut = (AcDbRegion*)arRegPtrs.first();
AcDb3dSolid* pSolidAll = new AcDb3dSolid;
if ( Acad::eOk == ( es = pSolidAll->extrudeAlongPath(pRegOut,&lnPath) ) )
{
AddToSection2dDraw(arLnPtrs,0);
arRegPtrs.removeAll();arLnPtrs.removeAll();
///offset
//减去内部
ptGe[0] += vtDirXY * m_fncNode.fNodeDef[14];
ptGe[0] += vtDirX * m_fncNode.fNodeDef[14];
ptGe[1] += vtDirXY * m_fncNode.fNodeDef[14];
ptGe[1] -= vtDirX * m_fncNode.fNodeDef[14];
ptGe[2] -= vtDirXY * m_fncNode.fNodeDef[14];
ptGe[2] -= vtDirX * m_fncNode.fNodeDef[14];
ptGe[3] -= vtDirXY * m_fncNode.fNodeDef[14];
ptGe[3] += vtDirX * m_fncNode.fNodeDef[14];
ptGe[4] += vtDirXY * m_fncNode.fNodeDef[14];
ptGe[4] += vtDirX * m_fncNode.fNodeDef[14];
ptGe[5] += vtDirXY * m_fncNode.fNodeDef[14];
ptGe[5] += vtDirX * m_fncNode.fNodeDef[14];
ptGe[6] += vtDirXY * m_fncNode.fNodeDef[14];
ptGe[6] += vtDirX * m_fncNode.fNodeDef[14];
for (int i = 0;i < 6;i++)
{
pLn = new AcDbLine(ptGe[i],ptGe[i+1]);
arLnPtrs.append(pLn);
}
es = AcDbRegion::createFromCurves(arLnPtrs,arRegPtrs);
if (arRegPtrs.length() == 0)
{
DELETE_PTR(pSolidAll);
FreeBuffer(0,arRegPtrs);
return Acad::eOk;
}
AcDbRegion* pRegIn = (AcDbRegion*)arRegPtrs.first();
lnPath.setStartPoint(ptGe[0]);
lnPath.setEndPoint(ptGe[0] + ( m_fncNode.fNodeDef[13] - m_fncNode.fNodeDef[14]) * AcGeVector3d::kZAxis);
AcDb3dSolid* pSolidInt = new AcDb3dSolid;
if ( Acad::eOk == ( es = pSolidInt->extrudeAlongPath(pRegIn,&lnPath) ) )
{
if (Acad::eOk == ( es = pSolidAll->booleanOper(AcDb::kBoolSubtract,pSolidInt) ) )
{
//生成纵段2d实体
AcGePoint3d ptCen;
Midpoint(ptGe[0],ptGe[1],ptCen);
MakeVerSection2d(pSolidAll,ptCen);
//楼板厚度普遍在80~100mm之间,取90
lnPath.setStartPoint(ptGeFloor[0]);
lnPath.setEndPoint(ptGeFloor[0] - AS_MUNIT(90.0) * AcGeVector3d::kZAxis);
AcDb3dSolid* pSolidFloor = new AcDb3dSolid;
if ( Acad::eOk == ( es = pSolidFloor->extrudeAlongPath(pRegOut,&lnPath) ) )
{
if (Acad::eOk == ( es = pSolidAll->booleanOper(AcDb::kBoolUnite,pSolidFloor) ) )
{
Add3DBuffer(pSolidAll);
//m_ar3DDrableBufPtrs.append(pSolidAll);
}
}
DELETE_PTR(pRegOut);
}
}
ptPos = ptGeGB;
ptPos.z += m_fncNode.fNodeDef[13];
ptPos += vtDir * 2.0 * m_fncNode.fNodeDef[14];
ptPos += vtDirX * 2.0 * m_fncNode.fNodeDef[14];
int nSlabs = (int)(m_fncNode.fNodeDef[15] + 0.5f);
double dL = m_fncNode.fNodeDef[1];
double dW = m_fncNode.fNodeDef[16];
double dH = m_fncNode.fNodeDef[17];
for (int i = 0;i < nSlabs;i++ )
{
AcDb3dSolid* pSlab = AecDbEarthWorm::NewXBox(ptPos,dL,dW,dH,vtDirX,vtDirXY);
if (pSlab != NULL)
{
MakeVerSection2d(pSlab);
Add3DBuffer(pSlab);
//m_ar3DDrableBufPtrs.append(pSlab);
ptGe[0] = ptPos;
ptGe[1] = ptGe[0] + vtDirXY * dW;
ptGe[2] = ptGe[1] + vtDirX * dL;
ptGe[3] = ptGe[2] - vtDirXY * dW;
ptGe[4] = ptGe[0];
for (int ii = 0;ii < 4;ii++)
{
pLn = new AcDbLine(ptGe[ii],ptGe[ii+1]);
AddToSection2dDraw(pLn,0);
}
}
ptPos += vtDirXY * dW;
}
}
FreeBuffer(0,arRegPtrs);
FreeBuffer(0,arLnPtrs);
return Acad::eOk;
}