Skip to content

differenceDifferenceDifferencedifferencedifference🔗

Short description🔗

differenceDifferenceDifferencedifferencedifference — Calculate the difference of two regions.

Signature🔗

difference( region Region, region Sub, out region RegionDifference )void Difference( const HObject& Region, const HObject& Sub, HObject* RegionDifference )static void HOperatorSet.Difference( HObject region, HObject sub, out HObject regionDifference )def difference( region: HObject, sub: HObject ) -> HObject

Herror difference( const Hobject Region, const Hobject Sub, Hobject* RegionDifference )

Herror T_difference( const Hobject Region, const Hobject Sub, Hobject* RegionDifference )

HRegion HRegion::Difference( const HRegion& Sub ) const

HRegion HRegion.Difference( HRegion sub )

Description🔗

differenceDifference calculates the set-theoretic difference of two regions: (Regions in Region) - (Regions in Sub) The resulting region is defined as the input region (Regionregionregion) with all points from Subsubsub removed. Note that, internally, all regions of Subsubsub are united to a single region before the differences between the individual regions of Regionregionregion and the united region are calculated.

Attention🔗

Empty regions are valid for both parameters. On output, empty regions may result. The value of the system flag 'store_empty_region'"store_empty_region" determines the behavior in this case.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Regionregionregion (input_object) region(-array) → objectHObjectHRegionHObjectHobject

Regions to be processed.

Subsubsub (input_object) region(-array) → objectHObjectHRegionHObjectHobject

The union of these regions is subtracted from Region.

RegionDifferenceregionDifferenceregion_difference (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

Resulting region.

Example🔗

(HDevelop)

* provides the region X without the points in Y
difference(X,Y,RegionDifference)
(C)
/* provides the region X without the points in Y */
difference(X,Y,&RegionDifference)\;

Complexity🔗

Let \(N\) be the number of regions, \(F_{1}\) be their average area, and \(F_{2}\) be the total area of all regions in Subsubsub. Then the runtime complexity is \(O(F_{1} * \log(F_{1}) + N * (\sqrt{F_{1}} + \sqrt{F_{2}}))\).

Result🔗

differenceDifference always returns the value 2 (H_MSG_TRUE). The behavior in case of empty input (no regions given) can be set via set_system('no_object_result',<Result>) and the behavior in case of an empty input region via set_system('empty_region_result',<Result>). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

thresholdThreshold, connectionConnection, regiongrowingRegiongrowing, pouringPouring, class_ndim_normClassNdimNorm

Possible successors

select_shapeSelectShape, disp_regionDispRegion

See also

intersectionIntersection, union1Union1, union2Union2, complementComplement, symm_differenceSymmDifference

Module🔗

Foundation