コード例 #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);
        }
コード例 #2
0
        private void ProcessComponents(List <CyPhy.Component> regular, List <CyPhy.Component> size2fitcomponents, CyPhy.ComponentAssembly cyphyasm)
        {
            if (regular.Count < 1)
            {
                if (!MetaLink)
                {
                    if (cyphyasm != null)
                    {
                        Logger.Instance.AddLogMessage("Assembly do not contain components with Creo CADModels [" + cyphyasm.Path + "]", Severity.Error);
                    }
                    else
                    {
                        Logger.Instance.AddLogMessage("CAD TestBench does not contain any valid TIPs!", Severity.Error);
                    }
                }
                return;
            }

            List <Task <string> > missingFiles = new List <Task <string> >();

            // [2] Create CADComponent, size2fit, and edges
            foreach (var item in regular)
            {
                DataRep.CADComponent component = new DataRep.CADComponent(item, ProjectDirectory: this.ProjectDirectory, Traceability: Traceability);
                this.regularComponents[item.ID] = component;
                missingFiles.Add(component.missingFile);
            }

            foreach (var item in size2fitcomponents)
            {
                DataRep.CADComponent component = new DataRep.CADComponent(item, ProjectDirectory: this.ProjectDirectory, size2fit: true, Traceability: Traceability);
                this.size2fitComponents[item.ID] = component;
                missingFiles.Add(component.missingFile);
            }

            foreach (var task in missingFiles.Where(t => t != null))
            {
                task.Wait();
                if (task.Result != null)
                {
                    Logger.Instance.AddLogMessage(task.Result, Severity.Error);
                }
            }

            foreach (var component in regularComponents)
            {
                foreach (var structintf in component.Value.StructuralInterfaceNodes)
                {
                    if (structintf.Value.Joint != null)
                    {
                        structintf.Value.Joint.FindTopLevelPort(cyphyasm);
                    }
                }
            }

            // [3] Create Edges
            foreach (KeyValuePair <string, DataRep.CADComponent> item in size2fitComponents)
            {
                CreateEdges(item.Value, cyphyasm, true);
            }

            foreach (KeyValuePair <string, DataRep.CADComponent> item in regularComponents)
            {
                CreateEdges(item.Value, cyphyasm);
            }

            // R. Owens 1/18/2017
            // The following code was moved to ProcessReferenceCoordinateSystems
            // This is because there are cases where ProcessReferenceCoordinateSystems should be called independent
            // of calling process components
            //if (cyphyasm != null)
            //{
            //    // [4] Find ReferenceCoordinateComponents
            //    foreach (CyPhy.ReferenceCoordinateSystem refCoord in cyphyasm.Children.ReferenceCoordinateSystemCollection)
            //    {
            //        ReferenceCoordinateSystemTraversal traverser = new ReferenceCoordinateSystemTraversal(refCoord);
            //        referenceCoordComponents.AddRange(traverser.referenceCoordComponents);
            //    }
            //}

            //if (referenceCoordComponents.Count == 0)
            //{
            //    Logger.Instance.AddLogMessage("No referencecoordinatesystem was found. Root component of assembly will be selected arbitrarily.", Severity.Warning);
            //}

            // [5] Print Assembly
            PrintAssembly();
        }
コード例 #3
0
        private void ProcessComponents(List<CyPhy.Component> regular, List<CyPhy.Component> size2fitcomponents, CyPhy.ComponentAssembly cyphyasm)
        {
            if (regular.Count < 1)
            {
                if (!MetaLink)
                {
                    if (cyphyasm != null)
                        Logger.Instance.AddLogMessage("Assembly do not contain components with Creo CADModels [" + cyphyasm.Path + "]", Severity.Error);
                    else
                        Logger.Instance.AddLogMessage("CAD TestBench does not contain any valid TIPs!", Severity.Error);
                }
                return;
            }

            // [2] Create CADComponent, size2fit, and edges
            foreach (var item in regular)
            {
                DataRep.CADComponent component = new DataRep.CADComponent(item, ProjectDirectory: this.ProjectDirectory);
                this.regularComponents[item.ID] = component;

            }

            foreach (var item in size2fitcomponents)
            {
                DataRep.CADComponent component = new DataRep.CADComponent(item, ProjectDirectory: this.ProjectDirectory, size2fit: true);
                this.size2fitComponents[item.ID] = component;
            }

            foreach (var component in regularComponents)
            {
                foreach (var structintf in component.Value.StructuralInterfaceNodes)
                {
                    if (structintf.Value.Joint != null)
                    {
                        structintf.Value.Joint.FindTopLevelPort(cyphyasm);
                    }
                }
            }

            // [3] Create Edges
            foreach (KeyValuePair<string, DataRep.CADComponent> item in size2fitComponents)
            {
                CreateEdges(item.Value, cyphyasm, true);
            }

            foreach (KeyValuePair<string, DataRep.CADComponent> item in regularComponents)
            {
                CreateEdges(item.Value, cyphyasm);
            }

            if (cyphyasm != null)
            {
                // [4] Find ReferenceCoordinateComponents
                foreach (CyPhy.ReferenceCoordinateSystem refCoord in cyphyasm.Children.ReferenceCoordinateSystemCollection)
                {
                    ReferenceCoordinateSystemTraversal traverser = new ReferenceCoordinateSystemTraversal(refCoord);
                    referenceCoordComponents.AddRange(traverser.referenceCoordComponents);
                }

            }

            if (referenceCoordComponents.Count == 0)
            {
                Logger.Instance.AddLogMessage("No referencecoordinatesystem was found. Root component of assembly will be selected arbitrarily.", Severity.Warning);
            }

            // [5] Print Assembly
            PrintAssembly();
        }
コード例 #4
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]);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: CADEdge.cs プロジェクト: landunin/meta-core
        public CAD.ConstraintType ToCADXMLOutput(TestBenchModel.TestBenchBase testBenchBase)
        {
            CAD.ConstraintType constraintout = new CAD.ConstraintType();
            constraintout._id = UtilityHelpers.MakeUdmID();
            CADComponent src = Src as CADComponent;
            CADComponent dst = Dst as CADComponent;

            string srcid = src.DisplayID;
            string dstid = dst.DisplayID;

            if (ConstraintPairs.Any())
            {
                List <CAD.PairType> pairlist = new List <CAD.PairType>();

                foreach (var item in ConstraintPairs)
                {
                    List <CAD.ConstraintFeatureType> constrainfeaturelist = new List <CAD.ConstraintFeatureType>();
                    CAD.PairType pair = new CAD.PairType();
                    pair._id = UtilityHelpers.MakeUdmID();
                    pair.FeatureAlignmentType = item.Item1.Alignment;
                    pair.FeatureGeometryType  = item.Item1.Type.ToString().ToUpper();
                    pair.FeatureInterfaceType = "CAD_DATUM";
                    if (item.Item1.Guide || item.Item2.Guide)
                    {
                        pair.Guide = "True";
                    }

                    CAD.ConstraintFeatureType afeature = new CAD.ConstraintFeatureType();
                    afeature._id                    = UtilityHelpers.MakeUdmID();
                    afeature.ComponentID            = item.Item1.ComponentID;
                    afeature.FeatureName            = item.Item1.DatumName;
                    afeature.FeatureOrientationType = item.Item1.Orientation;
                    if (item.Item1.Marker != null)
                    {
                        afeature.GeometryMarker = item.Item1.Marker.ToCADXml();
                    }

                    CAD.ConstraintFeatureType bfeature = new CAD.ConstraintFeatureType();
                    bfeature._id                    = UtilityHelpers.MakeUdmID();
                    bfeature.ComponentID            = item.Item2.ComponentID;
                    bfeature.FeatureName            = item.Item2.DatumName;
                    bfeature.FeatureOrientationType = item.Item2.Orientation;
                    if (item.Item2.Marker != null)
                    {
                        bfeature.GeometryMarker = item.Item2.Marker.ToCADXml();
                    }

                    constrainfeaturelist.Add(afeature);
                    constrainfeaturelist.Add(bfeature);
                    pair.ConstraintFeature = constrainfeaturelist.ToArray();
                    pairlist.Add(pair);
                }
                constraintout.Pair = pairlist.ToArray();

                // META-3124
                if (KinematicJointPair != null)
                {
                    constraintout.Joint = KinematicJointPair.ToCADXMLOutput();
                }

                // Associated geomnetries
                List <CAD.GeometryType> geoms = new List <CAD.GeometryType>();
                foreach (var geom in SrcIntf.Geometry.Union(DstIntf.Geometry))
                {
                    geoms.Add(geom.ToCADXMLOutput());
                }
                constraintout.Geometry = geoms.ToArray();

                // Adjoining surface treatment (if any)
                if (testBenchBase is TestBenchModel.FEATestBench)
                {
                    string surftreatment = GetAdjoiningSurfaceTreatment(testBenchBase as TestBenchModel.FEATestBench);
                    constraintout.AdjoiningSurfaceType = surftreatment;
                }
            }


            return(constraintout);
        }