2013-07-28 22:08:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Implementation of the Group class, which represents a set of entities and
|
|
|
|
// constraints that are solved together, in some cases followed by another
|
|
|
|
// operation, like to extrude surfaces from the entities or to step and
|
|
|
|
// repeat them parametrically.
|
|
|
|
//
|
|
|
|
// Copyright 2008-2013 Jonathan Westhues.
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-04-01 10:48:44 +00:00
|
|
|
#include "solvespace.h"
|
|
|
|
|
2008-05-11 06:09:46 +00:00
|
|
|
const hParam Param::NO_PARAM = { 0 };
|
|
|
|
#define NO_PARAM (Param::NO_PARAM)
|
2008-04-01 10:48:44 +00:00
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
const hGroup Group::HGROUP_REFERENCES = { 1 };
|
|
|
|
|
2010-02-28 19:23:01 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// The group structure includes pointers to other dynamically-allocated
|
|
|
|
// memory. This clears and frees them all.
|
|
|
|
//-----------------------------------------------------------------------------
|
2016-05-05 05:54:05 +00:00
|
|
|
void Group::Clear() {
|
2010-02-28 19:23:01 +00:00
|
|
|
polyLoops.Clear();
|
|
|
|
bezierLoops.Clear();
|
|
|
|
bezierOpens.Clear();
|
|
|
|
thisMesh.Clear();
|
|
|
|
runningMesh.Clear();
|
|
|
|
thisShell.Clear();
|
|
|
|
runningShell.Clear();
|
|
|
|
displayMesh.Clear();
|
2016-03-14 16:14:24 +00:00
|
|
|
displayOutlines.Clear();
|
2010-02-28 19:23:01 +00:00
|
|
|
impMesh.Clear();
|
|
|
|
impShell.Clear();
|
|
|
|
impEntity.Clear();
|
|
|
|
// remap is the only one that doesn't get recreated when we regen
|
|
|
|
remap.Clear();
|
|
|
|
}
|
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
void Group::AddParam(IdList<Param,hParam> *param, hParam hp, double v) {
|
2015-03-27 15:31:23 +00:00
|
|
|
Param pa = {};
|
2008-04-27 09:03:01 +00:00
|
|
|
pa.h = hp;
|
|
|
|
pa.val = v;
|
|
|
|
|
|
|
|
param->Add(&pa);
|
|
|
|
}
|
|
|
|
|
2016-05-05 05:54:05 +00:00
|
|
|
bool Group::IsVisible() {
|
2009-10-29 07:16:28 +00:00
|
|
|
if(!visible) return false;
|
2017-01-16 13:02:56 +00:00
|
|
|
Group *active = SK.GetGroup(SS.GW.activeGroup);
|
|
|
|
if(order > active->order) return false;
|
2009-10-29 07:16:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-04 10:18:13 +00:00
|
|
|
int Group::GetNumConstraints(void) {
|
|
|
|
int num = 0;
|
|
|
|
for(int i = 0; i < SK.constraint.n; i++) {
|
|
|
|
Constraint *c = &SK.constraint.elem[i];
|
|
|
|
if(c->group.v != h.v) continue;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector Group::ExtrusionGetVector() {
|
|
|
|
return Vector::From(h.param(0), h.param(1), h.param(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Group::ExtrusionForceVectorTo(const Vector &v) {
|
|
|
|
SK.GetParam(h.param(0))->val = v.x;
|
|
|
|
SK.GetParam(h.param(1))->val = v.y;
|
|
|
|
SK.GetParam(h.param(2))->val = v.z;
|
|
|
|
}
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
void Group::MenuGroup(Command id) {
|
2015-03-27 15:31:23 +00:00
|
|
|
Group g = {};
|
2008-04-27 09:03:01 +00:00
|
|
|
g.visible = true;
|
2013-12-02 06:25:09 +00:00
|
|
|
g.color = RGBi(100, 100, 100);
|
2009-12-15 12:26:22 +00:00
|
|
|
g.scale = 1;
|
2008-04-27 09:03:01 +00:00
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if((uint32_t)id >= (uint32_t)Command::RECENT_LINK &&
|
|
|
|
(uint32_t)id < ((uint32_t)Command::RECENT_LINK + MAX_RECENT)) {
|
|
|
|
g.linkFile = RecentFile[(uint32_t)id-(uint32_t)Command::RECENT_LINK];
|
|
|
|
id = Command::GROUP_LINK;
|
2008-05-29 10:10:12 +00:00
|
|
|
}
|
|
|
|
|
2008-05-11 10:40:37 +00:00
|
|
|
SS.GW.GroupSelection();
|
2016-10-10 12:34:10 +00:00
|
|
|
auto const &gs = SS.GW.gs;
|
2008-05-11 10:40:37 +00:00
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
switch(id) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Command::GROUP_3D:
|
|
|
|
g.type = Type::DRAWING_3D;
|
2017-01-07 06:41:13 +00:00
|
|
|
g.name = C_("group-name", "sketch-in-3d");
|
2008-04-27 09:03:01 +00:00
|
|
|
break;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Command::GROUP_WRKPL:
|
|
|
|
g.type = Type::DRAWING_WORKPLANE;
|
2017-01-07 06:41:13 +00:00
|
|
|
g.name = C_("group-name", "sketch-in-plane");
|
2008-05-11 10:40:37 +00:00
|
|
|
if(gs.points == 1 && gs.n == 1) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
g.subtype = Subtype::WORKPLANE_BY_POINT_ORTHO;
|
2008-05-11 10:40:37 +00:00
|
|
|
|
|
|
|
Vector u = SS.GW.projRight, v = SS.GW.projUp;
|
|
|
|
u = u.ClosestOrtho();
|
|
|
|
v = v.Minus(u.ScaledBy(v.Dot(u)));
|
|
|
|
v = v.ClosestOrtho();
|
|
|
|
|
2008-06-01 08:45:11 +00:00
|
|
|
g.predef.q = Quaternion::From(u, v);
|
2008-06-01 08:29:59 +00:00
|
|
|
g.predef.origin = gs.point[0];
|
2008-05-11 10:40:37 +00:00
|
|
|
} else if(gs.points == 1 && gs.lineSegments == 2 && gs.n == 3) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
g.subtype = Subtype::WORKPLANE_BY_LINE_SEGMENTS;
|
2008-05-11 10:40:37 +00:00
|
|
|
|
2008-06-01 08:29:59 +00:00
|
|
|
g.predef.origin = gs.point[0];
|
|
|
|
g.predef.entityB = gs.entity[0];
|
|
|
|
g.predef.entityC = gs.entity[1];
|
2008-05-11 10:40:37 +00:00
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector ut = SK.GetEntity(g.predef.entityB)->VectorGetNum();
|
|
|
|
Vector vt = SK.GetEntity(g.predef.entityC)->VectorGetNum();
|
2008-05-11 10:40:37 +00:00
|
|
|
ut = ut.WithMagnitude(1);
|
|
|
|
vt = vt.WithMagnitude(1);
|
|
|
|
|
|
|
|
if(fabs(SS.GW.projUp.Dot(vt)) < fabs(SS.GW.projUp.Dot(ut))) {
|
2015-03-27 15:43:28 +00:00
|
|
|
swap(ut, vt);
|
2008-06-01 08:29:59 +00:00
|
|
|
g.predef.swapUV = true;
|
2008-05-11 10:40:37 +00:00
|
|
|
}
|
2008-06-01 08:29:59 +00:00
|
|
|
if(SS.GW.projRight.Dot(ut) < 0) g.predef.negateU = true;
|
|
|
|
if(SS.GW.projUp. Dot(vt) < 0) g.predef.negateV = true;
|
2016-11-17 04:30:54 +00:00
|
|
|
} else if(gs.workplanes == 1 && gs.n == 1) {
|
2016-11-17 15:51:19 +00:00
|
|
|
if(gs.entity[0].request().IsFromReferences()) {
|
|
|
|
Entity *wrkpl = SK.GetEntity(gs.entity[0]);
|
|
|
|
Entity *normal = SK.GetEntity(wrkpl->normal);
|
|
|
|
g.subtype = Subtype::WORKPLANE_BY_POINT_ORTHO;
|
|
|
|
g.predef.origin = wrkpl->point[0];
|
|
|
|
g.predef.q = normal->NormalGetNum();
|
2016-11-17 04:30:54 +00:00
|
|
|
} else {
|
2016-11-17 15:51:19 +00:00
|
|
|
Group *wrkplg = SK.GetGroup(gs.entity[0].group());
|
|
|
|
g.subtype = wrkplg->subtype;
|
|
|
|
g.predef.origin = wrkplg->predef.origin;
|
|
|
|
if(wrkplg->subtype == Subtype::WORKPLANE_BY_LINE_SEGMENTS) {
|
|
|
|
g.predef.entityB = wrkplg->predef.entityB;
|
|
|
|
g.predef.entityC = wrkplg->predef.entityC;
|
|
|
|
g.predef.swapUV = wrkplg->predef.swapUV;
|
|
|
|
g.predef.negateU = wrkplg->predef.negateU;
|
|
|
|
g.predef.negateV = wrkplg->predef.negateV;
|
|
|
|
} else if(wrkplg->subtype == Subtype::WORKPLANE_BY_POINT_ORTHO) {
|
|
|
|
g.predef.q = wrkplg->predef.q;
|
|
|
|
} else ssassert(false, "Unexpected workplane subtype");
|
2016-11-17 04:30:54 +00:00
|
|
|
}
|
2008-05-11 10:40:37 +00:00
|
|
|
} else {
|
2017-01-07 06:41:13 +00:00
|
|
|
Error(_("Bad selection for new sketch in workplane. This "
|
|
|
|
"group can be created with:\n\n"
|
|
|
|
" * a point (through the point, orthogonal to coordinate axes)\n"
|
|
|
|
" * a point and two line segments (through the point, "
|
|
|
|
"parallel to the lines)\n"
|
|
|
|
" * a workplane (copy of the workplane)\n"));
|
2008-05-11 10:40:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Command::GROUP_EXTRUDE:
|
2009-06-11 05:57:23 +00:00
|
|
|
if(!SS.GW.LockedInWorkplane()) {
|
2017-01-07 06:41:13 +00:00
|
|
|
Error(_("Activate a workplane (Sketch -> In Workplane) before "
|
|
|
|
"extruding. The sketch will be extruded normal to the "
|
|
|
|
"workplane."));
|
2009-06-11 05:57:23 +00:00
|
|
|
return;
|
|
|
|
}
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
g.type = Type::EXTRUDE;
|
2008-05-11 06:09:46 +00:00
|
|
|
g.opA = SS.GW.activeGroup;
|
2008-06-01 08:29:59 +00:00
|
|
|
g.predef.entityB = SS.GW.ActiveWorkplane();
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
g.subtype = Subtype::ONE_SIDED;
|
2017-01-07 06:41:13 +00:00
|
|
|
g.name = C_("group-name", "extrude");
|
2008-04-27 09:03:01 +00:00
|
|
|
break;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Command::GROUP_LATHE:
|
2008-06-06 11:35:28 +00:00
|
|
|
if(gs.points == 1 && gs.vectors == 1 && gs.n == 2) {
|
|
|
|
g.predef.origin = gs.point[0];
|
|
|
|
g.predef.entityB = gs.vector[0];
|
|
|
|
} else if(gs.lineSegments == 1 && gs.n == 1) {
|
2009-04-19 05:53:16 +00:00
|
|
|
g.predef.origin = SK.GetEntity(gs.entity[0])->point[0];
|
2008-06-06 11:35:28 +00:00
|
|
|
g.predef.entityB = gs.entity[0];
|
|
|
|
// since a line segment is a vector
|
|
|
|
} else {
|
2017-01-07 06:41:13 +00:00
|
|
|
Error(_("Bad selection for new lathe group. This group can "
|
|
|
|
"be created with:\n\n"
|
|
|
|
" * a point and a line segment or normal "
|
|
|
|
"(revolved about an axis parallel to line / "
|
|
|
|
"normal, through point)\n"
|
|
|
|
" * a line segment (revolved about line segment)\n"));
|
2008-06-06 11:35:28 +00:00
|
|
|
return;
|
|
|
|
}
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
g.type = Type::LATHE;
|
2008-06-06 11:35:28 +00:00
|
|
|
g.opA = SS.GW.activeGroup;
|
2017-01-07 06:41:13 +00:00
|
|
|
g.name = C_("group-name", "lathe");
|
2008-06-06 11:35:28 +00:00
|
|
|
break;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Command::GROUP_ROT: {
|
2008-06-01 08:29:59 +00:00
|
|
|
if(gs.points == 1 && gs.n == 1 && SS.GW.LockedInWorkplane()) {
|
2008-06-13 05:32:55 +00:00
|
|
|
g.predef.origin = gs.point[0];
|
2009-04-19 05:53:16 +00:00
|
|
|
Entity *w = SK.GetEntity(SS.GW.ActiveWorkplane());
|
2008-06-13 05:32:55 +00:00
|
|
|
g.predef.entityB = w->Normal()->h;
|
2008-06-01 08:29:59 +00:00
|
|
|
g.activeWorkplane = w->h;
|
|
|
|
} else if(gs.points == 1 && gs.vectors == 1 && gs.n == 2) {
|
2008-06-13 05:32:55 +00:00
|
|
|
g.predef.origin = gs.point[0];
|
|
|
|
g.predef.entityB = gs.vector[0];
|
2008-06-01 08:29:59 +00:00
|
|
|
} else {
|
2017-01-07 06:41:13 +00:00
|
|
|
Error(_("Bad selection for new rotation. This group can "
|
|
|
|
"be created with:\n\n"
|
|
|
|
" * a point, while locked in workplane (rotate "
|
|
|
|
"in plane, about that point)\n"
|
|
|
|
" * a point and a line or a normal (rotate about "
|
|
|
|
"an axis through the point, and parallel to "
|
|
|
|
"line / normal)\n"));
|
2008-06-01 08:29:59 +00:00
|
|
|
return;
|
|
|
|
}
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
g.type = Type::ROTATE;
|
2008-05-11 06:09:46 +00:00
|
|
|
g.opA = SS.GW.activeGroup;
|
2008-06-14 08:43:38 +00:00
|
|
|
g.valA = 3;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
g.subtype = Subtype::ONE_SIDED;
|
2017-01-07 06:41:13 +00:00
|
|
|
g.name = C_("group-name", "rotate");
|
2008-05-11 06:09:46 +00:00
|
|
|
break;
|
2008-06-01 08:29:59 +00:00
|
|
|
}
|
2008-05-11 06:09:46 +00:00
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Command::GROUP_TRANS:
|
|
|
|
g.type = Type::TRANSLATE;
|
2008-05-27 06:36:59 +00:00
|
|
|
g.opA = SS.GW.activeGroup;
|
2008-06-14 08:43:38 +00:00
|
|
|
g.valA = 3;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
g.subtype = Subtype::ONE_SIDED;
|
2008-06-12 04:36:33 +00:00
|
|
|
g.predef.entityB = SS.GW.ActiveWorkplane();
|
|
|
|
g.activeWorkplane = SS.GW.ActiveWorkplane();
|
2017-01-07 06:41:13 +00:00
|
|
|
g.name = C_("group-name", "translate");
|
2008-05-27 06:36:59 +00:00
|
|
|
break;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Command::GROUP_LINK: {
|
|
|
|
g.type = Type::LINKED;
|
2017-03-08 19:25:45 +00:00
|
|
|
g.meshCombine = CombineAs::ASSEMBLE;
|
2016-05-07 05:27:54 +00:00
|
|
|
if(g.linkFile.empty()) {
|
|
|
|
if(!GetOpenFile(&g.linkFile, "", SlvsFileFilter)) return;
|
2008-05-29 10:10:12 +00:00
|
|
|
}
|
2010-05-03 05:38:25 +00:00
|
|
|
|
|
|
|
// Assign the default name of the group based on the name of
|
2016-05-07 05:27:54 +00:00
|
|
|
// the linked file.
|
2017-03-08 19:25:45 +00:00
|
|
|
g.name = Basename(g.linkFile, /*stripExtension=*/true);
|
|
|
|
for(size_t i = 0; i < g.name.length(); i++) {
|
|
|
|
if(!(isalnum(g.name[i]) || (unsigned)g.name[i] >= 0x80)) {
|
2015-11-05 19:39:27 +00:00
|
|
|
// convert punctuation to dashes
|
2017-03-08 19:25:45 +00:00
|
|
|
g.name[i] = '-';
|
2010-05-03 05:38:25 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-29 10:10:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-18 22:51:36 +00:00
|
|
|
default: ssassert(false, "Unexpected menu ID");
|
2008-04-27 09:03:01 +00:00
|
|
|
}
|
2016-04-02 13:34:17 +00:00
|
|
|
|
|
|
|
// Copy color from the previous mesh-contributing group.
|
|
|
|
if(g.IsMeshGroup() && SK.groupOrder.n > 0) {
|
2016-04-10 11:25:26 +00:00
|
|
|
Group *running = SK.GetRunningMeshGroupFor(SS.GW.activeGroup);
|
2016-04-02 13:34:17 +00:00
|
|
|
if(running != NULL) {
|
|
|
|
g.color = running->color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
SS.GW.ClearSelection();
|
2008-06-04 10:22:30 +00:00
|
|
|
SS.UndoRemember();
|
2008-06-30 09:09:17 +00:00
|
|
|
|
2016-02-17 10:31:15 +00:00
|
|
|
bool afterActive = false;
|
|
|
|
for(int i = 0; i < SK.groupOrder.n; i++) {
|
|
|
|
Group *gi = SK.GetGroup(SK.groupOrder.elem[i]);
|
|
|
|
if(afterActive)
|
|
|
|
gi->order += 1;
|
|
|
|
if(gi->h.v == SS.GW.activeGroup.v) {
|
|
|
|
g.order = gi->order + 1;
|
|
|
|
afterActive = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
SK.group.AddAndAssignId(&g);
|
|
|
|
Group *gg = SK.GetGroup(g.h);
|
2008-06-06 11:35:28 +00:00
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(gg->type == Type::LINKED) {
|
2008-05-29 10:10:12 +00:00
|
|
|
SS.ReloadAllImported();
|
|
|
|
}
|
2008-06-06 11:35:28 +00:00
|
|
|
gg->clean = false;
|
|
|
|
SS.GW.activeGroup = gg->h;
|
2008-06-02 09:31:26 +00:00
|
|
|
SS.GenerateAll();
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(gg->type == Type::DRAWING_WORKPLANE) {
|
2008-06-30 09:09:17 +00:00
|
|
|
// Can't set the active workplane for this one until after we've
|
|
|
|
// regenerated, because the workplane doesn't exist until then.
|
2008-06-06 11:35:28 +00:00
|
|
|
gg->activeWorkplane = gg->h.entity(0);
|
2008-05-11 10:40:37 +00:00
|
|
|
}
|
2008-06-06 11:35:28 +00:00
|
|
|
gg->Activate();
|
2008-05-27 02:22:20 +00:00
|
|
|
SS.GW.AnimateOntoWorkplane();
|
2008-06-06 11:35:28 +00:00
|
|
|
TextWindow::ScreenSelectGroup(0, gg->h.v);
|
2015-03-18 17:02:11 +00:00
|
|
|
SS.ScheduleShowTW();
|
2008-04-27 09:03:01 +00:00
|
|
|
}
|
|
|
|
|
2009-07-20 19:05:33 +00:00
|
|
|
void Group::TransformImportedBy(Vector t, Quaternion q) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
ssassert(type == Type::LINKED, "Expected a linked group");
|
2009-07-20 19:05:33 +00:00
|
|
|
|
|
|
|
hParam tx, ty, tz, qw, qx, qy, qz;
|
|
|
|
tx = h.param(0);
|
|
|
|
ty = h.param(1);
|
|
|
|
tz = h.param(2);
|
|
|
|
qw = h.param(3);
|
|
|
|
qx = h.param(4);
|
|
|
|
qy = h.param(5);
|
|
|
|
qz = h.param(6);
|
|
|
|
|
|
|
|
Quaternion qg = Quaternion::From(qw, qx, qy, qz);
|
|
|
|
qg = q.Times(qg);
|
2015-03-29 00:30:52 +00:00
|
|
|
|
2009-07-20 19:05:33 +00:00
|
|
|
Vector tg = Vector::From(tx, ty, tz);
|
|
|
|
tg = tg.Plus(t);
|
|
|
|
|
|
|
|
SK.GetParam(tx)->val = tg.x;
|
|
|
|
SK.GetParam(ty)->val = tg.y;
|
|
|
|
SK.GetParam(tz)->val = tg.z;
|
|
|
|
|
|
|
|
SK.GetParam(qw)->val = qg.w;
|
|
|
|
SK.GetParam(qx)->val = qg.vx;
|
|
|
|
SK.GetParam(qy)->val = qg.vy;
|
|
|
|
SK.GetParam(qz)->val = qg.vz;
|
|
|
|
}
|
|
|
|
|
2016-05-05 05:54:05 +00:00
|
|
|
std::string Group::DescriptionString() {
|
2015-11-06 08:40:12 +00:00
|
|
|
if(name.empty()) {
|
2017-01-07 06:41:13 +00:00
|
|
|
return ssprintf("g%03x-%s", h.v, _("(unnamed)"));
|
2008-04-12 14:12:26 +00:00
|
|
|
} else {
|
2015-11-06 08:40:12 +00:00
|
|
|
return ssprintf("g%03x-%s", h.v, name.c_str());
|
2008-04-12 14:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-05 05:54:05 +00:00
|
|
|
void Group::Activate() {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(type == Type::EXTRUDE || type == Type::LINKED || type == Type::LATHE ||
|
|
|
|
type == Type::TRANSLATE || type == Type::ROTATE) {
|
2008-06-02 05:38:12 +00:00
|
|
|
SS.GW.showFaces = true;
|
|
|
|
} else {
|
|
|
|
SS.GW.showFaces = false;
|
|
|
|
}
|
2008-06-02 11:43:27 +00:00
|
|
|
SS.MarkGroupDirty(h); // for good measure; shouldn't be needed
|
2015-03-18 17:02:11 +00:00
|
|
|
SS.ScheduleShowTW();
|
2008-06-02 05:38:12 +00:00
|
|
|
}
|
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
void Group::Generate(IdList<Entity,hEntity> *entity,
|
|
|
|
IdList<Param,hParam> *param)
|
|
|
|
{
|
2008-05-07 04:17:29 +00:00
|
|
|
Vector gn = (SS.GW.projRight).Cross(SS.GW.projUp);
|
2008-05-27 06:36:59 +00:00
|
|
|
Vector gp = SS.GW.projRight.Plus(SS.GW.projUp);
|
2008-06-01 08:29:59 +00:00
|
|
|
Vector gc = (SS.GW.offset).ScaledBy(-1);
|
2008-05-07 04:17:29 +00:00
|
|
|
gn = gn.WithMagnitude(200/SS.GW.scale);
|
2008-05-27 06:36:59 +00:00
|
|
|
gp = gp.WithMagnitude(200/SS.GW.scale);
|
|
|
|
int a, i;
|
2008-04-27 09:03:01 +00:00
|
|
|
switch(type) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Type::DRAWING_3D:
|
Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.
Moreover, we also change the switch statements in three ways:
* Switch statements that ought to be extended every time a new
enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
to explicitly list every single enumerand, and not have a
default: branch.
Note that the assertions are kept because it is legal for
a enumeration to have a value unlike any of its defined
enumerands, and we can e.g. read garbage from a file, or
an uninitialized variable. This requires some rearranging if
a default: branch is undesired.
* Switch statements that ought to only ever see a few select
enumerands, are changed to always assert in the default: branch.
* Switch statements that do something meaningful for a few
enumerands, and ignore everything else, are changed to do nothing
in a default: branch, under the assumption that changing them
every time an enumerand is added or removed would just result
in noise and catch no bugs.
This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-25 06:55:50 +00:00
|
|
|
return;
|
2008-05-11 10:40:37 +00:00
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Type::DRAWING_WORKPLANE: {
|
2008-05-11 10:40:37 +00:00
|
|
|
Quaternion q;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(subtype == Subtype::WORKPLANE_BY_LINE_SEGMENTS) {
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector u = SK.GetEntity(predef.entityB)->VectorGetNum();
|
|
|
|
Vector v = SK.GetEntity(predef.entityC)->VectorGetNum();
|
2008-05-11 10:40:37 +00:00
|
|
|
u = u.WithMagnitude(1);
|
|
|
|
Vector n = u.Cross(v);
|
|
|
|
v = (n.Cross(u)).WithMagnitude(1);
|
|
|
|
|
2015-03-27 15:43:28 +00:00
|
|
|
if(predef.swapUV) swap(u, v);
|
2008-06-01 08:29:59 +00:00
|
|
|
if(predef.negateU) u = u.ScaledBy(-1);
|
|
|
|
if(predef.negateV) v = v.ScaledBy(-1);
|
2008-06-01 08:45:11 +00:00
|
|
|
q = Quaternion::From(u, v);
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
} else if(subtype == Subtype::WORKPLANE_BY_POINT_ORTHO) {
|
2008-05-11 10:40:37 +00:00
|
|
|
// Already given, numerically.
|
2008-06-01 08:29:59 +00:00
|
|
|
q = predef.q;
|
2016-05-18 22:51:36 +00:00
|
|
|
} else ssassert(false, "Unexpected workplane subtype");
|
2008-05-11 10:40:37 +00:00
|
|
|
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity normal = {};
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
normal.type = Entity::Type::NORMAL_N_COPY;
|
2008-05-11 10:40:37 +00:00
|
|
|
normal.numNormal = q;
|
|
|
|
normal.point[0] = h.entity(2);
|
|
|
|
normal.group = h;
|
|
|
|
normal.h = h.entity(1);
|
|
|
|
entity->Add(&normal);
|
|
|
|
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity point = {};
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
point.type = Entity::Type::POINT_N_COPY;
|
2009-04-19 05:53:16 +00:00
|
|
|
point.numPoint = SK.GetEntity(predef.origin)->PointGetNum();
|
2016-10-31 14:22:33 +00:00
|
|
|
point.construction = true;
|
2008-05-11 10:40:37 +00:00
|
|
|
point.group = h;
|
|
|
|
point.h = h.entity(2);
|
|
|
|
entity->Add(&point);
|
|
|
|
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity wp = {};
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
wp.type = Entity::Type::WORKPLANE;
|
2008-05-11 10:40:37 +00:00
|
|
|
wp.normal = normal.h;
|
|
|
|
wp.point[0] = point.h;
|
|
|
|
wp.group = h;
|
|
|
|
wp.h = h.entity(0);
|
|
|
|
entity->Add(&wp);
|
Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.
Moreover, we also change the switch statements in three ways:
* Switch statements that ought to be extended every time a new
enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
to explicitly list every single enumerand, and not have a
default: branch.
Note that the assertions are kept because it is legal for
a enumeration to have a value unlike any of its defined
enumerands, and we can e.g. read garbage from a file, or
an uninitialized variable. This requires some rearranging if
a default: branch is undesired.
* Switch statements that ought to only ever see a few select
enumerands, are changed to always assert in the default: branch.
* Switch statements that do something meaningful for a few
enumerands, and ignore everything else, are changed to do nothing
in a default: branch, under the assumption that changing them
every time an enumerand is added or removed would just result
in noise and catch no bugs.
This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-25 06:55:50 +00:00
|
|
|
return;
|
2008-05-11 10:40:37 +00:00
|
|
|
}
|
2008-04-27 09:03:01 +00:00
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Type::EXTRUDE: {
|
2008-05-07 04:17:29 +00:00
|
|
|
AddParam(param, h.param(0), gn.x);
|
|
|
|
AddParam(param, h.param(1), gn.y);
|
|
|
|
AddParam(param, h.param(2), gn.z);
|
2008-05-17 08:02:39 +00:00
|
|
|
int ai, af;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(subtype == Subtype::ONE_SIDED) {
|
2008-05-27 06:36:59 +00:00
|
|
|
ai = 0; af = 2;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
} else if(subtype == Subtype::TWO_SIDED) {
|
2008-05-17 08:02:39 +00:00
|
|
|
ai = -1; af = 1;
|
2016-05-18 22:51:36 +00:00
|
|
|
} else ssassert(false, "Unexpected extrusion subtype");
|
2008-06-02 03:31:37 +00:00
|
|
|
|
|
|
|
// Get some arbitrary point in the sketch, that will be used
|
|
|
|
// as a reference when defining top and bottom faces.
|
|
|
|
hEntity pt = { 0 };
|
2008-04-27 09:03:01 +00:00
|
|
|
for(i = 0; i < entity->n; i++) {
|
|
|
|
Entity *e = &(entity->elem[i]);
|
|
|
|
if(e->group.v != opA.v) continue;
|
|
|
|
|
2008-06-02 03:31:37 +00:00
|
|
|
if(e->IsPoint()) pt = e->h;
|
|
|
|
|
2016-05-25 12:08:19 +00:00
|
|
|
e->CalculateNumerical(/*forExport=*/false);
|
2008-05-17 08:02:39 +00:00
|
|
|
hEntity he = e->h; e = NULL;
|
|
|
|
// As soon as I call CopyEntity, e may become invalid! That
|
|
|
|
// adds entities, which may cause a realloc.
|
2009-04-19 05:53:16 +00:00
|
|
|
CopyEntity(entity, SK.GetEntity(he), ai, REMAP_BOTTOM,
|
2008-05-11 06:09:46 +00:00
|
|
|
h.param(0), h.param(1), h.param(2),
|
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs::N_TRANS);
|
2009-04-19 05:53:16 +00:00
|
|
|
CopyEntity(entity, SK.GetEntity(he), af, REMAP_TOP,
|
2008-05-17 08:02:39 +00:00
|
|
|
h.param(0), h.param(1), h.param(2),
|
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs::N_TRANS);
|
2008-06-06 07:50:08 +00:00
|
|
|
MakeExtrusionLines(entity, he);
|
2008-05-11 06:09:46 +00:00
|
|
|
}
|
2008-06-02 03:31:37 +00:00
|
|
|
// Remapped versions of that arbitrary point will be used to
|
|
|
|
// provide points on the plane faces.
|
2008-06-06 07:50:08 +00:00
|
|
|
MakeExtrusionTopBottomFaces(entity, pt);
|
Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.
Moreover, we also change the switch statements in three ways:
* Switch statements that ought to be extended every time a new
enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
to explicitly list every single enumerand, and not have a
default: branch.
Note that the assertions are kept because it is legal for
a enumeration to have a value unlike any of its defined
enumerands, and we can e.g. read garbage from a file, or
an uninitialized variable. This requires some rearranging if
a default: branch is undesired.
* Switch statements that ought to only ever see a few select
enumerands, are changed to always assert in the default: branch.
* Switch statements that do something meaningful for a few
enumerands, and ignore everything else, are changed to do nothing
in a default: branch, under the assumption that changing them
every time an enumerand is added or removed would just result
in noise and catch no bugs.
This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-25 06:55:50 +00:00
|
|
|
return;
|
2008-06-02 03:31:37 +00:00
|
|
|
}
|
2008-05-11 06:09:46 +00:00
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Type::LATHE: {
|
2015-10-31 08:22:26 +00:00
|
|
|
Vector axis_pos = SK.GetEntity(predef.origin)->PointGetNum();
|
|
|
|
Vector axis_dir = SK.GetEntity(predef.entityB)->VectorGetNum();
|
|
|
|
|
|
|
|
// Remapped entity index.
|
|
|
|
int ai = 1;
|
|
|
|
|
|
|
|
for(i = 0; i < entity->n; i++) {
|
|
|
|
Entity *e = &(entity->elem[i]);
|
|
|
|
if(e->group.v != opA.v) continue;
|
|
|
|
|
2016-05-25 12:08:19 +00:00
|
|
|
e->CalculateNumerical(/*forExport=*/false);
|
2015-10-31 08:22:26 +00:00
|
|
|
hEntity he = e->h;
|
|
|
|
|
|
|
|
// As soon as I call CopyEntity, e may become invalid! That
|
|
|
|
// adds entities, which may cause a realloc.
|
|
|
|
CopyEntity(entity, SK.GetEntity(predef.origin), 0, ai,
|
2017-02-13 17:03:06 +00:00
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM,
|
2015-10-31 08:22:26 +00:00
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs::NUMERIC);
|
2015-10-31 08:22:26 +00:00
|
|
|
|
|
|
|
CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_START,
|
2017-02-13 17:03:06 +00:00
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM,
|
2015-10-31 08:22:26 +00:00
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs::NUMERIC);
|
2015-10-31 08:22:26 +00:00
|
|
|
|
|
|
|
CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_END,
|
2017-02-13 17:03:06 +00:00
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM,
|
2015-10-31 08:22:26 +00:00
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs::NUMERIC);
|
2015-10-31 08:22:26 +00:00
|
|
|
|
|
|
|
MakeLatheCircles(entity, param, he, axis_pos, axis_dir, ai);
|
|
|
|
ai++;
|
|
|
|
}
|
Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.
Moreover, we also change the switch statements in three ways:
* Switch statements that ought to be extended every time a new
enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
to explicitly list every single enumerand, and not have a
default: branch.
Note that the assertions are kept because it is legal for
a enumeration to have a value unlike any of its defined
enumerands, and we can e.g. read garbage from a file, or
an uninitialized variable. This requires some rearranging if
a default: branch is undesired.
* Switch statements that ought to only ever see a few select
enumerands, are changed to always assert in the default: branch.
* Switch statements that do something meaningful for a few
enumerands, and ignore everything else, are changed to do nothing
in a default: branch, under the assumption that changing them
every time an enumerand is added or removed would just result
in noise and catch no bugs.
This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-25 06:55:50 +00:00
|
|
|
return;
|
2008-06-06 11:35:28 +00:00
|
|
|
}
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Type::TRANSLATE: {
|
2016-10-11 16:46:42 +00:00
|
|
|
// inherit meshCombine from source group
|
|
|
|
Group *srcg = SK.GetGroup(opA);
|
|
|
|
meshCombine = srcg->meshCombine;
|
2008-05-27 06:36:59 +00:00
|
|
|
// The translation vector
|
|
|
|
AddParam(param, h.param(0), gp.x);
|
|
|
|
AddParam(param, h.param(1), gp.y);
|
|
|
|
AddParam(param, h.param(2), gp.z);
|
|
|
|
|
2008-06-14 08:43:38 +00:00
|
|
|
int n = (int)valA, a0 = 0;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(subtype == Subtype::ONE_SIDED && skipFirst) {
|
2008-06-12 04:36:33 +00:00
|
|
|
a0++; n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(a = a0; a < n; a++) {
|
2008-05-27 06:36:59 +00:00
|
|
|
for(i = 0; i < entity->n; i++) {
|
|
|
|
Entity *e = &(entity->elem[i]);
|
|
|
|
if(e->group.v != opA.v) continue;
|
|
|
|
|
2016-05-25 12:08:19 +00:00
|
|
|
e->CalculateNumerical(/*forExport=*/false);
|
2008-06-06 07:50:08 +00:00
|
|
|
CopyEntity(entity, e,
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
a*2 - (subtype == Subtype::ONE_SIDED ? 0 : (n-1)),
|
2008-06-01 08:29:59 +00:00
|
|
|
(a == (n - 1)) ? REMAP_LAST : a,
|
2008-05-27 06:36:59 +00:00
|
|
|
h.param(0), h.param(1), h.param(2),
|
|
|
|
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs::N_TRANS);
|
2008-05-27 06:36:59 +00:00
|
|
|
}
|
|
|
|
}
|
Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.
Moreover, we also change the switch statements in three ways:
* Switch statements that ought to be extended every time a new
enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
to explicitly list every single enumerand, and not have a
default: branch.
Note that the assertions are kept because it is legal for
a enumeration to have a value unlike any of its defined
enumerands, and we can e.g. read garbage from a file, or
an uninitialized variable. This requires some rearranging if
a default: branch is undesired.
* Switch statements that ought to only ever see a few select
enumerands, are changed to always assert in the default: branch.
* Switch statements that do something meaningful for a few
enumerands, and ignore everything else, are changed to do nothing
in a default: branch, under the assumption that changing them
every time an enumerand is added or removed would just result
in noise and catch no bugs.
This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-25 06:55:50 +00:00
|
|
|
return;
|
2008-05-27 06:36:59 +00:00
|
|
|
}
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Type::ROTATE: {
|
2016-10-11 16:46:42 +00:00
|
|
|
// inherit meshCombine from source group
|
|
|
|
Group *srcg = SK.GetGroup(opA);
|
|
|
|
meshCombine = srcg->meshCombine;
|
2008-06-01 08:29:59 +00:00
|
|
|
// The center of rotation
|
|
|
|
AddParam(param, h.param(0), gc.x);
|
|
|
|
AddParam(param, h.param(1), gc.y);
|
|
|
|
AddParam(param, h.param(2), gc.z);
|
2008-05-11 06:09:46 +00:00
|
|
|
// The rotation quaternion
|
2008-07-09 06:13:49 +00:00
|
|
|
AddParam(param, h.param(3), 30*PI/180);
|
2008-06-01 08:29:59 +00:00
|
|
|
AddParam(param, h.param(4), gn.x);
|
|
|
|
AddParam(param, h.param(5), gn.y);
|
|
|
|
AddParam(param, h.param(6), gn.z);
|
2008-05-11 06:09:46 +00:00
|
|
|
|
2008-06-14 08:43:38 +00:00
|
|
|
int n = (int)valA, a0 = 0;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(subtype == Subtype::ONE_SIDED && skipFirst) {
|
2008-06-12 04:36:33 +00:00
|
|
|
a0++; n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(a = a0; a < n; a++) {
|
2008-06-01 08:29:59 +00:00
|
|
|
for(i = 0; i < entity->n; i++) {
|
|
|
|
Entity *e = &(entity->elem[i]);
|
|
|
|
if(e->group.v != opA.v) continue;
|
2008-05-11 06:09:46 +00:00
|
|
|
|
2016-05-25 12:08:19 +00:00
|
|
|
e->CalculateNumerical(/*forExport=*/false);
|
2008-06-06 07:50:08 +00:00
|
|
|
CopyEntity(entity, e,
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
a*2 - (subtype == Subtype::ONE_SIDED ? 0 : (n-1)),
|
2008-06-01 08:29:59 +00:00
|
|
|
(a == (n - 1)) ? REMAP_LAST : a,
|
|
|
|
h.param(0), h.param(1), h.param(2),
|
|
|
|
h.param(3), h.param(4), h.param(5), h.param(6),
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs::N_ROT_AA);
|
2008-06-01 08:29:59 +00:00
|
|
|
}
|
2008-05-29 10:10:12 +00:00
|
|
|
}
|
Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.
Moreover, we also change the switch statements in three ways:
* Switch statements that ought to be extended every time a new
enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
to explicitly list every single enumerand, and not have a
default: branch.
Note that the assertions are kept because it is legal for
a enumeration to have a value unlike any of its defined
enumerands, and we can e.g. read garbage from a file, or
an uninitialized variable. This requires some rearranging if
a default: branch is undesired.
* Switch statements that ought to only ever see a few select
enumerands, are changed to always assert in the default: branch.
* Switch statements that do something meaningful for a few
enumerands, and ignore everything else, are changed to do nothing
in a default: branch, under the assumption that changing them
every time an enumerand is added or removed would just result
in noise and catch no bugs.
This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-25 06:55:50 +00:00
|
|
|
return;
|
2008-06-01 08:29:59 +00:00
|
|
|
}
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Type::LINKED:
|
2008-05-29 10:10:12 +00:00
|
|
|
// The translation vector
|
|
|
|
AddParam(param, h.param(0), gp.x);
|
|
|
|
AddParam(param, h.param(1), gp.y);
|
|
|
|
AddParam(param, h.param(2), gp.z);
|
|
|
|
// The rotation quaternion
|
|
|
|
AddParam(param, h.param(3), 1);
|
|
|
|
AddParam(param, h.param(4), 0);
|
|
|
|
AddParam(param, h.param(5), 0);
|
|
|
|
AddParam(param, h.param(6), 0);
|
2015-03-29 00:30:52 +00:00
|
|
|
|
2008-05-29 10:10:12 +00:00
|
|
|
for(i = 0; i < impEntity.n; i++) {
|
|
|
|
Entity *ie = &(impEntity.elem[i]);
|
2008-06-06 07:50:08 +00:00
|
|
|
CopyEntity(entity, ie, 0, 0,
|
2008-05-11 06:09:46 +00:00
|
|
|
h.param(0), h.param(1), h.param(2),
|
|
|
|
h.param(3), h.param(4), h.param(5), h.param(6),
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs::N_ROT_TRANS);
|
2008-04-27 09:03:01 +00:00
|
|
|
}
|
Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.
Moreover, we also change the switch statements in three ways:
* Switch statements that ought to be extended every time a new
enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
to explicitly list every single enumerand, and not have a
default: branch.
Note that the assertions are kept because it is legal for
a enumeration to have a value unlike any of its defined
enumerands, and we can e.g. read garbage from a file, or
an uninitialized variable. This requires some rearranging if
a default: branch is undesired.
* Switch statements that ought to only ever see a few select
enumerands, are changed to always assert in the default: branch.
* Switch statements that do something meaningful for a few
enumerands, and ignore everything else, are changed to do nothing
in a default: branch, under the assumption that changing them
every time an enumerand is added or removed would just result
in noise and catch no bugs.
This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-25 06:55:50 +00:00
|
|
|
return;
|
2008-04-27 09:03:01 +00:00
|
|
|
}
|
Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.
Moreover, we also change the switch statements in three ways:
* Switch statements that ought to be extended every time a new
enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
to explicitly list every single enumerand, and not have a
default: branch.
Note that the assertions are kept because it is legal for
a enumeration to have a value unlike any of its defined
enumerands, and we can e.g. read garbage from a file, or
an uninitialized variable. This requires some rearranging if
a default: branch is undesired.
* Switch statements that ought to only ever see a few select
enumerands, are changed to always assert in the default: branch.
* Switch statements that do something meaningful for a few
enumerands, and ignore everything else, are changed to do nothing
in a default: branch, under the assumption that changing them
every time an enumerand is added or removed would just result
in noise and catch no bugs.
This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-25 06:55:50 +00:00
|
|
|
ssassert(false, "Unexpected group type");
|
2008-04-27 09:03:01 +00:00
|
|
|
}
|
|
|
|
|
2016-01-21 15:01:43 +00:00
|
|
|
bool Group::IsSolvedOkay() {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
return this->solved.how == SolveResult::OKAY ||
|
|
|
|
(this->allowRedundant && this->solved.how == SolveResult::REDUNDANT_OKAY);
|
2016-01-21 15:01:43 +00:00
|
|
|
}
|
|
|
|
|
2008-06-01 08:29:59 +00:00
|
|
|
void Group::AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index) {
|
|
|
|
Equation eq;
|
|
|
|
eq.e = expr;
|
|
|
|
eq.h = h.equation(index);
|
|
|
|
l->Add(&eq);
|
|
|
|
}
|
|
|
|
|
2008-05-11 06:09:46 +00:00
|
|
|
void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(type == Type::LINKED) {
|
2008-05-11 06:09:46 +00:00
|
|
|
// Normalize the quaternion
|
|
|
|
ExprQuaternion q = {
|
2008-06-01 08:45:11 +00:00
|
|
|
Expr::From(h.param(3)),
|
|
|
|
Expr::From(h.param(4)),
|
|
|
|
Expr::From(h.param(5)),
|
|
|
|
Expr::From(h.param(6)) };
|
|
|
|
AddEq(l, (q.Magnitude())->Minus(Expr::From(1)), 0);
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
} else if(type == Type::ROTATE) {
|
2008-06-01 08:29:59 +00:00
|
|
|
// The axis and center of rotation are specified numerically
|
2008-06-01 08:45:11 +00:00
|
|
|
#define EC(x) (Expr::From(x))
|
|
|
|
#define EP(x) (Expr::From(h.param(x)))
|
2009-04-19 05:53:16 +00:00
|
|
|
ExprVector orig = SK.GetEntity(predef.origin)->PointGetExprs();
|
2008-06-13 05:32:55 +00:00
|
|
|
AddEq(l, (orig.x)->Minus(EP(0)), 0);
|
|
|
|
AddEq(l, (orig.y)->Minus(EP(1)), 1);
|
|
|
|
AddEq(l, (orig.z)->Minus(EP(2)), 2);
|
2008-06-01 08:29:59 +00:00
|
|
|
// param 3 is the angle, which is free
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector axis = SK.GetEntity(predef.entityB)->VectorGetNum();
|
2008-06-13 05:32:55 +00:00
|
|
|
axis = axis.WithMagnitude(1);
|
|
|
|
AddEq(l, (EC(axis.x))->Minus(EP(4)), 3);
|
|
|
|
AddEq(l, (EC(axis.y))->Minus(EP(5)), 4);
|
|
|
|
AddEq(l, (EC(axis.z))->Minus(EP(6)), 5);
|
2013-09-19 06:35:56 +00:00
|
|
|
#undef EC
|
|
|
|
#undef EP
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
} else if(type == Type::EXTRUDE) {
|
2008-06-01 08:29:59 +00:00
|
|
|
if(predef.entityB.v != Entity::FREE_IN_3D.v) {
|
2008-05-29 10:10:12 +00:00
|
|
|
// The extrusion path is locked along a line, normal to the
|
|
|
|
// specified workplane.
|
2009-04-19 05:53:16 +00:00
|
|
|
Entity *w = SK.GetEntity(predef.entityB);
|
2008-05-16 06:34:06 +00:00
|
|
|
ExprVector u = w->Normal()->NormalExprsU();
|
|
|
|
ExprVector v = w->Normal()->NormalExprsV();
|
|
|
|
ExprVector extruden = {
|
2008-06-01 08:45:11 +00:00
|
|
|
Expr::From(h.param(0)),
|
|
|
|
Expr::From(h.param(1)),
|
|
|
|
Expr::From(h.param(2)) };
|
2008-06-01 08:29:59 +00:00
|
|
|
|
|
|
|
AddEq(l, u.Dot(extruden), 0);
|
|
|
|
AddEq(l, v.Dot(extruden), 1);
|
2008-05-16 06:34:06 +00:00
|
|
|
}
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
} else if(type == Type::TRANSLATE) {
|
2008-06-12 04:36:33 +00:00
|
|
|
if(predef.entityB.v != Entity::FREE_IN_3D.v) {
|
2009-04-19 05:53:16 +00:00
|
|
|
Entity *w = SK.GetEntity(predef.entityB);
|
2008-06-12 04:36:33 +00:00
|
|
|
ExprVector n = w->Normal()->NormalExprsN();
|
|
|
|
ExprVector trans;
|
|
|
|
trans = ExprVector::From(h.param(0), h.param(1), h.param(2));
|
|
|
|
|
|
|
|
// The translation vector is parallel to the workplane
|
|
|
|
AddEq(l, trans.Dot(n), 0);
|
|
|
|
}
|
2008-05-11 06:09:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
hEntity Group::Remap(hEntity in, int copyNumber) {
|
2008-06-12 04:36:33 +00:00
|
|
|
// A hash table is used to accelerate the search
|
|
|
|
int hash = ((unsigned)(in.v*61 + copyNumber)) % REMAP_PRIME;
|
|
|
|
int i = remapCache[hash];
|
|
|
|
if(i >= 0 && i < remap.n) {
|
|
|
|
EntityMap *em = &(remap.elem[i]);
|
|
|
|
if(em->input.v == in.v && em->copyNumber == copyNumber) {
|
|
|
|
return h.entity(em->h.v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// but if we don't find it in the hash table, then linear search
|
2008-04-27 09:03:01 +00:00
|
|
|
for(i = 0; i < remap.n; i++) {
|
|
|
|
EntityMap *em = &(remap.elem[i]);
|
|
|
|
if(em->input.v == in.v && em->copyNumber == copyNumber) {
|
|
|
|
// We already have a mapping for this entity.
|
2008-06-12 04:36:33 +00:00
|
|
|
remapCache[hash] = i;
|
2008-04-27 09:03:01 +00:00
|
|
|
return h.entity(em->h.v);
|
|
|
|
}
|
|
|
|
}
|
2008-06-12 04:36:33 +00:00
|
|
|
// And if we still don't find it, then create a new entry.
|
2008-04-27 09:03:01 +00:00
|
|
|
EntityMap em;
|
|
|
|
em.input = in;
|
|
|
|
em.copyNumber = copyNumber;
|
|
|
|
remap.AddAndAssignId(&em);
|
|
|
|
return h.entity(em.h.v);
|
|
|
|
}
|
|
|
|
|
2008-06-06 07:50:08 +00:00
|
|
|
void Group::MakeExtrusionLines(IdList<Entity,hEntity> *el, hEntity in) {
|
2009-04-19 05:53:16 +00:00
|
|
|
Entity *ep = SK.GetEntity(in);
|
2008-05-17 08:02:39 +00:00
|
|
|
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity en = {};
|
2008-06-02 03:31:37 +00:00
|
|
|
if(ep->IsPoint()) {
|
|
|
|
// A point gets extruded to form a line segment
|
|
|
|
en.point[0] = Remap(ep->h, REMAP_TOP);
|
|
|
|
en.point[1] = Remap(ep->h, REMAP_BOTTOM);
|
|
|
|
en.group = h;
|
2009-09-22 05:46:30 +00:00
|
|
|
en.construction = ep->construction;
|
|
|
|
en.style = ep->style;
|
2008-06-02 03:31:37 +00:00
|
|
|
en.h = Remap(ep->h, REMAP_PT_TO_LINE);
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::LINE_SEGMENT;
|
2008-06-06 07:50:08 +00:00
|
|
|
el->Add(&en);
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
} else if(ep->type == Entity::Type::LINE_SEGMENT) {
|
2008-06-02 03:31:37 +00:00
|
|
|
// A line gets extruded to form a plane face; an endpoint of the
|
|
|
|
// original line is a point in the plane, and the line is in the plane.
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector a = SK.GetEntity(ep->point[0])->PointGetNum();
|
|
|
|
Vector b = SK.GetEntity(ep->point[1])->PointGetNum();
|
2008-06-02 03:31:37 +00:00
|
|
|
Vector ab = b.Minus(a);
|
|
|
|
|
|
|
|
en.param[0] = h.param(0);
|
|
|
|
en.param[1] = h.param(1);
|
|
|
|
en.param[2] = h.param(2);
|
|
|
|
en.numPoint = a;
|
2008-06-13 04:41:27 +00:00
|
|
|
en.numNormal = Quaternion::From(0, ab.x, ab.y, ab.z);
|
2008-06-02 03:31:37 +00:00
|
|
|
|
|
|
|
en.group = h;
|
2009-09-22 05:46:30 +00:00
|
|
|
en.construction = ep->construction;
|
|
|
|
en.style = ep->style;
|
2008-06-02 03:31:37 +00:00
|
|
|
en.h = Remap(ep->h, REMAP_LINE_TO_FACE);
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::FACE_XPROD;
|
2008-06-06 07:50:08 +00:00
|
|
|
el->Add(&en);
|
2008-06-02 03:31:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-31 08:22:26 +00:00
|
|
|
void Group::MakeLatheCircles(IdList<Entity,hEntity> *el, IdList<Param,hParam> *param, hEntity in, Vector pt, Vector axis, int ai) {
|
|
|
|
Entity *ep = SK.GetEntity(in);
|
|
|
|
|
|
|
|
Entity en = {};
|
|
|
|
if(ep->IsPoint()) {
|
|
|
|
// A point gets revolved to form an arc.
|
|
|
|
en.point[0] = Remap(predef.origin, ai);
|
|
|
|
en.point[1] = Remap(ep->h, REMAP_LATHE_START);
|
|
|
|
en.point[2] = Remap(ep->h, REMAP_LATHE_END);
|
|
|
|
|
|
|
|
// Get arc center and point on arc.
|
|
|
|
Entity *pc = SK.GetEntity(en.point[0]);
|
|
|
|
Entity *pp = SK.GetEntity(en.point[1]);
|
|
|
|
|
|
|
|
// Project arc point to the revolution axis and use it for arc center.
|
|
|
|
double k = pp->numPoint.Minus(pt).Dot(axis) / axis.Dot(axis);
|
|
|
|
pc->numPoint = pt.Plus(axis.ScaledBy(k));
|
|
|
|
|
|
|
|
// Create arc entity.
|
|
|
|
en.group = h;
|
|
|
|
en.construction = ep->construction;
|
|
|
|
en.style = ep->style;
|
|
|
|
en.h = Remap(ep->h, REMAP_PT_TO_ARC);
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::ARC_OF_CIRCLE;
|
2015-10-31 08:22:26 +00:00
|
|
|
|
|
|
|
// Generate a normal.
|
|
|
|
Entity n = {};
|
|
|
|
n.workplane = en.workplane;
|
|
|
|
n.h = Remap(ep->h, REMAP_PT_TO_NORMAL);
|
|
|
|
n.group = en.group;
|
|
|
|
n.style = en.style;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
n.type = Entity::Type::NORMAL_N_COPY;
|
2015-10-31 08:22:26 +00:00
|
|
|
|
|
|
|
// Create basis for the normal.
|
|
|
|
Vector nu = pp->numPoint.Minus(pc->numPoint).WithMagnitude(1.0);
|
|
|
|
Vector nv = nu.Cross(axis).WithMagnitude(1.0);
|
|
|
|
n.numNormal = Quaternion::From(nv, nu);
|
|
|
|
|
|
|
|
// The point determines where the normal gets displayed on-screen;
|
|
|
|
// it's entirely cosmetic.
|
|
|
|
n.point[0] = en.point[0];
|
|
|
|
el->Add(&n);
|
|
|
|
en.normal = n.h;
|
|
|
|
el->Add(&en);
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
} else if(ep->type == Entity::Type::LINE_SEGMENT) {
|
2015-10-31 08:22:26 +00:00
|
|
|
// An axis-perpendicular line gets revolved to form a face.
|
|
|
|
Vector a = SK.GetEntity(ep->point[0])->PointGetNum();
|
|
|
|
Vector b = SK.GetEntity(ep->point[1])->PointGetNum();
|
|
|
|
Vector u = b.Minus(a).WithMagnitude(1.0);
|
|
|
|
|
|
|
|
// Check for perpendicularity: calculate cosine of the angle
|
|
|
|
// between axis and line direction and check that
|
|
|
|
// cos(angle) == 0 <-> angle == +-90 deg.
|
|
|
|
if(fabs(u.Dot(axis) / axis.Magnitude()) < ANGLE_COS_EPS) {
|
|
|
|
en.param[0] = h.param(0);
|
|
|
|
en.param[1] = h.param(1);
|
|
|
|
en.param[2] = h.param(2);
|
|
|
|
Vector v = axis.Cross(u).WithMagnitude(1.0);
|
|
|
|
Vector n = u.Cross(v);
|
|
|
|
en.numNormal = Quaternion::From(0, n.x, n.y, n.z);
|
|
|
|
|
|
|
|
en.group = h;
|
|
|
|
en.construction = ep->construction;
|
|
|
|
en.style = ep->style;
|
|
|
|
en.h = Remap(ep->h, REMAP_LINE_TO_FACE);
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::FACE_NORMAL_PT;
|
2015-10-31 08:22:26 +00:00
|
|
|
en.point[0] = ep->point[0];
|
|
|
|
el->Add(&en);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-06 07:50:08 +00:00
|
|
|
void Group::MakeExtrusionTopBottomFaces(IdList<Entity,hEntity> *el, hEntity pt)
|
|
|
|
{
|
2008-06-02 03:31:37 +00:00
|
|
|
if(pt.v == 0) return;
|
2009-04-19 05:53:16 +00:00
|
|
|
Group *src = SK.GetGroup(opA);
|
2009-10-29 07:16:28 +00:00
|
|
|
Vector n = src->polyLoops.normal;
|
2008-06-02 03:31:37 +00:00
|
|
|
|
2017-02-15 03:43:57 +00:00
|
|
|
// When there is no loop normal (e.g. if the loop is broken), use normal of workplane
|
|
|
|
// as fallback, to avoid breaking constraints depending on the faces.
|
|
|
|
if(n.Equals(Vector::From(0.0, 0.0, 0.0)) && src->type == Group::Type::DRAWING_WORKPLANE) {
|
|
|
|
n = SK.GetEntity(src->h.entity(0))->Normal()->NormalN();
|
|
|
|
}
|
|
|
|
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity en = {};
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::FACE_NORMAL_PT;
|
2008-05-17 08:02:39 +00:00
|
|
|
en.group = h;
|
2008-06-02 03:31:37 +00:00
|
|
|
|
|
|
|
en.numNormal = Quaternion::From(0, n.x, n.y, n.z);
|
|
|
|
en.point[0] = Remap(pt, REMAP_TOP);
|
|
|
|
en.h = Remap(Entity::NO_ENTITY, REMAP_TOP);
|
2008-06-06 07:50:08 +00:00
|
|
|
el->Add(&en);
|
2008-06-02 03:31:37 +00:00
|
|
|
|
|
|
|
en.point[0] = Remap(pt, REMAP_BOTTOM);
|
|
|
|
en.h = Remap(Entity::NO_ENTITY, REMAP_BOTTOM);
|
2008-06-06 07:50:08 +00:00
|
|
|
el->Add(&en);
|
2008-05-17 08:02:39 +00:00
|
|
|
}
|
|
|
|
|
2008-06-06 07:50:08 +00:00
|
|
|
void Group::CopyEntity(IdList<Entity,hEntity> *el,
|
|
|
|
Entity *ep, int timesApplied, int remap,
|
2008-06-01 08:29:59 +00:00
|
|
|
hParam dx, hParam dy, hParam dz,
|
2008-05-11 06:09:46 +00:00
|
|
|
hParam qw, hParam qvx, hParam qvy, hParam qvz,
|
2017-02-13 17:03:06 +00:00
|
|
|
CopyAs as)
|
2008-05-05 06:18:01 +00:00
|
|
|
{
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity en = {};
|
2008-04-27 09:03:01 +00:00
|
|
|
en.type = ep->type;
|
2009-10-21 04:46:01 +00:00
|
|
|
en.extraPoints = ep->extraPoints;
|
2008-06-01 08:29:59 +00:00
|
|
|
en.h = Remap(ep->h, remap);
|
|
|
|
en.timesApplied = timesApplied;
|
2008-04-27 09:03:01 +00:00
|
|
|
en.group = h;
|
2008-05-25 14:36:03 +00:00
|
|
|
en.construction = ep->construction;
|
2009-09-22 05:46:30 +00:00
|
|
|
en.style = ep->style;
|
2015-11-06 08:40:12 +00:00
|
|
|
en.str = ep->str;
|
|
|
|
en.font = ep->font;
|
2008-04-27 09:03:01 +00:00
|
|
|
|
|
|
|
switch(ep->type) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Entity::Type::WORKPLANE:
|
2008-04-27 09:03:01 +00:00
|
|
|
// Don't copy these.
|
|
|
|
return;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Entity::Type::POINT_N_COPY:
|
|
|
|
case Entity::Type::POINT_N_TRANS:
|
|
|
|
case Entity::Type::POINT_N_ROT_TRANS:
|
|
|
|
case Entity::Type::POINT_N_ROT_AA:
|
|
|
|
case Entity::Type::POINT_IN_3D:
|
|
|
|
case Entity::Type::POINT_IN_2D:
|
2017-02-13 17:03:06 +00:00
|
|
|
if(as == CopyAs::N_TRANS) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::POINT_N_TRANS;
|
2008-05-11 06:09:46 +00:00
|
|
|
en.param[0] = dx;
|
|
|
|
en.param[1] = dy;
|
|
|
|
en.param[2] = dz;
|
2017-02-13 17:03:06 +00:00
|
|
|
} else if(as == CopyAs::NUMERIC) {
|
|
|
|
en.type = Entity::Type::POINT_N_COPY;
|
2008-05-11 06:09:46 +00:00
|
|
|
} else {
|
2017-02-13 17:03:06 +00:00
|
|
|
if(as == CopyAs::N_ROT_AA) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::POINT_N_ROT_AA;
|
2008-06-01 08:29:59 +00:00
|
|
|
} else {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::POINT_N_ROT_TRANS;
|
2008-06-01 08:29:59 +00:00
|
|
|
}
|
2008-05-11 06:09:46 +00:00
|
|
|
en.param[0] = dx;
|
|
|
|
en.param[1] = dy;
|
|
|
|
en.param[2] = dz;
|
|
|
|
en.param[3] = qw;
|
|
|
|
en.param[4] = qvx;
|
|
|
|
en.param[5] = qvy;
|
|
|
|
en.param[6] = qvz;
|
2008-05-05 06:18:01 +00:00
|
|
|
}
|
2009-12-15 12:26:22 +00:00
|
|
|
en.numPoint = (ep->actPoint).ScaledBy(scale);
|
2008-05-05 06:18:01 +00:00
|
|
|
break;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Entity::Type::NORMAL_N_COPY:
|
|
|
|
case Entity::Type::NORMAL_N_ROT:
|
|
|
|
case Entity::Type::NORMAL_N_ROT_AA:
|
|
|
|
case Entity::Type::NORMAL_IN_3D:
|
|
|
|
case Entity::Type::NORMAL_IN_2D:
|
2017-02-13 17:03:06 +00:00
|
|
|
if(as == CopyAs::N_TRANS || as == CopyAs::NUMERIC) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::NORMAL_N_COPY;
|
2008-05-11 06:09:46 +00:00
|
|
|
} else {
|
2017-02-13 17:03:06 +00:00
|
|
|
if(as == CopyAs::N_ROT_AA) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::NORMAL_N_ROT_AA;
|
2008-06-01 08:29:59 +00:00
|
|
|
} else {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::NORMAL_N_ROT;
|
2008-06-01 08:29:59 +00:00
|
|
|
}
|
2008-05-11 06:09:46 +00:00
|
|
|
en.param[0] = qw;
|
|
|
|
en.param[1] = qvx;
|
|
|
|
en.param[2] = qvy;
|
|
|
|
en.param[3] = qvz;
|
|
|
|
}
|
2008-05-29 10:10:12 +00:00
|
|
|
en.numNormal = ep->actNormal;
|
2009-12-15 12:26:22 +00:00
|
|
|
if(scale < 0) en.numNormal = en.numNormal.Mirror();
|
2009-10-09 12:57:10 +00:00
|
|
|
|
2008-06-01 08:29:59 +00:00
|
|
|
en.point[0] = Remap(ep->point[0], remap);
|
2008-04-27 09:03:01 +00:00
|
|
|
break;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Entity::Type::DISTANCE_N_COPY:
|
|
|
|
case Entity::Type::DISTANCE:
|
|
|
|
en.type = Entity::Type::DISTANCE_N_COPY;
|
2009-12-15 12:26:22 +00:00
|
|
|
en.numDistance = ep->actDistance*fabs(scale);
|
2008-05-07 08:19:37 +00:00
|
|
|
break;
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
case Entity::Type::FACE_NORMAL_PT:
|
|
|
|
case Entity::Type::FACE_XPROD:
|
|
|
|
case Entity::Type::FACE_N_ROT_TRANS:
|
|
|
|
case Entity::Type::FACE_N_TRANS:
|
|
|
|
case Entity::Type::FACE_N_ROT_AA:
|
2017-02-13 17:03:06 +00:00
|
|
|
if(as == CopyAs::N_TRANS) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::FACE_N_TRANS;
|
2008-06-21 22:49:57 +00:00
|
|
|
en.param[0] = dx;
|
|
|
|
en.param[1] = dy;
|
|
|
|
en.param[2] = dz;
|
2017-02-13 17:03:06 +00:00
|
|
|
} else if (as == CopyAs::NUMERIC) {
|
|
|
|
en.type = Entity::Type::FACE_NORMAL_PT;
|
2008-06-21 22:49:57 +00:00
|
|
|
} else {
|
2017-02-13 17:03:06 +00:00
|
|
|
if(as == CopyAs::N_ROT_AA) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::FACE_N_ROT_AA;
|
2008-06-21 22:49:57 +00:00
|
|
|
} else {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
en.type = Entity::Type::FACE_N_ROT_TRANS;
|
2008-06-21 22:49:57 +00:00
|
|
|
}
|
|
|
|
en.param[0] = dx;
|
|
|
|
en.param[1] = dy;
|
|
|
|
en.param[2] = dz;
|
|
|
|
en.param[3] = qw;
|
|
|
|
en.param[4] = qvx;
|
|
|
|
en.param[5] = qvy;
|
|
|
|
en.param[6] = qvz;
|
|
|
|
}
|
2009-12-15 12:26:22 +00:00
|
|
|
en.numPoint = (ep->actPoint).ScaledBy(scale);
|
|
|
|
en.numNormal = (ep->actNormal).ScaledBy(scale);
|
2008-06-02 03:31:37 +00:00
|
|
|
break;
|
|
|
|
|
2009-10-22 14:02:08 +00:00
|
|
|
default: {
|
|
|
|
int i, points;
|
|
|
|
bool hasNormal, hasDistance;
|
|
|
|
EntReqTable::GetEntityInfo(ep->type, ep->extraPoints,
|
|
|
|
NULL, &points, &hasNormal, &hasDistance);
|
|
|
|
for(i = 0; i < points; i++) {
|
|
|
|
en.point[i] = Remap(ep->point[i], remap);
|
|
|
|
}
|
|
|
|
if(hasNormal) en.normal = Remap(ep->normal, remap);
|
|
|
|
if(hasDistance) en.distance = Remap(ep->distance, remap);
|
|
|
|
break;
|
|
|
|
}
|
2008-04-27 09:03:01 +00:00
|
|
|
}
|
2009-06-14 04:36:38 +00:00
|
|
|
|
2016-05-07 05:27:54 +00:00
|
|
|
// If the entity came from an linked file where it was invisible then
|
2009-06-14 04:36:38 +00:00
|
|
|
// ep->actiVisble will be false, and we should hide it. Or if the entity
|
2016-05-07 05:27:54 +00:00
|
|
|
// came from a copy (e.g. step and repeat) of a force-hidden linked
|
2009-06-14 04:36:38 +00:00
|
|
|
// entity, then we also want to hide it.
|
|
|
|
en.forceHidden = (!ep->actVisible) || ep->forceHidden;
|
2008-06-13 04:41:27 +00:00
|
|
|
|
2008-06-06 07:50:08 +00:00
|
|
|
el->Add(&en);
|
2008-04-27 09:03:01 +00:00
|
|
|
}
|
|
|
|
|