Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: solvespace/solvespace
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 13820bf27d2c
Choose a base ref
...
head repository: solvespace/solvespace
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 22e4011cb67e
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 25, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2dd50d0 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e22c522 View commit details
  3. use std::vector in helix operations instead of fixed length array. Re…

    …move limit on number of sections. Delete definition of Revolved struct.
    phkahler authored and whitequark committed Aug 25, 2019
    Copy the full SHA
    22e4011 View commit details
Showing with 36 additions and 31 deletions.
  1. +12 −0 src/group.cpp
  2. +24 −31 src/srf/surface.cpp
12 changes: 12 additions & 0 deletions src/group.cpp
Original file line number Diff line number Diff line change
@@ -163,6 +163,10 @@ void Group::MenuGroup(Command id, Platform::Path linkFile) {
break;

case Command::GROUP_LATHE:
if(!SS.GW.LockedInWorkplane()) {
Error(_("Lathe operation can only be applied to planar sketches."));
return;
}
if(gs.points == 1 && gs.vectors == 1 && gs.n == 2) {
g.predef.origin = gs.point[0];
g.predef.entityB = gs.vector[0];
@@ -185,6 +189,10 @@ void Group::MenuGroup(Command id, Platform::Path linkFile) {
break;

case Command::GROUP_REVOLVE:
if(!SS.GW.LockedInWorkplane()) {
Error(_("Revolve operation can only be applied to planar sketches."));
return;
}
if(gs.points == 1 && gs.vectors == 1 && gs.n == 2) {
g.predef.origin = gs.point[0];
g.predef.entityB = gs.vector[0];
@@ -209,6 +217,10 @@ void Group::MenuGroup(Command id, Platform::Path linkFile) {
break;

case Command::GROUP_HELIX:
if(!SS.GW.LockedInWorkplane()) {
Error(_("Helix operation can only be applied to planar sketches."));
return;
}
if(gs.points == 1 && gs.vectors == 1 && gs.n == 2) {
g.predef.origin = gs.point[0];
g.predef.entityB = gs.vector[0];
55 changes: 24 additions & 31 deletions src/srf/surface.cpp
Original file line number Diff line number Diff line change
@@ -637,10 +637,6 @@ bool SShell::CheckNormalAxisRelationship(SBezierLoopSet *sbls, Vector pt, Vector
return (vp.Dot(sbls->normal) > 0);
}

typedef struct {
hSSurface d[100];
} Revolved;

// sketch must not contain the axis of revolution as a non-construction line for helix
void SShell::MakeFromHelicalRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
RgbaColor color, Group *group, double angles,
@@ -651,9 +647,6 @@ void SShell::MakeFromHelicalRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector
// distance will need to be parameters in the future.
double dist = distf - dists;
int sections = fabs(anglef - angles) / (PI / 2) + 1;
if(sections > 99) {
sections = 99;
}
double wedge = (anglef - angles) / sections;

if(CheckNormalAxisRelationship(sbls, pt, axis, anglef-angles, distf-dists)) {
@@ -694,18 +687,18 @@ void SShell::MakeFromHelicalRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
int i, j;
SBezier *sb;
List<Revolved> hsl = {};
List<std::vector<hSSurface>> hsl = {};

// This is where all the NURBS are created and Remapped to the generating curve
for(sb = sbl->l.First(); sb; sb = sbl->l.NextAfter(sb)) {
Revolved revs;
std::vector<hSSurface> revs(sections);
for(j = 0; j < sections; j++) {
if((dist == 0) && sb->deg == 1 &&
(sb->ctrl[0]).DistanceToLine(pt, axis) < LENGTH_EPS &&
(sb->ctrl[1]).DistanceToLine(pt, axis) < LENGTH_EPS) {
// This is a line on the axis of revolution; it does
// not contribute a surface.
revs.d[j].v = 0;
revs[j].v = 0;
} else {
SSurface ss = SSurface::FromRevolutionOf(
sb, pt, axis, angles + (wedge)*j, angles + (wedge) * (j + 1),
@@ -719,14 +712,14 @@ void SShell::MakeFromHelicalRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector
ss.face = hface.v;
}
}
revs.d[j] = surface.AddAndAssignId(&ss);
revs[j] = surface.AddAndAssignId(&ss);
}
}
hsl.Add(&revs);
}
// Still the same loop. Need to create trim curves
for(i = 0; i < sbl->l.n; i++) {
Revolved revs = hsl[i], revsp = hsl[WRAP(i - 1, sbl->l.n)];
std::vector<hSSurface> revs = hsl[i], revsp = hsl[WRAP(i - 1, sbl->l.n)];

sb = &(sbl->l[i]);

@@ -740,21 +733,21 @@ void SShell::MakeFromHelicalRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector

// If this input curve generated a surface, then trim that
// surface with the rotated version of the input curve.
if(revs.d[0].v) { // not d[j] because crash on j==sections
if(revs[0].v) { // not d[j] because crash on j==sections
sc = {};
sc.isExact = true;
sc.exact = sb->TransformedBy(ts, qs, 1.0);
(sc.exact).MakePwlInto(&(sc.pts));

// the surfaces already exist so trim with this curve
if(j < sections) {
sc.surfA = revs.d[j];
sc.surfA = revs[j];
} else {
sc.surfA = hs1; // end cap
}

if(j > 0) {
sc.surfB = revs.d[j - 1];
sc.surfB = revs[j - 1];
} else {
sc.surfB = hs0; // staring cap
}
@@ -784,16 +777,16 @@ void SShell::MakeFromHelicalRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector
// And if this input curve and the one after it both generated
// surfaces, then trim both of those by the appropriate
// curve based on the control points.
if((j < sections) && revs.d[j].v && revsp.d[j].v) {
SSurface *ss = surface.FindById(revs.d[j]);
if((j < sections) && revs[j].v && revsp[j].v) {
SSurface *ss = surface.FindById(revs[j]);

sc = {};
sc.isExact = true;
sc.exact = SBezier::From(ss->ctrl[0][0], ss->ctrl[0][1], ss->ctrl[0][2]);
sc.exact.weight[1] = ss->weight[0][1];
(sc.exact).MakePwlInto(&(sc.pts));
sc.surfA = revs.d[j];
sc.surfB = revsp.d[j];
sc.surfA = revs[j];
sc.surfB = revsp[j];

hSCurve hcc = curve.AddAndAssignId(&sc);

@@ -827,18 +820,18 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
int i, j;
SBezier *sb;
List<Revolved> hsl = {};
List<std::vector<hSSurface>> hsl = {};

for(sb = sbl->l.First(); sb; sb = sbl->l.NextAfter(sb)) {
Revolved revs;
std::vector<hSSurface> revs(4);
for(j = 0; j < 4; j++) {
if(sb->deg == 1 &&
(sb->ctrl[0]).DistanceToLine(pt, axis) < LENGTH_EPS &&
(sb->ctrl[1]).DistanceToLine(pt, axis) < LENGTH_EPS)
{
// This is a line on the axis of revolution; it does
// not contribute a surface.
revs.d[j].v = 0;
revs[j].v = 0;
} else {
SSurface ss = SSurface::FromRevolutionOf(sb, pt, axis, (PI / 2) * j,
(PI / 2) * (j + 1), 0.0, 0.0);
@@ -851,14 +844,14 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
ss.face = hface.v;
}
}
revs.d[j] = surface.AddAndAssignId(&ss);
revs[j] = surface.AddAndAssignId(&ss);
}
}
hsl.Add(&revs);
}

for(i = 0; i < sbl->l.n; i++) {
Revolved revs = hsl[i],
std::vector<hSSurface> revs = hsl[i],
revsp = hsl[WRAP(i-1, sbl->l.n)];

sb = &(sbl->l[i]);
@@ -871,13 +864,13 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,

// If this input curve generate a surface, then trim that
// surface with the rotated version of the input curve.
if(revs.d[j].v) {
if(revs[j].v) {
sc = {};
sc.isExact = true;
sc.exact = sb->TransformedBy(ts, qs, 1.0);
(sc.exact).MakePwlInto(&(sc.pts));
sc.surfA = revs.d[j];
sc.surfB = revs.d[WRAP(j-1, 4)];
sc.surfA = revs[j];
sc.surfB = revs[WRAP(j-1, 4)];

hSCurve hcb = curve.AddAndAssignId(&sc);

@@ -891,8 +884,8 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
// And if this input curve and the one after it both generated
// surfaces, then trim both of those by the appropriate
// circle.
if(revs.d[j].v && revsp.d[j].v) {
SSurface *ss = surface.FindById(revs.d[j]);
if(revs[j].v && revsp[j].v) {
SSurface *ss = surface.FindById(revs[j]);

sc = {};
sc.isExact = true;
@@ -901,8 +894,8 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
ss->ctrl[0][2]);
sc.exact.weight[1] = ss->weight[0][1];
(sc.exact).MakePwlInto(&(sc.pts));
sc.surfA = revs.d[j];
sc.surfB = revsp.d[j];
sc.surfA = revs[j];
sc.surfB = revsp[j];

hSCurve hcc = curve.AddAndAssignId(&sc);