Skip to content

Geometry and generation API

See the hands-on geometry guide before the reference.

rbflab.geometry.PointCloud dataclass

Validated 2D or 3D coordinates with tagged boundary nodes.

Parameters:

Name Type Description Default
points ndarray

Finite, unique coordinates with shape (N, dimension).

required
boundary dict

Mapping from boundary label to arrays of point indices.

required
normals dict

Mapping from labels to unit-normal arrays matching their nodes.

required
triangles ndarray

Optional (T, 3) connectivity for visualization.

(lambda: empty((0, 3), dtype=int))()
interfaces dict

Named internal-interface node indices (remain interior).

dict()
regions dict

Named region node indices, which may overlap.

dict()

rbflab.geometry.unit_box_grid(cells=5, dimension=2)

Small structured unit-box cloud for examples; Gmsh is not required.

Face labels and outward normals are supplied for boundary operators. Corners belong to each adjacent face; boundary conditions take list order.

rbflab.geometry.gmsh_square(cells=8, filename=None)

Create a deterministic transfinite triangular unit-square mesh.

Physical curve labels are bottom/right/top/left. Connectivity is for visualization; collocation uses only coordinates, labels and normals. Owns a short Gmsh session; does not clear a caller's existing Gmsh model.

rbflab.geometry.gmsh_cube(cells=4, filename=None)

Transfinite unit cube with six tagged faces and outward unit normals.

Gmsh generates hexahedra; collocation uses only the points. Volume connectivity is not stored in PointCloud. An optional .msh retains it.

rbflab.geometry.MeshPoint

Legacy labeled planar sample; use PointCloud for array-based PDE work.

rbflab.geometry.Border

Labeled parametric curve with signed segment-count syntax.

Parameters:

Name Type Description Default
parametric_function Callable | Sequence

Callable t -> (x, y), or two SymPy coordinate expressions. Bind extra symbolic parameters first.

required
label str | int

Boundary or interface group name; arcs may share a label.

required
t_start float

Initial parameter value.

required
t_end float

Distinct final parameter value; decreasing intervals work.

required
is_border bool

Retain samples as labeled boundary/interface nodes.

True
tangent Callable | Sequence | None

Optional derivative in the original parameter direction. Otherwise symbolic curves differentiate exactly, and ordinary callables use second-order finite differences.

None
parameter Symbol | None

Symbolic parameter; inferred if unambiguous.

None
normal Callable | Sequence | None

Explicit outward normal n(t), normalized on generation. Not flipped by negative segment counts.

None
difference_step float | None

Numerical derivative step in parameter units, default interval length times machine-epsilon^(1/3).

None

Call border(n) to select abs(n) segments; negative n reverses traversal. Sampling is uniform in the parameter and excludes the terminal endpoint. A call modifies this object; create distinct objects for distinct arcs. meshgen.generate accepts a list of sampled borders directly, computes outward normals, and returns a PointCloud. Split curves at corners/cusps.

get_midpoint()

Calculates the midpoint of the border.

Returns:

Name Type Description
tuple tuple

The coordinates of the midpoint.

generate_points()

Generates mesh points along the border.

Returns:

Name Type Description
list list

A list of MeshPoint objects representing the generated points.

rbflab.geometry.is_close(point1, point2, tolerance=1e-06)

Checks if two points are close to each other within a given tolerance.

Parameters:

Name Type Description Default
point1 tuple

The coordinates of the first point.

required
point2 tuple

The coordinates of the second point.

required
tolerance float

The tolerance for distance comparison. Defaults to 1e-6.

1e-06

Returns:

Name Type Description
bool bool

True if the points are close, False otherwise.

rbflab.geometry.find_polygons(borders, tolerance=1e-06)

Find directed closed contours without discarding open borders.

For shared junctions, each border uses a shortest directed closing path (in number of borders). Duplicate cycles are removed. Input order breaks ties; border direction is never silently reversed.

Parameters:

Name Type Description Default
borders list[Border]

A list of Border objects representing the borders.

required
tolerance float

The tolerance for distance comparison. Defaults to 1e-6.

1e-06

Returns:

Name Type Description
list list

A list of lists, where each inner list represents a group of connected borders forming a polygon.

rbflab.geometry.MeshPoint3D

A labeled point in three-dimensional space.

rbflab.geometry.ImplicitRegion

A bounded volume described by field(x, y, z) <= 0.

Parameters:

Name Type Description Default
field Callable

Scalar or NumPy-vectorized implicit function. Negative values are inside the region and zero is its boundary.

required
bounds Sequence

Three (minimum, maximum) pairs for x, y, and z.

required
label object

Optional point label. An automatic region label is used when omitted.

None
boundary_label object

Exterior boundary label; defaults to label when supplied, otherwise "boundary".

None
surface_area float | None

Optional positive known boundary area.

None
gradient Callable | None

Gradient of field, returning three components. Used for surface projection and outward normals; finite differences provide a fallback when omitted.

None
volume float | None

Optional known volume. It avoids numerical volume estimation when points are allocated across multiple regions.

None
clearance Callable | None

Optional function returning a positive physical distance to the boundary for interior points.

None
max_clearance float | None

Optional greatest possible interior clearance.

None

contains_points(points, *, strict=False, tolerance=1e-12)

Return a Boolean mask indicating which points are in the region.

contains(x, y, z, *, strict=False, tolerance=1e-12)

Return whether one point is in the region.

clearance_points(points)

Return physical interior boundary clearance for the supplied points.

gradient_points(points)

Evaluate an outward-pointing field gradient at multiple points.

boundary_candidates(unit_points, *, tolerance=1e-08, max_iterations=30)

Project bounding-box candidates onto the implicit zero level set.

rbflab.geometry.Sphere

Bases: ImplicitRegion

A solid ball with analytic membership, clearance and surface normals.

Parameters:

Name Type Description Default
center Sequence

Three coordinates of the center; defaults to the origin.

(0, 0, 0)
radius float

Positive physical radius, default 1.

1
label object

Optional label for the volume region.

None
boundary_label object

Surface label; defaults to label if supplied, otherwise "boundary".

None

Pass to meshgen.generate with separate interior and boundary counts. Boundary samples lie on the sphere and normals point radially outward.

rbflab.geometry.Box

Bases: ImplicitRegion

An axis-aligned solid box with individually labeled faces.

Parameters:

Name Type Description Default
minimum Sequence

Lower x, y, z coordinates, default (-1, -1, -1).

(-1, -1, -1)
maximum Sequence

Upper x, y, z coordinates, default (1, 1, 1). Each must exceed the corresponding minimum.

(1, 1, 1)
label object

Optional volume-region label.

None
boundary_labels dict | None

Optional face-name replacements, e.g. {"xmin": "inlet", "xmax": "outlet"}. Available keys are xmin, xmax, ymin, ymax, zmin, zmax; omitted faces keep their names.

None

meshgen.generate allocates the total boundary count across faces by area; it does not guarantee an exact count per face. Normals are face normals.

rbflab.geometry.Cylinder

Bases: ImplicitRegion

A finite solid cylinder with a lateral wall and two end caps.

Parameters:

Name Type Description Default
center Sequence

Midpoint of the cylinder axis, default (0, 0, 0).

(0, 0, 0)
radius float

Positive radius, default 1.

1
height float

Positive full axial length, default 2.

2
axis str

One of "x", "y", "z"; defaults to "z".

'z'
label object

Optional volume-region label.

None
boundary_labels dict | None

Optional replacements for side, bottom, and top. Bottom is the negative-axis cap; top is positive-axis.

None

The caps are center[axis] +/- height/2. Boundary sampling allocates a total count by surface area; normals point out of the solid.

rbflab.geometry.TriangleMesh2D

Validated conforming planar mesh, copied from zero-based arrays.

boundary_edges and interface_edges map str/int labels to (K, 2) vertex-index arrays. If boundary_edges is omitted, all exterior edges use label 'boundary'. Explicit boundary labels must cover every exterior edge. Triangle rows and vertex rows retain their original ordering/orientation.

rbflab.geometry.StaggeredLayout dataclass

Vertex and edge-midpoint clouds with explicit 2D triangle topology.

rbflab.geometry.staggered_clouds(mesh, triangles=None, boundary_edges=None, *, interface_edges=None, vertex_normals=None, edge_midpoint_normals=None)

Construct vertex and unique-edge-midpoint clouds.

Accept TriangleMesh2D or (vertices, triangles, boundary_edges) arrays. Optional normal maps override computed normals per label, aligned with sorted vertex indices or sorted edge indices respectively. Supplied normals are trusted to follow the caller's CAD orientation.

rbflab.geometry.save_staggered_layout(path, layout)

Save one compressed NPZ with numeric arrays and JSON metadata; no pickle.

rbflab.geometry.load_staggered_layout(path)

Read an archive without pickle and rebuild/validate deterministic topology.

rbflab.geometry.ParametricBoundary dataclass

A labeled regular planar curve, sampled approximately by arc length.

Parameters:

Name Type Description Default
curve Callable | Sequence

Callable t -> (x, y), or two SymPy expressions.

required
tangent Callable | Sequence | None

Optional derivative. Symbolic curves are differentiated exactly; ordinary callables use second-order finite differences when this is omitted.

None
label object

Unique arc name within its ParametricDomain.

'boundary'
interval tuple

Increasing finite parameter endpoints, default (0, 2*pi).

(0.0, 2 * pi)
parameter Symbol | None

Symbolic parameter; inferred if unambiguous.

None
normal Callable | Sequence | None

Explicit outward normal n(t), normalized on sampling. Overrides tangent-derived normals and is never flipped.

None
difference_step float | None

Finite-difference step in parameter units. Default is interval length times machine-epsilon^(1/3). Endpoint stencils are one-sided and never evaluate outside the interval.

None

Arcs in a contour must connect. Each arc excludes its terminal endpoint; the next arc owns the junction. Split curves at corners and singular points. Symbolic expressions must have all extra parameters substituted beforehand. Explicit normals must already point out of the material, including into holes.

derivative_source property

Return explicit, symbolic, or finite_difference for the tangent source.

evaluate(t)

Evaluate either a symbolic or callable curve at a scalar parameter.

sample(count)

Return samples and right-hand normals, or explicit outward overrides.

ParametricDomain corrects tangent-derived normals to point outward. Explicit normal callbacks already specify outward orientation.

rbflab.geometry.ParametricDomain

One closed outer contour with optional closed holes.

Parameters:

Name Type Description Default
outer ParametricBoundary | Sequence

ParametricBoundary or sequence of connected boundary arcs.

required
holes Sequence

Sequence of boundaries or arc sequences, one per hole.

()

Orientation may be clockwise or counterclockwise: outward normals are corrected automatically, including on holes. Explicit normal overrides keep their supplied direction. Labels must be unique across arcs. Membership uses 2048 straight segments per arc; refine the geometric model separately when studying very small spatial errors.

contains_points(points)

Return membership in the closed computational domain.

sample_boundary(counts)

Return label -> (coordinates, outward unit normals).

rbflab.geometry.Disk

Bases: Ellipse

Filled circular 2D domain, including its labeled perimeter.

Parameters:

Name Type Description Default
radius float

Positive radius, default 1.

1.0
center tuple

Finite (x, y) center, default (0, 0).

(0.0, 0.0)
label str

Name of the entire circular boundary, default boundary.

'boundary'

meshgen.generate(Disk(.8), interior=200, boundary=80) samples the filled disk and its perimeter. Use with_holes to remove an inner disk, or Annulus for concentric circles. Use Ellipse with equal axes for labeled circle arcs.

rbflab.geometry.Ellipse

Bases: ParametricDomain

Ellipse with analytic membership and automatically oriented normals.

Parameters:

Name Type Description Default
a float

Positive semi-axis along the local x direction (not full width).

1.3
b float

Positive semi-axis along the local y direction (not full height).

0.8
center tuple

Physical (x, y) center, default (0, 0).

(0.0, 0.0)
angle float

Counterclockwise rotation in radians, default zero.

0.0
labels Sequence[str]

One label for the full boundary, or distinct labels for equal parameter-angle arcs starting at local (a, 0). Four labels cover t in [0, pi/2), [pi/2, pi), [pi, 3pi/2), [3pi/2, 2*pi).

('boundary',)

The curve is center + rotation(angle) @ (acos(t), bsin(t)). Arc labels rotate with the shape. Node counts may be a total or a dictionary per label. Sampling along each arc is approximately uniform in physical arc length.

rbflab.geometry.Annulus

Bases: ParametricDomain

Planar material between two concentric circles.

Parameters:

Name Type Description Default
inner_radius float

Positive hole radius, smaller than outer_radius.

0.4
outer_radius float

Positive exterior radius, default 1.

1.0
center tuple

Common finite (x, y) center, default (0, 0).

(0.0, 0.0)

Labels are inner and outer. Counts can be set separately with boundary={"inner": 40, "outer": 80}. Inner normals point toward the center; outer normals point away. Membership is analytic rather than polygonal.

rbflab.geometry.Flower

Bases: ParametricDomain

Smooth filled domain with a radial, petal-shaped boundary.

Parameters:

Name Type Description Default
radius float

Positive reference radius in r(t)=radius(1+amplitudecos(petals*t)).

1.0
amplitude float

Relative modulation, 0 <= amplitude < 1; zero is a disk.

0.18
petals int

Positive number of lobes, default 5.

5
center tuple

Finite (x, y) center, default (0, 0).

(0.0, 0.0)
label str

Name for the complete exterior boundary, default boundary.

'boundary'

Membership is analytic. Large amplitudes create narrow necks needing suitable node resolution. This constructor provides one label; use ParametricBoundary arcs if different portions require different boundary conditions.

rbflab.geometry.Polygon

Bases: ParametricDomain

Simple planar polygon with one named straight boundary per edge.

Parameters:

Name Type Description Default
vertices array - like

At least three distinct finite (x, y) vertices in contour order. A repeated closing vertex is accepted and removed.

required
labels Sequence[str] | None

One distinct label per edge; defaults to edge_0, edge_1, ... .

None

Both orientations and concave polygons are supported. Self-intersections, repeated vertices and zero-area contours are rejected. Edge j joins vertex j to j+1 (cyclically); a corner belongs to the edge starting there. Its normal is that edge's outward normal, not an averaged corner normal.

rbflab.geometry.Rectangle

Bases: Polygon

Rectangle with optional rotation and individually labeled sides.

Parameters:

Name Type Description Default
width float

Positive length along the local x axis.

2.0
height float

Positive length along the local y axis.

1.0
center tuple

Two finite center coordinates.

(0.0, 0.0)
angle float

Counterclockwise rotation in radians.

0.0
labels Sequence[str]

Labels for local bottom, right, top, left sides, in that order.

('bottom', 'right', 'top', 'left')

Labels rotate with the rectangle. Junction ownership follows Polygon.

rbflab.geometry.with_holes(outer, holes)

Cut named, disjoint holes from a planar domain without changing inputs.

Parameters:

Name Type Description Default
outer ParametricDomain

Outer domain, optionally already perforated.

required
holes dict

Nonempty mapping from a nonempty string name to a simply connected ParametricDomain such as Disk, Ellipse or Polygon.

required

Returns:

Name Type Description
ParametricDomain ParametricDomain

A new domain with preserved exterior labels. A single-arc hole gets its mapping key as label; multi-arc holes get name/edge_label. Hole normals point out of the material.

Holes must lie strictly inside the existing material, without touching or overlapping each other. Existing holes are preserved. Topology and generic membership use the polygon representation of curved contours (2048 segments per arc), while sampling retains the analytic curves/tangents. This is a hole-composition helper, not a general Boolean CAD engine.

rbflab.meshgen.generate

Reproducible node generation returning the shared PointCloud contract.

generate(domain, *, interior=None, boundary=None, method='halton', seed=0, boundary_distance=0.0, max_candidates=1000000, normals=None, degree=None)

Generate labeled 2D/3D nodes through one geometry-independent entry point.

Parameters:

Name Type Description Default
domain ParametricDomain | ImplicitRegion | ParametricSurface3D | Border | Sequence | RBFMesh

Primitive/parametric 2D domain, implicit 3D region, sampled Border, list/tuple of sampled borders, an RBFMesh construction, or a ParametricSurface3D (use interior=0 for a surface).

required
interior int | None

Nonnegative number of points sampled in the material. Default 400 for random/Halton/Sobol; omit for Padua generation. Retained internal-interface samples add further interior unknowns.

None
boundary int | dict | None

Boundary count for domains (default 100). 2D parametric domains also accept a count per arc label. For borders, omit this argument: counts are already fixed by border(n).

None
method str

random, halton, sobol, or padua. Padua is 2D only.

'halton'
degree int | None

Positive Padua polynomial degree. The reference grid is scaled to the bounding box and clipped to the material; its retained interior count depends on geometry. Existing boundary sampling is unchanged. This is not a curved-domain Padua mapping and carries no polynomial interpolation optimality guarantee.

None
seed int | None

Nonnegative seed or None; global random state is unchanged.

0
boundary_distance float

Physical boundary clearance. Generic 2D domains use a polygon approximation; custom 3D regions need clearance support.

0.0
max_candidates int

Positive rejection budget; failure raises rather than silently returning fewer interior points.

1000000
normals dict | None

Optional label -> normal arrays or callbacks of the label's point coordinates. Overrides generated normals; finite nonzero vectors are normalized and their supplied direction is retained.

None

Returns:

Name Type Description
PointCloud PointCloud

Float64 coordinates, exterior boundary labels, outward unit normals, and region/interface metadata. No connectivity is invented.

Border geometry is rebuilt from its signed counts without mutating its objects or an input RBFMesh's samples. Internal interfaces remain interior; no interface normals or transmission equations are inferred. A label cannot simultaneously describe an exterior boundary and an internal interface.

quality(cloud, *, stencil_size=25, polynomial_degree=2)

Report nearest-node spacing and normalized local polynomial geometry.

Returns minimum/median spacing, min/max spacing ratio, worst stencil separation ratio and worst polynomial singular-value ratio. These are geometric diagnostics, not bounds on PDE error or stability.

rbflab.meshgen.padua_points(degree)

Return (n+1)(n+2)/2 Padua nodes on [-1, 1]^2 for degree n >= 1.

Uses the first family in Koushki et al. (2020), Eq. (8), doi:10.1016/j.aej.2020.04.047. Ordering is by increasing cosine-grid index in x, then y. These are coordinates only, without connectivity.

rbflab.meshgen.mapped_padua

Arc-length/radial Padua maps for domains with separated star-shaped holes.

mapped_padua(domain, *, degree, boundary=None, clustering=2.0, centers=None, min_spacing=0.0, max_candidates=1000000)

Map Padua nodes around holes using arc length and graded radial patches.

Parameters:

Name Type Description Default
domain ParametricDomain | Border | list | RBFMesh

Input geometry. One exterior and at least one hole; internal material interfaces unsupported.

required
degree int

Positive Padua degree per hole patch, not a total node count.

required
boundary int | dict | None

Existing boundary counts for ParametricDomain. Omit for borders.

None
clustering float

In [0, 8]; zero gives linear radial interpolation. Increasing this value compresses nodes toward holes via expm1(beta*r).

2.0
centers array - like | None

Optional (number_of_holes, 2) centers in contour order; default hole polygon centroids. Each center must lie in the strict kernel of its hole and surrounding nearest-center cell.

None
min_spacing float

Optional physical minimum allowed separation. Raises if violated; never silently thins the mapped cloud.

0.0
max_candidates int

Upper bound on reference, divider and boundary nodes.

1000000

The Padua cosine index is mapped to uniform periodic arc length around each hole, removing artificial crowding at the angular seam. Rays from its center reach the outer boundary or an internal Voronoi divider. The second coordinate spans this interval with exponential grading. The cells partition the whole exterior; each must contain its complete hole. Unsupported geometries raise rather than falling back to clipping.

Physical boundaries keep their existing sampler, labels and normals. The periodic seam is half-open; radial endpoint nodes are replaced by physical boundary samples and shared divider samples. regions['patch_i'] records nearest-center membership. Dividers are not physical boundaries or PDE interfaces. No triangle connectivity is returned.

Mapping uses dense polygonal curve tables (2048 segments per arc), including for borders. Checks are geometric checks at this resolution, not a proof for unresolved curve features. Clustering can worsen RBF conditioning; no polynomial interpolation or PDE accuracy guarantee follows from this map.

rbflab.meshgen.triangulate

Optional constrained triangulation with sizing inherited from boundary spacing.

triangulate(domain, *, boundary=None, growth=0.25, max_spacing=None, min_angle=25.0, fixed_boundary=True)

Generate a constrained triangle mesh with boundary-driven point density.

Parameters:

Name Type Description Default
domain ParametricDomain | Border | list | RBFMesh

Input geometry. One exterior plus disjoint holes, including non-star-shaped geometry.

required
boundary int | dict | None

Total/per-label arc-length counts for ParametricDomain. Omit for Border inputs, which use their existing signed counts.

None
growth float

Positive rate at which target edge spacing grows away from boundary segments. Smaller values extend fine resolution farther.

0.25
max_spacing float | None

Optional positive cap on target interior edge spacing; the default lets spacing grow with boundary distance.

None
min_angle float

Triangle's quality target in degrees, in [0, 28]. Geometric corners and a fixed boundary can prevent meeting it.

25.0
fixed_boundary bool

Keep exactly the supplied boundary nodes by default. False permits additional nodes on the sampled segments.

True

The sizing field is h(x) = min_e(length(e) + growthdistance(x,e)), capped by max_spacing when provided. Triangle refinement requests area <= sqrt(3)/4h(centroid)^2. Increasing samples on an arc therefore refines the adjacent interior. This is a local size target, not an exact edge-length bound.

Uses Triangle through the optional MeshPy dependency; install rbflab[triangulation]. This offers a FreeFEM-like boundary-driven workflow, not the FreeFEM/BAMG algorithm. No dependency is imported until called.

Curves are approximated by the sampled straight boundary segments. Labels attach to edges, so corner vertices can belong to multiple boundary groups. geometry.staggered_clouds(mesh).vertices produces a PDE PointCloud with the mesh's piecewise-linear normals and connectivity. Explicit analytic normal overrides can be supplied to staggered_clouds. Internal material interfaces and overlapping positive contours are currently unsupported.

rbflab.meshgen.quality(cloud, *, stencil_size=25, polynomial_degree=2)

Report nearest-node spacing and normalized local polynomial geometry.

Returns minimum/median spacing, min/max spacing ratio, worst stencil separation ratio and worst polynomial singular-value ratio. These are geometric diagnostics, not bounds on PDE error or stability.

rbflab.meshgen.from_gmsh()

Read the current planar first-order triangular Gmsh mesh.

Returns (TriangleMesh2D, original_node_tags). Physical curve names define boundary labels (or a single boundary group when none are supplied). Construction-only points are discarded. The caller owns initialization/finalization; this function does not alter the model. Supports exterior curves only; use TriangleMesh2D explicitly for interfaces.

rbflab.meshgen.RBFMesh

RBFMesh class for generating random points within polygons.

Parameters:

Name Type Description Default
*borders Border

Variable length argument list of Border objects representing the borders of the polygons.

()
abs_tol float

Absolute tolerance for geometric calculations. Defaults to 1e-04.

0.0001

Attributes:

Name Type Description
borders list

List of Border objects representing the borders of the polygons.

Points list

List of generated MeshPoint objects.

Boundary_Points list

Sampled border points on external or internal region boundaries.

outer_polygons list

List of outer Polygon objects.

holes_polygons list

List of hole Polygon objects.

abs_tol float

Absolute tolerance for geometric calculations.

Methods: generate_points(num_points): Generates random points within the polygons.

process_polygons(): Validates contours and partitions the domain.

process_polygons()

Processes polygons to prepare them for point generation by classifying them into outer polygons and holes, and then refining them to ensure that they are properly nested and non-overlapping. This method sets up the initial geometric configuration by finding polygons based on the provided borders, classifying them based on orientation, and generating points along these borders.

The method performs several key operations: 1. Identifies and orients polygons based on the input borders, distinguishing between counter-clockwise (outer polygons) and clockwise (holes). 2. Generates points along each border and collects these points, noting which are on boundary borders. 3. Resolve overlaps among multiple polygons by calculating unique and intersecting areas. 4. Subtracts hole polygons from outer polygons to finalize distinct regions. 5. Combines region boundaries, preserving internal interfaces, to filter border samples that remain after hole subtraction.

Modifies

self.outer_polygons: List of shapely.geometry.Polygon objects representing the outer boundaries. self.holes_polygons: List of shapely.geometry.Polygon objects representing the holes. self.region_polygons: List of shapely.geometry.Polygon objects representing the final regions after subtraction of holes from the outer polygons. self.Boundary_Points: Samples on any surviving region boundary, including internal interfaces, within the absolute tolerance.

This setup is crucial for ensuring that the subsequent point generation by generate_points occurs within properly defined and non-overlapping geometric regions.

generate_points(num_points, boundary_distance=1e-05, *, append=True, method='random', seed=None)

Generates random points within the polygons defined by the borders.

Parameters:

Name Type Description Default
boundary_distance float

distance from generated point to the boundary

1e-05
num_points int

Number of points to generate.

required
append bool

Keep existing interior points (default True). Set False to replace them after successful generation.

True
method str

'random', 'halton', or 'sobol'.

'random'
seed int or None

Non-negative seed for a fresh sampler per call. Reusing a seed reproduces points; use append=False to replace them.

None

Returns:

Name Type Description
list list

List of generated MeshPoint objects.

rbflab.meshgen.RBFMesh3D

Generate random, Halton, or Sobol point clouds in 3D implicit regions.

generate_points(num_points, boundary_distance=0, *, append=True, method='random', seed=None, estimate_samples=32768, max_candidates=None)

Generate exactly num_points interior points across the regions.

generate_boundary_points(num_points, *, append=True, method='random', seed=None, tolerance=1e-08, max_iterations=30, max_candidates=None)

Generate explicit boundary nodes with labels and outward normals.

rbflab.meshgen.ParametricSurface3D

A surface F(u, v) = (x, y, z) sampled without triangulation.

Points are sampled in parameter space and accepted in proportion to the local surface Jacobian |dF/du x dF/dv|. Consequently, accepted points are approximately uniform in physical surface area rather than merely uniform in the parameter rectangle.

Parameters:

Name Type Description Default
parametric_function Callable

Callable returning three coordinates.

required
u_range tuple

Finite increasing (minimum, maximum) pair.

required
v_range tuple

Finite increasing (minimum, maximum) pair.

required
label object

Boundary label assigned to generated points.

'boundary'
derivatives tuple | None

Optional (dF_du, dF_dv) callables. Finite differences are used when omitted.

None
periodic_u bool

Wrap finite-difference evaluations across the u seam.

False
periodic_v bool

Wrap finite-difference evaluations across the v seam.

False
orientation int

1 for dF/du x dF/dv or -1 to reverse normals.

1

generate_points(num_points, *, method='random', seed=None, append=True, jacobian_resolution=48, max_candidates=None)

Generate labeled random points and normals on the surface.

rbflab.meshgen.calculate_point_allocation(region_polygons, num_points)

Calculates the point allocation for each region_polygons based on their area.

Parameters:

Name Type Description Default
region_polygons list

List of outer Polygon objects.

required
num_points int

Number of points to allocate.

required

Returns:

Name Type Description
list list

List of integers representing the point allocation for each outer polygon.

rbflab.meshgen.generate_points_within_polygons(region_polygons, points_allocation, boundary_distance=1e-05, *, method='random', seed=None)

Generates random points within the outer polygons.

Parameters:

Name Type Description Default
region_polygons list

List of outer Polygon objects.

required
points_allocation list

List of integers representing the point allocation for each outer polygon.

required
boundary_distance float

Distance to buffer the polygons. Defaults to 1.0e-5.

1e-05
method str

'random' (default), scrambled 'halton', or scrambled 'sobol'.

'random'
seed int or None

Non-negative seed, reset on each call. With random sampling and no seed, the global random state is used as before.

None

QMC candidates are mapped from the unit square to each region's bounding box and rejected outside the buffered region. This preserves exact counts, but clipping/truncation does not preserve Sobol's power-of-two balance.

Returns:

Name Type Description
list list

List of generated MeshPoint objects.

rbflab.meshgen.generate_regions(outer_polygons, hole_polygons)

Subtract all holes without mutating the input list. Fully removed regions disappear, and disconnected results become separate Polygon components.

Parameters:

Name Type Description Default
outer_polygons list

List of outer Polygon objects.

required
hole_polygons list

List of hole Polygon objects.

required

Returns:

Name Type Description
list list

List of modified outer Polygon objects.

rbflab.meshgen.exclude_nested_polygons(outer_polygons)

Subtract contained polygons using the original containment relationships. This handles nesting and duplicates; use resolve_multiple_overlaps for partially overlapping inputs.

Parameters:

Name Type Description Default
outer_polygons list

List of outer Polygon objects.

required

Returns:

Name Type Description
list list

Polygon components with contained areas removed from their parents.

rbflab.meshgen.calculate_volume_allocation(regions, num_points, *, estimate_samples=32768)

Allocate an exact point count among regions in proportion to volume.

rbflab.meshgen.calculate_boundary_allocation(regions, num_points)

Allocate boundary points in proportion to known surface areas.

rbflab.meshgen.estimate_region_volume(region, samples=32768, *, method='halton', seed=0)

Estimate an implicit region's volume inside its declared bounds.

rbflab.meshgen.generate_points_within_regions(regions, points_allocation, boundary_distance=0, *, method='random', seed=None, max_candidates=None)

Generate unconnected 3D points inside bounded implicit regions.

rbflab.meshgen.generate_boundary_points(regions, points_allocation, *, method='random', seed=None, tolerance=1e-08, max_iterations=30, max_candidates=None)

Generate labeled boundary points with outward unit normals.