Friday, December 21, 2012

Released NaroCAD 1.7.3 Beta

Today we released NaroCAD 1.7.3 Beta:
- Fixed Boo script commands for main 2D and 3D shapes and tools
- Improved the Point to Edge and Point to Point constraints
- Updated Boo script help and sample files
- Property grid displayed values are automatically updated after shape resize
- Fixed Document Tree selection bug


You can download NaroCAD 1.7.3 here.

Improved point to edge constraint

Today's release includes the improvements I've made to the Point to Edge and Point to Point constraints, the main one being the ability to change the length set for the constraint from the property grid. There are still some improvements that need to be done, and they'll be included in the next release, which is planned for January 2013.



You can find the code changes here

Tuesday, December 18, 2012

Length and radius lock fixes

Today I commited the last batch of fixes for Boo scripts for this release - you can find the changes here.

I've fixed two bugs that were affecting the lock feature for line length and circle radius, and improved the property grid for mouse drag. After this change, if a line is resized, the length property is automatically updated, without needing to re-select the shape.

I've also started improving the Point to point and Point to Edge constraints, so that we can update the distance and control shape positioning this way. I've updated the Point to Edge property tab and the dimension display:


The next step is to allow the user to update the distance and update the shapes' positions through the Solver.

Thursday, December 13, 2012

Cut and Extrude for boo scripts

Almost all commands for boo scripts are updated, the most important ones being Extrude and Cut:


I've also updated the demo scripts and the help files for all the updated shapes. The first set of changes is here.

Tuesday, December 11, 2012

Fixes for the Boo scripts

Today I've worked on improving the Boo script functionality, mainly updating the methods to use the new structure (Reference instead of Point3D), adding sketch-related functionality and allowing methods to use references to previously created points instead of having to use their coordinates.

For example, the following Boo script:

s1=Sketch(5,0,0,1,2,0,0,0,0)
EnterSketch(s1)
p1=Point(s1,2,5,0)
Circle(p1,20)

s2=Sketch(5,0,0,0,5,0,0,0,5)
EnterSketch(s2)
p2=Point(s2,2,5,3)
Circle(p2,20)

EnterSketch(s1)
p3=Point(s1,10,10,0)
Circle(p3,5)

creates:


With the current version of the code it's possible to create and edit sketches and draw 2D shapes in them. Tomorrow I will complete the changes for the 2D shapes, update the help section for them and start working on the 3D commands.

Monday, December 10, 2012

Creating a sketch from the command line

Today I added a new functionality which allows us to create a sketch from the command line. after pressing 'Enter Sketch', we can type three coordinates in the command line and a new sketch with the plane defined by the three points will be created and set as the currently active sketch:



The first sketch was created parallel to the yOz plane, 5 units from the origin, and the other one at an angle to all axes, using the points (10,0,0), (0,10,0) and (0,0,10).

You can find the code changes here

Friday, December 7, 2012

Released NaroCAD 1.7.2 Beta

Today we release NaroCAD 1.7.2 Beta:
- Extrude and pipe can be performed on shapes with holes
- Extrude, pipe and cut are performed on the entire sketch containing the selected shape
- Cut can be performed on the shapes obtained from boolean operations
- Improved the Translate gizmo for 3D solids
- Fixed translate for solids obtained from extrude/cut
- Fixed point position display on default plane
- Fixed Save/Open for solids obtained from Extrude, Pipe and Cut operations
- 3D shapes are automatically notified when the underlying sketch changes and are redrawn
- Sketch shapes are displayed on enter/edit sketch and hidden on exit sketch
- Improved sketch selection algorithm
- Fixed crash caused by multiple open commands

You can download NaroCAD 1.7.2 here.

For the next release, we will:
- Add posibility to create sketch from command line
- Fix boo scripts functionality
- Fix undo/redo for translated shapes
- Fix translate for pipe
- Fix hinter line display bug

Wednesday, December 5, 2012

Fix for save/open with cut solids

I've fixed one of the two major issue we still have cut solids affected by cut, which is the save/open functionality. The problem was caused by the way the extruded solid was opened and the fact that the base shape's type was wrongly set to TopAbs_COMPOUND or TopAbs_SHELL instead of TopAbs_FACE. You can find the code change here.



Today I started working on the other major issue, which is undo/redo: undo and redo work correctly for Cut and for Translate, but don't work for a translate applied after a Cut.

Tuesday, December 4, 2012

Cutting on a sketch with multiple extrusions, using a sketch with multiple shapes

Today I fixed two bugs which didn't allow us to cut on a sketch with multiple extrusions, using a sketch with multiple different shapes. The first issue was caused by the way the sketch faces were composed to obtain a single shape. until now, we fused the shapes together, but cut failed on this shape. I've replaced the fuse with sewing and now cut works for all types of base sketch extrusions.

The second issue was caused by the different orientation of shapes. When cutting with a circle in an extruded circle, or a rectangle in an extruded rectangle, the cutting prism had the correct orientation and the cut to depth was performed correctly. When trying to cut in an extruded circle with a rectangle, the orientation was wrong and the extruded solid wasn't affected. I've added a check before the extrude and the prism vector is reversed if the direction is wrong.

Monday, December 3, 2012

Delete shape from sketch used for cut fix

Today I fixed several bugs related to sketch selection, mouse coordinates being wrongly calculated after editing an existing sketch in the default plane and deleting shapes from the sketch used as base for cut.

Here is a demo, where I delete a circle and a line from a polygon. Both holes disappear after exiting the sketch editing, but the remaining lines and circle center are visible when entering the sketch again and the entire solid can be translated:

Thursday, November 29, 2012

Cut and translate fixes

One of the issues that caused the Cut tool to fail was that the shapes it was meant to cut through weren't selected properly. Today I improved the code that selects these shapes (you can find the changes here). There are several cases when the list is refreshed, the main ones being:
1. First cut: for example, when performing a cut on a solid obtained after an Extrude. In this case, we need to check all the solid shapes in the document and try to perform the cut on them.
2. Second cut on the same solid: for this case, we need to perform the cut on the result of the previous cuts. Otherwise, the previous cut results would be displayed and some of the cut outs would be filled in. To do this, we analyze all the Cut nodes and exclude the nodes in their reference list from the final shape list
3. Updating an existing cut: for example, when performing translate on a solid resulted after one or more cut operations. In this case, the reference list is already filled in from the previous/first cut operation and we use that list.

An example that covers these cases is:



I'm working on testing and fixing bugs for cutting and translating shapes resulted from different operations. Here is an overview of the test cases I've worked on so far and the bugs that aren't yet fixed:

1a. Extrude sketch; cut through all with second sketch; translate (example 1, example 2)
1b. Extrude sketch; cut to depth with second sketch; translate (example)
2a. Extrude sketch; cut through all with second sketch; edit second sketch; translate
2b. Extrude sketch; cut to depth with second sketch; edit second sketch (example); translate
3a. Extrude sketch; cut through all with second sketch; edit base sketch; translate
3b. Extrude sketch; cut to depth with second sketch; edit base sketch; translate
4a. Extrude sketch; cut through all with second sketch; delete shape from second sketch; translate (example)
4b. Extrude sketch; cut to depth with second sketch; delete shape from second sketch; translate
5. Extrude sketch; cut to depth with second sketch; cut through all on result of first cut; cut to depth on result of second cut; translate (example)
6a. Extrude 2 sketches; apply boolean operation; cut through all on result (example); translate (BUG)
6b. Extrude 2 sketches; apply boolean operation; cut to depth on result; translate (BUG)
7. Extrude two sketches; cut through all so that both solids are affected (the result is one shape) ; translate (BUG)

There are also several bugs in the display and selection of items in the Document Tree view panel and for save/open and undo/redo for solids affected by cut.

Wednesday, November 28, 2012

Editing a sketch after cut

Today i fixed some more cut-related bugs, and it's possible to edit the sketch that was used to cut in an extruded solid (both cut through all and cut to depth):



I've also fixed a bug that caused the second sketch face to be visible when translating a solid after cut to depth was applied on it.
Tomorrow I'll continue fixing bugs for the Cut tool.

Tuesday, November 27, 2012

Translating a cut solid

Translating a solid that is resulted from a cut is a bit more complicated than the other solid shapes, because aside from a base sketch it references a list of affected shapes which need to be translated before the base sketch is translated and cut function executed again.

You can find the code changes here



Aside from this I've fixed two small issues:
- shapes drawn on the default sketch weren't positioned on the mouse click positions
- in some cases, the extrude height defaulted to 1

The next issue I'll work on is the cut shape disappearing after editing the base sketchese.

Friday, November 23, 2012

Translate on 3D solids

Over the past two days I worked on fixing the translate gizmo for 3D solids resulted from non-circle sketch shapes. There main issues were:
- the way the faces were created, using a check for visibility to determine the correct candidates
- the way the sketch nodes were being updated after the translation
- the extra faces that were created, which slowed down the redrawing of the shapes

Here is a video showing the translate performed on a shape which has lines and a SER arc, the editing of the sketch after the translate and the redrawing of the extruded shape after the sketch was changed:



Currently, the faces on the sketch are processed and fused into one shape, which is added as an interpreter for the sketch node. Whenever a 3D tool is applied, a reference to the sketch containing the selected shape is used, avoiding the reprocessing of the same faces each time. When the sketch is changed, the shape is re-processed and all tools are notified.
The translate tool applies the translation on the sketch's points, the point changes cause all the shapes that reference them to be notified and the sketch face is regenerated, causing the 3D tools to be automatically redrawn.

Since there were some big changes over the past two weeks, we decided not to have a release today and continue working on improving the tools and fixing bugs over the next two weeks. The next release, for version 1.7.2, will be on the 7th of December.



Tuesday, November 20, 2012

3D Translate and Cut on sketch

Today I fixed the other 2 major issues we had: translation for 3D solids and Cut on sketch.

Translate now works on 3D shapes, updating the shapes on the underlying sketch and triggering an update for the 3D shapes that reference the sketch. A shape can be translated using the Translate gizmo by dragging it along an axis (using one of the arrows) or on a plane (using one of the parallelograms):



I've also modified the Cut tool so that it applies the cuts (through all or to depth) for the entire sketch:







Monday, November 19, 2012

Hide/show sketch shapes

Today I made the changes related to edit sketch - sketch shapes are hidden after a 3D tool was applied, and shown again when the sketch they belong to is being edited. Shapes that belong to a sketch without a 3D operation are always displayed:



For this to work, I've also updated the way a sketch can be selected for editing:
- if there is no 3D tool on the sketch: select any shape from the sketch, then click on Enter Sketch
- if there is a 3D solid from the sketch: select the 3D solid and click Enter sketch
- either case: select one of the shapes in the Tree View and click Enter sketch.

After last week's 3D tool changes the Translate gizmo doesn't work correctly, so I'll work on fixing that next, along with updating the cut tool.

Friday, November 16, 2012

Editing a sketch after extrude/pipe

Today's fix allows any 3D shape built on a sketch to be notified by the underlying sketch that it was modified and be updated accordingly:





I haven't commited any of the recent fixes because I wanted to make sure the code was ok, but now that the notifying it working I'll clean up the code and submit it.

Thursday, November 15, 2012

Pipe on sketch

For the past few days I worked on improving the face generation for sketches and applying pipe on all sketch shapes.

Initially, the faces were created separately, once for each tool operation, but that wasn't efficient, so now we're creating just one face, which is a boolean add of all individual faces, and this operation is performed once, on Exit Sketch.

I've also modified the Pipe tool to work with the new sketch face structure:



Next steps:
- notify extrude when sketch is changed
- change the Cut tool to work with the new sketch face
- hide the sketch points and wire when we're not in Edit Sketch mode

Tuesday, November 13, 2012

Extrude with holes

Today I worked on improving the Extrude tool to allow extruding shapes with holes. Until now, if one shape was inside another, both of them were extruded. After today's changes, the shape inside will act as hole:



Tomorrow I will do more testing, fix any bugs and work on improving the speed.

Monday, November 12, 2012

Released NaroCAD 1.7.1 Beta

Today we released a new version of NaroCAD:
- Improved the Translate Gizmo for 3D shapes
- Improved same coordinate match in 3D
- Improved the solver constraints loading
- Fixed rectangle drawing on faces
- Fixed 2D and 3D chamfer and fillet
- Improved hints display in 3D

You can download NaroCAD 1.7.1 here.

For the next release we'll work on fixing bugs and improving 3D related tools.

Thursday, November 8, 2012

Hiding sketch shapes on extrude

Today I finished the changes which allow all sketch shapes to be hidden when Extrude is performed:



You can find the changes here. One of the next issues I'll be working on is showing these shapes when the sketch is being edited.

Wednesday, November 7, 2012

Improvements to translate gizmo

Today I committed the changes for the Translate gizmo: I've updated the code used for sketch shapes - if the shape is constrained the Solver is called and the points are updated according to the solution it finds - and I've fixed it for 3D objects.

For both cases, all dependencies are updated and there are no more points that remain in their original position or are transformed differently from their parent shape/solid:

Tuesday, November 6, 2012

Fixes for 3D Chamfer and 3D Fillet

Today I finished the fixes for the 3D Chamfer and Fillet tools, as well as some improvements for the Hinter display and same coordinate match.



Friday, November 2, 2012

Improvements for fillet, chamfer and rectangle

Today I finished the improvements for chamfer, fillet and rectangle drawing on faces of 3D solids. I've also started updating our website, narocad.com, and all the information and demo videos about these tools can be found there: fillet 2D, chamfer 2D and four line rectangle.

As I make more changes to tools I will add the information about them to the website, so that everything is easily available there.

Thursday, November 1, 2012

Constraints on faces

Today I completed the changes for adding constraints for shapes drawn on faces of 3D solids and modifying the shapes in the constraint:



Now I'm working on updating the 2D and 3D fillet and chamfer tools to work on faces and 3D solid edges respectively.

Monday, October 29, 2012

Editing constrained shapes on faces

I've improved the editing of constrained shapes on 3D faces:



There are still issues with the hinter and some special cases, and I need to test all the constraints for all the cases, but the changes should be ready this week.

Friday, October 26, 2012

Released NaroCAD 1.7.0 Beta

Today we released a new version of NaroCAD:
- Fixed the Cut Tool
- Fixed face selection, drawing and editing
- Improved constraints and related shapes loading algorithm
- Improved hinter speed
- Improved rectangle drawing and solve speed
- Fixed 3D solids drawing and property grid editing

You can download NaroCAD 1.7.0 here.

For the next release we'll improve editing and constraints on 3D object faces and 3D object translate and rotation.

Tuesday, October 23, 2012

Fixes for Cut

Until now, the cut tool tried to cut using the selected shape, which was a wire instead of a face. Now I've modified it to auto create faces and use the one that contains the selected wire (it correctly selects a rectangle when one of its lines is selected).

You can see a demonstration of the tool used in its three form: cut to depth for positive and negative values and cut through all:

Monday, October 22, 2012

Thursday, October 18, 2012

3D bug fixing

I've fixed some more bugs that affected 3D drawing and now I'm working on improving the Hinter which automatically adds perpendicular constraints between lines that are in perpendicular planes, but not perpendicular.

I also started testing the other 3D tools that can be used now that we can create sketches on extrusion faces, and the boolean operations work correctly:

Tuesday, October 16, 2012

Sketch improvements

I continued working on the sketch selection and fixed the issues I mentioned in the previous posts.

Here is a video demonstrating some of the new functionalities:
- select a face of an extruded shape for a new sketch
- draw different shapes on the face and extrude them
- use a shape on a face to select its sketch for editing
- edit shapes on the face

Monday, October 15, 2012

Speed improvements for rectangle

Rectangle drawing was slow, especially after more than one rectangle was drawn, because after each mouse move, when drawing the preview rectangle, the seven constraints were added, as well. I've updated the code so that during drawing the lines are drawn, but the constraints are added only once.

Here is a comparison, where I drew rectangles with the old version - the delay in drawing starts after the fourth rectangle is drawn. In the new version, there is no such delay (the message box is about the tree view, an issue I'll be working on soon):

Thursday, October 11, 2012

More fixes for Sketch

Today I fixed the bugs I talked about in yesterday's post, but unfortunately there is a problem with the face selection. Currently, the first face of the solid is being selected instead of the one we clicked on (if it's a different one).

Wednesday, October 10, 2012

New file bug fix and sketch investigations

Today I fixed the new file issue: when creating a new file, three green rectangles were added to the original axes (drawing a trihedron). The problem was caused by the automatic template we used which also had these, and was fixed by changing the file to one which has only the information needed for a blank stage.

I've also investigated the last scenario for 'Enter Sketch': selecting a face of a 3D object. There are two problems we have for this scenario:
- the Animation Document doesn't have the Axis set correctly and all 'intermediate' shapes are drawn in the default, xOy plane
- the final shape is drawn on the plane that is parallel to the one that was selected and which contains the origin

I am working on fixing this two issues and hopefully they'll be included in Friday's release.

Friday, October 5, 2012

Editing an existing sketch

I'm working on improving the sketch-related functionality, the first issue being the ability to add elements to an existing sketch - from now on, if we select an element before pressing the 'Enter Sketch' button, the sketch that contains that element will be used for the edits:

Thursday, October 4, 2012

Duplicate point creation fixed and hinter options fixes

Today I fixed a bug that caused duplicate points to be created on sketch: instead of returning the existing point, a new one was created. A case when duplicate points were created was when adding a fillet/chamfer.

Before the bug fix, we had 6 points:



After the fix, only 4 points remain:



I've also fixed some bugs related to the Hinter options dialog. All the changes are commited here

Wednesday, October 3, 2012

No duplicate lines for adjacent rectangles

Until now, if we drew two adjacent rectangles, we had a total of 8 lines. Today I made a change so that if we're drawing a line between the same two points, the existing line is returned instead and we have only 7 lines:



This helps when we have a complicated drawing and instead of two lines for the same points we have only one node.

Tuesday, October 2, 2012

Translate gizmo fix and tree view constraint delete

Today I fixed two issues: the most important one is for the translation gizmo. Now it's possible to drag any shape using any of the translation gizmo axes:



The second problem was deleting constraints from the Tree View. Until now, when we pressed delete when a constraint was selected in the Tree View, the shapes it was referencing were deleted, as well. After today's fix only the constraint is deleted, the shapes behave correctly and the constraint can be added again:

Monday, October 1, 2012

Point on segment and point to edge update

Today I added a new constraint, Point on Segment, which forces a point to be on a line, inside a segment:



This constraint is used instead of Point on line for the Point to edge constraint, allowing us to avoid the solutions where the projection points would fall outside of the original edge's points:



There are still some speed related problems for the point to edge constraint, which cause the slight delay in the dimension update and which cause different values to be displayed during drag, but these will be fixed soon.

Friday, September 28, 2012

Released NaroCAD 1.6.8 Beta

Today we made an important release version at Naro: NaroCAD 168. The main feature of this version is a new solver.

The constraints from scene are not displayed graphically yet, they currently can be seen with the Constraint Shapes tool from the Constraints tab. A constraint can be added or removed manually by the user with the Sketch Constraints tool.

Changes at 1.6.8:

Improved the existing Solver algorithm and added a new one
Replaced existing constraint error functions and added gradient functions
Added matrix and vector helper classes to simplify the Solver
Fixed circle constraints bugs
Fixed property grid editing for ellipse
Fixed tooltip display bug
Fixed floating point comparison bug
Refactored the Solver and constraints code and fixed dependency issues
Updated the constraints unit tests


You can download NaroCAD 1.6.8 here.

Thursday, September 27, 2012

New Solver

Aside from unit tests and individual constraint checks, we're using several 'scenarios' to test that the solver is finding good solutions:







Foating point comparison bug

While testing the new solver I found that in some cases, the solver behaved differently in debug and release mode. it turned out that the cause was the way floating point comparisons were done in some helper classes, using == instead of comparing the difference to a very small value.

Here's the behaviour without the fix, in release mode (the red line shouldn't be moving):



and after the fix:



The changes are commited here.

After some more reading I found Jon Skeet's article about .NET and floating point comparison where he mentions that the cause of the debug and release differences is JIT optimisation: in debug the JIT doesn't make as many optimisations and the == comparison returns true.

Wednesday, September 26, 2012

Ellipse property grid and tooltip fixes

Today I fixed the ellipse property grid bugs, and it's now possible to modify the major and minor radiuses and lock their values. If the typed major radius is smaller than the minor radius, the two values are automatically switched:



I've also fixed the tooltip displaying bug - the hinter helper text is displayed only when the mouse is in the correct position and it's removed immediately afterwards.

Friday, September 21, 2012

Solver and constraints updated

Today I commited the changes for the solver, constraints and all the fixes I did since I started working on the new solver. Here is a quick overview of the changes:
- updated error calculation for constraints
- added gradient calculation for all constraints
- added a new solver algorithm and improved the existing one
- added matrix and vector helper classes
- improved the solver classes structure
- updated unit tests
- fixed some circle constraints bugs

There are some minor issues to fix and then we'll have a release, probably at the beginning of next week.

Friday, September 7, 2012

Circle constraints bug fixes

Over the past few days I fixed some bugs that I found when testing the new Solver algorithm.

It's now possible to lock and unlock the circle radius from the property grid:



and the shapes that are connected to a circle through a constraint can be changed:

Friday, August 31, 2012

Refactoring and dependency fixes

As I was working on the solver improvements, I decided to move the solver methods to a new class that would contain only the solvers and the related methods, and this lead to some interesting changes.

First of all, we have several unrelated 'Solver'classes. We have the GeometricSolver and derived classes, which are used with the Hinter, and the actual Solver which is for now in the Sketch2DSolver class. I've split these two and the new Solvers will all be in the SolverModule class. The constraints will be in a separate module, the ConstraintsModule.

After making these changes there were several problems caused by circular dependencies, mainly because helper methods and utility classes were using business logic layer methods. To solve these issues I used a great tool, NDepend.

It allows all kinds of queries related to assemblies/methods/types that are using and being used by a certain assembly/method/type and creates all sorts of useful graphs.
Here's for example a graph of direct and indirect callers for the new ConstraintsModule:


The dependency errors are fixed now, so I'll go back to working on the Solver, but after I'm done with that I'll do some more modules refactoring and ensure that everything is in the correct class, remove unused code and references.

Wednesday, August 22, 2012

Updating the tangent to circle constraint

As mentioned in yesterday's post, I'm updating the constraints so that their calculation in the solver is faster and the partial derivatives are calculated instead of being approximated as they are now.

A line tangent to circle constraint is equivalent to a point to line constraint, where the point is the center of the circle and, following the demonstration here we have the following formula for the constraint function:



For the partial derivative calculation we have two cases: where the variable doesn't appear in the denominator, and when it does. For the first case, the result is obvious. For the second case, we need to use these three formulas:




After applying these, we obtain:


which can be further simplified by using the old dx and dy notations:



the formula becomes:


and the sign is given by the value of the module evaluation (if the value inside the absolute module is negative, the entire expression is multiplied by -1 because we've been differentiating an absolute value.

With some small modifications, the same formula will be used for the radius tangent constraint and after a structure update for the point to line constraint, it will be used there, as well.

Tuesday, August 21, 2012

Improving the Solver

I am working on improving the Solver and investigating ways to replace (at least in some cases) the current algorithm which is based on the BFGS method with an algorithm based on the Gauss-Newton algorithm which should be easier to compute.

I'm also updating the error functions to simplify the calculations and adding the calculated values for the first derivative for each function: each of the point's coordinate is a variable for the Jacobian matrix and for each method we'll have several expressions to evaluate depending on the coordinate. I'll explain this in more detail when the algorithm will be finalized.

I've also added two helper classes for vector and matrix calculations - these should make the algorithm a lot easier to understand and make debugging a lot easier.

Thursday, July 26, 2012

Released NaroCAD 1.6.7 Beta

Today we released a new version of NaroCAD, which includes all the changes of the past month:
- Added constraints for points, circles, arcs and their combinations (an overview of all existing constraints is here)
- Added the fixed point constraint
- Added point to point constraint
- Added point to edge constraint
- Improved the Solver speed
- Fixed the code that handles constraints removal
- Fixed property grid bugs
- Added the posibility to view existing constraints (per shape or entire sketch)

You can download NaroCAD 1.6.7 here.

For the next release we'll work on improving the Solver's solution finding algorithm and processing speed.

Wednesday, July 25, 2012

Solver speed improvements

Over the last few days I did some investigations and improvements to the SolverRef method.

I did tests with several shapes and constraint combinations, and for each set of changes I compared the performance using a saved file and changing just one value, in the property grid. This ensured that I was comparing the performance on the same steps.
Here is one of the cases I tested:


When changing the height of the main rectangle (where the mouse cursor is) the performance of the old code is:


There are 21 calls to the Solver method, and most of the time was spent accessing array values and calculating the constraints. The main problem is that most of the matrices have the number of rows with non-zero elements equal to the number of free points, and total row/column count equal to the number of constraints.

After limiting the number of processed rows, checking for zero values used in multiplications and using the 'rough' convergence (1e-8 instead of 1e-10), the results improved significantly:


There are more improvements to be done for constraint calculation, and I want to investigate more efficient ways of doing the multiplications considering that they're most of the time sparse matrices.



Wednesday, July 18, 2012

Fixed point constraint fixes

Today I fixed two problems with the fixed point constraint. Now it's possible to view existing constraints after they've been added and they can be removed by clicking the point a second time.

I've also fixed a bug in the line editing handler action which didn't revert the line points to the original position if no solver solution was found.

You can find the changes here

Tuesday, July 17, 2012

Point to edge constraint and constraint viewer

Today I improved the property grid, added the possibility to view the existing constraints on the sketch or the selected node and improved the point to edge constraint. Tomorrow I'll work improving the point to edge constraint speed and bug fixing.



Monday, July 16, 2012

Arc improvements and point to edge constraint

I've imrpoved the arc angle constraint and added an arc panel for the property grid. The property grid now displays the arc radius, start and end angle (in degrees). The arc angle soft constraint is not fully fixed because we still need to project the point that wasn't modified by the solver and that affects the angle value.

I've also worked on implementing the point to edge constraint. For this constraint, a new point is added on the target edge, obtained by projecting the point on the edge. The resulting line (the original point and the projected point) should have a constant length and be perpendicular on the edge in the intersection point for the constraint to be satisfied. For a line this is easy to implement, and for other shapes we need to find the line that is tangent to the edge in the projection point and use that for the perpendicular constraint.

Thursday, July 12, 2012

Removing constraints

Today I fixed the code that removed soft constraints if no solution was found after they were added and fixed the code that allows the removal of generic constraints and the line length constraint.

The changes are here

Wednesday, July 11, 2012

Point to point constraint

Today I updated the point to point constraint to use the existing line length constraint (which I've modified to take any two points from the scene) and draw a Dimension for it.

Tomorrow I'll do some more testing, fix bugs and fix the code that handles the removal of existing constraints.

Tuesday, July 10, 2012

Line Lenght Constraint and Point to Point Constraint

Until now we had several ways of defining and displaying the distance between two points, with or without a constraint. Today I started changing the code so that we only use two elements for these:
- distance between two points constraint, which is effectively the current line length constraint
- the dimension function which displays the distance.

This way we'll be able to use the new constraint format and call the solver on all changes and display the length independently of the old Execute method. For now I've modified the code that adds a line length constraint and tomorrow I'll add the logic for the point to point constraint.

Monday, July 9, 2012

Property grid improvements

Today I added the arc start and end angle soft constraint, but it needs some more tweaking because of the way the solver modifies the arc points.

I've continued my investigation on the point to point constraint: it currently works for some cases, but because of the way the references are passed, doesn't work correctly for shapes which are already in a constraint.

I also fixed the property grid editing event, so that any changes are processed through the solver:

Friday, July 6, 2012

Line and arc radius soft constraints

Today I added the soft constraints for line length and arc radius. There are still some small problems for the line tangent to an arc constraint, but the resize visible in the original video is not quite as bad. I'll continue working on this and add the arc angle soft constraint.

As the problem was most obvious with concentric arcs, I recorded a video that shows the concentric arcs constraint applied without and with the arc radius soft constraint. All soft constraints will be applied automatically; if adding a soft constraint causes the sketch to be over defined, it will not be used.

Thursday, July 5, 2012

Circle and arc constraints

Today I fixed the arc constraint solve problem: as the solver only modifies the minimum number of values needed to find a solution, only one of the arc points was modified and updated, leaving the end point of the arc unchanged. I've added a fix that projects the end point on the new arc, obtaining the correct end point. The changes are here.

I started investigating the 'soft constraints' that would allow the shapes keep their main attributes (line length, circle and arc radius, arc start and end angle) after the solver is called. There are some constraints for line length and circle radius, but they're using the old structure and can't be used by the current solver, so the next step is porting these to the new structure.

I also recorded the constraints videos for the last two shapes:

The current constraints for circles are:
- concentric circles
- circles with equal radius
- point on circle (shown in the point video)
- line tangent to circle



The current constraints for arcs are:
- concentric arcs
- arcswith equal radius
- point on arc (shown in the point video)
- line tangent to arc



The current constraints for arcs and circles are:
- concentric arc and circle
- arc and circle with equal radius

Wednesday, July 4, 2012

Point constraints

Today I finished making the fixes for the parameters array, checked all the constraints and added the point on circle constraint. There is something wrong with the arc drawing after a constraint is applied, and the start point position isn't correctly displayed (the new correct position is used only when we start editing the shape). I'll fix this tomorrow.

Today's changes are here.

The current constraints for point shapes are:
- point on point
- point on line
- point on line midpoint
- point on arc
- point on circle

For now the editing behaviour for the point on circle and point on arc is different - in one case dragging the point moves the point, in the other it changes the radius. I'll return to this when the arc drawing issue is fixed.



Tuesday, July 3, 2012

Line constraints fixes

Today I realised there was a problem with the way the shapes are mapped to the parameters array and had to revert some of the code commited after the 1.6.6 release. The problem is that by mapping the shapes and their points, the order of the points returned from the DocumentToSolverAdapter is lost and the Solver doesn't update the correct values.

I've reverted to the initial code, where the points are stored and the constraint shapes reference the points, and fixed the lines constraints. I've made a list of all the checks for line constraints and recorded the current behaviour for all of them:

- a rectangle can be rotated and resized by dragging a corner
- we can add constraints to existing lines:
    * parallel
    * perpendicular
    * horizontal
    * vertical
    * equal length
    * collinear
- after drawing two parallel lines, any of them can be moved/resized by dragging any of the points
- after drawing parallel lines and fixing a point (adding a constraint point) dragging the other point causes the other line to be updated so that the constraint is maintained.

Monday, July 2, 2012

Updates to the constraints

Today I continued working on the constraints, updated the Fixed Points constraint to use the new structure and as all the constraints are converted, removed all the old code. There is still some cleaning up to do, but it involves more complex changes and I'll leave that until all the constraint issues are fixed.



I've also started working on the distance constraint, but before continuing with that I'll work on setting some 'soft' constraints to force line length to be kept if possible when solving (in this video you can see how the line being dragged changes size even if it doesn't have to).

You can find the changes here

Thursday, June 28, 2012

Updates to constraints

I've finished updating the arc and circle constraints to use the new constraints structure and updated it for all shapes. Now, instead of saving all the individual points for a shape, we only save the shape index and retrieve the points using offsets.
You can find the changes here.

The only existing constraint that wasn't updated is PositionToCenter, which I'll rewrite as a OneShapeConstraintMapping instead of the current separate mapping. I will also add some more one shape constraints (line length, arc angle, arc radius, circle radius) and improve the way points are loaded for point related constraints. There is also a problem with one of the arc points that isn't repainted correctly after the constrained is applied.

Wednesday, June 27, 2012

Released NaroCAD 1.6.6 Beta

Today we released NaroCAD 1.6.6 Beta, which fixes some installer problems (the options.nxml file is now saved in AppData and the installer doesn't set any global environment variables) and allows constraints to be added after shapes were drawn for lines and circles.

The new version can be downloaded here.

For next version we'll continue working on the 2D sketching:
- Adding new constraints after the shapes are drawn for arcs,
- Define and implement all enter/exit sketch situations,
- Improve property grid (add solver processing after property grid changes),
- Bug fixing.

Monday, June 25, 2012

Adding constraints to lines

I've started working on the constraint tool and now it's possible to add constraints to already drawn lines:



The next step is fixing the constraints for circles and arcs, which requires changing the old constraints to fit the new structure we're using for the solver.

Friday, June 22, 2012

Realeased NaroCAD 1.6.5 Beta

Today we released the 1.6.5 version of NaroCAD. This version is built against the previous version of wrappers, it should work on most operating systems.
As the wrapper issue is solved for the moment from now we'll release more often (every 2-3 weeks).

The new version can be downloaded form here.

In this version:
- Extrude is enabled and working on most cases,
- Reverted to the old wrappers that were generated using C++/CLI. These work on most platforms and don't leak,
- Improved the Trim tool,
- Improved the Hinter,
- Fixed the 2D Fillet and Chamfer tools.

For next version we'll focus mostly on enhancing the 2D sketching:
- Enable adding new constraints after the shapes are drawn,
- Define and implement all enter/exit sketch situations,
- Improve property grid (add solver processing after property grid changes),
- Bug fixing.

Thursday, June 21, 2012

Extrude completed

As the Extrude tool had some difficult to fix issues decided to reimplement it. Probably this is the 4th time Extrude is reimplemented, let's hope this is a version that will remain for a long time :)
Added also an Extrude animation that shows the height during drawing.

A movie that demonstrates some use case:

Trimming tool changes commited

Today I've commited the changes for the trimming tool, which in addition to the changes mentioned in yesterday's post, are:
- the hinter isn't displayed when selecting a shape to be trimmed
- the reffered by nodes are loaded using the same method that is used for the solver, DocumentShapesGraph.GetReferredByNodes

I also fixed a bug found when testing the trim tool: the LineParallelAxis constraint added a new point identical to one of the line's extremities. This caused wrong nodes to be deleted and some points disappeared from the scene even if they weren't actually deleted.

The changeset also includes all the commits that bxtrx did for the porting to old wrappers.

Wednesday, June 20, 2012

Update to trim tool

When trying to trim a shape that had a constraint, the constraint wasn't removed and the points from the original shape remained on stage. I updated the tool and now the constraints are removed, along with the original shape and its unreferenced children.

Another update was for the circle trim. Until now, trimming lines, arcs and circles was done in the same method, causing some problems because the circle doesn't have a start and end point that can be used as it's used for arcs and lines. I've added a new method to handle only circle trimming and I've added trimming for more than two intersection points:



I've also done a 'list' of all the tested cases and their results for the special cases:
- trimming line is parallel to one of the axes
- trimming line crosses the radius parallel to the ox axis (the intersection between this and the circle is the origin and end of the circle curve)
- trimming wire is another circle
- trimming wire is an ellipse -> here we have a problem because the open cascade method that determines the intersection points finds only one point and so the entire circle is deleted
- trimming wire is an arc





Tuesday, June 19, 2012

Moved back to the old wrappers

We released the NaroCAD 1.6.x versions using a new set of wrappers that were implemented using PInvoke. This set of wrappers had a few advantages like: they were portable to Linux, easier to debug, lighter at deploy time. Among the disadvantages of this set of wrappers there are: they are generated from the old wrappers so we don't have a generator that works directly with OpenCascade headers, on Release build we have some strange behavior that we didn't identify yet, also they are leaking. Example of strange behavior: IntAna_IntConicQuad.IsParallel returns false on Debug mode and true in Release mode.

As our current focus is fixing Naro and deploying stable versions of it and because at the wrappers it seems that there is a lot of work to be made we decided to switch back to the old wrappers that were generated using C++/CLI. Also this wrapper version has issues (like they are still generated for OpenCascade 6.3.0) but at least with this version we can release and fix Naro.

We have a Naro 1.6.5 version built with the old C++/CLI wrappers that seems to work well. Now bug fixing it and preparing for release.
In parallel as a lower priority task we'll also put some work on wrappers, the most important task being the update to OpenCascade 6.5.x version. By the way: OpenCascade released for public the 6.5.3 version.

Friday, June 15, 2012

Fillet and chamfer changes commited

Today I commited the changes for the fillet and chamfer tools. I've added a validation for the fillet, to make sure we never draw the major arc, covered the chamfer corner cases (lines parallel to the axes) and changed the code so that the existing lines' coordinates are updated, instead of creating new lines and hiding the old ones.

Wednesday, June 13, 2012

Chamfer length update

Today I updated the chamfer and fillet tool because of some problems with method that calculated the intersection points. In some cases, this returned no solutions, even though the lines had a common point.

I've also updated the chamfer tool to use the size window value for the new line's length instead of the helper circle's radius. To do this, I calculated the required radius that creates a segment of the desired length:



Tuesday, June 12, 2012

Updates to 2D fillet and chamfer

As I mentioned in last week's post about the 2D fillet and chamfer tools, they created new generic shapes that couldn't be edited or extruded. Today I updated the tools to create known shapes.

For the chamfer, the resulting shapes are three lines. The new line's extremities are obtained by building a helper circle, with the center in the two lines' intersection point and the radius equal to the chamfer's radius:




For the fillet tool we need to create an arc and two lines. To determine the arc's center, we draw two additional circles (magenta) with the fillet's radius and the centers in the intersection points obtained from the first circle (lime green):


Friday, June 8, 2012

Irregular shapes extrude

I'm working on the extruding of irregular shapes, which now works for all types of lines and shapes resulted from drawing and trimming:



There is a small problem with trimming and intersection points aren't handled correctly when extruding, so for now this shape can't be extruded. I'll continue working on these and as soon as they're fixed I'll commit the changes.






Wednesday, June 6, 2012

Circle and ellipse extrude

I've continued working on the extrude tool and now it works on circles and ellipses, as well. There are some problems with the orientation of the extrusion and in some cases the extrusion is not displayed until the base shape is clicked. I'll fix these issues and then start working on extruding shapes resulted from complex drawing/trimming.



Tuesday, June 5, 2012

Fillet and chamfer

I've started investigating the 2D and 3D fillet and chamfer tools, which create a rounded or square edge between two lines that have an intersection point. The 3D tools create the chamfer/fillet without updating the underlying shape and the 2D tools create generic shapes instead of arcs and lines, so these are the changes I'll be working on for these tools.

Thursday, May 31, 2012

Extrude tool

Today I started working on the extrude tool, which will be affecting all the closed shapes on a sketch:



For now this works only on rectangles, so the next step is to make it work on all the closed shapes in a sketch.

Wednesday, May 30, 2012

Trimming tests

Today I cleaned up the trimming code and added tests for the new trimming algorithm, checking that the resulting shapes are what's expected for the four 'known' shapes:
- line
- circle
- SER arc
- CSE arc

The changes are here

Tuesday, May 29, 2012

Trimming ellipses

For now trimming an ellipse creates a generic wire, because we haven't implemented ellipse arcs (yet). The resulting wire can be changed by moving the object that created the trim (the movement of the object triggers the original trim to be recalculated on the base ellipse and the wire to be re-drawn).



Next I'll update the unit tests, clean up the code and commit all the trimming tool changes.

Monday, May 28, 2012

Trimming a SER arc

For the SER arc trim we calculate the centre of the existing arc and then using this and the calculated intersection points we create one or two CSE arcs. In the video you can notice that the new arcs reference three points and can be edited like any CSE arc:

Trimming tool shapes

I've updated the trimming to remove not only the shape that was clicked, but also any points that were used by it and aren't referenced by another shape, and the tree view is updated now after each trimming action, to reflect the current shape list.

In the video you can see that the circles become arcs after the trim tool is used, and the Point nodes are added and then removed:



I've commited the hinter changes and what I have so far for the trim tool here.

Friday, May 25, 2012

Improvements for the trimming tool

Today I worked on improving the Trimming tool so that when we want to trim something, we only need to click on the wire to be deleted.
Until now, trimming created a new node that was a generic trimmed wire, regardless of the shape that was trimmed and how many resulting wires we had. That wire was defined by several u-values which are now transformed in points and used to build new nodes for the resulting shapes: trimmed lines always result in lines, circles and arcs result in arcs.



The lines changes were pretty easy, but things were a bit more complicated for circles and arcs. When trimming a circle, we need to know which one it is, the minor or the major arc, and that is determined by the position of the mouse click. There was also a special case caused by the way the circle's curve is stored: an auxiliary axis is used for each circle, with the origin in the center and the first and last point on its oX. When trimming on this axis, we need to make sure that the point on oX is associated with the u-values of 0 and 2*Pi.



CSE arcs can be drawn clockwise or counterclockwise, and this affects the u-values of the extremities. When drawing clockwise, the u-values corresponding to the start and end points have an extra 2*Pi added to them, while the intersection points and mouse click don't. This led to wrong intervals and caused strange arcs to be drawn.



I will continue working on the SER arcs, see what can be done to improve spline and ellipse trimming and update the trimming unit tests.

Thursday, May 24, 2012

Update

Did some improvements on the hinter so instead of looking for solutions on the entire scene it uses the axes and the last selected shape. You can see in the video that the line isn't snapping to the line parallel to the rotated triangle until we pass over it. After that, hinter lines are shown for the line parallel to the rectangle, as well as the lines parallel to the axes.



We're still working on the installation problem: the issue is not caused by missing dlls, but by the way the occ wrappers and the way they are built.
We're also working on the trim to tool, to improve the way the parts to be trimmed are selected and to return known shapes instead of a generic shape for all trimmed wires.

Tuesday, May 22, 2012

Hinter changes

We're currently working on fixing the installer issues and updating the hinter to find a common point if there is more than one solution.

For the hinter, we need to show all the hinter lines for a certain position and then find the common point for all the lines in the area. The mouse point will snap to that position, as it does now for parallel or perpendicular lines:


Tuesday, May 15, 2012

NaroCAD 1.6.3 and 1.6.4 dll problems

There are some cases where versions 1.6.3 and 1.6.4 don't work because of some missing dlls. I'm investigating the issue and will update the installers as soon as I find the cause.

Thursday, May 10, 2012

Released NaroCAD 1.6.4 Alpha


The big feature delivered on this new version is the Solver. The line tool uses a new Solver that started to work properly at an acceptable speed.
Replaced Rectangle tool with a rectangle having different constraints on it. The Solver can modify it now.
The new Solver supports: parallel, perpendicular, horizontal, vertical, point on  point and point on line constraints.
The new constraints are covered with unit tests, these can be used as coding samples.

You can download the new version here.

Next iteration the focus will be on improving the solver, making more fixes at the spline tool and if there is time maybe also enhance the trim tool. With these the 2D tools will be stabilized and we'll move on stabilizing the 3D ones.

Wednesday, May 9, 2012

Solver changes commited

I finished updating the constraint tests for the new solver and commited the changes. The current revision, which contains the solver changes and a few release fixes, is here.

Until all the constraints will be ported to the new structure, the old ones will remain and all the new classes will have an added 'Ref' to differentiate them from the old ones and the tests are only for the constraints that are currently implemented for the new solver:
- horizontal line
- vertical line
- parallel lines
- perpendicular lines
- point on point
- point on line

Aside from the constraints that I've showed here and here, the solver works on more complicated shapes:



Here we have three rectangles that have common corners. When one of the points is dragged, the constraints and related shapes lists are loaded - in this case, all the points are related to the point being dragged, but they are sorted according to their level and only the minimum number of points is changed.





Tuesday, May 8, 2012

Changes to the Solver

As I've mentioned in the previous post, the Solver used global objects to keep the references to the shapes that it was using in the solver method, updating them on the fly and sometimes leaving there NaN values.

I've modified the solver to use only the data that was passed in the parameters, fixing two issues this way: the points don't get to have NaN values for the coordinates and subsequent calls to Solve don't influence each other.

The new parameters list contains double values, which are the coordinates of the points and the constraints list contains the indexes in the parameters list, instead of actual values. Let's say we have two parallel lines, with the node indexes as shown:


The paramaters list will contain the coordinates for nodes 1,2,4 and 5:
parameters content: [ 3.0   6.0   1.0   1.0   8.0   5.0   5.0   0.0 ]
                    [ P1.x  P1.y  P2.x  P2.y  P4.x  P4.y  P5.x  P5.y]
indexes:            [  0     1     2     3     4     5     6     7  ]
The indexes will be used in the constraints list. To define that the line P1P2 is parallel to P4P5 we add a new constraint wich has two lines, defined by the point indexes:

L1 = new Line { P1 = new Point(0,1), P2 = new Point(2,3) }
L2 = new Line { P1 = new Point(4,5), P2 = new Point(6,7) }

When the constraint is calculated, the parameters list is passed - this makes it easier to debug and test the constraints code.

Using this structure, whenever the point position changes, the parameters value is changed, but the constraint stays the same and will always use the updated version of the coordinate.

If a solutions is found, the coordinates are automatically updated by updating the node, using an additional mapping between the parameters indexes and the shape index.

This new implementation replaces the old populate methods which were called for each free points number with one loading of the parameters and constraint build per action and doesn't require unmaping.

I'm testing this for parallel and perpendicular constraints on lines and updating the unit tests. As soon as I'm finished I'll commit the changes.

Friday, May 4, 2012

Solver issues

Over the last few days I've worked with the Solver and the helpers that are calling it from LineEditingHandler to get it to work correctly on several consecutive calls. For example, if we call the solver on a four line rectangle with two free points, we always get a solution. If we call it with no free points and immediately after that with 2 free points, we don't get a solution, because the global objects that are used to store the point references weren't properly re-initialized and no solution is found.

Re-initializing them for every call causes the solver to become too slow and there are some cases where the references are not properly updated, resulting in NaN values for the point coordinates.

I'm trying to change the Solver so that the global objects won't be changed and the results returned by it will be used to update the references only when a solution is found. This way the initializers wouldn't be called multiple times and we would avoid the NaN problem.

Friday, April 27, 2012

Rectangle update

In the last version, the rectangle was constrained to be parallel to the axes, which meant that it couldn't be rotated, and with two fixed points which didn't allow it to be resized properly. I've replaced these constraints with 2 parallel and one perpendicular constraint. After this change, the rectangle can be rotated and can be resized using any of the 4 corners.

Constraints with lines also work, so if we draw a line parallel to one of the rectangle lines and then drag one of the corners, it won't allow us to rotate the rectangle anymore.

Thursday, April 26, 2012

Solver, logger and tests updates

Today I commited the changes I had so far for the solver, and I will prepare a detailed explanation of how the solver works for the release.

Some of the main changes are:
- The shapes are ordered in the shapesList according to the level on which they are compared to the mouse point. The list has all the points, with the mouse position last, then any other shapes and constraints.
- The parameters and constraints are kept in an OrderedDictionary, which maintains the order in which the elements are inserted (Dictionary doesn't and SortedDictionary orders the elements by key).
- When editing a shape, the points are divided in two categories: free points, which are related to the point that is currently changed, and fixed points. Related points are those points which have the same ancestor on the shape reference list.
- When editing a shape, we try to find the solution with the minimum number of changed free points.
- When adding new shapes, there are no free points.

I've updated the constraint tests for the case when the lines are parallel to the y-axis. We check if two lines are parallel by comparing their slopes, but for lines parallel to the y-axis we had division by 0 or very large numbers. I've updated the method to return double.PositiveInfinity for this case and check for this value in the tests.

I've also updated the logger to write in the AppData folder and to save messages for NaroStarter.

There are several commits for these changes; the most recent one, which has everything, is here.

Wednesday, April 25, 2012

Solver update: replacing SortedDictionary

SortedDictionary was used for keeping solver related data, but because of the new ordering of the parameters I had to remove them. Initially I tried to replace only the shapeList SortedDictionary, but this causes wrong references to be passed to the Solver and no solutions are found. I've been working on updating all the other relevant SortedDictionaries and fixing the code that relied on those dictionaries being sorted.

There are still some more fixes to be done and a lot of testing. Until we get to more complicated shapes, here is how two parallel lines behave:

Monday, April 23, 2012

Solver update

The first step in updating the solver was changing it so it will modify only some of the parameters that are passed to it. In the old version, it changed all the parameters so that the difference for each coordinate was minimal. Now we'll specify which points can be changed and which not. The solve method will have one additional parameter, which will hold the number of free points, and the parameters list will be sorted to have the free points first.

The changes for the solve method are complete, and now I'm updating the ReferingNode method to use a generic way of correctly ordering the parameters and determining the number of free points.

Friday, April 20, 2012

Released NaroCAD 1.6.3

After almost one year we finally released a new version of NaroCAD. This version added some new fixes on 2D tools:

Fixed arc drawing (both CSE and SER),
The Edit Gizmo is resizing as we zoom in and out,
Fixed plane view change crash,
Fixed shape selection and editing,
Fixed the New File crash,
Updated the Trim tool to work on Circle,
Updated unit tests to use the new Sketch structure,
Added unit tests for the shapes that didn't have any.

You can download it here.

Next release is planned for May 4th. On this version we planned to add a new enhanced solver, more 2D tools fixes, Gizmo fixes.

Thursday, April 19, 2012

Updates to the editing handlers and solver

I've updated the editing handler zooming to be limited, so that when the stage is zoomed out too much (the axes aren't visible anymore) the handles won't be visible, either. It seems to be working ok this way, if there will be a need to customize this differently depending on the drawing we can add the parameters in the UI options. This update will be included in tomorrow's release.

We've also done some changes to the solver so that only specific points are changed, instead of all, and I'm currently working on the algorithm that sets which points should be changed. The solver updates won't be ready for tomorrow's release, but will be included in the next one.

Monday, April 16, 2012

Updating the solver

I've been working on updating the solver to better handle creating and editing lines (the only shape that is currently implemented using SketchActions). The solver returns solutions for the existing contraints, but at the wrong coordinates. This causes the shapes to move around when only one shape is being added or edited.
I'm working on converting the coordinates that the Solver returns so that for a line that is being drawn or edited, using a constraint, only the second line's coordinates are being changed.

The constraints that I'm working with are:
- horizontal and vertical line (parallel to the plane's axes)
- parallel lines
- perpendicular lines
- point on line

Wednesday, April 11, 2012

Editing handler and gizmo zoom fixed

When editing a shape, the editing handlers and gizmo didn't scale according to the zoom level, so if the zoom was different than the default they were too big, sometimes covering the entire shape, or too small and couldn't be used. I've updated the code to scale them according to the zoom level and to update the scale during zoom in or zoom out if a shape is already selected.

You can find the changes here and here.

Tuesday, April 10, 2012

New tests and new file crash fix

I'm working on improving the hinter and solver, but in the meantime I added some unit tests for the four line rectangle and arcs and fixed some small issues that I discovered while writing these. I've also started working on the spline tests, but they're a bit more complicated and I've postponed them a bit. The changes are here.

I've also fixed a crash that was caused by the sketch editing not being closed before opening a new file. The changes for this are here.

Thursday, April 5, 2012

Planning NaroCAD 1.6.3 Beta Release

Good news for NaroCAD users: we planned for April 20 to release NaroCAD 1.6.3 and hopefully after that version every 2-3 weeks we'll deliver a new version.

On 1.6.3 we'll focus on finalizing the Sketching concept and fix the 2D tools to work with it.

The new solver, porting to OpenCascade 6.5.x and fixing the 3D tools are postponed for next versions.

Wednesday, April 4, 2012

Trim tool fixes


The trim tool allows us to cut a part of a curve using another curve to define the start/end points. Using it, we can obtain complex shapes easily:


When doing a trim, we need to select the guide line, click on the Trim tool and then click on the part of the line that we want to be cut out (the two shapes must have at least one intersecting point). The trimming tool didn't work because the mouse click was sent as a Point3D instead of Reference and it was always (0,0,0). After changing that and enabling the code that actually retrieves the intersection points, trimming a line using another line as a guide worked, but more 'complicated' shapes didn't. The problem is that wrapper that returns the intersection points returns extra points, as well.

For a circle and line, for example, we get the two intersection points, as well as the points that are produced by the perpendicular to the drawn line:


To eliminate the extra points, I've added a check using ExtremaExtPC which checks if the points are on the line and only returns the two points we need.

After this change the circle trim works ok (and the unit tests pass) but there are some issues with trimming arcs and splines that I'm working on.
Another issue is when trying to apply a trim on a trim result, e.g. we trim a circle using a line and then we want to trim the resulting shape again, using another line.

The changes are here

Tuesday, April 3, 2012

Unit tests updated

I'm done with one batch of unit test updates, for the tests in MetaActionTests. Aside for the 3D related tests which are currently disabled/failing the 2D drawing tests are all passing. There are some tests that need to be added for the shapes that aren't currently covered (spline, arc and four lines rectangle) and there is a small issue with the Mirror line because of the way the axis is passed, but all tests use the current sketch / point reference structure.

There are three ways in which the shapes are 'drawn' in the unit tests:

- MetaActions-specific: we push the dependency objects to a MetaActionContainer object.
- using clicks: we add mouse clicks by calling setup.MouseInput.MouseDown and setup.MouseInput.MouseUp
- using NodeBuilder: we create a new nodeBuilder and add the needed dependencies, then call ExecuteFunction()

and depending on the shape type, we call one of the methods in ShapeBuildHelp.cs

After I'll add the missing tests I'll clean up the files and remove all old MetaAction related code that isn't used anymore and move the non-MetaAction tests in another solution.

You can find the changes here.

Monday, April 2, 2012

Still working on the tests

I'm still working on the unit test updates, but I'm almost done and hopefully tomorrow I'll be able to commit some of the changes. There are some updates because of the new shape structure, so the Point3Ds were replaced by references and the asserts were updated accordingly and some changes to the shape drawing methods because of the Action/MetaAction changes.

I've updated the code for the 3D shapes that used Circle as a base shape but didn't pass the correct parameters (torus, cylinder, cone). The tests for these don't pass yet, because of some solver related errors, but the shape drawing part is working.

I've also reverted to LineAction for line drawing (instead of SketchLineAction) and the solver works a lot better when multiple lines are drawn on the sketch. I've disabled the tests for ParallelLine and NormalLine as the tools are disabled - when/if we decide to reactivate them, I'll come back to tests and update them.

Now I'm working on updating the MirrorPoint and MirrorLine tests to fix the MetaAction specific code.

Sunday, April 1, 2012

NaroPAD - an update

I know is April 1st, you may know it too, but you don't know what you read and why to read it.
I will move the development forward of NaroPAD (a minimalist subset of NaroCAD framework) as a separate endeavor (as I don't have time to keep things in sync with NaroCAD codebase, as I'm involved with my life projects). If the team will want to use another name for NaroPAD (to not seem like a ripoff). When I will have time, I will write on a separate blog. So this is a farewell from NaroCAD (no prank), and wish to the team best of luck.

Thursday, March 29, 2012

Updating the unit tests

Before doing more changes I thought of checking the unit tests and what they're doing right now. There are several projects in the UnitTests folder, each of them containing groups of tests.

They all run using the nunit-x86.exe file that is in $(repPath)\Lib\NUnit\bin\ so the installed version of Nunit doesn't matter. To run each of them, simply set them as startup project and run. You might notice that some of them have the output type 'Class Library' and opening them from your own installation of Nunit doesn't work - they are set up to run from the project configuration panel, the Debug tab.

Today I worked on the tests in the MetaActionTests project. There are two ways of constructing the shapes there: adding mouse clicks and adding the dependecy objects. I fixed some of the tests that added mouse clicks and didn't use the new node structure and added some more asserts so it's clear not only how many nodes we're expecting, but also what they should be. For the other type of tests, the ProposeCandidate and PushValue calls from ShapeBuildHelp.cs need to be updated to use references and the tests need to be updated to use the changed setup object.