← Back to team overview

kicad-developers team mailing list archive

Geometry ongoing work

 

Hi!

I've been working on some geometry code on this branch:
https://code.launchpad.net/~alejandro-garciamontoro/kicad/kicad-polygon-refactor

This is still an ongoing work. You can consider this as a new developer
getting used to the code, waiting for Wayne and Javier to review the code
and decide if I finally join the team :) By the way, for the guys that were
not at the CERN hackaton: I am Alejandro García, a Computer Science and
Mathematics student from Granada, Spain; the idea is to work on KiCAD
full-time once I finish my studies; that is, since September 19th.

So far, the following has been done:

   - CPolyLine refactoring, thouroughly tested in the tests directory.
   - CPolyLine::Chamfer method has been refactored into
      SHAPE_POLY_SET::ChamferPolygon method. The main behaviour of the old
      method has been maintained, returning a completely new POLYGON object; if
      you think it should modify the original polygon instead of
returning a copy
      of a new one, let me know. This was done this way just to
preserve the way
      CPolyLine did its job. Furthermore, a sanity check was
introduced into the
      old CPolyLine method: due to rounding errors, two corners with the exact
      same coordinates could be added, and the CPolyLine::RemoveNullSegments
      was not able to remove them (this is a bug that should be studied if we
      continue to use CPolyLine code; as this is not the idea, I just fixed the
      errors in the new ChamferPolygon method to be able to test my
      refactoring).
      - CPolyLine::Fillet method has been refactored into
      SHAPE_POLY_SET::FilletPolygon method. The same previous comments
      apply here.
      - The AppendBezier methods have not been moved to SHAPE_POLY_SET yes.
      As I think Michele is working on a SHAPE_ARC class, I though
it's better to
      wait for that code to be ready.
      - The collision between a SHAPE_POLY_SET object and a point has been
   implemented and tested: the main behaviour is managed from the Contains
   method, that has been fixed to support holes, and that is implemented with
   the new containsSingle private method.
   - Some more simple methods have been implemented in the SHAPE_POLY_SET
   class: HasHoles method, which was declared but not defined and
   PointOnEdge, which is basically a loop over the
   SHAPE_LINE_CHAIN::PointOnEdge method.
   - A tests folder has been added to the project directory structure (the
   main CMakeFile.txt was also modified in order to handle this new
   directory).  As a new developer in the project I missed there were some
   kind of standard test suite in KiCAD to be used; hopefully, Michele showed
   to me at CERN how he was doing his tests (thank you!), so this is based on
   his files. I think we should make sure that in the not so distant future we
   add some standard test suite to the project; maybe not this one, as I think
   you wanna get rid of Boost library and these tests are based on Boost Test;
   anyway, I think this could be a good idea for the project.
   The tests folder I added contains the following new files:
   - CMakeLists.txt: it creates a new MyTests executable inside the tests
      directory.
      - module.cpp: Defines the Boost test module.
      - fixtures.h: Defines common data for the tests to check the methods.
      - chamfer_fillet_test.cpp: Defines unity tests to check the CPolyLine
      -> SHAPE_POLY_SET refactor did not change the previous behaviour.
      - collision_test.cpp: Defines unity tests to check the implementation
      of the methods HasHoles, PointOnEdge, Contains and Collide works well.

Wayne, please, review these code changes and let me know if there is
anything wrong or something I can improve for the future work :)

Looking forward to hear from you, guys!

Regards,
Alejandro

Follow ups