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

373 lines
11 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 "AecDbPipeDoghouse.h"
#include "AecDbEarthWorm.h"
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt,AcDbDatabase* pDb,bool bClose);
ACRX_DXF_DEFINE_MEMBERS (AecDbPipeDoghouse, AecDbPortRoom,
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
AEC_PIPEDOGHOUSE,
"AecDbPipeDoghouse"
"|Product Desc: shanghua earthworm app obj"
"|Company: shanghua inc"
"|WEB Address: www.shanghuasoft.com")
AecDbPipeDoghouse::AecDbPipeDoghouse(void)
{
memset(&m_fncNode,0,sizeof(EWFnctNode));
m_fncNode.dDistFromPre = AS_MUNIT(5000.0);//5米位置
m_fncNode.eFnType = kPipeDoghouse;
_tcscpy(m_fncNode.szNodeSpec,_T("管类投料口"));
m_fncNode.nRoomIndex = 0;//舱0
m_fncNode.fNodeDef[0] = AS_MUNITF(7000.0f);//沿管廊方向开口内长
m_fncNode.fNodeDef[1] = AS_MUNITF(1000.0f);//管廊断面方向宽
m_fncNode.fNodeDef[2] = AS_MUNITF(1600.0f);//左室定位尺寸
_tcscpy(m_fncNode.szNodeDefSpec,_T("管类投料口"));
//房子描述尺寸
m_fncNode.fNodeDef[10] = AS_MUNITF(1350.0f);//房子左室定位尺寸
m_fncNode.fNodeDef[11] = AS_MUNITF(4500.0f);//房子横向宽
m_fncNode.fNodeDef[12] = AS_MUNITF(7500.0f);//房子纵向长
m_fncNode.fNodeDef[13] = AS_MUNITF(3000.0f);//房子高度
m_fncNode.fNodeDef[14] = AS_MUNITF(250.0f); //墙厚
m_fncNode.fNodeDef[15] = 14.0f; //钢筋混凝土活动盖板数量
m_fncNode.fNodeDef[16] = AS_MUNITF(500.0f); //钢筋混凝土活动盖板宽
m_fncNode.fNodeDef[17] = AS_MUNITF(50.0f); //钢筋混凝土活动盖板厚
m_fncNode.fNodeDef[18] = AS_MUNITF(5050.0f); //料口侧偏离管廊 X:
m_fncNode.fNodeDef[19] = AS_MUNITF(3250.0f); //房子伸出部分宽度:
//m_fncNode.fNodeDef[30] = 1.0f * _ttoi(_T("123"));//新的方式
//m_fncNode.fNodeDef[31] = 1.0f * m_nDirPos;
}
AecDbPipeDoghouse::~AecDbPipeDoghouse(void)
{
}
Acad::ErrorStatus AecDbPipeDoghouse::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 AecDbPipeDoghouse::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 AecDbPipeDoghouse::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 AecDbPipeDoghouse::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 AecDbPipeDoghouse::Draw2d(AcGiDraw &dc) const
{
if ( Acad::eOk != AecDbPortRoom::Draw2d(dc))
{
//外部图块
}
return Acad::eOk;
}
Acad::ErrorStatus AecDbPipeDoghouse::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(5000.0);//5米位置
m_fncNode.eFnType = kPipeDoghouse;
_tcscpy(m_fncNode.szNodeSpec,_T("管类投料口"));
m_fncNode.nRoomIndex = 0;//舱0
m_fncNode.fNodeDef[0] = AS_MUNITF(7000.0f);//沿管廊方向开口内长
m_fncNode.fNodeDef[1] = AS_MUNITF(1000.0f);//管廊断面方向宽
m_fncNode.fNodeDef[2] = AS_MUNITF(1600.0f);//左室定位尺寸
_tcscpy(m_fncNode.szNodeDefSpec,_T("管类投料口"));
//房子描述尺寸
m_fncNode.fNodeDef[10] = AS_MUNITF(1350.0f);//房子左侧定位尺寸
m_fncNode.fNodeDef[11] = AS_MUNITF(4500.0f);//房子横向宽
m_fncNode.fNodeDef[12] = AS_MUNITF(7500.0f);//房子纵向长
m_fncNode.fNodeDef[13] = AS_MUNITF(3000.0f);//房子高度
m_fncNode.fNodeDef[14] = AS_MUNITF(250.0f); //墙厚
m_fncNode.fNodeDef[15] = 14.0f; //钢筋混凝土活动盖板数量
m_fncNode.fNodeDef[16] = AS_MUNITF(500.0f); //钢筋混凝土活动盖板横向宽
m_fncNode.fNodeDef[17] = AS_MUNITF(50.0f); //钢筋混凝土活动盖板厚
m_fncNode.fNodeDef[18] = AS_MUNITF(5050.0f); //房子伸出部分距离 X:
*/
double fNodef12 = m_fncNode.fNodeDef[12];
double fNodef19 = m_fncNode.fNodeDef[15] * m_fncNode.fNodeDef[16] + 4 * m_fncNode.fNodeDef[14];
if (fNodef19 - m_fncNode.fNodeDef[12] > 0.1)
{
fNodef12 = fNodef19;//???
}
CString sPos,sRoomCheck;
float fRoomCheck = m_fncNode.fNodeDef[30] + 0.2f;
int nRoomCheck = (int)(fRoomCheck);
int nRooms = 0;
sRoomCheck.Format(_T("%d"),nRoomCheck);
for(int i = 1;i <= 9;i++) //最多9 个舱室 123456789
{
sPos.Format(_T("%d"),i);
if (sRoomCheck.Find(sPos) != -1)
{
nRooms += 1;
}
}
int nRoomOutIndex = (int)( m_fncNode.fNodeDef[31] + 0.5f);
const ERoom& room1 = arRooms.first();
const ERoom& room2 = arRooms.last();
AcGeVector3d vtDirX = room1.ptGe[1] - room1.ptGe[0];
vtDirX.normalize();
AcGePoint3d ptPos;
if (nRoomOutIndex == 0)
{
ptPos = room1.ptGe[3]; //左上角点
ptPos.z += ptThick.x;
ptPos += vtDir * m_fncNode.dDistFromPre;
//ptPos += vtDirX * m_fncNode.fNodeDef[10];
}
else
{
ptPos = room2.ptGe[2]; //右上角点
ptPos.z += ptThick.x;
ptPos += vtDir * m_fncNode.dDistFromPre;
//ptPos -= vtDirX * m_fncNode.fNodeDef[10];
vtDirX.negate();
}
vtDirX.z = 0.0;
vtDirX.normalize();
if (m_fncNode.nRoomIndex > -0.00001)
{
nRooms = 1;
const ERoom& room = arRooms.at(m_fncNode.nRoomIndex);
AcGeVector3d vtDirX = room.ptGe[1] - room.ptGe[0];
if (m_fncNode.nRoomIndex == arRooms.length() - 1)
{
vtDirX.negate();
}
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[18]);
ptGe[4] = ptGe[3] - vtDirXY * fNodef19;
ptGe[5] = ptGe[4] + vtDirX * m_fncNode.fNodeDef[18];
ptGe[6] = ptGe[5] - vtDirXY * (fNodef12 - fNodef19);
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);
//AddToModelSpace((AcDbEntity*)pLn->clone(),NULL,true);
}
es = AcDbRegion::createFromCurves(arLnPtrs,arRegPtrs);
if (arRegPtrs.length() == 0)
{
DELETE_PTR(pSolidAll);
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) ) )
{
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];
AcGePoint3d ptPosBk = ptPos;
for (int k = 0;k < nRooms;k++)
{
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;
}
ptPos = ptPosBk;
ptPos += vtDirX * 3 * m_fncNode.fNodeDef[1];//示意
ptPosBk = ptPos;
}
}
FreeBuffer(0,arRegPtrs);
FreeBuffer(0,arLnPtrs);
return Acad::eOk;
}