示例#1
0
文件: Graph.cs 项目: BHoM/BHoM_Engine
        /***************************************************/

        private static IElement0D ClonePositionGuid(this IElement0D element0D, Point position)
        {
            element0D = element0D.DeepClone();
            element0D = element0D.ISetGeometry(position);
            ((IBHoMObject)element0D).BHoM_Guid = Guid.NewGuid();
            return(element0D);
        }
示例#2
0
        /***************************************************/

        private static IElement0D Transform(this IElement0D element0D, TransformMatrix transform, double tolerance)
        {
            if (!transform.IsRigidTransformation(tolerance))
            {
                BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported.");
                return null;
            }

            return element0D.ISetGeometry(Geometry.Modify.Transform(element0D.IGeometry(), transform));
        }
示例#3
0
文件: Graph.cs 项目: BHoM/BHoM_Engine
        public static Graph Graph <T>(int width, int length, int height, double cellSize, T prototypeEntity, RelationDirection relationDirection = RelationDirection.Forwards)
            where T : IElement0D
        {
            Graph graph = new Graph();
            List <List <List <IBHoMObject> > > entityGrid = new List <List <List <IBHoMObject> > >();

            for (int k = 0; k < height; k++)
            {
                List <List <IBHoMObject> > level = new List <List <IBHoMObject> >();
                for (int i = 0; i < width; i++)
                {
                    List <IBHoMObject> col = new List <IBHoMObject>();
                    for (int j = 0; j < length; j++)
                    {
                        Point p = Geometry.Create.Point(i * cellSize, j * cellSize, k * cellSize);

                        IElement0D entity = prototypeEntity.DeepClone();
                        entity = entity.ISetGeometry(p);
                        ((IBHoMObject)entity).BHoM_Guid = Guid.NewGuid();

                        graph.Entities.Add(((IBHoMObject)entity).BHoM_Guid, ((IBHoMObject)entity));

                        col.Add((IBHoMObject)entity);
                    }
                    level.Add(col);
                }
                entityGrid.Add(level);
            }
            for (int k = 0; k < height; k++)
            {
                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < length; j++)
                    {
                        List <IBHoMObject> connections = RandomNeighbours(entityGrid, i, j, k);
                        foreach (IBHoMObject c in connections)
                        {
                            Relation relation = new Relation()
                            {
                                Source = entityGrid[k][i][j].BHoM_Guid,
                                Target = c.BHoM_Guid
                            };
                            graph.Relations.AddRange(RelationsToAdd(relation, relationDirection));
                        }
                    }
                }
            }

            graph.UniqueEntityNames();
            return(graph);
        }
示例#4
0
        /******************************************/

        public static IElement0D Translate(this IElement0D element0D, Vector transform) //todo: move this to analytical along with other IElement methods
        {
            return(element0D.ISetGeometry(Geometry.Modify.Translate(element0D.IGeometry(), transform)));
        }
示例#5
0
 public static IElement0D Translate(this IElement0D element0D, Vector transform)
 {
     return(element0D.ISetGeometry(Geometry.Modify.Translate(element0D.IGeometry(), transform)));
 }
示例#6
0
 public static IElement0D RoundCoordinates(this IElement0D element0d, int decimalPlaces = 6)
 {
     return(element0d.ISetGeometry(Geometry.Modify.RoundCoordinates(element0d.IGeometry(), decimalPlaces)));
 }