Skip to main content

GeometricObject

Trait GeometricObject 

Source
pub trait GeometricObject<Point: Clone, Input> {
    type Error;

    // Required methods
    fn get_points(&self) -> BTreeSet<&Point>;
    fn from_vector<T>(points: Vec<T>) -> Self
       where Self: Sized,
             T: Into<Point> + Clone;
    fn construct<T>(method: T) -> Result<Self, Self::Error>
       where Self: Sized,
             T: Into<ConstructionMethod<Point, Input, Self::Error>>;

    // Provided methods
    fn vector(&self) -> Vec<&Point> { ... }
    fn to_vector(&self) -> Vec<&Point> { ... }
    fn calculate_range<I>(iter: I) -> (Decimal, Decimal)
       where I: Iterator<Item = Decimal> { ... }
}
Expand description

Defines a geometric object constructed from a set of points. Provides methods for creating, accessing, and manipulating these objects.

Required Associated Types§

Source

type Error

Type alias for any errors that might occur during the construction of the geometric object.

Required Methods§

Source

fn get_points(&self) -> BTreeSet<&Point>

Returns a BTreeSet containing references to the points that constitute the geometric object. The BTreeSet ensures that the points are ordered and unique.

Source

fn from_vector<T>(points: Vec<T>) -> Self
where Self: Sized, T: Into<Point> + Clone,

Creates a new geometric object from a Vec of points.

The generic type T represents the input point type, which can be converted into the Point type associated with the geometric object.

Source

fn construct<T>(method: T) -> Result<Self, Self::Error>
where Self: Sized, T: Into<ConstructionMethod<Point, Input, Self::Error>>,

Constructs a geometric object using a specific construction method.

The generic type T represents a type that can be converted into a ConstructionMethod. The ConstructionMethod enum provides different strategies for building geometric objects, such as constructing from a set of data points or from a parametric function.

This method returns a Result to handle potential errors during construction.

§Errors

Returns the implementation’s Self::Error when the provided construction method cannot produce a valid geometry, for example when a FromData input is empty or a parametric function surfaces a domain violation.

Provided Methods§

Source

fn vector(&self) -> Vec<&Point>

Returns a Vec containing references to the points that constitute the geometric object. This method simply converts the BTreeSet from get_points into a Vec.

Source

fn to_vector(&self) -> Vec<&Point>

Returns the points of the geometric object as a Vec of references. Equivalent to calling the vector() method.

Source

fn calculate_range<I>(iter: I) -> (Decimal, Decimal)
where I: Iterator<Item = Decimal>,

Calculates the minimum and maximum decimal values from an iterator of decimals.

This is a utility function that can be used to find the range of values in a set of points.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl GeometricObject<Point2D, Decimal> for Curve

Source§

impl GeometricObject<Point3D, Point2D> for Surface

Implementation of the GeometricObject trait for the Surface struct.

This implementation provides functionality to create and manipulate 3D surfaces using points in three-dimensional space. It supports construction from explicit point collections or through parametric functions.

§Type Parameters

  • Uses Point3D as the points that form the surface
  • Uses Point2D as the parametric input for surface generation

§Methods

  • get_points(): Retrieves all points in the surface
  • from_vector(): Constructs a surface from a vector of points
  • construct(): Creates a surface using different construction methods

§Error Handling

Uses SurfaceError for various error conditions, including:

  • Empty point collections
  • Invalid construction parameters
  • Errors during parametric function evaluation