Пример #1
0
        private static bool AddFace(CyPhy.Face face, List <KeyValuePair <string, string> > featureList, out CADGeometry.FeatureTypeEnum type)
        {
            List <MgaFCO> referencePts = new List <MgaFCO>();

            referencePts = FindByRole(face.Impl as MgaModel, "ReferencePoint");
            int ptCnt   = referencePts.Count();
            int surfCnt = face.Children.SurfaceCollection.Count();

            type = CADGeometry.FeatureTypeEnum.POINT;
            if ((ptCnt + surfCnt) > 1)
            {
                // insert error message
                Logger.Instance.AddLogMessage(String.Format("Face geometry must contain a ReferencePoint or a ReferenceSurface: {0}", face.ToHyperLink()), Severity.Error);
                return(false);
            }

            if (ptCnt > 0)          // Plane
            {
                type = CADGeometry.FeatureTypeEnum.POINT;
                CyPhy.Point point = CyPhyClasses.Point.Cast(referencePts.First());
                if (CreateFeatureFromPoint(point,
                                           featureList))
                {
                    return(true);
                }
                else
                {
                    Logger.Instance.AddLogMessage(String.Format("Face geometry's ReferencePoint must connect to a Point datum inside a CADModel: {0}", face.ToHyperLink()), Severity.Error);
                    return(false);
                }
            }

            if (surfCnt > 0)        // Surface
            {
                type = CADGeometry.FeatureTypeEnum.SURFACE;
                CyPhy.Surface surface = face.Children.SurfaceCollection.First();
                if (CreateFeatureFromPoint(surface,
                                           featureList))
                {
                    return(true);
                }
                else
                {
                    Logger.Instance.AddLogMessage(String.Format("Face geometry's ReferenceSurface must connect to a Surface datum inside a CADModel: {0}", face.ToHyperLink()), Severity.Error);
                    return(false);
                }
            }

            return(false);
        }
Пример #2
0
        private void VisitPort(CyPhy.Port port)
        {
            if (!visitedItems.Contains(port.ID))
            {
                visitedItems.Add(port.ID);

                foreach (CyPhy.PortComposition conn in port.SrcConnections.PortCompositionCollection)
                {
                    CyPhy.Port feature = conn.SrcEnds.Port;
                    if (feature != null)
                    {
                        if (feature.ParentContainer.Kind == "CADModel" && feature.Kind == portKind)
                        {
                            portsFound.Add(feature);
                        }
                        else
                        {
                            VisitPort(feature);
                        }
                    }
                }

                foreach (CyPhy.PortComposition conn in port.DstConnections.PortCompositionCollection)
                {
                    CyPhy.Port feature = conn.DstEnds.Port;
                    if (feature != null)
                    {
                        if (feature.ParentContainer.Kind == "CADModel" && feature.Kind == portKind)
                        {
                            portsFound.Add(feature);
                        }
                        else
                        {
                            VisitPort(feature);
                        }
                    }
                }

                if (port.Kind == "Surface")
                {
                    foreach (CyPhy.SurfaceReverseMap conn in (port as CyPhy.Surface).SrcConnections.SurfaceReverseMapCollection)
                    {
                        CyPhy.Surface surface = conn.SrcEnds.Surface;
                        if (surface != null)
                        {
                            if (surface.ParentContainer.Kind == "CADModel")
                            {
                                portsFound.Add(surface);
                            }
                        }
                        else
                        {
                            VisitPort(surface);
                        }
                    }

                    foreach (CyPhy.SurfaceReverseMap conn in (port as CyPhy.Surface).DstConnections.SurfaceReverseMapCollection)
                    {
                        CyPhy.Surface surface = conn.DstEnds.Surface;
                        if (surface != null)
                        {
                            if (surface.ParentContainer.Kind == "CADModel")
                            {
                                portsFound.Add(surface);
                            }
                        }
                        else
                        {
                            VisitPort(surface);
                        }
                    }
                }
            }
        }