本文整理汇总了C#中Microsoft.Msagl.Core.Geometry.Rectangle类的典型用法代码示例。如果您正苦于以下问题:C# Rectangle类的具体用法?C# Rectangle怎么用?C# Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于Microsoft.Msagl.Core.Geometry命名空间,在下文中一共展示了Rectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MinimumSizeIsRespected
public void MinimumSizeIsRespected()
{
// Setup
string filePath = Path.Combine(this.TestContext.TestDir, "Out\\Dots", "chat.dot");
GeometryGraph graph = this.LoadGraph(filePath);
const double DesiredHeight = 100000;
const double DesiredWidth = 100000;
SugiyamaLayoutSettings settings = new SugiyamaLayoutSettings();
settings.MinimalHeight = DesiredHeight;
settings.MinimalWidth = DesiredWidth;
// Execute
LayeredLayout layeredLayout = new LayeredLayout(graph, settings);
layeredLayout.Run();
// Verify the graph is the correct size
Assert.IsTrue(DesiredHeight < graph.Height, "Graph height should be the minimal height.");
Assert.IsTrue(DesiredWidth < graph.Width, "Graph width should be the minimal width.");
// Verify the nodes were spread apart to fill the space
Rectangle nodeBounds = new Rectangle(graph.Nodes.Select(n => n.BoundingBox));
Assert.IsTrue(DesiredWidth < nodeBounds.Height, "The graph nodes weren't scaled vertically to fill the space.");
Assert.IsTrue(DesiredWidth < nodeBounds.Width, "The graph nodes weren't scaled horizontally to fill the space.");
}
示例2: PreGraph
internal PreGraph(EdgeGeometry[] egs, Set<ICurve> nodeBoundaries) {
edgeGeometries = new List<EdgeGeometry>(egs);
this.nodeBoundaries = new Set<ICurve>(nodeBoundaries);
boundingBox = Rectangle.CreateAnEmptyBox();
foreach (var curve in nodeBoundaries)
boundingBox.Add(curve.BoundingBox);
}
示例3: AddToAdjacentVertex
internal void AddToAdjacentVertex(TransientGraphUtility transUtil
, VisibilityVertex targetVertex, Directions dirToExtend, Rectangle limitRect) {
if (!PointComparer.Equal(this.Point, targetVertex.Point)) {
transUtil.FindOrAddEdge(this.Vertex, targetVertex, InitialWeight);
}
ExtendEdgeChain(transUtil, targetVertex, dirToExtend, limitRect);
}
示例4: InteriorEdgeCrossesObstacle
private bool InteriorEdgeCrossesObstacle(ObstacleTree obstacleTree) {
// File Test: Nudger_Overlap4
// Use the VisibilityBoundingBox for groups because those are what the tree consists of.
var rect = new Rectangle(this.UnpaddedBorderIntersect, this.VisibilityBorderIntersect);
return InteriorEdgeCrossesObstacle(rect, obs => obs.VisibilityPolyline,
obstacleTree.Root.GetLeafRectangleNodesIntersectingRectangle(rect)
.Where(node => !node.UserData.IsGroup && (node.UserData != this.Obstacle)).Select(node => node.UserData));
}
示例5: GridTraversal
public GridTraversal(Rectangle boundingBox, int iLevel)
{
_boundingBox = boundingBox;
_iLevel = iLevel;
_numberOfTilesOnSide = (ulong)Math.Pow(2, iLevel);
TileWidth = boundingBox.Width / _numberOfTilesOnSide;
TileHeight = boundingBox.Height / _numberOfTilesOnSide;
}
示例6: CommonArea
static double CommonArea(ref Rectangle a, ref Rectangle b)
{
double l = Math.Min(a.Left, b.Left);
double r = Math.Max(a.Right, b.Right);
double t = Math.Max(a.Top, b.Top);
double bt = Math.Min(a.Bottom, b.Bottom);
return (r - l) * (t - bt);
}
示例7: IntersectsOnY
internal bool IntersectsOnY(Rectangle r){
if (r.Bottom > top + ApproximateComparer.DistanceEpsilon)
return false;
if (r.Top < bottom - ApproximateComparer.DistanceEpsilon)
return false;
return true;
//return ApproximateComparer.Compare(r.bottom, top) <= 0 && ApproximateComparer.Compare(bottom, r.top) <= 0;
}
示例8: Area
/// <summary>
/// Additionally needed area of nodes compared to the optimal packing of the nodes.
/// </summary>
/// <param name="graphOriginal"></param>
/// <param name="graphNew"></param>
/// <returns></returns>
public static Tuple<String, double> Area(GeometryGraph graph)
{
double minimalArea = graph.Nodes.Sum(v => v.BoundingBox.Area);
Rectangle boundingBoxNew=new Rectangle(graph.Nodes.Select(v=>v.BoundingBox));
double areaNew = boundingBoxNew.Area;
double ratio = areaNew/minimalArea;
// return Tuple.Create("AreaIncreaseToMinPacking",ratio - 1);//we are interested in increase compared to optimal packing.
return Tuple.Create("AreaAbsolute/(1E6)", areaNew / (1E6));//we are interested in increase compared to optimal packing.
}
示例9: GetInitialBoundingBox
public Rectangle GetInitialBoundingBox() {
Rectangle bbox = new Rectangle();
bbox.SetToEmpty();
foreach (var rect in _fixedRectangles) {
bbox.Add(rect);
}
foreach (var rect in _moveableRectangles) {
bbox.Add(rect);
}
return bbox;
}
示例10: IntersectsOnX
internal bool IntersectsOnX(Rectangle r){
//return ApproximateComparer.Compare(r.left, right) <= 0 && ApproximateComparer.Compare(left, r.right) <= 0;
if (r.Left > right + ApproximateComparer.DistanceEpsilon)
return false;
if (r.Right < left - ApproximateComparer.DistanceEpsilon)
return false;
return true;
//return ApproximateComparer.Compare(r.left, right) <= 0 && ApproximateComparer.Compare(left, r.right) <= 0;
}
示例11: AddEdgeToAdjacentEdge
// Adds an edge from this.Vertex to a (possibly new) vertex at an intersection with an
// existing Edge that adjoins the point. We take 'dir' as an input parameter for edge
// extension because we may be on the edge so can't calculate the direction.
internal VisibilityVertex AddEdgeToAdjacentEdge(TransientGraphUtility transUtil
, VisibilityEdge targetEdge, Directions dirToExtend, Rectangle limitRect) {
Point targetIntersect = StaticGraphUtility.SegmentIntersection(targetEdge, this.Point);
VisibilityVertex targetVertex = transUtil.VisGraph.FindVertex(targetIntersect);
if (null != targetVertex) {
AddToAdjacentVertex(transUtil, targetVertex, dirToExtend, limitRect);
}
else {
targetVertex = transUtil.AddEdgeToTargetEdge(this.Vertex, targetEdge, targetIntersect);
}
ExtendEdgeChain(transUtil, targetVertex, dirToExtend, limitRect);
return targetVertex;
}
示例12: OverlapRemovalFixedSegmentsBitmap
public OverlapRemovalFixedSegmentsBitmap(Rectangle[] moveableRectangles, Rectangle[] fixedRectangles,
SymmetricSegment[] fixedSegments) {
_moveableRectangles = moveableRectangles;
_fixedRectangles = fixedRectangles;
_fixedSegments = fixedSegments;
_bbox = GetInitialBoundingBox();
_bbox.ScaleAroundCenter(1.25);
InitBitmap();
InitTransform();
movedRectangles = new Rectangle[moveableRectangles.Length];
}
示例13: Intersection
/// <summary>
/// intersection (possibly empty) of rectangles
/// </summary>
/// <param name="rectangle"></param>
/// <returns></returns>
public Rectangle Intersection(Rectangle rectangle)
{
Rectangle intersection = new Rectangle();
if (!Intersects(rectangle))
{
intersection.SetToEmpty();
return intersection;
}
double l = Math.Max(Left, rectangle.Left);
double r = Math.Min(Right, rectangle.Right);
double b = Math.Max(Bottom, rectangle.Bottom);
double t = Math.Min(Top, rectangle.Top);
return new Rectangle(l,b,r,t);
}
示例14: PlaceNodesOnly
public void PlaceNodesOnly(Rectangle bbox)
{
BoundingBox = bbox;
int numInserted = 0;
int level = 1;
int iLevel = 0;
while (numInserted < SortedLgNodeInfos.Count && level <= MaxLevel) {
numInserted = DrawNodesOnlyOnLevel(level, numInserted);
AddAllToNodeLevel(iLevel);
level *= 2;
iLevel++;
}
}
示例15: AddVoronoiCite
void AddVoronoiCite(CdtTriangle triangle)
{
Point p;
var goodTriangle = GetCenterOfDescribedCircle(triangle, out p);
if (!goodTriangle)
return;
if (!BoundingBox.Contains(p))
return;
var rect=new Rectangle(p);
rect.Pad(eps);
if (voronoiSiteTree.GetAllIntersecting(rect).Count() > 0)
return;
voronoiSiteTree.Add(rect, p);
}