Sunday, April 3, 2011

SketchSolve NaroCAD Infrastructure Explained

SketchSolve is a 2D Sketch Constraint Solver and NaroCAD is a 3D based designer.
SketchSolve have mostly a dynamic programming solution optimizer that will apply the constraints using a big dispatcher to compute the errors that may happen in applying the constraints.
From NaroCAD standpoint challenges are at two levels: sketch shapes need to be sketch oriented, so by design all shapes get references to a sketch. The second problem is how to setup at programming level map the Line, Point, Arc and Circle from NaroCAD to SketchSolve semantics and after the SketchSolve is done, to make things back. Another small feature, yet useful is that those constraints are in a chain, so at programming level, the code at NaroCAD level is smart enough that by simply stating a shape, will build all the dependency chains to be computed in SketchSolve. To be both efficient, this code uses the GraphMapping component that compute back-references and get the mapped constraints.

So let's take a simple(st) case:
"NaroCAD have defined two points and one constraint (PointToPoint) and one point may be moved"
How the back logic works:
- the scene computes the back references: so P1, P2 are references by P2PC
- BFS algorithm will find in P1 -> P2PC -> P2
- a re-mapping will translate NaroCAD shapes and constraints will be converted in SketchSolve logic
- SketchSolve will solve the the constraint system and will retranslate shapes to make the system to work
- at the end shapes will be un-mapped from SketchSolve so the constraints will work accordingly

No comments: