public void ExtractMainPrimitives(float childEdgeWidth) { if (mainPrimitives != null && mainPrimitives.Count > 0) { UtilityTools.Helper.DestroyChildren(transform); mainPrimitives.ForEach((p) => { 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 p.nodes) { subGraph.nodes.Add(node); } subGraph.edges = new List <Edge>(); foreach (var edge in p.edges) { Edge edgeCopy = new Edge(edge.Node1, edge.Node2, childEdgeWidth); subGraph.edges.Add(edgeCopy); } subGraph.ProcessMinimalCycles(); subGraphs.Add(subGraph); FootprintPlacer placer = GetComponent <FootprintPlacer>(); if (placer != null) { FootprintPlacer _placer = subGraph.gameObject.AddComponent <FootprintPlacer>(); _placer.footprintPrefabsOnEdge = placer.footprintPrefabsOnEdge; _placer.footprintPrefabsInside = placer.footprintPrefabsInside; _placer.UpdateData(); } }); } }
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(); } }); }