#ifndef _NODEASSISTANT_H_2006_6_29_ #define _NODEASSISTANT_H_2006_6_29_ #include "PipeTools.h" /*============================================================================* * Copyright(c), 1994-2007, Beijing Tangent Engineering Software Co.Ltd. * 文 件 名: NodeAssistant.h * 版 本: 1.0 * 作 者: sg * 归属项目: 给排水,暖通 * 历史记录: 1. sg creat,多次重复调用,连接不通过,由PipeWireMonitor.h文件 移入,但内容无改动 =============================================================================*/ /*============================================================================* * 类 名: TEntRect * 功能描述: 抽象的管线信息类 * 备 注: 1、记录管线的ID和管线的位置 2、用于TPsSide和TDsSide中 ==============================================================================*/ class TEntRect { public: AcDbObjectId id; XRectAngle rect; public: TEntRect(const TEntRect &ent): id(ent.id), rect(ent.rect){} TEntRect(const AcDbObjectId id, const XPoint ptMin, const XPoint ptMax) :id(id), rect(ptMin, ptMax){} void operator += (const TEntRect &ent) { rect.lowLeft.x = min(ent.rect.lowLeft.x, rect.lowLeft.x); rect.lowLeft.y = min(ent.rect.lowLeft.y, rect.lowLeft.y); rect.upRight.x = max(ent.rect.upRight.x, rect.upRight.x); rect.upRight.y = max(ent.rect.upRight.y, rect.upRight.y); } public: BOOL Intersect(const XRectAngle &box) const { return ExtendInBox02d(rect.lowLeft, rect.upRight,box); } BOOL Intersect(const TEntRect &other) const { return Intersect(other.rect); } BOOL InBox(const XRectAngle &box) const { return ExtendInBox2d(rect.lowLeft, rect.upRight, box); } static int CompareObjectId(const TEntRect* p1, const void* pId) { return !(p1->id == *(const AcDbObjectId*)pId); } }; /*============================================================================* * 类 名: TNodeLocation * 功能描述: 抽象的节点信息类 * 备 注: 1、记录节点的ID和节点的位置 2、用于TPsNode和TDsNode中 ==============================================================================*/ class TNodeLocation { public: AcDbObjectId id; XPoint ptLocation; public: TNodeLocation() {} TNodeLocation(const XPoint pt):ptLocation(pt) {} TNodeLocation(const TNodeLocation &node):id(node.id), ptLocation(node.ptLocation) {} TNodeLocation(const AcDbObjectId id, const XPoint pt):id(id), ptLocation(pt) {} public: BOOL Intersect(const XRectAngle &box, double nSnap = PS_SNAP) const { return !(ptLocation.x-box.upRight.x > nSnap || ptLocation.y-box.upRight.y > nSnap || box.lowLeft.x-ptLocation.x > nSnap || box.lowLeft.y-ptLocation.y > nSnap); } BOOL Intersect(const TEntRect &ent, double nSnap = PS_SNAP) const { return Intersect(ent.rect,nSnap); } BOOL Intersect(const TNodeLocation &node, double nSnap = PS_SNAP) const { return (fabs(node.ptLocation.x-ptLocation.x)<=nSnap && fabs(node.ptLocation.y-ptLocation.y)<=nSnap); } static int CompareObjectId(const TNodeLocation* p1, const void* pId) { return !(p1->id == *(const AcDbObjectId*)pId); } BOOL EqualLocation(const XPoint pt, double nSnap = PS_SNAP) const { return ptLocation.Distance(pt)