From 6bc2ed977160acc8915c7aa0e0700fa3ac65a0c4 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Tue, 14 Feb 2017 00:03:06 +0700 Subject: [PATCH] Remove nonexistent degrees of freedom from lathe groups. Before this commit, lathe groups had three DOFs, which of course could not actually move. After this commit, lathe groups have zero DOFs, as expected. This bug was introduced in commit 6dced80. --- src/group.cpp | 44 ++++++++++++++++++++++---------------------- src/sketch.h | 9 ++++++++- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/group.cpp b/src/group.cpp index c3da08a..70b6af1 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -438,11 +438,11 @@ void Group::Generate(IdList *entity, CopyEntity(entity, SK.GetEntity(he), ai, REMAP_BOTTOM, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - /*asTrans=*/true, /*asAxisAngle=*/false); + CopyAs::N_TRANS); CopyEntity(entity, SK.GetEntity(he), af, REMAP_TOP, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - /*asTrans=*/true, /*asAxisAngle=*/false); + CopyAs::N_TRANS); MakeExtrusionLines(entity, he); } // Remapped versions of that arbitrary point will be used to @@ -455,10 +455,6 @@ void Group::Generate(IdList *entity, Vector axis_pos = SK.GetEntity(predef.origin)->PointGetNum(); Vector axis_dir = SK.GetEntity(predef.entityB)->VectorGetNum(); - AddParam(param, h.param(0), axis_dir.x); - AddParam(param, h.param(1), axis_dir.y); - AddParam(param, h.param(2), axis_dir.z); - // Remapped entity index. int ai = 1; @@ -472,19 +468,19 @@ void Group::Generate(IdList *entity, // As soon as I call CopyEntity, e may become invalid! That // adds entities, which may cause a realloc. CopyEntity(entity, SK.GetEntity(predef.origin), 0, ai, - h.param(0), h.param(1), h.param(2), + NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - /*asTrans=*/true, /*asAxisAngle=*/false); + CopyAs::NUMERIC); CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_START, - h.param(0), h.param(1), h.param(2), + NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - /*asTrans=*/true, /*asAxisAngle=*/false); + CopyAs::NUMERIC); CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_END, - h.param(0), h.param(1), h.param(2), + NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - /*asTrans=*/true, /*asAxisAngle=*/false); + CopyAs::NUMERIC); MakeLatheCircles(entity, param, he, axis_pos, axis_dir, ai); ai++; @@ -517,7 +513,7 @@ void Group::Generate(IdList *entity, (a == (n - 1)) ? REMAP_LAST : a, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - /*asTrans=*/true, /*asAxisAngle=*/false); + CopyAs::N_TRANS); } } return; @@ -552,7 +548,7 @@ void Group::Generate(IdList *entity, (a == (n - 1)) ? REMAP_LAST : a, h.param(0), h.param(1), h.param(2), h.param(3), h.param(4), h.param(5), h.param(6), - /*asTrans=*/false, /*asAxisAngle=*/true); + CopyAs::N_ROT_AA); } } return; @@ -573,7 +569,7 @@ void Group::Generate(IdList *entity, CopyEntity(entity, ie, 0, 0, h.param(0), h.param(1), h.param(2), h.param(3), h.param(4), h.param(5), h.param(6), - /*asTrans=*/false, /*asAxisAngle=*/false); + CopyAs::N_ROT_TRANS); } return; } @@ -804,7 +800,7 @@ void Group::CopyEntity(IdList *el, Entity *ep, int timesApplied, int remap, hParam dx, hParam dy, hParam dz, hParam qw, hParam qvx, hParam qvy, hParam qvz, - bool asTrans, bool asAxisAngle) + CopyAs as) { Entity en = {}; en.type = ep->type; @@ -828,13 +824,15 @@ void Group::CopyEntity(IdList *el, case Entity::Type::POINT_N_ROT_AA: case Entity::Type::POINT_IN_3D: case Entity::Type::POINT_IN_2D: - if(asTrans) { + if(as == CopyAs::N_TRANS) { en.type = Entity::Type::POINT_N_TRANS; en.param[0] = dx; en.param[1] = dy; en.param[2] = dz; + } else if(as == CopyAs::NUMERIC) { + en.type = Entity::Type::POINT_N_COPY; } else { - if(asAxisAngle) { + if(as == CopyAs::N_ROT_AA) { en.type = Entity::Type::POINT_N_ROT_AA; } else { en.type = Entity::Type::POINT_N_ROT_TRANS; @@ -855,10 +853,10 @@ void Group::CopyEntity(IdList *el, case Entity::Type::NORMAL_N_ROT_AA: case Entity::Type::NORMAL_IN_3D: case Entity::Type::NORMAL_IN_2D: - if(asTrans) { + if(as == CopyAs::N_TRANS || as == CopyAs::NUMERIC) { en.type = Entity::Type::NORMAL_N_COPY; } else { - if(asAxisAngle) { + if(as == CopyAs::N_ROT_AA) { en.type = Entity::Type::NORMAL_N_ROT_AA; } else { en.type = Entity::Type::NORMAL_N_ROT; @@ -885,13 +883,15 @@ void Group::CopyEntity(IdList *el, case Entity::Type::FACE_N_ROT_TRANS: case Entity::Type::FACE_N_TRANS: case Entity::Type::FACE_N_ROT_AA: - if(asTrans) { + if(as == CopyAs::N_TRANS) { en.type = Entity::Type::FACE_N_TRANS; en.param[0] = dx; en.param[1] = dy; en.param[2] = dz; + } else if (as == CopyAs::NUMERIC) { + en.type = Entity::Type::FACE_NORMAL_PT; } else { - if(asAxisAngle) { + if(as == CopyAs::N_ROT_AA) { en.type = Entity::Type::FACE_N_ROT_AA; } else { en.type = Entity::Type::FACE_N_ROT_TRANS; diff --git a/src/sketch.h b/src/sketch.h index 4c85089..492da2e 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -118,6 +118,13 @@ public: int tag; hGroup h; + enum class CopyAs { + NUMERIC, + N_TRANS, + N_ROT_AA, + N_ROT_TRANS, + }; + enum class Type : uint32_t { DRAWING_3D = 5000, DRAWING_WORKPLANE = 5001, @@ -251,7 +258,7 @@ public: Entity *ep, int timesApplied, int remap, hParam dx, hParam dy, hParam dz, hParam qw, hParam qvx, hParam qvy, hParam qvz, - bool asTrans, bool asAxisAngle); + CopyAs as); void AddEq(IdList *l, Expr *expr, int index); void GenerateEquations(IdList *l);