72 lines
1.8 KiB
C++
72 lines
1.8 KiB
C++
#include "StdAfx.h"
|
|
#include "GePface.h"
|
|
#include "GePolyFacet.h"
|
|
#include "globalFunc.h"
|
|
|
|
GePface::~GePface()
|
|
{
|
|
|
|
}
|
|
int GePface::Make(const TCHAR *pszLay)
|
|
{
|
|
GePolyFacet a(1,2,3);
|
|
TCHAR clayer[80] = _T("");
|
|
GlobalFunc::TGGetVar(_T("CLAYER"), clayer);
|
|
|
|
const TCHAR * layer = pszLay ? pszLay : clayer;
|
|
|
|
int vtNum = Length();
|
|
ADSGePoint3d _pt;
|
|
GlobalFunc::MakeEntity(RTDXF0, _T("POLYLINE"), 10, &_pt, 66, 1,
|
|
8, layer, 70, 64, 71, vtNum, 72, 1, NULL);
|
|
|
|
GePface &pface = *this;
|
|
for (int i = 0; i < vtNum; i++)
|
|
{
|
|
GlobalFunc::MakeEntity(RTDXF0, _T("VERTEX"), 8, layer, 10, pface[i], 70, 192, NULL);
|
|
}
|
|
|
|
int nFaceNum = faces.Length();
|
|
for (i = 0; i < nFaceNum; i++)
|
|
{
|
|
faces[i]->Make(layer);
|
|
}
|
|
|
|
return GlobalFunc::MakeEntity(RTDXF0, _T("SEQEND"), NULL);
|
|
}
|
|
|
|
GePface * ConstructPolyFace(const AcDbVoidPtrArray &entSet)
|
|
{
|
|
GePface *pMesh = new GePface;
|
|
GePface &faces = *pMesh;
|
|
int nCount = entSet.length();
|
|
for (int n = 0; n<nCount; n++)
|
|
{
|
|
AcDbEntity *pEnt = (AcDbEntity *)entSet[n];
|
|
AcDbFace *pFace = AcDbFace::cast(pEnt);
|
|
if (pFace)
|
|
{
|
|
ADSGePoint3d vertex[4];
|
|
int vertice[4];
|
|
for (int idx = 0; idx<4; idx++)
|
|
{
|
|
VERIFY(pFace->getVertexAt(idx, vertex[idx]) == Acad::eOk);
|
|
Adesk::Boolean bVis = Adesk::kTrue;
|
|
VERIFY(pFace->isEdgeVisibleAt(idx, bVis) == Acad::eOk);
|
|
vertice[idx] = faces.NewAppend(vertex[idx])+1;
|
|
if (!bVis)
|
|
{
|
|
vertice[idx] = -vertice[idx];
|
|
}
|
|
}
|
|
pMesh->faces.Append(new GePolyFacet(vertice[0], vertice[1], vertice[2], vertice[3]));
|
|
}
|
|
}
|
|
if (pMesh->Length() == 0 || pMesh->faces.Length() == 0)
|
|
{
|
|
delete pMesh;
|
|
pMesh = NULL;
|
|
}
|
|
return pMesh;
|
|
}
|