use axiolid_core::{Aabb, Frame2, Frame3, Point2, Point3, Scalar, Transform3, Vec2, Vec3};
use axiolid_curve::{Curve2, Curve3};
use axiolid_mesh::{PolygonMesh, TriMesh};
use axiolid_primitive::{HalfSpace, Primitive};
use axiolid_profile::Profile;
use axiolid_surface::Surface;
use axiolid_topology::BRep;
use crate::{CurveRelation, NodeId, SolidOperation, SurfaceRelation};
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct PointOnCurve {
pub curve: NodeId,
pub parameter: Scalar,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct PointOnSurface {
pub surface: NodeId,
pub u: Scalar,
pub v: Scalar,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct OpenProfile {
pub path: NodeId,
}
impl OpenProfile {
pub const fn new(path: NodeId) -> Self {
Self { path }
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Instance {
pub source: NodeId,
pub transform: Transform3,
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum GeometryNode {
Point2(Point2),
Point3(Point3),
Vector2(Vec2),
Vector3(Vec3),
Frame2(Frame2),
Frame3(Frame3),
Transform(Transform3),
PointList2(Vec<Point2>),
PointList3(Vec<Point3>),
Curve2(Curve2),
Curve3(Curve3),
CurveRelation(CurveRelation),
PointOnCurve(PointOnCurve),
Surface(Surface),
SurfaceRelation(SurfaceRelation),
PointOnSurface(PointOnSurface),
Profile(Profile),
OpenProfile(OpenProfile),
Primitive(Primitive),
HalfSpace(HalfSpace),
SolidOperation(SolidOperation),
BRep(BRep<NodeId>),
PolygonMesh(PolygonMesh),
TriMesh(TriMesh),
BoundingBox(Aabb),
Instance(Instance),
Collection(Vec<NodeId>),
}
impl GeometryNode {
pub fn references(&self) -> Vec<NodeId> {
let mut references = Vec::new();
match self {
Self::CurveRelation(value) => value.references(&mut references),
Self::PointOnCurve(value) => references.push(value.curve),
Self::SurfaceRelation(value) => value.references(&mut references),
Self::PointOnSurface(value) => references.push(value.surface),
Self::OpenProfile(value) => references.push(value.path),
Self::SolidOperation(value) => value.references(&mut references),
Self::BRep(value) => {
references.extend(value.edges().iter().filter_map(|edge| edge.curve));
references.extend(
value
.loops()
.iter()
.flat_map(|wire| wire.edges.iter())
.filter_map(|use_| use_.pcurve),
);
references.extend(value.faces().iter().filter_map(|face| face.surface));
}
Self::Instance(value) => references.push(value.source),
Self::Collection(values) => references.extend(values.iter().copied()),
Self::Point2(_)
| Self::Point3(_)
| Self::Vector2(_)
| Self::Vector3(_)
| Self::Frame2(_)
| Self::Frame3(_)
| Self::Transform(_)
| Self::PointList2(_)
| Self::PointList3(_)
| Self::Curve2(_)
| Self::Curve3(_)
| Self::Surface(_)
| Self::Profile(_)
| Self::Primitive(_)
| Self::HalfSpace(_)
| Self::PolygonMesh(_)
| Self::TriMesh(_)
| Self::BoundingBox(_) => {}
}
references
}
}