예제 #1
0
 private Transform SetParents(HierarchyZone zone, Transform zoneTransform)
 {
     if (zone.Parent != null)
     {
         zoneTransform.SetParent(ZoneObjects[zone.Parent].transform, true);
     }
     return(zoneTransform);
 }
예제 #2
0
        private Transform InstantiateGameObjects(HierarchyZone zone)
        {
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            float      x    = zone.UpperLeft.X;
            float      y    = zone.UpperLeft.Y;
            float      z    = zone.UpperLeft.Z;

            if (float.IsInfinity(Mathf.Abs(x)))
            {
                x = 0;
            }
            if (float.IsInfinity(Mathf.Abs(y)))
            {
                y = 0;
            }
            if (float.IsInfinity(Mathf.Abs(z)))
            {
                z = 0;
            }
            cube.transform.position   = (new Vector3(x, y, z));
            cube.transform.localScale = (new Vector3(zone.GetLength(), zone.GetWidth(), 300));
            cube.name = zone.Label;
            return(cube.transform);
        }
        public List <HierarchyZone> GetZones(string pointsText, string basepointsText, string optionpointsText, string textpointsText)
        {
            List <HierarchyZone>     zones             = new List <HierarchyZone>();
            List <Assignment>        assignments       = new List <Assignment>();
            List <Point>             basepoints        = new List <Point>();
            List <Point>             optionpoints      = new List <Point>();
            Dictionary <int, Spline> splineAssignments = new Dictionary <int, Spline>();
            List <TextPoint>         textPoints        = new List <TextPoint>();

            zones.Add(new HierarchyZone());
            if (this.InputFormat == PointsInputFormat.MAX)
            {
                basepoints        = DeserializeMAXPoints(basepointsText);
                optionpoints      = DeserializeMAXPoints(optionpointsText);
                splineAssignments = DeserializeMAXSplinePoints(pointsText);
                textPoints        = DeserializeAutoCADTextPoints(textpointsText);
            }

            foreach (KeyValuePair <int, Spline> assignment in splineAssignments)
            {
                if (assignment.Value.Type == Spline.SplineType.RECTANGLE)
                {
                    zones.Add(new HierarchyZone(assignment.Value.Points));
                }
                else if (assignment.Value.Type == Spline.SplineType.ARC)
                {
                    assignments.Add(new Assignment(assignment.Value.Points));
                }
            }

            for (int i = 0; i < zones.Count; i++)
            {
                zones[i].Parent = GetSmallestPointZone(zones[i].UpperLeft, ref zones);
                try {
                    zones[i].Label = GetNearestTextPoint(zones[i].LowerLeft, ref textPoints).Text;
                } catch (NullReferenceException e)
                {
                }
            }

            foreach (Assignment assignment in assignments)
            {
                foreach (Point p in assignment.Optionpoints)
                {
                    Point refPoint = GetMatchingPoint(p, ref basepoints);
                    if (refPoint != null)
                    {
                        assignment.SetBasepoint(ref refPoint);
                        break;
                    }
                }

                foreach (Point optionpoint in assignment.Optionpoints)
                {
                    HierarchyZone smallestZone = GetSmallestPointZone(optionpoint, ref zones);
                    assignment.Children.Add(smallestZone);
                }
            }
            for (int i = 0; i < zones.Count; i++)
            {
                if (zones[i].Parent != null)
                {
                    zones[i].Parent.Children.Add(zones[i]);
                }
            }
            return(zones);
        }
 public HierarchyZone(List <Point> points, HierarchyZone parent, HierarchyZone child) : base(points)
 {
     this.Parent   = parent;
     this.Children = new List <HierarchyZone>();
     this.Children.Add(child);
 }
 public HierarchyZone(List <Point> points, HierarchyZone parent, List <HierarchyZone> children) : base(points)
 {
     this.Parent   = parent;
     this.Children = children;
 }