In Teigha you can work with solids and shells using boundary representations, or B-Reps. In different Teigha products, Teigha Drawings (for working with both .dwg and .dgn files), Teigha PRC, and Teigha BIM, there are separate implementations of B-Rep interfaces, but you can work with them using the common class OdBrBrep.
A B-Rep can be created with the help of the appropriate BrepBuilder. Builders are wrapped by the common class OdBrepBuilder just like a B-Rep.
You can fill the builder manually by calling add* functions (addFace, addEdge, etc.). Or you can get an existing B-Rep using OdBrepBuilderFillerModule.
The OdBrepBuilderFillerModule is the core extension module. It traverses a B-Rep and collects topology and material information. Then the module puts data into the builder.
To use B-Reps:
- Add the include header:
#include "BrepBuilderFillerModule.h"
- For static builds, add a declaration of the module:
#ifndef _TOOLKIT_IN_DLL_ ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdBrepBuilderFillerModule); ODRX_BEGIN_STATIC_MODULE_MAP() ODRX_DEFINE_STATIC_APPMODULE(OdBrepBuilderFillerModuleName, OdBrepBuilderFillerModule) ODRX_END_STATIC_MODULE_MAP() #endif
- Set up the implementation of OdBrepBuilder using the method brepBuilder of the host app service instance. For example:
OdDbHostAppServices* pHostApp; … OdBrepBuilder builder; OdResult err = pHostApp->brepBuilder(builder, kOpenShell); if (eOk != err) { throw err; }
- Load the module:
OdBrepBuilderFillerModulePtr pFillerModule = ::odrxDynamicLinker()->loadModule(OdBrepBuilderFillerModuleName, false);
- To handle materials, use a helper structure (its fields are optional):
OdMaterialHelper materialHelper; materialHelper.pDefaultMaterial = ...; materialHelper.pMaterialResolver = ...; materialHelper.pGiContext = ...;
- Because the builder does not own geometry data, you have to store this data while you use the builder:
OdGeCurve3dPtrArray arrEdges; OdGeCurve2dPtrArray arrCoedges; OdGeSurfacePtrArray arrSurfaces;
- To initialize the builder, use the method initFrom:
OdResult err = pFillerModule->initFrom(builder, brep, arrEdges, arrCoedges, arrSurfaces, materialHelper)); if (eOk != err) { throw err; }