AMCAX Kernel 1.0.0.0
|
This tutorial provides the basic usage of AMCAX kernel to model a valve model.
The developers need to have some basic knowledge including the modern C++ programming language, 3D geometric modeling concepts, and the B-Rep topology structure. In specific, the AMCAX kernel is designed by using C++ 17 standard, and STL containers and algorithms are used as basic data structures and utilities. The geometric entities are represented by a Boundary-Representation (B-Rep) structure, including geometry objects and topology structures.
This tutorial uses a simplified valve model to show some of main modeling functionalities in the AMCAX kernel. The model is shown in the figure below:
The model consists of three sub-parts:
We will introduce the constructions step-by-step, and provide explanations in as much detail as possible.
Let's start with the inlet/outlet of the valve. A rounded-corner hexagon prism is created to represent the fixing structure.
The first step is create a hexagon using the AMCAX::MakePolygon class. The resulting face can be constructed by using the AMCAX::MakeFace class.
Click here example1 to get the complete source code for the above example, which you can download according to your learning needs.
To construct a round-corner hexagon, we apply a 2D fillet to each vertex of the hexagon by using the AMCAX::MakeFillet2d class.
In the above sample code, the AMCAX::IndexSet class is essentially an unordered set whose elements have their own indices. The AMCAX::TopoExplorerTool::MapShapes function will find all the vertices in the shape. Click here example2 to get the complete source code for the above example, which you can download according to your learning needs.
Next, we extrude the hexagon to create a prism by using the AMCAX::MakePrism class.
Click here example3 to get the complete source code for the above example, which you can download according to your learning needs.
Then, we apply 3D chamfers by using AMCAX::MakeChamfer class.
Here, the AMCAX::TopoExplorer class is used to traverse all the edges in the shape. And if an edge has two vertices sharing the same x coordinate, then we chamfer along the edge. Click here example4 to get the complete source code for the above example, which you can download according to your learning needs.
Next, we create a curved pipe for inlet/outlet. The process seems a little bit complicated, but the main sub-steps are quite simple. The pipe is created by using the AMCAX::MakePipe class. This class requires a spine wire representing the sweeping path and a profile shape to be used to sweep.
The spine wire is a 'S' type path, consisting of five curves: line – arc – line – arc – line. All the curves are G1 connected. This means that the middle line is tangent to both the arcs. Here, we first create 2D circles using the AMCAX::MakeGeom2Circle class, and then use the AMCAX::GccLine2Tangent class to find the line tangent to two circles.
Then, we map the curves from 2D to 3D and build the five edges and the the spine wire. Here, the AMCAX::MakeArcOfCircle class is used to create arcs, the AMCAX::MakeSegment class is used to create line segments, the AMCAX::MakeEdge class is used to create edges from curves, and the AMCAX::MakeWire class is used to create the spine wire from edges.
The profile is a simple circle and is created by using the AMCAX::MakeGeom3Circle class.
Since the pipe is tunnel which has an inner face and an outer face, we create an offset shape for the profile of the outer face. The shape is copied by the AMCAX::CopyShape class, and then use the AMCAX::MakeOffset class to create a 2D offset wire.
Next, we use the AMCAX::MakePipe class to create sweeping solids by using a face, generated by the AMCAX::MakeFace class, as the profile shape. We will compute a boolean cut of these two solid at the next step.
Click here example5 to obtain the complete source code for curved track pipe1, which you can download according to your learning needs. Click here example6 to obtain the complete source code for curved track pipe2, which you can download according to your learning needs.
Finally, we build the central part of the valve, which is simplified to a cylinder where a piston can be used to control the valve.
A cylinder is created by using the AMCAX::MakeCylinder class.
Click here example7 to get the complete source code for the above example, which you can download according to your learning needs.
Here, we additionally add a small 3D fillet example to the middle cylinder by using the AMCAX::MakeFillet class as follows:
Click here example8 to get the complete source code for the above example, which you can download according to your learning needs.
As the valve should have both the inlet and the outlet, we have to mirror the pipe by using the AMCAX::TransformShape class.
Click here example9 to obtain the mirror curved track pipe1, the complete source code to construct pipe3, you can download according to your learning needs. Click here example10 to obtain the mirror curved track pipe2, to construct the complete source code of pipe4, you can download according to your learning needs. Click here example11 to obtain the mirror hex, construct hex2 complete source code, you can download according to your learning needs.
The final step is boolean all the parts together by using the AMCAX::BoolBRepFuse class and the AMCAX::BoolBRepCut class. Here shows the sample code:
Don't forget to construct a tunnel for pistons to contol the valve, although the construction is simplified to be a cylinder.
After generated a shape, you may want to render the shape by modern rendering engines like OpenGL. Thus, we also provide a simple meshing tool to generate meshes for shapes.
The AMCAX::BRepMeshIncrementalMesh class is often used to generate a mesh for each face in the shape. The edges have a polygon on mesh in each adjacent face, but the meshes only coincide at the boundary edges and are not topological connected. You can also use AMCAX::MakeShapeTool::EnsureNormalConsistency() to compute normals for vertices in the mesh. The sample code is as follows:
We provide tools for exporting meshes to STL files and OBJ files. Here is an example of exporting to a STL file.
Click here example12 to obtain the full source code of the entity modeling example, you can download it according to your needs.
The complete code of this sample is listed here: