function Superpose(MASK $mask = NULL) { if (!$mask || $mask->IsFull()) { return $this; } else { if ($this->IsFull()) { return $mask; } } $res = array(); foreach ($mask->ids as $id) { if (isset($this->ids[$id])) { array_push($res, $this->ids[$id]); } else { throw new ADEIException(translate("Invalid mask (%s) is passed for supperposing. The base mask is (%s)", $mask->GetProp(), $this->GetProp())); } } $mask = new MASK(); $mask->SetIDs($res); return $mask; }