You can create an element that has a free form. It can be a sphere, a torus, a single face, etc. A free form element that contains non-parametric geometry is created from an input solid outline. The element can be either solid or void.
To create a free form element, use the OdBmFreeFormElement class. The OdBmFreeFormElementPtr class is the typified smart pointer to an instance of the free form element and is used for storing and passing references to the free form element.
Currently this is the only way to create elements with geometry in ODA BimRv SDK.
To create an instance of a free form element, use the OdBmFreeFormElement::createObject() method which is the static pseudo-constructor. For example:
OdBmFreeFormElementPtr pFreeFormElement = OdBmFreeFormElement::createObject();
To set a form to this element, geometry should be applied; use OdBmFreeFormElement::createGeometry(OdBmGeometryPtr). For example:
// Create a FreeFormElement
OdBmFreeFormElementPtr pFreeFormElement = OdBmFreeFormElement::createObject();
You can use the geometry of an existing element, such as a basepoint, and modify it as needed by changing its faces, edges and points.
Another variant is to create geometry using the OdBrepBuilder class. For example, to create the geometry of a pyramid and return its geometry:
OdBmGeometryPtr createPyramid(OdBmHostAppServices* app)
{
// create a OdBrepBuilder;
BrepType bbType = kOpenShell;
OdBrepBuilder brep;
app->brepBuilder(brep, bbType);
// Set the points of the pyramid
OdGePoint3d pnt_1(10, 20, 0);
OdGePoint3d pnt_2(70, 20, 0);
OdGePoint3d pnt_3(40, 50, 0);
OdGePoint3d pnt_4(40, 30, -10);
// Create Planes
OdSharedPtr <OdGePlane> pPlane_Bottom = BmBrepBuilderGeometryCreatorHelper::createPlane(pnt_1, pnt_2, pnt_3);
OdSharedPtr <OdGePlane> pPlane_Front = BmBrepBuilderGeometryCreatorHelper::createPlane(pnt_4, pnt_2, pnt_1);
OdSharedPtr <OdGePlane> pPlane_Left = BmBrepBuilderGeometryCreatorHelper::createPlane(pnt_4, pnt_1, pnt_3);
OdSharedPtr <OdGePlane> pPlane_Right = BmBrepBuilderGeometryCreatorHelper::createPlane(pnt_4, pnt_3, pnt_2);
// Add Faces
BRepBuilderGeometryId faceId_Bottom = brep.addFace(pPlane_Bottom, OdBrepBuilder::kForward);
BRepBuilderGeometryId faceId_Front = brep.addFace(pPlane_Front, OdBrepBuilder::kForward);
BRepBuilderGeometryId faceId_Left = brep.addFace(pPlane_Left, OdBrepBuilder::kForward);
BRepBuilderGeometryId faceId_Right = brep.addFace(pPlane_Right, OdBrepBuilder::kForward);
// Create Edges
// Bottom edges
OdSharedPtr <OdGeLineSeg3d> edge_BottomFront = BmBrepBuilderGeometryCreatorHelper::createLine(pnt_1, pnt_2);
OdSharedPtr <OdGeLineSeg3d> edge_BottomRight = BmBrepBuilderGeometryCreatorHelper::createLine(pnt_2, pnt_3);
OdSharedPtr <OdGeLineSeg3d> edge_BottomLeft = BmBrepBuilderGeometryCreatorHelper::createLine(pnt_3, pnt_1);
// Side edges
OdSharedPtr <OdGeLineSeg3d> edge_Right = BmBrepBuilderGeometryCreatorHelper::createLine(pnt_2, pnt_4);
OdSharedPtr <OdGeLineSeg3d> edge_Left = BmBrepBuilderGeometryCreatorHelper::createLine(pnt_1, pnt_4);
OdSharedPtr <OdGeLineSeg3d> edge_Back = BmBrepBuilderGeometryCreatorHelper::createLine(pnt_3, pnt_4);
// Add Edges
// Bottom edges
BRepBuilderGeometryId edgeId_BottomFront = brep.addEdge(edge_BottomFront.get());
BRepBuilderGeometryId edgeId_BottomRight = brep.addEdge(edge_BottomRight.get());
BRepBuilderGeometryId edgeId_BottomLeft = brep.addEdge(edge_BottomLeft.get());
// Side edges
BRepBuilderGeometryId edgeId_Right = brep.addEdge(edge_Right.get());
BRepBuilderGeometryId edgeId_Back = brep.addEdge(edge_Back.get());
BRepBuilderGeometryId edgeId_Left = brep.addEdge(edge_Left.get());
// Add Loops
BRepBuilderGeometryId loopId_Bottom = brep.addLoop(faceId_Bottom);
BRepBuilderGeometryId loopId_Front = brep.addLoop(faceId_Front);
BRepBuilderGeometryId loopId_Left = brep.addLoop(faceId_Left);
BRepBuilderGeometryId loopId_Right = brep.addLoop(faceId_Right);
// Add Coedge
// Bottom face
brep.addCoedge(loopId_Bottom, edgeId_BottomFront, OdBrepBuilder::kForward);
brep.addCoedge(loopId_Bottom, edgeId_BottomRight, OdBrepBuilder::kForward);
brep.addCoedge(loopId_Bottom, edgeId_BottomLeft, OdBrepBuilder::kForward);
// Front Face
brep.addCoedge(loopId_Front, edgeId_Right, OdBrepBuilder::kReversed);
brep.addCoedge(loopId_Front, edgeId_BottomFront, OdBrepBuilder::kReversed);
brep.addCoedge(loopId_Front, edgeId_Left, OdBrepBuilder::kForward);
// Left face
brep.addCoedge(loopId_Left, edgeId_Left, OdBrepBuilder::kReversed);
brep.addCoedge(loopId_Left, edgeId_BottomLeft, OdBrepBuilder::kReversed);
brep.addCoedge(loopId_Left, edgeId_Back, OdBrepBuilder::kForward);
// Right face
brep.addCoedge(loopId_Right, edgeId_Back, OdBrepBuilder::kReversed);
brep.addCoedge(loopId_Right, edgeId_BottomRight, OdBrepBuilder::kReversed);
brep.addCoedge(loopId_Right, edgeId_Right, OdBrepBuilder::kForward);
// Return geometry of the pyramid
return brep.finish();
}
To see how to create faces and edges, see Overview of B-Rep in .rfa/.rvt Files.
To see the full sample find Examples/TB_DevGuideCommands/BmFreeFormElemCmd sample command inside your ODA BimRv SDK installation folder.
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|