From 3fe634956355e4078fd0ee43542444f0b4222212 Mon Sep 17 00:00:00 2001 From: phkahler <14852918+phkahler@users.noreply.github.com> Date: Sat, 11 Jun 2022 20:20:04 -0400 Subject: [PATCH] Add faces perpendicular and parallel constraints. --- src/constraint.cpp | 14 ++++++++++++-- src/entity.cpp | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/constraint.cpp b/src/constraint.cpp index 6a25c265..fbea9e27 100644 --- a/src/constraint.cpp +++ b/src/constraint.cpp @@ -721,7 +721,11 @@ void Constraint::MenuConstrain(Command id) { } case Command::PARALLEL: - if(gs.vectors == 2 && gs.n == 2) { + if(gs.faces == 2 && gs.n == 2) { + c.type = Type::PARALLEL; + c.entityA = gs.face[0]; + c.entityB = gs.face[1]; + } else if(gs.vectors == 2 && gs.n == 2) { c.type = Type::PARALLEL; c.entityA = gs.vector[0]; c.entityB = gs.vector[1]; @@ -765,6 +769,7 @@ void Constraint::MenuConstrain(Command id) { } else { Error(_("Bad selection for parallel / tangent constraint. This " "constraint can apply to:\n\n" + " * two faces\n" " * two line segments (parallel)\n" " * a line segment and a normal (parallel)\n" " * two normals (parallel)\n" @@ -776,13 +781,18 @@ void Constraint::MenuConstrain(Command id) { break; case Command::PERPENDICULAR: - if(gs.vectors == 2 && gs.n == 2) { + if(gs.faces == 2 && gs.n == 2) { + c.type = Type::PERPENDICULAR; + c.entityA = gs.face[0]; + c.entityB = gs.face[1]; + } else if(gs.vectors == 2 && gs.n == 2) { c.type = Type::PERPENDICULAR; c.entityA = gs.vector[0]; c.entityB = gs.vector[1]; } else { Error(_("Bad selection for perpendicular constraint. This " "constraint can apply to:\n\n" + " * two faces\n" " * two line segments\n" " * a line segment and a normal\n" " * two normals\n")); diff --git a/src/entity.cpp b/src/entity.cpp index a0f2f946..dd42cba6 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -26,6 +26,9 @@ bool EntityBase::HasVector() const { } ExprVector EntityBase::VectorGetExprsInWorkplane(hEntity wrkpl) const { + if(IsFace()) { + return FaceGetNormalExprs(); + } switch(type) { case Type::LINE_SEGMENT: return (SK.GetEntity(point[0])->PointGetExprsInWorkplane(wrkpl)).Minus( @@ -62,6 +65,9 @@ ExprVector EntityBase::VectorGetExprs() const { } Vector EntityBase::VectorGetNum() const { + if(IsFace()) { + return FaceGetNormalNum(); + } switch(type) { case Type::LINE_SEGMENT: return (SK.GetEntity(point[0])->PointGetNum()).Minus( @@ -79,6 +85,9 @@ Vector EntityBase::VectorGetNum() const { } Vector EntityBase::VectorGetRefPoint() const { + if(IsFace()) { + return FaceGetPointNum(); + } switch(type) { case Type::LINE_SEGMENT: return ((SK.GetEntity(point[0])->PointGetNum()).Plus(