Skip to main content

opensubdiv_rs/far/
topology_refiner.rs

1//! The topology refiner and its factory (port of
2//! `opensubdiv/far/topologyRefiner.h` and
3//! `opensubdiv/far/topologyRefinerFactory.h`).
4
5use super::fvar::FVarChannel;
6use super::topology_descriptor::TopologyDescriptor;
7use crate::sdc::{self, Scheme, SchemeType};
8use crate::vtr::{Level, Refinement, TopologyError};
9use crate::Index;
10
11/// Options controlling uniform refinement
12/// (`Far::TopologyRefiner::UniformOptions`).
13#[derive(Debug, Clone, Copy)]
14pub struct UniformOptions {
15    /// The number of refinement iterations to apply.
16    pub refinement_level: usize,
17}
18
19impl UniformOptions {
20    /// Refine uniformly `refinement_level` times.
21    pub fn new(refinement_level: usize) -> Self {
22        Self { refinement_level }
23    }
24}
25
26/// Options controlling feature-adaptive refinement
27/// (`Far::TopologyRefiner::AdaptiveOptions`).
28#[derive(Debug, Clone, Copy)]
29pub struct AdaptiveOptions {
30    /// The maximum level of refinement applied to isolate irregular
31    /// features (`isolationLevel`), capped at
32    /// [`MAX_ISOLATION_LEVEL`](Self::MAX_ISOLATION_LEVEL).
33    pub isolation_level: usize,
34    /// Represent regular faces along a semi-sharp crease as single-crease
35    /// patches instead of isolating the crease (`useSingleCreasePatch`).
36    /// Applies to the Catmark scheme only.
37    ///
38    /// A face whose corners are regular and which a single straight
39    /// semi-sharp crease of uniform sharpness bounds on one side is not
40    /// refined further: the [`super::PatchTable`] covers it with one exact
41    /// [`super::PatchType::Regular`] patch carrying the crease's sharpness
42    /// ([`super::PatchTable::single_crease_sharpness`]), rather than with
43    /// `4^level` patches down to where the crease decays (or to the
44    /// isolation cap). Off by default, as in OpenSubdiv.
45    pub use_single_crease_patch: bool,
46    /// Also isolate the irregular features of face-varying channels
47    /// (`considerFVarChannels`): a face is refined further when the value
48    /// mesh of a channel that is not linear
49    /// ([`FVarLinearInterpolation::All`](crate::sdc::FVarLinearInterpolation::All))
50    /// is irregular around it — at seam junctions, fvar darts and
51    /// irregular seam corners, say — even where the vertex topology is
52    /// regular.
53    ///
54    /// Without it, such a face is patched where its vertex topology becomes
55    /// regular, and its face-varying patch
56    /// ([`super::PatchTable::evaluate_basis_face_varying`]) is a Gregory
57    /// end cap at that level: an approximation of the channel's limit
58    /// there. With it, the face-varying patches approximate the limit as
59    /// closely as the vertex patches do, at the cost of more patches. Off
60    /// by default, as in OpenSubdiv.
61    pub consider_fvar_channels: bool,
62}
63
64impl AdaptiveOptions {
65    /// The deepest isolation level [`TopologyRefiner::refine_adaptive`]
66    /// applies; larger requests are clamped to it. As in OpenSubdiv
67    /// (whose `isolationLevel` is documented for `0..=10`), features not
68    /// resolved by then are capped with Gregory patches, which also keeps
69    /// every [`super::PatchParam::depth`] well within the range the
70    /// parametric scale `2^depth` is computed for.
71    pub const MAX_ISOLATION_LEVEL: usize = 10;
72
73    /// Isolate irregular features up to `isolation_level` levels deep
74    /// (at most [`MAX_ISOLATION_LEVEL`](Self::MAX_ISOLATION_LEVEL)).
75    pub fn new(isolation_level: usize) -> Self {
76        Self {
77            isolation_level,
78            use_single_crease_patch: false,
79            consider_fvar_channels: false,
80        }
81    }
82
83    /// Enable or disable single-crease patches
84    /// ([`use_single_crease_patch`](Self::use_single_crease_patch)).
85    pub fn with_single_crease_patch(mut self, enabled: bool) -> Self {
86        self.use_single_crease_patch = enabled;
87        self
88    }
89
90    /// Enable or disable the isolation of face-varying features
91    /// ([`consider_fvar_channels`](Self::consider_fvar_channels)).
92    pub fn with_consider_fvar_channels(mut self, enabled: bool) -> Self {
93        self.consider_fvar_channels = enabled;
94        self
95    }
96}
97
98/// Public interface to the topology of one refinement level
99/// (`Far::TopologyLevel`) — a thin view over a [`crate::vtr::Level`].
100#[derive(Debug, Clone, Copy)]
101pub struct TopologyLevel<'a> {
102    level: &'a Level,
103    fvar_channels: &'a [FVarChannel],
104    level_index: usize,
105}
106
107impl<'a> TopologyLevel<'a> {
108    /// The number of vertices in this level (`GetNumVertices`).
109    pub fn num_vertices(&self) -> usize {
110        self.level.num_vertices()
111    }
112
113    /// The number of edges in this level (`GetNumEdges`).
114    pub fn num_edges(&self) -> usize {
115        self.level.num_edges()
116    }
117
118    /// The number of faces in this level (`GetNumFaces`).
119    pub fn num_faces(&self) -> usize {
120        self.level.num_faces()
121    }
122
123    /// Total number of face-vertex pairs (`GetNumFaceVerticesTotal`).
124    pub fn num_face_vertices_total(&self) -> usize {
125        self.level.num_face_vertices_total()
126    }
127
128    /// The vertices of `face`, in winding order (`GetFaceVertices`).
129    pub fn face_vertices(&self, face: usize) -> &'a [Index] {
130        self.level.face_vertices(face)
131    }
132
133    /// The edges of `face` (`GetFaceEdges`).
134    pub fn face_edges(&self, face: usize) -> &'a [Index] {
135        self.level.face_edges(face)
136    }
137
138    /// The two end vertices of `edge` (`GetEdgeVertices`).
139    pub fn edge_vertices(&self, edge: usize) -> [Index; 2] {
140        self.level.edge_vertices(edge)
141    }
142
143    /// The faces incident `edge` (`GetEdgeFaces`).
144    pub fn edge_faces(&self, edge: usize) -> &'a [Index] {
145        self.level.edge_faces(edge)
146    }
147
148    /// The faces incident `vertex` (`GetVertexFaces`).
149    pub fn vertex_faces(&self, vertex: usize) -> &'a [Index] {
150        self.level.vertex_faces(vertex)
151    }
152
153    /// The edges incident `vertex` (`GetVertexEdges`).
154    pub fn vertex_edges(&self, vertex: usize) -> &'a [Index] {
155        self.level.vertex_edges(vertex)
156    }
157
158    /// Find the edge connecting two vertices (`FindEdge`).
159    pub fn find_edge(&self, v0: Index, v1: Index) -> Option<Index> {
160        self.level.find_edge(v0, v1)
161    }
162
163    /// The effective sharpness of `edge` (`GetEdgeSharpness`). Boundary
164    /// sharpening implied by the boundary-interpolation option is included.
165    pub fn edge_sharpness(&self, edge: usize) -> f32 {
166        self.level.edge_sharpness(edge)
167    }
168
169    /// The effective sharpness of `vertex` (`GetVertexSharpness`).
170    pub fn vertex_sharpness(&self, vertex: usize) -> f32 {
171        self.level.vertex_sharpness(vertex)
172    }
173
174    /// Does `edge` lie on a mesh boundary (`IsEdgeBoundary`)?
175    pub fn is_edge_boundary(&self, edge: usize) -> bool {
176        self.level.is_edge_boundary(edge)
177    }
178
179    /// Is `edge` non-manifold, i.e. shared by more than two faces
180    /// (`IsEdgeNonManifold`)?
181    pub fn is_edge_non_manifold(&self, edge: usize) -> bool {
182        self.level.is_edge_non_manifold(edge)
183    }
184
185    /// Does `vertex` lie on a mesh boundary (`IsVertexBoundary`)?
186    pub fn is_vertex_boundary(&self, vertex: usize) -> bool {
187        self.level.is_vertex_boundary(vertex)
188    }
189
190    /// Is `face` tagged as a hole (`IsFaceHole`)?
191    pub fn is_face_hole(&self, face: usize) -> bool {
192        self.level.is_face_hole(face)
193    }
194
195    /// The number of face-varying channels (`GetNumFVarChannels`).
196    pub fn num_fvar_channels(&self) -> usize {
197        self.fvar_channels.len()
198    }
199
200    /// The number of face-varying values of `channel` at this level
201    /// (`GetNumFVarValues`).
202    pub fn num_fvar_values(&self, channel: usize) -> usize {
203        self.fvar_channels[channel].num_values(self.level_index)
204    }
205
206    /// The face-varying values associated with the corners of `face`, in the
207    /// same winding order as [`face_vertices`](Self::face_vertices)
208    /// (`GetFaceFVarValues`).
209    pub fn face_fvar_values(&self, face: usize, channel: usize) -> &'a [Index] {
210        self.fvar_channels[channel].face_values(self.level_index, face)
211    }
212
213    pub(super) fn inner(&self) -> &'a Level {
214        self.level
215    }
216}
217
218/// Stores the hierarchy of refined topology levels and the refinements
219/// between them (`Far::TopologyRefiner`).
220#[derive(Debug, Clone)]
221pub struct TopologyRefiner {
222    scheme: Scheme,
223    options: sdc::Options,
224    levels: Vec<Level>,
225    refinements: Vec<Refinement>,
226    fvar_channels: Vec<FVarChannel>,
227    /// True when the hierarchy was produced by [`refine_adaptive`]
228    /// (`Self::refine_adaptive`); levels above 0 are then sparse.
229    adaptive: bool,
230    /// For each refinement step, the faces of the parent level that were
231    /// selected for refinement (all `true` for uniform steps).
232    selections: Vec<Vec<bool>>,
233    /// Did adaptive refinement leave single-crease patches unrefined
234    /// ([`AdaptiveOptions::use_single_crease_patch`])?
235    single_crease_patch: bool,
236}
237
238impl TopologyRefiner {
239    /// The subdivision scheme of this refiner (`GetSchemeType`).
240    pub fn scheme_type(&self) -> SchemeType {
241        self.scheme.scheme_type()
242    }
243
244    /// The subdivision options of this refiner (`GetSchemeOptions`).
245    pub fn scheme_options(&self) -> sdc::Options {
246        self.options
247    }
248
249    pub(super) fn scheme(&self) -> &Scheme {
250        &self.scheme
251    }
252
253    /// The number of refinement levels, including the base level
254    /// (`GetNumLevels`).
255    pub fn num_levels(&self) -> usize {
256        self.levels.len()
257    }
258
259    /// The highest refinement level (`GetMaxLevel`).
260    pub fn max_level(&self) -> usize {
261        self.levels.len() - 1
262    }
263
264    /// The topology of refinement level `level` (`GetLevel`).
265    pub fn level(&self, level: usize) -> TopologyLevel<'_> {
266        TopologyLevel {
267            level: &self.levels[level],
268            fvar_channels: &self.fvar_channels,
269            level_index: level,
270        }
271    }
272
273    /// The number of face-varying channels (`GetNumFVarChannels`).
274    pub fn num_fvar_channels(&self) -> usize {
275        self.fvar_channels.len()
276    }
277
278    /// The face-varying channel `channel`.
279    pub fn fvar_channel(&self, channel: usize) -> &FVarChannel {
280        &self.fvar_channels[channel]
281    }
282
283    /// The refinement that produced level `level` from level `level - 1`.
284    pub fn refinement(&self, level: usize) -> &Refinement {
285        &self.refinements[level - 1]
286    }
287
288    /// Sum of the vertex counts of all levels (`GetNumVerticesTotal`).
289    pub fn num_vertices_total(&self) -> usize {
290        self.levels.iter().map(|l| l.num_vertices()).sum()
291    }
292
293    /// Sum of the face counts of all levels (`GetNumFacesTotal`).
294    pub fn num_faces_total(&self) -> usize {
295        self.levels.iter().map(|l| l.num_faces()).sum()
296    }
297
298    /// Refine the topology uniformly (`RefineUniform`): every face is
299    /// subdivided at every iteration until `options.refinement_level` levels
300    /// of refinement exist.
301    ///
302    /// Calling this more than once extends the existing hierarchy if the new
303    /// target is deeper; it never discards levels.
304    pub fn refine_uniform(&mut self, options: UniformOptions) {
305        assert!(
306            !self.adaptive,
307            "cannot mix uniform and adaptive refinement on one refiner"
308        );
309        while self.max_level() < options.refinement_level {
310            let num_faces = self.levels.last().unwrap().num_faces();
311            let (child, refinement) = Refinement::refine(self.levels.last().unwrap(), &self.scheme)
312                .expect("refined topology is always internally consistent");
313            self.levels.push(child);
314            self.refinements.push(refinement);
315            self.selections.push(vec![true; num_faces]);
316            // Face-varying channels refine in lockstep with the geometry.
317            for channel in &mut self.fvar_channels {
318                channel.refine_once(None);
319            }
320        }
321    }
322
323    /// Feature-adaptively refine the topology (`RefineAdaptive`): starting
324    /// from the base level, only faces whose neighborhood prevents the
325    /// limit surface from being a (boundary-aware) bicubic B-spline patch —
326    /// extraordinary vertices, non-quads, semi-sharp creases, and irregular
327    /// infinitely sharp features — are *selected* and subdivided, together
328    /// with their one-ring support, until they resolve or
329    /// `options.isolation_level` is reached. Regular infinitely sharp
330    /// creases and corners are not isolated: like boundaries, they bound
331    /// exact B-spline patches (OpenSubdiv's `useInfSharpPatch`); with
332    /// [`AdaptiveOptions::use_single_crease_patch`], neither are regular
333    /// faces bounded by a single semi-sharp crease. Levels
334    /// above 0 are sparse: memory grows with the mesh's irregular features,
335    /// not with `4^level`.
336    ///
337    /// Isolation stops at [`AdaptiveOptions::MAX_ISOLATION_LEVEL`] however
338    /// deep a level is requested.
339    ///
340    /// Patches for an adaptively refined mesh live at mixed depths — build
341    /// a [`super::PatchTable`] to evaluate the limit surface, or a
342    /// [`super::LimitStencilTable`] to evaluate it straight from the base
343    /// cage. [`super::PrimvarRefiner::interpolate`] and
344    /// [`super::StencilTableFactory::create`] work level by level as
345    /// usual; [`super::PrimvarRefiner::limit`] and
346    /// [`super::StencilTableFactory::create_limit`] — the limit of the
347    /// last level's vertices — require uniform refinement.
348    ///
349    /// For the Loop scheme the same isolation applies to triangles: faces
350    /// whose three corners are regular (interior valence 6, regular
351    /// boundary and crease vertices, pinned corners) are exact box-spline
352    /// patches and are not refined; the rest — extraordinary vertices,
353    /// semi-sharp creases, irregular boundaries and darts — descend to the
354    /// isolation cap. For Bilinear only non-quad base faces need one round
355    /// of isolation.
356    ///
357    /// With [`AdaptiveOptions::consider_fvar_channels`], faces around the
358    /// irregular features of non-linear face-varying channels are isolated
359    /// the same way.
360    ///
361    /// To isolate features around a few base faces only, use
362    /// [`refine_adaptive_selected`](Self::refine_adaptive_selected).
363    pub fn refine_adaptive(&mut self, options: AdaptiveOptions) {
364        self.refine_adaptive_impl(options, None);
365    }
366
367    /// Feature-adaptively refine the topology around the base faces
368    /// `selected_faces` only (`RefineAdaptive` with `selectedFaces`).
369    ///
370    /// As [`refine_adaptive`](Self::refine_adaptive), except that at the
371    /// base level only the faces in `selected_faces` are inspected and
372    /// isolated: the rest of the cage is left unrefined, apart from the
373    /// one-ring support the selected faces' children need. Below the base
374    /// level isolation proceeds as usual among the descendants of the
375    /// selected faces, so each selected face is refined exactly as
376    /// [`refine_adaptive`](Self::refine_adaptive) refines it, and the
377    /// cost grows with the selected area instead of the cage size.
378    ///
379    /// Build the patches of the selected faces with
380    /// [`PatchTableFactory::create_with_options_selected`](super::PatchTableFactory::create_with_options_selected):
381    /// they are the patches a full refinement and a full table give those
382    /// faces, and they evaluate the same limit surface. A full table built
383    /// from this refiner caps the irregular faces that were not selected at
384    /// the base level (and cannot cover unselected non-quad faces, which
385    /// need a refinement to be patched).
386    ///
387    /// Unlike OpenSubdiv, where an empty `selectedFaces` array means every
388    /// face, an empty `selected_faces` selects nothing and leaves the
389    /// refiner unrefined. Duplicates and holes are ignored.
390    ///
391    /// # Panics
392    ///
393    /// Panics when a selected face is not a face of the base level, or, as
394    /// [`refine_adaptive`](Self::refine_adaptive), when the refiner has
395    /// already been refined.
396    pub fn refine_adaptive_selected(&mut self, options: AdaptiveOptions, selected_faces: &[Index]) {
397        let num_faces = self.levels[0].num_faces();
398        if let Some(&face) = selected_faces.iter().find(|&&f| f as usize >= num_faces) {
399            panic!("selected face {face} out of range ({num_faces} base faces)");
400        }
401        self.refine_adaptive_impl(options, Some(selected_faces));
402    }
403
404    /// Adaptive refinement, inspecting only `base_faces` (when given) at
405    /// the base level.
406    fn refine_adaptive_impl(&mut self, options: AdaptiveOptions, base_faces: Option<&[Index]>) {
407        assert!(
408            self.max_level() == 0,
409            "adaptive refinement must start from an unrefined refiner"
410        );
411        self.adaptive = true;
412        self.single_crease_patch = options.use_single_crease_patch;
413        let isolation_level = options
414            .isolation_level
415            .min(AdaptiveOptions::MAX_ISOLATION_LEVEL);
416
417        while self.max_level() < isolation_level {
418            let level_index = self.max_level();
419            let level = self.levels.last().unwrap();
420
421            let mut selected = vec![false; level.num_faces()];
422            let mut any = false;
423            let mut inspect = |f: usize| {
424                if !selected[f] && self.face_needs_isolation(&options, level_index, f) {
425                    selected[f] = true;
426                    any = true;
427                }
428            };
429            match (level_index, base_faces) {
430                (0, Some(faces)) => faces.iter().for_each(|&f| inspect(f as usize)),
431                _ => (0..level.num_faces()).for_each(inspect),
432            }
433            if !any {
434                break;
435            }
436
437            // The selection is expanded to its one-ring support once, on
438            // the geometry, and that mask refines the face-varying channels
439            // too: their value meshes mirror the geometry's faces but not
440            // its vertex connectivity (seams split vertices), so expanding
441            // on each mesh separately would refine different faces.
442            let included = Refinement::expand_selection(level, &selected);
443            let (child, refinement) =
444                Refinement::refine_included(self.levels.last().unwrap(), &self.scheme, &included)
445                    .expect("refined topology is always internally consistent");
446            self.levels.push(child);
447            self.refinements.push(refinement);
448            for channel in &mut self.fvar_channels {
449                channel.refine_once(Some(&included));
450            }
451            self.selections.push(selected);
452        }
453    }
454
455    /// Does face `f` of the last level `level_index` need to be refined
456    /// further: is it a non-hole candidate whose neighborhood — or, with
457    /// [`AdaptiveOptions::consider_fvar_channels`], a non-linear channel's —
458    /// is not a regular patch?
459    fn face_needs_isolation(
460        &self,
461        options: &AdaptiveOptions,
462        level_index: usize,
463        f: usize,
464    ) -> bool {
465        let level = &self.levels[level_index];
466        if level.is_face_hole(f) || !self.face_is_candidate(level_index, f) {
467            return false;
468        }
469        let needs_isolation = |level: &Level| match self.scheme_type() {
470            SchemeType::Catmark => {
471                super::patch_table::gather_regular_patch(level, f).is_none()
472                    && !(options.use_single_crease_patch
473                        && super::patch_table::single_crease_patch(level, f).is_some())
474            }
475            SchemeType::Bilinear => level.face_vertices(f).len() != 4,
476            SchemeType::Loop => super::loop_patch::gather_regular_patch(level, f).is_none(),
477        };
478        // A channel's value mesh mirrors the geometry's faces, so face `f`
479        // is the same face in each.
480        let fvar_needs_isolation = || {
481            options.consider_fvar_channels
482                && self.scheme_type() != SchemeType::Bilinear
483                && self.fvar_channels.iter().any(|channel| {
484                    !channel.is_linear() && needs_isolation(channel.level(level_index))
485                })
486        };
487        needs_isolation(level) || fvar_needs_isolation()
488    }
489
490    /// Was this refiner refined adaptively (`IsAdaptive`)?
491    pub fn is_adaptive(&self) -> bool {
492        self.adaptive
493    }
494
495    /// Is `face` of `level` a *candidate* for patches or further isolation:
496    /// the base level entirely, and above it the children of selected
497    /// faces (whose neighborhoods are guaranteed complete).
498    pub(super) fn face_is_candidate(&self, level: usize, face: usize) -> bool {
499        if level == 0 {
500            return true;
501        }
502        let parent = self.refinements[level - 1].child_face_parent_face(face) as usize;
503        self.selections[level - 1][parent]
504    }
505
506    /// Should the patch table cover single-crease faces with single-crease
507    /// patches ([`AdaptiveOptions::use_single_crease_patch`])?
508    pub(super) fn uses_single_crease_patch(&self) -> bool {
509        self.single_crease_patch
510    }
511
512    /// Was `face` of `level` selected for further refinement?
513    pub(super) fn face_is_selected(&self, level: usize, face: usize) -> bool {
514        level < self.selections.len() && self.selections[level][face]
515    }
516}
517
518/// Factory constructing a [`TopologyRefiner`] from a
519/// [`TopologyDescriptor`]
520/// (`Far::TopologyRefinerFactory<TopologyDescriptor>`).
521pub struct TopologyRefinerFactory;
522
523impl TopologyRefinerFactory {
524    /// Validate the descriptor and instantiate the base level of a
525    /// [`TopologyRefiner`] (`TopologyRefinerFactory::Create`).
526    pub fn create(
527        descriptor: TopologyDescriptor<'_>,
528        scheme_type: SchemeType,
529        options: sdc::Options,
530    ) -> Result<TopologyRefiner, TopologyError> {
531        // The Loop scheme is only defined for triangular meshes.
532        if scheme_type == SchemeType::Loop {
533            for (f, &size) in descriptor.num_verts_per_face.iter().enumerate() {
534                if size != 3 {
535                    return Err(TopologyError::NonTriangularFaceForLoop { face: f, size });
536                }
537            }
538        }
539
540        let mut level = Level::from_face_vertices(
541            descriptor.num_vertices,
542            descriptor.num_verts_per_face,
543            descriptor.vert_indices_per_face,
544        )?;
545
546        // Creases.
547        for (pair, &weight) in descriptor
548            .crease_vertex_index_pairs
549            .iter()
550            .zip(descriptor.crease_weights)
551        {
552            for &v in pair {
553                if v as usize >= level.num_vertices() {
554                    return Err(TopologyError::InvalidDescriptorIndex {
555                        what: "crease vertex",
556                        index: v,
557                    });
558                }
559            }
560            let edge = level
561                .find_edge(pair[0], pair[1])
562                .ok_or(TopologyError::CreaseEdgeNotFound { vertices: *pair })?;
563            level.set_edge_sharpness(edge as usize, weight);
564        }
565
566        // Corners.
567        for (&v, &weight) in descriptor
568            .corner_vertex_indices
569            .iter()
570            .zip(descriptor.corner_weights)
571        {
572            if v as usize >= level.num_vertices() {
573                return Err(TopologyError::InvalidDescriptorIndex {
574                    what: "corner vertex",
575                    index: v,
576                });
577            }
578            level.set_vertex_sharpness(v as usize, weight);
579        }
580
581        // Holes.
582        for &f in descriptor.hole_indices {
583            if f as usize >= level.num_faces() {
584                return Err(TopologyError::InvalidDescriptorIndex {
585                    what: "hole face",
586                    index: f,
587                });
588            }
589            level.set_face_hole(f as usize, true);
590        }
591
592        let scheme = Scheme::new(scheme_type, options);
593        level.sharpen_boundaries(scheme.crease());
594
595        // Face-varying channels — built after boundary sharpening so the
596        // geometry's effective sharpness transfers onto the value meshes.
597        let mut fvar_channels = Vec::with_capacity(descriptor.fvar_channels.len());
598        for (c, channel) in descriptor.fvar_channels.iter().enumerate() {
599            fvar_channels.push(FVarChannel::create(
600                &level,
601                scheme_type,
602                options,
603                c,
604                channel.num_values,
605                channel.value_indices,
606            )?);
607        }
608
609        Ok(TopologyRefiner {
610            scheme,
611            options,
612            levels: vec![level],
613            refinements: Vec::new(),
614            fvar_channels,
615            adaptive: false,
616            selections: Vec::new(),
617            single_crease_patch: false,
618        })
619    }
620}