Fix "Sketch in New Workplane" point & normal to set correct orientation of workplane

Temporary disable other ways because of wrong implementation
This commit is contained in:
Maxipaille 2021-06-07 15:59:19 +02:00 committed by phkahler
parent 3ccf7845f5
commit 4308dc136b
2 changed files with 14 additions and 12 deletions

View File

@ -139,15 +139,13 @@ void Group::MenuGroup(Command id, Platform::Path linkFile) {
} else ssassert(false, "Unexpected workplane subtype"); } else ssassert(false, "Unexpected workplane subtype");
} }
} else if(gs.anyNormals == 1 && gs.points == 1 && gs.n == 2) { } else if(gs.anyNormals == 1 && gs.points == 1 && gs.n == 2) {
g.subtype = Subtype::WORKPLANE_BY_POINT_ORTHO; g.subtype = Subtype::WORKPLANE_BY_POINT_NORMAL;
Vector direction = SK.GetEntity(gs.anyNormal[0])->VectorGetNum(); g.predef.q = SK.GetEntity(gs.anyNormal[0])->NormalGetNum();
g.predef.q = Quaternion::From(direction, 0);
g.predef.origin = gs.point[0];
} else if(gs.faces == 1 && gs.points == 1 && gs.n == 2) {
g.subtype = Subtype::WORKPLANE_BY_POINT_ORTHO;
Vector direction = SK.GetEntity(gs.face[0])->FaceGetNormalNum();
g.predef.q = Quaternion::From(direction, 0);
g.predef.origin = gs.point[0]; g.predef.origin = gs.point[0];
//} else if(gs.faces == 1 && gs.points == 1 && gs.n == 2) {
// g.subtype = Subtype::WORKPLANE_BY_POINT_FACE;
// g.predef.q = SK.GetEntity(gs.face[0])->NormalGetNum();
// g.predef.origin = gs.point[0];
} else { } else {
Error(_("Bad selection for new sketch in workplane. This " Error(_("Bad selection for new sketch in workplane. This "
"group can be created with:\n\n" "group can be created with:\n\n"
@ -156,8 +154,8 @@ void Group::MenuGroup(Command id, Platform::Path linkFile) {
"parallel to the lines)\n" "parallel to the lines)\n"
" * a point and a normal (through the point, " " * a point and a normal (through the point, "
"orthogonal to the normal)\n" "orthogonal to the normal)\n"
" * a point and a face (through the point, " /*" * a point and a face (through the point, "
"parallel to the face)\n" "parallel to the face)\n"*/
" * a workplane (copy of the workplane)\n")); " * a workplane (copy of the workplane)\n"));
return; return;
} }
@ -454,7 +452,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
if(predef.negateU) u = u.ScaledBy(-1); if(predef.negateU) u = u.ScaledBy(-1);
if(predef.negateV) v = v.ScaledBy(-1); if(predef.negateV) v = v.ScaledBy(-1);
q = Quaternion::From(u, v); q = Quaternion::From(u, v);
} else if(subtype == Subtype::WORKPLANE_BY_POINT_ORTHO) { } else if(subtype == Subtype::WORKPLANE_BY_POINT_ORTHO || subtype == Subtype::WORKPLANE_BY_POINT_NORMAL /*|| subtype == Subtype::WORKPLANE_BY_POINT_FACE*/) {
// Already given, numerically. // Already given, numerically.
q = predef.q; q = predef.q;
} else ssassert(false, "Unexpected workplane subtype"); } else ssassert(false, "Unexpected workplane subtype");
@ -462,6 +460,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
Entity normal = {}; Entity normal = {};
normal.type = Entity::Type::NORMAL_N_COPY; normal.type = Entity::Type::NORMAL_N_COPY;
normal.numNormal = q; normal.numNormal = q;
normal.point[0] = h.entity(2); normal.point[0] = h.entity(2);
normal.group = h; normal.group = h;
normal.h = h.entity(1); normal.h = h.entity(1);

View File

@ -198,6 +198,9 @@ public:
// For drawings in 2d // For drawings in 2d
WORKPLANE_BY_POINT_ORTHO = 6000, WORKPLANE_BY_POINT_ORTHO = 6000,
WORKPLANE_BY_LINE_SEGMENTS = 6001, WORKPLANE_BY_LINE_SEGMENTS = 6001,
WORKPLANE_BY_POINT_NORMAL = 6002,
//WORKPLANE_BY_POINT_FACE = 6003,
//WORKPLANE_BY_FACE = 6004,
// For extrudes, translates, and rotates // For extrudes, translates, and rotates
ONE_SIDED = 7000, ONE_SIDED = 7000,
TWO_SIDED = 7001 TWO_SIDED = 7001