2013-07-28 22:08:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Routines to generate our watertight brep shells from the operations
|
|
|
|
// and entities specified by the user in each group; templated to work either
|
|
|
|
// on an SShell of ratpoly surfaces or on an SMesh of triangles.
|
|
|
|
//
|
|
|
|
// Copyright 2008-2013 Jonathan Westhues.
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-06-06 08:14:37 +00:00
|
|
|
#include "solvespace.h"
|
|
|
|
|
2009-12-03 19:14:34 +00:00
|
|
|
void Group::AssembleLoops(bool *allClosed,
|
|
|
|
bool *allCoplanar,
|
|
|
|
bool *allNonZeroLen)
|
|
|
|
{
|
2015-03-27 15:31:23 +00:00
|
|
|
SBezierList sbl = {};
|
2009-01-19 03:33:15 +00:00
|
|
|
|
2008-02-10 12:43:48 +00:00
|
|
|
int i;
|
2009-04-19 05:53:16 +00:00
|
|
|
for(i = 0; i < SK.entity.n; i++) {
|
|
|
|
Entity *e = &(SK.entity.elem[i]);
|
2019-07-09 14:44:57 +00:00
|
|
|
if(e->group != h) continue;
|
2009-01-19 03:33:15 +00:00
|
|
|
if(e->construction) continue;
|
2009-06-14 04:36:38 +00:00
|
|
|
if(e->forceHidden) continue;
|
2008-02-10 12:43:48 +00:00
|
|
|
|
2009-01-19 03:51:00 +00:00
|
|
|
e->GenerateBezierCurves(&sbl);
|
2008-02-10 12:43:48 +00:00
|
|
|
}
|
2009-01-19 03:33:15 +00:00
|
|
|
|
2009-12-03 19:14:34 +00:00
|
|
|
SBezier *sb;
|
|
|
|
*allNonZeroLen = true;
|
|
|
|
for(sb = sbl.l.First(); sb; sb = sbl.l.NextAfter(sb)) {
|
|
|
|
for(i = 1; i <= sb->deg; i++) {
|
|
|
|
if(!(sb->ctrl[i]).Equals(sb->ctrl[0])) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(i > sb->deg) {
|
|
|
|
// This is a zero-length edge.
|
|
|
|
*allNonZeroLen = false;
|
|
|
|
polyError.errorPointAt = sb->ctrl[0];
|
2013-09-19 04:33:12 +00:00
|
|
|
goto done;
|
2009-12-03 19:14:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-29 07:16:28 +00:00
|
|
|
// Try to assemble all these Beziers into loops. The closed loops go into
|
|
|
|
// bezierLoops, with the outer loops grouped with their holes. The
|
|
|
|
// leftovers, if any, go in bezierOpens.
|
|
|
|
bezierLoops.FindOuterFacesFrom(&sbl, &polyLoops, NULL,
|
|
|
|
SS.ChordTolMm(),
|
|
|
|
allClosed, &(polyError.notClosedAt),
|
|
|
|
allCoplanar, &(polyError.errorPointAt),
|
|
|
|
&bezierOpens);
|
2013-09-19 04:33:12 +00:00
|
|
|
done:
|
2009-01-19 03:51:00 +00:00
|
|
|
sbl.Clear();
|
2008-02-10 12:43:48 +00:00
|
|
|
}
|
|
|
|
|
2016-05-05 05:54:05 +00:00
|
|
|
void Group::GenerateLoops() {
|
2009-10-29 07:16:28 +00:00
|
|
|
polyLoops.Clear();
|
|
|
|
bezierLoops.Clear();
|
|
|
|
bezierOpens.Clear();
|
2008-06-06 08:14: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
|
|
|
if(type == Type::DRAWING_3D || type == Type::DRAWING_WORKPLANE ||
|
|
|
|
type == Type::ROTATE || type == Type::TRANSLATE || type == Type::LINKED)
|
2008-06-06 08:14:37 +00:00
|
|
|
{
|
2013-09-16 20:22:14 +00:00
|
|
|
bool allClosed = false, allCoplanar = false, allNonZeroLen = false;
|
2009-12-03 19:14:34 +00:00
|
|
|
AssembleLoops(&allClosed, &allCoplanar, &allNonZeroLen);
|
2016-04-17 01:33:15 +00:00
|
|
|
if(!allNonZeroLen) {
|
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
|
|
|
polyError.how = PolyError::ZERO_LEN_EDGE;
|
2016-04-17 01:33:15 +00:00
|
|
|
} else if(!allCoplanar) {
|
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
|
|
|
polyError.how = PolyError::NOT_COPLANAR;
|
2009-10-29 07:16:28 +00:00
|
|
|
} else if(!allClosed) {
|
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
|
|
|
polyError.how = PolyError::NOT_CLOSED;
|
2009-10-29 07:16:28 +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
|
|
|
polyError.how = PolyError::GOOD;
|
2009-10-29 07:16:28 +00:00
|
|
|
// The self-intersecting check is kind of slow, so don't run it
|
|
|
|
// unless requested.
|
|
|
|
if(SS.checkClosedContour) {
|
|
|
|
if(polyLoops.SelfIntersecting(&(polyError.errorPointAt))) {
|
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
|
|
|
polyError.how = PolyError::SELF_INTERSECTING;
|
2009-10-29 07:16:28 +00:00
|
|
|
}
|
2009-01-23 03:30:30 +00:00
|
|
|
}
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-24 11:37:07 +00:00
|
|
|
void SShell::RemapFaces(Group *g, int remap) {
|
|
|
|
SSurface *ss;
|
|
|
|
for(ss = surface.First(); ss; ss = surface.NextAfter(ss)){
|
|
|
|
hEntity face = { ss->face };
|
2019-07-09 14:44:57 +00:00
|
|
|
if(face == Entity::NO_ENTITY) continue;
|
2009-05-24 11:37:07 +00:00
|
|
|
|
|
|
|
face = g->Remap(face, remap);
|
|
|
|
ss->face = face.v;
|
|
|
|
}
|
|
|
|
}
|
2008-06-21 22:49:57 +00:00
|
|
|
|
2009-05-24 11:37:07 +00:00
|
|
|
void SMesh::RemapFaces(Group *g, int remap) {
|
|
|
|
STriangle *tr;
|
|
|
|
for(tr = l.First(); tr; tr = l.NextAfter(tr)) {
|
|
|
|
hEntity face = { tr->meta.face };
|
2019-07-09 14:44:57 +00:00
|
|
|
if(face == Entity::NO_ENTITY) continue;
|
2009-05-24 11:37:07 +00:00
|
|
|
|
|
|
|
face = g->Remap(face, remap);
|
|
|
|
tr->meta.face = face.v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
2016-05-03 07:44:10 +00:00
|
|
|
void Group::GenerateForStepAndRepeat(T *steps, T *outs, Group::CombineAs forWhat) {
|
2009-05-24 11:37:07 +00:00
|
|
|
T workA, workB;
|
2015-03-27 15:31:23 +00:00
|
|
|
workA = {};
|
|
|
|
workB = {};
|
2009-05-24 11:37:07 +00:00
|
|
|
T *soFar = &workA, *scratch = &workB;
|
2009-03-15 23:04:45 +00:00
|
|
|
|
2008-06-21 22:49:57 +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-21 22:49:57 +00:00
|
|
|
a0++; n++;
|
|
|
|
}
|
|
|
|
int a;
|
|
|
|
for(a = a0; a < n; a++) {
|
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
|
|
|
int ap = a*2 - (subtype == Subtype::ONE_SIDED ? 0 : (n-1));
|
2008-06-21 22:49:57 +00:00
|
|
|
int remap = (a == (n - 1)) ? REMAP_LAST : a;
|
|
|
|
|
2015-03-27 15:31:23 +00:00
|
|
|
T transd = {};
|
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::TRANSLATE) {
|
2008-06-21 22:49:57 +00:00
|
|
|
Vector trans = Vector::From(h.param(0), h.param(1), h.param(2));
|
|
|
|
trans = trans.ScaledBy(ap);
|
2009-10-09 12:57:10 +00:00
|
|
|
transd.MakeFromTransformationOf(steps,
|
2009-12-15 12:26:22 +00:00
|
|
|
trans, Quaternion::IDENTITY, 1.0);
|
2008-06-21 22:49:57 +00:00
|
|
|
} else {
|
|
|
|
Vector trans = Vector::From(h.param(0), h.param(1), h.param(2));
|
2009-04-19 05:53:16 +00:00
|
|
|
double theta = ap * SK.GetParam(h.param(3))->val;
|
2008-06-21 22:49:57 +00:00
|
|
|
double c = cos(theta), s = sin(theta);
|
|
|
|
Vector axis = Vector::From(h.param(4), h.param(5), h.param(6));
|
|
|
|
Quaternion q = Quaternion::From(c, s*axis.x, s*axis.y, s*axis.z);
|
2009-03-15 23:04:45 +00:00
|
|
|
// Rotation is centered at t; so A(x - t) + t = Ax + (t - At)
|
2009-05-24 11:37:07 +00:00
|
|
|
transd.MakeFromTransformationOf(steps,
|
2009-12-15 12:26:22 +00:00
|
|
|
trans.Minus(q.Rotate(trans)), q, 1.0);
|
2008-06-21 22:49:57 +00:00
|
|
|
}
|
|
|
|
|
2009-03-16 05:11:06 +00:00
|
|
|
// We need to rewrite any plane face entities to the transformed ones.
|
2009-05-24 11:37:07 +00:00
|
|
|
transd.RemapFaces(this, remap);
|
2009-03-16 05:11:06 +00:00
|
|
|
|
2009-07-20 01:47:59 +00:00
|
|
|
// And tack this transformed copy on to the return.
|
|
|
|
if(soFar->IsEmpty()) {
|
|
|
|
scratch->MakeFromCopyOf(&transd);
|
2016-05-03 07:44:10 +00:00
|
|
|
} else if (forWhat == CombineAs::ASSEMBLE) {
|
|
|
|
scratch->MakeFromAssemblyOf(soFar, &transd);
|
2009-05-20 03:04:36 +00:00
|
|
|
} else {
|
2009-07-20 01:47:59 +00:00
|
|
|
scratch->MakeFromUnionOf(soFar, &transd);
|
2008-06-21 22:49:57 +00:00
|
|
|
}
|
2009-03-15 23:04:45 +00:00
|
|
|
|
2015-03-27 15:43:28 +00:00
|
|
|
swap(scratch, soFar);
|
2009-03-15 23:04:45 +00:00
|
|
|
scratch->Clear();
|
|
|
|
transd.Clear();
|
2008-06-21 22:49:57 +00:00
|
|
|
}
|
2009-03-15 23:04:45 +00:00
|
|
|
|
2009-05-24 11:37:07 +00:00
|
|
|
outs->Clear();
|
|
|
|
*outs = *soFar;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
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::GenerateForBoolean(T *prevs, T *thiss, T *outs, Group::CombineAs how) {
|
2009-05-24 11:37:07 +00:00
|
|
|
// If this group contributes no new mesh, then our running mesh is the
|
|
|
|
// same as last time, no combining required. Likewise if we have a mesh
|
|
|
|
// but it's suppressed.
|
|
|
|
if(thiss->IsEmpty() || suppress) {
|
|
|
|
outs->MakeFromCopyOf(prevs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// So our group's shell appears in thisShell. Combine this with the
|
|
|
|
// previous group's shell, using the requested operation.
|
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(how == CombineAs::UNION) {
|
2009-05-24 11:37:07 +00:00
|
|
|
outs->MakeFromUnionOf(prevs, thiss);
|
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(how == CombineAs::DIFFERENCE) {
|
2009-05-24 11:37:07 +00:00
|
|
|
outs->MakeFromDifferenceOf(prevs, thiss);
|
|
|
|
} else {
|
|
|
|
outs->MakeFromAssemblyOf(prevs, thiss);
|
|
|
|
}
|
2008-06-21 22:49:57 +00:00
|
|
|
}
|
|
|
|
|
2016-05-05 05:54:05 +00:00
|
|
|
void Group::GenerateShellAndMesh() {
|
2009-05-30 08:49:09 +00:00
|
|
|
bool prevBooleanFailed = booleanFailed;
|
|
|
|
booleanFailed = false;
|
|
|
|
|
2009-07-20 01:47:59 +00:00
|
|
|
Group *srcg = this;
|
|
|
|
|
2009-01-19 10:37:10 +00:00
|
|
|
thisShell.Clear();
|
2009-05-24 11:37:07 +00:00
|
|
|
thisMesh.Clear();
|
|
|
|
runningShell.Clear();
|
|
|
|
runningMesh.Clear();
|
2008-06-21 10:18:20 +00:00
|
|
|
|
2009-10-29 07:16:28 +00:00
|
|
|
// Don't attempt a lathe or extrusion unless the source section is good:
|
|
|
|
// planar and not self-intersecting.
|
|
|
|
bool haveSrc = true;
|
2019-04-14 20:05:50 +00:00
|
|
|
if(type == Type::EXTRUDE || type == Type::LATHE || type == Type::REVOLVE) {
|
2009-10-29 07:16:28 +00:00
|
|
|
Group *src = SK.GetGroup(opA);
|
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(src->polyError.how != PolyError::GOOD) {
|
2009-10-29 07:16:28 +00:00
|
|
|
haveSrc = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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::TRANSLATE || type == Type::ROTATE) {
|
2018-07-12 05:05:43 +00:00
|
|
|
// A step and repeat gets merged against the group's previous group,
|
2009-07-20 01:47:59 +00:00
|
|
|
// not our own previous group.
|
|
|
|
srcg = SK.GetGroup(opA);
|
2009-05-24 11:37:07 +00:00
|
|
|
|
2016-10-09 13:26:58 +00:00
|
|
|
if(!srcg->suppress) {
|
2017-03-21 15:47:59 +00:00
|
|
|
if(!IsForcedToMesh()) {
|
|
|
|
GenerateForStepAndRepeat<SShell>(&(srcg->thisShell), &thisShell, srcg->meshCombine);
|
|
|
|
} else {
|
|
|
|
SMesh prevm = {};
|
|
|
|
prevm.MakeFromCopyOf(&srcg->thisMesh);
|
|
|
|
srcg->thisShell.TriangulateInto(&prevm);
|
|
|
|
GenerateForStepAndRepeat<SMesh> (&prevm, &thisMesh, srcg->meshCombine);
|
|
|
|
}
|
2016-10-09 13:26:58 +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::EXTRUDE && haveSrc) {
|
2009-04-19 05:53:16 +00:00
|
|
|
Group *src = SK.GetGroup(opA);
|
2008-06-06 08:14:37 +00:00
|
|
|
Vector translate = Vector::From(h.param(0), h.param(1), h.param(2));
|
|
|
|
|
|
|
|
Vector tbot, ttop;
|
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-06-06 08:14:37 +00:00
|
|
|
tbot = Vector::From(0, 0, 0); ttop = translate.ScaledBy(2);
|
|
|
|
} else {
|
|
|
|
tbot = translate.ScaledBy(-1); ttop = translate.ScaledBy(1);
|
|
|
|
}
|
2015-03-29 00:30:52 +00:00
|
|
|
|
2009-10-29 07:16:28 +00:00
|
|
|
SBezierLoopSetSet *sblss = &(src->bezierLoops);
|
|
|
|
SBezierLoopSet *sbls;
|
|
|
|
for(sbls = sblss->l.First(); sbls; sbls = sblss->l.NextAfter(sbls)) {
|
|
|
|
int is = thisShell.surface.n;
|
|
|
|
// Extrude this outer contour (plus its inner contours, if present)
|
|
|
|
thisShell.MakeFromExtrusionOf(sbls, tbot, ttop, color);
|
|
|
|
|
|
|
|
// And for any plane faces, annotate the model with the entity for
|
|
|
|
// that face, so that the user can select them with the mouse.
|
|
|
|
Vector onOrig = sbls->point;
|
|
|
|
int i;
|
|
|
|
for(i = is; i < thisShell.surface.n; i++) {
|
|
|
|
SSurface *ss = &(thisShell.surface.elem[i]);
|
|
|
|
hEntity face = Entity::NO_ENTITY;
|
|
|
|
|
|
|
|
Vector p = ss->PointAt(0, 0),
|
|
|
|
n = ss->NormalAt(0, 0).WithMagnitude(1);
|
|
|
|
double d = n.Dot(p);
|
|
|
|
|
|
|
|
if(i == is || i == (is + 1)) {
|
|
|
|
// These are the top and bottom of the shell.
|
|
|
|
if(fabs((onOrig.Plus(ttop)).Dot(n) - d) < LENGTH_EPS) {
|
|
|
|
face = Remap(Entity::NO_ENTITY, REMAP_TOP);
|
|
|
|
ss->face = face.v;
|
|
|
|
}
|
|
|
|
if(fabs((onOrig.Plus(tbot)).Dot(n) - d) < LENGTH_EPS) {
|
|
|
|
face = Remap(Entity::NO_ENTITY, REMAP_BOTTOM);
|
|
|
|
ss->face = face.v;
|
|
|
|
}
|
|
|
|
continue;
|
2009-03-15 23:04:45 +00:00
|
|
|
}
|
|
|
|
|
2009-10-29 07:16:28 +00:00
|
|
|
// So these are the sides
|
|
|
|
if(ss->degm != 1 || ss->degn != 1) continue;
|
|
|
|
|
|
|
|
Entity *e;
|
|
|
|
for(e = SK.entity.First(); e; e = SK.entity.NextAfter(e)) {
|
2019-07-09 14:44:57 +00:00
|
|
|
if(e->group != opA) continue;
|
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(e->type != Entity::Type::LINE_SEGMENT) continue;
|
2009-10-29 07:16:28 +00:00
|
|
|
|
|
|
|
Vector a = SK.GetEntity(e->point[0])->PointGetNum(),
|
|
|
|
b = SK.GetEntity(e->point[1])->PointGetNum();
|
|
|
|
a = a.Plus(ttop);
|
|
|
|
b = b.Plus(ttop);
|
|
|
|
// Could get taken backwards, so check all cases.
|
|
|
|
if((a.Equals(ss->ctrl[0][0]) && b.Equals(ss->ctrl[1][0])) ||
|
|
|
|
(b.Equals(ss->ctrl[0][0]) && a.Equals(ss->ctrl[1][0])) ||
|
|
|
|
(a.Equals(ss->ctrl[0][1]) && b.Equals(ss->ctrl[1][1])) ||
|
|
|
|
(b.Equals(ss->ctrl[0][1]) && a.Equals(ss->ctrl[1][1])))
|
|
|
|
{
|
|
|
|
face = Remap(e->h, REMAP_LINE_TO_FACE);
|
|
|
|
ss->face = face.v;
|
|
|
|
break;
|
|
|
|
}
|
2009-03-15 23:04:45 +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::LATHE && haveSrc) {
|
2009-04-19 05:53:16 +00:00
|
|
|
Group *src = SK.GetGroup(opA);
|
2008-06-06 11:35:28 +00:00
|
|
|
|
2009-04-29 02:42:44 +00:00
|
|
|
Vector pt = SK.GetEntity(predef.origin)->PointGetNum(),
|
|
|
|
axis = SK.GetEntity(predef.entityB)->VectorGetNum();
|
2008-06-06 11:35:28 +00:00
|
|
|
axis = axis.WithMagnitude(1);
|
|
|
|
|
2009-10-29 07:16:28 +00:00
|
|
|
SBezierLoopSetSet *sblss = &(src->bezierLoops);
|
|
|
|
SBezierLoopSet *sbls;
|
|
|
|
for(sbls = sblss->l.First(); sbls; sbls = sblss->l.NextAfter(sbls)) {
|
2015-10-31 08:22:26 +00:00
|
|
|
thisShell.MakeFromRevolutionOf(sbls, pt, axis, color, this);
|
2009-10-29 07:16:28 +00:00
|
|
|
}
|
2019-04-14 20:05:50 +00:00
|
|
|
} else if(type == Type::REVOLVE && haveSrc) {
|
|
|
|
Group *src = SK.GetGroup(opA);
|
|
|
|
double anglef = SK.GetParam(h.param(3))->val * 4; // why the 4 is needed?
|
|
|
|
double angles = 0.0;
|
|
|
|
if(subtype != Subtype::ONE_SIDED) {
|
|
|
|
anglef *= 0.5;
|
|
|
|
angles = -anglef;
|
|
|
|
}
|
|
|
|
Vector pt = SK.GetEntity(predef.origin)->PointGetNum(),
|
|
|
|
axis = SK.GetEntity(predef.entityB)->VectorGetNum();
|
|
|
|
axis = axis.WithMagnitude(1);
|
|
|
|
|
|
|
|
SBezierLoopSetSet *sblss = &(src->bezierLoops);
|
|
|
|
SBezierLoopSet *sbls;
|
|
|
|
for(sbls = sblss->l.First(); sbls; sbls = sblss->l.NextAfter(sbls)) {
|
|
|
|
if(fabs(anglef - angles) < 2 * PI) {
|
|
|
|
thisShell.MakeFromHelicalRevolutionOf(sbls, pt, axis, color, this, angles, anglef);
|
|
|
|
} else {
|
|
|
|
thisShell.MakeFromRevolutionOf(sbls, pt, axis, color, this);
|
|
|
|
}
|
|
|
|
}
|
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::LINKED) {
|
2009-05-19 07:26:38 +00:00
|
|
|
// The imported shell or mesh are copied over, with the appropriate
|
|
|
|
// transformation applied. We also must remap the face entities.
|
2008-06-06 08:14:37 +00:00
|
|
|
Vector offset = {
|
2009-04-19 05:53:16 +00:00
|
|
|
SK.GetParam(h.param(0))->val,
|
|
|
|
SK.GetParam(h.param(1))->val,
|
|
|
|
SK.GetParam(h.param(2))->val };
|
2008-06-06 08:14:37 +00:00
|
|
|
Quaternion q = {
|
2009-04-19 05:53:16 +00:00
|
|
|
SK.GetParam(h.param(3))->val,
|
|
|
|
SK.GetParam(h.param(4))->val,
|
|
|
|
SK.GetParam(h.param(5))->val,
|
|
|
|
SK.GetParam(h.param(6))->val };
|
2008-06-06 08:14:37 +00:00
|
|
|
|
2009-12-15 12:26:22 +00:00
|
|
|
thisMesh.MakeFromTransformationOf(&impMesh, offset, q, scale);
|
2009-05-24 11:37:07 +00:00
|
|
|
thisMesh.RemapFaces(this, 0);
|
2009-05-19 07:26:38 +00:00
|
|
|
|
2009-12-15 12:26:22 +00:00
|
|
|
thisShell.MakeFromTransformationOf(&impShell, offset, q, scale);
|
2009-05-24 11:37:07 +00:00
|
|
|
thisShell.RemapFaces(this, 0);
|
2008-06-06 08:14: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
|
|
|
if(srcg->meshCombine != CombineAs::ASSEMBLE) {
|
2009-06-06 08:21:03 +00:00
|
|
|
thisShell.MergeCoincidentSurfaces();
|
|
|
|
}
|
2009-06-05 05:38:41 +00:00
|
|
|
|
2009-05-24 11:37:07 +00:00
|
|
|
// So now we've got the mesh or shell for this group. Combine it with
|
|
|
|
// the previous group's mesh or shell with the requested Boolean, and
|
|
|
|
// we're done.
|
2008-06-21 22:49:57 +00:00
|
|
|
|
2009-07-20 01:47:59 +00:00
|
|
|
Group *prevg = srcg->RunningMeshGroup();
|
2009-06-06 08:21:03 +00:00
|
|
|
|
2017-03-21 15:47:59 +00:00
|
|
|
if(!IsForcedToMesh()) {
|
2009-07-20 01:47:59 +00:00
|
|
|
SShell *prevs = &(prevg->runningShell);
|
|
|
|
GenerateForBoolean<SShell>(prevs, &thisShell, &runningShell,
|
|
|
|
srcg->meshCombine);
|
|
|
|
|
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(srcg->meshCombine != CombineAs::ASSEMBLE) {
|
2009-06-06 08:21:03 +00:00
|
|
|
runningShell.MergeCoincidentSurfaces();
|
|
|
|
}
|
2009-05-30 08:49:09 +00:00
|
|
|
|
|
|
|
// If the Boolean failed, then we should note that in the text screen
|
|
|
|
// for this group.
|
|
|
|
booleanFailed = runningShell.booleanFailed;
|
|
|
|
if(booleanFailed != prevBooleanFailed) {
|
2015-03-18 17:02:11 +00:00
|
|
|
SS.ScheduleShowTW();
|
2009-05-30 08:49:09 +00:00
|
|
|
}
|
2008-06-06 08:14:37 +00:00
|
|
|
} else {
|
2009-05-24 11:37:07 +00:00
|
|
|
SMesh prevm, thism;
|
2015-03-27 15:31:23 +00:00
|
|
|
prevm = {};
|
|
|
|
thism = {};
|
2009-05-24 11:37:07 +00:00
|
|
|
|
2009-07-20 01:47:59 +00:00
|
|
|
prevm.MakeFromCopyOf(&(prevg->runningMesh));
|
|
|
|
prevg->runningShell.TriangulateInto(&prevm);
|
2009-05-24 11:37:07 +00:00
|
|
|
|
|
|
|
thism.MakeFromCopyOf(&thisMesh);
|
|
|
|
thisShell.TriangulateInto(&thism);
|
|
|
|
|
2015-03-27 15:31:23 +00:00
|
|
|
SMesh outm = {};
|
2009-07-20 01:47:59 +00:00
|
|
|
GenerateForBoolean<SMesh>(&prevm, &thism, &outm, srcg->meshCombine);
|
2009-05-28 07:07:54 +00:00
|
|
|
|
2017-02-04 10:47:39 +00:00
|
|
|
// Remove degenerate triangles; if we don't, they'll get split in SnapToMesh
|
|
|
|
// in every generated group, resulting in polynomial increase in triangle count,
|
|
|
|
// and corresponding slowdown.
|
|
|
|
outm.RemoveDegenerateTriangles();
|
|
|
|
|
2017-08-31 17:42:50 +00:00
|
|
|
if(srcg->meshCombine != CombineAs::ASSEMBLE) {
|
|
|
|
// And make sure that the output mesh is vertex-to-vertex.
|
|
|
|
SKdNode *root = SKdNode::From(&outm);
|
|
|
|
root->SnapToMesh(&outm);
|
|
|
|
root->MakeMeshInto(&runningMesh);
|
|
|
|
} else {
|
|
|
|
runningMesh.MakeFromCopyOf(&outm);
|
|
|
|
}
|
2009-05-24 11:37:07 +00:00
|
|
|
|
2009-05-28 07:07:54 +00:00
|
|
|
outm.Clear();
|
2009-05-24 11:37:07 +00:00
|
|
|
thism.Clear();
|
|
|
|
prevm.Clear();
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
2008-07-06 07:56:24 +00:00
|
|
|
|
2009-05-21 09:06:26 +00:00
|
|
|
displayDirty = true;
|
|
|
|
}
|
|
|
|
|
2016-05-05 05:54:05 +00:00
|
|
|
void Group::GenerateDisplayItems() {
|
2009-05-29 05:40:17 +00:00
|
|
|
// This is potentially slow (since we've got to triangulate a shell, or
|
|
|
|
// to find the emphasized edges for a mesh), so we will run it only
|
|
|
|
// if its inputs have changed.
|
2009-05-21 09:06:26 +00:00
|
|
|
if(displayDirty) {
|
2009-10-08 07:55:09 +00:00
|
|
|
Group *pg = RunningMeshGroup();
|
|
|
|
if(pg && thisMesh.IsEmpty() && thisShell.IsEmpty()) {
|
|
|
|
// We don't contribute any new solid model in this group, so our
|
|
|
|
// display items are identical to the previous group's; which means
|
|
|
|
// that we can just display those, and stop ourselves from
|
|
|
|
// recalculating for those every time we get a change in this group.
|
|
|
|
//
|
|
|
|
// Note that this can end up recursing multiple times (if multiple
|
|
|
|
// groups that contribute no solid model exist in sequence), but
|
|
|
|
// that's okay.
|
|
|
|
pg->GenerateDisplayItems();
|
|
|
|
|
|
|
|
displayMesh.Clear();
|
|
|
|
displayMesh.MakeFromCopyOf(&(pg->displayMesh));
|
|
|
|
|
2016-03-14 16:14:24 +00:00
|
|
|
displayOutlines.Clear();
|
2016-08-14 00:55:27 +00:00
|
|
|
if(SS.GW.showEdges || SS.GW.showOutlines) {
|
2016-03-14 16:14:24 +00:00
|
|
|
displayOutlines.MakeFromCopyOf(&pg->displayOutlines);
|
2009-10-08 07:55:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We do contribute new solid model, so we have to triangulate the
|
|
|
|
// shell, and edge-find the mesh.
|
|
|
|
displayMesh.Clear();
|
|
|
|
runningShell.TriangulateInto(&displayMesh);
|
|
|
|
STriangle *t;
|
|
|
|
for(t = runningMesh.l.First(); t; t = runningMesh.l.NextAfter(t)) {
|
|
|
|
STriangle trn = *t;
|
|
|
|
Vector n = trn.Normal();
|
|
|
|
trn.an = n;
|
|
|
|
trn.bn = n;
|
|
|
|
trn.cn = n;
|
|
|
|
displayMesh.AddTriangle(&trn);
|
|
|
|
}
|
2009-05-24 11:37:07 +00:00
|
|
|
|
2016-03-14 16:14:24 +00:00
|
|
|
displayOutlines.Clear();
|
2009-05-29 05:40:17 +00:00
|
|
|
|
2016-08-14 00:55:27 +00:00
|
|
|
if(SS.GW.showEdges || SS.GW.showOutlines) {
|
2016-10-11 10:38:21 +00:00
|
|
|
SOutlineList rawOutlines = {};
|
2016-03-22 10:52:09 +00:00
|
|
|
if(runningMesh.l.n > 0) {
|
|
|
|
// Triangle mesh only; no shell or emphasized edges.
|
2016-10-11 10:38:21 +00:00
|
|
|
runningMesh.MakeOutlinesInto(&rawOutlines, EdgeKind::EMPHASIZED);
|
2016-03-22 10:52:09 +00:00
|
|
|
} else {
|
2016-10-11 10:38:21 +00:00
|
|
|
displayMesh.MakeOutlinesInto(&rawOutlines, EdgeKind::SHARP);
|
2016-03-22 10:52:09 +00:00
|
|
|
}
|
2016-10-11 10:38:21 +00:00
|
|
|
|
|
|
|
PolylineBuilder builder;
|
|
|
|
builder.MakeFromOutlines(rawOutlines);
|
|
|
|
builder.GenerateOutlines(&displayOutlines);
|
|
|
|
rawOutlines.Clear();
|
2009-10-08 07:55:09 +00:00
|
|
|
}
|
2009-05-29 05:40:17 +00:00
|
|
|
}
|
2009-05-24 11:37:07 +00:00
|
|
|
|
2016-12-05 03:11:34 +00:00
|
|
|
// If we render this mesh, we need to know whether it's transparent,
|
|
|
|
// and we'll want all transparent triangles last, to make the depth test
|
|
|
|
// work correctly.
|
|
|
|
displayMesh.PrecomputeTransparency();
|
|
|
|
|
2017-01-17 16:57:27 +00:00
|
|
|
// Recalculate mass center if needed
|
2019-07-09 14:44:57 +00:00
|
|
|
if(SS.centerOfMass.draw && SS.centerOfMass.dirty && h == SS.GW.activeGroup) {
|
2017-01-17 16:57:27 +00:00
|
|
|
SS.UpdateCenterOfMass();
|
|
|
|
}
|
2009-05-21 09:06:26 +00:00
|
|
|
displayDirty = false;
|
|
|
|
}
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
|
|
|
|
2017-03-21 15:47:59 +00:00
|
|
|
Group *Group::PreviousGroup() const {
|
2008-06-06 08:14:37 +00:00
|
|
|
int i;
|
2016-02-17 10:03:07 +00:00
|
|
|
for(i = 0; i < SK.groupOrder.n; i++) {
|
|
|
|
Group *g = SK.GetGroup(SK.groupOrder.elem[i]);
|
2019-07-09 14:44:57 +00:00
|
|
|
if(g->h == h) break;
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
2016-02-17 10:03:07 +00:00
|
|
|
if(i == 0 || i >= SK.groupOrder.n) return NULL;
|
|
|
|
return SK.GetGroup(SK.groupOrder.elem[i - 1]);
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
|
|
|
|
2017-03-21 15:47:59 +00:00
|
|
|
Group *Group::RunningMeshGroup() const {
|
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::TRANSLATE || type == Type::ROTATE) {
|
2009-07-20 01:47:59 +00:00
|
|
|
return SK.GetGroup(opA)->RunningMeshGroup();
|
|
|
|
} else {
|
|
|
|
return PreviousGroup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-02 13:34:17 +00:00
|
|
|
bool Group::IsMeshGroup() {
|
|
|
|
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 Group::Type::EXTRUDE:
|
|
|
|
case Group::Type::LATHE:
|
2019-04-14 20:05:50 +00:00
|
|
|
case Group::Type::REVOLVE:
|
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 Group::Type::ROTATE:
|
|
|
|
case Group::Type::TRANSLATE:
|
2016-04-02 13:34:17 +00:00
|
|
|
return true;
|
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
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
2016-04-02 13:34:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
void Group::DrawMesh(DrawMeshAs how, Canvas *canvas) {
|
2016-08-13 09:02:12 +00:00
|
|
|
if(!(SS.GW.showShaded ||
|
|
|
|
SS.GW.drawOccludedAs != GraphicsWindow::DrawOccludedAs::VISIBLE)) return;
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
|
|
|
|
switch(how) {
|
|
|
|
case DrawMeshAs::DEFAULT: {
|
|
|
|
// Force the shade color to something dim to not distract from
|
|
|
|
// the sketch.
|
|
|
|
Canvas::Fill fillFront = {};
|
|
|
|
if(!SS.GW.showShaded) {
|
2016-08-13 09:02:12 +00:00
|
|
|
fillFront.layer = Canvas::Layer::DEPTH_ONLY;
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
}
|
|
|
|
if(type == Type::DRAWING_3D || type == Type::DRAWING_WORKPLANE) {
|
|
|
|
fillFront.color = Style::Color(Style::DIM_SOLID);
|
|
|
|
}
|
|
|
|
Canvas::hFill hcfFront = canvas->GetFill(fillFront);
|
|
|
|
|
|
|
|
// The back faces are drawn in red; should never seem them, since we
|
|
|
|
// draw closed shells, so that's a debugging aid.
|
|
|
|
Canvas::hFill hcfBack = {};
|
|
|
|
if(SS.drawBackFaces && !displayMesh.isTransparent) {
|
|
|
|
Canvas::Fill fillBack = {};
|
|
|
|
fillBack.layer = fillFront.layer;
|
|
|
|
fillBack.color = RgbaColor::FromFloat(1.0f, 0.1f, 0.1f);
|
|
|
|
hcfBack = canvas->GetFill(fillBack);
|
2016-11-18 10:56:35 +00:00
|
|
|
} else {
|
|
|
|
hcfBack = hcfFront;
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
}
|
|
|
|
|
2016-11-17 16:47:45 +00:00
|
|
|
// Draw the shaded solid into the depth buffer for hidden line removal,
|
|
|
|
// and if we're actually going to display it, to the color buffer too.
|
|
|
|
canvas->DrawMesh(displayMesh, hcfFront, hcfBack);
|
|
|
|
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
// Draw mesh edges, for debugging.
|
|
|
|
if(SS.GW.showMesh) {
|
|
|
|
Canvas::Stroke strokeTriangle = {};
|
|
|
|
strokeTriangle.zIndex = 1;
|
|
|
|
strokeTriangle.color = RgbaColor::FromFloat(0.0f, 1.0f, 0.0f);
|
|
|
|
strokeTriangle.width = 1;
|
2016-11-17 16:47:45 +00:00
|
|
|
strokeTriangle.unit = Canvas::Unit::PX;
|
|
|
|
Canvas::hStroke hcsTriangle = canvas->GetStroke(strokeTriangle);
|
|
|
|
SEdgeList edges = {};
|
|
|
|
for(const STriangle &t : displayMesh.l) {
|
|
|
|
edges.AddEdge(t.a, t.b);
|
|
|
|
edges.AddEdge(t.b, t.c);
|
|
|
|
edges.AddEdge(t.c, t.a);
|
|
|
|
}
|
|
|
|
canvas->DrawEdges(edges, hcsTriangle);
|
|
|
|
edges.Clear();
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-03-26 10:30:12 +00:00
|
|
|
}
|
|
|
|
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
case DrawMeshAs::HOVERED: {
|
|
|
|
Canvas::Fill fill = {};
|
|
|
|
fill.color = Style::Color(Style::HOVERED);
|
|
|
|
fill.pattern = Canvas::FillPattern::CHECKERED_A;
|
|
|
|
fill.zIndex = 2;
|
|
|
|
Canvas::hFill hcf = canvas->GetFill(fill);
|
|
|
|
|
|
|
|
std::vector<uint32_t> faces;
|
|
|
|
hEntity he = SS.GW.hover.entity;
|
|
|
|
if(he.v != 0 && SK.GetEntity(he)->IsFace()) {
|
|
|
|
faces.push_back(he.v);
|
|
|
|
}
|
|
|
|
canvas->DrawFaces(displayMesh, faces, hcf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DrawMeshAs::SELECTED: {
|
|
|
|
Canvas::Fill fill = {};
|
|
|
|
fill.color = Style::Color(Style::SELECTED);
|
|
|
|
fill.pattern = Canvas::FillPattern::CHECKERED_B;
|
|
|
|
fill.zIndex = 1;
|
|
|
|
Canvas::hFill hcf = canvas->GetFill(fill);
|
|
|
|
|
|
|
|
std::vector<uint32_t> faces;
|
|
|
|
SS.GW.GroupSelection();
|
2016-10-10 12:34:10 +00:00
|
|
|
auto const &gs = SS.GW.gs;
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
if(gs.faces > 0) faces.push_back(gs.face[0].v);
|
|
|
|
if(gs.faces > 1) faces.push_back(gs.face[1].v);
|
|
|
|
canvas->DrawFaces(displayMesh, faces, hcf);
|
|
|
|
break;
|
|
|
|
}
|
2009-03-18 04:26:04 +00:00
|
|
|
}
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Group::Draw(Canvas *canvas) {
|
|
|
|
// Everything here gets drawn whether or not the group is hidden; we
|
|
|
|
// can control this stuff independently, with show/hide solids, edges,
|
|
|
|
// mesh, etc.
|
|
|
|
|
|
|
|
GenerateDisplayItems();
|
|
|
|
DrawMesh(DrawMeshAs::DEFAULT, canvas);
|
2015-03-26 10:30:12 +00:00
|
|
|
|
2009-03-18 04:26:04 +00:00
|
|
|
if(SS.GW.showEdges) {
|
2016-06-30 15:54:35 +00:00
|
|
|
Canvas::Stroke strokeEdge = Style::Stroke(Style::SOLID_EDGE);
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
strokeEdge.zIndex = 1;
|
|
|
|
Canvas::hStroke hcsEdge = canvas->GetStroke(strokeEdge);
|
|
|
|
|
2016-06-26 06:39:27 +00:00
|
|
|
canvas->DrawOutlines(displayOutlines, hcsEdge,
|
|
|
|
SS.GW.showOutlines
|
|
|
|
? Canvas::DrawOutlinesAs::EMPHASIZED_WITHOUT_CONTOUR
|
|
|
|
: Canvas::DrawOutlinesAs::EMPHASIZED_AND_CONTOUR);
|
2016-03-14 16:14:24 +00:00
|
|
|
|
2016-06-30 15:54:35 +00:00
|
|
|
if(SS.GW.drawOccludedAs != GraphicsWindow::DrawOccludedAs::INVISIBLE) {
|
2016-06-30 15:54:35 +00:00
|
|
|
Canvas::Stroke strokeHidden = Style::Stroke(Style::HIDDEN_EDGE);
|
2016-06-30 15:54:35 +00:00
|
|
|
if(SS.GW.drawOccludedAs == GraphicsWindow::DrawOccludedAs::VISIBLE) {
|
|
|
|
strokeHidden.stipplePattern = StipplePattern::CONTINUOUS;
|
|
|
|
}
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
strokeHidden.layer = Canvas::Layer::OCCLUDED;
|
|
|
|
Canvas::hStroke hcsHidden = canvas->GetStroke(strokeHidden);
|
|
|
|
|
2016-06-26 06:39:27 +00:00
|
|
|
canvas->DrawOutlines(displayOutlines, hcsHidden,
|
|
|
|
Canvas::DrawOutlinesAs::EMPHASIZED_AND_CONTOUR);
|
2016-03-14 16:14:24 +00:00
|
|
|
}
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
2016-08-14 00:55:27 +00:00
|
|
|
|
|
|
|
if(SS.GW.showOutlines) {
|
2016-10-13 13:23:22 +00:00
|
|
|
Canvas::Stroke strokeOutline = Style::Stroke(Style::OUTLINE);
|
2016-08-14 00:55:27 +00:00
|
|
|
strokeOutline.zIndex = 1;
|
|
|
|
Canvas::hStroke hcsOutline = canvas->GetStroke(strokeOutline);
|
|
|
|
|
|
|
|
canvas->DrawOutlines(displayOutlines, hcsOutline,
|
|
|
|
Canvas::DrawOutlinesAs::CONTOUR_ONLY);
|
|
|
|
}
|
2009-06-30 07:24:36 +00:00
|
|
|
}
|
|
|
|
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
void Group::DrawPolyError(Canvas *canvas) {
|
|
|
|
const Camera &camera = canvas->GetCamera();
|
2009-06-30 07:24:36 +00:00
|
|
|
|
2016-06-30 15:54:35 +00:00
|
|
|
Canvas::Stroke strokeUnclosed = Style::Stroke(Style::DRAW_ERROR);
|
|
|
|
strokeUnclosed.color = strokeUnclosed.color.WithAlpha(50);
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
Canvas::hStroke hcsUnclosed = canvas->GetStroke(strokeUnclosed);
|
|
|
|
|
2016-06-30 15:54:35 +00:00
|
|
|
Canvas::Stroke strokeError = Style::Stroke(Style::DRAW_ERROR);
|
|
|
|
strokeError.layer = Canvas::Layer::FRONT;
|
2016-10-11 21:25:46 +00:00
|
|
|
strokeError.width = 1.0f;
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
Canvas::hStroke hcsError = canvas->GetStroke(strokeError);
|
2008-06-06 08:14:37 +00:00
|
|
|
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
double textHeight = Style::DefaultTextHeight() / camera.scale;
|
2009-10-01 10:35:11 +00:00
|
|
|
|
|
|
|
// And finally show the polygons too, and any errors if it's not possible
|
|
|
|
// to assemble the lines into closed polygons.
|
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(polyError.how == PolyError::NOT_CLOSED) {
|
2008-07-13 09:57:46 +00:00
|
|
|
// Report this error only in sketch-in-workplane groups; otherwise
|
|
|
|
// it's just a nuisance.
|
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::DRAWING_WORKPLANE) {
|
2017-01-07 06:41:13 +00:00
|
|
|
canvas->DrawVectorText(_("not closed contour, or not all same style!"),
|
|
|
|
textHeight,
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
polyError.notClosedAt.b, camera.projRight, camera.projUp,
|
|
|
|
hcsError);
|
|
|
|
canvas->DrawLine(polyError.notClosedAt.a, polyError.notClosedAt.b, hcsUnclosed);
|
2008-07-13 09:57: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
|
|
|
} else if(polyError.how == PolyError::NOT_COPLANAR ||
|
|
|
|
polyError.how == PolyError::SELF_INTERSECTING ||
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
polyError.how == PolyError::ZERO_LEN_EDGE) {
|
2009-01-23 03:30:30 +00:00
|
|
|
// These errors occur at points, not lines
|
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::DRAWING_WORKPLANE) {
|
2013-08-26 18:58:35 +00:00
|
|
|
const char *msg;
|
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(polyError.how == PolyError::NOT_COPLANAR) {
|
2017-01-07 06:41:13 +00:00
|
|
|
msg = _("points not all coplanar!");
|
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(polyError.how == PolyError::SELF_INTERSECTING) {
|
2017-01-07 06:41:13 +00:00
|
|
|
msg = _("contour is self-intersecting!");
|
2009-12-03 19:14:34 +00:00
|
|
|
} else {
|
2017-01-07 06:41:13 +00:00
|
|
|
msg = _("zero-length edge!");
|
2009-12-03 19:14:34 +00:00
|
|
|
}
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
canvas->DrawVectorText(msg, textHeight,
|
|
|
|
polyError.errorPointAt, camera.projRight, camera.projUp,
|
|
|
|
hcsError);
|
2008-07-13 09:57:46 +00:00
|
|
|
}
|
2008-06-06 08:14:37 +00:00
|
|
|
} else {
|
2009-10-29 07:16:28 +00:00
|
|
|
// The contours will get filled in DrawFilledPaths.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
void Group::DrawFilledPaths(Canvas *canvas) {
|
|
|
|
for(const SBezierLoopSet &sbls : bezierLoops.l) {
|
|
|
|
if(sbls.l.n == 0 || sbls.l.elem[0].l.n == 0) continue;
|
2009-10-29 07:16:28 +00:00
|
|
|
|
2009-10-30 10:38:34 +00:00
|
|
|
// In an assembled loop, all the styles should be the same; so doesn't
|
|
|
|
// matter which one we grab.
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
SBezier *sb = &(sbls.l.elem[0].l.elem[0]);
|
|
|
|
Style *s = Style::Get({ (uint32_t)sb->auxA });
|
|
|
|
|
|
|
|
Canvas::Fill fill = {};
|
|
|
|
fill.zIndex = 1;
|
2009-10-30 10:38:34 +00:00
|
|
|
if(s->filled) {
|
|
|
|
// This is a filled loop, where the user specified a fill color.
|
2016-07-31 10:34:18 +00:00
|
|
|
fill.color = s->fillColor;
|
2019-07-09 14:44:57 +00:00
|
|
|
} else if(h == SS.GW.activeGroup && SS.checkClosedContour &&
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
polyError.how == PolyError::GOOD) {
|
|
|
|
// If this is the active group, and we are supposed to check
|
|
|
|
// for closed contours, and we do indeed have a closed and
|
|
|
|
// non-intersecting contour, then fill it dimly.
|
|
|
|
fill.color = Style::Color(Style::CONTOUR_FILL).WithAlpha(127);
|
|
|
|
} else continue;
|
|
|
|
Canvas::hFill hcf = canvas->GetFill(fill);
|
|
|
|
|
|
|
|
SPolygon sp = {};
|
|
|
|
sbls.MakePwlInto(&sp);
|
|
|
|
canvas->DrawPolygon(sp, hcf);
|
2016-08-01 03:52:12 +00:00
|
|
|
sp.Clear();
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-30 14:39:42 +00:00
|
|
|
void Group::DrawContourAreaLabels(Canvas *canvas) {
|
|
|
|
const Camera &camera = canvas->GetCamera();
|
|
|
|
Vector gr = camera.projRight.ScaledBy(1 / camera.scale);
|
|
|
|
Vector gu = camera.projUp.ScaledBy(1 / camera.scale);
|
|
|
|
|
|
|
|
for(SBezierLoopSet &sbls : bezierLoops.l) {
|
|
|
|
if(sbls.l.n == 0 || sbls.l.elem[0].l.n == 0) continue;
|
|
|
|
|
|
|
|
Vector min = sbls.l.elem[0].l.elem[0].ctrl[0];
|
|
|
|
Vector max = min;
|
|
|
|
Vector zero = Vector::From(0.0, 0.0, 0.0);
|
|
|
|
sbls.GetBoundingProjd(Vector::From(1.0, 0.0, 0.0), zero, &min.x, &max.x);
|
|
|
|
sbls.GetBoundingProjd(Vector::From(0.0, 1.0, 0.0), zero, &min.y, &max.y);
|
|
|
|
sbls.GetBoundingProjd(Vector::From(0.0, 0.0, 1.0), zero, &min.z, &max.z);
|
|
|
|
|
|
|
|
Vector mid = min.Plus(max).ScaledBy(0.5);
|
|
|
|
|
|
|
|
hStyle hs = { Style::CONSTRAINT };
|
|
|
|
Canvas::Stroke stroke = Style::Stroke(hs);
|
|
|
|
stroke.layer = Canvas::Layer::FRONT;
|
|
|
|
|
|
|
|
double scale = SS.MmPerUnit();
|
|
|
|
std::string label = ssprintf("%.3f %s²",
|
|
|
|
fabs(sbls.SignedArea() / (scale * scale)),
|
|
|
|
SS.UnitName());
|
|
|
|
|
|
|
|
double fontHeight = Style::TextHeight(hs);
|
|
|
|
double textWidth = VectorFont::Builtin()->GetWidth(fontHeight, label),
|
|
|
|
textHeight = VectorFont::Builtin()->GetCapHeight(fontHeight);
|
|
|
|
Vector pos = mid.Minus(gr.ScaledBy(textWidth / 2.0))
|
|
|
|
.Minus(gu.ScaledBy(textHeight / 2.0));
|
|
|
|
canvas->DrawVectorText(label, fontHeight, pos, gr, gu, canvas->GetStroke(stroke));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|