
points are now entities like any others; so a line segment request will generate three entities, the line segment and its endpoints. I think that's cleaner. When I do step and repeats (and imports, and other similar), I'll need a consistent way to assign those entity ids. That assignment must not change if the sketch is edited. I don't have a clean way to do that; best thought right now is to keep a record of what maps have been used previously, and not pick a new map as long as it's possible to use one that was used previously. This all means that more crap gets pushed in to the Entity structure, so that they can keep track of what solver variables define them. Still seems better, though. I'm closer to ready to start solving. [git-p4: depot-paths = "//depot/solvespace/": change = 1673]
77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
#include "solvespace.h"
|
|
|
|
bool SolveSpace::SaveToFile(char *filename) {
|
|
fh = fopen(filename, "w");
|
|
if(!fh) {
|
|
Error("Couldn't write to file '%s'", fh);
|
|
return false;
|
|
}
|
|
|
|
fprintf(fh, "!!SolveSpaceREVa\n\n\n");
|
|
|
|
int i;
|
|
for(i = 0; i < group.n; i++) {
|
|
Group *g = &(group.elem[i]);
|
|
fprintf(fh, "Group.h.v=%08x\n", g->h.v);
|
|
fprintf(fh, "Group.name=%s\n", g->name.str);
|
|
fprintf(fh, "AddGroup\n\n");
|
|
}
|
|
|
|
for(i = 0; i < param.n; i++) {
|
|
Param *p = &(param.elem[i]);
|
|
fprintf(fh, "Param.h.v=%08x\n", p->h.v);
|
|
fprintf(fh, "Param.val=%.20f\n", p->val);
|
|
fprintf(fh, "AddParam\n\n");
|
|
}
|
|
|
|
for(i = 0; i < request.n; i++) {
|
|
Request *r = &(request.elem[i]);
|
|
fprintf(fh, "Request.h.v=%08x\n", r->h.v);
|
|
fprintf(fh, "Request.type=%d\n", r->type);
|
|
fprintf(fh, "Request.csys.v=%08x\n", r->csys.v);
|
|
fprintf(fh, "Request.group.v=%08x\n", r->group.v);
|
|
fprintf(fh, "Request.name=%s\n", r->name.str);
|
|
fprintf(fh, "AddRequest\n\n");
|
|
}
|
|
|
|
for(i = 0; i < entity.n; i++) {
|
|
Entity *e = &(entity.elem[i]);
|
|
fprintf(fh, "Entity.h.v=%08x\n", e->h.v);
|
|
fprintf(fh, "Entity.type=%d\n", e->type);
|
|
fprintf(fh, "AddEntity\n\n");
|
|
}
|
|
|
|
for(i = 0; i < constraint.n; i++) {
|
|
Constraint *c = &(constraint.elem[i]);
|
|
fprintf(fh, "Constraint.h.v=%08x\n", c->h.v);
|
|
fprintf(fh, "Constraint.type=%d\n", c->type);
|
|
fprintf(fh, "Constraint.group.v=%08x\n", c->group);
|
|
fprintf(fh, "Constraint.exprA=%s\n", c->exprA->Print());
|
|
fprintf(fh, "Constraint.exprB=%s\n", c->exprB->Print());
|
|
fprintf(fh, "Constraint.ptA.v=%08x\n", c->ptA.v);
|
|
fprintf(fh, "Constraint.ptB.v=%08x\n", c->ptB.v);
|
|
fprintf(fh, "Constraint.ptC.v=%08x\n", c->ptC.v);
|
|
fprintf(fh, "Constraint.entityA.v=%08x\n", c->entityA.v);
|
|
fprintf(fh, "Constraint.entityB.v=%08x\n", c->entityB.v);
|
|
fprintf(fh, "Constraint.disp.offset.x=%.20f\n", c->disp.offset.x);
|
|
fprintf(fh, "Constraint.disp.offset.y=%.20f\n", c->disp.offset.y);
|
|
fprintf(fh, "Constraint.disp.offset.z=%.20f\n", c->disp.offset.z);
|
|
fprintf(fh, "AddConstraint\n\n");
|
|
}
|
|
|
|
fclose(fh);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool SolveSpace::LoadFromFile(char *filename) {
|
|
fh = fopen(filename, "r");
|
|
if(!fh) {
|
|
Error("Couldn't read from file '%s'", fh);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|