Ejemplo n.º 1
0
 /// <summary>
 /// Expand this bounding box to contain the specified geometry, if
 /// necessary.
 /// </summary>
 /// <param name="geometry"></param>
 public void Include(VertexGeometry geometry)
 {
     if (geometry != null)
     {
         Include(geometry.Vertices);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Fit this bounding box around a shape
 /// </summary>
 /// <param name="shape"></param>
 public void Fit(VertexGeometry shape)
 {
     if (shape?.Vertices != null && shape.Vertices.Count > 0)
     {
         Fit(shape.Vertices[0].Position);
         shape.StretchBoxAround(this);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Copy attached data (for example, nodes connected to vertices)
 /// from another shape to this one.
 /// </summary>
 /// <param name="other"></param>
 /// <param name="copyOnlyIfCoincident">If true, data will only be copied between
 /// vertices if the old and new vertex are within tolerance of one another.
 /// If false (default) data will be copied regardless.</param>
 public void CopyAttachedDataFrom(VertexGeometry other, bool copyOnlyIfCoincident = false)
 {
     for (int i = 0; i < Math.Min(Vertices.Count, other.Vertices.Count); i++)
     {
         Vertex vA = Vertices[i];
         Vertex vB = other.Vertices[i];
         if (!copyOnlyIfCoincident || vA.DistanceToSquared(vB) < Tolerance.Distance)
         {
             vA.CopyAttachedDataFrom(vB);
         }
     }
     Attributes = other.Attributes; //TODO: Duplicate instead?
     //Add any other attached data to be copied here
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Find and return the layer (if any) that the specified piece
        /// of geometry is on.
        /// </summary>
        /// <param name="geometry"></param>
        /// <returns>The layer the geometry is on, else null if no layer
        /// containing the geometry can be found</returns>
        public GeometryLayer LayerOf(VertexGeometry geometry)
        {
            if (geometry.Attributes?.LayerName != null && Contains(geometry.Attributes.LayerName))
            {
                GeometryLayer result = this[geometry.Attributes.LayerName];
                if (result.Contains(geometry.GUID))
                {
                    return(result);
                }
            }

            foreach (GeometryLayer layer in this)
            {
                if (layer.Contains(geometry.GUID))
                {
                    return(layer);
                }
            }

            return(null); // Nothing found!
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Does this bounding box entirely contain the specified geometry?
 /// To test for partial containment use the Overlaps function instead
 /// </summary>
 /// <param name="geometry"></param>
 /// <returns></returns>
 public bool Contains(VertexGeometry geometry)
 {
     return(Contains(geometry.BoundingBox));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Does this bounding box overlap that of the specified geometry object?
 /// </summary>
 /// <param name="geometry"></param>
 /// <returns></returns>
 public bool Overlaps(VertexGeometry geometry)
 {
     return(Overlaps(geometry.BoundingBox));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Determines whether or not the layers within this table contain the
 /// specified piece of geometry
 /// </summary>
 /// <param name="geometry"></param>
 /// <returns></returns>
 public bool Contains(VertexGeometry geometry)
 {
     return(LayerOf(geometry) != null);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Remove any instances of the geometry with the specified
 /// key from any layer in this table
 /// </summary>
 /// <param name="geometry">The geometry to remove</param>
 /// <returns>True if any geometry was removed, else false.</returns>
 public bool RemoveGeometry(VertexGeometry geometry)
 {
     return(RemoveGeometry(geometry.GUID));
 }