Ejemplo n.º 1
0
        public Datum(string name, string type, string compid, bool guide)
        {
            DatumName = name;
            if (type == "CoordinateSystem")
            {
                Type = DatumType.CSYS;
            }
            else if (type == "Point")
            {
                Type = DatumType.Point;
            }
            else if (type == "Surface")
            {
                Type = DatumType.Surface;
            }
            else if (type == "Axis")
            {
                Type = DatumType.Axis;
            }

            ComponentID = compid;
            DatumID     = UtilityHelpers.MakeUdmID();

            Guide = guide;
        }
Ejemplo n.º 2
0
        public IActionResult OpenFoodTrucks()
        {
            int    currentSystemDayIndex = (int)System.DateTime.Now.DayOfWeek;
            string currentSystemTime     = DateTime.Now.ToString("HH:mm", System.Globalization.DateTimeFormatInfo.InvariantInfo);

            //To Do: Cheat function to convert webserver time to UTC-8. Fix this.
            currentSystemTime = UtilityHelpers.ConvertToUtcMinus8(currentSystemTime);

            string url = "https://data.sfgov.org/resource/jjew-r69b.json";

            ApiHelper.InitializeClient();
            List <FoodTruckModel> allFoodTrucks  = Task.Run(() => FoodTruckProcessor.LoadFoodTruckData(url)).Result;
            List <FoodTruckModel> openFoodTrucks = FoodTruckProcessor.GetOpenFoodTrucks(currentSystemDayIndex, currentSystemTime, allFoodTrucks);
            int maxPageCounter = (int)Math.Ceiling((decimal)openFoodTrucks.Count / 10);
            FoodTruckViewModel foodTruckViewModel = new FoodTruckViewModel
            {
                allFoodTrucks      = allFoodTrucks,
                openFoodTrucks     = openFoodTrucks,
                currentPageCounter = 1,
                maxPageCounter     = maxPageCounter,
                currentSystemTime  = currentSystemTime
            };

            return(View(foodTruckViewModel));
        }
Ejemplo n.º 3
0
        public CAD.GeometryType ToCADXMLOutput()
        {
            CAD.GeometryType geometryout = new CAD.GeometryType();
            geometryout._id = UtilityHelpers.MakeUdmID();

            CAD.FeaturesType featuresout = new CAD.FeaturesType();
            featuresout._id = UtilityHelpers.MakeUdmID();
            featuresout.FeatureInterfaceType       = "CAD_DATUM";            // fixed
            featuresout.FeatureGeometryType        = featureType.ToString(); //featuresout.FeatureGeometryType = "POINT";
            featuresout.GeometryType               = GeometryType;
            featuresout.FeatureID                  = FeatureID;
            featuresout.PrimaryGeometryQualifier   = PrimaryQualifier;
            featuresout.SecondaryGeometryQualifier = SecondaryQualifier;

            List <CAD.FeatureType> featureList = new List <CAD.FeatureType>();

            foreach (var item in GeometryFeatures)
            {
                CAD.FeatureType feature = new CAD.FeatureType
                {
                    _id         = UtilityHelpers.MakeUdmID(),
                    ComponentID = item.ComponentID,
                    Name        = item.DatumName,
                    MetricID    = item.MetricID
                };
                featureList.Add(feature);
            }
            featuresout.Feature = featureList.ToArray();

            geometryout.Features    = new CAD.FeaturesType[1];
            geometryout.Features[0] = featuresout;
            return(geometryout);
        }
Ejemplo n.º 4
0
        public override string ToGraphViz(bool directed = false)
        {
            StringBuilder sbuilder = new StringBuilder();

            sbuilder.AppendFormat("subgraph cluster_{0}",
                                  UtilityHelpers.CleanString2(Id, 100, "-"));
            sbuilder.Append("{\n").AppendLine();
            sbuilder.AppendFormat("label = \"{0}\";",
                                  Id).AppendLine();

            foreach (CADComponent item in ChildComponents.Values)
            {
                sbuilder.Append(item.ToGraphViz(directed)).AppendLine();
            }

            foreach (CADComponent item in ChildSize2FitComponents.Values)
            {
                sbuilder.Append(item.ToGraphViz(directed)).AppendLine();
            }

            foreach (CADEdge item in ChildEdges)
            {
                sbuilder.Append(item.ToGraphViz(directed)).AppendLine();
            }

            sbuilder.Append("}\n").AppendLine();

            return(sbuilder.ToString());
        }
Ejemplo n.º 5
0
        protected override void AddAnalysisToXMLOutput(CAD.AssemblyType cadassembly)
        {
            base.AddAnalysisToXMLOutput(cadassembly);
            CAD.AnalysesType cadanalysis = GetCADAnalysis(cadassembly);

            CAD.BlastType blastanalysis = new CAD.BlastType();
            blastanalysis._id        = UtilityHelpers.MakeUdmID();
            blastanalysis.AnalysisID = blastConfig.analysis.ID;
            if (referencePlaneType != Survivability.ReferencePlaneTypeEnum.None)
            {
                CAD.ReferencePlaneType refplane = new CAD.ReferencePlaneType();
                refplane._id  = UtilityHelpers.MakeUdmID();
                refplane.Type = referencePlaneType.ToString();
                blastanalysis.ReferencePlane    = new CAD.ReferencePlaneType[1];         // cardinality should be changed to have 0..1 in CAD_Uml.xme
                blastanalysis.ReferencePlane[0] = refplane;
            }

            List <CAD.MetricType> metrics = MetricsToCADXMLOutput(Computations, cadassembly.ConfigurationID);

            if (metrics.Count > 0)
            {
                blastanalysis.Metrics        = new CAD.MetricsType();
                blastanalysis.Metrics._id    = UtilityHelpers.MakeUdmID();
                blastanalysis.Metrics.Metric = metrics.ToArray();
            }

            if (blastanalysis.ReferencePlane != null || blastanalysis.Metrics != null)
            {
                cadanalysis.Blast = new CAD.BlastType[] { blastanalysis };
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Meta-Link feature: If there's no components in an assembly still need to add one empty root component
        /// </summary>
        /// <param name="?"></param>
        public void AddRootComponent(CyPhy.ComponentAssembly assembly)
        {
            CADAssembly a = new CADAssembly();

            a.Id   = a.ConfigID = assembly.Guid.ToString();
            a.Name = a.DisplayName = assembly.Name;
            assemblies.Add(UtilityHelpers.CleanString2(assembly.Name), a);
        }
Ejemplo n.º 7
0
        public CADComponent(CyPhy.Component cyphycomp, string ProjectDirectory, bool size2fit = false,
                            CyPhyCOMInterfaces.IMgaTraceability Traceability = null, CyPhyClasses.CADModel.AttributesClass.FileFormat_enum cadFormat = CyPhyClasses.CADModel.AttributesClass.FileFormat_enum.Creo)
        {
            Type = CADDataType.Component;
            StructuralInterfaceNodes = new Dictionary <string, StructuralInterfaceConstraint>();
            DisplayID            = cyphycomp.Attributes.InstanceGUID;
            Id                   = cyphycomp.ID;
            GraphvizID           = UtilityHelpers.CleanString2(cyphycomp.ID, 50, "-");
            AVMID                = cyphycomp.Attributes.AVMID;
            RevID                = "";
            VersionID            = cyphycomp.Attributes.Version;
            CADFormat            = cadFormat;
            Name                 = cyphycomp.Name;
            CadParameters        = new List <CADParameter>();
            ModelType            = "Part";
            Size2Fit             = size2fit;
            MaterialName         = "";
            CyPhyModelPath       = cyphycomp.GetDirectoryPath(ProjectDirectory: ProjectDirectory);
            Classification       = cyphycomp.Attributes.Classifications;
            HyperLink            = cyphycomp.ToHyperLink();
            CadElementsList      = new List <CAD.ElementType>();
            pointCoordinatesList = new List <TestBenchModel.TBComputation>();
            this.Traceability    = Traceability;

            CreateStructuralInterfaceEquivalent(cyphycomp);

            AddManufacturingParameters(cyphycomp);

            var specialinstr = cyphycomp.Children.ParameterCollection.Where(p => p.Name.ToUpper() == SpecialInstrParamStr);

            if (specialinstr.Any())
            {
                SpecialInstructions = specialinstr.First().Attributes.Value.Replace("\"", "");
            }

            // META-3555 hack
            if (cyphycomp.Children.CADModelCollection.Any())
            {
                foreach (var datum in cyphycomp.Children.CADModelCollection.First().Children.CADDatumCollection)
                {
                    if (datum.Name == "FRONT" || datum.Name == "TOP" || datum.Name == "RIGHT")
                    {
                        SpecialDatums.Add(new Datum(datum, "", false));
                    }
                }
            }

            foreach (var prop in cyphycomp.Children.PropertyCollection)
            {
                if (prop.Name.StartsWith("METADATA."))
                {
                    MetaData.Add(prop.Name.Substring(9), prop.Attributes.Value);
                }
            }

            TraverseComposites(cyphycomp);
            CreatePointCoordinatesList(cyphycomp);
        }
Ejemplo n.º 8
0
        protected override void AddAnalysisToXMLOutput(CAD.AssemblyType cadassembly)
        {
            base.AddAnalysisToXMLOutput(cadassembly);
            CAD.AnalysesType cadanalysis = GetCADAnalysis(cadassembly);

            CAD.BallisticType ballisticanalysis = new CAD.BallisticType();
            ballisticanalysis._id        = UtilityHelpers.MakeUdmID();
            ballisticanalysis.AnalysisID = AnalysisID;

            if (referencePlaneType != Survivability.ReferencePlaneTypeEnum.None)
            {
                CAD.ReferencePlaneType refplane = new CAD.ReferencePlaneType();
                refplane._id  = UtilityHelpers.MakeUdmID();
                refplane.Type = referencePlaneType.ToString();
                ballisticanalysis.ReferencePlane = refplane;
            }

            if (customShotlineList.Any())
            {
                CAD.ShotlinesType cadshotlinesuite = new CAD.ShotlinesType();
                cadshotlinesuite._id = UtilityHelpers.MakeUdmID();
                List <CAD.ShotlineType> shotlineList = new List <CAD.ShotlineType>();
                foreach (var shotline in customShotlineList)
                {
                    CAD.ShotlineType cadshotline = new CAD.ShotlineType();
                    cadshotline._id                = UtilityHelpers.MakeUdmID();
                    cadshotline.Azimuth            = shotline.Azimuth;
                    cadshotline.Elevation          = shotline.Elevation;
                    cadshotline.BallisticThreatRef = shotline.BallisticThreatRef;
                    cadshotline.ComponentID        = shotline.ComponentID;
                    cadshotline.DatumPoint         = shotline.DatumPoint;
                    cadshotline.ShotlineName       = shotline.ShotlineName;
                    shotlineList.Add(cadshotline);
                }

                cadshotlinesuite.Shotline   = shotlineList.ToArray();
                ballisticanalysis.Shotlines = cadshotlinesuite;
            }


            List <CAD.MetricType> metrics = MetricsToCADXMLOutput(Computations, cadassembly.ConfigurationID);

            if (metrics.Count > 0)
            {
                ballisticanalysis.Metrics        = new CAD.MetricsType();
                ballisticanalysis.Metrics._id    = UtilityHelpers.MakeUdmID();
                ballisticanalysis.Metrics.Metric = metrics.ToArray();
            }

            if (ballisticanalysis.Metrics != null || ballisticanalysis.ReferencePlane != null || ballisticanalysis.Shotlines != null)
            {
                cadanalysis.Ballistic = new CAD.BallisticType[] { ballisticanalysis };
            }
        }
Ejemplo n.º 9
0
        public virtual CAD.LoadType ToCADXMLOutput()
        {
            CAD.LoadType loadout = new CAD.LoadType();
            loadout._id = UtilityHelpers.MakeUdmID();
            if (Geometry != null)
            {
                loadout.Geometry = Geometry.ToCADXMLOutput();
            }

            return(loadout);
        }
Ejemplo n.º 10
0
        public virtual CAD.AnalysisConstraintType ToCADXMLOutput()
        {
            CAD.AnalysisConstraintType constraintout = new CAD.AnalysisConstraintType();
            constraintout._id = UtilityHelpers.MakeUdmID();
            if (Geometry != null)
            {
                constraintout.Geometry = Geometry.ToCADXMLOutput();
            }

            return(constraintout);
        }
Ejemplo n.º 11
0
 public override CAD.AnalysisConstraintType ToCADXMLOutput()
 {
     CAD.AnalysisConstraintType constraintout = base.ToCADXMLOutput();
     constraintout.Pin     = new CAD.PinType();
     constraintout.Pin._id = UtilityHelpers.MakeUdmID();
     constraintout.Pin.AxialDisplacement          = new CAD.AxialDisplacementType();
     constraintout.Pin.AxialDisplacement._id      = UtilityHelpers.MakeUdmID();
     constraintout.Pin.AxialDisplacement.Property = AxialDisplacement;
     constraintout.Pin.AxialRotation          = new CAD.AxialRotationType();
     constraintout.Pin.AxialRotation._id      = UtilityHelpers.MakeUdmID();
     constraintout.Pin.AxialRotation.Property = AxialRotation;
     return(constraintout);
 }
Ejemplo n.º 12
0
 public KinematicJointPair(KinematicJoint a, KinematicJoint b)
 {
     XmlID = UtilityHelpers.MakeUdmID();
     if (a.TopLevelID != null)
     {
         XmlID = a.TopLevelID;
     }
     else if (b.TopLevelID != null)
     {
         XmlID = b.TopLevelID;
     }
     A = a;
     B = b;
 }
Ejemplo n.º 13
0
 public CAD.GeometryMarkerType ToCADXml()
 {
     CAD.GeometryMarkerType marker = new CAD.GeometryMarkerType();
     marker._id         = UtilityHelpers.MakeUdmID();
     marker.ComponentID = ComponentID;
     marker.x           = x;
     marker.y           = y;
     marker.z           = z;
     marker.i           = i;
     marker.j           = j;
     marker.k           = k;
     marker.pi          = pi;
     return(marker);
 }
Ejemplo n.º 14
0
        public CAD.AssembliesType ToCADXMLOutput(TestBenchModel.TestBenchBase tb, bool metalink = false)
        {
            CAD.AssembliesType outputAssembliesType = new CAD.AssembliesType();
            outputAssembliesType.VersionInfo = "";

            List <CAD.AssemblyType> asmlist = new List <CAD.AssemblyType>();

            foreach (var item in assemblies.Values)
            {
                CAD.AssemblyType assembly = item.ToCADXMLOutput(tb);
                asmlist.Add(assembly);
                pointCoordinatesList.AddRange(item.PointCoordinatesList);
            }

            if (asmlist.Count > 1 && metalink)
            {
                Logger.Instance.AddLogMessage("There's more than one unconnected assembly in the model. Meta-Link may not work with this model.", Severity.Warning);
            }

            if (orphans.Any())
            {
                if (metalink)
                {
                    CAD.AssemblyType            topAssembly      = asmlist.First();
                    List <CAD.CADComponentType> cadcomponentlist = topAssembly.CADComponent.CADComponent.ToList();
                    foreach (var orphan in orphans)
                    {
                        cadcomponentlist.Add(orphan.ToCADXMLOutput(tb.GetRepresentation(orphan)));
                    }
                    topAssembly.CADComponent.CADComponent = cadcomponentlist.ToArray();
                }
                else
                {
                    List <CAD.CADComponentType>   orphanlist            = new List <CAD.CADComponentType>();
                    CAD.UnassembledComponentsType orphancomponentParent = new CAD.UnassembledComponentsType();
                    orphancomponentParent._id = UtilityHelpers.MakeUdmID();

                    foreach (var orphan in orphans)
                    {
                        orphanlist.Add(orphan.ToCADXMLOutput(tb.GetRepresentation(orphan)));
                    }
                    orphancomponentParent.CADComponent         = orphanlist.ToArray();
                    outputAssembliesType.UnassembledComponents = orphancomponentParent;
                }
            }

            outputAssembliesType.Assembly = asmlist.ToArray();

            return(outputAssembliesType);
        }
Ejemplo n.º 15
0
 protected CAD.AnalysesType GetCADAnalysis(CAD.AssemblyType assembly)
 {
     CAD.AnalysesType analysis;
     if (assembly.Analyses == null)
     {
         analysis = new CAD.AnalysesType()
         {
             _id = UtilityHelpers.MakeUdmID()
         };
         assembly.Analyses = analysis;
     }
     else
     {
         analysis = assembly.Analyses;
     }
     return(analysis);
 }
Ejemplo n.º 16
0
        private CAD.PairType MakeRootConstraint(string location,
                                                string componentDispID,
                                                string assemblyID,
                                                bool rootIsAsmType,
                                                Datum datum)
        {
            CAD.PairType pair = new CAD.PairType();
            pair._id = UtilityHelpers.MakeUdmID();
            pair.FeatureGeometryType  = "SURFACE";
            pair.FeatureAlignmentType = "ALIGN";
            pair.FeatureInterfaceType = "CAD_DATUM";

            List <CAD.ConstraintFeatureType> featurelist = new List <CAD.ConstraintFeatureType>();

            CAD.ConstraintFeatureType constraintFeature = new CAD.ConstraintFeatureType();
            constraintFeature._id                    = UtilityHelpers.MakeUdmID();
            constraintFeature.ComponentID            = componentDispID;
            constraintFeature.FeatureOrientationType = "SIDE_A";
            if (rootIsAsmType)
            {
                constraintFeature.FeatureName = "ASM_" + location;
            }
            else
            {
                constraintFeature.FeatureName = location;
            }

            // META-3555 hack
            if (datum != null && datum.Marker != null)
            {
                constraintFeature.GeometryMarker = datum.Marker.ToCADXml();
            }

            featurelist.Add(constraintFeature);

            CAD.ConstraintFeatureType asmConstraint = new CAD.ConstraintFeatureType();
            asmConstraint._id                    = UtilityHelpers.MakeUdmID();
            asmConstraint.ComponentID            = assemblyID;
            asmConstraint.FeatureOrientationType = "SIDE_A";
            asmConstraint.FeatureName            = "ASM_" + location;
            featurelist.Add(asmConstraint);
            pair.ConstraintFeature = featurelist.ToArray();

            return(pair);
        }
Ejemplo n.º 17
0
        private void CopyCFDPreprocessing()
        {
            META.AnalysisTool tool = META.AnalysisTool.GetByName("cfd_preprocessing");
            if (tool != null)
            {
                string cfdPreprocessDir = Path.Combine(tool.InstallLocation, tool.OutputDirectory);
                if (Directory.Exists(cfdPreprocessDir))
                {
                    UtilityHelpers.CopyFiles(cfdPreprocessDir,
                                             Path.Combine(OutputDirectory, "PreProcessing"));
                }
                else
                {
                    Logger.Instance.AddLogMessage(cfdPreprocessDir + " does not exist. META analysis tool did not install correctly.", Severity.Warning);
                }
            }
            else
            {
                Logger.Instance.AddLogMessage("Could not retrieve information about CFD Preprocessing tool from registry!", Severity.Warning);
            }

            using (StreamWriter writer = new StreamWriter(Path.Combine(this.OutputDirectory, "TestBench_PreProcess.cmd")))
            {
                Template.postprocess_cmd appendscript = new Template.postprocess_cmd()
                {
                    ScriptName = "main_pre_process.py"
                };

                writer.WriteLine(appendscript.TransformText());
            }

            List <string> ScriptPaths = new List <string>();

            ScriptPaths.Add("PreProcessing\\CFDPreprocess.py");
            using (StreamWriter writer = new StreamWriter(Path.Combine(this.OutputDirectory, "main_pre_process.py")))
            {
                Template.postprocess_py postpy = new Template.postprocess_py()
                {
                    ScriptNames = ScriptPaths,      //ScriptNames = scripts,
                    LogName     = "pre_process.log"
                };
                writer.WriteLine(postpy.TransformText());
            }
        }
Ejemplo n.º 18
0
 public override CAD.AnalysisConstraintType ToCADXMLOutput()
 {
     CAD.AnalysisConstraintType constraintout = base.ToCADXMLOutput();
     constraintout.Displacement                   = new CAD.DisplacementType();
     constraintout.Displacement._id               = UtilityHelpers.MakeUdmID();
     constraintout.Displacement.Rotation          = new CAD.RotationType();
     constraintout.Displacement.Rotation._id      = UtilityHelpers.MakeUdmID();
     constraintout.Displacement.Rotation.Units    = RotationUnits;
     constraintout.Displacement.Rotation.x        = Rotation_X;
     constraintout.Displacement.Rotation.y        = Rotation_Y;
     constraintout.Displacement.Rotation.z        = Rotation_Z;
     constraintout.Displacement.Translation       = new CAD.TranslationType();
     constraintout.Displacement.Translation._id   = UtilityHelpers.MakeUdmID();
     constraintout.Displacement.Translation.Units = TranslationUnits;
     constraintout.Displacement.Translation.x     = Translation_X;
     constraintout.Displacement.Translation.y     = Translation_Y;
     constraintout.Displacement.Translation.z     = Translation_Z;
     return(constraintout);
 }
Ejemplo n.º 19
0
 public override CAD.LoadType ToCADXMLOutput()
 {
     CAD.LoadType loadout = base.ToCADXMLOutput();
     loadout.ForceMoment              = new CAD.ForceMomentType();
     loadout.ForceMoment._id          = UtilityHelpers.MakeUdmID();
     loadout.ForceMoment.Force        = new CAD.ForceType();
     loadout.ForceMoment.Force._id    = Force_id;
     loadout.ForceMoment.Force.Units  = ForceUnit;
     loadout.ForceMoment.Force.x      = Force_X;
     loadout.ForceMoment.Force.y      = Force_Y;
     loadout.ForceMoment.Force.z      = Force_Z;
     loadout.ForceMoment.Moment       = new CAD.MomentType();
     loadout.ForceMoment.Moment._id   = Moment_id;
     loadout.ForceMoment.Moment.Units = MomentUnit;
     loadout.ForceMoment.Moment.x     = Moment_X;
     loadout.ForceMoment.Moment.y     = Moment_Y;
     loadout.ForceMoment.Moment.z     = Moment_Z;
     return(loadout);
 }
Ejemplo n.º 20
0
        protected void AddStaticAnalysisMetrics(CAD.AssemblyType assemblyRoot)
        {
            if (ExportComponentPoints && cadDataContainer.PointCoordinatesList.Any())
            {
                StaticAnalysisMetrics.AddRange(cadDataContainer.PointCoordinatesList.Where(x => !StaticAnalysisMetrics.Exists(r => r.MetricID == x.MetricID)));
            }

            if (StaticAnalysisMetrics.Any())
            {
                CAD.AnalysesType cadanalysis    = GetCADAnalysis(assemblyRoot);
                CAD.StaticType   staticanalysis = GetStaticAnalysis(cadanalysis);         //CAD.StaticType staticanalysis = new CAD.StaticType();

                List <CAD.MetricType> metriclist = MetricsToCADXMLOutput(StaticAnalysisMetrics);
                staticanalysis.Metrics        = new CAD.MetricsType();
                staticanalysis.Metrics._id    = UtilityHelpers.MakeUdmID();
                staticanalysis.Metrics.Metric = metriclist.ToArray();

                cadanalysis.Static = new CAD.StaticType[] { staticanalysis };
            }
        }
Ejemplo n.º 21
0
        /*
         * public List<CAD.MetricType> MetricsToCADXMLOutput(string componentID)
         * {
         *  List<CAD.MetricType> metriclist = new List<CAD.MetricType>();
         *  foreach (var item in Computations)
         *  {
         *      CAD.MetricType metric = new CAD.MetricType();
         *      metric._id = UtilityHelpers.MakeUdmID();
         *      metric.ComponentID = componentID;
         *      metric.MetricID = item.MetricID;
         *      metric.RequestedValueType = "Scalar";
         *      metric.MetricType1 = item.ComputationType.ToString();
         *      metric.Details = "";
         *      metric.MetricName = item.MetricName ?? "";
         *      metriclist.Add(metric);
         *  }
         *
         *  return metriclist;
         * }
         */

        public List <CAD.MetricType> MetricsToCADXMLOutput(List <TBComputation> dataSet, string componentID = "")
        {
            List <CAD.MetricType> metriclist = new List <CAD.MetricType>();

            foreach (var item in dataSet)
            {
                CAD.MetricType ptout = new CAD.MetricType();
                ptout._id                = UtilityHelpers.MakeUdmID();
                ptout.ComponentID        = item.ComponentID;
                ptout.MetricID           = item.MetricID;
                ptout.MetricType1        = item.ComputationType.ToString();
                ptout.RequestedValueType = item.RequestedValueType;
                ptout.ComponentID        = String.IsNullOrEmpty(componentID) ? item.ComponentID : componentID; // PointCoordinate metric is tied to a specific Component
                ptout.Details            = item.Details ?? "";
                ptout.MetricName         = item.MetricName ?? "";
                metriclist.Add(ptout);
            }

            return(metriclist);
        }
Ejemplo n.º 22
0
        protected override void AddAnalysisToXMLOutput(CAD.AssemblyType cadassembly)
        {
            base.AddAnalysisToXMLOutput(cadassembly);
            CAD.AnalysesType cadanalysis = GetCADAnalysis(cadassembly);

            CAD.CFDType cfdanalysis = new CAD.CFDType();
            cfdanalysis._id        = UtilityHelpers.MakeUdmID();
            cfdanalysis.AnalysisID = AnalysisID;

            List <CAD.MetricType> metrics = MetricsToCADXMLOutput(Computations, cadassembly.ConfigurationID);

            if (metrics.Count > 0)
            {
                cfdanalysis.Metrics        = new CAD.MetricsType();
                cfdanalysis.Metrics._id    = UtilityHelpers.MakeUdmID();
                cfdanalysis.Metrics.Metric = metrics.ToArray();
            }

            // Hydrostatics solver setting will go to the CadAssembly.xml as it is interpreted by CadCreateAssembly.exe
            foreach (var config in cfdConfigs.Where(cfg => cfg is CFDConfig.HydrostaticsSolverSettings))
            {
                CFDConfig.HydrostaticsSolverSettings hconfig = config as CFDConfig.HydrostaticsSolverSettings;
                cfdanalysis.HydrostaticsSolverSettings    = new CAD.HydrostaticsSolverSettingsType[1];
                cfdanalysis.HydrostaticsSolverSettings[0] = new CAD.HydrostaticsSolverSettingsType()
                {
                    VehicleVelocity    = 1,
                    FluidMaterial      = hconfig.FluidMaterial.ToString(),
                    FluidTemperature   = hconfig.FluidTemperature,
                    PitchAngleStart    = hconfig.PitchAngleStart,
                    PitchAngleEnd      = hconfig.PitchAngleEnd,
                    PitchAngleStepSize = hconfig.PitchAngleStep,
                    RollAngleStart     = hconfig.RollAngleStart,
                    RollAngleEnd       = hconfig.RollAngleEnd,
                    RollAngleStepSize  = hconfig.RollAngleStep
                };
            }

            cadanalysis.CFD = new CAD.CFDType[] { cfdanalysis };

            AddStaticAnalysisMetrics(cadassembly);
        }
Ejemplo n.º 23
0
        public override void GenerateRunBat()
        {
            Template.run_bat_cfd searchmeta = new Template.run_bat_cfd()
            {
                Automation = IsAutomated,
            };
            using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "runCADJob.bat")))
            {
                writer.WriteLine(searchmeta.TransformText());
            }

            string metaPath = META.VersionInfo.MetaPath;

            if (!Directory.Exists(metaPath))
            {
                Logger.Instance.AddLogMessage("META_PATH is not found in registry!", Severity.Error);
            }

            string ergonomicsPath = Path.Combine(metaPath, @"analysis_tools\PYTHON_RICARDO\output_ergonomics\scripts");

            UtilityHelpers.CopyFiles(ergonomicsPath, Path.Combine(OutputDirectory, "scripts"));
        }
Ejemplo n.º 24
0
        protected CAD.StaticType GetStaticAnalysis(CAD.AnalysesType analyses)
        {
            CAD.StaticType staticAnalysis;
            if (analyses.Static == null)
            {
                analyses.Static = new CAD.StaticType[1]
                {
                    new CAD.StaticType()
                    {
                        _id        = UtilityHelpers.MakeUdmID(),
                        AnalysisID = AnalysisID
                    }
                };

                staticAnalysis = analyses.Static[0];
            }
            else
            {
                staticAnalysis = analyses.Static.FirstOrDefault();
            }

            return(staticAnalysis);
        }
Ejemplo n.º 25
0
        private void TraverseComposites(CyPhy.Component component)
        {
            foreach (var material in component.Children.MaterialContentsCollection)
            {
                CAD.ElementType cadElement = new CAD.ElementType()
                {
                    _id          = UtilityHelpers.MakeUdmID(),
                    ElementType1 = "SURFACE"
                };

                MgaModel      materialMga = material.Impl as MgaModel;
                List <MgaFCO> startDirPts = new List <MgaFCO>();
                List <MgaFCO> endDirPts   = new List <MgaFCO>();

                startDirPts = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(materialMga, "Start_Direction");
                endDirPts   = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(materialMga, "End_Direction");

                if (startDirPts.Count != 1 && endDirPts.Count != 1)
                {
                    Logger.Instance.AddLogMessage("Material Content must contain one Start_Direction and one End_Direction point.", Severity.Warning);
                    continue;
                }


                CyPhy.Point startDirPt          = CyPhyClasses.Point.Cast(startDirPts[0]);
                string      startDirPtDatumName = GetFeatureName(startDirPt);

                CyPhy.Point endDirPt          = CyPhyClasses.Point.Cast(endDirPts[0]);
                string      endDirPtDatumName = GetFeatureName(endDirPt);

                CAD.OrientationType cadOrientation = new CAD.OrientationType()
                {
                    _id = UtilityHelpers.MakeUdmID()
                };
                CAD.GeometryType cadGeometry = new CAD.GeometryType()
                {
                    _id = UtilityHelpers.MakeUdmID()
                };


                CAD.FeatureType cadStartFeature = new CAD.FeatureType()
                {
                    _id         = UtilityHelpers.MakeUdmID(),
                    ComponentID = DisplayID,
                    Name        = startDirPtDatumName,
                    MetricID    = DisplayID + ":" + startDirPtDatumName
                };
                TestBenchModel.TBComputation startFeatureComputation = new TestBenchModel.TBComputation()
                {
                    ComponentID        = DisplayID,
                    ComputationType    = TestBenchModel.TBComputation.Type.POINTCOORDINATES,
                    Details            = startDirPtDatumName,
                    FeatureDatumName   = startDirPtDatumName,
                    MetricID           = DisplayID + ":" + startDirPtDatumName,
                    RequestedValueType = "Vector"
                };
                pointCoordinatesList.Add(startFeatureComputation);
                if (String.IsNullOrEmpty(startDirPtDatumName))
                {
                    Logger.Instance.AddLogMessage("Empty point datum name [" + startDirPt.Path + "]", Severity.Warning);
                }

                CAD.FeatureType cadEndFeature = new CAD.FeatureType()
                {
                    _id         = UtilityHelpers.MakeUdmID(),
                    ComponentID = DisplayID,
                    Name        = endDirPtDatumName,
                    MetricID    = DisplayID + ":" + endDirPtDatumName
                };
                TestBenchModel.TBComputation endFeatureComputation = new TestBenchModel.TBComputation()
                {
                    ComponentID        = DisplayID,
                    ComputationType    = TestBenchModel.TBComputation.Type.POINTCOORDINATES,
                    Details            = endDirPtDatumName,
                    FeatureDatumName   = endDirPtDatumName,
                    MetricID           = DisplayID + ":" + endDirPtDatumName,
                    RequestedValueType = "Vector"
                };
                pointCoordinatesList.Add(endFeatureComputation);
                if (String.IsNullOrEmpty(endDirPtDatumName))
                {
                    Logger.Instance.AddLogMessage("Empty point datum name [" + endDirPt.Path + "]", Severity.Warning);
                }

                CAD.FeaturesType cadFeatures = new CAD.FeaturesType()
                {
                    _id                        = UtilityHelpers.MakeUdmID(),
                    FeatureID                  = material.ID,
                    GeometryType               = "Vector",
                    FeatureInterfaceType       = "CAD_DATUM",
                    FeatureGeometryType        = "POINT",
                    PrimaryGeometryQualifier   = "",
                    SecondaryGeometryQualifier = ""
                };

                cadFeatures.Feature     = new CAD.FeatureType[2];
                cadFeatures.Feature[0]  = cadStartFeature;
                cadFeatures.Feature[1]  = cadEndFeature;
                cadGeometry.Features    = new CAD.FeaturesType[1];
                cadGeometry.Features[0] = cadFeatures;
                cadOrientation.Geometry = cadGeometry;


                // Material Layups
                CAD.MaterialLayupType cadLayers = new CAD.MaterialLayupType()
                {
                    _id       = UtilityHelpers.MakeUdmID(),
                    Position  = material.Attributes.Position.ToString().ToUpper(),
                    Offset    = (material.Attributes.Position.ToString().ToUpper() != "OFFSET_BY_VALUE") ? 0 : (material.Attributes.PositionOffset),
                    Direction = material.Attributes.MaterialLayupDirection.ToString().ToUpper()
                };

                int layerCnt = material.Children.MaterialLayerCollection.Count();
                if (layerCnt > 0)
                {
                    cadLayers.Layer = new CAD.LayerType[layerCnt];

                    int k = 0;
                    foreach (var layer in material.Children.MaterialLayerCollection.OrderBy(i => i.Attributes.LayerID))
                    {
                        CAD.LayerType cadLayer = new CAD.LayerType()
                        {
                            _id           = UtilityHelpers.MakeUdmID(),
                            ID            = layer.Attributes.LayerID,
                            Drop_Order    = layer.Attributes.DropOrder,
                            Material_Name = layer.Attributes.LayerMaterial,
                            Orientation   = layer.Attributes.LayerOrientation,
                            Thickness     = layer.Attributes.LayerThickness
                        };

                        cadLayers.Layer[k] = cadLayer;
                        k++;
                    }
                }

                CAD.ElementContentsType cadElementContents = new CAD.ElementContentsType();
                cadElementContents._id           = UtilityHelpers.MakeUdmID();
                cadElementContents.Orientation   = cadOrientation;
                cadElementContents.MaterialLayup = cadLayers;
                cadElement.ElementContents       = cadElementContents;


                if (material.DstConnections.ContentsToGeometryCollection.Count() < 1 || material.DstConnections.ContentsToGeometryCollection.Count() > 1)
                {
                    Logger.Instance.AddLogMessage("Material Content need to connect to one Face geometry.", Severity.Warning);
                    continue;
                }


                // Face, Polygon, or Extrusion Geometry
                CyPhy.ContentsToGeometry conn = material.DstConnections.ContentsToGeometryCollection.FirstOrDefault();
                if (conn != null)
                {
                    CyPhy.Face      faceGeometry      = conn.DstEnds.Face;
                    CyPhy.Polygon   polgonGeometry    = conn.DstEnds.Polygon;
                    CyPhy.Extrusion extrusionGeometry = conn.DstEnds.Extrusion;


                    int countGeometryTypes = 0;

                    if (faceGeometry != null)
                    {
                        ++countGeometryTypes;
                    }
                    if (polgonGeometry != null)
                    {
                        ++countGeometryTypes;
                    }
                    if (extrusionGeometry != null)
                    {
                        ++countGeometryTypes;
                    }

                    if (countGeometryTypes != 1)
                    {
                        Logger.Instance.AddLogMessage("MaterialContents must be connected to one and only one geometry type (i.e. FACE, POLOGON, or EXTRUSION).", Severity.Warning);
                        continue;
                    }


                    // Approach when only FACE was supported
                    //String primBoundaryQ = faceGeometry.Attributes.BoundaryQualifier.ToString().Replace("_", string.Empty);
                    //MgaModel faceMga = faceGeometry.Impl as MgaModel;
                    //List<MgaFCO> normalDirPts = new List<MgaFCO>();
                    //normalDirPts = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(faceMga, "Direction_Reference_Point");

                    String        primBoundaryQ = "";
                    MgaModel      faceMga;
                    List <MgaFCO> normalDirPts = new List <MgaFCO>();

                    if (faceGeometry != null)
                    {
                        primBoundaryQ = faceGeometry.Attributes.BoundaryQualifier.ToString().Replace("_", string.Empty);
                        faceMga       = faceGeometry.Impl as MgaModel;
                        normalDirPts  = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(faceMga, "Direction_Reference_Point");
                    }
                    else if (polgonGeometry != null)
                    {
                        primBoundaryQ = polgonGeometry.Attributes.BoundaryQualifier.ToString().Replace("_", string.Empty);
                        faceMga       = polgonGeometry.Impl as MgaModel;
                        normalDirPts  = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(faceMga, "Direction_Reference_Point");
                    }
                    else if (extrusionGeometry != null)
                    {
                        primBoundaryQ = extrusionGeometry.Attributes.BoundaryQualifier.ToString().Replace("_", string.Empty);
                        faceMga       = extrusionGeometry.Impl as MgaModel;
                        normalDirPts  = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(faceMga, "Direction_Reference_Point");
                    }

                    if (normalDirPts.Count != 1)
                    {
                        Logger.Instance.AddLogMessage("Geometry (FACE, POLYGON, or EXTRUSION) can contain only one Direction_Reference_Point point.", Severity.Warning);
                        continue;
                    }

                    CyPhy.Point normalDirPt         = CyPhyClasses.Point.Cast(normalDirPts.FirstOrDefault());
                    string      normalPtFeatureName = GetFeatureName(normalDirPt);
                    if (String.IsNullOrEmpty(normalPtFeatureName))
                    {
                        Logger.Instance.AddLogMessage("Direction_Reference_Point point of the Face/Ploygon/Extrusion geometry doesn't have a datum name. Make sure it is connected to a valid point inside a CADModel.", Severity.Warning);
                        continue;
                    }

                    CyPhy2CAD_CSharp.DataRep.CADGeometry faceOrExtruOrPolyGeometryRep = null;
                    if (faceGeometry != null)
                    {
                        faceOrExtruOrPolyGeometryRep = CyPhy2CAD_CSharp.DataRep.CADGeometry.CreateGeometry(faceGeometry);
                        if (faceOrExtruOrPolyGeometryRep == null)
                        {
                            Logger.Instance.AddLogMessage("Unsuccessfully created a representation of a Face Geometry.", Severity.Warning);
                            continue;
                        }
                    }
                    else if (polgonGeometry != null)
                    {
                        faceOrExtruOrPolyGeometryRep = CyPhy2CAD_CSharp.DataRep.CADGeometry.CreateGeometry(polgonGeometry);
                        if (faceOrExtruOrPolyGeometryRep == null)
                        {
                            Logger.Instance.AddLogMessage("Unsuccessfully created a representation of a Polygon Geometry.", Severity.Warning);
                            continue;
                        }
                    }
                    else if (extrusionGeometry != null)
                    {
                        faceOrExtruOrPolyGeometryRep = CyPhy2CAD_CSharp.DataRep.CADGeometry.CreateGeometry(extrusionGeometry);
                        if (faceOrExtruOrPolyGeometryRep == null)
                        {
                            Logger.Instance.AddLogMessage("Unsuccessfully created a representation of a Extrusion Geometry.", Severity.Warning);
                            continue;
                        }
                    }

                    // Element/Geometry
                    CAD.GeometryType cadFaceOrExtruOrPolyGeometryOut = faceOrExtruOrPolyGeometryRep.ToCADXMLOutput();
                    if (cadFaceOrExtruOrPolyGeometryOut == null)
                    {
                        Logger.Instance.AddLogMessage("Unsuccessfully converted a representation of a Face/Ploygon/Extrusion Geometry to CAD xml.", Severity.Warning);
                        continue;
                    }


                    cadElement.Geometry = cadFaceOrExtruOrPolyGeometryOut;
                    foreach (var faceOrExtruOrPolyGeomFeatures in cadFaceOrExtruOrPolyGeometryOut.Features)
                    {
                        foreach (var feature_temp in faceOrExtruOrPolyGeomFeatures.Feature)
                        {
                            TestBenchModel.TBComputation faceGeometryComputation = new TestBenchModel.TBComputation()
                            {
                                ComponentID        = DisplayID,
                                ComputationType    = TestBenchModel.TBComputation.Type.POINTCOORDINATES,
                                Details            = feature_temp.Name,
                                FeatureDatumName   = feature_temp.Name,
                                MetricID           = feature_temp.MetricID,
                                RequestedValueType = "Vector"
                            };
                            pointCoordinatesList.Add(faceGeometryComputation);
                        }
                    }

                    // Element/Geometry

                    string direction_temp = "";

                    if (faceGeometry != null)
                    {
                        direction_temp = (faceGeometry.Attributes.NormalDirection == CyPhyClasses.Face.AttributesClass.NormalDirection_enum.Toward_Reference_Point) ? "TOWARD" : "AWAY";
                    }
                    else if (polgonGeometry != null)
                    {
                        direction_temp = (polgonGeometry.Attributes.NormalDirection == CyPhyClasses.Polygon.AttributesClass.NormalDirection_enum.Toward_Reference_Point) ? "TOWARD" : "AWAY";
                    }
                    else if (extrusionGeometry != null)
                    {
                        direction_temp = (extrusionGeometry.Attributes.NormalDirection == CyPhyClasses.Extrusion.AttributesClass.NormalDirection_enum.Toward_Reference_Point) ? "TOWARD" : "AWAY";
                    }

                    CAD.SurfaceNormalType cadSurfaceNormal = new CAD.SurfaceNormalType()
                    {
                        _id       = UtilityHelpers.MakeUdmID(),
                        Direction = direction_temp
                    };

                    CAD.FeaturesType cadSurfaceNormFeatures = new CAD.FeaturesType()
                    {
                        _id                        = UtilityHelpers.MakeUdmID(),
                        FeatureID                  = normalDirPt.ID,
                        GeometryType               = "POINT",
                        FeatureInterfaceType       = "CAD_DATUM",
                        FeatureGeometryType        = "POINT",
                        Feature                    = new CAD.FeatureType[1],
                        PrimaryGeometryQualifier   = primBoundaryQ,
                        SecondaryGeometryQualifier = ""
                    };

                    cadSurfaceNormFeatures.Feature[0] = new CAD.FeatureType()
                    {
                        _id         = UtilityHelpers.MakeUdmID(),
                        Name        = normalPtFeatureName,
                        ComponentID = DisplayID,
                        MetricID    = DisplayID + ":" + normalPtFeatureName
                    };
                    TestBenchModel.TBComputation surfNormalComputation = new TestBenchModel.TBComputation()
                    {
                        ComponentID        = DisplayID,
                        ComputationType    = TestBenchModel.TBComputation.Type.POINTCOORDINATES,
                        Details            = normalPtFeatureName,
                        FeatureDatumName   = normalPtFeatureName,
                        MetricID           = DisplayID + ":" + normalPtFeatureName,
                        RequestedValueType = "Vector"
                    };
                    pointCoordinatesList.Add(surfNormalComputation);
                    if (String.IsNullOrEmpty(normalPtFeatureName))
                    {
                        Logger.Instance.AddLogMessage("Empty point datum name [" + normalDirPt.Path + "]", Severity.Warning);
                    }

                    CAD.GeometryType cadSurfaceNormGeom = new CAD.GeometryType()
                    {
                        _id      = UtilityHelpers.MakeUdmID(),
                        Features = new CAD.FeaturesType[1],
                    };

                    cadSurfaceNormGeom.Features[0] = cadSurfaceNormFeatures;
                    cadSurfaceNormal.Geometry      = cadSurfaceNormGeom;
                    cadElement.SurfaceNormal       = cadSurfaceNormal;
                }

                this.CadElementsList.Add(cadElement);
            }
        }
Ejemplo n.º 26
0
        /*
         * private void FindMatchingSolidModelingFeatures(CyPhy.CADDatum datum,
         *                                             CyPhy.CADModel acadmodel)
         * {
         *  // META-947: Creates a virtual connector
         *
         *  Dictionary<string, DataRep.Datum> featuremap = new Dictionary<string, DataRep.Datum>();
         *  FindMatchingDatums(datum,
         *                     acadmodel,
         *                     featuremap);
         *
         *  if (featuremap.Count > 0)
         *  {
         *      // virtual connector
         *      DataRep.StructuralInterfaceConstraint sirep = new StructuralInterfaceConstraint(datum, this.Id);
         *      sirep.DatumList = featuremap;
         *      sirep.DegreeFreedom = sirep.GetDegreesOfFreedom();
         *      StructuralInterfaceNodes[datum.ID] = sirep;
         *  }
         * }
         *
         * private void FindMatchingSolidModelingFeatures(CyPhy.Connector a,
         *                                             CyPhy.CADModel acadmodel)
         * {
         *  // META-947: Connector instead of StructuralInterface
         *  // [1] Connectors can be nested so find all cad datums within a connector recursively
         *  // [2] Find connected datums
         *  //     Skip Connector without any Datum Ports
         *
         *  List<CyPhy.CADDatum> CadDatum_List = new List<CyPhy.CADDatum>();
         *  FindCadDatumsInConnector(a, CadDatum_List);
         *
         *  Dictionary<string, DataRep.Datum> featuremap = new Dictionary<string, DataRep.Datum>();
         *
         *  if (CadDatum_List.Count() > 0)
         *  {
         *      foreach (CyPhy.CADDatum item in CadDatum_List)
         *      {
         *          FindMatchingDatums(item,
         *                             acadmodel,
         *                             featuremap);
         *      }
         *
         *  }
         *
         *  if (featuremap.Count > 0)
         *  {
         *      DataRep.StructuralInterfaceConstraint sirep = new StructuralInterfaceConstraint(a, this.Id);
         *      sirep.DatumList = featuremap;
         *      sirep.DegreeFreedom = sirep.GetDegreesOfFreedom();
         *      StructuralInterfaceNodes[a.ID] = sirep;
         *  }
         * }
         *
         *
         * private void FindMatchingDatums(CyPhy.CADDatum datum,
         *                              CyPhy.CADModel cadmodel,
         *                              Dictionary<string, DataRep.Datum> featuremap)
         * {
         *  string cadmodel_id = cadmodel.ID;
         *  string alignment = "ALIGN";
         *  string orientation = "NONE";
         *
         *
         *  if (datum.Kind == "Surface")
         *  {
         *      alignment = (datum as CyPhy.Surface).Attributes.Alignment.ToString();
         *  }
         *
         *  CadDatumTraversal traversal = new CadDatumTraversal(datum,
         *                                                      cadmodel_id);
         *
         *  if (traversal.datumFound.Count > 0)
         *  {
         *      if (traversal.datumFound.Count > 1)
         *      {
         *          Logger.Instance.AddLogMessage("Connector datum connected to multiple datums in the same CADModel [" + datum.Path + "]", Severity.Error);
         *          return;
         *      }
         *
         *      CyPhy2CAD_CSharp.DataRep.Datum datumRep = new DataRep.Datum(traversal.datumFound.First().Attributes.DatumName,
         *                                                                    datum.Kind,
         *                                                                    this.DisplayID);
         *      if (datum.Kind == "Surface")
         *      {
         *          if (traversal.ReverseMap)
         *              orientation = "SIDE_B";
         *          else
         *              orientation = "SIDE_A";
         *      }
         *
         *      if (datum.Kind == "CoordinateSystem")
         *      {
         *          alignment = "CSYS";
         *      }
         *
         *      datumRep.Alignment = alignment;
         *      datumRep.Orientation = orientation;
         *
         *      if (!featuremap.ContainsKey(datum.Name))
         *      {
         *          featuremap[datum.Name] = datumRep;
         *      }
         *  }
         * }
         *
         * // Connectors can be nested!
         * private void FindCadDatumsInConnector(CyPhy.Connector connector,
         *                         List<CyPhy.CADDatum> caddatum_list)
         * {
         *  caddatum_list.AddRange(connector.Children.CADDatumCollection);
         *
         *  //foreach (CyPhy.Connector conn in connector.Children.ConnectorCollection)
         *  //{
         *  //    FindCadDatumsInConnector(conn, caddatum_list);
         *  //}
         *
         * }
         */

        public CAD.CADComponentType ToCADXMLOutput(string representation)
        {
            CAD.CADComponentType cadoutput = new CAD.CADComponentType();
            cadoutput._id                = UtilityHelpers.MakeUdmID();
            cadoutput.Type               = ModelType.ToUpper();
            cadoutput.Standalone         = false;
            cadoutput.SpecialInstruction = Size2Fit ? "SIZE_TO_FIT" : "";
            if (!String.IsNullOrEmpty(SpecialInstructions))
            {
                cadoutput.SpecialInstruction += (cadoutput.SpecialInstruction.Length != 0 ? "," : "") + SpecialInstructions;
            }
            cadoutput.Name           = String.IsNullOrEmpty(ModelName) ? "" : ModelName;
            cadoutput.DisplayName    = Name;
            cadoutput.MaterialID     = MaterialName;
            cadoutput.ComponentID    = DisplayID;
            cadoutput.Classification = Classification;


            if (CadParameters.Any())
            {
                CAD.ParametricParametersType parameterRoot = new CAD.ParametricParametersType();
                parameterRoot._id = UtilityHelpers.MakeUdmID();

                List <CAD.CADParameterType> paramarray = new List <CAD.CADParameterType>();
                foreach (var item in CadParameters)
                {
                    CAD.CADParameterType parameter = new CAD.CADParameterType();
                    parameter._id         = UtilityHelpers.MakeUdmID();
                    parameter.Type        = item.Type;
                    parameter.Name        = item.Name;
                    parameter.Value       = item.Value;
                    parameter.Units       = new CAD.UnitsType();
                    parameter.Units._id   = UtilityHelpers.MakeUdmID();
                    parameter.Units.Value = item.Unit;
                    paramarray.Add(parameter);
                }
                parameterRoot.CADParameter     = paramarray.ToArray();
                cadoutput.ParametricParameters = parameterRoot;
            }

            if (ManufacturingParameters != null && ManufacturingParameters.Count != 0)
            {
                cadoutput.ManufacturingParameter = new CAD.ManufacturingParameterType[ManufacturingParameters.Count];

                int i = 0;
                foreach (var param in ManufacturingParameters)
                {
                    cadoutput.ManufacturingParameter[i++] = new CAD.ManufacturingParameterType()
                    {
                        Name  = param.Key,
                        Value = param.Value
                    };
                }
            }

            if (MetaData != null && MetaData.Count != 0)
            {
                cadoutput.MetaData = new CAD.MetaDataType[MetaData.Count];

                int i = 0;
                foreach (var param in MetaData)
                {
                    cadoutput.MetaData[i++] = new CAD.MetaDataType()
                    {
                        Key   = param.Key,
                        Value = param.Value
                    };
                }
            }

            cadoutput.Representation = representation;
            if (this.CadElementsList.Count > 0)
            {
                cadoutput.Elements = new CAD.ElementsType()
                {
                    _id = UtilityHelpers.MakeUdmID()
                };

                cadoutput.Elements.Element = this.CadElementsList.ToArray();
            }

            return(cadoutput);
        }
Ejemplo n.º 27
0
        public object ToMultibodyOutput()
        {
            if (KinematicJointPair != null)
            {
                if (KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.PRISMATIC || KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.CYLINDRICAL || KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.REVOLUTE)   // Joint_One_Axis_Given
                {
                    Multibody.ModelAssemblyJointsJoint_One_Axis_Given joint = new Multibody.ModelAssemblyJointsJoint_One_Axis_Given();
                    joint.ComponentA                   = new Multibody.ModelAssemblyJointsJoint_One_Axis_GivenComponentA();
                    joint.ComponentA.ComponentID       = Src.DisplayID;
                    joint.ComponentA.Location_MetricID = SrcPortID;
                    joint.ComponentB                   = new Multibody.ModelAssemblyJointsJoint_One_Axis_GivenComponentB();
                    joint.ComponentB.ComponentID       = Dst.DisplayID;
                    joint.ComponentB.Location_MetricID = DstPortID;
                    joint.ID = KinematicJointPair.XmlID;

                    if (KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.PRISMATIC)
                    {
                        joint.Type = Multibody.ModelAssemblyJointsJoint_One_Axis_GivenType.Translational;
                    }
                    else if (KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.REVOLUTE)
                    {
                        joint.Type = Multibody.ModelAssemblyJointsJoint_One_Axis_GivenType.Revolute;
                    }
                    else
                    {
                        joint.Type = Multibody.ModelAssemblyJointsJoint_One_Axis_GivenType.Cylindrical;
                    }

                    joint.Geometry          = new Multibody.ModelAssemblyJointsJoint_One_Axis_GivenGeometry();
                    joint.Geometry.MetricID = UtilityHelpers.MakeUdmID();
                    joint.Geometry.Type     = "Vector";

                    return(joint);
                }
                else    // Joint_Locations_Only
                {
                    Multibody.ModelAssemblyJointsJoint_Locations_Only joint = new Multibody.ModelAssemblyJointsJoint_Locations_Only();
                    joint.ComponentA                   = new Multibody.ModelAssemblyJointsJoint_Locations_OnlyComponentA();
                    joint.ComponentA.ComponentID       = Src.DisplayID;
                    joint.ComponentA.Location_MetricID = SrcPortID;
                    joint.ComponentB                   = new Multibody.ModelAssemblyJointsJoint_Locations_OnlyComponentB();
                    joint.ComponentB.ComponentID       = Dst.DisplayID;
                    joint.ComponentB.Location_MetricID = DstPortID;
                    joint.ID = KinematicJointPair.XmlID;

                    if (KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.SPHERICAL)
                    {
                        joint.Type = Multibody.ModelAssemblyJointsJoint_Locations_OnlyType.Spherical;
                    }
                    else
                    {
                        joint.Type = Multibody.ModelAssemblyJointsJoint_Locations_OnlyType.Fixed;
                    }


                    return(joint);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
        public CAD.AssemblyType ToCADXMLOutput(TestBenchModel.TestBenchBase tb)
        {
            CAD.AssemblyType cadassemblyoutput = new CAD.AssemblyType();
            cadassemblyoutput._id             = UtilityHelpers.MakeUdmID();
            cadassemblyoutput.ConfigurationID = ConfigID;

            CAD.CADComponentType cadassemblycomponentoutput = new CAD.CADComponentType();
            cadassemblycomponentoutput._id                = UtilityHelpers.MakeUdmID();
            cadassemblycomponentoutput.ComponentID        = ConfigID;
            cadassemblycomponentoutput.Type               = "ASSEMBLY";
            cadassemblycomponentoutput.Standalone         = false;
            cadassemblycomponentoutput.SpecialInstruction = "";
            cadassemblycomponentoutput.Name               = this.Name;
            cadassemblycomponentoutput.DisplayName        = DisplayName;
            cadassemblycomponentoutput.MaterialID         = "";
            cadassemblycomponentoutput.Representation     = "";
            cadassemblycomponentoutput.Classification     = "";


            Dictionary <string, List <CAD.ConstraintType> > compidToConstraint = new Dictionary <string, List <CAD.ConstraintType> >();       // Dictionary<Id, List<Constraints>>
            var sortedEdges = ChildEdges.OrderBy(x => x.DstPortName).ToList();

            foreach (CADEdge edge in sortedEdges)        //foreach (CADEdge edge in ChildEdges)
            {
                CAD.ConstraintType constraintout = edge.ToCADXMLOutput(tb);
                if (!compidToConstraint.ContainsKey(edge.Dst.Id))
                {
                    compidToConstraint.Add(edge.Dst.Id, new List <CAD.ConstraintType>());
                }
                compidToConstraint[edge.Dst.Id].Add(constraintout);
            }

            var sortedS2FEdges = ChildSize2FitEdges.OrderBy(x => x.DstPortName).ToList();

            foreach (CADEdge edge in sortedS2FEdges)        //foreach (CADEdge edge in ChildSize2FitEdges)
            {
                CAD.ConstraintType constraintout = edge.ToCADXMLOutput(tb);
                if (!compidToConstraint.ContainsKey(edge.Dst.Id))
                {
                    compidToConstraint.Add(edge.Dst.Id, new List <CAD.ConstraintType>());
                }
                compidToConstraint[edge.Dst.Id].Add(constraintout);
            }

            // META-2885
            //Dictionary<string, CAD.CADComponentType> tmpComponents = new Dictionary<string, CAD.CADComponentType>();
            List <CAD.CADComponentType> tmpComponents = new List <CAD.CADComponentType>();
            var sortedComponents = ChildComponents.OrderBy(x => x.Value.Name).ToDictionary(x => x.Key, x => x.Value).Values.ToList();

            foreach (CADComponent component in sortedComponents)      //foreach (CADComponent component in ChildComponents.Values)
            {
                CAD.CADComponentType componentout = component.ToCADXMLOutput(tb.GetRepresentation(component));

                // root constraint
                if (component.Id == RootComponentID)
                {
                    bool rootIsAsmType                    = component.ModelType == "Assembly"; //bool rootIsAsmType = component.ModelType == "PART";
                    List <CAD.PairType> pairlist          = new List <CAD.PairType>();
                    CAD.ConstraintType  rootconstraintout = new CAD.ConstraintType();
                    rootconstraintout._id = UtilityHelpers.MakeUdmID();

                    // front pair
                    pairlist.Add(MakeRootConstraint("FRONT",
                                                    component.DisplayID,
                                                    ConfigID,
                                                    rootIsAsmType,
                                                    component.SpecialDatums.Where(d => d.DatumName == "FRONT").FirstOrDefault()));

                    // top pair
                    pairlist.Add(MakeRootConstraint("TOP",
                                                    component.DisplayID,
                                                    ConfigID,
                                                    rootIsAsmType,
                                                    component.SpecialDatums.Where(d => d.DatumName == "TOP").FirstOrDefault()));

                    // right pair
                    pairlist.Add(MakeRootConstraint("RIGHT",
                                                    component.DisplayID,
                                                    ConfigID,
                                                    rootIsAsmType,
                                                    component.SpecialDatums.Where(d => d.DatumName == "RIGHT").FirstOrDefault()));

                    rootconstraintout.Pair = pairlist.ToArray();

                    componentout.Constraint    = new CAD.ConstraintType[1];
                    componentout.Constraint[0] = rootconstraintout;
                }
                else
                {
                    if (compidToConstraint.ContainsKey(component.Id))
                    {
                        componentout.Constraint = compidToConstraint[component.Id].ToArray();
                    }
                }

                //tmpComponents[component.Id] = componentout;
                tmpComponents.Add(componentout);

                // 3/7/2016 - Export_All_Component_Points at TB level
                pointCoordinatesList.AddRange(component.PointCoordinatesList);
            }

            var size2fitCompSorted = ChildSize2FitComponents.OrderBy(x => x.Value.Name).ToDictionary(x => x.Key, x => x.Value).Values.ToList();

            foreach (CADComponent component in size2fitCompSorted)//foreach (CADComponent component in ChildSize2FitComponents.Values)      // META-2885
            {
                CAD.CADComponentType componentout = component.ToCADXMLOutput(tb.GetRepresentation(component));
                if (compidToConstraint.ContainsKey(component.Id))
                {
                    componentout.Constraint = compidToConstraint[component.Id].ToArray();
                }

                //tmpComponents[component.Id] = componentout;
                tmpComponents.Add(componentout);

                // 3/7/2016 - Export_All_Component_Points at TB level
                pointCoordinatesList.AddRange(component.PointCoordinatesList);
            }

            // Fill MetaLinkData. Only needed in case if data is prepared for Meta-Link communication
            if (MetaLinkData != null && MetaLinkData.Components.Count > 0)
            {
                cadassemblyoutput.MetaLinkData = new CAD.MetaLinkDataType();
                cadassemblyoutput.MetaLinkData.CadComponentMLData = new CAD.CadComponentMLDataType[MetaLinkData.Components.Count];
                int i = 0;
                foreach (MetaLinkData.Component comp in MetaLinkData.Components)
                {
                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i]       = new CAD.CadComponentMLDataType();
                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ID    = comp.ID;
                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].AvmID = comp.AvmID;
                    if (comp.Connectors.Count > 0)
                    {
                        cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData = new CAD.ConnectorMLDataType[comp.Connectors.Count];
                        int j = 0;
                        foreach (MetaLinkData.Connector conn in comp.Connectors)
                        {
                            cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j]             = new CAD.ConnectorMLDataType();
                            cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].ID          = conn.ID;
                            cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DisplayName = conn.DisplayName;
                            if (conn.Datums.Count > 0)
                            {
                                cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData = new CAD.DatumMLDataType[conn.Datums.Count];
                                int k = 0;
                                foreach (MetaLinkData.Datum d in conn.Datums)
                                {
                                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k]             = new CAD.DatumMLDataType();
                                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k].ID          = d.ID;
                                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k].DisplayName = d.DisplayName;
                                    k++;
                                }
                            }
                            j++;
                        }
                    }
                    i++;
                }
            }

            cadassemblycomponentoutput.CADComponent = tmpComponents.ToArray();       //cadassemblycomponentoutput.CADComponent = tmpComponents.Values.ToArray();
            cadassemblyoutput.CADComponent          = cadassemblycomponentoutput;

            CAD.PropertiesType asmproperties = new CAD.PropertiesType();
            asmproperties._id = UtilityHelpers.MakeUdmID();
            CAD.UnitsType asmunit = new CAD.UnitsType();
            asmunit._id                  = UtilityHelpers.MakeUdmID();
            asmunit.Value                = "value1";
            asmproperties.Units          = asmunit;
            cadassemblyoutput.Properties = asmproperties;
            return(cadassemblyoutput);
        }
Ejemplo n.º 30
0
        public void AddDataExchangeFormatToXMLOutput(CAD.AssembliesType assembliesRoot)
        {
            if (STEP_DataExchangeFormats.Count > 0 || NonSTEP_DataExchangeFormats.Count > 0 || SpecialDataFormatInstructions.Count > 0)
            {
                CAD.DataExchangeType dataexchangeout = new CAD.DataExchangeType();
                dataexchangeout._id = UtilityHelpers.MakeUdmID();

                List <CAD.STEPFormatType> exchangelist = new List <CAD.STEPFormatType>();
                foreach (var item in STEP_DataExchangeFormats)
                {
                    CAD.STEPFormatType formatout = new CAD.STEPFormatType();
                    formatout._id  = UtilityHelpers.MakeUdmID();
                    formatout.Name = item;
                    exchangelist.Add(formatout);
                }

                List <CAD.NonSTEPFormatType> stllist = new List <CAD.NonSTEPFormatType>();
                foreach (var item in NonSTEP_DataExchangeFormats)
                {
                    CAD.NonSTEPFormatType formatout = new CAD.NonSTEPFormatType();
                    formatout._id = UtilityHelpers.MakeUdmID();

                    switch (item.ToLower())
                    {
                    case "inventor":
                    case "parasolid":
                        formatout.FormatType    = item;
                        formatout.FormatSubType = "";
                        break;

                    case "stereolithography_ascii":
                        formatout.FormatType    = "Stereolithography";
                        formatout.FormatSubType = "ASCII";
                        break;

                    case "stereolithography_binary":
                        formatout.FormatType    = "Stereolithography";
                        formatout.FormatSubType = "BINARY";
                        break;

                    case "dxf_2013":
                        formatout.FormatType    = "DXF";
                        formatout.FormatSubType = "2013";
                        break;

                    default:
                        Logger.Instance.AddLogMessage("AddDataExchangeFormatToXMLOutput received an unknown NonSTEP_DataExchangeFormat, recieved value: " + item
                                                      + "  This would be due to a programming error/bug.", Severity.Error);
                        break;
                    }
                    stllist.Add(formatout);
                }

                List <CAD.SpecialDataFormatInstructionType> specialInst = new List <CAD.SpecialDataFormatInstructionType>();
                foreach (var item in SpecialDataFormatInstructions)
                {
                    CAD.SpecialDataFormatInstructionType formatout = new CAD.SpecialDataFormatInstructionType();
                    formatout._id         = UtilityHelpers.MakeUdmID();
                    formatout.Instruction = item;
                    specialInst.Add(formatout);
                }

                if (exchangelist.Count > 0)
                {
                    dataexchangeout.STEPFormat = exchangelist.ToArray();
                }
                if (stllist.Count > 0)
                {
                    dataexchangeout.NonSTEPFormat = stllist.ToArray();
                }
                if (specialInst.Count > 0)
                {
                    dataexchangeout.SpecialDataFormatInstruction = specialInst.ToArray();
                }
                assembliesRoot.DataExchange = dataexchangeout;
            }
        }