| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e377eb8 commit f87152e
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,6 +76,22 @@ Vector EntityBase::VectorGetRefPoint(void) { | |||
| 76 | 76 | } | |
| 77 | 77 | } | |
| 78 | 78 | ||
| 79 | + Vector EntityBase::VectorGetStartPoint(void) { | ||
| 80 | + switch(type) { | ||
| 81 | + case LINE_SEGMENT: | ||
| 82 | + return SK.GetEntity(point[1])->PointGetNum(); | ||
| 83 | + | ||
| 84 | + case NORMAL_IN_3D: | ||
| 85 | + case NORMAL_IN_2D: | ||
| 86 | + case NORMAL_N_COPY: | ||
| 87 | + case NORMAL_N_ROT: | ||
| 88 | + case NORMAL_N_ROT_AA: | ||
| 89 | + return SK.GetEntity(point[0])->PointGetNum(); | ||
| 90 | + | ||
| 91 | + default: oops(); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + | ||
| 79 | 95 | bool EntityBase::IsCircle(void) { | |
| 80 | 96 | return (type == CIRCLE) || (type == ARC_OF_CIRCLE); | |
| 81 | 97 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -112,6 +112,9 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const std::string &filename, bool wir | |||
| 112 | 112 | SEdgeList edges = {}; | |
| 113 | 113 | SBezierList beziers = {}; | |
| 114 | 114 | ||
| 115 | + VectorFileWriter *out = VectorFileWriter::ForFile(filename); | ||
| 116 | + if(!out) return; | ||
| 117 | + | ||
| 115 | 118 | SS.exportMode = true; | |
| 116 | 119 | GenerateAll(GENERATE_ALL); | |
| 117 | 120 | ||
@@ -153,31 +156,41 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const std::string &filename, bool wir | |||
| 153 | 156 | } | |
| 154 | 157 | ||
| 155 | 158 | if(SS.GW.showConstraints) { | |
| 156 | - Constraint *c; | ||
| 157 | - for(c = SK.constraint.First(); c; c = SK.constraint.NextAfter(c)) { | ||
| 158 | - c->GetEdges(&edges); | ||
| 159 | + if(!out->OutputConstraints(&SK.constraint)) { | ||
| 160 | + // The output format cannot represent constraints directly, | ||
| 161 | + // so convert them to edges. | ||
| 162 | + Constraint *c; | ||
| 163 | + for(c = SK.constraint.First(); c; c = SK.constraint.NextAfter(c)) { | ||
| 164 | + c->GetEdges(&edges); | ||
| 165 | + } | ||
| 159 | 166 | } | |
| 160 | 167 | } | |
| 161 | 168 | ||
| 162 | 169 | if(wireframe) { | |
| 163 | - VectorFileWriter *out = VectorFileWriter::ForFile(filename); | ||
| 164 | - if(out) { | ||
| 165 | - ExportWireframeCurves(&edges, &beziers, out); | ||
| 166 | - } | ||
| 170 | + Vector u = Vector::From(1.0, 0.0, 0.0), | ||
| 171 | + v = Vector::From(0.0, 1.0, 0.0), | ||
| 172 | + n = Vector::From(0.0, 0.0, 1.0), | ||
| 173 | + origin = Vector::From(0.0, 0.0, 0.0); | ||
| 174 | + double cameraTan = 0.0, | ||
| 175 | + scale = 1.0; | ||
| 176 | + | ||
| 177 | + out->SetModelviewProjection(u, v, n, origin, cameraTan, scale); | ||
| 178 | + | ||
| 179 | + ExportWireframeCurves(&edges, &beziers, out); | ||
| 167 | 180 | } else { | |
| 168 | 181 | Vector u = SS.GW.projRight, | |
| 169 | 182 | v = SS.GW.projUp, | |
| 170 | 183 | n = u.Cross(v), | |
| 171 | 184 | origin = SS.GW.offset.ScaledBy(-1); | |
| 172 | 185 | ||
| 173 | - VectorFileWriter *out = VectorFileWriter::ForFile(filename); | ||
| 174 | - if(out) { | ||
| 175 | - ExportLinesAndMesh(&edges, &beziers, sm, | ||
| 176 | - u, v, n, origin, SS.CameraTangent()*SS.GW.scale, | ||
| 177 | - out); | ||
| 178 | - } | ||
| 186 | + out->SetModelviewProjection(u, v, n, origin, | ||
| 187 | + SS.CameraTangent()*SS.GW.scale, SS.exportScale); | ||
| 179 | 188 | ||
| 180 | - if(out && !out->HasCanvasSize()) { | ||
| 189 | + ExportLinesAndMesh(&edges, &beziers, sm, | ||
| 190 | + u, v, n, origin, SS.CameraTangent()*SS.GW.scale, | ||
| 191 | + out); | ||
| 192 | + | ||
| 193 | + if(!out->HasCanvasSize()) { | ||
| 181 | 194 | // These file formats don't have a canvas size, so they just | |
| 182 | 195 | // get exported in the raw coordinate system. So indicate what | |
| 183 | 196 | // that was on-screen. | |
@@ -215,7 +228,7 @@ void SolveSpaceUI::ExportWireframeCurves(SEdgeList *sel, SBezierList *sbl, | |||
| 215 | 228 | sblss.AddOpenPath(sb); | |
| 216 | 229 | } | |
| 217 | 230 | ||
| 218 | - out->Output(&sblss, NULL); | ||
| 231 | + out->OutputLinesAndMesh(&sblss, NULL); | ||
| 219 | 232 | sblss.Clear(); | |
| 220 | 233 | } | |
| 221 | 234 | ||
@@ -381,7 +394,7 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s | |||
| 381 | 394 | } | |
| 382 | 395 | ||
| 383 | 396 | // Now write the lines and triangles to the output file | |
| 384 | - out->Output(&sblss, &sms); | ||
| 397 | + out->OutputLinesAndMesh(&sblss, &sms); | ||
| 385 | 398 | ||
| 386 | 399 | leftovers.Clear(); | |
| 387 | 400 | spxyz.Clear(); | |
@@ -441,7 +454,22 @@ VectorFileWriter *VectorFileWriter::ForFile(const std::string &filename) { | |||
| 441 | 454 | return ret; | |
| 442 | 455 | } | |
| 443 | 456 | ||
| 444 | - void VectorFileWriter::Output(SBezierLoopSetSet *sblss, SMesh *sm) { | ||
| 457 | + void VectorFileWriter::SetModelviewProjection(const Vector &u, const Vector &v, const Vector &n, | ||
| 458 | + const Vector &origin, double cameraTan, | ||
| 459 | + double scale) { | ||
| 460 | + this->u = u; | ||
| 461 | + this->v = v; | ||
| 462 | + this->n = n; | ||
| 463 | + this->origin = origin; | ||
| 464 | + this->cameraTan = cameraTan; | ||
| 465 | + this->scale = scale; | ||
| 466 | + } | ||
| 467 | + | ||
| 468 | + Vector VectorFileWriter::Transform(Vector &pos) const { | ||
| 469 | + return pos.InPerspective(u, v, n, origin, cameraTan).ScaledBy(1.0 / scale); | ||
| 470 | + } | ||
| 471 | + | ||
| 472 | + void VectorFileWriter::OutputLinesAndMesh(SBezierLoopSetSet *sblss, SMesh *sm) { | ||
| 445 | 473 | STriangle *tr; | |
| 446 | 474 | SBezier *b; | |
| 447 | 475 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments