Sometimes curves don’t look quite right. In Visualize, curves (e.g. a circular arc) are tessellated, meaning they are drawn using a series of line segments. In HPS, you can use the CurveAttributeControl API to control curve tessellation at the segment level.
Consider the following code, which inserts markers at the same locations used to define and insert an arc;
auto key = GetCanvas().GetFrontView().GetAttachedModel().GetSegmentKey();
Point pt1(407530, 445592, 0);
Point pt2(407669, 445636, 0);
Point pt3(407803, 445694, 0);
key.InsertCircularArc(pt1, pt2, pt3);
key.InsertMarker(pt1);
key.InsertMarker(pt2);
key.InsertMarker(pt3);
The result is rendered as shown;
The scale of the data, the default curve attributes, and the camera settings combine to show an arc rendered as a straight line. If the camera were zoomed out, this level of tessellation might be satisfactory. Assuming it’s not, let’s see what we can do to fix the problem.
Instructions
There are two approaches that could be employed in this example to render the arc as a curve.
- Add the following to the code above;
key.GetCurveAttributeControl().SetViewDependent(true);
to make this arc’s tessellation view dependent (cf. HPS.CurveAttributeControl — HOOPS Visualize HPS Documentation 2022.0.0 documentation ). This adjusts the tessellation as you zoom in to render the curve smoothly.
- The tessellation for view independent curves is set (based on the curve attribute defaults) once and does not change dynamically with camera adjustments. Consider setting other curve attributes for a view independent result that meets your needs.
A couple things to note:
1. After the curve tessellation is computed and rendered for view independent curves, changing the curve attributes will not result in an updated rendering. The curve attributes should be set prior to the initial rendering. A file I/O cycle will also force a curve tessellation update.
2. If a sub-segment doesn’t have curve attributes, they will be inherited from the defaults set on the root segment. If you query a sub-segment in this case, it will return unexpected values (e.g. budget = 0) because the sub-segment does not have any curve attributes. The CurveAttributeControl
does not return net attributes.