Is a heekscad Constraint valid?

A friend of my was telling me a story about a programmer who worked on software he uses.
Apparently, this guy was brilliant but a bit eccentric.  I guess he would program for a couple of hours and take a nap. Wake and repeat this cycle immediately.
There must be something to this.  I woke up this morning, hopped in the shower and had an idea come to me how identify bad constraints.

Ok… I’m almost a point where I become dangerous with this C++ stuff. ie,  the point at which you think you know what your doing.  I’m not quite there yet, but getting there.

The problem that needs to be solved is that there are bugs in heekscad which are created invalid constraints which results in segmentation faults.

But… I think the you should be able to ask the Constraint itself hey are you valid?     Ok… I think that should be easy enough to do.  Build a member function within  “class Constraint”  called isValid  which will check to make sure that nothing is hosed up.

Now, what I have in mind is some type of global routine called ValidateAllConstraints.   Basically, I would iterate through all the constraints and check if they’re valid.   Sounds simple enough.  Looking at the code, I’m still a little fuzzy on how to do this.
I think my path lies here:

// SolveSketch.cpp
// Copyright (c) 2009, Dan Heeks
// This program is released under the BSD license. See the file COPYING for details.

#include “stdafx.h”
#include “Sketch.h”
#include “../interface/ObjList.h”
#include “SolveSketch.h”
#include “ConstrainedObject.h”
#include “EndedObject.h”
#include “HArc.h”
#include “HCircle.h”
#include “HEllipse.h”
#include “../sketchsolve/src/solve.h”
#include “HDimension.h”

//This file traverses the tree associated with a sketch and creates and linear
//data structure suitable for use by sketch solve. If the solver is succesful,
//the new points are written into the corresponding heeksobj’s.

arc GetArc(HArc* a);
circle GetCircle(HCircle* a);
ellipse GetEllipse(HEllipse* a);
line GetLineFromEndedObject(EndedObject* eobj);
point GetPoint(HPoint* point);
void AddPointConstraints(HPoint* point);
int solvewpoints(double  **parms,int nparms, constraint * cons, int consLength, std::set<double*> fixed, int isFine);

std::vector<double*> params;
std::set<double*> paramset;
std::set<double*> fixedset;
std::vector<constraint> constraints;
std::set<Constraint*> cons;
std::map<HeeksObj*,HeeksObj*> pointonpoint;

I’m  very tempted to pop a pointer into class constraint of
class constraint
{
public:

Constraint * HeeksContraint // Tempted to add this. To be able to valididate that everything jives.
constraint(){parameter = 0;}
constraintType type;
point point1;
point point2;
line line1;
line line2;
line SymLine;
circle circle1;
circle circle2;
ellipse ellipse1;
ellipse ellipse2;
arc arc1;
arc arc2;
double *parameter; //radius, length, angle etc…
};

I need to think on this a bit..

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *