2026-04-02 18:51:38 +03:00
|
|
|
use acadrust::entities::{Polyline, Polyline2D, Polyline3D};
|
|
|
|
|
use glam::Vec3;
|
|
|
|
|
use truck_modeling::{builder, Edge, Point3, Wire};
|
|
|
|
|
|
|
|
|
|
use crate::command::EntityTransform;
|
|
|
|
|
use crate::entities::common::{edit_prop as edit, ro_prop as ro, square_grip};
|
|
|
|
|
use crate::entities::traits::{Grippable, PropertyEditable, Transformable, TruckConvertible};
|
|
|
|
|
use crate::scene::acad_to_truck::{TruckEntity, TruckObject};
|
|
|
|
|
use crate::scene::object::{GripApply, GripDef, PropSection, PropValue, Property};
|
|
|
|
|
use crate::scene::wire_model::TangentGeom;
|
|
|
|
|
|
|
|
|
|
// ── Polyline (old-style 3D heavy polyline) ────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
fn tessellate_polyline(pl: &Polyline) -> TruckEntity {
|
2026-05-12 23:47:40 +03:00
|
|
|
let pts: Vec<[f64; 3]> = pl
|
2026-04-02 18:51:38 +03:00
|
|
|
.vertices
|
|
|
|
|
.iter()
|
2026-05-12 23:47:40 +03:00
|
|
|
.map(|v| [v.location.x, v.location.y, v.location.z])
|
2026-04-02 18:51:38 +03:00
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
let mut points = pts.clone();
|
|
|
|
|
if pl.flags.is_closed() && pts.len() >= 2 {
|
|
|
|
|
points.push(pts[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let key_verts = pts.clone();
|
|
|
|
|
TruckEntity {
|
|
|
|
|
object: TruckObject::Lines(points),
|
|
|
|
|
snap_pts: vec![],
|
|
|
|
|
tangent_geoms: vec![],
|
|
|
|
|
key_vertices: key_verts,
|
2026-05-06 23:24:26 +03:00
|
|
|
fill_tris: vec![],
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl TruckConvertible for Polyline {
|
|
|
|
|
fn to_truck(&self, _document: &acadrust::CadDocument) -> Option<TruckEntity> {
|
|
|
|
|
Some(tessellate_polyline(self))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Grippable for Polyline {
|
|
|
|
|
fn grips(&self) -> Vec<GripDef> {
|
|
|
|
|
self.vertices
|
|
|
|
|
.iter()
|
|
|
|
|
.enumerate()
|
|
|
|
|
.map(|(i, v)| {
|
|
|
|
|
square_grip(
|
|
|
|
|
i,
|
2026-05-12 10:36:15 +03:00
|
|
|
Vec3::new(
|
|
|
|
|
v.location.x as f32,
|
|
|
|
|
v.location.y as f32,
|
|
|
|
|
v.location.z as f32,
|
|
|
|
|
),
|
2026-04-02 18:51:38 +03:00
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
.collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_grip(&mut self, grip_id: usize, apply: GripApply) {
|
|
|
|
|
if let Some(v) = self.vertices.get_mut(grip_id) {
|
|
|
|
|
match apply {
|
|
|
|
|
GripApply::Translate(d) => {
|
|
|
|
|
v.location.x += d.x as f64;
|
|
|
|
|
v.location.y += d.y as f64;
|
|
|
|
|
v.location.z += d.z as f64;
|
|
|
|
|
}
|
|
|
|
|
GripApply::Absolute(p) => {
|
|
|
|
|
v.location.x = p.x as f64;
|
|
|
|
|
v.location.y = p.y as f64;
|
|
|
|
|
v.location.z = p.z as f64;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
feat(grip): popup menus for polylines, spline, mline, hatch, leaders, text
Vocabulary added: AddFitPoint, RemoveFitPoint, Refit, RefineVertices,
TangentDirection, MoveWithText, StackText, UnstackText.
Polyline/Polyline2D/Polyline3D: vertex Add/Remove. MLine: same.
Spline: CV Add/Remove plus Refine Vertices (chord-midpoint insertion,
weights kept in sync, knots cleared so to_truck rebuilds uniform vec).
Hatch: centroid Origin/Angle/Scale (Angle and Scale prompt for value).
Leader: vertex Add/Remove (arrow + centroid stay Stretch-only).
MultiLeader: vertex Add/Remove Leader; MText location Move-with-Leader /
Move-Independent (menu live, structural edits stubbed). Text/MText:
Rotate prompts for degrees and sets rotation.
Spline, Leader, MultiLeader switched from impl_entity_basics! to manual
trait impls so grip_menu can be overridden.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 15:14:43 +03:00
|
|
|
|
|
|
|
|
fn grip_menu(
|
|
|
|
|
&self,
|
|
|
|
|
_grip_id: usize,
|
|
|
|
|
) -> Vec<crate::scene::object::GripMenuItem> {
|
|
|
|
|
use crate::scene::object::{GripMenuAction, GripMenuItem};
|
|
|
|
|
vec![
|
|
|
|
|
GripMenuItem { label: "Stretch", action: GripMenuAction::Stretch },
|
|
|
|
|
GripMenuItem { label: "Add Vertex", action: GripMenuAction::AddVertex },
|
|
|
|
|
GripMenuItem { label: "Remove Vertex", action: GripMenuAction::RemoveVertex },
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_grip_menu(
|
|
|
|
|
&mut self,
|
|
|
|
|
grip_id: usize,
|
|
|
|
|
action: crate::scene::object::GripMenuAction,
|
|
|
|
|
) {
|
|
|
|
|
use crate::scene::object::GripMenuAction as A;
|
|
|
|
|
let n = self.vertices.len();
|
|
|
|
|
match action {
|
|
|
|
|
A::AddVertex if grip_id < n => {
|
|
|
|
|
let i1 = (grip_id + 1) % n;
|
|
|
|
|
if i1 == 0 && grip_id + 1 == n {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let v0 = &self.vertices[grip_id];
|
|
|
|
|
let v1 = &self.vertices[i1];
|
|
|
|
|
let mx = (v0.location.x + v1.location.x) * 0.5;
|
|
|
|
|
let my = (v0.location.y + v1.location.y) * 0.5;
|
|
|
|
|
let mz = (v0.location.z + v1.location.z) * 0.5;
|
|
|
|
|
let mut new_v = v0.clone();
|
|
|
|
|
new_v.location.x = mx;
|
|
|
|
|
new_v.location.y = my;
|
|
|
|
|
new_v.location.z = mz;
|
|
|
|
|
let insert_at = (grip_id + 1).min(self.vertices.len());
|
|
|
|
|
self.vertices.insert(insert_at, new_v);
|
|
|
|
|
}
|
|
|
|
|
A::RemoveVertex if grip_id < n && n > 2 => {
|
|
|
|
|
self.vertices.remove(grip_id);
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PropertyEditable for Polyline {
|
|
|
|
|
fn geometry_properties(&self, _text_style_names: &[String]) -> PropSection {
|
|
|
|
|
PropSection {
|
|
|
|
|
title: "Geometry".into(),
|
|
|
|
|
props: vec![
|
|
|
|
|
ro("Vertices", "vertices", self.vertices.len().to_string()),
|
|
|
|
|
Property {
|
|
|
|
|
label: "Closed".into(),
|
|
|
|
|
field: "pl_closed",
|
|
|
|
|
value: PropValue::BoolToggle {
|
|
|
|
|
field: "pl_closed",
|
|
|
|
|
value: self.flags.is_closed(),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_geom_prop(&mut self, field: &str, value: &str) {
|
|
|
|
|
if field == "pl_closed" {
|
|
|
|
|
let closed = if value == "toggle" {
|
|
|
|
|
!self.flags.is_closed()
|
|
|
|
|
} else {
|
|
|
|
|
value == "true"
|
|
|
|
|
};
|
|
|
|
|
self.flags.set_closed(closed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Transformable for Polyline {
|
|
|
|
|
fn apply_transform(&mut self, t: &EntityTransform) {
|
|
|
|
|
crate::scene::transform::apply_standard_entity_transform(self, t, |entity, p1, p2| {
|
|
|
|
|
for v in &mut entity.vertices {
|
|
|
|
|
crate::scene::transform::reflect_xy_point(
|
|
|
|
|
&mut v.location.x,
|
|
|
|
|
&mut v.location.y,
|
|
|
|
|
p1,
|
|
|
|
|
p2,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Polyline2D (heavy 2D polyline with bulge) ─────────────────────────────────
|
|
|
|
|
|
|
|
|
|
fn tessellate_polyline2d(pl: &Polyline2D) -> TruckEntity {
|
|
|
|
|
let verts = &pl.vertices;
|
|
|
|
|
if verts.is_empty() {
|
|
|
|
|
return TruckEntity {
|
|
|
|
|
object: TruckObject::Lines(vec![]),
|
|
|
|
|
snap_pts: vec![],
|
|
|
|
|
tangent_geoms: vec![],
|
|
|
|
|
key_vertices: vec![],
|
2026-05-06 23:24:26 +03:00
|
|
|
fill_tris: vec![],
|
2026-04-02 18:51:38 +03:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let elev = pl.elevation;
|
2026-05-02 20:04:30 +03:00
|
|
|
let normal = (pl.normal.x, pl.normal.y, pl.normal.z);
|
2026-04-02 18:51:38 +03:00
|
|
|
let count = verts.len();
|
|
|
|
|
let seg_count = if pl.is_closed() { count } else { count - 1 };
|
|
|
|
|
let mut edges: Vec<Edge> = Vec::new();
|
|
|
|
|
let mut tangents: Vec<TangentGeom> = Vec::new();
|
2026-05-12 23:47:40 +03:00
|
|
|
let mut key_verts: Vec<[f64; 3]> = Vec::new();
|
2026-04-02 18:51:38 +03:00
|
|
|
|
2026-05-02 20:04:30 +03:00
|
|
|
let to_wcs = |x: f64, y: f64| -> (f64, f64, f64) {
|
|
|
|
|
crate::scene::transform::ocs_point_to_wcs((x, y, elev), normal)
|
|
|
|
|
};
|
2026-04-02 18:51:38 +03:00
|
|
|
let to_pt = |v: &acadrust::entities::Vertex2D| -> Point3 {
|
2026-05-02 20:04:30 +03:00
|
|
|
let (wx, wy, wz) = to_wcs(v.location.x, v.location.y);
|
|
|
|
|
Point3::new(wx, wy, wz)
|
2026-04-02 18:51:38 +03:00
|
|
|
};
|
|
|
|
|
|
2026-05-05 20:03:57 +03:00
|
|
|
if pl.thickness.abs() > 1e-10 {
|
|
|
|
|
let (nx, ny, nz) = normal;
|
|
|
|
|
let t = pl.thickness;
|
2026-05-12 23:47:40 +03:00
|
|
|
let off = |p: [f64; 3]| -> [f64; 3] {
|
|
|
|
|
[p[0] + t * nx, p[1] + t * ny, p[2] + t * nz]
|
2026-05-05 20:03:57 +03:00
|
|
|
};
|
2026-05-12 23:47:40 +03:00
|
|
|
let to_f32 = |p: [f64; 3]| -> [f32; 3] {
|
|
|
|
|
[p[0] as f32, p[1] as f32, p[2] as f32]
|
|
|
|
|
};
|
|
|
|
|
let mut path: Vec<[f64; 3]> = Vec::new();
|
|
|
|
|
let mut kv: Vec<[f64; 3]> = Vec::new();
|
2026-05-05 20:03:57 +03:00
|
|
|
let mut tgs: Vec<TangentGeom> = Vec::new();
|
|
|
|
|
let (w0x, w0y, w0z) = to_wcs(verts[0].location.x, verts[0].location.y);
|
2026-05-12 23:47:40 +03:00
|
|
|
path.push([w0x, w0y, w0z]);
|
|
|
|
|
kv.push([w0x, w0y, w0z]);
|
2026-05-05 20:03:57 +03:00
|
|
|
for i in 0..seg_count {
|
|
|
|
|
let va = &verts[i];
|
|
|
|
|
let vb = &verts[(i + 1) % count];
|
|
|
|
|
let (ox0, oy0) = (va.location.x, va.location.y);
|
|
|
|
|
let (ox1, oy1) = (vb.location.x, vb.location.y);
|
|
|
|
|
let bulge = va.bulge;
|
|
|
|
|
if bulge.abs() < 1e-9 {
|
|
|
|
|
let (wx, wy, wz) = to_wcs(ox1, oy1);
|
2026-05-12 23:47:40 +03:00
|
|
|
path.push([wx, wy, wz]);
|
|
|
|
|
let p1_pt = path[path.len() - 2];
|
|
|
|
|
let p2_pt = *path.last().unwrap();
|
2026-05-12 10:36:15 +03:00
|
|
|
tgs.push(TangentGeom::Line {
|
2026-05-12 23:47:40 +03:00
|
|
|
p1: to_f32(p1_pt),
|
|
|
|
|
p2: to_f32(p2_pt),
|
2026-05-12 10:36:15 +03:00
|
|
|
});
|
refactor(common): unify bulge → arc math into BulgeArc
The same DXF/DWG bulge → (center, radius, sweep) formula was inlined
in six places (hatch outline, polyline tess + truck path, lwpolyline
×4, scene hatch fill, explode bulge_to_arc) — each with subtly
different sweep-direction handling for the bulge sign.
Add `entities::common::BulgeArc { center, radius, start_angle,
end_angle, sweep }` with one `from_bulge(p0, p1, bulge)` constructor
and a `sample(t)` helper. Callsites collapse to a few lines.
Net: -121 lines, one canonical sweep-direction convention shared by
all consumers.
array.rs (the path-along-curve f32 helper) keeps its inline math —
its sign convention is inverted relative to the others and changing
it without exercising the array-path command risks regressing the
output.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 23:42:26 +03:00
|
|
|
} else if let Some(arc) =
|
|
|
|
|
crate::entities::common::BulgeArc::from_bulge([ox0, oy0], [ox1, oy1], bulge)
|
|
|
|
|
{
|
|
|
|
|
let (wcx, wcy, wcz) = to_wcs(arc.center[0], arc.center[1]);
|
2026-05-12 10:36:15 +03:00
|
|
|
tgs.push(TangentGeom::Circle {
|
|
|
|
|
center: [wcx as f32, wcy as f32, wcz as f32],
|
refactor(common): unify bulge → arc math into BulgeArc
The same DXF/DWG bulge → (center, radius, sweep) formula was inlined
in six places (hatch outline, polyline tess + truck path, lwpolyline
×4, scene hatch fill, explode bulge_to_arc) — each with subtly
different sweep-direction handling for the bulge sign.
Add `entities::common::BulgeArc { center, radius, start_angle,
end_angle, sweep }` with one `from_bulge(p0, p1, bulge)` constructor
and a `sample(t)` helper. Callsites collapse to a few lines.
Net: -121 lines, one canonical sweep-direction convention shared by
all consumers.
array.rs (the path-along-curve f32 helper) keeps its inline math —
its sign convention is inverted relative to the others and changing
it without exercising the array-path command risks regressing the
output.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 23:42:26 +03:00
|
|
|
radius: arc.radius as f32,
|
2026-05-12 10:36:15 +03:00
|
|
|
});
|
2026-05-05 20:03:57 +03:00
|
|
|
for j in 1..=16usize {
|
refactor(common): unify bulge → arc math into BulgeArc
The same DXF/DWG bulge → (center, radius, sweep) formula was inlined
in six places (hatch outline, polyline tess + truck path, lwpolyline
×4, scene hatch fill, explode bulge_to_arc) — each with subtly
different sweep-direction handling for the bulge sign.
Add `entities::common::BulgeArc { center, radius, start_angle,
end_angle, sweep }` with one `from_bulge(p0, p1, bulge)` constructor
and a `sample(t)` helper. Callsites collapse to a few lines.
Net: -121 lines, one canonical sweep-direction convention shared by
all consumers.
array.rs (the path-along-curve f32 helper) keeps its inline math —
its sign convention is inverted relative to the others and changing
it without exercising the array-path command risks regressing the
output.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 23:42:26 +03:00
|
|
|
let s = arc.sample(j as f64 / 16.0);
|
|
|
|
|
let (wx, wy, wz) = to_wcs(s[0], s[1]);
|
2026-05-12 23:47:40 +03:00
|
|
|
path.push([wx, wy, wz]);
|
2026-05-05 20:03:57 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let (wbx, wby, wbz) = to_wcs(ox1, oy1);
|
2026-05-12 23:47:40 +03:00
|
|
|
kv.push([wbx, wby, wbz]);
|
2026-05-05 20:03:57 +03:00
|
|
|
}
|
2026-05-12 23:47:40 +03:00
|
|
|
let mut pts: Vec<[f64; 3]> = Vec::with_capacity(path.len() * 2 + kv.len() * 3 + 4);
|
2026-05-05 20:03:57 +03:00
|
|
|
pts.extend_from_slice(&path);
|
2026-05-12 23:47:40 +03:00
|
|
|
pts.push([f64::NAN; 3]);
|
2026-05-12 10:36:15 +03:00
|
|
|
for &p in &path {
|
|
|
|
|
pts.push(off(p));
|
|
|
|
|
}
|
2026-05-05 20:03:57 +03:00
|
|
|
if !kv.is_empty() {
|
2026-05-12 23:47:40 +03:00
|
|
|
pts.push([f64::NAN; 3]);
|
2026-05-05 20:03:57 +03:00
|
|
|
for (i, &pb) in kv.iter().enumerate() {
|
2026-05-12 10:36:15 +03:00
|
|
|
pts.push(pb);
|
|
|
|
|
pts.push(off(pb));
|
|
|
|
|
if i + 1 < kv.len() {
|
2026-05-12 23:47:40 +03:00
|
|
|
pts.push([f64::NAN; 3]);
|
2026-05-12 10:36:15 +03:00
|
|
|
}
|
2026-05-05 20:03:57 +03:00
|
|
|
}
|
|
|
|
|
}
|
2026-05-12 10:36:15 +03:00
|
|
|
return TruckEntity {
|
|
|
|
|
object: TruckObject::Lines(pts),
|
|
|
|
|
snap_pts: vec![],
|
|
|
|
|
tangent_geoms: tgs,
|
|
|
|
|
key_vertices: kv,
|
|
|
|
|
fill_tris: vec![],
|
|
|
|
|
};
|
2026-05-05 20:03:57 +03:00
|
|
|
}
|
|
|
|
|
|
2026-04-02 18:51:38 +03:00
|
|
|
for i in 0..seg_count {
|
|
|
|
|
let v0 = &verts[i];
|
|
|
|
|
let v1 = &verts[(i + 1) % count];
|
|
|
|
|
let p0 = to_pt(v0);
|
|
|
|
|
let p1 = to_pt(v1);
|
|
|
|
|
let bulge = v0.bulge;
|
|
|
|
|
|
|
|
|
|
if bulge.abs() < 1e-9 {
|
|
|
|
|
let tv0 = builder::vertex(p0);
|
|
|
|
|
let tv1 = builder::vertex(p1);
|
|
|
|
|
edges.push(builder::line(&tv0, &tv1));
|
|
|
|
|
tangents.push(TangentGeom::Line {
|
|
|
|
|
p1: [p0.x as f32, p0.y as f32, p0.z as f32],
|
|
|
|
|
p2: [p1.x as f32, p1.y as f32, p1.z as f32],
|
|
|
|
|
});
|
refactor(common): unify bulge → arc math into BulgeArc
The same DXF/DWG bulge → (center, radius, sweep) formula was inlined
in six places (hatch outline, polyline tess + truck path, lwpolyline
×4, scene hatch fill, explode bulge_to_arc) — each with subtly
different sweep-direction handling for the bulge sign.
Add `entities::common::BulgeArc { center, radius, start_angle,
end_angle, sweep }` with one `from_bulge(p0, p1, bulge)` constructor
and a `sample(t)` helper. Callsites collapse to a few lines.
Net: -121 lines, one canonical sweep-direction convention shared by
all consumers.
array.rs (the path-along-curve f32 helper) keeps its inline math —
its sign convention is inverted relative to the others and changing
it without exercising the array-path command risks regressing the
output.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 23:42:26 +03:00
|
|
|
} else if let Some(arc) = crate::entities::common::BulgeArc::from_bulge(
|
|
|
|
|
[v0.location.x, v0.location.y],
|
|
|
|
|
[v1.location.x, v1.location.y],
|
|
|
|
|
bulge,
|
|
|
|
|
) {
|
|
|
|
|
let mid_s = arc.sample(0.5);
|
|
|
|
|
let (mid_wx, mid_wy, mid_wz) = to_wcs(mid_s[0], mid_s[1]);
|
2026-05-02 20:04:30 +03:00
|
|
|
let p_mid = Point3::new(mid_wx, mid_wy, mid_wz);
|
2026-04-02 18:51:38 +03:00
|
|
|
let tv0 = builder::vertex(p0);
|
|
|
|
|
let tv1 = builder::vertex(p1);
|
|
|
|
|
edges.push(builder::circle_arc(&tv0, &tv1, p_mid));
|
refactor(common): unify bulge → arc math into BulgeArc
The same DXF/DWG bulge → (center, radius, sweep) formula was inlined
in six places (hatch outline, polyline tess + truck path, lwpolyline
×4, scene hatch fill, explode bulge_to_arc) — each with subtly
different sweep-direction handling for the bulge sign.
Add `entities::common::BulgeArc { center, radius, start_angle,
end_angle, sweep }` with one `from_bulge(p0, p1, bulge)` constructor
and a `sample(t)` helper. Callsites collapse to a few lines.
Net: -121 lines, one canonical sweep-direction convention shared by
all consumers.
array.rs (the path-along-curve f32 helper) keeps its inline math —
its sign convention is inverted relative to the others and changing
it without exercising the array-path command risks regressing the
output.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 23:42:26 +03:00
|
|
|
let (wcx, wcy, wcz) = to_wcs(arc.center[0], arc.center[1]);
|
2026-04-02 18:51:38 +03:00
|
|
|
tangents.push(TangentGeom::Circle {
|
2026-05-02 20:04:30 +03:00
|
|
|
center: [wcx as f32, wcy as f32, wcz as f32],
|
refactor(common): unify bulge → arc math into BulgeArc
The same DXF/DWG bulge → (center, radius, sweep) formula was inlined
in six places (hatch outline, polyline tess + truck path, lwpolyline
×4, scene hatch fill, explode bulge_to_arc) — each with subtly
different sweep-direction handling for the bulge sign.
Add `entities::common::BulgeArc { center, radius, start_angle,
end_angle, sweep }` with one `from_bulge(p0, p1, bulge)` constructor
and a `sample(t)` helper. Callsites collapse to a few lines.
Net: -121 lines, one canonical sweep-direction convention shared by
all consumers.
array.rs (the path-along-curve f32 helper) keeps its inline math —
its sign convention is inverted relative to the others and changing
it without exercising the array-path command risks regressing the
output.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 23:42:26 +03:00
|
|
|
radius: arc.radius as f32,
|
2026-04-02 18:51:38 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if i == 0 {
|
2026-05-12 23:47:40 +03:00
|
|
|
key_verts.push([p0.x, p0.y, p0.z]);
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
2026-05-12 23:47:40 +03:00
|
|
|
key_verts.push([p1.x, p1.y, p1.z]);
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TruckEntity {
|
|
|
|
|
object: TruckObject::Contour(edges.into_iter().collect::<Wire>()),
|
|
|
|
|
snap_pts: vec![],
|
|
|
|
|
tangent_geoms: tangents,
|
|
|
|
|
key_vertices: key_verts,
|
2026-05-06 23:24:26 +03:00
|
|
|
fill_tris: vec![],
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl TruckConvertible for Polyline2D {
|
|
|
|
|
fn to_truck(&self, _document: &acadrust::CadDocument) -> Option<TruckEntity> {
|
|
|
|
|
Some(tessellate_polyline2d(self))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Grippable for Polyline2D {
|
|
|
|
|
fn grips(&self) -> Vec<GripDef> {
|
|
|
|
|
let elev = self.elevation as f32;
|
|
|
|
|
self.vertices
|
|
|
|
|
.iter()
|
|
|
|
|
.enumerate()
|
2026-05-12 10:36:15 +03:00
|
|
|
.map(|(i, v)| square_grip(i, Vec3::new(v.location.x as f32, v.location.y as f32, elev)))
|
2026-04-02 18:51:38 +03:00
|
|
|
.collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_grip(&mut self, grip_id: usize, apply: GripApply) {
|
|
|
|
|
if let Some(v) = self.vertices.get_mut(grip_id) {
|
|
|
|
|
match apply {
|
|
|
|
|
GripApply::Translate(d) => {
|
|
|
|
|
v.location.x += d.x as f64;
|
|
|
|
|
v.location.y += d.y as f64;
|
|
|
|
|
}
|
|
|
|
|
GripApply::Absolute(p) => {
|
|
|
|
|
v.location.x = p.x as f64;
|
|
|
|
|
v.location.y = p.y as f64;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
feat(grip): popup menus for polylines, spline, mline, hatch, leaders, text
Vocabulary added: AddFitPoint, RemoveFitPoint, Refit, RefineVertices,
TangentDirection, MoveWithText, StackText, UnstackText.
Polyline/Polyline2D/Polyline3D: vertex Add/Remove. MLine: same.
Spline: CV Add/Remove plus Refine Vertices (chord-midpoint insertion,
weights kept in sync, knots cleared so to_truck rebuilds uniform vec).
Hatch: centroid Origin/Angle/Scale (Angle and Scale prompt for value).
Leader: vertex Add/Remove (arrow + centroid stay Stretch-only).
MultiLeader: vertex Add/Remove Leader; MText location Move-with-Leader /
Move-Independent (menu live, structural edits stubbed). Text/MText:
Rotate prompts for degrees and sets rotation.
Spline, Leader, MultiLeader switched from impl_entity_basics! to manual
trait impls so grip_menu can be overridden.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 15:14:43 +03:00
|
|
|
|
|
|
|
|
fn grip_menu(
|
|
|
|
|
&self,
|
|
|
|
|
_grip_id: usize,
|
|
|
|
|
) -> Vec<crate::scene::object::GripMenuItem> {
|
|
|
|
|
use crate::scene::object::{GripMenuAction, GripMenuItem};
|
|
|
|
|
vec![
|
|
|
|
|
GripMenuItem { label: "Stretch", action: GripMenuAction::Stretch },
|
|
|
|
|
GripMenuItem { label: "Add Vertex", action: GripMenuAction::AddVertex },
|
|
|
|
|
GripMenuItem { label: "Remove Vertex", action: GripMenuAction::RemoveVertex },
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_grip_menu(
|
|
|
|
|
&mut self,
|
|
|
|
|
grip_id: usize,
|
|
|
|
|
action: crate::scene::object::GripMenuAction,
|
|
|
|
|
) {
|
|
|
|
|
use crate::scene::object::GripMenuAction as A;
|
|
|
|
|
let n = self.vertices.len();
|
|
|
|
|
let elev = self.elevation;
|
|
|
|
|
match action {
|
|
|
|
|
A::AddVertex if grip_id < n => {
|
|
|
|
|
let i1 = (grip_id + 1) % n;
|
|
|
|
|
if i1 == 0 && grip_id + 1 == n {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let v0 = &self.vertices[grip_id];
|
|
|
|
|
let v1 = &self.vertices[i1];
|
|
|
|
|
let mx = (v0.location.x + v1.location.x) * 0.5;
|
|
|
|
|
let my = (v0.location.y + v1.location.y) * 0.5;
|
|
|
|
|
let mut new_v = v0.clone();
|
|
|
|
|
new_v.location.x = mx;
|
|
|
|
|
new_v.location.y = my;
|
|
|
|
|
new_v.location.z = elev;
|
|
|
|
|
let insert_at = (grip_id + 1).min(self.vertices.len());
|
|
|
|
|
self.vertices.insert(insert_at, new_v);
|
|
|
|
|
}
|
|
|
|
|
A::RemoveVertex if grip_id < n && n > 2 => {
|
|
|
|
|
self.vertices.remove(grip_id);
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PropertyEditable for Polyline2D {
|
|
|
|
|
fn geometry_properties(&self, _text_style_names: &[String]) -> PropSection {
|
feat(entities): surface remaining 2D + Region fields in properties
Closes out the 2D-entity audit (and the Region partner that ships next
to Solid3D / Body). Round-trip-only metadata fields plus a few editable
ones gain Properties-panel rows so the values the parser populates are
visible and don't get silently dropped on save:
- Hatch: seed_points count, pixel_size, normal
- Polyline2D: smooth_surface, default_start_width, default_end_width,
thickness, normal (with editors for the widths/thickness)
- Region: uid, silhouettes (shared file with Solid3D / Body)
- Underlay: clip_inverted
- RasterImage: class_version, definition_handle, definition_reactor_handle
- Wipeout: class_version, clip_mode, definition_handle,
definition_reactor_handle
- Leader: annotation_handle, override_color
- Tolerance: dimension_style_name, dimension_style_handle, dimension_gap,
text_height (editable), direction, normal
- MLine: style_handle, style_element_count, justification picker
- Ole2Frame: version, source_application, binary_data size, dwg_mode,
dwg_trailing_byte, is_paper_space
- Viewport: snap_base/spacing/angle, twist_angle, front/back clip Z,
circle_sides, grid_flags, grid_major, base_ucs_handle, ucs_ortho_type,
background_handle, shade_plot_handle, visual_style_handle,
default_lighting, default_lighting_type, ambient_color (with editors
for the snap / clip / circle_sides values)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 21:28:16 +03:00
|
|
|
let smooth = match self.smooth_surface {
|
|
|
|
|
acadrust::entities::SmoothSurfaceType::None => "None",
|
|
|
|
|
acadrust::entities::SmoothSurfaceType::QuadraticBSpline => "Quadratic",
|
|
|
|
|
acadrust::entities::SmoothSurfaceType::CubicBSpline => "Cubic",
|
|
|
|
|
acadrust::entities::SmoothSurfaceType::Bezier => "Bezier",
|
|
|
|
|
};
|
2026-04-02 18:51:38 +03:00
|
|
|
PropSection {
|
|
|
|
|
title: "Geometry".into(),
|
|
|
|
|
props: vec![
|
|
|
|
|
ro("Vertices", "vertices", self.vertices.len().to_string()),
|
|
|
|
|
edit("Elevation", "pl2_elevation", self.elevation),
|
feat(entities): surface remaining 2D + Region fields in properties
Closes out the 2D-entity audit (and the Region partner that ships next
to Solid3D / Body). Round-trip-only metadata fields plus a few editable
ones gain Properties-panel rows so the values the parser populates are
visible and don't get silently dropped on save:
- Hatch: seed_points count, pixel_size, normal
- Polyline2D: smooth_surface, default_start_width, default_end_width,
thickness, normal (with editors for the widths/thickness)
- Region: uid, silhouettes (shared file with Solid3D / Body)
- Underlay: clip_inverted
- RasterImage: class_version, definition_handle, definition_reactor_handle
- Wipeout: class_version, clip_mode, definition_handle,
definition_reactor_handle
- Leader: annotation_handle, override_color
- Tolerance: dimension_style_name, dimension_style_handle, dimension_gap,
text_height (editable), direction, normal
- MLine: style_handle, style_element_count, justification picker
- Ole2Frame: version, source_application, binary_data size, dwg_mode,
dwg_trailing_byte, is_paper_space
- Viewport: snap_base/spacing/angle, twist_angle, front/back clip Z,
circle_sides, grid_flags, grid_major, base_ucs_handle, ucs_ortho_type,
background_handle, shade_plot_handle, visual_style_handle,
default_lighting, default_lighting_type, ambient_color (with editors
for the snap / clip / circle_sides values)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 21:28:16 +03:00
|
|
|
edit("Default Start W", "pl2_start_w", self.start_width),
|
|
|
|
|
edit("Default End W", "pl2_end_w", self.end_width),
|
|
|
|
|
edit("Thickness", "pl2_thickness", self.thickness),
|
|
|
|
|
ro("Smooth Surface", "pl2_smooth", smooth),
|
|
|
|
|
ro(
|
|
|
|
|
"Normal",
|
|
|
|
|
"pl2_normal",
|
|
|
|
|
format!(
|
|
|
|
|
"{:.3}, {:.3}, {:.3}",
|
|
|
|
|
self.normal.x, self.normal.y, self.normal.z
|
|
|
|
|
),
|
|
|
|
|
),
|
2026-04-02 18:51:38 +03:00
|
|
|
Property {
|
|
|
|
|
label: "Closed".into(),
|
|
|
|
|
field: "pl2_closed",
|
|
|
|
|
value: PropValue::BoolToggle {
|
|
|
|
|
field: "pl2_closed",
|
|
|
|
|
value: self.is_closed(),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_geom_prop(&mut self, field: &str, value: &str) {
|
|
|
|
|
match field {
|
|
|
|
|
"pl2_closed" => {
|
|
|
|
|
let closed = if value == "toggle" {
|
|
|
|
|
!self.is_closed()
|
|
|
|
|
} else {
|
|
|
|
|
value == "true"
|
|
|
|
|
};
|
2026-05-12 10:36:15 +03:00
|
|
|
if closed {
|
|
|
|
|
self.close();
|
|
|
|
|
} else {
|
|
|
|
|
self.flags.set_closed(false);
|
|
|
|
|
}
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
"pl2_elevation" => {
|
|
|
|
|
if let Ok(v) = value.trim().parse::<f64>() {
|
|
|
|
|
self.elevation = v;
|
|
|
|
|
}
|
|
|
|
|
}
|
feat(entities): surface remaining 2D + Region fields in properties
Closes out the 2D-entity audit (and the Region partner that ships next
to Solid3D / Body). Round-trip-only metadata fields plus a few editable
ones gain Properties-panel rows so the values the parser populates are
visible and don't get silently dropped on save:
- Hatch: seed_points count, pixel_size, normal
- Polyline2D: smooth_surface, default_start_width, default_end_width,
thickness, normal (with editors for the widths/thickness)
- Region: uid, silhouettes (shared file with Solid3D / Body)
- Underlay: clip_inverted
- RasterImage: class_version, definition_handle, definition_reactor_handle
- Wipeout: class_version, clip_mode, definition_handle,
definition_reactor_handle
- Leader: annotation_handle, override_color
- Tolerance: dimension_style_name, dimension_style_handle, dimension_gap,
text_height (editable), direction, normal
- MLine: style_handle, style_element_count, justification picker
- Ole2Frame: version, source_application, binary_data size, dwg_mode,
dwg_trailing_byte, is_paper_space
- Viewport: snap_base/spacing/angle, twist_angle, front/back clip Z,
circle_sides, grid_flags, grid_major, base_ucs_handle, ucs_ortho_type,
background_handle, shade_plot_handle, visual_style_handle,
default_lighting, default_lighting_type, ambient_color (with editors
for the snap / clip / circle_sides values)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 21:28:16 +03:00
|
|
|
"pl2_start_w" => {
|
|
|
|
|
if let Ok(v) = value.trim().parse::<f64>() {
|
|
|
|
|
if v >= 0.0 {
|
|
|
|
|
self.start_width = v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"pl2_end_w" => {
|
|
|
|
|
if let Ok(v) = value.trim().parse::<f64>() {
|
|
|
|
|
if v >= 0.0 {
|
|
|
|
|
self.end_width = v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"pl2_thickness" => {
|
|
|
|
|
if let Ok(v) = value.trim().parse::<f64>() {
|
|
|
|
|
self.thickness = v;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-02 18:51:38 +03:00
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Transformable for Polyline2D {
|
|
|
|
|
fn apply_transform(&mut self, t: &EntityTransform) {
|
|
|
|
|
crate::scene::transform::apply_standard_entity_transform(self, t, |entity, p1, p2| {
|
|
|
|
|
for v in &mut entity.vertices {
|
|
|
|
|
crate::scene::transform::reflect_xy_point(
|
|
|
|
|
&mut v.location.x,
|
|
|
|
|
&mut v.location.y,
|
|
|
|
|
p1,
|
|
|
|
|
p2,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Polyline3D ────────────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
fn tessellate_polyline3d(pl: &Polyline3D) -> TruckEntity {
|
2026-05-12 23:47:40 +03:00
|
|
|
let to_pt = |v: &acadrust::entities::Vertex3DPolyline| -> [f64; 3] {
|
|
|
|
|
[v.position.x, v.position.y, v.position.z]
|
2026-04-26 22:12:56 +03:00
|
|
|
};
|
2026-04-02 18:51:38 +03:00
|
|
|
|
2026-04-26 22:12:56 +03:00
|
|
|
// DXF vertex flags: 8 = spline-fit curve point, 16 = spline frame control point.
|
|
|
|
|
// When spline-fit vertices are present use them for the wire and control points for snap;
|
|
|
|
|
// otherwise treat all vertices uniformly.
|
|
|
|
|
let spline_curve: Vec<_> = pl.vertices.iter().filter(|v| v.flags & 8 != 0).collect();
|
2026-05-12 10:36:15 +03:00
|
|
|
let ctrl_pts: Vec<_> = pl.vertices.iter().filter(|v| v.flags & 16 != 0).collect();
|
2026-04-26 22:12:56 +03:00
|
|
|
|
|
|
|
|
let (wire_pts, key_verts) = if !spline_curve.is_empty() {
|
2026-05-12 23:47:40 +03:00
|
|
|
let wire: Vec<[f64; 3]> = spline_curve.iter().map(|v| to_pt(v)).collect();
|
|
|
|
|
let ctrl: Vec<[f64; 3]> = ctrl_pts.iter().map(|v| to_pt(v)).collect();
|
2026-04-26 22:12:56 +03:00
|
|
|
(wire, ctrl)
|
|
|
|
|
} else {
|
2026-05-12 23:47:40 +03:00
|
|
|
let pts: Vec<[f64; 3]> = pl.vertices.iter().map(to_pt).collect();
|
2026-04-26 22:12:56 +03:00
|
|
|
(pts.clone(), pts)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let mut points = wire_pts.clone();
|
|
|
|
|
if pl.is_closed() && wire_pts.len() >= 2 {
|
|
|
|
|
points.push(wire_pts[0]);
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TruckEntity {
|
|
|
|
|
object: TruckObject::Lines(points),
|
|
|
|
|
snap_pts: vec![],
|
|
|
|
|
tangent_geoms: vec![],
|
|
|
|
|
key_vertices: key_verts,
|
2026-05-06 23:24:26 +03:00
|
|
|
fill_tris: vec![],
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl TruckConvertible for Polyline3D {
|
|
|
|
|
fn to_truck(&self, _document: &acadrust::CadDocument) -> Option<TruckEntity> {
|
|
|
|
|
Some(tessellate_polyline3d(self))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Grippable for Polyline3D {
|
|
|
|
|
fn grips(&self) -> Vec<GripDef> {
|
|
|
|
|
self.vertices
|
|
|
|
|
.iter()
|
|
|
|
|
.enumerate()
|
|
|
|
|
.map(|(i, v)| {
|
|
|
|
|
square_grip(
|
|
|
|
|
i,
|
2026-05-12 10:36:15 +03:00
|
|
|
Vec3::new(
|
|
|
|
|
v.position.x as f32,
|
|
|
|
|
v.position.y as f32,
|
|
|
|
|
v.position.z as f32,
|
|
|
|
|
),
|
2026-04-02 18:51:38 +03:00
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
.collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_grip(&mut self, grip_id: usize, apply: GripApply) {
|
|
|
|
|
if let Some(v) = self.vertices.get_mut(grip_id) {
|
|
|
|
|
match apply {
|
|
|
|
|
GripApply::Translate(d) => {
|
|
|
|
|
v.position.x += d.x as f64;
|
|
|
|
|
v.position.y += d.y as f64;
|
|
|
|
|
v.position.z += d.z as f64;
|
|
|
|
|
}
|
|
|
|
|
GripApply::Absolute(p) => {
|
|
|
|
|
v.position.x = p.x as f64;
|
|
|
|
|
v.position.y = p.y as f64;
|
|
|
|
|
v.position.z = p.z as f64;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
feat(grip): popup menus for polylines, spline, mline, hatch, leaders, text
Vocabulary added: AddFitPoint, RemoveFitPoint, Refit, RefineVertices,
TangentDirection, MoveWithText, StackText, UnstackText.
Polyline/Polyline2D/Polyline3D: vertex Add/Remove. MLine: same.
Spline: CV Add/Remove plus Refine Vertices (chord-midpoint insertion,
weights kept in sync, knots cleared so to_truck rebuilds uniform vec).
Hatch: centroid Origin/Angle/Scale (Angle and Scale prompt for value).
Leader: vertex Add/Remove (arrow + centroid stay Stretch-only).
MultiLeader: vertex Add/Remove Leader; MText location Move-with-Leader /
Move-Independent (menu live, structural edits stubbed). Text/MText:
Rotate prompts for degrees and sets rotation.
Spline, Leader, MultiLeader switched from impl_entity_basics! to manual
trait impls so grip_menu can be overridden.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 15:14:43 +03:00
|
|
|
|
|
|
|
|
fn grip_menu(
|
|
|
|
|
&self,
|
|
|
|
|
_grip_id: usize,
|
|
|
|
|
) -> Vec<crate::scene::object::GripMenuItem> {
|
|
|
|
|
use crate::scene::object::{GripMenuAction, GripMenuItem};
|
|
|
|
|
vec![
|
|
|
|
|
GripMenuItem { label: "Stretch", action: GripMenuAction::Stretch },
|
|
|
|
|
GripMenuItem { label: "Add Vertex", action: GripMenuAction::AddVertex },
|
|
|
|
|
GripMenuItem { label: "Remove Vertex", action: GripMenuAction::RemoveVertex },
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_grip_menu(
|
|
|
|
|
&mut self,
|
|
|
|
|
grip_id: usize,
|
|
|
|
|
action: crate::scene::object::GripMenuAction,
|
|
|
|
|
) {
|
|
|
|
|
use crate::scene::object::GripMenuAction as A;
|
|
|
|
|
let n = self.vertices.len();
|
|
|
|
|
match action {
|
|
|
|
|
A::AddVertex if grip_id < n => {
|
|
|
|
|
let i1 = (grip_id + 1) % n;
|
|
|
|
|
if i1 == 0 && grip_id + 1 == n {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let v0 = &self.vertices[grip_id];
|
|
|
|
|
let v1 = &self.vertices[i1];
|
|
|
|
|
let mx = (v0.position.x + v1.position.x) * 0.5;
|
|
|
|
|
let my = (v0.position.y + v1.position.y) * 0.5;
|
|
|
|
|
let mz = (v0.position.z + v1.position.z) * 0.5;
|
|
|
|
|
let mut new_v = v0.clone();
|
|
|
|
|
new_v.position.x = mx;
|
|
|
|
|
new_v.position.y = my;
|
|
|
|
|
new_v.position.z = mz;
|
|
|
|
|
let insert_at = (grip_id + 1).min(self.vertices.len());
|
|
|
|
|
self.vertices.insert(insert_at, new_v);
|
|
|
|
|
}
|
|
|
|
|
A::RemoveVertex if grip_id < n && n > 2 => {
|
|
|
|
|
self.vertices.remove(grip_id);
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PropertyEditable for Polyline3D {
|
|
|
|
|
fn geometry_properties(&self, _text_style_names: &[String]) -> PropSection {
|
feat(entities): surface remaining 3D fields + add Mesh render path
Closes out the 3D-entity audit. Mesh (modern SubD mesh) gained a full
render impl since it had no TruckConvertible / Grippable / PropertyEditable
hookup at all — it was silently dropped on open. Remaining mesh-style
entities pick up the few fields the parser populated:
- Mesh (SubD): wireframe + face-fan fill_tris rendering, per-vertex grips,
Properties panel surfaces version, subdivision_level, blend_crease,
creased-edge count, vertex / face / edge counts; wired into the
Transformable / Grippable / PropertyEditable / TruckConvertible
dispatch in entities/traits.rs
- Polyline3D: smooth_type, default_start_width, default_end_width,
mesh_m_count, mesh_n_count, smooth_m_density, smooth_n_density
(widths editable)
- PolygonMesh: smooth_type, m/n_smooth_density, elevation, normal
- PolyfaceMesh: smooth_surface, seqend_handle, elevation, normal,
thickness
Solid3D / Region / Body's uid + silhouettes + history_handle were
included in the prior 2D commit since they share the same file.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 21:35:14 +03:00
|
|
|
use acadrust::entities::polyline3d::SmoothSurfaceType as SST;
|
|
|
|
|
let smooth = match self.smooth_type {
|
|
|
|
|
SST::None => "None",
|
|
|
|
|
SST::QuadraticBSpline => "Quadratic",
|
|
|
|
|
SST::CubicBSpline => "Cubic",
|
|
|
|
|
SST::Bezier => "Bezier",
|
|
|
|
|
};
|
2026-04-02 18:51:38 +03:00
|
|
|
PropSection {
|
|
|
|
|
title: "Geometry".into(),
|
|
|
|
|
props: vec![
|
|
|
|
|
ro("Vertices", "vertices", self.vertices.len().to_string()),
|
feat(entities): surface remaining 3D fields + add Mesh render path
Closes out the 3D-entity audit. Mesh (modern SubD mesh) gained a full
render impl since it had no TruckConvertible / Grippable / PropertyEditable
hookup at all — it was silently dropped on open. Remaining mesh-style
entities pick up the few fields the parser populated:
- Mesh (SubD): wireframe + face-fan fill_tris rendering, per-vertex grips,
Properties panel surfaces version, subdivision_level, blend_crease,
creased-edge count, vertex / face / edge counts; wired into the
Transformable / Grippable / PropertyEditable / TruckConvertible
dispatch in entities/traits.rs
- Polyline3D: smooth_type, default_start_width, default_end_width,
mesh_m_count, mesh_n_count, smooth_m_density, smooth_n_density
(widths editable)
- PolygonMesh: smooth_type, m/n_smooth_density, elevation, normal
- PolyfaceMesh: smooth_surface, seqend_handle, elevation, normal,
thickness
Solid3D / Region / Body's uid + silhouettes + history_handle were
included in the prior 2D commit since they share the same file.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 21:35:14 +03:00
|
|
|
edit("Default Start W", "pl3_start_w", self.default_start_width),
|
|
|
|
|
edit("Default End W", "pl3_end_w", self.default_end_width),
|
|
|
|
|
ro("Smooth", "pl3_smooth", smooth),
|
|
|
|
|
ro("Mesh M", "pl3_mesh_m", self.mesh_m_count.to_string()),
|
|
|
|
|
ro("Mesh N", "pl3_mesh_n", self.mesh_n_count.to_string()),
|
|
|
|
|
ro(
|
|
|
|
|
"Smooth M Density",
|
|
|
|
|
"pl3_smooth_m",
|
|
|
|
|
self.smooth_m_density.to_string(),
|
|
|
|
|
),
|
|
|
|
|
ro(
|
|
|
|
|
"Smooth N Density",
|
|
|
|
|
"pl3_smooth_n",
|
|
|
|
|
self.smooth_n_density.to_string(),
|
|
|
|
|
),
|
2026-04-02 18:51:38 +03:00
|
|
|
Property {
|
|
|
|
|
label: "Closed".into(),
|
|
|
|
|
field: "pl3_closed",
|
|
|
|
|
value: PropValue::BoolToggle {
|
|
|
|
|
field: "pl3_closed",
|
|
|
|
|
value: self.is_closed(),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_geom_prop(&mut self, field: &str, value: &str) {
|
|
|
|
|
if field == "pl3_closed" {
|
2026-05-12 10:36:15 +03:00
|
|
|
let closed = if value == "toggle" {
|
|
|
|
|
!self.is_closed()
|
|
|
|
|
} else {
|
|
|
|
|
value == "true"
|
|
|
|
|
};
|
|
|
|
|
if closed {
|
|
|
|
|
self.close();
|
|
|
|
|
} else {
|
|
|
|
|
self.open();
|
|
|
|
|
}
|
feat(entities): surface remaining 3D fields + add Mesh render path
Closes out the 3D-entity audit. Mesh (modern SubD mesh) gained a full
render impl since it had no TruckConvertible / Grippable / PropertyEditable
hookup at all — it was silently dropped on open. Remaining mesh-style
entities pick up the few fields the parser populated:
- Mesh (SubD): wireframe + face-fan fill_tris rendering, per-vertex grips,
Properties panel surfaces version, subdivision_level, blend_crease,
creased-edge count, vertex / face / edge counts; wired into the
Transformable / Grippable / PropertyEditable / TruckConvertible
dispatch in entities/traits.rs
- Polyline3D: smooth_type, default_start_width, default_end_width,
mesh_m_count, mesh_n_count, smooth_m_density, smooth_n_density
(widths editable)
- PolygonMesh: smooth_type, m/n_smooth_density, elevation, normal
- PolyfaceMesh: smooth_surface, seqend_handle, elevation, normal,
thickness
Solid3D / Region / Body's uid + silhouettes + history_handle were
included in the prior 2D commit since they share the same file.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 21:35:14 +03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if let Ok(v) = value.trim().parse::<f64>() {
|
|
|
|
|
match field {
|
|
|
|
|
"pl3_start_w" if v >= 0.0 => self.default_start_width = v,
|
|
|
|
|
"pl3_end_w" if v >= 0.0 => self.default_end_width = v,
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
2026-04-02 18:51:38 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Transformable for Polyline3D {
|
|
|
|
|
fn apply_transform(&mut self, t: &EntityTransform) {
|
|
|
|
|
crate::scene::transform::apply_standard_entity_transform(self, t, |entity, p1, p2| {
|
|
|
|
|
for v in &mut entity.vertices {
|
|
|
|
|
crate::scene::transform::reflect_xy_point(
|
|
|
|
|
&mut v.position.x,
|
|
|
|
|
&mut v.position.y,
|
|
|
|
|
p1,
|
|
|
|
|
p2,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-23 23:26:14 +03:00
|
|
|
/// Generate solid-fill boundary polygons for each wide segment of a Polyline2D.
|
|
|
|
|
pub(crate) fn wide_fills(pl: &acadrust::entities::Polyline2D) -> Vec<Vec<[f32; 2]>> {
|
|
|
|
|
let hw_default = (pl.start_width.max(pl.end_width) / 2.0) as f32;
|
|
|
|
|
let verts = &pl.vertices;
|
|
|
|
|
let n = verts.len();
|
|
|
|
|
if n < 2 {
|
|
|
|
|
return vec![];
|
|
|
|
|
}
|
|
|
|
|
let seg_count = if pl.is_closed() { n } else { n - 1 };
|
|
|
|
|
let mut out = Vec::new();
|
|
|
|
|
for i in 0..seg_count {
|
|
|
|
|
let v0 = &verts[i];
|
|
|
|
|
let v1 = &verts[(i + 1) % n];
|
|
|
|
|
let hw0 = if v0.start_width > 1e-9 {
|
|
|
|
|
v0.start_width as f32 / 2.0
|
|
|
|
|
} else {
|
|
|
|
|
hw_default
|
|
|
|
|
};
|
|
|
|
|
let hw1 = if v0.end_width > 1e-9 {
|
|
|
|
|
v0.end_width as f32 / 2.0
|
|
|
|
|
} else {
|
|
|
|
|
hw_default
|
|
|
|
|
};
|
|
|
|
|
if hw0 < 1e-6 && hw1 < 1e-6 {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
let p0 = [v0.location.x as f32, v0.location.y as f32];
|
|
|
|
|
let p1 = [v1.location.x as f32, v1.location.y as f32];
|
|
|
|
|
if let Some(poly) = crate::entities::common::polyline_segment_fill(p0, p1, hw0, hw1, v0.bulge as f32) {
|
|
|
|
|
out.push(poly);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
out
|
|
|
|
|
}
|