Friday, 26 April 2013

Drawing Updates & Bloodhound SSC


Pardon me for starting the post off-topic, but last night I went to a talk given by Richard Noble the director of Bloodhound SSC (below), aiming to achieve Mach 1.4 or 1000 mph (~1600km/h ). I freely admit it was an inspiring talk and especially given how little I knew from the small excerpts produced by IMechE - UK's institute for Mechanical Engineering, it provided to be very informative.
Bloodhound SSC
Why I raise this, is that one of the key emphases on the talk is about inspiring the next generation of Engineers not just in the UK but all over the world - akin to Nasa's Moon Landing Programme in the 60's. We share a responsibility as engineers to foster the development of the youth. Many open design such Raspberry Pi and Adruino  are sharing such successes involving children and young adults alike.

Without becoming too philosophical, FreeCAD would be part of this idealistic goal. Being able to provide free but importantly open tools that I never had when I was at school would bring opportunities I wouldn't have dreamt off - I was the one of the last generation at our school to produce hand-drawn drawings, which shockingly was only six years ago.

Ultimately if you cannot contribute to FreeCAD as a programmer, there are endless ways you could help and I wish to thank the members of our community for doing so without initiative!

Back on topic: Drawing Tweaks and Updates

Probably the biggest changes came last night and was most surprisingly because of the fact how tired I was. The Drawing View (QGraphicsView) updates itself when you change it's property, this includes dimensions too and surprisingly works very well. Additionally the drawings are correctly created when you restore a document. 

Hopefully I'll publish a video to better demonstrate this, because  find it a satisfying result.

The other changes is scale independent rendering, edges retain the same stroke width regardless of the document zoom.All this we get for (nearly) free in QGraphicsView! There's a problem with selection at the minute, but hopefully will be sorted out soon (Fixed). I don't believe this is easily done using SVG because transformations are applied at object level. 


The example of above scales as you would expect, which was scaled really small on my screen but is not desirable in CAD drawings. You don't want lines to obscure each other when you zoom in, especially on an extremely complicated part with greater detail such as below.



I've also added a scale option. This currently transforms the original FreeCAD Part, however, I am still unsure is the best approach in terms of performance which could be natively applied in the projection algorithm. However, now it appears to work correctly.


In the previous drawing module the scale was applied at the presentation layer in SVG and wasn't really the best solution although it worked.

I wanted to put a picture up but I am currently upgrading Kubuntu. It will most likely not go smoothly, but atleast I'll be ready to report any problems compiling with FreeCAD.

Taken a short screen cast to show off the Drawing Module in it's current state. Only had 15 minutes to make it this morning, so sorry for the lack of quality!



Note: The drawing artefacts appear when recording the video for some reason but otherwise are not there normally.


Saturday, 20 April 2013

Finally we have arcs that work!

For over a month this has been a problem where on 3D projections, arcs are turned into partial ellipses but were being incorrectly drawn. Attempts to diagnose the problem were unproductive - see the forum topic

There a sudden moments that make you realise that perhaps there is an easier way, just like last night. I though of mimicking the previous code that generates SVG directly. Instead of creating an actual ellipse arc, an cubic arc is produced instead - see the Mozilla Docs.For Qt to render SVG it must process this, so that there must be a method for drawing these somewhere. After some searching I found a function available in qsvg/qsvghandler.cpp. This had what I desperately needed and thanks to Opensource is possible.

Literally copy and pasting the relevant code - later will be re factored to be simplified if possible, this morning I got it working and produced the results I was craving!

This accomplishment crowns the ending of my Easter Vacation. I return to University tomorrow.

The couple of bigs tasks remaining are growing smaller. Ideally, I need the drawing to update automatically by itself, but changes don't propagate into non-3d views. Also we need working templates - looked at by Joshua.

The other is re-doing the export code - we get .svg and .pdf free with QGraphicsView, but .dxf.One thing I am going to enquire is an export to librecad. dxf sounds like the devil, so I think promoting an open format would go well.

The remainder should be smaller jobs that other people could get involved with. By then I hope I could get this be ready for testing by mid-summer. 

Thursday, 18 April 2013

Little updates

Spent the past few days tidying up the Drawing Module as a needed break from revision.


It is starting to come together:

  • Added support for radius dimensions on arcs.
  • Added support for point to point dimension
  • Improved selection of edges and vertexes
  • Antialiased Edges
For an hour I spent adding a nicer selection box for moving a views around which definitely helps prevent annoying selection of the view. 


Dimensions are coming together too quite nicely, although the radius dimensions don't work yet in 3D view. I probably add some arrows, but these are not high priority. 



I've started the work on correctly showing hidden lines. I am pretty pleased with the result. I have opted for selecting the whole edge (visible and hidden), hopefully that seems reasonable.



I was slightly disappointed to find that references for some edges cannot be find in 3D views, however is a limitation imposed by Open Cascade. If a reference cannot be found, these edges are not selectable, since they cannot be used for any measurements. One possible idea to circumvent this problem is to compare the projected edges with references to edges on the original geometry that weren't found. This isn't really ideal, but would be a temporary solution.

One of the other problems is ellipse arcs which still I cannot figure out.

Friday, 12 April 2013

Parametric dimensions in the Drawing Module


After about three weeks, of having to work on various assignments (nearing completion) and revision, I finally had a day off to work on dimension support in the Drawing Module (see above and compare to previous post).

Obviously the dimensions look much better and are correctly positioned and it also shares similar behaviour to sketcher where if the datum label lies outside the arrow lines change position accordingly.

Additionally the dimension can be set to the edge length in X or Y direction now quite easily by changing the dimension mode. Currently the dimensions only work for Straight Line edges, but I plan to address some support for vertexes and obviously circular arcs.

One of the interesting things that had to be thought was how to reference edges that are broken up into smaller segments by any geometry in front.


My first attempt at this failed miserably, where I thought I would reference each segment of the edge and find the ends from there but clearly it wouldn't work. After scratching my head, I thought the best way to go was getting the reference to the original geometry and projecting the whole edge and using this instead for dimensions.

The limitation with this strategy is that if the original reference isn't available you won't be able to get true parametric dimensions. Generally this isn't a problem - nearly all the time I have found references are available and if they aren't usually it is for curves projected onto a 3D view.

It was a bit of work to get to work, because I was using HLRBrep_Curve and that require figuring out what type of curve was produced when finished. I kept to this OpenCascade Algorithm to allow perspective projections if they were ever needed. Luckily it worked!

Behold Parametric Dimensions!

The big test really was to change the projection direction and see what happens...


And yes it worked - although the datum label positions need correcting, nothing else had to be changed. Now changing the geometry (nothing too drastic)...



It's a pleasing result because it's been several months in the works to get this working, not knowing if this would be even possible. Obviously there's a lot left to do.One of my biggest problems at the minute is that if there are changes in the Document Structure, the drawing view must be closed and re-opened

The next priority is to tidy the module up more as it's still feels experimental.



Sunday, 17 March 2013

First step of having DImensions in Drawing Module


Spent today working on adding dimension support. The first results are in and are quite pleasing. The dimension lines aren't correct but do indeed move interactively and the values for the dimensions update with changes basic changes in geometry. Obviously this is no where near being done, but is a step in the right direction once again.

-----
One area that does become problematic is making large changes in the geometry, and will be quite troublesome to deal with, even with robust naming. This should be a problem with vertices. because they cannot be decomposed further. 

Currently dimensions refer to the individual projected edge, or vertex because in theory multiple projected curves could exist. This needs further thought, but perhaps the best solution is consider merging projected edges together which share the original reference to the object and then having dimensions refer to these instead. Any ideas? 


Friday, 15 March 2013

Projecting Points - Drawing Module


Having started on dimensioning support I stumbled across quite an obvious problem, how would I do point to point  Dimensioning. Obviously I could extrapolate the points from the edges and use these, but any changes in the Base FreeCAD model and your dimensions would very easily mess-up. 

I started thinking about this last night and indeed to support such dimensioning modes with parametric relations, the points would have to be projected from the base FreeCAD model. I hit a brick wall trying to figure this out last night, but suddenly it came to me this morning. Sleep is a powerful thing. 

All I had to do is use the Projector algorithm to project points from project curves and then check if these can be referenced to the original object by checking if the topology exactly matches. 

The result is the above, all the points are recognised from the original object and now means we can in theory reference these. It is slightly dumb at the minute, because it projects points from all the edges (even if they are hidden). However, it should be trivial to fix this. 

Obviously in the GUI, the points will be hidden until an appropriate tool is used but is a step in the right direction indeed!

Easter break officially begins today and hopefully will have a helper who can assist me on the Drawing Module too *fingers crossed. 

Thursday, 14 March 2013

Further work on Measurements Framework

I've spent a bit more time and adding more measurement tools that should be quite useful now for querying geometric properties of FreeCAD objects. This now includes measuring the
  • total length of selected edges
  • shortest distance between point and edge
  • shortest distance between point and face
  • radius of an arc or circle

Also now we can calculate the centre of mass for a selection of objects in a straightforward manner:



Fundamentally these were quite easy to calculate as they are provided by Open Cascade essentially for free and therefore it hasn't been very difficult to implement this.


Since the essential functionality is already there, the next step is to integrate this with the Drawing Module. This should hopefully be the start a dimensioning tool!

Hopefully I can push this onto Git for people to try during the weekend.


In slightly unrelated news to FreeCAD: I have finally received some funding for an interesting expedition that I will be attempting once finished University in June. Under this premise I do hope to continue working on FreeCAD as I will still be in civilisation and should have enough time to make smaller contributions and experiments that may be useful. It would be interesting to see if it would be possible to develop this on the go. Anyway we will have to see!




Saturday, 9 March 2013

First signs of measuring

I spent last night putting something rudimentary together for this Measurement module to see how it will work. Surprisingly, I was up till 1:30AM probably because of a sugar high brought on by making chocolate cake last night. Nevertheless I was up bright and early to finish off my work from last night, and already we are bearing results:



Below 'Import Measure' are the commands used for making a measurement, hopefully it seems quite logical:

The output works correctly and fortunately when the geometry in the FreeCAD object does change, taking a new measurement does indeed return the correct result.

My only concern at the minute is whether it seems a good idea to bundle so many different measurements together in one package, even if the correct mode can be chosen and when the selection is incorrect an error is politely thrown to the user.

I guess in reality, this is more of a convenience solution to provide parametric measurement for most important measurements that both the user and in the case of Drawing Module may need.

What are people's thoughts?

Thursday, 7 March 2013

Measurements Framework: (Plan of Action)

Having some further thought on making the measurement framework, my overall idea is that this should be very accessible to a novice user either using the command line or the GUI. Simplicity is key. Specifically the user should be able to specify a set of geometric features: edge or points and the measurement framework figures the rest out - that's the plan atleast!



This could be extended to gather more complex information such as surface area when specifying a face for the measurement or perhaps retrieving the moment of inertia or mass, for a given FreeCAD part. 

Querying Information:

This builds up a quite complex cases, but what I think would be eventually be a good idea is to create an extensible approach, so that plugins could be called to provide extra methods when querying a set of features. This is over-kill at the minute, but could be interesting. 

If a particular query cannot be made - e.g. querying the surface area of an edge an Exception will be thrown. Potentially this means we could introduce annotations that can reference the measurements and appropriately display output: e.g. 'Volume of My FreeCAD object: myMeasurement.volume()'

Building Annotations and Dimensions

Making use of measurements can be temporary, (whether in the command line or GUI). Using an object to store this information with reference properties means that these can be parametric hence update automatically. This means we should be able to pass this Measurement Object to a Dimension Feature and it can automatically create this and be absorbed into the Document. 

The Dimension Feature will be an Annotation Feature which will provide a more extensive coverage of options such as tolerances, dimension line type etc. These Dimension Features could in theory be used in the Drawing Module or in any other area of FreeCAD or atleast I would hope. 

Hopefully this sounds good!

Now it's time to shut up and time to start coding!




Tuesday, 5 March 2013

Thoughts on making Measurements

After having some troubles with projected faces (dealing with correct wire orders)  for the mean time I have considered looking at measurements or the ability to add parametric dimensions to drawings. These are dimensions which will update with geometry accordingly.

With some discussion on the forums about this: further discussion encouraged the idea for a generic measurement framework which would be useful throughout FreeCAD to make useful parametric dimensions and 'temporary' measurements which are common place inside most CAD packages.

Temporary measurement is a tool that provides a quick and convenient method to check the length of an edge or the distance (including components) between two points. These points use geometric references to provide a more accurate measurement unlike previously.

Parametric dimensions are more permanent and would be stored inside the Document as a feature or an annotation in the Drawing Module.

The Measurement framework aims to take a set of geometric entries such as line edge or two points and calculate the distance between them using a given vector. This is fairly simple stuff, but having a centralised framework would allow it to be adopted in other areas in FreeCAD, namely the Drawing Module for providing dimensioning support. it is in fact possible to calculate this from the projected shapes inside Drawing but using the previous reference geometry provides a means of obtaining the 'true' value for the geometric feature and will adapt to changes to the 3D Part more sensibly. However, in the future there could be an option for using projected lengths. 

Eventually, I would imagine this can be extended for displaying and calculating more complex properties such as moment or inertia, centre of mass etc. For the time being the measurement framework will only provide a c++ and python framework. The focus for the interface is simplicity - where it will specify the geometric features used and should then be able to determine measurement. There will be most likely ambiguous cases so giving an option to override this seems sensible.

In the Drawing Module  my aim is to apply a similar philosophy of creating dimensions using one tool; some people don't prefer this understandably, so there will tool bar and menu options for creating specific dimension types. In most cases this will allow convenient dimensioning.

I still need to figure out including point contacts since these are not explicitly projected by OCC and are contained inside the edge data.

This was slight regurgitation of thoughts I had on this before I attempt to start so apologies if this wasn't written well.

+ Checking out the current state of the Drawing Module:

I figured that it would be good idea to share my progress so far and allow people to contribute. The module is no where near ready for any testing - so please don't point out the obvious if something's broke. If there are any users interested in helping develop I would be more happy to take feedback and contributions to help with development!

Please checkout the github repo:
https://github.com/mrlukeparry/FreeCAD_sf_master/tree/drawing