Mapper  0.9.0
API documentation
Public Types | Public Member Functions | List of all members
OpenOrienteering::BooleanTool Class Reference

Wraps some helper functions for boolean operations. More...

#include <boolean_tool.h>

Public Types

enum  Operation {
  Union, Intersection, Difference, XOr,
  MergeHoles
}
 Types of boolean operation. More...
 
typedef std::vector< PathObject *> PathObjects
 A list of PathObject elements. More...
 

Public Member Functions

 BooleanTool (Operation op, Map *map)
 Constructs a tool for the given operation and map. More...
 
bool execute ()
 Executes the operation on the selected objects in the map. More...
 
bool executePerSymbol ()
 Executes the operation per symbol on the selected objects in the map. More...
 
bool executeForObjects (PathObject *subject, PathObjects &in_objects, PathObjects &out_objects)
 Executes the operation on particular objects. More...
 
void executeForLine (const PathObject *area, const PathObject *line, PathObjects &out_objects)
 Executes the Intersection and Difference operation on the given line object. More...
 

Detailed Description

Wraps some helper functions for boolean operations.

The implementation of the boolean operation tools is based on the Clipper library (aka libpolyclipping) (http://www.angusj.com/delphi/clipper.php).

Because Clipper does not support bezier curves, areas are clipped as polygonal approximations, and after clipping we try to rebuild the curves.

Todo:
This class should get unit tests.

Member Typedef Documentation

◆ PathObjects

A list of PathObject elements.

Member Enumeration Documentation

◆ Operation

Types of boolean operation.

Enumerator
Union 
Intersection 
Difference 
XOr 
MergeHoles 

Constructor & Destructor Documentation

◆ BooleanTool()

OpenOrienteering::BooleanTool::BooleanTool ( Operation  op,
Map map 
)

Constructs a tool for the given operation and map.

map must not be nullptr (for some member functions).

Member Function Documentation

◆ execute()

bool OpenOrienteering::BooleanTool::execute ( )

Executes the operation on the selected objects in the map.

The first selected object is treated special and must be a path.

Returns
True on success, false on error

◆ executeForLine()

void OpenOrienteering::BooleanTool::executeForLine ( const PathObject area,
const PathObject line,
BooleanTool::PathObjects out_objects 
)

Executes the Intersection and Difference operation on the given line object.

Parameters
areaThe primary object, here defining a boundary.
lineThe line object to operate on.
out_objectsThe resulting collection of objects.

◆ executeForObjects()

bool OpenOrienteering::BooleanTool::executeForObjects ( PathObject subject,
PathObjects in_objects,
PathObjects out_objects 
)

Executes the operation on particular objects.

This function does not (actively) change the collection of objects in the map or the selection.

Parameters
subjectThe primary affected object.
in_objectsAll objects to operate on. Must contain subject.
out_objectsThe resulting collection of objects.

◆ executePerSymbol()

bool OpenOrienteering::BooleanTool::executePerSymbol ( )

Executes the operation per symbol on the selected objects in the map.

Executes the operation independently for every group of path objects which have got the same symbol. Objects which are not of type Object::Path are ignored.

Errors during the operation are ignored, too. The original objects the operation failed for remain unchanged. The operation continues for other groups of objects.

Returns
True if the map was changed, false otherwise.

The documentation for this class was generated from the following files: