A ray is a parametric entity that specifies a straight line beginning at a point and continuing to infinity in world space. The OdDbRay class is a ray object that represents the interface for accessing a ray entity and manipulating its properties. The OdDbRayPtr class is the typified smart pointer to an instance of the ray entity and is used for storing and passing references to the ray object.
To create an instance of the ray object, use the createObject() method of the OdDbRay class that is the static pseudo-constructor. For example:
OdDbRayPtr pRay = OdDbRay::createObject();
The pseudo-constructor initializes the properties of a new instance using default values. After creating, the new instance must be added in model space, paper space, or a block using the appendOdDbEntity() method. The database associates the object ID with the ray instance. In examples, the pDb variable stores a pointer to the database object. For example:
// Add in the block
OdDbBlockTablePtr pBlocks = pDb->getBlockTableId().safeOpenObject(OdDb::kForRead);
OdDbBlockTableRecordPtr pBlock = pBlocks->getAt(L"BLOCK", OdDb::kForWrite)
OdDbObjectId idRay = pBlock->appendOdDbEntity(pRay);
// Add in the model space
OdDbBlockTableRecordPtr pModel = pDb->getModelSpaceId().safeOpenObject(OdDb::kForWrite);
pModel->appendOdDbEntity(pRay);
// Add in the paper space
OdDbBlockTableRecordPtr pPaper = pDb->getPaperSpaceId().safeOpenObject(OdDb::kForWrite);
pPaper->appendOdDbEntity(pRay);
The OdDbRay class is derived from the OdDbCurve class and inherits the common properties of parametric curves. The OdDbCurve class is derived from the OdDbEntity class, therefore the OdDbRay class also inherits the general properties of entities. A pointer to a ray object can be converted to an entity object or a curve object. For example:
OdDbEntityPtr pEntity = pRay;
OdDbCurvePtr pCurve = pRay;
The ray object has the AcDbRay class name. To verify an instance, use the isKindOf() and desc() methods. For example:
// Accurate comparing
if(pEntity->isA() == OdDbRay::desc())
odPrintConsoleString(L"\nEntity is the ray");
// Check on belonging
if(pEntity->isKindOf(OdDbRay::desc()))
odPrintConsoleString(L"\nEntity is derived from the ray object");
Example of Working with the Ray Object
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|