Пример #1
0
        /***************************************************/
        /****           Private Methods                 ****/
        /***************************************************/
        private static IElement0D FindOrCreateEntity(List <IElement0D> entities, Point point, double tolerance, IElement0D prototypeEntity)
        {
            IElement0D entity = entities.ClosestIElement0D(point);

            if (entity == null || entity.IGeometry().Distance(point) > tolerance)
            {
                entity = prototypeEntity.ClonePositionGuid(point);
                entities.Add(entity);
            }

            return(entity);
        }
Пример #2
0
        public static Graph Graph(int entityCount, int branching, BoundingBox boundingBox, IElement0D prototypeEntity, double tolerance = Tolerance.Distance, RelationDirection relationDirection = RelationDirection.Forwards)
        {
            Graph             graph    = new Graph();
            List <IElement0D> entities = new List <IElement0D>();

            for (int i = 0; i < entityCount; i++)
            {
                Point      p      = Geometry.Create.RandomPoint(m_Rnd, boundingBox);
                IElement0D entity = prototypeEntity.ClonePositionGuid(p);

                if (!ToCloseToAny(entities, entity, tolerance))
                {
                    entities.Add(entity);
                }
            }

            List <IRelation> relations = new List <IRelation>();

            foreach (IElement0D entity in entities)
            {
                foreach (IElement0D d in ClosestIElement0Ds(entities, entity, branching))
                {
                    Relation relation = new Relation()
                    {
                        Source = ((IBHoMObject)entity).BHoM_Guid,
                        Target = ((IBHoMObject)d).BHoM_Guid
                    };
                    relations.AddRange(RelationsToAdd(relation, relationDirection));
                }
            }

            graph.UniqueEntityNames();
            entities.ForEach(n => graph.Entities.Add(((IBHoMObject)n).BHoM_Guid, ((IBHoMObject)n)));
            graph.Relations = relations;

            return(graph);
        }