PART II – How 3D Models are Stored in DWG. —– Tech Tips: Creating 3D models with Teigha Platform
Guest post by Alexander Spivakov, mathematician and programmer at C3D Labs
As a rule, swept bodies are included in the list of the operations’ operands. A swept body is constructed using two curves: the sweep contour and the sweeping path. When it comes to the sweeping path, of particular importance is the straight line and the circular arc, as well as the extrusion and revolution bodies that correspond to them.
Teigha provides the following functions to create sweeping bodies:
OdResultextrude(const OdDbRegion* region, double height, double taper, bool isSolid = true);
OdResultrevolve(const OdDbRegion* pRegion, const OdGePoint3d&axisPoint, const OdGeVector3d&axisDir, double angleOfRevolution);
OdResultextrudeAlongPath(const OdDbRegion* region, const OdDbCurve* path, double taperAngle = 0.0, bool isSolid = true);
I’d like to draw your attention to an interesting feature of API: it has a cone parameter that is responsible for the smooth scaling of the swept contour along the extrusion path.
There are other ways to create bodies but, without mentioning them, in my view the power of the extended CSG is clear. It’s an impressive tool for creating bodies with complex shapes. Moreover, the formalized constructive geometry can become the basis for storing models in the form in which they were created by designers.
It might seem that constructive representation has very serious advantages over the boundary one. The way, how to generate topological elements during the design process isn’t clear unlike direct construction from simple enough primitives. But the fact is that for description of bodies’ shape boundary representation was selected. In this regard, an important aspect of 3D modeling must be mentioned: the possibility of controlled modification of the body shape.
Modifying 3D Models with the Help of Teigha
Describing3D bodies using Constructive Solid Geometry (CSG) involves significant difficultyin modifying the shape of the bodies. Yet the need for modifications arisesas design is an iterative process. The reasons for model revision are extensive: new calculations, results from prototype testing, customer feedback, design improvements, and so on. Indeed, even the transition to a different manufacturing method can require changes to the shapes of parts. For these reasons, the modeler and CAD applications should allow changes to the body shape to be made easily.
The weak point of structured geometry in CSG is its need to take into account the interdependence of all properties of all original operands of Boolean operations — or at least some of them. This is a special task for which commercial products are available. (They are known parametric kernels but are usually used to solve different design problems.) In addition, you may have to take into account the interdependence of the parameters of the original bodies and the set itself.
Fillets, Chamfers, and Thin-walled Bodies
The operation of filleting the corners of a parallelepiped is an example of a problem where the parameters of many bodies must be changed in a consistent way.
Filleting can be considered a local operation in the sense that the modification of the body occurs near the selected edges. Operations that are used to create chamfers and thin-walled bodies can also be considered local.
The chamfer operation is similar to the fillet operation, the difference being that the surface between the faces adjacent to the edges is not mated tangentially but at a specified angle.
Operations to create thin-walled bodies are based not on edges, but on faces. One face is removed from the shell, and the remaining ones are offset by the distance specified. Afterwards, the offset faces are “glued” to the faces relative to the distance they were offset.
Note that this is an incomplete list of geometric modeling operations.
Implementing Geometric Modeling Operations in Teigha
Modeling itself is not the primary purpose of the Teigha platform; it is designed to work with DWG files.So the Teigha platform includes functionsfor creating only elementary bodies. All other operations must be sourcedfrom thirdparties, and are attached to the platform through modules called “adapters.”
When it comes to 3D solid modeling, the role of adapters is to get SAT streams from files, create source bodies, execute operations with specified parameters, and then generate SAT streamsof the results.
Until recently, 3D modeling operations in Teigha could be performed with only the ACIS geometric kernel from Dassault Systemes Spatial. The Open Design Alliance supports a module that mates Teigha to the ACIS kernel, but the ACIS modeler itself must be licensed by each ODA member independently.
An alternative to ACIS is to use the modeling module from C3D Labs, which can be licensed directly from ODA, in one click from member portal – you no need to sign agreements with C3D Labs, and there is no royalty – just annual fee. The functionality of C3D Modeler for Teigha is reduced from the original C3D Toolkit, but it’s enough for most tasks of developers, and we are ready to increase it on customers requests.
As the SAT format is not native to the C3D geometric kernel (unlike ACIS), a converter must be used with the modeler. Fortunately, the process of converting input data and modeling results is hidden from Teigha users, and so attaching the C3D Modeler to the Teigha module is sufficient to make non-trivial modeling operationsavailable. Further, the full C3D Toolkit libraries can be downloaded from the Open Design Alliance’s server, and you can request a license key via your personal ODA account with one click. C3D Labs believes that this integrated procedure for accessing 3D modeling with Teigha is an advantage over licensing the ACIS kernel separately.
The idea behind choosing several practical examples is to reproduce the history of the construction of a model designed in any CAD system. I came across, however, two difficulties.
Firstly, I needed to find amodel old enough that it was made without using construction operations not present in Teigha’s API. Or, at the very least, for there to be as few operations as possible. It can be reasonably expected that CAD developers releasing new versions of their products will provide sample files, including ones that showcase new features and functions. In this regard, the most striking example I encountered was related toextrusion “to object”.
A second difficulty was purely technical: how to clearly illustrate the “before” and “after” states for each operation in the process of construction? The main contradiction that I had to overcome was that the orientation of the model and its scale are not standard, but they must be the same before and after each operation. At the same time, to select operands of Boolean operations or, for example, edges, I need to scale or rotate the model. This may exaggerate the complexity, which arises only because of an incomplete understanding of the capabilities of the test application for the Teigha platform.
Nevertheless, I was able to implement a history of model construction for two demonstrations and examples.
In addition to the modeling operation itself, the functionof searching for topological objects and obtaining geometry for them was implemented for the construction of the models. With the development of the test system and the expansion of the scope of practical applications, this function was further improved.
Teigha is the trademark of the Open Design Alliance. All other trademarks are the property of their respective owners.
This article was first posted at Teigha Blog https://www.opendesign.com/blog
Guest Blogger -