//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
#include <dbobjptr2.h>
#include <omp.h>
//-----------------------------------------------------------------------------
#define szRDS _RXST("")
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CAddDynamicPropertyApp : public AcRxArxApp {
public:
CAddDynamicPropertyApp() : AcRxArxApp() {}
virtual AcRx::AppRetCode On_kInitAppMsg(void *pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg(pkt);
return (retCode);
}
virtual AcRx::AppRetCode On_kUnloadAppMsg(void *pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kUnloadAppMsg(pkt);
return (retCode);
}
virtual void RegisterServerComponents() { }
static void RivilisTestAcDbAcGe() {
ads_name en; ads_point p;
while (acedEntSel(L"\nВыберите мультилинию", en, p) == RTNORM)
{
AcDbObjectId id; acdbGetObjectId(id, en);
if (!id.objectClass()->isDerivedFrom(AcDbMline::desc()))
{
acutPrintf(L"\nЭто не мультилиния! Повторите выбор.");
continue;
}
AcDbSmartObjectPointer<AcDbMline> pMline(id, AcDb::kForRead);
if (pMline.openStatus() == Acad::eOk)
{
AcGePoint3dArray pts;
for (int i = 0; i < pMline->numVertices(); i++) pts.append(pMline->vertexAt(i));
AcGePoint3dArray ptsAxis1;
double d_start = omp_get_wtime();
for (int i = 0; i < 1000; i++) GetAcDb(ptsAxis1, pts);
acutPrintf(L"\nTime AcDb = %g", omp_get_wtime() - d_start);
AcGePoint3dArray ptsAxis2;
d_start = omp_get_wtime();
for (int i = 0; i < 1000; i++) GetAcGe(ptsAxis2, pts);
acutPrintf(L"\nTime AcGe = %g", omp_get_wtime() - d_start);
for (int i = 0; i < min(ptsAxis1.length(), ptsAxis2.length()); i++)
{
acutPrintf(L"\nDist[%d]=%g", i, (ptsAxis1[i]-ptsAxis2[i]).length());
}
break;
}
}
}
static void GetAcDb(AcGePoint3dArray &ptsAxis, AcGePoint3dArray &pts)
{
AcDbPolyline poly(pts.length() + 1);
for (int i = 0; i < pts.length(); i++)
{
AcGePoint2d p(pts[i].x, pts[i].y);
poly.addVertexAt(i, p);
}
ptsAxis.setLogicalLength(0); ptsAxis.setPhysicalLength(100);
double pEnd = 0, pLength = 0;
poly.getEndParam(pEnd); poly.getDistAtParam(pEnd, pLength);
for (double d = 0; d < pLength; d += pLength * 0.01)
{
AcGePoint3d p; poly.getPointAtDist(d, p);
ptsAxis.append(p);
}
}
static void GetAcGe(AcGePoint3dArray &ptsAxis, AcGePoint3dArray &pts)
{
AcGePolyline3d poly(pts);
ptsAxis.setLogicalLength(0); ptsAxis.setPhysicalLength(100);
double pLength = poly.length(poly.startParam(), poly.endParam());
for (double d = 0; d < pLength; d += pLength * 0.01)
{
ptsAxis.append(poly.evalPoint(poly.paramAtLength(0, d)));
}
}
};
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CAddDynamicPropertyApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CAddDynamicPropertyApp, Rivilis, TestAcDbAcGe, TestAcDbAcGe, ACRX_CMD_MODAL, NULL)