130 lines
4.9 KiB
C++
130 lines
4.9 KiB
C++
#ifndef _SEARCH_PIPESYS_H
|
|
#define _SEARCH_PIPESYS_H
|
|
|
|
#include "PipeWireMonitor.h"
|
|
#include "PipePrototype.h"
|
|
#include <afxtempl.h>
|
|
#include <list>
|
|
|
|
class TPsSide;
|
|
class TPsNode: public DStack<TPsSide> {
|
|
public:
|
|
TNodeLocation m_node;
|
|
BOOL m_bAutoLiving;
|
|
public: // 构造函数
|
|
TPsNode(const XPoint &pt,BOOL bAutoLiving=TRUE)
|
|
:m_node(pt),m_bAutoLiving(bAutoLiving){}
|
|
TPsNode(const TNodeLocation &node,BOOL bAutoLiving)
|
|
:m_node(node),m_bAutoLiving(bAutoLiving){}
|
|
public:
|
|
BOOL IsAutoLiving() const {
|
|
return m_bAutoLiving;
|
|
}
|
|
// 是否与当前节点位置重合:应当局限与隐式节点
|
|
BOOL IsDupLocation(const XPoint& pt) const {
|
|
return m_bAutoLiving && m_node.EqualLocation(pt);
|
|
}
|
|
BOOL IsDupLocation(const TNodeLocation &node) const {
|
|
return m_bAutoLiving && m_node.EqualLocation(node.ptLocation);
|
|
}
|
|
BOOL IsDbObject() const {
|
|
return m_node.id.isValid();
|
|
}
|
|
// 判断节点是否可以连接边的端点. nPos: 0--start; 1--end
|
|
BOOL CanLinkSide(const TPsSide &rSide, int nPos) const;
|
|
// 根据节点对st类型管段的连接
|
|
void UpdateLinkage(TPipeSys::SysType st);
|
|
// 真正从数据库中删除和替换管线
|
|
void RemovePipeFromDb(const AcDbObjectId &idSide);
|
|
void ReplacePipeFromDb(const AcDbObjectId &idOld,const AcDbObjectId &idNew);
|
|
};
|
|
|
|
class TPsSide: public XDirectionCurve {
|
|
public:
|
|
TEntRect m_pipe;
|
|
TPsNode *m_pStartNode, *m_pEndNode;
|
|
public:
|
|
TPsSide(const AcDbObjectId &id);
|
|
TPsSide(const TEntRect &pipe);
|
|
public:
|
|
BOOL IsDbObject() const {
|
|
return m_pipe.id.isValid();
|
|
}
|
|
BOOL IsValid() const {
|
|
return (GetLength()>_distSnap);
|
|
}
|
|
void GetPoints(XPoint &pt1, XPoint &pt2) {
|
|
pt1=GetStartPoint();
|
|
pt2=GetEndPoint();
|
|
}
|
|
//完全重合的管段
|
|
BOOL IsFullDupSide(const XCurveSegment *pSeg) const {
|
|
return ((XCurveSegment &)*this == *pSeg);
|
|
}
|
|
BOOL IsFullDupSide(const TPsSide &side) const;
|
|
// 对数据库对象进行合并
|
|
BOOL MergeWith(TPsSide &pipeOther, const TPsNode &nodeMerge);
|
|
// 更新管线对节点的连接: 位标志0x01-起点;0x02-终点
|
|
void UpdateLinkage(int nFlag);
|
|
};
|
|
|
|
// 由墙找房间的辅助类,用来初始化全局变量和清除全局变量
|
|
// 状态: 考虑了墙体底标高不同时候的处理
|
|
class TSearchPipeSys {
|
|
public:
|
|
DList<TPsNode> m_lstAllNode;
|
|
DList<TPsSide> m_lstAllSide;
|
|
DList<TPsNode> m_lstNewNode; // cet 2015.7.3 add 生成的新节点
|
|
DList<AcDbObjectId> m_lstDupNode; //重合,有待于删除的节点
|
|
DList<AcDbObjectId> m_lstDupPipe; //重合,有待于删除的管段
|
|
// AcDbIdMapping m_idMapMergeVPipe; //2立管合并, sr 2009-4-10
|
|
CMap<LONG_PTR,LONG_PTR,LONG_PTR,LONG_PTR> m_idMapMergeVPipe; //2立管合并, sr 2009-4-10
|
|
|
|
BOOL m_bOptimize; //是否优化 :1、不判断重合管线
|
|
// 2、只处理自动生成的管线为一个的节点
|
|
public:
|
|
TSearchPipeSys(BOOL bOptimize=FALSE):m_bOptimize(bOptimize) {}
|
|
public:
|
|
//void InitStart(TPipeSys::SysType st, PickSet &ssPipes, PickSet &ssNodes);
|
|
void InitStart(TPipeSys::SysType st,const DList<TEntRect>& lstPipe,
|
|
const DList<TNodeLocation>& lstNode,const XPointList& lstBreak);
|
|
void MergePipes(XPointList &lstCorners, PickSet &ssDel, bool bDelTPsSide = false); // 合并所有墙段
|
|
//void BreakPipes(XPointList &lstCorners); //在断点处,或裁剪区域中心打断墙体
|
|
void BreakPipes(XPointList &lstCorners,BOOL bJudge=TRUE);
|
|
|
|
// cet 2015.7.8 add 获得经过该点的管线
|
|
void PassPointPipes(XPoint pt, std::vector<TPsSide*> &vecSide);
|
|
|
|
// box-指定更新范围(忽略z)
|
|
void UpdateNodeLinkage(TPipeSys::SysType st, const XRectAngle *box=NULL);//更新节点对管线的连接
|
|
void UpdatePipeLinkage(const XRectAngle *box=NULL); //更新管线对节点的连接
|
|
|
|
//移除范围A内的孤独隐式节点
|
|
//void DelSoleNodeFromDb(const XRectAngle *box=NULL);
|
|
void DelSoleNodeFromDb(TPipeSys::SysType st,const XRectAngle *box=NULL);
|
|
|
|
void AddAutoNodeToDb(const XRectAngle *box=NULL);
|
|
void DelDupPipeFromDb(const XRectAngle& box);
|
|
void DelDupNodeFromDb(const XRectAngle& box);
|
|
// cet 2015.7.3 add 删除所有自动生成的节点实体
|
|
void DelAllNodeFromDb(const XRectAngle *box=NULL);
|
|
// cet 2015.7.6 add 更新TPsSide关联的node信息
|
|
void UpdateTPsSideNode(int nPos, const AcDbObjectId &idPipe, TPsNode *pNode);
|
|
protected:
|
|
// 根据pSide提供的id所引用的节点或端点,查找Ps节点。nPos: 0--start; 1--end
|
|
TPsNode *FindPsNodeAt(const TPsSide &rSide, int nPos);
|
|
void UpdateLinkageOnBreak(TDbPipePrototype *pSide,TPsSide &side,
|
|
TPsNode &node,AcDbObjectId& idNewPipe);
|
|
void AddPipe(const TEntRect &pipe,TPipeSys::SysType st);// 增加管段
|
|
//BOOL BreakPipeAt(int nPos, XPointList &lstCorners);//在第nPos个位置合并管段
|
|
void BreakPipeAt(int nPos, XPointList &lstCorners,BOOL bJudge=TRUE);
|
|
BOOL MergePipeAt(int nPos, XPointList &lstCorners, PickSet &ssDel); //在第nPos个位置合并管段
|
|
BOOL IsDupNode(const TNodeLocation &node) const; //从AllNode判断是否为重复节点
|
|
BOOL IsDupNode(const XPoint& pt) const;
|
|
BOOL IsFullDupPipe(const XCurveSegment *pSeg) const;//是否完全重合的管线
|
|
BOOL IsFullDupPipe(const TPsSide &side) const;//是否完全重合的管线
|
|
BOOL DelNodeFromDb(const AcDbObjectId& id,const XRectAngle& box);
|
|
BOOL DelPipeFromDb(const AcDbObjectId& id,const XRectAngle& box);
|
|
};
|
|
|
|
#endif |