//-----------------------------------------------------------------------------+ // Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd. // = FileName : TGObject.h // = Version : ver2.0 // = Author : xlc // = CreateDate : 2002-09-09 // = Description: 类的声明 几何实体抽象基类 // = Maintainers: // //-----------------------------------------------------------------------------+ #ifndef _TGOBJECT_H_ #define _TGOBJECT_H_ #ifndef _TWRUNTIMECLASS_H_ #include "TWRunTimeClass.h" #endif #ifndef _TWFLAG_H_ #include "TWFlag.h" #endif #ifndef _TPGECOORDSYS_H_ #include "TPGeCoordSys.h" #endif #ifndef _TGPOINT_H_ #include "TGPoint.h" #endif class TPGeExtend2D; class TPGeExtend3D; class TGMatrix; class TGObjectList; class GEOAPI TGObject : public TWRunTimeClass, public TWFlag { DECLARE_RUN_TIME_CLASS(TGObject) public: bool operator > (const TGObject&obj) const; bool operator < (const TGObject&obj) const; virtual ~TGObject(); //实体有效性,如果非特殊说明,对实体的所有函数调用必须满足实体有效! virtual bool IsValid() const; virtual TGObject * Clone() const; //坐标变换 virtual void TransformBy(const TGMatrix& pMatrix); virtual bool Explode(TGObjectList& res) const; //求交,禁止TGObject2D与TGObject3D混合运算! //须满足操作顺序可交换规则!结果可能出现冗余 //此处实现了复合实体与其它实体的分解后求交 //子类中,基本实体与基本实体的求交一定要重载,基本实体与复杂实体的求交一般要反向进行 virtual bool Intersect(const TGObject&obj,TGObjectList& res) const; //此处实现了对复合实体的包含判断(分解之后对子实体进行判断) //子类中对基本实体的包含判断要重载 //包含判断,禁止TGObject2D与TGObject3D混合运算! virtual bool IsInclude(const TGObject&obj) const; //此处实现了复合实体的点包含测试(GR_IN/GR_OUT),基本实体类要重载 //点相对集合的关系判断,要求最少包含判断GR_IN/GR_OUT virtual GRelation HitTest(const TGPoint&pt) const; //此处实现了复合实体的取包围盒,基本实体类要重载 //无包围盒返回false virtual bool GetExtend2D(TPGeExtend2D& pExt) const; //此处实现了复合实体的取包围盒,基本实体类要重载 //无包围盒返回false virtual bool GetExtend3D(TPGeExtend3D& pExt) const; //如果ECS与WCS不重合,返回实体坐标系且return true virtual bool GetEcs(TPGeCoordSys&ecs) const; //采样测试点,不取端点、节点之类的不光滑点! virtual TGPoint GetSamplePoint() const; //图形输出,调试用 virtual void Output(int color) const; //operate //一直分解为基本实体,如果是基本实体,将取得其拷贝 void ExplodeEx(TGObjectList& pRes) const; void TransEcs(TGObject* pObj) const; void TransWcs(TGObject* pObj) const; bool IsExtendInter(const TPGeExtend2D& pExt) const; bool IsExtendInter(const TPGeExtend3D& pExt) const; typedef void (*OutputGObject)(const TGObject *pObject,int color); static OutputGObject s_pOutputFun; }; #endif