상속: MonoBehaviour
        public void CanHandleVertexLimit()
        {
            // ARRANGE
            var builder = new FacadeBuilder(TestHelper.GetCustomizationService())
            {
                Trace = new ConsoleTrace()
            };
            var building = new Building()
            {
                Footprint = new List <Vector2d>()
                {
                    new Vector2d(0, 0),
                    new Vector2d(500, 0),
                    new Vector2d(500, 500),
                    new Vector2d(0, 500),
                },
                FacadeColor = "gradient(#0eff94, #0deb88 50%, #07854d)",
                Height      = 100
            };

            // ACT
            var result = builder.Build(building);

            // ASSERT
            Assert.IsNotNull(result);
            Assert.Greater(result.Count, 1);
        }
예제 #2
0
 void OnEnable()
 {
     builder = (FacadeBuilder)target;
 }
예제 #3
0
        void ProcessSubPrimitives(Primitive p)
        {
            if (p.subEdges == null || p.subEdges.Count <= 0)
            {
                return;
            }

            // Copy local lists from primitive's sub nodes and edges
            List <Node> _nodes = new List <Node>();
            List <Edge> _edges = new List <Edge>();

            EdgeGraphUtility.CopyNodesAndEdges(p.subNodes, p.subEdges, out _nodes, out _edges);

            EdgeGraphUtility.CheckAdjacentNodes(ref _nodes, ref _edges);

            //subPrimitives = new List<Primitive>();
            List <Primitive> _subPrimitives = new List <Primitive>();

            // Extract primitives inside main primitives
            try
            {
                MinimalCycle.Extract(ref _nodes, ref _edges, ref _subPrimitives);
            }
            catch (Exception e)
            {
                Debug.LogWarning("Graph::GeneratePrimitiveSubPrimitives() - Error while extracting primitives: " + e.Message);
                return;
            }

            _subPrimitives.ForEach((sp) =>
            {
                sp.Process();
            });

            for (int i = _subPrimitives.Count - 1; i >= 0; i--)
            {
                if (!_subPrimitives[i].EvaluationResult)
                {
                    _subPrimitives.RemoveAt(i);
                }
            }

            _subPrimitives.ForEach((sp) =>
            {
                sp.parent = p.ID;

                GameObject subGraphObj = new GameObject("SubGraph");
                subGraphObj.transform.SetParent(transform);
                subGraphObj.transform.localPosition = Vector3.zero;
                subGraphObj.transform.localScale    = Vector3.one;

                Graph subGraph    = subGraphObj.AddComponent <Graph>();
                subGraph.GraphID  = Guid.NewGuid().GetHashCode();
                subGraphObj.name += subGraph.GraphID;

                subGraph.nodes = new List <Node>();
                foreach (var node in sp.nodes)
                {
                    subGraph.nodes.Add(node);
                }
                subGraph.edges = new List <Edge>();
                foreach (var edge in sp.edges)
                {
                    edge.Width = 0f;
                    subGraph.edges.Add(edge);
                }

                subGraph.ProcessMinimalCycles();

                subGraph.mainPrimitives[0].parent = p.ID;

                subGraphs.Add(subGraph);

                //subPrimitives.Add(subGraph.mainPrimitives[0]);

                FacadeBuilder builder = GetComponent <FacadeBuilder>();
                if (builder != null)
                {
                    FacadeBuilder subBuilder       = subGraph.gameObject.AddComponent <FacadeBuilder>();
                    subBuilder.inSet               = builder.inSet;
                    subBuilder.facadeStretchPrefab = builder.facadeStretchPrefab;
                    subBuilder.facadePrefabs       = builder.facadePrefabs;
                    subBuilder.roofMiddleMaterial  = builder.roofMiddleMaterial;
                    subBuilder.roofSideMaterial    = builder.roofSideMaterial;
                    subBuilder.roofHeight          = builder.roofHeight;
                    subBuilder.roofMiddleAddHeight = builder.roofMiddleAddHeight;
                    subBuilder.roofAccentWidth     = builder.roofAccentWidth;
                }

                FootprintPlacer placer = GetComponent <FootprintPlacer>();
                if (placer != null)
                {
                    FootprintPlacer _placer        = subGraph.gameObject.AddComponent <FootprintPlacer>();
                    _placer.footprintPrefabsOnEdge = placer.footprintPrefabsOnEdge;
                    _placer.footprintPrefabsInside = placer.footprintPrefabsInside;
                    _placer.UpdateData();
                }
            });
        }