Exemplo n.º 1
0
        private void CreateEdges(DataRep.CADComponent component, CyPhy.ComponentAssembly topassembly, bool size2fit = false)
        {
            foreach (KeyValuePair <string, DataRep.StructuralInterfaceConstraint> item in component.StructuralInterfaceNodes)
            {
                // [1] find matching structural interface
                // [2] CreateEdge(a, b)

                var found = structuralInfProcessed.Find(x => x == item.Key);
                if (found == null)
                {
                    CommonTraversal traverser = new CommonTraversal(item.Value.CyPhyImpl, topassembly);
                    if (traverser.FoundConnectedNodes.Count() > 1)
                    {
                        Logger.Instance.AddLogMessage("StructuralInterface connected to >1 StructuralInterface [" + item.Value.CyPhyImpl.Path + "]", Severity.Error);
                        continue;
                    }
                    else if (traverser.FoundConnectedNodes.Count() < 1)
                    {
                        if (traverser.GetVisitedConnectionCount() > 0)
                        {
                            Logger.Instance.AddLogMessage("StructuralInterface not connected to another StructuralInterface [" + item.Value.CyPhyImpl.Path + "]", Severity.Warning);
                        }
                        continue;
                    }

                    string dstparentid = traverser.FoundConnectedNodes.First().ParentContainer.ID;
                    string dstsiid     = traverser.FoundConnectedNodes.First().ID;
                    if (!size2fitComponents.ContainsKey(dstparentid))
                    {
                        if (regularComponents.ContainsKey(dstparentid))
                        {
                            if (regularComponents[dstparentid].StructuralInterfaceNodes.ContainsKey(dstsiid))
                            {
                                // META-3124
                                if (item.Value.Joint != null && regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint != null)
                                {
                                    if (item.Value.Joint.Name == regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint.Name)
                                    {
                                        CreateEdge(component,
                                                   item.Value,
                                                   regularComponents[dstparentid],
                                                   regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid]);
                                    }
                                    else
                                    {
                                        Logger.Instance.AddLogMessage("Mismatched joints in connected Connectors: " + component.CyPhyModelPath + item.Value.CyPhyImpl.Name + "(" + item.Value.Joint + "), " + regularComponents[dstparentid].CyPhyModelPath + regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].CyPhyImpl.Name + "(" + regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint + ")", Severity.Error);
                                    }
                                }
                                else
                                {
                                    CreateEdge(component,
                                               item.Value,
                                               regularComponents[dstparentid],
                                               regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid]);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void CreateEdges (DataRep.CADComponent component, CyPhy.ComponentAssembly topassembly, bool size2fit = false)
        {
            foreach (KeyValuePair<string, DataRep.StructuralInterfaceConstraint> item in component.StructuralInterfaceNodes)
            {
                // [1] find matching structural interface
                // [2] CreateEdge(a, b) 

                var found = structuralInfProcessed.Find(x => x == item.Key);
                if (found == null)
                {
                    CommonTraversal traverser = new CommonTraversal(item.Value.CyPhyImpl, topassembly);
                    if (traverser.FoundConnectedNodes.Count() > 1)
                    {
                        Logger.Instance.AddLogMessage("StructuralInterface connected to >1 StructuralInterface [" + item.Value.CyPhyImpl.Path + "]", Severity.Error);
                        continue;
                    }
                    else if (traverser.FoundConnectedNodes.Count() < 1)
                    {
                        if (traverser.GetVisitedConnectionCount() > 0)
                            Logger.Instance.AddLogMessage("StructuralInterface not connected to another StructuralInterface [" + item.Value.CyPhyImpl.Path + "]", Severity.Warning);
                        continue;
                    }

                    string dstparentid = traverser.FoundConnectedNodes.First().ParentContainer.ID;
                    string dstsiid = traverser.FoundConnectedNodes.First().ID;
                    if (!size2fitComponents.ContainsKey(dstparentid))
                    {
                        if (regularComponents.ContainsKey(dstparentid))
                        {
                            if (regularComponents[dstparentid].StructuralInterfaceNodes.ContainsKey(dstsiid))
                            {
                                // META-3124
                                if (item.Value.Joint != null && regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint != null)
                                {
                                    if (item.Value.Joint.Name == regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint.Name)
                                        CreateEdge(component,
                                                   item.Value,
                                                   regularComponents[dstparentid],
                                                   regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid]);
                                    else
                                    {
                                        Logger.Instance.AddLogMessage("Mismatched joints in connected Connectors: " + component.CyPhyModelPath + item.Value.CyPhyImpl.Name + "(" + item.Value.Joint + "), " + regularComponents[dstparentid].CyPhyModelPath + regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].CyPhyImpl.Name + "(" + regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid].Joint + ")", Severity.Error);
                                    }
                                }
                                else
                                {
                                    CreateEdge(component,
                                               item.Value,
                                               regularComponents[dstparentid],
                                               regularComponents[dstparentid].StructuralInterfaceNodes[dstsiid]);

                                }
                            }
                        }
                    }
                }
            }
        }