5116 lines
115 KiB
C++
5116 lines
115 KiB
C++
#include "stdafx.h"
|
|
#include "encryption.h"
|
|
#include "AecDbSlab.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
#include "AecDbX3dPart.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "aecdbx3dpartentity.h"
|
|
#include "CoreTools.h"
|
|
#include "KTTempTol.h"
|
|
#include "AecDbWall.h"
|
|
#include <vector>
|
|
#include "simpleproperty.h"
|
|
#include "entityfilter.h"
|
|
|
|
extern CString IDCreate();
|
|
extern double PixelToWcs(int nPixel);
|
|
extern BOOL Is2DView();
|
|
extern AcGeVector3d GetUcsZvt();
|
|
extern void PushGripMessage(GripMessage&);
|
|
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt, AcDbDatabase* pDb = NULL, bool bClose = true);
|
|
extern int IsPointInPoly(int nvert, float *vertx, float *verty, float testx, float testy);
|
|
extern void transfromRegion(AcDbRegion *pRegion, const AcGePoint3d &ptOnRegion, const AcGeVector3d &vtNormal, const AcGePoint3d &ptOnPlan);
|
|
extern AcDbPolyline* PointsScrToPolyline(LPCTSTR pszPoint2ds);
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1, const AcGePoint3d& pt2);
|
|
extern void DLLIMPEXP OrthoProjected3DSolid(AcDb3dSolid* pSolidClone,const AcGePlane& plan,AcGeMatrix3d& xformPlanToWorld,AcDbVoidPtrArray& arEntPtrs);
|
|
extern AcDbRegion* CreateRetangeRegion(AcGePoint3d* pPoints,int nSize);
|
|
extern BOOL DLLIMPEXP GetDimGripOff();
|
|
|
|
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;
|
|
|
|
|
|
const CString AecDbXSlab::KEY_DB_Flag = _T("_KEY_DB_Flag_");
|
|
const CString AecDbXSlab::KEY_LB_Flag = _T("_KEY_LB_Flag_");
|
|
const CString AecDbXSlab::KEY_GB_Flag = _T("_KEY_GB_Flag_");
|
|
const CString AecDbXSlab::KEY_XDB_Flag = _T("_KEY_XDB_Flag_");
|
|
|
|
static AcGePoint3d Mid(AcGePoint3d& ptGe1,AcGePoint3d& ptGe2)
|
|
{
|
|
return AcGePoint3d( (ptGe1.x + ptGe2.x) / 2.0,
|
|
(ptGe1.y + ptGe2.y) / 2.0,
|
|
(ptGe1.z + ptGe2.z) / 2.0);
|
|
}
|
|
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 pEnt;
|
|
}
|
|
}
|
|
}
|
|
|
|
AcDbRegion* PolylineToRegion( AcDbPolyline* pPl)
|
|
{
|
|
AcDbVoidPtrArray arCurPtrs,arRegPtrs;
|
|
arCurPtrs.append(pPl);
|
|
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
return (AcDbRegion*)arRegPtrs.first();
|
|
}
|
|
acutPrintf(_T("\n1394"));
|
|
arCurPtrs.removeAll();
|
|
pPl->explode(arCurPtrs);
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
return (AcDbRegion*)arRegPtrs.first();
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
AcDbRegion* PointsScrToRegion(LPCTSTR pszPoint2ds)
|
|
{
|
|
AcDbPolyline* pPl = PointsScrToPolyline(pszPoint2ds);
|
|
if (pPl != NULL)
|
|
{
|
|
AcDbRegion* pReg = PolylineToRegion(pPl);
|
|
delete pPl;
|
|
return pReg;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbPolyline* PointsScrToPolyline(LPCTSTR pszPoint2ds)
|
|
{
|
|
AcDbPolyline* pPlT = CoreTools::StringToPolyline(pszPoint2ds);
|
|
if (pPlT != NULL)
|
|
return pPlT;
|
|
|
|
//OLD 2021-10-25
|
|
CStringArray arXYs;
|
|
CoreTools::SplitStrintToArray(pszPoint2ds,arXYs,_T(','));
|
|
|
|
CString sX,sYB,sBulge,sY;
|
|
double dBulge = 0.0;
|
|
int nFind = -1;
|
|
AcGePoint2d pt;
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
for (int i = 0;i < arXYs.GetSize() / 2 ;i++)
|
|
{
|
|
sX = arXYs.GetAt(2 * i);
|
|
sYB = arXYs.GetAt(2 * i + 1);
|
|
sY = sYB;
|
|
dBulge = 0.0;
|
|
|
|
nFind = sYB.Find( _T('@') );
|
|
if (nFind != -1)
|
|
{
|
|
sBulge = sYB.Mid(nFind + 1);
|
|
dBulge = _ttof(sBulge);
|
|
sY = sYB.Mid(0,nFind);
|
|
}
|
|
|
|
pt.set(_ttof(sX),_ttof(sY));
|
|
pPl->addVertexAt(i,pt,dBulge);
|
|
}
|
|
return pPl;
|
|
}
|
|
|
|
DLLIMPEXP AcDbCurve* GetOffsetCurve(AcDbCurve* pCurve,double dOffset,bool bGetInSide)
|
|
{
|
|
if (pCurve == NULL)
|
|
return NULL;
|
|
|
|
if (fabs(dOffset) < 1.e-3)
|
|
{
|
|
return (AcDbCurve*)pCurve->clone();
|
|
}
|
|
|
|
KTTempTol tol(1.e-3);
|
|
AcDbVoidPtrArray arCurOff1,arCurOff2;
|
|
pCurve->getOffsetCurves( dOffset,arCurOff1);
|
|
pCurve->getOffsetCurves(-dOffset,arCurOff2);
|
|
|
|
if (arCurOff1.length() == 1 && arCurOff2.length() == 1)
|
|
{
|
|
double dEnd = 0.0,dLen1 = 0.0,dLen2 = 0.0,dLen = 0.0;
|
|
AcDbCurve* pCurveT = NULL;
|
|
AcDbCurve* pCurve1 = (AcDbCurve*)arCurOff1.first();
|
|
AcDbCurve* pCurve2 = (AcDbCurve*)arCurOff2.first();
|
|
|
|
pCurve1->getEndParam(dEnd);
|
|
pCurve1->getDistAtParam(dEnd,dLen1);
|
|
|
|
pCurve2->getEndParam(dEnd);
|
|
pCurve2->getDistAtParam(dEnd,dLen2);
|
|
|
|
pCurve->getEndParam(dEnd);
|
|
pCurve->getDistAtParam(dEnd,dLen);
|
|
|
|
if (bGetInSide)
|
|
{
|
|
if (dLen1 - dLen < 1.e-6)//取最小内部
|
|
{
|
|
pCurveT = pCurve1;
|
|
delete pCurve2;
|
|
}
|
|
else
|
|
{
|
|
pCurveT = pCurve2;
|
|
delete pCurve1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (dLen1 - dLen > 1.e-6)//取最大外部
|
|
{
|
|
pCurveT = pCurve1;
|
|
delete pCurve2;
|
|
}
|
|
else
|
|
{
|
|
pCurveT = pCurve2;
|
|
delete pCurve1;
|
|
}
|
|
}
|
|
return pCurveT;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
DLLIMPEXP AcDbCurve* GetOffsetCurve(AcDbCurve* pCurve,double dOffset,const AcGeVector3d& vtToGet)
|
|
{
|
|
if (pCurve == NULL)
|
|
return NULL;
|
|
|
|
KTTempTol tol(1.e-3);
|
|
Acad::ErrorStatus es;
|
|
AcDbVoidPtrArray arCurOff1,arCurOff2;
|
|
es = pCurve->getOffsetCurves( dOffset,arCurOff1);
|
|
es = pCurve->getOffsetCurves(-dOffset,arCurOff2);
|
|
|
|
if (arCurOff1.length() == 1 && arCurOff2.length() == 1)
|
|
{
|
|
AcDbCurve* pCurve1 = (AcDbCurve*)arCurOff1.first();
|
|
AcDbCurve* pCurve2 = (AcDbCurve*)arCurOff2.first();
|
|
|
|
AcGePoint3d ptSta,ptSta1,ptSta2;
|
|
pCurve->getStartPoint(ptSta);
|
|
|
|
pCurve1->getStartPoint(ptSta1);
|
|
pCurve2->getStartPoint(ptSta2);
|
|
|
|
AcGeVector3d vt1 = ptSta1 - ptSta;
|
|
AcGeVector3d vt2 = ptSta2 - ptSta;
|
|
|
|
if (vt1.dotProduct(vtToGet) > 1.e-10)
|
|
{
|
|
delete pCurve2;
|
|
return pCurve1;
|
|
}
|
|
else
|
|
{
|
|
delete pCurve1;
|
|
return pCurve2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
acutPrintf(_T("\nOffset error:%d"),es);
|
|
AcDbCurve* pCln = (AcDbCurve*)pCurve->clone();
|
|
pCln->setColorIndex(1);
|
|
AddToModelSpace(pCln);
|
|
}
|
|
FreeBuffer(0,arCurOff1);
|
|
FreeBuffer(0,arCurOff2);
|
|
return NULL;
|
|
}
|
|
|
|
AcDbRegion* CreatePipeRegion(AcDbCurve* pOutSide,AcDbCurve* pInSide)
|
|
{
|
|
if (pOutSide == NULL)
|
|
return NULL;
|
|
|
|
if (pInSide == NULL)
|
|
return NULL;
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
arCurPtrs.append(pOutSide);
|
|
|
|
AcDbVoidPtrArray arRegPtrs;
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
if (arRegPtrs.length() == 0)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
AcDbRegion* pRegOut = (AcDbRegion*)arRegPtrs.first();
|
|
|
|
arCurPtrs.removeAll();
|
|
arCurPtrs.append(pInSide);
|
|
|
|
arRegPtrs.removeAll();
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
if (arRegPtrs.length() == 0)
|
|
{
|
|
delete pRegOut;
|
|
return NULL;
|
|
}
|
|
|
|
AcDbRegion* pRegIns = (AcDbRegion*)arRegPtrs.first();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ( Acad::eOk == (es = pRegOut->booleanOper(AcDb::kBoolSubtract,pRegIns)))
|
|
{
|
|
return pRegOut;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
bool PointsToScript(CString& sTop,AcGePoint3d* pptGe,int nCount)
|
|
{
|
|
CString sText;
|
|
double dBulge = 0.0;
|
|
sTop = _T("");
|
|
|
|
AcGePoint2d pt2d;
|
|
for (int i = 0;i < nCount;i++)
|
|
{
|
|
pt2d.set(pptGe[i].x,pptGe[i].y);
|
|
|
|
sText.Format(_T("%.9f,%.9f@%.9f,"),pt2d.x,pt2d.y,0.0);
|
|
sTop += sText;
|
|
}
|
|
|
|
sTop.TrimRight(_T(","));
|
|
return !sTop.IsEmpty();
|
|
}
|
|
|
|
Adesk::UInt32 AecDbXSlab::kCurrentVersionNumber = 2;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbXSlab, AecDbBDPipeBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DBSLAB,
|
|
"AecDbXSlab"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
AecDbXSlab::AecDbXSlab(void)
|
|
{
|
|
AcDbLine* pBaseLn = new AcDbLine;
|
|
pBaseLn->setStartPoint(AcGePoint3d::kOrigin);
|
|
pBaseLn->setEndPoint(AcGePoint3d(0,0,1));
|
|
m_pBaseCurve = pBaseLn;
|
|
m_mapSpecXData.SetAt(KEY_CENNODRAW,TRUE);
|
|
m_mapSpecXData.SetAt(KEY_NAME,_T("板"));
|
|
}
|
|
|
|
AecDbXSlab::~AecDbXSlab(void)
|
|
{
|
|
}
|
|
|
|
void AecDbXSlab::SetThick(double dThick)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
ptEnd.z = ptSta.z + dThick;
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
}
|
|
|
|
double AecDbXSlab::GetThick() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
double dW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE2,dW);
|
|
return dW;
|
|
}
|
|
else
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
return ptSta.distanceTo(ptEnd);
|
|
}
|
|
}
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
bool AecDbXSlab::SetRectSlab(double dW,double dThick,double dBomEl,const AcGePoint3d& ptFr,const AcGePoint3d& ptTo)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcGePoint3d ptSta,ptEnd;
|
|
ptSta = ptFr;ptSta.z = dBomEl;
|
|
ptEnd = ptTo;ptEnd.z = dBomEl;
|
|
AcDbLine ln(ptSta,ptEnd);
|
|
SetBaseCurve(&ln);
|
|
SetAsWallData(dW,dThick,0.0);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXSlab::SetRectSlab(double dL,double dW,double dThick,double dBomEl,const AcGePoint3d& ptCenPos)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//basecurve
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = ptSta.z + dThick;
|
|
|
|
AcGeVector3d vt = ptCenPos.asVector();
|
|
ptSta += vt;
|
|
ptEnd += vt;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
|
|
AcGePoint3dArray arSidePts;
|
|
AcGePoint3d pt;
|
|
|
|
pt.set(0,0,0);
|
|
pt.x -= dL * 0.5;
|
|
pt.y += dW * 0.5;
|
|
pt.z = 0.0;
|
|
|
|
arSidePts.append(pt);
|
|
|
|
pt.x += dL;
|
|
arSidePts.append(pt);
|
|
|
|
pt.y -= dW;
|
|
arSidePts.append(pt);
|
|
|
|
pt.x -= dL;
|
|
arSidePts.append(pt);
|
|
|
|
arSidePts.append(arSidePts.first());
|
|
|
|
AcDbRegion* pReg = AecDbEarthWorm::CreatePolygonRegionOnly(arSidePts.asArrayPtr(),arSidePts.length());
|
|
if (pReg != NULL)
|
|
{
|
|
SetSection(pReg,AcGePoint3d::kOrigin);
|
|
delete pReg;
|
|
}
|
|
|
|
pt = ptCenPos;
|
|
pt.z = dBomEl;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,pt,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_Length,dL);
|
|
GetSpecialtyData()->SetAt(KEY_Width,dW);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dThick);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eRect);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,TRUE);//平底
|
|
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::subDeepClone(AcDbObject *pOwnerObject
|
|
, AcDbObject *&pClonedObject
|
|
, AcDbIdMapping &idMap
|
|
, Adesk::Boolean isPrimary) const
|
|
{
|
|
Acad::ErrorStatus es = AecDbBDPipeBase::subDeepClone(pOwnerObject, pClonedObject, idMap, isPrimary);
|
|
if (es != Acad::eOk) return es;
|
|
|
|
AcDb::DeepCloneType dt = idMap.deepCloneContext();
|
|
if (dt == AcDb::kDcCopy
|
|
|| dt == AcDb::kDcObjects
|
|
|| dt == AcDb::kDcExplode
|
|
|| dt == AcDb::kDcInsertCopy )
|
|
{
|
|
// pCloneObject 中 m_arAssocPartEntIds 需要更新
|
|
AecDbXSlab *pClnSlab = AecDbXSlab::cast(pClonedObject);
|
|
|
|
for (int i = 0; i < m_arAssocPartEntIds.length(); i++)
|
|
{
|
|
const AcDbSoftPointerId &idOpening = m_arAssocPartEntIds[i];
|
|
if (!idOpening) continue;
|
|
AcDbIdPair idPairOpening(idOpening, AcDbObjectId::kNull, false, isPrimary ? true : false);
|
|
if (idMap.compute(idPairOpening))
|
|
{
|
|
if (pClnSlab)
|
|
{
|
|
// 删除旧的
|
|
pClnSlab->RemoveAssocPart(idOpening);
|
|
// 添加新的
|
|
pClnSlab->AppendAssocPart(idPairOpening.value());
|
|
|
|
// 板上没有门窗,只需要处理 X3dPartEntity 即可
|
|
AcDbObjectPointer<AecDbX3dPartEntity> pClnXPart(idPairOpening.value(), AcDb::kForWrite);
|
|
if (pClnXPart.openStatus() == Acad::eOk)
|
|
{
|
|
if (pClnSlab->id().isValid())
|
|
pClnXPart->SetAt(KEY_ASSOIC, pClnSlab->id());
|
|
}
|
|
|
|
}
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
AcDbObject *pSubObject = NULL;
|
|
acdbOpenAcDbObject(pSubObject, idOpening, AcDb::kForRead);
|
|
if (pSubObject != NULL)
|
|
{
|
|
AcDbObject *pClonedSubObject = NULL;
|
|
pSubObject->deepClone(pOwnerObject, pClonedSubObject, idMap, isPrimary);
|
|
|
|
if (pSubObject != pClonedSubObject)
|
|
{
|
|
pSubObject->close();
|
|
}
|
|
|
|
if (pClonedSubObject != NULL)
|
|
{
|
|
if (pClonedSubObject->objectId().isValid() && pClnSlab)
|
|
{
|
|
// 删除旧的
|
|
pClnSlab->RemoveAssocPart(idOpening);
|
|
// 添加新的
|
|
pClnSlab->AppendAssocPart(pClonedSubObject->objectId());
|
|
// 板上没有门窗,只需要处理 X3dPartEntity 即可
|
|
AecDbX3dPartEntity *pClnXPart = AecDbX3dPartEntity::cast(pClonedSubObject);
|
|
if (pClnXPart)
|
|
{
|
|
if (pClnSlab->id().isValid())
|
|
pClnXPart->SetAt(KEY_ASSOIC, pClnSlab->id());
|
|
}
|
|
}
|
|
pClonedSubObject->close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::subWblockClone(AcRxObject* pOwnerObject,
|
|
AcDbObject*& pClonedObject,
|
|
AcDbIdMapping& idMap,
|
|
Adesk::Boolean isPrimary/* = true*/) const
|
|
{
|
|
Acad::ErrorStatus es = AecDbBDPipeBase::subWblockClone(pOwnerObject, pClonedObject, idMap, isPrimary);
|
|
if (es != Acad::eOk) return es;
|
|
|
|
AcDb::DeepCloneType dt = idMap.deepCloneContext();
|
|
if (dt == AcDb::kDcCopy ||
|
|
dt == AcDb::kDcObjects ||
|
|
dt == AcDb::kDcWblock ||
|
|
dt == AcDb::kDcWblkObjects)
|
|
{
|
|
// pCloneObject 中 m_arAssocPartEntIds 需要更新
|
|
AecDbXSlab *pClnSlab = AecDbXSlab::cast(pClonedObject);
|
|
|
|
for (int i = 0; i < m_arAssocPartEntIds.length(); i++)
|
|
{
|
|
const AcDbSoftPointerId &idOpening = m_arAssocPartEntIds[i];
|
|
if (!idOpening) continue;
|
|
AcDbIdPair idPairOpening(idOpening, AcDbObjectId::kNull, false, isPrimary ? true : false);
|
|
if (idMap.compute(idPairOpening))
|
|
{
|
|
if (pClnSlab)
|
|
{
|
|
// 删除旧的
|
|
pClnSlab->RemoveAssocPart(idOpening);
|
|
// 添加新的
|
|
pClnSlab->AppendAssocPart(idPairOpening.value());
|
|
|
|
// 板上没有门窗,只需要处理 X3dPartEntity 即可
|
|
AcDbObjectPointer<AecDbX3dPartEntity> pClnXPart(idPairOpening.value(), AcDb::kForWrite);
|
|
if (pClnXPart.openStatus() == Acad::eOk)
|
|
{
|
|
if (pClnSlab->id().isValid())
|
|
pClnXPart->SetAt(KEY_ASSOIC, pClnSlab->id());
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
AcDbObject *pSubObject = NULL;
|
|
acdbOpenAcDbObject(pSubObject, idOpening, AcDb::kForRead);
|
|
if (pSubObject != NULL)
|
|
{
|
|
AcDbObject *pClonedSubObject = NULL;
|
|
pSubObject->wblockClone(pOwnerObject, pClonedSubObject, idMap, isPrimary);
|
|
|
|
if (pSubObject != pClonedSubObject)
|
|
{
|
|
pSubObject->close();
|
|
}
|
|
|
|
if (pClonedSubObject != NULL)
|
|
{
|
|
if (pClonedSubObject->objectId().isValid() && pClnSlab)
|
|
{
|
|
// 删除旧的
|
|
pClnSlab->RemoveAssocPart(idOpening);
|
|
// 添加新的
|
|
pClnSlab->AppendAssocPart(pClonedSubObject->objectId());
|
|
// 板上没有门窗,只需要处理 X3dPartEntity 即可
|
|
AecDbX3dPartEntity *pClnXPart = AecDbX3dPartEntity::cast(pClonedSubObject);
|
|
if (pClnXPart)
|
|
{
|
|
if (pClnSlab->id().isValid())
|
|
pClnXPart->SetAt(KEY_ASSOIC, pClnSlab->id());
|
|
}
|
|
}
|
|
|
|
pClonedSubObject->close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (!m_pRegion) return Acad::eOk;
|
|
|
|
AecDbBDPipeBase::subTransformBy(xform);
|
|
|
|
CString sPoint2dsTop;
|
|
if ( GetSpecialtyData()->GetAt(KEY_POINTS,sPoint2dsTop) )
|
|
{
|
|
AcDbPolyline* pPl = PointsScrToPolyline(sPoint2dsTop);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->transformBy(xform);
|
|
pPl->setClosed(Adesk::kTrue);
|
|
|
|
CString sPl;
|
|
CoreTools::PolylineToString(pPl,sPl,true);
|
|
|
|
GetSpecialtyData()->SetAt(KEY_POINTS,sPl);
|
|
|
|
AcGePoint3d ptCen;
|
|
if ( m_mapSpecXData.GetAt(KEY_SECCEN,ptCen) )
|
|
{
|
|
ptCen.transformBy(xform);
|
|
m_mapSpecXData.SetAt(KEY_SECCEN,ptCen);
|
|
}
|
|
|
|
m_pRegion->transformBy(xform);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbXSlab::SetCircleSlab(double dR,double dThick,double dBomEl,const AcGePoint3d& ptCenPos,BOOL bCenptAsMove)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//basecurve
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = ptSta.z + dThick;
|
|
|
|
if (bCenptAsMove)
|
|
{
|
|
AcGeVector3d vt = ptCenPos.asVector();
|
|
ptSta += vt;
|
|
ptEnd += vt;
|
|
}
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
|
|
AcGePoint3d ptCen3d(0,0,0);
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setCenter(ptCen3d);
|
|
pCir->setRadius(dR);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
AcDbVoidPtrArray arCurPtrs,arRegPtrs;
|
|
arCurPtrs.append(pCir);
|
|
|
|
AcDbRegion* pReg = NULL;
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
pReg = (AcDbRegion*)arRegPtrs.first();
|
|
if (pReg != NULL)
|
|
{
|
|
SetSection(pReg,AcGePoint3d::kOrigin);
|
|
delete pReg;
|
|
}
|
|
delete pCir;
|
|
|
|
AcGePoint3d pt = ptCenPos;
|
|
pt.z = dBomEl;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,pt,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_RAD,dR);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dThick);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eCircle);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,TRUE);//平底否
|
|
|
|
return true;
|
|
}
|
|
delete pCir;
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXSlab::SetSectorSlab(double dR, double dThick, double dBomEl, double dStaAng, double dEndAng, const AcGePoint3d &ptCenPos, BOOL bCenptAsMove)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//basecurve
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine *pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = ptSta.z + dThick;
|
|
|
|
if (bCenptAsMove)
|
|
{
|
|
AcGeVector3d vt = ptCenPos.asVector();
|
|
ptSta += vt;
|
|
ptEnd += vt;
|
|
}
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
|
|
|
|
AcGePoint3d ptCen3d(0, 0, 0);
|
|
AcDbArc *pArc = new AcDbArc;
|
|
pArc->setCenter(ptCen3d);
|
|
pArc->setRadius(dR);
|
|
pArc->setStartAngle(dStaAng);
|
|
pArc->setEndAngle(dEndAng);
|
|
pArc->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
AcDbVoidPtrArray arCurPtrs, arRegPtrs;
|
|
arCurPtrs.append(pArc);
|
|
|
|
AcGePoint3d pt;
|
|
AcDbLine *pLn1 = new AcDbLine;
|
|
pLn1->setStartPoint(ptCen3d);
|
|
pArc->getStartPoint(pt);
|
|
pLn1->setEndPoint(pt);
|
|
pLn1->setNormal(AcGeVector3d::kZAxis);
|
|
arCurPtrs.append(pLn1);
|
|
|
|
AcDbLine* pLn2 = new AcDbLine;
|
|
pLn2->setStartPoint(ptCen3d);
|
|
pArc->getEndPoint(pt);
|
|
pLn2->setEndPoint(pt);
|
|
pLn2->setNormal(AcGeVector3d::kZAxis);
|
|
arCurPtrs.append(pLn2);
|
|
|
|
AcDbRegion *pReg = NULL;
|
|
AcDbRegion::createFromCurves(arCurPtrs, arRegPtrs);
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
pReg = (AcDbRegion *)arRegPtrs.first();
|
|
if (pReg != NULL)
|
|
{
|
|
SetSection(pReg, AcGePoint3d::kOrigin);
|
|
delete pReg;
|
|
}
|
|
delete pArc;
|
|
delete pLn1;
|
|
delete pLn2;
|
|
|
|
AcGePoint3d pt = ptCenPos;
|
|
pt.z = dBomEl;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT, pt, TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_RAD, dR);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK, dThick);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL, _T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE, eCircle);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM, TRUE);//平底否
|
|
|
|
return true;
|
|
}
|
|
delete pArc;
|
|
delete pLn1;
|
|
delete pLn2;
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXSlab::SetRegionSlab(AcGePoint2dArray& arPts,double dThick,double dBomEl,const AcGePoint3d& ptCenPos)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//basecurve
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = ptSta.z + dThick;
|
|
|
|
AcGeVector3d vt = ptCenPos.asVector();
|
|
ptSta += vt;
|
|
ptEnd += vt;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
|
|
AcGePoint3dArray arPt3ds;
|
|
AcGePoint3d ptGe;
|
|
|
|
CString sText,sPoints = _T("");
|
|
for (int i = 0;i < arPts.length();i++)
|
|
{
|
|
ptGe.set(arPts.at(i).x,arPts.at(i).y,0.0);
|
|
arPt3ds.append(ptGe);
|
|
|
|
sText.Format(_T("%.9f,%.9f@%.9f,"), ptGe.x, ptGe.y, 0.0);
|
|
sPoints += sText;
|
|
}
|
|
|
|
//make closed
|
|
AcGePoint2d ptGe2d;
|
|
if (arPts.last().distanceTo(arPts.first()) > 1.e-2)
|
|
{
|
|
ptGe2d = arPts.first();
|
|
sText.Format(_T("%.9f,%.9f@0.0,"), ptGe2d.x, ptGe2d.y);
|
|
sPoints += sText;
|
|
}
|
|
sText.Format(_T("[%.9f;%.9f;%.9f;%.9f]"), dBomEl, 0.0, 0.0, 1.0);
|
|
sPoints += sText;
|
|
|
|
AcDbRegion* pReg = NULL;
|
|
pReg = AecDbEarthWorm::CreatePolygonRegionOnly(arPt3ds.asArrayPtr(),arPt3ds.length());
|
|
|
|
if (pReg != NULL)
|
|
{
|
|
//ptCenPos为创建region的pl的第一点
|
|
SetSection(pReg,ptCenPos);
|
|
delete pReg;
|
|
|
|
AcGePoint3d pt = ptCenPos;
|
|
pt.z = dBomEl;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,pt,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dThick);
|
|
GetSpecialtyData()->SetAt(KEY_POINTS,sPoints);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eUserDef);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,TRUE);//平底否
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXSlab::SetRegionSlab(LPCTSTR pszPoint2ds,double dThick,double dBomEl,const AcGePoint3d& ptCenPos)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//basecurve
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = ptSta.z + dThick;
|
|
|
|
AcGeVector3d vt = ptCenPos.asVector();
|
|
ptSta += vt;
|
|
ptEnd += vt;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
|
|
if (pszPoint2ds != NULL)
|
|
{
|
|
AcDbPolyline* pPl = CoreTools::StringToPolyline(pszPoint2ds);
|
|
if (pPl != NULL)
|
|
{
|
|
AcDbVoidPtrArray arCurPtrs,arRegPtrs;
|
|
//arCurPtrs.append(pPl);
|
|
pPl->explode(arCurPtrs);
|
|
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
AcDbRegion* pReg = NULL;
|
|
pReg = (AcDbRegion*)arRegPtrs.first();
|
|
|
|
if (pReg != NULL)
|
|
{
|
|
//ptCenPos为创建region的pl的第一点
|
|
SetSection(pReg,ptCenPos);
|
|
delete pReg;
|
|
|
|
AcGePoint3d pt = ptCenPos;
|
|
pt.z = dBomEl;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,pt,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dThick);
|
|
GetSpecialtyData()->SetAt(KEY_POINTS,pszPoint2ds);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eUserDef);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,TRUE);//平底否
|
|
}
|
|
delete pPl;
|
|
return true;
|
|
}
|
|
delete pPl;
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXSlab::SetFenceBasin(LPCTSTR pszPoint2dsTop,double dBomThick,double dWallHeight,double dWallWidth,double dCenBomEl)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcGePoint3d ptOrg(0,0,0);
|
|
AcGeVector3d vtZ(0,0,1);
|
|
|
|
AcDbRegion* pRegion = PointsScrToRegion(pszPoint2dsTop);
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbPolyline* pPl = CoreTools::StringToPolyline(pszPoint2dsTop);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->getPointAt(0, ptOrg);
|
|
DELETE_PTR(pPl);
|
|
}
|
|
//section
|
|
//AcDbExtents ext;
|
|
//pRegion->getGeomExtents(ext);
|
|
|
|
SetSection(pRegion, ptOrg);
|
|
delete pRegion;
|
|
|
|
//base curve
|
|
AcGePoint3d ptSta, ptEnd;
|
|
|
|
ptSta = ptOrg;
|
|
ptEnd = (ptOrg + vtZ * dBomThick);
|
|
|
|
AcGeVector3d vtZ(0, 0, dCenBomEl);
|
|
ptSta += vtZ;
|
|
ptEnd += vtZ;
|
|
|
|
AcDbLine ln;
|
|
ln.setStartPoint(ptSta);
|
|
ln.setEndPoint(ptEnd);
|
|
|
|
SetBaseCurve(&ln);
|
|
}
|
|
else
|
|
return false;
|
|
|
|
//序列化BIM数据
|
|
ptOrg.z = dCenBomEl;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptOrg,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dBomThick);
|
|
GetSpecialtyData()->SetAt(KEY_POINTS,pszPoint2dsTop);
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eUserDef);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,TRUE);//平底否
|
|
|
|
//墙体
|
|
GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
|
|
//添加墙体
|
|
AecDbX3dPart* pPart = NULL;
|
|
if (dWallHeight > 1.e-3 && dWallWidth > 1.e-3)
|
|
{
|
|
RemoveAllX3dPart();
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
pPart = new AecDbX3dPart;
|
|
pPart->SetName(_T("墙体"));
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
ptOrg.z += dBomThick;
|
|
pXSolid->CreateExtrude(ptOrg,vtZ,pszPoint2dsTop,dWallHeight,dWallWidth,TRUE);
|
|
pPart->AddX3dSolid(pXSolid,AcDb::kBoolUnite);
|
|
|
|
pPart->SetOrgPoint( ptOrg );
|
|
pPart->SetAxis(X,AcGeVector3d::kXAxis);
|
|
pPart->SetAxis(Y,AcGeVector3d::kYAxis);
|
|
pPart->SetAxis(Z,AcGeVector3d::kZAxis);
|
|
|
|
//序列化BIM数据
|
|
pPart->GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
pPart->GetSpecialtyData()->SetAt(_T("POIINTS"),pszPoint2dsTop);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_SHAPE,eUserDef);
|
|
AddX3dPart(pPart);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
typedef struct KBox
|
|
{
|
|
AcGePoint3d ptCen;
|
|
AcGePoint3d ptSize;
|
|
}KBOX;
|
|
|
|
|
|
bool AecDbXSlab::SetRectBasin(double dL,double dW,double dBomThick,double dWallHeight,double dWallWidth,const AcGePoint3d& ptCenPos)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
SetSection(dL,dW,0.0);
|
|
|
|
AcGePoint3d ptOrg(0,0,0);
|
|
AcGeVector3d vtZ(0,0,1);
|
|
|
|
AcGePoint3d ptSta = ptOrg;
|
|
AcGePoint3d ptEnd = ptOrg + vtZ * dBomThick;
|
|
|
|
//移动到真实位置
|
|
AcGeVector3d vt = ptCenPos.asVector();
|
|
ptSta += vt;
|
|
ptEnd += vt;
|
|
|
|
SetBaseCurve(ptSta,ptEnd);
|
|
|
|
//序列化BIM数据
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptCenPos,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_Length,dL);
|
|
GetSpecialtyData()->SetAt(KEY_Width,dW);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dBomThick);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eRect);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,TRUE);//平底
|
|
|
|
GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
|
|
AecDbX3dPart* pPart = NULL;
|
|
//围墙
|
|
ptOrg += vt;
|
|
ptOrg.z += dBomThick;
|
|
AcGePoint3d ptCen = ptOrg;
|
|
|
|
KBox kbox[4];
|
|
AcGePoint3d ptGe[5];
|
|
|
|
if (dWallHeight > 1.e-3 && dWallWidth > 1.e-3)
|
|
{
|
|
ptCen = ptOrg;
|
|
ptCen.y -= (0.5 * dW);
|
|
ptGe[0] = ptCen;
|
|
ptGe[0].x -= 0.5 * dL;
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1].x += dL;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2].y += dW;
|
|
|
|
ptGe[3] = ptGe[0];
|
|
ptGe[3].y += dW;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
CString sPoint2dsTop;
|
|
PointsToScript(sPoint2dsTop,ptGe,5);
|
|
|
|
//1.各面墙体
|
|
RemoveAllX3dPart();
|
|
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
pPart = new AecDbX3dPart;
|
|
pPart->SetName(_T("墙体"));
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
ptOrg.z += dBomThick;
|
|
pXSolid->CreateExtrude(ptOrg,vtZ,sPoint2dsTop,dWallHeight,dWallWidth,TRUE);
|
|
//pXSolid->AddMove(dBomThick * AcGeVector3d::kZAxis);
|
|
pPart->AddX3dSolid(pXSolid,AcDb::kBoolUnite);
|
|
|
|
pPart->SetOrgPoint( ptOrg );
|
|
pPart->SetAxis(X,AcGeVector3d::kXAxis);
|
|
pPart->SetAxis(Y,AcGeVector3d::kYAxis);
|
|
pPart->SetAxis(Z,AcGeVector3d::kZAxis);
|
|
|
|
//序列化BIM数据
|
|
pPart->GetSpecialtyData()->SetAt(KEY_L,dL);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_W,dW);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
pPart->GetSpecialtyData()->SetAt(_T("POIINTS"),sPoint2dsTop);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_SHAPE,eRect);
|
|
AddX3dPart(pPart);
|
|
|
|
/*ptCen = ptOrg;
|
|
ptCen.z += 0.5 * dWallHeight;
|
|
|
|
ptCen.y -= (0.5 * dW - 0.5 * dWallWidth);
|
|
kbox[0].ptCen = ptCen;
|
|
kbox[0].ptSize.set(dL,dWallWidth,dWallHeight);
|
|
|
|
ptCen.y += (dW - dWallWidth);
|
|
kbox[1].ptCen = ptCen;
|
|
kbox[1].ptSize.set(dL,dWallWidth,dWallHeight);
|
|
|
|
ptCen = ptOrg;
|
|
ptCen.z += 0.5 * dWallHeight;
|
|
|
|
ptCen.x -= (0.5 * dL - 0.5 * dWallWidth);
|
|
kbox[2].ptCen = ptCen;
|
|
kbox[2].ptSize.set(dWallWidth,dW - 2 * dWallWidth,dWallHeight);
|
|
|
|
ptCen.x += (dL - dWallWidth);
|
|
kbox[3].ptCen = ptCen;
|
|
kbox[3].ptSize.set(dWallWidth,dW - 2 * dWallWidth,dWallHeight);
|
|
*/
|
|
|
|
/*for(int i = 0;i < 4;i++)
|
|
{
|
|
pPart = new AecDbX3dPart;
|
|
pPart->SetName(_T("墙体"));
|
|
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,kbox[i].ptCen,vtZ,3,kbox[i].ptSize.x,kbox[i].ptSize.y,kbox[i].ptSize.z);
|
|
pPart->AddX3dSolid(pXSolid,AcDb::kBoolUnite);
|
|
|
|
pPart->SetOrgPoint( kbox[i].ptCen );
|
|
pPart->SetAxis(X,AcGeVector3d::kXAxis);
|
|
pPart->SetAxis(Y,AcGeVector3d::kYAxis);
|
|
pPart->SetAxis(Z,AcGeVector3d::kZAxis);
|
|
|
|
//序列化BIM数据
|
|
pPart->GetSpecialtyData()->SetAt(KEY_Length,i < 2 ? dL : dW );
|
|
pPart->GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
pPart->GetSpecialtyData()->SetAt(KEY_SHAPE,eRect);
|
|
AddX3dPart(pPart);
|
|
}*/
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//dR 为池外径
|
|
bool AecDbXSlab::SetCircleBasin(double dR,double dBomThick,double dWallHeight,double dWallWidth,const AcGePoint3d& ptCenPos)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcGePoint3d ptOrg(0,0,0);
|
|
AcGeVector3d vtZ(0,0,1);
|
|
|
|
if (dWallWidth > 1.e-3)
|
|
{
|
|
dR += 0.5 * dWallWidth;
|
|
}
|
|
SetSection(dR * 2.0,0.0);
|
|
if (dWallWidth > 1.e-3)
|
|
{
|
|
dR -= 0.5 * dWallWidth;
|
|
}
|
|
|
|
AcGePoint3d ptSta,ptEnd;
|
|
ptSta = ptOrg;
|
|
ptEnd = ptOrg + vtZ * dBomThick;
|
|
|
|
//移动到真实位置
|
|
AcGeVector3d vt = ptCenPos.asVector();
|
|
ptSta += vt;
|
|
ptEnd += vt;
|
|
|
|
AcDbLine ln;
|
|
ln.setStartPoint(ptSta);
|
|
ln.setEndPoint(ptEnd);
|
|
ln.setNormal(AcGeVector3d::kZAxis);
|
|
|
|
SetBaseCurve(&ln);
|
|
|
|
ptOrg += vt;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptCenPos,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_RAD,dR);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dBomThick);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eCircle);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,TRUE);//平底否
|
|
|
|
GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
|
|
//弧形墙体
|
|
AecDbX3dPart* pPart = NULL;
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
if (dWallHeight > 1.e-3 && dWallWidth > 1.e-3)
|
|
{
|
|
ptOrg.z += dBomThick;
|
|
|
|
RemoveAllX3dPart();
|
|
pPart = new AecDbX3dPart;
|
|
pPart->SetName(_T("墙体"));
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
|
|
ptOrg.z += 0.5 * dWallHeight;
|
|
dR += 0.5 * dWallWidth;
|
|
|
|
pXSolid->Create(AcDbX3dSolid::kPipe,ptOrg,vtZ,3,dR,dWallWidth,dWallHeight);
|
|
pPart->AddX3dSolid(pXSolid,AcDb::kBoolUnite);
|
|
|
|
pPart->SetOrgPoint( ptOrg );
|
|
pPart->SetAxis(X,AcGeVector3d::kXAxis);
|
|
pPart->SetAxis(Y,AcGeVector3d::kYAxis);
|
|
pPart->SetAxis(Z,AcGeVector3d::kZAxis);
|
|
|
|
pPart->GetSpecialtyData()->SetAt(KEY_RAD,dR);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_SHAPE,eCircle);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
AddX3dPart(pPart);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXSlab::SetEllipseBasin(double dRmaj,double radiusRatio,double dBomThick,double dWallHeight,double dWallWidth,const AcGePoint3d& ptCenPos)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcGePoint3d ptOrg(0,0,0);
|
|
AcGeVector3d vtZ(0,0,1);
|
|
|
|
AcDbVoidPtrArray arCurPtrs,arRegPtrs;
|
|
AcGeVector3d vtMaj(dRmaj,0.0,0.0);
|
|
AcDbEllipse* pEllipse = new AcDbEllipse;
|
|
pEllipse->set(ptOrg,vtZ,vtMaj,radiusRatio);
|
|
pEllipse->getOffsetCurves(dWallWidth,arCurPtrs);
|
|
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
|
|
if (arRegPtrs.isEmpty())
|
|
{
|
|
delete pEllipse;
|
|
return false;
|
|
}
|
|
|
|
AcDbLine lnPath;
|
|
AcGePoint3d ptSta,ptEnd;
|
|
ptSta = ptOrg;
|
|
ptEnd = ptOrg + vtZ * dBomThick;
|
|
|
|
//移动到真实位置
|
|
AcGeVector3d vt = ptCenPos.asVector();
|
|
ptSta += vt;
|
|
ptEnd += vt;
|
|
|
|
lnPath.setStartPoint(ptSta);
|
|
lnPath.setEndPoint(ptEnd);
|
|
|
|
AcDbRegion* pRegion = (AcDbRegion*)arRegPtrs.first();
|
|
if (pRegion != NULL)
|
|
{
|
|
SetSection(pRegion,ptOrg);
|
|
SetBaseCurve(&lnPath);
|
|
}
|
|
|
|
ptOrg += vt;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptOrg,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_RAD,dRmaj);
|
|
GetSpecialtyData()->SetAt(KEY_RRATIO,radiusRatio);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dBomThick);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eEllispe);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,TRUE);//平底否
|
|
GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
|
|
if (dWallHeight > 1.e-3 && dWallWidth > 1.e-3)
|
|
{
|
|
AcDbCurve* pOutSide = GetOffsetCurve(pEllipse,dWallWidth,false);
|
|
if (pOutSide != NULL)
|
|
{
|
|
AcDbRegion* pRegWall = CreatePipeRegion(pOutSide,pEllipse);
|
|
if (pRegWall != NULL)
|
|
{
|
|
ptOrg.z += dBomThick;
|
|
lnPath.setStartPoint(ptOrg);
|
|
lnPath.setEndPoint(ptOrg + vtZ * dWallHeight);
|
|
|
|
AecDbX3dPart* pPart = new AecDbX3dPart;
|
|
pPart->SetName(_T("墙体"));
|
|
AcDbX3dSolid* pXSolid = new AcDbX3dSolid;
|
|
pXSolid->CreateExtrude(pRegWall,lnPath);
|
|
pPart->AddX3dSolid(pXSolid,AcDb::kBoolUnite);
|
|
pPart->SetOrgPoint( ptOrg );
|
|
pPart->SetAxis(X,AcGeVector3d::kXAxis);
|
|
pPart->SetAxis(Y,AcGeVector3d::kYAxis);
|
|
pPart->SetAxis(Z,AcGeVector3d::kZAxis);
|
|
|
|
pPart->GetSpecialtyData()->SetAt(KEY_RAD,dRmaj);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_RRATIO,radiusRatio);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_HEIGHT,dWallHeight);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_THICK,dWallWidth);
|
|
pPart->GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
pPart->GetSpecialtyData()->SetAt(KEY_SHAPE,eEllispe);
|
|
AddX3dPart(pPart);
|
|
delete pRegWall;
|
|
}
|
|
delete pOutSide;
|
|
}
|
|
}
|
|
delete pEllipse;
|
|
delete pRegion;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXSlab::SetExtrudeBasin(AcDbRegion* pReg,AcDbLine* pBaseLine)
|
|
{
|
|
AssertWriteEnabled();
|
|
if (pReg != NULL)
|
|
{
|
|
AcGePoint3d ptCen(0,0,0);
|
|
SetSection(pReg,ptCen);
|
|
}
|
|
|
|
AcGePoint3d ptOrg;
|
|
if (pBaseLine != NULL)
|
|
{
|
|
SetBaseCurve(pBaseLine);
|
|
ptOrg = pBaseLine->startPoint();
|
|
}
|
|
|
|
double dBomThick = 0.0;
|
|
if (pReg != NULL && pBaseLine != NULL)
|
|
{
|
|
AcDbExtents ext;
|
|
pReg->getGeomExtents(ext);
|
|
|
|
AcGePoint3d ptCen;
|
|
ptCen = MidPoint(ext.maxPoint(),ext.minPoint());
|
|
|
|
//认为水平放置
|
|
AcDbXline xl;
|
|
xl.setBasePoint(ptCen);
|
|
xl.setUnitDir(AcGeVector3d::kYAxis);
|
|
|
|
AcGePoint3dArray arPts;
|
|
pReg->intersectWith(&xl,AcDb::kOnBothOperands,arPts);
|
|
|
|
dBomThick = 100.0;
|
|
if (arPts.length() > 1)
|
|
{
|
|
dBomThick = arPts.first().distanceTo(arPts.last());
|
|
}
|
|
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptOrg,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dBomThick);
|
|
GetSpecialtyData()->SetAt(KEY_MATERIAL,_T("钢筋混土"));
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eXShape);
|
|
GetSpecialtyData()->SetAt(KEY_HORBOM,FALSE);//平底否
|
|
GetSpecialtyData()->SetAt(KEY_HEIGHT,0.0);
|
|
GetSpecialtyData()->SetAt(KEY_THICK,0.0);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int AecDbXSlab::PeelBasinWall(AcDbVoidPtrArray& arWallPtrs)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
double dWallHeight = 0.0,dWallWidth = 0.0,dR = 0.0;
|
|
double dRmaj = 0.0,radiusRatio = 0.0,dBomThick = 0.0;
|
|
|
|
CString sName,sPoint2dsTop,sMaterial;
|
|
AecDbXWall* pWall = NULL;
|
|
AecDbX3dPart* pPart = NULL;
|
|
AcDbPolyline* pPl = NULL;
|
|
AcDbCurve* pBaseCrv = NULL;
|
|
|
|
AcGePoint3d ptCenPos;
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptCenPos);
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK,dBomThick);
|
|
|
|
EAlign eAgn = kMid;
|
|
for (int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pPart = m_arX3DPartPtrs.at(i);
|
|
pPart->GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("墙体")) == 0)
|
|
{
|
|
int nShape = -1;
|
|
pPart->GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
pPart->GetSpecialtyData()->GetAt(KEY_HEIGHT,dWallHeight);
|
|
pPart->GetSpecialtyData()->GetAt(KEY_THICK,dWallWidth);
|
|
pPart->GetSpecialtyData()->GetAt(KEY_MATERIAL,sMaterial);
|
|
|
|
ESection eShape = (ESection)nShape;
|
|
switch(eShape)
|
|
{
|
|
case eRect:
|
|
case eUserDef:
|
|
{
|
|
pPart->GetSpecialtyData()->GetAt(_T("POIINTS"),sPoint2dsTop);
|
|
pPl = PointsScrToPolyline(sPoint2dsTop);
|
|
ptCenPos.z += dBomThick;
|
|
if (pPl != NULL)
|
|
{
|
|
pBaseCrv = pPl;
|
|
m_arX3DPartPtrs.removeAt(i);
|
|
delete pPart;
|
|
i -= 1;
|
|
}
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
pPart->GetSpecialtyData()->GetAt(KEY_RAD,dR);//外径
|
|
dR -= 0.5 * dWallWidth;
|
|
|
|
eAgn = kMid;
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
ptCenPos.z += dBomThick;
|
|
pCir->setCenter(ptCenPos);
|
|
pCir->setRadius(dR);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
pBaseCrv = pCir;
|
|
m_arX3DPartPtrs.removeAt(i);
|
|
delete pPart;
|
|
i -= 1;
|
|
|
|
//重新设置没有墙体的外半径
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dR);
|
|
dR += 0.5 * dWallWidth;
|
|
GetSpecialtyData()->SetAt(KEY_RAD,dR);
|
|
|
|
break;
|
|
}
|
|
case eEllispe:
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dRmaj);
|
|
GetSpecialtyData()->GetAt(KEY_RRATIO,radiusRatio);
|
|
|
|
eAgn = kLeft;
|
|
AcDbEllipse* pEllip = new AcDbEllipse;
|
|
ptCenPos.z += dBomThick;
|
|
pEllip->setCenter(ptCenPos);
|
|
AcGeVector3d vtMaj(dRmaj,0.0,0.0);
|
|
pEllip->set(ptCenPos,AcGeVector3d::kZAxis,vtMaj,radiusRatio);
|
|
|
|
pBaseCrv = pEllip;
|
|
m_arX3DPartPtrs.removeAt(i);
|
|
delete pPart;
|
|
i -= 1;
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
AcDbVoidPtrArray arPtrs;
|
|
if (pBaseCrv != NULL)
|
|
{
|
|
AcDbPolyline* pPlT = AcDbPolyline::cast(pBaseCrv);
|
|
if (pPlT != NULL)
|
|
{
|
|
pPlT->explode(arPtrs);
|
|
delete pPlT;
|
|
}
|
|
else
|
|
{
|
|
arPtrs.append(pBaseCrv);
|
|
}
|
|
|
|
//RESET
|
|
GetSpecialtyData()->SetAt(KEY_HEIGHT,0.0);
|
|
GetSpecialtyData()->SetAt(KEY_THICK,0.0);
|
|
|
|
for (int ii = 0;ii < arPtrs.length();ii++)
|
|
{
|
|
pBaseCrv = (AcDbCurve*)arPtrs.at(ii);
|
|
if (pBaseCrv != NULL)
|
|
{
|
|
|
|
AcGeMatrix3d xRote;
|
|
xRote.setToRotation(m_dRotate[X],AcGeVector3d::kXAxis,ptCenPos);
|
|
pBaseCrv->transformBy(xRote);
|
|
|
|
//原位置按轴旋转 轴Y
|
|
xRote.setToRotation(m_dRotate[Y],AcGeVector3d::kYAxis,ptCenPos);
|
|
pBaseCrv->transformBy(xRote);
|
|
|
|
//原位置按轴旋转 轴Z
|
|
xRote.setToRotation(m_dRotate[Z],AcGeVector3d::kZAxis,ptCenPos);
|
|
pBaseCrv->transformBy(xRote);
|
|
|
|
pWall = new AecDbXWall;
|
|
pWall->SetWallData(dWallWidth,dWallHeight,ptCenPos.z,eAgn);
|
|
pWall->SetBaseCurve(pBaseCrv);
|
|
pWall->GetSpecialtyData()->SetAt(KEY_MATERIAL,sMaterial);
|
|
|
|
if (eShape == eCircle)
|
|
{
|
|
pWall->GetSpecialtyData()->SetAt(KEY_RAD,dR);//内径
|
|
}
|
|
else if(eShape == eEllispe)
|
|
{
|
|
pWall->GetSpecialtyData()->SetAt(KEY_RAD,dRmaj);
|
|
pWall->GetSpecialtyData()->SetAt(KEY_RRATIO,radiusRatio);
|
|
}
|
|
arWallPtrs.append(pWall);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return arWallPtrs.length();
|
|
}
|
|
|
|
bool AecDbXSlab::SetElBom(double dEl)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
double dLen = ptEnd.distanceTo(ptSta);
|
|
|
|
ptSta.z = dEl;
|
|
ptEnd.z = ptSta.z + dLen;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
double AecDbXSlab::GetElBom() const
|
|
{
|
|
assertReadEnabled();
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
return ptSta.z;
|
|
}
|
|
else
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
return __min(ptSta.z,ptEnd.z);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcGePoint3d ptSta;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
return ptSta.z;
|
|
}
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
typedef float coord_t; // coordinate type
|
|
typedef double coord2_t; // must be big enough to hold 2*max(|coordinate|)^2
|
|
struct Point2d
|
|
{
|
|
coord_t x, y;
|
|
|
|
bool operator <(const Point2d &p) const {
|
|
return x < p.x || (x == p.x && y < p.y);
|
|
}
|
|
};
|
|
extern std::vector<Point2d> convex_hull(std::vector<Point2d> P);
|
|
|
|
int Disperse(const AcDbPolyline &poly,int nCirDiv,AcDbPolyline& polyBoundry)
|
|
{
|
|
polyBoundry.reset(Adesk::kFalse,0);
|
|
polyBoundry.setNormal(poly.normal());
|
|
polyBoundry.setElevation(poly.elevation());
|
|
|
|
int nNum = 0,nRetFlag = 0;
|
|
double dincrement = 0.0;
|
|
|
|
AcDbVoidPtrArray arCurSegs;
|
|
poly.explode(arCurSegs);
|
|
|
|
ads_point pt;
|
|
AcGePoint3d pt3d;
|
|
double dBulge = 0.0;
|
|
int nLen = poly.numVerts();
|
|
for(int i = 0;i < nLen;i++)
|
|
{
|
|
dBulge = 0.0;
|
|
poly.getBulgeAt(i,dBulge);
|
|
|
|
if (fabs(dBulge) < 1.e-6)
|
|
{
|
|
poly.getPointAt(i,pt3d);
|
|
polyBoundry.addVertexAt(polyBoundry.numVerts(),pt3d.convert2d(AcGePlane::kXYPlane));
|
|
|
|
if (i == nLen - 1 && poly.isClosed())
|
|
{
|
|
poly.getPointAt(0,pt3d);
|
|
polyBoundry.addVertexAt(polyBoundry.numVerts(),pt3d.convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!poly.isClosed() && i == nLen - 1)
|
|
{
|
|
poly.getPointAt(i,pt3d);
|
|
polyBoundry.addVertexAt(polyBoundry.numVerts(),pt3d.convert2d(AcGePlane::kXYPlane));
|
|
FreeBuffer(0,arCurSegs);
|
|
return RTNORM;
|
|
}
|
|
|
|
AcDbCurve* pCurve = (AcDbCurve*)arCurSegs.at(i);
|
|
AcDbArc* pArc = AcDbArc::cast(pCurve);
|
|
if (pArc != NULL)
|
|
{
|
|
double dEndAng = pArc->endAngle();
|
|
double dStaAng = pArc->startAngle();
|
|
|
|
double dSweep = dEndAng - dStaAng;
|
|
if (dSweep < -1e-6)
|
|
{
|
|
dSweep = 2.0 * PI + dSweep;
|
|
}
|
|
|
|
nNum = (int)(dSweep / (2.0 * PI) * nCirDiv);
|
|
nNum = max(nNum, 1);
|
|
dincrement = dSweep / nNum;
|
|
|
|
if (i == nLen-1 && poly.isClosed() )
|
|
{
|
|
//最后一封闭弧段
|
|
nNum += 1;
|
|
}
|
|
|
|
for (int n = 0; n < nNum; n++)
|
|
{
|
|
if (dBulge > 0)
|
|
{
|
|
ads_polar(asDblArray(pArc->center()), dStaAng + dincrement * n, pArc->radius(), pt);
|
|
}
|
|
else
|
|
{
|
|
ads_polar(asDblArray(pArc->center()), dEndAng - dincrement * n, pArc->radius(), pt);
|
|
}
|
|
polyBoundry.addVertexAt(polyBoundry.numVerts(),asPnt3d(pt).convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
FreeBuffer(0,arCurSegs);
|
|
return RTNORM;
|
|
}
|
|
|
|
bool AecDbXSlab::IsPointInSide(const AcGePoint3d& ptOn) const
|
|
{
|
|
AcGePoint3d ptT = ptOn;
|
|
ptT.z = 0.0;
|
|
|
|
AcDbCurve* pShapeCurve = GetBasinShapeCurve(true);
|
|
if (pShapeCurve != NULL)
|
|
{
|
|
AcDbCircle* pCir = AcDbCircle::cast(pShapeCurve);
|
|
if (pCir != NULL)
|
|
{
|
|
AcGePoint3d ptCen = pCir->center();
|
|
ptCen.z = 0.0;
|
|
|
|
double dR = pCir->radius();
|
|
double dDist = ptT.distanceTo(ptCen);
|
|
|
|
if (dDist - dR < 1.e-6)
|
|
{
|
|
delete pCir;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
AcDbEllipse* pElp = AcDbEllipse::cast(pShapeCurve);
|
|
if (pElp != NULL)
|
|
{
|
|
AcGePoint3d ptCen = pElp->center();
|
|
ptT.z = ptCen.z;
|
|
|
|
AcGePoint3dArray arPts;
|
|
|
|
AcDbLine ln(ptCen,ptT);
|
|
ln.intersectWith(pElp,AcDb::kOnBothOperands,arPts);
|
|
if (arPts.isEmpty())
|
|
{
|
|
delete pElp;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pShapeCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
AcDbPolyline polyBoundry;
|
|
Disperse(*pPl,50,polyBoundry);//50为圆弧分化
|
|
|
|
int nPts = polyBoundry.numVerts();
|
|
if (nPts > 2)
|
|
{
|
|
float* pfPtx = new float[nPts];
|
|
float* pfPty = new float[nPts];
|
|
|
|
AcGePoint3d pt;
|
|
for (int i = 0;i < nPts;i++)
|
|
{
|
|
polyBoundry.getPointAt(i,pt);
|
|
pfPtx[i] = (float)pt.x;
|
|
pfPty[i] = (float)pt.y;
|
|
}
|
|
|
|
BOOL bIn = IsPointInPoly(nPts,pfPtx,pfPty,(float)ptOn.x,(float)ptOn.y);
|
|
|
|
delete [] pfPtx;
|
|
delete [] pfPty;
|
|
//delete pPl;
|
|
|
|
//pPl->setColorIndex(1);
|
|
//AddToModelSpace(pPl);
|
|
return bIn > 0 ? true : false;
|
|
}
|
|
}
|
|
delete pShapeCurve;
|
|
}
|
|
else
|
|
{
|
|
int nShape = -1;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
ESection eShape = (ESection)nShape;
|
|
if (eShape == eXShape)
|
|
{
|
|
Point2d pt;
|
|
std::vector<Point2d> vtPoint3ds;
|
|
|
|
AcGePoint3d ptS,ptE;
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
AcDbCurve* pCurve = AcDbCurve::cast(pEnt);
|
|
if (pCurve != NULL)
|
|
{
|
|
pCurve->getStartPoint(ptS);
|
|
pCurve->getEndPoint(ptE);
|
|
|
|
pt.x = ptS.x;
|
|
pt.y = ptS.y;
|
|
vtPoint3ds.push_back(pt);
|
|
|
|
pt.x = ptE.x;
|
|
pt.y = ptE.y;
|
|
vtPoint3ds.push_back(pt);
|
|
}
|
|
}
|
|
|
|
AcGePoint2d pt2d;
|
|
std::vector<Point2d> vtPts2 = convex_hull(vtPoint3ds);
|
|
if (vtPts2.size() > 0)
|
|
{
|
|
float* pfPtx = new float[vtPts2.size()];
|
|
float* pfPty = new float[vtPts2.size()];
|
|
|
|
for (int i = 0; i < vtPts2.size(); i++)
|
|
{
|
|
pfPtx[i] = vtPts2[i].x;
|
|
pfPty[i] = vtPts2[i].y;
|
|
}
|
|
BOOL bIn = IsPointInPoly(vtPts2.size(),pfPtx,pfPty,(float)ptOn.x,(float)ptOn.y);
|
|
|
|
delete [] pfPtx;
|
|
delete [] pfPty;
|
|
//delete pPl;
|
|
|
|
//pPl->setColorIndex(1);
|
|
//AddToModelSpace(pPl);
|
|
return bIn > 0 ? true : false;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXSlab::ClosestPointToCen(AcGePoint3d& ptOrg) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nShape = -1;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
ESection eShape = (ESection)nShape;
|
|
if (eShape == eXShape)
|
|
{
|
|
AcGePoint3d ptCenInRgn;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCenInRgn);
|
|
|
|
AcDbCurve* pCurve = GetNativeCurve();
|
|
if (pCurve != NULL)
|
|
{
|
|
AcGePoint3d ptStart(AcGePoint3d::kOrigin);
|
|
pCurve->getStartPoint(ptStart);
|
|
AcGePoint3d ptEnd;
|
|
pCurve->getEndPoint(ptEnd);
|
|
|
|
AcGeVector3d vtNormal(AcGeVector3d::kIdentity);
|
|
pCurve->getFirstDeriv(ptStart, vtNormal);
|
|
|
|
AcDbRegion *pCloneRegion = (AcDbRegion*)m_pRegion->clone();
|
|
if (pCloneRegion != NULL)
|
|
{
|
|
transfromRegion(pCloneRegion, ptCenInRgn, vtNormal, ptStart);
|
|
|
|
AcGePlane regPlan;
|
|
pCloneRegion->getPlane(regPlan);
|
|
|
|
AcGePoint3d ptGeT = regPlan.closestPointTo(ptOrg);
|
|
|
|
AcDbXline xln;
|
|
xln.setBasePoint(ptGeT);
|
|
xln.setUnitDir(AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3dArray arPts;
|
|
pCloneRegion->intersectWith(&xln,AcDb::kOnBothOperands,arPts);
|
|
delete pCloneRegion;
|
|
|
|
if (!arPts.isEmpty())//去最低的标高
|
|
{
|
|
double dZ = 0.0;
|
|
for (int k = 0;k < arPts.length();k++)
|
|
{
|
|
if (k == 0)
|
|
dZ = arPts.at(k).z;
|
|
else
|
|
{
|
|
dZ = __min(dZ,arPts.at(k).z);
|
|
}
|
|
}
|
|
ptOrg.z = dZ;//定位到传入的Z位置
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcDbRegion* pRegion = (AcDbRegion*)m_pRegion->clone();
|
|
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);
|
|
|
|
//1.设置 region 标高
|
|
AcGePlane plan;
|
|
pRegion->getPlane(plan);
|
|
|
|
ptOrg = plan.closestPointTo(ptOrg);
|
|
delete pRegion;
|
|
return true;
|
|
}
|
|
delete pRegion;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
AcGeVector3d AecDbXSlab::GetBasinXDir() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToRotation(m_dRotate[Z],AcGeVector3d::kZAxis);
|
|
vtDirX.transformBy(xform);
|
|
|
|
return vtDirX;
|
|
}
|
|
|
|
AcGePoint3d AecDbXSlab::GetBasinOrg() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptOrg;
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
|
|
return ptOrg;
|
|
}
|
|
|
|
AcDbCurve* AecDbXSlab::GetBasinShapeCurve(bool bAtTruePos/* = true*/) const
|
|
{
|
|
AcDbCurve* pShapeCrv = NULL;
|
|
|
|
//RECT
|
|
AcGePoint3d ptGe[5],ptGeT[5],ptOrg;
|
|
double dL = 0.0,dW = 0.0,dTL = 0.0,dWallWidth = 0.0,dPlotW = 0.0;
|
|
|
|
GetSpecialtyData()->GetAt(KEY_PLOTW,dPlotW);
|
|
//Circle
|
|
double dR = 0.0;
|
|
|
|
//Fence
|
|
CString sPoint2dsTop;
|
|
AcGeMatrix3d xform;
|
|
|
|
//ellipse
|
|
double dRmaj = 0.0;
|
|
double radiusRatio = 0.0;
|
|
|
|
int nShape = -1;
|
|
if ( !GetSpecialtyData()->GetAt(KEY_SHAPE,nShape) )
|
|
{
|
|
//类墙体
|
|
m_mapSpecXData.GetAt(KEY_SECSHAPE,nShape);
|
|
}
|
|
ESection eShape = (ESection)nShape;
|
|
|
|
if (bAtTruePos)
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
}
|
|
else
|
|
{
|
|
ptOrg.set(0,0,0);
|
|
}
|
|
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtDirY = AcGeVector3d::kYAxis;
|
|
|
|
//根据rotate旋转 X,Y
|
|
double dRotate = GetRotation(Z);
|
|
vtDirX.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
vtDirY.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtDir;
|
|
switch(eShape)
|
|
{
|
|
case eRect:
|
|
{
|
|
//特殊处理截面拉伸的类墙的板
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
vtDir = pLn->endPoint() - pLn->startPoint();
|
|
AcGeLine3d ln(AcGePoint3d::kOrigin,vtDir);
|
|
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
|
{
|
|
AcGeVector3d vtV = vtDir;
|
|
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtV.normalize();
|
|
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,dW);
|
|
|
|
//截面拉伸的板
|
|
ptGe[0] = pLn->startPoint();
|
|
ptGe[0] += vtV * 0.5 * dW;
|
|
ptGe[1] = pLn->endPoint();
|
|
ptGe[1] += vtV * 0.5 * dW;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] -= vtV * dW;
|
|
|
|
ptGe[3] = ptGe[0];
|
|
ptGe[3] -= vtV * dW;
|
|
|
|
ptGe[4] = ptGe[0];
|
|
|
|
//墙顶面,水平
|
|
AcDbPolyline* pPl = new AcDbPolyline;//外线
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
for (int k = 0;k < 5;k++)
|
|
{
|
|
pPl->addVertexAt(k,ptGe[k].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setClosed(Adesk::kTrue);
|
|
pPl->setConstantWidth(dPlotW);
|
|
pShapeCrv = pPl;
|
|
}
|
|
}
|
|
|
|
if (pShapeCrv == NULL)//常规
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_Length,dL);
|
|
GetSpecialtyData()->GetAt(KEY_Width,dW);
|
|
|
|
if (!bAtTruePos)
|
|
{
|
|
vtDirX = GetBasinXDir();
|
|
vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
}
|
|
|
|
ptGe[0] = ptOrg;
|
|
ptGe[0] -= vtDirX * 0.5 * dL;
|
|
ptGe[0] -= vtDirY * 0.5 * dW;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] += vtDirY * dW;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] += vtDirX * dL;
|
|
|
|
ptGe[3] = ptGe[2];
|
|
ptGe[3] -= vtDirY * dW;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
//墙顶面,水平
|
|
AcDbPolyline* pPl = new AcDbPolyline;//外线
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
for (int k = 0;k < 5;k++)
|
|
{
|
|
pPl->addVertexAt(k,ptGe[k].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setClosed(Adesk::kTrue);
|
|
pPl->setConstantWidth(dPlotW);
|
|
pShapeCrv = pPl;
|
|
}
|
|
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dR);
|
|
GetSpecialtyData()->GetAt(KEY_THICK,dWallWidth);
|
|
|
|
if (dWallWidth > 1.e-3)
|
|
{
|
|
dR += dWallWidth;
|
|
}
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setRadius(dR);
|
|
pCir->setCenter(ptOrg);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pShapeCrv = pCir;
|
|
break;
|
|
}
|
|
case eEllispe://椭圆斜坡
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dRmaj);
|
|
GetSpecialtyData()->GetAt(KEY_RRATIO,radiusRatio);
|
|
|
|
AcGeVector3d vtMaj(dRmaj,0.0,0.0);
|
|
AcDbEllipse* pEllipse = new AcDbEllipse;
|
|
pEllipse->set(ptOrg,AcGeVector3d::kZAxis,vtMaj,radiusRatio);
|
|
pShapeCrv = pEllipse;
|
|
break;
|
|
}
|
|
case eUserDef://异形斜坡
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_POINTS,sPoint2dsTop);
|
|
|
|
AcDbPolyline* pPl = PointsScrToPolyline(sPoint2dsTop);
|
|
if (pPl != NULL)
|
|
{
|
|
pShapeCrv = pPl;
|
|
}
|
|
pPl->setClosed(Adesk::kTrue);
|
|
pPl->setConstantWidth(dPlotW);
|
|
break;
|
|
}
|
|
case eXShape://不确定截面,拉伸
|
|
{
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (pShapeCrv != NULL)//可能轴旋转
|
|
{
|
|
AcGeMatrix3d xRote;
|
|
xRote.setToRotation(m_dRotate[X],AcGeVector3d::kXAxis,ptOrg);
|
|
pShapeCrv->transformBy(xRote);
|
|
|
|
//原位置按轴旋转 轴Y
|
|
xRote.setToRotation(m_dRotate[Y],AcGeVector3d::kYAxis,ptOrg);
|
|
pShapeCrv->transformBy(xRote);
|
|
|
|
//原位置按轴旋转 轴Z
|
|
xRote.setToRotation(m_dRotate[Z],AcGeVector3d::kZAxis,ptOrg);
|
|
pShapeCrv->transformBy(xRote);
|
|
}
|
|
return pShapeCrv;
|
|
}
|
|
|
|
ESection AecDbXSlab::GetBasinShape() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nShape = 0;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
return (ESection)nShape;
|
|
}
|
|
|
|
bool AecDbXSlab::GetBasinSlabData(PoolData& data) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
/*
|
|
typedef struct PoolData
|
|
{
|
|
double m_dBomEl;
|
|
double m_dBomThick;
|
|
double m_dH;
|
|
double m_dWallThick;
|
|
|
|
TCHAR m_sGradX[33];
|
|
TCHAR m_sGradY[33];
|
|
TCHAR m_sMaterial[256];
|
|
|
|
double m_dData[16];//共用
|
|
//...
|
|
}POOLDATA;
|
|
*/
|
|
|
|
memset(&data,0,sizeof(PoolData));
|
|
|
|
int nShape = -1,nIsHorBom = 0;
|
|
CString sName;
|
|
AcGePoint3d ptOrg;
|
|
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
GetSpecialtyData()->GetAt(KEY_HORBOM,nIsHorBom);//平底否
|
|
data.m_nHorBom = nIsHorBom;
|
|
data.m_nShape = nShape;
|
|
|
|
//根据nShape决定data的数据
|
|
//以下示意
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
|
|
data.m_dBomEl = GetElBom();
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK,data.m_dBomThick);
|
|
GetSpecialtyData()->GetAt(KEY_Length,data.m_dData[0]);
|
|
GetSpecialtyData()->GetAt(KEY_Width,data.m_dData[1]);
|
|
GetSpecialtyData()->GetAt(KEY_RAD,data.m_dData[2]);
|
|
GetSpecialtyData()->GetAt(KEY_RRATIO,data.m_dData[3]);
|
|
|
|
GetSpecialtyData()->GetAt(KEY_HEIGHT,data.m_dWallH);
|
|
GetSpecialtyData()->GetAt(KEY_THICK,data.m_dWallThick);
|
|
|
|
GetSpecialtyData()->GetAt(KEY_MATERIAL,sName);
|
|
_tcscpy(data.m_sMaterial,(LPCTSTR)sName);
|
|
|
|
//水池内径
|
|
//data.m_dData[0] -= 2 * data.m_dWallThick;
|
|
//data.m_dData[1] -= 2 * data.m_dWallThick;
|
|
|
|
return true;
|
|
}
|
|
|
|
void AecDbXSlab::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
acutPrintf(_T("\n板"));
|
|
AecDbBDPipeBase::subList();
|
|
acutPrintf(_T("\n体积: 立方"),GetVolume() / 1.e9);
|
|
}
|
|
|
|
bool AecDbXSlab::GetBimInfoTip(CString& sInfoTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sField,sFmt,sVal;
|
|
|
|
sField = _T("板:\n");
|
|
sInfoTip += sField;
|
|
|
|
MAKEFIELD(_T("厚度"),_T("%.1f 毫米"),GetThick(),sInfoTip);
|
|
|
|
MAKEFIELD(_T("板底标高"),_T("%.1f 毫米"),GetElBom(),sInfoTip);
|
|
|
|
MAKEFIELD(_T("面积"),_T("%.1f 平方米"),GetArea() / 1.e6,sInfoTip);
|
|
|
|
MAKEFIELD(_T("体积"),_T("%.1f 立方米"),GetVolume() / 1.e9,sInfoTip);
|
|
|
|
GetSpecialtyData()->GetAt(KEY_MATERIAL,sVal);
|
|
MAKEFIELD(_T("材质"),_T("%s"),sVal,sInfoTip);
|
|
|
|
GetSpecialtyData()->GetAt(KEY_NO,sVal);
|
|
MAKEFIELD(_T("编号"),_T("%s"),sVal,sInfoTip);
|
|
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
if (g_BALock::instance().Draw() != BIT_SUCCESS)
|
|
return Acad::eOk;
|
|
|
|
int nCrBk = dc.GetColor();
|
|
int nColor = nCrBk;
|
|
if ( m_mapSpecXData.GetAt(_T("COLOR"),nColor) )
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
AecDb3dRoadAxisLine* pRoad = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoad != NULL)
|
|
{
|
|
AecDbBDPipeBase::Draw2d(dc);
|
|
DrawHatch(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(m_pBaseCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
AecDbBDPipeBase::Draw2d(dc);
|
|
DrawHatch(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
AcDbLine* pPl = AcDbLine::cast(m_pBaseCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
AcGeVector3d vtL = pPl->endPoint() - pPl->startPoint();
|
|
AcGeLine3d ln(AcGePoint3d::kOrigin,vtL);
|
|
if (!ln.isParallelTo(AcGePlane::kXYPlane))
|
|
{
|
|
AecDbBDPipeBase::Draw2d(dc);
|
|
}
|
|
|
|
AcDbCurve* pShape = GetBasinShapeCurve(TRUE);
|
|
if (pShape != NULL)
|
|
{
|
|
double dPlotW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_PLOTW,dPlotW);
|
|
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pShape);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setColorIndex(nColor);
|
|
pPl->setConstantWidth(dPlotW);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
}
|
|
|
|
DrawHatch(dc);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(m_pBaseCurve);
|
|
if (pArc != NULL)
|
|
{
|
|
AecDbBDPipeBase::Draw2d(dc);
|
|
DrawHatch(dc);
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
AcDbObjectId idCurLay = dc.GetLayerId();
|
|
AcDbObjectId idCurLty = dc.GetLineTypeId();
|
|
|
|
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);
|
|
|
|
//DrawHatch(dc);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbCurve* pShape = GetBasinShapeCurve(TRUE);
|
|
if (pShape != NULL)
|
|
{
|
|
double dPlotW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_PLOTW,dPlotW);
|
|
|
|
if (dPlotW > 1.e-3)
|
|
{
|
|
AcDbCircle* pCir = AcDbCircle::cast(pShape);
|
|
if (pCir != NULL)
|
|
{
|
|
AcGePoint3d ptCen = pCir->center();
|
|
double dR = pCir->radius();
|
|
|
|
AcGePoint3d ptL = ptCen + dR * AcGeVector3d::kXAxis;
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0,ptL.convert2d(AcGePlane::kXYPlane),tan(PI / 4.0));
|
|
|
|
ptL -= 2.0 * dR * AcGeVector3d::kXAxis;
|
|
pPl->addVertexAt(1,ptL.convert2d(AcGePlane::kXYPlane),tan(PI / 4.0));
|
|
|
|
ptL = ptCen + dR * AcGeVector3d::kXAxis;
|
|
pPl->addVertexAt(2,ptL.convert2d(AcGePlane::kXYPlane));
|
|
|
|
pPl->setColorIndex(nColor);
|
|
pPl->setConstantWidth(dPlotW);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
|
|
AcDbEllipse* pElp = AcDbEllipse::cast(pShape);
|
|
if (pElp != NULL)
|
|
{
|
|
//椭圆暂时不宽度显示
|
|
pShape->setColorIndex(nColor);
|
|
dc.DrawEntity(pShape);
|
|
Add2DBuffer(pShape);
|
|
}
|
|
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pShape);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setColorIndex(nColor);
|
|
pPl->setConstantWidth(dPlotW);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pShape->setColorIndex(nColor);
|
|
dc.DrawEntity(pShape);
|
|
Add2DBuffer(pShape);
|
|
}
|
|
DrawHatch(dc);
|
|
}
|
|
else
|
|
{
|
|
int nShape = -1;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
ESection eShape = (ESection)nShape;
|
|
|
|
//三维投影
|
|
if (eShape == eXShape)
|
|
{
|
|
DrawXShape2d(dc);
|
|
}
|
|
}
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::DrawXShape2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDb3dSolid* pSolid = GetDraw3dSolid(false, dc.GetColor());
|
|
if (pSolid != NULL)
|
|
{
|
|
AcGeMatrix3d xform;
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
OrthoProjected3DSolid(pSolid,AcGePlane::kXYPlane,xform,arEntPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
pEnt->setColorIndex(dc.GetColor());
|
|
dc.DrawEntity(pEnt);
|
|
Add2DBuffer(pEnt);
|
|
}
|
|
}
|
|
delete pSolid;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
return AecDbBDPipeBase::Draw3d(dc);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
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 > AecDbXSlab::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
if (version == 1 )//低版本失误
|
|
{
|
|
Adesk::UInt32 nLen = 0;
|
|
pFiler->readUInt32(&nLen);
|
|
|
|
AcDbSoftPointerId id;
|
|
m_arAssocPartEntIds.removeAll();
|
|
for(int i = 0;i < nLen;i++)
|
|
{
|
|
pFiler->readSoftPointerId(&id);
|
|
m_arAssocPartEntIds.append(id);
|
|
}
|
|
}
|
|
|
|
// 处理一下 m_pRegion 为空的情况,或者绘制错误的情况
|
|
// 除了 圆板,其他的都根据KEY_POINTS的数据重新生成截面
|
|
do
|
|
{
|
|
if (m_pRegion) break;
|
|
|
|
int shape;
|
|
GetAt(KEY_SHAPE, shape);
|
|
if (shape == eCircle) break;
|
|
|
|
double dBomThick(400.);
|
|
GetAt(KEY_BOMTHICK, dBomThick);
|
|
|
|
CString sPl;
|
|
if (!GetAt(KEY_POINTS, sPl)) break;
|
|
AcDbRegion *pRegion = PointsScrToRegion(sPl);
|
|
if (!pRegion) break;
|
|
|
|
AcGePoint3d ptOrg(AcGePoint3d::kOrigin);
|
|
GetAt(KEY_ORGPT, ptOrg);
|
|
|
|
// 保存板底标高
|
|
double dCenBomEl = ptOrg.z;
|
|
|
|
AcDbPolyline *pPl = CoreTools::StringToPolyline(sPl);
|
|
if (pPl)
|
|
{
|
|
pPl->getPointAt(0, ptOrg);
|
|
DELETE_PTR(pPl);
|
|
}
|
|
else
|
|
{
|
|
double d;
|
|
AcGePlane pln;
|
|
CoreTools::getRegionInfo(pRegion, ptOrg, d, pln);
|
|
}
|
|
|
|
ptOrg.z = dCenBomEl;
|
|
|
|
SetSection(pRegion, ptOrg);
|
|
delete pRegion;
|
|
|
|
//base curve
|
|
AcGePoint3d ptSta, ptEnd;
|
|
|
|
ptSta = ptOrg;
|
|
ptEnd = (ptOrg + AcGeVector3d::kZAxis * dBomThick);
|
|
|
|
AcGeVector3d vtZ(0, 0, dCenBomEl);
|
|
ptSta += vtZ;
|
|
ptEnd += vtZ;
|
|
|
|
AcDbLine ln;
|
|
ln.setStartPoint(ptSta);
|
|
ln.setEndPoint(ptEnd);
|
|
|
|
SetBaseCurve(&ln);
|
|
|
|
} while (false);
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
es = AecDbBDPipeBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es);
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbXSlab::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
if (AecDbXSlab::kCurrentVersionNumber < 2)//低版本失误
|
|
{
|
|
AcDbSoftPointerId id;
|
|
Adesk::UInt32 nLen = m_arAssocPartEntIds.length();
|
|
|
|
pFiler->writeUInt32(nLen);
|
|
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
id = m_arAssocPartEntIds.at(i);
|
|
pFiler->writeSoftPointerId(id);
|
|
}
|
|
}
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::subGetGripPoints(AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//夹点设计
|
|
//reg的夹点+中心夹点+改厚度夹点(上下)+ 标高夹点(下)
|
|
|
|
AcGePoint3dArray gripPoints;
|
|
ImpGetGripPoints(gripPoints,bitflags);
|
|
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcGePoint3dArray arPts;
|
|
AcDbIntArray osnapModes,geomIds;
|
|
m_pBaseCurve->getGripPoints(arPts,osnapModes,geomIds);
|
|
|
|
//同墙体的夹点设计 待定
|
|
ImpGetRectWallGripPoints(arPts,bitflags);
|
|
gripPoints.append(arPts);
|
|
}
|
|
}
|
|
|
|
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 AecDbXSlab::SubAddDimPoints(AcDbGripDataPtrArray& grips,const AcGeVector3d& curViewDir) const
|
|
{
|
|
if (GetDimGripOff())
|
|
return Acad::eOk;
|
|
|
|
//夹点设计
|
|
//reg的夹点+中心夹点+改厚度夹点(上下)+ 标高夹点(下)
|
|
|
|
//RECT
|
|
AcGePoint3d ptOrg,ptGe[5],ptGeT,ptMid;
|
|
double dL = 0.0,dW = 0.0,dTL = 0.0;
|
|
int nGripPts = 0;
|
|
|
|
//Circle
|
|
double dR = 0.0;
|
|
|
|
//Fence
|
|
CString sPoint2dsTop;
|
|
|
|
//ellipse
|
|
double dRmaj = 0.0,dThick = 0.0;
|
|
double radiusRatio = 0.0;
|
|
|
|
int nShape = -1;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK,dThick);
|
|
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtDirY = AcGeVector3d::kYAxis;
|
|
|
|
//根据rotate旋转 X,Y
|
|
double dRotate = GetRotation(Z);
|
|
vtDirX.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
vtDirY.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
|
|
//如果原点设置,则为类墙体似截面拉板
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
AcDbPolyline* pPl = AcDbPolyline::cast( m_pBaseCurve );
|
|
if (pPl != NULL)
|
|
{
|
|
for (int ii = 0;ii < pPl->numVerts() - 1;ii++)
|
|
{
|
|
pPl->getPointAt(ii,ptGe[0]);
|
|
pPl->getPointAt(ii+1,ptGe[1]);
|
|
|
|
pPl->getFirstDeriv(ptGe[0],vtDirX);
|
|
vtDirX.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
ptMid += vtDirX * 10.0 * 100.0;//标注文字位置
|
|
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
|
|
if (ii == pPl->numVerts() - 1)
|
|
{
|
|
pPl->getPointAt(ii,ptGe[0]);
|
|
pPl->getPointAt(0,ptGe[1]);
|
|
|
|
pPl->getFirstDeriv(ptGe[0],vtDirX);
|
|
vtDirX.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
ptMid += vtDirX * 10.0 * 100.0;//标注文字位置
|
|
|
|
//AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
}
|
|
}
|
|
|
|
//厚度
|
|
pPl->getPointAt(0,ptGe[0]);
|
|
pPl->getFirstDeriv(ptGe[0],vtDirX);
|
|
vtDirX.normalize();
|
|
vtDirX *= 100.0;
|
|
vtDirX.negate();
|
|
|
|
dThick = GetThick();
|
|
ptGe[0] += vtDirX;
|
|
ptGe[0].z -= 0.5 * dThick;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1].z += dThick;
|
|
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
vtDirX.normalize();
|
|
ptMid += vtDirX * 5.0 * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
|
|
//宽度
|
|
double dL = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,dL);
|
|
|
|
pPl->getPointAt(0,ptGe[0]);
|
|
ptGe[0] += 2.0 * vtDirX;
|
|
|
|
vtDirX.rotateBy(PI/2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();
|
|
vtDirX *= dL;
|
|
|
|
ptGe[0] += 0.5 * vtDirX;
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] -= vtDirX;
|
|
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
vtDirX.rotateBy(-PI/2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();
|
|
ptMid += vtDirX * 15.0 * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//第四个夹点为位置夹点
|
|
//2.曲线的夹点,位置和尺寸
|
|
ESection eShape = (ESection)nShape;
|
|
switch(eShape)
|
|
{
|
|
case eRect:
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_Length,dL);
|
|
GetSpecialtyData()->GetAt(KEY_Width,dW);
|
|
|
|
ptGe[0] = ptOrg;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] -= vtDirX * 0.5 * dL;
|
|
ptGe[1] -= vtDirY * 0.5 * dW;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] += vtDirY * dW;
|
|
|
|
ptGe[3] = ptGe[2];
|
|
ptGe[3] += vtDirX * dL;
|
|
|
|
ptGe[4] = ptGe[3];
|
|
ptGe[4] -= vtDirY * dW;
|
|
|
|
//L
|
|
ptMid = MidPoint(ptGe[1],ptGe[2]);
|
|
vtDirX.normalize();
|
|
ptMid -= vtDirX * 10.0 * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[1],ptGe[2],ptMid,0);
|
|
|
|
//W
|
|
ptMid = MidPoint(ptGe[1],ptGe[4]);
|
|
vtDirX.normalize();
|
|
ptMid -= vtDirY * 10.0 * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[1],ptGe[4],ptMid,0);
|
|
|
|
//厚度
|
|
ptGe[0].z += dThick;
|
|
ptMid = MidPoint(ptGe[0],ptOrg);
|
|
vtDirX.normalize();
|
|
ptMid -= vtDirX * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptOrg,ptMid,0);
|
|
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dR);
|
|
|
|
ptGe[0] = ptOrg;
|
|
ptGe[1] = ptOrg + vtDirX * dR;
|
|
|
|
//半径标注
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,1,dR);
|
|
|
|
//厚度
|
|
ptGe[0].z += dThick;
|
|
ptMid = MidPoint(ptGe[0],ptOrg);
|
|
vtDirX.normalize();
|
|
ptMid -= vtDirX * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptOrg,ptMid,0);
|
|
|
|
break;
|
|
}
|
|
case eEllispe://椭圆斜坡
|
|
{
|
|
break;
|
|
}
|
|
case eUserDef://异形斜坡
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_POINTS,sPoint2dsTop);
|
|
AcDbPolyline* pPl = PointsScrToPolyline(sPoint2dsTop);
|
|
if (pPl != NULL)
|
|
{
|
|
for (int ii = 0;ii < pPl->numVerts() - 1;ii++)
|
|
{
|
|
pPl->getPointAt(ii,ptGe[0]);
|
|
pPl->getPointAt(ii+1,ptGe[1]);
|
|
|
|
pPl->getFirstDeriv(ptGe[0],vtDirX);
|
|
vtDirX.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
ptMid += vtDirX * 10.0 * 100.0;//标注文字位置
|
|
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
|
|
if (ii == pPl->numVerts() - 1)
|
|
{
|
|
pPl->getPointAt(ii,ptGe[0]);
|
|
pPl->getPointAt(0,ptGe[1]);
|
|
|
|
pPl->getFirstDeriv(ptGe[0],vtDirX);
|
|
vtDirX.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
vtDirX.normalize();
|
|
ptMid += vtDirX * 10.0 * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
}
|
|
}
|
|
|
|
//中心
|
|
AcDbExtents ext;
|
|
pPl->getGeomExtents(ext);
|
|
ptGe[0] = MidPoint(ext.minPoint(),ext.maxPoint());
|
|
|
|
//厚度
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1].z += dThick;
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
vtDirX.normalize();
|
|
ptMid -= vtDirX * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
|
|
delete pPl;
|
|
}
|
|
break;
|
|
}
|
|
case eXShape:
|
|
{
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbXSlab::SetAsWallData(double dThick,double dH,double dBomEl)
|
|
{
|
|
if (dThick < 1.e-3 || dH < 1.e-3 )
|
|
return false;
|
|
|
|
AssertWriteEnabled();
|
|
|
|
EAlign kAlign = kMid;
|
|
|
|
/*
|
|
0/4 1
|
|
+-----+
|
|
| |
|
|
| |
|
|
| |
|
|
+-----+
|
|
3 2
|
|
*/
|
|
|
|
AcGePoint3d ptGe[5];
|
|
ptGe[0].set(0,0,0);
|
|
ptGe[0].y += (dBomEl + 0.5 * dH);//中心
|
|
|
|
ptGe[0].x -= 0.5 * dThick;
|
|
ptGe[0].y += 0.5 * dH;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1].x += dThick;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2].y -= dH;
|
|
|
|
ptGe[3] = ptGe[2];
|
|
ptGe[3].x -= dThick;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
switch(kAlign)
|
|
{
|
|
case kMid://居中
|
|
{
|
|
break;
|
|
}
|
|
case kLeft://左侧
|
|
{
|
|
for (int i = 0;i < 5;i++)
|
|
{
|
|
ptGe[i].x -= 0.5 * dThick;
|
|
}
|
|
break;
|
|
}
|
|
case kRight:
|
|
{
|
|
for (int i = 0;i < 5;i++)
|
|
{
|
|
ptGe[i].x += 0.5 * dThick;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//底标高基准点
|
|
AcGePoint3d ptCen;
|
|
ptCen.set(0,0,0);
|
|
|
|
AcDbRegion* pReg = CreateRetangeRegion(ptGe,5);
|
|
SetSection(pReg,ptCen);
|
|
|
|
//TEST
|
|
//AddToModelSpace(pReg);
|
|
delete pReg;
|
|
|
|
//记录底部标高数值
|
|
m_mapSpecXData.SetAt(KEY_SIZE1,dThick);
|
|
m_mapSpecXData.SetAt(KEY_SIZE2,dH);
|
|
m_mapSpecXData.SetAt(PIPE_EL,dBomEl);
|
|
m_mapSpecXData.SetAt(KEY_SECSHAPE,eRect);//标准
|
|
m_mapSpecXData.SetAt(KEY_ALIGN,kAlign);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXSlab::GetAsWallData(WallData& data) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
memset(&data,0,sizeof(WallData));
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,data.dThick);
|
|
m_mapSpecXData.GetAt(KEY_SIZE2,data.dH);
|
|
m_mapSpecXData.GetAt(KEY_SIZE3,data.dThick2);
|
|
m_mapSpecXData.GetAt(KEY_SIZE4,data.dH2);
|
|
m_mapSpecXData.GetAt(PIPE_EL,data.dBomEl);
|
|
m_mapSpecXData.GetAt(KEY_NO,data.szNO);
|
|
|
|
int nAlign = 0;
|
|
m_mapSpecXData.GetAt(KEY_ALIGN,nAlign);
|
|
data.kAlign = (EAlign)nAlign;
|
|
|
|
m_mapSpecXData.GetAt(KEY_SECSHAPE,data.nSecShape);//标准
|
|
m_mapSpecXData.GetAt(KEY_W2POS,data.nW2Pos);
|
|
|
|
CString sTemp;
|
|
m_mapSpecXData.GetAt(KEY_MATERIAL,sTemp);
|
|
_tcscpy(data.szMat,(LPCTSTR)sTemp);
|
|
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::ImpGetRectWallGripPoints(AcGePoint3dArray& gripPoints,const int bitflags) const
|
|
{
|
|
AcDbCurve* pBaseCrv = m_pBaseCurve;
|
|
if (pBaseCrv == NULL)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
double dSta = 0.0,dEnd = 0.0;
|
|
pBaseCrv->getStartParam(dSta);
|
|
|
|
AcGeVector3d vtL,vtDir;
|
|
pBaseCrv->getFirstDeriv(dSta,vtL);
|
|
vtDir = vtL;
|
|
vtDir.normalize();
|
|
vtL.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtL.normalize();
|
|
|
|
AcGePoint3d ptGe[3],ptTmp;
|
|
pBaseCrv->getStartPoint(ptGe[0]);
|
|
|
|
ptGe[0] += vtDir * 100.0;
|
|
ptGe[2] = ptGe[0] + vtDir * 100.0;
|
|
AcDbLine ln(ptGe[0],ptGe[2]);
|
|
AcDbLine* pLn = &ln;
|
|
pBaseCrv = pLn;
|
|
pBaseCrv->getStartParam(dSta);
|
|
pBaseCrv->getEndParam(dEnd);
|
|
|
|
int nAlign = 0;
|
|
EAlign kAlign = (EAlign)nAlign;//kMid
|
|
|
|
pBaseCrv->getPointAtParam((dSta+dEnd) / 2.0,ptGe[1]);
|
|
|
|
double dCmd = PixelToWcs(10);
|
|
|
|
//板宽
|
|
double dW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,dW);
|
|
|
|
double dH = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE2,dH);
|
|
|
|
if (pLn != NULL)
|
|
{
|
|
WallData data;
|
|
GetAsWallData(data);
|
|
|
|
//中下 1个点 改标高
|
|
ptTmp = ptGe[1];
|
|
ptTmp.z -= dCmd;
|
|
gripPoints.append(ptTmp);
|
|
|
|
//下前 中点
|
|
ptGe[1] += vtL * 0.5 * data.dThick;
|
|
gripPoints.append(ptGe[1]);
|
|
|
|
//下后 中点
|
|
ptGe[1] -= vtL * data.dThick;
|
|
gripPoints.append(ptGe[1]);
|
|
|
|
//上 1个点
|
|
//3D视图下
|
|
if (!Is2DView())
|
|
{
|
|
ptGe[1] += vtL * 0.5 * data.dThick;
|
|
ptGe[1].z += data.dH;
|
|
gripPoints.append(ptGe[1]);
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::ImpGetGripPoints(AcGePoint3dArray& gripPoints,const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//如果原点设置,则为类墙体似截面拉板
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//夹点设计
|
|
//reg的夹点+中心夹点+改厚度夹点(上下)+ 标高夹点(下)
|
|
|
|
//RECT
|
|
AcGePoint3d ptGe[5],ptGeT;
|
|
double dL = 0.0,dW = 0.0,dTL = 0.0;
|
|
int nGripPts = 0;
|
|
|
|
//Circle
|
|
double dR = 0.0;
|
|
|
|
//Fence
|
|
CString sPoint2dsTop;
|
|
|
|
//ellipse
|
|
double dRmaj = 0.0,dThick = 0.0;
|
|
double radiusRatio = 0.0;
|
|
|
|
int nShape = -1;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK,dThick);
|
|
|
|
//1.前面三个点 : 改标高, 改厚度2 三个夹点
|
|
double dCmd = PixelToWcs(10);
|
|
|
|
//改上厚度
|
|
ptGeT = ptOrg;
|
|
ptGeT.z += dThick;
|
|
gripPoints.append(ptGeT);
|
|
|
|
//改标高
|
|
ptGeT = ptOrg - dCmd * AcGeVector3d::kXAxis;
|
|
gripPoints.append(ptGeT);
|
|
|
|
//改下厚度
|
|
ptGeT = ptOrg;
|
|
gripPoints.append(ptGeT);
|
|
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtDirY = AcGeVector3d::kYAxis;
|
|
|
|
//根据rotate旋转 X,Y
|
|
double dRotate = GetRotation(Z);
|
|
vtDirX.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
vtDirY.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
|
|
//第四个夹点为位置夹点
|
|
//2.曲线的夹点,位置和尺寸
|
|
ESection eShape = (ESection)nShape;
|
|
switch(eShape)
|
|
{
|
|
case eRect:
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_Length,dL);
|
|
GetSpecialtyData()->GetAt(KEY_Width,dW);
|
|
|
|
ptGe[0] = ptOrg;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] -= vtDirX * 0.5 * dL;
|
|
ptGe[1] -= vtDirY * 0.5 * dW;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] += vtDirY * dW;
|
|
|
|
ptGe[3] = ptGe[2];
|
|
ptGe[3] += vtDirX * dL;
|
|
|
|
ptGe[4] = ptGe[3];
|
|
ptGe[4] -= vtDirY * dW;
|
|
|
|
nGripPts = 5;
|
|
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dR);
|
|
|
|
ptGe[0] = ptOrg;
|
|
ptGe[1] = ptOrg + vtDirX * dR;
|
|
nGripPts = 2;
|
|
|
|
break;
|
|
}
|
|
case eEllispe://椭圆斜坡
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dRmaj);
|
|
GetSpecialtyData()->GetAt(KEY_RRATIO,radiusRatio);
|
|
|
|
ptGe[0] = ptOrg;
|
|
|
|
ptGe[1] = ptOrg + vtDirX * dRmaj;
|
|
ptGe[2] = ptOrg + vtDirY * dRmaj * radiusRatio;
|
|
nGripPts = 3;
|
|
|
|
break;
|
|
}
|
|
case eUserDef://异形斜坡
|
|
{
|
|
GetSpecialtyData()->GetAt(KEY_POINTS,sPoint2dsTop);
|
|
|
|
AcDbPolyline* pPl = PointsScrToPolyline(sPoint2dsTop);
|
|
if (pPl != NULL)
|
|
{
|
|
//中心
|
|
AcDbExtents ext;
|
|
pPl->getGeomExtents(ext);
|
|
|
|
ptGeT = MidPoint(ext.maxPoint(),ext.minPoint());
|
|
|
|
ptGeT.z = ptOrg.z;
|
|
gripPoints.append(ptGeT);
|
|
|
|
for (int i = 0;i < pPl->numVerts();i++)
|
|
{
|
|
pPl->getPointAt(i,ptGeT);
|
|
ptGeT.z = ptOrg.z;
|
|
|
|
if (gripPoints.find(ptGeT) == -1)
|
|
{
|
|
gripPoints.append(ptGeT);
|
|
}
|
|
}
|
|
delete pPl;
|
|
}
|
|
break;
|
|
}
|
|
case eXShape:
|
|
{
|
|
gripPoints.removeAll();
|
|
|
|
AcGePoint3d ptSta,ptEnd,ptMid;
|
|
AcDbIntArray osnapModes,geomIds;
|
|
GetNativeCurve()->getStartPoint(ptSta);
|
|
GetNativeCurve()->getEndPoint(ptEnd);
|
|
|
|
gripPoints.append(ptSta);
|
|
|
|
ptMid = MidPoint(ptSta,ptEnd);
|
|
gripPoints.append(ptMid);
|
|
|
|
gripPoints.append(ptEnd);
|
|
|
|
nGripPts = 0;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (nGripPts > 0)
|
|
{
|
|
for (int j = 0;j < nGripPts;j++)
|
|
{
|
|
gripPoints.append(ptGe[j]);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
EPosition AecDbXSlab::ExplainGripIndex(int nIndex,CString& sTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
EPosition ePos = eStart;
|
|
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbIntArray osnapModes;
|
|
AcDbIntArray geomIds;
|
|
AcGePoint3dArray arPts;
|
|
|
|
m_pBaseCurve->getGripPoints(arPts,osnapModes,geomIds);
|
|
|
|
if (nIndex > arPts.length() - 1)
|
|
{
|
|
nIndex -= arPts.length();
|
|
|
|
switch (nIndex)
|
|
{
|
|
case 0://下中线中下 ->改标高
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("标高修改夹点");
|
|
break;
|
|
}
|
|
case 1://前线mid ->改宽,不改长
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("宽度修改夹点");
|
|
break;
|
|
}
|
|
case 2://后线mid ->改宽,不改长
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("宽度修改夹点");
|
|
break;
|
|
}
|
|
case 3://上线mid ->改高度
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("高度修改夹点");
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return ePos;
|
|
}
|
|
else
|
|
{
|
|
sTip = _T("修改板的节点");
|
|
return eAdjust0;
|
|
}
|
|
}
|
|
}
|
|
|
|
//如果原点设置,则为类墙体似截面拉板
|
|
int nShape = -1;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
ESection eShape = (ESection)nShape;
|
|
if (eXShape == eShape)
|
|
{
|
|
switch(nIndex)
|
|
{
|
|
case 0:
|
|
{
|
|
ePos = eStart;
|
|
sTip = _T("改板起点位置");
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
ePos = eMid;
|
|
sTip = _T("改板整体位置");
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
ePos = eEnd;
|
|
sTip = _T("改板终点位置");
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return ePos;
|
|
}
|
|
|
|
//改下厚度
|
|
switch(nIndex)
|
|
{
|
|
case 0://上厚度
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("改板上部厚度");
|
|
break;
|
|
}
|
|
case 1://中,改标高
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("改板底部标高");
|
|
break;
|
|
}
|
|
case 2://改,下厚度
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("改板下部厚度");
|
|
break;
|
|
}
|
|
case 3://中心,位置
|
|
{
|
|
ePos = eMid;
|
|
sTip = _T("改板整体位置");
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
ePos = eAdjust0;
|
|
sTip = _T("改板平面尺寸");
|
|
break;
|
|
}
|
|
}
|
|
return ePos;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::subMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//只能一个点处理
|
|
if (gripAppData.length() > 1)
|
|
return Acad::eOk;
|
|
|
|
if (HitOnGripEdit(gripAppData))
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
AcGePoint3d ptSta,ptEnd;
|
|
if ( gripAppData.isEmpty() )
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
arIndex.append(pAppData->nIndex);
|
|
|
|
//如果原点设置,则为类墙体似截面拉板
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbIntArray osnapModes;
|
|
AcDbIntArray geomIds;
|
|
AcGePoint3dArray arPts;
|
|
m_pBaseCurve->getGripPoints(arPts,osnapModes,geomIds);
|
|
|
|
if (pAppData->nIndex < arPts.length() )//曲线夹点
|
|
{
|
|
AcDbIntArray indices;
|
|
indices.append(pAppData->nIndex);
|
|
return m_pBaseCurve->moveGripPointsAt(indices,offset);
|
|
}
|
|
else
|
|
{
|
|
//板夹点
|
|
return ImpMoveRectWallGripPointsAt(gripAppData,offset);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
|
|
int nShape = -1;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
ESection eShape = (ESection)nShape;
|
|
|
|
//>3 为尺寸调整夹点
|
|
if (pAppData->nIndex > 3)
|
|
{
|
|
switch(eShape)
|
|
{
|
|
case eRect:
|
|
{
|
|
RectImpMoveGripPointsAt(gripAppData,offset,bitflags);
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
CircleImpMoveGripPointsAt(gripAppData,offset,bitflags);
|
|
break;
|
|
}
|
|
case eEllispe://椭圆斜坡
|
|
{
|
|
EllispeImpMoveGripPointsAt(gripAppData,offset,bitflags);
|
|
break;
|
|
}
|
|
case eUserDef://异形斜坡
|
|
{
|
|
UserDefImpMoveGripPointsAt(gripAppData,offset,bitflags);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (eShape == eXShape)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
if (pAppData->nIndex == 0)
|
|
{
|
|
ptSta = pLn->startPoint();
|
|
ptSta += offset;
|
|
pLn->setStartPoint(ptSta);
|
|
}
|
|
else if (pAppData->nIndex == 1)
|
|
{
|
|
AcGeMatrix3d xMove;
|
|
xMove.setToTranslation(offset);
|
|
pLn->transformBy(xMove);
|
|
}
|
|
else if (pAppData->nIndex == 2)
|
|
{
|
|
ptEnd = pLn->endPoint();
|
|
ptEnd += offset;
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
|
|
//<=3 标高,厚度,位移 统一夹点
|
|
AcGeVector3d vtOffset = offset;
|
|
|
|
AcGeVector3d vtXYOffset;
|
|
vtXYOffset = vtOffset.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtZOffset;
|
|
vtZOffset = vtOffset.orthoProject(AcGeVector3d::kXAxis);
|
|
|
|
double dLen = offset.length();
|
|
|
|
AcGeVector3d vtWidth,vtL,vtW,vtH;
|
|
|
|
int nGripIndex = arIndex.first();
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtOffset);
|
|
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
double dThick = 0.0,dHAdd = 0.0;
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK,dThick);
|
|
|
|
switch(nGripIndex)
|
|
{
|
|
case 0://上,上厚度
|
|
{
|
|
if (pLn != NULL)
|
|
{
|
|
if (vtZOffset.isCodirectionalTo(AcGeVector3d::kZAxis))//增厚
|
|
{
|
|
dThick += dLen;
|
|
}
|
|
else//减去厚度
|
|
{
|
|
dThick -= dLen;
|
|
}
|
|
|
|
if (dThick > 1.0)//最薄 1 毫米
|
|
{
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dThick);
|
|
GetSpecialtyData()->SetAt(KEY_THICK,dThick);
|
|
|
|
ptSta = pLn->startPoint();
|
|
ptEnd = pLn->endPoint();
|
|
|
|
double dThickOld = ptEnd.distanceTo(ptSta);
|
|
|
|
vtL = ptEnd - ptSta;
|
|
vtL.normalize();
|
|
|
|
ptEnd = ptSta + vtL * dThick;
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
double dThickAdd = dThick - dThickOld;
|
|
AcGeVector3d vtAdd = vtL * 0.5 * dThickAdd;
|
|
|
|
HoleAndPipeExtend(dThickAdd,vtAdd);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case 1://中,改标高
|
|
{
|
|
if (pLn != NULL)
|
|
{
|
|
ptSta = pLn->startPoint();
|
|
ptEnd = pLn->endPoint();
|
|
|
|
vtZOffset.normalize();
|
|
vtZOffset *= dLen;
|
|
ptSta += vtZOffset;
|
|
ptEnd += vtZOffset;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptSta,TRUE);
|
|
|
|
HoleAndPipeExtend(0,vtZOffset);
|
|
}
|
|
break;
|
|
}
|
|
case 2://下,改厚度和标高
|
|
{
|
|
if (pLn != NULL)
|
|
{
|
|
ptSta = pLn->startPoint();
|
|
ptEnd = pLn->endPoint();
|
|
vtL = ptEnd - ptSta;
|
|
vtL.normalize();
|
|
|
|
double dThickOld = ptEnd.distanceTo(ptSta);
|
|
|
|
vtZOffset.normalize();
|
|
vtZOffset *= dLen;
|
|
ptSta += vtZOffset;
|
|
|
|
dHAdd = pLn->startPoint().z - ptSta.z;
|
|
|
|
if ( ( dThick + dHAdd ) > 1.0)
|
|
{
|
|
pLn->setStartPoint(ptSta);
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptSta,TRUE);
|
|
|
|
ptEnd = ptSta + vtL * (dThick + dHAdd);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
GetSpecialtyData()->SetAt(KEY_BOMTHICK,dThick + dHAdd);
|
|
GetSpecialtyData()->SetAt(KEY_THICK,dThick + dHAdd);
|
|
|
|
double dThickNew = dThick + dHAdd;
|
|
|
|
double dThickAdd = dThickNew - dThickOld;
|
|
AcGeVector3d vtAdd = vtL * 0.5 * dThickAdd;
|
|
|
|
HoleAndPipeExtend(dThickAdd,vtAdd);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case 3://中心,位置
|
|
{
|
|
if (eShape == eUserDef)
|
|
{
|
|
CString sPoint2dsTop1;
|
|
GetSpecialtyData()->GetAt(KEY_POINTS,sPoint2dsTop1);
|
|
AcDbPolyline* pPl = CoreTools::StringToPolyline(sPoint2dsTop1);
|
|
if (pPl != NULL)
|
|
{
|
|
xformM.setToTranslation(offset);
|
|
pPl->transformBy(xformM);
|
|
|
|
CString sPoint2dsTop;
|
|
CoreTools::PolylineToString(pPl,sPoint2dsTop);
|
|
|
|
GetSpecialtyData()->SetAt(KEY_POINTS,sPoint2dsTop);
|
|
delete pPl;
|
|
}
|
|
}
|
|
|
|
ptSta = pLn->startPoint();
|
|
ptEnd = pLn->endPoint();
|
|
|
|
ptSta += offset;
|
|
ptEnd += offset;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
ptOrg += offset;
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptOrg);
|
|
|
|
HoleAndPipeExtend(0,offset);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::ImpMoveRectWallGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset)
|
|
{
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if ( gripAppData.isEmpty() )
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
arIndex.append(pAppData->nIndex);
|
|
|
|
AcDbIntArray osnapModes;
|
|
AcDbIntArray geomIds;
|
|
AcGePoint3dArray arPts;
|
|
m_pBaseCurve->getGripPoints(arPts,osnapModes,geomIds);
|
|
|
|
if (pAppData->nIndex < arPts.length() )//曲线夹点
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int nIndex = pAppData->nIndex - arPts.length();
|
|
|
|
AcGeVector3d vtOffset = offset;
|
|
|
|
AcGeVector3d vtXYOffset;
|
|
vtXYOffset = vtOffset.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtZOffset;
|
|
vtZOffset = vtOffset.orthoProject(AcGeVector3d::kXAxis);
|
|
|
|
AcGeVector3d vtWidth,vtL,vtW,vtH;
|
|
|
|
int nGripIndex = arIndex.first();
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtOffset);
|
|
|
|
WallData data;
|
|
GetAsWallData(data);
|
|
|
|
AcGePoint3d ptTmp,ptTmp2;
|
|
AcGeMatrix3d xform;
|
|
double dThick = 0.0,dHAdd = 0.0;
|
|
double dLen = offset.length();
|
|
|
|
AcDbCurve* pBaseCrv = m_pBaseCurve;
|
|
if (pBaseCrv != NULL)
|
|
{
|
|
double dSta = 0.0,dEnd = 0.0;
|
|
pBaseCrv->getStartParam(dSta);
|
|
|
|
AcGeVector3d vtL,vtDir;
|
|
pBaseCrv->getFirstDeriv(dSta,vtL);
|
|
vtDir = vtL;
|
|
vtDir.normalize();
|
|
vtL.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtL.normalize();
|
|
|
|
AcGePoint3d ptGe[3],ptTmp;
|
|
pBaseCrv->getStartPoint(ptGe[0]);
|
|
|
|
ptGe[0] += vtDir * 100.0;
|
|
ptGe[2] = ptGe[0] + vtDir * 100.0;
|
|
AcDbLine ln(ptGe[0],ptGe[2]);
|
|
AcDbLine* pLn = &ln;
|
|
pBaseCrv = pLn;
|
|
pBaseCrv->getStartParam(dSta);
|
|
pBaseCrv->getEndParam(dEnd);
|
|
|
|
int nAlign = 0;
|
|
EAlign kAlign = (EAlign)nAlign;//kMid
|
|
|
|
pBaseCrv->getPointAtParam((dSta+dEnd) / 2.0,ptGe[1]);
|
|
|
|
//1.直线墙
|
|
if (pLn != NULL)
|
|
{
|
|
vtL = pLn->endPoint() - pLn->startPoint();
|
|
vtW = vtL;
|
|
vtW.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
switch(nIndex)//最多 6 个点
|
|
{
|
|
case 0://下中线中下 ->改标高
|
|
{
|
|
ptTmp = pLn->startPoint();
|
|
//ptTmp += vtOffset;
|
|
vtZOffset.normalize();
|
|
vtZOffset *= dLen;
|
|
ptTmp += vtZOffset;
|
|
|
|
dHAdd = pLn->startPoint().z - ptTmp.z;
|
|
|
|
if (data.nSecShape == eRect)//矩形墙体
|
|
{
|
|
if ( (data.dH + dHAdd)>1.e-3)
|
|
{
|
|
SetAsWallData(data.dThick,data.dH + dHAdd,data.dBomEl - dHAdd);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case 1://前线mid ->改宽,不改长
|
|
{
|
|
vtWidth = vtXYOffset.orthoProject(vtL);
|
|
|
|
ptTmp = pLn->startPoint();
|
|
ptTmp2 = ptTmp + vtWidth;
|
|
|
|
dThick = dLen;//vtWidth.length();//增加的宽度
|
|
if (!vtW.isCodirectionalTo(vtWidth))
|
|
{
|
|
dThick *= -1.0;
|
|
}
|
|
|
|
if ( (data.dThick + dThick ) > 1.e-3)
|
|
{
|
|
//中线移动一半
|
|
vtWidth.normalize();
|
|
vtWidth *= dLen;
|
|
xform.setToTranslation(0.5 * vtWidth);
|
|
pLn->transformBy(xform);
|
|
|
|
if (data.nSecShape == eRect)//矩形墙体
|
|
{
|
|
SetAsWallData(data.dThick + dThick,data.dH,data.dBomEl);
|
|
}
|
|
else
|
|
{
|
|
//...
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case 2://后线mid ->改宽,不改长
|
|
{
|
|
vtWidth = vtXYOffset.orthoProject(vtL);
|
|
|
|
ptTmp = pLn->startPoint();
|
|
ptTmp2 = ptTmp + vtWidth;
|
|
|
|
dThick = dLen;//vtWidth.length();//增加的宽度
|
|
if (vtW.isCodirectionalTo(vtWidth))
|
|
{
|
|
dThick *= -1.0;
|
|
}
|
|
|
|
if ( (data.dThick + dThick) > 1.e-3)
|
|
{
|
|
//中线移动一半
|
|
vtWidth.normalize();
|
|
vtWidth *= dLen;
|
|
xform.setToTranslation(0.5 * vtWidth);
|
|
pLn->transformBy(xform);
|
|
|
|
if (data.nSecShape == eRect)//矩形墙体
|
|
{
|
|
SetAsWallData(data.dThick + dThick,data.dH,data.dBomEl);
|
|
}
|
|
else
|
|
{
|
|
//..
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case 3://上线mid ->改高度
|
|
{
|
|
ptTmp = pLn->startPoint();
|
|
//ptTmp += vtOffset;
|
|
vtZOffset.normalize();
|
|
vtZOffset *= dLen;
|
|
ptTmp += vtZOffset;
|
|
|
|
dHAdd = ptTmp.z - pLn->startPoint().z;
|
|
|
|
if (data.nSecShape == eRect)//矩形墙体
|
|
{
|
|
if ( (data.dH + dHAdd) > 1.e-3)
|
|
{
|
|
SetAsWallData(data.dThick,data.dH + dHAdd,data.dBomEl);
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::RectImpMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AecGripData* pAppData = NULL;
|
|
if ( gripAppData.isEmpty() )
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//>3 为尺寸调整夹点
|
|
AcGeVector3d vtOffset = offset;
|
|
|
|
AcGeVector3d vtXYOffset;
|
|
vtXYOffset = vtOffset.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtX(vtXYOffset.x,0,0);
|
|
AcGeVector3d vtY(0,vtXYOffset.y,0);
|
|
|
|
AcGePoint3d ptSta,ptEnd,ptOrg;
|
|
AcGeVector3d vt1,vt2;
|
|
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
|
|
double dL = 0.0,dW = 0.0;
|
|
GetSpecialtyData()->GetAt(KEY_Length,dL);
|
|
GetSpecialtyData()->GetAt(KEY_Width,dW);
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtDirY = AcGeVector3d::kYAxis;
|
|
|
|
//根据rotate旋转 X,Y
|
|
double dRotate = GetRotation(Z);
|
|
vtDirX.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
vtDirY.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d ptGe[5],ptGeT;
|
|
ptGe[0] = ptOrg;
|
|
|
|
//左下
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] -= vtDirX * 0.5 * dL;
|
|
ptGe[1] -= vtDirY * 0.5 * dW;
|
|
|
|
//左上
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] += vtDirY * dW;
|
|
|
|
//右上
|
|
ptGe[3] = ptGe[2];
|
|
ptGe[3] += vtDirX * dL;
|
|
|
|
//右下
|
|
ptGe[4] = ptGe[3];
|
|
ptGe[4] -= vtDirY * dW;
|
|
|
|
AcGeVector3d vt1x,vt1y,vt2x,vt2y;
|
|
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
int nGripIndex = pAppData->nIndex;
|
|
if (nGripIndex < 3)
|
|
return Acad::eOk;
|
|
|
|
vt1 = ptGe[nGripIndex - 3] - ptOrg;
|
|
|
|
//修改尺寸,修改位置点
|
|
ptGeT = ptGe[nGripIndex - 3] + vtXYOffset;
|
|
vt2 = ptGeT - ptGe[nGripIndex - 3];
|
|
|
|
vt1x.set(vt1.x,0,0);
|
|
vt1y.set(0,vt1.y,0);
|
|
|
|
vt2x.set(vt2.x,0,0);
|
|
vt2y.set(0,vt2.y,0);
|
|
|
|
//判断方向一致性
|
|
if (vt1x.dotProduct(vt2x) > 1.e-10)
|
|
{
|
|
dL += vtX.length();
|
|
}
|
|
else
|
|
{
|
|
dL -= vtX.length();
|
|
}
|
|
|
|
if (vt1y.dotProduct(vt2y) > 1.e-10)
|
|
{
|
|
dW += vtY.length();
|
|
}
|
|
else
|
|
{
|
|
dW -= vtY.length();
|
|
}
|
|
|
|
ptOrg += 0.5 * vtXYOffset;
|
|
if (dL > 1.0 && dW > 1.0)
|
|
{
|
|
SetSection(dL,dW,0.0);
|
|
|
|
GetSpecialtyData()->SetAt(KEY_Length,dL);
|
|
GetSpecialtyData()->SetAt(KEY_Width,dW);
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptOrg);
|
|
|
|
if (pLn != NULL)
|
|
{
|
|
ptSta = pLn->startPoint();
|
|
ptEnd = pLn->endPoint();
|
|
|
|
double dThickOld = ptEnd.distanceTo(ptSta);
|
|
|
|
vt1 = ptEnd - ptSta;
|
|
ptSta = ptOrg;
|
|
ptEnd = ptSta + vt1;
|
|
|
|
double dThickNew = ptEnd.distanceTo(ptSta);
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
double dThickAdd = dThickNew - dThickOld;
|
|
vt1.normalize();
|
|
AcGeVector3d vtAdd = vt1 * 0.5 * dThickAdd;
|
|
|
|
HoleAndPipeExtend(dThickAdd,vtAdd);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::CircleImpMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AecGripData* pAppData = NULL;
|
|
if ( gripAppData.isEmpty() )
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//>3 为尺寸调整夹点
|
|
AcGeVector3d vtOffset = offset;
|
|
|
|
AcGeVector3d vtXYOffset;
|
|
vtXYOffset = vtOffset.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d ptOrg;
|
|
|
|
double dR = 0.0;
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dR);
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtDirY = AcGeVector3d::kYAxis;
|
|
|
|
//根据rotate旋转 X,Y
|
|
double dRotate = GetRotation(Z);
|
|
vtDirX.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
vtDirY.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d ptGe[2],ptGeT;
|
|
ptGe[1] = ptOrg + vtDirX * dR;
|
|
ptGeT = ptGe[1] + vtXYOffset;
|
|
|
|
dR = ptGeT.distanceTo(ptOrg);
|
|
if (dR > 1.0)
|
|
{
|
|
double dWallHeight = 0.0,dWallWidth = 0.0,dBomThick = 0.0;
|
|
|
|
//SetSection(2.0 * dR,0.0);
|
|
//GetSpecialtyData()->SetAt(KEY_RAD,dR);
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK,dBomThick);
|
|
GetSpecialtyData()->GetAt(KEY_HEIGHT,dWallHeight);
|
|
GetSpecialtyData()->GetAt(KEY_THICK,dWallWidth);
|
|
|
|
if (dWallHeight > 1.0 || dWallWidth > 1.0)
|
|
{
|
|
SetCircleBasin(dR,dBomThick,dWallHeight,dWallWidth,ptOrg);
|
|
}
|
|
else
|
|
{
|
|
SetCircleSlab(dR,dBomThick,ptOrg.z,ptOrg,FALSE);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::EllispeImpMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AecGripData* pAppData = NULL;
|
|
if ( gripAppData.isEmpty() )
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//>3 为尺寸调整夹点
|
|
AcGeVector3d vtOffset = offset;
|
|
|
|
AcGeVector3d vtXYOffset;
|
|
vtXYOffset = vtOffset.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d ptOrg;
|
|
|
|
double dR = 0.0,radiusRatio = 0.0;
|
|
double dWallH = 0.0,dWallW = 0.0,dBomThick = 0.0;
|
|
|
|
GetSpecialtyData()->GetAt(KEY_RAD,dR);
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
GetSpecialtyData()->GetAt(KEY_RRATIO,radiusRatio);
|
|
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK,dBomThick);
|
|
GetSpecialtyData()->GetAt(KEY_HEIGHT,dWallH);
|
|
GetSpecialtyData()->GetAt(KEY_THICK,dWallW);
|
|
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtDirY = AcGeVector3d::kYAxis;
|
|
|
|
//根据rotate旋转 X,Y
|
|
double dRotate = GetRotation(Z);
|
|
vtDirX.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
vtDirY.rotateBy(dRotate,AcGeVector3d::kZAxis);
|
|
|
|
//4,5
|
|
//ptGe[1] = ptOrg + vtDirX * dRmaj;
|
|
//ptGe[2] = ptOrg + vtDirY * dRmaj * radiusRatio;
|
|
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
int nGripIndex = pAppData->nIndex;
|
|
if (nGripIndex < 3)
|
|
return Acad::eOk;
|
|
|
|
AcGePoint3d ptGe[3],ptGeT;
|
|
ptGe[1] = ptOrg + vtDirX * dR;
|
|
ptGe[2] = ptOrg + vtDirY * dR * radiusRatio;
|
|
|
|
AcGeVector3d vt1,vtMaj,vtMin;
|
|
switch(nGripIndex)
|
|
{
|
|
case 4://maj
|
|
{
|
|
ptGeT = ptGe[1] + vtXYOffset;
|
|
vt1 = ptGeT - ptOrg;
|
|
vtMaj = vt1.orthoProject(vtDirY);
|
|
|
|
if (vtMaj.length() > 1.0 )
|
|
{
|
|
dR = vtMaj.length();
|
|
SetEllipseBasin(dR,radiusRatio,dBomThick,dWallH,dWallW,ptOrg);
|
|
}
|
|
break;
|
|
}
|
|
case 5://min
|
|
{
|
|
ptGeT = ptGe[2] + vtXYOffset;
|
|
vt1 = ptGeT - ptOrg;
|
|
vtMin = vt1.orthoProject(vtDirX);
|
|
|
|
if (vtMin.length() > 1.0)
|
|
{
|
|
dR = vtMin.length() / radiusRatio;
|
|
SetEllipseBasin(dR,radiusRatio,dBomThick,dWallH,dWallW,ptOrg);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::UserDefImpMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AecGripData* pAppData = NULL;
|
|
if ( gripAppData.isEmpty() )
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//>3 为尺寸调整夹点
|
|
AcGeVector3d vtOffset = offset;
|
|
|
|
AcGeVector3d vtXYOffset;
|
|
vtXYOffset = vtOffset.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
int nGripIndex = pAppData->nIndex;
|
|
if (nGripIndex < 3)
|
|
return Acad::eOk;
|
|
|
|
int nIndex = nGripIndex - 4;//pl点索引
|
|
|
|
AcGePoint3d ptOrg;
|
|
CString sPoint2dsTop;
|
|
GetSpecialtyData()->GetAt(KEY_POINTS,sPoint2dsTop);
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
|
|
AcDbPolyline* pPl = PointsScrToPolyline(sPoint2dsTop);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setClosed(Adesk::kTrue);
|
|
|
|
AcGePoint3d ptGe[2],ptGeT;
|
|
if ( nIndex < pPl->numVerts() )
|
|
{
|
|
pPl->getPointAt(nIndex,ptGeT);
|
|
|
|
ptGeT += vtXYOffset;
|
|
pPl->setPointAt(nIndex,ptGeT.convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
|
|
AcDbRegion* pReg = PolylineToRegion(pPl);
|
|
if (pReg != NULL)
|
|
{
|
|
//region的中心点
|
|
pPl->getPointAt(0,ptOrg);
|
|
|
|
SetSection(pReg,ptOrg);
|
|
delete pReg;
|
|
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptOrg,TRUE);
|
|
|
|
if ( CoreTools::PolylineToString(pPl,sPoint2dsTop) )
|
|
{
|
|
GetSpecialtyData()->SetAt(KEY_POINTS,sPoint2dsTop);
|
|
}
|
|
}
|
|
delete pPl;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::subGetStretchPoints(AcGePoint3dArray& stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
extern BOOL IsFrontView();
|
|
if (IsFrontView())//立面
|
|
{
|
|
//如果原点设置,则为类墙体似截面拉板
|
|
AcGePoint3d ptOrg,ptGeT;
|
|
if (GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
//ellipse
|
|
double dThick = 0.0;
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg);
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK,dThick);
|
|
|
|
//上厚
|
|
ptGeT = ptOrg;
|
|
ptGeT.z += dThick;
|
|
stretchPoints.append(ptGeT);
|
|
|
|
//下厚
|
|
ptGeT = ptOrg;
|
|
stretchPoints.append(ptGeT);
|
|
}
|
|
else
|
|
{
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcGePoint3d ptGeT;
|
|
double dSta = 0.0,dEnd = 0.0;
|
|
|
|
m_pBaseCurve->getStartParam(dSta);
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
|
|
m_pBaseCurve->getPointAtParam((dSta+dEnd) / 2.0,ptGeT);
|
|
|
|
WallData data;
|
|
GetAsWallData(data);
|
|
|
|
ptGeT.z += data.dThick;
|
|
stretchPoints.append(ptGeT);
|
|
|
|
ptGeT.z -= data.dThick;
|
|
stretchPoints.append(ptGeT);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//如果原点设置,则为类墙体似截面拉板
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
m_pBaseCurve->getStretchPoints(stretchPoints);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbCurve* pShape = GetBasinShapeCurve(true);
|
|
if (pShape != NULL)
|
|
{
|
|
pShape->getStretchPoints(stretchPoints);
|
|
delete pShape;
|
|
}
|
|
else
|
|
{
|
|
int nShape = -1;
|
|
GetSpecialtyData()->GetAt(KEY_SHAPE,nShape);
|
|
ESection eShape = (ESection)nShape;
|
|
|
|
if (eShape == eXShape)
|
|
{
|
|
GetNativeCurve()->getStretchPoints(stretchPoints);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXSlab::subMoveStretchPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (offset.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
if (!indices.isEmpty())
|
|
{
|
|
AcGeMatrix3d xMove;
|
|
xMove.setToTranslation(offset);
|
|
|
|
return transformBy(xMove);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//如果原点设置,则为类墙体似截面拉板
|
|
AcGePoint3d ptOrg;
|
|
if (!GetSpecialtyData()->GetAt(KEY_ORGPT,ptOrg))
|
|
{
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
m_pBaseCurve->moveStretchPointsAt(indices,offset);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbCurve* pShape = GetBasinShapeCurve(true);
|
|
ESection eSection = GetBasinShape();
|
|
|
|
AcGePoint3d ptCenPos;
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(offset);
|
|
|
|
m_mapSpecXData.GetAt(KEY_ORGPT,ptCenPos);
|
|
ptCenPos.transformBy(xform);
|
|
m_mapSpecXData.SetAt(KEY_ORGPT,ptCenPos);
|
|
|
|
if (pShape != NULL)
|
|
{
|
|
pShape->moveStretchPointsAt(indices,offset);
|
|
|
|
//凸包曲线
|
|
AcDbCircle* pCir = AcDbCircle::cast(pShape);
|
|
if (pCir != NULL)
|
|
{
|
|
m_pBaseCurve->transformBy(xform);
|
|
}
|
|
|
|
AcDbEllipse* pElp = AcDbEllipse::cast(pShape);
|
|
if (pElp != NULL)
|
|
{
|
|
m_pBaseCurve->transformBy(xform);
|
|
}
|
|
|
|
//凹包曲线
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pShape);
|
|
if (pPl != NULL)
|
|
{
|
|
AcDbRegion* pReg = NULL;
|
|
|
|
pReg = PolylineToRegion(pPl);
|
|
if (pReg != NULL)
|
|
{
|
|
//region的中心点
|
|
AcGePoint3d ptOrg;
|
|
pPl->getPointAt(0,ptOrg);
|
|
|
|
SetSection(pReg,ptOrg);
|
|
delete pReg;
|
|
|
|
ptOrg.z = GetElBom();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta,ptEnd;
|
|
ptEnd = pLn->endPoint();
|
|
ptSta = pLn->startPoint();
|
|
|
|
AcGeVector3d vt = ptEnd - ptSta;
|
|
|
|
pLn->setStartPoint(ptOrg);
|
|
ptEnd = ptOrg + vt;
|
|
pLn->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
|
|
GetSpecialtyData()->SetAt(KEY_ORGPT,ptOrg,TRUE);
|
|
GetSpecialtyData()->SetAt(KEY_Length,0.0);
|
|
GetSpecialtyData()->SetAt(KEY_Width,0.0);
|
|
GetSpecialtyData()->SetAt(KEY_SHAPE,eUserDef);
|
|
|
|
CString sPoint2dsTop;
|
|
if ( CoreTools::PolylineToString(pPl,sPoint2dsTop) )
|
|
{
|
|
GetSpecialtyData()->SetAt(KEY_POINTS,sPoint2dsTop);
|
|
}
|
|
}
|
|
}
|
|
delete pShape;
|
|
}
|
|
else if (eSection == eXShape)
|
|
{
|
|
GetNativeCurve()->moveStretchPointsAt(indices,offset);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbXSlab::ComparedTo(AecDbCurveBase* pCurOther) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbXSlab* pOther = AecDbXSlab::cast(pCurOther);
|
|
if (pOther != NULL)
|
|
{
|
|
PoolData data;
|
|
GetBasinSlabData(data);
|
|
|
|
PoolData data2;
|
|
pOther->GetBasinSlabData(data2);
|
|
|
|
//厚度
|
|
if ( fabs(data.m_dBomThick - data2.m_dBomThick) > 1.0)
|
|
return 1;
|
|
|
|
if ( fabs(data.m_dBomEl - data2.m_dBomEl) > 1.0)
|
|
return 1;
|
|
|
|
if ( fabs(data.m_dData[0] - data2.m_dData[0]) > 1.0)
|
|
return 1;
|
|
|
|
if ( fabs(data.m_dData[1] - data2.m_dData[1]) > 1.0)
|
|
return 1;
|
|
|
|
if ( fabs(data.m_dData[2] - data2.m_dData[2]) > 1.0)
|
|
return 1;
|
|
|
|
//体积 体积数据较大不考虑比对
|
|
//double dVol1 = GetVolume();
|
|
//double dVol2 = pOther->GetVolume();
|
|
|
|
//if ( fabs(dVol1 - dVol2) > 1.0)
|
|
// return 1;
|
|
|
|
//相同
|
|
return 0;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
SHJson::WValue& AecDbXSlab::ToJson(bool bExprotGeo) const
|
|
{
|
|
assertReadEnabled();
|
|
return AecDbBDPipeBase::ToJson(bExprotGeo);
|
|
}
|
|
|
|
bool AecDbXSlab::ByJson(const SHJson::WValue &v)
|
|
{
|
|
AssertWriteEnabled();
|
|
return AecDbBDPipeBase::ByJson(v);
|
|
}
|
|
|
|
#include "HlrCutOption.h"
|
|
#include "AcGiviewDraw.h"
|
|
|
|
void AecDbXSlab::PreprocessForHlr(const AcGePoint3d &ptPlnO
|
|
, const AcGeVector3d &vtPlnN
|
|
, AcArray<AcDbEntity *> &ar) const
|
|
{
|
|
// 只处理水平剖切
|
|
if (!vtPlnN.isParallelTo(AcGeVector3d::kZAxis))
|
|
return;
|
|
|
|
PipeHatch ph;
|
|
if (!GetHatch(ph)) return;
|
|
|
|
// 得到上表面标高
|
|
double dTopElev = GetElBom() + GetThick();
|
|
|
|
// 遍历2d buffer 得到 hatch
|
|
if (!Has2DBuffer())
|
|
{
|
|
AcGiViewDraw dc;
|
|
Draw2d(dc);
|
|
}
|
|
const AcDbVoidPtrArray &ar2ds = Get2DBuffer();
|
|
if (ar2ds.isEmpty()) return;
|
|
|
|
for (int i(0); i < ar2ds.length(); ++i)
|
|
{
|
|
AcDbEntity *pEnt((AcDbEntity*)ar2ds[i]);
|
|
if (!pEnt) continue;
|
|
AcDbHatch *pHatch(AcDbHatch::cast(pEnt));
|
|
if (!pHatch) continue;
|
|
|
|
AcDbHatch *pNewH = (AcDbHatch*)pHatch->clone();
|
|
// 调整标高
|
|
pNewH->setElevation(dTopElev);
|
|
ar.append(pNewH);
|
|
}
|
|
|
|
// 如果实体和剖面相交,标记
|
|
HlrCutOption::setIntersectWithSection(this, AcGePlane(ptPlnO, vtPlnN));
|
|
}
|
|
|
|
void AecDbXSlab::ProcessHlrResult(const AcArray<AcDbEntity *> &ar
|
|
, const std::map<AcDbEntity *, AcArray<AcDbEntity *>> &preAr
|
|
, AcArray<AcDbEntity *> &output) const
|
|
{
|
|
std::map<AcDbEntity *, AcArray<AcDbEntity *>>::const_iterator it(preAr.begin());
|
|
int clr(colorIndex());
|
|
for (; it != preAr.end(); ++it)
|
|
{
|
|
AcDbEntity *pEnt(it->first);
|
|
AcDbHatch *pHatch(AcDbHatch::cast(pEnt));
|
|
if (!pHatch) continue;
|
|
|
|
for (int i(0); i < it->second.length(); ++i)
|
|
{
|
|
AcDbEntity *p((AcDbEntity *)it->second[i]->clone());
|
|
if (p)
|
|
{
|
|
p->setColorIndex(clr);
|
|
// output 内的内存,会在HlrCutOption::ProcessHlrResult里面销毁
|
|
output.append(p);
|
|
}
|
|
}
|
|
}
|
|
|
|
double dW(.0);
|
|
BOOL bBold = HlrCutOption::getEnvCutLW(this, dW);
|
|
|
|
HlrCutOption::ProcessHlrResult(this
|
|
, bBold
|
|
, dW
|
|
, FALSE
|
|
, ar
|
|
, preAr
|
|
, output);
|
|
}
|
|
|
|
namespace
|
|
{
|
|
void SetZeroEl(AcDbEntity *pEntCln)
|
|
{
|
|
AcGePoint3d pt1, pt2;
|
|
AcDbLine *pLn = AcDbLine::cast(pEntCln);
|
|
if (pLn != NULL)
|
|
{
|
|
pt1 = pLn->startPoint();
|
|
pt1.z = 0.0;
|
|
pt2 = pLn->endPoint();
|
|
pt2.z = 0.0;
|
|
pLn->setStartPoint(pt1);
|
|
pLn->setEndPoint(pt2);
|
|
}
|
|
|
|
AcDbArc *pArc = AcDbArc::cast(pEntCln);
|
|
if (pArc != NULL)
|
|
{
|
|
pt1 = pArc->center();
|
|
pt1.z = 0.0;
|
|
pArc->setCenter(pt1);
|
|
}
|
|
|
|
AcDbCircle *pCir = AcDbCircle::cast(pEntCln);
|
|
if (pCir != NULL)
|
|
{
|
|
pt1 = pCir->center();
|
|
pt1.z = 0.0;
|
|
pCir->setCenter(pt1);
|
|
}
|
|
|
|
AcDbPolyline *pPl = AcDbPolyline::cast(pEntCln);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setElevation(0);
|
|
}
|
|
}
|
|
|
|
AcDbHatch *DrawHatch(AcGiDraw &dc, const PipeHatch &sHatch, AcDbPolyline *pPl)
|
|
{
|
|
if (!pPl) return NULL;
|
|
if (pPl->numVerts() < 2) return NULL;
|
|
|
|
AcGiDraw::Vertex3d vt;
|
|
AcGiDraw::AcGiPoly2d polyReg;
|
|
for (int i = 0; i < pPl->numVerts(); i++)
|
|
{
|
|
pPl->getPointAt(i, vt.pt);
|
|
pPl->getBulgeAt(i, vt.dBulge);
|
|
polyReg.append(vt);
|
|
}
|
|
|
|
AcDbHatch *pHatch = dc.DrawHatch(polyReg, sHatch.szPattern, sHatch.dScale, sHatch.dAngle);
|
|
if (!pHatch) return NULL;
|
|
return pHatch;
|
|
|
|
|
|
AcDbCircle cir(AcGePoint3d::kOrigin, AcGeVector3d::kZAxis, 2500);
|
|
AcDbPolyline *p = CoreTools::MakePolyline(&cir);
|
|
if (p && pHatch)
|
|
{
|
|
AcGePoint2dArray pts;
|
|
AcGeDoubleArray bulges;
|
|
for (int j = 0; j < p->numVerts(); j++)
|
|
{
|
|
p->getPointAt(j, vt.pt);
|
|
p->getBulgeAt(j, vt.dBulge);
|
|
pts.append(AcGePosition2d(vt.pt.x, vt.pt.y));
|
|
bulges.append(vt.dBulge);
|
|
}
|
|
pts.append(pts.first());
|
|
bulges.append(bulges.first());
|
|
pHatch->setHatchStyle(AcDbHatch::kOuter);
|
|
pHatch->appendLoop(AcDbHatch::kPolyline|AcDbHatch::kDerived|AcDbHatch::kOutermost, pts, bulges);
|
|
pHatch->evaluateHatch();
|
|
DELETE_PTR(p);
|
|
|
|
CoreTools::CloneAndAddToModelSpace(pHatch, 1);
|
|
|
|
}
|
|
}
|
|
}
|
|
extern AcDbPolyline *FormatPolyline(const AcGePoint3d &ptCen, double dL, double dW);
|
|
void AecDbXSlab::DrawHatch(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
PipeHatch sHatch;
|
|
if (!GetHatch(sHatch)) return;
|
|
|
|
const AcDbVoidPtrArray &arEntPtrs = Get2DBuffer();
|
|
AcDbEntity *pEnt = NULL;
|
|
AcDbEntity *pEntCln = NULL;
|
|
AcDbVoidPtrArray arEntClnPtrs, arRelt;
|
|
|
|
for (int i = 0; i < arEntPtrs.length(); i++)
|
|
{
|
|
pEnt = (AcDbEntity *)arEntPtrs.at(i);
|
|
|
|
// 填充不处理
|
|
if (AcDbHatch::cast(pEnt)) continue;
|
|
|
|
if (pEnt != NULL)
|
|
{
|
|
pEntCln = (AcDbEntity *)pEnt->isA()->create();
|
|
CopyObject(*pEnt, *pEntCln);
|
|
//设置成0标高
|
|
SetZeroEl(pEntCln);
|
|
arEntClnPtrs.append(pEntCln);
|
|
}
|
|
}
|
|
|
|
AcDbCurve *pCurve = KTCADUtilityEx::ConvertBoundCurve(arEntClnPtrs, arRelt);
|
|
if (!pCurve) return;
|
|
FreeBuffer(0, arRelt);
|
|
|
|
AcDbPolyline *pPl = AcDbPolyline::cast(pCurve);
|
|
if (!pPl) return;
|
|
|
|
pPl->setElevation(.0);
|
|
pPl->setClosed(Adesk::kTrue);
|
|
AcDbHatch *pHatch = ::DrawHatch(dc, sHatch, pPl);
|
|
DELETE_PTR(pCurve);
|
|
if (!pHatch) return;
|
|
|
|
// 在这里处理一下楼板,盖板的洞口
|
|
AcGiDraw::Vertex3d vt;
|
|
AcGePoint2dArray pts;
|
|
AcGeDoubleArray bulges;
|
|
bool bMoreLoop(false);
|
|
for (int i(0); i < m_arAssocPartEntIds.length(); ++i)
|
|
{
|
|
const AcDbObjectId &id(m_arAssocPartEntIds[i]);
|
|
AcDbObjectPointer<AecDbX3dPartEntity> entPart(id, AcDb::kForRead);
|
|
if (entPart.openStatus() != Acad::eOk) continue;
|
|
if (entPart->GetName() != _T("开洞")) continue;
|
|
|
|
const AecDbObjXDataMap *pMap = entPart->GetSpecialtyData();
|
|
if (!pMap) continue;
|
|
|
|
int nDir(0);
|
|
pMap->GetAt(_T("m_nDir"), nDir);
|
|
if (nDir != 1) continue;
|
|
|
|
int nHoleType(eTrape);
|
|
pMap->GetAt(_T("nShape"), nHoleType);
|
|
AcGePoint3d ptCenter(entPart->GetOrgPoint());
|
|
std::shared_ptr<AcDbPolyline> pline;
|
|
if (nHoleType == eRect)
|
|
{
|
|
double dL, dW;
|
|
if (!pMap->GetAt(_T("dL"), dL) || !pMap->GetAt(_T("dW"), dW)) continue;
|
|
pline.reset(FormatPolyline(ptCenter, dL, dW));
|
|
if (!pline) continue;
|
|
}
|
|
else if (nHoleType == eCircle)
|
|
{
|
|
double dRad;
|
|
if (!pMap->GetAt(_T("dRad"), dRad)) continue;
|
|
AcDbCircle cir(ptCenter, AcGeVector3d::kZAxis, dRad);
|
|
pline.reset(CoreTools::MakePolyline(&cir));
|
|
if (!pline) continue;
|
|
}
|
|
else if (nHoleType == eUserDef)
|
|
{
|
|
CString strPts(_T(""));
|
|
if (!pMap->GetAt(_T("Points"), strPts)) continue;
|
|
pline.reset(CoreTools::StringToPolyline(strPts));
|
|
if (!pline) continue;
|
|
}
|
|
else
|
|
continue;
|
|
|
|
pts.removeAll();
|
|
bulges.removeAll();
|
|
|
|
for (int j = 0; j < pline->numVerts(); j++)
|
|
{
|
|
pline->getPointAt(j, vt.pt);
|
|
pline->getBulgeAt(j, vt.dBulge);
|
|
pts.append(AcGePosition2d(vt.pt.x, vt.pt.y));
|
|
bulges.append(vt.dBulge);
|
|
}
|
|
pts.append(pts.first());
|
|
bulges.append(bulges.first());
|
|
pHatch->appendLoop(AcDbHatch::kPolyline|AcDbHatch::kDerived|AcDbHatch::kOutermost, pts, bulges);
|
|
bMoreLoop = true;
|
|
}
|
|
if (bMoreLoop)
|
|
{
|
|
pHatch->setHatchStyle(AcDbHatch::kOuter);
|
|
pHatch->evaluateHatch();
|
|
}
|
|
Add2DBuffer(pHatch);
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
|
|
bool AecDbXSlab::GetProperties(SimpleProperty::PropertySetByIndex & properties) const
|
|
{
|
|
AecDbBDPipeBase::GetProperties(properties);
|
|
CoreTools::setLayerPorperty(properties);
|
|
CoreTools::setSubSystemPorperty(properties);
|
|
|
|
CEntityProperty::SlabType tp = CEntityProperty::getSlabType((AcDbEntity *)this);
|
|
|
|
AcGePoint3d ptCenPos;
|
|
double dBomThick(.0), dHZ(.0), dHZ2(.0);
|
|
CString sMaterial, sPurpose, sZFlag;
|
|
GetSpecialtyData()->GetAt(KEY_MATERIAL, sMaterial);
|
|
GetSpecialtyData()->GetAt(KEY_PURPOSE, sPurpose);
|
|
GetSpecialtyData()->GetAt(KEY_HZ, dHZ);
|
|
GetSpecialtyData()->GetAt(KEY_HZ2, dHZ2);
|
|
GetSpecialtyData()->GetAt(KEY_ZHFS, sZFlag);
|
|
GetSpecialtyData()->GetAt(KEY_BOMTHICK, dBomThick);
|
|
GetSpecialtyData()->GetAt(KEY_ORGPT, ptCenPos); // 这里取出的是底板外底标高
|
|
|
|
SimpleProperty::makeAndInsert(properties, _T("板厚"), dBomThick, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("材质"), sMaterial, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("用途"), sPurpose, true);
|
|
|
|
switch (tp)
|
|
{
|
|
case CEntityProperty::eDB:
|
|
{
|
|
SimpleProperty::makeAndInsert(properties, _T("类型"), _T("水池底板"), false);
|
|
|
|
// 准备数据容器
|
|
double dWallH = 0.0;
|
|
double dWallThick = 0.0;
|
|
|
|
// 读取实体数据
|
|
GetSpecialtyData()->GetAt(KEY_HEIGHT, dWallH);
|
|
GetSpecialtyData()->GetAt(KEY_THICK, dWallThick);
|
|
|
|
// 2. 基本属性
|
|
// 计算池内底中心标高 (外底标高 + 厚度)
|
|
double dInnerEl = ptCenPos.z + dBomThick;
|
|
SimpleProperty::makeAndInsert(properties, _T("板顶标高"), dInnerEl, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("堰墙高度"), dWallH, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("堰墙壁厚"), dWallThick, true);
|
|
|
|
SimpleProperty::makeAndInsert(properties, _T("恒载"), dHZ, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("活载"), dHZ2, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("载荷方式"), sZFlag, true);
|
|
|
|
}
|
|
break;
|
|
case CEntityProperty::eLB:
|
|
{
|
|
SimpleProperty::makeAndInsert(properties, _T("类型"), _T("楼板"), false);
|
|
|
|
// 准备数据容器
|
|
CString sPattern;
|
|
double dAngle = 0.0;
|
|
double dScale = 1.0;
|
|
|
|
// 读取实体数据
|
|
const AecDbObjXDataMap *pData = GetSpecialtyData();
|
|
|
|
// 二维填充数据
|
|
pData->GetAt(KEY_PATTERN, sPattern);
|
|
pData->GetAt(KEY_PATTERNANG, dAngle);
|
|
pData->GetAt(KEY_PATTERNSCA, dScale);
|
|
|
|
// 界面显示为“板顶标高”,计算公式:板底 + 板厚
|
|
double dTopEl = ptCenPos.z + dBomThick;
|
|
SimpleProperty::makeAndInsert(properties, _T("板顶标高"), dTopEl, true);
|
|
|
|
// 2. 二维填充属性 (如果有图案名称才输出)
|
|
if (!sPattern.IsEmpty())
|
|
{
|
|
SimpleProperty::makeAndInsert(properties, _T("二维填充图案"), sPattern, false);
|
|
SimpleProperty::makeAndInsert(properties, _T("二维填充角度"), dAngle, false);
|
|
SimpleProperty::makeAndInsert(properties, _T("二维填充比例"), dScale, false);
|
|
}
|
|
|
|
BOOL bOffsetHalfWall(FALSE);
|
|
pData->GetAt(_T("_SLAB_HALF_WALL_"), bOffsetHalfWall);
|
|
if (bOffsetHalfWall)
|
|
{
|
|
double d;
|
|
pData->GetAt(_T("_HALF_WALL_THICK_"), d);
|
|
SimpleProperty::makeAndInsert(properties, _T("向外偏移半个墙厚"), _T("是"), false);
|
|
SimpleProperty::makeAndInsert(properties, _T("墙厚"), d, false);
|
|
}
|
|
else
|
|
{
|
|
SimpleProperty::makeAndInsert(properties, _T("向外偏移半个墙厚"), _T("否"), false);
|
|
}
|
|
}
|
|
break;
|
|
case CEntityProperty::eGB:
|
|
{
|
|
SimpleProperty::makeAndInsert(properties, _T("类型"), _T("盖板"), false);
|
|
|
|
// 准备数据容器
|
|
CString sPattern;
|
|
double dAngle = 0.0;
|
|
double dScale = 1.0;
|
|
int nColor = 256; // 默认随层
|
|
|
|
// 读取实体数据
|
|
const AecDbObjXDataMap *pData = GetSpecialtyData();
|
|
pData->GetAt(_T("COLOR"), nColor); // 读取颜色
|
|
|
|
// 二维填充数据
|
|
pData->GetAt(KEY_PATTERN, sPattern);
|
|
pData->GetAt(KEY_PATTERNANG, dAngle);
|
|
pData->GetAt(KEY_PATTERNSCA, dScale);
|
|
|
|
// 盖板界面显示的就是“盖板底标高”,实体存的也是底标高,直接输出
|
|
SimpleProperty::makeAndInsert(properties, _T("盖板底标高"), ptCenPos.z, true);
|
|
|
|
// 二维填充属性 (如果有图案名称才输出)
|
|
if (!sPattern.IsEmpty())
|
|
{
|
|
SimpleProperty::makeAndInsert(properties, _T("二维填充图案"), sPattern, false);
|
|
SimpleProperty::makeAndInsert(properties, _T("二维填充角度"), dAngle, false);
|
|
SimpleProperty::makeAndInsert(properties, _T("二维填充比例"), dScale, false);
|
|
|
|
// 颜色属性 (处理特殊值 256 为随层)
|
|
if (nColor == 256)
|
|
SimpleProperty::makeAndInsert(properties, _T("材质颜色"), _T("随层"), false);
|
|
else if (nColor == 0)
|
|
SimpleProperty::makeAndInsert(properties, _T("材质颜色"), _T("随块"), false);
|
|
else
|
|
SimpleProperty::makeAndInsert(properties, _T("材质颜色"), nColor, false);
|
|
}
|
|
}
|
|
break;
|
|
case CEntityProperty::eXDB:
|
|
{
|
|
SimpleProperty::makeAndInsert(properties, _T("类型"), _T("斜底板"), false);
|
|
|
|
// 准备数据容器
|
|
double dElev = 0.0;
|
|
double dIDist = 0.0; // 坡度分母
|
|
|
|
// 读取实体数据
|
|
const AecDbObjXDataMap* pData = GetSpecialtyData();
|
|
|
|
// 斜底板特有数据
|
|
pData->GetAt(_T("_XDB_FLAG_ELEV_"), dElev);
|
|
pData->GetAt(_T("_XDB_FLAG_DIST_"), dIDist);
|
|
|
|
// 1. 基本属性
|
|
SimpleProperty::makeAndInsert(properties, _T("倾斜基准点标高"), dElev, true); // 为了表述准确,加上前缀
|
|
SimpleProperty::makeAndInsert(properties, _T("每米下降坡度"), dIDist, true);
|
|
|
|
SimpleProperty::makeAndInsert(properties, _T("恒载"), dHZ, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("活载"), dHZ2, true);
|
|
SimpleProperty::makeAndInsert(properties, _T("载荷方式"), sZFlag, true);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXSlab::SetProperties(SimpleProperty::PropertySetByName & properties)
|
|
{
|
|
using namespace SimpleProperty;
|
|
|
|
if (properties.m_set.empty())
|
|
return false;
|
|
|
|
|
|
AecDbBDPipeBase::SetProperties(properties);
|
|
|
|
AecDbObjXDataMap *pData = GetSpecialtyData(AcDb::kForWrite);
|
|
if (!pData) return false;
|
|
|
|
CEntityProperty::SlabType tp = CEntityProperty::getSlabType((AcDbEntity *)this);
|
|
|
|
double dVal(.0);
|
|
properties.findAndSet<double>(_T("恒载"), pData, KEY_HZ);
|
|
properties.findAndSet<double>(_T("活载"), pData, KEY_HZ2);
|
|
properties.findAndSet<CString>(_T("载荷方式"), pData, KEY_ZHFS);
|
|
properties.findAndSet<CString>(_T("材质"), pData, KEY_MATERIAL);
|
|
properties.findAndSet<CString>(_T("用途"), pData, KEY_PURPOSE);
|
|
|
|
properties.findAndSet<double>(_T("堰墙高度"), pData, KEY_HEIGHT);
|
|
properties.findAndSet<double>(_T("堰墙壁厚"), pData, KEY_HEIGHT);
|
|
|
|
|
|
switch (tp)
|
|
{
|
|
case CEntityProperty::eDB:
|
|
{
|
|
double dT, dBomEl;
|
|
AcGePoint3d ptCenPos;
|
|
GetAt(KEY_ORGPT, ptCenPos);
|
|
GetAt(KEY_BOMTHICK, dT);
|
|
dBomEl = ptCenPos.z + dT;
|
|
|
|
// 当<板顶标高>和<板厚>有一个修改时
|
|
bool bEl = properties.findAndSet(_T("板顶标高"), dBomEl);
|
|
bool bT = properties.findAndSet(_T("板厚"), dT);
|
|
if (!bEl && !bT)
|
|
break;
|
|
|
|
// 板厚
|
|
pData->SetAt(KEY_BOMTHICK, dT);
|
|
dBomEl -= dT;
|
|
|
|
AcDbLine *pLn = AcDbLine::cast(GetBaseCurve());
|
|
if (!pLn) break;
|
|
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
AcGeVector3d vtDir = ptEnd - ptSta;
|
|
if (vtDir.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = ptSta.z + dT;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
SetBaseCurve(pLn);
|
|
delete pLn;
|
|
}
|
|
else//截面拉伸底板
|
|
{
|
|
AcGeLine3d lnSeg(ptSta, ptEnd);
|
|
if (AcGePlane::kXYPlane.isParallelTo(lnSeg))
|
|
{
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = dBomEl;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
SetBaseCurve(pLn);
|
|
delete pLn;
|
|
}
|
|
}
|
|
|
|
// 板顶标高
|
|
ptCenPos.z = dBomEl;
|
|
SetAt(KEY_ORGPT,ptCenPos,TRUE);
|
|
}
|
|
break;
|
|
case CEntityProperty::eGB:
|
|
{
|
|
double dT, dBomEl;
|
|
AcGePoint3d ptCenPos;
|
|
GetAt(KEY_ORGPT, ptCenPos);
|
|
GetAt(KEY_BOMTHICK, dT);
|
|
dBomEl = ptCenPos.z;
|
|
|
|
// 当<盖板底标高>和<板厚>有一个修改时
|
|
bool bEl = properties.findAndSet(_T("盖板底标高"), dBomEl);
|
|
bool bT = properties.findAndSet(_T("板厚"), dT);
|
|
if (!bEl && !bT)
|
|
break;
|
|
|
|
// 板厚
|
|
pData->SetAt(KEY_BOMTHICK, dT);
|
|
|
|
CString sPl;
|
|
GetAt(KEY_POINTS, sPl);
|
|
|
|
AcDbPolyline *pPl = CoreTools::StringToPolyline(sPl);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setElevation(dBomEl);
|
|
CoreTools::PolylineToString(pPl, sPl);
|
|
delete pPl;
|
|
}
|
|
|
|
AcDbLine *pLn = AcDbLine::cast(GetBaseCurve());
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = ptSta.z + dT;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
SetBaseCurve(pLn);
|
|
delete pLn;
|
|
}
|
|
|
|
// 底标高
|
|
AcGePoint3d pt = ptCenPos;
|
|
pt.z = dBomEl;
|
|
SetAt(KEY_ORGPT, pt, TRUE);
|
|
|
|
SetAt(KEY_POINTS, sPl);
|
|
|
|
}
|
|
break;
|
|
case CEntityProperty::eLB:
|
|
{
|
|
double dT, dBomEl;
|
|
AcGePoint3d ptCenPos;
|
|
GetAt(KEY_ORGPT, ptCenPos);
|
|
GetAt(KEY_BOMTHICK, dT);
|
|
dBomEl = ptCenPos.z + dT;
|
|
|
|
// 当<板顶标高>和<板厚>有一个修改时
|
|
bool bEl = properties.findAndSet(_T("板顶标高"), dBomEl);
|
|
bool bT = properties.findAndSet(_T("板厚"), dT);
|
|
if (!bEl && !bT)
|
|
break;
|
|
|
|
// 板厚
|
|
pData->SetAt(KEY_BOMTHICK, dT);
|
|
dBomEl -= dT;
|
|
|
|
CString sPl;
|
|
GetAt(KEY_POINTS, sPl);
|
|
|
|
AcDbPolyline *pPl = CoreTools::StringToPolyline(sPl);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setElevation(dBomEl);
|
|
CoreTools::PolylineToString(pPl, sPl);
|
|
delete pPl;
|
|
}
|
|
|
|
AcDbLine *pLn = AcDbLine::cast(GetBaseCurve());
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
ptSta.z = dBomEl;
|
|
ptEnd.z = ptSta.z + dT;
|
|
|
|
pLn->setStartPoint(ptSta);
|
|
pLn->setEndPoint(ptEnd);
|
|
|
|
SetBaseCurve(pLn);
|
|
delete pLn;
|
|
}
|
|
|
|
AcGePoint3d pt = ptCenPos;
|
|
pt.z = dBomEl;
|
|
SetAt(KEY_ORGPT, pt, TRUE);
|
|
SetAt(KEY_POINTS, sPl);
|
|
}
|
|
break;
|
|
case CEntityProperty::eXDB:
|
|
{
|
|
double dT, dBomEl;
|
|
if (properties.findAndSet(_T("板厚"), dT))
|
|
{
|
|
CString sProfile;
|
|
GetAt(_T("_XDB_FLAG_PROFILE_"), sProfile);
|
|
AcDbPolyline *pXYPoly = CoreTools::StringToPolyline(sProfile);
|
|
if (pXYPoly)
|
|
{
|
|
AcGePoint3d ptCen;
|
|
pXYPoly->getPointAt(0, ptCen);
|
|
AcDbLine tmpLine(ptCen, ptCen - AcGeVector3d::kZAxis * dT);
|
|
SetBaseCurve(&tmpLine);
|
|
SetSection(pXYPoly, ptCen);
|
|
}
|
|
SetAt(KEY_BOMTHICK, dT);
|
|
}
|
|
properties.findAndSet<double>(_T("倾斜基准点标高"), pData, _T("_XDB_FLAG_ELEV_"));
|
|
properties.findAndSet<double>(_T("每米下降坡度"), pData, _T("_XDB_FLAG_DIST_"));
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
}
|