Make the export scale factor affect the surfaces in a STEP file,
and lay groundwork for wireframe export. [git-p4: depot-paths = "//depot/solvespace/": change = 2052]
This commit is contained in:
parent
c153e23f49
commit
730bb8f73e
@ -61,7 +61,7 @@ void TextWindow::ScreenChangeExportScale(int link, DWORD v) {
|
||||
char str[1024];
|
||||
sprintf(str, "%.3f", (double)SS.exportScale);
|
||||
|
||||
ShowTextEditControl(57, 3, str);
|
||||
ShowTextEditControl(57, 5, str);
|
||||
SS.TW.edit.meaning = EDIT_EXPORT_SCALE;
|
||||
}
|
||||
|
||||
@ -174,8 +174,8 @@ void TextWindow::ShowConfiguration(void) {
|
||||
&ScreenChangeGridSpacing, 0);
|
||||
|
||||
Printf(false, "");
|
||||
Printf(false, "%Ft export scale factor (1.0=mm, 25.4=inch)");
|
||||
Printf(false, "%Ba %# %Fl%Ll%f%D[change]%E",
|
||||
Printf(false, "%Ft export scale factor (1:1=mm, 1:25.4=inch)");
|
||||
Printf(false, "%Ba 1:%# %Fl%Ll%f%D[change]%E",
|
||||
(double)SS.exportScale,
|
||||
&ScreenChangeExportScale, 0);
|
||||
Printf(false, "%Ft cutter radius offset (0=no offset) ");
|
||||
|
@ -158,7 +158,7 @@ int StepFileWriter::ExportCurveLoop(SBezierLoop *loop, bool inner) {
|
||||
return fb;
|
||||
}
|
||||
|
||||
void StepFileWriter::ExportSurface(SSurface *ss) {
|
||||
void StepFileWriter::ExportSurface(SSurface *ss, SBezierList *sbl) {
|
||||
int i, j, srfid = id;
|
||||
|
||||
fprintf(f, "#%d=(\n", srfid);
|
||||
@ -205,17 +205,14 @@ void StepFileWriter::ExportSurface(SSurface *ss) {
|
||||
|
||||
id = srfid + 1 + (ss->degm + 1)*(ss->degn + 1);
|
||||
|
||||
// Get all of the loops of Beziers that trim our surface (with each
|
||||
// Bezier split so that we use the section as t goes from 0 to 1), and
|
||||
// the piecewise linearization of those loops in xyz space.
|
||||
SBezierList sbl;
|
||||
SPolygon sp;
|
||||
ZERO(&sbl);
|
||||
ZERO(&sp);
|
||||
SEdge errorAt;
|
||||
bool allClosed;
|
||||
ss->MakeSectionEdgesInto(shell, NULL, &sbl);
|
||||
SBezierLoopSet sbls = SBezierLoopSet::From(&sbl, &sp, &allClosed, &errorAt);
|
||||
SEdge errorAt;
|
||||
SPolygon sp;
|
||||
ZERO(&sp);
|
||||
// Assemble the Bezier trim curves into closed loops; we also get the
|
||||
// piecewise linearization of the curves (in the SPolygon sp), as a
|
||||
// calculation aid for the loop direction.
|
||||
SBezierLoopSet sbls = SBezierLoopSet::From(sbl, &sp, &allClosed, &errorAt);
|
||||
|
||||
// Convert the xyz piecewise linear to uv piecewise linear.
|
||||
SContour *contour;
|
||||
@ -334,7 +331,8 @@ void StepFileWriter::WriteFooter(void) {
|
||||
|
||||
void StepFileWriter::ExportSurfacesTo(char *file) {
|
||||
Group *g = SK.GetGroup(SS.GW.activeGroup);
|
||||
shell = &(g->runningShell);
|
||||
SShell *shell = &(g->runningShell);
|
||||
|
||||
if(shell->surface.n == 0) {
|
||||
Error("The model does not contain any surfaces to export.%s",
|
||||
g->runningMesh.l.n > 0 ?
|
||||
@ -358,7 +356,20 @@ void StepFileWriter::ExportSurfacesTo(char *file) {
|
||||
for(ss = shell->surface.First(); ss; ss = shell->surface.NextAfter(ss)) {
|
||||
if(ss->trim.n == 0) continue;
|
||||
|
||||
ExportSurface(ss);
|
||||
// Get all of the loops of Beziers that trim our surface (with each
|
||||
// Bezier split so that we use the section as t goes from 0 to 1), and
|
||||
// the piecewise linearization of those loops in xyz space.
|
||||
SBezierList sbl;
|
||||
ZERO(&sbl);
|
||||
ss->MakeSectionEdgesInto(shell, NULL, &sbl);
|
||||
|
||||
// Apply the export scale factor.
|
||||
ss->ScaleSelfBy(1.0/SS.exportScale);
|
||||
sbl.ScaleSelfBy(1.0/SS.exportScale);
|
||||
|
||||
ExportSurface(ss, &sbl);
|
||||
|
||||
sbl.Clear();
|
||||
}
|
||||
|
||||
fprintf(f, "#%d=CLOSED_SHELL('',(", id);
|
||||
|
@ -22,6 +22,7 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = {
|
||||
{ 1, "Export &Image...", MNU_EXPORT_PNG, 0, mFile },
|
||||
{ 1, "Export 2d &View...", MNU_EXPORT_VIEW, 0, mFile },
|
||||
{ 1, "Export 2d &Section...", MNU_EXPORT_SECTION, 0, mFile },
|
||||
{ 1, "Export 3d &Wireframe...", MNU_EXPORT_WIREFRAME, 0, mFile },
|
||||
{ 1, "Export Triangle &Mesh...", MNU_EXPORT_MESH, 0, mFile },
|
||||
{ 1, "Export &Surfaces...", MNU_EXPORT_SURFACES,0, mFile },
|
||||
{ 1, NULL, 0, 0, NULL },
|
||||
|
@ -378,13 +378,12 @@ public:
|
||||
void WriteHeader(void);
|
||||
int ExportCurve(SBezier *sb);
|
||||
int ExportCurveLoop(SBezierLoop *loop, bool inner);
|
||||
void ExportSurface(SSurface *ss);
|
||||
void ExportSurface(SSurface *ss, SBezierList *sbl);
|
||||
void WriteWireframe(void);
|
||||
void WriteFooter(void);
|
||||
|
||||
List<int> curves;
|
||||
List<int> advancedFaces;
|
||||
SShell *shell;
|
||||
FILE *f;
|
||||
int id;
|
||||
};
|
||||
|
@ -77,6 +77,13 @@ void SBezier::Reverse(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void SBezier::ScaleSelfBy(double s) {
|
||||
int i;
|
||||
for(i = 0; i <= deg; i++) {
|
||||
ctrl[i] = ctrl[i].ScaledBy(s);
|
||||
}
|
||||
}
|
||||
|
||||
void SBezier::GetBoundingProjd(Vector u, Vector orig,
|
||||
double *umin, double *umax)
|
||||
{
|
||||
@ -202,6 +209,13 @@ void SBezierList::Clear(void) {
|
||||
l.Clear();
|
||||
}
|
||||
|
||||
void SBezierList::ScaleSelfBy(double s) {
|
||||
SBezier *sb;
|
||||
for(sb = l.First(); sb; sb = l.NextAfter(sb)) {
|
||||
sb->ScaleSelfBy(s);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// If our list contains multiple identical Beziers (in either forward or
|
||||
// reverse order), then cull them.
|
||||
|
@ -471,6 +471,15 @@ void SSurface::Reverse(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void SSurface::ScaleSelfBy(double s) {
|
||||
int i, j;
|
||||
for(i = 0; i <= degm; i++) {
|
||||
for(j = 0; j <= degn; j++) {
|
||||
ctrl[i][j] = ctrl[i][j].ScaledBy(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SSurface::Clear(void) {
|
||||
trim.Clear();
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
SBezier TransformedBy(Vector t, Quaternion q, bool mirror);
|
||||
SBezier InPerspective(Vector u, Vector v, Vector n,
|
||||
Vector origin, double cameraTan);
|
||||
void ScaleSelfBy(double s);
|
||||
|
||||
static SBezier From(Vector p0, Vector p1, Vector p2, Vector p3);
|
||||
static SBezier From(Vector p0, Vector p1, Vector p2);
|
||||
@ -106,6 +107,7 @@ public:
|
||||
List<SBezier> l;
|
||||
|
||||
void Clear(void);
|
||||
void ScaleSelfBy(double s);
|
||||
void CullIdenticalBeziers(void);
|
||||
void AllIntersectionsWith(SBezierList *sblb, SPointList *spl);
|
||||
};
|
||||
@ -239,6 +241,7 @@ public:
|
||||
static SSurface FromTransformationOf(SSurface *a, Vector t, Quaternion q,
|
||||
bool mirror,
|
||||
bool includingTrims);
|
||||
void ScaleSelfBy(double s);
|
||||
|
||||
void EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
|
||||
Vector *pt, Vector *enin, Vector *enout,
|
||||
|
Loading…
Reference in New Issue
Block a user