//-----------------------------------------------------------------------------+ // Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd. // = FileName : TPGeGLineRay3D.cpp // = Version : ver2.0 // = Author : xlc // = CreateDate : 2002-09-09 // = Description: ÀàµÄ¶¨Òå // = Maintainers: // //-----------------------------------------------------------------------------+ #include "StdAfx.h" #include "TPGeGLineRay3D.h" #include "TPGeGLineSeg3D.h" #include "TGPoint3D.h" IMPLEMENT_RUN_TIME_CLASS1(TPGeGLineRay3D,"TPGeGLineRay3D",TPGeGLine3D) TPGeGLineRay3D::TPGeGLineRay3D() { } TPGeGLineRay3D::TPGeGLineRay3D(const TGVector3D&vt,const TGPoint&pt) : TPGeGLine3D(vt,pt) { } TPGeGLineRay3D::TPGeGLineRay3D(const TGPoint&pt0,const TGPoint&pt1) : TPGeGLine3D(pt0,pt1) { } TPGeGLineRay3D::TPGeGLineRay3D(const TPGeLine3D&line) : TPGeGLine3D(line) { } TPGeGLineRay3D::~TPGeGLineRay3D() { } bool TPGeGLineRay3D::IsFinite(bool bStart) const { return bStart ? true : false; } TGObject2D* TPGeGLineRay3D::Convert2D() const { return new TPGeGLineRay2D(TGVector2D(x,y),basePoint); } TGObject * TPGeGLineRay3D::Clone() const { return new TPGeGLineRay3D(*this); } GRelation TPGeGLineRay3D::HitTest(const TGPoint&pt) const { GRelation r = TPGeGLine3D::HitTest(pt); if (r.Is(GR_IN)) { double pa; Pt2Pa(pt,pa); if (DOWN_ZERO(pa)) { return GR_OUT; } else { return GR_IN; } } return r; } bool TPGeGLineRay3D::IsInclude(const TGObject&obj) const { switch(obj.GetClassID()) { case CID_GLine3D: return false; case CID_GLineRay3D: { const TPGeGLineRay3D&ray = (const TPGeGLineRay3D&)obj; if (GetGeLine() == ray.GetGeLine() && IsSameDirection(ray)) { double pa; Pt2Pa(ray.basePoint,pa); return UPEQUAL_ZERO(pa); } else { return false; } } case CID_GLineSeg3D: { const TPGeGLineSeg3D&seg = (const TPGeGLineSeg3D&)obj; if (GetGeLine() == seg.GetGeLine()) { double pa; Pt2Pa(seg.GetStartPoint(),pa); if (DOWN_ZERO(pa)) { return false; } Pt2Pa(seg.GetEndPoint(),pa); return UPEQUAL_ZERO(pa); } else { return false; } } default: return TPGeCurve3D::IsInclude(obj); } } bool TPGeGLineRay3D::Intersect(const TGObject&obj,TGObjectList&res) const { switch(obj.GetClassID()) { case CID_GLine3D: { double pa; int ret = TPGeLine3D::Intersect((const TPGeGLine3D&)obj,pa); if (ret == INT_NULL) { return false; } else if (ret == INT_LINE) { res<&paTable,TGObjectList&res) const { if (paTable.IsEmpty()) { return; } TGPoint pt0; if (UP_ZERO(paTable.GetAt(0))) { Pa2Pt(paTable.GetAt(0),pt0); res<