Rewrite declarations of form f(void) as f().
In C++ there is no difference and newly added functions are all declared as f(), so this brings back consistency.
This commit is contained in:
parent
ad4a204edf
commit
bbca4cc224
@ -36,7 +36,7 @@ static void *CheckMalloc(size_t n)
|
|||||||
* An example of a constraint in 3d. We create a single group, with some
|
* An example of a constraint in 3d. We create a single group, with some
|
||||||
* entities and constraints.
|
* entities and constraints.
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
void Example3d(void)
|
void Example3d()
|
||||||
{
|
{
|
||||||
/* This will contain a single group, which will arbitrarily number 1. */
|
/* This will contain a single group, which will arbitrarily number 1. */
|
||||||
Slvs_hGroup g = 1;
|
Slvs_hGroup g = 1;
|
||||||
@ -88,7 +88,7 @@ void Example3d(void)
|
|||||||
* along the reference frame's xy plane. In a second group, we create some
|
* along the reference frame's xy plane. In a second group, we create some
|
||||||
* entities in that group and dimension them.
|
* entities in that group and dimension them.
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
void Example2d(void)
|
void Example2d()
|
||||||
{
|
{
|
||||||
Slvs_hGroup g;
|
Slvs_hGroup g;
|
||||||
double qw, qx, qy, qz;
|
double qw, qx, qy, qz;
|
||||||
@ -254,7 +254,7 @@ void Example2d(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main()
|
||||||
{
|
{
|
||||||
sys.param = CheckMalloc(50*sizeof(sys.param[0]));
|
sys.param = CheckMalloc(50*sizeof(sys.param[0]));
|
||||||
sys.entity = CheckMalloc(50*sizeof(sys.entity[0]));
|
sys.entity = CheckMalloc(50*sizeof(sys.entity[0]));
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
SBsp2 *SBsp2::Alloc(void) { return (SBsp2 *)AllocTemporary(sizeof(SBsp2)); }
|
SBsp2 *SBsp2::Alloc() { return (SBsp2 *)AllocTemporary(sizeof(SBsp2)); }
|
||||||
SBsp3 *SBsp3::Alloc(void) { return (SBsp3 *)AllocTemporary(sizeof(SBsp3)); }
|
SBsp3 *SBsp3::Alloc() { return (SBsp3 *)AllocTemporary(sizeof(SBsp3)); }
|
||||||
|
|
||||||
SBsp3 *SBsp3::FromMesh(SMesh *m) {
|
SBsp3 *SBsp3::FromMesh(SMesh *m) {
|
||||||
SBsp3 *bsp3 = NULL;
|
SBsp3 *bsp3 = NULL;
|
||||||
@ -424,7 +424,7 @@ void SBsp3::GenerateInPaintOrder(SMesh *m) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBsp3::DebugDraw(void) {
|
void SBsp3::DebugDraw() {
|
||||||
|
|
||||||
if(pos) pos->DebugDraw();
|
if(pos) pos->DebugDraw();
|
||||||
Vector norm = tri.Normal();
|
Vector norm = tri.Normal();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
void SolveSpaceUI::Clipboard::Clear(void) {
|
void SolveSpaceUI::Clipboard::Clear() {
|
||||||
c.Clear();
|
c.Clear();
|
||||||
r.Clear();
|
r.Clear();
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ hEntity SolveSpaceUI::Clipboard::NewEntityFor(hEntity he) {
|
|||||||
ssassert(false, "Expected to find entity in some clipboard request");
|
ssassert(false, "Expected to find entity in some clipboard request");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::DeleteSelection(void) {
|
void GraphicsWindow::DeleteSelection() {
|
||||||
SK.request.ClearTags();
|
SK.request.ClearTags();
|
||||||
SK.constraint.ClearTags();
|
SK.constraint.ClearTags();
|
||||||
List<Selection> *ls = &(selection);
|
List<Selection> *ls = &(selection);
|
||||||
@ -69,7 +69,7 @@ void GraphicsWindow::DeleteSelection(void) {
|
|||||||
DeleteTaggedRequests();
|
DeleteTaggedRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::CopySelection(void) {
|
void GraphicsWindow::CopySelection() {
|
||||||
SS.clipboard.Clear();
|
SS.clipboard.Clear();
|
||||||
|
|
||||||
Entity *wrkpl = SK.GetEntity(ActiveWorkplane());
|
Entity *wrkpl = SK.GetEntity(ActiveWorkplane());
|
||||||
@ -386,7 +386,7 @@ void TextWindow::ScreenPasteTransformed(int link, uint32_t v) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ShowPasteTransformed(void) {
|
void TextWindow::ShowPasteTransformed() {
|
||||||
Printf(true, "%FtPASTE TRANSFORMED%E");
|
Printf(true, "%FtPASTE TRANSFORMED%E");
|
||||||
Printf(true, "%Ba %Ftrepeat%E %d time%s %Fl%Lt%f[change]%E",
|
Printf(true, "%Ba %Ftrepeat%E %d time%s %Fl%Lt%f[change]%E",
|
||||||
shown.paste.times, (shown.paste.times == 1) ? "" : "s",
|
shown.paste.times, (shown.paste.times == 1) ? "" : "s",
|
||||||
|
@ -160,7 +160,7 @@ void TextWindow::ScreenChangeAutosaveInterval(int link, uint32_t v) {
|
|||||||
SS.TW.edit.meaning = EDIT_AUTOSAVE_INTERVAL;
|
SS.TW.edit.meaning = EDIT_AUTOSAVE_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ShowConfiguration(void) {
|
void TextWindow::ShowConfiguration() {
|
||||||
int i;
|
int i;
|
||||||
Printf(true, "%Ft user color (r, g, b)");
|
Printf(true, "%Ft user color (r, g, b)");
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
std::string Constraint::DescriptionString(void) {
|
std::string Constraint::DescriptionString() {
|
||||||
const char *s;
|
const char *s;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case POINTS_COINCIDENT: s = "pts-coincident"; break;
|
case POINTS_COINCIDENT: s = "pts-coincident"; break;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
const hConstraint ConstraintBase::NO_CONSTRAINT = { 0 };
|
const hConstraint ConstraintBase::NO_CONSTRAINT = { 0 };
|
||||||
|
|
||||||
bool ConstraintBase::HasLabel(void) {
|
bool ConstraintBase::HasLabel() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case PT_LINE_DISTANCE:
|
case PT_LINE_DISTANCE:
|
||||||
case PT_PLANE_DISTANCE:
|
case PT_PLANE_DISTANCE:
|
||||||
@ -166,7 +166,7 @@ ExprVector ConstraintBase::PointInThreeSpace(hEntity workplane,
|
|||||||
return (ub.ScaledBy(u)).Plus(vb.ScaledBy(v)).Plus(ob);
|
return (ub.ScaledBy(u)).Plus(vb.ScaledBy(v)).Plus(ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstraintBase::ModifyToSatisfy(void) {
|
void ConstraintBase::ModifyToSatisfy() {
|
||||||
if(type == ANGLE) {
|
if(type == ANGLE) {
|
||||||
Vector a = SK.GetEntity(entityA)->VectorGetNum();
|
Vector a = SK.GetEntity(entityA)->VectorGetNum();
|
||||||
Vector b = SK.GetEntity(entityB)->VectorGetNum();
|
Vector b = SK.GetEntity(entityB)->VectorGetNum();
|
||||||
|
@ -51,7 +51,7 @@ void TextWindow::ScreenConstraintShowAsRadius(int link, uint32_t v) {
|
|||||||
SS.ScheduleShowTW();
|
SS.ScheduleShowTW();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::DescribeSelection(void) {
|
void TextWindow::DescribeSelection() {
|
||||||
Entity *e;
|
Entity *e;
|
||||||
Vector p;
|
Vector p;
|
||||||
int i;
|
int i;
|
||||||
|
20
src/draw.cpp
20
src/draw.cpp
@ -13,24 +13,24 @@ bool GraphicsWindow::Selection::Equals(Selection *b) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsWindow::Selection::IsEmpty(void) {
|
bool GraphicsWindow::Selection::IsEmpty() {
|
||||||
if(entity.v) return false;
|
if(entity.v) return false;
|
||||||
if(constraint.v) return false;
|
if(constraint.v) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsWindow::Selection::HasEndpoints(void) {
|
bool GraphicsWindow::Selection::HasEndpoints() {
|
||||||
if(!entity.v) return false;
|
if(!entity.v) return false;
|
||||||
Entity *e = SK.GetEntity(entity);
|
Entity *e = SK.GetEntity(entity);
|
||||||
return e->HasEndpoints();
|
return e->HasEndpoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::Selection::Clear(void) {
|
void GraphicsWindow::Selection::Clear() {
|
||||||
entity.v = constraint.v = 0;
|
entity.v = constraint.v = 0;
|
||||||
emphasized = false;
|
emphasized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::Selection::Draw(void) {
|
void GraphicsWindow::Selection::Draw() {
|
||||||
Vector refp = Vector::From(0, 0, 0);
|
Vector refp = Vector::From(0, 0, 0);
|
||||||
if(entity.v) {
|
if(entity.v) {
|
||||||
Entity *e = SK.GetEntity(entity);
|
Entity *e = SK.GetEntity(entity);
|
||||||
@ -62,13 +62,13 @@ void GraphicsWindow::Selection::Draw(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::ClearSelection(void) {
|
void GraphicsWindow::ClearSelection() {
|
||||||
selection.Clear();
|
selection.Clear();
|
||||||
SS.ScheduleShowTW();
|
SS.ScheduleShowTW();
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::ClearNonexistentSelectionItems(void) {
|
void GraphicsWindow::ClearNonexistentSelectionItems() {
|
||||||
bool change = false;
|
bool change = false;
|
||||||
Selection *s;
|
Selection *s;
|
||||||
selection.ClearTags();
|
selection.ClearTags();
|
||||||
@ -184,7 +184,7 @@ void GraphicsWindow::MakeSelected(Selection *stog) {
|
|||||||
// points, we test by the point location. For normals, we test by the normal's
|
// points, we test by the point location. For normals, we test by the normal's
|
||||||
// associated point. For anything else, we test by any piecewise linear edge.
|
// associated point. For anything else, we test by any piecewise linear edge.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void GraphicsWindow::SelectByMarquee(void) {
|
void GraphicsWindow::SelectByMarquee() {
|
||||||
Point2d begin = ProjectPoint(orig.marqueePoint);
|
Point2d begin = ProjectPoint(orig.marqueePoint);
|
||||||
double xmin = min(orig.mouse.x, begin.x),
|
double xmin = min(orig.mouse.x, begin.x),
|
||||||
xmax = max(orig.mouse.x, begin.x),
|
xmax = max(orig.mouse.x, begin.x),
|
||||||
@ -239,7 +239,7 @@ void GraphicsWindow::SelectByMarquee(void) {
|
|||||||
// constraints separately, counts of certain types of entities (circles,
|
// constraints separately, counts of certain types of entities (circles,
|
||||||
// lines, etc.), and so on.
|
// lines, etc.), and so on.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void GraphicsWindow::GroupSelection(void) {
|
void GraphicsWindow::GroupSelection() {
|
||||||
gs = {};
|
gs = {};
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < selection.n && i < MAX_SELECTED; i++) {
|
for(i = 0; i < selection.n && i < MAX_SELECTED; i++) {
|
||||||
@ -442,7 +442,7 @@ Vector GraphicsWindow::UnProjectPoint3(Vector p) {
|
|||||||
return orig;
|
return orig;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::NormalizeProjectionVectors(void) {
|
void GraphicsWindow::NormalizeProjectionVectors() {
|
||||||
if(projRight.Magnitude() < LENGTH_EPS) {
|
if(projRight.Magnitude() < LENGTH_EPS) {
|
||||||
projRight = Vector::From(1, 0, 0);
|
projRight = Vector::From(1, 0, 0);
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ Vector GraphicsWindow::VectorFromProjs(Vector rightUpForward) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::Paint(void) {
|
void GraphicsWindow::Paint() {
|
||||||
int i;
|
int i;
|
||||||
havePainted = true;
|
havePainted = true;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ static void LineCallback(void *fndata, Vector a, Vector b)
|
|||||||
c->LineDrawOrGetDistance(a, b);
|
c->LineDrawOrGetDistance(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Constraint::Label(void) {
|
std::string Constraint::Label() {
|
||||||
std::string result;
|
std::string result;
|
||||||
if(type == ANGLE) {
|
if(type == ANGLE) {
|
||||||
if(valA == floor(valA)) {
|
if(valA == floor(valA)) {
|
||||||
@ -1170,7 +1170,7 @@ s:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Constraint::Draw(void) {
|
void Constraint::Draw() {
|
||||||
dogd.drawing = true;
|
dogd.drawing = true;
|
||||||
dogd.sel = NULL;
|
dogd.sel = NULL;
|
||||||
hStyle hs = GetStyle();
|
hStyle hs = GetStyle();
|
||||||
@ -1192,7 +1192,7 @@ double Constraint::GetDistance(Point2d mp) {
|
|||||||
return dogd.dmin;
|
return dogd.dmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Constraint::GetLabelPos(void) {
|
Vector Constraint::GetLabelPos() {
|
||||||
dogd.drawing = false;
|
dogd.drawing = false;
|
||||||
dogd.sel = NULL;
|
dogd.sel = NULL;
|
||||||
dogd.mp.x = 0; dogd.mp.y = 0;
|
dogd.mp.x = 0; dogd.mp.y = 0;
|
||||||
@ -1203,7 +1203,7 @@ Vector Constraint::GetLabelPos(void) {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Constraint::GetReferencePos(void) {
|
Vector Constraint::GetReferencePos() {
|
||||||
dogd.drawing = false;
|
dogd.drawing = false;
|
||||||
dogd.sel = NULL;
|
dogd.sel = NULL;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
std::string Entity::DescriptionString(void) {
|
std::string Entity::DescriptionString() {
|
||||||
if(h.isFromRequest()) {
|
if(h.isFromRequest()) {
|
||||||
Request *r = SK.GetRequest(h.request());
|
Request *r = SK.GetRequest(h.request());
|
||||||
return r->DescriptionString();
|
return r->DescriptionString();
|
||||||
@ -202,7 +202,7 @@ double Entity::GetDistance(Point2d mp) {
|
|||||||
return dogd.dmin;
|
return dogd.dmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Entity::GetReferencePos(void) {
|
Vector Entity::GetReferencePos() {
|
||||||
dogd.drawing = false;
|
dogd.drawing = false;
|
||||||
|
|
||||||
dogd.refp = SS.GW.offset.ScaledBy(-1);
|
dogd.refp = SS.GW.offset.ScaledBy(-1);
|
||||||
@ -218,7 +218,7 @@ bool Entity::IsStylable() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::IsVisible(void) {
|
bool Entity::IsVisible() {
|
||||||
Group *g = SK.GetGroup(group);
|
Group *g = SK.GetGroup(group);
|
||||||
|
|
||||||
if(g->h.v == Group::HGROUP_REFERENCES.v && IsNormal()) {
|
if(g->h.v == Group::HGROUP_REFERENCES.v && IsNormal()) {
|
||||||
@ -271,7 +271,7 @@ void Entity::CalculateNumerical(bool forExport) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::PointIsFromReferences(void) {
|
bool Entity::PointIsFromReferences() {
|
||||||
return h.request().IsFromReferences();
|
return h.request().IsFromReferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +519,7 @@ void Entity::GenerateBezierCurves(SBezierList *sbl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::DrawOrGetDistance(void) {
|
void Entity::DrawOrGetDistance() {
|
||||||
// If we're about to perform hit testing on an entity, consider
|
// If we're about to perform hit testing on an entity, consider
|
||||||
// whether the pointer is inside its bounding box first.
|
// whether the pointer is inside its bounding box first.
|
||||||
if(!dogd.drawing) {
|
if(!dogd.drawing) {
|
||||||
|
70
src/dsc.h
70
src/dsc.h
@ -30,20 +30,20 @@ public:
|
|||||||
Quaternion Plus(Quaternion b);
|
Quaternion Plus(Quaternion b);
|
||||||
Quaternion Minus(Quaternion b);
|
Quaternion Minus(Quaternion b);
|
||||||
Quaternion ScaledBy(double s);
|
Quaternion ScaledBy(double s);
|
||||||
double Magnitude(void);
|
double Magnitude();
|
||||||
Quaternion WithMagnitude(double s);
|
Quaternion WithMagnitude(double s);
|
||||||
|
|
||||||
// Call a rotation matrix [ u' v' n' ]'; this returns the first and
|
// Call a rotation matrix [ u' v' n' ]'; this returns the first and
|
||||||
// second rows, where that matrix is generated by this quaternion
|
// second rows, where that matrix is generated by this quaternion
|
||||||
Vector RotationU(void);
|
Vector RotationU();
|
||||||
Vector RotationV(void);
|
Vector RotationV();
|
||||||
Vector RotationN(void);
|
Vector RotationN();
|
||||||
Vector Rotate(Vector p);
|
Vector Rotate(Vector p);
|
||||||
|
|
||||||
Quaternion ToThe(double p);
|
Quaternion ToThe(double p);
|
||||||
Quaternion Inverse(void);
|
Quaternion Inverse();
|
||||||
Quaternion Times(Quaternion b);
|
Quaternion Times(Quaternion b);
|
||||||
Quaternion Mirror(void);
|
Quaternion Mirror();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Vector {
|
class Vector {
|
||||||
@ -73,7 +73,7 @@ public:
|
|||||||
bool EqualsExactly(Vector v);
|
bool EqualsExactly(Vector v);
|
||||||
Vector Plus(Vector b);
|
Vector Plus(Vector b);
|
||||||
Vector Minus(Vector b);
|
Vector Minus(Vector b);
|
||||||
Vector Negated(void);
|
Vector Negated();
|
||||||
Vector Cross(Vector b);
|
Vector Cross(Vector b);
|
||||||
double DirectionCosineWith(Vector b);
|
double DirectionCosineWith(Vector b);
|
||||||
double Dot(Vector b);
|
double Dot(Vector b);
|
||||||
@ -85,14 +85,14 @@ public:
|
|||||||
double DistanceToLine(Vector p0, Vector dp);
|
double DistanceToLine(Vector p0, Vector dp);
|
||||||
bool OnLineSegment(Vector a, Vector b, double tol=LENGTH_EPS);
|
bool OnLineSegment(Vector a, Vector b, double tol=LENGTH_EPS);
|
||||||
Vector ClosestPointOnLine(Vector p0, Vector dp);
|
Vector ClosestPointOnLine(Vector p0, Vector dp);
|
||||||
double Magnitude(void);
|
double Magnitude();
|
||||||
double MagSquared(void);
|
double MagSquared();
|
||||||
Vector WithMagnitude(double s);
|
Vector WithMagnitude(double s);
|
||||||
Vector ScaledBy(double s);
|
Vector ScaledBy(double s);
|
||||||
Vector ProjectInto(hEntity wrkpl);
|
Vector ProjectInto(hEntity wrkpl);
|
||||||
Vector ProjectVectorInto(hEntity wrkpl);
|
Vector ProjectVectorInto(hEntity wrkpl);
|
||||||
double DivPivoting(Vector delta);
|
double DivPivoting(Vector delta);
|
||||||
Vector ClosestOrtho(void);
|
Vector ClosestOrtho();
|
||||||
void MakeMaxMin(Vector *maxv, Vector *minv);
|
void MakeMaxMin(Vector *maxv, Vector *minv);
|
||||||
Vector ClampWithin(double minv, double maxv);
|
Vector ClampWithin(double minv, double maxv);
|
||||||
static bool BoundingBoxesDisjoint(Vector amax, Vector amin,
|
static bool BoundingBoxesDisjoint(Vector amax, Vector amin,
|
||||||
@ -103,8 +103,8 @@ public:
|
|||||||
Vector InPerspective(Vector u, Vector v, Vector n,
|
Vector InPerspective(Vector u, Vector v, Vector n,
|
||||||
Vector origin, double cameraTan);
|
Vector origin, double cameraTan);
|
||||||
Point2d Project2d(Vector u, Vector v);
|
Point2d Project2d(Vector u, Vector v);
|
||||||
Point2d ProjectXy(void);
|
Point2d ProjectXy();
|
||||||
Vector4 Project4d(void);
|
Vector4 Project4d();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Vector4 {
|
class Vector4 {
|
||||||
@ -118,7 +118,7 @@ public:
|
|||||||
Vector4 Plus(Vector4 b);
|
Vector4 Plus(Vector4 b);
|
||||||
Vector4 Minus(Vector4 b);
|
Vector4 Minus(Vector4 b);
|
||||||
Vector4 ScaledBy(double s);
|
Vector4 ScaledBy(double s);
|
||||||
Vector PerspectiveProject(void);
|
Vector PerspectiveProject();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Point2d {
|
class Point2d {
|
||||||
@ -137,10 +137,10 @@ public:
|
|||||||
double DistanceToLine(const Point2d &p0, const Point2d &dp, bool segment) const;
|
double DistanceToLine(const Point2d &p0, const Point2d &dp, bool segment) const;
|
||||||
double Angle() const;
|
double Angle() const;
|
||||||
double AngleTo(const Point2d &p) const;
|
double AngleTo(const Point2d &p) const;
|
||||||
double Magnitude(void) const;
|
double Magnitude() const;
|
||||||
double MagSquared(void) const;
|
double MagSquared() const;
|
||||||
Point2d WithMagnitude(double v) const;
|
Point2d WithMagnitude(double v) const;
|
||||||
Point2d Normal(void) const;
|
Point2d Normal() const;
|
||||||
bool Equals(Point2d v, double tol=LENGTH_EPS) const;
|
bool Equals(Point2d v, double tol=LENGTH_EPS) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public:
|
|||||||
int n;
|
int n;
|
||||||
int elemsAllocated;
|
int elemsAllocated;
|
||||||
|
|
||||||
void AllocForOneMore(void) {
|
void AllocForOneMore() {
|
||||||
if(n >= elemsAllocated) {
|
if(n >= elemsAllocated) {
|
||||||
elemsAllocated = (elemsAllocated + 32)*2;
|
elemsAllocated = (elemsAllocated + 32)*2;
|
||||||
T *newElem = (T *)MemAlloc((size_t)elemsAllocated*sizeof(elem[0]));
|
T *newElem = (T *)MemAlloc((size_t)elemsAllocated*sizeof(elem[0]));
|
||||||
@ -178,7 +178,7 @@ public:
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *First(void) {
|
T *First() {
|
||||||
return (n == 0) ? NULL : &(elem[0]);
|
return (n == 0) ? NULL : &(elem[0]);
|
||||||
}
|
}
|
||||||
T *NextAfter(T *prev) {
|
T *NextAfter(T *prev) {
|
||||||
@ -187,14 +187,14 @@ public:
|
|||||||
return prev + 1;
|
return prev + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearTags(void) {
|
void ClearTags() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
elem[i].tag = 0;
|
elem[i].tag = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear(void) {
|
void Clear() {
|
||||||
for(int i = 0; i < n; i++)
|
for(int i = 0; i < n; i++)
|
||||||
elem[i].~T();
|
elem[i].~T();
|
||||||
if(elem) MemFree(elem);
|
if(elem) MemFree(elem);
|
||||||
@ -202,7 +202,7 @@ public:
|
|||||||
n = elemsAllocated = 0;
|
n = elemsAllocated = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveTagged(void) {
|
void RemoveTagged() {
|
||||||
int src, dest;
|
int src, dest;
|
||||||
dest = 0;
|
dest = 0;
|
||||||
for(src = 0; src < n; src++) {
|
for(src = 0; src < n; src++) {
|
||||||
@ -229,7 +229,7 @@ public:
|
|||||||
// and elemsAllocated is untouched, same as in RemoveTagged
|
// and elemsAllocated is untouched, same as in RemoveTagged
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reverse(void) {
|
void Reverse() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < (n/2); i++) {
|
for(i = 0; i < (n/2); i++) {
|
||||||
swap(elem[i], elem[(n-1)-i]);
|
swap(elem[i], elem[(n-1)-i]);
|
||||||
@ -247,7 +247,7 @@ public:
|
|||||||
int n;
|
int n;
|
||||||
int elemsAllocated;
|
int elemsAllocated;
|
||||||
|
|
||||||
uint32_t MaximumId(void) {
|
uint32_t MaximumId() {
|
||||||
uint32_t id = 0;
|
uint32_t id = 0;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -334,7 +334,7 @@ public:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *First(void) {
|
T *First() {
|
||||||
return (n == 0) ? NULL : &(elem[0]);
|
return (n == 0) ? NULL : &(elem[0]);
|
||||||
}
|
}
|
||||||
T *NextAfter(T *prev) {
|
T *NextAfter(T *prev) {
|
||||||
@ -343,7 +343,7 @@ public:
|
|||||||
return prev + 1;
|
return prev + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearTags(void) {
|
void ClearTags() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
elem[i].tag = 0;
|
elem[i].tag = 0;
|
||||||
@ -359,7 +359,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveTagged(void) {
|
void RemoveTagged() {
|
||||||
int src, dest;
|
int src, dest;
|
||||||
dest = 0;
|
dest = 0;
|
||||||
for(src = 0; src < n; src++) {
|
for(src = 0; src < n; src++) {
|
||||||
@ -399,7 +399,7 @@ public:
|
|||||||
l->n = n;
|
l->n = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear(void) {
|
void Clear() {
|
||||||
for(int i = 0; i < n; i++) {
|
for(int i = 0; i < n; i++) {
|
||||||
elem[i].Clear();
|
elem[i].Clear();
|
||||||
elem[i].~T();
|
elem[i].~T();
|
||||||
@ -424,7 +424,7 @@ public:
|
|||||||
double X[MAX_UNKNOWNS];
|
double X[MAX_UNKNOWNS];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
void Solve(void);
|
void Solve();
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RGBi(r, g, b) RgbaColor::From((r), (g), (b))
|
#define RGBi(r, g, b) RgbaColor::From((r), (g), (b))
|
||||||
@ -436,10 +436,10 @@ class RgbaColor {
|
|||||||
public:
|
public:
|
||||||
uint8_t red, green, blue, alpha;
|
uint8_t red, green, blue, alpha;
|
||||||
|
|
||||||
float redF(void) const { return (float)red / 255.0f; }
|
float redF() const { return (float)red / 255.0f; }
|
||||||
float greenF(void) const { return (float)green / 255.0f; }
|
float greenF() const { return (float)green / 255.0f; }
|
||||||
float blueF(void) const { return (float)blue / 255.0f; }
|
float blueF() const { return (float)blue / 255.0f; }
|
||||||
float alphaF(void) const { return (float)alpha / 255.0f; }
|
float alphaF() const { return (float)alpha / 255.0f; }
|
||||||
|
|
||||||
bool Equals(RgbaColor c) const {
|
bool Equals(RgbaColor c) const {
|
||||||
return
|
return
|
||||||
@ -449,7 +449,7 @@ public:
|
|||||||
c.alpha == alpha;
|
c.alpha == alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ToPackedIntBGRA(void) const {
|
uint32_t ToPackedIntBGRA() const {
|
||||||
return
|
return
|
||||||
blue |
|
blue |
|
||||||
(uint32_t)(green << 8) |
|
(uint32_t)(green << 8) |
|
||||||
@ -457,7 +457,7 @@ public:
|
|||||||
(uint32_t)((255 - alpha) << 24);
|
(uint32_t)((255 - alpha) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ToPackedInt(void) const {
|
uint32_t ToPackedInt() const {
|
||||||
return
|
return
|
||||||
red |
|
red |
|
||||||
(uint32_t)(green << 8) |
|
(uint32_t)(green << 8) |
|
||||||
@ -465,7 +465,7 @@ public:
|
|||||||
(uint32_t)((255 - alpha) << 24);
|
(uint32_t)((255 - alpha) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ToARGB32(void) const {
|
uint32_t ToARGB32() const {
|
||||||
return
|
return
|
||||||
blue |
|
blue |
|
||||||
(uint32_t)(green << 8) |
|
(uint32_t)(green << 8) |
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
const hEntity EntityBase::FREE_IN_3D = { 0 };
|
const hEntity EntityBase::FREE_IN_3D = { 0 };
|
||||||
const hEntity EntityBase::NO_ENTITY = { 0 };
|
const hEntity EntityBase::NO_ENTITY = { 0 };
|
||||||
|
|
||||||
bool EntityBase::HasVector(void) {
|
bool EntityBase::HasVector() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LINE_SEGMENT:
|
case LINE_SEGMENT:
|
||||||
case NORMAL_IN_3D:
|
case NORMAL_IN_3D:
|
||||||
@ -25,7 +25,7 @@ bool EntityBase::HasVector(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector EntityBase::VectorGetExprs(void) {
|
ExprVector EntityBase::VectorGetExprs() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LINE_SEGMENT:
|
case LINE_SEGMENT:
|
||||||
return (SK.GetEntity(point[0])->PointGetExprs()).Minus(
|
return (SK.GetEntity(point[0])->PointGetExprs()).Minus(
|
||||||
@ -42,7 +42,7 @@ ExprVector EntityBase::VectorGetExprs(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::VectorGetNum(void) {
|
Vector EntityBase::VectorGetNum() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LINE_SEGMENT:
|
case LINE_SEGMENT:
|
||||||
return (SK.GetEntity(point[0])->PointGetNum()).Minus(
|
return (SK.GetEntity(point[0])->PointGetNum()).Minus(
|
||||||
@ -59,7 +59,7 @@ Vector EntityBase::VectorGetNum(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::VectorGetRefPoint(void) {
|
Vector EntityBase::VectorGetRefPoint() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LINE_SEGMENT:
|
case LINE_SEGMENT:
|
||||||
return ((SK.GetEntity(point[0])->PointGetNum()).Plus(
|
return ((SK.GetEntity(point[0])->PointGetNum()).Plus(
|
||||||
@ -76,7 +76,7 @@ Vector EntityBase::VectorGetRefPoint(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::VectorGetStartPoint(void) {
|
Vector EntityBase::VectorGetStartPoint() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LINE_SEGMENT:
|
case LINE_SEGMENT:
|
||||||
return SK.GetEntity(point[1])->PointGetNum();
|
return SK.GetEntity(point[1])->PointGetNum();
|
||||||
@ -92,11 +92,11 @@ Vector EntityBase::VectorGetStartPoint(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityBase::IsCircle(void) {
|
bool EntityBase::IsCircle() {
|
||||||
return (type == CIRCLE) || (type == ARC_OF_CIRCLE);
|
return (type == CIRCLE) || (type == ARC_OF_CIRCLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr *EntityBase::CircleGetRadiusExpr(void) {
|
Expr *EntityBase::CircleGetRadiusExpr() {
|
||||||
if(type == CIRCLE) {
|
if(type == CIRCLE) {
|
||||||
return SK.GetEntity(distance)->DistanceGetExpr();
|
return SK.GetEntity(distance)->DistanceGetExpr();
|
||||||
} else if(type == ARC_OF_CIRCLE) {
|
} else if(type == ARC_OF_CIRCLE) {
|
||||||
@ -104,7 +104,7 @@ Expr *EntityBase::CircleGetRadiusExpr(void) {
|
|||||||
} else ssassert(false, "Unexpected entity type");
|
} else ssassert(false, "Unexpected entity type");
|
||||||
}
|
}
|
||||||
|
|
||||||
double EntityBase::CircleGetRadiusNum(void) {
|
double EntityBase::CircleGetRadiusNum() {
|
||||||
if(type == CIRCLE) {
|
if(type == CIRCLE) {
|
||||||
return SK.GetEntity(distance)->DistanceGetNum();
|
return SK.GetEntity(distance)->DistanceGetNum();
|
||||||
} else if(type == ARC_OF_CIRCLE) {
|
} else if(type == ARC_OF_CIRCLE) {
|
||||||
@ -137,42 +137,42 @@ void EntityBase::ArcGetAngles(double *thetaa, double *thetab, double *dtheta) {
|
|||||||
while(*dtheta > (2*PI)) *dtheta -= 2*PI;
|
while(*dtheta > (2*PI)) *dtheta -= 2*PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::CubicGetStartNum(void) {
|
Vector EntityBase::CubicGetStartNum() {
|
||||||
return SK.GetEntity(point[0])->PointGetNum();
|
return SK.GetEntity(point[0])->PointGetNum();
|
||||||
}
|
}
|
||||||
Vector EntityBase::CubicGetFinishNum(void) {
|
Vector EntityBase::CubicGetFinishNum() {
|
||||||
return SK.GetEntity(point[3+extraPoints])->PointGetNum();
|
return SK.GetEntity(point[3+extraPoints])->PointGetNum();
|
||||||
}
|
}
|
||||||
ExprVector EntityBase::CubicGetStartTangentExprs(void) {
|
ExprVector EntityBase::CubicGetStartTangentExprs() {
|
||||||
ExprVector pon = SK.GetEntity(point[0])->PointGetExprs(),
|
ExprVector pon = SK.GetEntity(point[0])->PointGetExprs(),
|
||||||
poff = SK.GetEntity(point[1])->PointGetExprs();
|
poff = SK.GetEntity(point[1])->PointGetExprs();
|
||||||
return (pon.Minus(poff));
|
return (pon.Minus(poff));
|
||||||
}
|
}
|
||||||
ExprVector EntityBase::CubicGetFinishTangentExprs(void) {
|
ExprVector EntityBase::CubicGetFinishTangentExprs() {
|
||||||
ExprVector pon = SK.GetEntity(point[3+extraPoints])->PointGetExprs(),
|
ExprVector pon = SK.GetEntity(point[3+extraPoints])->PointGetExprs(),
|
||||||
poff = SK.GetEntity(point[2+extraPoints])->PointGetExprs();
|
poff = SK.GetEntity(point[2+extraPoints])->PointGetExprs();
|
||||||
return (pon.Minus(poff));
|
return (pon.Minus(poff));
|
||||||
}
|
}
|
||||||
Vector EntityBase::CubicGetStartTangentNum(void) {
|
Vector EntityBase::CubicGetStartTangentNum() {
|
||||||
Vector pon = SK.GetEntity(point[0])->PointGetNum(),
|
Vector pon = SK.GetEntity(point[0])->PointGetNum(),
|
||||||
poff = SK.GetEntity(point[1])->PointGetNum();
|
poff = SK.GetEntity(point[1])->PointGetNum();
|
||||||
return (pon.Minus(poff));
|
return (pon.Minus(poff));
|
||||||
}
|
}
|
||||||
Vector EntityBase::CubicGetFinishTangentNum(void) {
|
Vector EntityBase::CubicGetFinishTangentNum() {
|
||||||
Vector pon = SK.GetEntity(point[3+extraPoints])->PointGetNum(),
|
Vector pon = SK.GetEntity(point[3+extraPoints])->PointGetNum(),
|
||||||
poff = SK.GetEntity(point[2+extraPoints])->PointGetNum();
|
poff = SK.GetEntity(point[2+extraPoints])->PointGetNum();
|
||||||
return (pon.Minus(poff));
|
return (pon.Minus(poff));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityBase::IsWorkplane(void) {
|
bool EntityBase::IsWorkplane() {
|
||||||
return (type == WORKPLANE);
|
return (type == WORKPLANE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector EntityBase::WorkplaneGetOffsetExprs(void) {
|
ExprVector EntityBase::WorkplaneGetOffsetExprs() {
|
||||||
return SK.GetEntity(point[0])->PointGetExprs();
|
return SK.GetEntity(point[0])->PointGetExprs();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::WorkplaneGetOffset(void) {
|
Vector EntityBase::WorkplaneGetOffset() {
|
||||||
return SK.GetEntity(point[0])->PointGetNum();
|
return SK.GetEntity(point[0])->PointGetNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,18 +188,18 @@ void EntityBase::WorkplaneGetPlaneExprs(ExprVector *n, Expr **dn) {
|
|||||||
} else ssassert(false, "Unexpected entity type");
|
} else ssassert(false, "Unexpected entity type");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityBase::IsDistance(void) {
|
bool EntityBase::IsDistance() {
|
||||||
return (type == DISTANCE) ||
|
return (type == DISTANCE) ||
|
||||||
(type == DISTANCE_N_COPY);
|
(type == DISTANCE_N_COPY);
|
||||||
}
|
}
|
||||||
double EntityBase::DistanceGetNum(void) {
|
double EntityBase::DistanceGetNum() {
|
||||||
if(type == DISTANCE) {
|
if(type == DISTANCE) {
|
||||||
return SK.GetParam(param[0])->val;
|
return SK.GetParam(param[0])->val;
|
||||||
} else if(type == DISTANCE_N_COPY) {
|
} else if(type == DISTANCE_N_COPY) {
|
||||||
return numDistance;
|
return numDistance;
|
||||||
} else ssassert(false, "Unexpected entity type");
|
} else ssassert(false, "Unexpected entity type");
|
||||||
}
|
}
|
||||||
Expr *EntityBase::DistanceGetExpr(void) {
|
Expr *EntityBase::DistanceGetExpr() {
|
||||||
if(type == DISTANCE) {
|
if(type == DISTANCE) {
|
||||||
return Expr::From(param[0]);
|
return Expr::From(param[0]);
|
||||||
} else if(type == DISTANCE_N_COPY) {
|
} else if(type == DISTANCE_N_COPY) {
|
||||||
@ -214,11 +214,11 @@ void EntityBase::DistanceForceTo(double v) {
|
|||||||
} else ssassert(false, "Unexpected entity type");
|
} else ssassert(false, "Unexpected entity type");
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityBase *EntityBase::Normal(void) {
|
EntityBase *EntityBase::Normal() {
|
||||||
return SK.GetEntity(normal);
|
return SK.GetEntity(normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityBase::IsPoint(void) {
|
bool EntityBase::IsPoint() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case POINT_IN_3D:
|
case POINT_IN_3D:
|
||||||
case POINT_IN_2D:
|
case POINT_IN_2D:
|
||||||
@ -233,7 +233,7 @@ bool EntityBase::IsPoint(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityBase::IsNormal(void) {
|
bool EntityBase::IsNormal() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case NORMAL_IN_3D:
|
case NORMAL_IN_3D:
|
||||||
case NORMAL_IN_2D:
|
case NORMAL_IN_2D:
|
||||||
@ -246,7 +246,7 @@ bool EntityBase::IsNormal(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion EntityBase::NormalGetNum(void) {
|
Quaternion EntityBase::NormalGetNum() {
|
||||||
Quaternion q;
|
Quaternion q;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case NORMAL_IN_3D:
|
case NORMAL_IN_3D:
|
||||||
@ -310,27 +310,27 @@ void EntityBase::NormalForceTo(Quaternion q) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::NormalU(void) {
|
Vector EntityBase::NormalU() {
|
||||||
return NormalGetNum().RotationU();
|
return NormalGetNum().RotationU();
|
||||||
}
|
}
|
||||||
Vector EntityBase::NormalV(void) {
|
Vector EntityBase::NormalV() {
|
||||||
return NormalGetNum().RotationV();
|
return NormalGetNum().RotationV();
|
||||||
}
|
}
|
||||||
Vector EntityBase::NormalN(void) {
|
Vector EntityBase::NormalN() {
|
||||||
return NormalGetNum().RotationN();
|
return NormalGetNum().RotationN();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector EntityBase::NormalExprsU(void) {
|
ExprVector EntityBase::NormalExprsU() {
|
||||||
return NormalGetExprs().RotationU();
|
return NormalGetExprs().RotationU();
|
||||||
}
|
}
|
||||||
ExprVector EntityBase::NormalExprsV(void) {
|
ExprVector EntityBase::NormalExprsV() {
|
||||||
return NormalGetExprs().RotationV();
|
return NormalGetExprs().RotationV();
|
||||||
}
|
}
|
||||||
ExprVector EntityBase::NormalExprsN(void) {
|
ExprVector EntityBase::NormalExprsN() {
|
||||||
return NormalGetExprs().RotationN();
|
return NormalGetExprs().RotationN();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprQuaternion EntityBase::NormalGetExprs(void) {
|
ExprQuaternion EntityBase::NormalGetExprs() {
|
||||||
ExprQuaternion q;
|
ExprQuaternion q;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case NORMAL_IN_3D:
|
case NORMAL_IN_3D:
|
||||||
@ -430,7 +430,7 @@ void EntityBase::PointForceTo(Vector p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::PointGetNum(void) {
|
Vector EntityBase::PointGetNum() {
|
||||||
Vector p;
|
Vector p;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case POINT_IN_3D:
|
case POINT_IN_3D:
|
||||||
@ -479,7 +479,7 @@ Vector EntityBase::PointGetNum(void) {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector EntityBase::PointGetExprs(void) {
|
ExprVector EntityBase::PointGetExprs() {
|
||||||
ExprVector r;
|
ExprVector r;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case POINT_IN_3D:
|
case POINT_IN_3D:
|
||||||
@ -583,7 +583,7 @@ ExprQuaternion EntityBase::GetAxisAngleQuaternionExprs(int param0) {
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion EntityBase::PointGetQuaternion(void) {
|
Quaternion EntityBase::PointGetQuaternion() {
|
||||||
Quaternion q;
|
Quaternion q;
|
||||||
|
|
||||||
if(type == POINT_N_ROT_AA) {
|
if(type == POINT_N_ROT_AA) {
|
||||||
@ -595,7 +595,7 @@ Quaternion EntityBase::PointGetQuaternion(void) {
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityBase::IsFace(void) {
|
bool EntityBase::IsFace() {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case FACE_NORMAL_PT:
|
case FACE_NORMAL_PT:
|
||||||
case FACE_XPROD:
|
case FACE_XPROD:
|
||||||
@ -608,7 +608,7 @@ bool EntityBase::IsFace(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector EntityBase::FaceGetNormalExprs(void) {
|
ExprVector EntityBase::FaceGetNormalExprs() {
|
||||||
ExprVector r;
|
ExprVector r;
|
||||||
if(type == FACE_NORMAL_PT) {
|
if(type == FACE_NORMAL_PT) {
|
||||||
Vector v = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
|
Vector v = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
|
||||||
@ -637,7 +637,7 @@ ExprVector EntityBase::FaceGetNormalExprs(void) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::FaceGetNormalNum(void) {
|
Vector EntityBase::FaceGetNormalNum() {
|
||||||
Vector r;
|
Vector r;
|
||||||
if(type == FACE_NORMAL_PT) {
|
if(type == FACE_NORMAL_PT) {
|
||||||
r = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
|
r = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
|
||||||
@ -660,7 +660,7 @@ Vector EntityBase::FaceGetNormalNum(void) {
|
|||||||
return r.WithMagnitude(1);
|
return r.WithMagnitude(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector EntityBase::FaceGetPointExprs(void) {
|
ExprVector EntityBase::FaceGetPointExprs() {
|
||||||
ExprVector r;
|
ExprVector r;
|
||||||
if(type == FACE_NORMAL_PT) {
|
if(type == FACE_NORMAL_PT) {
|
||||||
r = SK.GetEntity(point[0])->PointGetExprs();
|
r = SK.GetEntity(point[0])->PointGetExprs();
|
||||||
@ -689,7 +689,7 @@ ExprVector EntityBase::FaceGetPointExprs(void) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector EntityBase::FaceGetPointNum(void) {
|
Vector EntityBase::FaceGetPointNum() {
|
||||||
Vector r;
|
Vector r;
|
||||||
if(type == FACE_NORMAL_PT) {
|
if(type == FACE_NORMAL_PT) {
|
||||||
r = SK.GetEntity(point[0])->PointGetNum();
|
r = SK.GetEntity(point[0])->PointGetNum();
|
||||||
@ -714,7 +714,7 @@ Vector EntityBase::FaceGetPointNum(void) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityBase::HasEndpoints(void) {
|
bool EntityBase::HasEndpoints() {
|
||||||
return (type == LINE_SEGMENT) ||
|
return (type == LINE_SEGMENT) ||
|
||||||
(type == CUBIC) ||
|
(type == CUBIC) ||
|
||||||
(type == ARC_OF_CIRCLE);
|
(type == ARC_OF_CIRCLE);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
void StepFileWriter::WriteHeader(void) {
|
void StepFileWriter::WriteHeader() {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"ISO-10303-21;\n"
|
"ISO-10303-21;\n"
|
||||||
"HEADER;\n"
|
"HEADER;\n"
|
||||||
@ -66,7 +66,7 @@ void StepFileWriter::WriteHeader(void) {
|
|||||||
// Start the ID somewhere beyond the header IDs.
|
// Start the ID somewhere beyond the header IDs.
|
||||||
id = 200;
|
id = 200;
|
||||||
}
|
}
|
||||||
void StepFileWriter::WriteProductHeader(void) {
|
void StepFileWriter::WriteProductHeader() {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"#175 = SHAPE_DEFINITION_REPRESENTATION(#176, #169);\n"
|
"#175 = SHAPE_DEFINITION_REPRESENTATION(#176, #169);\n"
|
||||||
"#176 = PRODUCT_DEFINITION_SHAPE('Version', 'Test Part', #177);\n"
|
"#176 = PRODUCT_DEFINITION_SHAPE('Version', 'Test Part', #177);\n"
|
||||||
@ -283,7 +283,7 @@ void StepFileWriter::ExportSurface(SSurface *ss, SBezierList *sbl) {
|
|||||||
spxyz.Clear();
|
spxyz.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StepFileWriter::WriteFooter(void) {
|
void StepFileWriter::WriteFooter() {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"\n"
|
"\n"
|
||||||
"ENDSEC;\n"
|
"ENDSEC;\n"
|
||||||
@ -354,7 +354,7 @@ void StepFileWriter::ExportSurfacesTo(const std::string &filename) {
|
|||||||
advancedFaces.Clear();
|
advancedFaces.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StepFileWriter::WriteWireframe(void) {
|
void StepFileWriter::WriteWireframe() {
|
||||||
fprintf(f, "#%d=GEOMETRIC_CURVE_SET('curves',(", id);
|
fprintf(f, "#%d=GEOMETRIC_CURVE_SET('curves',(", id);
|
||||||
int *c;
|
int *c;
|
||||||
for(c = curves.First(); c; c = curves.NextAfter(c)) {
|
for(c = curves.First(); c; c = curves.NextAfter(c)) {
|
||||||
|
@ -658,7 +658,7 @@ bool DxfFileWriter::OutputConstraints(IdList<Constraint,hConstraint> *constraint
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DxfFileWriter::StartFile(void) {
|
void DxfFileWriter::StartFile() {
|
||||||
paths.clear();
|
paths.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,7 +680,7 @@ void DxfFileWriter::Bezier(SBezier *sb) {
|
|||||||
paths.back().beziers.push_back(sb);
|
paths.back().beziers.push_back(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DxfFileWriter::FinishAndCloseFile(void) {
|
void DxfFileWriter::FinishAndCloseFile() {
|
||||||
dxfRW dxf(filename.c_str());
|
dxfRW dxf(filename.c_str());
|
||||||
DxfWriteInterface interface(this, &dxf);
|
DxfWriteInterface interface(this, &dxf);
|
||||||
dxf.write(&interface, DRW::AC1021, false);
|
dxf.write(&interface, DRW::AC1021, false);
|
||||||
@ -759,7 +759,7 @@ static std::string MakeStipplePattern(int pattern, double scale, char delimiter,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EpsFileWriter::StartFile(void) {
|
void EpsFileWriter::StartFile() {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"%%!PS-Adobe-2.0\r\n"
|
"%%!PS-Adobe-2.0\r\n"
|
||||||
"%%%%Creator: SolveSpace\r\n"
|
"%%%%Creator: SolveSpace\r\n"
|
||||||
@ -871,7 +871,7 @@ void EpsFileWriter::Bezier(SBezier *sb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EpsFileWriter::FinishAndCloseFile(void) {
|
void EpsFileWriter::FinishAndCloseFile() {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"grestore\r\n"
|
"grestore\r\n"
|
||||||
@ -883,7 +883,7 @@ void EpsFileWriter::FinishAndCloseFile(void) {
|
|||||||
// Routines for PDF output, some extra complexity because we have to generate
|
// Routines for PDF output, some extra complexity because we have to generate
|
||||||
// a correct xref table.
|
// a correct xref table.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void PdfFileWriter::StartFile(void) {
|
void PdfFileWriter::StartFile() {
|
||||||
if((ptMax.x - ptMin.x) > 200*25.4 ||
|
if((ptMax.x - ptMin.x) > 200*25.4 ||
|
||||||
(ptMax.y - ptMin.y) > 200*25.4)
|
(ptMax.y - ptMin.y) > 200*25.4)
|
||||||
{
|
{
|
||||||
@ -945,7 +945,7 @@ void PdfFileWriter::StartFile(void) {
|
|||||||
bodyStart = (uint32_t)ftell(f);
|
bodyStart = (uint32_t)ftell(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfFileWriter::FinishAndCloseFile(void) {
|
void PdfFileWriter::FinishAndCloseFile() {
|
||||||
uint32_t bodyEnd = (uint32_t)ftell(f);
|
uint32_t bodyEnd = (uint32_t)ftell(f);
|
||||||
|
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
@ -1087,7 +1087,7 @@ void PdfFileWriter::Bezier(SBezier *sb) {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Routines for SVG output
|
// Routines for SVG output
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SvgFileWriter::StartFile(void) {
|
void SvgFileWriter::StartFile() {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" "
|
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" "
|
||||||
"\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\r\n"
|
"\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\r\n"
|
||||||
@ -1211,7 +1211,7 @@ void SvgFileWriter::Bezier(SBezier *sb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgFileWriter::FinishAndCloseFile(void) {
|
void SvgFileWriter::FinishAndCloseFile() {
|
||||||
fprintf(f, "\r\n</svg>\r\n");
|
fprintf(f, "\r\n</svg>\r\n");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
@ -1223,7 +1223,7 @@ double HpglFileWriter::MmToHpglUnits(double mm) {
|
|||||||
return mm*40;
|
return mm*40;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HpglFileWriter::StartFile(void) {
|
void HpglFileWriter::StartFile() {
|
||||||
fprintf(f, "IN;\r\n");
|
fprintf(f, "IN;\r\n");
|
||||||
fprintf(f, "SP1;\r\n");
|
fprintf(f, "SP1;\r\n");
|
||||||
}
|
}
|
||||||
@ -1253,7 +1253,7 @@ void HpglFileWriter::Bezier(SBezier *sb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HpglFileWriter::FinishAndCloseFile(void) {
|
void HpglFileWriter::FinishAndCloseFile() {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1262,7 +1262,7 @@ void HpglFileWriter::FinishAndCloseFile(void) {
|
|||||||
// multiple passes, and to specify the feeds and depth; those parameters get
|
// multiple passes, and to specify the feeds and depth; those parameters get
|
||||||
// set in the configuration screen.
|
// set in the configuration screen.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void GCodeFileWriter::StartFile(void) {
|
void GCodeFileWriter::StartFile() {
|
||||||
sel = {};
|
sel = {};
|
||||||
}
|
}
|
||||||
void GCodeFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth,
|
void GCodeFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth,
|
||||||
@ -1284,7 +1284,7 @@ void GCodeFileWriter::Bezier(SBezier *sb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeFileWriter::FinishAndCloseFile(void) {
|
void GCodeFileWriter::FinishAndCloseFile() {
|
||||||
SPolygon sp = {};
|
SPolygon sp = {};
|
||||||
sel.AssemblePolygon(&sp, NULL);
|
sel.AssemblePolygon(&sp, NULL);
|
||||||
|
|
||||||
@ -1324,7 +1324,7 @@ void GCodeFileWriter::FinishAndCloseFile(void) {
|
|||||||
// Routine for STEP output; just a wrapper around the general STEP stuff that
|
// Routine for STEP output; just a wrapper around the general STEP stuff that
|
||||||
// can also be used for surfaces or 3d curves.
|
// can also be used for surfaces or 3d curves.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Step2dFileWriter::StartFile(void) {
|
void Step2dFileWriter::StartFile() {
|
||||||
sfw = {};
|
sfw = {};
|
||||||
sfw.f = f;
|
sfw.f = f;
|
||||||
sfw.WriteHeader();
|
sfw.WriteHeader();
|
||||||
@ -1347,7 +1347,7 @@ void Step2dFileWriter::Bezier(SBezier *sb) {
|
|||||||
sfw.curves.Add(&c);
|
sfw.curves.Add(&c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Step2dFileWriter::FinishAndCloseFile(void) {
|
void Step2dFileWriter::FinishAndCloseFile() {
|
||||||
sfw.WriteWireframe();
|
sfw.WriteWireframe();
|
||||||
sfw.WriteFooter();
|
sfw.WriteFooter();
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
40
src/expr.cpp
40
src/expr.cpp
@ -82,7 +82,7 @@ ExprVector ExprVector::WithMagnitude(Expr *s) {
|
|||||||
return ScaledBy(s->Div(m));
|
return ScaledBy(s->Div(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr *ExprVector::Magnitude(void) {
|
Expr *ExprVector::Magnitude() {
|
||||||
Expr *r;
|
Expr *r;
|
||||||
r = x->Square();
|
r = x->Square();
|
||||||
r = r->Plus(y->Square());
|
r = r->Plus(y->Square());
|
||||||
@ -90,7 +90,7 @@ Expr *ExprVector::Magnitude(void) {
|
|||||||
return r->Sqrt();
|
return r->Sqrt();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector ExprVector::Eval(void) {
|
Vector ExprVector::Eval() {
|
||||||
Vector r;
|
Vector r;
|
||||||
r.x = x->Eval();
|
r.x = x->Eval();
|
||||||
r.y = y->Eval();
|
r.y = y->Eval();
|
||||||
@ -126,7 +126,7 @@ ExprQuaternion ExprQuaternion::From(Quaternion qn) {
|
|||||||
return qe;
|
return qe;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector ExprQuaternion::RotationU(void) {
|
ExprVector ExprQuaternion::RotationU() {
|
||||||
ExprVector u;
|
ExprVector u;
|
||||||
Expr *two = Expr::From(2);
|
Expr *two = Expr::From(2);
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ ExprVector ExprQuaternion::RotationU(void) {
|
|||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector ExprQuaternion::RotationV(void) {
|
ExprVector ExprQuaternion::RotationV() {
|
||||||
ExprVector v;
|
ExprVector v;
|
||||||
Expr *two = Expr::From(2);
|
Expr *two = Expr::From(2);
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ ExprVector ExprQuaternion::RotationV(void) {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprVector ExprQuaternion::RotationN(void) {
|
ExprVector ExprQuaternion::RotationN() {
|
||||||
ExprVector n;
|
ExprVector n;
|
||||||
Expr *two = Expr::From(2);
|
Expr *two = Expr::From(2);
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ ExprQuaternion ExprQuaternion::Times(ExprQuaternion b) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr *ExprQuaternion::Magnitude(void) {
|
Expr *ExprQuaternion::Magnitude() {
|
||||||
return ((w ->Square())->Plus(
|
return ((w ->Square())->Plus(
|
||||||
(vx->Square())->Plus(
|
(vx->Square())->Plus(
|
||||||
(vy->Square())->Plus(
|
(vy->Square())->Plus(
|
||||||
@ -262,7 +262,7 @@ Expr *Expr::AnyOp(int newOp, Expr *b) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Expr::Children(void) {
|
int Expr::Children() {
|
||||||
switch(op) {
|
switch(op) {
|
||||||
case PARAM:
|
case PARAM:
|
||||||
case PARAM_PTR:
|
case PARAM_PTR:
|
||||||
@ -288,7 +288,7 @@ int Expr::Children(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Expr::Nodes(void) {
|
int Expr::Nodes() {
|
||||||
switch(Children()) {
|
switch(Children()) {
|
||||||
case 0: return 1;
|
case 0: return 1;
|
||||||
case 1: return 1 + a->Nodes();
|
case 1: return 1 + a->Nodes();
|
||||||
@ -297,7 +297,7 @@ int Expr::Nodes(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr *Expr::DeepCopy(void) {
|
Expr *Expr::DeepCopy() {
|
||||||
Expr *n = AllocExpr();
|
Expr *n = AllocExpr();
|
||||||
*n = *this;
|
*n = *this;
|
||||||
int c = n->Children();
|
int c = n->Children();
|
||||||
@ -333,7 +333,7 @@ Expr *Expr::DeepCopyWithParamsAsPointers(IdList<Param,hParam> *firstTry,
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Expr::Eval(void) {
|
double Expr::Eval() {
|
||||||
switch(op) {
|
switch(op) {
|
||||||
case PARAM: return SK.GetParam(parh)->val;
|
case PARAM: return SK.GetParam(parh)->val;
|
||||||
case PARAM_PTR: return parp->val;
|
case PARAM_PTR: return parp->val;
|
||||||
@ -400,7 +400,7 @@ Expr *Expr::PartialWrt(hParam p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Expr::ParamsUsed(void) {
|
uint64_t Expr::ParamsUsed() {
|
||||||
uint64_t r = 0;
|
uint64_t r = 0;
|
||||||
if(op == PARAM) r |= ((uint64_t)1 << (parh.v % 61));
|
if(op == PARAM) r |= ((uint64_t)1 << (parh.v % 61));
|
||||||
if(op == PARAM_PTR) r |= ((uint64_t)1 << (parp->h.v % 61));
|
if(op == PARAM_PTR) r |= ((uint64_t)1 << (parp->h.v % 61));
|
||||||
@ -424,7 +424,7 @@ bool Expr::DependsOn(hParam p) {
|
|||||||
bool Expr::Tol(double a, double b) {
|
bool Expr::Tol(double a, double b) {
|
||||||
return fabs(a - b) < 0.001;
|
return fabs(a - b) < 0.001;
|
||||||
}
|
}
|
||||||
Expr *Expr::FoldConstants(void) {
|
Expr *Expr::FoldConstants() {
|
||||||
Expr *n = AllocExpr();
|
Expr *n = AllocExpr();
|
||||||
*n = *this;
|
*n = *this;
|
||||||
|
|
||||||
@ -546,7 +546,7 @@ hParam Expr::ReferencedParams(ParamList *pl) {
|
|||||||
// Routines to pretty-print an expression. Mostly for debugging.
|
// Routines to pretty-print an expression. Mostly for debugging.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
std::string Expr::Print(void) {
|
std::string Expr::Print() {
|
||||||
|
|
||||||
char c;
|
char c;
|
||||||
switch(op) {
|
switch(op) {
|
||||||
@ -597,11 +597,11 @@ void Expr::PushOperator(Expr *e) {
|
|||||||
if(OperatorsP >= MAX_UNPARSED) throw "operator stack full!";
|
if(OperatorsP >= MAX_UNPARSED) throw "operator stack full!";
|
||||||
Operators[OperatorsP++] = e;
|
Operators[OperatorsP++] = e;
|
||||||
}
|
}
|
||||||
Expr *Expr::TopOperator(void) {
|
Expr *Expr::TopOperator() {
|
||||||
if(OperatorsP <= 0) throw "operator stack empty (get top)";
|
if(OperatorsP <= 0) throw "operator stack empty (get top)";
|
||||||
return Operators[OperatorsP-1];
|
return Operators[OperatorsP-1];
|
||||||
}
|
}
|
||||||
Expr *Expr::PopOperator(void) {
|
Expr *Expr::PopOperator() {
|
||||||
if(OperatorsP <= 0) throw "operator stack empty (pop)";
|
if(OperatorsP <= 0) throw "operator stack empty (pop)";
|
||||||
return Operators[--OperatorsP];
|
return Operators[--OperatorsP];
|
||||||
}
|
}
|
||||||
@ -609,15 +609,15 @@ void Expr::PushOperand(Expr *e) {
|
|||||||
if(OperandsP >= MAX_UNPARSED) throw "operand stack full";
|
if(OperandsP >= MAX_UNPARSED) throw "operand stack full";
|
||||||
Operands[OperandsP++] = e;
|
Operands[OperandsP++] = e;
|
||||||
}
|
}
|
||||||
Expr *Expr::PopOperand(void) {
|
Expr *Expr::PopOperand() {
|
||||||
if(OperandsP <= 0) throw "operand stack empty";
|
if(OperandsP <= 0) throw "operand stack empty";
|
||||||
return Operands[--OperandsP];
|
return Operands[--OperandsP];
|
||||||
}
|
}
|
||||||
Expr *Expr::Next(void) {
|
Expr *Expr::Next() {
|
||||||
if(UnparsedP >= UnparsedCnt) return NULL;
|
if(UnparsedP >= UnparsedCnt) return NULL;
|
||||||
return Unparsed[UnparsedP];
|
return Unparsed[UnparsedP];
|
||||||
}
|
}
|
||||||
void Expr::Consume(void) {
|
void Expr::Consume() {
|
||||||
if(UnparsedP >= UnparsedCnt) throw "no token to consume";
|
if(UnparsedP >= UnparsedCnt) throw "no token to consume";
|
||||||
UnparsedP++;
|
UnparsedP++;
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ int Expr::Precedence(Expr *e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Expr::Reduce(void) {
|
void Expr::Reduce() {
|
||||||
Expr *a, *b;
|
Expr *a, *b;
|
||||||
|
|
||||||
Expr *op = PopOperator();
|
Expr *op = PopOperator();
|
||||||
@ -676,7 +676,7 @@ void Expr::ReduceAndPush(Expr *n) {
|
|||||||
PushOperator(n);
|
PushOperator(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Expr::Parse(void) {
|
void Expr::Parse() {
|
||||||
Expr *e = AllocExpr();
|
Expr *e = AllocExpr();
|
||||||
e->op = ALL_RESOLVED;
|
e->op = ALL_RESOLVED;
|
||||||
PushOperator(e);
|
PushOperator(e);
|
||||||
|
58
src/expr.h
58
src/expr.h
@ -60,7 +60,7 @@ public:
|
|||||||
Expr() { }
|
Expr() { }
|
||||||
Expr(double val) : op(CONSTANT) { v = val; }
|
Expr(double val) : op(CONSTANT) { v = val; }
|
||||||
|
|
||||||
static inline Expr *AllocExpr(void)
|
static inline Expr *AllocExpr()
|
||||||
{ return (Expr *)AllocTemporary(sizeof(Expr)); }
|
{ return (Expr *)AllocTemporary(sizeof(Expr)); }
|
||||||
|
|
||||||
static Expr *From(hParam p);
|
static Expr *From(hParam p);
|
||||||
@ -72,36 +72,36 @@ public:
|
|||||||
inline Expr *Times(Expr *b_) { return AnyOp(TIMES, b_); }
|
inline Expr *Times(Expr *b_) { return AnyOp(TIMES, b_); }
|
||||||
inline Expr *Div (Expr *b_) { return AnyOp(DIV, b_); }
|
inline Expr *Div (Expr *b_) { return AnyOp(DIV, b_); }
|
||||||
|
|
||||||
inline Expr *Negate(void) { return AnyOp(NEGATE, NULL); }
|
inline Expr *Negate() { return AnyOp(NEGATE, NULL); }
|
||||||
inline Expr *Sqrt (void) { return AnyOp(SQRT, NULL); }
|
inline Expr *Sqrt () { return AnyOp(SQRT, NULL); }
|
||||||
inline Expr *Square(void) { return AnyOp(SQUARE, NULL); }
|
inline Expr *Square() { return AnyOp(SQUARE, NULL); }
|
||||||
inline Expr *Sin (void) { return AnyOp(SIN, NULL); }
|
inline Expr *Sin () { return AnyOp(SIN, NULL); }
|
||||||
inline Expr *Cos (void) { return AnyOp(COS, NULL); }
|
inline Expr *Cos () { return AnyOp(COS, NULL); }
|
||||||
inline Expr *ASin (void) { return AnyOp(ASIN, NULL); }
|
inline Expr *ASin () { return AnyOp(ASIN, NULL); }
|
||||||
inline Expr *ACos (void) { return AnyOp(ACOS, NULL); }
|
inline Expr *ACos () { return AnyOp(ACOS, NULL); }
|
||||||
|
|
||||||
Expr *PartialWrt(hParam p);
|
Expr *PartialWrt(hParam p);
|
||||||
double Eval(void);
|
double Eval();
|
||||||
uint64_t ParamsUsed(void);
|
uint64_t ParamsUsed();
|
||||||
bool DependsOn(hParam p);
|
bool DependsOn(hParam p);
|
||||||
static bool Tol(double a, double b);
|
static bool Tol(double a, double b);
|
||||||
Expr *FoldConstants(void);
|
Expr *FoldConstants();
|
||||||
void Substitute(hParam oldh, hParam newh);
|
void Substitute(hParam oldh, hParam newh);
|
||||||
|
|
||||||
static const hParam NO_PARAMS, MULTIPLE_PARAMS;
|
static const hParam NO_PARAMS, MULTIPLE_PARAMS;
|
||||||
hParam ReferencedParams(ParamList *pl);
|
hParam ReferencedParams(ParamList *pl);
|
||||||
|
|
||||||
void ParamsToPointers(void);
|
void ParamsToPointers();
|
||||||
|
|
||||||
std::string Print(void);
|
std::string Print();
|
||||||
|
|
||||||
// number of child nodes: 0 (e.g. constant), 1 (sqrt), or 2 (+)
|
// number of child nodes: 0 (e.g. constant), 1 (sqrt), or 2 (+)
|
||||||
int Children(void);
|
int Children();
|
||||||
// total number of nodes in the tree
|
// total number of nodes in the tree
|
||||||
int Nodes(void);
|
int Nodes();
|
||||||
|
|
||||||
// Make a simple copy
|
// Make a simple copy
|
||||||
Expr *DeepCopy(void);
|
Expr *DeepCopy();
|
||||||
// Make a copy, with the parameters (usually referenced by hParam)
|
// Make a copy, with the parameters (usually referenced by hParam)
|
||||||
// resolved to pointers to the actual value. This speeds things up
|
// resolved to pointers to the actual value. This speeds things up
|
||||||
// considerably.
|
// considerably.
|
||||||
@ -110,21 +110,21 @@ public:
|
|||||||
|
|
||||||
static Expr *From(const char *in, bool popUpError);
|
static Expr *From(const char *in, bool popUpError);
|
||||||
static void Lex(const char *in);
|
static void Lex(const char *in);
|
||||||
static Expr *Next(void);
|
static Expr *Next();
|
||||||
static void Consume(void);
|
static void Consume();
|
||||||
|
|
||||||
static void PushOperator(Expr *e);
|
static void PushOperator(Expr *e);
|
||||||
static Expr *PopOperator(void);
|
static Expr *PopOperator();
|
||||||
static Expr *TopOperator(void);
|
static Expr *TopOperator();
|
||||||
static void PushOperand(Expr *e);
|
static void PushOperand(Expr *e);
|
||||||
static Expr *PopOperand(void);
|
static Expr *PopOperand();
|
||||||
|
|
||||||
static void Reduce(void);
|
static void Reduce();
|
||||||
static void ReduceAndPush(Expr *e);
|
static void ReduceAndPush(Expr *e);
|
||||||
static int Precedence(Expr *e);
|
static int Precedence(Expr *e);
|
||||||
|
|
||||||
static int Precedence(int op);
|
static int Precedence(int op);
|
||||||
static void Parse(void);
|
static void Parse();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExprVector {
|
class ExprVector {
|
||||||
@ -142,9 +142,9 @@ public:
|
|||||||
ExprVector Cross(ExprVector b);
|
ExprVector Cross(ExprVector b);
|
||||||
ExprVector ScaledBy(Expr *s);
|
ExprVector ScaledBy(Expr *s);
|
||||||
ExprVector WithMagnitude(Expr *s);
|
ExprVector WithMagnitude(Expr *s);
|
||||||
Expr *Magnitude(void);
|
Expr *Magnitude();
|
||||||
|
|
||||||
Vector Eval(void);
|
Vector Eval();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExprQuaternion {
|
class ExprQuaternion {
|
||||||
@ -155,14 +155,14 @@ public:
|
|||||||
static ExprQuaternion From(Quaternion qn);
|
static ExprQuaternion From(Quaternion qn);
|
||||||
static ExprQuaternion From(hParam w, hParam vx, hParam vy, hParam vz);
|
static ExprQuaternion From(hParam w, hParam vx, hParam vy, hParam vz);
|
||||||
|
|
||||||
ExprVector RotationU(void);
|
ExprVector RotationU();
|
||||||
ExprVector RotationV(void);
|
ExprVector RotationV();
|
||||||
ExprVector RotationN(void);
|
ExprVector RotationN();
|
||||||
|
|
||||||
ExprVector Rotate(ExprVector p);
|
ExprVector Rotate(ExprVector p);
|
||||||
ExprQuaternion Times(ExprQuaternion b);
|
ExprQuaternion Times(ExprQuaternion b);
|
||||||
|
|
||||||
Expr *Magnitude(void);
|
Expr *Magnitude();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +16,7 @@ static int StrStartsWith(const char *str, const char *start) {
|
|||||||
// sketch. This does not leave the program in an acceptable state (with the
|
// sketch. This does not leave the program in an acceptable state (with the
|
||||||
// references created, and so on), so anyone calling this must fix that later.
|
// references created, and so on), so anyone calling this must fix that later.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SolveSpaceUI::ClearExisting(void) {
|
void SolveSpaceUI::ClearExisting() {
|
||||||
UndoClearStack(&redo);
|
UndoClearStack(&redo);
|
||||||
UndoClearStack(&undo);
|
UndoClearStack(&undo);
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ void SolveSpaceUI::ClearExisting(void) {
|
|||||||
SK.param.Clear();
|
SK.param.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
hGroup SolveSpaceUI::CreateDefaultDrawingGroup(void) {
|
hGroup SolveSpaceUI::CreateDefaultDrawingGroup() {
|
||||||
Group g = {};
|
Group g = {};
|
||||||
|
|
||||||
// And an empty group, for the first stuff the user draws.
|
// And an empty group, for the first stuff the user draws.
|
||||||
@ -52,7 +52,7 @@ hGroup SolveSpaceUI::CreateDefaultDrawingGroup(void) {
|
|||||||
return g.h;
|
return g.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::NewFile(void) {
|
void SolveSpaceUI::NewFile() {
|
||||||
ClearExisting();
|
ClearExisting();
|
||||||
|
|
||||||
// Our initial group, that contains the references.
|
// Our initial group, that contains the references.
|
||||||
|
@ -28,7 +28,7 @@ void SolveSpaceUI::MarkGroupDirty(hGroup hg) {
|
|||||||
unsaved = true;
|
unsaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SolveSpaceUI::PruneOrphans(void) {
|
bool SolveSpaceUI::PruneOrphans() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < SK.request.n; i++) {
|
for(i = 0; i < SK.request.n; i++) {
|
||||||
Request *r = &(SK.request.elem[i]);
|
Request *r = &(SK.request.elem[i]);
|
||||||
@ -399,7 +399,7 @@ pruned:
|
|||||||
GenerateAll(type, andFindFree, genForBBox);
|
GenerateAll(type, andFindFree, genForBBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::ForceReferences(void) {
|
void SolveSpaceUI::ForceReferences() {
|
||||||
// Force the values of the parameters that define the three reference
|
// Force the values of the parameters that define the three reference
|
||||||
// coordinate systems.
|
// coordinate systems.
|
||||||
static const struct {
|
static const struct {
|
||||||
@ -429,7 +429,7 @@ void SolveSpaceUI::ForceReferences(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::MarkDraggedParams(void) {
|
void SolveSpaceUI::MarkDraggedParams() {
|
||||||
sys.dragged.Clear();
|
sys.dragged.Clear();
|
||||||
|
|
||||||
for(int i = -1; i < SS.GW.pending.points.n; i++) {
|
for(int i = -1; i < SS.GW.pending.points.n; i++) {
|
||||||
|
@ -244,7 +244,7 @@ void ssglLockColorTo(RgbaColor rgb)
|
|||||||
ColorLocked = true;
|
ColorLocked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ssglUnlockColor(void)
|
void ssglUnlockColor()
|
||||||
{
|
{
|
||||||
ColorLocked = false;
|
ColorLocked = false;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ std::string SolveSpace::MakeAcceleratorLabel(int accel) {
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::Init(void) {
|
void GraphicsWindow::Init() {
|
||||||
scale = 5;
|
scale = 5;
|
||||||
offset = Vector::From(0, 0, 0);
|
offset = Vector::From(0, 0, 0);
|
||||||
projRight = Vector::From(1, 0, 0);
|
projRight = Vector::From(1, 0, 0);
|
||||||
@ -239,7 +239,7 @@ void GraphicsWindow::Init(void) {
|
|||||||
ClearSuper();
|
ClearSuper();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::AnimateOntoWorkplane(void) {
|
void GraphicsWindow::AnimateOntoWorkplane() {
|
||||||
if(!LockedInWorkplane()) return;
|
if(!LockedInWorkplane()) return;
|
||||||
|
|
||||||
Entity *w = SK.GetEntity(ActiveWorkplane());
|
Entity *w = SK.GetEntity(ActiveWorkplane());
|
||||||
@ -601,7 +601,7 @@ void GraphicsWindow::MenuView(int id) {
|
|||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::EnsureValidActives(void) {
|
void GraphicsWindow::EnsureValidActives() {
|
||||||
bool change = false;
|
bool change = false;
|
||||||
// The active group must exist, and not be the references.
|
// The active group must exist, and not be the references.
|
||||||
Group *g = SK.group.FindByIdNoOops(activeGroup);
|
Group *g = SK.group.FindByIdNoOops(activeGroup);
|
||||||
@ -681,10 +681,10 @@ void GraphicsWindow::EnsureValidActives(void) {
|
|||||||
if(change) SS.ScheduleShowTW();
|
if(change) SS.ScheduleShowTW();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::SetWorkplaneFreeIn3d(void) {
|
void GraphicsWindow::SetWorkplaneFreeIn3d() {
|
||||||
SK.GetGroup(activeGroup)->activeWorkplane = Entity::FREE_IN_3D;
|
SK.GetGroup(activeGroup)->activeWorkplane = Entity::FREE_IN_3D;
|
||||||
}
|
}
|
||||||
hEntity GraphicsWindow::ActiveWorkplane(void) {
|
hEntity GraphicsWindow::ActiveWorkplane() {
|
||||||
Group *g = SK.group.FindByIdNoOops(activeGroup);
|
Group *g = SK.group.FindByIdNoOops(activeGroup);
|
||||||
if(g) {
|
if(g) {
|
||||||
return g->activeWorkplane;
|
return g->activeWorkplane;
|
||||||
@ -692,11 +692,11 @@ hEntity GraphicsWindow::ActiveWorkplane(void) {
|
|||||||
return Entity::FREE_IN_3D;
|
return Entity::FREE_IN_3D;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool GraphicsWindow::LockedInWorkplane(void) {
|
bool GraphicsWindow::LockedInWorkplane() {
|
||||||
return (SS.GW.ActiveWorkplane().v != Entity::FREE_IN_3D.v);
|
return (SS.GW.ActiveWorkplane().v != Entity::FREE_IN_3D.v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::ForceTextWindowShown(void) {
|
void GraphicsWindow::ForceTextWindowShown() {
|
||||||
if(!showTextWindow) {
|
if(!showTextWindow) {
|
||||||
showTextWindow = true;
|
showTextWindow = true;
|
||||||
CheckMenuById(MNU_SHOW_TEXT_WND, true);
|
CheckMenuById(MNU_SHOW_TEXT_WND, true);
|
||||||
@ -704,7 +704,7 @@ void GraphicsWindow::ForceTextWindowShown(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::DeleteTaggedRequests(void) {
|
void GraphicsWindow::DeleteTaggedRequests() {
|
||||||
// Rewrite any point-coincident constraints that were affected by this
|
// Rewrite any point-coincident constraints that were affected by this
|
||||||
// deletion.
|
// deletion.
|
||||||
Request *r;
|
Request *r;
|
||||||
@ -1039,7 +1039,7 @@ c:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::ClearSuper(void) {
|
void GraphicsWindow::ClearSuper() {
|
||||||
HideGraphicsEditControl();
|
HideGraphicsEditControl();
|
||||||
ClearPending();
|
ClearPending();
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
|
@ -19,7 +19,7 @@ const hGroup Group::HGROUP_REFERENCES = { 1 };
|
|||||||
// The group structure includes pointers to other dynamically-allocated
|
// The group structure includes pointers to other dynamically-allocated
|
||||||
// memory. This clears and frees them all.
|
// memory. This clears and frees them all.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Group::Clear(void) {
|
void Group::Clear() {
|
||||||
polyLoops.Clear();
|
polyLoops.Clear();
|
||||||
bezierLoops.Clear();
|
bezierLoops.Clear();
|
||||||
bezierOpens.Clear();
|
bezierOpens.Clear();
|
||||||
@ -45,7 +45,7 @@ void Group::AddParam(IdList<Param,hParam> *param, hParam hp, double v) {
|
|||||||
param->Add(&pa);
|
param->Add(&pa);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Group::IsVisible(void) {
|
bool Group::IsVisible() {
|
||||||
if(!visible) return false;
|
if(!visible) return false;
|
||||||
if(SS.GroupsInOrder(SS.GW.activeGroup, h)) return false;
|
if(SS.GroupsInOrder(SS.GW.activeGroup, h)) return false;
|
||||||
return true;
|
return true;
|
||||||
@ -314,7 +314,7 @@ void Group::TransformImportedBy(Vector t, Quaternion q) {
|
|||||||
SK.GetParam(qz)->val = qg.vz;
|
SK.GetParam(qz)->val = qg.vz;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Group::DescriptionString(void) {
|
std::string Group::DescriptionString() {
|
||||||
if(name.empty()) {
|
if(name.empty()) {
|
||||||
return ssprintf("g%03x-(unnamed)", h.v);
|
return ssprintf("g%03x-(unnamed)", h.v);
|
||||||
} else {
|
} else {
|
||||||
@ -322,7 +322,7 @@ std::string Group::DescriptionString(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::Activate(void) {
|
void Group::Activate() {
|
||||||
if(type == EXTRUDE || type == LINKED || type == LATHE || type == TRANSLATE || type == ROTATE) {
|
if(type == EXTRUDE || type == LINKED || type == LATHE || type == TRANSLATE || type == ROTATE) {
|
||||||
SS.GW.showFaces = true;
|
SS.GW.showFaces = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,7 +53,7 @@ void Group::AssembleLoops(bool *allClosed,
|
|||||||
sbl.Clear();
|
sbl.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::GenerateLoops(void) {
|
void Group::GenerateLoops() {
|
||||||
polyLoops.Clear();
|
polyLoops.Clear();
|
||||||
bezierLoops.Clear();
|
bezierLoops.Clear();
|
||||||
bezierOpens.Clear();
|
bezierOpens.Clear();
|
||||||
@ -177,7 +177,7 @@ void Group::GenerateForBoolean(T *prevs, T *thiss, T *outs, int how) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::GenerateShellAndMesh(void) {
|
void Group::GenerateShellAndMesh() {
|
||||||
bool prevBooleanFailed = booleanFailed;
|
bool prevBooleanFailed = booleanFailed;
|
||||||
booleanFailed = false;
|
booleanFailed = false;
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ void Group::GenerateShellAndMesh(void) {
|
|||||||
displayDirty = true;
|
displayDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::GenerateDisplayItems(void) {
|
void Group::GenerateDisplayItems() {
|
||||||
// This is potentially slow (since we've got to triangulate a shell, or
|
// 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
|
// to find the emphasized edges for a mesh), so we will run it only
|
||||||
// if its inputs have changed.
|
// if its inputs have changed.
|
||||||
@ -421,7 +421,7 @@ void Group::GenerateDisplayItems(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Group *Group::PreviousGroup(void) {
|
Group *Group::PreviousGroup() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < SK.groupOrder.n; i++) {
|
for(i = 0; i < SK.groupOrder.n; i++) {
|
||||||
Group *g = SK.GetGroup(SK.groupOrder.elem[i]);
|
Group *g = SK.GetGroup(SK.groupOrder.elem[i]);
|
||||||
@ -431,7 +431,7 @@ Group *Group::PreviousGroup(void) {
|
|||||||
return SK.GetGroup(SK.groupOrder.elem[i - 1]);
|
return SK.GetGroup(SK.groupOrder.elem[i - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Group *Group::RunningMeshGroup(void) {
|
Group *Group::RunningMeshGroup() {
|
||||||
if(type == TRANSLATE || type == ROTATE) {
|
if(type == TRANSLATE || type == ROTATE) {
|
||||||
return SK.GetGroup(opA)->RunningMeshGroup();
|
return SK.GetGroup(opA)->RunningMeshGroup();
|
||||||
} else {
|
} else {
|
||||||
@ -518,7 +518,7 @@ void Group::DrawDisplayItems(int t) {
|
|||||||
if(SS.GW.showMesh) ssglDebugMesh(&displayMesh);
|
if(SS.GW.showMesh) ssglDebugMesh(&displayMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::Draw(void) {
|
void Group::Draw() {
|
||||||
// Everything here gets drawn whether or not the group is hidden; we
|
// Everything here gets drawn whether or not the group is hidden; we
|
||||||
// can control this stuff independently, with show/hide solids, edges,
|
// can control this stuff independently, with show/hide solids, edges,
|
||||||
// mesh, etc.
|
// mesh, etc.
|
||||||
@ -583,7 +583,7 @@ void Group::FillLoopSetAsPolygon(SBezierLoopSet *sbls) {
|
|||||||
sp.Clear();
|
sp.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::DrawFilledPaths(void) {
|
void Group::DrawFilledPaths() {
|
||||||
SBezierLoopSet *sbls;
|
SBezierLoopSet *sbls;
|
||||||
SBezierLoopSetSet *sblss = &bezierLoops;
|
SBezierLoopSetSet *sblss = &bezierLoops;
|
||||||
for(sbls = sblss->l.First(); sbls; sbls = sblss->l.NextAfter(sbls)) {
|
for(sbls = sblss->l.First(); sbls; sbls = sblss->l.NextAfter(sbls)) {
|
||||||
|
10
src/mesh.cpp
10
src/mesh.cpp
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
void SMesh::Clear(void) {
|
void SMesh::Clear() {
|
||||||
l.Clear();
|
l.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ void SMesh::MakeFromTransformationOf(SMesh *a,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMesh::IsEmpty(void) {
|
bool SMesh::IsEmpty() {
|
||||||
return (l.n == 0);
|
return (l.n == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,9 +356,9 @@ uint32_t SMesh::FirstIntersectionWith(Point2d mp) {
|
|||||||
return face;
|
return face;
|
||||||
}
|
}
|
||||||
|
|
||||||
STriangleLl *STriangleLl::Alloc(void)
|
STriangleLl *STriangleLl::Alloc()
|
||||||
{ return (STriangleLl *)AllocTemporary(sizeof(STriangleLl)); }
|
{ return (STriangleLl *)AllocTemporary(sizeof(STriangleLl)); }
|
||||||
SKdNode *SKdNode::Alloc(void)
|
SKdNode *SKdNode::Alloc()
|
||||||
{ return (SKdNode *)AllocTemporary(sizeof(SKdNode)); }
|
{ return (SKdNode *)AllocTemporary(sizeof(SKdNode)); }
|
||||||
|
|
||||||
SKdNode *SKdNode::From(SMesh *m) {
|
SKdNode *SKdNode::From(SMesh *m) {
|
||||||
@ -487,7 +487,7 @@ leaf:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SKdNode::ClearTags(void) {
|
void SKdNode::ClearTags() {
|
||||||
if(gt && lt) {
|
if(gt && lt) {
|
||||||
gt->ClearTags();
|
gt->ClearTags();
|
||||||
lt->ClearTags();
|
lt->ClearTags();
|
||||||
|
@ -133,7 +133,7 @@ void GraphicsWindow::ParametricCurve::MakeFromEntity(hEntity he, bool reverse) {
|
|||||||
v = wrkpln->NormalV();
|
v = wrkpln->NormalV();
|
||||||
} else ssassert(false, "Unexpected entity type");
|
} else ssassert(false, "Unexpected entity type");
|
||||||
}
|
}
|
||||||
double GraphicsWindow::ParametricCurve::LengthForAuto(void) {
|
double GraphicsWindow::ParametricCurve::LengthForAuto() {
|
||||||
if(isLine) {
|
if(isLine) {
|
||||||
// Allow a third of the line to disappear with auto radius
|
// Allow a third of the line to disappear with auto radius
|
||||||
return (p1.Minus(p0)).Magnitude() / 3;
|
return (p1.Minus(p0)).Magnitude() / 3;
|
||||||
@ -232,7 +232,7 @@ void GraphicsWindow::ParametricCurve::ConstrainPointIfCoincident(hEntity hpt) {
|
|||||||
// non-construction line segments that join at this point, and create a
|
// non-construction line segments that join at this point, and create a
|
||||||
// tangent arc joining them.
|
// tangent arc joining them.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void GraphicsWindow::MakeTangentArc(void) {
|
void GraphicsWindow::MakeTangentArc() {
|
||||||
if(!LockedInWorkplane()) {
|
if(!LockedInWorkplane()) {
|
||||||
Error("Must be sketching in workplane to create tangent "
|
Error("Must be sketching in workplane to create tangent "
|
||||||
"arc.");
|
"arc.");
|
||||||
@ -599,7 +599,7 @@ hEntity GraphicsWindow::SplitEntity(hEntity he, Vector pinter) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::SplitLinesOrCurves(void) {
|
void GraphicsWindow::SplitLinesOrCurves() {
|
||||||
if(!LockedInWorkplane()) {
|
if(!LockedInWorkplane()) {
|
||||||
Error("Must be sketching in workplane to split.");
|
Error("Must be sketching in workplane to split.");
|
||||||
return;
|
return;
|
||||||
|
@ -62,7 +62,7 @@ void GraphicsWindow::StartDraggingByEntity(hEntity he) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::StartDraggingBySelection(void) {
|
void GraphicsWindow::StartDraggingBySelection() {
|
||||||
List<Selection> *ls = &(selection);
|
List<Selection> *ls = &(selection);
|
||||||
for(Selection *s = ls->First(); s; s = ls->NextAfter(s)) {
|
for(Selection *s = ls->First(); s; s = ls->NextAfter(s)) {
|
||||||
if(!s->entity.v) continue;
|
if(!s->entity.v) continue;
|
||||||
@ -466,7 +466,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::ClearPending(void) {
|
void GraphicsWindow::ClearPending() {
|
||||||
pending.points.Clear();
|
pending.points.Clear();
|
||||||
pending = {};
|
pending = {};
|
||||||
SS.ScheduleShowTW();
|
SS.ScheduleShowTW();
|
||||||
@ -483,7 +483,7 @@ void GraphicsWindow::MouseMiddleOrRightDown(double x, double y) {
|
|||||||
orig.startedMoving = false;
|
orig.startedMoving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::ContextMenuListStyles(void) {
|
void GraphicsWindow::ContextMenuListStyles() {
|
||||||
CreateContextSubmenu();
|
CreateContextSubmenu();
|
||||||
Style *s;
|
Style *s;
|
||||||
bool empty = true;
|
bool empty = true;
|
||||||
@ -1394,7 +1394,7 @@ void GraphicsWindow::MouseScroll(double x, double y, int delta) {
|
|||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::MouseLeave(void) {
|
void GraphicsWindow::MouseLeave() {
|
||||||
// Un-hover everything when the mouse leaves our window, unless there's
|
// Un-hover everything when the mouse leaves our window, unless there's
|
||||||
// currently a context menu shown.
|
// currently a context menu shown.
|
||||||
if(!context.active) {
|
if(!context.active) {
|
||||||
@ -1472,7 +1472,7 @@ void GraphicsWindow::SpaceNavigatorMoved(double tx, double ty, double tz,
|
|||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::SpaceNavigatorButtonUp(void) {
|
void GraphicsWindow::SpaceNavigatorButtonUp() {
|
||||||
ZoomToFit(/*includingInvisibles=*/false, /*useSelection=*/true);
|
ZoomToFit(/*includingInvisibles=*/false, /*useSelection=*/true);
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
@ -203,12 +203,12 @@ void SolveSpace::AddContextMenuItem(const char *label, int id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpace::CreateContextSubmenu(void)
|
void SolveSpace::CreateContextSubmenu()
|
||||||
{
|
{
|
||||||
ContextSubmenu = CreatePopupMenu();
|
ContextSubmenu = CreatePopupMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SolveSpace::ShowContextMenu(void)
|
int SolveSpace::ShowContextMenu()
|
||||||
{
|
{
|
||||||
POINT p;
|
POINT p;
|
||||||
GetCursorPos(&p);
|
GetCursorPos(&p);
|
||||||
@ -268,7 +268,7 @@ void SolveSpace::OpenWebsite(const char *url) {
|
|||||||
ShellExecuteW(GraphicsWnd, L"open", Widen(url).c_str(), NULL, NULL, SW_SHOWNORMAL);
|
ShellExecuteW(GraphicsWnd, L"open", Widen(url).c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpace::ExitNow(void) {
|
void SolveSpace::ExitNow() {
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,11 +710,11 @@ static bool ProcessKeyDown(WPARAM wParam)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpace::ToggleMenuBar(void)
|
void SolveSpace::ToggleMenuBar()
|
||||||
{
|
{
|
||||||
// Implement me
|
// Implement me
|
||||||
}
|
}
|
||||||
bool SolveSpace::MenuBarIsVisible(void)
|
bool SolveSpace::MenuBarIsVisible()
|
||||||
{
|
{
|
||||||
// Implement me
|
// Implement me
|
||||||
return true;
|
return true;
|
||||||
@ -752,27 +752,27 @@ static void CreateGlContext(HWND hwnd, HGLRC *glrc)
|
|||||||
wglMakeCurrent(hdc, *glrc);
|
wglMakeCurrent(hdc, *glrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpace::PaintGraphics(void)
|
void SolveSpace::PaintGraphics()
|
||||||
{
|
{
|
||||||
SS.GW.Paint();
|
SS.GW.Paint();
|
||||||
SwapBuffers(GetDC(GraphicsWnd));
|
SwapBuffers(GetDC(GraphicsWnd));
|
||||||
}
|
}
|
||||||
void SolveSpace::InvalidateGraphics(void)
|
void SolveSpace::InvalidateGraphics()
|
||||||
{
|
{
|
||||||
InvalidateRect(GraphicsWnd, NULL, false);
|
InvalidateRect(GraphicsWnd, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpace::ToggleFullScreen(void)
|
void SolveSpace::ToggleFullScreen()
|
||||||
{
|
{
|
||||||
// Implement me
|
// Implement me
|
||||||
}
|
}
|
||||||
bool SolveSpace::FullScreenIsActive(void)
|
bool SolveSpace::FullScreenIsActive()
|
||||||
{
|
{
|
||||||
// Implement me
|
// Implement me
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t SolveSpace::GetMilliseconds(void)
|
int64_t SolveSpace::GetMilliseconds()
|
||||||
{
|
{
|
||||||
LARGE_INTEGER t, f;
|
LARGE_INTEGER t, f;
|
||||||
QueryPerformanceCounter(&t);
|
QueryPerformanceCounter(&t);
|
||||||
@ -781,7 +781,7 @@ int64_t SolveSpace::GetMilliseconds(void)
|
|||||||
return (int64_t)d;
|
return (int64_t)d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpace::InvalidateText(void)
|
void SolveSpace::InvalidateText()
|
||||||
{
|
{
|
||||||
InvalidateRect(TextWnd, NULL, false);
|
InvalidateRect(TextWnd, NULL, false);
|
||||||
}
|
}
|
||||||
@ -830,11 +830,11 @@ void SolveSpace::ShowTextEditControl(int x, int y, const std::string &str)
|
|||||||
ShowEditControl(TextEditControl, x, y, TextWindow::CHAR_HEIGHT, 30,
|
ShowEditControl(TextEditControl, x, y, TextWindow::CHAR_HEIGHT, 30,
|
||||||
/*isMonospace=*/true, Widen(str));
|
/*isMonospace=*/true, Widen(str));
|
||||||
}
|
}
|
||||||
void SolveSpace::HideTextEditControl(void)
|
void SolveSpace::HideTextEditControl()
|
||||||
{
|
{
|
||||||
ShowWindow(TextEditControl, SW_HIDE);
|
ShowWindow(TextEditControl, SW_HIDE);
|
||||||
}
|
}
|
||||||
bool SolveSpace::TextEditControlIsVisible(void)
|
bool SolveSpace::TextEditControlIsVisible()
|
||||||
{
|
{
|
||||||
return IsWindowVisible(TextEditControl) ? true : false;
|
return IsWindowVisible(TextEditControl) ? true : false;
|
||||||
}
|
}
|
||||||
@ -851,11 +851,11 @@ void SolveSpace::ShowGraphicsEditControl(int x, int y, int fontHeight, int minWi
|
|||||||
ShowEditControl(GraphicsEditControl, x, y, fontHeight, minWidthChars,
|
ShowEditControl(GraphicsEditControl, x, y, fontHeight, minWidthChars,
|
||||||
/*isMonospace=*/false, Widen(str));
|
/*isMonospace=*/false, Widen(str));
|
||||||
}
|
}
|
||||||
void SolveSpace::HideGraphicsEditControl(void)
|
void SolveSpace::HideGraphicsEditControl()
|
||||||
{
|
{
|
||||||
ShowWindow(GraphicsEditControl, SW_HIDE);
|
ShowWindow(GraphicsEditControl, SW_HIDE);
|
||||||
}
|
}
|
||||||
bool SolveSpace::GraphicsEditControlIsVisible(void)
|
bool SolveSpace::GraphicsEditControlIsVisible()
|
||||||
{
|
{
|
||||||
return IsWindowVisible(GraphicsEditControl) ? true : false;
|
return IsWindowVisible(GraphicsEditControl) ? true : false;
|
||||||
}
|
}
|
||||||
@ -1048,7 +1048,7 @@ bool SolveSpace::GetSaveFile(std::string *filename, const std::string &defExtens
|
|||||||
return OpenSaveFile(false, filename, defExtension, filters);
|
return OpenSaveFile(false, filename, defExtension, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogChoice SolveSpace::SaveFileYesNoCancel(void)
|
DialogChoice SolveSpace::SaveFileYesNoCancel()
|
||||||
{
|
{
|
||||||
EnableWindow(GraphicsWnd, false);
|
EnableWindow(GraphicsWnd, false);
|
||||||
EnableWindow(TextWnd, false);
|
EnableWindow(TextWnd, false);
|
||||||
@ -1073,7 +1073,7 @@ DialogChoice SolveSpace::SaveFileYesNoCancel(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogChoice SolveSpace::LoadAutosaveYesNo(void)
|
DialogChoice SolveSpace::LoadAutosaveYesNo()
|
||||||
{
|
{
|
||||||
EnableWindow(GraphicsWnd, false);
|
EnableWindow(GraphicsWnd, false);
|
||||||
EnableWindow(TextWnd, false);
|
EnableWindow(TextWnd, false);
|
||||||
@ -1192,13 +1192,13 @@ static void DoRecent(HMENU m, int base)
|
|||||||
}
|
}
|
||||||
if(c == 0) AppendMenuW(m, MF_STRING | MF_GRAYED, 0, L"(no recent files)");
|
if(c == 0) AppendMenuW(m, MF_STRING | MF_GRAYED, 0, L"(no recent files)");
|
||||||
}
|
}
|
||||||
void SolveSpace::RefreshRecentMenus(void)
|
void SolveSpace::RefreshRecentMenus()
|
||||||
{
|
{
|
||||||
DoRecent(RecentOpenMenu, RECENT_OPEN);
|
DoRecent(RecentOpenMenu, RECENT_OPEN);
|
||||||
DoRecent(RecentImportMenu, RECENT_LINK);
|
DoRecent(RecentImportMenu, RECENT_LINK);
|
||||||
}
|
}
|
||||||
|
|
||||||
HMENU CreateGraphicsWindowMenus(void)
|
HMENU CreateGraphicsWindowMenus()
|
||||||
{
|
{
|
||||||
HMENU top = CreateMenu();
|
HMENU top = CreateMenu();
|
||||||
HMENU m = 0;
|
HMENU m = 0;
|
||||||
@ -1241,7 +1241,7 @@ HMENU CreateGraphicsWindowMenus(void)
|
|||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateMainWindows(void)
|
static void CreateMainWindows()
|
||||||
{
|
{
|
||||||
WNDCLASSEX wc = {};
|
WNDCLASSEX wc = {};
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void *AllocTemporary(size_t n)
|
|||||||
void FreeTemporary(void *p) {
|
void FreeTemporary(void *p) {
|
||||||
HeapFree(TempHeap, HEAP_NO_SERIALIZE, p);
|
HeapFree(TempHeap, HEAP_NO_SERIALIZE, p);
|
||||||
}
|
}
|
||||||
void FreeAllTemporary(void)
|
void FreeAllTemporary()
|
||||||
{
|
{
|
||||||
if(TempHeap) HeapDestroy(TempHeap);
|
if(TempHeap) HeapDestroy(TempHeap);
|
||||||
TempHeap = HeapCreate(HEAP_NO_SERIALIZE, 1024*1024*20, 0);
|
TempHeap = HeapCreate(HEAP_NO_SERIALIZE, 1024*1024*20, 0);
|
||||||
@ -133,12 +133,12 @@ void MemFree(void *p) {
|
|||||||
HeapFree(PermHeap, HEAP_NO_SERIALIZE, p);
|
HeapFree(PermHeap, HEAP_NO_SERIALIZE, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vl(void) {
|
void vl() {
|
||||||
ssassert(HeapValidate(TempHeap, HEAP_NO_SERIALIZE, NULL), "Corrupted heap");
|
ssassert(HeapValidate(TempHeap, HEAP_NO_SERIALIZE, NULL), "Corrupted heap");
|
||||||
ssassert(HeapValidate(PermHeap, HEAP_NO_SERIALIZE, NULL), "Corrupted heap");
|
ssassert(HeapValidate(PermHeap, HEAP_NO_SERIALIZE, NULL), "Corrupted heap");
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitHeaps(void) {
|
void InitHeaps() {
|
||||||
// Create the heap used for long-lived stuff (that gets freed piecewise).
|
// Create the heap used for long-lived stuff (that gets freed piecewise).
|
||||||
PermHeap = HeapCreate(HEAP_NO_SERIALIZE, 1024*1024*20, 0);
|
PermHeap = HeapCreate(HEAP_NO_SERIALIZE, 1024*1024*20, 0);
|
||||||
// Create the heap that we use to store Exprs and other temp stuff.
|
// Create the heap that we use to store Exprs and other temp stuff.
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
Vector STriangle::Normal(void) {
|
Vector STriangle::Normal() {
|
||||||
Vector ab = b.Minus(a), bc = c.Minus(b);
|
Vector ab = b.Minus(a), bc = c.Minus(b);
|
||||||
return ab.Cross(bc);
|
return ab.Cross(bc);
|
||||||
}
|
}
|
||||||
|
|
||||||
double STriangle::MinAltitude(void) {
|
double STriangle::MinAltitude() {
|
||||||
double altA = a.DistanceToLine(b, c.Minus(b)),
|
double altA = a.DistanceToLine(b, c.Minus(b)),
|
||||||
altB = b.DistanceToLine(c, a.Minus(c)),
|
altB = b.DistanceToLine(c, a.Minus(c)),
|
||||||
altC = c.DistanceToLine(a, b.Minus(a));
|
altC = c.DistanceToLine(a, b.Minus(a));
|
||||||
@ -42,7 +42,7 @@ bool STriangle::ContainsPointProjd(Vector n, Vector p) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STriangle::FlipNormal(void) {
|
void STriangle::FlipNormal() {
|
||||||
swap(a, b);
|
swap(a, b);
|
||||||
swap(an, bn);
|
swap(an, bn);
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ bool SEdge::EdgeCrosses(Vector ea, Vector eb, Vector *ppi, SPointList *spl) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SEdgeList::Clear(void) {
|
void SEdgeList::Clear() {
|
||||||
l.Clear();
|
l.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ bool SEdgeList::ContainsEdge(SEdge *set) {
|
|||||||
// Remove unnecessary edges: if two are anti-parallel then remove both, and if
|
// Remove unnecessary edges: if two are anti-parallel then remove both, and if
|
||||||
// two are parallel then remove one.
|
// two are parallel then remove one.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SEdgeList::CullExtraneousEdges(void) {
|
void SEdgeList::CullExtraneousEdges() {
|
||||||
l.ClearTags();
|
l.ClearTags();
|
||||||
int i, j;
|
int i, j;
|
||||||
for(i = 0; i < l.n; i++) {
|
for(i = 0; i < l.n; i++) {
|
||||||
@ -295,12 +295,12 @@ void SEdgeList::CullExtraneousEdges(void) {
|
|||||||
// Make a kd-tree of edges. This is used for O(log(n)) implementations of stuff
|
// Make a kd-tree of edges. This is used for O(log(n)) implementations of stuff
|
||||||
// that would naively be O(n).
|
// that would naively be O(n).
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
SKdNodeEdges *SKdNodeEdges::Alloc(void) {
|
SKdNodeEdges *SKdNodeEdges::Alloc() {
|
||||||
SKdNodeEdges *ne = (SKdNodeEdges *)AllocTemporary(sizeof(SKdNodeEdges));
|
SKdNodeEdges *ne = (SKdNodeEdges *)AllocTemporary(sizeof(SKdNodeEdges));
|
||||||
*ne = {};
|
*ne = {};
|
||||||
return ne;
|
return ne;
|
||||||
}
|
}
|
||||||
SEdgeLl *SEdgeLl::Alloc(void) {
|
SEdgeLl *SEdgeLl::Alloc() {
|
||||||
SEdgeLl *sell = (SEdgeLl *)AllocTemporary(sizeof(SEdgeLl));
|
SEdgeLl *sell = (SEdgeLl *)AllocTemporary(sizeof(SEdgeLl));
|
||||||
*sell = {};
|
*sell = {};
|
||||||
return sell;
|
return sell;
|
||||||
@ -458,7 +458,7 @@ void SEdgeList::MergeCollinearSegments(Vector a, Vector b) {
|
|||||||
l.RemoveTagged();
|
l.RemoveTagged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPointList::Clear(void) {
|
void SPointList::Clear() {
|
||||||
l.Clear();
|
l.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ void SContour::CopyInto(SContour *dest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SContour::FindPointWithMinX(void) {
|
void SContour::FindPointWithMinX() {
|
||||||
SPoint *sp;
|
SPoint *sp;
|
||||||
xminPt = Vector::From(1e10, 1e10, 1e10);
|
xminPt = Vector::From(1e10, 1e10, 1e10);
|
||||||
for(sp = l.First(); sp; sp = l.NextAfter(sp)) {
|
for(sp = l.First(); sp; sp = l.NextAfter(sp)) {
|
||||||
@ -530,7 +530,7 @@ void SContour::FindPointWithMinX(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector SContour::ComputeNormal(void) {
|
Vector SContour::ComputeNormal() {
|
||||||
Vector n = Vector::From(0, 0, 0);
|
Vector n = Vector::From(0, 0, 0);
|
||||||
|
|
||||||
for(int i = 0; i < l.n - 2; i++) {
|
for(int i = 0; i < l.n - 2; i++) {
|
||||||
@ -544,7 +544,7 @@ Vector SContour::ComputeNormal(void) {
|
|||||||
return n.WithMagnitude(1);
|
return n.WithMagnitude(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector SContour::AnyEdgeMidpoint(void) {
|
Vector SContour::AnyEdgeMidpoint() {
|
||||||
ssassert(l.n >= 2, "Need two points to find a midpoint");
|
ssassert(l.n >= 2, "Need two points to find a midpoint");
|
||||||
return ((l.elem[0].p).Plus(l.elem[1].p)).ScaledBy(0.5);
|
return ((l.elem[0].p).Plus(l.elem[1].p)).ScaledBy(0.5);
|
||||||
}
|
}
|
||||||
@ -600,12 +600,12 @@ bool SContour::ContainsPointProjdToNormal(Vector n, Vector p) {
|
|||||||
return inside;
|
return inside;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SContour::Reverse(void) {
|
void SContour::Reverse() {
|
||||||
l.Reverse();
|
l.Reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SPolygon::Clear(void) {
|
void SPolygon::Clear() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < l.n; i++) {
|
for(i = 0; i < l.n; i++) {
|
||||||
(l.elem[i]).l.Clear();
|
(l.elem[i]).l.Clear();
|
||||||
@ -613,7 +613,7 @@ void SPolygon::Clear(void) {
|
|||||||
l.Clear();
|
l.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPolygon::AddEmptyContour(void) {
|
void SPolygon::AddEmptyContour() {
|
||||||
SContour c = {};
|
SContour c = {};
|
||||||
l.Add(&c);
|
l.Add(&c);
|
||||||
}
|
}
|
||||||
@ -625,12 +625,12 @@ void SPolygon::MakeEdgesInto(SEdgeList *el) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector SPolygon::ComputeNormal(void) {
|
Vector SPolygon::ComputeNormal() {
|
||||||
if(l.n < 1) return Vector::From(0, 0, 0);
|
if(l.n < 1) return Vector::From(0, 0, 0);
|
||||||
return (l.elem[0]).ComputeNormal();
|
return (l.elem[0]).ComputeNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
double SPolygon::SignedArea(void) {
|
double SPolygon::SignedArea() {
|
||||||
SContour *sc;
|
SContour *sc;
|
||||||
double area = 0;
|
double area = 0;
|
||||||
// This returns the true area only if the contours are all oriented
|
// This returns the true area only if the contours are all oriented
|
||||||
@ -657,7 +657,7 @@ int SPolygon::WindingNumberForPoint(Vector p) {
|
|||||||
return winding;
|
return winding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPolygon::FixContourDirections(void) {
|
void SPolygon::FixContourDirections() {
|
||||||
// At output, the contour's tag will be 1 if we reversed it, else 0.
|
// At output, the contour's tag will be 1 if we reversed it, else 0.
|
||||||
l.ClearTags();
|
l.ClearTags();
|
||||||
|
|
||||||
@ -690,12 +690,12 @@ void SPolygon::FixContourDirections(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPolygon::IsEmpty(void) {
|
bool SPolygon::IsEmpty() {
|
||||||
if(l.n == 0 || l.elem[0].l.n == 0) return true;
|
if(l.n == 0 || l.elem[0].l.n == 0) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector SPolygon::AnyPoint(void) {
|
Vector SPolygon::AnyPoint() {
|
||||||
ssassert(!IsEmpty(), "Need at least one point");
|
ssassert(!IsEmpty(), "Need at least one point");
|
||||||
return l.elem[0].l.elem[0].p;
|
return l.elem[0].l.elem[0].p;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class SEdgeList {
|
|||||||
public:
|
public:
|
||||||
List<SEdge> l;
|
List<SEdge> l;
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
void AddEdge(Vector a, Vector b, int auxA=0, int auxB=0);
|
void AddEdge(Vector a, Vector b, int auxA=0, int auxB=0);
|
||||||
bool AssemblePolygon(SPolygon *dest, SEdge *errorAt, bool keepDir=false);
|
bool AssemblePolygon(SPolygon *dest, SEdge *errorAt, bool keepDir=false);
|
||||||
bool AssembleContour(Vector first, Vector last, SContour *dest,
|
bool AssembleContour(Vector first, Vector last, SContour *dest,
|
||||||
@ -38,7 +38,7 @@ public:
|
|||||||
Vector *pi=NULL, SPointList *spl=NULL);
|
Vector *pi=NULL, SPointList *spl=NULL);
|
||||||
bool ContainsEdgeFrom(SEdgeList *sel);
|
bool ContainsEdgeFrom(SEdgeList *sel);
|
||||||
bool ContainsEdge(SEdge *se);
|
bool ContainsEdge(SEdge *se);
|
||||||
void CullExtraneousEdges(void);
|
void CullExtraneousEdges();
|
||||||
void MergeCollinearSegments(Vector a, Vector b);
|
void MergeCollinearSegments(Vector a, Vector b);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
SEdge *se;
|
SEdge *se;
|
||||||
SEdgeLl *next;
|
SEdgeLl *next;
|
||||||
|
|
||||||
static SEdgeLl *Alloc(void);
|
static SEdgeLl *Alloc();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SKdNodeEdges {
|
class SKdNodeEdges {
|
||||||
@ -66,7 +66,7 @@ public:
|
|||||||
|
|
||||||
static SKdNodeEdges *From(SEdgeList *sel);
|
static SKdNodeEdges *From(SEdgeList *sel);
|
||||||
static SKdNodeEdges *From(SEdgeLl *sell);
|
static SKdNodeEdges *From(SEdgeLl *sell);
|
||||||
static SKdNodeEdges *Alloc(void);
|
static SKdNodeEdges *Alloc();
|
||||||
int AnyEdgeCrossings(Vector a, Vector b, int cnt,
|
int AnyEdgeCrossings(Vector a, Vector b, int cnt,
|
||||||
Vector *pi=NULL, SPointList *spl=NULL);
|
Vector *pi=NULL, SPointList *spl=NULL);
|
||||||
};
|
};
|
||||||
@ -90,7 +90,7 @@ class SPointList {
|
|||||||
public:
|
public:
|
||||||
List<SPoint> l;
|
List<SPoint> l;
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
bool ContainsPoint(Vector pt);
|
bool ContainsPoint(Vector pt);
|
||||||
int IndexForPoint(Vector pt);
|
int IndexForPoint(Vector pt);
|
||||||
void IncrementTagFor(Vector pt);
|
void IncrementTagFor(Vector pt);
|
||||||
@ -106,15 +106,15 @@ public:
|
|||||||
|
|
||||||
void AddPoint(Vector p);
|
void AddPoint(Vector p);
|
||||||
void MakeEdgesInto(SEdgeList *el);
|
void MakeEdgesInto(SEdgeList *el);
|
||||||
void Reverse(void);
|
void Reverse();
|
||||||
Vector ComputeNormal(void);
|
Vector ComputeNormal();
|
||||||
double SignedAreaProjdToNormal(Vector n);
|
double SignedAreaProjdToNormal(Vector n);
|
||||||
bool IsClockwiseProjdToNormal(Vector n);
|
bool IsClockwiseProjdToNormal(Vector n);
|
||||||
bool ContainsPointProjdToNormal(Vector n, Vector p);
|
bool ContainsPointProjdToNormal(Vector n, Vector p);
|
||||||
void OffsetInto(SContour *dest, double r);
|
void OffsetInto(SContour *dest, double r);
|
||||||
void CopyInto(SContour *dest);
|
void CopyInto(SContour *dest);
|
||||||
void FindPointWithMinX(void);
|
void FindPointWithMinX();
|
||||||
Vector AnyEdgeMidpoint(void);
|
Vector AnyEdgeMidpoint();
|
||||||
|
|
||||||
bool IsEar(int bp, double scaledEps);
|
bool IsEar(int bp, double scaledEps);
|
||||||
bool BridgeToContour(SContour *sc, SEdgeList *el, List<Vector> *vl);
|
bool BridgeToContour(SContour *sc, SEdgeList *el, List<Vector> *vl);
|
||||||
@ -132,17 +132,17 @@ public:
|
|||||||
List<SContour> l;
|
List<SContour> l;
|
||||||
Vector normal;
|
Vector normal;
|
||||||
|
|
||||||
Vector ComputeNormal(void);
|
Vector ComputeNormal();
|
||||||
void AddEmptyContour(void);
|
void AddEmptyContour();
|
||||||
int WindingNumberForPoint(Vector p);
|
int WindingNumberForPoint(Vector p);
|
||||||
double SignedArea(void);
|
double SignedArea();
|
||||||
bool ContainsPoint(Vector p);
|
bool ContainsPoint(Vector p);
|
||||||
void MakeEdgesInto(SEdgeList *el);
|
void MakeEdgesInto(SEdgeList *el);
|
||||||
void FixContourDirections(void);
|
void FixContourDirections();
|
||||||
void Clear(void);
|
void Clear();
|
||||||
bool SelfIntersecting(Vector *intersectsAt);
|
bool SelfIntersecting(Vector *intersectsAt);
|
||||||
bool IsEmpty(void);
|
bool IsEmpty();
|
||||||
Vector AnyPoint(void);
|
Vector AnyPoint();
|
||||||
void OffsetInto(SPolygon *dest, double r);
|
void OffsetInto(SPolygon *dest, double r);
|
||||||
void UvTriangulateInto(SMesh *m, SSurface *srf);
|
void UvTriangulateInto(SMesh *m, SSurface *srf);
|
||||||
void UvGridTriangulateInto(SMesh *m, SSurface *srf);
|
void UvGridTriangulateInto(SMesh *m, SSurface *srf);
|
||||||
@ -156,9 +156,9 @@ public:
|
|||||||
Vector an, bn, cn;
|
Vector an, bn, cn;
|
||||||
|
|
||||||
static STriangle From(STriMeta meta, Vector a, Vector b, Vector c);
|
static STriangle From(STriMeta meta, Vector a, Vector b, Vector c);
|
||||||
Vector Normal(void);
|
Vector Normal();
|
||||||
void FlipNormal(void);
|
void FlipNormal();
|
||||||
double MinAltitude(void);
|
double MinAltitude();
|
||||||
int WindingNumberForPoint(Vector p);
|
int WindingNumberForPoint(Vector p);
|
||||||
bool ContainsPoint(Vector p);
|
bool ContainsPoint(Vector p);
|
||||||
bool ContainsPointProjd(Vector n, Vector p);
|
bool ContainsPointProjd(Vector n, Vector p);
|
||||||
@ -183,7 +183,7 @@ public:
|
|||||||
Vector IntersectionWith(Vector a, Vector b);
|
Vector IntersectionWith(Vector a, Vector b);
|
||||||
void InsertEdge(SEdge *nedge, Vector nnp, Vector out);
|
void InsertEdge(SEdge *nedge, Vector nnp, Vector out);
|
||||||
static SBsp2 *InsertOrCreateEdge(SBsp2 *where, SEdge *nedge, Vector nnp, Vector out);
|
static SBsp2 *InsertOrCreateEdge(SBsp2 *where, SEdge *nedge, Vector nnp, Vector out);
|
||||||
static SBsp2 *Alloc(void);
|
static SBsp2 *Alloc();
|
||||||
|
|
||||||
void DebugDraw(Vector n, double d);
|
void DebugDraw(Vector n, double d);
|
||||||
};
|
};
|
||||||
@ -201,7 +201,7 @@ public:
|
|||||||
|
|
||||||
SBsp2 *edges;
|
SBsp2 *edges;
|
||||||
|
|
||||||
static SBsp3 *Alloc(void);
|
static SBsp3 *Alloc();
|
||||||
static SBsp3 *FromMesh(SMesh *m);
|
static SBsp3 *FromMesh(SMesh *m);
|
||||||
|
|
||||||
Vector IntersectionWith(Vector a, Vector b);
|
Vector IntersectionWith(Vector a, Vector b);
|
||||||
@ -219,7 +219,7 @@ public:
|
|||||||
|
|
||||||
void GenerateInPaintOrder(SMesh *m);
|
void GenerateInPaintOrder(SMesh *m);
|
||||||
|
|
||||||
void DebugDraw(void);
|
void DebugDraw();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SMesh {
|
class SMesh {
|
||||||
@ -231,7 +231,7 @@ public:
|
|||||||
bool atLeastOneDiscarded;
|
bool atLeastOneDiscarded;
|
||||||
bool isTransparent;
|
bool isTransparent;
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
void AddTriangle(STriangle *st);
|
void AddTriangle(STriangle *st);
|
||||||
void AddTriangle(STriMeta meta, Vector a, Vector b, Vector c);
|
void AddTriangle(STriMeta meta, Vector a, Vector b, Vector c);
|
||||||
void AddTriangle(STriMeta meta, Vector n, Vector a, Vector b, Vector c);
|
void AddTriangle(STriMeta meta, Vector n, Vector a, Vector b, Vector c);
|
||||||
@ -252,7 +252,7 @@ public:
|
|||||||
void MakeEdgesInPlaneInto(SEdgeList *sel, Vector n, double d);
|
void MakeEdgesInPlaneInto(SEdgeList *sel, Vector n, double d);
|
||||||
void MakeCertainEdgesAndOutlinesInto(SEdgeList *sel, SOutlineList *sol, int type);
|
void MakeCertainEdgesAndOutlinesInto(SEdgeList *sel, SOutlineList *sol, int type);
|
||||||
|
|
||||||
bool IsEmpty(void);
|
bool IsEmpty();
|
||||||
void RemapFaces(Group *g, int remap);
|
void RemapFaces(Group *g, int remap);
|
||||||
|
|
||||||
uint32_t FirstIntersectionWith(Point2d mp);
|
uint32_t FirstIntersectionWith(Point2d mp);
|
||||||
@ -265,7 +265,7 @@ public:
|
|||||||
|
|
||||||
STriangleLl *next;
|
STriangleLl *next;
|
||||||
|
|
||||||
static STriangleLl *Alloc(void);
|
static STriangleLl *Alloc();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SOutline {
|
class SOutline {
|
||||||
@ -305,14 +305,14 @@ public:
|
|||||||
|
|
||||||
STriangleLl *tris;
|
STriangleLl *tris;
|
||||||
|
|
||||||
static SKdNode *Alloc(void);
|
static SKdNode *Alloc();
|
||||||
static SKdNode *From(SMesh *m);
|
static SKdNode *From(SMesh *m);
|
||||||
static SKdNode *From(STriangleLl *tll);
|
static SKdNode *From(STriangleLl *tll);
|
||||||
|
|
||||||
void AddTriangle(STriangle *tr);
|
void AddTriangle(STriangle *tr);
|
||||||
void MakeMeshInto(SMesh *m);
|
void MakeMeshInto(SMesh *m);
|
||||||
void ListTrianglesInto(std::vector<STriangle *> *tl);
|
void ListTrianglesInto(std::vector<STriangle *> *tl);
|
||||||
void ClearTags(void);
|
void ClearTags();
|
||||||
|
|
||||||
void FindEdgeOn(Vector a, Vector b, int cnt, bool coplanarIsInter, EdgeOnInfo *info);
|
void FindEdgeOn(Vector a, Vector b, int cnt, bool coplanarIsInter, EdgeOnInfo *info);
|
||||||
enum {
|
enum {
|
||||||
|
@ -169,7 +169,7 @@ void Request::Generate(IdList<Entity,hEntity> *entity,
|
|||||||
if(et) entity->Add(&e);
|
if(et) entity->Add(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Request::DescriptionString(void) {
|
std::string Request::DescriptionString() {
|
||||||
const char *s;
|
const char *s;
|
||||||
if(h.v == Request::HREQUEST_REFERENCE_XY.v) {
|
if(h.v == Request::HREQUEST_REFERENCE_XY.v) {
|
||||||
s = "#XY";
|
s = "#XY";
|
||||||
|
180
src/sketch.h
180
src/sketch.h
@ -41,7 +41,7 @@ public:
|
|||||||
inline hEntity entity(int i);
|
inline hEntity entity(int i);
|
||||||
inline hParam param(int i);
|
inline hParam param(int i);
|
||||||
|
|
||||||
inline bool IsFromReferences(void);
|
inline bool IsFromReferences();
|
||||||
};
|
};
|
||||||
class hEntity {
|
class hEntity {
|
||||||
public:
|
public:
|
||||||
@ -49,9 +49,9 @@ public:
|
|||||||
// 31:16 -- request index
|
// 31:16 -- request index
|
||||||
uint32_t v;
|
uint32_t v;
|
||||||
|
|
||||||
inline bool isFromRequest(void);
|
inline bool isFromRequest();
|
||||||
inline hRequest request(void);
|
inline hRequest request();
|
||||||
inline hGroup group(void);
|
inline hGroup group();
|
||||||
inline hEquation equation(int i);
|
inline hEquation equation(int i);
|
||||||
};
|
};
|
||||||
class hParam {
|
class hParam {
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
// 31:16 -- request index
|
// 31:16 -- request index
|
||||||
uint32_t v;
|
uint32_t v;
|
||||||
|
|
||||||
inline hRequest request(void);
|
inline hRequest request();
|
||||||
};
|
};
|
||||||
|
|
||||||
class hStyle {
|
class hStyle {
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
int copyNumber;
|
int copyNumber;
|
||||||
// (input, copyNumber) gets mapped to ((Request)xxx).entity(h.v)
|
// (input, copyNumber) gets mapped to ((Request)xxx).entity(h.v)
|
||||||
|
|
||||||
void Clear(void) {}
|
void Clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// A set of requests. Every request must have an associated group.
|
// A set of requests. Every request must have an associated group.
|
||||||
@ -201,9 +201,9 @@ public:
|
|||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
|
|
||||||
void Activate(void);
|
void Activate();
|
||||||
std::string DescriptionString(void);
|
std::string DescriptionString();
|
||||||
void Clear(void);
|
void Clear();
|
||||||
|
|
||||||
static void AddParam(ParamList *param, hParam hp, double v);
|
static void AddParam(ParamList *param, hParam hp, double v);
|
||||||
void Generate(EntityList *entity, ParamList *param);
|
void Generate(EntityList *entity, ParamList *param);
|
||||||
@ -236,7 +236,7 @@ public:
|
|||||||
|
|
||||||
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
||||||
void GenerateEquations(IdList<Equation,hEquation> *l);
|
void GenerateEquations(IdList<Equation,hEquation> *l);
|
||||||
bool IsVisible(void);
|
bool IsVisible();
|
||||||
int GetNumConstraints();
|
int GetNumConstraints();
|
||||||
Vector ExtrusionGetVector();
|
Vector ExtrusionGetVector();
|
||||||
void ExtrusionForceVectorTo(const Vector &v);
|
void ExtrusionForceVectorTo(const Vector &v);
|
||||||
@ -244,23 +244,23 @@ public:
|
|||||||
// Assembling the curves into loops, and into a piecewise linear polygon
|
// Assembling the curves into loops, and into a piecewise linear polygon
|
||||||
// at the same time.
|
// at the same time.
|
||||||
void AssembleLoops(bool *allClosed, bool *allCoplanar, bool *allNonZeroLen);
|
void AssembleLoops(bool *allClosed, bool *allCoplanar, bool *allNonZeroLen);
|
||||||
void GenerateLoops(void);
|
void GenerateLoops();
|
||||||
// And the mesh stuff
|
// And the mesh stuff
|
||||||
Group *PreviousGroup(void);
|
Group *PreviousGroup();
|
||||||
Group *RunningMeshGroup(void);
|
Group *RunningMeshGroup();
|
||||||
bool IsMeshGroup();
|
bool IsMeshGroup();
|
||||||
void GenerateShellAndMesh(void);
|
void GenerateShellAndMesh();
|
||||||
template<class T> void GenerateForStepAndRepeat(T *steps, T *outs);
|
template<class T> void GenerateForStepAndRepeat(T *steps, T *outs);
|
||||||
template<class T> void GenerateForBoolean(T *a, T *b, T *o, int how);
|
template<class T> void GenerateForBoolean(T *a, T *b, T *o, int how);
|
||||||
void GenerateDisplayItems(void);
|
void GenerateDisplayItems();
|
||||||
void DrawDisplayItems(int t);
|
void DrawDisplayItems(int t);
|
||||||
void Draw(void);
|
void Draw();
|
||||||
RgbaColor GetLoopSetFillColor(SBezierLoopSet *sbls,
|
RgbaColor GetLoopSetFillColor(SBezierLoopSet *sbls,
|
||||||
bool *allSame, Vector *errorAt);
|
bool *allSame, Vector *errorAt);
|
||||||
void FillLoopSetAsPolygon(SBezierLoopSet *sbls);
|
void FillLoopSetAsPolygon(SBezierLoopSet *sbls);
|
||||||
void DrawFilledPaths(void);
|
void DrawFilledPaths();
|
||||||
|
|
||||||
SPolygon GetPolygon(void);
|
SPolygon GetPolygon();
|
||||||
|
|
||||||
static void MenuGroup(int id);
|
static void MenuGroup(int id);
|
||||||
};
|
};
|
||||||
@ -303,10 +303,10 @@ public:
|
|||||||
static hParam AddParam(ParamList *param, hParam hp);
|
static hParam AddParam(ParamList *param, hParam hp);
|
||||||
void Generate(EntityList *entity, ParamList *param);
|
void Generate(EntityList *entity, ParamList *param);
|
||||||
|
|
||||||
std::string DescriptionString(void);
|
std::string DescriptionString();
|
||||||
int IndexOfPoint(hEntity he);
|
int IndexOfPoint(hEntity he);
|
||||||
|
|
||||||
void Clear(void) {}
|
void Clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_POINTS_IN_ENTITY (12)
|
#define MAX_POINTS_IN_ENTITY (12)
|
||||||
@ -381,74 +381,74 @@ public:
|
|||||||
Quaternion GetAxisAngleQuaternion(int param0);
|
Quaternion GetAxisAngleQuaternion(int param0);
|
||||||
ExprQuaternion GetAxisAngleQuaternionExprs(int param0);
|
ExprQuaternion GetAxisAngleQuaternionExprs(int param0);
|
||||||
|
|
||||||
bool IsCircle(void);
|
bool IsCircle();
|
||||||
Expr *CircleGetRadiusExpr(void);
|
Expr *CircleGetRadiusExpr();
|
||||||
double CircleGetRadiusNum(void);
|
double CircleGetRadiusNum();
|
||||||
void ArcGetAngles(double *thetaa, double *thetab, double *dtheta);
|
void ArcGetAngles(double *thetaa, double *thetab, double *dtheta);
|
||||||
|
|
||||||
bool HasVector(void);
|
bool HasVector();
|
||||||
ExprVector VectorGetExprs(void);
|
ExprVector VectorGetExprs();
|
||||||
Vector VectorGetNum(void);
|
Vector VectorGetNum();
|
||||||
Vector VectorGetRefPoint(void);
|
Vector VectorGetRefPoint();
|
||||||
Vector VectorGetStartPoint(void);
|
Vector VectorGetStartPoint();
|
||||||
|
|
||||||
// For distances
|
// For distances
|
||||||
bool IsDistance(void);
|
bool IsDistance();
|
||||||
double DistanceGetNum(void);
|
double DistanceGetNum();
|
||||||
Expr *DistanceGetExpr(void);
|
Expr *DistanceGetExpr();
|
||||||
void DistanceForceTo(double v);
|
void DistanceForceTo(double v);
|
||||||
|
|
||||||
bool IsWorkplane(void);
|
bool IsWorkplane();
|
||||||
// The plane is points P such that P dot (xn, yn, zn) - d = 0
|
// The plane is points P such that P dot (xn, yn, zn) - d = 0
|
||||||
void WorkplaneGetPlaneExprs(ExprVector *n, Expr **d);
|
void WorkplaneGetPlaneExprs(ExprVector *n, Expr **d);
|
||||||
ExprVector WorkplaneGetOffsetExprs(void);
|
ExprVector WorkplaneGetOffsetExprs();
|
||||||
Vector WorkplaneGetOffset(void);
|
Vector WorkplaneGetOffset();
|
||||||
EntityBase *Normal(void);
|
EntityBase *Normal();
|
||||||
|
|
||||||
bool IsFace(void);
|
bool IsFace();
|
||||||
ExprVector FaceGetNormalExprs(void);
|
ExprVector FaceGetNormalExprs();
|
||||||
Vector FaceGetNormalNum(void);
|
Vector FaceGetNormalNum();
|
||||||
ExprVector FaceGetPointExprs(void);
|
ExprVector FaceGetPointExprs();
|
||||||
Vector FaceGetPointNum(void);
|
Vector FaceGetPointNum();
|
||||||
|
|
||||||
bool IsPoint(void);
|
bool IsPoint();
|
||||||
// Applies for any of the point types
|
// Applies for any of the point types
|
||||||
Vector PointGetNum(void);
|
Vector PointGetNum();
|
||||||
ExprVector PointGetExprs(void);
|
ExprVector PointGetExprs();
|
||||||
void PointGetExprsInWorkplane(hEntity wrkpl, Expr **u, Expr **v);
|
void PointGetExprsInWorkplane(hEntity wrkpl, Expr **u, Expr **v);
|
||||||
void PointForceTo(Vector v);
|
void PointForceTo(Vector v);
|
||||||
// These apply only the POINT_N_ROT_TRANS, which has an assoc rotation
|
// These apply only the POINT_N_ROT_TRANS, which has an assoc rotation
|
||||||
Quaternion PointGetQuaternion(void);
|
Quaternion PointGetQuaternion();
|
||||||
void PointForceQuaternionTo(Quaternion q);
|
void PointForceQuaternionTo(Quaternion q);
|
||||||
|
|
||||||
bool IsNormal(void);
|
bool IsNormal();
|
||||||
// Applies for any of the normal types
|
// Applies for any of the normal types
|
||||||
Quaternion NormalGetNum(void);
|
Quaternion NormalGetNum();
|
||||||
ExprQuaternion NormalGetExprs(void);
|
ExprQuaternion NormalGetExprs();
|
||||||
void NormalForceTo(Quaternion q);
|
void NormalForceTo(Quaternion q);
|
||||||
|
|
||||||
Vector NormalU(void);
|
Vector NormalU();
|
||||||
Vector NormalV(void);
|
Vector NormalV();
|
||||||
Vector NormalN(void);
|
Vector NormalN();
|
||||||
ExprVector NormalExprsU(void);
|
ExprVector NormalExprsU();
|
||||||
ExprVector NormalExprsV(void);
|
ExprVector NormalExprsV();
|
||||||
ExprVector NormalExprsN(void);
|
ExprVector NormalExprsN();
|
||||||
|
|
||||||
Vector CubicGetStartNum(void);
|
Vector CubicGetStartNum();
|
||||||
Vector CubicGetFinishNum(void);
|
Vector CubicGetFinishNum();
|
||||||
ExprVector CubicGetStartTangentExprs(void);
|
ExprVector CubicGetStartTangentExprs();
|
||||||
ExprVector CubicGetFinishTangentExprs(void);
|
ExprVector CubicGetFinishTangentExprs();
|
||||||
Vector CubicGetStartTangentNum(void);
|
Vector CubicGetStartTangentNum();
|
||||||
Vector CubicGetFinishTangentNum(void);
|
Vector CubicGetFinishTangentNum();
|
||||||
|
|
||||||
bool HasEndpoints(void);
|
bool HasEndpoints();
|
||||||
Vector EndpointStart();
|
Vector EndpointStart();
|
||||||
Vector EndpointFinish();
|
Vector EndpointFinish();
|
||||||
|
|
||||||
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
||||||
void GenerateEquations(IdList<Equation,hEquation> *l);
|
void GenerateEquations(IdList<Equation,hEquation> *l);
|
||||||
|
|
||||||
void Clear(void) {}
|
void Clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Entity : public EntityBase {
|
class Entity : public EntityBase {
|
||||||
@ -500,11 +500,11 @@ public:
|
|||||||
int data;
|
int data;
|
||||||
} dogd; // state for drawing or getting distance (for hit testing)
|
} dogd; // state for drawing or getting distance (for hit testing)
|
||||||
void LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat=false, int userData = -1);
|
void LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat=false, int userData = -1);
|
||||||
void DrawOrGetDistance(void);
|
void DrawOrGetDistance();
|
||||||
|
|
||||||
bool IsStylable();
|
bool IsStylable();
|
||||||
bool IsVisible(void);
|
bool IsVisible();
|
||||||
bool PointIsFromReferences(void);
|
bool PointIsFromReferences();
|
||||||
|
|
||||||
void ComputeInterpolatingSpline(SBezierList *sbl, bool periodic);
|
void ComputeInterpolatingSpline(SBezierList *sbl, bool periodic);
|
||||||
void GenerateBezierCurves(SBezierList *sbl);
|
void GenerateBezierCurves(SBezierList *sbl);
|
||||||
@ -513,11 +513,11 @@ public:
|
|||||||
static void DrawAll(bool drawAsHidden);
|
static void DrawAll(bool drawAsHidden);
|
||||||
void Draw(bool drawAsHidden);
|
void Draw(bool drawAsHidden);
|
||||||
double GetDistance(Point2d mp);
|
double GetDistance(Point2d mp);
|
||||||
Vector GetReferencePos(void);
|
Vector GetReferencePos();
|
||||||
|
|
||||||
void CalculateNumerical(bool forExport);
|
void CalculateNumerical(bool forExport);
|
||||||
|
|
||||||
std::string DescriptionString(void);
|
std::string DescriptionString();
|
||||||
|
|
||||||
SBezierList *GetOrGenerateBezierCurves();
|
SBezierList *GetOrGenerateBezierCurves();
|
||||||
SEdgeList *GetOrGenerateEdges();
|
SEdgeList *GetOrGenerateEdges();
|
||||||
@ -567,7 +567,7 @@ public:
|
|||||||
|
|
||||||
static const hParam NO_PARAM;
|
static const hParam NO_PARAM;
|
||||||
|
|
||||||
void Clear(void) {}
|
void Clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -643,12 +643,12 @@ public:
|
|||||||
bool reference; // a ref dimension, that generates no eqs
|
bool reference; // a ref dimension, that generates no eqs
|
||||||
std::string comment; // since comments are represented as constraints
|
std::string comment; // since comments are represented as constraints
|
||||||
|
|
||||||
bool HasLabel(void);
|
bool HasLabel();
|
||||||
|
|
||||||
void Generate(IdList<Equation,hEquation> *l);
|
void Generate(IdList<Equation,hEquation> *l);
|
||||||
void GenerateReal(IdList<Equation,hEquation> *l);
|
void GenerateReal(IdList<Equation,hEquation> *l);
|
||||||
// Some helpers when generating symbolic constraint equations
|
// Some helpers when generating symbolic constraint equations
|
||||||
void ModifyToSatisfy(void);
|
void ModifyToSatisfy();
|
||||||
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
||||||
static Expr *DirectionCosine(hEntity wrkpl, ExprVector ae, ExprVector be);
|
static Expr *DirectionCosine(hEntity wrkpl, ExprVector ae, ExprVector be);
|
||||||
static Expr *Distance(hEntity workplane, hEntity pa, hEntity pb);
|
static Expr *Distance(hEntity workplane, hEntity pa, hEntity pb);
|
||||||
@ -657,7 +657,7 @@ public:
|
|||||||
static Expr *VectorsParallel(int eq, ExprVector a, ExprVector b);
|
static Expr *VectorsParallel(int eq, ExprVector a, ExprVector b);
|
||||||
static ExprVector PointInThreeSpace(hEntity workplane, Expr *u, Expr *v);
|
static ExprVector PointInThreeSpace(hEntity workplane, Expr *u, Expr *v);
|
||||||
|
|
||||||
void Clear(void) {}
|
void Clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Constraint : public ConstraintBase {
|
class Constraint : public ConstraintBase {
|
||||||
@ -681,9 +681,9 @@ public:
|
|||||||
} dogd;
|
} dogd;
|
||||||
|
|
||||||
double GetDistance(Point2d mp);
|
double GetDistance(Point2d mp);
|
||||||
Vector GetLabelPos(void);
|
Vector GetLabelPos();
|
||||||
Vector GetReferencePos(void);
|
Vector GetReferencePos();
|
||||||
void Draw(void);
|
void Draw();
|
||||||
void GetEdges(SEdgeList *sel);
|
void GetEdges(SEdgeList *sel);
|
||||||
bool IsStylable();
|
bool IsStylable();
|
||||||
hStyle GetStyle() const;
|
hStyle GetStyle() const;
|
||||||
@ -692,7 +692,7 @@ public:
|
|||||||
void LineDrawOrGetDistance(Vector a, Vector b);
|
void LineDrawOrGetDistance(Vector a, Vector b);
|
||||||
bool IsVisible() const;
|
bool IsVisible() const;
|
||||||
void DrawOrGetDistance(Vector *labelPos);
|
void DrawOrGetDistance(Vector *labelPos);
|
||||||
std::string Label(void);
|
std::string Label();
|
||||||
bool DoLineExtend(Vector p0, Vector p1, Vector pt, double salient);
|
bool DoLineExtend(Vector p0, Vector p1, Vector pt, double salient);
|
||||||
void DoArcForAngle(Vector a0, Vector da, Vector b0, Vector db,
|
void DoArcForAngle(Vector a0, Vector da, Vector b0, Vector db,
|
||||||
Vector offset, Vector *ref, bool trim);
|
Vector offset, Vector *ref, bool trim);
|
||||||
@ -706,7 +706,7 @@ public:
|
|||||||
void DoEqualLenTicks(Vector a, Vector b, Vector gn);
|
void DoEqualLenTicks(Vector a, Vector b, Vector gn);
|
||||||
void DoEqualRadiusTicks(hEntity he);
|
void DoEqualRadiusTicks(hEntity he);
|
||||||
|
|
||||||
std::string DescriptionString(void);
|
std::string DescriptionString();
|
||||||
|
|
||||||
static hConstraint AddConstraint(Constraint *c, bool rememberForUndo);
|
static hConstraint AddConstraint(Constraint *c, bool rememberForUndo);
|
||||||
static hConstraint AddConstraint(Constraint *c);
|
static hConstraint AddConstraint(Constraint *c);
|
||||||
@ -724,8 +724,8 @@ class hEquation {
|
|||||||
public:
|
public:
|
||||||
uint32_t v;
|
uint32_t v;
|
||||||
|
|
||||||
inline bool isFromConstraint(void);
|
inline bool isFromConstraint();
|
||||||
inline hConstraint constraint(void);
|
inline hConstraint constraint();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Equation {
|
class Equation {
|
||||||
@ -735,7 +735,7 @@ public:
|
|||||||
|
|
||||||
Expr *e;
|
Expr *e;
|
||||||
|
|
||||||
void Clear(void) {}
|
void Clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -825,11 +825,11 @@ public:
|
|||||||
static std::string CnfTextHeight(const std::string &prefix);
|
static std::string CnfTextHeight(const std::string &prefix);
|
||||||
static std::string CnfPrefixToName(const std::string &prefix);
|
static std::string CnfPrefixToName(const std::string &prefix);
|
||||||
|
|
||||||
static void CreateAllDefaultStyles(void);
|
static void CreateAllDefaultStyles();
|
||||||
static void CreateDefaultStyle(hStyle h);
|
static void CreateDefaultStyle(hStyle h);
|
||||||
static void FillDefaultStyle(Style *s, const Default *d = NULL);
|
static void FillDefaultStyle(Style *s, const Default *d = NULL);
|
||||||
static void FreezeDefaultStyles(void);
|
static void FreezeDefaultStyles();
|
||||||
static void LoadFactoryDefaults(void);
|
static void LoadFactoryDefaults();
|
||||||
|
|
||||||
static void AssignSelectionToStyle(uint32_t v);
|
static void AssignSelectionToStyle(uint32_t v);
|
||||||
static uint32_t CreateCustomStyle(bool rememberForUndo = true);
|
static uint32_t CreateCustomStyle(bool rememberForUndo = true);
|
||||||
@ -850,9 +850,9 @@ public:
|
|||||||
static int PatternType(hStyle hs);
|
static int PatternType(hStyle hs);
|
||||||
static double StippleScaleMm(hStyle hs);
|
static double StippleScaleMm(hStyle hs);
|
||||||
|
|
||||||
std::string DescriptionString(void);
|
std::string DescriptionString();
|
||||||
|
|
||||||
void Clear(void) {}
|
void Clear() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -863,7 +863,7 @@ inline hParam hGroup::param(int i)
|
|||||||
inline hEquation hGroup::equation(int i)
|
inline hEquation hGroup::equation(int i)
|
||||||
{ hEquation r; r.v = (v << 16) | 0x80000000 | (uint32_t)i; return r; }
|
{ hEquation r; r.v = (v << 16) | 0x80000000 | (uint32_t)i; return r; }
|
||||||
|
|
||||||
inline bool hRequest::IsFromReferences(void) {
|
inline bool hRequest::IsFromReferences() {
|
||||||
if(v == Request::HREQUEST_REFERENCE_XY.v) return true;
|
if(v == Request::HREQUEST_REFERENCE_XY.v) return true;
|
||||||
if(v == Request::HREQUEST_REFERENCE_YZ.v) return true;
|
if(v == Request::HREQUEST_REFERENCE_YZ.v) return true;
|
||||||
if(v == Request::HREQUEST_REFERENCE_ZX.v) return true;
|
if(v == Request::HREQUEST_REFERENCE_ZX.v) return true;
|
||||||
@ -874,25 +874,25 @@ inline hEntity hRequest::entity(int i)
|
|||||||
inline hParam hRequest::param(int i)
|
inline hParam hRequest::param(int i)
|
||||||
{ hParam r; r.v = (v << 16) | (uint32_t)i; return r; }
|
{ hParam r; r.v = (v << 16) | (uint32_t)i; return r; }
|
||||||
|
|
||||||
inline bool hEntity::isFromRequest(void)
|
inline bool hEntity::isFromRequest()
|
||||||
{ if(v & 0x80000000) return false; else return true; }
|
{ if(v & 0x80000000) return false; else return true; }
|
||||||
inline hRequest hEntity::request(void)
|
inline hRequest hEntity::request()
|
||||||
{ hRequest r; r.v = (v >> 16); return r; }
|
{ hRequest r; r.v = (v >> 16); return r; }
|
||||||
inline hGroup hEntity::group(void)
|
inline hGroup hEntity::group()
|
||||||
{ hGroup r; r.v = (v >> 16) & 0x3fff; return r; }
|
{ hGroup r; r.v = (v >> 16) & 0x3fff; return r; }
|
||||||
inline hEquation hEntity::equation(int i)
|
inline hEquation hEntity::equation(int i)
|
||||||
{ hEquation r; r.v = v | 0x40000000; return r; }
|
{ hEquation r; r.v = v | 0x40000000; return r; }
|
||||||
|
|
||||||
inline hRequest hParam::request(void)
|
inline hRequest hParam::request()
|
||||||
{ hRequest r; r.v = (v >> 16); return r; }
|
{ hRequest r; r.v = (v >> 16); return r; }
|
||||||
|
|
||||||
|
|
||||||
inline hEquation hConstraint::equation(int i)
|
inline hEquation hConstraint::equation(int i)
|
||||||
{ hEquation r; r.v = (v << 16) | (uint32_t)i; return r; }
|
{ hEquation r; r.v = (v << 16) | (uint32_t)i; return r; }
|
||||||
|
|
||||||
inline bool hEquation::isFromConstraint(void)
|
inline bool hEquation::isFromConstraint()
|
||||||
{ if(v & 0xc0000000) return false; else return true; }
|
{ if(v & 0xc0000000) return false; else return true; }
|
||||||
inline hConstraint hEquation::constraint(void)
|
inline hConstraint hEquation::constraint()
|
||||||
{ hConstraint r; r.v = (v >> 16); return r; }
|
{ hConstraint r; r.v = (v >> 16); return r; }
|
||||||
|
|
||||||
// The format for entities stored on the clipboard.
|
// The format for entities stored on the clipboard.
|
||||||
|
@ -146,7 +146,7 @@ bool SolveSpaceUI::OpenFile(const std::string &filename) {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::Exit(void) {
|
void SolveSpaceUI::Exit() {
|
||||||
if(!OkayToStartNewFile())
|
if(!OkayToStartNewFile())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -242,20 +242,20 @@ void SolveSpaceUI::ScheduleShowTW() {
|
|||||||
later.showTW = true;
|
later.showTW = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::DoLater(void) {
|
void SolveSpaceUI::DoLater() {
|
||||||
if(later.generateAll) GenerateAll();
|
if(later.generateAll) GenerateAll();
|
||||||
if(later.showTW) TW.Show();
|
if(later.showTW) TW.Show();
|
||||||
later = {};
|
later = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
double SolveSpaceUI::MmPerUnit(void) {
|
double SolveSpaceUI::MmPerUnit() {
|
||||||
if(viewUnits == UNIT_INCHES) {
|
if(viewUnits == UNIT_INCHES) {
|
||||||
return 25.4;
|
return 25.4;
|
||||||
} else {
|
} else {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const char *SolveSpaceUI::UnitName(void) {
|
const char *SolveSpaceUI::UnitName() {
|
||||||
if(viewUnits == UNIT_INCHES) {
|
if(viewUnits == UNIT_INCHES) {
|
||||||
return "inch";
|
return "inch";
|
||||||
} else {
|
} else {
|
||||||
@ -275,18 +275,18 @@ double SolveSpaceUI::ExprToMm(Expr *e) {
|
|||||||
double SolveSpaceUI::StringToMm(const std::string &str) {
|
double SolveSpaceUI::StringToMm(const std::string &str) {
|
||||||
return std::stod(str) * MmPerUnit();
|
return std::stod(str) * MmPerUnit();
|
||||||
}
|
}
|
||||||
double SolveSpaceUI::ChordTolMm(void) {
|
double SolveSpaceUI::ChordTolMm() {
|
||||||
if(exportMode) return ExportChordTolMm();
|
if(exportMode) return ExportChordTolMm();
|
||||||
return chordTolCalculated;
|
return chordTolCalculated;
|
||||||
}
|
}
|
||||||
double SolveSpaceUI::ExportChordTolMm(void) {
|
double SolveSpaceUI::ExportChordTolMm() {
|
||||||
return exportChordTol / exportScale;
|
return exportChordTol / exportScale;
|
||||||
}
|
}
|
||||||
int SolveSpaceUI::GetMaxSegments(void) {
|
int SolveSpaceUI::GetMaxSegments() {
|
||||||
if(exportMode) return exportMaxSegments;
|
if(exportMode) return exportMaxSegments;
|
||||||
return maxSegments;
|
return maxSegments;
|
||||||
}
|
}
|
||||||
int SolveSpaceUI::UnitDigitsAfterDecimal(void) {
|
int SolveSpaceUI::UnitDigitsAfterDecimal() {
|
||||||
return (viewUnits == UNIT_INCHES) ? afterDecimalInch : afterDecimalMm;
|
return (viewUnits == UNIT_INCHES) ? afterDecimalInch : afterDecimalMm;
|
||||||
}
|
}
|
||||||
void SolveSpaceUI::SetUnitDigitsAfterDecimal(int v) {
|
void SolveSpaceUI::SetUnitDigitsAfterDecimal(int v) {
|
||||||
@ -297,7 +297,7 @@ void SolveSpaceUI::SetUnitDigitsAfterDecimal(int v) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double SolveSpaceUI::CameraTangent(void) {
|
double SolveSpaceUI::CameraTangent() {
|
||||||
if(!usePerspectiveProj) {
|
if(!usePerspectiveProj) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@ -305,7 +305,7 @@ double SolveSpaceUI::CameraTangent(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::AfterNewFile(void) {
|
void SolveSpaceUI::AfterNewFile() {
|
||||||
// Clear out the traced point, which is no longer valid
|
// Clear out the traced point, which is no longer valid
|
||||||
traced.point = Entity::NO_ENTITY;
|
traced.point = Entity::NO_ENTITY;
|
||||||
traced.path.l.Clear();
|
traced.path.l.Clear();
|
||||||
@ -413,7 +413,7 @@ void SolveSpaceUI::RemoveAutosave()
|
|||||||
ssremove(autosaveFile);
|
ssremove(autosaveFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SolveSpaceUI::OkayToStartNewFile(void) {
|
bool SolveSpaceUI::OkayToStartNewFile() {
|
||||||
if(!unsaved) return true;
|
if(!unsaved) return true;
|
||||||
|
|
||||||
switch(SaveFileYesNoCancel()) {
|
switch(SaveFileYesNoCancel()) {
|
||||||
@ -430,7 +430,7 @@ bool SolveSpaceUI::OkayToStartNewFile(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::UpdateWindowTitle(void) {
|
void SolveSpaceUI::UpdateWindowTitle() {
|
||||||
SetCurrentFilename(saveFile);
|
SetCurrentFilename(saveFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,7 +827,7 @@ void SolveSpaceUI::MenuHelp(int id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::Clear(void) {
|
void SolveSpaceUI::Clear() {
|
||||||
sys.Clear();
|
sys.Clear();
|
||||||
for(int i = 0; i < MAX_UNDO; i++) {
|
for(int i = 0; i < MAX_UNDO; i++) {
|
||||||
if(i < undo.cnt) undo.d[i].Clear();
|
if(i < undo.cnt) undo.d[i].Clear();
|
||||||
@ -835,7 +835,7 @@ void SolveSpaceUI::Clear(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sketch::Clear(void) {
|
void Sketch::Clear() {
|
||||||
group.Clear();
|
group.Clear();
|
||||||
groupOrder.Clear();
|
groupOrder.Clear();
|
||||||
constraint.Clear();
|
constraint.Clear();
|
||||||
|
122
src/solvespace.h
122
src/solvespace.h
@ -157,11 +157,11 @@ void ssremove(const std::string &filename);
|
|||||||
#define RECENT_OPEN (0xf000)
|
#define RECENT_OPEN (0xf000)
|
||||||
#define RECENT_LINK (0xf100)
|
#define RECENT_LINK (0xf100)
|
||||||
extern std::string RecentFile[MAX_RECENT];
|
extern std::string RecentFile[MAX_RECENT];
|
||||||
void RefreshRecentMenus(void);
|
void RefreshRecentMenus();
|
||||||
|
|
||||||
enum DialogChoice { DIALOG_YES = 1, DIALOG_NO = -1, DIALOG_CANCEL = 0 };
|
enum DialogChoice { DIALOG_YES = 1, DIALOG_NO = -1, DIALOG_CANCEL = 0 };
|
||||||
DialogChoice SaveFileYesNoCancel(void);
|
DialogChoice SaveFileYesNoCancel();
|
||||||
DialogChoice LoadAutosaveYesNo(void);
|
DialogChoice LoadAutosaveYesNo();
|
||||||
DialogChoice LocateImportedFileYesNoCancel(const std::string &filename,
|
DialogChoice LocateImportedFileYesNoCancel(const std::string &filename,
|
||||||
bool canCancel);
|
bool canCancel);
|
||||||
|
|
||||||
@ -237,30 +237,30 @@ void EnableMenuById(int id, bool enabled);
|
|||||||
|
|
||||||
void ShowGraphicsEditControl(int x, int y, int fontHeight, int minWidthChars,
|
void ShowGraphicsEditControl(int x, int y, int fontHeight, int minWidthChars,
|
||||||
const std::string &str);
|
const std::string &str);
|
||||||
void HideGraphicsEditControl(void);
|
void HideGraphicsEditControl();
|
||||||
bool GraphicsEditControlIsVisible(void);
|
bool GraphicsEditControlIsVisible();
|
||||||
void ShowTextEditControl(int x, int y, const std::string &str);
|
void ShowTextEditControl(int x, int y, const std::string &str);
|
||||||
void HideTextEditControl(void);
|
void HideTextEditControl();
|
||||||
bool TextEditControlIsVisible(void);
|
bool TextEditControlIsVisible();
|
||||||
void MoveTextScrollbarTo(int pos, int maxPos, int page);
|
void MoveTextScrollbarTo(int pos, int maxPos, int page);
|
||||||
|
|
||||||
#define CONTEXT_SUBMENU (-1)
|
#define CONTEXT_SUBMENU (-1)
|
||||||
#define CONTEXT_SEPARATOR (-2)
|
#define CONTEXT_SEPARATOR (-2)
|
||||||
void AddContextMenuItem(const char *legend, int id);
|
void AddContextMenuItem(const char *legend, int id);
|
||||||
void CreateContextSubmenu(void);
|
void CreateContextSubmenu();
|
||||||
int ShowContextMenu(void);
|
int ShowContextMenu();
|
||||||
|
|
||||||
void ToggleMenuBar(void);
|
void ToggleMenuBar();
|
||||||
bool MenuBarIsVisible(void);
|
bool MenuBarIsVisible();
|
||||||
void ShowTextWindow(bool visible);
|
void ShowTextWindow(bool visible);
|
||||||
void InvalidateText(void);
|
void InvalidateText();
|
||||||
void InvalidateGraphics(void);
|
void InvalidateGraphics();
|
||||||
void PaintGraphics(void);
|
void PaintGraphics();
|
||||||
void ToggleFullScreen(void);
|
void ToggleFullScreen();
|
||||||
bool FullScreenIsActive(void);
|
bool FullScreenIsActive();
|
||||||
void GetGraphicsWindowSize(int *w, int *h);
|
void GetGraphicsWindowSize(int *w, int *h);
|
||||||
void GetTextWindowSize(int *w, int *h);
|
void GetTextWindowSize(int *w, int *h);
|
||||||
int64_t GetMilliseconds(void);
|
int64_t GetMilliseconds();
|
||||||
|
|
||||||
void dbp(const char *str, ...);
|
void dbp(const char *str, ...);
|
||||||
#define DBPTRI(tri) \
|
#define DBPTRI(tri) \
|
||||||
@ -273,7 +273,7 @@ void DoMessageBox(const char *str, int rows, int cols, bool error);
|
|||||||
void SetTimerFor(int milliseconds);
|
void SetTimerFor(int milliseconds);
|
||||||
void SetAutosaveTimerFor(int minutes);
|
void SetAutosaveTimerFor(int minutes);
|
||||||
void ScheduleLater();
|
void ScheduleLater();
|
||||||
void ExitNow(void);
|
void ExitNow();
|
||||||
|
|
||||||
void CnfFreezeInt(uint32_t val, const std::string &name);
|
void CnfFreezeInt(uint32_t val, const std::string &name);
|
||||||
void CnfFreezeFloat(float val, const std::string &name);
|
void CnfFreezeFloat(float val, const std::string &name);
|
||||||
@ -284,11 +284,11 @@ float CnfThawFloat(float val, const std::string &name);
|
|||||||
|
|
||||||
void *AllocTemporary(size_t n);
|
void *AllocTemporary(size_t n);
|
||||||
void FreeTemporary(void *p);
|
void FreeTemporary(void *p);
|
||||||
void FreeAllTemporary(void);
|
void FreeAllTemporary();
|
||||||
void *MemAlloc(size_t n);
|
void *MemAlloc(size_t n);
|
||||||
void MemFree(void *p);
|
void MemFree(void *p);
|
||||||
void InitHeaps(void);
|
void InitHeaps();
|
||||||
void vl(void); // debug function to validate heaps
|
void vl(); // debug function to validate heaps
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ void ssglAxisAlignedLineLoop(double l, double r, double t, double b);
|
|||||||
#else
|
#else
|
||||||
# define SSGL_CALLBACK
|
# define SSGL_CALLBACK
|
||||||
#endif
|
#endif
|
||||||
extern "C" { typedef void SSGL_CALLBACK ssglCallbackFptr(void); }
|
extern "C" { typedef void SSGL_CALLBACK ssglCallbackFptr(); }
|
||||||
void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
||||||
void ssglFillPolygon(SPolygon *p);
|
void ssglFillPolygon(SPolygon *p);
|
||||||
void ssglFillMesh(bool useSpecColor, RgbaColor color,
|
void ssglFillMesh(bool useSpecColor, RgbaColor color,
|
||||||
@ -366,7 +366,7 @@ void ssglStippledLine(Vector a, Vector b, double width,
|
|||||||
void ssglStippledLine(Vector a, Vector b, double width,
|
void ssglStippledLine(Vector a, Vector b, double width,
|
||||||
const char *stipplePattern, double stippleScale, bool maybeFat);
|
const char *stipplePattern, double stippleScale, bool maybeFat);
|
||||||
void ssglFatLine(Vector a, Vector b, double width);
|
void ssglFatLine(Vector a, Vector b, double width);
|
||||||
void ssglUnlockColor(void);
|
void ssglUnlockColor();
|
||||||
void ssglColorRGB(RgbaColor rgb);
|
void ssglColorRGB(RgbaColor rgb);
|
||||||
void ssglColorRGBa(RgbaColor rgb, double a);
|
void ssglColorRGBa(RgbaColor rgb, double a);
|
||||||
void ssglDepthRangeOffset(int units);
|
void ssglDepthRangeOffset(int units);
|
||||||
@ -449,18 +449,18 @@ public:
|
|||||||
} mat;
|
} mat;
|
||||||
|
|
||||||
static const double RANK_MAG_TOLERANCE, CONVERGE_TOLERANCE;
|
static const double RANK_MAG_TOLERANCE, CONVERGE_TOLERANCE;
|
||||||
int CalculateRank(void);
|
int CalculateRank();
|
||||||
bool TestRank(void);
|
bool TestRank();
|
||||||
static bool SolveLinearSystem(double X[], double A[][MAX_UNKNOWNS],
|
static bool SolveLinearSystem(double X[], double A[][MAX_UNKNOWNS],
|
||||||
double B[], int N);
|
double B[], int N);
|
||||||
bool SolveLeastSquares(void);
|
bool SolveLeastSquares();
|
||||||
|
|
||||||
bool WriteJacobian(int tag);
|
bool WriteJacobian(int tag);
|
||||||
void EvalJacobian(void);
|
void EvalJacobian();
|
||||||
|
|
||||||
void WriteEquationsExceptFor(hConstraint hc, Group *g);
|
void WriteEquationsExceptFor(hConstraint hc, Group *g);
|
||||||
void FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad);
|
void FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad);
|
||||||
void SolveBySubstitution(void);
|
void SolveBySubstitution();
|
||||||
|
|
||||||
bool IsDragged(hParam p);
|
bool IsDragged(hParam p);
|
||||||
|
|
||||||
@ -476,7 +476,7 @@ public:
|
|||||||
int Solve(Group *g, int *dof, List<hConstraint> *bad,
|
int Solve(Group *g, int *dof, List<hConstraint> *bad,
|
||||||
bool andFindBad, bool andFindFree);
|
bool andFindBad, bool andFindFree);
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "ttf.h"
|
#include "ttf.h"
|
||||||
@ -484,13 +484,13 @@ public:
|
|||||||
class StepFileWriter {
|
class StepFileWriter {
|
||||||
public:
|
public:
|
||||||
void ExportSurfacesTo(const std::string &filename);
|
void ExportSurfacesTo(const std::string &filename);
|
||||||
void WriteHeader(void);
|
void WriteHeader();
|
||||||
void WriteProductHeader(void);
|
void WriteProductHeader();
|
||||||
int ExportCurve(SBezier *sb);
|
int ExportCurve(SBezier *sb);
|
||||||
int ExportCurveLoop(SBezierLoop *loop, bool inner);
|
int ExportCurveLoop(SBezierLoop *loop, bool inner);
|
||||||
void ExportSurface(SSurface *ss, SBezierList *sbl);
|
void ExportSurface(SSurface *ss, SBezierList *sbl);
|
||||||
void WriteWireframe(void);
|
void WriteWireframe();
|
||||||
void WriteFooter(void);
|
void WriteFooter();
|
||||||
|
|
||||||
List<int> curves;
|
List<int> curves;
|
||||||
List<int> advancedFaces;
|
List<int> advancedFaces;
|
||||||
@ -678,7 +678,7 @@ public:
|
|||||||
inline Group *GetGroup (hGroup h) { return group. FindById(h); }
|
inline Group *GetGroup (hGroup h) { return group. FindById(h); }
|
||||||
// Styles are handled a bit differently.
|
// Styles are handled a bit differently.
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
|
|
||||||
BBox CalculateEntityBBox(bool includingInvisible);
|
BBox CalculateEntityBBox(bool includingInvisible);
|
||||||
Group *GetRunningMeshGroupFor(hGroup h);
|
Group *GetRunningMeshGroupFor(hGroup h);
|
||||||
@ -702,7 +702,7 @@ public:
|
|||||||
IdList<Style,hStyle> style;
|
IdList<Style,hStyle> style;
|
||||||
hGroup activeGroup;
|
hGroup activeGroup;
|
||||||
|
|
||||||
void Clear(void) {
|
void Clear() {
|
||||||
group.Clear();
|
group.Clear();
|
||||||
request.Clear();
|
request.Clear();
|
||||||
constraint.Clear();
|
constraint.Clear();
|
||||||
@ -718,10 +718,10 @@ public:
|
|||||||
} UndoStack;
|
} UndoStack;
|
||||||
UndoStack undo;
|
UndoStack undo;
|
||||||
UndoStack redo;
|
UndoStack redo;
|
||||||
void UndoEnableMenus(void);
|
void UndoEnableMenus();
|
||||||
void UndoRemember(void);
|
void UndoRemember();
|
||||||
void UndoUndo(void);
|
void UndoUndo();
|
||||||
void UndoRedo(void);
|
void UndoRedo();
|
||||||
void PushFromCurrentOnto(UndoStack *uk);
|
void PushFromCurrentOnto(UndoStack *uk);
|
||||||
void PopOntoCurrentFrom(UndoStack *uk);
|
void PopOntoCurrentFrom(UndoStack *uk);
|
||||||
void UndoClearState(UndoState *ut);
|
void UndoClearState(UndoState *ut);
|
||||||
@ -782,15 +782,15 @@ public:
|
|||||||
std::string MmToString(double v);
|
std::string MmToString(double v);
|
||||||
double ExprToMm(Expr *e);
|
double ExprToMm(Expr *e);
|
||||||
double StringToMm(const std::string &s);
|
double StringToMm(const std::string &s);
|
||||||
const char *UnitName(void);
|
const char *UnitName();
|
||||||
double MmPerUnit(void);
|
double MmPerUnit();
|
||||||
int UnitDigitsAfterDecimal(void);
|
int UnitDigitsAfterDecimal();
|
||||||
void SetUnitDigitsAfterDecimal(int v);
|
void SetUnitDigitsAfterDecimal(int v);
|
||||||
double ChordTolMm(void);
|
double ChordTolMm();
|
||||||
double ExportChordTolMm(void);
|
double ExportChordTolMm();
|
||||||
int GetMaxSegments(void);
|
int GetMaxSegments();
|
||||||
bool usePerspectiveProj;
|
bool usePerspectiveProj;
|
||||||
double CameraTangent(void);
|
double CameraTangent();
|
||||||
|
|
||||||
// Some stuff relating to the tangent arcs created non-parametrically
|
// Some stuff relating to the tangent arcs created non-parametrically
|
||||||
// as special requests.
|
// as special requests.
|
||||||
@ -799,14 +799,14 @@ public:
|
|||||||
bool tangentArcDeleteOld;
|
bool tangentArcDeleteOld;
|
||||||
|
|
||||||
// The platform-dependent code calls this before entering the msg loop
|
// The platform-dependent code calls this before entering the msg loop
|
||||||
void Init(void);
|
void Init();
|
||||||
bool OpenFile(const std::string &filename);
|
bool OpenFile(const std::string &filename);
|
||||||
void Exit(void);
|
void Exit();
|
||||||
|
|
||||||
// File load/save routines, including the additional files that get
|
// File load/save routines, including the additional files that get
|
||||||
// loaded when we have link groups.
|
// loaded when we have link groups.
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
void AfterNewFile(void);
|
void AfterNewFile();
|
||||||
static void RemoveFromRecentList(const std::string &filename);
|
static void RemoveFromRecentList(const std::string &filename);
|
||||||
static void AddToRecentList(const std::string &filename);
|
static void AddToRecentList(const std::string &filename);
|
||||||
std::string saveFile;
|
std::string saveFile;
|
||||||
@ -833,11 +833,11 @@ public:
|
|||||||
bool Autosave();
|
bool Autosave();
|
||||||
void RemoveAutosave();
|
void RemoveAutosave();
|
||||||
bool GetFilenameAndSave(bool saveAs);
|
bool GetFilenameAndSave(bool saveAs);
|
||||||
bool OkayToStartNewFile(void);
|
bool OkayToStartNewFile();
|
||||||
hGroup CreateDefaultDrawingGroup(void);
|
hGroup CreateDefaultDrawingGroup();
|
||||||
void UpdateWindowTitle(void);
|
void UpdateWindowTitle();
|
||||||
void ClearExisting(void);
|
void ClearExisting();
|
||||||
void NewFile(void);
|
void NewFile();
|
||||||
bool SaveToFile(const std::string &filename);
|
bool SaveToFile(const std::string &filename);
|
||||||
bool LoadAutosaveFor(const std::string &filename);
|
bool LoadAutosaveFor(const std::string &filename);
|
||||||
bool LoadFromFile(const std::string &filename);
|
bool LoadFromFile(const std::string &filename);
|
||||||
@ -890,7 +890,7 @@ public:
|
|||||||
List<ClipboardRequest> r;
|
List<ClipboardRequest> r;
|
||||||
List<Constraint> c;
|
List<Constraint> c;
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
bool ContainsEntity(hEntity old);
|
bool ContainsEntity(hEntity old);
|
||||||
hEntity NewEntityFor(hEntity old);
|
hEntity NewEntityFor(hEntity old);
|
||||||
};
|
};
|
||||||
@ -908,7 +908,7 @@ public:
|
|||||||
int nonTrivialConstraints;
|
int nonTrivialConstraints;
|
||||||
} deleted;
|
} deleted;
|
||||||
bool GroupExists(hGroup hg);
|
bool GroupExists(hGroup hg);
|
||||||
bool PruneOrphans(void);
|
bool PruneOrphans();
|
||||||
bool EntityExists(hEntity he);
|
bool EntityExists(hEntity he);
|
||||||
bool GroupsInOrder(hGroup before, hGroup after);
|
bool GroupsInOrder(hGroup before, hGroup after);
|
||||||
bool PruneGroups(hGroup hg);
|
bool PruneGroups(hGroup hg);
|
||||||
@ -925,10 +925,10 @@ public:
|
|||||||
void GenerateAll(GenerateType type = GENERATE_DIRTY, bool andFindFree = false,
|
void GenerateAll(GenerateType type = GENERATE_DIRTY, bool andFindFree = false,
|
||||||
bool genForBBox = false);
|
bool genForBBox = false);
|
||||||
void SolveGroup(hGroup hg, bool andFindFree);
|
void SolveGroup(hGroup hg, bool andFindFree);
|
||||||
void MarkDraggedParams(void);
|
void MarkDraggedParams();
|
||||||
void ForceReferences(void);
|
void ForceReferences();
|
||||||
|
|
||||||
bool ActiveGroupsOkay(void);
|
bool ActiveGroupsOkay();
|
||||||
|
|
||||||
// The system to be solved.
|
// The system to be solved.
|
||||||
System *pSys;
|
System *pSys;
|
||||||
@ -949,11 +949,11 @@ public:
|
|||||||
} later;
|
} later;
|
||||||
void ScheduleShowTW();
|
void ScheduleShowTW();
|
||||||
void ScheduleGenerateAll();
|
void ScheduleGenerateAll();
|
||||||
void DoLater(void);
|
void DoLater();
|
||||||
|
|
||||||
static void MenuHelp(int id);
|
static void MenuHelp(int id);
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
|
|
||||||
// We allocate TW and sys on the heap to work around an MSVC problem
|
// We allocate TW and sys on the heap to work around an MSVC problem
|
||||||
// where it puts zero-initialized global data in the binary (~30M of zeroes)
|
// where it puts zero-initialized global data in the binary (~30M of zeroes)
|
||||||
|
@ -627,7 +627,7 @@ void SShell::MakeIntersectionCurvesAgainst(SShell *agnst, SShell *into) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SShell::CleanupAfterBoolean(void) {
|
void SShell::CleanupAfterBoolean() {
|
||||||
SSurface *ss;
|
SSurface *ss;
|
||||||
for(ss = surface.First(); ss; ss = surface.NextAfter(ss)) {
|
for(ss = surface.First(); ss; ss = surface.NextAfter(ss)) {
|
||||||
ss->edges.Clear();
|
ss->edges.Clear();
|
||||||
@ -769,7 +769,7 @@ void SSurface::MakeClassifyingBsp(SShell *shell, SShell *useCurvesFrom) {
|
|||||||
MakeEdgesInto(shell, &edges, AS_XYZ, useCurvesFrom);
|
MakeEdgesInto(shell, &edges, AS_XYZ, useCurvesFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
SBspUv *SBspUv::Alloc(void) {
|
SBspUv *SBspUv::Alloc() {
|
||||||
return (SBspUv *)AllocTemporary(sizeof(SBspUv));
|
return (SBspUv *)AllocTemporary(sizeof(SBspUv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,15 +60,15 @@ SBezier SBezier::From(Vector p0, Vector p1, Vector p2, Vector p3) {
|
|||||||
p3.Project4d());
|
p3.Project4d());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector SBezier::Start(void) {
|
Vector SBezier::Start() {
|
||||||
return ctrl[0];
|
return ctrl[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector SBezier::Finish(void) {
|
Vector SBezier::Finish() {
|
||||||
return ctrl[deg];
|
return ctrl[deg];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBezier::Reverse(void) {
|
void SBezier::Reverse() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < (deg+1)/2; i++) {
|
for(i = 0; i < (deg+1)/2; i++) {
|
||||||
swap(ctrl[i], ctrl[deg-i]);
|
swap(ctrl[i], ctrl[deg-i]);
|
||||||
@ -170,7 +170,7 @@ bool SBezier::IsCircle(Vector axis, Vector *center, double *r) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SBezier::IsRational(void) {
|
bool SBezier::IsRational() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i <= deg; i++) {
|
for(i = 0; i <= deg; i++) {
|
||||||
if(fabs(weight[i] - 1) > LENGTH_EPS) return true;
|
if(fabs(weight[i] - 1) > LENGTH_EPS) return true;
|
||||||
@ -218,7 +218,7 @@ bool SBezier::Equals(SBezier *b) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBezierList::Clear(void) {
|
void SBezierList::Clear() {
|
||||||
l.Clear();
|
l.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ void SBezierList::ScaleSelfBy(double s) {
|
|||||||
// If our list contains multiple identical Beziers (in either forward or
|
// If our list contains multiple identical Beziers (in either forward or
|
||||||
// reverse order), then cull them.
|
// reverse order), then cull them.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SBezierList::CullIdenticalBeziers(void) {
|
void SBezierList::CullIdenticalBeziers() {
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
l.ClearTags();
|
l.ClearTags();
|
||||||
@ -443,7 +443,7 @@ SBezierLoop SBezierLoop::FromCurves(SBezierList *sbl,
|
|||||||
return loop;
|
return loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBezierLoop::Reverse(void) {
|
void SBezierLoop::Reverse() {
|
||||||
l.Reverse();
|
l.Reverse();
|
||||||
SBezier *sb;
|
SBezier *sb;
|
||||||
for(sb = l.First(); sb; sb = l.NextAfter(sb)) {
|
for(sb = l.First(); sb; sb = l.NextAfter(sb)) {
|
||||||
@ -478,7 +478,7 @@ void SBezierLoop::MakePwlInto(SContour *sc, double chordTol) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SBezierLoop::IsClosed(void) {
|
bool SBezierLoop::IsClosed() {
|
||||||
if(l.n < 1) return false;
|
if(l.n < 1) return false;
|
||||||
Vector s = l.elem[0].Start(),
|
Vector s = l.elem[0].Start(),
|
||||||
f = l.elem[l.n-1].Finish();
|
f = l.elem[l.n-1].Finish();
|
||||||
@ -553,7 +553,7 @@ void SBezierLoopSet::MakePwlInto(SPolygon *sp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBezierLoopSet::Clear(void) {
|
void SBezierLoopSet::Clear() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < l.n; i++) {
|
for(i = 0; i < l.n; i++) {
|
||||||
(l.elem[i]).Clear();
|
(l.elem[i]).Clear();
|
||||||
@ -724,7 +724,7 @@ void SBezierLoopSetSet::AddOpenPath(SBezier *sb) {
|
|||||||
l.Add(&sbls);
|
l.Add(&sbls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBezierLoopSetSet::Clear(void) {
|
void SBezierLoopSetSet::Clear() {
|
||||||
SBezierLoopSet *sbls;
|
SBezierLoopSet *sbls;
|
||||||
for(sbls = l.First(); sbls; sbls = l.NextAfter(sbls)) {
|
for(sbls = l.First(); sbls; sbls = l.NextAfter(sbls)) {
|
||||||
sbls->Clear();
|
sbls->Clear();
|
||||||
@ -753,7 +753,7 @@ SCurve SCurve::FromTransformationOf(SCurve *a,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCurve::Clear(void) {
|
void SCurve::Clear() {
|
||||||
pts.Clear();
|
pts.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "../solvespace.h"
|
#include "../solvespace.h"
|
||||||
|
|
||||||
void SShell::MergeCoincidentSurfaces(void) {
|
void SShell::MergeCoincidentSurfaces() {
|
||||||
surface.ClearTags();
|
surface.ClearTags();
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -16,7 +16,7 @@ const double SShell::DOTP_TOL = 1e-5;
|
|||||||
extern int FLAG;
|
extern int FLAG;
|
||||||
|
|
||||||
|
|
||||||
double SSurface::DepartureFromCoplanar(void) {
|
double SSurface::DepartureFromCoplanar() {
|
||||||
int i, j;
|
int i, j;
|
||||||
int ia, ja, ib = 0, jb = 0, ic = 0, jc = 0;
|
int ia, ja, ib = 0, jb = 0, ic = 0, jc = 0;
|
||||||
double best;
|
double best;
|
||||||
@ -73,7 +73,7 @@ double SSurface::DepartureFromCoplanar(void) {
|
|||||||
return farthest;
|
return farthest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSurface::WeightControlPoints(void) {
|
void SSurface::WeightControlPoints() {
|
||||||
int i, j;
|
int i, j;
|
||||||
for(i = 0; i <= degm; i++) {
|
for(i = 0; i <= degm; i++) {
|
||||||
for(j = 0; j <= degn; j++) {
|
for(j = 0; j <= degn; j++) {
|
||||||
@ -81,7 +81,7 @@ void SSurface::WeightControlPoints(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SSurface::UnWeightControlPoints(void) {
|
void SSurface::UnWeightControlPoints() {
|
||||||
int i, j;
|
int i, j;
|
||||||
for(i = 0; i <= degm; i++) {
|
for(i = 0; i <= degm; i++) {
|
||||||
for(j = 0; j <= degn; j++) {
|
for(j = 0; j <= degn; j++) {
|
||||||
|
@ -449,7 +449,7 @@ void SSurface::TriangulateInto(SShell *shell, SMesh *sm) {
|
|||||||
// normal. We therefore must reverse all our trim curves too. The uv
|
// normal. We therefore must reverse all our trim curves too. The uv
|
||||||
// coordinates change, but trim curves are stored as xyz so nothing happens
|
// coordinates change, but trim curves are stored as xyz so nothing happens
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SSurface::Reverse(void) {
|
void SSurface::Reverse() {
|
||||||
int i, j;
|
int i, j;
|
||||||
for(i = 0; i < (degm+1)/2; i++) {
|
for(i = 0; i < (degm+1)/2; i++) {
|
||||||
for(j = 0; j <= degn; j++) {
|
for(j = 0; j <= degn; j++) {
|
||||||
@ -474,7 +474,7 @@ void SSurface::ScaleSelfBy(double s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSurface::Clear(void) {
|
void SSurface::Clear() {
|
||||||
trim.Clear();
|
trim.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,11 +860,11 @@ void SShell::TriangulateInto(SMesh *sm) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SShell::IsEmpty(void) {
|
bool SShell::IsEmpty() {
|
||||||
return (surface.n == 0);
|
return (surface.n == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SShell::Clear(void) {
|
void SShell::Clear() {
|
||||||
SSurface *s;
|
SSurface *s;
|
||||||
for(s = surface.First(); s; s = surface.NextAfter(s)) {
|
for(s = surface.First(); s; s = surface.NextAfter(s)) {
|
||||||
s->Clear();
|
s->Clear();
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
EDGE_OTHER = 500
|
EDGE_OTHER = 500
|
||||||
};
|
};
|
||||||
|
|
||||||
static SBspUv *Alloc(void);
|
static SBspUv *Alloc();
|
||||||
static SBspUv *From(SEdgeList *el, SSurface *srf);
|
static SBspUv *From(SEdgeList *el, SSurface *srf);
|
||||||
|
|
||||||
void ScalePoints(Point2d *pt, Point2d *a, Point2d *b, SSurface *srf);
|
void ScalePoints(Point2d *pt, Point2d *a, Point2d *b, SSurface *srf);
|
||||||
@ -86,8 +86,8 @@ public:
|
|||||||
void SplitAt(double t, SBezier *bef, SBezier *aft);
|
void SplitAt(double t, SBezier *bef, SBezier *aft);
|
||||||
bool PointOnThisAndCurve(SBezier *sbb, Vector *p);
|
bool PointOnThisAndCurve(SBezier *sbb, Vector *p);
|
||||||
|
|
||||||
Vector Start(void);
|
Vector Start();
|
||||||
Vector Finish(void);
|
Vector Finish();
|
||||||
bool Equals(SBezier *b);
|
bool Equals(SBezier *b);
|
||||||
void MakePwlInto(SEdgeList *sel, double chordTol=0);
|
void MakePwlInto(SEdgeList *sel, double chordTol=0);
|
||||||
void MakePwlInto(List<SCurvePt> *l, double chordTol=0);
|
void MakePwlInto(List<SCurvePt> *l, double chordTol=0);
|
||||||
@ -98,11 +98,11 @@ public:
|
|||||||
|
|
||||||
void AllIntersectionsWith(SBezier *sbb, SPointList *spl);
|
void AllIntersectionsWith(SBezier *sbb, SPointList *spl);
|
||||||
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax);
|
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax);
|
||||||
void Reverse(void);
|
void Reverse();
|
||||||
|
|
||||||
bool IsInPlane(Vector n, double d);
|
bool IsInPlane(Vector n, double d);
|
||||||
bool IsCircle(Vector axis, Vector *center, double *r);
|
bool IsCircle(Vector axis, Vector *center, double *r);
|
||||||
bool IsRational(void);
|
bool IsRational();
|
||||||
|
|
||||||
SBezier TransformedBy(Vector t, Quaternion q, double scale);
|
SBezier TransformedBy(Vector t, Quaternion q, double scale);
|
||||||
SBezier InPerspective(Vector u, Vector v, Vector n,
|
SBezier InPerspective(Vector u, Vector v, Vector n,
|
||||||
@ -121,9 +121,9 @@ class SBezierList {
|
|||||||
public:
|
public:
|
||||||
List<SBezier> l;
|
List<SBezier> l;
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
void ScaleSelfBy(double s);
|
void ScaleSelfBy(double s);
|
||||||
void CullIdenticalBeziers(void);
|
void CullIdenticalBeziers();
|
||||||
void AllIntersectionsWith(SBezierList *sblb, SPointList *spl);
|
void AllIntersectionsWith(SBezierList *sblb, SPointList *spl);
|
||||||
bool GetPlaneContainingBeziers(Vector *p, Vector *u, Vector *v,
|
bool GetPlaneContainingBeziers(Vector *p, Vector *u, Vector *v,
|
||||||
Vector *notCoplanarAt);
|
Vector *notCoplanarAt);
|
||||||
@ -134,9 +134,9 @@ public:
|
|||||||
int tag;
|
int tag;
|
||||||
List<SBezier> l;
|
List<SBezier> l;
|
||||||
|
|
||||||
inline void Clear(void) { l.Clear(); }
|
inline void Clear() { l.Clear(); }
|
||||||
bool IsClosed(void);
|
bool IsClosed();
|
||||||
void Reverse(void);
|
void Reverse();
|
||||||
void MakePwlInto(SContour *sc, double chordTol=0);
|
void MakePwlInto(SContour *sc, double chordTol=0);
|
||||||
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax);
|
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax);
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ public:
|
|||||||
|
|
||||||
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax);
|
void GetBoundingProjd(Vector u, Vector orig, double *umin, double *umax);
|
||||||
void MakePwlInto(SPolygon *sp);
|
void MakePwlInto(SPolygon *sp);
|
||||||
void Clear(void);
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SBezierLoopSetSet {
|
class SBezierLoopSetSet {
|
||||||
@ -170,7 +170,7 @@ public:
|
|||||||
bool *allCoplanar, Vector *notCoplanarAt,
|
bool *allCoplanar, Vector *notCoplanarAt,
|
||||||
SBezierList *openContours);
|
SBezierList *openContours);
|
||||||
void AddOpenPath(SBezier *sb);
|
void AddOpenPath(SBezier *sb);
|
||||||
void Clear(void);
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Stuff for the surface trim curves: piecewise linear
|
// Stuff for the surface trim curves: piecewise linear
|
||||||
@ -212,7 +212,7 @@ public:
|
|||||||
SSurface *GetSurfaceA(SShell *a, SShell *b);
|
SSurface *GetSurfaceA(SShell *a, SShell *b);
|
||||||
SSurface *GetSurfaceB(SShell *a, SShell *b);
|
SSurface *GetSurfaceB(SShell *a, SShell *b);
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
// A segment of a curve by which a surface is trimmed: indicates which curve,
|
// A segment of a curve by which a surface is trimmed: indicates which curve,
|
||||||
@ -297,12 +297,12 @@ public:
|
|||||||
int tag;
|
int tag;
|
||||||
Point2d p;
|
Point2d p;
|
||||||
} Inter;
|
} Inter;
|
||||||
void WeightControlPoints(void);
|
void WeightControlPoints();
|
||||||
void UnWeightControlPoints(void);
|
void UnWeightControlPoints();
|
||||||
void CopyRowOrCol(bool row, int this_ij, SSurface *src, int src_ij);
|
void CopyRowOrCol(bool row, int this_ij, SSurface *src, int src_ij);
|
||||||
void BlendRowOrCol(bool row, int this_ij, SSurface *a, int a_ij,
|
void BlendRowOrCol(bool row, int this_ij, SSurface *a, int a_ij,
|
||||||
SSurface *b, int b_ij);
|
SSurface *b, int b_ij);
|
||||||
double DepartureFromCoplanar(void);
|
double DepartureFromCoplanar();
|
||||||
void SplitInHalf(bool byU, SSurface *sa, SSurface *sb);
|
void SplitInHalf(bool byU, SSurface *sa, SSurface *sb);
|
||||||
void AllPointsIntersecting(Vector a, Vector b,
|
void AllPointsIntersecting(Vector a, Vector b,
|
||||||
List<SInter> *l,
|
List<SInter> *l,
|
||||||
@ -352,8 +352,8 @@ public:
|
|||||||
bool swapped);
|
bool swapped);
|
||||||
Vector PointAtMaybeSwapped(double u, double v, bool swapped);
|
Vector PointAtMaybeSwapped(double u, double v, bool swapped);
|
||||||
|
|
||||||
void Reverse(void);
|
void Reverse();
|
||||||
void Clear(void);
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SShell {
|
class SShell {
|
||||||
@ -386,7 +386,7 @@ public:
|
|||||||
void MakeCoincidentEdgesInto(SSurface *proto, bool sameNormal,
|
void MakeCoincidentEdgesInto(SSurface *proto, bool sameNormal,
|
||||||
SEdgeList *el, SShell *useCurvesFrom);
|
SEdgeList *el, SShell *useCurvesFrom);
|
||||||
void RewriteSurfaceHandlesForCurves(SShell *a, SShell *b);
|
void RewriteSurfaceHandlesForCurves(SShell *a, SShell *b);
|
||||||
void CleanupAfterBoolean(void);
|
void CleanupAfterBoolean();
|
||||||
|
|
||||||
// Definitions when classifying regions of a surface; it is either inside,
|
// Definitions when classifying regions of a surface; it is either inside,
|
||||||
// outside, or coincident (with parallel or antiparallel normal) with a
|
// outside, or coincident (with parallel or antiparallel normal) with a
|
||||||
@ -408,15 +408,15 @@ public:
|
|||||||
void MakeFromTransformationOf(SShell *a,
|
void MakeFromTransformationOf(SShell *a,
|
||||||
Vector trans, Quaternion q, double scale);
|
Vector trans, Quaternion q, double scale);
|
||||||
void MakeFromAssemblyOf(SShell *a, SShell *b);
|
void MakeFromAssemblyOf(SShell *a, SShell *b);
|
||||||
void MergeCoincidentSurfaces(void);
|
void MergeCoincidentSurfaces();
|
||||||
|
|
||||||
void TriangulateInto(SMesh *sm);
|
void TriangulateInto(SMesh *sm);
|
||||||
void MakeEdgesInto(SEdgeList *sel);
|
void MakeEdgesInto(SEdgeList *sel);
|
||||||
void MakeSectionEdgesInto(Vector n, double d,
|
void MakeSectionEdgesInto(Vector n, double d,
|
||||||
SEdgeList *sel, SBezierList *sbl);
|
SEdgeList *sel, SBezierList *sbl);
|
||||||
bool IsEmpty(void);
|
bool IsEmpty();
|
||||||
void RemapFaces(Group *g, int remap);
|
void RemapFaces(Group *g, int remap);
|
||||||
void Clear(void);
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,7 +51,7 @@ std::string Style::CnfPrefixToName(const std::string &prefix) {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::CreateAllDefaultStyles(void) {
|
void Style::CreateAllDefaultStyles() {
|
||||||
const Default *d;
|
const Default *d;
|
||||||
for(d = &(Defaults[0]); d->h.v; d++) {
|
for(d = &(Defaults[0]); d->h.v; d++) {
|
||||||
(void)Get(d->h);
|
(void)Get(d->h);
|
||||||
@ -102,7 +102,7 @@ void Style::FillDefaultStyle(Style *s, const Default *d) {
|
|||||||
s->zIndex = d->zIndex;
|
s->zIndex = d->zIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::LoadFactoryDefaults(void) {
|
void Style::LoadFactoryDefaults() {
|
||||||
const Default *d;
|
const Default *d;
|
||||||
for(d = &(Defaults[0]); d->h.v; d++) {
|
for(d = &(Defaults[0]); d->h.v; d++) {
|
||||||
Style *s = Get(d->h);
|
Style *s = Get(d->h);
|
||||||
@ -113,7 +113,7 @@ void Style::LoadFactoryDefaults(void) {
|
|||||||
SS.bgImage.fromFile = NULL;
|
SS.bgImage.fromFile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::FreezeDefaultStyles(void) {
|
void Style::FreezeDefaultStyles() {
|
||||||
const Default *d;
|
const Default *d;
|
||||||
for(d = &(Defaults[0]); d->h.v; d++) {
|
for(d = &(Defaults[0]); d->h.v; d++) {
|
||||||
CnfFreezeColor(Color(d->h), CnfColor(d->cnfPrefix));
|
CnfFreezeColor(Color(d->h), CnfColor(d->cnfPrefix));
|
||||||
@ -337,7 +337,7 @@ double Style::StippleScaleMm(hStyle hs) {
|
|||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Style::DescriptionString(void) {
|
std::string Style::DescriptionString() {
|
||||||
if(name.empty()) {
|
if(name.empty()) {
|
||||||
return ssprintf("s%03x-(unnamed)", h.v);
|
return ssprintf("s%03x-(unnamed)", h.v);
|
||||||
} else {
|
} else {
|
||||||
@ -447,7 +447,7 @@ void TextWindow::ScreenChangeBackgroundImageScale(int link, uint32_t v) {
|
|||||||
SS.TW.ShowEditControl(10, ssprintf("%.3f", SS.bgImage.scale * SS.MmPerUnit()));
|
SS.TW.ShowEditControl(10, ssprintf("%.3f", SS.bgImage.scale * SS.MmPerUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ShowListOfStyles(void) {
|
void TextWindow::ShowListOfStyles() {
|
||||||
Printf(true, "%Ft color style-name");
|
Printf(true, "%Ft color style-name");
|
||||||
|
|
||||||
bool darkbg = false;
|
bool darkbg = false;
|
||||||
@ -755,7 +755,7 @@ bool TextWindow::EditControlDoneForStyles(const char *str) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ShowStyleInfo(void) {
|
void TextWindow::ShowStyleInfo() {
|
||||||
Printf(true, "%Fl%f%Ll(back to list of styles)%E", &ScreenShowListOfStyles);
|
Printf(true, "%Fl%f%Ll(back to list of styles)%E", &ScreenShowListOfStyles);
|
||||||
|
|
||||||
Style *s = Style::Get(shown.style);
|
Style *s = Style::Get(shown.style);
|
||||||
|
@ -67,7 +67,7 @@ bool System::WriteJacobian(int tag) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::EvalJacobian(void) {
|
void System::EvalJacobian() {
|
||||||
int i, j;
|
int i, j;
|
||||||
for(i = 0; i < mat.m; i++) {
|
for(i = 0; i < mat.m; i++) {
|
||||||
for(j = 0; j < mat.n; j++) {
|
for(j = 0; j < mat.n; j++) {
|
||||||
@ -84,7 +84,7 @@ bool System::IsDragged(hParam p) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::SolveBySubstitution(void) {
|
void System::SolveBySubstitution() {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < eq.n; i++) {
|
for(i = 0; i < eq.n; i++) {
|
||||||
Equation *teq = &(eq.elem[i]);
|
Equation *teq = &(eq.elem[i]);
|
||||||
@ -135,7 +135,7 @@ void System::SolveBySubstitution(void) {
|
|||||||
// in place. A row (~equation) is considered to be all zeros if its magnitude
|
// in place. A row (~equation) is considered to be all zeros if its magnitude
|
||||||
// is less than the tolerance RANK_MAG_TOLERANCE.
|
// is less than the tolerance RANK_MAG_TOLERANCE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int System::CalculateRank(void) {
|
int System::CalculateRank() {
|
||||||
// Actually work with magnitudes squared, not the magnitudes
|
// Actually work with magnitudes squared, not the magnitudes
|
||||||
double rowMag[MAX_UNKNOWNS] = {};
|
double rowMag[MAX_UNKNOWNS] = {};
|
||||||
double tol = RANK_MAG_TOLERANCE*RANK_MAG_TOLERANCE;
|
double tol = RANK_MAG_TOLERANCE*RANK_MAG_TOLERANCE;
|
||||||
@ -172,7 +172,7 @@ int System::CalculateRank(void) {
|
|||||||
return rank;
|
return rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool System::TestRank(void) {
|
bool System::TestRank() {
|
||||||
EvalJacobian();
|
EvalJacobian();
|
||||||
return CalculateRank() == mat.m;
|
return CalculateRank() == mat.m;
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ bool System::SolveLinearSystem(double X[], double A[][MAX_UNKNOWNS],
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool System::SolveLeastSquares(void) {
|
bool System::SolveLeastSquares() {
|
||||||
int r, c, i;
|
int r, c, i;
|
||||||
|
|
||||||
// Scale the columns; this scale weights the parameters for the least
|
// Scale the columns; this scale weights the parameters for the least
|
||||||
@ -532,7 +532,7 @@ didnt_converge:
|
|||||||
return rankOk ? System::DIDNT_CONVERGE : System::REDUNDANT_DIDNT_CONVERGE;
|
return rankOk ? System::DIDNT_CONVERGE : System::REDUNDANT_DIDNT_CONVERGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::Clear(void) {
|
void System::Clear() {
|
||||||
entity.Clear();
|
entity.Clear();
|
||||||
param.Clear();
|
param.Clear();
|
||||||
eq.Clear();
|
eq.Clear();
|
||||||
|
@ -89,7 +89,7 @@ void TextWindow::ScreenShowEditView(int link, uint32_t v) {
|
|||||||
void TextWindow::ScreenGoToWebsite(int link, uint32_t v) {
|
void TextWindow::ScreenGoToWebsite(int link, uint32_t v) {
|
||||||
OpenWebsite("http://solvespace.com/txtlink");
|
OpenWebsite("http://solvespace.com/txtlink");
|
||||||
}
|
}
|
||||||
void TextWindow::ShowListOfGroups(void) {
|
void TextWindow::ShowListOfGroups() {
|
||||||
const char *radioTrue = " " RADIO_TRUE " ",
|
const char *radioTrue = " " RADIO_TRUE " ",
|
||||||
*radioFalse = " " RADIO_FALSE " ",
|
*radioFalse = " " RADIO_FALSE " ",
|
||||||
*checkTrue = " " CHECK_TRUE " ",
|
*checkTrue = " " CHECK_TRUE " ",
|
||||||
@ -275,7 +275,7 @@ void TextWindow::ScreenDeleteGroup(int link, uint32_t v) {
|
|||||||
// group if it was removed.
|
// group if it was removed.
|
||||||
SS.GW.ClearSuper();
|
SS.GW.ClearSuper();
|
||||||
}
|
}
|
||||||
void TextWindow::ShowGroupInfo(void) {
|
void TextWindow::ShowGroupInfo() {
|
||||||
Group *g = SK.GetGroup(shown.group);
|
Group *g = SK.GetGroup(shown.group);
|
||||||
const char *s = "???";
|
const char *s = "???";
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ void TextWindow::ScreenAllowRedundant(int link, uint32_t v) {
|
|||||||
SS.TW.shown.screen = SCREEN_GROUP_INFO;
|
SS.TW.shown.screen = SCREEN_GROUP_INFO;
|
||||||
SS.TW.Show();
|
SS.TW.Show();
|
||||||
}
|
}
|
||||||
void TextWindow::ShowGroupSolveInfo(void) {
|
void TextWindow::ShowGroupSolveInfo() {
|
||||||
Group *g = SK.GetGroup(shown.group);
|
Group *g = SK.GetGroup(shown.group);
|
||||||
if(g->IsSolvedOkay()) {
|
if(g->IsSolvedOkay()) {
|
||||||
// Go back to the default group info screen
|
// Go back to the default group info screen
|
||||||
@ -569,7 +569,7 @@ void TextWindow::ScreenStepDimGo(int link, uint32_t v) {
|
|||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
SS.TW.GoToScreen(SCREEN_LIST_OF_GROUPS);
|
SS.TW.GoToScreen(SCREEN_LIST_OF_GROUPS);
|
||||||
}
|
}
|
||||||
void TextWindow::ShowStepDimension(void) {
|
void TextWindow::ShowStepDimension() {
|
||||||
Constraint *c = SK.constraint.FindByIdNoOops(shown.constraint);
|
Constraint *c = SK.constraint.FindByIdNoOops(shown.constraint);
|
||||||
if(!c) {
|
if(!c) {
|
||||||
shown.screen = SCREEN_LIST_OF_GROUPS;
|
shown.screen = SCREEN_LIST_OF_GROUPS;
|
||||||
@ -613,7 +613,7 @@ void TextWindow::ScreenChangeTangentArc(int link, uint32_t v) {
|
|||||||
case 'd': SS.tangentArcDeleteOld = !SS.tangentArcDeleteOld; break;
|
case 'd': SS.tangentArcDeleteOld = !SS.tangentArcDeleteOld; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void TextWindow::ShowTangentArc(void) {
|
void TextWindow::ShowTangentArc() {
|
||||||
Printf(true, "%FtTANGENT ARC PARAMETERS%E");
|
Printf(true, "%FtTANGENT ARC PARAMETERS%E");
|
||||||
|
|
||||||
Printf(true, "%Ft radius of created arc%E");
|
Printf(true, "%Ft radius of created arc%E");
|
||||||
|
@ -55,11 +55,11 @@ void TextWindow::MakeColorTable(const Color *in, float *out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::Init(void) {
|
void TextWindow::Init() {
|
||||||
ClearSuper();
|
ClearSuper();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ClearSuper(void) {
|
void TextWindow::ClearSuper() {
|
||||||
HideEditControl();
|
HideEditControl();
|
||||||
|
|
||||||
// Cannot use *this = {} here because TextWindow instances
|
// Cannot use *this = {} here because TextWindow instances
|
||||||
@ -74,7 +74,7 @@ void TextWindow::ClearSuper(void) {
|
|||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::HideEditControl(void) {
|
void TextWindow::HideEditControl() {
|
||||||
editControl.colorPicker.show = false;
|
editControl.colorPicker.show = false;
|
||||||
HideTextEditControl();
|
HideTextEditControl();
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ void TextWindow::ShowEditControlWithColorPicker(int col, RgbaColor rgb)
|
|||||||
ShowEditControl(col, ssprintf("%.2f, %.2f, %.2f", rgb.redF(), rgb.greenF(), rgb.blueF()));
|
ShowEditControl(col, ssprintf("%.2f, %.2f, %.2f", rgb.redF(), rgb.greenF(), rgb.blueF()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ClearScreen(void) {
|
void TextWindow::ClearScreen() {
|
||||||
int i, j;
|
int i, j;
|
||||||
for(i = 0; i < MAX_ROWS; i++) {
|
for(i = 0; i < MAX_ROWS; i++) {
|
||||||
for(j = 0; j < MAX_COLS; j++) {
|
for(j = 0; j < MAX_COLS; j++) {
|
||||||
@ -282,7 +282,7 @@ done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define gs (SS.GW.gs)
|
#define gs (SS.GW.gs)
|
||||||
void TextWindow::Show(void) {
|
void TextWindow::Show() {
|
||||||
if(!(SS.GW.pending.operation)) SS.GW.ClearPending();
|
if(!(SS.GW.pending.operation)) SS.GW.ClearPending();
|
||||||
|
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
@ -338,7 +338,7 @@ void TextWindow::Show(void) {
|
|||||||
InvalidateText();
|
InvalidateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::TimerCallback(void)
|
void TextWindow::TimerCallback()
|
||||||
{
|
{
|
||||||
tooltippedIcon = hoveredIcon;
|
tooltippedIcon = hoveredIcon;
|
||||||
InvalidateText();
|
InvalidateText();
|
||||||
@ -506,7 +506,7 @@ Vector TextWindow::HsvToRgb(Vector hsv) {
|
|||||||
return rgb;
|
return rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *TextWindow::HsvPattern2d(void) {
|
uint8_t *TextWindow::HsvPattern2d() {
|
||||||
static uint8_t Texture[256*256*3];
|
static uint8_t Texture[256*256*3];
|
||||||
static bool Init;
|
static bool Init;
|
||||||
|
|
||||||
@ -546,7 +546,7 @@ uint8_t *TextWindow::HsvPattern1d(double h, double s) {
|
|||||||
return Texture;
|
return Texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ColorPickerDone(void) {
|
void TextWindow::ColorPickerDone() {
|
||||||
RgbaColor rgb = editControl.colorPicker.rgb;
|
RgbaColor rgb = editControl.colorPicker.rgb;
|
||||||
EditControlDone(ssprintf("%.2f, %.2f, %.3f", rgb.redF(), rgb.greenF(), rgb.blueF()).c_str());
|
EditControlDone(ssprintf("%.2f, %.2f, %.3f", rgb.redF(), rgb.greenF(), rgb.blueF()).c_str());
|
||||||
}
|
}
|
||||||
@ -795,7 +795,7 @@ bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::Paint(void) {
|
void TextWindow::Paint() {
|
||||||
int width, height;
|
int width, height;
|
||||||
GetTextWindowSize(&width, &height);
|
GetTextWindowSize(&width, &height);
|
||||||
|
|
||||||
@ -1028,7 +1028,7 @@ done:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::MouseLeave(void) {
|
void TextWindow::MouseLeave() {
|
||||||
tooltippedIcon = NULL;
|
tooltippedIcon = NULL;
|
||||||
hoveredIcon = NULL;
|
hoveredIcon = NULL;
|
||||||
hoveredRow = 0;
|
hoveredRow = 0;
|
||||||
|
@ -54,7 +54,7 @@ static struct {
|
|||||||
{ NULL, 0, 0, {} }
|
{ NULL, 0, 0, {} }
|
||||||
};
|
};
|
||||||
|
|
||||||
void GraphicsWindow::ToolbarDraw(void) {
|
void GraphicsWindow::ToolbarDraw() {
|
||||||
ToolbarDrawOrHitTest(0, 0, true, NULL);
|
ToolbarDrawOrHitTest(0, 0, true, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
|
|||||||
return withinToolbar;
|
return withinToolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::TimerCallback(void) {
|
void GraphicsWindow::TimerCallback() {
|
||||||
SS.GW.toolbarTooltipped = SS.GW.toolbarHovered;
|
SS.GW.toolbarTooltipped = SS.GW.toolbarHovered;
|
||||||
PaintGraphics();
|
PaintGraphics();
|
||||||
}
|
}
|
||||||
|
104
src/ui.h
104
src/ui.h
@ -70,10 +70,10 @@ public:
|
|||||||
static bool SPACER;
|
static bool SPACER;
|
||||||
|
|
||||||
// These are called by the platform-specific code.
|
// These are called by the platform-specific code.
|
||||||
void Paint(void);
|
void Paint();
|
||||||
void MouseEvent(bool isClick, bool leftDown, double x, double y);
|
void MouseEvent(bool isClick, bool leftDown, double x, double y);
|
||||||
void MouseScroll(double x, double y, int delta);
|
void MouseScroll(double x, double y, int delta);
|
||||||
void MouseLeave(void);
|
void MouseLeave();
|
||||||
void ScrollbarEvent(int newPos);
|
void ScrollbarEvent(int newPos);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -82,22 +82,22 @@ public:
|
|||||||
CLICK = 2
|
CLICK = 2
|
||||||
};
|
};
|
||||||
void DrawOrHitTestIcons(int how, double mx, double my);
|
void DrawOrHitTestIcons(int how, double mx, double my);
|
||||||
void TimerCallback(void);
|
void TimerCallback();
|
||||||
Point2d oldMousePos;
|
Point2d oldMousePos;
|
||||||
HideShowIcon *hoveredIcon, *tooltippedIcon;
|
HideShowIcon *hoveredIcon, *tooltippedIcon;
|
||||||
|
|
||||||
Vector HsvToRgb(Vector hsv);
|
Vector HsvToRgb(Vector hsv);
|
||||||
uint8_t *HsvPattern2d(void);
|
uint8_t *HsvPattern2d();
|
||||||
uint8_t *HsvPattern1d(double h, double s);
|
uint8_t *HsvPattern1d(double h, double s);
|
||||||
void ColorPickerDone(void);
|
void ColorPickerDone();
|
||||||
bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y);
|
bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y);
|
||||||
|
|
||||||
void Init(void);
|
void Init();
|
||||||
void MakeColorTable(const Color *in, float *out);
|
void MakeColorTable(const Color *in, float *out);
|
||||||
void Printf(bool half, const char *fmt, ...);
|
void Printf(bool half, const char *fmt, ...);
|
||||||
void ClearScreen(void);
|
void ClearScreen();
|
||||||
|
|
||||||
void Show(void);
|
void Show();
|
||||||
|
|
||||||
// State for the screen that we are showing in the text window.
|
// State for the screen that we are showing in the text window.
|
||||||
enum {
|
enum {
|
||||||
@ -209,27 +209,27 @@ public:
|
|||||||
} colorPicker;
|
} colorPicker;
|
||||||
} editControl;
|
} editControl;
|
||||||
|
|
||||||
void HideEditControl(void);
|
void HideEditControl();
|
||||||
void ShowEditControl(int col, const std::string &str, int halfRow = -1);
|
void ShowEditControl(int col, const std::string &str, int halfRow = -1);
|
||||||
void ShowEditControlWithColorPicker(int col, RgbaColor rgb);
|
void ShowEditControlWithColorPicker(int col, RgbaColor rgb);
|
||||||
|
|
||||||
void ClearSuper(void);
|
void ClearSuper();
|
||||||
|
|
||||||
void ShowHeader(bool withNav);
|
void ShowHeader(bool withNav);
|
||||||
// These are self-contained screens, that show some information about
|
// These are self-contained screens, that show some information about
|
||||||
// the sketch.
|
// the sketch.
|
||||||
void ShowListOfGroups(void);
|
void ShowListOfGroups();
|
||||||
void ShowGroupInfo(void);
|
void ShowGroupInfo();
|
||||||
void ShowGroupSolveInfo(void);
|
void ShowGroupSolveInfo();
|
||||||
void ShowConfiguration(void);
|
void ShowConfiguration();
|
||||||
void ShowListOfStyles(void);
|
void ShowListOfStyles();
|
||||||
void ShowStyleInfo(void);
|
void ShowStyleInfo();
|
||||||
void ShowStepDimension(void);
|
void ShowStepDimension();
|
||||||
void ShowPasteTransformed(void);
|
void ShowPasteTransformed();
|
||||||
void ShowEditView(void);
|
void ShowEditView();
|
||||||
void ShowTangentArc(void);
|
void ShowTangentArc();
|
||||||
// Special screen, based on selection
|
// Special screen, based on selection
|
||||||
void DescribeSelection(void);
|
void DescribeSelection();
|
||||||
|
|
||||||
void GoToScreen(int screen);
|
void GoToScreen(int screen);
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ public:
|
|||||||
|
|
||||||
class GraphicsWindow {
|
class GraphicsWindow {
|
||||||
public:
|
public:
|
||||||
void Init(void);
|
void Init();
|
||||||
|
|
||||||
// This table describes the top-level menus in the graphics winodw.
|
// This table describes the top-level menus in the graphics winodw.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -465,8 +465,8 @@ public:
|
|||||||
static void MenuView(int id);
|
static void MenuView(int id);
|
||||||
static void MenuEdit(int id);
|
static void MenuEdit(int id);
|
||||||
static void MenuRequest(int id);
|
static void MenuRequest(int id);
|
||||||
void DeleteSelection(void);
|
void DeleteSelection();
|
||||||
void CopySelection(void);
|
void CopySelection();
|
||||||
void PasteClipboard(Vector trans, double theta, double scale);
|
void PasteClipboard(Vector trans, double theta, double scale);
|
||||||
static void MenuClipboard(int id);
|
static void MenuClipboard(int id);
|
||||||
|
|
||||||
@ -511,14 +511,14 @@ public:
|
|||||||
bool active;
|
bool active;
|
||||||
} context;
|
} context;
|
||||||
|
|
||||||
void NormalizeProjectionVectors(void);
|
void NormalizeProjectionVectors();
|
||||||
Point2d ProjectPoint(Vector p);
|
Point2d ProjectPoint(Vector p);
|
||||||
Vector ProjectPoint3(Vector p);
|
Vector ProjectPoint3(Vector p);
|
||||||
Vector ProjectPoint4(Vector p, double *w);
|
Vector ProjectPoint4(Vector p, double *w);
|
||||||
Vector UnProjectPoint(Point2d p);
|
Vector UnProjectPoint(Point2d p);
|
||||||
Vector UnProjectPoint3(Vector p);
|
Vector UnProjectPoint3(Vector p);
|
||||||
void AnimateOnto(Quaternion quatf, Vector offsetf);
|
void AnimateOnto(Quaternion quatf, Vector offsetf);
|
||||||
void AnimateOntoWorkplane(void);
|
void AnimateOntoWorkplane();
|
||||||
Vector VectorFromProjs(Vector rightUpForward);
|
Vector VectorFromProjs(Vector rightUpForward);
|
||||||
void HandlePointForZoomToFit(Vector p, Point2d *pmax, Point2d *pmin,
|
void HandlePointForZoomToFit(Vector p, Point2d *pmax, Point2d *pmin,
|
||||||
double *wmin, bool usePerspective);
|
double *wmin, bool usePerspective);
|
||||||
@ -527,11 +527,11 @@ public:
|
|||||||
void ZoomToFit(bool includingInvisibles, bool useSelection = false);
|
void ZoomToFit(bool includingInvisibles, bool useSelection = false);
|
||||||
|
|
||||||
hGroup activeGroup;
|
hGroup activeGroup;
|
||||||
void EnsureValidActives(void);
|
void EnsureValidActives();
|
||||||
bool LockedInWorkplane(void);
|
bool LockedInWorkplane();
|
||||||
void SetWorkplaneFreeIn3d(void);
|
void SetWorkplaneFreeIn3d();
|
||||||
hEntity ActiveWorkplane(void);
|
hEntity ActiveWorkplane();
|
||||||
void ForceTextWindowShown(void);
|
void ForceTextWindowShown();
|
||||||
|
|
||||||
// Operations that must be completed by doing something with the mouse
|
// Operations that must be completed by doing something with the mouse
|
||||||
// are noted here. These occupy the same space as the menu ids.
|
// are noted here. These occupy the same space as the menu ids.
|
||||||
@ -569,7 +569,7 @@ public:
|
|||||||
|
|
||||||
SuggestedConstraint suggestion;
|
SuggestedConstraint suggestion;
|
||||||
} pending;
|
} pending;
|
||||||
void ClearPending(void);
|
void ClearPending();
|
||||||
// The constraint that is being edited with the on-screen textbox.
|
// The constraint that is being edited with the on-screen textbox.
|
||||||
hConstraint constraintBeingEdited;
|
hConstraint constraintBeingEdited;
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ public:
|
|||||||
|
|
||||||
Vector SnapToGrid(Vector p);
|
Vector SnapToGrid(Vector p);
|
||||||
bool ConstrainPointByHovered(hEntity pt);
|
bool ConstrainPointByHovered(hEntity pt);
|
||||||
void DeleteTaggedRequests(void);
|
void DeleteTaggedRequests();
|
||||||
hRequest AddRequest(int type, bool rememberForUndo);
|
hRequest AddRequest(int type, bool rememberForUndo);
|
||||||
hRequest AddRequest(int type);
|
hRequest AddRequest(int type);
|
||||||
|
|
||||||
@ -591,14 +591,14 @@ public:
|
|||||||
void MakeFromEntity(hEntity he, bool reverse);
|
void MakeFromEntity(hEntity he, bool reverse);
|
||||||
Vector PointAt(double t);
|
Vector PointAt(double t);
|
||||||
Vector TangentAt(double t);
|
Vector TangentAt(double t);
|
||||||
double LengthForAuto(void);
|
double LengthForAuto();
|
||||||
|
|
||||||
hRequest CreateRequestTrimmedTo(double t, bool extraConstraints,
|
hRequest CreateRequestTrimmedTo(double t, bool extraConstraints,
|
||||||
hEntity orig, hEntity arc, bool arcFinish);
|
hEntity orig, hEntity arc, bool arcFinish);
|
||||||
void ConstrainPointIfCoincident(hEntity hpt);
|
void ConstrainPointIfCoincident(hEntity hpt);
|
||||||
};
|
};
|
||||||
void MakeTangentArc(void);
|
void MakeTangentArc();
|
||||||
void SplitLinesOrCurves(void);
|
void SplitLinesOrCurves();
|
||||||
hEntity SplitEntity(hEntity he, Vector pinter);
|
hEntity SplitEntity(hEntity he, Vector pinter);
|
||||||
hEntity SplitLine(hEntity he, Vector pinter);
|
hEntity SplitLine(hEntity he, Vector pinter);
|
||||||
hEntity SplitCircle(hEntity he, Vector pinter);
|
hEntity SplitCircle(hEntity he, Vector pinter);
|
||||||
@ -617,19 +617,19 @@ public:
|
|||||||
hConstraint constraint;
|
hConstraint constraint;
|
||||||
bool emphasized;
|
bool emphasized;
|
||||||
|
|
||||||
void Draw(void);
|
void Draw();
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
bool IsEmpty(void);
|
bool IsEmpty();
|
||||||
bool Equals(Selection *b);
|
bool Equals(Selection *b);
|
||||||
bool HasEndpoints(void);
|
bool HasEndpoints();
|
||||||
};
|
};
|
||||||
Selection hover;
|
Selection hover;
|
||||||
bool hoverWasSelectedOnMousedown;
|
bool hoverWasSelectedOnMousedown;
|
||||||
List<Selection> selection;
|
List<Selection> selection;
|
||||||
void HitTestMakeSelection(Point2d mp);
|
void HitTestMakeSelection(Point2d mp);
|
||||||
void ClearSelection(void);
|
void ClearSelection();
|
||||||
void ClearNonexistentSelectionItems(void);
|
void ClearNonexistentSelectionItems();
|
||||||
enum { MAX_SELECTED = 32 };
|
enum { MAX_SELECTED = 32 };
|
||||||
struct {
|
struct {
|
||||||
hEntity point[MAX_SELECTED];
|
hEntity point[MAX_SELECTED];
|
||||||
@ -655,15 +655,15 @@ public:
|
|||||||
int withEndpoints;
|
int withEndpoints;
|
||||||
int n;
|
int n;
|
||||||
} gs;
|
} gs;
|
||||||
void GroupSelection(void);
|
void GroupSelection();
|
||||||
bool IsSelected(Selection *s);
|
bool IsSelected(Selection *s);
|
||||||
bool IsSelected(hEntity he);
|
bool IsSelected(hEntity he);
|
||||||
void MakeSelected(hEntity he);
|
void MakeSelected(hEntity he);
|
||||||
void MakeSelected(Selection *s);
|
void MakeSelected(Selection *s);
|
||||||
void MakeUnselected(hEntity he, bool coincidentPointTrick);
|
void MakeUnselected(hEntity he, bool coincidentPointTrick);
|
||||||
void MakeUnselected(Selection *s, bool coincidentPointTrick);
|
void MakeUnselected(Selection *s, bool coincidentPointTrick);
|
||||||
void SelectByMarquee(void);
|
void SelectByMarquee();
|
||||||
void ClearSuper(void);
|
void ClearSuper();
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CMNU_UNSELECT_ALL = 0x100,
|
CMNU_UNSELECT_ALL = 0x100,
|
||||||
@ -686,15 +686,15 @@ public:
|
|||||||
CMNU_ADD_SPLINE_PT = 0x142,
|
CMNU_ADD_SPLINE_PT = 0x142,
|
||||||
CMNU_FIRST_STYLE = 0x40000000
|
CMNU_FIRST_STYLE = 0x40000000
|
||||||
};
|
};
|
||||||
void ContextMenuListStyles(void);
|
void ContextMenuListStyles();
|
||||||
int64_t contextMenuCancelTime;
|
int64_t contextMenuCancelTime;
|
||||||
|
|
||||||
// The toolbar, in toolbar.cpp
|
// The toolbar, in toolbar.cpp
|
||||||
bool ToolbarDrawOrHitTest(int x, int y, bool paint, int *menuHit);
|
bool ToolbarDrawOrHitTest(int x, int y, bool paint, int *menuHit);
|
||||||
void ToolbarDraw(void);
|
void ToolbarDraw();
|
||||||
bool ToolbarMouseMoved(int x, int y);
|
bool ToolbarMouseMoved(int x, int y);
|
||||||
bool ToolbarMouseDown(int x, int y);
|
bool ToolbarMouseDown(int x, int y);
|
||||||
static void TimerCallback(void);
|
static void TimerCallback();
|
||||||
int toolbarHovered;
|
int toolbarHovered;
|
||||||
int toolbarTooltipped;
|
int toolbarTooltipped;
|
||||||
int toolbarMouseX, toolbarMouseY;
|
int toolbarMouseX, toolbarMouseY;
|
||||||
@ -717,12 +717,12 @@ public:
|
|||||||
|
|
||||||
void AddPointToDraggedList(hEntity hp);
|
void AddPointToDraggedList(hEntity hp);
|
||||||
void StartDraggingByEntity(hEntity he);
|
void StartDraggingByEntity(hEntity he);
|
||||||
void StartDraggingBySelection(void);
|
void StartDraggingBySelection();
|
||||||
void UpdateDraggedNum(Vector *pos, double mx, double my);
|
void UpdateDraggedNum(Vector *pos, double mx, double my);
|
||||||
void UpdateDraggedPoint(hEntity hp, double mx, double my);
|
void UpdateDraggedPoint(hEntity hp, double mx, double my);
|
||||||
|
|
||||||
// These are called by the platform-specific code.
|
// These are called by the platform-specific code.
|
||||||
void Paint(void);
|
void Paint();
|
||||||
void MouseMoved(double x, double y, bool leftDown, bool middleDown,
|
void MouseMoved(double x, double y, bool leftDown, bool middleDown,
|
||||||
bool rightDown, bool shiftDown, bool ctrlDown);
|
bool rightDown, bool shiftDown, bool ctrlDown);
|
||||||
void MouseLeftDown(double x, double y);
|
void MouseLeftDown(double x, double y);
|
||||||
@ -731,7 +731,7 @@ public:
|
|||||||
void MouseMiddleOrRightDown(double x, double y);
|
void MouseMiddleOrRightDown(double x, double y);
|
||||||
void MouseRightUp(double x, double y);
|
void MouseRightUp(double x, double y);
|
||||||
void MouseScroll(double x, double y, int delta);
|
void MouseScroll(double x, double y, int delta);
|
||||||
void MouseLeave(void);
|
void MouseLeave();
|
||||||
bool KeyDown(int c);
|
bool KeyDown(int c);
|
||||||
void EditControlDone(const char *s);
|
void EditControlDone(const char *s);
|
||||||
|
|
||||||
@ -739,7 +739,7 @@ public:
|
|||||||
hGroup lastSpaceNavigatorGroup;
|
hGroup lastSpaceNavigatorGroup;
|
||||||
void SpaceNavigatorMoved(double tx, double ty, double tz,
|
void SpaceNavigatorMoved(double tx, double ty, double tz,
|
||||||
double rx, double ry, double rz, bool shiftDown);
|
double rx, double ry, double rz, bool shiftDown);
|
||||||
void SpaceNavigatorButtonUp(void);
|
void SpaceNavigatorButtonUp();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
void SolveSpaceUI::UndoRemember(void) {
|
void SolveSpaceUI::UndoRemember() {
|
||||||
unsaved = true;
|
unsaved = true;
|
||||||
PushFromCurrentOnto(&undo);
|
PushFromCurrentOnto(&undo);
|
||||||
UndoClearStack(&redo);
|
UndoClearStack(&redo);
|
||||||
UndoEnableMenus();
|
UndoEnableMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::UndoUndo(void) {
|
void SolveSpaceUI::UndoUndo() {
|
||||||
if(undo.cnt <= 0) return;
|
if(undo.cnt <= 0) return;
|
||||||
|
|
||||||
PushFromCurrentOnto(&redo);
|
PushFromCurrentOnto(&redo);
|
||||||
@ -22,7 +22,7 @@ void SolveSpaceUI::UndoUndo(void) {
|
|||||||
UndoEnableMenus();
|
UndoEnableMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::UndoRedo(void) {
|
void SolveSpaceUI::UndoRedo() {
|
||||||
if(redo.cnt <= 0) return;
|
if(redo.cnt <= 0) return;
|
||||||
|
|
||||||
PushFromCurrentOnto(&undo);
|
PushFromCurrentOnto(&undo);
|
||||||
@ -30,7 +30,7 @@ void SolveSpaceUI::UndoRedo(void) {
|
|||||||
UndoEnableMenus();
|
UndoEnableMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SolveSpaceUI::UndoEnableMenus(void) {
|
void SolveSpaceUI::UndoEnableMenus() {
|
||||||
EnableMenuById(GraphicsWindow::MNU_UNDO, undo.cnt > 0);
|
EnableMenuById(GraphicsWindow::MNU_UNDO, undo.cnt > 0);
|
||||||
EnableMenuById(GraphicsWindow::MNU_REDO, redo.cnt > 0);
|
EnableMenuById(GraphicsWindow::MNU_REDO, redo.cnt > 0);
|
||||||
}
|
}
|
||||||
|
34
src/util.cpp
34
src/util.cpp
@ -178,7 +178,7 @@ RgbaColor SolveSpace::CnfThawColor(RgbaColor v, const std::string &name)
|
|||||||
// There also may be elements in the last two columns of any row. We solve
|
// There also may be elements in the last two columns of any row. We solve
|
||||||
// without pivoting.
|
// without pivoting.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void BandedMatrix::Solve(void) {
|
void BandedMatrix::Solve() {
|
||||||
int i, ip, j, jp;
|
int i, ip, j, jp;
|
||||||
double temp;
|
double temp;
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ Quaternion Quaternion::ScaledBy(double s) {
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Quaternion::Magnitude(void) {
|
double Quaternion::Magnitude() {
|
||||||
return sqrt(w*w + vx*vx + vy*vy + vz*vz);
|
return sqrt(w*w + vx*vx + vy*vy + vz*vz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ Quaternion Quaternion::WithMagnitude(double s) {
|
|||||||
return ScaledBy(s/Magnitude());
|
return ScaledBy(s/Magnitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Quaternion::RotationU(void) {
|
Vector Quaternion::RotationU() {
|
||||||
Vector v;
|
Vector v;
|
||||||
v.x = w*w + vx*vx - vy*vy - vz*vz;
|
v.x = w*w + vx*vx - vy*vy - vz*vz;
|
||||||
v.y = 2*w *vz + 2*vx*vy;
|
v.y = 2*w *vz + 2*vx*vy;
|
||||||
@ -322,7 +322,7 @@ Vector Quaternion::RotationU(void) {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Quaternion::RotationV(void) {
|
Vector Quaternion::RotationV() {
|
||||||
Vector v;
|
Vector v;
|
||||||
v.x = 2*vx*vy - 2*w*vz;
|
v.x = 2*vx*vy - 2*w*vz;
|
||||||
v.y = w*w - vx*vx + vy*vy - vz*vz;
|
v.y = w*w - vx*vx + vy*vy - vz*vz;
|
||||||
@ -330,7 +330,7 @@ Vector Quaternion::RotationV(void) {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Quaternion::RotationN(void) {
|
Vector Quaternion::RotationN() {
|
||||||
Vector v;
|
Vector v;
|
||||||
v.x = 2*w*vy + 2*vx*vz;
|
v.x = 2*w*vy + 2*vx*vz;
|
||||||
v.y = 2*vy*vz - 2*w*vx;
|
v.y = 2*vy*vz - 2*w*vx;
|
||||||
@ -345,7 +345,7 @@ Vector Quaternion::Rotate(Vector p) {
|
|||||||
RotationN().ScaledBy(p.z));
|
RotationN().ScaledBy(p.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Quaternion::Inverse(void) {
|
Quaternion Quaternion::Inverse() {
|
||||||
Quaternion r;
|
Quaternion r;
|
||||||
r.w = w;
|
r.w = w;
|
||||||
r.vx = -vx;
|
r.vx = -vx;
|
||||||
@ -390,7 +390,7 @@ Quaternion Quaternion::Times(Quaternion b) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Quaternion::Mirror(void) {
|
Quaternion Quaternion::Mirror() {
|
||||||
Vector u = RotationU(),
|
Vector u = RotationU(),
|
||||||
v = RotationV();
|
v = RotationV();
|
||||||
u = u.ScaledBy(-1);
|
u = u.ScaledBy(-1);
|
||||||
@ -457,7 +457,7 @@ Vector Vector::Minus(Vector b) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Vector::Negated(void) {
|
Vector Vector::Negated() {
|
||||||
Vector r;
|
Vector r;
|
||||||
|
|
||||||
r.x = -x;
|
r.x = -x;
|
||||||
@ -614,11 +614,11 @@ Vector Vector::ClosestPointOnLine(Vector p0, Vector dp) {
|
|||||||
return this->Plus(n.WithMagnitude(d));
|
return this->Plus(n.WithMagnitude(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
double Vector::MagSquared(void) {
|
double Vector::MagSquared() {
|
||||||
return x*x + y*y + z*z;
|
return x*x + y*y + z*z;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Vector::Magnitude(void) {
|
double Vector::Magnitude() {
|
||||||
return sqrt(x*x + y*y + z*z);
|
return sqrt(x*x + y*y + z*z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,14 +672,14 @@ Point2d Vector::Project2d(Vector u, Vector v) {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2d Vector::ProjectXy(void) {
|
Point2d Vector::ProjectXy() {
|
||||||
Point2d p;
|
Point2d p;
|
||||||
p.x = x;
|
p.x = x;
|
||||||
p.y = y;
|
p.y = y;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector::Project4d(void) {
|
Vector4 Vector::Project4d() {
|
||||||
return Vector4::From(1, x, y, z);
|
return Vector4::From(1, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,7 +695,7 @@ double Vector::DivPivoting(Vector delta) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Vector::ClosestOrtho(void) {
|
Vector Vector::ClosestOrtho() {
|
||||||
double mx = fabs(x), my = fabs(y), mz = fabs(z);
|
double mx = fabs(x), my = fabs(y), mz = fabs(z);
|
||||||
|
|
||||||
if(mx > my && mx > mz) {
|
if(mx > my && mx > mz) {
|
||||||
@ -930,7 +930,7 @@ Vector4 Vector4::ScaledBy(double s) {
|
|||||||
return Vector4::From(w*s, x*s, y*s, z*s);
|
return Vector4::From(w*s, x*s, y*s, z*s);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Vector4::PerspectiveProject(void) {
|
Vector Vector4::PerspectiveProject() {
|
||||||
return Vector::From(x / w, y / w, z / w);
|
return Vector::From(x / w, y / w, z / w);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,11 +971,11 @@ double Point2d::DivPivoting(Point2d delta) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double Point2d::MagSquared(void) const {
|
double Point2d::MagSquared() const {
|
||||||
return x*x + y*y;
|
return x*x + y*y;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Point2d::Magnitude(void) const {
|
double Point2d::Magnitude() const {
|
||||||
return sqrt(x*x + y*y);
|
return sqrt(x*x + y*y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1017,7 +1017,7 @@ double Point2d::DistanceToLine(const Point2d &p0, const Point2d &dp, bool segmen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2d Point2d::Normal(void) const {
|
Point2d Point2d::Normal() const {
|
||||||
return { y, -x };
|
return { y, -x };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
void TextWindow::ShowEditView(void) {
|
void TextWindow::ShowEditView() {
|
||||||
Printf(true, "%Ft3D VIEW PARAMETERS%E");
|
Printf(true, "%Ft3D VIEW PARAMETERS%E");
|
||||||
|
|
||||||
Printf(true, "%Bd %Ftoverall scale factor%E");
|
Printf(true, "%Bd %Ftoverall scale factor%E");
|
||||||
|
Loading…
Reference in New Issue
Block a user