/* 武士刀,可以撕裂墙壁! - gjm */ #pragma once #include "tdbcurveentity.h" namespace { template T MidPt(const T &pt1, const T &pt2) { return T((pt1.x+pt2.x)*.5, (pt1.y+pt2.y)*.5, (pt1.z+pt2.z)*.5); } } class TARCH_EXP CGlwKatana : public TDbCurveEntity { DECLARE_TENTBASE(); ACRX_DECLARE_MEMBERS(CGlwKatana); public: CGlwKatana(): m_ptCenter(AcGePoint3d::kOrigin), m_objLeftWall(AcDbObjectId::kNull), m_objRightWall(AcDbObjectId::kNull), m_bDragGripPt(false){} virtual ~CGlwKatana(){} public: virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler *pFiler); virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler *pFiler) const; virtual Acad::ErrorStatus ExplodeOrDraw2d(TGGiExplodeDrawBase &dc) const; virtual Acad::ErrorStatus ExplodeOrDraw3d(TGGiExplodeDrawBase &dc) const; virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d &xform); virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray &gripPoints, AcDbIntArray&,AcDbIntArray&)const; virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray &indices, const AcGeVector3d &offset); virtual Acad::ErrorStatus subDeepClone(AcDbObject *pOwner, AcDbObject *&pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary) const; Acad::ErrorStatus subWblockClone(AcRxObject* pOwner, AcDbObject*& pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary) const; virtual Acad::ErrorStatus GetExtents2d(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const; virtual Acad::ErrorStatus GetExtents(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const; virtual Acad::ErrorStatus subErase(Adesk::Boolean erasing); virtual int GetFirstVersion()const; public: void SetLeftWallID(AcDbObjectId &id) {m_objLeftWall = id;} AcDbObjectId GetLeftWallID() {return m_objLeftWall;} void SetRightWallID(AcDbObjectId &id) {m_objRightWall = id;} AcDbObjectId GetRightWallID() {return m_objRightWall;} AcGePoint3d GetLeftPt() {return m_ptLeft;} AcGePoint3d GetRightPt() {return m_ptRight;} AcGePoint3d GetCenterPt() {return m_ptCenter;} void Init(AcDbObjectId &idNew, AcDbObjectId &idOld); bool IsDragGripPt() {return m_bDragGripPt;} void SetIsDragGripPt(bool bDrag) {m_bDragGripPt = bDrag;} static double GetLessLength(); private: bool CalcTraitPtByWall(const AcGePoint3d &pt); AcDbObjectId FindCloneId(AcDbObjectId id, AcRxObject* pOwner, AcDbIdMapping& idMap, Adesk::Boolean isPrimary, bool bIsDeepClone) const; bool UpdateNewKatana(CGlwKatana *pNewKa, AcDbObjectId idLeft, AcDbObjectId idRight) const; private: AcDbSoftPointerId m_objLeftWall, m_objRightWall;// 刀两侧的墙 AcGePoint3d m_ptCenter, m_ptLeft, m_ptRight; // 刀的特征点 bool m_bDragGripPt; static double m_dWallLessLength; // 左右两墙的最小长度 }; namespace KatanaToolkit { AcDbObjectId GetKatanaByTwoWalls(TDbWall *pWall1, TDbWall *pWall2); bool JudgeCollinearByWalls(TDbWall *pWall1, TDbWall *pWall2); void Erase(AcDbObjectId id); void ModifyKatana(CGlwKatana *pKa); AcDbObjectId GetOtherWallByKatana(TDbWall *pWall, AcDbObjectId KaID); void SetBegKatanaIdForWall(TWallData *pWall, AcDbObjectId KaID); void SetEndKatanaIdForWall(TWallData *pWall, AcDbObjectId KaID); AcDbObjectId GetBegKatanaIdByWall(TDbWall *pWall); AcDbObjectId GetEndKatanaIdByWall(TDbWall *pWall); void SetLeftWallIdForKatana(AcDbObjectId wallID, AcDbObjectId KaID); void SetRightWallIdForKatana(AcDbObjectId wallID, AcDbObjectId KaID); AcDbObjectId GetLeftWallIdByKatana(AcDbObjectId KaID); AcDbObjectId GetRightWallIdByKatana(AcDbObjectId KaID); void UnRegister(TDbWall *pWall, AcDbObjectId idOther); void Register(TDbWall *pWall, AcDbObjectId idOther); CString GetCMDName(); }