我参考了以下阅读PCG点数。
acdbProcessPointCloudData 的状态为 eOk,但未从处理器获取任何点。谁能帮我解决我可能做错的事情。
我低于例外
acad.exe 中的 0x00007FFDA06BBBA4 (mscordacwks.dll) 抛出异常:0xC0000005:访问冲突读取位置 0x0000000000000000.
------------------
void searchPcg()
{
ads_name sset;
if (acedSSGet(_T("_X"), NULL, NULL, NULL, sset) != RTNORM) {
acutPrintf(_T("\nacedSSGet has failed"));
return;
}
ads_name ename;
if (acedSSName(sset, 0, ename) != RTNORM) {
acedSSFree(sset);
return;
}
acedSSFree(sset);
AcDbObjectId objId;
acdbGetObjectId(objId, ename);
AcDbEntity *pEnt;
acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);
AcGePoint3d minp(-16.2341, 13.5081, -3.0741);
AcGePoint3d maxp(8.8861, 26.2551, 1.1911);
const AcDbExtents ext(minp, maxp);
IAcPcDataBuffer* bfr = new AcPcDataBuffer();
IAcPcPointFilter* flt = new AcPcPointFilter();
IAcPcPointProcessor* proc = new AcPcPointProcessor(bfr, flt);
Acad::ErrorStatus res = acdbProcessPointCloudData(pEnt, ext, 100, proc);
auto x = proc->buffer()->size();
}
//AcPcPointProcessor-----------------------------------
#pragma once
#include <Windows.h>
#include <stdlib.h>
#include <aced.h>
#include <dbsymtb.h>
#include <dbapserv.h>
#include <adslib.h>
#include "tchar.h"
#include <AcPointCloud.h>
#include <AcDbPointCloudEx.h>
#include <AcDbPointCloudApi.h>
#include <dbobjptr.h>
#include <gearc3d.h>
#include <rxobject.h>
#include <rxregsvc.h>
#include <gemat3d.h>
#include "AcPcDataBuffer.h"
#include "AcPointCloudFilter.h"
class ACDB_PORT AcPcPointProcessor : public IAcPcPointProcessor
{
private:
IAcPcDataBuffer* mpBuffer;
bool bCancel;
IAcPcPointFilter* ptFilter;
public:
AcPcPointProcessor(IAcPcDataBuffer *bfr, IAcPcPointFilter* flt)
{
this->bCancel = false;
this->setBuffer(bfr);
this->ptFilter = flt;
}
~AcPcPointProcessor()
{
if (this->buffer())
delete this->buffer();
}
bool cancel() { return false; }
void abort() {}
void finished()
{
}
bool processPoints()
{
return true;
}
IAcPcPointFilter* filter()
{
if (ptFilter)
return this->ptFilter;
else
return NULL;
}
IAcPcDataBuffer* buffer()
{
return(mpBuffer);
}
void setBuffer(IAcPcDataBuffer* buffer)
{
mpBuffer = buffer;
}
};
//AcPcDataBuffer -----------------------------------
#pragma once
#include <Windows.h>
#include <stdlib.h>
#include <aced.h>
#include <dbsymtb.h>
#include <dbapserv.h>
#include <adslib.h>
#include "tchar.h"
#include <AcPointCloud.h>
#include <AcDbPointCloudEx.h>
#include <AcDbPointCloudApi.h>
#include <dbobjptr.h>
#include <gearc3d.h>
#include <rxobject.h>
#include <rxregsvc.h>
#include <gemat3d.h>
#include <vector>
class ACDB_PORT AcPcDataBuffer : public IAcPcDataBuffer
{
public:
AcPcDataBuffer()
{
}
AcPcPointAttributes* pointAttributes()
{
return(NULL);
}
bool nativeDbl()
{
return true;
}
bool resize(DWORD size)
{
try
{
this->AcPcPointDoubleArray.resize(size);
}
catch (...)
{
return false;
}
return true;
};
bool shrink(DWORD size)
{
try
{
this->AcPcPointDoubleArray.shrink_to_fit();
}
catch (...)
{
return false;
}
return true;
}
DWORD size() const
{
return (DWORD)this->AcPcPointDoubleArray.size();
}
AcPcPointFloat* floatPoints() { return NULL; }
AcPcPointDouble* doublePoints()
{
return &this->AcPcPointDoubleArray[0];
}
bool floatPoint(DWORD ptIx, AcPcPointFloat& pt) const
{
if (ptIx < this->AcPcPointDoubleArray.size())
{
pt = (AcPcPointFloat&)this->AcPcPointDoubleArray[ptIx];
return true;
}
return false;
}
bool doublePoint(DWORD ptIx, AcPcPointDouble& pt) const
{
if (ptIx < this->AcPcPointDoubleArray.size())
{
pt = this->AcPcPointDoubleArray[ptIx];
return true;
}
return false;
}
bool setFloatPoint(DWORD ptIx, AcPcPointFloat& pt)
{
if (ptIx < this->AcPcPointDoubleArray.size())
{
this->AcPcPointDoubleArray[ptIx] = (AcPcPointDouble&)pt;
return true;
}
return false;
}
bool setDoublePoint(DWORD ptIx, AcPcPointDouble& pt)
{
if (ptIx < this->AcPcPointDoubleArray.size())
{
this->AcPcPointDoubleArray[ptIx] = pt;
return true;
}
return true;
}
bool offset(double& x, double& y, double& z) const
{
return true;
}
bool entityTransform(AcGeMatrix3d& matrix) const
{
return true;
}
void copyFrom(IAcPcDataBuffer const & from)
{
this->AcPcPointDoubleArray.clear();
AcPcPointDouble temp;
for (DWORD i = 0; i < from.size(); i++)
{
from.doublePoint(i, temp);
this->AcPcPointDoubleArray.push_back(temp);
}
}
public:
std::vector<AcPcPointDouble> AcPcPointDoubleArray;
};
//AcPcPointFilter -----------------------------------
#pragma once
#include <Windows.h>
#include <stdlib.h>
#include <aced.h>
#include <dbsymtb.h>
#include <dbapserv.h>
#include <adslib.h>
#include "tchar.h"
#include <AcPointCloud.h>
#include <AcDbPointCloudEx.h>
#include <AcDbPointCloudApi.h>
#include <dbobjptr.h>
#include <gearc3d.h>
#include <rxobject.h>
#include <rxregsvc.h>
#include <gemat3d.h>
class ACDB_PORT AcPcPointFilter : public IAcPcPointFilter
{
public:
AcPcPointFilter()
{
}
void doFilter(const IAcPcDataBuffer& inBuffer, IAcPcDataBuffer& outBuffer)
{
}
};
请帮助我如何从PCG点云中获取积分
提前谢谢你!