Refactor all math into a new kimath library

* Split up the thirdparty code into the thirdparty folder (#3637)
* Create a new kimath static library containing all the math functions

This is part of cleaning the build system for #1906.
This commit is contained in:
Ian McInerney 2020-01-07 17:12:59 +00:00
parent 270aaec443
commit 13b6028e1b
193 changed files with 2311 additions and 285 deletions

View File

@ -34,6 +34,7 @@
#include <3d_math.h> #include <3d_math.h>
#include "3d_fastmath.h" #include "3d_fastmath.h"
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <math/util.h> // for KiROUND
/** /**
* Trace mask used to enable or disable the trace output of this class. * Trace mask used to enable or disable the trace output of this class.

View File

@ -35,6 +35,7 @@
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <3d_math.h> #include <3d_math.h>
#include <math/util.h> // for KiROUND
#include <base_units.h> #include <base_units.h>

View File

@ -106,7 +106,7 @@ add_dependencies( 3d-viewer pcbcommon )
target_link_libraries( 3d-viewer target_link_libraries( 3d-viewer
gal gal
polygon kimath
${Boost_} ${Boost_}
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}

View File

@ -1027,7 +1027,6 @@ add_subdirectory( cvpcb )
add_subdirectory( eeschema ) add_subdirectory( eeschema )
add_subdirectory( gerbview ) add_subdirectory( gerbview )
add_subdirectory( pcbnew ) add_subdirectory( pcbnew )
add_subdirectory( polygon )
add_subdirectory( pagelayout_editor ) add_subdirectory( pagelayout_editor )
add_subdirectory( bitmap2component ) add_subdirectory( bitmap2component )
add_subdirectory( pcb_calculator ) add_subdirectory( pcb_calculator )

View File

@ -13,6 +13,7 @@ Licensed under AGPLv3 (or later):
- TTL [https://www.sintef.no/projectweb/geometry-toolkits/ttl/], sources in include/ttl/* - TTL [https://www.sintef.no/projectweb/geometry-toolkits/ttl/], sources in include/ttl/*
Licensed under BOOSTv1: Licensed under BOOSTv1:
- libcontext [https://github.com/boostorg/context] in thirdparty/libcontext - libcontext [https://github.com/boostorg/context] in thirdparty/libcontext
- clipper in thirdparty/clipper
Licensed under ISC: Licensed under ISC:
- portions of code in include/geometry/polygon_triangulation.h - portions of code in include/geometry/polygon_triangulation.h
Licensed under MIT: Licensed under MIT:
@ -22,6 +23,8 @@ Licensed under MIT:
Licensed under GPLv2 (or later): Licensed under GPLv2 (or later):
- dxflib in thirdparty/dxflib_qcad - dxflib in thirdparty/dxflib_qcad
- potrace in thirdparty/potrace - potrace in thirdparty/potrace
- math_for_graphics in thirdparty/other_math
- SutherlandHodgmanClipPoly in thirdparty/other_math
Licensed under ZLib: Licensed under ZLib:
- nanosvg in thirdparty/nanosvg - nanosvg in thirdparty/nanosvg
Licensed under CC-BY-SA-4.0: Licensed under CC-BY-SA-4.0:

View File

@ -26,13 +26,9 @@
#include "bitmap2component.h" #include "bitmap2component.h"
#include <bitmap_io.h> #include <bitmap_io.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <build_version.h>
#include <confirm.h>
#include <fctsys.h>
#include <gestfich.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <math/util.h> // for KiROUND
#include <kiway.h> #include <kiway.h>
#include <macros.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <potracelib.h> #include <potracelib.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>

View File

@ -40,7 +40,7 @@ set( GAL_SRCS
gal/graphics_abstraction_layer.cpp gal/graphics_abstraction_layer.cpp
gal/hidpi_gl_canvas.cpp gal/hidpi_gl_canvas.cpp
gal/stroke_font.cpp gal/stroke_font.cpp
geometry/hetriang.cpp
view/view_controls.cpp view/view_controls.cpp
view/view_overlay.cpp view/view_overlay.cpp
view/wx_view_controls.cpp view/wx_view_controls.cpp
@ -72,7 +72,8 @@ set( GAL_SRCS
add_library( gal STATIC ${GAL_SRCS} ) add_library( gal STATIC ${GAL_SRCS} )
target_link_libraries( gal target_link_libraries( gal
polygon ttl
kimath
bitmaps bitmaps
${GLEW_LIBRARIES} ${GLEW_LIBRARIES}
${CAIRO_LIBRARIES} ${CAIRO_LIBRARIES}
@ -258,7 +259,6 @@ set( COMMON_SRCS
array_options.cpp array_options.cpp
base64.cpp base64.cpp
base_struct.cpp base_struct.cpp
bezier_curves.cpp
bin_mod.cpp bin_mod.cpp
bitmap.cpp bitmap.cpp
bitmap_base.cpp bitmap_base.cpp
@ -270,7 +270,6 @@ set( COMMON_SRCS
common.cpp common.cpp
config_params.cpp config_params.cpp
confirm.cpp confirm.cpp
convert_basic_shapes_to_polygon.cpp
cursor_store.cpp cursor_store.cpp
dialog_shim.cpp dialog_shim.cpp
displlst.cpp displlst.cpp
@ -313,7 +312,6 @@ set( COMMON_SRCS
lib_tree_model_adapter.cpp lib_tree_model_adapter.cpp
lockfile.cpp lockfile.cpp
marker_base.cpp marker_base.cpp
md5_hash.cpp
msgpanel.cpp msgpanel.cpp
observable.cpp observable.cpp
prependpath.cpp prependpath.cpp
@ -364,8 +362,6 @@ set( COMMON_SRCS
view/view_item.cpp view/view_item.cpp
view/view_group.cpp view/view_group.cpp
math/math_util.cpp
tool/action_manager.cpp tool/action_manager.cpp
tool/action_menu.cpp tool/action_menu.cpp
tool/action_toolbar.cpp tool/action_toolbar.cpp
@ -388,17 +384,6 @@ set( COMMON_SRCS
tool/zoom_menu.cpp tool/zoom_menu.cpp
tool/zoom_tool.cpp tool/zoom_tool.cpp
geometry/convex_hull.cpp
geometry/geometry_utils.cpp
geometry/seg.cpp
geometry/shape.cpp
geometry/shape_collisions.cpp
geometry/shape_arc.cpp
geometry/shape_file_io.cpp
geometry/shape_line_chain.cpp
geometry/shape_poly_set.cpp
geometry/trigo.cpp
libeval/numeric_evaluator.cpp libeval/numeric_evaluator.cpp
) )
@ -415,8 +400,8 @@ add_dependencies( common libcontext )
add_dependencies( common version_header ) add_dependencies( common version_header )
target_link_libraries( common target_link_libraries( common
kimath
bitmaps bitmaps
polygon
gal gal
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${CURL_LIBRARIES} ${CURL_LIBRARIES}
@ -501,6 +486,7 @@ target_include_directories( pcbcommon PUBLIC
target_link_libraries( pcbcommon PUBLIC target_link_libraries( pcbcommon PUBLIC
common common
kimath
) )

View File

@ -29,13 +29,15 @@
* @brief BASE_SCREEN object implementation. * @brief BASE_SCREEN object implementation.
*/ */
#include <fctsys.h>
#include <macros.h>
#include <common.h>
#include <base_struct.h>
#include <base_screen.h> #include <base_screen.h>
#include <id.h> #include <base_struct.h>
#include <base_units.h> #include <base_units.h>
#include <common.h>
#include <fctsys.h>
#include <id.h>
#include <math/util.h> // for KiROUND
#include <macros.h>
#include <trace_helpers.h> #include <trace_helpers.h>

View File

@ -34,11 +34,13 @@
* depending on the application. * depending on the application.
*/ */
#include <macros.h>
#include <base_struct.h> #include <base_struct.h>
#include <title_block.h>
#include <common.h>
#include <base_units.h> #include <base_units.h>
#include <common.h>
#include <math/util.h> // for KiROUND
#include <macros.h>
#include <title_block.h>
#include "libeval/numeric_evaluator.h" #include "libeval/numeric_evaluator.h"

View File

@ -26,16 +26,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "fctsys.h" #include <bitmap_base.h>
#include "gr_basic.h" #include <eda_rect.h> // for EDA_RECT
#include "macros.h" #include <gal/color4d.h> // for COLOR4D
#include "trigo.h" #include <gr_basic.h>
#include "common.h" #include <math/util.h> // for KiROUND
#include "richio.h" #include <memory> // for make_unique, unique_ptr
#include "plotter.h" #include <plotter.h>
#include <richio.h>
#include "bitmap_base.h" #include <wx/bitmap.h> // for wxBitmap
#include <wx/mstream.h> #include <wx/mstream.h>

View File

@ -23,19 +23,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <fctsys.h>
#include <gr_basic.h>
#include <pgm_base.h>
#include <common.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <eda_base_frame.h>
#include <config_params.h>
#include <wx/apptrait.h> #include <colors.h> // for ColorByName, EDA_COLOR_T, UNSPECIFIE...
#include <wx/stdpaths.h> #include <common.h> // for LOCALE_IO
#include <config_params.h> // for PARAM_CFG_INT_WITH_SCALE, PARAM_CFG_...
#include <wildcards_and_files_ext.h> #include <gal/color4d.h> // for COLOR4D
#include <math/util.h> // for KiROUND
#include <wx/config.h> // for wxConfigBase
#include <wx/debug.h> // for wxASSERT
#include <wx/wx.h> // for wxString, operator!=, operator==
void wxConfigLoadParams( wxConfigBase* aCfg, void wxConfigLoadParams( wxConfigBase* aCfg,

View File

@ -21,31 +21,31 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <fctsys.h>
#include <common.h>
#include <project.h>
#include <confirm.h>
#include <gr_basic.h>
#include <base_struct.h>
#include <title_block.h>
#include <eda_draw_frame.h>
#include <ws_data_model.h>
#include <base_screen.h> #include <base_screen.h>
#include <wildcards_and_files_ext.h> #include <base_struct.h>
#include <common.h>
#include <confirm.h>
#include <dialog_page_settings.h>
#include <eda_draw_frame.h>
#include <fctsys.h>
#include <gr_basic.h>
#include <kiface_i.h>
#include <math/util.h> // for KiROUND, Clamp
#include <project.h>
#include <title_block.h>
#include <tool/actions.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <wildcards_and_files_ext.h>
#include <ws_data_model.h>
#include <ws_painter.h>
#include <wx/valgen.h> #include <wx/valgen.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
#ifdef EESCHEMA #ifdef EESCHEMA
#include <sch_screen.h>
#include <general.h> #include <general.h>
#include <sch_screen.h>
#endif #endif
#include <ws_painter.h>
#include <dialog_page_settings.h>
#include <tool/actions.h>
#include <kiface_i.h>
#define MAX_PAGE_EXAMPLE_SIZE 200 #define MAX_PAGE_EXAMPLE_SIZE 200

View File

@ -24,6 +24,8 @@
#ifndef _DIALOG_PAGES_SETTINGS_H_ #ifndef _DIALOG_PAGES_SETTINGS_H_
#define _DIALOG_PAGES_SETTINGS_H_ #define _DIALOG_PAGES_SETTINGS_H_
#include <page_info.h>
#include <title_block.h>
#include <widgets/unit_binder.h> #include <widgets/unit_binder.h>
#include <dialog_page_settings_base.h> #include <dialog_page_settings_base.h>

View File

@ -27,15 +27,32 @@
* @brief Implementation of base KiCad text object. * @brief Implementation of base KiCad text object.
*/ */
#include <eda_text.h> #include <algorithm> // for max
#include <gr_text.h> #include <stddef.h> // for NULL
#include <eda_rect.h> #include <type_traits> // for swap
#include <macros.h> #include <vector> // for vector
#include <trigo.h> // RotatePoint
#include <basic_gal.h> #include <base_struct.h> // for EDA_ITEM
#include <base_units.h> #include <base_units.h>
#include <convert_to_biu.h> #include <basic_gal.h> // for BASIC_GAL, basic_gal
#include <common.h> // for wxStringSplit
#include <convert_to_biu.h> // for Mils2iu
#include <core/typeinfo.h> // for KICAD_T, SCH_LABEL_T, SCH_TEXT_T, SCH_G...
#include <eda_rect.h> // for EDA_RECT
#include <eda_text.h> // for EDA_TEXT, TEXT_EFFECTS, GR_TEXT_VJUSTIF...
#include <gal/color4d.h> // for COLOR4D, COLOR4D::BLACK
#include <gal/stroke_font.h> // for STROKE_FONT
#include <gr_text.h> // for GRText
#include <kicad_string.h> // for UnescapeString
#include <math/util.h> // for KiROUND
#include <math/vector2d.h> // for VECTOR2D
#include <trigo.h> // for RotatePoint
#include <wx/debug.h> // for wxASSERT
#include <wx/wx.h> // for wxPoint, wxString, wxArrayString, wxSize
class OUTPUTFORMATTER;
class wxFindReplaceData;
// Sadly we store the orientation of hierarchical and global labels using a different // Sadly we store the orientation of hierarchical and global labels using a different
// int encoding than that for local labels: // int encoding than that for local labels:

View File

@ -33,6 +33,7 @@
#include <gal/cairo/cairo_compositor.h> #include <gal/cairo/cairo_compositor.h>
#include <gal/definitions.h> #include <gal/definitions.h>
#include <geometry/shape_poly_set.h> #include <geometry/shape_poly_set.h>
#include <math/util.h> // for KiROUND
#include <bitmap_base.h> #include <bitmap_base.h>
#include <limits> #include <limits>

View File

@ -29,6 +29,8 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <gal/definitions.h> #include <gal/definitions.h>
#include <math/util.h> // for KiROUND
#include <cmath> #include <cmath>
using namespace KIGFX; using namespace KIGFX;

View File

@ -39,6 +39,7 @@
#include <geometry/shape_poly_set.h> #include <geometry/shape_poly_set.h>
#include <bitmap_base.h> #include <bitmap_base.h>
#include <bezier_curves.h> #include <bezier_curves.h>
#include <math/util.h> // for KiROUND
#include <macros.h> #include <macros.h>

View File

@ -28,6 +28,7 @@
#include <gal/stroke_font.h> #include <gal/stroke_font.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <math/util.h> // for KiROUND
#include <wx/string.h> #include <wx/string.h>

View File

@ -36,6 +36,7 @@
#include <wx/graphics.h> #include <wx/graphics.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <math/util.h> // for KiROUND
static const bool FILLED = true; static const bool FILLED = true;
static const bool NOT_FILLED = false; static const bool NOT_FILLED = false;

View File

@ -38,6 +38,7 @@
#include <macros.h> #include <macros.h>
#include <base_screen.h> #include <base_screen.h>
#include <gr_text.h> #include <gr_text.h>
#include <math/util.h> // for KiROUND
#include <basic_gal.h> #include <basic_gal.h>

View File

@ -22,11 +22,17 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <bitset> // for bitset, __bitset<>::ref...
#include <cassert> #include <cassert>
#include <cstdarg> #include <cstdarg>
#include <iostream> // for string, endl, basic_ost...
#include <stddef.h> // for size_t
#include <layers_id_colors_and_visibility.h> #include <math/util.h> // for Clamp
#include <layers_id_colors_and_visibility.h> // for LSET, PCB_LAYER_ID, LSEQ
#include <macros.h> // for arrayDim
#include <wx/debug.h> // for wxASSERT, wxASSERT_MSG
#include <wx/wx.h> // for wxT, wxChar
LSET::LSET( const PCB_LAYER_ID* aArray, unsigned aCount ) : LSET::LSET( const PCB_LAYER_ID* aArray, unsigned aCount ) :

View File

@ -52,6 +52,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <gr_text.h> #include <gr_text.h>
#include <eda_rect.h> #include <eda_rect.h>
#include <math/util.h> // for KiROUND
#include <view/view.h> #include <view/view.h>
#include <ws_painter.h> #include <ws_painter.h>
#include <title_block.h> #include <title_block.h>

View File

@ -37,6 +37,7 @@
#include <macros.h> #include <macros.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
#include <math/util.h> // for KiROUND
#include <build_version.h> #include <build_version.h>

View File

@ -203,6 +203,8 @@
#include <macros.h> #include <macros.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
#include <math/util.h> // for KiROUND
// The hpgl command to close a polygon def, fill it and plot outline: // The hpgl command to close a polygon def, fill it and plot outline:
// PM 2; ends the polygon definition and closes it if not closed // PM 2; ends the polygon definition and closes it if not closed

View File

@ -38,6 +38,7 @@
#include <kicad_string.h> #include <kicad_string.h>
#include <wx/zstream.h> #include <wx/zstream.h>
#include <wx/mstream.h> #include <wx/mstream.h>
#include <math/util.h> // for KiROUND
/* /*

View File

@ -36,6 +36,7 @@
#include <macros.h> #include <macros.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
#include <math/util.h> // for KiROUND
/* Forward declaration of the font width metrics /* Forward declaration of the font width metrics
(yes extern! this is the way to forward declare variables */ (yes extern! this is the way to forward declare variables */

View File

@ -51,6 +51,7 @@
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <bezier_curves.h> #include <bezier_curves.h>
#include <math/util.h> // for KiROUND
PLOTTER::PLOTTER( ) PLOTTER::PLOTTER( )
{ {

View File

@ -23,7 +23,7 @@
#include <preview_items/arc_geom_manager.h> #include <preview_items/arc_geom_manager.h>
#include <common.h> // KiROUND #include <math/util.h> // for KiROUND
using namespace KIGFX::PREVIEW; using namespace KIGFX::PREVIEW;

View File

@ -26,6 +26,7 @@
#include "tool/edit_points.h" #include "tool/edit_points.h"
#include <geometry/seg.h> #include <geometry/seg.h>
#include <math/util.h> // for KiROUND
#include <common.h> #include <common.h>

View File

@ -24,6 +24,7 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <gal/color4d.h> #include <gal/color4d.h>
#include <math/util.h> // for KiROUND
#include "tool/edit_points.h" #include "tool/edit_points.h"
bool EDIT_POINT::WithinPoint( const VECTOR2I& aPoint, unsigned int aSize ) const bool EDIT_POINT::WithinPoint( const VECTOR2I& aPoint, unsigned int aSize ) const

View File

@ -32,6 +32,8 @@
#include <view/zoom_controller.h> #include <view/zoom_controller.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
#include <math/util.h> // for KiROUND
using namespace KIGFX; using namespace KIGFX;

View File

@ -89,6 +89,7 @@ target_link_libraries( cvpcb_kiface
3d-viewer 3d-viewer
gal gal
common common
kimath
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES} ${GDI_PLUS_LIBRARIES}
) )

View File

@ -28,6 +28,7 @@
#include <pgm_base.h> #include <pgm_base.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <dialog_text_entry.h> #include <dialog_text_entry.h>
#include <math/util.h> // for KiROUND
#include <general.h> #include <general.h>
#include <widgets/wx_grid.h> #include <widgets/wx_grid.h>

View File

@ -32,6 +32,7 @@
#include <base_units.h> #include <base_units.h>
#include <msgpanel.h> #include <msgpanel.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <math/util.h> // for KiROUND
#include <general.h> #include <general.h>
#include <lib_arc.h> #include <lib_arc.h>

View File

@ -31,6 +31,7 @@
#include <base_units.h> #include <base_units.h>
#include <msgpanel.h> #include <msgpanel.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <math/util.h> // for KiROUND
#include <general.h> #include <general.h>
#include <lib_circle.h> #include <lib_circle.h>

View File

@ -26,6 +26,7 @@
#define LIB_CIRCLE_H #define LIB_CIRCLE_H
#include <lib_item.h> #include <lib_item.h>
#include <math/util.h> // for KiROUND
class LIB_CIRCLE : public LIB_ITEM class LIB_CIRCLE : public LIB_ITEM

View File

@ -40,6 +40,7 @@
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <base_units.h> #include <base_units.h>
#include <msgpanel.h> #include <msgpanel.h>
#include <math/util.h> // for KiROUND
#include <general.h> #include <general.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>

View File

@ -31,6 +31,8 @@
#include <sch_item.h> #include <sch_item.h>
#include <math/util.h> // for KiROUND
class NETLIST_OBJECT_LIST; class NETLIST_OBJECT_LIST;

View File

@ -59,6 +59,7 @@
#include <connection_graph.h> #include <connection_graph.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <bezier_curves.h> #include <bezier_curves.h>
#include <math/util.h> // for KiROUND
#include "sch_painter.h" #include "sch_painter.h"

View File

@ -36,6 +36,7 @@
#include <plotter.h> #include <plotter.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <msgpanel.h> #include <msgpanel.h>
#include <math/util.h> // for KiROUND
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_sheet_path.h> #include <sch_sheet_path.h>

View File

@ -39,6 +39,7 @@
#include <msgpanel.h> #include <msgpanel.h>
#include <gal/stroke_font.h> #include <gal/stroke_font.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <math/util.h> // for KiROUND
#include <sch_text.h> #include <sch_text.h>
#include <netlist_object.h> #include <netlist_object.h>

View File

@ -45,6 +45,7 @@
#include <invoke_sch_dialog.h> #include <invoke_sch_dialog.h>
#include <project.h> #include <project.h>
#include <dialogs/dialog_display_info_HTML_base.h> #include <dialogs/dialog_display_info_HTML_base.h>
#include <math/util.h> // for KiROUND
EE_INSPECTION_TOOL::EE_INSPECTION_TOOL() EE_INSPECTION_TOOL::EE_INSPECTION_TOOL()

View File

@ -46,6 +46,7 @@
#include <painter.h> #include <painter.h>
#include <eeschema_id.h> // For MAX_SELECT_ITEM_IDS #include <eeschema_id.h> // For MAX_SELECT_ITEM_IDS
#include <menus_helpers.h> #include <menus_helpers.h>
#include <math/util.h> // for KiROUND
SELECTION_CONDITION EE_CONDITIONS::Empty = [] (const SELECTION& aSelection ) SELECTION_CONDITION EE_CONDITIONS::Empty = [] (const SELECTION& aSelection )

View File

@ -41,6 +41,7 @@
#include <sch_legacy_plugin.h> #include <sch_legacy_plugin.h>
#include <lib_text.h> #include <lib_text.h>
#include "lib_edit_tool.h" #include "lib_edit_tool.h"
#include <math/util.h> // for KiROUND
LIB_EDIT_TOOL::LIB_EDIT_TOOL() : LIB_EDIT_TOOL::LIB_EDIT_TOOL() :

View File

@ -50,6 +50,7 @@
#include <dialogs/dialog_edit_sheet_pin.h> #include <dialogs/dialog_edit_sheet_pin.h>
#include <dialogs/dialog_edit_one_field.h> #include <dialogs/dialog_edit_one_field.h>
#include "sch_drawing_tools.h" #include "sch_drawing_tools.h"
#include <math/util.h> // for KiROUND
char g_lastBusEntryShape = '/'; char g_lastBusEntryShape = '/';

View File

@ -51,6 +51,8 @@
#include <invoke_sch_dialog.h> #include <invoke_sch_dialog.h>
#include <dialogs/dialog_paste_special.h> #include <dialogs/dialog_paste_special.h>
#include <netlist_exporters/netlist_exporter_pspice.h> #include <netlist_exporters/netlist_exporter_pspice.h>
#include <math/util.h> // for KiROUND
int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent ) int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
{ {

View File

@ -27,6 +27,7 @@
#include <transform.h> #include <transform.h>
#include <common.h> #include <common.h>
#include <eda_rect.h> #include <eda_rect.h>
#include <math/util.h> // for KiROUND
bool TRANSFORM::operator==( const TRANSFORM& aTransform ) const bool TRANSFORM::operator==( const TRANSFORM& aTransform ) const

View File

@ -34,6 +34,7 @@
#include <convert_to_biu.h> #include <convert_to_biu.h>
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <math/util.h> // for KiROUND
#include <gerbview.h> #include <gerbview.h>
#include <gerber_file_image.h> #include <gerber_file_image.h>

View File

@ -65,6 +65,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <common.h> #include <common.h>
#include <confirm.h> #include <confirm.h>
#include <math/util.h> // for KiROUND
#include <gerbview.h> #include <gerbview.h>
#include <gerbview_frame.h> #include <gerbview_frame.h>

View File

@ -35,6 +35,7 @@
#include <gerber_file_image_list.h> #include <gerber_file_image_list.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <geometry/shape_arc.h> #include <geometry/shape_arc.h>
#include <math/util.h> // for KiROUND
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberImageFile ) : GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberImageFile ) :
EDA_ITEM( (EDA_ITEM*)NULL, GERBER_DRAW_ITEM_T ) EDA_ITEM( (EDA_ITEM*)NULL, GERBER_DRAW_ITEM_T )

View File

@ -34,6 +34,7 @@
#include <gal/gal_print.h> #include <gal/gal_print.h>
#include <view/view.h> #include <view/view.h>
#include <gerbview_painter.h> #include <gerbview_painter.h>
#include <math/util.h> // for KiROUND
GERBVIEW_PRINTOUT::GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const BOARD_PRINTOUT_SETTINGS& aParams, GERBVIEW_PRINTOUT::GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const BOARD_PRINTOUT_SETTINGS& aParams,

View File

@ -24,6 +24,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <common.h> #include <common.h>
#include <math/util.h> // for KiROUND
#include <gerber_file_image.h> #include <gerber_file_image.h>
#include <base_units.h> #include <base_units.h>

View File

@ -30,6 +30,7 @@
#include <common.h> #include <common.h>
#include <macros.h> #include <macros.h>
#include <base_units.h> #include <base_units.h>
#include <math/util.h> // for KiROUND
#include <gerbview.h> #include <gerbview.h>
#include <gerber_file_image.h> #include <gerber_file_image.h>

View File

@ -34,9 +34,10 @@
#include <string> #include <string>
#include <math/vector2d.h>
#include <common.h> #include <common.h>
#include <convert_to_biu.h> #include <convert_to_biu.h>
#include <math/util.h> // for KiROUND
#include <math/vector2d.h>
//TODO: Abstract Base Units to a single class //TODO: Abstract Base Units to a single class

View File

@ -69,33 +69,6 @@ typedef uint32_t timestamp_t;
#define TEXT_ANGLE_HORIZ 0 #define TEXT_ANGLE_HORIZ 0
#define TEXT_ANGLE_VERT 900 #define TEXT_ANGLE_VERT 900
//-----<KiROUND KIT>------------------------------------------------------------
/**
* Round a floating point number to an integer using "round halfway cases away from zero".
*
* In Debug build an assert fires if will not fit into the return type.
*/
template <typename fp_type, typename ret_type = int>
constexpr ret_type KiROUND( fp_type v )
{
using max_ret = long long int;
fp_type ret = v < 0 ? v - 0.5 : v + 0.5;
if( std::numeric_limits<ret_type>::max() < ret ||
std::numeric_limits<ret_type>::lowest() > ret )
{
wxLogDebug
( "Overflow KiROUND converting value %f to %s", double( v ), typeid(ret_type).name() );
return 0;
}
return ret_type( max_ret( ret ) );
}
//-----</KiROUND KIT>-----------------------------------------------------------
enum class EDA_UNITS enum class EDA_UNITS
{ {
INCHES = 0, INCHES = 0,

View File

@ -126,27 +126,6 @@ void MIRROR( T& aPoint, const T& aMirrorRef )
} }
/**
* Function Clamp
* limits @a value within the range @a lower <= @a value <= @a upper. It will work
* on temporary expressions, since they are evaluated only once, and it should work
* on most if not all numeric types, string types, or any type for which "operator < ()"
* is present. The arguments are accepted in this order so you can remember the
* expression as a memory aid:
* <p>
* result is: lower <= value <= upper
*/
template <typename T> inline const T& Clamp( const T& lower, const T& value, const T& upper )
{
wxASSERT( lower <= upper );
if( value < lower )
return lower;
else if( upper < value )
return upper;
return value;
}
#ifdef SWIG #ifdef SWIG
/// Declare a std::vector and also the swig %template in unison /// Declare a std::vector and also the swig %template in unison
#define DECL_VEC_FOR_SWIG(TypeName, MemberType) namespace std { %template(TypeName) vector<MemberType>; } typedef std::vector<MemberType> TypeName; #define DECL_VEC_FOR_SWIG(TypeName, MemberType) namespace std { %template(TypeName) vector<MemberType>; } typedef std::vector<MemberType> TypeName;

View File

@ -26,6 +26,7 @@
#ifndef SELECTION_H #ifndef SELECTION_H
#define SELECTION_H #define SELECTION_H
#include <core/optional.h>
#include <deque> #include <deque>
#include <eda_rect.h> #include <eda_rect.h>
#include <base_struct.h> #include <base_struct.h>

View File

@ -22,5 +22,5 @@
# #
# Build file for generic re-useable libraries # Build file for generic re-useable libraries
add_subdirectory( kimath )
add_subdirectory( sexpr ) add_subdirectory( sexpr )

View File

@ -0,0 +1,49 @@
set( KIMATH_SRCS
src/bezier_curves.cpp
src/convert_basic_shapes_to_polygon.cpp
src/md5_hash.cpp
src/trigo.cpp
src/geometry/convex_hull.cpp
src/geometry/geometry_utils.cpp
src/geometry/polygon_test_point_inside.cpp
src/geometry/seg.cpp
src/geometry/shape.cpp
src/geometry/shape_arc.cpp
src/geometry/shape_collisions.cpp
src/geometry/shape_file_io.cpp
src/geometry/shape_line_chain.cpp
src/geometry/shape_poly_set.cpp
src/math/util.cpp
)
# Include the other smaller math libraries in this one for convenience
add_library( kimath STATIC
${KIMATH_SRCS}
$<TARGET_OBJECTS:clipper>
$<TARGET_OBJECTS:othermath>
)
add_dependencies( kimath clipper )
add_dependencies( kimath rtree )
add_dependencies( kimath othermath )
target_link_libraries( kimath
${wxWidgets_LIBRARIES} # wxLogDebug, wxASSERT
${Boost_LIBRARIES} # Because of the OPT types
)
target_include_directories( kimath PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
$<TARGET_PROPERTY:clipper,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:othermath,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:rtree,INTERFACE_INCLUDE_DIRECTORIES>
)
# core/optional.h is needed for OPT types
target_include_directories( kimath PRIVATE
${PROJECT_SOURCE_DIR}/include
${wxWidgets_LIBRARIES}
${Boost_INCLUDE_DIR}
)

View File

@ -29,13 +29,8 @@
* @file convert_basic_shapes_to_polygon.h * @file convert_basic_shapes_to_polygon.h
*/ */
#include <vector>
#include <fctsys.h>
#include <trigo.h>
#include <macros.h>
#include <geometry/shape_poly_set.h> #include <geometry/shape_poly_set.h>
#include <wx/gdicmn.h> // for wxPoint
// The chamfer positions of chamfered rect shape. // The chamfer positions of chamfered rect shape.
// the position is relative to a pad with orientation = 0 // the position is relative to a pad with orientation = 0

View File

@ -24,6 +24,7 @@
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <math/vector2d.h>
// believe or not, X11 headers have a F****ING macro called Opposite... // believe or not, X11 headers have a F****ING macro called Opposite...
#undef Opposite #undef Opposite

View File

@ -30,6 +30,9 @@
#ifndef GEOMETRY_UTILS_H #ifndef GEOMETRY_UTILS_H
#define GEOMETRY_UTILS_H #define GEOMETRY_UTILS_H
#include <math.h> // for copysign
#include <stdlib.h> // for abs
#include <math/vector2d.h> #include <math/vector2d.h>
class EDA_RECT; class EDA_RECT;

View File

@ -25,14 +25,18 @@
#ifndef __POLY_GRID_PARTITION_H #ifndef __POLY_GRID_PARTITION_H
#define __POLY_GRID_PARTITION_H #define __POLY_GRID_PARTITION_H
#include <algorithm>
#include <functional>
#include <set>
#include <unordered_map>
#include <vector>
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <geometry/shape_rect.h> #include <geometry/shape_rect.h>
#include <math/util.h>
#include <vector> #include <math/vector2d.h>
#include <algorithm>
#include <unordered_map>
#include <set>
/** /**
* Class POLY_GRID_PARTITION * Class POLY_GRID_PARTITION

View File

@ -22,7 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#if 1 // Set to 0 to compile outside wxWidgets #ifdef WX_COMPATIBILITY
#include <wx/gdicmn.h> // for wxPoint definition #include <wx/gdicmn.h> // for wxPoint definition
#else #else
// define here wxPoint if we want to compile outside wxWidgets // define here wxPoint if we want to compile outside wxWidgets

View File

@ -47,11 +47,14 @@
#define __POLYGON_TRIANGULATION_H #define __POLYGON_TRIANGULATION_H
#include <algorithm> #include <algorithm>
#include <deque>
#include <cmath> #include <cmath>
#include <vector>
#include <math/box2.h>
#include "clipper.hpp" #include <clipper.hpp>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_poly_set.h>
#include <math/box2.h>
#include <math/vector2d.h>
class PolygonTriangulation class PolygonTriangulation
{ {

View File

@ -25,11 +25,14 @@
#ifndef __SEG_H #ifndef __SEG_H
#define __SEG_H #define __SEG_H
#include <cstdio> #include <math.h> // for sqrt
#include <climits> #include <stdlib.h> // for abs
#include <ostream> // for operator<<, ostream, basic_os...
#include <type_traits> // for swap
#include <math/vector2d.h>
#include <core/optional.h> #include <core/optional.h>
#include <math/util.h> // for rescale
#include <math/vector2d.h>
typedef OPT<VECTOR2I> OPT_VECTOR2I; typedef OPT<VECTOR2I> OPT_VECTOR2I;

View File

@ -25,13 +25,15 @@
#ifndef __SHAPE_H #ifndef __SHAPE_H
#define __SHAPE_H #define __SHAPE_H
#include <string> #include <assert.h> // for assert
#include <sstream> #include <sstream>
#include <stddef.h> // for NULL
#include <geometry/seg.h>
#include <math/vector2d.h> #include <math/vector2d.h>
#include <math/box2.h> #include <math/box2.h>
#include <geometry/seg.h>
/** /**
* Enum SHAPE_TYPE * Enum SHAPE_TYPE

View File

@ -25,8 +25,10 @@
#ifndef __SHAPE_ARC_H #ifndef __SHAPE_ARC_H
#define __SHAPE_ARC_H #define __SHAPE_ARC_H
#include <geometry/shape.h>
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape.h>
#include <math/box2.h> // for BOX2I
#include <math/vector2d.h> // for VECTOR2I
class SHAPE_LINE_CHAIN; class SHAPE_LINE_CHAIN;

View File

@ -25,7 +25,9 @@
#ifndef __SHAPE_CIRCLE_H #ifndef __SHAPE_CIRCLE_H
#define __SHAPE_CIRCLE_H #define __SHAPE_CIRCLE_H
#include "shape.h" #include <geometry/shape.h>
#include <math/box2.h>
#include <math/vector2d.h>
class SHAPE_CIRCLE : public SHAPE class SHAPE_CIRCLE : public SHAPE
{ {

View File

@ -27,7 +27,7 @@
#define __SHAPE_FILE_IO_H #define __SHAPE_FILE_IO_H
#include <cstdio> #include <cstdio>
#include <string> #include <string> // for string
class SHAPE; class SHAPE;

View File

@ -27,9 +27,10 @@
#define __SHAPE_INDEX_H #define __SHAPE_INDEX_H
#include <vector> #include <vector>
#include <geometry/shape.h>
#include <geometry/rtree.h>
#include <geometry/rtree.h>
#include <geometry/shape.h>
#include <math/box2.h>
/** /**
* shapeFunctor template function * shapeFunctor template function

View File

@ -25,6 +25,12 @@
#ifndef __SHAPE_INDEX_LIST_H #ifndef __SHAPE_INDEX_LIST_H
#define __SHAPE_INDEX_LIST_H #define __SHAPE_INDEX_LIST_H
#include <vector>
#include <geometry/shape.h>
#include <math/box2.h>
#include <math/vector2d.h>
template <class T> template <class T>
const SHAPE* defaultShapeFunctor( const T aItem ) const SHAPE* defaultShapeFunctor( const T aItem )
{ {

View File

@ -26,17 +26,20 @@
#ifndef __SHAPE_LINE_CHAIN #ifndef __SHAPE_LINE_CHAIN
#define __SHAPE_LINE_CHAIN #define __SHAPE_LINE_CHAIN
#include <algorithm> // for max
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include <wx/gdicmn.h> #include <wx/gdicmn.h> // for wxPoint
#include <core/optional.h> #include <core/optional.h>
#include <math/vector2d.h>
#include <geometry/shape.h>
#include <geometry/seg.h>
#include <clipper.hpp> #include <clipper.hpp>
#include <geometry/seg.h>
#include <geometry/shape.h>
#include <math/box2.h> // for BOX2I
#include <math/vector2d.h>
/** /**
* Class SHAPE_LINE_CHAIN * Class SHAPE_LINE_CHAIN

View File

@ -26,12 +26,21 @@
#ifndef __SHAPE_POLY_SET_H #ifndef __SHAPE_POLY_SET_H
#define __SHAPE_POLY_SET_H #define __SHAPE_POLY_SET_H
#include <vector>
#include <cstdio> #include <cstdio>
#include <deque> // for deque
#include <iosfwd> // for string, stringstream
#include <memory> #include <memory>
#include <set> // for set
#include <stdexcept> // for out_of_range
#include <stdlib.h> // for abs
#include <vector>
#include <clipper.hpp> // for ClipType, PolyTree (ptr only)
#include <geometry/seg.h> // for SEG
#include <geometry/shape.h> #include <geometry/shape.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <math/box2.h> // for BOX2I
#include <math/vector2d.h> // for VECTOR2I
#include <md5_hash.h> #include <md5_hash.h>

View File

@ -25,10 +25,11 @@
#ifndef __SHAPE_RECT_H #ifndef __SHAPE_RECT_H
#define __SHAPE_RECT_H #define __SHAPE_RECT_H
#include <geometry/seg.h>
#include <geometry/shape.h> #include <geometry/shape.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <geometry/shape_circle.h> #include <math/box2.h>
#include <geometry/seg.h> #include <math/vector2d.h>
class SHAPE_RECT : public SHAPE class SHAPE_RECT : public SHAPE
{ {

View File

@ -25,8 +25,10 @@
#ifndef __SHAPE_SEGMENT_H #ifndef __SHAPE_SEGMENT_H
#define __SHAPE_SEGMENT_H #define __SHAPE_SEGMENT_H
#include <geometry/shape.h>
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape.h>
#include <math/box2.h>
#include <math/vector2d.h>
class SHAPE_SEGMENT : public SHAPE { class SHAPE_SEGMENT : public SHAPE {

View File

@ -24,11 +24,11 @@
#ifndef __SHAPE_SIMPLE_H #ifndef __SHAPE_SIMPLE_H
#define __SHAPE_SIMPLE_H #define __SHAPE_SIMPLE_H
#include <vector>
#include <geometry/shape.h>
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <math/box2.h>
#include <math/vector2d.h>
/** /**
* Class SHAPE_SIMPLE * Class SHAPE_SIMPLE

View File

@ -30,6 +30,7 @@
#include <math/vector2d.h> #include <math/vector2d.h>
#include <limits> #include <limits>
// Needed for the OPT definition
#include <core/optional.h> #include <core/optional.h>
/** /**

View File

@ -23,10 +23,56 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#ifndef __MATH_UTIL_H #ifndef UTIL_H
#define __MATH_UTIL_H #define UTIL_H
#include <cstdint> #include <cstdint>
#include <limits>
#include <typeinfo>
#include <wx/debug.h>
#include <wx/log.h>
/**
* Function Clamp
* limits @a value within the range @a lower <= @a value <= @a upper. It will work
* on temporary expressions, since they are evaluated only once, and it should work
* on most if not all numeric types, string types, or any type for which "operator < ()"
* is present. The arguments are accepted in this order so you can remember the
* expression as a memory aid:
* <p>
* result is: lower <= value <= upper
*/
template <typename T> inline const T& Clamp( const T& lower, const T& value, const T& upper )
{
wxASSERT( lower <= upper );
if( value < lower )
return lower;
else if( upper < value )
return upper;
return value;
}
/**
* Round a floating point number to an integer using "round halfway cases away from zero".
*
* In Debug build an assert fires if will not fit into the return type.
*/
template <typename fp_type, typename ret_type = int>
constexpr ret_type KiROUND( fp_type v )
{
using max_ret = long long int;
fp_type ret = v < 0 ? v - 0.5 : v + 0.5;
if( std::numeric_limits<ret_type>::max() < ret ||
std::numeric_limits<ret_type>::lowest() > ret )
{
wxLogDebug
( "Overflow KiROUND converting value %f to %s", double( v ), typeid(ret_type).name() );
return 0;
}
return ret_type( max_ret( ret ) );
}
/** /**
* Function rescale() * Function rescale()
@ -58,4 +104,4 @@ static inline int round_nearest( double v )
return int( v < 0 ? v - 0.5 : v + 0.5 ); return int( v < 0 ? v - 0.5 : v + 0.5 );
} }
#endif // __MATH_UTIL_H #endif // UTIL_H

View File

@ -32,7 +32,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <math/math_util.h> #include <math/util.h>
#ifdef WX_COMPATIBILITY #ifdef WX_COMPATIBILITY
#include <wx/gdicmn.h> #include <wx/gdicmn.h>

View File

@ -26,6 +26,10 @@
/************************************/ /************************************/
#include <bezier_curves.h> #include <bezier_curves.h>
#include <math/vector2d.h> // for VECTOR2D, operator*, VECTOR2
#include <wx/debug.h> // for wxASSERT
#include <wx/gdicmn.h> // for wxPoint
BEZIER_POLY::BEZIER_POLY( const std::vector<wxPoint>& aControlPoints ) BEZIER_POLY::BEZIER_POLY( const std::vector<wxPoint>& aControlPoints )
{ {

View File

@ -24,14 +24,18 @@
* or you may write to the Free Software Foundation, Inc., * or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <vector>
#include <fctsys.h> #include <algorithm> // for max, min
#include <trigo.h> #include <math.h> // for atan2
#include <macros.h> #include <type_traits> // for swap
#include <common.h>
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <geometry/shape_line_chain.h> // for SHAPE_LINE_CHAIN
#include <geometry/shape_poly_set.h> // for SHAPE_POLY_SET, SHAPE_POLY_SE...
#include <math/util.h>
#include <math/vector2d.h> // for VECTOR2I
#include <trigo.h>
void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aBuffer, void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aBuffer,

View File

@ -55,12 +55,14 @@
* Points in the result will be listed in counter-clockwise order. * Points in the result will be listed in counter-clockwise order.
*/ */
#include <geometry/shape_poly_set.h>
#include <geometry/convex_hull.h> #include <geometry/convex_hull.h>
#include <geometry/shape_line_chain.h> // for SHAPE_LINE_CHAIN
#include <geometry/shape_poly_set.h>
#include <math/vector2d.h> // for VECTOR2I
#include <trigo.h>
#include <algorithm> #include <algorithm>
#include <wx/wx.h> #include <wx/wx.h>
#include <trigo.h>
typedef long long coord2_t; // must be big enough to hold 2*max(|coordinate|)^2 typedef long long coord2_t; // must be big enough to hold 2*max(|coordinate|)^2

View File

@ -27,8 +27,12 @@
* @brief a few functions useful in geometry calculations. * @brief a few functions useful in geometry calculations.
*/ */
#include <stdint.h> // for int64_t
#include <algorithm> // for max, min
#include <eda_rect.h> #include <eda_rect.h>
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <math/util.h> // for round_nearest
// To approximate a circle by segments, a minimal seg count is mandatory // To approximate a circle by segments, a minimal seg count is mandatory
#define MIN_SEGCOUNT_FOR_CIRCLE 6 #define MIN_SEGCOUNT_FOR_CIRCLE 6

View File

@ -26,10 +26,7 @@
* @file polygon_test_point_inside.cpp * @file polygon_test_point_inside.cpp
*/ */
#include <cmath> #include <geometry/polygon_test_point_inside.h>
#include <vector>
#include "polygon_test_point_inside.h"
/* this algo uses the the Jordan curve theorem to find if a point is inside or outside a polygon: /* this algo uses the the Jordan curve theorem to find if a point is inside or outside a polygon:
* It run a semi-infinite line horizontally (increasing x, fixed y) * It run a semi-infinite line horizontally (increasing x, fixed y)

View File

@ -22,7 +22,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <algorithm> // for min
#include <geometry/seg.h> #include <geometry/seg.h>
#include <math/util.h> // for rescale
#include <math/vector2d.h> // for VECTOR2I, VECTOR2
template <typename T> template <typename T>
int sgn( T aVal ) int sgn( T aVal )

View File

@ -22,12 +22,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <algorithm> #include <assert.h> // for assert
#include <math.h> // for cos, sin, M_PI, atan2, ceil
#include <type_traits> // for swap
#include <vector> #include <vector>
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <geometry/seg.h> // for SEG
#include <geometry/shape_arc.h> #include <geometry/shape_arc.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <math/box2.h> // for BOX2I
#include <math/vector2d.h> // for VECTOR2I, VECTOR2D, VECTOR2
bool SHAPE_ARC::Collide( const SEG& aSeg, int aClearance ) const bool SHAPE_ARC::Collide( const SEG& aSeg, int aClearance ) const
{ {

View File

@ -22,16 +22,22 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <cmath>
#include <math/vector2d.h>
#include <assert.h> // for assert
#include <cmath>
#include <limits.h> // for INT_MAX
#include <stdlib.h> // for abs
#include <geometry/seg.h> // for SEG
#include <geometry/shape.h> #include <geometry/shape.h>
#include <geometry/shape_arc.h> #include <geometry/shape_arc.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <geometry/shape_circle.h> #include <geometry/shape_circle.h>
#include <geometry/shape_rect.h> #include <geometry/shape_rect.h>
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include "../../include/geometry/shape_simple.h" #include <geometry/shape_simple.h>
#include <math/box2.h> // for BOX2I
#include <math/vector2d.h>
typedef VECTOR2I::extended_type ecoord; typedef VECTOR2I::extended_type ecoord;

View File

@ -22,8 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <string>
#include <cassert> #include <cassert>
#include <string>
#include <geometry/shape.h> #include <geometry/shape.h>
#include <geometry/shape_file_io.h> #include <geometry/shape_file_io.h>

View File

@ -23,11 +23,17 @@
*/ */
#include <algorithm> #include <algorithm>
#include <limits.h> // for INT_MAX
#include <math.h> // for hypot
#include <string> // for basic_string
#include <clipper.hpp>
#include <geometry/seg.h> // for SEG, OPT_VECTOR2I
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <geometry/shape_circle.h> #include <math/box2.h> // for BOX2I
#include <trigo.h> #include <math/util.h> // for rescale
#include "clipper.hpp" #include <math/vector2d.h> // for VECTOR2, VECTOR2I
class SHAPE;
ClipperLib::Path SHAPE_LINE_CHAIN::convertToClipper( bool aRequiredOrientation ) const ClipperLib::Path SHAPE_LINE_CHAIN::convertToClipper( bool aRequiredOrientation ) const

View File

@ -26,23 +26,31 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <vector>
#include <cstdio>
#include <set>
#include <list>
#include <algorithm> #include <algorithm>
#include <unordered_set> #include <assert.h> // for assert
#include <cmath> // for sqrt, cos, hypot, isinf
#include <cstdio>
#include <istream> // for operator<<, operator>>
#include <limits> // for numeric_limits
#include <memory> #include <memory>
#include <set>
#include <string> // for char_traits, operator!=
#include <type_traits> // for swap, move
#include <unordered_set>
#include <vector>
#include <md5_hash.h> #include <clipper.hpp> // for Clipper, PolyNode, Clipp...
#include <map>
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <geometry/polygon_triangulation.h>
#include <geometry/seg.h> // for SEG, OPT_VECTOR2I
#include <geometry/shape.h> #include <geometry/shape.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <geometry/shape_poly_set.h> #include <geometry/shape_poly_set.h>
#include <geometry/polygon_triangulation.h> #include <math/box2.h> // for BOX2I
#include <math/util.h> // for round_nearest, rescale
#include <math/vector2d.h> // for VECTOR2I, VECTOR2D, VECTOR2
#include <md5_hash.h>
using namespace ClipperLib; using namespace ClipperLib;

View File

@ -26,7 +26,7 @@
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <climits> #include <climits>
#include <math/math_util.h> #include <math/util.h>
template<> template<>
int rescale( int aNumerator, int aValue, int aDenominator ) int rescale( int aNumerator, int aValue, int aDenominator )

Some files were not shown because too many files have changed in this diff Show More