#include "stdafx.h" #include "TDbImpFitting.h" #include "acgs.h" #include "gs.h" #include "TImpSpecFitting.h" #include "TDbFittingCreatorService.h" #include "TDbExtentsEdge.h" #include "math.h" #include "TCoverBooleanOper.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif TDbImpFitting::TDbImpFitting(TDbFittingBase* pEnt) : m_XDataMap(*pEnt->GetSpecialtyData()) // add by hh 2013-9-2 { m_pSpecFitting = NULL; m_pOwnerEnt = pEnt; m_nDwgVersion = 1; } TDbImpFitting::~TDbImpFitting() { m_XDataMap.Empty(); if (m_pSpecFitting != NULL) { m_pSpecFitting->Destroy(); } } // 设置版本 void TDbImpFitting::SetVersion(int nVersion) { m_nDwgVersion = nVersion; } BOOL TDbImpFitting::GetInterface(int nIndex,TInterface& pipeInterface) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->GetInterface(nIndex,pipeInterface); } return FALSE; } BOOL TDbImpFitting::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->GetInterface(ptCon,pipeInterface); } return FALSE; } BOOL TDbImpFitting::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->HasInterface(ptCon,vtDir); } return FALSE; } int TDbImpFitting::GetInterfaceCount() const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->GetInterfaceCount(); } return 0; } BOOL TDbImpFitting::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->SetInterfaceRelation(ptConnect,idConnect); } return 0; } BOOL TDbImpFitting::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect1,const AcDbObjectId& idConnect2) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->SetInterfaceRelation(ptConnect,idConnect1,idConnect2); } return 0; } BOOL TDbImpFitting::RemoveInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->RemoveInterfaceRelation(ptConnect,idConnect); } return 0; } BOOL TDbImpFitting::NotifyInterfaceToModify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->NotifyInterfaceToModify(iModiMsg,iModiMsgs); } return FALSE; } TDbXDataMap* TDbImpFitting::GetSpecialtyData() { return &m_XDataMap; } BOOL TDbImpFitting::AddCoverEdge(AcDbObjectId& id,TComplexCurve& curEdge) { TDbExtentsEdge edage; edage.SetOwnerId(id); edage.SetEdage(curEdge); m_arDbExtEdgs.Add(edage); return TRUE; } BOOL TDbImpFitting::RemoveCoverEdge(AcDbObjectId& id) { if (id.isNull()) { m_arDbExtEdgs.RemoveAll(); return TRUE; } // 加入的时候已经排序了; for (int i = 0;i < m_arDbExtEdgs.GetCount();i++) { if (m_arDbExtEdgs.GetAt(i).GetOwnerId() == id) { m_arDbExtEdgs.RemoveAt(i); break; } } return TRUE; } BOOL TDbImpFitting::GetCoverEdgeIds(AcDbObjectIdArray& arIds) { for (int i = 0;i < m_arDbExtEdgs.GetCount();i++) { arIds.append(m_arDbExtEdgs.GetAt(i).GetOwnerId()); } return arIds.length() > 0; } TDb::Position TDbImpFitting::ExplainGripIndex(int nIndex) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->ExplainGripIndex(nIndex); } return TDb::eStart; } BOOL TDbImpFitting::AddIdsCoverByMe(AcDbObjectId& id) { int nFound = -1; if (!m_arIdCoverByMe.find(id,nFound)) { m_arIdCoverByMe.append(id); return TRUE; } return FALSE; } BOOL TDbImpFitting::GetIdsCoverByMe(AcDbObjectIdArray& arByMeIds) { arByMeIds.append(m_arIdCoverByMe); return TRUE; } BOOL TDbImpFitting::GetGeomExtentsEdge(TComplexCurve& crLoop) { if (m_pSpecFitting != NULL) { AcDbPolyline* pPl = MakePolyCurve(); if (pPl != NULL) { double dBulge = 0.0; TDb::TCurveElement curel; memset(&curel,0,sizeof(TDb::TCurveElement)); int nVerts = pPl->numVerts(); for (int i = 0;i < nVerts - 1;i++) { pPl->getPointAt(i,curel.ptGe[0]); dBulge = 0.0; pPl->getBulgeAt(i,dBulge); if (fabs(dBulge) < 1.e-10) // 直线 { pPl->getPointAt(i + 1,curel.ptGe[1]); curel.ptGe[2] = curel.ptGe[1]; crLoop.append(curel); } else //圆弧 { double dPar1 = 0.0,dPar2 = 0.0; pPl->getParamAtPoint(curel.ptGe[0],dPar1); pPl->getPointAt(i + 1,curel.ptGe[2]); AcGeCircArc3d geArc; pPl->getArcSegAt(i,geArc); curel.ptGe[0] = geArc.startPoint(); curel.ptGe[2] = geArc.endPoint(); dPar1 = geArc.paramOf(curel.ptGe[0]); dPar2 = geArc.paramOf(curel.ptGe[2]); curel.ptGe[1] = geArc.evalPoint((dPar2 + dPar1) / 2.0); crLoop.append(curel); } } if (pPl->isClosed()) { //最后一段 memset(&curel,0,sizeof(TDb::TCurveElement)); pPl->getPointAt(nVerts - 1,curel.ptGe[0]); double dBulge = 0.0; pPl->getBulgeAt(nVerts - 1,dBulge); if (fabs(dBulge) > 1.e-6) //ARC { double dEndPa = 0.0; pPl->getEndParam(dEndPa); dEndPa -= 0.2; pPl->getPointAtParam(dEndPa,curel.ptGe[1]); pPl->getPointAt(0,curel.ptGe[2]); } else { pPl->getPointAt(0,curel.ptGe[1]); curel.ptGe[2] = curel.ptGe[1]; } //if (curel.ptGe[0].distanceTo(curel.ptGe[1]) > AcGeContext::gTol.equalPoint()) if (curel.ptGe[0].distanceTo(curel.ptGe[1]) > g_globalTol.equalPoint()) // modify by cq TFS8208 { crLoop.append(curel); } } delete pPl; } } return crLoop.length() > 0; } void TDbImpFitting::GetKindName(CString& sName) { sName = _T("TCH_DBFITTING"); if (m_pSpecFitting != NULL) { m_pSpecFitting->GetKindName(sName); } } BOOL TDbImpFitting::ReCreateByXDataMap() { CString sService; m_XDataMap.GetAt(KEY_FITSRV,sService); TDbFittingCreatorService* pFitCreatorService = NULL; pFitCreatorService = (TDbFittingCreatorService*)acrxServiceDictionary->at(sService); if (pFitCreatorService != NULL) { TImpSpecFitting* pNewFitting = NULL; pNewFitting = pFitCreatorService->CreateSpecialFitting(&m_XDataMap,m_pOwnerEnt); if (pNewFitting != NULL) { if (m_pSpecFitting != NULL) m_pSpecFitting->Destroy(); m_pSpecFitting = pNewFitting; return TRUE; } } return FALSE; } Acad::ErrorStatus TDbImpFitting::setNormal(const AcGeVector3d& vtNorm) { m_XDataMap.SetAt(KEY_NORMAL,vtNorm); return Acad::eOk; } AcGeVector3d TDbImpFitting::normal() const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->normal(); } AcGeVector3d vt = AcGeVector3d::kZAxis; if (!m_XDataMap.GetAt(KEY_NORMAL,vt)) { m_XDataMap.GetAt(KEY_MAJBR,vt); } return vt; } Acad::ErrorStatus TDbImpFitting::copyFrom(const TDbImpFitting* pSrc) { if (pSrc != NULL) { m_XDataMap.CopyFrom(&pSrc->m_XDataMap); m_arDbExtEdgs.RemoveAll(); m_arDbExtEdgs.Add(pSrc->m_arDbExtEdgs); m_arIdCoverByMe.setLogicalLength(0); m_arIdCoverByMe.append(pSrc->m_arIdCoverByMe); ReCreateByXDataMap(); return Acad::eOk; } return Acad::eInvalidInput; } void TDbImpFitting::list() const { if (m_pSpecFitting != NULL) { m_pSpecFitting->list(); } } Acad::ErrorStatus TDbImpFitting::dwgInFields(AcDbDwgFiler* pFiler) { // change by hh 2013-9-2 版本小于2时 才读取XDataMap // m_XDataMap.dwgInFields(pFiler); if(2 > m_nDwgVersion) { m_XDataMap.dwgInFields(pFiler); } AcDbSoftPointerId idSoft; #if ADS > 20 int lLen = 0l; #else long lLen = 0l; #endif m_arDbExtEdgs.RemoveAll(); m_arIdCoverByMe.setLogicalLength(0); TDbExtentsEdge edage; pFiler->readInt32(&lLen); int i = 0; for (i = 0;i < lLen;i++) { edage.dwgInFields(pFiler); m_arDbExtEdgs.Add(edage); } pFiler->readInt32(&lLen); for (i = 0;i < lLen;i++) { pFiler->readSoftPointerId(&idSoft); m_arIdCoverByMe.append(idSoft); } ReCreateByXDataMap(); return Acad::eOk; } Acad::ErrorStatus TDbImpFitting::dwgOutFields(AcDbDwgFiler* pFiler) const { // change by hh 2013-9-2 TXDataMap改在底层中进行读写 // Write version number. // m_XDataMap.dwgOutFields(pFiler); // 另存为9版以下的图纸时 TXDataMap仍需自行写入 if (g_nSaveTArchVer <= 9) { m_XDataMap.dwgOutFields(pFiler); } // 边界存储 long lLen = m_arDbExtEdgs.GetCount(); pFiler->writeInt32(lLen); for (int i = 0;i < lLen;i++) { m_arDbExtEdgs.GetAt(i).dwgOutFields(pFiler); } lLen = m_arIdCoverByMe.length(); pFiler->writeInt32(lLen); for (i = 0;i < lLen;i++) { pFiler->writeSoftPointerId(AcDbSoftPointerId(m_arIdCoverByMe.at(i))); } return Acad::eOk; } Acad::ErrorStatus TDbImpFitting::dxfInFields(AcDbDxfFiler* pFiler) { return Acad::eOutOfMemory; } Acad::ErrorStatus TDbImpFitting::dxfOutFields(AcDbDxfFiler* pFiler) const { return Acad::eOutOfMemory; } Acad::ErrorStatus TDbImpFitting::extend(Adesk::Boolean extendStart, const AcGePoint3d& toPoint) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->extend(extendStart,toPoint); } return Acad::eOutOfMemory; } Acad::ErrorStatus TDbImpFitting::extend(double newParam) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->extend(newParam); } return Acad::eOutOfMemory; } Acad::ErrorStatus TDbImpFitting::getClassID(CLSID* pClsid) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getClassID(pClsid); } return Acad::eOutOfMemory; } Acad::ErrorStatus TDbImpFitting::getClosestPointTo(const AcGePoint3d& givenPnt, AcGePoint3d& pointOnCurve, Adesk::Boolean extend) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getClosestPointTo(givenPnt,pointOnCurve,extend); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getClosestPointTo(const AcGePoint3d& givenPnt, const AcGeVector3d& direction, AcGePoint3d& pointOnCurve, Adesk::Boolean extend) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getClosestPointTo(givenPnt,direction,pointOnCurve,extend); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getDistAtParam(double param, double& dist) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getDistAtParam(param,dist); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getDistAtPoint(const AcGePoint3d& x0, double& x1)const { if (m_pSpecFitting != NULL) { m_pSpecFitting->getDistAtPoint(x0,x1); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getEndParam(double& x0) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getEndParam(x0); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getEndPoint(AcGePoint3d& x0) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getEndPoint(x0); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getFirstDeriv(const AcGePoint3d& x0, AcGeVector3d& firstDeriv) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getFirstDeriv(x0,firstDeriv); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getFirstDeriv(double param, AcGeVector3d& firstDeriv) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getFirstDeriv(param,firstDeriv); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getGeomExtents(AcDbExtents& extents) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getGeomExtents(extents); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getGripPoints(gripPoints,osnapModes,geomIds); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getOffsetCurves(double offsetDist, AcDbVoidPtrArray& offsetCurves) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getOffsetCurves(offsetDist,offsetCurves); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getOsnapPoints(AcDb::OsnapMode osnapMode, INT_PTR gsSelectionMark, const AcGePoint3d& pickPoint, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcGePoint3dArray& snapPoints, AcDbIntArray& geomIds) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getOsnapPoints(osnapMode,gsSelectionMark, pickPoint,lastPoint, viewXform,snapPoints, geomIds); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getParamAtDist(double dist, double& param) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getParamAtDist(dist,param); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getParamAtPoint(const AcGePoint3d& x0, double& x1)const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getParamAtPoint(x0,x1); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getPointAtDist(double x0, AcGePoint3d& x1) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getPointAtDist(x0,x1); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getPointAtParam(double x0, AcGePoint3d& x1) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getPointAtParam(x0,x1); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getSplitCurves(const AcGeDoubleArray& params, AcDbVoidPtrArray& curveSegments) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getSplitCurves(params,curveSegments); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getSplitCurves(const AcGePoint3dArray& points, AcDbVoidPtrArray& curveSegments) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getSplitCurves(points,curveSegments); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getStartParam(double& x0) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getStartParam(x0); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getStartPoint(AcGePoint3d& x0) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getStartPoint(x0); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::getStretchPoints(AcGePoint3dArray& stretchPoints) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->getStretchPoints(stretchPoints); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::intersectWith(const AcDbEntity* pEnt, AcDb::Intersect intType, AcGePoint3dArray& points, INT_PTR thisGsMarker, INT_PTR otherGsMarker) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->intersectWith(pEnt,intType,points,thisGsMarker,otherGsMarker); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::intersectWith(const AcDbEntity* pEnt, AcDb::Intersect intType, const AcGePlane& projPlane, AcGePoint3dArray& points, INT_PTR thisGsMarker, INT_PTR otherGsMarker) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->intersectWith(pEnt,intType,projPlane,points,thisGsMarker,otherGsMarker); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->moveGripPointsAt(indices,offset); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::moveStretchPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->moveStretchPointsAt(indices,offset); } return Acad::eInvalidInput; } Acad::ErrorStatus TDbImpFitting::transformBy(const AcGeMatrix3d& xform) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->transformBy(xform); } return Acad::eNotApplicable; } Acad::ErrorStatus TDbImpFitting::ExplodeOrDraw3d(XExplodeDraw &mode) const { if (m_pSpecFitting != NULL) { m_pSpecFitting->ExplodeOrDraw3d(mode); return Acad::eOk; } return Acad::eNotImplementedYet; } Acad::ErrorStatus TDbImpFitting::ExplodeOrDraw2d(XExplodeDraw &mode) const { if (m_pSpecFitting != NULL) { BOOL bWeight = FALSE; m_XDataMap.GetAt(KEY_EDAGEWEIGHT,bWeight); BOOL bCenWeight = FALSE; m_XDataMap.GetAt(KEY_CENLWEIGHT,bCenWeight); AcDbObjectId idReal = ((TDbInterfacesObj*)m_pOwnerEnt)->layerId(); AcDbObjectId idDash = ((TDbInterfacesObj*)m_pOwnerEnt)->DashLayer(); AcDbObjectId idCent = ((TDbInterfacesObj*)m_pOwnerEnt)->CenterLayer(); double dPScale = ((TDbInterfacesObj*)m_pOwnerEnt)->GetPrintScale(); if (dPScale < 1.e-3) dPScale = 1.0; //如果单线中心线显示; BOOL nSingleLine = FALSE; m_XDataMap.GetAt(KEY_SINGLE,nSingleLine); if (nSingleLine) { // 获取实体自身原来的pl边界对象[源]; TComplexCurve compInside; GetCurvesInSide(compInside); compInside.setSubElementGsMark(0); TDb::TCurveElement* pElTmpl = NULL; if (!acrxServiceDictionary->has(KEY_FITCAB)) { if (compInside.length() > 0) pElTmpl = &compInside.first(); } TDbExtentsEdge edage; // 画被虚图元段.该部分由外部计算传入; for (int i = 0;i < m_arDbExtEdgs.GetCount();i++) { edage = m_arDbExtEdgs.GetAt(i); // 然后[源]实边界对象减去虚图元段;] if (TCoverBooleanOper::BoolSubtract(compInside,edage)) { // 画虚图元部分[被遮挡] m_arDbExtEdgs.GetAt(i).ExplodeOrDraw2d(mode,idReal,idDash,idCent,pElTmpl,bWeight,bCenWeight,dPScale); } } TDbExtentsEdge edge; edge.SetEdage(compInside); edge.ExplodeOrDraw2d(mode,idReal,idDash,idCent,NULL,bWeight,bCenWeight,dPScale); return Acad::eOk; } if (m_arDbExtEdgs.GetCount() == 0) { TDbExtentsEdge edge; //获取实体自身原来的边界对象[源]; TComplexCurve compCurve; MakeCurves(compCurve); edge.SetEdage(compCurve); edge.ExplodeOrDraw2d(mode,idReal,idDash,idCent,NULL,bWeight,bCenWeight,dPScale); //画减去虚段后剩下的实图元段; TComplexCurve compInside; GetCurvesInSide(compInside); edge.SetEdage(compInside); edge.ExplodeOrDraw2d(mode,idReal,idDash,idCent,NULL,bWeight,bCenWeight,dPScale); } else { //获取实体自身原来的pl边界对象[源]; TComplexCurve compCurve,compInside; MakeCurves(compCurve); GetCurvesInSide(compInside); TDb::TCurveElement* pElTmpl = NULL; if (!acrxServiceDictionary->has(KEY_FITCAB)) { if (compInside.length() > 0) pElTmpl = &compInside.first(); } //画被虚图元段.该部分由外部计算传入; for (int i = 0;i < m_arDbExtEdgs.GetCount();i++) { // 然后[源]实边界对象减去虚图元段;] if (TCoverBooleanOper::BoolSubtract(compCurve,m_arDbExtEdgs.GetAt(i))) { // 画虚图元部分[被遮挡] m_arDbExtEdgs.GetAt(i).ExplodeOrDraw2d(mode,idReal,idDash,idCent,pElTmpl,bWeight,bCenWeight,dPScale); } // 内部的中心线等分布线减去被遮挡的部分 TCoverBooleanOper::BoolSubtract(compInside,m_arDbExtEdgs.GetAt(i)); } //确保去掉重复的画线 [补漏] for (i = 0;i < m_arDbExtEdgs.GetCount();i++) { // 然后[源]实边界对象减去虚图元段;] TCoverBooleanOper::BoolSubtract(compCurve,m_arDbExtEdgs.GetAt(i)); } //画减去虚段后剩下的实图元段; TDbExtentsEdge edge; edge.SetEdage(compCurve); edge.ExplodeOrDraw2d(mode,idReal,idDash,idCent,NULL,bWeight,bCenWeight,dPScale); // 画内部的中心线等分布线 edge.SetEdage(compInside); edge.ExplodeOrDraw2d(mode,idReal,idDash,idCent,NULL,bWeight,bCenWeight,dPScale); } } return Acad::eOk; } Acad::ErrorStatus TDbImpFitting::explode(AcDbVoidPtrArray& entitySet) const { if (m_pSpecFitting != NULL) { BOOL bWeight = FALSE; m_XDataMap.GetAt(KEY_EDAGEWEIGHT,bWeight); BOOL bCenWeight = FALSE; m_XDataMap.GetAt(KEY_CENLWEIGHT,bCenWeight); AcDbObjectId idReal = ((TDbInterfacesObj*)m_pOwnerEnt)->layerId(); AcDbObjectId idDash = ((TDbInterfacesObj*)m_pOwnerEnt)->DashLayer(); AcDbObjectId idCent = ((TDbInterfacesObj*)m_pOwnerEnt)->CenterLayer(); if (m_arDbExtEdgs.GetCount() == 0) { TComplexCurve compOutSide; m_pSpecFitting->MakeCurves(compOutSide); TDbExtentsEdge edgeOut; edgeOut.SetEdage(compOutSide); edgeOut.explode(entitySet,idReal,idDash,idCent,NULL,bWeight,bCenWeight); // 画减去虚段后剩下的实图元段; TComplexCurve compInside; GetCurvesInSide(compInside); TDbExtentsEdge edge; edge.SetEdage(compInside); edge.explode(entitySet,idReal,idDash,idCent,NULL,bWeight,bCenWeight); } else { // 获取实体自身原来的pl边界对象[源]; TComplexCurve compCurve,compInside; MakeCurves(compCurve); GetCurvesInSide(compInside); TDb::TCurveElement elTmpl; memset(&elTmpl,0,sizeof(TDb::TCurveElement)); if (compInside.length() > 0) elTmpl = compInside.first(); // 画被虚图元段.该部分由外部计算传入; for (int i = 0;i < m_arDbExtEdgs.GetCount();i++) { // 然后[源]实边界对象减去虚图元段;] if (TCoverBooleanOper::BoolSubtract(compCurve,m_arDbExtEdgs.GetAt(i))) { // 画虚图元部分[被遮挡] m_arDbExtEdgs.GetAt(i).explode(entitySet,idReal,idDash,idCent,&elTmpl,bWeight,bCenWeight); } // 内部的中心线等分布线减去被遮挡的部分 TCoverBooleanOper::BoolSubtract(compInside,m_arDbExtEdgs.GetAt(i)); } // 画减去虚段后剩下的实图元段; TDbExtentsEdge edge; edge.SetEdage(compCurve); edge.explode(entitySet,idReal,idDash,idCent,NULL,bWeight,bCenWeight); // 画内部的中心线等分布线 edge.SetEdage(compInside); edge.explode(entitySet,idReal,idDash,idCent,NULL,bWeight,bCenWeight); } } return Acad::eOk; } BOOL TDbImpFitting::GetActiveViewPortInfo(AcGeVector3d& viewDir) { viewDir = AcGeVector3d::kZAxis; struct resbuf rb; memset (&rb, 0, sizeof (struct resbuf)); acedGetVar (_T("VIEWDIR"), &rb); viewDir.set(rb.resval.rpoint[X], rb.resval.rpoint[Y], rb.resval.rpoint[Z]); viewDir.normalize(); return TRUE; } BOOL TDbImpFitting::MakeCurves(TComplexCurve& cplCurve) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->MakeCurves(cplCurve); } return FALSE; } BOOL TDbImpFitting::GetCurvesInSide(TComplexCurve& compCurve) const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->GetCurvesInSide(compCurve); } return FALSE; } AcDbPolyline* TDbImpFitting::MakePolyCurve() const { if (m_pSpecFitting != NULL) { return m_pSpecFitting->MakePolyCurve(); } return NULL; } BOOL TDbImpFitting::MakePolyCurveFaces(AcDbVoidPtrArray& arFaces) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->MakePolyCurveFaces(arFaces); } return NULL; } void TDbImpFitting::GetTips(CMapStringToString& mapLable2Tip) const { if (m_pSpecFitting != NULL) { m_pSpecFitting->GetTips(mapLable2Tip); } } void TDbImpFitting::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag) { if (m_pSpecFitting != NULL) { m_pSpecFitting->CopyPropertiesFrom(pSrc, gMatchFlag); } } void TDbImpFitting::CopyPropertiesTo(AcDbObjectId& idTgr,unsigned gMatchFlag) { if (m_pSpecFitting != NULL) { m_pSpecFitting->CopyPropertiesTo(idTgr, gMatchFlag); } } BOOL TDbImpFitting::OPMInfo(LPCTSTR pszName, TDb::OPMInfo* pInfo) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->OPMInfo(pszName, pInfo); } return FALSE; } BOOL TDbImpFitting::IsValid(TDbXDataMap* pXMap) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->IsValid(pXMap); } return FALSE; } void TDbImpFitting::OnSubErase( Adesk::Boolean erasing ) { if (m_pSpecFitting != NULL) m_pSpecFitting->OnSubErase(erasing); } int TDbImpFitting::GetXBaseShell(TXShell& xShell) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->GetXBaseShell(xShell); } return 0; } int TDbImpFitting::GetBodyBox(AcDbExtents& ext) { if (m_pSpecFitting != NULL) { return m_pSpecFitting->GetBodyBox(ext); } return 0; } LRESULT TDbImpFitting::UserCall( long i,LPVOID pData ) { if (NULL != m_pSpecFitting) return m_pSpecFitting->UserCall(i, pData); return 0l; } CString TDbImpFitting::GetXml(const AcGeMatrix3d& mat) const { return m_pSpecFitting->GetXml(mat); } bool TDbImpFitting::GetSection( const AcDbFace &face, const AcGeVector3d &vtPlaneSecDir, std::vector §ionRecord, AcDbVoidPtrArray& arFillPtrs ) const { if(NULL == m_pSpecFitting) return false; return m_pSpecFitting->GetSection(face, vtPlaneSecDir, sectionRecord, arFillPtrs); } Acad::ErrorStatus TDbImpFitting::GetExtents( TADSGePoint3d &ptLow, TADSGePoint3d &ptUp ) const { if(NULL == m_pSpecFitting) return Acad::eNotImplementedYet; return m_pSpecFitting->GetExtents(ptLow, ptUp); } // add by hh 2014-08-06 支持管件与水管遮挡 Acad::ErrorStatus TDbImpFitting::GetClipBoundary(TGGePoly2D& poly)const { if(NULL == m_pSpecFitting) return Acad::eNotImplementedYet; return m_pSpecFitting->GetClipBoundary(poly); } bool TDbImpFitting::IsMeClip() const { if(NULL == m_pSpecFitting) return false; return m_pSpecFitting->IsMeClip(); } bool TDbImpFitting::IsClipMe(const TEntityBase* pEnt)const//ok是否被裁剪 { if(NULL == m_pSpecFitting) return false; return m_pSpecFitting->IsClipMe(pEnt); }