From adddc41bc5bf9398054cc999b91780e7d073174f Mon Sep 17 00:00:00 2001 From: John Beard Date: Thu, 24 Jan 2019 14:14:08 +0000 Subject: [PATCH] QA: Reinstate polygon_triangulation utility This utility has been disabled since the eeschema GAL merge. It can be reinstated as part of the qa_pcbnew_tools framework. --- Documentation/development/testing.md | 1 + qa/CMakeLists.txt | 1 - qa/pcbnew_tools/CMakeLists.txt | 2 + qa/pcbnew_tools/pcbnew_tools.cpp | 2 + .../polygon_triangulation.cpp} | 27 +++++- .../polygon_triangulation.h | 32 +++++++ qa/polygon_triangulation/CMakeLists.txt | 92 ------------------- 7 files changed, 59 insertions(+), 98 deletions(-) rename qa/{polygon_triangulation/test_polygon_triangulation.cpp => pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.cpp} (92%) create mode 100644 qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.h delete mode 100644 qa/polygon_triangulation/CMakeLists.txt diff --git a/Documentation/development/testing.md b/Documentation/development/testing.md index 5130dad0ad..3bad8e3a5c 100644 --- a/Documentation/development/testing.md +++ b/Documentation/development/testing.md @@ -172,6 +172,7 @@ parameters, refer to the tools' usage test (`-h`). * `drc`: Run and benchmark certain DRC functions on a user-provided `.kicad_pcb` files * `pcb_parser`: Parse user-provided `.kicad_pcb` files * `polygon_generator`: Dump polygons found on a PCB to the console + * `polygon_triangulation`: Perform triangulation of zone polygons on PCBs # Fuzz testing {#fuzz-testing} diff --git a/qa/CMakeLists.txt b/qa/CMakeLists.txt index 6502a461c8..ea0e6712d9 100644 --- a/qa/CMakeLists.txt +++ b/qa/CMakeLists.txt @@ -27,4 +27,3 @@ add_subdirectory( common_tools ) add_subdirectory( pcbnew_tools ) # add_subdirectory( pcb_test_window ) -# add_subdirectory( polygon_triangulation ) diff --git a/qa/pcbnew_tools/CMakeLists.txt b/qa/pcbnew_tools/CMakeLists.txt index 9b01c24e10..372946ee4d 100644 --- a/qa/pcbnew_tools/CMakeLists.txt +++ b/qa/pcbnew_tools/CMakeLists.txt @@ -35,6 +35,8 @@ add_executable( qa_pcbnew_tools tools/polygon_generator/polygon_generator.cpp + tools/polygon_triangulation/polygon_triangulation.cpp + # Older CMakes cannot link OBJECT libraries # https://cmake.org/pipermail/cmake/2013-November/056263.html $ diff --git a/qa/pcbnew_tools/pcbnew_tools.cpp b/qa/pcbnew_tools/pcbnew_tools.cpp index 0753e4f8f8..4b810b8b98 100644 --- a/qa/pcbnew_tools/pcbnew_tools.cpp +++ b/qa/pcbnew_tools/pcbnew_tools.cpp @@ -26,6 +26,7 @@ #include "tools/drc_tool/drc_tool.h" #include "tools/pcb_parser/pcb_parser_tool.h" #include "tools/polygon_generator/polygon_generator.h" +#include "tools/polygon_triangulation/polygon_triangulation.h" /** * List of registered tools. @@ -37,6 +38,7 @@ const static std::vector known_tools = { &drc_tool, &pcb_parser_tool, &polygon_generator_tool, + &polygon_triangulation_tool, }; diff --git a/qa/polygon_triangulation/test_polygon_triangulation.cpp b/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.cpp similarity index 92% rename from qa/polygon_triangulation/test_polygon_triangulation.cpp rename to qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.cpp index 0410e12255..d10af9a6b7 100644 --- a/qa/polygon_triangulation/test_polygon_triangulation.cpp +++ b/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.cpp @@ -22,6 +22,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "polygon_triangulation.h" + #include #include @@ -198,7 +200,7 @@ aResult->clear(); std::swap( (*aResult) [0], (*aResult)[outline] ); } -BOARD* loadBoard( const std::string& filename ) +BOARD* loadBoardTri( const std::string& filename ) { PLUGIN::RELEASER pi( new PCB_IO ); BOARD* brd = nullptr; @@ -219,12 +221,18 @@ BOARD* loadBoard( const std::string& filename ) return brd; } -int main( int argc, char *argv[] ) +enum POLY_TRI_RET_CODES { - auto brd = loadBoard( argc > 1 ? argv[1] : "../../../../tests/dp.kicad_pcb" ); + LOAD_FAILED = KI_TEST::RET_CODES::TOOL_SPECIFIC, +}; + + +int polygon_triangulation_main( int argc, char *argv[] ) +{ + auto brd = loadBoardTri( argc > 1 ? argv[1] : "../../../../tests/dp.kicad_pcb" ); if( !brd ) - return -1; + return POLY_TRI_RET_CODES::LOAD_FAILED; PROF_COUNTER cnt( "allBoard" ); @@ -278,6 +286,15 @@ int main( int argc, char *argv[] ) delete brd; - return 0; + return KI_TEST::RET_CODES::OK; } + +/* + * Define the tool interface + */ +KI_TEST::UTILITY_PROGRAM polygon_triangulation_tool = { + "polygon_triangulation", + "Process polygon trianguation on a PCB", + polygon_triangulation_main, +}; \ No newline at end of file diff --git a/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.h b/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.h new file mode 100644 index 0000000000..b3410db60a --- /dev/null +++ b/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.h @@ -0,0 +1,32 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PCBNEW_TOOLS_POLYGON_TRIANGULATION_UTILITY_H +#define PCBNEW_TOOLS_POLYGON_TRIANGULATION_UTILITY_H + +#include + +/// A tool to parse kicad PCBs from the command line +extern KI_TEST::UTILITY_PROGRAM polygon_triangulation_tool; + +#endif //PCBNEW_TOOLS_POLYGON_TRIANGULATION_UTILITY_H \ No newline at end of file diff --git a/qa/polygon_triangulation/CMakeLists.txt b/qa/polygon_triangulation/CMakeLists.txt deleted file mode 100644 index 2281206916..0000000000 --- a/qa/polygon_triangulation/CMakeLists.txt +++ /dev/null @@ -1,92 +0,0 @@ -# -# This program source code file is part of KiCad, a free EDA CAD application. -# -# Copyright (C) 2017 CERN -# @author Alejandro GarcĂ­a Montoro -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, you may find one here: -# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# or you may search the http://www.gnu.org website for the version 2 license, -# or you may write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -#find_package(Boost COMPONENTS unit_test_framework REQUIRED) -#find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc REQUIRED ) - -add_definitions(-DPCBNEW -DBOOST_TEST_DYN_LINK) - -if( BUILD_GITHUB_PLUGIN ) - set( GITHUB_PLUGIN_LIBRARIES github_plugin ) -endif() - -add_dependencies( pnsrouter pcbcommon pcad2kicadpcb ${GITHUB_PLUGIN_LIBRARIES} ) - -add_executable(test_polygon_triangulation - ../qa_utils/mocks.cpp - ../../common/base_units.cpp - test_polygon_triangulation.cpp -) - -include_directories( BEFORE ${INC_BEFORE} ) -include_directories( - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/3d-viewer - ${CMAKE_SOURCE_DIR}/common - ${CMAKE_SOURCE_DIR}/pcbnew - ${CMAKE_SOURCE_DIR}/pcbnew/router - ${CMAKE_SOURCE_DIR}/pcbnew/tools - ${CMAKE_SOURCE_DIR}/pcbnew/dialogs - ${CMAKE_SOURCE_DIR}/polygon - ${CMAKE_SOURCE_DIR}/common/geometry - ${CMAKE_SOURCE_DIR}/qa/common - ${Boost_INCLUDE_DIR} - ${INC_AFTER} -) - -target_link_libraries( test_polygon_triangulation - polygon - pnsrouter - common - pcbcommon - bitmaps - polygon - pnsrouter - common - pcbcommon - bitmaps - polygon - pnsrouter - common - pcbcommon - bitmaps - polygon - pnsrouter - common - pcbcommon - bitmaps - gal - pcad2kicadpcb - common - pcbcommon - ${GITHUB_PLUGIN_LIBRARIES} - common - pcbcommon - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} - ${wxWidgets_LIBRARIES} -) - -