Little stuff: show polygon assembly errors only for draw-in-plane

groups, rename "drawing" groups to "sketch" groups, and keep
assembling even after finding an open curve.

[git-p4: depot-paths = "//depot/solvespace/": change = 1835]
solver
Jonathan Westhues 2008-07-13 01:57:46 -08:00
parent 6269d702fb
commit 36870360cb
5 changed files with 40 additions and 31 deletions

View File

@ -13,7 +13,7 @@ hGroup SolveSpace::CreateDefaultDrawingGroup(void) {
g.predef.q = Quaternion::From(1, 0, 0, 0); g.predef.q = Quaternion::From(1, 0, 0, 0);
hRequest hr = Request::HREQUEST_REFERENCE_XY; hRequest hr = Request::HREQUEST_REFERENCE_XY;
g.predef.origin = hr.entity(1); g.predef.origin = hr.entity(1);
g.name.strcpy("draw-in-plane"); g.name.strcpy("sketch-in-plane");
group.AddAndAssignId(&g); group.AddAndAssignId(&g);
SS.GetGroup(g.h)->activeWorkplane = g.h.entity(0); SS.GetGroup(g.h)->activeWorkplane = g.h.entity(0);
return g.h; return g.h;

View File

@ -42,8 +42,8 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = {
{ 1, "Dimensions in &Millimeters", MNU_UNITS_MM, 0, mView }, { 1, "Dimensions in &Millimeters", MNU_UNITS_MM, 0, mView },
{ 0, "&New Group", 0, 0, NULL }, { 0, "&New Group", 0, 0, NULL },
{ 1, "&Drawing in 3d\tShift+D", MNU_GROUP_3D, 'D'|S, mGrp }, { 1, "Sketch In &3d\tShift+3", MNU_GROUP_3D, '3'|S, mGrp },
{ 1, "Drawing in Workplane\tShift+W", MNU_GROUP_WRKPL, 'W'|S, mGrp }, { 1, "Sketch In New &Workplane\tShift+W", MNU_GROUP_WRKPL, 'W'|S, mGrp },
{ 1, NULL, 0, NULL }, { 1, NULL, 0, NULL },
{ 1, "Step &Translating\tShift+T", MNU_GROUP_TRANS, 'T'|S, mGrp }, { 1, "Step &Translating\tShift+T", MNU_GROUP_TRANS, 'T'|S, mGrp },
{ 1, "Step &Rotating\tShift+R", MNU_GROUP_ROT, 'R'|S, mGrp }, { 1, "Step &Rotating\tShift+R", MNU_GROUP_ROT, 'R'|S, mGrp },
@ -96,7 +96,7 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = {
{ 0, "&Help", 0, NULL }, { 0, "&Help", 0, NULL },
{ 1, "&Load License...", 0, NULL }, { 1, "&Load License...", 0, NULL },
{ 1, NULL, 0, NULL }, { 1, NULL, 0, NULL },
{ 1, "Open &Website", 0, NULL }, { 1, "&Website / Manual", 0, NULL },
{ 1, "&About", 0, NULL }, { 1, "&About", 0, NULL },
{ -1 }, { -1 },
}; };

View File

@ -32,12 +32,12 @@ void Group::MenuGroup(int id) {
switch(id) { switch(id) {
case GraphicsWindow::MNU_GROUP_3D: case GraphicsWindow::MNU_GROUP_3D:
g.type = DRAWING_3D; g.type = DRAWING_3D;
g.name.strcpy("draw-in-3d"); g.name.strcpy("sketch-in-3d");
break; break;
case GraphicsWindow::MNU_GROUP_WRKPL: case GraphicsWindow::MNU_GROUP_WRKPL:
g.type = DRAWING_WORKPLANE; g.type = DRAWING_WORKPLANE;
g.name.strcpy("draw-in-plane"); g.name.strcpy("sketch-in-plane");
if(gs.points == 1 && gs.n == 1) { if(gs.points == 1 && gs.n == 1) {
g.subtype = WORKPLANE_BY_POINT_ORTHO; g.subtype = WORKPLANE_BY_POINT_ORTHO;

View File

@ -612,30 +612,37 @@ void Group::Draw(void) {
// And finally show the polygons too // And finally show the polygons too
if(!SS.GW.showShaded) return; if(!SS.GW.showShaded) return;
if(polyError.how == POLY_NOT_CLOSED) { if(polyError.how == POLY_NOT_CLOSED) {
glDisable(GL_DEPTH_TEST); // Report this error only in sketch-in-workplane groups; otherwise
glxColor4d(1, 0, 0, 0.2); // it's just a nuisance.
glLineWidth(10); if(type == DRAWING_WORKPLANE) {
glBegin(GL_LINES); glDisable(GL_DEPTH_TEST);
glxVertex3v(polyError.notClosedAt.a); glxColor4d(1, 0, 0, 0.2);
glxVertex3v(polyError.notClosedAt.b); glLineWidth(10);
glEnd(); glBegin(GL_LINES);
glLineWidth(1); glxVertex3v(polyError.notClosedAt.a);
glxColor3d(1, 0, 0); glxVertex3v(polyError.notClosedAt.b);
glPushMatrix(); glEnd();
glxTranslatev(polyError.notClosedAt.b); glLineWidth(1);
glxOntoWorkplane(SS.GW.projRight, SS.GW.projUp); glxColor3d(1, 0, 0);
glxWriteText("not closed contour!"); glPushMatrix();
glPopMatrix(); glxTranslatev(polyError.notClosedAt.b);
glEnable(GL_DEPTH_TEST); glxOntoWorkplane(SS.GW.projRight, SS.GW.projUp);
glxWriteText("not closed contour!");
glPopMatrix();
glEnable(GL_DEPTH_TEST);
}
} else if(polyError.how == POLY_NOT_COPLANAR) { } else if(polyError.how == POLY_NOT_COPLANAR) {
glDisable(GL_DEPTH_TEST); // And this one too
glxColor3d(1, 0, 0); if(type == DRAWING_WORKPLANE) {
glPushMatrix(); glDisable(GL_DEPTH_TEST);
glxTranslatev(polyError.notCoplanarAt); glxColor3d(1, 0, 0);
glxOntoWorkplane(SS.GW.projRight, SS.GW.projUp); glPushMatrix();
glxWriteText("points not all coplanar!"); glxTranslatev(polyError.notCoplanarAt);
glPopMatrix(); glxOntoWorkplane(SS.GW.projRight, SS.GW.projUp);
glEnable(GL_DEPTH_TEST); glxWriteText("points not all coplanar!");
glPopMatrix();
glEnable(GL_DEPTH_TEST);
}
} else { } else {
glxColor4d(0, 0.1, 0.1, 0.5); glxColor4d(0, 0.1, 0.1, 0.5);
glxDepthRangeOffset(1); glxDepthRangeOffset(1);

View File

@ -105,6 +105,7 @@ bool SEdgeList::AssembleContour(Vector first, Vector last,
bool SEdgeList::AssemblePolygon(SPolygon *dest, SEdge *errorAt) { bool SEdgeList::AssemblePolygon(SPolygon *dest, SEdge *errorAt) {
dest->Clear(); dest->Clear();
bool allClosed = true;
for(;;) { for(;;) {
Vector first, last; Vector first, last;
int i; int i;
@ -117,14 +118,15 @@ bool SEdgeList::AssemblePolygon(SPolygon *dest, SEdge *errorAt) {
} }
} }
if(i >= l.n) { if(i >= l.n) {
return true; return allClosed;
} }
// Create a new empty contour in our polygon, and finish assembling // Create a new empty contour in our polygon, and finish assembling
// into that contour. // into that contour.
dest->AddEmptyContour(); dest->AddEmptyContour();
if(!AssembleContour(first, last, &(dest->l.elem[dest->l.n-1]), errorAt)) if(!AssembleContour(first, last, &(dest->l.elem[dest->l.n-1]), errorAt))
return false; allClosed = false;
// But continue assembling, even if some of the contours are open
} }
} }