<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Biosystems Engineering Blog (Posts about gsoc)</title><link>https://kwk.systems/blog/</link><description></description><atom:link href="https://kwk.systems/blog/categories/gsoc.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:info@kwk.systems"&gt;Kurt Kremitzki&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-SA"
style="border-width:0; margin-bottom:12px;"
src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Thu, 16 May 2024 22:41:32 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>GSoC Week 5 recap</title><link>https://kwk.systems/blog/posts/gsoc-week-5-recap/</link><dc:creator>Kurt Kremitzki</dc:creator><description>&lt;p&gt;This week started out with some interesting discussions on the future Python structure of FreeCAD, over
&lt;a class="reference external" href="https://forum.freecadweb.org/viewtopic.php?f=10&amp;amp;t=23197"&gt;on the forums&lt;/a&gt;. This was especially salient
as I have a bit of pain interacting with parts of the FreeCAD Python API and improvements to it would
be a good long-term goal after finishing GSoC.&lt;/p&gt;
&lt;p&gt;I decided that the &lt;code class="docutils literal"&gt;TestPartDesignApp.py&lt;/code&gt; file I had been working in thus far needed splitting up,
as I was cramming almost every new test into it.
The &lt;a class="reference external" href="https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/PartDesign/TestPartDesignApp.py"&gt;new version of this file&lt;/a&gt;
is a pretty nice indicator of the overall status of PartDesign test coverage.&lt;/p&gt;
&lt;p&gt;I also added some basic tests for datum tools, covering simple creation scenarios. While exploring the 4th datum
tool, &lt;code class="docutils literal"&gt;ShapeBinder&lt;/code&gt;, I found a bug that causes a crash, so I will need to look into that shortly to see if it's an
easy fix.&lt;/p&gt;
&lt;p&gt;&lt;code class="docutils literal"&gt;LinearPattern&lt;/code&gt; and &lt;code class="docutils literal"&gt;PolarPattern&lt;/code&gt; got 6 new tests each, covering all the major variations of sketch-
or primitive-based features.&lt;/p&gt;
&lt;p&gt;Finally, I added one new test for each of the dressup features, &lt;code class="docutils literal"&gt;Fillet&lt;/code&gt;, &lt;code class="docutils literal"&gt;Chamfer&lt;/code&gt;, &lt;code class="docutils literal"&gt;Draft&lt;/code&gt;, and &lt;code class="docutils literal"&gt;Thickness&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Here's the pull request summarizing my work: &lt;a class="reference external" href="https://github.com/FreeCAD/FreeCAD/pull/869"&gt;https://github.com/FreeCAD/FreeCAD/pull/869&lt;/a&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th class="head"&gt;&lt;p&gt;tool category&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;initial, current test count&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;status&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;notes&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;datum tools&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 3&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;found shapebinder crash bug&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;add. &amp;amp; sub. features/primitives&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;15, 15&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;transformations&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;3, 15&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;all done but MultiTransform&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;dressup features&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 4&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;boolean operation&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 0&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description><category>freecad</category><category>gsoc</category><guid>https://kwk.systems/blog/posts/gsoc-week-5-recap/</guid><pubDate>Tue, 11 Jul 2017 19:45:35 GMT</pubDate></item><item><title>GSoC Week 4 recap</title><link>https://kwk.systems/blog/posts/gsoc-week-4-recap/</link><dc:creator>Kurt Kremitzki</dc:creator><description>&lt;p&gt;I started this week out with the goal of troubleshooting the bugs I found with PartDesign Pipe and Revolve.
However, I ended up running into several annoying issues. The LLDB debugging integration I previously wrote about
began showing some inexplicable errors:&lt;/p&gt;
&lt;pre class="literal-block"&gt;error caught in async handler 'exec ('continue',)'
Traceback (most recent call last):
  File "/home/kurt/.config/nvim/bundles/repos/github.com/dbgx/lldb.nvim/rplugin/python/lldb_nvim/__init_
_.py", line 49, in _exec
    self.ctrl.safe_execute(args)
  File "/home/kurt/.config/nvim/bundles/repos/github.com/dbgx/lldb.nvim/rplugin/python/lldb_nvim/control
ler.py", line 101, in safe_execute
    self.safe_call(self.exec_command, [cmd])
  File "/home/kurt/.config/nvim/bundles/repos/github.com/dbgx/lldb.nvim/rplugin/python/lldb_nvim/control
ler.py", line 94, in safe_call
    raise EventLoopError("Dead event loop!")
EventLoopError: Dead event loop!&lt;/pre&gt;
&lt;p&gt;Eventually I found &lt;a class="reference external" href="https://github.com/dbgx/lldb.nvim/issues/52"&gt;an issue on Github&lt;/a&gt; which refers to
a now-deleted comment in the author's original repository, stating the project was no longer being developed.
The question remains as to how it was working just fine when I began and only just now stopped working, but
the end result was that my debugger-editor integration was broken, which makes it quite a bit tougher to debug
the C++ side of the codebase.&lt;/p&gt;
&lt;p&gt;One option I had was to just use GDB as a standalone command line application, but it's really convenient, e.g.
to not have to manually type out file names and line numbers for breakpoints, and otherwise have your debugger
wired up to your editor.&lt;/p&gt;
&lt;p&gt;However, this was inexplicably not working either! Basic features of GDB worked, but trying to specify breakpoints
to step through the code was not. I banged my head on this issue for a while until I figured up &lt;code class="docutils literal"&gt;ccmake&lt;/code&gt; to
take a look at my build options. The issue? Somehow, the &lt;code class="docutils literal"&gt;CMAKE_BUILD_TYPE&lt;/code&gt;, which had been set to &lt;code class="docutils literal"&gt;Debug&lt;/code&gt;,
was unset. So, I set it again and started the debug build, which takes quite a long time.
(Around 2 hours with &lt;code class="docutils literal"&gt;make &lt;span class="pre"&gt;-j4&lt;/span&gt;&lt;/code&gt;.)&lt;/p&gt;
&lt;p&gt;I also did more research on options for debugger integration. I found an interesting option called Pyclewn
which is a debugger front-end for (neo)vim. This option was attractive since I could have a unified front-end
to both my C++ debugger as well as a Python one. However, setup wasn't straightforward, so I continued searching
for a simpler option.&lt;/p&gt;
&lt;p&gt;Luckily, I stumbled upon &lt;a class="reference external" href="https://github.com/neovim/neovim/blob/master/contrib/gdb/neovim_gdb.vim"&gt;neovim_gdb.vim&lt;/a&gt;,
a simple combination of vim settings, available in the &lt;code class="docutils literal"&gt;contrib&lt;/code&gt; folder of the neovim repository.&lt;/p&gt;
&lt;p&gt;Once that was taken care of, I started working on my original objective for the week. I found that the
PartDesign Pipe issue was being caused by the code checking for whether or not the Pipe's AuxillerySpine (sic)
was a part of the active body, but didn't check if the thing existed first. This resulted in a check to
see if a null pointer was part of the active body, which is never the case. Checking for existence first
&lt;a class="reference external" href="https://github.com/FreeCAD/FreeCAD/pull/848"&gt;resolved the issue&lt;/a&gt;. With that bug fixed, I also added
two tests each for PartDesign Pipe and Loft.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th class="head"&gt;&lt;p&gt;tool category&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;initial, current test count&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;status&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;notes&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;datum tools&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 0&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;add. &amp;amp; sub. features/primitives&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;11, 15&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;all additive &amp;amp; subtractive
features now have at least
one test&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;transformations&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;3, 3&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;dressup features&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 0&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;boolean operation&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 0&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description><category>freecad</category><category>gsoc</category><guid>https://kwk.systems/blog/posts/gsoc-week-4-recap/</guid><pubDate>Fri, 30 Jun 2017 10:48:06 GMT</pubDate></item><item><title>GSoC Week 3 recap</title><link>https://kwk.systems/blog/posts/gsoc-week-3-recap/</link><dc:creator>Kurt Kremitzki</dc:creator><description>&lt;p&gt;Howdy! I wasn't sure of the best way to represent my progress thus far, but I figure a table is an alright way to summarize.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th class="head"&gt;&lt;p&gt;tool category&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;initial, current test count&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;status&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;notes&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;datum tools&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 0&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;hold&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;waiting on attachment
editor work in phase 2&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;add. &amp;amp; sub. features/primitives&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;3, 11&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;blocked&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;basic Pipe not working; when
fixed, all tools in this
category (but not all their
options) will have test
coverage&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;transformations&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 3&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;Mirrored added, still need
Linear and PolarPattern&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;dressup features&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 0&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;boolean operation&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0, 0&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;ready&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;Previously seemed to
misbehave but recent changes
to containers may have fixed
this&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I got my Pad &amp;amp; Pocket tests added, so right now the total Δtests is 11. Next up is Loft and Pipe. However,
Pipe has a bit of a blocking bug right now. My test scenario involves a simple circle centered at the origin
in an XY-attached sketch, serving as the base Profile, and a simple line on the Z axis in an XZ-attached sketch.
The test construction is illustrated in figure 1.&lt;/p&gt;
&lt;p&gt;This should result in a cylinder, as the preview indicates in figure 2. For some reason, when clicking OK,
an external reference warning is being generated, and this is blocking any test constructions for PartDesign Pipe.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="test pipe construction" src="https://kwk.systems/blog/images/gsoc-3-3.png" style="width: 300px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 1. PartDesign Pipe Profile and Spine sketches which should form a simple cylinder.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="external reference warning" src="https://kwk.systems/blog/images/gsoc-3-4.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 2. PartDesign Pipe erroneously warning about external references.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;I also ran into a bug in PartDesign Revolve, which, as bugs are wont to do, ended up being two bugs.
The construction case to see them is depicted in figure 3.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="revolution sketches" src="https://kwk.systems/blog/images/gsoc-3-1.png" style="width: 300px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 3. Simple sketches attached to the three base planes.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;I attached a simple circle sketch to each of the three base planes, and offset them so they wouldn't be symmetric
with respect to the origin or any base axes. When attempting to add a Revolution with these sketches, they behave
as expected, until one attempts to revolve them about the axis which is normal to the sketch's plane. For the
XY- and YZ-attached sketches, the following error appears:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Rotation axis must not be perpendicular with the sketch plane&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;However, if one tries to revolve the XZ-attached circle, FreeCAD gives it the ol' college try, but
ends up with an awfully thin "solid":&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="faulty revolution" src="https://kwk.systems/blog/images/gsoc-3-2.png" style="width: 300px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 4. An "error-free" PartDesign Revolution.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;I'll also be looking into these bugs this week.&lt;/p&gt;</description><category>freecad</category><category>gsoc</category><guid>https://kwk.systems/blog/posts/gsoc-week-3-recap/</guid><pubDate>Thu, 22 Jun 2017 16:15:49 GMT</pubDate></item><item><title>GSoC Week 2 recap</title><link>https://kwk.systems/blog/posts/gsoc-week-2-recap/</link><dc:creator>Kurt Kremitzki</dc:creator><description>&lt;p&gt;With the four major bugs blocking the usage of &lt;code class="docutils literal"&gt;PartDesign Mirrored&lt;/code&gt; fixed,
I started out the week exploring the now-functioning tool with the goal of getting what I call "command test coverage".
In short, this means testing major variations for tools presented to the user in the PartDesign WB.&lt;/p&gt;
&lt;p&gt;For reference, they are depicted and categorized in figures 1 and 2,
with the newly redesigned icons made by &lt;a class="reference external" href="https://github.com/agryson"&gt;Alexander Gryson&lt;/a&gt; (kudos to his major rework of all of FreeCAD's icons!)&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="command palette" src="https://kwk.systems/blog/images/gsoc-2-1.png" style="width: 900px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 1. Datum tools, additive/subtractive features and primitives.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="command palette" src="https://kwk.systems/blog/images/gsoc-2-2.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 2. Transformations, dressup features, and multi-body boolean operation.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The Mirrored tool takes as input feature(s) and a mirror plane, but the other transformation tools like LinearPattern and PolarPattern behave in a fundamentally similar way.
By that reasoning, I figured that tests regarding the Mirrored tool really only have two major permutations if one assumes valid input:
the case where a choice of features and plane succeeds, and one where it doesn't.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="mirrored success" src="https://kwk.systems/blog/images/gsoc-2-3.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 3. Success!&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="mirrored failure" src="https://kwk.systems/blog/images/gsoc-2-4.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 4. Failure...&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;So, I cleaned up the test case submission I started GSoC out with, &lt;code class="docutils literal"&gt;testMirroredSketchCase&lt;/code&gt;,
and added the new case depicted in figure 4, &lt;code class="docutils literal"&gt;testMirroredOffsetFailureCase&lt;/code&gt;.
However, I noticed both of my test cases involved &lt;code class="docutils literal"&gt;Sketch&lt;/code&gt;-based additive features, but no additive primitives.
So, I also included &lt;code class="docutils literal"&gt;testMirroredPrimitiveCase&lt;/code&gt; in &lt;a class="reference external" href="https://github.com/FreeCAD/FreeCAD/pull/816"&gt;FreeCAD PR#816&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What's nice is that besides &lt;code class="docutils literal"&gt;PartDesign Mirrored&lt;/code&gt; now being fixed, several other transformation tools' bugs were resolved.
Altogether, the PR resolved four issues, &lt;a class="reference external" href="https://www.freecadweb.org/tracker/view.php?id=2235"&gt;2235&lt;/a&gt;,
&lt;a class="reference external" href="https://www.freecadweb.org/tracker/view.php?id=2248"&gt;2248&lt;/a&gt;, &lt;a class="reference external" href="https://www.freecadweb.org/tracker/view.php?id=3006"&gt;3006&lt;/a&gt;,
and &lt;a class="reference external" href="https://www.freecadweb.org/tracker/view.php?id=3065"&gt;3065&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With all that wrapped up,
I moved on to adding tests for the various options for the fundamental sketch-based features &lt;code class="docutils literal"&gt;Pad&lt;/code&gt; and &lt;code class="docutils literal"&gt;Pocket&lt;/code&gt;.
Altogether, I added &lt;code class="docutils literal"&gt;testPadToFirstCase&lt;/code&gt;, &lt;code class="docutils literal"&gt;testPadtoLastCase&lt;/code&gt;, &lt;code class="docutils literal"&gt;testPadToFaceCase&lt;/code&gt;,
and &lt;code class="docutils literal"&gt;testPadTwoDimensionsCase&lt;/code&gt; to cover the options for &lt;code class="docutils literal"&gt;PartDesign Pad&lt;/code&gt;.
Unfortunately, these test cases are not very interesting to look at and mostly involve 2-4 lined up cubes similar to
what figure 3 looks like.&lt;/p&gt;
&lt;p&gt;However, for &lt;code class="docutils literal"&gt;PartDesign Pad&lt;/code&gt;, things do get a little more interesting.
The base case is a simple reversed pad with a pocket in the middle, shown in figure 5.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="mirrored failure" src="https://kwk.systems/blog/images/gsoc-2-5.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 5. The base Pocket test construction.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;It was straightforward to add &lt;code class="docutils literal"&gt;testPocketDimensionCase&lt;/code&gt;, &lt;code class="docutils literal"&gt;testPocketThroughAllCase&lt;/code&gt;,
and &lt;code class="docutils literal"&gt;testPocketToFirstCase&lt;/code&gt;.
However, covering the last Pocket option with &lt;code class="docutils literal"&gt;testPocketToFaceCase&lt;/code&gt; is not (necessarily) so trivial.&lt;/p&gt;
&lt;p&gt;If you refer to figure 5, you'll note that the base Pad feature is a hexahedron, or six-sided shape.
The Pocket feature adds four new faces to the overall shape, &lt;code class="docutils literal"&gt;Face7&lt;/code&gt; through &lt;code class="docutils literal"&gt;Face10&lt;/code&gt;.
However, references relying on the numbering of those faces is inherently brittle and it turns out that
a particular face number OpenCASCADE &amp;gt; 7.0 does not correspond to the same face in a lower version, e.g.
the version used on the FreeCAD CI machines over at Travis.&lt;/p&gt;</description><category>freecad</category><category>gsoc</category><guid>https://kwk.systems/blog/posts/gsoc-week-2-recap/</guid><pubDate>Sun, 18 Jun 2017 23:40:33 GMT</pubDate></item><item><title>GSoC Week 1 Recap</title><link>https://kwk.systems/blog/posts/gsoc-week-1-recap/</link><dc:creator>Kurt Kremitzki</dc:creator><description>&lt;p&gt;The first week of Google Summer of Code has ended, and so it's time for a recap post!&lt;/p&gt;
&lt;p&gt;The main topic this week was &lt;a class="reference external" href="https://www.freecadweb.org/wiki/PartDesign_Mirrored"&gt;PartDesign Mirrored&lt;/a&gt;, a fairly self-explanatory feature,
with a show-stopping bug explained in &lt;a class="reference external" href="https://freecadweb.org/tracker/view.php?id=3006"&gt;FreeCAD issue 3006&lt;/a&gt;.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="unit cube construction" src="https://kwk.systems/blog/images/gsoc-1-1.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 1. The base of my PartDesign Mirrored experiments.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;In this picture, we have a simple &lt;code class="docutils literal"&gt;1 mm&lt;/code&gt; square sketch (pictured in white) attached to the &lt;span class="math"&gt;\(xy\)&lt;/span&gt;-plane.
One corner is at the origin, and the sketch is the base for a Pad feature &lt;code class="docutils literal"&gt;1 mm&lt;/code&gt; high.
Length is handled internally as &lt;code class="docutils literal"&gt;mm&lt;/code&gt; by FreeCAD, so this "unit cube" serves as a useful basis for testing behavior.
A useful alteration involves displacing this cube, say, &lt;code class="docutils literal"&gt;1 mm&lt;/code&gt; up the &lt;span class="math"&gt;\(y\)&lt;/span&gt;-axis.
This constructs a case where mirroring not all mirrorings should succeed, but we'll get into that later.&lt;/p&gt;
&lt;p&gt;Let's turn now to the bug itself, depicted in figure 2.
The unit cube is supposed to be mirrored about its vertical sketch axis (the &lt;span class="math"&gt;\(y\)&lt;/span&gt;-axis, pictured running off to the top right.)
Obviously, it's not, and the failure is helpfully represented in red.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="mirroring bug" src="https://kwk.systems/blog/images/gsoc-1-2.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 2. FreeCAD bug 3006 in action.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Note that the body diagonal of the mirrored part should run from the origin to  &lt;span class="math"&gt;\((-1, 1, 1)\)&lt;/span&gt;.
Instead, it's going to &lt;span class="math"&gt;\((1, -1, -1)\)&lt;/span&gt;, in the opposite direction.&lt;/p&gt;
&lt;p&gt;Well, this was my first really serious bug to tackle for the summer.
I chose this as a way to really dive in, since it directly involves Open CASCADE, the open source C++ geometry kernel at the heart of FreeCAD.&lt;/p&gt;
&lt;p&gt;However, my programming background is chiefly with Python (as well as JavaScript and Lua), all interpreted languages.
One nicety of that sort of language is that it can be very quick to debug and examine behavior using the interpreter.
There is a Python debugger, &lt;code class="docutils literal"&gt;pdb&lt;/code&gt;, but I rarely needed to use it for my mostly personal-sized projects.
Even then, it's quite straightforward to use since you're already in an interpreter-native environment.&lt;/p&gt;
&lt;p&gt;C++ is a very different beast. In this case, stepping through the code with a debugger was my only choice.
I use Neovim as my IDE, though, so I wanted a way to combine the power of my text editor with my debugger.
So, I found and set up &lt;a class="reference external" href="https://github.com/dbgx/lldb.nvim"&gt;LLDB.nvim&lt;/a&gt;, an LLDB frontend, with an event-based, non-blocking UI,
session-saving, and
"... takes advantage of Neovim's job API to spawn a separate process and communicates with the Neovim process using RPC calls."&lt;/p&gt;
&lt;p&gt;Pretty nice. Anyway, I was able to step through the code and see exactly what was flying around, just like I wanted.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="neovim" src="https://kwk.systems/blog/images/neovim1.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 3. Neovim in an LLDB debug session.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;So, what was the problem? Hah! Not so simple. Turns out there are &lt;em&gt;at least four bugs here!!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;First, the algorithm which first checks if the mirrored shapes are adjacent and thus, can be fused, was broken.&lt;/p&gt;
&lt;p&gt;Once this failed, FreeCAD then attempts to generate a mesh from the shape, and then converts a generalized transformation object representing the mirroring into a matrix to put the mesh in the correct place.
It turns out that in Open CASCADE 7.0.0, the &lt;code class="docutils literal"&gt;gp_Trsf&lt;/code&gt; API was changed so that &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;gp_Trsf::VectorialPart()&lt;/span&gt;&lt;/code&gt; returns a 3x3 matrix including the scale factor.
The previous behavior was to return the homogeneous part of the transformation which does not include the scale factor, and the FreeCAD algorithm for constructing the 4x4 matrix for the mesh included multiplying every term by a scale factor.
In other words, the scale factor multiplication was happening twice. The scale factor I had observed in the debugger was -1, so this perfectly explained the inverted positioning of the failure result!&lt;/p&gt;
&lt;p&gt;The third bug, of a much more minor nature, involved a a classic "failure... success!" message displayed in the event of a mirroring failure, and was easier to fix.&lt;/p&gt;
&lt;p&gt;The fourth, though, was a bit trickier! It only appeared when fixing the mesh placement.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="new mirroring bug" src="https://kwk.systems/blog/images/gsoc-1-3.png" style="width: 600px;"&gt;
&lt;figcaption&gt;
&lt;p&gt;Figure 4. A strange, new mirroring bug.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;This one was diagnosed by ickby, my mentor for this project.
It turns out the failure meshes' faces were getting constructed inside out, and so the material's color was not considered "illuminated".&lt;/p&gt;
&lt;p&gt;The three of us considered a few different options to get around this. One way would be to use Coin3D, FreeCAD's scene graph library, and change the material
properties to define something that looked the same, illuminated or not. Another is to essentially duplicate each face with the second instance having an inverted normal, so that you're guaranteed to have an outward-facing face.&lt;/p&gt;
&lt;p&gt;The fix ended up being much simpler than that! It was possible to simply change the vertex ordering. Originally, it was set to &lt;code class="docutils literal"&gt;COUNTERCLOCKWISE&lt;/code&gt;.
However, in figure 4, you can see that simply changing it to &lt;code class="docutils literal"&gt;CLOCKWISE&lt;/code&gt; would not be an obvious fix.
Abdullah also fixed this one, presumably by checking the docs for that option and finding that there was an "option C", &lt;code class="docutils literal"&gt;UNKNOWN&lt;/code&gt;. That did the trick!&lt;/p&gt;
&lt;p&gt;So now, PartDesign Mirrored is fixed and ready. Not a bad start for the summer!&lt;/p&gt;
&lt;!-- Open CASCADE and quaternions --&gt;
&lt;!-- Transformation matrices --&gt;
&lt;!-- OpenInventor and tessellation --&gt;
&lt;!-- Plans for the future --&gt;
&lt;!-- Rebuild test --&gt;</description><category>freecad</category><category>gsoc</category><guid>https://kwk.systems/blog/posts/gsoc-week-1-recap/</guid><pubDate>Tue, 06 Jun 2017 19:28:12 GMT</pubDate></item></channel></rss>