CAD Sketch

CAD Sketch

The goal of this project is to create a 3D CAD program. Current work is focusing on 2D functionality and overall GUI elements. The intent is to create 2D sketches and extrude them into solid objects, then perform boolean operations to create more complicated objects for machining or 3D printing.

This version is written in C++, using Vulkan 3D API, on top of GLFW3. I rolled my own GUI widgets and text handling routines. All the graphics are presented using only a few shaders: a unit square, line, arc, and TTF glyph rendering.

The shaders are represented in the source as elements of a scene graph. Sizes are controlled using transformations in the graph structure. There are currently no images used, elements such as button-tops are rendered as text. The button tops were drawn using FontForge and are stored in a font file and are rendered as regular text.

The following presents images of the sketch editor in action. The steps increase the number of constraints active on the sketch, and highlights the different constraints used. While it is possible to explicitly declare the length of a dimension, angle, point coordinates, and add labels, this functionality was disabled in this version.

The last image in this document shows a sketch where this application was used to lay out an oddly shaped flower-bed by my father.

Looking at the GUI there is a toolbar at the top, status bar beneath and a drawing area with a simple sketch created using a poly-line tool and an arc tool.

Slide 1: The toolbar from left to right includes select, text label, merge points, point, line, poly-line, rectangle, circle, 3-point arc, fix point coordinates, concentric points, horizontal constraint, vertical constraint, co-linear lines constraint, parallel constraint, perpendicular constraint, lines of equal length, line length dimension, horizontal distance dimension, vertical distance dimension, angles equal constraint, fixed angle dimension, OK , Cancel, Undo, Redo, About, Save. The status bar indicates what the active tool expects the user to do. A polygon has been drawn including an arc to create an unconstrained starting sketch for the demo.
Slide 2: A perpendicular constraint has been added relating two lines. The constraint is indicated on the sketch using blue boxes and the solver has updated the drawing coordinates changing the angles of the lines.
Slide 3: In step two line segments are set to be co-linear. Again the solver automatically updates to include the new information and makes the two indicated lines co-linear.
Slide 4: Two lines are made parallel.
Slide 5: Two more lines have been made parallel, additionally two angles have been made equal.
Slide 6: Here the outside edges of the angles, made equal in the prior step, are set to be the same length. This is indicated by the equal signs in the blue constraint boxes.
Slide 7: More side lengths are made equal length.
Slide 8: The bottom right near vertical line is set to be equal length to the edge at the other end of the arc. The result is the radial arc starts and ends at the ends of the perpendicular lines. Where the arc center line is perpendicular to the outside edge the arc will be tangent to that edge. This is how I expect to handle fillets.
Slide 9: Here another equality constraint has been added.
Slide 10: And another equality constraint.
Slide 11: Finally, a horizontal constraint is added causing the whole sketch to rotate. Now the arrow is pointing up.

This simple demonstration showed the solver and 2D sketch in action.

Because of conflicting development, the text edit widget needs revisited. Tools requiring input, number entry and text entry, are not functioning.

The last element on the toolbar brings up a save dialog. Currently saving and loading is completely drag and drop. Clicking on the save button will present a window with a drag source area and file name field. The current implementation uses X Window drag functionality to write the file.

Dragging a saved file into the application window will open the file. Dragging from the save dialog allows the file to be dropped into a folder on the KDE Desktop.

Slide 12: My father was the first person to make real use of my application. Although requiring guidance he used a modified version of this program to layout an oddly shaped flower bed. Measurements were made of the four outside edges of his bed and a polygon was created with the side lengths fixed to these values. Properly scaled flowers were drawn as circles to locate the plants.

Streamlines Document Generator