The C3D Modeler kernel includes the sweep operation (creating a surface by moving a curve along a path) as its core functionality. It is one of the oldest and most refined 3D modeling operations. Still, a customer requested us to expand the capabilities of the sweep operation. We were asked to enable modifications of the generatrix curve as it moves along the path.
Such modifications include changing the segment lengths, constraints applied to the angle between segments, and constraints that require the generatrix to be tangent to a given surface, or to intersect some curves. Such functionality cannot be implemented analytically while managing the large number of parameters is rather challenging.
After some heated discussions, we agreed to add an abstract, kernel-level interface to access the generatrix at any point of the path, while the user independently implements the interface.
class MATH_CLASS IVariableSectionData { public: /// Destructor. virtual ~IVariableSectionData(){} /** \brief Access the section. \~ \param[in] t - \ Parameter value along the path. \~ \param[in] place - \ Placement of the section. \~ \param[out] contours - \ Array of planar contours. \~ \return \ Returns true in case of success. \~ */ virtual bool GetSection( double t, const MbPlacement3D & place, c3d::PlaneContoursSPtrVector & contours ) const = 0; };
With this approach, the kernel focuses on the construction of the approximating surface applied to several sections with the specified accuracy. The user adds a code to flexibly control the section shape.
In this regard, an efficient strategy is calling the C3D Solver geometric constraint solver from the user code. The solver calculates the section shape for given geometric constraints. The developer has to “set up” the solver before initializing the sweep operation. Upon request from the kernel, C3D Solver solves the system of constraints and defines the generatrix section shape at the given point of the path. Note that all the sections must consist of an identical number of segments. We’ve managed to compensate for the inevitable loss of performance along the "geometric kernel - user code - parametric solver” chain by parallel computing on the kernel side.
Joint efforts of the С3D Labs teams have resulted in a sweep operation where the section can be dynamically modified along the path, making it possible to apply a range of flexible strategies within a single operation to build complex geometry. Fig. 1 shows a red section which is modified as it is swept along the orange path. The arc center and radius values are provided by user-defined functions of the path length.
Another example (Figure 2) shows the green curves used as constraints. The generatrix section (red) must pass through the green curves as the section moves along the orange path.
Figure 3 shows the animated sweep operation.
The last example (Figure 4) shows the tangent constraint using external geometric entities. The AB and СD segments (red) must stay tangents to the surfaces of the bodies as the section moves along the path. The linear length of the section is also preserved.
Fig. 4. Sweep operation. The section shape is modified using the tangent constraint and external surfaces
These are just a few examples. The range of possible scenarios is enormous. The user now has unlimited capabilities to construct complex shapes in one operation.
Andrey Tumanin
C3D Modeler development team leader
Ph.D.
C3D Labs