forked from 1b-agent/opencadstudio-upstream
fix(trim): honor preselected cutting boundaries
This commit is contained in:
1 parent
5ed508ce76
commit
2885898da6
2 files changed
+44
-7
No files matched your search
+11
-1
@@ -1238,8 +1238,18 @@ impl OpenCADStudio {
|
|||||||
.map(|e| (h, e))
|
.map(|e| (h, e))
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
let initial_edges: Vec<acadrust::Handle> = self.tabs[i]
|
||||||
|
.scene
|
||||||
|
.selected_entities()
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|(handle, entity)| {
|
||||||
|
crate::modules::draw::modify::trim::is_trim_boundary_entity(&entity)
|
||||||
|
.then_some(handle)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
let all_entities: Vec<_> = entities.into_iter().map(|(_, e)| e).collect();
|
let all_entities: Vec<_> = entities.into_iter().map(|(_, e)| e).collect();
|
||||||
let new_cmd = TrimCommand::new(all_entities);
|
let new_cmd =
|
||||||
|
TrimCommand::with_cutting_edges(all_entities, initial_edges);
|
||||||
self.command_line.push_info(&new_cmd.prompt());
|
self.command_line.push_info(&new_cmd.prompt());
|
||||||
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
|
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,22 @@ impl Geo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn is_trim_boundary_entity(entity: &EntityType) -> bool {
|
||||||
|
matches!(
|
||||||
|
entity,
|
||||||
|
EntityType::Line(_)
|
||||||
|
| EntityType::Arc(_)
|
||||||
|
| EntityType::Circle(_)
|
||||||
|
| EntityType::Ellipse(_)
|
||||||
|
| EntityType::Ray(_)
|
||||||
|
| EntityType::XLine(_)
|
||||||
|
| EntityType::Spline(_)
|
||||||
|
| EntityType::LwPolyline(_)
|
||||||
|
| EntityType::Polyline(_)
|
||||||
|
| EntityType::Polyline2D(_)
|
||||||
|
| EntityType::Polyline3D(_)
|
||||||
|
)
|
||||||
|
}
|
||||||
fn build_geos(entities: &[EntityType]) -> Vec<Geo> {
|
fn build_geos(entities: &[EntityType]) -> Vec<Geo> {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
for e in entities {
|
for e in entities {
|
||||||
@@ -2169,21 +2184,33 @@ pub struct TrimCommand {
|
|||||||
|
|
||||||
impl TrimCommand {
|
impl TrimCommand {
|
||||||
pub fn new(all_entities: Vec<EntityType>) -> Self {
|
pub fn new(all_entities: Vec<EntityType>) -> Self {
|
||||||
|
Self::with_cutting_edges(all_entities, Vec::new())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_cutting_edges(
|
||||||
|
all_entities: Vec<EntityType>,
|
||||||
|
initial_edges: Vec<Handle>,
|
||||||
|
) -> Self {
|
||||||
let all_entities: Vec<EntityType> = all_entities
|
let all_entities: Vec<EntityType> = all_entities
|
||||||
.iter()
|
.iter()
|
||||||
.map(entity_with_lwpolyline_world_xy)
|
.map(entity_with_lwpolyline_world_xy)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let entity_index = ModifyEntityIndex::build(&all_entities);
|
let entity_index = ModifyEntityIndex::build(&all_entities);
|
||||||
let geos = build_geos(&all_entities);
|
|
||||||
Self {
|
let mut cmd = Self {
|
||||||
all_entities,
|
all_entities,
|
||||||
entity_index,
|
entity_index,
|
||||||
geos,
|
geos: Vec::new(),
|
||||||
mode: TrimMode::Pick,
|
mode: TrimMode::Pick,
|
||||||
edge_set: Vec::new(),
|
edge_set: initial_edges,
|
||||||
implied_edges: false,
|
implied_edges: false,
|
||||||
shift: false,
|
shift: false,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
cmd.rebuild_geos();
|
||||||
|
|
||||||
|
cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Boundary geometry from the edge selection (or everything when none),
|
/// Boundary geometry from the edge selection (or everything when none),
|
||||||
|
|||||||
Reference in new issue
Block a user