33 template<
class RangeType >
void doComputeSetDifference(
34 std::vector< RangeType >& o_rRanges,
45 o_rRanges.push_back( b );
50 o_rRanges.push_back( a );
54 const typename RangeType::ValueType ax(
a.getMinX());
55 const typename RangeType::ValueType ay(
a.getMinY());
56 const typename RangeType::TraitsType::DifferenceType aw(
a.getWidth());
57 const typename RangeType::TraitsType::DifferenceType ah(
a.getHeight());
58 const typename RangeType::ValueType bx(b.getMinX());
59 const typename RangeType::ValueType by(b.getMinY());
60 const typename RangeType::TraitsType::DifferenceType bw(b.getWidth());
61 const typename RangeType::TraitsType::DifferenceType bh(b.getHeight());
63 const typename RangeType::TraitsType::DifferenceType h0( (by > ay) ? by - ay : 0 );
64 const typename RangeType::TraitsType::DifferenceType h3( (by + bh < ay + ah) ? ay + ah - by - bh : 0 );
65 const typename RangeType::TraitsType::DifferenceType w1( (bx > ax) ? bx - ax : 0 );
66 const typename RangeType::TraitsType::DifferenceType w2( (ax + aw > bx + bw) ? ax + aw - bx - bw : 0 );
67 const typename RangeType::TraitsType::DifferenceType h12( (h0 + h3 < ah) ? ah - h0 - h3 : 0 );
74 static_cast<typename RangeType::ValueType
>(ax+aw),
75 static_cast<typename RangeType::ValueType
>(ay+h0)) );
77 if (w1 > 0 && h12 > 0)
80 static_cast<typename RangeType::ValueType
>(ay+h0),
81 static_cast<typename RangeType::ValueType
>(ax+w1),
82 static_cast<typename RangeType::ValueType
>(ay+h0+h12)) );
84 if (w2 > 0 && h12 > 0)
86 RangeType(
static_cast<typename RangeType::ValueType
>(bx+bw),
87 static_cast<typename RangeType::ValueType
>(ay+h0),
88 static_cast<typename RangeType::ValueType
>(bx+bw+w2),
89 static_cast<typename RangeType::ValueType
>(ay+h0+h12)) );
94 static_cast<typename RangeType::ValueType
>(ay+h0+h12),
95 static_cast<typename RangeType::ValueType
>(ax+aw),
96 static_cast<typename RangeType::ValueType
>(ay+h0+h12+h3)) );
104 doComputeSetDifference( o_rResult, rFirst, rSecond );
113 doComputeSetDifference( o_rResult, rFirst, rSecond );
A two-dimensional interval over doubles.
A two-dimensional interval over integers.
std::vector< B2IRange > & computeSetDifference(std::vector< B2IRange > &o_rResult, const B2IRange &rFirst, const B2IRange &rSecond)
Compute the set difference of the two given ranges.