Пример #1
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static Panel ToPanel(this IFSurface lusasSurface,
                                    Dictionary <string, Edge> edges,
                                    HashSet <string> groupNames,
                                    Dictionary <string, ISurfaceProperty> surfaceProperties,
                                    Dictionary <string, IMaterialFragment> materials,
                                    Dictionary <string, Constraint4DOF> supports,
                                    Dictionary <string, MeshSettings2D> meshes)

        {
            object[]      lusasSurfaceLines = lusasSurface.getLOFs();
            List <ICurve> dummyCurve        = new List <ICurve>();

            int n = lusasSurfaceLines.Length;
            HashSet <string> tags = new HashSet <string>(IsMemberOf(lusasSurface, groupNames));

            List <Edge> surfaceEdges = new List <Edge>();

            for (int i = 0; i < n; i++)
            {
                Edge edge = GetEdge(lusasSurface, i, edges);
                surfaceEdges.Add(edge);
            }

            Panel panel = Engine.Structure.Create.Panel(surfaceEdges, dummyCurve);

            panel.Tags = tags;

            int adapterID = lusasSurface.getID();

            panel.SetAdapterId(typeof(LusasId), adapterID);

            List <string> geometricAssignments = GetAttributeAssignments(lusasSurface, "Geometric");
            List <string> materialAssignments  = GetAttributeAssignments(lusasSurface, "Material");

            IMaterialFragment panelMaterial;
            ISurfaceProperty  surfaceProperty;

            if (!(geometricAssignments.Count() == 0))
            {
                surfaceProperties.TryGetValue(geometricAssignments[0], out surfaceProperty);
                if (!(materialAssignments.Count() == 0))
                {
                    materials.TryGetValue(materialAssignments[0], out panelMaterial);
                    surfaceProperty.Material = panelMaterial;
                }

                panel.Property = surfaceProperty;
            }

            MeshSettings2D surfaceMesh;
            List <string>  meshSettings = GetAttributeAssignments(lusasSurface, "Mesh");

            if (!(meshSettings.Count() == 0))
            {
                meshes.TryGetValue(meshSettings[0], out surfaceMesh);
                panel.Fragments.Add(surfaceMesh);
            }

            return(panel);
        }
Пример #2
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFSurface CreateSurface(Panel panel)
        {
            List <IFLine> edges = new List <IFLine>();

            foreach (Edge edge in panel.ExternalEdges)
            {
                string edgeId = GetAdapterId <string>(edge);

                if (string.IsNullOrEmpty(edgeId))
                {
                    Engine.Base.Compute.RecordError("Could not find the ids for at least one Edge, Panel not created.");
                    return(null);
                }
                else
                {
                    edges.Add(d_LusasData.getLineByNumber(edgeId));
                }
            }

            IFSurface lusasSurface = d_LusasData.createSurfaceBy(edges.ToArray());

            if (lusasSurface != null)
            {
                int adapterIdName = lusasSurface.getID();
                panel.SetAdapterId(typeof(LusasId), adapterIdName);

                if (!(panel.Tags.Count == 0))
                {
                    AssignObjectSet(lusasSurface, panel.Tags);
                }

                if (CheckPropertyWarning(panel, p => p.Property) && !Engine.Adapters.Lusas.Query.InvalidSurfaceProperty(panel.Property))
                {
                    IFAttribute lusasGeometricSurface = d_LusasData.getAttribute("Surface Geometric", panel.Property.AdapterId <int>(typeof(LusasId)));

                    lusasGeometricSurface.assignTo(lusasSurface);
                    if (CheckPropertyWarning(panel, p => p.Property.Material))
                    {
                        IFAttribute lusasMaterial = d_LusasData.getAttribute("Material", panel.Property.Material.AdapterId <int>(typeof(LusasId)));
                        lusasMaterial.assignTo(lusasSurface);
                    }
                }

                if (panel.Fragments.Contains(typeof(MeshSettings2D)))
                {
                    IFAssignment meshAssignment = m_LusasApplication.newAssignment();
                    meshAssignment.setAllDefaults();

                    MeshSettings2D meshSettings2D = panel.FindFragment <MeshSettings2D>();
                    IFMeshAttr     mesh           = d_LusasData.getMesh(meshSettings2D.Name);
                    mesh.assignTo(lusasSurface, meshAssignment);
                }
            }

            return(lusasSurface);
        }
Пример #3
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static IEnumerable <IAreaElement> GetSurfaceAssignments(IEnumerable <IFAssignment> lusasAssignments,
                                                                        Dictionary <string, Panel> panels)
        {
            List <IAreaElement> assignedSurfs = new List <IAreaElement>();
            Panel panel;

            foreach (IFAssignment lusasAssignment in lusasAssignments)
            {
                if (lusasAssignment.getDatabaseObject() is IFSurface)
                {
                    IFSurface lusasSurface = (IFSurface)lusasAssignment.getDatabaseObject();
                    panels.TryGetValue(lusasSurface.getID().ToString(), out panel);
                    assignedSurfs.Add(panel);
                }
                else
                {
                    AssignmentWarning(lusasAssignment);
                }
            }

            return(assignedSurfs);
        }