Bounding bounding boxes

Today, and a little bit of yesterday too, were involved in a bit more geometry-related than most of my FreeCAD time so far. That’s a good thing, I think, but a bit tedious at times.

Without getting too far into boring details, there were some problems in the Drawing module, which boiled down to objects having bounding boxes that weren’t centred on the origin of their coordinate space. This is a problem because the position of things displayed on the screen (eg one of the orthographic views), is calculated in part based on the object’s bounding box, which is assumed to be centred on the origin of the object’s coordinate space. So, with the bounding box origin changing, the position of the object would in turn change, and make things move around on the screen in odd ways.

Getting a little closer to boring details, the issue was that a scaling operation used the wrong origin – the objects were being projected to 2D, then scaled using the origin of the original 3D coordinate space. Result is the top situation, where the scaling operation “pushes” the object off to the upper-right. The solution is just to be mindful that the operations are combined properly, so that the scaling uses the centre of the object as the origin.
bb scaling issue

The patch behind the orthographic projections post basically corrected for this error at a later stage, so now that fix is unnecessary and future work will hopefully be a bit more intuitive! That’s how it goes though; it took a “first draft” solution to see what the problem actually was, then the final draft got a better solution, but obsoleted the first.

Have also put a few hours in to work on the file opening stuff – the patch I submitted has some issues on Windows (unicode…), and so have put together another version. Unfortunately, the second iteration involves some changes to an “external” (quotes as it wasn’t written specifically for FreeCAD, but is packaged with FreeCAD’s source code) open source library, so not sure how that’ll go over. It’s a really annoying problem; basically the issue is just that we can’t confirm the filename of the first file stored in a zip file…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s