Improve handling of corner cases related to assembled loop normals.

Extrustion top and bottom faces require a normal to be present.

Before this commit, the normal is always taken from the assembled
loop; if the loop could not be assembled (i.e. the loop is broken
or not coplanar) the normal will be (0,0,0), which breaks the sketch.
Also, loops are not generated when generating the sketch
to determine its bounding box.

This may result in spuriously broken sketches when e.g. undoing
a change that has broken a loop.

After this commit, loops are generated when generating for bounding
box, and if the loop could not be assembled, then the workplane
normal is used. This still results in failures when there is
no workplane, but those cases should be quite pathological.
pull/216/head
EvilSpirit 2017-02-15 10:43:57 +07:00 committed by whitequark
parent dea573e156
commit 91574254fe
2 changed files with 7 additions and 1 deletions

View File

@ -275,8 +275,8 @@ void SolveSpaceUI::GenerateAll(Generate type, bool andFindFree, bool genForBBox)
// and then regenerate the mesh based on the solved stuff.
if(genForBBox) {
SolveGroupAndReport(g->h, andFindFree);
} else {
g->GenerateLoops();
} else {
g->GenerateShellAndMesh();
g->clean = true;
}

View File

@ -782,6 +782,12 @@ void Group::MakeExtrusionTopBottomFaces(IdList<Entity,hEntity> *el, hEntity pt)
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;