Class SampledRegion2D
- Namespace
- VirtualLabAPI.Core.Numerics.Region2D
- Assembly
- VirtualLabAPI.dll
Class which describes a region via sampled data. A data point marks its own small rectangular region as being 'inside' if its value is unequal zero.
[Serializable]
public class SampledRegion2D : Region2D, ISerializable, IDeserializationCallback, IRegion1D2D, IDocument, IEquatable<IObjectBase>, ICloneable, IDisposable
- Inheritance
-
ObjectBaseSerializableObjectBaseManualSerializationDocumentBaseSampledRegion2D
- Implements
-
IEquatable<IObjectBase>
- Inherited Members
- Extension Methods
Constructors
SampledRegion2D(bool)
Default constructor creating a default sampled RegionData object, if wanted.
public SampledRegion2D(bool initWithTemplateData)
Parameters
initWithTemplateDataboolIf
true, the sampled data will be initialized with template data.
SampledRegion2D(ComplexAmplitude)
Constructor getting an old signal region (represented by ComplexAmplitude) as parameter.
public SampledRegion2D(ComplexAmplitude signalRegion)
Parameters
signalRegionComplexAmplitude
SampledRegion2D(DataArray2D)
Constructor which gets the sampled region data as data array.
public SampledRegion2D(DataArray2D regionData)
Parameters
regionDataDataArray2DSampled region data to be set.
SampledRegion2D(Region2D, SamplingParameters, (bool centerX, bool centerY, bool nodeCentering))
Constructor converting a non-sampled region to a sampled one.
public SampledRegion2D(Region2D region, SamplingParameters sp, (bool centerX, bool centerY, bool nodeCentering) centerAroundZero)
Parameters
regionRegion2DRegion to be sampled
spSamplingParametersSampling Parameters
centerAroundZero(bool centerX, bool centerY, bool nodeCentering)If
true, the sampled data will be centered around zero, otherwise the old region coordinates will be kept unchanged.
SampledRegion2D(SampledRegion2D)
Copy constructor.
public SampledRegion2D(SampledRegion2D regionToCopy)
Parameters
regionToCopySampledRegion2DSampledRegion2D to copy.
Properties
RegionData
Get or set the sampled region data. All values unequal zero will be interpreted as 'inside' the region. The other values will mark areas 'outside'.
public DataArray2D RegionData { get; }
Property Value
Methods
CalculateAxisAlignedBoundingBox()
Method for (re)calculating the axis aligned bounding box.
public override void CalculateAxisAlignedBoundingBox()
Clone()
Deep copy of the object.
public override object Clone()
Returns
- object
A deep copy of this.
Equals(object, EqualityIntent)
Determines whether the specified object is equal to this instance.
public override bool Equals(object obj, EqualityIntent equalityIntent)
Parameters
objobjectequalityIntentEqualityIntentDefines what kind of equality you want to check when comparing two objects, for example all values or just physical equality.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
GetInOutRelation(VectorD, ExtrapolationInfo)
Method which checks whether or not a point lies inside or outside the 2D region or on its boundary. A data point marks its own small rectangular region as being 'inside' if its value is unequal zero.
public override InsideOutside GetInOutRelation(VectorD point, ExtrapolationInfo extrapolation2use = null)
Parameters
pointVectorDThe point to be checked whether it lies inside.
extrapolation2useExtrapolationInfoExtrapolation info actually to be used.
Returns
- InsideOutside
Information where the point lies in relation to the region.
GetRegionDataRestrictions()
Method which gets the restrictions which apply to the RegionData object.
public static DataArray2DRestrictions GetRegionDataRestrictions()
Returns
- DataArray2DRestrictions
The restrictions which apply to the RegionData object.
InOutRelationForBorderPixelOfComposedRegion(VectorD, RectanglePhysical)
If a sampled region is used inside a composed region, we may need a special handling for the border pixels (i.e. near a given bounding box). See ITN.064 for more information on the mode 'border continuation'.
public InsideOutside InOutRelationForBorderPixelOfComposedRegion(VectorD point, RectanglePhysical boundingBoxOfParentComposedRegion)
Parameters
pointVectorDPoint near the borders of a given bounding box.
boundingBoxOfParentComposedRegionRectanglePhysicalBounding box of the parenting composed region.
Returns
- InsideOutside
The InOut-relation for the given point.
MayBeNonzeroOutside(out bool, out bool, out bool, out bool)
Method which determines whether or not the region can provide "inside" state outside of its boundary interval. This is not the case for extrapolation mode 'ConstantZero', of course.
public override void MayBeNonzeroOutside(out bool maybeNonZeroLeft, out bool maybeNonZeroRight, out bool maybeNonZeroBottom, out bool maybeNonZeroTop)
Parameters
maybeNonZeroLeftboolTrue, if there may be nonzero values left of the bounding box.maybeNonZeroRightboolTrue, if there may be nonzero values right of the bounding box.maybeNonZeroBottomboolTrue, if there may be nonzero values below the bottom of the bounding box.maybeNonZeroTopboolTrue, if there may be nonzero values above the top of the bounding box.
Rotate(double, VectorD, Vector, InterpolationMethod, bool)
Method for transforming a given sampled region by rotating by an angle around a given rotation center.
public void Rotate(double angle, VectorD centerOfRotation, Vector newSamplingPoints, InterpolationMethod interpolationMethod, bool considerExtrapolation)
Parameters
angledoubleThe angle to rotate the polygon with (given in radian).
centerOfRotationVectorDThe center to rotate the polygon around.
newSamplingPointsVectorNumber of sampling points in the rotated data.
interpolationMethodInterpolationMethodInterpolation method to be used for rotating.
considerExtrapolationboolIf
true, extrapolated values will be rotated into the result if angle is no integer multiple of ±π/2.
ScaleByFactors(VectorD, bool)
Scales the region by the given factor.
public override void ScaleByFactors(VectorD factors, bool keepCenter)
Parameters
factorsVectorDThe scaling factors for both x- and y-direction.
keepCenterboolWhether the center of the region remains unchanged (true) or is scaled by the same factors (false).
SetRegionData(DataArray2D, bool, bool)
Sets the sampled region data.
public void SetRegionData(DataArray2D regionData2bSet, bool cloneData, bool enforceValidity)
Parameters
regionData2bSetDataArray2DSampled data to be set. The data array has to fulfill some restrictions defined in the static method GetRegionDataRestrictions().
cloneDataboolIf
true, the regionData2bSet will be cloned first. This is also the case if regionData2bSet has wrong precision or doesn't fulfill the restrictions.enforceValidityboolIf
true, a data array not fulfilling the restrictions will be adapted so it does. iffalse, a data array not fulfilling the restrictions will cause an ArgumentException.
Shift(VectorD)
Shifts this region by the given vector.
public override void Shift(VectorD shift)
Parameters
shiftVectorDThe shift added to the current position of the region.
UpdatePropertyOfCoordinates()
Method for handling update after change of the physical property of the coordinate
public override void UpdatePropertyOfCoordinates()
Operators
operator ==(SampledRegion2D, SampledRegion2D)
Equals operator
public static bool operator ==(SampledRegion2D o1, SampledRegion2D o2)
Parameters
o1SampledRegion2DThe first sampled region to compare
o2SampledRegion2DThe second sampled region to compare
Returns
- bool
trueif both objects have equal data.
operator !=(SampledRegion2D, SampledRegion2D)
Inequality operator.
public static bool operator !=(SampledRegion2D o1, SampledRegion2D o2)
Parameters
o1SampledRegion2DThe first sampled region to compare
o2SampledRegion2DThe second sampled region to compare
Returns
- bool
trueif both objects have unequal data.