Close

Relief for ODA Team in Ukraine

Learn more
ODA IFC SDK
Access to Representation Body Geometry

Representation Geometry Implementation in IFC SDK

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.

Retrieve the Representation Body from a IFC File

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).

  1. Check whether the provided smart pointer to the OdIfcFile object is valid:
              
    if (pIfcFile.isNull()) 
    {
      return;
    }
              
            
  2. Get the file model and proceed with its validation:
              
    OdIfcModelPtr pModel = pIfcFile->getModel();
    
    if (pModel.isNull()) 
    {
      return;
    }
              
            
  3. Retrieve all products from the model:
              
    OdDAI::OdDAIObjectIdSet* productIdSet = pModel->getEntityExtent("IfcProduct");
    if (!productIdSet) {
      return;
    }
              
            
  4. Convert the set of products identifiers available via a raw pointer into an array of identifiers:
              
    const OdDAIObjectIds& productIds = productIdSet->getArray();
              
            
  5. Iterate through the products array:
              
    for (OdDAIObjectIds::size_type iProduct = 0; iProduct < productIds.size(); ++iProduct)
    {
      
    }
              
            

    Fill the body of the cycle through the products with the following actions:

    1. Open the entity referenced by the current identifier:
                    
      OdIfc::OdIfcEntityPtr pEntity = productIds[iProduct].openObject();
      if (pEntity.isNull()) 
      {
        continue;
      }
                    
                  
    2. Retrieve the product object from the entity if available:
                    
      OdIfc::OdIfcProductPtr pProduct = OdIfc::OdIfcEntity::asCompound(pEntity);
      if (pProduct.isNull()) 
      {    
        continue;
      }
                    
                  
    3. Get geometry items from the product object:
                    
      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.

    4. Iterate the geometry items:
                    
      for (OdDAIObjectIds::size_type iItem = 0; iItem < geomItems.size(); ++iItem)
      {
      
      }
                    
                  

      The body of the cycle above contains the following actions:

      1. Get the representation body from the current geometry item:
                          
        OdIfc::OdIfcGeometricRepresentationItemPtr pGeomItem = geomItems[iItem];
        OdDAI::OdBodyVariant bodyContainer = pGeomItem->bodyContainer();
                          
                        
      2. Analyze the type of the representation body and process it with an appropriate function call:
                          
        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.

See Also

Export IFC Content to a .dwg Database

Data Access Mechanisms in IFC SDK

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.