Example #1
0
        private bool CreateEdge(DataRep.CADComponent aparent,
                                DataRep.StructuralInterfaceConstraint a,
                                DataRep.CADComponent bparent,
                                DataRep.StructuralInterfaceConstraint b,
                                bool size2fit = false)
        {
            structuralInfProcessed.Add(a.PortID);
            structuralInfProcessed.Add(b.PortID);

            // Create Edge
            DataRep.CADEdge edge = new DataRep.CADEdge(aparent, bparent)
            {
                SrcPortID     = a.PortID,
                DstPortID     = b.PortID,
                SrcPortName   = a.Name,
                DstPortName   = b.Name,
                DegreeFreedom = a.DegreeFreedom,
                SrcIntf       = a,
                DstIntf       = b
            };

            List <Tuple <DataRep.Datum, DataRep.Datum> > constraintPairs = new List <Tuple <DataRep.Datum, DataRep.Datum> >();
            bool result = DataRep.StructuralInterfaceConstraint.MatchStructuralInterfaceDatums(a, b, constraintPairs, Traceability);

            edge.ConstraintPairs.AddRange(constraintPairs);

            // TODO: Add more checking for this
            if (a.Joint != null && b.Joint != null)
            {
                var aJointType = a.Joint.JointType;
                var bJointType = b.Joint.JointType;
                if (aJointType != bJointType)
                {
                    Logger.Instance.AddLogMessage("Mismatched joint type in connected Connectors.", Severity.Error);
                }
                else
                {
                    edge.KinematicJointPair = new DataRep.KinematicJointPair(a.Joint, b.Joint);
                    GMEIDJointIDMap.Add(a.Joint.CyPhyID, edge.KinematicJointPair.XmlID);
                    GMEIDJointIDMap.Add(b.Joint.CyPhyID, edge.KinematicJointPair.XmlID);
                }
            }


            if (size2fit)
            {
                size2fitEdges.Add(edge);
            }
            else
            {
                regularEdges.Add(edge);
            }

            // TODO: !!!!!!!!!!!!!! NEED TO IMPLEMENT !!!!!!!!!!!!!!
            // Check for coordinatesystem datum should be the only 1

            return(!result);
        }
Example #2
0
        private bool CreateEdge(DataRep.CADComponent aparent,
                                DataRep.StructuralInterfaceConstraint a,
                                DataRep.CADComponent bparent,
                                DataRep.StructuralInterfaceConstraint b,
                                bool size2fit = false)
        {
            structuralInfProcessed.Add(a.PortID);
            structuralInfProcessed.Add(b.PortID);

            // Create Edge
            DataRep.CADEdge edge = new DataRep.CADEdge(aparent, bparent)
            {
                SrcPortID = a.PortID,
                DstPortID = b.PortID,
                SrcPortName = a.Name,
                DstPortName = b.Name,
                DegreeFreedom = a.DegreeFreedom,
                SrcIntf = a,
                DstIntf = b
            };

            List<Tuple<DataRep.Datum, DataRep.Datum>> constraintPairs = new List<Tuple<DataRep.Datum,DataRep.Datum>>();
            bool result = DataRep.StructuralInterfaceConstraint.MatchStructuralInterfaceDatums(a, b, constraintPairs);
            edge.ConstraintPairs.AddRange(constraintPairs);

            // TODO: Add more checking for this
            if (a.Joint != null && b.Joint != null)
            {
                var aJointType = a.Joint.JointType;
                var bJointType = b.Joint.JointType;
                if (aJointType != bJointType)
                {
                    Logger.Instance.AddLogMessage("Mismatched joint type in connected Connectors.", Severity.Error);
                }
                else
                {
                    edge.KinematicJointPair = new DataRep.KinematicJointPair(a.Joint, b.Joint);
                    GMEIDJointIDMap.Add(a.Joint.CyPhyID, edge.KinematicJointPair.XmlID);
                    GMEIDJointIDMap.Add(b.Joint.CyPhyID, edge.KinematicJointPair.XmlID);
                }
            }


            if (size2fit)
                size2fitEdges.Add(edge);
            else
                regularEdges.Add(edge);

            // TODO: !!!!!!!!!!!!!! NEED TO IMPLEMENT !!!!!!!!!!!!!!
            // Check for coordinatesystem datum should be the only 1

            return !result;
        }
Example #3
0
        public DataRep.CADContainer WalkAssembly(Dictionary <string, DataRep.CADComponent> regularComponents,
                                                 List <DataRep.CADEdge> regularEdges,
                                                 Dictionary <string, DataRep.CADComponent> size2fitComponents,
                                                 List <DataRep.CADEdge> size2fitEdges,
                                                 List <DataRep.CADComponent> orphans,
                                                 List <string> RefCoordIDs)
        {
            //Dictionary<string, DataRep.CADAssembly> tmpassemblies = new Dictionary<string, DataRep.CADAssembly>();

            DataRep.CADContainer assembliesContainer = new DataRep.CADContainer("jklmn");

            List <DataRep.CADEdge> openEdges = new List <DataRep.CADEdge>();

            openEdges = regularEdges;
            List <string>  openComponents = regularComponents.Keys.ToList();
            Queue <string> openQ          = new Queue <string>();

            assembliesContainer.orphans.AddRange(orphans);

            if (openComponents.Count() == 1 && !openEdges.Any())
            {
                string ID = assemblyID + "|" + newAssemblyIDSeed.ToString();
                DataRep.CADAssembly anassembly = new DataRep.CADAssembly(ID, assemblyName + "_" + (newAssemblyIDSeed++).ToString());               //DataRep.CADAssembly anassembly = new DataRep.CADAssembly(assemblyID, assemblyName);
                anassembly.ChildComponents.Add(regularComponents.First().Key, regularComponents.First().Value);
                anassembly.ChildComponents = regularComponents;
                anassembly.ChildEdges      = regularEdges;
                ToDAG(anassembly, RefCoordIDs);     // EXPERIMENT!!!
                assembliesContainer.assemblies.Add(assemblyID, anassembly);
            }
            else
            {
                int z = 1;
                while (openEdges.Any())
                {
                    List <DataRep.CADEdge> closedEdges      = new List <DataRep.CADEdge>();
                    List <string>          closedComponents = new List <string>();

                    DataRep.CADEdge lastEdge = openEdges.Last();
                    string          srcid    = lastEdge.Src.Id;
                    FindComponentID(srcid,
                                    openComponents,
                                    openQ);

                    WalkIncidentEdges(openQ,
                                      openComponents,
                                      closedComponents,
                                      openEdges,
                                      closedEdges);

                    // create a new island CAssembly;
                    string ID = assemblyID + "|" + newAssemblyIDSeed.ToString();
                    DataRep.CADAssembly anassembly = new DataRep.CADAssembly(ID, assemblyName + "_" + newAssemblyIDSeed.ToString());
                    foreach (var key in closedComponents)
                    {
                        if (regularComponents.ContainsKey(key))
                        {
                            anassembly.ChildComponents.Add(key, regularComponents[key]);
                            component2assemblyTable[key] = ID;
                        }
                    }

                    anassembly.ChildEdges.AddRange(closedEdges);
                    ToDAG(anassembly, RefCoordIDs);
                    assembliesContainer.assemblies.Add(ID, anassembly);

                    newAssemblyIDSeed++;
                    z++;
                }

                if (openComponents.Any())
                {
                    foreach (string id in openComponents)
                    {
                        DataRep.CADComponent component;
                        if (regularComponents.TryGetValue(id, out component))
                        {
                            assembliesContainer.orphans.Add(component);
                        }
                    }
                }

                // size2fit
                // iterate through Size2Fit (are they orphans or belong to a CAssembly?)
                // for each size2fit, find its size2fit edges
                // find which assembly contains the edge's source
                // if they are in the same
                foreach (var item in size2fitComponents)
                {
                    List <DataRep.CADEdge> s2fclosedEdges = new List <DataRep.CADEdge>();                                       // <source, CEdge*>
                    string assemblyParent_ID = FindSize2FitEdges(item.Key, size2fitEdges, s2fclosedEdges);

                    // orphan if no edges or parentID is -1
                    if (!s2fclosedEdges.Any() || assemblyParent_ID == "-1")
                    {
                        assembliesContainer.orphans.Add(item.Value);
                    }
                    else
                    {
                        // add size2fit + size2fit edges to island assembly
                        if (assembliesContainer.assemblies.ContainsKey(assemblyParent_ID))
                        {
                            assembliesContainer.assemblies[assemblyParent_ID].ChildSize2FitComponents[item.Key] = item.Value;
                            assembliesContainer.assemblies[assemblyParent_ID].ChildSize2FitEdges.AddRange(s2fclosedEdges);
                        }
                    }
                }

                // Testing
                //assembliesContainer.ToString();

                // Convert to DAG
                //ToDAG(assembliesContainer.assemblies, RefCoordIDs);

                Print();
            } // else



            return(assembliesContainer);
        }