Files
envi-code/SourceCode/Code2026/tg_shs/shs_geLib/TGGeTrianglePface.cpp
T
2026-09-28 15:28:50 +08:00

110 lines
2.1 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TGGeTrianglePface Àà
// = Version : ver2.0
// = Author : wlw
// = CreateDate : 2002-09-09
// = Description: TGGeTrianglePface ÀàÉùÃ÷
// = Maintainers:
//
//-----------------------------------------------------------------------------+
#include "StdAfx.h"
#include "TGGeTrianglePface.h"
#include "TADSGePoint3d.h"
#include "TGGePolyFacet.h"
#include "TGGePface.h"
#include "TchGlobalFunc.h"
TGGeTrianglePface::~TGGeTrianglePface()
{
}
int TGGeTrianglePface::MakeSolid(const TCHAR *pszLay)
{
TCHAR szLayer[80] = _T("");
if (pszLay)
{
_tcscpy(szLayer, pszLay);
}
else
{
TGGetVar(_T("CLAYER"), szLayer);
}
int nLen = Length();
int nRet = RTERROR;
for (int i = 0; i < nLen; i++)
{
TGGeTriangle *pTri = (*this)[i];
nRet = MakeEntity(RTDXF0, _T("SOLID"), 8, szLayer, 10, &pTri->vertex1, 11, &pTri->vertex2,
12, &pTri->vertex3, 13, &pTri->vertex3, NULL);
}
return nRet;
}
// ´´½¨ Pface
int TGGeTrianglePface::MakePolyface(const TCHAR *pszLay)
{
TGGePface pface;
int nLen = Length();
for (int i = 0; i < nLen; i++)
{
TGGeTriangle *pTri = (*this)[i];
int nIndex1, nIndex2, nIndex3;
if (pface.FindPoint(pTri->vertex1))
{
nIndex1 = pface.CurPosition()+1;
}
else
{
pface.Append(new TADSGePoint3d(pTri->vertex1));
nIndex1 = pface.Length();
}
if (pface.FindPoint(pTri->vertex2))
{
nIndex2 = pface.CurPosition() + 1;
}
else
{
pface.Append(new TADSGePoint3d(pTri->vertex2));
nIndex2 = pface.Length();
}
if (pface.FindPoint(pTri->vertex3))
{
nIndex3 = pface.CurPosition() + 1;
}
else
{
pface.Append(new TADSGePoint3d(pTri->vertex3));
nIndex3 = pface.Length();
}
if (pTri->m_nFlag & SIDE1_INVISIBLE)
{
nIndex1 = -nIndex1;
}
if (pTri->m_nFlag & SIDE2_INVISIBLE)
{
nIndex2 = -nIndex2;
}
if (pTri->m_nFlag & SIDE3_INVISIBLE)
{
nIndex3 = -nIndex3;
}
pface.faces.Append(new TGGePolyFacet(nIndex1, nIndex2, nIndex3));
}
return pface.Make(pszLay);
}