### Run the example program Source: https://github.com/kallaballa/libnfporb/blob/master/README.md Command to execute the compiled example program with two WKT polygon files as arguments. ```bash examples/nfp data/crossing/A.wkt data/crossing/B.wkt ``` -------------------------------- ### Build the library Source: https://github.com/kallaballa/libnfporb/blob/master/README.md Standard commands to clone, compile, and install the library from source. ```bash git clone https://github.com/kallaballa/libnfp.git cd libnfp make sudo make install ``` -------------------------------- ### Generate NFP from WKT files Source: https://github.com/kallaballa/libnfporb/blob/master/README.md Example demonstrating how to read two polygons from WKT files, generate their no-fit polygon, and export the result to an SVG file. ```cpp //uncomment next line to use arbitrary precision (slow) //#define LIBNFP_USE_RATIONAL //uncomment to enable debug mode //#define NFP_DEBUG #include "../src/libnfporb.hpp" int main(int argc, char** argv) { using namespace libnfporb; polygon_t pA; polygon_t pB; //read polygons from wkt files read_wkt_polygon(argv[1], pA); read_wkt_polygon(argv[2], pB); //generate NFP of polygon A and polygon B and check the polygons for validity. //When the third parameters is false validity check is skipped for a little performance increase nfp_t nfp = generate_nfp(pA, pB, true); //write a svg containing pA, pB and NFP write_svg("nfp.svg", pA, pB, nfp); return 0; } ``` -------------------------------- ### search_start_translation Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/namespacelibnfporb.html Searches for a new start position for the NFP traversal. ```APIDOC ## search_start_translation ### Description Searches for a new start position at the beginning of traversal or after a completed NFP-ring. ### Parameters - **rA** (polygon_t::ring_type) - Required - The ring of polygon A to search. - **rB** (polygon_t::ring_type) - Required - The ring of polygon B to fit. - **nfp** (nfp_t) - Required - The NFP so far. - **inside** (bool) - Required - Flag indicating if inside a hole. - **result** (point_t) - Required - Reference to store the translation vector. ### Response - **SearchStartResult** - Indicates if a perfect fit, new start position, or new possible position was found. ``` -------------------------------- ### Determine Starting Points for NFP Calculation Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/libnfporb_8hpp_source.html Calculates the starting points for NFP calculation by finding the rightmost vertex of polygon A with the minimum Y and the leftmost vertex of polygon B with the maximum Y. Handles cases where multiple vertices share extreme Y values. ```cpp if (yAminI.size() > 1 || yBmaxI.size() > 1) { //find right-most of A and left-most of B to prevent double connection at start [coord_t](classlibnfporb_1_1LongDouble.html) maxX = [MIN_COORD](namespacelibnfporb.html#a125f9bff0a4aaed7ffa722b859f4876b); [psize_t](namespacelibnfporb.html#a83ffffdc4e4235604aa207e82bbb4eab) iRightMost = 0; for ([psize_t](namespacelibnfporb.html#a83ffffdc4e4235604aa207e82bbb4eab)& ia : yAminI) { const [point_t](classlibnfporb_1_1point__t.html)& candidateA = pA.outer()[ia]; if ([larger](namespacelibnfporb.html#a3021c2838a351048bd223d1e9a0493c3)(candidateA.x_, maxX)) { maxX = candidateA.x_; iRightMost = ia; } } [coord_t](classlibnfporb_1_1LongDouble.html) minX = [MAX_COORD](namespacelibnfporb.html#a6090f5c63d46f9e812f2fc128fb7f249); [psize_t](namespacelibnfporb.html#a83ffffdc4e4235604aa207e82bbb4eab) iLeftMost = 0; for ([psize_t](namespacelibnfporb.html#a83ffffdc4e4235604aa207e82bbb4eab)& ib : yBmaxI) { const [point_t](classlibnfporb_1_1point__t.html)& candidateB = pB.outer()[ib]; if ([smaller](namespacelibnfporb.html#a4bf253739214a0da53cfc62291c36a5f)(candidateB.x_, minX)) { minX = candidateB.x_; iLeftMost = ib; } } pAstart = pA.outer()[iRightMost]; pBstart = pB.outer()[iLeftMost]; } else { pAstart = pA.outer()[yAminI.front()]; pBstart = pB.outer()[yBmaxI.front()]; } ``` -------------------------------- ### libnfporb::search_start_translation Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/search__start_8hpp.html Searches for a new starting position for translation, used at the beginning of traversal and after each completed NFP-ring. ```APIDOC ## SearchStartResult search_start_translation(polygon_t::ring_type &rA, const polygon_t::ring_type &rB, const nfp_t &nfp, const bool &inside, point_t &result) ### Description At the start of traversal and after every completed nfp-ring this function is used to search for a new start position. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (SearchStartResult) - **Return Value** (SearchStartResult) - Indicates the result of the search (FIT, FOUND, NOT_FOUND). - **result** (point_t &) - Output parameter for the found point. #### Response Example N/A ``` -------------------------------- ### libnfporb::search_start_translation Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/search__start_8hpp_source.html This function searches for a starting translation for a given set of polygons. It involves trimming translation vectors, transforming polygons, and checking for various geometric relationships like containment, overlap, and proximity. ```APIDOC ## search_start_translation ### Description Searches for a suitable starting translation for geometric objects, considering containment, overlap, and proximity conditions. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, this is a library function) ### Parameters (Parameters are inferred from the code usage, not explicitly listed in the provided text. Key variables used include: rA, translated, slideVector, trimmed, translated2, testTranslation, inside, nfp) ### Request Example (Not applicable, this is a library function) ### Response #### Success Response - **SearchStartResult** (enum) - Indicates whether a translation was FIT, FOUND, or NOT_FOUND. #### Response Example ``` libnfporb::FIT libnfporb::FOUND libnfporb::NOT_FOUND ``` ### Error Handling (Specific error handling not detailed in the provided text.) ``` -------------------------------- ### SearchStartResult search_start_translation Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/search__start_8hpp_source.html Initiates a search for a new starting point for normal form polygon (NFP) traversal. This function is called at the beginning of a traversal and after each completed NFP ring. ```APIDOC ## search_start_translation ### Description At the start of traversal and after every completed nfp-ring this function is used to search for a new starting point for the nfp traversal. ### Method N/A (This appears to be a function signature, not a REST API endpoint) ### Endpoint N/A ### Parameters - **rA** (polygon_t::ring_type &) - Description not provided - **rB** (const polygon_t::ring_type &) - Description not provided - **nfp** (const nfp_t &) - Description not provided - **inside** (const bool &) - Description not provided - **result** (point_t &) - Description not provided ### Return Value - **SearchStartResult** - Description not provided ``` -------------------------------- ### Calculate Initial Translation for NFP Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/libnfporb_8hpp_source.html Computes the initial translation vector required to align the starting points of the two polygons for NFP calculation. This translation is based on the determined start points. ```cpp [point_t](classlibnfporb_1_1point__t.html) transB = { pAstart - pBstart }; ``` -------------------------------- ### Generate NFP with generate_nfp Source: https://context7.com/kallaballa/libnfporb/llms.txt Illustrates the full workflow of defining polygons, generating an NFP, and handling potential runtime errors. ```cpp #include "libnfporb.hpp" using namespace libnfporb; int main() { // Define two polygons polygon_t stationary; stationary.outer().push_back(point_t(0, 0)); stationary.outer().push_back(point_t(100, 0)); stationary.outer().push_back(point_t(100, 100)); stationary.outer().push_back(point_t(0, 100)); stationary.outer().push_back(point_t(0, 0)); bg::correct(stationary); polygon_t orbiting; orbiting.outer().push_back(point_t(0, 0)); orbiting.outer().push_back(point_t(30, 0)); orbiting.outer().push_back(point_t(30, 30)); orbiting.outer().push_back(point_t(0, 30)); orbiting.outer().push_back(point_t(0, 0)); bg::correct(orbiting); try { // Generate NFP with validity checking enabled nfp_t nfp = generate_nfp(stationary, orbiting, true); // NFP generated successfully std::cout << "NFP has " << nfp.size() << " ring(s)" << std::endl; std::cout << "Outer ring has " << nfp.front().size() << " points" << std::endl; // Skip validity check for performance (use with caution) // nfp_t nfp_fast = generate_nfp(stationary, orbiting, false); } catch (const std::runtime_error& e) { std::cerr << "NFP generation failed: " << e.what() << std::endl; return 1; } return 0; } ``` -------------------------------- ### Read polygons from WKT files Source: https://context7.com/kallaballa/libnfporb/llms.txt Demonstrates loading polygon data from WKT files and using them to generate an NFP. ```cpp #include "libnfporb.hpp" using namespace libnfporb; int main(int argc, char** argv) { polygon_t polygonA; polygon_t polygonB; // Read polygons from WKT files // File content example: POLYGON((30 30,40 30,40 40,30 40,30 30)) read_wkt_polygon("data/handcrafted/crossing/A.wkt", polygonA); read_wkt_polygon("data/handcrafted/crossing/B.wkt", polygonB); // WKT format for polygon with hole: // POLYGON((0 0,100 0,100 100,0 100,0 0),(25 25,75 25,75 75,25 75,25 25)) // Generate NFP from loaded polygons nfp_t nfp = generate_nfp(polygonA, polygonB, true); return 0; } ``` -------------------------------- ### SearchStartResult Enum Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/search__start_8hpp_source.html Enumeration for the possible outcomes of a search start operation. ```APIDOC ## enum SearchStartResult ### Description Defines the possible results when attempting to find a starting point for a search or collision detection. ### Enum Values - **FIT**: Indicates that a perfect fit was found. - **FOUND**: Indicates that a valid position was found, but not necessarily a perfect fit. - **NOT_FOUND**: Indicates that no suitable position was found. ``` -------------------------------- ### libnfporb Algorithm Headers Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/dir_8111f045ab156cab490d6e0f8a4c6c64.html List of available header files in the src/algo directory for the libnfporb library. ```APIDOC ## Algorithm Header Files ### Description The following header files are available in the `src/algo` directory of the libnfporb project. ### Files - **find_feasible.hpp** - Algorithm for finding feasible solutions. - **search_start.hpp** - Algorithm for determining search starting points. - **select_next.hpp** - Algorithm for selecting the next step in the process. - **slide.hpp** - Algorithm for sliding operations. - **touching_point.hpp** - Algorithm for identifying touching points. - **trim_vector.hpp** - Algorithm for trimming vectors. ``` -------------------------------- ### GET /in_nfp Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/libnfporb_8hpp_source.html Checks if a specific point exists within a given NFP structure. ```APIDOC ## GET /in_nfp ### Description Checks if a point exists in a NFP. ### Method GET ### Endpoint /in_nfp ### Parameters #### Query Parameters - **pt** (point_t) - Required - The point to check - **nfp** (nfp_t) - Required - The NFP structure to search within ### Response #### Success Response (200) - **result** (bool) - True if the point exists in the NFP, false otherwise ``` -------------------------------- ### Static Method: apply Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/structboost_1_1geometry_1_1math_1_1detail_1_1equals_3_01libnfporb_1_1LongDouble_00_01false_01_4.html The apply method provides a static interface to compare two libnfporb::LongDouble objects based on a provided policy. ```APIDOC ## static bool apply(lhs, rhs, policy) ### Description Compares two libnfporb::LongDouble objects for equality using a specified policy. ### Parameters - **lhs** (libnfporb::LongDouble) - Required - The left-hand side value to compare. - **rhs** (libnfporb::LongDouble) - Required - The right-hand side value to compare. - **policy** (Policy) - Required - The comparison policy to apply. ### Response - **bool** - Returns true if the values are considered equal according to the policy, false otherwise. ``` -------------------------------- ### Generate NFP from WKT Polygons Source: https://context7.com/kallaballa/libnfporb/llms.txt Demonstrates the complete workflow of loading polygons from WKT files, generating the NFP, and exporting the result to an SVG file. ```cpp // Compile: g++ -o nfp nfp.cpp -lboost_system -lgmp // Run: ./nfp data/handcrafted/crossing/A.wkt data/handcrafted/crossing/B.wkt // Optional: Enable for complex geometries with precision issues // #define LIBNFP_USE_RATIONAL // Optional: Enable for debug output during NFP generation // #define NFP_DEBUG #include "libnfporb.hpp" #include int main(int argc, char** argv) { if (argc != 3) { std::cerr << "Usage: " << argv[0] << " " << std::endl; return 1; } using namespace libnfporb; polygon_t pA; polygon_t pB; // Read polygons from WKT files // Example A.wkt: POLYGON((30 30,40 30,40 40,30 40,30 50,40 50,40 60,50 60,50 50,60 50,60 40,50 40,50 30,60 30,70 50,50 70,40 70,20 50)) // Example B.wkt: POLYGON((50 30,50 20,60 20,60 30)) read_wkt_polygon(argv[1], pA); read_wkt_polygon(argv[2], pB); try { // Generate NFP with polygon validity checking // Set third parameter to false to skip validation for performance nfp_t nfp = generate_nfp(pA, pB, true); // Write SVG visualization // Green = polygon A (stationary) // Orange = polygon B (orbiting) // Blue = NFP (no-fit polygon) write_svg("nfp.svg", pA, pB, nfp); std::cout << "NFP generated successfully!" << std::endl; std::cout << "Output written to nfp.svg" << std::endl; std::cout << "NFP contains " << nfp.size() << " ring(s)" << std::endl; } catch (const std::runtime_error& e) { std::cerr << "Error: " << e.what() << std::endl; return 1; } return 0; } ``` -------------------------------- ### Find Extreme Y-Coordinates for Polygons Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/libnfporb_8hpp_source.html Identifies indices of vertices with minimum Y in polygon A and maximum Y in polygon B. Used to determine starting points for NFP calculations. ```cpp std::vector yAminI = [find_minimum_y](namespacelibnfporb.html#a6e84c3110a3df3edf346de96c14625fe)(pA); std::vector yBmaxI = [find_maximum_y](namespacelibnfporb.html#acca4f428f8d3159f5f97a8dabb227e4c)(pB); ``` -------------------------------- ### Boost Geometry Math Details Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/geometry_8hpp_source.html Details on Boost.Geometry's math implementations for `LongDouble`. ```APIDOC ## BOOST MATH DETAIL ABS ### Description Provides the absolute value function for `libnfporb::LongDouble`. ### Method Not applicable (static method provided) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp static libnfporb::LongDouble apply(libnfporb::LongDouble const &value); ``` ### Response #### Success Response (200) - **libnfporb::LongDouble** - The absolute value of the input. #### Response Example ```cpp // Example return value structure 123.45 ``` ``` ```APIDOC ## BOOST MATH DETAIL EQUALS ### Description Provides an equality comparison function for `libnfporb::LongDouble` with a policy. ### Method Not applicable (static method provided) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp static bool apply(libnfporb::LongDouble const &lhs, libnfporb::LongDouble const &rhs, Policy const &policy); ``` ### Response #### Success Response (200) - **bool** - True if the values are considered equal based on the policy, false otherwise. #### Response Example ```cpp // Example return value structure true ``` ``` ```APIDOC ## BOOST MATH DETAIL SMALLER ### Description Provides a less-than comparison function for `libnfporb::LongDouble`. ### Method Not applicable (static method provided) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp static bool apply(libnfporb::LongDouble const &lhs, libnfporb::LongDouble const &rhs); ``` ### Response #### Success Response (200) - **bool** - True if lhs is smaller than rhs, false otherwise. #### Response Example ```cpp // Example return value structure false ``` ``` ```APIDOC ## BOOST MATH DETAIL SQUARE ROOT ### Description Provides the square root function for `libnfporb::LongDouble`. ### Method Not applicable (static method provided) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp static libnfporb::LongDouble apply(libnfporb::LongDouble const &a); ``` ### Response #### Success Response (200) - **libnfporb::LongDouble** - The square root of the input. #### Response Example ```cpp // Example return value structure 5.0 ``` ``` -------------------------------- ### Define Geometry Header and Dependencies Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/geometry_8hpp_source.html Includes necessary standard libraries and Boost Geometry headers, with conditional support for rational arithmetic via Boost Multiprecision. ```cpp #ifndef SRC_GEOMETRY_HPP_ #define SRC_GEOMETRY_HPP_ #include #include #include #include #ifdef LIBNFP_USE_RATIONAL #include #include #endif #include #include #include #include #include #include #ifdef LIBNFP_USE_RATIONAL namespace bm = boost::multiprecision; #endif namespace bg = boost::geometry; namespace trans = boost::geometry::strategy::transform; ``` -------------------------------- ### Function Documentation Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/namespacelibnfporb.html Documentation for various functions within the libnfporb library. ```APIDOC ## Functions ### convert() (1/2) Converts a `polygon_t` to a `polygonf_t` because the boost svg mapper cannot handle custom types directly. `polygonf_t` uses `long double` for coordinates. #### Parameters - **p** (const polygon_t &) - The polygon to convert. #### Returns - A converted copy of `p`. ```cpp polygonf_t libnfporb::convert(const polygon_t & p); ``` ### convert() (2/2) Converts a `polygon_t::ring_type` to a `polygonf_t::ring_type` for compatibility with boost svg mappers, using `long double` for coordinates. #### Parameters - **r** (const polygon_t::ring_type &) - The ring to convert. #### Returns - A converted copy of `r`. ```cpp polygonf_t::ring_type libnfporb::convert(const polygon_t::ring_type & r); ``` ### count() Counts the occurrences of a specific translation vector within a given history. #### Parameters - **h** (const History &) - The history to search within. - **tv** (const TranslationVector &) - The translation vector to count. #### Returns - The number of times the translation vector appears in the history. ```cpp size_t libnfporb::count(const History & h, const TranslationVector & tv); ``` ### delete_consecutive_repeating_point_patterns() Deletes consecutive repeating point patterns (oscillations and loops) from a given ring. #### Parameters - **ring** (polygon_t::ring_type &) - A reference to the ring to be modified. #### Returns - `true` if the ring was changed, `false` otherwise. ```cpp bool libnfporb::delete_consecutive_repeating_point_patterns(polygon_t::ring_type & ring); ``` ### equals() (1/3) Compares two `LongDouble` values for equality. #### Parameters - **lhs** (const LongDouble &) - The left-hand side value. - **rhs** (const LongDouble &) - The right-hand side value. #### Returns - `true` if the values are equal, `false` otherwise. ```cpp bool libnfporb::equals(const LongDouble & lhs, const LongDouble & rhs); ``` ### equals() (2/3) Compares two `point_t` objects for equality. #### Parameters - **lhs** (const point_t &) - The left-hand side point. - **rhs** (const point_t &) - The right-hand side point. #### Returns - `true` if the points are equal, `false` otherwise. ```cpp bool libnfporb::equals(const point_t & lhs, const point_t & rhs); ``` ### equals() (3/3) Compares two `segment_t` objects for equality. #### Parameters - **lhs** (const segment_t &) - The left-hand side segment. - **rhs** (const segment_t &) - The right-hand side segment. #### Returns - `true` if the segments are equal, `false` otherwise. ```cpp bool libnfporb::equals(const segment_t & lhs, const segment_t & rhs); ``` ### find() (1/2) Finds a translation vector within a history, starting from a specified offset. #### Parameters - **h** (const History &) - The history to search within. - **tv** (const TranslationVector &) - The translation vector to find. - **offset** (const off_t &) - The index offset to start searching from (defaults to 0). #### Returns - The offset of the found translation vector, or an indicator if not found (specific return value for not found is not detailed in the source). ```cpp off_t libnfporb::find(const History & h, const TranslationVector & tv, const off_t & offset = 0); ``` ``` -------------------------------- ### Find TranslationVector in History with Equality Predicate Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/history_8hpp_source.html Searches for a TranslationVector in a History object using the default equality predicate. Returns the index of the first match or -1 if not found. The search starts from the specified offset. ```cpp off_t find(const History& h, const TranslationVector& tv, const off_t& offset = 0) { if(offset < 0) return -1; for(size_t i = offset; i < h.size(); ++i) { if (find(h, tv, [](const TranslationVector& lhs, const TranslationVector& rhs){ return lhs == rhs; }, offset)) { return i; } } return -1; } ``` -------------------------------- ### boost::geometry::math::detail::abs< libnfporb::LongDouble > Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/structboost_1_1geometry_1_1math_1_1detail_1_1abs_3_01libnfporb_1_1LongDouble_01_4-members.html Documentation for the apply method within the abs structure for LongDouble types. ```APIDOC ## Method: apply ### Description Calculates the absolute value for a libnfporb::LongDouble type. ### Signature static inline libnfporb::LongDouble apply(libnfporb::LongDouble const &value) ### Parameters - **value** (libnfporb::LongDouble const &) - The input value to calculate the absolute value for. ``` -------------------------------- ### Find TranslationVector in History with Custom Predicate Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/history_8hpp_source.html Searches for a TranslationVector in a History object using a custom predicate function. Returns the index of the first match or -1 if not found. The search starts from the specified offset. ```cpp #ifndef SRC_HISTORY_HPP_ #define SRC_HISTORY_HPP_ #include "geometry.hpp" #include "translation_vector.hpp" namespace libnfporb { typedef std::vector History; off_t find(const History& h, const TranslationVector& tv, std::function predicate, const off_t& offset = 0) { if(offset < 0) return -1; for(size_t i = offset; i < h.size(); ++i) { if (predicate(h[i], tv)) { return i; } } return -1; } ``` -------------------------------- ### Determine Alignment and Add Potential Vectors Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/find__feasible_8hpp_source.html Calculates alignment between segments and adds potential translation vectors based on the alignment. Handles LEFT and RIGHT alignments, pushing vectors to potentialVectors. Used when segments meet at an end and start. ```cpp al = [get_alignment](namespacelibnfporb.html#a821049b74c902ecafa0da3b19464717d)(a1, b2.second); if (al == [LEFT](namespacelibnfporb.html#ab8d12caab4bf53479cc06d350cd5706faad2f75e6345098a73fba38cae5ad5703)) { //no feasible translation [DEBUG_MSG](geometry_8hpp.html#ae18601ba88bb34208da9e4a0f11fa983)("not feasible", a1.second - a1.first); } else if (al == [RIGHT](namespacelibnfporb.html#ab8d12caab4bf53479cc06d350cd5706fa3fb8da88633a285b8fca71c579077015)) { potentialVectors.push_back( { a1.second - a1.first, a1, true, "vertex5" }); } else { potentialVectors.push_back( { a1.second - a1.first, a1, true, "vertex6" }); } al = [get_alignment](namespacelibnfporb.html#a821049b74c902ecafa0da3b19464717d)(a2, b1.second); if (al == [LEFT](namespacelibnfporb.html#ab8d12caab4bf53479cc06d350cd5706faad2f75e6345098a73fba38cae5ad5703)) { potentialVectors.push_back( { b1.first - b1.second, b1, false, "vertex7" }); } else if (al == [RIGHT](namespacelibnfporb.html#ab8d12caab4bf53479cc06d350cd5706fa3fb8da88633a285b8fca71c579077015)) { potentialVectors.push_back( { b1.first - b1.second, b1, false, "vertex8" }); } else { potentialVectors.push_back( { b1.first - b1.second, b1, false, "vertex9" }); } ``` -------------------------------- ### boost::geometry::math::detail Namespace Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/namespaceboost_1_1geometry_1_1math_1_1detail.html This section details the structures available within the boost::geometry::math::detail namespace for the libnfporb library. ```APIDOC ## Namespace boost::geometry::math::detail ### Description This namespace contains detail implementations for mathematical operations within the Boost.Geometry library, specialized for libnfporb's LongDouble type. ### Classes - **struct square_root< libnfporb::LongDouble >** - Description: Represents the square root operation for libnfporb::LongDouble. - **struct abs< libnfporb::LongDouble >** - Description: Represents the absolute value operation for libnfporb::LongDouble. - **struct equals< libnfporb::LongDouble, false >** - Description: Represents an equality comparison for libnfporb::LongDouble with a specific tolerance. - **struct smaller< libnfporb::LongDouble >** - Description: Represents a less-than comparison for libnfporb::LongDouble. ``` -------------------------------- ### Namespace List Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/namespaces.html Lists all namespaces within the libnfporb API and their associated elements. ```APIDOC ## Namespace List This section provides a hierarchical view of all namespaces available in the libnfporb library. ### Namespaces - **boost** - **geometry** - **math** - **detail** - `square_root< libnfporb::LongDouble >` - `abs< libnfporb::LongDouble >` - `equals< libnfporb::LongDouble, false >` - `smaller< libnfporb::LongDouble >` - **numeric** - `raw_converter< boost::numeric::conversion_traits< double, libnfporb::LongDouble > >` - **libnfporb** - `LongDouble` - `point_t` - `TranslationVector` - `TouchingPoint` - **std** - `numeric_limits< libnfporb::LongDouble >` ### Classes and Structs - **boost::geometry::math::detail::square_root< libnfporb::LongDouble >** - **boost::geometry::math::detail::abs< libnfporb::LongDouble >** - **boost::geometry::math::detail::equals< libnfporb::LongDouble, false >** - **boost::geometry::math::detail::smaller< libnfporb::LongDouble >** - **boost::numeric::raw_converter< boost::numeric::conversion_traits< double, libnfporb::LongDouble > >** - **libnfporb::LongDouble** - **libnfporb::point_t** - **libnfporb::TranslationVector** - **libnfporb::TouchingPoint** - **std::numeric_limits< libnfporb::LongDouble >** * * * Generated by doxygen ``` -------------------------------- ### libnfporb Namespace Overview Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/namespacelibnfporb.html This section outlines the core components available within the libnfporb namespace, including geometric primitives and type definitions. ```APIDOC ## libnfporb Namespace ### Description The libnfporb namespace contains the primary data structures and utility functions for handling geometric operations, specifically focused on polygon processing and translation. ### Classes - **LongDouble**: High-precision floating point representation. - **point_t**: Standard point structure. - **TranslationVector**: Structure representing a translation vector. - **TouchingPoint**: Structure representing a point of contact. ### Typedefs - **coord_t**: Alias for LongDouble. - **segment_t**: Boost geometry segment using point_t. - **polygon_t**: Boost geometry polygon using point_t. - **nfp_t**: Vector of polygon rings. - **linestring_t**: Boost geometry linestring using point_t. - **pointf_t**: Boost geometry point_xy using long double. ### Enumerations - **Alignment**: {LEFT, RIGHT, ON} - **SearchStartResult**: {FIT, FOUND, NOT_FOUND} - **SlideResult**: {LOOP, NO_LOOP, NO_TRANSLATION} ``` -------------------------------- ### Define and manipulate polygon_t Source: https://context7.com/kallaballa/libnfporb/llms.txt Demonstrates programmatic creation of a polygon, ensuring correct orientation and closure, and accessing ring structures. ```cpp #include "libnfporb.hpp" using namespace libnfporb; // Create a polygon programmatically polygon_t square; square.outer().push_back(point_t(0, 0)); square.outer().push_back(point_t(10, 0)); square.outer().push_back(point_t(10, 10)); square.outer().push_back(point_t(0, 10)); square.outer().push_back(point_t(0, 0)); // Close the ring // Correct the polygon orientation and closure bg::correct(square); // Access polygon properties auto& outer_ring = square.outer(); auto& inner_rings = square.inners(); // For polygons with holes ``` -------------------------------- ### libnfporb::point_t Structure Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/functions_func.html Overview of the point_t structure and its supported operators. ```APIDOC ## libnfporb::point_t ### Description The point_t structure represents a point in the libnfporb library, supporting basic arithmetic and comparison operations. ### Available Operators - **Arithmetic**: operator+(), operator-() - **Comparison**: operator<() ``` -------------------------------- ### boost::geometry Namespace Reference Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/namespaceboost_1_1geometry.html Overview of the boost::geometry namespace structure within the libnfporb library. ```APIDOC ## boost::geometry Namespace ### Description This namespace contains the geometry-related functionality provided by the libnfporb library, leveraging the boost::geometry framework. ### Namespaces - **math** (namespace) - Contains mathematical utilities and functions for geometric operations. ``` -------------------------------- ### void write_svg(std::string const& filename, const polygon_t& p, const polygon_t::ring_type& ring) Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/svg_8hpp_source.html Writes a polygon and a ring to an SVG file. ```APIDOC ## write_svg (polygon and ring) ### Description Writes a polygon and a specific ring to an SVG file, applying different styles to each. ### Parameters - **filename** (std::string) - Required - The path to the output SVG file. - **p** (polygon_t) - Required - The polygon to render. - **ring** (polygon_t::ring_type) - Required - The ring to render. ``` -------------------------------- ### libnfporb::TouchingPoint Variables Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/functions_vars.html Lists the variables available within the libnfporb::TouchingPoint structure. ```APIDOC ## Variables in libnfporb::TouchingPoint ### Description This section lists the member variables of the `TouchingPoint` structure in the `libnfporb` library. ### Variables - **A_** : [libnfporb::TouchingPoint](structlibnfporb_1_1TouchingPoint.html#ac1374a2f822841422b7fd2379554d41f) - **B_** : [libnfporb::TouchingPoint](structlibnfporb_1_1TouchingPoint.html#a75de8d3c56c6d69aa2ca36d642af1c27) ``` -------------------------------- ### Segment and Point Comparison Utilities Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/geometry_8hpp_source.html Utility functions for comparing segments and points, including equality and ordering operators. ```cpp bool equals(const segment_t& lhs, const segment_t& rhs) { return equals(lhs.first, rhs.first) && equals(lhs.second, rhs.second); } ``` ```cpp bool operator<(const segment_t& lhs, const segment_t& rhs) { return lhs.first < rhs.first || (equals(lhs.first, rhs.first) && (lhs.second < rhs.second)); } ``` -------------------------------- ### static bool apply() Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/structboost_1_1geometry_1_1math_1_1detail_1_1smaller_3_01libnfporb_1_1LongDouble_01_4.html Compares two libnfporb::LongDouble objects to determine if the left-hand side is smaller than the right-hand side. ```APIDOC ## static bool apply() ### Description Compares two libnfporb::LongDouble objects to determine if the left-hand side is smaller than the right-hand side. ### Parameters - **lhs** (libnfporb::LongDouble const &) - Required - The left-hand side operand. - **rhs** (libnfporb::LongDouble const &) - Required - The right-hand side operand. ### Response - **bool** - Returns true if lhs is smaller than rhs, otherwise false. ``` -------------------------------- ### Coordinate Constants and Equality Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/geometry_8hpp_source.html Defines coordinate bounds and equality comparison functions for libnfporb types. ```cpp bool equals(const LongDouble& lhs, const LongDouble& rhs); #ifdef LIBNFP_USE_RATIONAL bool equals(const rational_t& lhs, const rational_t& rhs); #endif const coord_t MAX_COORD = 999999999999999999; const coord_t MIN_COORD = std::numeric_limits::min(); ``` -------------------------------- ### libnfporb Class List Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/annotated.html Lists the classes, structs, unions, and interfaces within the libnfporb library and its associated namespaces. ```APIDOC ## libnfporb API Reference - Class List ### Description This section lists the available classes, structs, unions, and interfaces within the libnfporb library, organized by namespace. ### Namespaces and Classes **Namespace: boost::geometry::math::detail** - `square_root< libnfporb::LongDouble >` - `abs< libnfporb::LongDouble >` - `equals< libnfporb::LongDouble, false >` - `smaller< libnfporb::LongDouble >` **Namespace: boost::numeric** - `raw_converter< boost::numeric::conversion_traits< double, libnfporb::LongDouble > >` **Namespace: libnfporb** - `LongDouble` (class) - `point_t` (class) - `TranslationVector` (struct) - `TouchingPoint` (struct) **Namespace: std** - `numeric_limits< libnfporb::LongDouble >` ``` -------------------------------- ### Enable Arbitrary Precision Arithmetic Source: https://context7.com/kallaballa/libnfporb/llms.txt Define `LIBNFP_USE_RATIONAL` before including the library header to enable arbitrary precision arithmetic using GMP. This mode is slower but mitigates floating-point precision issues, making it more robust for complex edge cases. ```cpp // Enable arbitrary precision (must be before include) #define LIBNFP_USE_RATIONAL // Enable debug output (optional) // #define NFP_DEBUG #include "libnfporb.hpp" using namespace libnfporb; int main() { polygon_t pA, pB; read_wkt_polygon("complex_A.wkt", pA); read_wkt_polygon("complex_B.wkt", pB); // NFP generation now uses arbitrary precision // Slower but more robust for edge cases nfp_t nfp = generate_nfp(pA, pB, true); write_svg("precise_nfp.svg", pA, pB, nfp); return 0; } ``` -------------------------------- ### LongDouble Constructors Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/classlibnfporb_1_1LongDouble.html Constructors for initializing the LongDouble object. ```APIDOC ## LongDouble Constructors ### Description Initializes a new instance of the LongDouble class. ### Methods - **LongDouble()** - Default constructor. - **LongDouble(const long double &val)** - Constructor with initial value. ### Parameters #### Request Body - **val** (long double) - Optional - The initial value for the LongDouble object. ``` -------------------------------- ### void write_svg(filename, pA, pB, nfp) Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/svg_8hpp_source.html Writes a visualization of two polygons and their corresponding No-Fit Polygon (NFP) to an SVG file. ```APIDOC ## void write_svg(std::string const& filename, const polygon_t& pA, const polygon_t& pB, const nfp_t& nfp) ### Description Generates an SVG file representing two input polygons (pA, pB) and the calculated No-Fit Polygon (nfp). The output uses the Boost Geometry SVG mapper to visualize the shapes with specific styling. ### Parameters #### Path Parameters - **filename** (std::string) - Required - The path to the output SVG file. - **pA** (polygon_t) - Required - The first polygon to visualize. - **pB** (polygon_t) - Required - The second polygon to visualize. - **nfp** (nfp_t) - Required - The No-Fit Polygon data to visualize. ``` -------------------------------- ### Constants and Macros Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/geometry_8hpp.html Defines constants and macros for coordinate limits and debugging. ```APIDOC ## Constants ### MAX_COORD - **Type**: coord_t - **Value**: 999999999999999999 - **Description**: Represents the maximum coordinate value. ### MIN_COORD - **Type**: coord_t - **Value**: std::numeric_limits::min() - **Description**: Represents the minimum coordinate value. ### INVALID_POINT - **Type**: point_t - **Value**: { MAX_COORD, MAX_COORD } - **Description**: Represents an invalid or uninitialized point. ## Macros ### DEBUG_MSG - **Description**: Macro for debugging messages. ### DEBUG_VAL - **Description**: Macro for debugging values. ``` -------------------------------- ### search_start_translation Function Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/search__start_8hpp_source.html Attempts to find a translation that results in a 'FIT' or 'FOUND' state for two polygons, considering an 'inside' flag. ```APIDOC ## SearchStartResult search_start_translation(polygon_t::ring_type& rA, const polygon_t::ring_type& rB, const nfp_t& nfp, const bool& inside, point_t& result) ### Description This function iterates through potential translations of polygon `rB` relative to `rA`. It checks for geometric fits, containment, and overlap conditions based on the `inside` flag and NFP constraints. The `result` parameter is updated with the translation vector if a suitable position is found. ### Method N/A (Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (SearchStartResult) - **FIT**: A translation was found where `rB` perfectly aligns with `rA`. - **FOUND**: A translation was found where `rB` is contained within `rA` or vice-versa, satisfying the `inside` condition and NFP constraints. - **NOT_FOUND**: No suitable translation was found based on the given criteria. #### Response Example ```json { "example": "FIT" } ``` ``` -------------------------------- ### boost::geometry::math Namespace Source: https://github.com/kallaballa/libnfporb/blob/master/apidoc/namespaceboost_1_1geometry_1_1math.html Overview of the namespace structure for the math components within the geometry library. ```APIDOC ## Namespace: boost::geometry::math ### Description This namespace contains mathematical utilities and functions used within the boost::geometry framework as implemented in libnfporb. ### Namespaces - **detail** (namespace) - Internal implementation details for math operations. ```