Skip to content

Conversation

@kennyweiss
Copy link
Member

@kennyweiss kennyweiss commented Jan 12, 2026

Summary

  • This PR is a feature
  • It adds a quest example for running 3D winding number queries on a STEP file
  • It is modeled after the 2D winding number example, and we might eventually want to merge the two examples. In the short term, during development, it seemed easiest to keep them separate.
  • I cherry-picked a few commits from @jcs15c's Fix surface orientation in quest::STEPReader #1765 (all the changes in this PR to STEPReader.cpp), so that should be merged first
  • Several unnecessarily intrusive SLIC_ASSERTS were removed/made more informative in NURBSPatch.hpp to accommodate the fact that many in-the-wild CAD examples have trimming curves which extend beyond the range of the patch's parameter space. In the future, these could be handled by the methods described in Add slic macros that only log the first time they're called #1685, which would alert the user without cluttering output.
  • Includes some performance and robustness improvements to 2D winding number computations
    • linear_winding_number is now based on atan2 instead of acos. This was the bottleneck in 2D WN computations and shaves about 25% of runtimes
    • determinants are now implemented in terms of a portable axom::utilities::fma function (with the expectation that this will improve robustness)
  • Adds some helpful features to 2D winding number example, e.g. using the curve collection bounding box when not specified by the user, and output some helpful runtime stats about query times and rates

@kennyweiss kennyweiss self-assigned this Jan 12, 2026
@kennyweiss kennyweiss added enhancement New feature or request Quest Issues related to Axom's 'quest' component labels Jan 12, 2026
Comment on lines 2166 to 2179
SLIC_ASSERT_MSG(
isValidParameter_u(u, 1e-5),
axom::fmt::format("Requested u-parameter {} is outside valid range [{},{}] with tolerance {}",
u,
getMinKnot_u(),
getMaxKnot_u(),
1e-5));
SLIC_ASSERT_MSG(
isValidParameter_v(v, 1e-5),
axom::fmt::format("Requested v-parameter {} is outside valid range [{},{}] with tolerance {}",
v,
getMinKnot_v(),
getMaxKnot_v(),
1e-5));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcs15c and I spoke about this -- this is triggered called when evaluating the normal for a trimmed patch, and was failing for some files due to trimming curves that are slightly outside the parametric bounding box. Since the user has no control over this, we should probably preprocess/fix this before processing the NURBS patches,

Copy link
Contributor

@jcs15c jcs15c Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To further keep record of this conversation, at this point it's unrealistic to clip or clamp the trimming curves to the correct parameter space for a given patch. Instead, the methods in NURBSPatch (which already clamp the inputs to the parameter space) should probably give a one-time warning if out-of-bounds input is recorded, then move on. Since #1765 is mostly concerned with the STEPReader, I'll make those changes here instead.

@kennyweiss kennyweiss force-pushed the feature/kweiss/wn-example-3D branch 2 times, most recently from 4d0dd2d to 59746cf Compare January 15, 2026 10:16
"NURBSPatchGWNCache::getKnots_v() must match NURBSPatch signature");
static_assert(std::is_same_v<decltype(std::declval<const Cache&>().getTrimmingCurves()),
decltype(std::declval<const Patch&>().getTrimmingCurves())>,
"NURBSPatchGWNCache::getTrimmingCurves() must match NURBSPatch signature");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are great tests, thank you! It's worth keeping in mind that a future implementation of NURBSPatchGWNCache might have trimming curves of type NURBSCurveGWNCache instead of NURBSCurve, since that seems easier than templating the type of NURBSPatch on trimming curve type.

Copy link
Contributor

@jcs15c jcs15c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the optimizations of winding_number(NURBSPatch)! It all looks great.

kennyweiss and others added 13 commits January 15, 2026 14:37
* Allows user to omit bounding box and will use input bounding box instead.
* Checks for consistency in query grid bounds and resolution (min/max/res)
* Adds a few timers and annotations
Scales query bounding box when user does not supply one.
…or u- and v-

The function already clamps the parametric coordinates to the knot-span, so there's no real loss here.

In this case, the function was called when computing the patch normal of the trimmed patch.
We should probably preprocess the trimming curves to be withing the parametric bounding box
since the user of the 3D winding numbers has no control over the trimming curves.
We can now choose not to provide a query_mesh bounding box, and it will instead use
the input mesh's bounding box (slightly inflated).

We also print the query times and rates.
I tracked down the changes in containment determination
exclusively to samples on/near the boundary.
atan2 is more stable, robust and performant than acos
for the linear_winding_number calculations.
* \return a*b+c computed using an fma operation
*/
template <typename T>
inline AXOM_HOST_DEVICE T fma(const T& a, const T& b, const T& c)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can think of a bunch of places to use this!

Copy link
Member

@BradWhitlock BradWhitlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice optimizations!

@kennyweiss kennyweiss force-pushed the feature/kweiss/wn-example-3D branch from 8716c0a to c63ef54 Compare January 15, 2026 22:45
@kennyweiss kennyweiss merged commit cb2c8b5 into develop Jan 18, 2026
15 checks passed
@kennyweiss kennyweiss deleted the feature/kweiss/wn-example-3D branch January 18, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Quest Issues related to Axom's 'quest' component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants