Ruled Surface: strips off an edge chain, exact where possible (#762) (#1151)

Ruled Surface: strips off an edge chain in normal, tangent, angle or direction mode, exact planes/cylinders/cones where possible, mitred or round corners, stitched into one surface body. SurfaceRuled is noted under format 21. Closes #762.
This commit is contained in:
Irakli Kourtis authored and GitHub committed 2026-10-14 21:44:56 -04:00
1 parent ed22d663e4
commit 2a4907884b
24 files changed
+1343 -36

No files matched your search

+61
View File
@@ -138,6 +138,44 @@ pub enum Direction {
Symmetric,
}
/// The direction a ruled surface leaves its edges (`surface.ruled`).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RuledMode {
/// Along the normal of the face beside each edge.
#[default]
Normal,
/// Continuing the face beside each edge.
Tangent,
/// At an angle from a reference direction (the face's normal unless one is given).
Angle,
/// Along a fixed direction.
Direction,
}
impl RuledMode {
fn is_normal(&self) -> bool {
*self == RuledMode::Normal
}
}
/// How a ruled surface's strips meet at sharp corners of its edge chain.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RuledCorners {
/// Extended or cut back until they meet.
#[default]
Mitre,
/// Joined by a sector (inside corners are cut back).
Round,
}
impl RuledCorners {
fn is_mitre(&self) -> bool {
*self == RuledCorners::Mitre
}
}
/// Angular starts in older designs used the raw axis sign. New revolves measure starts
/// along the same sketch-normal sweep direction as the kernel.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
@@ -1078,6 +1116,27 @@ pub enum FeatureKind {
#[serde(default, skip_serializing_if = "Option::is_none")]
tolerance: Option<String>,
},
/// A strip of ruled surface `distance` wide hanging off the chain of `body`'s edges through
/// `edges`, as a new surface body: along `mode` (`angle` from `direction`, or from the
/// face's normal; along `direction`), from the face at `face` where it borders the chain;
/// `flip` puts it on the other side; sharp corners as `corners` says.
SurfaceRuled {
body: String,
edges: Vec<Vec3>,
distance: String,
#[serde(default, skip_serializing_if = "RuledMode::is_normal")]
mode: RuledMode,
#[serde(default, skip_serializing_if = "Option::is_none")]
angle: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
direction: Option<Vec3>,
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
flip: bool,
#[serde(default, skip_serializing_if = "RuledCorners::is_mitre")]
corners: RuledCorners,
#[serde(default, skip_serializing_if = "Option::is_none")]
face: Option<Vec3>,
},
/// A planar surface body extended outward by `distance` past the edges through `edges`.
SurfaceExtend {
body: String,
@@ -1455,6 +1514,7 @@ impl FeatureKind {
FeatureKind::Thicken { .. } => "ThickenFeature",
FeatureKind::SurfaceTrim { .. } => "TrimFeature",
FeatureKind::SurfaceExtend { .. } => "ExtendFeature",
FeatureKind::SurfaceRuled { .. } => "RuledSurfaceFeature",
FeatureKind::Unstitch { .. } => "UnstitchFeature",
FeatureKind::ReverseNormal { .. } => "ReverseNormalFeature",
FeatureKind::SurfaceUntrim { .. } => "UntrimFeature",
@@ -1530,6 +1590,7 @@ impl FeatureKind {
FeatureKind::Thicken { .. } => "Thicken",
FeatureKind::SurfaceTrim { .. } => "Trim",
FeatureKind::SurfaceExtend { .. } => "Extend",
FeatureKind::SurfaceRuled { .. } => "RuledSurface",
FeatureKind::Unstitch { .. } => "Unstitch",
FeatureKind::ReverseNormal { .. } => "ReverseNormal",
FeatureKind::SurfaceUntrim { .. } => "Untrim",