remesh
triwarp.remesh
Changing a mesh's triangulation: subdividing it, coarsening it, and improving its triangle shapes.
Four families, in decreasing order of how much they rearrange:
- Remeshing.
isotropic_remeshruns the Botsch-Kobbelt split / collapse / flip / smooth / reproject loop until every edge is near a target length. It is the only entry point here that does all four of the others' jobs at once. - Decimation.
quadric_decimatecollapses edges in quadric-error order to a target face count;cluster_decimateinstead welds each voxel of a uniform grid to a single vertex, which is far cheaper and far blunter. - Edge flipping, which moves no vertex and changes no vertex count:
flip_to_delaunaytoward the Delaunay criterion,flip_by_objectivetoward a triangle-shape or flatness objective, andintrinsic_delaunaytoward the intrinsic Delaunay triangulation, which flips the connectivity a Laplacian sees without touching the embedding. - Subdivision, which only ever adds:
subdivide(one-to-four splits),subdivide_loop(Loop's approximating scheme),subdivide_to_sizeandsubdivide_region_to_size(until every edge, or every edge of a face region, is under a target length).
isotropic_remesh
isotropic_remesh(
vertices: array[vec3],
faces: array[int32],
*,
target_length: float | array[float32] | None = None,
iterations: int = 10,
feature_angle: float = 30.0,
split: bool = True,
collapse: bool = True,
swap: bool = True,
smooth: bool = True,
reproject: bool = True,
max_deviation: float | None = None,
) -> tuple[wp.array[wp.vec3], wp.array[wp.int32]]
Isotropic explicit remeshing (Botsch-Kobbelt split / collapse / flip / smooth / reproject).
GPU port of the classic incremental isotropic remesher (PyMeshLab's
meshing_isotropic_explicit_remeshing, vcglib IsotropicRemeshing): each iteration drives
all edge lengths toward target_length by (1) splitting every edge longer than
4/3 * target_length at its midpoint (crack-free, reusing
subdivide_to_size); (2) collapsing every edge shorter
than 4/5 * target_length (a parallel primitive with full 1-ring locking and a manifold
link-condition guard); (3) flipping interior edges toward the ideal vertex valence (6
interior, 4 boundary); (4) tangentially smoothing free vertices (area-equalizing Laplacian
projected onto the tangent plane); and (5) reprojecting free vertices back onto the original
surface. Feature and boundary structure is preserved: each vertex is classified FREE / CREASE
(on a boundary loop or a dihedral crease sharper than feature_angle) / CORNER (feature
junction or endpoint), corners are frozen, crease vertices only move along their feature, and
feature edges are never flipped. Passing max_deviation relaxes that last guarantee on
purpose — see its own entry below.
Inputs are cloned and never mutated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
target_length
|
float | array[float32] | None
|
Desired edge length. A scalar is the uniform target, defaulting to |
None
|
iterations
|
int
|
Number of full remeshing passes. |
10
|
feature_angle
|
float
|
Dihedral angle in degrees above which an interior edge is treated as a sharp feature (protected from flipping and collapsing across). |
30.0
|
split
|
bool
|
Enable/disable each stage of the per-iteration pipeline. |
True
|
collapse
|
bool
|
Enable/disable each stage of the per-iteration pipeline. |
True
|
swap
|
bool
|
Enable/disable each stage of the per-iteration pipeline. |
True
|
smooth
|
bool
|
Enable/disable each stage of the per-iteration pipeline. |
True
|
reproject
|
bool
|
Enable/disable each stage of the per-iteration pipeline. |
True
|
max_deviation
|
float | None
|
Bound on how far the result may move off the input surface, in model units. At the end of
every iteration each vertex further than this from the input surface is pulled straight back
toward its own closest point until it is exactly this far, bounding the result's one-sided
Hausdorff distance to the input. The clamp overrides feature preservation, deliberately, and it is the one thing here
that does. It runs over every vertex with no regard for its FREE / CREASE / CORNER
classification, because a crease or a corner is exactly the kind of vertex that drifts and
that |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
vertices |
array[vec3]
|
Remeshed vertex positions on |
faces |
array[int32]
|
Flat |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
See Also
Notes
Hysteresis (split above 4/3 t, collapse below 4/5 t) keeps split and collapse from
fighting. The collapse primitive guarantees manifoldness through the link condition but has no
normal-flip guard in this version, relying on the reprojection step to keep free vertices on the
original surface.
An adaptive field is re-sampled from the input surface before each stage that reads it, with
transfer_onto_vertices, rather than
transported through the split / collapse operations. The field is a property of the input
geometry, so re-sampling keeps it exact under an arbitrary sequence of operations where
transport would accumulate error; the cost is one closest-point query per vertex per stage (two
per iteration with both split and collapse on). Inside a single stage the field is
transported, because there the correspondence is known exactly: a split midpoint takes the mean
of the endpoints it splits, and a collapse compacts the bands alongside the vertices.
A constant field is not quite the scalar path: the two agree on the face buffer exactly and
on positions to within float rounding. The gap is float rounding in the threshold alone — the
array path forms 4/3 * t per vertex in float32 where the scalar path forms it in Python
float64 and narrows once. Pass a scalar when the target is uniform; it is also one
closest-point query per stage cheaper.
max_deviation is a positional bound applied per iteration, not a per-operation rejection
test: an individual collapse or flip is never vetoed for moving the surface too far, it is the
accumulated vertex position that is corrected afterwards. A mesh whose edges must never sweep
past the bound mid-iteration needs the flip stage's own gate as well
(flip_to_delaunay takes one).
How tightly the bound holds is worth stating, because it is set by
wp.mesh_query_point_no_sign rather than by this function. Against that query — the one the
clamp is implemented with, and the one reproject has always used — the result is within the
bound almost exactly. Against an independent closest-point query, the bound controls deviation
proportionally, but at a bound near Warp's own query accuracy it becomes approximate rather
than hard, because the two queries can disagree by a small absolute amount and iterating the
clamp does not converge further (Warp's answer is a fixed point). Ask for a bound comfortably
above the scale of a single-precision closest-point query, or scale the model up.
The remaining limitation, stated because the parameter that used to advertise it is gone:
PyMeshLab's selectedonly has no equivalent here, and a region-restricted refinement is
subdivide_region_to_size rather than a mode of this
function.
Source code in triwarp/remesh.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
cluster_decimate
cluster_decimate(
vertices: array[vec3],
faces: array[int32],
*,
voxel_size: float | None = None,
contraction: Literal["average", "closest"] = "average",
) -> tuple[wp.array[wp.vec3], wp.array[wp.int32]]
Decimate by snapping vertices to a uniform voxel grid and welding each cell to one vertex.
The one decimation scheme that is naturally parallel: there is no priority queue and no
sequential dependence anywhere, so the whole thing is a handful of kernel launches whatever the
mesh size. Every vertex is binned into a cell of width voxel_size, each occupied cell
becomes a single output vertex, faces are remapped onto those, and the faces that collapsed
(two or three corners in the same cell) or duplicated are dropped.
Ports MeshLab's meshing_decimation_clustering and Open3D's simplify_vertex_clustering;
the grid is anchored half a cell below the bounding box, which is Open3D's convention, so both
libraries produce the same cell assignment for the same voxel_size. The vertex output alone
is also MeshLab's generate_sampling_clustered_vertex.
This does not preserve topology
Two sheets of the surface that pass within voxel_size of each other get welded
together, and a thin feature narrower than a cell disappears. That is the point of the
algorithm — it is a resampling, not a simplification — but it means the result can be
non-manifold even when the input is not. Use
isotropic_remesh when the topology matters and
quadric_decimate when a face budget does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
voxel_size
|
float | None
|
Cell width. Defaults to |
None
|
contraction
|
Literal['average', 'closest']
|
How each cell picks its output position:
|
'average'
|
Returns:
| Name | Type | Description |
|---|---|---|
vertices |
array[vec3]
|
One position per occupied cell that still carries a face, compacted from index zero. |
faces |
array[int32]
|
Flat |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
See Also
quadric_decimate
The other way to simplify: a face budget and a quadric error metric, rather than a voxel
size.
isotropic_remesh
triwarp.repair.remove_duplicated_vertices
triwarp.grouping.unique_faces
triwarp.voxels.voxel_down_sample
Notes
Cells whose every face collapsed are dropped from the output, where Open3D keeps them as unreferenced vertices. So the face counts agree exactly and the vertex counts can differ by the number of such cells — usually zero, and never in a way that changes the surface.
The binning goes through triwarp.voxels.cell_indices, but the
dedup deliberately stays on triwarp.grouping.unique_rows
rather than moving onto a NanoVDB grid: a grid numbers its clusters leaf-major, so preserving
today's vertex order would need a restoring sort that gives back most of any gain, and it is not
worth changing the public output convention for what remains.
Source code in triwarp/remesh.py
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 | |
quadric_decimate
quadric_decimate(
vertices: array[vec3],
faces: array[int32],
*,
target_faces: int | None = ...,
target_ratio: float | None = ...,
feature_angle: float = ...,
max_iter: int = ...,
return_index: Literal[False] = False,
) -> tuple[wp.array[wp.vec3], wp.array[wp.int32]]
quadric_decimate(
vertices: array[vec3],
faces: array[int32],
*,
target_faces: int | None = ...,
target_ratio: float | None = ...,
feature_angle: float = ...,
max_iter: int = ...,
return_index: Literal[True],
) -> tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wp.array[wp.int32],
wp.array[wp.int32],
]
quadric_decimate(
vertices: array[vec3],
faces: array[int32],
*,
target_faces: int | None = None,
target_ratio: float | None = None,
feature_angle: float = 30.0,
max_iter: int = 100,
return_index: bool = False,
) -> (
tuple[wp.array[wp.vec3], wp.array[wp.int32]]
| tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wp.array[wp.int32],
wp.array[wp.int32],
]
)
Simplify to a target face count by quadric-error edge collapses (Garland-Heckbert).
The decimation to reach for when the requirement is a face budget rather than an edge
length: isotropic_remesh targets a length and
cluster_decimate a voxel size, and neither lets a caller
ask for "this mesh at 10 % of its triangles". This does, and it is the method every comparable
library exposes for the purpose (MeshLab's meshing_decimation_quadric_edge_collapse,
igl.decimate, Open3D's simplify_quadric_decimation).
Each vertex accumulates the area-weighted plane quadrics of its incident faces; the cost of collapsing an edge is the residual of the summed quadric at its own minimizer, which is also where the surviving vertex is placed. Cheap collapses are the ones that barely move the surface, so the flat regions go first and the features last — the property that makes this the standard method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
target_faces
|
int | None
|
Desired face count. Mutually exclusive with |
None
|
target_ratio
|
float | None
|
Desired face count as a fraction of the input's, so |
None
|
feature_angle
|
float
|
Dihedral angle in degrees above which an edge is a feature. Feature and boundary
structure is preserved exactly as in
|
30.0
|
max_iter
|
int
|
Cap on collapse passes. Each pass commits a conflict-free independent set, so a large reduction needs many; the loop also stops early once the target is met or a pass commits nothing. |
100
|
return_index
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
vertices |
array[vec3]
|
Simplified vertex positions on |
faces |
array[int32]
|
Flat |
vertex_index |
array[int32]
|
Only when |
face_index |
array[int32]
|
Only when |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither or both of |
RuntimeError
|
If |
Notes
This is a batched-parallel greedy method, not the textbook serial one, and the difference is visible in the output. Textbook QEM pops one edge at a time from a global priority queue, which is inherently sequential. Here each pass scores every edge, ranks the candidates by cost, and commits the cheapest independent set of them — two collapses may commit together only if their closed 1-rings are disjoint. So the sequence of collapses differs from a serial run's and the resulting triangulation is not the same mesh, even though both are driven by the same metric. Compare the two by deviation from the input rather than by equality.
In exchange the quality is competitive with the sequential method despite the different collapse order: committing an independent set spreads the error over the surface where draining a priority queue concentrates it, and a max-norm error measure rewards that.
A pass commits several independent sets against one scoring, not one. A single hashed-key
round takes on the order of m / 50 of the candidates, because each winner locks the closed
1-rings of both its endpoints, and rebuilding the geometry between rounds is comparatively
expensive. So the pass retires only the candidates the previous round's commits actually
invalidated — those whose closed 1-rings touch a collapsed neighbourhood, for which the cached
quadric, cost, target position, link condition and normal-flip verdict are the only things that
went stale — and runs another round until one finds nothing new.
That round loop runs entirely on device, as one wp.capture_while graph — see
_run_collapse_rounds — which removes the host readback that would otherwise happen once per
round.
The per-pass rebuild cost is dominated by the number of wrapper calls it issues rather than by
the mesh size, which is why it shares its edge grouping (an _EdgeIncidence) with
_classify instead of letting each re-derive it, and why _DecimationBuffers goes further
still and replays the whole rebuild as one captured graph with fixed-width buffers and live
sizes carried in a device array. Read that class before changing anything here.
return_index costs nothing when it is off and next to nothing when it is on. The two
provenance maps are folded per pass by two launches and one copy, and the branch that adds them
is evaluated when the pass is issued, so the captured graph a CUDA run replays does not even
contain it.
Four consequences to plan around:
- The target is reached exactly whenever it is reachable, and it is
feature_anglethat decides whether it is. A pass is budgeted at half the remaining surplus (an interior collapse removes two faces), shared across its rounds, and the loop stops early when a pass can commit nothing. What stops it is almost always the feature rule rather than the link condition or the normal-flip guard: a surface's own dihedral angles grow as it is coarsened, so past some face count every edge of a smooth mesh is sharper thanfeature_angle, every vertex becomes a frozen corner, and no collapse is legal at anymax_iter. That floor is the parameter working, not a limitation to route around — it is the same rule that keeps a cylinder's rim and a box's creases intact. Raisingfeature_anglelowers it; at 180 degrees nothing is a feature and the target is reached. Check the returned face count if it matters. - Every collapse is also checked against a normal-flip guard: an incident face whose normal
would turn by more than ~78 degrees vetoes it. That is what keeps the output free of the
inverted, self-intersecting triangles an unguarded quadric method produces at high reduction
ratios. It is not usually what stops a decimation short, and is deliberately not exposed
as a keyword — see
COLLAPSE_MIN_NORMAL_DOTinkernels/remesh.py, which records the veto census this claim rests on. - The independent set is chosen under a hashed lock key rather than by cost rank. That looks
like a detail and is not: on a structured mesh both the edge index and the quadric cost are
spatially monotone fields, and a monotone key has one local minimum, so either of those keys
would commit only a single collapse per pass. See
scramble_indexinkernels/remesh.py. - The output is not bit-reproducible on a mesh with tied costs, and never was. The vertex-face incidence CSR is built by an atomic counting scatter, so a row's order varies run to run; where two candidate edges tie on cost, which one the sort keeps varies with it. On a mesh with many tied costs this can move the two-sided Hausdorff distance noticeably between otherwise identical runs, so treat the max-norm as a band, not a value — the mean deviation is far more stable. Compare a change to this function on the mean, or on many repeats.
Source code in triwarp/remesh.py
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 | |
flip_to_delaunay
flip_to_delaunay(
vertices: array[vec3],
faces: array[int32],
region: array[bool] | None = None,
max_angle_change: float | None = None,
max_deviation: float | None = None,
critical_aspect_ratio: float = 1000.0,
max_iter: int = 100,
) -> wp.array[wp.int32]
Improve triangle quality by flipping interior edges toward the Delaunay criterion.
For every interior edge whose two incident faces are both in region, the shared diagonal
is flipped when doing so satisfies the local Delone (empty-circumcircle) test — subject to an
optional dihedral-angle-change gate and a surface-deviation gate, so the flips never distort
the surface. Rim edges (with a face
outside the region, or on the mesh boundary) are never flipped. Vertices, face count and
region membership are unchanged; only the triangulation of the region is rewritten.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
region
|
array[bool] | None
|
Optional length- |
None
|
max_angle_change
|
float | None
|
Maximum dihedral-angle change (radians) a flip may introduce. |
None
|
max_deviation
|
float | None
|
Maximum surface deviation a flip may introduce. |
None
|
critical_aspect_ratio
|
float
|
Triangle aspect ratio above which the dihedral-angle gate is lifted, so degenerate triangles can still be repaired. |
1000.0
|
max_iter
|
int
|
Maximum number of parallel flip passes. |
100
|
Returns:
| Type | Description |
|---|---|
array[int32]
|
Flat face buffer with the region re-triangulated, on |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
See Also
flip_by_objective
The same flip engine with a shape or flatness predicate in front of it instead of the
Delone test.
subdivide_region_to_size
delaunay_triangulation
face_adjacency
Source code in triwarp/remesh.py
1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 | |
flip_by_objective
flip_by_objective(
vertices: array[vec3],
faces: array[int32],
*,
objective: Literal[
"planarity", "curvature", "t_vertex"
] = "planarity",
region: array[bool] | None = None,
planar_angle: float = 1.0,
metric: Literal[
"radius_ratio", "area_max_side", "mean_ratio"
] = "area_max_side",
aspect_threshold: float = 40.0,
max_iter: int = 100,
) -> wp.array[wp.int32]
Flip interior edges to optimize triangle shape or surface flatness, instead of the Delone test.
Runs the same parallel flip engine as flip_to_delaunay —
independent-set selection over the face adjacency, iterated until no edge is a candidate — with
a different predicate at the front. That is the whole port: the machinery was already there, and
these two objectives are what MeshLab's meshing_edge_flip_by_planar_optimization and
meshing_edge_flip_by_curvature_optimization put in front of it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
objective
|
Literal['planarity', 'curvature', 't_vertex']
|
Which predicate to flip on:
|
'planarity'
|
region
|
array[bool] | None
|
Optional length- |
None
|
planar_angle
|
float
|
Planarity tolerance in degrees for |
1.0
|
metric
|
Literal['radius_ratio', 'area_max_side', 'mean_ratio']
|
Which |
'area_max_side'
|
aspect_threshold
|
float
|
Sliver threshold for |
40.0
|
max_iter
|
int
|
Maximum number of parallel flip passes. Each pass commits a conflict-free independent set, so a mesh needing many local rewrites needs several. |
100
|
Returns:
| Type | Description |
|---|---|
array[int32]
|
Flat face buffer with the region re-triangulated, on |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
Notes
A quad whose two diagonals score equally — every quad of a regular grid — would flip back and
forth forever, one pass each way, so a flip must beat the incumbent by a relative 1e-6
rather than merely tie it. That margin is what makes max_iter a safety net rather than the
normal stopping condition.
Source code in triwarp/remesh.py
2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 | |
intrinsic_delaunay
intrinsic_delaunay(
vertices: array[vec3],
faces: array[int32],
epsilon: float = TOLERANCE_MOLLIFY,
max_iter: int = 100,
) -> tuple[wp.array[wp.int32], twt.Array2dFloat32, int]
Retriangulate to the intrinsic Delaunay triangulation, without moving a vertex.
Flips edges whose two opposite angles sum past pi — exactly the edges whose cotangent weight
is negative — until none is left. The flip is intrinsic: the new edge is not a straight line
in space but the geodesic across the two triangles, and its length comes from unfolding them
into a plane and measuring the other diagonal. The surface, its vertices and its metric are all
untouched; only which pairs of vertices count as connected changes, so every operator built from
the result is a better-behaved operator for the same geometry.
Its practical effect is that the cotangent weights all become non-negative, which is what a Laplacian needs to satisfy a maximum principle: no spurious extrema, no negative diffusion, far better conditioned solves on a badly-shaped mesh.
Flips run in parallel rounds, each committing a conflict-free independent set (the same engine
behind flip_to_delaunay) with the edge-length table carried
alongside the connectivity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
epsilon
|
float
|
Mollification margin applied before flipping, relative to the mean edge length: a degenerate triangle has no well-defined angles to test. |
TOLERANCE_MOLLIFY
|
max_iter
|
int
|
Cap on the number of parallel flip rounds. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
intrinsic_faces |
array[int32]
|
Length- |
edge_lengths |
Array2dFloat32
|
|
n_flips |
int
|
How many edges were flipped. Zero means the input was already intrinsically Delaunay. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Notes
Unlike the other flip passes in this module, this one can create a second edge between two
vertices some other edge already connects — intrinsically that is a different geodesic, not a
duplicate, and the flip loop tracks connectivity through an incrementally-maintained halfedge
twin table rather than a vertex-pair key, so the two never collide. The one thing that still
cannot be flipped away is a negative weight on a boundary edge: the Delaunay two-opposite-
angles condition has nothing to compare a boundary edge's one incident angle against, so no
flip of any kind addresses it. A caller that needs the maximum principle should check the
weights it got (cotmatrix_entries_intrinsic)
rather than inferring them from convergence.
Source code in triwarp/remesh.py
2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 | |
subdivide
subdivide(
vertices: array[vec3], faces: array[int32]
) -> tuple[wp.array[wp.vec3], wp.array[wp.int32]]
Subdivide a mesh by splitting every face into four triangles.
Each triangle is split by placing a new vertex at the midpoint of each
edge. The four child triangles share these midpoints and preserve the
original winding order, matching trimesh.remesh.subdivide exactly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
Returns:
| Type | Description |
|---|---|
tuple[array[vec3], array[int32]]
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
See Also
Source code in triwarp/remesh.py
2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 | |
subdivide_loop
subdivide_loop(
vertices: array[vec3],
faces: array[int32],
*,
return_operator: Literal[False] = False,
) -> tuple[wp.array[wp.vec3], wp.array[wp.int32]]
subdivide_loop(
vertices: array[vec3],
faces: array[int32],
*,
return_operator: Literal[True],
) -> tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wps.BsrMatrix[wp.float32],
]
subdivide_loop(
vertices: array[vec3],
faces: array[int32],
*,
return_operator: bool = False,
) -> (
tuple[wp.array[wp.vec3], wp.array[wp.int32]]
| tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wps.BsrMatrix[wp.float32],
]
)
Subdivide a mesh with one pass of Loop subdivision.
Same 1-to-4 split as subdivide -- identical face table, identical
index layout -- but the positions are the smooth Loop stencils rather than midpoints, so the
surface is approximated instead of interpolated: original vertices move, and repeated
application converges to a C² limit surface (C¹ at irregular vertices).
- Odd (edge) vertices, one per unique edge:
3/8on each endpoint and1/8on each of the two vertices opposite the edge. A boundary edge takes the midpoint instead. - Even (original) vertices, interior:
(1 - n * beta) * v + beta * sum(ring)with Warren'sbeta--3/16at valence 3,3/(8n)above -- which is the variantigl.loopuses, rather than Loop's original trigonometric weight. - Even vertices on a boundary:
3/4 * vplus1/8of each of the two neighbours along the boundary, with interior neighbours excluded, so a boundary curve subdivides identically from either side of a seam.
The mesh should be edge-manifold. Where it is not, the stencils are not defined and the fallbacks are conservative rather than arbitrary: an edge with three or more incident faces takes the midpoint rule, and a vertex where one or three-plus boundary edges meet -- or one with no edges at all -- keeps its position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
return_operator
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
new_vertices |
array[vec3]
|
Positions on |
new_faces |
array[int32]
|
Flat |
operator |
BsrMatrix
|
Only when |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Notes
Why an operator rather than an index map. Every other topology edit here reports provenance
as one int32 per output element, because each output comes from exactly one input. A Loop
vertex does not: an odd vertex is an affine combination of four inputs and an even vertex of its
whole 1-ring, so no index map can express it, and an attribute cannot otherwise be carried
through this function at all. The operator is the honest form, it is the standard prolongation
object (kernels/algorithms/multigrid.py builds one for a different purpose), and it costs
nothing unless asked for.
The operator is assembled from the same three grids and through the same two weight functions
(kernels/remesh.loop_odd_weights / loop_even_weights) that the position kernels use, so
the two cannot drift onto different surfaces. It is not used to compute the positions -- those
stay two direct kernels, since a bsr_from_triplets build plus a bsr_mv would make every
caller pay for the matrix.
Four launches over three grids -- faces, unique edges, vertices -- plus the shared topology.
Neither stencil needs an ordered 1-ring: the valence and the ring sum come from an atomic pass
over the unique edges, which is the deduplicated neighbour count igl::loop reads off a
sorted adjacency list, and the two boundary neighbours are found as the ones joined by boundary
edges rather than as the ends of that list.
For several passes, call this repeatedly -- that is what igl.loop's number_of_subdivs
does internally, and each pass multiplies the face count by four.
See Also
subdivide
subdivide_to_size
igl.loop
Source code in triwarp/remesh.py
2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 | |
subdivide_to_size
subdivide_to_size(
vertices: array[vec3],
faces: array[int32],
max_edge: float | array[float32],
max_iter: int = 10,
return_index: Literal[False] = False,
) -> tuple[wp.array[wp.vec3], wp.array[wp.int32]]
subdivide_to_size(
vertices: array[vec3],
faces: array[int32],
max_edge: float | array[float32],
max_iter: int = 10,
*,
return_index: Literal[True],
) -> tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wp.array[wp.int32],
]
subdivide_to_size(
vertices: array[vec3],
faces: array[int32],
max_edge: float | array[float32],
max_iter: int = 10,
return_index: bool = False,
) -> (
tuple[wp.array[wp.vec3], wp.array[wp.int32]]
| tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wp.array[wp.int32],
]
)
Subdivide a mesh until every edge is at most max_edge long.
Every edge longer than max_edge is bisected at a single shared midpoint,
so the two faces on either side stay in sync and a watertight input stays
watertight — no T-junctions (cracks) are introduced. Faces already small
enough are left untouched. Each pass splits every over-long edge once and
re-triangulates the incident faces with per-face templates (1, 2, or 3 split
edges; the 2-split quad is cut along its shorter diagonal), iterating until
no edge exceeds the threshold, matching
trimesh.remesh.subdivide_to_size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
max_edge
|
float | array[float32]
|
Maximum length of any edge in the result. A scalar gives the uniform target; a
|
required |
max_iter
|
int
|
Maximum number of subdivision passes. A |
10
|
return_index
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
new_vertices |
array[vec3]
|
Refined vertex positions on |
new_faces |
array[int32]
|
Flat buffer of the refined faces. |
index |
array[int32]
|
Only returned when |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any edge is still longer than |
RuntimeError
|
If |
Source code in triwarp/remesh.py
2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 | |
subdivide_region_to_size
subdivide_region_to_size(
vertices: array[vec3],
faces: array[int32],
region: array[bool],
max_edge: float,
max_iter: int = 10,
max_splits: int | None = None,
delaunay: bool = True,
max_angle_change: float | None = math.pi / 6.0,
max_deviation: float | None = None,
) -> tuple[
wp.array[wp.vec3], wp.array[wp.int32], wp.array[wp.bool]
]
Subdivide only a face region until its edges are at most max_edge long.
The region-restricted form of subdivide_to_size, and the
refinement stage of the smooth-patch pipeline: every edge with at least one incident region
face and length
greater than max_edge is bisected, the incident faces are re-triangulated crack-free
(the subdivide_to_size 1/2/3-split templates, so faces
outside the region that touch a split edge stay watertight), and — unless disabled — a
parallel Delaunay edge-flip pass (flip_to_delaunay)
improves the region triangulation after each pass. New vertices are appended after the
originals, so the caller derives the new-vertex set as the index range
[len(vertices), len(new_vertices)).
Where a sequential implementation would drive this from a longest-edge-first priority queue,
splitting is done in parallel passes; max_splits is honoured as a soft budget by keeping
only the longest eligible edges of the pass that would exceed it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
region
|
array[bool]
|
Length- |
required |
max_edge
|
float
|
Target maximum edge length inside the region. |
required |
max_iter
|
int
|
Maximum number of subdivision passes. |
10
|
max_splits
|
int | None
|
Optional soft cap on the total number of edge splits. |
None
|
delaunay
|
bool
|
When |
True
|
max_angle_change
|
float | None
|
Dihedral-angle-change gate (radians) for the flip pass (default 30°). |
pi / 6.0
|
max_deviation
|
float | None
|
Surface-deviation gate for the flip pass. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
new_vertices |
array[vec3]
|
Original vertices followed by the inserted midpoints, on |
new_faces |
array[int32]
|
Flat buffer of the refined faces. |
new_region |
array[bool]
|
Length |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
See Also
Source code in triwarp/remesh.py
2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 | |
refine_region_to_density
refine_region_to_density(
vertices: array[vec3],
faces: array[int32],
region: array[bool],
*,
max_iter: int = 10,
alpha: float = math.sqrt(2.0),
delaunay: bool = True,
max_angle_change: float | None = math.radians(30.0),
max_deviation: float | None = None,
) -> tuple[
wp.array[wp.vec3], wp.array[wp.int32], wp.array[wp.bool]
]
Refine a face region until its sampling matches the surrounding mesh's, not a target length.
The density-driven sibling of
subdivide_region_to_size, and the difference is the
criterion rather than the mechanism. That one bisects every region edge longer than a single
global max_edge; this one gives each vertex a scale attribute -- the average length of
the edges incident to it -- and splits a region triangle only while its own scale is coarse
relative to its corners'. On a uniformly sampled neighbourhood the two agree; on a graded one
they do not, because a single length cannot be right at both ends of the grading.
The rule is Liepa's (see Notes). Writing sigma(v) for the scale attribute, c for a
triangle's centroid and sigma(c) for the mean of its three corners' attributes, the triangle
is split at c when
``alpha * |c - v_m| > sigma(c)`` and ``alpha * sigma(c) > sigma(v_m)``
holds for every corner m. The first clause refines; the second is what makes the process
terminate at the surrounding sampling rather than at a tolerance. A pass that splits nothing
ends the loop.
The split is a 1 -> 3 centroid split, which is what makes this cheap in parallel: the new
vertex is interior to the triangle and no edge is divided, so there is nothing to agree with the
neighbours about and no crack-free template is needed -- unlike edge bisection, which is why
subdivide_region_to_size carries the 1/2/3 split families. One pass is two prefix scans and
one kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
region
|
array[bool]
|
Length- |
required |
max_iter
|
int
|
Cap on refinement passes. Unlike |
10
|
alpha
|
float
|
The criterion's constant, |
sqrt(2.0)
|
delaunay
|
bool
|
When |
True
|
max_angle_change
|
float | None
|
Dihedral-angle-change gate for that flip pass (default 30 degrees). |
radians(30.0)
|
max_deviation
|
float | None
|
Surface-deviation gate for the flip pass. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
new_vertices |
array[vec3]
|
Positions with the centroid vertices appended after the originals, so the caller derives the
new-vertex set as the index range |
new_faces |
array[int32]
|
Flat buffer of the refined faces. |
new_region |
array[bool]
|
Length |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
See Also
subdivide_region_to_size
The same operation driven by a target edge length instead.
smoothing.refine_and_smooth_region
Where the two criteria are selected between, and what the hole fillers reach through.
holes.fill_smooth
Notes
The criterion is section 3 of P. Liepa, "Filling holes in meshes", Eurographics/ACM SIGGRAPH Symposium on Geometry Processing (2003).
The scale attribute is computed once, from the mesh as given, and only extended as vertices are added -- a centroid inherits the mean of its parents'. That is the point of it: it carries the surrounding sampling inward across the patch instead of being re-measured from the increasingly fine triangles it is producing, which would never converge.
Source code in triwarp/remesh.py
3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 | |
split_edges
split_edges(
vertices: array[vec3],
faces: array[int32],
split_mask: array[bool],
split_positions: array[vec3] | None = None,
*,
unique_edges: Array2dInt32 | None = None,
inverse: array[int32] | None = None,
index: array[int32] | None = None,
return_index: Literal[False] = False,
) -> tuple[wp.array[wp.vec3], wp.array[wp.int32]]
split_edges(
vertices: array[vec3],
faces: array[int32],
split_mask: array[bool],
split_positions: array[vec3] | None = None,
*,
unique_edges: Array2dInt32 | None = None,
inverse: array[int32] | None = None,
index: array[int32] | None = None,
return_index: Literal[True],
) -> tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wp.array[wp.int32],
]
split_edges(
vertices: array[vec3],
faces: array[int32],
split_mask: array[bool],
split_positions: array[vec3] | None = None,
*,
unique_edges: Array2dInt32 | None = None,
inverse: array[int32] | None = None,
index: array[int32] | None = None,
return_index: bool = False,
) -> (
tuple[wp.array[wp.vec3], wp.array[wp.int32]]
| tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wp.array[wp.int32],
]
)
Split a chosen set of edges in one crack-free pass, inserting one vertex per edge.
The primitive the whole subdivide_* family is built from, exposed because the choice of
edges and the position of the new vertex are the only things that differ between its members:
subdivide_to_size iterates this with a length test and
midpoints, and
triwarp.intersection.split_mesh_with_plane calls
it once with the edges a plane crosses and the crossing points. A caller with a different
criterion — a curvature threshold, a paint selection, an isovalue — needs no new machinery.
Crack-free means the new vertex of an edge is inserted once and both incident faces reference it, so a watertight input stays watertight and no T-junction is introduced. Each face is re-triangulated by how many of its three edges were split: 1 gives two triangles, 2 gives three (the quad cut along its shorter diagonal), 3 gives the regular 1-to-4 split, and 0 passes through unchanged.
Every return is freshly allocated and independently owned, on the path where nothing was
flagged and the mesh comes back unchanged as much as on the splitting one -- including
index, which is a copy of the caller's rather than the array they passed in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
split_mask
|
array[bool]
|
|
required |
split_positions
|
array[vec3] | None
|
Where to put each new vertex, as a |
None
|
unique_edges
|
Array2dInt32 | None
|
The |
None
|
inverse
|
Array2dInt32 | None
|
The |
None
|
index
|
array[int32] | None
|
|
None
|
return_index
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
new_vertices |
array[vec3]
|
Original vertices followed by the |
new_faces |
array[int32]
|
Flat |
index |
array[int32]
|
Only when |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
See Also
subdivide_to_size
subdivide
triwarp.intersection.split_mesh_with_plane
triwarp.edges.edges_unique
Examples:
Splitting every edge is the regular 1-to-4 subdivision, so the face count quadruples:
unique_edges, inverse = tw.edges.edges_unique(f)
every_edge = wp.full(int(unique_edges.shape[0]), True, dtype=wp.bool, device=f.device)
fine_v, fine_f = tw.remesh.split_edges(
v, f, every_edge, unique_edges=unique_edges, inverse=inverse
)
print(int(fine_f.shape[0]) // 3 == 4 * (int(f.shape[0]) // 3))
Source code in triwarp/remesh.py
3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 | |