1994 lines
41 KiB
C++
1994 lines
41 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbXXXDoghouse.h"
|
|
#include "AecDbX3dPart.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "AecGripCback.h"
|
|
#include "KTCadUtility.h"
|
|
#include "AecCoverBooleanOper.h"
|
|
#include "AcGiViewDraw.h"
|
|
|
|
extern double PixelToWcs(int nPixel);
|
|
extern BOOL Is2DView();
|
|
extern AcGeVector3d GetUcsZvt();
|
|
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt,AcDbDatabase* pDb = NULL,bool bClose = true);
|
|
void DLLIMPEXP OrthoProjected3DSolid(AcDb3dSolid* pSolidClone,const AcGePlane& plan,AcGeMatrix3d& xformPlanToWorld,AcDbVoidPtrArray& arEntPtrs);
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2);
|
|
|
|
Adesk::UInt32 AecDbXXXDoghouse::kCurrentVersionNumber = 1;
|
|
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;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbXXXDoghouse, AecDbPortRoom,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_XXXDOGHS,
|
|
"AecDbConnectDoghouse"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
|
|
|
|
AecDbXXXDoghouse::AecDbXXXDoghouse(void)
|
|
{
|
|
m_pSolidDraw = NULL;
|
|
m_nActivePart = -1;
|
|
|
|
m_vtMove.set(0,0,0); //整体移动
|
|
m_xformR.setToIdentity(); //整体旋转变换,非XYZ轴旋转
|
|
m_pGripAppData = new AecGripData[2048];//
|
|
}
|
|
|
|
AecDbXXXDoghouse::~AecDbXXXDoghouse(void)
|
|
{
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
if (NULL != pGroup)
|
|
DELETE_PTR(pGroup);
|
|
}
|
|
}
|
|
|
|
AecDbObjXDataMap* AecDbXXXDoghouse::GetSpecialtyData(AcDb::OpenMode bMode)
|
|
{
|
|
switch (bMode)
|
|
{
|
|
case AcDb::kForRead:
|
|
{
|
|
assertReadEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForWrite:
|
|
{
|
|
if (!isWriteEnabled())
|
|
{
|
|
upgradeOpen();
|
|
}
|
|
assertWriteEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForNotify:
|
|
{
|
|
assertReadEnabled();
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return &m_mapXData;
|
|
}
|
|
|
|
const AecDbObjXDataMap* AecDbXXXDoghouse::GetSpecialtyData() const
|
|
{
|
|
assertReadEnabled();
|
|
return &m_mapXData;
|
|
}
|
|
|
|
void AecDbXXXDoghouse::AddX3dPart(AecDbX3dPart* pPart,int nBoolOper /* = 0*/)
|
|
{
|
|
//0 kBoolUnite 2 kBoolSubtract 3 free
|
|
assertWriteEnabled();
|
|
|
|
pPart->SetBoolOperFor(nBoolOper);
|
|
m_arX3DPartPtrs.append(pPart);
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
int AecDbXXXDoghouse::GetX3dPartCount() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_arX3DPartPtrs.length();
|
|
}
|
|
|
|
AecDbX3dPart* AecDbXXXDoghouse::GetX3dPart(LPCTSTR pszID) const
|
|
{
|
|
assertReadEnabled();
|
|
AecDbX3dPart* pGroup = NULL;
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
return pGroup;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
BOOL AecDbXXXDoghouse::GetX3dPartNext(int& nPos,AecDbX3dPart*& pGroupNext) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
if (nPos > -1 && nPos < m_arX3DPartPtrs.length() )
|
|
{
|
|
pGroupNext = (AecDbX3dPart* )m_arX3DPartPtrs.at(nPos);
|
|
nPos += 1;
|
|
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::RemoveX3dPart(int nIndex)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
if (nIndex >= 0 && nIndex < m_arX3DPartPtrs.length())
|
|
{
|
|
m_arX3DPartPtrs.removeAt( nIndex );
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void AecDbXXXDoghouse::RemoveAllX3dPart(bool bDelete)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
while( m_arX3DPartPtrs.length() > 0)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.last();
|
|
|
|
if (NULL != pGroup && bDelete)
|
|
DELETE_PTR(pGroup);
|
|
|
|
m_arX3DPartPtrs.removeLast();
|
|
}
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::RemoveX3dPart(LPCTSTR pszID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
m_arX3DPartPtrs.removeAt( i );
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::UpdateDrawGroupAxis(LPCTSTR pszGUID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
pGroup->SetActive(false);
|
|
}
|
|
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
if (pszGUID != NULL && _tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
m_nActivePart = i;
|
|
pGroup->SetActive(true);
|
|
return true;
|
|
}
|
|
}
|
|
m_nActivePart = -1;
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::HidePart(LPCTSTR pszGUID,bool bHide)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bSuccess = false;
|
|
AecDbX3dPart* pGroup = NULL;
|
|
|
|
if (pszGUID == NULL)
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
//if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->SetHide(bHide);
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
bSuccess = true;
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->SetHide(bHide);
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
bSuccess = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return bSuccess;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::HideOrShowPart(LPCTSTR pszGUID )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bSuccess = false;
|
|
AecDbX3dPart* pGroup = NULL;
|
|
|
|
if (pszGUID == NULL)
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
//if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->SetHideShow();
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
bSuccess = true;
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->SetHideShow();
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
bSuccess = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return bSuccess;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::PeelOffTheSkin(LPCTSTR pszGUID,int nPos)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bSuccess = false;
|
|
AecDbX3dPart* pGroup = NULL;
|
|
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->PeelOffTheSkin(nPos);
|
|
bSuccess = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
|
|
return true;
|
|
}
|
|
|
|
void AecDbXXXDoghouse::AddMove(const AcGeVector3d& vtMove,LPCTSTR pszID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
if (pszID == NULL)//整体移动
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
pGroup->AddMove(vtMove);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
pGroup->AddMove(vtMove);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
}
|
|
|
|
void AecDbXXXDoghouse::AddMove(const AcGeMatrix3d& xMirror,LPCTSTR pszID)
|
|
{
|
|
AecDbX3dPart* pGroup = NULL;
|
|
if (pszID == NULL)//整体移动
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
pGroup->AddMove(xMirror);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
pGroup->AddMove(xMirror);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
}
|
|
|
|
void AecDbXXXDoghouse::ResetMove(LPCTSTR pszID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
pGroup->ResetMove();
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
}
|
|
|
|
void AecDbXXXDoghouse::AddRotate(int nAxisIndex,double dRot,LPCTSTR pszID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
if (pszID == NULL)
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
pGroup->AddRotate(nAxisIndex,dRot);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
pGroup->AddRotate(nAxisIndex,dRot);
|
|
break;;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
}
|
|
|
|
void AecDbXXXDoghouse::ResetRotate(int nAxisIndex,LPCTSTR pszID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbX3dPart* pGroup = NULL;
|
|
for(int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
pGroup->ResetRotate(nAxisIndex);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
}
|
|
|
|
int AecDbXXXDoghouse::GetSectionDraw(const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,const AcGeVector3d& vtViewDir,const AcGeVector3d& vtTo,AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nCount = 0;
|
|
AcGePlane plan;
|
|
AcGeVector3d vtU = ptTo - ptFr;
|
|
|
|
Acad::ErrorStatus es;
|
|
plan.set(ptFr,vtU,vtViewDir);
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
if (m_pSolidDraw == NULL)
|
|
{
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
Draw3d(dc);
|
|
}
|
|
|
|
AcDbExtents ext;
|
|
m_pSolidDraw->getGeomExtents(ext);
|
|
|
|
double dX = ext.maxPoint().x - ext.minPoint().x;
|
|
double dY = ext.maxPoint().y - ext.minPoint().y;
|
|
double dz = ext.maxPoint().z - ext.minPoint().z;
|
|
double dMaxL = __max(dX,dY);
|
|
dMaxL = __max(dMaxL,dz);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
ptGe[0] = ptFr;
|
|
ptGe[1] = ptTo;
|
|
ptGe[2] = ptTo + vtTo;
|
|
ptGe[3] = ptFr + vtTo;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcGeVector3d vtLook = vtViewDir;
|
|
|
|
//提取8个点
|
|
AcGePoint3d ptGeT[8];
|
|
AcGePoint3dArray arBoxPts;
|
|
|
|
ptGeT[0] = ext.minPoint();
|
|
|
|
ptGeT[1] = ptGeT[0];
|
|
ptGeT[1].x = ext.maxPoint().x;
|
|
|
|
ptGeT[2] = ptGeT[1];
|
|
ptGeT[2].y = ext.maxPoint().y;
|
|
|
|
ptGeT[3] = ptGeT[0];
|
|
ptGeT[3].y = ext.maxPoint().y;
|
|
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
arBoxPts.append(ptGeT[i]);
|
|
ptGeT[i].z = ext.maxPoint().z;
|
|
arBoxPts.append(ptGeT[i]);
|
|
}
|
|
|
|
AcDbLine ln3d;
|
|
ln3d.setStartPoint(arBoxPts.first());
|
|
AcGePoint3d ptE = arBoxPts.first() + vtViewDir * 1.5;
|
|
ln3d.setEndPoint(ptE);
|
|
|
|
AecCoverBooleanOper::SortPoints(arBoxPts,&ln3d,true);
|
|
|
|
AcGePoint3d ptNear = arBoxPts.last();
|
|
AcGePoint3d ptFar = arBoxPts.first();
|
|
AcGePoint3d ptMid = MidPoint(ptNear,ptFar);
|
|
|
|
AcGeVector3d vtN2F = ptFar - ptNear;
|
|
vtN2F *= 0.6;
|
|
ptFar = ptMid + vtN2F;
|
|
ptNear = ptMid - vtN2F;
|
|
vtN2F *= 2.0;
|
|
|
|
AcGePlane planNear(ptNear,vtLook);
|
|
AcGePoint3d ptOnMin;
|
|
ptOnMin = planNear.closestPointTo(ptGe[0]);
|
|
|
|
//调整到Near面
|
|
AcGeVector3d vtM = ptOnMin - ptGe[0];
|
|
for (int k = 0;k < 5;k++)
|
|
{
|
|
ptGe[k] += vtM;
|
|
}
|
|
|
|
//Near-->Far 拉伸路径
|
|
AcDbLine lnPath;
|
|
lnPath.setStartPoint(ptGe[0]);
|
|
ptE = ptGe[0] + vtN2F;
|
|
lnPath.setEndPoint(ptE);
|
|
|
|
AcDbRegion* pRegionT = AecDbEarthWorm::CreatePolygonRegionOnly(ptGe,5);
|
|
if (pRegionT != NULL)
|
|
{
|
|
AcDb3dSolid* pSolidBox = new AcDb3dSolid;
|
|
if ( Acad::eOk == pSolidBox->extrudeAlongPath(pRegionT,&lnPath) )
|
|
{
|
|
pSolidBox->setColorIndex(kRed);
|
|
}
|
|
|
|
AcDb3dSolid* pSolidCln = (AcDb3dSolid*)m_pSolidDraw->clone();
|
|
pSolidCln->booleanOper(AcDb::kBoolIntersect,pSolidBox);
|
|
pSolidCln->setRecordHistory(true);
|
|
OrthoProjected3DSolid(pSolidCln,plan,xform,arRegionPtrs);
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("useri3"),&rb);
|
|
if (rb.resval.rint == 1358)//特定情况下
|
|
{
|
|
//TEST
|
|
pSolidCln->setColorIndex(kRed);
|
|
AddToModelSpace(pSolidCln);
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pSolidCln);
|
|
}
|
|
|
|
DELETE_PTR(pRegionT);
|
|
DELETE_PTR(pSolidBox);
|
|
}
|
|
return arRegionPtrs.length();
|
|
|
|
//old version
|
|
AcDb3dSolid* pSolid = NULL;
|
|
AcDbRegion* pRegion = NULL;
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
pSolid = m_pSolidDraw;
|
|
if (pSolid != NULL)
|
|
{
|
|
es = pSolid->getSection(plan,pRegion);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
pRegion->transformBy(xform);
|
|
arRegionPtrs.append(pRegion);
|
|
nCount += 1;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
AcDb3dSolid* pSolidClone = (AcDb3dSolid*)pSolid->clone();
|
|
if (pSolidClone != NULL)
|
|
{
|
|
AcGePlane plan2;
|
|
plan2.set( ptFr,vtTo);
|
|
|
|
AcDb3dSolid* pNegHalfSolid = NULL;
|
|
es = pSolidClone->getSlice(plan2,false,pNegHalfSolid);//获取法向的结果
|
|
if (es == Acad::eOk)
|
|
{
|
|
AcGeMatrix3d xMove;
|
|
xMove.setToTranslation(vtTo);
|
|
|
|
plan2.transformBy(xMove);
|
|
|
|
es = pSolidClone->getSlice(plan2,true,pNegHalfSolid);
|
|
if (es == Acad::eOk)
|
|
{
|
|
if (pNegHalfSolid != NULL)
|
|
OrthoProjected3DSolid(pNegHalfSolid,plan,xform,arRegionPtrs);
|
|
}
|
|
}
|
|
|
|
if (pNegHalfSolid != NULL)
|
|
{
|
|
//pNegHalfSolid->setColorIndex(1);
|
|
//AddToModelSpace(pNegHalfSolid);
|
|
DELETE_PTR(pNegHalfSolid);
|
|
}
|
|
DELETE_PTR(pSolidClone);
|
|
}
|
|
return nCount;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::SaveAs(CFile* pFile) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CMFCDbDwgFiler mfcFiler(pFile);
|
|
AcDbDwgFiler* pFiler = &mfcFiler;
|
|
|
|
Acad::ErrorStatus es = dwgOutFields(pFiler);
|
|
return es == Acad::eOk ? true : false;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::ReadFrom(LPCTSTR pszFile)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
m_nActivePart = -1;
|
|
|
|
CFile file;
|
|
if (file.Open(pszFile,CFile::modeRead ))
|
|
{
|
|
CMFCDbDwgFiler mfcFiler(&file);
|
|
|
|
Acad::ErrorStatus es = dwgInFields(&mfcFiler);
|
|
file.Close();
|
|
|
|
return es == Acad::eOk ? true : false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::ReadFrom(CFile* pFile)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
m_nActivePart = -1;
|
|
|
|
CMFCDbDwgFiler mfcFiler(pFile);
|
|
|
|
Acad::ErrorStatus es = dwgInFields(&mfcFiler);
|
|
|
|
return es == Acad::eOk ? true : false;
|
|
|
|
return false;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::MergeReadFrom(LPCTSTR pszFile) throw()
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
m_nActivePart = -1;
|
|
|
|
CFile file;
|
|
if (file.Open(pszFile,CFile::modeRead ))
|
|
{
|
|
CMFCDbDwgFiler mfcFiler(&file);
|
|
|
|
Acad::ErrorStatus es = mergedwgInFields(&mfcFiler);
|
|
file.Close();
|
|
|
|
return es == Acad::eOk ? true : false;
|
|
}
|
|
return false;
|
|
|
|
assertWriteEnabled();
|
|
}
|
|
|
|
AcDb3dSolid* AecDbXXXDoghouse::CreateDraw3dSolid() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDb3dSolid* pSolid = NULL,*pSolidAll = NULL;
|
|
// FreeBuffer(0,m_ar2DDrableBufPtrs);
|
|
// m_ar2DDrableBufPtrs.removeAll();
|
|
Clean2DBuffer();
|
|
|
|
AcDbVoidPtrArray arSolidPtrForVerDraw;
|
|
|
|
CString sName;
|
|
AcArray<const AecDbX3dPart*> arKCGroups;//开窗
|
|
AcArray<const AecDbX3dPart*> arSliceGrps;//剖切
|
|
|
|
Acad::ErrorStatus es;
|
|
AecDbX3dPart* pPart = NULL;
|
|
for (int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pPart = m_arX3DPartPtrs.at(i);
|
|
if (pPart->IsHide())
|
|
continue;
|
|
|
|
pPart->GetName(sName);
|
|
if (sName.CompareNoCase(_T("开窗")) == 0)
|
|
{
|
|
arKCGroups.append(pPart);
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("剖切")) == 0)
|
|
{
|
|
arSliceGrps.append(pPart);
|
|
continue;
|
|
}
|
|
|
|
pSolid = pPart->CreateDraw3dSolid();
|
|
if (pSolid == NULL)
|
|
{
|
|
pPart->Create();
|
|
pSolid = pPart->CreateDraw3dSolid();
|
|
}
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
//MakeVerSection2d(pSolid,1);
|
|
arSolidPtrForVerDraw.append(pSolid->clone());
|
|
}
|
|
|
|
if (pSolidAll == NULL)
|
|
{
|
|
pSolidAll = pSolid;
|
|
}
|
|
else if (pSolid != NULL)
|
|
{
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapXData;
|
|
pXDataMap->SetAt(sName,i+1,*pPart->GetSpecialtyData());
|
|
|
|
if ( Acad::eOk == (es = pSolidAll->booleanOper(AcDb::kBoolUnite,pSolid) ) )
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
|
|
//然后减
|
|
AcDbVoidPtrArray arSolidPtrs;
|
|
if (pSolidAll != NULL)
|
|
{
|
|
for (int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pPart = m_arX3DPartPtrs.at(i);
|
|
|
|
arSolidPtrs.removeAll();
|
|
pPart->GetForHouseSubtract(arSolidPtrs);
|
|
|
|
for (int j = 0;j < arSolidPtrs.length();j++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)arSolidPtrs.at(j);
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
//MakeVerSection2d(pSolid,1);
|
|
arSolidPtrForVerDraw.append(pSolid->clone());
|
|
}
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
if ( Acad::eOk == (es = pSolidAll->booleanOper(AcDb::kBoolSubtract,pSolid) ) )
|
|
{
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//Free
|
|
if (pSolidAll != NULL)
|
|
{
|
|
for (int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pPart = m_arX3DPartPtrs.at(i);
|
|
if (pPart->GetBoolOperFor() > 2) //free
|
|
{
|
|
pSolid = pPart->CreateDraw3dSolid();
|
|
if (pSolid == NULL)
|
|
{
|
|
pPart->Create();
|
|
pSolid = pPart->CreateDraw3dSolid();
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
//MakeVerSection2d(pSolid,1);
|
|
arSolidPtrForVerDraw.append(pSolid->clone());
|
|
|
|
if ( Acad::eOk == (es = pSolidAll->booleanOper(AcDb::kBoolUnite,pSolid) ) )
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pSolidAll != NULL)
|
|
{
|
|
//开窗
|
|
for (int i = 0;i < arKCGroups.length();i++)
|
|
{
|
|
pPart = (AecDbX3dPart*)arKCGroups.at(i);
|
|
|
|
pSolid = pPart->CreateDraw3dSolid();
|
|
if (pSolid == NULL)
|
|
{
|
|
pPart->Create();
|
|
pSolid = pPart->CreateDraw3dSolid();
|
|
}
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
if (Acad::eOk != (es = pSolidAll->booleanOper(AcDb::kBoolSubtract,pSolid )))
|
|
{
|
|
acutPrintf(_T("\nCreate from rec error:%d:%d"),i,es);
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
|
|
//剖切
|
|
int nPartRetain = 0;
|
|
for (int i = 0;i < arSliceGrps.length();i++)
|
|
{
|
|
pPart = (AecDbX3dPart*)arSliceGrps.at(i);
|
|
|
|
AcGePlane plan;
|
|
pPart->GetSlicePlan(plan);
|
|
|
|
pPart->GetSpecialtyData()->GetAt(_T("m_nPartRetain"),nPartRetain);
|
|
|
|
AcDb3dSolid* pSolidNew = NULL;
|
|
if ( Acad::eOk == (es = pSolidAll->getSlice(plan,nPartRetain > 0 ? Adesk::kTrue : Adesk::kFalse,pSolidNew) ) )
|
|
{
|
|
if (nPartRetain > 0 && pSolidNew != NULL)
|
|
{
|
|
DELETE_PTR(pSolidAll);
|
|
pSolidAll = pSolidNew;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
if (pSolidAll != NULL)
|
|
{
|
|
MakeVerSection2d(pSolidAll,1);
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(m_vtMove);
|
|
|
|
pSolidAll->transformBy(xformM);
|
|
pSolidAll->transformBy(m_xformR);
|
|
|
|
//俯视图
|
|
for (int j = 0;j < arSolidPtrForVerDraw.length();j++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)arSolidPtrForVerDraw.at(j);
|
|
if (pSolid != NULL)
|
|
{
|
|
//新的纵断如下必须注释掉
|
|
MakeVerSection2d(pSolid,1);
|
|
pSolid->transformBy(xformM);
|
|
pSolid->transformBy(m_xformR);
|
|
MakeHorSection2d(pSolid);
|
|
}
|
|
}
|
|
MakeHorSection2d(pSolidAll);
|
|
}
|
|
return pSolidAll;
|
|
}
|
|
|
|
Adesk::Boolean AecDbXXXDoghouse::GetDraw2d(AcDbVoidPtrArray& arEntPtrs,int nSectionDrawStyle) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (!Has2DBuffer())
|
|
{
|
|
AcGiViewDraw dcTmp(NULL,NULL);
|
|
Draw3d(dcTmp);
|
|
}
|
|
|
|
int nCor = 0;
|
|
AcDbEntity* pEnt = NULL,*pEntClone = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
nCor = pEnt->colorIndex();
|
|
if (nSectionDrawStyle == nCor)
|
|
{
|
|
pEntClone = (AcDbEntity*)pEnt->clone();
|
|
pEntClone->setColorIndex(nSectionDrawStyle);
|
|
arEntPtrs.append(pEntClone);
|
|
}
|
|
}
|
|
}
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
Adesk::Boolean AecDbXXXDoghouse::GetDraw3d(AcDbVoidPtrArray& arEntPtrs,bool bWriteBimInfo) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (bWriteBimInfo)
|
|
{
|
|
CString sName;
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
|
|
AcDb3dSolid* pSolid = NULL;
|
|
AcDb3dSolid* pSolidAll = NULL;
|
|
|
|
AecDbX3dPart* pPart = NULL;
|
|
for (int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pPart = m_arX3DPartPtrs.at(i);
|
|
if (pPart->IsHide())
|
|
continue;
|
|
|
|
pPart->GetName(sName);
|
|
if (sName.CompareNoCase(_T("开窗")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("剖切")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
pSolid = pPart->CreateDraw3dSolid();
|
|
if (pSolid == NULL)
|
|
{
|
|
pPart->Create();
|
|
pSolid = pPart->CreateDraw3dSolid();
|
|
}
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
//房子
|
|
if (sName.Find(_T("房子")) != -1)//房子
|
|
{
|
|
if (pSolidAll == NULL)
|
|
{
|
|
pSolidAll = pSolid;
|
|
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapXData;
|
|
pXDataMap->SetAt(sName,i+1,*pPart->GetSpecialtyData());
|
|
}
|
|
else
|
|
{
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapXData;
|
|
pXDataMap->SetAt(sName,i+1,*pPart->GetSpecialtyData());
|
|
|
|
if ( Acad::eOk == (es = pSolidAll->booleanOper(AcDb::kBoolUnite,pSolid) ) )
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pPart->GetSpecialtyData()->Write(pSolid,_T("BIMDATA"));
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(m_vtMove);
|
|
|
|
pSolid->transformBy(xformM);
|
|
pSolid->transformBy(m_xformR);
|
|
|
|
arEntPtrs.append(pSolid);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pSolidAll != NULL)
|
|
{
|
|
//然后减
|
|
AcDbVoidPtrArray arSolidPtrs;
|
|
for (int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pPart = m_arX3DPartPtrs.at(i);
|
|
|
|
arSolidPtrs.removeAll();
|
|
pPart->GetForHouseSubtract(arSolidPtrs);
|
|
|
|
for (int j = 0;j < arSolidPtrs.length();j++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)arSolidPtrs.at(j);
|
|
if (pSolid != NULL)
|
|
{
|
|
if ( Acad::eOk == (es = pSolidAll->booleanOper(AcDb::kBoolSubtract,pSolid) ) )
|
|
{
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pSolidAll != NULL)
|
|
{
|
|
m_mapXData.Write(pSolidAll,_T("BIMDATA"));
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(m_vtMove);
|
|
|
|
pSolidAll->transformBy(xformM);
|
|
pSolidAll->transformBy(m_xformR);
|
|
|
|
arEntPtrs.append(pSolidAll);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!Has3DBuffer())
|
|
{
|
|
AcGiViewDraw dcTmp(NULL,NULL);
|
|
Draw3d(dcTmp);
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
AcDbEntity* pEntClone = (AcDbEntity*)m_pSolidDraw->clone();
|
|
if (pEntClone != NULL)
|
|
{
|
|
m_mapXData.Write(pEntClone,_T("BIMDATA"));
|
|
}
|
|
arEntPtrs.append(pEntClone);
|
|
}
|
|
}
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
if ( !GetEWormId().isValid() )//如果是造族
|
|
{
|
|
Draw3d(dc);
|
|
}
|
|
else
|
|
{
|
|
AcDbVoidPtrArray ar2DEntPtrs;
|
|
GetDraw2d(ar2DEntPtrs,0);
|
|
|
|
if (ar2DEntPtrs.isEmpty())
|
|
{
|
|
AcGiViewDraw dcTmp(NULL,NULL);
|
|
Draw3d(dcTmp);
|
|
GetDraw2d(ar2DEntPtrs,0);
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < ar2DEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2DEntPtrs.at(i);
|
|
pEnt->setColorIndex(kMagenta);
|
|
dc.DrawEntity(pEnt);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::UpdateDraw( ) const
|
|
{
|
|
assertReadEnabled();
|
|
AecDbPortRoom::UpdateDraw();
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::UpdateDraw( )
|
|
{
|
|
assertReadEnabled();
|
|
AecDbPortRoom::UpdateDraw();
|
|
|
|
ReCreateDraw3d();
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::ReCreateDraw3d()
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pSolidDraw == NULL)
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
|
|
if (m_pSolidDraw == NULL)
|
|
return Acad::eOk;
|
|
|
|
//管线系统屏蔽掉
|
|
if (dc.IsDragging())
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
//dc.SetSelectionMarker(1);
|
|
|
|
dc.DrawEntity(*m_pSolidDraw);
|
|
dc.SetLayer(idLay);
|
|
|
|
DrawActiveXYZArrow(dc);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbXXXDoghouse::GetKernelSolids(AcDbVoidPtrArray& arSolidPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pSolidDraw == NULL)
|
|
{
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
Draw3d(dc);
|
|
}
|
|
|
|
arSolidPtrs.append(m_pSolidDraw);
|
|
return arSolidPtrs.length();
|
|
}
|
|
|
|
void AecDbXXXDoghouse::SetToTranslation(const AcGeVector3d& vtMove)
|
|
{
|
|
assertWriteEnabled();
|
|
m_vtMove = vtMove;
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
void AecDbXXXDoghouse::setToRotation(const AcGeMatrix3d& xformR)
|
|
{
|
|
assertWriteEnabled();
|
|
m_xformR = xformR;
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
void AecDbXXXDoghouse::Transformby(const AcGePoint3d& ptPos,const AcGeVector3d& vtDir)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AcGeVector3d vtMove = ptPos.asVector();
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtMove);
|
|
m_vtMove = vtMove;
|
|
|
|
AcGeVector3d vtDirXY = vtDir.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtNorm = vtDirXY.crossProduct(vtDir);
|
|
double dRot = vtDirXY.angleTo(vtDir,vtNorm);
|
|
AcGeMatrix3d xformRz;
|
|
xformRz.setToRotation(dRot,vtNorm,ptPos);
|
|
|
|
dRot = AcGeVector3d::kXAxis.angleTo(vtDirXY,AcGeVector3d::kZAxis);
|
|
AcGeMatrix3d xformRx;
|
|
xformRx.setToRotation(dRot,AcGeVector3d::kZAxis,ptPos);
|
|
|
|
m_xformR = xformRz;
|
|
m_xformR *= xformRx;
|
|
|
|
//pSolid->transformBy(xformM);
|
|
//pSolid->transformBy(xformRx);
|
|
//pSolid->transformBy(xformRz);
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
void AecDbXXXDoghouse::Transformby(const AcGeVector3d &vtDir)
|
|
{
|
|
assertWriteEnabled();
|
|
m_vtMove += vtDir;
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
void AecDbXXXDoghouse::Transformby(const AcGeVector3d& vt,const AcGeVector3d &vtDir)
|
|
{
|
|
assertWriteEnabled();
|
|
//vt.z为标高
|
|
AcGeVector3d vtMove(m_vtMove.x + vt.x,m_vtMove.y+vt.y,m_vtMove.z + vt.z);
|
|
AcGePoint3d pt(vtMove.x,vtMove.y,vtMove.z);
|
|
|
|
m_vtMove.set(0,0,0);
|
|
m_xformR.setToIdentity();
|
|
|
|
Transformby(pt,vtDir);
|
|
}
|
|
|
|
void AecDbXXXDoghouse::TransformByEwDir(const AcGeVector3d &vtMove, const AcGeVector3d &vtDir)
|
|
{
|
|
assertWriteEnabled();
|
|
m_vtMove += vtMove;
|
|
|
|
AcGePoint3d ptPos(m_vtMove.x,m_vtMove.y,m_vtMove.z);
|
|
AcGeVector3d vtDirXY = vtDir.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtNorm = vtDirXY.crossProduct(vtDir);
|
|
double dRot = vtDirXY.angleTo(vtDir,vtNorm);
|
|
AcGeMatrix3d xformRz;
|
|
xformRz.setToRotation(dRot,vtNorm,ptPos);
|
|
|
|
dRot = AcGeVector3d::kXAxis.angleTo(vtDirXY,AcGeVector3d::kZAxis);
|
|
AcGeMatrix3d xformRx;
|
|
xformRx.setToRotation(dRot,AcGeVector3d::kZAxis,ptPos);
|
|
|
|
m_xformR = xformRz;
|
|
m_xformR *= xformRx;
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
extern void Get3dSolidOutSideFaces(AcDb3dSolid* pSolid,AcGePoint3dArray& arPts);
|
|
extern void Get3dSolidOutSideFacesEx(AcDb3dSolid* pSolid,AcGePoint3dArray& arPts);
|
|
|
|
#if (ARX > 16)
|
|
Acad::ErrorStatus AecDbXXXDoghouse::subGetOsnapPoints( AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (!objectId().isValid()) return Acad::eOk;
|
|
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
AcGePoint3dArray arPts1;
|
|
AcGePoint3dArray arPts2;
|
|
m_pSolidDraw->getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,arPts1,geomIds);
|
|
|
|
if (arPts1.isEmpty())
|
|
{
|
|
//通过边界分析
|
|
AcDbIntArray osnapModes;
|
|
AcDbIntArray geomIds;
|
|
m_pSolidDraw->getGripPoints(arPts1,osnapModes,geomIds);
|
|
}
|
|
|
|
if (!arPts2.isEmpty())
|
|
arPts1.append(arPts2);
|
|
|
|
snapPoints.append(arPts1);
|
|
|
|
/*AcGePoint3d ptNear;
|
|
double dSpace = -1.0,dDist = 0.0;
|
|
for (int i = 0;i < arPts1.length();i++)
|
|
{
|
|
dDist = pickPoint.distanceTo(arPts1.at(i));
|
|
if (dSpace < -1.e-10)
|
|
{
|
|
dSpace = dDist;
|
|
ptNear = arPts1.at(i);
|
|
}
|
|
else
|
|
{
|
|
if (dSpace > dDist)
|
|
{
|
|
dSpace = dDist;
|
|
ptNear = arPts1.at(i);
|
|
}
|
|
}
|
|
}
|
|
snapPoints.append(ptNear);*/
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::subGetGripPoints( AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (GetEWormId().isValid())//如果是插在主管廊上
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
CString sName,sTip;
|
|
AcGePoint3d ptOrg;
|
|
AcDbGripData* pGripData = NULL;
|
|
double dCmd = PixelToWcs(20);
|
|
|
|
const AecDbX3dPart* pGroup = NULL;
|
|
for (int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
if (pGroup->IsHide())
|
|
continue;
|
|
|
|
pGroup->GetName(sName);
|
|
if (sName.CompareNoCase(_T("开窗")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("剖切")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
ptOrg = pGroup->GetOrgPoint();
|
|
pGroup->Transformby(ptOrg);
|
|
|
|
//定位用
|
|
memset(&m_pGripAppData[2 * i],NULL,sizeof(AecGripData));
|
|
m_pGripAppData[2 * i].nIndex = 0;
|
|
m_pGripAppData[2 * i].ePos = eFlag;
|
|
m_pGripAppData[2 * i].ptGrip = ptOrg;
|
|
m_pGripAppData[2 * i].nColor = kWhite;
|
|
m_pGripAppData[2 * i].pOwner = (AcDbEntity*)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(ptOrg);
|
|
pGripData->setAppData((void*)&m_pGripAppData[2 * i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
|
|
sTip.Format(_T("点击定位造族组件<%s>记录"),sName);
|
|
_tcscpy(m_pGripAppData[2 * i].szTip,sTip);
|
|
_tcscpy(m_pGripAppData[2 * i].szID,pGroup->GetGUID());
|
|
grips.append(pGripData);
|
|
|
|
//修改用
|
|
ptOrg.x += dCmd;
|
|
memset(&m_pGripAppData[2 * i + 1],NULL,sizeof(AecGripData));
|
|
m_pGripAppData[2 * i + 1].nIndex = 0;
|
|
m_pGripAppData[2 * i + 1].ePos = eEdit;
|
|
m_pGripAppData[2 * i + 1].ptGrip = ptOrg;
|
|
m_pGripAppData[2 * i + 1].nColor = kWhite;
|
|
m_pGripAppData[0].pOwner = (AcDbEntity*)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(ptOrg);
|
|
pGripData->setAppData((void*)&m_pGripAppData[2 * i + 1]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
|
|
sTip.Format(_T("点击修改造族组件<%s>记录"),sName);
|
|
_tcscpy(m_pGripAppData[2 * i + 1].szTip,sTip);
|
|
_tcscpy(m_pGripAppData[2 * i + 1].szID,pGroup->GetGUID());
|
|
grips.append(pGripData);
|
|
}
|
|
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::subMoveGripPointsAt(const AcDbVoidPtrArray& appData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if ( !appData.isEmpty() )
|
|
{
|
|
pAppData = (AecGripData*)appData.first();
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGeVector3d vtOffset = offset;
|
|
if(Is2DView())
|
|
{
|
|
vtOffset = offset.orthoProject(GetUcsZvt());
|
|
}
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtOffset);
|
|
|
|
const AecDbX3dPart* pGroup = NULL;
|
|
for (int i = 0;i < m_arX3DPartPtrs.length();i++)
|
|
{
|
|
pGroup = m_arX3DPartPtrs.at(i);
|
|
|
|
if ( _tcscmp(pAppData->szID,pGroup->GetGUID()) == 0 )
|
|
{
|
|
if (pAppData->ePos == eFlag)//定位
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
|
|
CKTCadUtility::SetSystemVar(_T("users5"),pAppData->szID);
|
|
|
|
CString sID;
|
|
CKTCadUtility::GetSystemVar(_T("users5"),sID);
|
|
|
|
if (sID.CompareNoCase(pAppData->szID) == 0)
|
|
{
|
|
acedPostCommand(_T("EW_JDDW "));
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
else if (pAppData->ePos == eEdit)
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
|
|
CKTCadUtility::SetSystemVar(_T("users5"),pAppData->szID);
|
|
|
|
CString sID;
|
|
CKTCadUtility::GetSystemVar(_T("users5"),sID);
|
|
|
|
if (sID.CompareNoCase(pAppData->szID) == 0)
|
|
{
|
|
acedPostCommand(_T("EW_JDMO "));
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::subGetGeomExtents(AcDbExtents& extents) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pSolidDraw == NULL)
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
|
|
if (m_pSolidDraw == NULL)
|
|
return Acad::eOk;
|
|
|
|
return m_pSolidDraw->getGeomExtents(extents);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::subIntersectWith( const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pSolidDraw != NULL && pEnt != NULL)
|
|
{
|
|
return pEnt->intersectWith(m_pSolidDraw,intType,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::subIntersectWith( const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
const AcGePlane& projPlane,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
if (m_pSolidDraw != NULL && pEnt != NULL)
|
|
{
|
|
return pEnt->intersectWith(m_pSolidDraw,intType,projPlane,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#endif
|
|
|
|
void AecDbXXXDoghouse::DrawActiveXYZArrow(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_nActivePart >= 0 && m_nActivePart < m_arX3DPartPtrs.length() )
|
|
{
|
|
AecDbX3dPart* pGroup = m_arX3DPartPtrs.at(m_nActivePart);
|
|
pGroup->DrawAxis(dc);
|
|
}
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::IsXXXDoghouse() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::mergedwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbPortRoom::dwgInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
//CString sFileHeader = _T("shanghuasoft xxx 3d model file");
|
|
TCHAR* pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
CString sFileHeader;
|
|
if (pszTemp != NULL)
|
|
{
|
|
sFileHeader = pszTemp;
|
|
acutDelString(pszTemp);
|
|
|
|
if (sFileHeader.CompareNoCase(_T("shanghuasoft xxx 3d model file")) != 0)
|
|
{
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
}
|
|
|
|
//----- Object version number needs to be read first
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es = pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
if ( version > AecDbXXXDoghouse::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy) ;
|
|
|
|
pFiler->readInt32(&m_nActivePart);
|
|
m_nActivePart = -1;//不需要序列化
|
|
|
|
pFiler->readVector3d(&m_vtMove);
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
for (int j = 0;j < 4;j++)
|
|
{
|
|
pFiler->readDouble(&m_xformR.entry[i][j]);
|
|
}
|
|
}
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
AecDbX3dPart* pPart = NULL;
|
|
|
|
//merge
|
|
//m_arX3DPartPtrs.removeAll();
|
|
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pPart = new AecDbX3dPart;
|
|
pPart->dwgInFields(pFiler);
|
|
m_arX3DPartPtrs.append(pPart);
|
|
}
|
|
|
|
AecDbObjXDataMap xdata;
|
|
xdata.dwgInFields(pFiler);
|
|
m_mapXData.AppendFrom(&xdata);
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbPortRoom::dwgInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
//CString sFileHeader = _T("shanghuasoft xxx 3d model file");
|
|
TCHAR* pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
CString sFileHeader;
|
|
if (pszTemp != NULL)
|
|
{
|
|
sFileHeader = pszTemp;
|
|
acutDelString(pszTemp);
|
|
|
|
if (sFileHeader.CompareNoCase(_T("shanghuasoft xxx 3d model file")) != 0)
|
|
{
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
}
|
|
|
|
//----- Object version number needs to be read first
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es = pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
if ( version > AecDbXXXDoghouse::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy) ;
|
|
|
|
pFiler->readInt32(&m_nActivePart);
|
|
m_nActivePart = -1;//不需要序列化
|
|
|
|
pFiler->readVector3d(&m_vtMove);
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
for (int j = 0;j < 4;j++)
|
|
{
|
|
pFiler->readDouble(&m_xformR.entry[i][j]);
|
|
}
|
|
}
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
AecDbX3dPart* pPart = NULL;
|
|
m_arX3DPartPtrs.removeAll();
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pPart = new AecDbX3dPart;
|
|
pPart->dwgInFields(pFiler);
|
|
m_arX3DPartPtrs.append(pPart);
|
|
}
|
|
|
|
m_mapXData.dwgInFields(pFiler);
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled () ;
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbPortRoom::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
CString sFileHeader = _T("shanghuasoft xxx 3d model file");
|
|
pFiler->writeString((LPCTSTR)sFileHeader);
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbXXXDoghouse::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
pFiler->writeInt32(m_nActivePart);
|
|
pFiler->writeVector3d(m_vtMove);
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
for (int j = 0;j < 4;j++)
|
|
{
|
|
pFiler->writeDouble(m_xformR.entry[i][j]);
|
|
}
|
|
}
|
|
|
|
Adesk::Int32 nLen = m_arX3DPartPtrs.length();
|
|
pFiler->writeInt32(nLen);
|
|
|
|
AecDbX3dPart* pPart = NULL;
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pPart = m_arX3DPartPtrs.at(i);
|
|
pPart->dwgOutFields(pFiler);
|
|
}
|
|
|
|
m_mapXData.dwgOutFields(pFiler);
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = AecDbPortRoom::dxfInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
return (pFiler->filerStatus ()) ;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXXXDoghouse::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled () ;
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = AecDbPortRoom::dxfOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
return (pFiler->filerStatus ()) ;
|
|
}
|
|
|
|
void AecDbXXXDoghouse::MakeVerSection2d(AcDb3dSolid* pSolid,int nSectionDrawStyle) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//通风口符号
|
|
AcGePoint3d ptPos(0,0,0);
|
|
AcGeVector2d vtDir = AcGeVector2d::kXAxis;
|
|
AcGePoint2d ptSize;
|
|
double dVol = 0.0,momInertia[3],prodInertia[3],prinMoments[3],radiiGyration[3];
|
|
AcGePoint3d ptCen;
|
|
AcGeVector3d prinAxes[3];
|
|
AcDbExtents extents;
|
|
|
|
if ( nSectionDrawStyle == 1)//纵断 1
|
|
{
|
|
AcGeVector3d vtDir3d(vtDir.x,vtDir.y,0.0);
|
|
AcGeVector3d vtDir3dv = vtDir3d;
|
|
vtDir3dv.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGeMatrix3d xformV = AcGeMatrix3d::kIdentity;
|
|
//xformV.setToTranslation(AcGeVector3d::kZAxis * -ptTmp.z);
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->getMassProp(dVol,ptCen,momInertia,prodInertia,prinMoments,prinAxes,radiiGyration,extents);
|
|
|
|
AcGePlane plan;
|
|
plan.set(ptCen,vtDir3dv);
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
pSolid->getSection(plan,pRegion);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
//投影到中心面
|
|
AcGePlane planV;
|
|
planV.set(ptPos,vtDir3dv);
|
|
|
|
AcGePoint3d ptCen2 = ptCen.orthoProject(planV);
|
|
AcGeVector3d vtMove = ptCen2 - ptCen;
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtMove);
|
|
pRegion->transformBy(xformM);
|
|
|
|
//移动到最外边
|
|
pRegion->transformBy(xformV);
|
|
|
|
//翻转
|
|
AcGeMatrix3d xformR;
|
|
xformR.setToRotation(-PI / 2.0,vtDir3d,ptPos);
|
|
pRegion->transformBy(xformR);
|
|
|
|
//倾斜放置的房子
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
vtDirX.transformBy(m_xformR);
|
|
AcGeVector3d vtDirXY = vtDirX.orthoProject(AcGeVector3d::kZAxis);
|
|
double dRot = vtDirXY.angleTo(vtDirX);
|
|
if (vtDirX.z < -1.e-10)
|
|
dRot *= -1.0;
|
|
|
|
AcGeMatrix3d xformRz;
|
|
xformRz.setToRotation(dRot,AcGeVector3d::kZAxis,ptPos);
|
|
pRegion->transformBy(xformRz);
|
|
|
|
AcGePoint3d pt1 = ptPos;
|
|
pt1.transformBy(m_xformR);
|
|
|
|
double dDist = pt1.distanceTo(ptPos);
|
|
vtMove = pt1 - ptPos;
|
|
vtMove.normalize();
|
|
vtMove *= 2.5;
|
|
xformM.setToTranslation(vtMove);
|
|
//pRegion->transformBy(xformM);
|
|
|
|
AddToSection2dDraw(pRegion,1);
|
|
|
|
DELETE_PTR(pRegion);
|
|
//TEST
|
|
//pRegion->setColorIndex(kMagenta);
|
|
//AddToModelSpace(pRegion);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pSolid != NULL)
|
|
{
|
|
MakeHorSection2d(pSolid);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbXXXDoghouse::MakeVerSection2d(AcDb3dSolid* pSolid,const AcGePoint3d& ptCen,int nSectionDrawStyle) const
|
|
{
|
|
}
|
|
|
|
void AecDbXXXDoghouse::AddToSection2dDraw(AcDbEntity* pComEnt,int nSectionDrawtyle) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (pComEnt == NULL)
|
|
return;
|
|
|
|
AcDbRegion* pRegAll = AcDbRegion::cast(pComEnt);
|
|
if (pRegAll != NULL)
|
|
{
|
|
AcDbVoidPtrArray arSubEntPtrs;
|
|
pRegAll->explode(arSubEntPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arSubEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arSubEntPtrs.at(i);
|
|
pEnt->setColorIndex( nSectionDrawtyle);
|
|
Add2DBuffer(pEnt);
|
|
//m_ar2DDrableBufPtrs.append(pEnt);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pComEnt->setColorIndex( nSectionDrawtyle);
|
|
Add2DBuffer(pComEnt);
|
|
//m_ar2DDrableBufPtrs.append(pComEnt);
|
|
}
|
|
}
|
|
|
|
void AecDbXXXDoghouse::MakeHorSection2d(AcDb3dSolid* pSolid) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (pSolid == NULL)
|
|
return;
|
|
|
|
double dVol = 0.0,momInertia[3],prodInertia[3],prinMoments[3],radiiGyration[3];
|
|
AcGeVector3d prinAxes[3];
|
|
AcDbExtents extents;
|
|
AcGePoint3d ptCen1;
|
|
|
|
pSolid->getMassProp(dVol,ptCen1,momInertia,prodInertia,prinMoments,prinAxes,radiiGyration,extents);
|
|
|
|
AcGePlane plan;
|
|
plan.set(ptCen1,AcGeVector3d::kZAxis);
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
pSolid->getSection(plan,pRegion);
|
|
|
|
if (pRegion)
|
|
{
|
|
AddToSection2dDraw(pRegion, 0);
|
|
DELETE_PTR(pRegion);
|
|
}
|
|
|
|
//一下旧代码
|
|
return;
|
|
AcDbVoidPtrArray arRegPtrs;
|
|
pSolid->explode(arRegPtrs);
|
|
|
|
AcGeVector3d vtNorm;
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbRegion* pRegAll = NULL;
|
|
|
|
for(int i = 0;i < arRegPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arRegPtrs.at(i);
|
|
|
|
AcDbRegion* pReg = AcDbRegion::cast(pEnt);
|
|
if (pReg != NULL)
|
|
{
|
|
pReg->getNormal(vtNorm);
|
|
if (vtNorm.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
//投影到XY 面
|
|
AcGePlane plan;
|
|
pReg->getPlane(plan);
|
|
|
|
AcGePoint3d ptOnNN = plan.pointOnPlane();
|
|
AcGePoint3d ptOnXY = AcGePlane::kXYPlane.closestPointTo(ptOnNN);
|
|
|
|
AcGeVector3d vtMove = ptOnXY - ptOnNN;
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(vtMove);
|
|
pReg->transformBy(xform);
|
|
|
|
AddToSection2dDraw(pReg,0);
|
|
DELETE_PTR(pReg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//acutPrintf(_T("\nclass = %s"),pEnt->isA()->name());
|
|
//AcDbSurface
|
|
AddToSection2dDraw(pEnt,0);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool AecDbXXXDoghouse::HasGroupItem(LPCTSTR pszGUID)
|
|
{
|
|
for (int i = 0; i < m_arX3DPartPtrs.length(); ++i)
|
|
{
|
|
AecDbX3dPart *pGroup = m_arX3DPartPtrs.at(i);
|
|
if (!pGroup) continue;
|
|
if (CString(pGroup->GetGUID()).CompareNoCase(pszGUID) == 0)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|