Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

156 lines
2.9 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TPGeFace3D.cpp
// = Version : ver2.0
// = Author : xlc
// = CreateDate : 2002-09-09
// = Description: 类的定义
// = Maintainers:
//
//-----------------------------------------------------------------------------+
#include "StdAfx.h"
#include "TPGeFace3D.h"
#include "TGPoint3D.h"
#include "TGSolid.h"
#include "TPGeCurve3D.h"
IMPLEMENT_RUN_TIME_CLASS1(TPGeFace3D,"TPGeFace3D",TGObject3D)
TPGeFace3D::~TPGeFace3D()
{
}
bool TPGeFace3D::IsInclude(const TGObject&obj) const
{
if(IS_CLASS(&obj,TGSolid))
{
return false;
}
else
{
return TGObject3D::IsInclude(obj);
}
}
void TPGeFace3D::Cut(const TGObject&obj,TGObjectList&left,TGObjectList&right,TGObjectList&mid) const
{
if(IS_CLASS(&obj,TPGeCurve3D))
{
const TPGeCurve3D& curve = (const TPGeCurve3D&)obj;
TGObjectList interList;
if(!Intersect(curve,interList))
{
GRelation r = HitTest(curve.GetSamplePoint());
if(r.Is(GR_UP))
{
right << curve.Clone();
}
else
{
left << curve.Clone();
}
return;
}
TSqTable<double> paList(interList.GetLength());
for(interList.MoveToFirst();!interList.IsOut();interList.MoveToNext())
{
if(IS_TYPE(interList.GetCurData(),TGPoint3D))
{
double pa;
curve.Pt2Pa((TGPoint3D&)interList.GetCurPData(),pa);
paList.AddTail(pa);
}
else
{
TGPoint pt;
double pa;
TPGeCurve3D& subCurve = interList.GetCurCurve3D();
if(subCurve.IsFinite(true))
{
subCurve.GetStartPoint(pt);
curve.Pt2Pa(pt,pa);
paList.AddTail(pa);
}
if(subCurve.IsFinite(false))
{
subCurve.GetEndPoint(pt);
curve.Pt2Pa(pt,pa);
paList.AddTail(pa);
}
}
}
TGObjectList subCurve;
if(paList.IsEmpty())
{
mid << curve.Clone();
return;
}
else
{
paList.Arrange();
curve.Split(paList,subCurve);
}
for(subCurve.MoveToFirst();!subCurve.IsOut();subCurve.MoveToNext())
{
GRelation r = HitTest(subCurve.GetCurPData().GetSamplePoint());
if(r.Is(GR_IN))
{
mid << subCurve.FetchCur();
}
else if(r.Is(GR_UP))
{
right << subCurve.FetchCur();
}
else
{
left << subCurve.FetchCur();
}
}
}
else if(IS_CLASS(&obj,TPGeFace3D))
{
}
else if(IS_CLASS(&obj,TGSolid))
{
((const TGSolid&)obj).CutBy(*this,left,right);
}
else
{
const TGPoint3D&pt=(const TGPoint3D&)obj;
GRelation r=HitTest(pt);
if(r.Is(GR_IN))
{
mid << new TGPoint3D(pt);
}
else if(r.Is(GR_UP))
{
right << new TGPoint3D(pt);
}
else
{
left << new TGPoint3D(pt);
}
}
}
bool TPGeFace3D::IsClosed() const
{
return false;
}
bool TPGeFace3D::IsSelfCross() const
{
return false;
}
double TPGeFace3D::Area() const
{
return 0;
}
double TPGeFace3D::Volume() const
{
return 0;
}