Drawings SDK provides the ExPointCloudHost example that demonstrates point cloud data loading and visualization using the RcsFileServices library from PointCloud SDK. The example is implemented as an extension module (.tx).
This example provides an implementation of the special set of interfaces declared in the Drawing\Include\DbPointCloudObj\DbPointCloudHostPE.h
header file.
The following classes work with OdDbPointCloudEx
entity:
OdDbPointCloudExItem
– abstraction of data source to use from point cloud definition to access .rcs/.rcp files while rendering;OdDbPointCloudExScanItem
– successor of OdDbPointCloudExItem representing a scan (.rcs file) attached to .dwg file;OdDbPointCloudExProjItem
– successor of OdDbPointCloudExItem representing a project (.rcp) attached to .dwg file;OdDbPointCloudExHostPE
– protocol extension to load point cloud data from .rcs/.rcp files to memory while starting the visualization process.All of these abstract interfaces implemented by ExPointCloudHost example.
Example of loading data from an .rcs file:
OdResult ExPointCloudExHostPE::loadRcs(const OdString& filename, OdDbPointCloudExItemPtr& pItem)
{
OdRxRcsFileServicesPtr pRcsFileServices;
pRcsFileServices = odrxDynamicLinker()->loadApp(RX_RCS_FILE_SERVICES);
if (!pRcsFileServices.isNull())
{
OdPointCloudScanDatabasePtr pScanDb;
try
{
pScanDb = pRcsFileServices->readRcsFile(filename);
}
catch (OdError& )
{
return eCantOpenFile;
}
ExPointCloudExScanItemPtr exItem = ExPointCloudExScanItem::createObject();
exItem->m_pScanDb = pScanDb;
exItem->m_pRcsDataMgr = pRcsFileServices->getRcsDataManager(exItem->m_pScanDb);
pItem = exItem;
return eOk;
}
else
return eCantOpenFile;
}
Example of loading data from an .rcp file:
OdResult ExPointCloudExHostPE::loadRcp(const OdString& filename, OdDbPointCloudExItemPtr& pItem)
{
OdRxRcsFileServicesPtr pRcsFileServices;
pRcsFileServices = odrxDynamicLinker()->loadApp(RX_RCS_FILE_SERVICES);
if (!pRcsFileServices.isNull())
{
OdPointCloudProjectDatabasePtr pProjDb;
try
{
pProjDb = pRcsFileServices->readRcpFile(filename);
}
catch (OdError&)
{
return eCantOpenFile;
}
ExPointCloudExProjItemPtr exItem = ExPointCloudExProjItem::createObject();
exItem->m_pProjDb = pProjDb;
exItem->m_pRcsDataMgrs.clear();
OdPointCloudScanIteratorPtr pScanIt = pProjDb->getScanIterator();
for (; !pScanIt->done(); pScanIt->step())
{
OdPointCloudScanDatabasePtr pCurScanDb = pScanIt->getScanDb();
if (!pCurScanDb.isNull())
{
OdRcsDataManagerPtr pMgr = pRcsFileServices->getRcsDataManager(pCurScanDb, exItem->m_pProjDb);
exItem->m_pRcsDataMgrs.push_back(pMgr);
}
}
pItem = exItem;
return eOk;
}
else
return eCantOpenFile;
}
Example of rendering an .rcs file (scan):
void ExPointCloudExScanItem::viewportDrawPoints(OdGiViewportDraw* pVd) const
{
if (!m_pRcsDataMgr.isNull())
{
OdDbDatabasePtr pDb = pVd->context()->database();
OdInt16 pointSize = pDb->getPOINTCLOUDPOINTSIZE();
pVd->geometry().pushModelTransform(m_pScanDb->getTransformMatrix());
OdGiPointCloudPtr pGiPointCloud = m_pRcsDataMgr->newGiPointCloud(pointSize);
pVd->geometry().pointCloud(*pGiPointCloud);
pVd->geometry().popModelTransform();
}
}
Example of rendering an .rcp file (point cloud project):
void ExPointCloudExProjItem::viewportDrawPoints(OdGiViewportDraw* pVd) const
{
OdDbDatabasePtr pDb = pVd->context()->database();
OdInt16 pointSize = pDb->getPOINTCLOUDPOINTSIZE();
OdGeMatrix3d globalTransformation = m_pProjDb->getGlobalTransformation();
pVd->geometry().pushModelTransform(globalTransformation);
OdArray::iterator pMgrIt = m_pRcsDataMgrs.begin();
for (; pMgrIt != m_pRcsDataMgrs.end(); ++pMgrIt)
{
OdRcsDataManagerPtr pCurManager = *pMgrIt;
OdPointCloudScanDatabasePtr pCurScanDb = pCurManager->getScanDb();
OdString scanId = pCurScanDb->getScanId();
OdGeMatrix3d scanTransformation = m_pProjDb->getScanTransform(scanId);
pVd->geometry().pushModelTransform(scanTransformation);
OdGiPointCloudPtr pGiPointCloud = pCurManager->newGiPointCloud(pointSize);
pVd->geometry().pointCloud(*pGiPointCloud);
pVd->geometry().popModelTransform();
}
pVd->geometry().popModelTransform();
}
Any additional info about visualizing point clouds attached to .dwg files you may find in the ExPointCloudHost sample (see Drawing/Examples/ExPointCloudHost/ExPointCloudExHostPE.cpp
).
Work with Point Cloud Definitions
Work with Point Cloud Entities
Insert a Point Cloud into a Drawing
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|