To insert a point cloud into a drawing, use the oddbCreatePointCloudExEntity()
function:
OdResult oddbCreatePointCloudExEntity(
OdDbBlockTableRecord* pBTR,
OdDbPointCloudExPtr& newPointCloud,
const OdString& sourceFile,
const OdGePoint3d& location,
double scale,
double rotation,
const OdGeVector3d& vAxis);
Here is an example of adding point cloud to a drawing (see the OdWriteEx sample application: Drawing/Examples/OdWriteEx/DbFiller.cpp
):
void DbFiller::addPointCloudEx(OdDbDatabase* pDb, const int boxRow, const int boxCol, const OdDbObjectId& layerId, const OdDbObjectId& styleId)
{
/**********************************************************************/
/* Open the BlockTableRecord */
/**********************************************************************/
OdDbObjectId blockId = pDb->getModelSpaceId();
OdDbBlockTableRecordPtr bBTR = blockId.safeOpenObject(OdDb::kForWrite);
OdGePoint3d point = m_EntityBoxes.getBox(boxRow, boxCol);
/**********************************************************************/
/* Add the label */
/**********************************************************************/
addTextEnt(bBTR, point + m_textOffset, point + m_textOffset,
OD_T("Point Cloud Ex"), m_textSize, OdDb::kTextLeft, OdDb::kTextTop, layerId, styleId);
/**********************************************************************/
/* File name for RCS file */
/**********************************************************************/
OdString rcsFileName = "bunny2.rcs";
OdGePoint3d p1, p2;
OdGeExtents3d extents(p1, p2);
OdGeVector3d translation;
if (::odSystemServices()->accessFile(rcsFileName, Oda::kFileRead))
{
/**********************************************************************/
/* Start parsing RCS file */
/**********************************************************************/
OdRxRcsFileServicesPtr pRcsFileServices;
pRcsFileServices = odrxDynamicLinker()->loadApp(RX_RCS_FILE_SERVICES);
if (!pRcsFileServices.isNull())
{
OdPointCloudScanDatabasePtr pScanDb;
pScanDb = pRcsFileServices->readRcsFile(rcsFileName);
if (!pScanDb.isNull())
{
extents = pScanDb->getTransformedExtents();
translation = pScanDb->getTranslation();
}
}
/**********************************************************************/
/* Calculate point cloud scale and center position */
/**********************************************************************/
double scale = 1;
if (extents.maxPoint().x - extents.minPoint().x != 0)
scale = m_EntityBoxes.getWidth(boxRow, boxCol) / (extents.maxPoint().x - extents.minPoint().x);
OdGePoint3d location = m_EntityBoxes.getBoxCenter(boxRow, boxCol);
translation = location.asVector() - translation * scale;
location.set(translation.x, translation.y, translation.z);
/**********************************************************************/
/* Load point cloud module */
/**********************************************************************/
OdRxModulePtr pPointCloudModule = ::odrxDynamicLinker()->loadApp(DbPointCloudObjModuleName);
if (!pPointCloudModule.isNull())
{
/**********************************************************************/
/* Create point cloud entity */
/**********************************************************************/
OdDbPointCloudExPtr pPointCloud;
oddbCreatePointCloudExEntity(bBTR, pPointCloud, rcsFileName, location, scale);
}
}
}
Work with Point Cloud Definitions
Work with Point Cloud Entities
Point Clouds Visualization and RCS/RCP File Formats
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|