### Property Merge Usage Example Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_property_merge.htm Demonstrates the usage of the n-layer map-overlay algorithm on polygon data with associated properties. This example requires the 'property_merge_usage.cpp' file. ```cpp #include #include #include #include #include int main() { typedef int coordinate_type; typedef int property_type; typedef std::set property_set_type; typedef std::vector property_vector_type; typedef boost::polygon::polygon_set_data polygon_set_data_type; boost::polygon::property_merge pm; // Example polygon set and property polygon_set_data_type ps1; // ... populate ps1 with polygon data ... property_type prop1 = 1; pm.insert(ps1, prop1); // Example geometry object and property // Assume GeoObjT is a type that can be inserted // GeoObjT geoObj1; // ... populate geoObj1 ... property_type prop2 = 2; // pm.insert(geoObj1, prop2); // Result containers std::map result_set; std::map result_vector; // Perform property merge pm.merge(result_set); // pm.merge(result_vector); return 0; } ``` -------------------------------- ### Main Application Entry Point Source: https://www.boost.org/doc/libs/latest/libs/polygon/example/voronoi_visualizer.cpp The main function initializes the Qt application, creates the MainWindow, shows it, and starts the event loop. ```cpp int main(int argc, char* argv[]) { QApplication app(argc, argv); MainWindow window; window.show(); return app.exec(); } ``` -------------------------------- ### Main Function Example Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/tutorial/minkowski.cpp Demonstrates the creation and manipulation of polygon sets using rectangle and point data, including Minkowski sum operations. ```cpp int main(int argc, char **argv) { polygon_set a, b, c; a += boost::polygon::rectangle_data(0, 0, 1000, 1000); a -= boost::polygon::rectangle_data(100, 100, 900, 900); a += boost::polygon::rectangle_data(1000, -1000, 1010, -990); std::vector polys; std::vector pts; pts.push_back(point(-40, 0)); pts.push_back(point(-10, 10)); pts.push_back(point(0, 40)); pts.push_back(point(10, 10)); pts.push_back(point(40, 0)); pts.push_back(point(10, -10)); pts.push_back(point(0, -40)); pts.push_back(point(-10, -10)); pts.push_back(point(-40, 0)); polygon poly; boost::polygon::set_points(poly, pts.begin(), pts.end()); b+=poly; pts.clear(); ``` -------------------------------- ### Populate connectivity database from layout pins Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/tutorial/connectivity_database.hpp Initializes and populates the connectivity database using a list of layout pins and a layout database. This is a setup function for further processing. ```cpp //given a layout_database we populate a connectivity database inline void populate_connectivity_database(connectivity_database& connectivity, std::vector& pins, layout_database& layout) { using namespace boost::polygon; using namespace boost::polygon::operators; ``` -------------------------------- ### Point Coordinate Accessors and Mutators Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_point_concept.htm Explains how to get and set the coordinates of a point. ```APIDOC ## Coordinate Accessors and Mutators ### Get Coordinate by Orientation ```cpp T get(orientation_2d orient) const; ``` Gets the coordinate in the specified orientation. ### Get X Coordinate ```cpp T x() const; ``` Gets the coordinate in the horizontal orientation. ### Get Y Coordinate ```cpp T y() const; ``` Gets the coordinate in the vertical orientation. ### Set Coordinate by Orientation ```cpp void set(orientation_2d orient, T value); ``` Sets the coordinate in the specified orientation to the given value. ### Set X Coordinate ```cpp void x(T value); ``` Sets the coordinate in the horizontal orientation to the given value. ### Set Y Coordinate ```cpp void y(T value); ``` Sets the coordinate in the vertical orientation to the given value. ``` -------------------------------- ### Initiate Schematic Comparison Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/tutorial/compare_schematics.hpp Initializes and starts the recursive comparison of two schematics. It sets up the necessary data structures for the recursive function. ```cpp //this is a trivial brute force comparison algorithm because comparing //schematics does not require the use of Boost.Polygon and doing it more //optimally does not add to the tutorial inline bool compare_schematics(schematic_database& reference_schematic, schematic_database& schematic) { std::vector reference_to_internal_device_map(reference_schematic.devices.size(), 0); std::set assigned_devices; return compare_schematics_recursive(reference_schematic, schematic, reference_to_internal_device_map, assigned_devices, 0); } ``` -------------------------------- ### Get direction_2d from orientation_2d Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_isotropy.htm Demonstrates how to obtain a direction_2d from an orientation_2d by passing a direction_1d. This illustrates the interaction between isotropic types. ```cpp orientation_2d orient = HORIZONTAL; direction_2d dir = orient.get_direction(direction_1d(HIGH)); assert(dir == EAST); ``` -------------------------------- ### Polygon Clipping and Union Operation Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/index.htm Demonstrates clipping a list of polygons against a bounding box and performing a union operation. This example showcases the use of overloaded operators for polygon manipulation. ```cpp const list& b, int deflateValue) { CBoundingBox domainExtent; using namespace boost::polygon::operators; boost::polygon::extents(domainExtent, a); result += (b & domainExtent) ^ (a - deflateValue); } ``` -------------------------------- ### Test Convolution of Two Polygon Sets Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_minkowski_tutorial.htm Tests the convolution of two polygon sets, producing the first example shown in the tutorial. It defines two polygon sets 'a' and 'b' and then computes their convolution into 'c'. ```cpp polygon_set a, b, c; a += boost::polygon::rectangle_data(0+300, 0, 200+300, 200); a -= boost::polygon::rectangle_data(50+300, 50, 150+300, 150); std::vector polys; std::vector pts; pts.push_back(point(-40, 0+300)); pts.push_back(point(-10, 10+300)); pts.push_back(point(0, 40+300)); pts.push_back(point(10, 10+300)); pts.push_back(point(40, 0+300)); pts.push_back(point(10, -10+300)); pts.push_back(point(0, -40+300)); pts.push_back(point(-10, -10+300)); pts.push_back(point(-40, 0+300)); polygon poly; boost::polygon::set_points(poly, pts.begin(), pts.end()); b+=poly; polys.clear(); convolve_two_polygon_sets(c, a, b); ``` -------------------------------- ### Voronoi Vertex Accessors and Mutators Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/voronoi_diagram.htm Provides methods to get and set the start and end vertices of a Voronoi edge. ```APIDOC ## vertex0, vertex1 ### Description Accessors and mutators for the start and end vertices of the Voronoi edge. ### Methods - **vertex0()** (voronoi_vertex_type*): Returns the pointer to the start point of the edge. Returns NULL if the edge is infinite in that direction. - **vertex0() const** (const voronoi_vertex_type*): Returns the const pointer to the start point vertex of the edge. Returns NULL if the edge is infinite in that direction. - **vertex0(voronoi_vertex_type* v)**: Sets the start point pointer of the edge. - **vertex1()** (voronoi_vertex_type*): Returns the pointer to the end point of the edge. Returns NULL if the edge is infinite in that direction. - **vertex1() const** (const voronoi_vertex_type*): Returns the const pointer to the end point vertex of the edge. Returns NULL if the edge is infinite in that direction. - **vertex1(voronoi_vertex_type* v)**: Sets the end point pointer of the edge. ``` -------------------------------- ### Voronoi Rotated Next and Previous Edge Accessors Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/voronoi_diagram.htm Provides methods to get the CCW next and previous edges rotated around the edge's start point. ```APIDOC ## rot_next, rot_prev ### Description Accessors for the CCW next and previous edges rotated around the edge start point. Works for infinite edges as well. ### Methods - **rot_next()** (voronoi_edge_type*): Returns the pointer to the CCW next edge rotated around the edge start point. - **rot_next() const** (const voronoi_edge_type*): Returns the const pointer to the CCW next edge rotated around the edge start point. - **rot_prev()** (voronoi_edge_type*): Returns the pointer to the CCW prev edge rotated around the edge start point. - **rot_prev() const** (const voronoi_edge_type*): Returns the const pointer to the CCW prev edge rotated around the edge start point. ``` -------------------------------- ### Initialize MainWindow Source: https://www.boost.org/doc/libs/latest/libs/polygon/example/voronoi_visualizer.cpp Constructor for the MainWindow class. Sets up the UI layout, initializes the GLWidget, and configures file handling. ```cpp MainWindow() { glWidget_ = new GLWidget(); file_dir_ = QDir(QDir::currentPath(), tr("*.txt")); file_name_ = tr(""); QHBoxLayout* centralLayout = new QHBoxLayout; centralLayout->addWidget(glWidget_); centralLayout->addLayout(create_file_layout()); setLayout(centralLayout); update_file_list(); setWindowTitle(tr("Voronoi Visualizer")); layout()->setSizeConstraint(QLayout::SetFixedSize); } ``` -------------------------------- ### Main Function for File Comparison Utility Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/tutorial/extract.cpp This is the entry point for the comparison utility. It expects two command-line arguments: the layout file path and the schematic file path. It prints the comparison result to standard output. ```cpp int main(int argc, char **argv) { if(argc < 3) { std::cout << "usage: " << argv[0] << " " << std::endl; return -1; } bool result = compare_files(argv[1], argv[2]); if(result == false) { std::cout << "Layout does not match schematic." << std::endl; return 1; } std::cout << "Layout does match schematic." << std::endl; return 0; } ``` -------------------------------- ### rectangle_data Accessors Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Methods to get and set intervals of the rectangle. ```APIDOC ## rectangle_data Accessors ### Description Provides methods to access and modify the intervals of a rectangle. ### Methods - **interval_data<T>** get(orientation_2d orient) const Get the interval in the given orientation. - **void** set<T2>(orientation_2d orient, const T2& value) Sets the interval in the given orientation to the value of an object that models interval. ``` -------------------------------- ### Hole Iteration Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_45_with_holes_concept.htm Functions to get iterators for the holes of the polygon. ```APIDOC ## begin_holes ### Description Expects a model of polygon_45_with_holes. Returns the begin iterator over the range of coordinates that correspond to horizontal and vertical edges. ### Method `template hole_iterator_type begin_holes(const T& polygon)` ## end_holes ### Description Expects a model of polygon_45_with_holes. Returns the end iterator over the range of coordinates that correspond to horizontal and vertical edges. ### Method `template hole_iterator_type end_holes(const T& polygon)` ``` -------------------------------- ### begin() Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_45_concept.htm Returns an iterator to the beginning of the polygon's vertices. ```APIDOC ## begin() ### Description Get the begin iterator over vertices of the polygon. ### Method const member function ### Endpoint N/A ### Parameters None ### Request Example None ### Response * **iterator_type** - An iterator pointing to the first vertex of the polygon. ``` -------------------------------- ### Point Iteration Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_45_with_holes_concept.htm Functions to get iterators for the vertices of the polygon. ```APIDOC ## begin_points ### Description Expects a model of polygon_45_with_holes. Returns the begin iterator over the range of points that correspond to vertices of the polygon. ### Method `template point_iterator_type begin_points(const T& polygon)` ## end_points ### Description Expects a model of polygon_45_with_holes. Returns the end iterator over the range of points that correspond to vertices of the polygon. ### Method `template point_iterator_type end_points(const T& polygon)` ``` -------------------------------- ### Main Benchmark Execution Source: https://www.boost.org/doc/libs/latest/libs/polygon/benchmark/voronoi_benchmark_points.cpp Sets up precision for output and runs the benchmark tests for Boost.Polygon Voronoi, CGAL Delaunay, and S-Hull Delaunay, then closes the output file. ```C++ int main() { bf << std::setiosflags(std::ios::right | std::ios::fixed) << std::setprecision(6); run_boost_voronoi_test(); run_cgal_delaunay_test(); run_shull_delaunay_test(); bf.close(); } ``` -------------------------------- ### Get Vertical Interval Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the y interval of an object that models rectangle. ```APIDOC ## vertical ### Description Returns the y interval of an object that models rectangle. ### Signature ```cpp template interval_type vertical(const T& rectangle) ``` ``` -------------------------------- ### Main function for benchmarking Source: https://www.boost.org/doc/libs/latest/libs/polygon/benchmark/voronoi_benchmark_segments.cpp Sets up precision for output and runs both Boost.Polygon Voronoi and CGAL Delaunay triangulation benchmarks. Closes the output file stream. ```cpp int main() { bf << std::setiosflags(std::ios::right | std::ios::fixed) << std::setprecision(6); std::vector running_times = get_intersection_runtime(); run_boost_voronoi_test(running_times); run_cgal_delaunay_test(running_times); bf.close(); return 0; } ``` -------------------------------- ### Polygon Iteration Functions Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_concept.htm Functions to get iterators for the vertices of a polygon. ```APIDOC ## begin_points ### Description Expects a model of polygon. Returns the begin iterator over the range of points that correspond to vertices of the polygon. ### Signature `template point_iterator_type begin_points(const T& polygon)` ## end_points ### Description Expects a model of polygon. Returns the end iterator over the range of points that correspond to vertices of the polygon. ### Signature `template point_iterator_type end_points(const T& polygon)` ``` -------------------------------- ### get Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_interval_concept.htm Retrieves the low or high coordinate of an interval based on the direction. ```APIDOC ## get ### Description Expects a model of interval. Returns the low or high coordinate of the interval, depending on the direction_1d value. ### Signature ```cpp template coordinate_type **get**(const T& interval, direction_1d) ``` ``` -------------------------------- ### Get YH Coordinate Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the north coordinate of an object that models rectangle. ```APIDOC ## yh ### Description Returns the north coordinate of an object that models rectangle. ### Signature ```cpp template coordinate_type yh(const T& rectangle) ``` ``` -------------------------------- ### Point Constructors Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_point_concept.htm Demonstrates the different ways to construct a point object. ```APIDOC ## Constructors ### Default Constructor ```cpp point_data(); ``` Default constructs the two coordinate values of the point. ### Parameterized Constructor ```cpp point_data(T x, T y); ``` Constructs a point with two specified coordinates. ### Copy Constructor ```cpp point_data(const point_data& that); ``` Copy constructs a point from another point object. ``` -------------------------------- ### Get YL Coordinate Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the south coordinate of an object that models rectangle. ```APIDOC ## yl ### Description Returns the south coordinate of an object that models rectangle. ### Signature ```cpp template coordinate_type yl(const T& rectangle) ``` ``` -------------------------------- ### Create File Layout Source: https://www.boost.org/doc/libs/latest/libs/polygon/example/voronoi_visualizer.cpp Creates and configures the layout for file selection and control widgets. ```cpp QGridLayout* create_file_layout() { QGridLayout* file_layout = new QGridLayout; message_label_ = new QLabel("Double click item to build voronoi diagram:"); file_list_ = new QListWidget(); file_list_->connect(file_list_, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(build())); QCheckBox* primary_checkbox = new QCheckBox("Show primary edges only."); connect(primary_checkbox, SIGNAL(clicked()), this, SLOT(primary_edges_only())); QCheckBox* internal_checkbox = new QCheckBox("Show internal edges only."); connect(internal_checkbox, SIGNAL(clicked()), this, SLOT(internal_edges_only())); QPushButton* browse_button = new QPushButton(tr("Browse Input Directory")); connect(browse_button, SIGNAL(clicked()), this, SLOT(browse())); browse_button->setMinimumHeight(50); QPushButton* print_scr_button = new QPushButton(tr("Make Screenshot")); connect(print_scr_button, SIGNAL(clicked()), this, SLOT(print_scr())); print_scr_button->setMinimumHeight(50); file_layout->addWidget(message_label_, 0, 0); file_layout->addWidget(file_list_, 1, 0); file_layout->addWidget(primary_checkbox, 2, 0); file_layout->addWidget(internal_checkbox, 3, 0); file_layout->addWidget(browse_button, 4, 0); file_layout->addWidget(print_scr_button, 5, 0); return file_layout; } ``` -------------------------------- ### Construct and Access Point Data Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_point_usage.htm Shows how to construct a point with integer coordinates and access its x and y values using gtl::x and gtl::y. ```cpp #include #include namespace gtl = boost::polygon; using namespace boost::polygon::operators; int main() { //constructing a gtl point typedef gtl::point_data Point; int x = 10; int y = 20; Point pt(x, y); assert(gtl::x(pt) == 10); assert(gtl::y(pt) == 20); //a quick primer in isotropic point access typedef gtl::orientation_2d O; using gtl::HORIZONTAL; using gtl::VERTICAL; O o = HORIZONTAL; assert(gtl::x(pt) == gtl::get(pt, o)); o = o.get_perpendicular(); assert(o == VERTICAL); assert(gtl::y(pt) == gtl::get(pt, o)); gtl::set(pt, o, 30); assert(gtl::y(pt) == 30); //using some of the library functions Point pt2(10, 30); assert(gtl::equivalence(pt, pt2)); gtl::transformation tr(gtl::axis_transformation::SWAP_XY); gtl::transform(pt, tr); assert(gtl::equivalence(pt, Point(30, 10))); gtl::transformation tr2 = tr.inverse(); assert(tr == tr2); //SWAP_XY is its own inverse transform gtl::transform(pt, tr2); assert(gtl::equivalence(pt, pt2)); //the two points are equal again gtl::move(pt, o, 10); //move pt 10 units in y assert(gtl::euclidean_distance(pt, pt2) == 10.0f); gtl::move(pt, o.get_perpendicular(), 10); //move pt 10 units in x assert(gtl::manhattan_distance(pt, pt2) == 20); return 0; } ``` -------------------------------- ### Get XH Coordinate Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the east coordinate of an object that models rectangle. ```APIDOC ## xh ### Description Returns the east coordinate of an object that models rectangle. ### Signature ```cpp template coordinate_type xh(const T& rectangle) ``` ``` -------------------------------- ### Constructors Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_45_set_concept.htm Various constructors for initializing a polygon_45_set_data object. ```APIDOC ## polygon_45_set_data() ### Description Default constructor. Initializes an empty polygon set. ### Method polygon_45_set_data ``` ```APIDOC ## polygon_45_set_data(iT input_begin, iT input_end) ### Description Construct from an iterator range of insertable objects. ### Method polygon_45_set_data ### Parameters #### Path Parameters - **input_begin** (iterator) - Required - Iterator to the beginning of the input range. - **input_end** (iterator) - Required - Iterator to the end of the input range. ``` ```APIDOC ## polygon_45_set_data(const polygon_45_set_data& that) ### Description Copy construct. Creates a new polygon set as a copy of an existing one. ### Method polygon_45_set_data ### Parameters #### Path Parameters - **that** (const polygon_45_set_data&) - Required - The polygon set to copy. ``` ```APIDOC ## polygon_45_set_data(const polygon_45_set_view& t) ### Description Copy construct from a Boolean operator template. Initializes the polygon set based on a view of a boolean operation on other polygon sets. ### Method polygon_45_set_data ### Parameters #### Path Parameters - **t** (const polygon_45_set_view&) - Required - The boolean operation view to construct from. ``` -------------------------------- ### Get XL Coordinate Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the west coordinate of an object that models rectangle. ```APIDOC ## xl ### Description Returns the west coordinate of an object that models rectangle. ### Signature ```cpp template coordinate_type xl(const T& rectangle) ``` ``` -------------------------------- ### Create Input Geometries for Voronoi Diagram Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/voronoi_basic_tutorial.htm Populates vectors with custom Point and Segment objects to serve as input sites for the Voronoi diagram construction. Includes sample points and segments. ```cpp std::vector points; points.push_back(Point(0, 0)); points.push_back(Point(1, 6)); std::vector segments; segments.push_back(Segment(-4, 5, 5, -1)); segments.push_back(Segment(3, -11, 13, -1)); ``` -------------------------------- ### Get Horizontal Interval Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the x interval of an object that models rectangle. ```APIDOC ## horizontal ### Description Returns the x interval of an object that models rectangle. ### Signature ```cpp template interval_type horizontal(const T& rectangle) ``` ``` -------------------------------- ### Voronoi Diagram Construction with Custom Traits Source: https://www.boost.org/doc/libs/latest/libs/polygon/example/voronoi_advanced_tutorial.cpp Main function demonstrating the construction of a Voronoi diagram using custom traits. It generates a specified number of random points with large integer coordinates, builds the Voronoi diagram using `voronoi_builder` and `construct`, and then prints the construction time and statistics of the resulting diagram. ```cpp const unsigned int GENERATED_POINTS = 100; const boost::int64_t MAX = 0x1000000000000LL; int main() { boost::mt19937_64 gen(std::time(0)); boost::random::uniform_int_distribution distr(-MAX, MAX-1); voronoi_builder vb; for (size_t i = 0; i < GENERATED_POINTS; ++i) { boost::int64_t x = distr(gen); boost::int64_t y = distr(gen); vb.insert_point(x, y); } printf("Constructing Voronoi diagram of %d points...\n", GENERATED_POINTS); boost::timer::cpu_timer t; voronoi_diagram vd; t.start(); vb.construct(&vd); boost::timer::cpu_times times = t.elapsed(); std::string ftime = boost::timer::format(times, 5, "%w"); printf("Construction done in: %s seconds.\n", ftime.c_str()); printf("Resulting Voronoi graph has the following stats:\n"); printf("Number of Voronoi cells: %lu.\n", vd.num_cells()); printf("Number of Voronoi vertices: %lu.\n", vd.num_vertices()); printf("Number of Voronoi edges: %lu.\n", vd.num_edges()); return 0; } ``` -------------------------------- ### Main Function for LVS Tool Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_tutorial.htm Entry point for the layout versus schematic (LVS) tool. It checks for the correct number of command-line arguments and calls the compare_files function to perform the comparison, reporting the result to the console. ```cpp int main(int argc, char **argv) { if(argc < 3) { std::cout << "usage: " << argv[0] << " " << std::endl; return -1; } bool result = compare_files(argv[1], argv[2]); if(result == false) { std::cout << "Layout does not match schematic." << std::endl; return 1; } std::cout << "Layout does match schematic." << std::endl; return 0; } ``` -------------------------------- ### Point Access and Modification Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_point_concept.htm Functions for getting and setting coordinates of a point object. ```APIDOC ## get ### Description Expects a model of point. Returns the x or y coordinate of the point, depending on the orientation_2d value. ### Signature ```cpp template coordinate_type **get**(const PointType& point, orientation_2d) ``` ## set ### Description Expects a model of point. Sets the x or y coordinate of the point to the coordinate, depending on the orientation_2d value. ### Signature ```cpp template void **set**(PointType& point, orientation_2d, coordinate_type) ``` ## x (get) ### Description Returns the x coordinate of an object that models point. ### Signature ```cpp template coordinate_type **x**(const PointType& point) ``` ## y (get) ### Description Returns the y coordinate of an object that models point. ### Signature ```cpp template coordinate_type **y**(const PointType& point) ``` ## x (set) ### Description Sets the x coordinate of the object that models point to the coordinate value. ### Signature ```cpp template void **x**(pPointType& point, coordinate_type) ``` ## y (set) ### Description Sets the y coordinate of the object that models point to the coordinate value. ### Signature ```cpp template void **y**(PointType& point, coordinate_type) ``` ``` -------------------------------- ### Main Function to Test Property Merge Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_property_merge_usage.htm The main function serves as an entry point to test the property merge algorithms. It calls the `test_pm` function with both the 90-degree axis-aligned (`property_merge_90`) and the general arbitrary-angle (`property_merge`) versions of the algorithm. ```cpp int main() { test_pm >(); test_pm >(); return 0; } ``` -------------------------------- ### Get Polygon Extents (Bounding Box) Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_with_holes_concept.htm Calculates and sets the bounding box of the polygon. ```APIDOC ## extents ### Description Sets object that models rectangle to the bounding box of an object that models polygon_with_holes and returns true. Returns false and leaves bbox unchanged if polygon is empty. ### Signature ```cpp template bool extents(rectangle_type& bbox, const T& polygon) ``` ``` -------------------------------- ### Accessing Polygon Holes Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_with_holes_concept.htm Provides functions to get iterators for the holes within a polygon. ```APIDOC ## begin_holes ### Description Expects a model of polygon_with_holes. Returns the begin iterator over the range of coordinates that correspond to horizontal and vertical edges of the holes. ### Signature ```cpp template hole_iterator_type begin_holes(const T& polygon) ``` ## end_holes ### Description Expects a model of polygon_with_holes. Returns the end iterator over the range of coordinates that correspond to horizontal and vertical edges of the holes. ### Signature ```cpp template hole_iterator_type end_holes(const T& polygon) ``` ``` -------------------------------- ### Constructors Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_set_concept.htm Various constructors for initializing a polygon_set_data object. ```APIDOC ## Constructors ### Default Constructor ```cpp polygon_set_data(); ``` ### Iterator Range Constructor Constructs a polygon set from an iterator range of insertable objects, considering scanning orientation. ```cpp template polygon_set_data(iT input_begin, iT input_end); ``` ### Copy Constructor Creates a new polygon set by copying an existing one. ```cpp polygon_set_data(const polygon_set_data& that); ``` ### Boolean Operator View Constructor Constructs a polygon set from a boolean operator view. ```cpp template polygon_set_data(const polygon_set_view& t); ``` ``` -------------------------------- ### Parse Schematic Database from File Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/tutorial/schematic_database.hpp Parses a schematic database from an input file stream. It reads device and pin information, populates the devices vector, and then extracts the netlist. ```cpp inline void parse_schematic_database(schematic_database& schematic, std::ifstream& sin) { std::vector& devices = schematic.devices; while(!sin.eof()) { std::string type_id; sin >> type_id; if(type_id == "Device") { device d; sin >> d; devices.push_back(d); } else if (type_id == "Pin") { std::string net; sin >> net; device d; d.type = "PIN"; d.terminals.push_back(net); devices.push_back(d); } else if (type_id == "") { break; } } extract_netlist(schematic.nets, devices); } #endif ``` -------------------------------- ### Polygon Extents and Area Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_90_concept.htm Functions to get the bounding box of a polygon and to calculate its area. ```APIDOC ## extents ### Description Sets object that models rectangle to the bounding box of an object that models polygon_90 and returns true. Returns false and leaves bbox unchanged if polygon is empty. Linear wrt. vertices. ### Signature ```cpp template bool extents(rectangle_type& bbox, const T& polygon) ``` ## area ### Description Returns the area of an object that models polygon_90. Linear wrt. vertices. ### Signature ```cpp template manhattan_area_type area(const T& polygon) ``` ``` -------------------------------- ### Construct and Manipulate a Polygon Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_usage.htm Demonstrates constructing a rectangle-shaped polygon, performing various assertions on its properties like area, containment, and extents. It also shows how to modify the polygon using convolve and scale_up operations. ```cpp #include #include namespace gtl = boost::polygon; using namespace boost::polygon::operators; int main() { //lets construct a 10x10 rectangle shaped polygon typedef gtl::polygon_data Polygon; typedef gtl::polygon_traits::point_type Point; Point pts[] = {gtl::construct(0, 0), gtl::construct(10, 0), gtl::construct(10, 10), gtl::construct(0, 10) }; Polygon poly; gtl::set_points(poly, pts, pts+4); //now lets see what we can do with this polygon assert(gtl::area(poly) == 100.0f); assert(gtl::contains(poly, gtl::construct(5, 5))); assert(!gtl::contains(poly, gtl::construct(15, 5))); gtl::rectangle_data rect; assert(gtl::extents(rect, poly)); //get bounding box of poly assert(gtl::equivalence(rect, poly)); //hey, that's slick assert(gtl::winding(poly) == gtl::COUNTERCLOCKWISE); assert(gtl::perimeter(poly) == 40.0f); //add 5 to all coords of poly gtl::convolve(poly, gtl::construct(5, 5)); //multiply all coords of poly by 2 gtl::scale_up(poly, 2); gtl::set_points(rect, gtl::point_data(10, 10), gtl::point_data(30, 30)); assert(gtl::equivalence(poly, rect)); return 0; } ``` -------------------------------- ### Get Polygon Winding Direction Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_with_holes_concept.htm Determines the winding direction of the polygon's outer shell. ```APIDOC ## winding ### Description Returns the winding direction of an object that models polygon_with_holes, LOW == CLOCKWISE, HIGH = COUNTERCLOCKWISE. ### Signature ```cpp template direction_1d winding(const T& polygon) ``` ``` -------------------------------- ### Include Voronoi Builder Headers Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/voronoi_builder.htm Include the necessary headers for using the Voronoi builder and diagram. This set of includes does not depend on external libraries like MPL. ```cpp #include #include ``` -------------------------------- ### Get Polygon Center Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_with_holes_concept.htm Calculates and sets the center point of the polygon's bounding box. ```APIDOC ## center ### Description Sets object that models point to the center point of the bounding box of an object that models polygon_with_holes. ### Signature ```cpp template void center(point_type& p, const T& polygon) ``` ``` -------------------------------- ### Concept Casting with view_as() Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_90_with_holes_concept.htm Demonstrates using view_as<>() to cast a polygon_90_with_holes object to other related concepts like rectangle_concept or polygon_90_concept at runtime, provided the object conforms to the target concept's restrictions. ```cpp view_as(polygon_90_with_holes_object) view_as(polygon_90_with_holes_object) ``` -------------------------------- ### Polygon Size and Assignment Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_90_concept.htm Functions to get the number of edges in a polygon and to copy polygon data. ```APIDOC ## size ### Description Returns the number of edges in the polygon. ### Signature ```cpp template unsigned int size(const T& polygon) ``` ## assign ### Description Copies data from right object that models polygon_90 into left object that models polygon_90. ### Signature ```cpp template T1& assign(T1& left, const T2& right) ``` ``` -------------------------------- ### Voronoi Cell Accessors and Mutators Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/voronoi_diagram.htm Provides methods to get and set the Voronoi cell associated with an edge. ```APIDOC ## cell ### Description Accessors and mutators for the Voronoi cell associated with the edge. ### Methods - **cell()** (voronoi_cell_type*): Returns the pointer to the Voronoi cell that the edge belongs to. - **cell() const** (const voronoi_cell_type*): Returns the const pointer to the Voronoi cell that the edge belongs to. - **cell(voronoi_cell_type* c)**: Sets the Voronoi cell pointer to the cell the current edge belongs to. ``` -------------------------------- ### Constructors Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_90_set_concept.htm Various constructors for initializing a polygon_90_set_data object. ```APIDOC ## Constructors ### Default Constructor **polygon_90_set_data**() *Description*: Default constructor. Scanning orientation defaults to HORIZONTAL. ### Constructor with Orientation **polygon_90_set_data**(orientation_2d orient) *Description*: Construct with scanning orientation. ### Constructor with Iterator Range template **polygon_90_set_data**(orientation_2d orient, iT input_begin, iT input_end) *Description*: Construct with scanning orientation from an iterator range of insertable objects. ### Copy Constructor **polygon_90_set_data**(const polygon_90_set_data& that) *Description*: Copy construct. ### Constructor from Boolean Operator template **polygon_90_set_data**(const polygon_90_view& t) *Description*: Copy construct from a Boolean operator template. ### Constructor with Orientation and Copy **polygon_90_set_data**(orientation_2d orient, const polygon_90_set_data& that) *Description*: Construct with scanning orientation and copy from another polygon set. ``` -------------------------------- ### Compare Layout and Schematic Files Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/tutorial/extract.cpp This function compares a layout file with a schematic file. It parses both, extracts devices and netlists, and returns true if they match, false otherwise. Ensure input files are correctly formatted. ```cpp #include "schematic_database.hpp" #include "layout_pin.hpp" #include "layout_rectangle.hpp" #include "connectivity_database.hpp" #include "compare_schematics.hpp" #include "extract_devices.hpp" #include "parse_layout.hpp" #include "layout_database.hpp" #include "device.hpp" #include #include #include bool compare_files(std::string layout_file, std::string schematic_file) { std::ifstream sin(schematic_file.c_str()); std::ifstream lin(layout_file.c_str()); std::vector rects; std::vector pins; parse_layout(rects, pins, lin); schematic_database reference_schematic; parse_schematic_database(reference_schematic, sin); layout_database layout; populate_layout_database(layout, rects); connectivity_database connectivity; populate_connectivity_database(connectivity, pins, layout); schematic_database schematic; std::vector& devices = schematic.devices; for(std::size_t i = 0; i < pins.size(); ++i) { devices.push_back(device()); devices.back().type = "PIN"; devices.back().terminals.push_back(pins[i].net); } extract_devices(devices, connectivity, layout); extract_netlist(schematic.nets, devices); return compare_schematics(reference_schematic, schematic); } ``` -------------------------------- ### Get Upper Right Corner Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the upper right corner point of an object that models rectangle. ```APIDOC ## ur ### Description Returns the upper right corner point of an object that models rectangle. ### Signature ```cpp template point_type ur(const T& rectangle) ``` ``` -------------------------------- ### Get Upper Left Corner Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the upper left corner point of an object that models rectangle. ```APIDOC ## ul ### Description Returns the upper left corner point of an object that models rectangle. ### Signature ```cpp template point_type ul(const T& rectangle) ``` ``` -------------------------------- ### Populate Layout Database Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/tutorial/layout_database.hpp Inserts layout rectangles into the layout database, organized by layer. ```cpp //insert layout rectangles into a layout database inline void populate_layout_database(layout_database& layout, std::vector& rects) { for(std::size_t i = 0; i < rects.size(); ++i) { layout[rects[i].layer].insert(rects[i]); } } ``` -------------------------------- ### Compare Layout and Schematic Files Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_tutorial.htm Compares a layout file against a schematic file by parsing both, populating layout and connectivity databases, extracting devices and netlists, and finally comparing the generated schematic with the reference. This function is the core of the layout versus schematic verification. ```cpp bool compare_files(std::string layout_file, std::string schematic_file) { std::ifstream sin(schematic_file.c_str()); std::ifstream lin(layout_file.c_str()); std::vector rects; std::vector pins; parse_layout(rects, pins, lin); schematic_database reference_schematic; parse_schematic_database(reference_schematic, sin); layout_database layout; populate_layout_database(layout, rects); connectivity_database connectivity; populate_connectivity_database(connectivity, pins, layout); schematic_database schematic; std::vector& devices = schematic.devices; for(std::size_t i = 0; i < pins.size(); ++i) { devices.push_back(device()); devices.back().type = "PIN"; devices.back().terminals.push_back(pins[i].net); } extract_devices(devices, connectivity, layout); extract_netlist(schematic.nets, devices); return compare_schematics(reference_schematic, schematic); } ``` -------------------------------- ### Get Lower Right Corner Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the lower right corner point of an object that models rectangle. ```APIDOC ## lr ### Description Returns the lower right corner point of an object that models rectangle. ### Signature ```cpp template point_type lr(const T& rectangle) ``` ``` -------------------------------- ### Get Lower Left Corner Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_rectangle_concept.htm Returns the lower left corner point of an object that models rectangle. ```APIDOC ## ll ### Description Returns the lower left corner point of an object that models rectangle. ### Signature ```cpp template point_type ll(const T& rectangle) ``` ``` -------------------------------- ### Update OpenGL Viewport Source: https://www.boost.org/doc/libs/latest/libs/polygon/example/voronoi_visualizer.cpp Configures the OpenGL projection matrix for rendering. It uses `glOrtho` to set up a 2D viewing volume based on a rectangle and a shift factor. ```cpp void update_view_port() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); rect_type view_rect = brect_; deconvolve(view_rect, shift_); glOrtho(xl(view_rect), xh(view_rect), yl(view_rect), yh(view_rect), -1.0, 1.0); glMatrixMode(GL_MODELVIEW); } ``` -------------------------------- ### Accessing Polygon Vertices Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_with_holes_concept.htm Provides functions to get iterators for the vertices of the polygon's outer shell. ```APIDOC ## begin_points ### Description Expects a model of polygon_with_holes. Returns the begin iterator over the range of points that correspond to vertices of the polygon. ### Signature ```cpp template point_iterator_type begin_points(const T& polygon) ``` ## end_points ### Description Expects a model of polygon_with_holes. Returns the end iterator over the range of points that correspond to vertices of the polygon. ### Signature ```cpp template point_iterator_type end_points(const T& polygon) ``` ``` -------------------------------- ### Run S-Hull Delaunay Triangulation Benchmark Source: https://www.boost.org/doc/libs/latest/libs/polygon/benchmark/voronoi_benchmark_points.cpp Executes a benchmark for the S-Hull library's Delaunay triangulation. It includes preprocessing to handle coordinate scaling and duplicate points before triangulation. ```C++ void run_shull_delaunay_test() { boost::mt19937 gen(RANDOM_SEED); bf << "S-Hull Delaunay Triangulation of Points:\n"; // This value is required by S-Hull as it doesn't seem to support properly // coordinates with the absolute value higher than 100. float koef = 100.0 / (1 << 16) / (1 << 15); for (int i = 0; i < NUM_TESTS; ++i) { timer.start(); for (int j = 0; j < NUM_RUNS[i]; ++j) { // S-Hull doesn't deal properly with duplicates so we need // to eliminate them before running the algorithm. std::vector< pair > upts; std::vector pts; std::vector triads; Shx pt; for (int k = 0; k < NUM_POINTS[i]; ++k) { int32 x = static_cast(gen()); int32 y = static_cast(gen()); upts.push_back(std::make_pair(x, y)); } // Absolutely the same code is used by the Boost.Polygon Voronoi library. std::sort(upts.begin(), upts.end()); upts.erase(std::unique(upts.begin(), upts.end()), upts.end()); for (int k = 0; k < upts.size(); ++k) { pt.r = koef * upts[k].first; pt.c = koef * upts[k].second; pt.id = k; pts.push_back(pt); } s_hull_del_ray2(pts, triads); } double time_per_test = get_elapsed_secs() / NUM_RUNS[i]; format_line(NUM_POINTS[i], NUM_RUNS[i], time_per_test); } bf << "\n"; } ``` -------------------------------- ### Iterators for Polygon Vertices and Holes Source: https://www.boost.org/doc/libs/latest/libs/polygon/doc/gtl_polygon_90_with_holes_concept.htm Provides functions to get iterators for the vertices of a polygon with holes, and for its holes. ```APIDOC ## begin_points ### Description Expects a model of polygon_90_with_holes. Returns the begin iterator over the range of points that correspond to vertices of the polygon. ### Method `template point_iterator_type begin_points(const T& polygon)` ## end_points ### Description Expects a model of polygon_90_with_holes. Returns the end iterator over the range of points that correspond to vertices of the polygon. ### Method `template point_iterator_type end_points(const T& polygon)` ## begin_holes ### Description Expects a model of polygon_90_with_holes. Returns the begin iterator over the range of coordinates that correspond to horizontal and vertical edges. ### Method `template hole_iterator_type begin_holes(const T& polygon)` ## end_holes ### Description Expects a model of polygon_90_with_holes. Returns the end iterator over the range of coordinates that correspond to horizontal and vertical edges. ### Method `template hole_iterator_type end_holes(const T& polygon)` ```