Allow Revolve and Helix end surface selection and constraints. (#584)
parent
45eb246865
commit
700b5d6719
|
@ -561,12 +561,18 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
|
||||||
AddParam(param, h.param(5), axis_dir.y);
|
AddParam(param, h.param(5), axis_dir.y);
|
||||||
AddParam(param, h.param(6), axis_dir.z);
|
AddParam(param, h.param(6), axis_dir.z);
|
||||||
|
|
||||||
|
// Get some arbitrary point in the sketch, that will be used
|
||||||
|
// as a reference when defining end faces.
|
||||||
|
hEntity pt = { 0 };
|
||||||
|
|
||||||
// Not using range-for here because we're changing the size of entity in the loop.
|
// Not using range-for here because we're changing the size of entity in the loop.
|
||||||
for(i = 0; i < entity->n; i++) {
|
for(i = 0; i < entity->n; i++) {
|
||||||
Entity *e = &(entity->Get(i));
|
Entity *e = &(entity->Get(i));
|
||||||
if(e->group != opA)
|
if(e->group != opA)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(e->IsPoint()) pt = e->h;
|
||||||
|
|
||||||
e->CalculateNumerical(/*forExport=*/false);
|
e->CalculateNumerical(/*forExport=*/false);
|
||||||
hEntity he = e->h;
|
hEntity he = e->h;
|
||||||
// one copy for each end of the revolved surface
|
// one copy for each end of the revolved surface
|
||||||
|
@ -587,7 +593,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
|
||||||
// MakeLatheCircles(entity, param, he, axis_pos, axis_dir);
|
// MakeLatheCircles(entity, param, he, axis_pos, axis_dir);
|
||||||
MakeLatheSurfacesSelectable(entity, he, axis_dir);
|
MakeLatheSurfacesSelectable(entity, he, axis_dir);
|
||||||
}
|
}
|
||||||
|
MakeRevolveEndFaces(entity, pt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,12 +613,18 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
|
||||||
// distance to translate along the rotation axis
|
// distance to translate along the rotation axis
|
||||||
AddParam(param, h.param(7), 20);
|
AddParam(param, h.param(7), 20);
|
||||||
|
|
||||||
|
// Get some arbitrary point in the sketch, that will be used
|
||||||
|
// as a reference when defining end faces.
|
||||||
|
hEntity pt = { 0 };
|
||||||
|
|
||||||
// Not using range-for here because we're changing the size of entity in the loop.
|
// Not using range-for here because we're changing the size of entity in the loop.
|
||||||
for(i = 0; i < entity->n; i++) {
|
for(i = 0; i < entity->n; i++) {
|
||||||
Entity *e = &(entity->Get(i));
|
Entity *e = &(entity->Get(i));
|
||||||
if((e->group.v != opA.v) && !(e->h == predef.origin))
|
if((e->group.v != opA.v) && !(e->h == predef.origin))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(e->IsPoint()) pt = e->h;
|
||||||
|
|
||||||
e->CalculateNumerical(/*forExport=*/false);
|
e->CalculateNumerical(/*forExport=*/false);
|
||||||
|
|
||||||
// one copy for each end of the helix
|
// one copy for each end of the helix
|
||||||
|
@ -644,6 +656,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MakeRevolveEndFaces(entity, pt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,6 +940,32 @@ void Group::MakeLatheSurfacesSelectable(IdList<Entity, hEntity> *el, hEntity in,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Group::MakeRevolveEndFaces(IdList<Entity,hEntity> *el, hEntity pt)
|
||||||
|
{
|
||||||
|
if(pt.v == 0) return;
|
||||||
|
Group *src = SK.GetGroup(opA);
|
||||||
|
Vector n = src->polyLoops.normal;
|
||||||
|
|
||||||
|
// When there is no loop normal (e.g. if the loop is broken), use normal of workplane
|
||||||
|
// as fallback, to avoid breaking constraints depending on the faces.
|
||||||
|
if(n.Equals(Vector::From(0.0, 0.0, 0.0)) && src->type == Group::Type::DRAWING_WORKPLANE) {
|
||||||
|
n = SK.GetEntity(src->h.entity(0))->Normal()->NormalN();
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity en = {};
|
||||||
|
en.type = Entity::Type::FACE_NORMAL_PT;
|
||||||
|
en.group = h;
|
||||||
|
|
||||||
|
en.numNormal = Quaternion::From(0, n.x, n.y, n.z);
|
||||||
|
en.point[0] = Remap(pt, REMAP_LATHE_END);
|
||||||
|
en.h = Remap(Entity::NO_ENTITY, REMAP_LATHE_END);
|
||||||
|
el->Add(&en);
|
||||||
|
|
||||||
|
en.point[0] = Remap(pt, REMAP_LATHE_START);
|
||||||
|
en.h = Remap(Entity::NO_ENTITY, REMAP_LATHE_START);
|
||||||
|
el->Add(&en);
|
||||||
|
}
|
||||||
|
|
||||||
void Group::MakeExtrusionTopBottomFaces(IdList<Entity,hEntity> *el, hEntity pt)
|
void Group::MakeExtrusionTopBottomFaces(IdList<Entity,hEntity> *el, hEntity pt)
|
||||||
{
|
{
|
||||||
if(pt.v == 0) return;
|
if(pt.v == 0) return;
|
||||||
|
|
|
@ -285,6 +285,7 @@ public:
|
||||||
void MakeExtrusionLines(EntityList *el, hEntity in);
|
void MakeExtrusionLines(EntityList *el, hEntity in);
|
||||||
void MakeLatheCircles(IdList<Entity,hEntity> *el, IdList<Param,hParam> *param, hEntity in, Vector pt, Vector axis);
|
void MakeLatheCircles(IdList<Entity,hEntity> *el, IdList<Param,hParam> *param, hEntity in, Vector pt, Vector axis);
|
||||||
void MakeLatheSurfacesSelectable(IdList<Entity, hEntity> *el, hEntity in, Vector axis);
|
void MakeLatheSurfacesSelectable(IdList<Entity, hEntity> *el, hEntity in, Vector axis);
|
||||||
|
void MakeRevolveEndFaces(IdList<Entity,hEntity> *el, hEntity pt);
|
||||||
void MakeExtrusionTopBottomFaces(EntityList *el, hEntity pt);
|
void MakeExtrusionTopBottomFaces(EntityList *el, hEntity pt);
|
||||||
void CopyEntity(EntityList *el,
|
void CopyEntity(EntityList *el,
|
||||||
Entity *ep, int timesApplied, int remap,
|
Entity *ep, int timesApplied, int remap,
|
||||||
|
|
|
@ -674,14 +674,23 @@ void SShell::MakeFromHelicalRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector
|
||||||
// So we can now generate the end caps of the extrusion within
|
// So we can now generate the end caps of the extrusion within
|
||||||
// a translated and rotated (and maybe mirrored) version of that csys.
|
// a translated and rotated (and maybe mirrored) version of that csys.
|
||||||
SSurface s0, s1;
|
SSurface s0, s1;
|
||||||
s0 = SSurface::FromPlane(orig.RotatedAbout(pt, axis, angles).Plus(axis.ScaledBy(dists)),
|
s0 = SSurface::FromPlane(orig.RotatedAbout(pt, axis, angles).Plus(axis.ScaledBy(dists)),
|
||||||
u.RotatedAbout(axis, angles), v.RotatedAbout(axis, angles));
|
u.RotatedAbout(axis, angles), v.RotatedAbout(axis, angles));
|
||||||
s0.color = color;
|
s0.color = color;
|
||||||
s1 = SSurface::FromPlane(
|
|
||||||
|
hEntity face0 = group->Remap(Entity::NO_ENTITY, Group::REMAP_LATHE_END);
|
||||||
|
s0.face = face0.v;
|
||||||
|
|
||||||
|
s1 = SSurface::FromPlane(
|
||||||
orig.Plus(u).RotatedAbout(pt, axis, anglef).Plus(axis.ScaledBy(distf)),
|
orig.Plus(u).RotatedAbout(pt, axis, anglef).Plus(axis.ScaledBy(distf)),
|
||||||
u.ScaledBy(-1).RotatedAbout(axis, anglef), v.RotatedAbout(axis, anglef));
|
u.ScaledBy(-1).RotatedAbout(axis, anglef), v.RotatedAbout(axis, anglef));
|
||||||
s1.color = color;
|
s1.color = color;
|
||||||
hSSurface hs0 = surface.AddAndAssignId(&s0), hs1 = surface.AddAndAssignId(&s1);
|
|
||||||
|
hEntity face1 = group->Remap(Entity::NO_ENTITY, Group::REMAP_LATHE_START);
|
||||||
|
s1.face = face1.v;
|
||||||
|
|
||||||
|
hSSurface hs0 = surface.AddAndAssignId(&s0);
|
||||||
|
hSSurface hs1 = surface.AddAndAssignId(&s1);
|
||||||
|
|
||||||
// Now we actually build and trim the swept surfaces. One loop at a time.
|
// Now we actually build and trim the swept surfaces. One loop at a time.
|
||||||
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
|
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
|
||||||
|
|
Loading…
Reference in New Issue