Skip to main content

PolygonAdapter

PolygonAdapter

Adapter class to interface between our Polygon class and the Martinez-Rueda library. More…

#include <polygon_adapter.hpp>

Public Functions

Name
cbop::Polygon toMartinezPolygon(const Polygon & polygon)
Convert our Polygon to Martinez-Rueda cbop::Polygon.
Polygon fromMartinezPolygon(const cbop::Polygon & martinez_polygon)
Convert Martinez-Rueda cbop::Polygon to our Polygon.
cbop::Point_2 toMartinezPoint(const Point2D< float > & point)
Convert our Point2D to Martinez-Rueda cbop::Point_2.
Point2D< float > fromMartinezPoint(const cbop::Point_2 & martinez_point)
Convert Martinez-Rueda cbop::Point_2 to our Point2D.
Polygon performUnion(const Polygon & poly1, const Polygon & poly2)
Perform polygon union using Martinez-Rueda algorithm.
Polygon performIntersection(const Polygon & poly1, const Polygon & poly2)
Perform polygon intersection using Martinez-Rueda algorithm.
Polygon performDifference(const Polygon & poly1, const Polygon & poly2)
Perform polygon difference using Martinez-Rueda algorithm.
Polygon performXor(const Polygon & poly1, const Polygon & poly2)
Perform polygon XOR using Martinez-Rueda algorithm.

Detailed Description

class PolygonAdapter;

Adapter class to interface between our Polygon class and the Martinez-Rueda library.

This adapter converts between our Point2D/Polygon representation and the cbop::Point_2/cbopPolygon representation used by the Martinez-Rueda clipping library.

Public Functions Documentation

function toMartinezPolygon

static cbop::Polygon toMartinezPolygon(
    const Polygon & polygon
)

Convert our Polygon to Martinez-Rueda cbop::Polygon.

Parameters:

  • polygon The polygon to convert

Return: Martinez-Rueda polygon representation

function fromMartinezPolygon

static Polygon fromMartinezPolygon(
    const cbop::Polygon & martinez_polygon
)

Convert Martinez-Rueda cbop::Polygon to our Polygon.

Parameters:

  • martinez_polygon The Martinez-Rueda polygon to convert

Return: Our polygon representation

function toMartinezPoint

static cbop::Point_2 toMartinezPoint(
    const Point2D< float > & point
)

Convert our Point2D to Martinez-Rueda cbop::Point_2.

Parameters:

  • point The point to convert

Return: Martinez-Rueda point representation

function fromMartinezPoint

static Point2D< float > fromMartinezPoint(
    const cbop::Point_2 & martinez_point
)

Convert Martinez-Rueda cbop::Point_2 to our Point2D.

Parameters:

  • martinez_point The Martinez-Rueda point to convert

Return: Our point representation

function performUnion

static Polygon performUnion(
    const Polygon & poly1,
    const Polygon & poly2
)

Perform polygon union using Martinez-Rueda algorithm.

Parameters:

  • poly1 First polygon
  • poly2 Second polygon

Return: Union of the two polygons

function performIntersection

static Polygon performIntersection(
    const Polygon & poly1,
    const Polygon & poly2
)

Perform polygon intersection using Martinez-Rueda algorithm.

Parameters:

  • poly1 First polygon
  • poly2 Second polygon

Return: Intersection of the two polygons

function performDifference

static Polygon performDifference(
    const Polygon & poly1,
    const Polygon & poly2
)

Perform polygon difference using Martinez-Rueda algorithm.

Parameters:

  • poly1 First polygon (minuend)
  • poly2 Second polygon (subtrahend)

Return: Difference of the two polygons (poly1 - poly2)

function performXor

static Polygon performXor(
    const Polygon & poly1,
    const Polygon & poly2
)

Perform polygon XOR using Martinez-Rueda algorithm.

Parameters:

  • poly1 First polygon
  • poly2 Second polygon

Return: XOR of the two polygons


Updated on 2026-11-13 at 20:25:40 +0000