IFC SDK provides access to internal representation of body geometry and topology through the
OdDAI::OdBodyVariant
class.
Each OdDAI::OdBodyVariant
class instance contains a raw pointer to a representation item body of
an OdIfcProduct
object.
The body object is created by the and OdIfcModelerGeometry
class instance.
Some bodies are stored as an IfcBrepBuilder
body. Such bodies returned as an OdBrBrep
object.
When the IfcFacetModeler
is used with the IfcBrepModelerPE
protocol extension,
some of the bodies are represented with the OdMdBody
objects.
For access to work with representation bodies functionality, you need to add the following public headers:
#include "IfcFile.h"
#include "IfcModel.h"
#include "Entities/IfcProduct.h"
#include "Entities/IfcGeometricRepresentationItem.h"
To get the representation body geometry from a given IFC file, use the routine described below.
It is assumed that you have a smart pointer to an OdIfcFile
object (represented with the pIfcFile
variable).
OdIfcFile
object is valid:
if (pIfcFile.isNull())
{
return;
}
OdIfcModelPtr pModel = pIfcFile->getModel();
if (pModel.isNull())
{
return;
}
OdDAI::OdDAIObjectIdSet* productIdSet = pModel->getEntityExtent("IfcProduct");
if (!productIdSet) {
return;
}
const OdDAIObjectIds& productIds = productIdSet->getArray();
for (OdDAIObjectIds::size_type iProduct = 0; iProduct < productIds.size(); ++iProduct)
{
}
Fill the body of the cycle through the products with the following actions:
OdIfc::OdIfcEntityPtr pEntity = productIds[iProduct].openObject();
if (pEntity.isNull())
{
continue;
}
OdIfc::OdIfcProductPtr pProduct = OdIfc::OdIfcEntity::asCompound(pEntity);
if (pProduct.isNull())
{
continue;
}
const OdIfc::OdIfcGeometricRepresentationItemPtrArray geomItems = pProduct->getGeometricRepresentationItems();
Please note that the resulted array of smart pointers may be empty in the case when the product object does not contain any geometry item.
for (OdDAIObjectIds::size_type iItem = 0; iItem < geomItems.size(); ++iItem)
{
}
The body of the cycle above contains the following actions:
OdIfc::OdIfcGeometricRepresentationItemPtr pGeomItem = geomItems[iItem];
OdDAI::OdBodyVariant bodyContainer = pGeomItem->bodyContainer();
switch (bodyContainer.kind())
{
case OdDAI::OdBodyVariant::kFacetModelerBody:
{
handleFacetModelerBody(bodyContainer.facetModelerBody());
break;
}
case OdDAI::OdBodyVariant::kMdBody:
{
handleBrepModelerBody(bodyContainer.mdBody());
break;
}
case OdDAI::OdBodyVariant::kAcisBody:
{
handleAcisModelerBody(bodyContainer.acisBody());
break;
}
case OdDAI::OdBodyVariant::kIfcBrep:
{
handleIfcBrep(bodyContainer.ifcBrep());
break;
}
}
Pay your attention that the bodyContainer
method can return a container that does not contain a body.
It happens when, for example, an underlying geometry item is a curve object.
You can see the full code source described above in a separate document.
Export IFC Content to a .dwg Database
Data Access Mechanisms in IFC SDK
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|