Skip to content

airframe_geometry

adh.wbs.airframe.airframe_geometry ¤

Classes:

  • Airfoil

    Represents an airfoil section, a fundamental component in aircraft design for wings and control surfaces.

  • Body

    Represents the geometric definition of a body-like surface component, such as an aircraft fuselage or engine nacelle.

  • Boolean

    Represents a boolean data type with enhanced attributes for engineering applications.

  • CrossSection

    Represents a cross-section of a body component at a specific station along its length.

  • Float

    Represents a floating-point number with enhanced attributes for engineering applications.

  • Integer

    Represents an integer data type with enhanced attributes for engineering applications.

  • LiftingSurface

    Represents the geometric characteristics of a lifting surface, such as wings and tail surfaces of aircraft.

  • Loft

    Represents a lofted surface, a smooth spatial surface generated by transitioning between multiple spline curves.

  • Mesh

    Represents a 3D mesh, a collection of polygons (typically triangles or quadrilaterals) used to model the surface of a 3D object.

  • Point

    Represents a point in 3D space, defined by its x, y, and z coordinates.

  • Polyline

    Represents a polyline, a series of connected 3D points forming a continuous line or path.

  • ReferenceAxis

    Represents the reference axis of a body component, such as an aircraft fuselage or wing.

  • Spline

    Represents a spline, which is a smooth curve constructed from a series of control points.

  • String

    Represents a string data type with enhanced attributes for engineering applications.

Airfoil pydantic-model ¤

Bases: BaseModel

Represents an airfoil section, a fundamental component in aircraft design for wings and control surfaces.

Attributes:

Raises:

Show JSON schema:
{
  "$defs": {
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    },
    "Spline": {
      "description": "Represents a spline, which is a smooth curve constructed from a series of control points.\n\nSplines are essential in various applications such as computer graphics, geometric modeling, and trajectory planning.\n\nAttributes:\n    points (List[Point]): The list of control points that define the spline. The spline passes through these points.\n    degree (int): The degree of the spline curve. Common values are 2 (quadratic) and 3 (cubic).\n\nRaises:\n    ValueError: If the number of points is less than the degree + 1, which is necessary for defining a valid spline.",
      "properties": {
        "points": {
          "description": "Control points that define the spline.",
          "items": {
            "$ref": "#/$defs/Point"
          },
          "minItems": 2,
          "title": "Points",
          "type": "array"
        },
        "degree": {
          "default": 3,
          "description": "The degree of the spline curve. Commonly 2 (quadratic) or 3 (cubic).",
          "exclusiveMinimum": 0,
          "title": "Degree",
          "type": "integer"
        }
      },
      "required": [
        "points"
      ],
      "title": "Spline",
      "type": "object"
    }
  },
  "description": "Represents an airfoil section, a fundamental component in aircraft design for wings and control surfaces.\n\nAttributes:\n    spline (Optional[Spline]): A spline defining the contour of the airfoil section.\n\nRaises:\n    ValueError: If the spline is not provided.",
  "properties": {
    "spline": {
      "anyOf": [
        {
          "$ref": "#/$defs/Spline"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A spline defining the contour of the airfoil section."
    }
  },
  "title": "Airfoil",
  "type": "object"
}

Fields:

Validators:

spline pydantic-field ¤

spline: Optional[Spline] = None

A spline defining the contour of the airfoil section.

validate_spline pydantic-validator ¤

validate_spline(value: Optional[Spline]) -> Spline

Validates the spline defining the airfoil contour.

Parameters:

Returns:

  • Spline

    The validated spline object.

Raises:

Source code in src/adh/wbs/airframe/airframe_geometry.py
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
@field_validator("spline", mode="before")
def validate_spline(cls, value: Optional[Spline]) -> Spline:
    """
    Validates the spline defining the airfoil contour.

    Args:
        value: The spline object to validate.

    Returns:
        The validated spline object.

    Raises:
        ValueError: If the spline is not provided.
    """
    if value is None:
        raise ValueError(
            "The spline defining the airfoil contour must be provided."
        )
    return value

Body pydantic-model ¤

Bases: BaseModel

Represents the geometric definition of a body-like surface component, such as an aircraft fuselage or engine nacelle.

Attributes:

Raises:

  • ValueError

    If the list of cross sections is empty.

Show JSON schema:
{
  "$defs": {
    "CrossSection": {
      "description": "Represents a cross-section of a body component at a specific station along its length.\n\nAttributes:\n    station (float): Normalized station of the cross-section along the body's length.\n    upper_curve (Optional[Spline]): Spline defining the upper curve of the cross-section.\n    lower_curve (Optional[Spline]): Spline defining the lower curve of the cross-section.\n\nRaises:\n    ValueError: If neither an upper nor a lower curve spline is provided.",
      "properties": {
        "station": {
          "description": "Normalized station of the cross-section along the body's length.",
          "maximum": 1,
          "minimum": 0,
          "title": "Station",
          "type": "number"
        },
        "upper_curve": {
          "anyOf": [
            {
              "$ref": "#/$defs/Spline"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Spline defining the upper curve of the cross-section."
        },
        "lower_curve": {
          "anyOf": [
            {
              "$ref": "#/$defs/Spline"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Spline defining the lower curve of the cross-section."
        }
      },
      "required": [
        "station"
      ],
      "title": "CrossSection",
      "type": "object"
    },
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    },
    "Spline": {
      "description": "Represents a spline, which is a smooth curve constructed from a series of control points.\n\nSplines are essential in various applications such as computer graphics, geometric modeling, and trajectory planning.\n\nAttributes:\n    points (List[Point]): The list of control points that define the spline. The spline passes through these points.\n    degree (int): The degree of the spline curve. Common values are 2 (quadratic) and 3 (cubic).\n\nRaises:\n    ValueError: If the number of points is less than the degree + 1, which is necessary for defining a valid spline.",
      "properties": {
        "points": {
          "description": "Control points that define the spline.",
          "items": {
            "$ref": "#/$defs/Point"
          },
          "minItems": 2,
          "title": "Points",
          "type": "array"
        },
        "degree": {
          "default": 3,
          "description": "The degree of the spline curve. Commonly 2 (quadratic) or 3 (cubic).",
          "exclusiveMinimum": 0,
          "title": "Degree",
          "type": "integer"
        }
      },
      "required": [
        "points"
      ],
      "title": "Spline",
      "type": "object"
    }
  },
  "description": "Represents the geometric definition of a body-like surface component, such as an aircraft fuselage or engine nacelle.\n\nAttributes:\n    reference_axis (Optional[Spline]): Spline defining the reference axis of the body.\n    cross_sections (List[CrossSection]): List of CrossSection objects defining the body's shape at various stations.\n\nRaises:\n    ValueError: If the list of cross sections is empty.",
  "properties": {
    "reference_axis": {
      "anyOf": [
        {
          "$ref": "#/$defs/Spline"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Spline defining the reference axis of the body."
    },
    "cross_sections": {
      "description": "List of CrossSection objects defining the body's shape at various stations.",
      "items": {
        "$ref": "#/$defs/CrossSection"
      },
      "title": "Cross Sections",
      "type": "array"
    }
  },
  "required": [
    "cross_sections"
  ],
  "title": "Body",
  "type": "object"
}

Fields:

Validators:

cross_sections pydantic-field ¤

cross_sections: list[CrossSection]

List of CrossSection objects defining the body's shape at various stations.

reference_axis pydantic-field ¤

reference_axis: Optional[Spline] = None

Spline defining the reference axis of the body.

validate_cross_sections pydantic-validator ¤

validate_cross_sections(value: list[CrossSection]) -> list[CrossSection]

Ensures that at least one CrossSection object is provided.

Parameters:

Returns:

Raises:

Source code in src/adh/wbs/airframe/airframe_geometry.py
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
@field_validator("cross_sections", mode="before")
def validate_cross_sections(cls, value: list[CrossSection]) -> list[CrossSection]:
    """
    Ensures that at least one CrossSection object is provided.

    Args:
        value: The list of CrossSection objects to validate.

    Returns:
        The validated list of CrossSection objects.

    Raises:
        ValueError: If the list is empty.
    """
    if not value:
        raise ValueError(
            "At least one CrossSection must be provided for the body geometry."
        )
    return value

Boolean pydantic-model ¤

Bases: BaseModel

Represents a boolean data type with enhanced attributes for engineering applications.

Attributes:

Raises:

  • ValidationError

    If the input value does not meet the validation criteria.

Show JSON schema:
{
  "$defs": {
    "Metadata": {
      "additionalProperties": false,
      "description": "Key-value metadata for annotating architecture nodes.",
      "properties": {
        "key": {
          "title": "Key",
          "type": "string"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Units of measure",
          "title": "Units"
        },
        "uncertainty": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Uncertainty value",
          "title": "Uncertainty"
        },
        "lower_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Lower bound",
          "title": "Lower Bounds"
        },
        "upper_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Upper bound",
          "title": "Upper Bounds"
        }
      },
      "required": [
        "key"
      ],
      "title": "Metadata",
      "type": "object"
    }
  },
  "description": "Represents a boolean data type with enhanced attributes for engineering applications.\n\nAttributes:\n    value (bool): The actual boolean value.\n    units (str): Units of the variable, typically 'unitless' for boolean types.\n    description (Optional[str]): A brief description of the variable.\n    default (Optional[bool]): Default boolean value of the variable, if any.\n    metadata (Metadata): Additional metadata for the variable.\n\nRaises:\n    ValidationError: If the input value does not meet the validation criteria.",
  "properties": {
    "value": {
      "description": "The actual boolean value.",
      "title": "Value",
      "type": "boolean"
    },
    "units": {
      "default": "unitless",
      "description": "Units of the variable, typically 'unitless' for boolean types.",
      "title": "Units",
      "type": "string"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A brief description of the variable.",
      "title": "Description"
    },
    "default": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Default boolean value of the variable, if any.",
      "title": "Default"
    },
    "metadata": {
      "anyOf": [
        {
          "$ref": "#/$defs/Metadata"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Additional metadata for the variable."
    }
  },
  "required": [
    "value"
  ],
  "title": "Boolean",
  "type": "object"
}

Fields:

Validators:

default pydantic-field ¤

default: Optional[bool] = None

Default boolean value of the variable, if any.

description pydantic-field ¤

description: Optional[str] = None

A brief description of the variable.

metadata pydantic-field ¤

metadata: Optional[Metadata] = None

Additional metadata for the variable.

units pydantic-field ¤

units: str = 'unitless'

Units of the variable, typically 'unitless' for boolean types.

value pydantic-field ¤

value: bool

The actual boolean value.

validate_default pydantic-validator ¤

validate_default(value: Optional[bool], info: ValidationInfo) -> Optional[bool]

Validate and convert the default value to a boolean if it's provided as a string.

Parameters:

  • value (Optional[bool]) –

    The default value being validated.

  • info (ValidationInfo) –

    Validation context information for the field being validated.

Returns:

Raises:

  • ValueError

    If the default value is a string that cannot be converted to a boolean.

Source code in src/adh/wbs/airframe/airframe_geometry.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@field_validator("default", mode="before")
def validate_default(
    cls, value: Optional[bool], info: ValidationInfo
) -> Optional[bool]:
    """Validate and convert the default value to a boolean if it's provided as a string.

    Args:
        value: The default value being validated.
        info: Validation context information for the field being validated.

    Returns:
        The validated default value.

    Raises:
        ValueError: If the default value is a string that cannot be converted to a boolean.
    """
    if isinstance(value, str):
        lower_value = value.lower()
        if lower_value in {"true", "1", "t", "y", "yes"}:
            return True
        elif lower_value in {"false", "0", "f", "n", "no"}:
            return False
        else:
            raise ValueError(
                f"Invalid string value for a boolean conversion: {value}"
            )
    return value

CrossSection pydantic-model ¤

Bases: BaseModel

Represents a cross-section of a body component at a specific station along its length.

Attributes:

Raises:

  • ValueError

    If neither an upper nor a lower curve spline is provided.

Show JSON schema:
{
  "$defs": {
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    },
    "Spline": {
      "description": "Represents a spline, which is a smooth curve constructed from a series of control points.\n\nSplines are essential in various applications such as computer graphics, geometric modeling, and trajectory planning.\n\nAttributes:\n    points (List[Point]): The list of control points that define the spline. The spline passes through these points.\n    degree (int): The degree of the spline curve. Common values are 2 (quadratic) and 3 (cubic).\n\nRaises:\n    ValueError: If the number of points is less than the degree + 1, which is necessary for defining a valid spline.",
      "properties": {
        "points": {
          "description": "Control points that define the spline.",
          "items": {
            "$ref": "#/$defs/Point"
          },
          "minItems": 2,
          "title": "Points",
          "type": "array"
        },
        "degree": {
          "default": 3,
          "description": "The degree of the spline curve. Commonly 2 (quadratic) or 3 (cubic).",
          "exclusiveMinimum": 0,
          "title": "Degree",
          "type": "integer"
        }
      },
      "required": [
        "points"
      ],
      "title": "Spline",
      "type": "object"
    }
  },
  "description": "Represents a cross-section of a body component at a specific station along its length.\n\nAttributes:\n    station (float): Normalized station of the cross-section along the body's length.\n    upper_curve (Optional[Spline]): Spline defining the upper curve of the cross-section.\n    lower_curve (Optional[Spline]): Spline defining the lower curve of the cross-section.\n\nRaises:\n    ValueError: If neither an upper nor a lower curve spline is provided.",
  "properties": {
    "station": {
      "description": "Normalized station of the cross-section along the body's length.",
      "maximum": 1,
      "minimum": 0,
      "title": "Station",
      "type": "number"
    },
    "upper_curve": {
      "anyOf": [
        {
          "$ref": "#/$defs/Spline"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Spline defining the upper curve of the cross-section."
    },
    "lower_curve": {
      "anyOf": [
        {
          "$ref": "#/$defs/Spline"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Spline defining the lower curve of the cross-section."
    }
  },
  "required": [
    "station"
  ],
  "title": "CrossSection",
  "type": "object"
}

Fields:

Validators:

lower_curve pydantic-field ¤

lower_curve: Optional[Spline] = None

Spline defining the lower curve of the cross-section.

station pydantic-field ¤

station: float

Normalized station of the cross-section along the body's length.

upper_curve pydantic-field ¤

upper_curve: Optional[Spline] = None

Spline defining the upper curve of the cross-section.

validate_curves pydantic-validator ¤

validate_curves(values: dict) -> dict

Validates that at least one of the upper or lower curve splines is provided.

Parameters:

  • values (dict) –

    Dictionary of field values.

Returns:

  • dict

    The validated dictionary of field values.

Raises:

  • ValueError

    If neither an upper nor a lower curve spline is provided.

Source code in src/adh/wbs/airframe/airframe_geometry.py
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
@model_validator(mode="before")
@classmethod
def validate_curves(cls, values: dict) -> dict:
    """
    Validates that at least one of the upper or lower curve splines is provided.

    Args:
        values: Dictionary of field values.

    Returns:
        The validated dictionary of field values.

    Raises:
        ValueError: If neither an upper nor a lower curve spline is provided.
    """
    upper_curve = values.get("upper_curve")
    lower_curve = values.get("lower_curve")

    if upper_curve is None and lower_curve is None:
        raise ValueError(
            "At least one of the upper or lower curve splines must be provided."
        )

    return values

Float pydantic-model ¤

Bases: BaseModel

Represents a floating-point number with enhanced attributes for engineering applications.

Attributes:

Raises:

  • ValidationError

    If the input value does not meet the validation criteria.

Show JSON schema:
{
  "$defs": {
    "Metadata": {
      "additionalProperties": false,
      "description": "Key-value metadata for annotating architecture nodes.",
      "properties": {
        "key": {
          "title": "Key",
          "type": "string"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Units of measure",
          "title": "Units"
        },
        "uncertainty": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Uncertainty value",
          "title": "Uncertainty"
        },
        "lower_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Lower bound",
          "title": "Lower Bounds"
        },
        "upper_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Upper bound",
          "title": "Upper Bounds"
        }
      },
      "required": [
        "key"
      ],
      "title": "Metadata",
      "type": "object"
    }
  },
  "description": "Represents a floating-point number with enhanced attributes for engineering applications.\n\nAttributes:\n    value (float): The actual floating-point value.\n    units (str): Units of the variable, allowing for dimensional analysis.\n    description (Optional[str]): A brief description of the variable.\n    default (Optional[float]): Default floating-point value of the variable, if any.\n    metadata (Metadata): Additional metadata for the variable.\n\nRaises:\n    ValidationError: If the input value does not meet the validation criteria.",
  "properties": {
    "value": {
      "description": "The actual floating-point value.",
      "title": "Value",
      "type": "number"
    },
    "units": {
      "default": "unitless",
      "description": "Units of the variable.",
      "title": "Units",
      "type": "string"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A brief description of the variable.",
      "title": "Description"
    },
    "default": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Default floating-point value of the variable, if any.",
      "title": "Default"
    },
    "metadata": {
      "anyOf": [
        {
          "$ref": "#/$defs/Metadata"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Additional metadata for the variable."
    }
  },
  "required": [
    "value"
  ],
  "title": "Float",
  "type": "object"
}

Fields:

Validators:

default pydantic-field ¤

default: Optional[float] = None

Default floating-point value of the variable, if any.

description pydantic-field ¤

description: Optional[str] = None

A brief description of the variable.

metadata pydantic-field ¤

metadata: Optional[Metadata] = None

Additional metadata for the variable.

units pydantic-field ¤

units: str = 'unitless'

Units of the variable.

value pydantic-field ¤

value: float

The actual floating-point value.

validate_default pydantic-validator ¤

validate_default(value: Optional[float], info: ValidationInfo) -> Optional[float]

Validate and convert the default value to a float if it's provided as a string.

Parameters:

  • value (Optional[float]) –

    The default value being validated.

  • info (ValidationInfo) –

    Validation context information for the field being validated.

Returns:

Raises:

  • ValueError

    If the default value is a string that cannot be converted to a float.

Source code in src/adh/wbs/airframe/airframe_geometry.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
@field_validator("default", mode="before")
def validate_default(
    cls, value: Optional[float], info: ValidationInfo
) -> Optional[float]:
    """Validate and convert the default value to a float if it's provided as a string.

    Args:
        value: The default value being validated.
        info: Validation context information for the field being validated.

    Returns:
        The validated default value.

    Raises:
        ValueError: If the default value is a string that cannot be converted to a float.
    """
    if isinstance(value, str):
        try:
            return float(value)
        except ValueError as e:
            raise ValueError(
                f"Invalid string value for a float conversion: {value}"
            ) from e
    return value

Integer pydantic-model ¤

Bases: BaseModel

Represents an integer data type with enhanced attributes for engineering applications.

Attributes:

Raises:

  • ValidationError

    If the input value does not meet the validation criteria.

Show JSON schema:
{
  "$defs": {
    "Metadata": {
      "additionalProperties": false,
      "description": "Key-value metadata for annotating architecture nodes.",
      "properties": {
        "key": {
          "title": "Key",
          "type": "string"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Units of measure",
          "title": "Units"
        },
        "uncertainty": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Uncertainty value",
          "title": "Uncertainty"
        },
        "lower_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Lower bound",
          "title": "Lower Bounds"
        },
        "upper_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Upper bound",
          "title": "Upper Bounds"
        }
      },
      "required": [
        "key"
      ],
      "title": "Metadata",
      "type": "object"
    }
  },
  "description": "Represents an integer data type with enhanced attributes for engineering applications.\n\nAttributes:\n    value (int): The actual integer value.\n    units (str): Units of the variable, allowing for dimensional analysis.\n    description (Optional[str]): A brief description of the variable.\n    default (Optional[int]): Default integer value of the variable, if any.\n    metadata: Optional[Metadata]): Additional metadata for the variable.\n\nRaises:\n    ValidationError: If the input value does not meet the validation criteria.",
  "properties": {
    "value": {
      "description": "The actual integer value.",
      "title": "Value",
      "type": "integer"
    },
    "units": {
      "default": "unitless",
      "description": "Units of the variable.",
      "title": "Units",
      "type": "string"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A brief description of the variable.",
      "title": "Description"
    },
    "default": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Default integer value of the variable, if any.",
      "title": "Default"
    },
    "metadata": {
      "anyOf": [
        {
          "$ref": "#/$defs/Metadata"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Additional metadata for the variable."
    }
  },
  "required": [
    "value"
  ],
  "title": "Integer",
  "type": "object"
}

Fields:

Validators:

default pydantic-field ¤

default: Optional[int] = None

Default integer value of the variable, if any.

description pydantic-field ¤

description: Optional[str] = None

A brief description of the variable.

metadata pydantic-field ¤

metadata: Optional[Metadata] = None

Additional metadata for the variable.

units pydantic-field ¤

units: str = 'unitless'

Units of the variable.

value pydantic-field ¤

value: int

The actual integer value.

validate_default pydantic-validator ¤

validate_default(value: Optional[int], info: ValidationInfo) -> Optional[int]

Validate and convert the default value to an integer if it's provided as a string.

Parameters:

  • value (Optional[int]) –

    The default value being validated.

  • info (ValidationInfo) –

    Validation context information for the field being validated.

Returns:

Raises:

  • ValueError

    If the default value is a string that cannot be converted to an integer.

Source code in src/adh/wbs/airframe/airframe_geometry.py
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
@field_validator("default", mode="before")
def validate_default(
    cls, value: Optional[int], info: ValidationInfo
) -> Optional[int]:
    """Validate and convert the default value to an integer if it's provided as a string.

    Args:
        value: The default value being validated.
        info: Validation context information for the field being validated.

    Returns:
        The validated default value.

    Raises:
        ValueError: If the default value is a string that cannot be converted to an integer.
    """
    if isinstance(value, str):
        try:
            return int(value)
        except ValueError as e:
            raise ValueError(
                f"Invalid string value for an integer conversion: {value}"
            ) from e
    return value

LiftingSurface pydantic-model ¤

Bases: BaseModel

Represents the geometric characteristics of a lifting surface, such as wings and tail surfaces of aircraft.

Attributes:

Raises:

  • ValueError

    If the list of airfoil sections is empty.

Show JSON schema:
{
  "$defs": {
    "Airfoil": {
      "description": "Represents an airfoil section, a fundamental component in aircraft design for wings and control surfaces.\n\nAttributes:\n    spline (Optional[Spline]): A spline defining the contour of the airfoil section.\n\nRaises:\n    ValueError: If the spline is not provided.",
      "properties": {
        "spline": {
          "anyOf": [
            {
              "$ref": "#/$defs/Spline"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A spline defining the contour of the airfoil section."
        }
      },
      "title": "Airfoil",
      "type": "object"
    },
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    },
    "Spline": {
      "description": "Represents a spline, which is a smooth curve constructed from a series of control points.\n\nSplines are essential in various applications such as computer graphics, geometric modeling, and trajectory planning.\n\nAttributes:\n    points (List[Point]): The list of control points that define the spline. The spline passes through these points.\n    degree (int): The degree of the spline curve. Common values are 2 (quadratic) and 3 (cubic).\n\nRaises:\n    ValueError: If the number of points is less than the degree + 1, which is necessary for defining a valid spline.",
      "properties": {
        "points": {
          "description": "Control points that define the spline.",
          "items": {
            "$ref": "#/$defs/Point"
          },
          "minItems": 2,
          "title": "Points",
          "type": "array"
        },
        "degree": {
          "default": 3,
          "description": "The degree of the spline curve. Commonly 2 (quadratic) or 3 (cubic).",
          "exclusiveMinimum": 0,
          "title": "Degree",
          "type": "integer"
        }
      },
      "required": [
        "points"
      ],
      "title": "Spline",
      "type": "object"
    }
  },
  "description": "Represents the geometric characteristics of a lifting surface, such as wings and tail surfaces of aircraft.\n\nAttributes:\n    leading_edge_spline (Optional[Spline]): Spline defining the leading edge of the lifting surface.\n    trailing_edge_spline (Optional[Spline]): Spline defining the trailing edge of the lifting surface.\n    airfoil_sections (List[Airfoil]): List of Airfoil objects representing the airfoil shapes along the span.\n\nRaises:\n    ValueError: If the list of airfoil sections is empty.",
  "properties": {
    "leading_edge_spline": {
      "anyOf": [
        {
          "$ref": "#/$defs/Spline"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Spline defining the leading edge of the lifting surface."
    },
    "trailing_edge_spline": {
      "anyOf": [
        {
          "$ref": "#/$defs/Spline"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Spline defining the trailing edge of the lifting surface."
    },
    "airfoil_sections": {
      "description": "List of Airfoil objects representing the airfoil shapes along the span.",
      "items": {
        "$ref": "#/$defs/Airfoil"
      },
      "title": "Airfoil Sections",
      "type": "array"
    }
  },
  "required": [
    "airfoil_sections"
  ],
  "title": "LiftingSurface",
  "type": "object"
}

Fields:

Validators:

airfoil_sections pydantic-field ¤

airfoil_sections: list[Airfoil]

List of Airfoil objects representing the airfoil shapes along the span.

leading_edge_spline pydantic-field ¤

leading_edge_spline: Optional[Spline] = None

Spline defining the leading edge of the lifting surface.

trailing_edge_spline pydantic-field ¤

trailing_edge_spline: Optional[Spline] = None

Spline defining the trailing edge of the lifting surface.

validate_airfoil_sections pydantic-validator ¤

validate_airfoil_sections(value: list[Airfoil]) -> list[Airfoil]

Ensures that at least one Airfoil object is provided.

Parameters:

  • value (list[Airfoil]) –

    The list of Airfoil objects to validate.

Returns:

  • list[Airfoil]

    The validated list of Airfoil objects.

Raises:

Source code in src/adh/wbs/airframe/airframe_geometry.py
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
@field_validator("airfoil_sections", mode="before")
def validate_airfoil_sections(cls, value: list[Airfoil]) -> list[Airfoil]:
    """
    Ensures that at least one Airfoil object is provided.

    Args:
        value: The list of Airfoil objects to validate.

    Returns:
        The validated list of Airfoil objects.

    Raises:
        ValueError: If the list is empty.
    """
    if not value:
        raise ValueError(
            "At least one Airfoil must be provided for the lifting surface."
        )
    return value

Loft pydantic-model ¤

Bases: BaseModel

Represents a lofted surface, a smooth spatial surface generated by transitioning between multiple spline curves.

In engineering and design, lofts are used to create complex shapes by smoothly connecting a series of cross-sectional profiles. This class enables the representation of lofted surfaces, facilitating their use in computational modeling, simulation, and visualization of aerodynamic shapes, product designs, and more.

Attributes:

  • splines (List[Spline]) –

    A series of splines defining the shapes to interpolate for the loft.

  • num_samples (int) –

    The number of sample points to generate along each spline.

  • metadata (Metadata) –

    Additional metadata for the loft.

Show JSON schema:
{
  "$defs": {
    "Metadata": {
      "additionalProperties": false,
      "description": "Key-value metadata for annotating architecture nodes.",
      "properties": {
        "key": {
          "title": "Key",
          "type": "string"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Units of measure",
          "title": "Units"
        },
        "uncertainty": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Uncertainty value",
          "title": "Uncertainty"
        },
        "lower_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Lower bound",
          "title": "Lower Bounds"
        },
        "upper_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Upper bound",
          "title": "Upper Bounds"
        }
      },
      "required": [
        "key"
      ],
      "title": "Metadata",
      "type": "object"
    },
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    },
    "Spline": {
      "description": "Represents a spline, which is a smooth curve constructed from a series of control points.\n\nSplines are essential in various applications such as computer graphics, geometric modeling, and trajectory planning.\n\nAttributes:\n    points (List[Point]): The list of control points that define the spline. The spline passes through these points.\n    degree (int): The degree of the spline curve. Common values are 2 (quadratic) and 3 (cubic).\n\nRaises:\n    ValueError: If the number of points is less than the degree + 1, which is necessary for defining a valid spline.",
      "properties": {
        "points": {
          "description": "Control points that define the spline.",
          "items": {
            "$ref": "#/$defs/Point"
          },
          "minItems": 2,
          "title": "Points",
          "type": "array"
        },
        "degree": {
          "default": 3,
          "description": "The degree of the spline curve. Commonly 2 (quadratic) or 3 (cubic).",
          "exclusiveMinimum": 0,
          "title": "Degree",
          "type": "integer"
        }
      },
      "required": [
        "points"
      ],
      "title": "Spline",
      "type": "object"
    }
  },
  "description": "Represents a lofted surface, a smooth spatial surface generated by transitioning between multiple spline curves.\n\nIn engineering and design, lofts are used to create complex shapes by smoothly connecting a series of cross-sectional\nprofiles. This class enables the representation of lofted surfaces, facilitating their use in computational modeling,\nsimulation, and visualization of aerodynamic shapes, product designs, and more.\n\nAttributes:\n    splines (List[Spline]): A series of splines defining the shapes to interpolate for the loft.\n    num_samples (int): The number of sample points to generate along each spline.\n    metadata (Metadata): Additional metadata for the loft.",
  "properties": {
    "splines": {
      "description": "A series of splines defining the shapes to interpolate for the loft.",
      "items": {
        "$ref": "#/$defs/Spline"
      },
      "title": "Splines",
      "type": "array"
    },
    "num_samples": {
      "default": 100,
      "description": "The number of sample points to generate along each spline.",
      "title": "Num Samples",
      "type": "integer"
    },
    "metadata": {
      "anyOf": [
        {
          "$ref": "#/$defs/Metadata"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Additional metadata for the loft."
    }
  },
  "required": [
    "splines"
  ],
  "title": "Loft",
  "type": "object"
}

Fields:

Validators:

metadata pydantic-field ¤

metadata: Optional[Metadata] = None

Additional metadata for the loft.

num_samples pydantic-field ¤

num_samples: int = 100

The number of sample points to generate along each spline.

splines pydantic-field ¤

splines: list[Spline]

A series of splines defining the shapes to interpolate for the loft.

add_spline ¤

add_spline(spline: Spline) -> None

Add a new spline to the series of cross-sectional profiles, potentially altering the shape of the lofted surface.

Parameters:

  • spline (Spline) –

    The new spline to be added to the series defining the loft.

Source code in src/adh/wbs/airframe/airframe_geometry.py
629
630
631
632
633
634
635
def add_spline(self, spline: Spline) -> None:
    """Add a new spline to the series of cross-sectional profiles, potentially altering the shape of the lofted surface.

    Args:
        spline: The new spline to be added to the series defining the loft.
    """
    self.splines.append(spline)

calculate_surface ¤

calculate_surface() -> list[list[float]]

Calculate the lofted surface by interpolating between the splines.

This method generates a series of intermediate curves by interpolating between the given splines, creating a smooth surface that transitions from one cross-sectional profile to another.

Returns:

  • list[list[float]]

    A list of lists representing the lofted surface points, where each inner list represents a point

  • list[list[float]]

    on the surface with [x, y, z] coordinates.

Source code in src/adh/wbs/airframe/airframe_geometry.py
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
def calculate_surface(self) -> list[list[float]]:
    """Calculate the lofted surface by interpolating between the splines.

    This method generates a series of intermediate curves by interpolating between the given splines,
    creating a smooth surface that transitions from one cross-sectional profile to another.

    Returns:
        A list of lists representing the lofted surface points, where each inner list represents a point
        on the surface with [x, y, z] coordinates.
    """

    def interpolate_points(p1: Point, p2: Point, t: float) -> Point:
        """Interpolate between two points.

        Args:
            p1: The first point.
            p2: The second point.
            t: The interpolation parameter (0 <= t <= 1).

        Returns:
            The interpolated point.
        """
        return Point(
            x=p1.x + t * (p2.x - p1.x),
            y=p1.y + t * (p2.y - p1.y),
            z=p1.z + t * (p2.z - p1.z),
        )

    def interpolate_splines(
        spline1: Spline, spline2: Spline, t: float
    ) -> list[Point]:
        """Interpolate between two splines.

        Args:
            spline1: The first spline.
            spline2: The second spline.
            t: The interpolation parameter (0 <= t <= 1).

        Returns:
            A list of interpolated points.
        """
        return [
            interpolate_points(p1, p2, t)
            for p1, p2 in zip(spline1.points, spline2.points)
        ]

    surface_points = []

    for i in range(len(self.splines) - 1):
        spline1 = self.splines[i]
        spline2 = self.splines[i + 1]

        for j in range(self.num_samples):
            t = j / (self.num_samples - 1)
            interpolated_points = interpolate_splines(spline1, spline2, t)
            surface_points.extend([[p.x, p.y, p.z] for p in interpolated_points])

    return surface_points

validate_num_samples pydantic-validator ¤

validate_num_samples(value: int) -> int

Validate the 'num_samples' field to ensure it is a positive integer.

Parameters:

  • value (int) –

    The number of samples being validated.

Returns:

  • int

    The validated number of samples.

Raises:

  • ValueError

    If the number of samples is not a positive integer.

Source code in src/adh/wbs/airframe/airframe_geometry.py
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
@field_validator("num_samples", mode="before")
def validate_num_samples(cls, value: int) -> int:
    """Validate the 'num_samples' field to ensure it is a positive integer.

    Args:
        value: The number of samples being validated.

    Returns:
        The validated number of samples.

    Raises:
        ValueError: If the number of samples is not a positive integer.
    """
    if value <= 0:
        raise ValueError("The number of samples must be a positive integer.")
    return value

validate_splines pydantic-validator ¤

validate_splines(value: list[Spline]) -> list[Spline]

Validate the 'splines' list to ensure it contains at least two splines with the same degree.

Parameters:

  • value (list[Spline]) –

    The list of splines being validated.

Returns:

Raises:

  • ValueError

    If the list contains fewer than two splines or if the splines have different degrees.

Source code in src/adh/wbs/airframe/airframe_geometry.py
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
@field_validator("splines", mode="before")
def validate_splines(cls, value: list[Spline]) -> list[Spline]:
    """Validate the 'splines' list to ensure it contains at least two splines with the same degree.

    Args:
        value: The list of splines being validated.

    Returns:
        The validated list of splines.

    Raises:
        ValueError: If the list contains fewer than two splines or if the splines have different degrees.
    """
    if len(value) < 2:
        raise ValueError("A loft requires at least two splines.")

    degree = value[0].degree
    if any(spline.degree != degree for spline in value):
        raise ValueError("All splines in the loft must have the same degree.")

    return value

Mesh pydantic-model ¤

Bases: BaseModel

Represents a 3D mesh, a collection of polygons (typically triangles or quadrilaterals) used to model the surface of a 3D object.

Meshes are fundamental in computer graphics, engineering simulations, and geometric modeling, allowing for the detailed representation of complex 3D shapes. This class facilitates the construction, manipulation, and analysis of mesh geometries, supporting applications in visualization, physical simulation, and more.

Attributes:

Show JSON schema:
{
  "$defs": {
    "Metadata": {
      "additionalProperties": false,
      "description": "Key-value metadata for annotating architecture nodes.",
      "properties": {
        "key": {
          "title": "Key",
          "type": "string"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Units of measure",
          "title": "Units"
        },
        "uncertainty": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Uncertainty value",
          "title": "Uncertainty"
        },
        "lower_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Lower bound",
          "title": "Lower Bounds"
        },
        "upper_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Upper bound",
          "title": "Upper Bounds"
        }
      },
      "required": [
        "key"
      ],
      "title": "Metadata",
      "type": "object"
    },
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    },
    "Polyline": {
      "description": "Represents a polyline, a series of connected 3D points forming a continuous line or path.\n\nUseful in geometric modeling and spatial analysis, the Polyline class enables the representation\nof linear paths, edges, or trajectories in three-dimensional space, facilitating calculations and\nvisualizations related to lines.\n\nAttributes:\n    points (List[Point]): A series of 3D points defining the polyline.\n    metadata (Metadata): Additional metadata for the polyline.",
      "properties": {
        "points": {
          "description": "A series of 3D points defining the polyline.",
          "items": {
            "$ref": "#/$defs/Point"
          },
          "title": "Points",
          "type": "array"
        },
        "metadata": {
          "anyOf": [
            {
              "$ref": "#/$defs/Metadata"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Additional metadata for the polyline."
        }
      },
      "required": [
        "points"
      ],
      "title": "Polyline",
      "type": "object"
    }
  },
  "description": "Represents a 3D mesh, a collection of polygons (typically triangles or quadrilaterals) used to model the surface of a 3D object.\n\nMeshes are fundamental in computer graphics, engineering simulations, and geometric modeling, allowing for the detailed\nrepresentation of complex 3D shapes. This class facilitates the construction, manipulation, and analysis of mesh geometries,\nsupporting applications in visualization, physical simulation, and more.\n\nAttributes:\n    polylines (List[Polyline]): A collection of polylines defining the mesh.\n    metadata (Metadata): Additional metadata for the mesh.",
  "properties": {
    "polylines": {
      "description": "A collection of polylines defining the mesh.",
      "items": {
        "$ref": "#/$defs/Polyline"
      },
      "title": "Polylines",
      "type": "array"
    },
    "metadata": {
      "anyOf": [
        {
          "$ref": "#/$defs/Metadata"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Additional metadata for the mesh."
    }
  },
  "required": [
    "polylines"
  ],
  "title": "Mesh",
  "type": "object"
}

Fields:

Validators:

metadata pydantic-field ¤

metadata: Optional[Metadata] = None

Additional metadata for the mesh.

polylines pydantic-field ¤

polylines: list[Polyline]

A collection of polylines defining the mesh.

add_polyline ¤

add_polyline(polyline: Polyline) -> None

Add a new polyline object to the mesh, expanding its geometry.

Parameters:

  • polyline (Polyline) –

    The new polyline to be added to the mesh.

Source code in src/adh/wbs/airframe/airframe_geometry.py
461
462
463
464
465
466
467
def add_polyline(self, polyline: Polyline) -> None:
    """Add a new polyline object to the mesh, expanding its geometry.

    Args:
        polyline: The new polyline to be added to the mesh.
    """
    self.polylines.append(polyline)

calculate_volume ¤

calculate_volume() -> float

Calculate the volume enclosed by the mesh.

This method uses the tetrahedron decomposition algorithm to compute the volume enclosed by the mesh geometry.

Returns:

  • float

    The calculated volume of the mesh.

Source code in src/adh/wbs/airframe/airframe_geometry.py
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
def calculate_volume(self) -> float:
    """Calculate the volume enclosed by the mesh.

    This method uses the tetrahedron decomposition algorithm to compute the volume
    enclosed by the mesh geometry.

    Returns:
        The calculated volume of the mesh.
    """

    def signed_tetrahedron_volume(a: Point, b: Point, c: Point, d: Point) -> float:
        """Calculate the signed volume of a tetrahedron given its four vertices.

        Args:
            a: The first vertex of the tetrahedron.
            b: The second vertex of the tetrahedron.
            c: The third vertex of the tetrahedron.
            d: The fourth vertex of the tetrahedron.

        Returns:
            The signed volume of the tetrahedron.
        """
        return (
            (a.x - d.x) * (b.y - d.y) * (c.z - d.z)
            + (a.y - d.y) * (b.z - d.z) * (c.x - d.x)
            + (a.z - d.z) * (b.x - d.x) * (c.y - d.y)
            - (a.z - d.z) * (b.y - d.y) * (c.x - d.x)
            - (a.y - d.y) * (b.x - d.x) * (c.z - d.z)
            - (a.x - d.x) * (b.z - d.z) * (c.y - d.y)
        ) / 6.0

    # Assuming the mesh is closed and the polylines form a valid surface
    # We will use the first point as the reference point for tetrahedron decomposition
    reference_point = self.polylines[0].points[0]
    total_volume = 0.0

    for polyline in self.polylines:
        points = polyline.points
        for i in range(1, len(points) - 1):
            total_volume += signed_tetrahedron_volume(
                reference_point, points[0], points[i], points[i + 1]
            )

    return abs(total_volume)

remove_polyline ¤

remove_polyline(index: int) -> None

Remove a polyline from the mesh at the specified index.

Parameters:

  • index (int) –

    The index of the polyline to be removed.

Raises:

  • IndexError

    If the specified index is out of range.

Source code in src/adh/wbs/airframe/airframe_geometry.py
469
470
471
472
473
474
475
476
477
478
479
480
def remove_polyline(self, index: int) -> None:
    """Remove a polyline from the mesh at the specified index.

    Args:
        index: The index of the polyline to be removed.

    Raises:
        IndexError: If the specified index is out of range.
    """
    if index < 0 or index >= len(self.polylines):
        raise IndexError("Invalid index for polyline removal.")
    self.polylines.pop(index)

validate_polylines pydantic-validator ¤

validate_polylines(value: list[Polyline]) -> list[Polyline]

Validate the 'polylines' list to ensure it contains at least one polyline.

Parameters:

  • value (list[Polyline]) –

    The list of polylines being validated.

Returns:

Raises:

Source code in src/adh/wbs/airframe/airframe_geometry.py
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
@field_validator("polylines", mode="before")
def validate_polylines(cls, value: list[Polyline]) -> list[Polyline]:
    """Validate the 'polylines' list to ensure it contains at least one polyline.

    Args:
        value: The list of polylines being validated.

    Returns:
        The validated list of polylines.

    Raises:
        ValueError: If the list is empty.
    """
    if not value:
        raise ValueError("A mesh must contain at least one polyline.")
    return value

Point pydantic-model ¤

Bases: BaseModel

Represents a point in 3D space, defined by its x, y, and z coordinates.

Attributes:

  • x (float) –

    The x-coordinate of the point.

  • y (float) –

    The y-coordinate of the point.

  • z (float) –

    The z-coordinate of the point.

Raises:

  • ValueError

    If any coordinate is not a finite number, ensuring points are well-defined in 3D space.

Show JSON schema:
{
  "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
  "properties": {
    "x": {
      "description": "The x-coordinate of the point.",
      "title": "X",
      "type": "number"
    },
    "y": {
      "description": "The y-coordinate of the point.",
      "title": "Y",
      "type": "number"
    },
    "z": {
      "description": "The z-coordinate of the point.",
      "title": "Z",
      "type": "number"
    }
  },
  "required": [
    "x",
    "y",
    "z"
  ],
  "title": "Point",
  "type": "object"
}

Fields:

Validators:

coordinates property ¤

coordinates: tuple[float, float, float]

Return the coordinates as a tuple (x, y, z).

x pydantic-field ¤

x: float

The x-coordinate of the point.

y pydantic-field ¤

y: float

The y-coordinate of the point.

z pydantic-field ¤

z: float

The z-coordinate of the point.

__hash__ ¤

__hash__()

Return the hash value of the Point object.

Source code in src/adh/wbs/airframe/airframe_geometry.py
257
258
259
def __hash__(self):
    """Return the hash value of the Point object."""
    return hash(self.coordinates)

distance_to ¤

distance_to(other: Point) -> float

Calculate the Euclidean distance between this point and another point.

Parameters:

  • other (Point) –

    The other point to calculate the distance to.

Returns:

  • float

    The Euclidean distance between the two points.

Source code in src/adh/wbs/airframe/airframe_geometry.py
244
245
246
247
248
249
250
251
252
253
254
255
def distance_to(self, other: Point) -> float:
    """Calculate the Euclidean distance between this point and another point.

    Args:
        other: The other point to calculate the distance to.

    Returns:
        The Euclidean distance between the two points.
    """
    return sqrt(
        sum((a - b) ** 2 for a, b in zip(self.coordinates, other.coordinates))
    )

validate_coordinate pydantic-validator ¤

validate_coordinate(value: float) -> float

Validate that the coordinate is a finite number, ensuring the point is well-defined.

Parameters:

  • value (float) –

    The coordinate value to validate.

Returns:

  • float

    The validated coordinate value.

Raises:

  • ValueError

    If the coordinate is not a finite number.

Source code in src/adh/wbs/airframe/airframe_geometry.py
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
@field_validator("x", "y", "z")
@classmethod
def validate_coordinate(cls, value: float) -> float:
    """Validate that the coordinate is a finite number, ensuring the point is well-defined.

    Args:
        value: The coordinate value to validate.

    Returns:
        The validated coordinate value.

    Raises:
        ValueError: If the coordinate is not a finite number.
    """
    if not math_isfinite(value):
        raise ValueError("Coordinate values must be finite.")
    return value

Polyline pydantic-model ¤

Bases: BaseModel

Represents a polyline, a series of connected 3D points forming a continuous line or path.

Useful in geometric modeling and spatial analysis, the Polyline class enables the representation of linear paths, edges, or trajectories in three-dimensional space, facilitating calculations and visualizations related to lines.

Attributes:

Show JSON schema:
{
  "$defs": {
    "Metadata": {
      "additionalProperties": false,
      "description": "Key-value metadata for annotating architecture nodes.",
      "properties": {
        "key": {
          "title": "Key",
          "type": "string"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Units of measure",
          "title": "Units"
        },
        "uncertainty": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Uncertainty value",
          "title": "Uncertainty"
        },
        "lower_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Lower bound",
          "title": "Lower Bounds"
        },
        "upper_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Upper bound",
          "title": "Upper Bounds"
        }
      },
      "required": [
        "key"
      ],
      "title": "Metadata",
      "type": "object"
    },
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    }
  },
  "description": "Represents a polyline, a series of connected 3D points forming a continuous line or path.\n\nUseful in geometric modeling and spatial analysis, the Polyline class enables the representation\nof linear paths, edges, or trajectories in three-dimensional space, facilitating calculations and\nvisualizations related to lines.\n\nAttributes:\n    points (List[Point]): A series of 3D points defining the polyline.\n    metadata (Metadata): Additional metadata for the polyline.",
  "properties": {
    "points": {
      "description": "A series of 3D points defining the polyline.",
      "items": {
        "$ref": "#/$defs/Point"
      },
      "title": "Points",
      "type": "array"
    },
    "metadata": {
      "anyOf": [
        {
          "$ref": "#/$defs/Metadata"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Additional metadata for the polyline."
    }
  },
  "required": [
    "points"
  ],
  "title": "Polyline",
  "type": "object"
}

Fields:

Validators:

metadata pydantic-field ¤

metadata: Optional[Metadata] = None

Additional metadata for the polyline.

points pydantic-field ¤

points: list[Point]

A series of 3D points defining the polyline.

add_point ¤

add_point(point: Point) -> None

Add a new point object to the end of the polyline, extending its path.

Parameters:

  • point (Point) –

    The point object to be appended to the polyline.

Source code in src/adh/wbs/airframe/airframe_geometry.py
298
299
300
301
302
303
304
def add_point(self, point: Point) -> None:
    """Add a new point object to the end of the polyline, extending its path.

    Args:
        point: The point object to be appended to the polyline.
    """
    self.points.append(point)

length ¤

length() -> float

Calculate the total length of the polyline by summing the distances between consecutive points.

Returns:

  • float

    The total length of the polyline.

Source code in src/adh/wbs/airframe/airframe_geometry.py
306
307
308
309
310
311
312
313
314
315
def length(self) -> float:
    """Calculate the total length of the polyline by summing the distances between consecutive points.

    Returns:
        The total length of the polyline.
    """
    total_length = 0.0
    for i in range(1, len(self.points)):
        total_length += self.points[i].distance_to(self.points[i - 1])
    return total_length

simplify ¤

simplify(tolerance: float) -> Polyline

Simplify the polyline by removing redundant points based on a specified tolerance.

The simplification algorithm iteratively removes points that deviate from the line segment formed by their neighboring points by a distance less than the specified tolerance. This process continues until no more points can be removed without exceeding the tolerance.

Parameters:

  • tolerance (float) –

    The maximum deviation allowed for a point to be considered redundant.

Returns:

  • Polyline

    A new simplified polyline with redundant points removed.

Source code in src/adh/wbs/airframe/airframe_geometry.py
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
347
348
349
350
351
def simplify(self, tolerance: float) -> Polyline:
    """Simplify the polyline by removing redundant points based on a specified tolerance.

    The simplification algorithm iteratively removes points that deviate from the line segment formed
    by their neighboring points by a distance less than the specified tolerance. This process continues
    until no more points can be removed without exceeding the tolerance.

    Args:
        tolerance: The maximum deviation allowed for a point to be considered redundant.

    Returns:
        A new simplified polyline with redundant points removed.
    """
    if len(self.points) < 3:
        return self

    simplified_points = [self.points[0]]  # Always keep the first point
    for i in range(1, len(self.points) - 1):
        prev_point = simplified_points[-1]
        point = self.points[i]
        next_point = self.points[i + 1]

        area = abs(
            (next_point.coordinates[0] - prev_point.coordinates[0])
            * (point.coordinates[1] - prev_point.coordinates[1])
            - (next_point.coordinates[1] - prev_point.coordinates[1])
            * (point.coordinates[0] - prev_point.coordinates[0])
        )
        height = area / prev_point.distance_to(next_point)

        if height > tolerance:
            simplified_points.append(point)

    simplified_points.append(self.points[-1])  # Always keep the last point
    return Polyline(points=simplified_points)

validate_points pydantic-validator ¤

validate_points(value: list[Point]) -> list[Point]

Validate the 'points' list to ensure it contains at least two points.

Parameters:

  • value (list[Point]) –

    The list of points being validated.

Returns:

  • list[Point]

    The validated list of points.

Raises:

  • ValueError

    If the list contains fewer than two points.

Source code in src/adh/wbs/airframe/airframe_geometry.py
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
@field_validator("points", mode="before")
def validate_points(cls, value: list[Point]) -> list[Point]:
    """Validate the 'points' list to ensure it contains at least two points.

    Args:
        value: The list of points being validated.

    Returns:
        The validated list of points.

    Raises:
        ValueError: If the list contains fewer than two points.
    """
    if len(value) < 2:
        raise ValueError("A polyline must contain at least two points.")
    return value

ReferenceAxis pydantic-model ¤

ReferenceAxis(**data: Any)

Bases: BaseModel

Represents the reference axis of a body component, such as an aircraft fuselage or wing.

Attributes:

Show JSON schema:
{
  "$defs": {
    "Metadata": {
      "additionalProperties": false,
      "description": "Key-value metadata for annotating architecture nodes.",
      "properties": {
        "key": {
          "title": "Key",
          "type": "string"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Units of measure",
          "title": "Units"
        },
        "uncertainty": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Uncertainty value",
          "title": "Uncertainty"
        },
        "lower_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Lower bound",
          "title": "Lower Bounds"
        },
        "upper_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Upper bound",
          "title": "Upper Bounds"
        }
      },
      "required": [
        "key"
      ],
      "title": "Metadata",
      "type": "object"
    },
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    },
    "ReferenceAxis": {
      "description": "Represents the reference axis of a body component, such as an aircraft fuselage or wing.\n\nAttributes:\n    name (str): The name of the reference axis.\n    points (List[Point]): A series of 3D points defining the reference axis.\n    description (Optional[str]): A brief description of the reference axis.\n    metadata (Metadata): Additional metadata for the reference axis.\n    relative_to (Optional[str]): The name of another reference axis to which this axis is relative.",
      "properties": {
        "name": {
          "description": "The name of the reference axis.",
          "title": "Name",
          "type": "string"
        },
        "points": {
          "description": "A series of 3D points defining the reference axis.",
          "items": {
            "$ref": "#/$defs/Point"
          },
          "title": "Points",
          "type": "array"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A brief description of the reference axis.",
          "title": "Description"
        },
        "metadata": {
          "anyOf": [
            {
              "$ref": "#/$defs/Metadata"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Additional metadata for the reference axis."
        },
        "relative_to": {
          "anyOf": [
            {
              "$ref": "#/$defs/ReferenceAxis"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The name or instance of another reference axis to which this axis is relative.",
          "title": "Relative To"
        }
      },
      "required": [
        "name",
        "points"
      ],
      "title": "ReferenceAxis",
      "type": "object"
    }
  },
  "$ref": "#/$defs/ReferenceAxis"
}

Fields:

Validators:

Source code in src/adh/wbs/airframe/airframe_geometry.py
828
829
830
831
def __init__(self, **data: Any):
    super().__init__(**data)
    # Register the instance after initialization
    self._registry[self.name] = self

description pydantic-field ¤

description: Optional[str] = None

A brief description of the reference axis.

metadata pydantic-field ¤

metadata: Optional[Metadata] = None

Additional metadata for the reference axis.

name pydantic-field ¤

name: str

The name of the reference axis.

points pydantic-field ¤

points: list[Point]

A series of 3D points defining the reference axis.

relative_to pydantic-field ¤

relative_to: Optional[Union[ReferenceAxis, str]] = None

The name or instance of another reference axis to which this axis is relative.

resolve_relative_to pydantic-validator ¤

resolve_relative_to() -> ReferenceAxis

Resolve the 'relative_to' name to a ReferenceAxis instance.

Parameters:

Returns:

Raises:

  • ValueError

    If the 'relative_to' name does not exist.

Source code in src/adh/wbs/airframe/airframe_geometry.py
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
@model_validator(mode="after")
def resolve_relative_to(self: ReferenceAxis) -> ReferenceAxis:
    """Resolve the 'relative_to' name to a ReferenceAxis instance.

    Args:
        self: The validated ReferenceAxis instance.

    Returns:
        The validated dictionary of field values.

    Raises:
        ValueError: If the 'relative_to' name does not exist.
    """
    if self.relative_to:
        if isinstance(self.relative_to, ReferenceAxis):
            return self
        relative_to_axis = self._registry.get(str(self.relative_to))
        if not relative_to_axis:
            raise ValueError(
                f"ReferenceAxis with name '{self.relative_to}' does not exist."
            )
        self.relative_to = relative_to_axis
    return self

validate_and_register pydantic-validator ¤

validate_and_register(values: dict[str, Any]) -> dict[str, Any]

Ensure that the name is unique and register the instance.

Parameters:

  • values (dict[str, Any]) –

    The dictionary of field values.

Returns:

  • dict[str, Any]

    The validated dictionary of field values.

Raises:

Source code in src/adh/wbs/airframe/airframe_geometry.py
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
@model_validator(mode="before")
@classmethod
def validate_and_register(cls, values: dict[str, Any]) -> dict[str, Any]:
    """Ensure that the name is unique and register the instance.

    Args:
        values: The dictionary of field values.

    Returns:
        The validated dictionary of field values.

    Raises:
        ValueError: If the name is not unique.
    """
    name = values.get("name")
    if name in cls._registry:
        raise ValueError(f"A ReferenceAxis with the name '{name}' already exists.")
    return values

validate_points pydantic-validator ¤

validate_points(value: list[Point]) -> list[Point]

Validate the 'points' list to ensure it contains at least two points.

Parameters:

  • value (list[Point]) –

    The list of points being validated.

Returns:

  • list[Point]

    The validated list of points.

Raises:

  • ValueError

    If the list contains fewer than two points.

Source code in src/adh/wbs/airframe/airframe_geometry.py
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
@field_validator("points", mode="before")
def validate_points(cls, value: list[Point]) -> list[Point]:
    """Validate the 'points' list to ensure it contains at least two points.

    Args:
        value: The list of points being validated.

    Returns:
        The validated list of points.

    Raises:
        ValueError: If the list contains fewer than two points.
    """
    if len(value) < 2:
        raise ValueError("A reference axis must contain at least two points.")
    return value

Spline pydantic-model ¤

Bases: BaseModel

Represents a spline, which is a smooth curve constructed from a series of control points.

Splines are essential in various applications such as computer graphics, geometric modeling, and trajectory planning.

Attributes:

  • points (List[Point]) –

    The list of control points that define the spline. The spline passes through these points.

  • degree (int) –

    The degree of the spline curve. Common values are 2 (quadratic) and 3 (cubic).

Raises:

  • ValueError

    If the number of points is less than the degree + 1, which is necessary for defining a valid spline.

Show JSON schema:
{
  "$defs": {
    "Point": {
      "description": "Represents a point in 3D space, defined by its x, y, and z coordinates.\n\nAttributes:\n    x (float): The x-coordinate of the point.\n    y (float): The y-coordinate of the point.\n    z (float): The z-coordinate of the point.\n\nRaises:\n    ValueError: If any coordinate is not a finite number, ensuring points are well-defined in 3D space.",
      "properties": {
        "x": {
          "description": "The x-coordinate of the point.",
          "title": "X",
          "type": "number"
        },
        "y": {
          "description": "The y-coordinate of the point.",
          "title": "Y",
          "type": "number"
        },
        "z": {
          "description": "The z-coordinate of the point.",
          "title": "Z",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ],
      "title": "Point",
      "type": "object"
    }
  },
  "description": "Represents a spline, which is a smooth curve constructed from a series of control points.\n\nSplines are essential in various applications such as computer graphics, geometric modeling, and trajectory planning.\n\nAttributes:\n    points (List[Point]): The list of control points that define the spline. The spline passes through these points.\n    degree (int): The degree of the spline curve. Common values are 2 (quadratic) and 3 (cubic).\n\nRaises:\n    ValueError: If the number of points is less than the degree + 1, which is necessary for defining a valid spline.",
  "properties": {
    "points": {
      "description": "Control points that define the spline.",
      "items": {
        "$ref": "#/$defs/Point"
      },
      "minItems": 2,
      "title": "Points",
      "type": "array"
    },
    "degree": {
      "default": 3,
      "description": "The degree of the spline curve. Commonly 2 (quadratic) or 3 (cubic).",
      "exclusiveMinimum": 0,
      "title": "Degree",
      "type": "integer"
    }
  },
  "required": [
    "points"
  ],
  "title": "Spline",
  "type": "object"
}

Fields:

Validators:

degree pydantic-field ¤

degree: int = 3

The degree of the spline curve. Commonly 2 (quadratic) or 3 (cubic).

points pydantic-field ¤

points: list[Point]

Control points that define the spline.

validate_degree pydantic-validator ¤

validate_degree(value: int) -> int

Validate that the degree of the spline is a positive integer.

Parameters:

  • value (int) –

    The degree of the spline.

Returns:

  • int

    The validated degree of the spline.

Raises:

  • ValueError

    If the degree is not a positive integer.

Source code in src/adh/wbs/airframe/airframe_geometry.py
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
@field_validator("degree", mode="before")
def validate_degree(cls, value: int) -> int:
    """Validate that the degree of the spline is a positive integer.

    Args:
        value: The degree of the spline.

    Returns:
        The validated degree of the spline.

    Raises:
        ValueError: If the degree is not a positive integer.
    """
    if value <= 0:
        raise ValueError("The degree of the spline must be a positive integer.")
    return value

validate_points pydantic-validator ¤

validate_points(value: list[Point], info: ValidationInfo) -> list[Point]

Validate that the list of points is sufficient to define a spline of the specified degree.

Parameters:

  • value (list[Point]) –

    The list of control points.

  • info (ValidationInfo) –

    Validation context information for the field being validated.

Returns:

  • list[Point]

    The validated list of control points.

Raises:

  • ValueError

    If the number of points is less than the required for the spline's degree.

Source code in src/adh/wbs/airframe/airframe_geometry.py
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
@field_validator("points", mode="before")
def validate_points(cls, value: list[Point], info: ValidationInfo) -> list[Point]:
    """Validate that the list of points is sufficient to define a spline of the specified degree.

    Args:
        value: The list of control points.
        info: Validation context information for the field being validated.

    Returns:
        The validated list of control points.

    Raises:
        ValueError: If the number of points is less than the required for the spline's degree.
    """
    # Default to cubic if degree is not yet validated
    degree_value = 3
    if info.data and "degree" in info.data:
        degree_value = info.data.get("degree", 3)
    try:
        degree = int(degree_value) if degree_value is not None else 3
    except (TypeError, ValueError):
        degree = 3
    if len(value) < degree + 1:
        raise ValueError(
            f"At least {degree + 1} points are required to define a spline of degree {degree}."
        )
    return value

String pydantic-model ¤

Bases: BaseModel

Represents a string data type with enhanced attributes for engineering applications.

Attributes:

  • value (str) –

    The actual string value. It must have at least 1 character.

  • default (Optional[str]) –

    A default value for the variable, if any. Defaults to None.

  • metadata (Metadata) –

    Additional metadata providing further context or details about the variable. Defaults to a new instance of Metadata.

Raises:

  • ValidationError

    If the input value does not meet the validation criteria.

Show JSON schema:
{
  "$defs": {
    "Metadata": {
      "additionalProperties": false,
      "description": "Key-value metadata for annotating architecture nodes.",
      "properties": {
        "key": {
          "title": "Key",
          "type": "string"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Units of measure",
          "title": "Units"
        },
        "uncertainty": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Uncertainty value",
          "title": "Uncertainty"
        },
        "lower_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Lower bound",
          "title": "Lower Bounds"
        },
        "upper_bounds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Upper bound",
          "title": "Upper Bounds"
        }
      },
      "required": [
        "key"
      ],
      "title": "Metadata",
      "type": "object"
    }
  },
  "description": "Represents a string data type with enhanced attributes for engineering applications.\n\nAttributes:\n    value (str): The actual string value. It must have at least 1 character.\n    default (Optional[str]): A default value for the variable, if any. Defaults to None.\n    metadata (Metadata): Additional metadata providing further context or details about the variable.\n                         Defaults to a new instance of Metadata.\n\nRaises:\n    ValidationError: If the input value does not meet the validation criteria.",
  "properties": {
    "value": {
      "description": "The actual string value.",
      "minLength": 1,
      "title": "Value",
      "type": "string"
    },
    "default": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A default value for the variable, if any.",
      "title": "Default"
    },
    "metadata": {
      "anyOf": [
        {
          "$ref": "#/$defs/Metadata"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Additional metadata providing further context or details about the variable."
    }
  },
  "required": [
    "value"
  ],
  "title": "String",
  "type": "object"
}

Fields:

default pydantic-field ¤

default: Optional[str] = None

A default value for the variable, if any.

metadata pydantic-field ¤

metadata: Optional[Metadata] = None

Additional metadata providing further context or details about the variable.

value pydantic-field ¤

value: str

The actual string value.