A line segment is a basic geometric object most widely used in drawings or sketches. Can you guess, how many math representations a segment has? While you’re counting, let me tell you how C3D Solver handles segments, and about the new option: degenerate segments. Please note that the term “degenerate” does not have any negative connotations. Moreover, it describes a valid, useful condition.
The C3D Solver parametric solver supports two internal representations of line segments. The first definition of a segment is two ordered points that do not coincide. Such a definition excludes segments degenerated to a point because the start and end points may not coincide. This imposes challenges in many operations such as:
- construction of a parametric contour with segments that disappear and reappear (Fig. 1)
- construction of variable topology parametric 3D models from 2D contours
- construction of loft surfaces with variable geometry cross-sections (Fig. 2).
In all of the above cases, the segments have to be shrunk to zero length and then returned to their initial state.
C3D Solver has already supported degenerate geometry: zero radius circles. One interesting example of using this option is modeling the transition between rounded and square cross-sections Imagine a standard or custom HVAC duct fitting (Fig. 3). Now the kernel also supports segments whose length varies in a range starting from zero.
To enable a segment to degenerate into a point and generate back, there is another segment definition: two points and a direction vector. The direction vector preserves the segment’s direction while the segment is degenerated into a point. This definition also requires the points to be ordered to avoid segment inversion when it is used in the effect of "inversion" of the segment when participating in constraints such as Tangency or At Distance constraints.
How to use these degenerate segments and circles? Just learn a few callback functions now available in the 2D solver.
First, associate your geometric objects with C3D Solver’s objects to set up each segment individually. For this, call the function:
void GCE_Bind( GCE_system, geom_item, GCE_app_geom );
Next, permit the solver to handle zero-length curves with the following callback:
GCE_allow_zero_length/GCE_allow_zero_radius.
Having individual callbacks for each object offers several advantages. For example, it makes sense to disable zero length for centerline segments. Also, your CAD may need to visualize degenerate geometry so the user can see that a segment can disappear/reappear at some point.
The last tool to handle degenerate segments is the function GCE_get_lseg_direction
. It returns the segment’s direction vector. With this function, your application memorizes the direction of the segment with L=0 to be used when the segment is regenerated back.
The callback functions to support L=0, R=0 curves:
/* Callback functions return individual results for each object. */ using GCE_allow_zero_radius = bool (*)(GCE_app_geom ag); using GCE_allow_zero_length = bool (*)(GCE_app_geom ag); using GCE_get_lseg_direction = GCE_vec2d (*)(GCE_app_geom ag); struct GCE_callback_table { /* Geometry properties */ GCE_allow_zero_radius allowZeroRadius; // Enables circles with R=0. GCE_allow_zero_length allowZeroLength; // Enables curves with L=0. GCE_get_lseg_direction getLSegDirection; // Returns the direction vector of the segment with L=0 or L != 0. // .. };
The degenerate geometry, which includes circles and segments, is already available in the two-dimensional C3D Solver. This feature improves the flexibility of geometric entities and provides more advanced parameterization.
Ksenia Nosulko
Math Software Engineer
C3D Labs