Treatment of numerical faces was screwy, exporting stuff in numXXX.
So fix that, and now I can simplify what's exported for an entity. And add an extra measurement (face-face distance/angle), and some other little stuff. [git-p4: depot-paths = "//depot/solvespace/": change = 1789]solver
parent
9bba9425be
commit
b284baffce
|
@ -47,6 +47,7 @@ void Entity::DrawAll(void) {
|
|||
if(!e->IsPoint()) continue;
|
||||
if(!(SS.GetGroup(e->group)->visible)) continue;
|
||||
if(SS.GroupsInOrder(SS.GW.activeGroup, e->group)) continue;
|
||||
if(e->forceHidden) continue;
|
||||
|
||||
Vector v = e->PointGetNum();
|
||||
glxVertex3v(v.Plus (r).Plus (d));
|
||||
|
@ -123,6 +124,9 @@ bool Entity::IsVisible(void) {
|
|||
// The group-associated workplanes are hidden outside their group.
|
||||
if(g->h.v != SS.GW.activeGroup.v) return false;
|
||||
}
|
||||
|
||||
if(forceHidden) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
18
entity.cpp
18
entity.cpp
|
@ -574,7 +574,8 @@ ExprVector Entity::FaceGetNormalExprs(void) {
|
|||
r = ExprVector::From(v.WithMagnitude(1));
|
||||
} else if(type == FACE_XPROD) {
|
||||
ExprVector vc = ExprVector::From(param[0], param[1], param[2]);
|
||||
ExprVector vn = ExprVector::From(numVector);
|
||||
ExprVector vn =
|
||||
ExprVector::From(numNormal.vx, numNormal.vy, numNormal.vz);
|
||||
r = vc.Cross(vn);
|
||||
r = r.WithMagnitude(Expr::From(1.0));
|
||||
} else if(type == FACE_N_ROT_TRANS) {
|
||||
|
@ -595,7 +596,8 @@ Vector Entity::FaceGetNormalNum(void) {
|
|||
r = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
|
||||
} else if(type == FACE_XPROD) {
|
||||
Vector vc = Vector::From(param[0], param[1], param[2]);
|
||||
r = vc.Cross(numVector);
|
||||
Vector vn = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
|
||||
r = vc.Cross(vn);
|
||||
} else if(type == FACE_N_ROT_TRANS) {
|
||||
// The numerical normal vector gets the rotation
|
||||
r = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
|
||||
|
@ -669,17 +671,23 @@ void Entity::GenerateEquations(IdList<Equation,hEquation> *l) {
|
|||
}
|
||||
}
|
||||
|
||||
void Entity::CalculateNumerical(void) {
|
||||
void Entity::CalculateNumerical(bool forExport) {
|
||||
if(IsPoint()) actPoint = PointGetNum();
|
||||
if(IsNormal()) actNormal = NormalGetNum();
|
||||
if(type == DISTANCE || type == DISTANCE_N_COPY) {
|
||||
actDistance = DistanceGetNum();
|
||||
}
|
||||
if(IsFace()) {
|
||||
numPoint = FaceGetPointNum();
|
||||
actPoint = FaceGetPointNum();
|
||||
Vector n = FaceGetNormalNum();
|
||||
numNormal = Quaternion::From(0, n.x, n.y, n.z);
|
||||
actNormal = Quaternion::From(0, n.x, n.y, n.z);
|
||||
}
|
||||
if(forExport) {
|
||||
// Visibility in copied import entities follows source file
|
||||
actVisible = IsVisible();
|
||||
} else {
|
||||
// Copied entities within a file are always visible
|
||||
actVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
22
file.cpp
22
file.cpp
|
@ -95,15 +95,7 @@ const SolveSpace::SaveTable SolveSpace::SAVED[] = {
|
|||
|
||||
{ 'e', "Entity.h.v", 'x', &(SS.sv.e.h.v) },
|
||||
{ 'e', "Entity.type", 'd', &(SS.sv.e.type) },
|
||||
{ 'e', "Entity.group.v", 'x', &(SS.sv.e.group.v) },
|
||||
{ 'e', "Entity.construction", 'b', &(SS.sv.e.construction) },
|
||||
{ 'e', "Entity.param[0].v", 'x', &(SS.sv.e.param[0].v) },
|
||||
{ 'e', "Entity.param[1].v", 'x', &(SS.sv.e.param[1].v) },
|
||||
{ 'e', "Entity.param[2].v", 'x', &(SS.sv.e.param[2].v) },
|
||||
{ 'e', "Entity.param[3].v", 'x', &(SS.sv.e.param[3].v) },
|
||||
{ 'e', "Entity.param[4].v", 'x', &(SS.sv.e.param[4].v) },
|
||||
{ 'e', "Entity.param[5].v", 'x', &(SS.sv.e.param[5].v) },
|
||||
{ 'e', "Entity.param[6].v", 'x', &(SS.sv.e.param[6].v) },
|
||||
{ 'e', "Entity.point[0].v", 'x', &(SS.sv.e.point[0].v) },
|
||||
{ 'e', "Entity.point[1].v", 'x', &(SS.sv.e.point[1].v) },
|
||||
{ 'e', "Entity.point[2].v", 'x', &(SS.sv.e.point[2].v) },
|
||||
|
@ -111,14 +103,6 @@ const SolveSpace::SaveTable SolveSpace::SAVED[] = {
|
|||
{ 'e', "Entity.normal.v", 'x', &(SS.sv.e.normal.v) },
|
||||
{ 'e', "Entity.distance.v", 'x', &(SS.sv.e.distance.v) },
|
||||
{ 'e', "Entity.workplane.v", 'x', &(SS.sv.e.workplane.v) },
|
||||
{ 'e', "Entity.numPoint.x", 'f', &(SS.sv.e.numPoint.x) },
|
||||
{ 'e', "Entity.numPoint.y", 'f', &(SS.sv.e.numPoint.y) },
|
||||
{ 'e', "Entity.numPoint.z", 'f', &(SS.sv.e.numPoint.z) },
|
||||
{ 'e', "Entity.numNormal.w", 'f', &(SS.sv.e.numNormal.w) },
|
||||
{ 'e', "Entity.numNormal.vx", 'f', &(SS.sv.e.numNormal.vx) },
|
||||
{ 'e', "Entity.numNormal.vy", 'f', &(SS.sv.e.numNormal.vy) },
|
||||
{ 'e', "Entity.numNormal.vz", 'f', &(SS.sv.e.numNormal.vz) },
|
||||
{ 'e', "Entity.numDistance", 'f', &(SS.sv.e.numDistance) },
|
||||
{ 'e', "Entity.actPoint.x", 'f', &(SS.sv.e.actPoint.x) },
|
||||
{ 'e', "Entity.actPoint.y", 'f', &(SS.sv.e.actPoint.y) },
|
||||
{ 'e', "Entity.actPoint.z", 'f', &(SS.sv.e.actPoint.z) },
|
||||
|
@ -192,6 +176,10 @@ void SolveSpace::SaveUsingTable(int type) {
|
|||
}
|
||||
|
||||
bool SolveSpace::SaveToFile(char *filename) {
|
||||
// Make sure all the entities are regenerated up to date, since they
|
||||
// will be exported.
|
||||
SS.GenerateAll(0, INT_MAX);
|
||||
|
||||
fh = fopen(filename, "w");
|
||||
if(!fh) {
|
||||
Error("Couldn't write to file '%s'", filename);
|
||||
|
@ -220,7 +208,7 @@ bool SolveSpace::SaveToFile(char *filename) {
|
|||
}
|
||||
|
||||
for(i = 0; i < entity.n; i++) {
|
||||
(entity.elem[i]).CalculateNumerical();
|
||||
(entity.elem[i]).CalculateNumerical(true);
|
||||
sv.e = entity.elem[i];
|
||||
SaveUsingTable('e');
|
||||
fprintf(fh, "AddEntity\n\n");
|
||||
|
|
|
@ -107,8 +107,6 @@ void GraphicsWindow::Init(void) {
|
|||
}
|
||||
SS.GetGroup(activeGroup)->Activate();
|
||||
|
||||
EnsureValidActives();
|
||||
|
||||
showWorkplanes = true;
|
||||
showNormals = true;
|
||||
showPoints = true;
|
||||
|
@ -119,6 +117,9 @@ void GraphicsWindow::Init(void) {
|
|||
|
||||
showTextWindow = true;
|
||||
ShowTextWindow(showTextWindow);
|
||||
|
||||
// Do this last, so that all the menus get updated correctly.
|
||||
EnsureValidActives();
|
||||
}
|
||||
|
||||
void GraphicsWindow::NormalizeProjectionVectors(void) {
|
||||
|
|
14
group.cpp
14
group.cpp
|
@ -266,7 +266,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
|
|||
|
||||
if(e->IsPoint()) pt = e->h;
|
||||
|
||||
e->CalculateNumerical();
|
||||
e->CalculateNumerical(false);
|
||||
hEntity he = e->h; e = NULL;
|
||||
// As soon as I call CopyEntity, e may become invalid! That
|
||||
// adds entities, which may cause a realloc.
|
||||
|
@ -306,7 +306,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
|
|||
Entity *e = &(entity->elem[i]);
|
||||
if(e->group.v != opA.v) continue;
|
||||
|
||||
e->CalculateNumerical();
|
||||
e->CalculateNumerical(false);
|
||||
CopyEntity(entity, e,
|
||||
a*2 - (subtype == ONE_SIDED ? 0 : (n-1)),
|
||||
(a == (n - 1)) ? REMAP_LAST : a,
|
||||
|
@ -338,7 +338,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
|
|||
Entity *e = &(entity->elem[i]);
|
||||
if(e->group.v != opA.v) continue;
|
||||
|
||||
e->CalculateNumerical();
|
||||
e->CalculateNumerical(false);
|
||||
CopyEntity(entity, e,
|
||||
a*2 - (subtype == ONE_SIDED ? 0 : (n-1)),
|
||||
(a == (n - 1)) ? REMAP_LAST : a,
|
||||
|
@ -481,7 +481,7 @@ void Group::MakeExtrusionLines(IdList<Entity,hEntity> *el, hEntity in) {
|
|||
en.param[1] = h.param(1);
|
||||
en.param[2] = h.param(2);
|
||||
en.numPoint = a;
|
||||
en.numVector = ab;
|
||||
en.numNormal = Quaternion::From(0, ab.x, ab.y, ab.z);
|
||||
|
||||
en.group = h;
|
||||
en.h = Remap(ep->h, REMAP_LINE_TO_FACE);
|
||||
|
@ -624,13 +624,15 @@ void Group::CopyEntity(IdList<Entity,hEntity> *el,
|
|||
en.param[4] = qvx;
|
||||
en.param[5] = qvy;
|
||||
en.param[6] = qvz;
|
||||
en.numPoint = ep->numPoint;
|
||||
en.numNormal = ep->numNormal;
|
||||
en.numPoint = ep->actPoint;
|
||||
en.numNormal = ep->actNormal;
|
||||
break;
|
||||
|
||||
default:
|
||||
oops();
|
||||
}
|
||||
en.forceHidden = !ep->actVisible;
|
||||
|
||||
el->Add(&en);
|
||||
}
|
||||
|
||||
|
|
8
sketch.h
8
sketch.h
|
@ -279,8 +279,10 @@ public:
|
|||
Vector numPoint;
|
||||
Quaternion numNormal;
|
||||
double numDistance;
|
||||
// and a bit more state that the faces need
|
||||
Vector numVector;
|
||||
|
||||
// An imported entity that was hidden in the source file ends up hidden
|
||||
// here too.
|
||||
bool forceHidden;
|
||||
|
||||
// All points/normals/distances have their numerical value; this is
|
||||
// a convenience, to simplify the import/assembly code, so that the
|
||||
|
@ -376,7 +378,7 @@ public:
|
|||
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
||||
void GenerateEquations(IdList<Equation,hEquation> *l);
|
||||
|
||||
void CalculateNumerical(void);
|
||||
void CalculateNumerical(bool forExport);
|
||||
|
||||
char *DescriptionString(void);
|
||||
};
|
||||
|
|
24
textwin.cpp
24
textwin.cpp
|
@ -221,6 +221,7 @@ void TextWindow::Show(void) {
|
|||
case SCREEN_CONFIGURATION: ShowConfiguration(); break;
|
||||
}
|
||||
}
|
||||
Printf(false, "");
|
||||
InvalidateText();
|
||||
}
|
||||
|
||||
|
@ -371,6 +372,29 @@ void TextWindow::DescribeSelection(void) {
|
|||
Printf(true, " vector = " PT_AS_NUM, CO(v));
|
||||
double d = (p1.Minus(p0)).Dot(v);
|
||||
Printf(true, " proj_d = %Fi%s", SS.GW.ToString(d));
|
||||
} else if(gs.n == 2 && gs.faces == 2) {
|
||||
Printf(false, "%FtTWO PLANE FACES");
|
||||
|
||||
Vector n0 = SS.GetEntity(gs.face[0])->FaceGetNormalNum();
|
||||
Printf(true, " planeA normal = " PT_AS_NUM, CO(n0));
|
||||
Vector p0 = SS.GetEntity(gs.face[0])->FaceGetPointNum();
|
||||
Printf(false, " planeA thru = " PT_AS_STR, COSTR(p0));
|
||||
|
||||
Vector n1 = SS.GetEntity(gs.face[1])->FaceGetNormalNum();
|
||||
Printf(true, " planeB normal = " PT_AS_NUM, CO(n1));
|
||||
Vector p1 = SS.GetEntity(gs.face[1])->FaceGetPointNum();
|
||||
Printf(false, " planeB thru = " PT_AS_STR, COSTR(p1));
|
||||
|
||||
double theta = acos(n0.Dot(n1));
|
||||
Printf(true, " angle = %Fi%2%E degrees", theta*180/PI);
|
||||
while(theta < PI/2) theta += PI;
|
||||
while(theta > PI/2) theta -= PI;
|
||||
Printf(false, " or angle = %Fi%2%E (mod 180)", theta*180/PI);
|
||||
|
||||
if(fabs(theta) < 0.01) {
|
||||
double d = (p1.Minus(p0)).Dot(n0);
|
||||
Printf(true, " distance = %Fi%s", SS.GW.ToString(d));
|
||||
}
|
||||
} else {
|
||||
Printf(true, "%FtSELECTED:%E %d item%s", gs.n, gs.n == 1 ? "" : "s");
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
STL check for meshes, and T intersection removal
|
||||
STL export
|
||||
DXF export
|
||||
partitioned subsystems in the solver
|
||||
TTF font text
|
||||
display with proper formatting/units
|
||||
some kind of rounding / chamfer
|
||||
remove back button in browser?
|
||||
clean up user-created workplanes
|
||||
|
@ -12,6 +10,10 @@ graphic export
|
|||
relative paths for import
|
||||
auto-generate circles and faces when lathing
|
||||
|
||||
partitioned subsystems in the solver
|
||||
display with proper formatting/units
|
||||
sweep tool
|
||||
|
||||
|
||||
long term
|
||||
-----
|
||||
|
|
Loading…
Reference in New Issue