2013-07-29 06:08:34 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Functions relating to rational polynomial surfaces, which are trimmed by
|
|
|
|
// curves (either rational polynomial curves, or piecewise linear
|
|
|
|
// approximations to curves of intersection that can't be represented
|
|
|
|
// exactly in ratpoly form), and assembled into watertight shells.
|
|
|
|
//
|
|
|
|
// Copyright 2008-2013 Jonathan Westhues.
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-01-10 16:18:54 +08:00
|
|
|
|
|
|
|
#ifndef __SURFACE_H
|
|
|
|
#define __SURFACE_H
|
|
|
|
|
2009-01-19 11:33:15 +08:00
|
|
|
// Utility functions, Bernstein polynomials of order 1-3 and their derivatives.
|
2009-01-15 11:55:42 +08:00
|
|
|
double Bernstein(int k, int deg, double t);
|
2009-01-19 11:33:15 +08:00
|
|
|
double BernsteinDerivative(int k, int deg, double t);
|
2009-01-15 11:55:42 +08:00
|
|
|
|
2009-02-27 21:04:36 +08:00
|
|
|
class SSurface;
|
2009-05-18 15:26:51 +08:00
|
|
|
class SCurvePt;
|
2009-02-27 21:04:36 +08:00
|
|
|
|
2009-02-01 13:13:43 +08:00
|
|
|
// Utility data structure, a two-dimensional BSP to accelerate polygon
|
|
|
|
// operations.
|
|
|
|
class SBspUv {
|
|
|
|
public:
|
|
|
|
Point2d a, b;
|
|
|
|
|
|
|
|
SBspUv *pos;
|
|
|
|
SBspUv *neg;
|
|
|
|
|
|
|
|
SBspUv *more;
|
|
|
|
|
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 16:31:20 +08:00
|
|
|
enum class Class : uint32_t {
|
2013-09-10 03:50:32 +08:00
|
|
|
INSIDE = 100,
|
|
|
|
OUTSIDE = 200,
|
|
|
|
EDGE_PARALLEL = 300,
|
|
|
|
EDGE_ANTIPARALLEL = 400,
|
|
|
|
EDGE_OTHER = 500
|
|
|
|
};
|
2009-02-01 13:13:43 +08:00
|
|
|
|
2016-05-05 13:54:05 +08:00
|
|
|
static SBspUv *Alloc();
|
2009-07-02 11:32:17 +08:00
|
|
|
static SBspUv *From(SEdgeList *el, SSurface *srf);
|
2009-02-01 13:13:43 +08:00
|
|
|
|
2016-05-21 13:18:00 +08:00
|
|
|
void ScalePoints(Point2d *pt, Point2d *a, Point2d *b, SSurface *srf) const;
|
2009-07-02 11:32:17 +08:00
|
|
|
double ScaledSignedDistanceToLine(Point2d pt, Point2d a, Point2d b,
|
2016-05-21 13:18:00 +08:00
|
|
|
SSurface *srf) const;
|
2016-05-25 20:08:19 +08:00
|
|
|
double ScaledDistanceToLine(Point2d pt, Point2d a, Point2d b, bool asSegment,
|
2016-05-21 13:18:00 +08:00
|
|
|
SSurface *srf) const;
|
2009-07-02 11:32:17 +08:00
|
|
|
|
2016-03-25 22:16:58 +08:00
|
|
|
void InsertEdge(Point2d a, Point2d b, SSurface *srf);
|
2016-05-21 13:18:00 +08:00
|
|
|
static SBspUv *InsertOrCreateEdge(SBspUv *where, Point2d ea, Point2d eb, SSurface *srf);
|
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 16:31:20 +08:00
|
|
|
Class ClassifyPoint(Point2d p, Point2d eb, SSurface *srf) const;
|
|
|
|
Class ClassifyEdge(Point2d ea, Point2d eb, SSurface *srf) const;
|
2016-05-21 13:18:00 +08:00
|
|
|
double MinimumDistanceToEdge(Point2d p, SSurface *srf) const;
|
2009-02-01 13:13:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Now the data structures to represent a shell of trimmed rational polynomial
|
|
|
|
// surfaces.
|
|
|
|
|
2009-01-19 18:37:10 +08:00
|
|
|
class SShell;
|
|
|
|
|
2009-01-15 11:55:42 +08:00
|
|
|
class hSSurface {
|
|
|
|
public:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 13:45:13 +08:00
|
|
|
uint32_t v;
|
2009-01-15 11:55:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class hSCurve {
|
|
|
|
public:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 13:45:13 +08:00
|
|
|
uint32_t v;
|
2009-01-15 11:55:42 +08:00
|
|
|
};
|
2009-01-10 16:18:54 +08:00
|
|
|
|
2009-01-14 13:10:42 +08:00
|
|
|
// Stuff for rational polynomial curves, of degree one to three. These are
|
2009-04-14 12:19:23 +08:00
|
|
|
// our inputs, and are also calculated for certain exact surface-surface
|
|
|
|
// intersections.
|
2009-01-19 11:51:00 +08:00
|
|
|
class SBezier {
|
2009-01-14 13:10:42 +08:00
|
|
|
public:
|
2009-01-17 13:28:49 +08:00
|
|
|
int tag;
|
2009-09-22 13:46:30 +08:00
|
|
|
int auxA, auxB;
|
|
|
|
|
2009-01-14 13:10:42 +08:00
|
|
|
int deg;
|
|
|
|
Vector ctrl[4];
|
|
|
|
double weight[4];
|
2015-10-31 16:22:26 +08:00
|
|
|
uint32_t entity;
|
2009-01-14 13:10:42 +08:00
|
|
|
|
2016-05-21 13:18:00 +08:00
|
|
|
Vector PointAt(double t) const;
|
|
|
|
Vector TangentAt(double t) const;
|
2016-05-25 20:08:19 +08:00
|
|
|
void ClosestPointTo(Vector p, double *t, bool mustConverge=true) const;
|
2016-05-21 13:18:00 +08:00
|
|
|
void SplitAt(double t, SBezier *bef, SBezier *aft) const;
|
|
|
|
bool PointOnThisAndCurve(const SBezier *sbb, Vector *p) const;
|
|
|
|
|
|
|
|
Vector Start() const;
|
|
|
|
Vector Finish() const;
|
|
|
|
bool Equals(SBezier *b) const;
|
|
|
|
void MakePwlInto(SEdgeList *sel, double chordTol=0) const;
|
|
|
|
void MakePwlInto(List<SCurvePt> *l, double chordTol=0) const;
|
|
|
|
void MakePwlInto(SContour *sc, double chordTol=0) const;
|
|
|
|
void MakePwlInto(List<Vector> *l, double chordTol=0) const;
|
|
|
|
void MakePwlWorker(List<Vector> *l, double ta, double tb, double chordTol) const;
|
|
|
|
void MakePwlInitialWorker(List<Vector> *l, double ta, double tb, double chordTol) const;
|
|
|
|
|
|
|
|
void AllIntersectionsWith(const SBezier *sbb, SPointList *spl) const;
|
|
|
|
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax) const;
|
2016-05-05 13:54:05 +08:00
|
|
|
void Reverse();
|
2009-01-17 13:28:49 +08:00
|
|
|
|
2016-05-21 13:18:00 +08:00
|
|
|
bool IsInPlane(Vector n, double d) const;
|
|
|
|
bool IsCircle(Vector axis, Vector *center, double *r) const;
|
|
|
|
bool IsRational() const;
|
2009-04-15 10:55:18 +08:00
|
|
|
|
2016-05-21 13:18:00 +08:00
|
|
|
SBezier TransformedBy(Vector t, Quaternion q, double scale) const;
|
2009-04-14 12:19:23 +08:00
|
|
|
SBezier InPerspective(Vector u, Vector v, Vector n,
|
2016-05-21 13:18:00 +08:00
|
|
|
Vector origin, double cameraTan) const;
|
2009-10-12 17:28:34 +08:00
|
|
|
void ScaleSelfBy(double s);
|
2009-01-23 11:30:30 +08:00
|
|
|
|
2009-01-19 11:51:00 +08:00
|
|
|
static SBezier From(Vector p0, Vector p1, Vector p2, Vector p3);
|
|
|
|
static SBezier From(Vector p0, Vector p1, Vector p2);
|
|
|
|
static SBezier From(Vector p0, Vector p1);
|
2009-04-14 12:19:23 +08:00
|
|
|
static SBezier From(Vector4 p0, Vector4 p1, Vector4 p2, Vector4 p3);
|
|
|
|
static SBezier From(Vector4 p0, Vector4 p1, Vector4 p2);
|
|
|
|
static SBezier From(Vector4 p0, Vector4 p1);
|
2009-01-14 13:10:42 +08:00
|
|
|
};
|
|
|
|
|
2009-01-19 11:51:00 +08:00
|
|
|
class SBezierList {
|
2009-01-14 13:10:42 +08:00
|
|
|
public:
|
2009-01-19 11:51:00 +08:00
|
|
|
List<SBezier> l;
|
2009-01-15 11:55:42 +08:00
|
|
|
|
2016-05-05 13:54:05 +08:00
|
|
|
void Clear();
|
2009-10-12 17:28:34 +08:00
|
|
|
void ScaleSelfBy(double s);
|
2016-05-05 13:54:05 +08:00
|
|
|
void CullIdenticalBeziers();
|
2016-05-21 13:18:00 +08:00
|
|
|
void AllIntersectionsWith(SBezierList *sblb, SPointList *spl) const;
|
2009-10-29 15:16:28 +08:00
|
|
|
bool GetPlaneContainingBeziers(Vector *p, Vector *u, Vector *v,
|
2016-05-21 13:18:00 +08:00
|
|
|
Vector *notCoplanarAt) const;
|
2009-01-14 13:10:42 +08:00
|
|
|
};
|
|
|
|
|
2009-01-19 11:51:00 +08:00
|
|
|
class SBezierLoop {
|
2009-01-17 13:28:49 +08:00
|
|
|
public:
|
2009-06-09 00:21:33 +08:00
|
|
|
int tag;
|
2009-01-19 11:51:00 +08:00
|
|
|
List<SBezier> l;
|
2009-01-17 13:28:49 +08:00
|
|
|
|
2016-05-05 13:54:05 +08:00
|
|
|
inline void Clear() { l.Clear(); }
|
2016-05-21 13:18:00 +08:00
|
|
|
bool IsClosed() const;
|
2016-05-05 13:54:05 +08:00
|
|
|
void Reverse();
|
2016-05-21 13:18:00 +08:00
|
|
|
void MakePwlInto(SContour *sc, double chordTol=0) const;
|
|
|
|
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax) const;
|
2009-01-17 13:28:49 +08:00
|
|
|
|
2009-01-19 11:51:00 +08:00
|
|
|
static SBezierLoop FromCurves(SBezierList *spcl,
|
|
|
|
bool *allClosed, SEdge *errorAt);
|
2009-01-17 13:28:49 +08:00
|
|
|
};
|
|
|
|
|
2009-01-19 11:51:00 +08:00
|
|
|
class SBezierLoopSet {
|
2009-01-19 11:33:15 +08:00
|
|
|
public:
|
2009-01-19 11:51:00 +08:00
|
|
|
List<SBezierLoop> l;
|
2009-01-19 11:33:15 +08:00
|
|
|
Vector normal;
|
2009-01-19 18:37:10 +08:00
|
|
|
Vector point;
|
2009-01-19 11:33:15 +08:00
|
|
|
|
2009-01-19 11:51:00 +08:00
|
|
|
static SBezierLoopSet From(SBezierList *spcl, SPolygon *poly,
|
2009-10-29 15:16:28 +08:00
|
|
|
double chordTol,
|
|
|
|
bool *allClosed, SEdge *errorAt,
|
|
|
|
SBezierList *openContours);
|
2009-01-19 11:33:15 +08:00
|
|
|
|
2016-05-21 13:18:00 +08:00
|
|
|
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax) const;
|
|
|
|
void MakePwlInto(SPolygon *sp) const;
|
2016-05-05 13:54:05 +08:00
|
|
|
void Clear();
|
2009-01-19 11:33:15 +08:00
|
|
|
};
|
2009-01-14 13:10:42 +08:00
|
|
|
|
2009-10-23 01:16:20 +08:00
|
|
|
class SBezierLoopSetSet {
|
|
|
|
public:
|
|
|
|
List<SBezierLoopSet> l;
|
|
|
|
|
2009-10-29 15:16:28 +08:00
|
|
|
void FindOuterFacesFrom(SBezierList *sbl, SPolygon *spxyz, SSurface *srfuv,
|
|
|
|
double chordTol,
|
|
|
|
bool *allClosed, SEdge *notClosedAt,
|
|
|
|
bool *allCoplanar, Vector *notCoplanarAt,
|
|
|
|
SBezierList *openContours);
|
2009-10-30 18:38:34 +08:00
|
|
|
void AddOpenPath(SBezier *sb);
|
2016-05-05 13:54:05 +08:00
|
|
|
void Clear();
|
2009-10-23 01:16:20 +08:00
|
|
|
};
|
|
|
|
|
2009-01-14 13:10:42 +08:00
|
|
|
// Stuff for the surface trim curves: piecewise linear
|
2009-05-18 15:26:51 +08:00
|
|
|
class SCurvePt {
|
|
|
|
public:
|
|
|
|
int tag;
|
|
|
|
Vector p;
|
|
|
|
bool vertex;
|
|
|
|
};
|
|
|
|
|
2009-01-10 16:18:54 +08:00
|
|
|
class SCurve {
|
|
|
|
public:
|
|
|
|
hSCurve h;
|
|
|
|
|
2009-02-27 21:04:36 +08:00
|
|
|
// In a Boolean, C = A op B. The curves in A and B get copied into C, and
|
|
|
|
// therefore must get new hSCurves assigned. For the curves in A and B,
|
|
|
|
// we use newH to record their new handle in C.
|
|
|
|
hSCurve newH;
|
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 16:31:20 +08:00
|
|
|
enum class Source : uint32_t {
|
|
|
|
A = 100,
|
|
|
|
B = 200,
|
|
|
|
INTERSECTION = 300
|
2013-09-10 03:50:32 +08: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 16:31:20 +08:00
|
|
|
Source source;
|
2009-01-25 19:52:29 +08:00
|
|
|
|
2009-01-19 18:37:10 +08:00
|
|
|
bool isExact;
|
|
|
|
SBezier exact;
|
|
|
|
|
2009-05-18 15:26:51 +08:00
|
|
|
List<SCurvePt> pts;
|
2009-01-19 18:37:10 +08:00
|
|
|
|
2009-01-27 15:59:58 +08:00
|
|
|
hSSurface surfA;
|
|
|
|
hSSurface surfB;
|
|
|
|
|
2016-05-21 13:18:00 +08:00
|
|
|
static SCurve FromTransformationOf(SCurve *a, Vector t,
|
|
|
|
Quaternion q, double scale);
|
2009-02-27 21:04:36 +08:00
|
|
|
SCurve MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB,
|
2016-05-21 13:18:00 +08:00
|
|
|
SSurface *srfA, SSurface *srfB) const;
|
2009-05-18 15:26:51 +08:00
|
|
|
void RemoveShortSegments(SSurface *srfA, SSurface *srfB);
|
2016-05-21 13:18:00 +08:00
|
|
|
SSurface *GetSurfaceA(SShell *a, SShell *b) const;
|
|
|
|
SSurface *GetSurfaceB(SShell *a, SShell *b) const;
|
2009-01-23 11:30:30 +08:00
|
|
|
|
2016-05-05 13:54:05 +08:00
|
|
|
void Clear();
|
2009-01-10 16:18:54 +08:00
|
|
|
};
|
|
|
|
|
2009-01-14 13:10:42 +08:00
|
|
|
// A segment of a curve by which a surface is trimmed: indicates which curve,
|
|
|
|
// by its handle, and the starting and ending points of our segment of it.
|
|
|
|
// The vector out points out of the surface; it, the surface outer normal,
|
|
|
|
// and a tangent to the beginning of the curve are all orthogonal.
|
2009-01-10 16:18:54 +08:00
|
|
|
class STrimBy {
|
|
|
|
public:
|
|
|
|
hSCurve curve;
|
2009-01-25 17:19:59 +08:00
|
|
|
bool backwards;
|
|
|
|
// If a trim runs backwards, then start and finish still correspond to
|
|
|
|
// the actual start and finish, but they appear in reverse order in
|
|
|
|
// the referenced curve.
|
2009-01-10 16:18:54 +08:00
|
|
|
Vector start;
|
|
|
|
Vector finish;
|
2009-01-19 18:37:10 +08:00
|
|
|
|
2016-05-25 20:08:19 +08:00
|
|
|
static STrimBy EntireCurve(SShell *shell, hSCurve hsc, bool backwards);
|
2009-01-10 16:18:54 +08:00
|
|
|
};
|
|
|
|
|
2009-02-01 21:01:28 +08:00
|
|
|
// An intersection point between a line and a surface
|
|
|
|
class SInter {
|
|
|
|
public:
|
2009-02-27 21:04:36 +08:00
|
|
|
int tag;
|
2009-02-01 21:01:28 +08:00
|
|
|
Vector p;
|
2009-02-27 21:04:36 +08:00
|
|
|
SSurface *srf;
|
2009-06-04 11:59:40 +08:00
|
|
|
Point2d pinter;
|
|
|
|
Vector surfNormal; // of the intersecting surface, at pinter
|
|
|
|
bool onEdge; // pinter is on edge of trim poly
|
2009-02-01 21:01:28 +08:00
|
|
|
};
|
|
|
|
|
2009-01-19 18:37:10 +08:00
|
|
|
// A rational polynomial surface in Bezier form.
|
2009-01-10 16:18:54 +08:00
|
|
|
class SSurface {
|
|
|
|
public:
|
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 16:31:20 +08:00
|
|
|
|
|
|
|
enum class CombineAs : uint32_t {
|
|
|
|
UNION = 10,
|
|
|
|
DIFFERENCE = 11,
|
|
|
|
INTERSECT = 12
|
|
|
|
};
|
|
|
|
|
2009-06-05 13:38:41 +08:00
|
|
|
int tag;
|
2009-01-10 16:18:54 +08:00
|
|
|
hSSurface h;
|
|
|
|
|
2009-03-16 07:04:45 +08:00
|
|
|
// Same as newH for the curves; record what a surface gets renamed to
|
|
|
|
// when I copy things over.
|
|
|
|
hSSurface newH;
|
|
|
|
|
2015-07-10 19:54:39 +08:00
|
|
|
RgbaColor color;
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 13:45:13 +08:00
|
|
|
uint32_t face;
|
2009-01-25 17:19:59 +08:00
|
|
|
|
2009-01-14 13:10:42 +08:00
|
|
|
int degm, degn;
|
2009-01-10 16:18:54 +08:00
|
|
|
Vector ctrl[4][4];
|
2009-01-14 13:10:42 +08:00
|
|
|
double weight[4][4];
|
2009-01-10 16:18:54 +08:00
|
|
|
|
2009-01-15 11:55:42 +08:00
|
|
|
List<STrimBy> trim;
|
2009-01-17 13:28:49 +08:00
|
|
|
|
2009-02-01 13:13:43 +08:00
|
|
|
// For testing whether a point (u, v) on the surface lies inside the trim
|
|
|
|
SBspUv *bsp;
|
2009-06-04 11:59:40 +08:00
|
|
|
SEdgeList edges;
|
2009-01-27 15:59:58 +08:00
|
|
|
|
2009-08-21 12:58:28 +08:00
|
|
|
// For caching our initial (u, v) when doing Newton iterations to project
|
|
|
|
// a point into our surface.
|
|
|
|
Point2d cached;
|
|
|
|
|
2009-01-19 11:51:00 +08:00
|
|
|
static SSurface FromExtrusionOf(SBezier *spc, Vector t0, Vector t1);
|
2009-04-29 10:42:44 +08:00
|
|
|
static SSurface FromRevolutionOf(SBezier *sb, Vector pt, Vector axis,
|
|
|
|
double thetas, double thetaf);
|
2009-01-25 19:52:29 +08:00
|
|
|
static SSurface FromPlane(Vector pt, Vector u, Vector v);
|
2009-10-09 20:57:10 +08:00
|
|
|
static SSurface FromTransformationOf(SSurface *a, Vector t, Quaternion q,
|
2009-12-15 20:26:22 +08:00
|
|
|
double scale,
|
2009-01-23 11:30:30 +08:00
|
|
|
bool includingTrims);
|
2009-10-12 17:28:34 +08:00
|
|
|
void ScaleSelfBy(double s);
|
2009-01-17 13:28:49 +08:00
|
|
|
|
2009-06-04 11:59:40 +08:00
|
|
|
void EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
|
|
|
|
Vector *pt, Vector *enin, Vector *enout,
|
|
|
|
Vector *surfn,
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 13:45:13 +08:00
|
|
|
uint32_t auxA,
|
2009-06-19 15:56:33 +08:00
|
|
|
SShell *shell, SShell *sha, SShell *shb);
|
2009-06-27 13:53:56 +08:00
|
|
|
void FindChainAvoiding(SEdgeList *src, SEdgeList *dest, SPointList *avoid);
|
2009-06-19 15:56:33 +08:00
|
|
|
SSurface MakeCopyTrimAgainst(SShell *parent, SShell *a, SShell *b,
|
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 16:31:20 +08:00
|
|
|
SShell *into, SSurface::CombineAs type);
|
2009-06-05 13:38:41 +08:00
|
|
|
void TrimFromEdgeList(SEdgeList *el, bool asUv);
|
2015-03-29 08:30:52 +08:00
|
|
|
void IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
|
2009-02-01 13:13:43 +08:00
|
|
|
SShell *into);
|
2009-02-27 21:04:36 +08:00
|
|
|
void AddExactIntersectionCurve(SBezier *sb, SSurface *srfB,
|
2009-02-23 18:06:02 +08:00
|
|
|
SShell *agnstA, SShell *agnstB, SShell *into);
|
2009-03-20 01:40:11 +08:00
|
|
|
|
2009-03-08 18:59:57 +08:00
|
|
|
typedef struct {
|
|
|
|
int tag;
|
|
|
|
Point2d p;
|
|
|
|
} Inter;
|
2016-05-05 13:54:05 +08:00
|
|
|
void WeightControlPoints();
|
|
|
|
void UnWeightControlPoints();
|
2009-03-08 18:59:57 +08:00
|
|
|
void CopyRowOrCol(bool row, int this_ij, SSurface *src, int src_ij);
|
|
|
|
void BlendRowOrCol(bool row, int this_ij, SSurface *a, int a_ij,
|
|
|
|
SSurface *b, int b_ij);
|
2016-05-21 13:18:00 +08:00
|
|
|
double DepartureFromCoplanar() const;
|
2009-03-08 18:59:57 +08:00
|
|
|
void SplitInHalf(bool byU, SSurface *sa, SSurface *sb);
|
2009-02-23 18:06:02 +08:00
|
|
|
void AllPointsIntersecting(Vector a, Vector b,
|
2016-05-21 13:18:00 +08:00
|
|
|
List<SInter> *l,
|
2016-05-25 20:08:19 +08:00
|
|
|
bool asSegment, bool trimmed, bool inclTangent);
|
2009-03-08 18:59:57 +08:00
|
|
|
void AllPointsIntersectingUntrimmed(Vector a, Vector b,
|
2016-05-21 13:18:00 +08:00
|
|
|
int *cnt, int *level,
|
2016-05-25 20:08:19 +08:00
|
|
|
List<Inter> *l, bool asSegment,
|
2016-05-21 13:18:00 +08:00
|
|
|
SSurface *sorig);
|
2009-01-25 19:52:29 +08:00
|
|
|
|
2016-05-25 20:08:19 +08:00
|
|
|
void ClosestPointTo(Vector p, Point2d *puv, bool mustConverge=true);
|
|
|
|
void ClosestPointTo(Vector p, double *u, double *v, bool mustConverge=true);
|
|
|
|
bool ClosestPointNewton(Vector p, double *u, double *v, bool mustConverge=true) const;
|
2009-08-21 12:58:28 +08:00
|
|
|
|
2016-05-21 13:18:00 +08:00
|
|
|
bool PointIntersectingLine(Vector p0, Vector p1, double *u, double *v) const;
|
2009-06-04 11:59:40 +08:00
|
|
|
Vector ClosestPointOnThisAndSurface(SSurface *srf2, Vector p);
|
2009-02-27 21:04:36 +08:00
|
|
|
void PointOnSurfaces(SSurface *s1, SSurface *s2, double *u, double *v);
|
2016-05-21 13:18:00 +08:00
|
|
|
Vector PointAt(double u, double v) const;
|
|
|
|
Vector PointAt(Point2d puv) const;
|
|
|
|
void TangentsAt(double u, double v, Vector *tu, Vector *tv) const;
|
|
|
|
Vector NormalAt(Point2d puv) const;
|
|
|
|
Vector NormalAt(double u, double v) const;
|
2016-05-25 20:08:19 +08:00
|
|
|
bool LineEntirelyOutsideBbox(Vector a, Vector b, bool asSegment) const;
|
2016-05-21 13:18:00 +08:00
|
|
|
void GetAxisAlignedBounding(Vector *ptMax, Vector *ptMin) const;
|
|
|
|
bool CoincidentWithPlane(Vector n, double d) const;
|
|
|
|
bool CoincidentWith(SSurface *ss, bool sameNormal) const;
|
|
|
|
bool IsExtrusion(SBezier *of, Vector *along) const;
|
2009-04-15 10:55:18 +08:00
|
|
|
bool IsCylinder(Vector *axis, Vector *center, double *r,
|
2016-05-21 13:18:00 +08:00
|
|
|
Vector *start, Vector *finish) const;
|
2009-01-19 11:33:15 +08:00
|
|
|
|
2009-01-19 18:37:10 +08:00
|
|
|
void TriangulateInto(SShell *shell, SMesh *sm);
|
2009-08-21 12:58:28 +08:00
|
|
|
|
|
|
|
// these are intended as bitmasks, even though there's just one now
|
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 16:31:20 +08:00
|
|
|
enum class MakeAs : uint32_t {
|
|
|
|
UV = 0x01,
|
|
|
|
XYZ = 0x00
|
2013-09-10 03:50:32 +08: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 16:31:20 +08:00
|
|
|
void MakeTrimEdgesInto(SEdgeList *sel, MakeAs flags, SCurve *sc, STrimBy *stb);
|
|
|
|
void MakeEdgesInto(SShell *shell, SEdgeList *sel, MakeAs flags,
|
2016-05-21 13:18:00 +08:00
|
|
|
SShell *useCurvesFrom=NULL);
|
2009-08-21 12:58:28 +08:00
|
|
|
|
2009-06-22 10:54:09 +08:00
|
|
|
Vector ExactSurfaceTangentAt(Vector p, SSurface *srfA, SSurface *srfB,
|
|
|
|
Vector dir);
|
2009-04-14 12:19:23 +08:00
|
|
|
void MakeSectionEdgesInto(SShell *shell, SEdgeList *sel, SBezierList *sbl);
|
2009-06-04 11:59:40 +08:00
|
|
|
void MakeClassifyingBsp(SShell *shell, SShell *useCurvesFrom);
|
2016-05-21 13:18:00 +08:00
|
|
|
double ChordToleranceForEdge(Vector a, Vector b) const;
|
2009-05-08 16:33:04 +08:00
|
|
|
void MakeTriangulationGridInto(List<double> *l, double vs, double vf,
|
2016-05-21 13:18:00 +08:00
|
|
|
bool swapped) const;
|
|
|
|
Vector PointAtMaybeSwapped(double u, double v, bool swapped) const;
|
2009-01-19 18:37:10 +08:00
|
|
|
|
2016-05-05 13:54:05 +08:00
|
|
|
void Reverse();
|
|
|
|
void Clear();
|
2009-01-10 16:18:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SShell {
|
|
|
|
public:
|
2009-01-14 13:10:42 +08:00
|
|
|
IdList<SCurve,hSCurve> curve;
|
2009-01-10 16:18:54 +08:00
|
|
|
IdList<SSurface,hSSurface> surface;
|
2009-01-17 13:28:49 +08:00
|
|
|
|
2009-05-30 16:49:09 +08:00
|
|
|
bool booleanFailed;
|
|
|
|
|
2009-01-25 17:19:59 +08:00
|
|
|
void MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1,
|
2015-07-10 19:54:39 +08:00
|
|
|
RgbaColor color);
|
2009-04-29 10:42:44 +08:00
|
|
|
void MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
|
2015-10-31 16:22:26 +08:00
|
|
|
RgbaColor color, Group *group);
|
2009-01-25 19:52:29 +08:00
|
|
|
|
2009-01-23 11:30:30 +08:00
|
|
|
void MakeFromUnionOf(SShell *a, SShell *b);
|
|
|
|
void MakeFromDifferenceOf(SShell *a, SShell *b);
|
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 16:31:20 +08:00
|
|
|
void MakeFromBoolean(SShell *a, SShell *b, SSurface::CombineAs type);
|
2009-02-27 21:04:36 +08:00
|
|
|
void CopyCurvesSplitAgainst(bool opA, SShell *agnst, SShell *into);
|
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 16:31:20 +08:00
|
|
|
void CopySurfacesTrimAgainst(SShell *sha, SShell *shb, SShell *into, SSurface::CombineAs type);
|
2009-01-27 15:59:58 +08:00
|
|
|
void MakeIntersectionCurvesAgainst(SShell *against, SShell *into);
|
2009-06-04 11:59:40 +08:00
|
|
|
void MakeClassifyingBsps(SShell *useCurvesFrom);
|
2009-02-23 18:06:02 +08:00
|
|
|
void AllPointsIntersecting(Vector a, Vector b, List<SInter> *il,
|
2016-05-25 20:08:19 +08:00
|
|
|
bool asSegment, bool trimmed, bool inclTangent);
|
2009-02-09 20:40:48 +08:00
|
|
|
void MakeCoincidentEdgesInto(SSurface *proto, bool sameNormal,
|
2009-03-16 07:04:45 +08:00
|
|
|
SEdgeList *el, SShell *useCurvesFrom);
|
2009-05-20 11:04:36 +08:00
|
|
|
void RewriteSurfaceHandlesForCurves(SShell *a, SShell *b);
|
2016-05-05 13:54:05 +08:00
|
|
|
void CleanupAfterBoolean();
|
2009-01-25 19:52:29 +08:00
|
|
|
|
2009-06-04 11:59:40 +08:00
|
|
|
// Definitions when classifying regions of a surface; it is either inside,
|
|
|
|
// outside, or coincident (with parallel or antiparallel normal) with a
|
|
|
|
// shell.
|
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 16:31:20 +08:00
|
|
|
enum class Class : uint32_t {
|
2013-09-10 03:50:32 +08:00
|
|
|
INSIDE = 100,
|
|
|
|
OUTSIDE = 200,
|
|
|
|
COINC_SAME = 300,
|
|
|
|
COINC_OPP = 400
|
|
|
|
};
|
2009-06-04 11:59:40 +08:00
|
|
|
static const double DOTP_TOL;
|
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 16:31:20 +08:00
|
|
|
Class ClassifyRegion(Vector edge_n, Vector inter_surf_n,
|
2016-05-21 13:18:00 +08:00
|
|
|
Vector edge_surf_n) 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 16:31:20 +08:00
|
|
|
bool ClassifyEdge(Class *indir, Class *outdir,
|
2009-06-04 11:59:40 +08:00
|
|
|
Vector ea, Vector eb,
|
2016-05-21 13:18:00 +08:00
|
|
|
Vector p, Vector edge_n_in,
|
|
|
|
Vector edge_n_out, Vector surf_n);
|
2009-02-01 21:01:28 +08:00
|
|
|
|
2009-01-23 11:30:30 +08:00
|
|
|
void MakeFromCopyOf(SShell *a);
|
2009-12-15 20:26:22 +08:00
|
|
|
void MakeFromTransformationOf(SShell *a,
|
2016-05-21 13:18:00 +08:00
|
|
|
Vector trans, Quaternion q, double scale);
|
2009-05-20 11:04:36 +08:00
|
|
|
void MakeFromAssemblyOf(SShell *a, SShell *b);
|
2016-05-05 13:54:05 +08:00
|
|
|
void MergeCoincidentSurfaces();
|
2009-01-19 18:37:10 +08:00
|
|
|
|
|
|
|
void TriangulateInto(SMesh *sm);
|
2009-01-23 11:30:30 +08:00
|
|
|
void MakeEdgesInto(SEdgeList *sel);
|
2016-05-21 13:18:00 +08:00
|
|
|
void MakeSectionEdgesInto(Vector n, double d, SEdgeList *sel, SBezierList *sbl);
|
|
|
|
bool IsEmpty() const;
|
2009-05-24 19:37:07 +08:00
|
|
|
void RemapFaces(Group *g, int remap);
|
2016-05-05 13:54:05 +08:00
|
|
|
void Clear();
|
2009-01-10 16:18:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|