Built-in Modules#

These helpers register the conversion sets bundled with the resolver package: foaming filaments (TPU, PLA), J750 Shore hardness and modulus/toughness, Stratasys RadioMatrix HU calibration, generic RGB/RGBA color, and vector component splitting and joining. Use them to populate the registry before calling pyvcad_attribute_resolver.adapt().

Foaming filaments#

pyvcad_attribute_resolver.register_foaming_conversions()[source]#

Register all five foaming filament conversions (TPU + PLA).

pyvcad_attribute_resolver.register_tpu_conversions()[source]#

Register the three VarioShore TPU conversions.

pyvcad_attribute_resolver.register_pla_conversions()[source]#

Register the two LW-PLA conversions.

Stratasys J750#

pyvcad_attribute_resolver.register_j750_shore_hardness_conversions(material_defs=None, agilus_material=None, vero_material=None)[source]#

Register the J750 shore-hardness to volume-fractions conversion.

By default this resolves the first J750 materials whose names begin with Agilus30 and Vero. Callers can override the representative material names when they want a specific color variant.

pyvcad_attribute_resolver.register_j750_modulus_toughness_conversions(material_defs=None, rigid_material='VeroBlack', soft_material='Agilus30Clr', liquid_material='M.Cleanser', lookup_table_path=None)[source]#

Register the J750 modulus+toughness to volume-fractions conversion.

The bundled lookup table assumes modulus values are provided in MPa and toughness values are provided in MJ/m^3. The shipped table is generated from the legacy C++ inverse model using the default 0.30 liquid cap.

To use a different liquid cap or table resolution, generate a new table file with generate_j750_modulus_toughness_lookup_table() and pass its path via lookup_table_path.

Medical imaging#

pyvcad_attribute_resolver.register_stratasys_radiomatrix_conversions(kv, material_defs=None, radio_matrix_material='RadioMatrix', vero_material='VeroBlack', tissue_matrix_material='TissueMatrix', mode='radio_matrix_vero_tissue_matrix')[source]#

Register the Stratasys RadioMatrix HU-to-volume-fractions conversion.

The selected kv value must be 100, 120, or 140. The selected mode controls whether both calibration curves are joined or only one calibration curve is used. By default this resolves material IDs from the bundled J750 material definitions and maps the RadioMatrix/Vero pair to RadioMatrix and VeroBlack. Both material names can be overridden.

Parameters:
  • kv (int) – CT tube voltage the scan was taken at: 100, 120 or 140.

  • material_defs (MaterialDefs, optional) – Material definitions to look the names up in. Defaults to pyvcad.j750_materials.

  • radio_matrix_material (str) – Name of the RadioMatrix material.

  • vero_material (str) – Name of the Vero material.

  • tissue_matrix_material (str) – Name of the TissueMatrix material.

  • mode (str) – Which calibration curves to use: MODE_RADIO_MATRIX_VERO_TISSUE_MATRIX (“radio_matrix_vero_tissue_matrix”, both joined), MODE_RADIO_MATRIX_VERO (“radio_matrix_vero”) or MODE_VERO_TISSUE_MATRIX (“vero_tissue_matrix”).

Raises:

ValueError – If kv or mode is not supported.

Example

>>> import pyvcad_attribute_resolver as par
>>> par.register_stratasys_radiomatrix_conversions(120)

Color#

pyvcad_attribute_resolver.register_generic_color_conversions(alpha=1.0)[source]#

Register all generic RGB/RGBA color conversions.

pyvcad_attribute_resolver.register_rgb_to_rgba_conversion(alpha=1.0)[source]#

Register the generic COLOR_RGB to COLOR_RGBA conversion.

The conversion copies the RGB channels and sets a constant alpha (pv.RgbToRgbaConverter).

Parameters:

alpha (float) – Alpha value written to every sample. Defaults to 1.0.

Example

>>> import pyvcad_attribute_resolver as par
>>> par.register_rgb_to_rgba_conversion(alpha=0.8)
pyvcad_attribute_resolver.register_rgba_to_rgb_conversion()[source]#

Register the generic COLOR_RGBA to COLOR_RGB conversion.

The conversion drops the alpha channel (pv.RgbaToRgbConverter).

Example

>>> import pyvcad_attribute_resolver as par
>>> par.register_rgba_to_rgb_conversion()

Vector components#

pyvcad_attribute_resolver.register_vector_component_conversions(vec3_source=None, vec3_x=None, vec3_y=None, vec3_z=None, vec4_source=None, vec4_x=None, vec4_y=None, vec4_z=None, vec4_w=None, register_demote=True, register_promote=True)[source]#

Register demote and/or promote conversions for the supplied attribute names.

Pass a complete Vec3 name set and/or a complete Vec4 name set. Incomplete name sets are ignored. At least one complete set must be provided.

pyvcad_attribute_resolver.register_vec3_to_scalars_conversions(source, x_name, y_name, z_name)[source]#

Register Vec3 demotion edges that produce three named float attributes.

One converter instance produces all three outputs. Separate graph edges are registered for each component so adapt(..., [x_name]) (and likewise for Y/Z) can discover the conversion.

pyvcad_attribute_resolver.register_vec4_to_scalars_conversions(source, x_name, y_name, z_name, w_name)[source]#

Register Vec4 demotion edges that produce four named float attributes.

pyvcad_attribute_resolver.register_scalars_to_vec3_conversions(x_name, y_name, z_name, target)[source]#

Register a multi-input conversion that builds a Vec3 from three floats.

pyvcad_attribute_resolver.register_scalars_to_vec4_conversions(x_name, y_name, z_name, w_name, target)[source]#

Register a multi-input conversion that builds a Vec4 from four floats.

Data generation#

Offline helpers that regenerate the fitted models and figures behind the J750 modules. The registered conversions use the stored results, so you only need these when changing the source data.

pyvcad_attribute_resolver.fit_j750_shore_hardness_curve(polynomial_degree=6)[source]#

Fit the source CSV and return the expression data.

The bundled J750 measurements of Shore hardness against Agilus30 fraction are fitted with an endpoint-constrained polynomial. This is an offline helper for regenerating the fitted model; the registered converter uses the stored model, so adapting a design never imports NumPy or reads the CSV.

Parameters:

polynomial_degree (int) – Degree of the fitted polynomial. Must be at least 2.

Returns:

The fit, with keys polynomial_degree, min_hardness, max_hardness, min_fraction, max_fraction, coefficients, metrics (max_abs_error and rmse) and expression (the Agilus30 fraction as an expression string).

Return type:

dict

Raises:

ValueError – If polynomial_degree is less than 2.

pyvcad_attribute_resolver.generate_j750_shore_hardness_fit_plot(output_path=None, polynomial_degree=6)[source]#

Generate the out-of-loop J750 hardness fit SVG figure.

Plots the measured Shore hardness against the rigid Vero fraction, with the fitted curve.

Parameters:
  • output_path (str | Path, optional) – SVG file to write. Parent directories are created. Defaults to .tmp/j750_shore_hardness_rigid_fraction_fit.svg under the working directory.

  • polynomial_degree (int) – Degree of the fitted polynomial. Must be at least 2.

Returns:

The path of the written figure.

Return type:

Path

pyvcad_attribute_resolver.generate_j750_modulus_toughness_lookup_table(output_path=None, table_size=128, max_liquid_volume=0.3, fail_threshold=0.05)[source]#

Generate a J750 modulus+toughness lookup-table JSON file.

pyvcad_attribute_resolver.generate_j750_modulus_toughness_reachable_region_plot(output_path, lookup_table_path=None, table_size=128, max_liquid_volume=0.3, fail_threshold=0.05, fraction_steps=181)[source]#

Generate the reachable-region validation plot used in the docs.