With the ODA Platform you can work with solids and shells using boundary representations, or B-Reps. In ODA Drawings (for working with both .dwg and .dgn files), ODA PRC, and ODA BimRv, 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* methods (addFace, addEdge, etc.). Examples can be found in:
- BimRv/Examples/TB_DevGuideCommands/BmFreeFormElemCmd.cpp
- CommonApplications/Prc/Examples/OdPrcBrepBuilderEx/Box.cpp
- CommonApplications/Prc/Examples/OdPrcBrepBuilderEx/ComplexPlane.cpp
- CommonApplications/Prc/Examples/OdPrcBrepBuilderEx/Cone.cpp
- CommonApplications/Prc/Examples/OdPrcBrepBuilderEx/Cylinder.cpp
- CommonApplications/Prc/Examples/OdPrcBrepBuilderEx/Sphere.cpp
- Drawing/Examples/ExCustObjs/ExCreateBreps.cpp
- Drawing/Examples/OdWriteEx/DbFiller.cpp
Or you can use an existing B-Rep and OdBrepBuilderFiller. The OdBrepBuilderFiller is the core extension module. It traverses a B-Rep and collects topology and visual information. Then the module puts data into the builder.
To use the OdBrepBuilderFiller:
- Add the include header:
#include "BrepBuilderFillerModule.h""
- 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 OdError(err); }
- Initialize a B-Rep. For example:
OdDbSurface* pSurf; … OdBrBrep brep; pSurf->brep(brep);
- Create the OdBrepBuilderFiller:
OdBrepBuilderFiller bbFiller;
Note: The filler stores geometry referenced by the builder. So the filler should exist when you call builder.finish().
- Initialize the filler parameters, which can be done in different ways:
- This variant is useful when you need to handle materials and colors:
bbFiller.params().setupFor(pDbOfBrep, pDbOfBuilder);
- The DGN format supports both Parasolid and ACIS B-Rep topology. So setupFor cannot determine the topology type. To determine the B-Rep topology format:
OdDgModelerGeometry* pModeler; … OdDgModelerGeometry::OdDgModelerVersion modelerVersion = 0; OdResult err = pModeler->comeFromVersion(modelerVersion); if (eOk != err) { throw OdError(err); } OdBrepBuilderFillerParams::BrepType brepType = (modelerVersion & OdDgModelerGeometry::kAcisMask) ? OdBrepBuilderFillerParams::kBrepAcisDgn : OdBrepBuilderFillerParams::kBrepPS; bbFiller.params().setupFor(pDbOfBrep, brepType, pDbOfBuilder);
- You can also manually set the topology format. For example:
bbFiller.params().setupFor(OdBrepBuilderFillerParams::kBrepAcisDwg, OdBrepBuilderFillerParams::kBrepAcisDgn);
Also you can directly set options of the filler by calling OdBrepBuilderFillerParams::set* methods. These options are needed because different B-Rep topology can have their own rules.
Note: The setupFor method resets options of the filler to default values specific for database conversion. So you need to call setupFor before all set* calls.
- This variant is useful when you need to handle materials and colors:
- Use a helper class OdBaseMaterialAndColorHelper to handle materials when you convert a B-Rep within the same database:
OdBaseMaterialAndColorHelper materialHelper;
Note: Provide databases in the filler parameters.
Also, OdBaseMaterialAndColorHelper has a simple mechanism for caching earlier created materials. So an instance of OdBaseMaterialAndColorHelper should be used within the same database pair. Conversion between different databases is somewhat complicated. You may need to override some methods of OdBaseMaterialAndColorHelper.
- To initialize the builder, use the method initFrom:
OdResult err = bbFiller.initFrom(builder, brep, &materialHelper); if (eOk != err) { throw OdError(err); }