Exemple #1
0
        public List <double[]> getPointCoordinatesFromLusas()
        {
            List <double[]> pointsCoordinates = new List <double[]>();
            IFSelection     userInp           = lusas.getSelection();
            object          points            = userInp.getObjects("points");

            object[] pointsArray = (object[])points;

            //check if selection is at least one point
            if (pointsArray.Length < 1)
            {
                MessageBox.Show("please select at least one point", "", MessageBoxButtons.OK);
                return(null);
            }

            for (int i = 0; i < pointsArray.Length; i++)
            {
                IFPoint  point    = (IFPoint)pointsArray[i];
                double[] position = new double[3];
                //point.getXYZ(ref position);
                position[0] = point.getX();
                position[1] = point.getY();
                position[2] = point.getZ();
                pointsCoordinates.Add(position);
            }

            return(pointsCoordinates);
        }
Exemple #2
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static Node ToNode(this IFPoint lusasPoint,
                                  HashSet <string> groupNames, Dictionary <string, Constraint6DOF> constraint6DOFs)
        {
            HashSet <string> tags = new HashSet <string>(IsMemberOf(lusasPoint, groupNames));
            List <string>    supportAssignments = GetAttributeAssignments(lusasPoint, "Support");

            Constraint6DOF nodeConstraint = null;

            if (!(supportAssignments.Count() == 0))
            {
                constraint6DOFs.TryGetValue(supportAssignments[0], out nodeConstraint);
            }

            Node node = new Node
            {
                Position = new Point {
                    X = lusasPoint.getX(), Y = lusasPoint.getY(), Z = lusasPoint.getZ()
                },
                Name    = "",
                Support = nodeConstraint
            };

            node.Tags = tags;

            string adapterID = lusasPoint.getID().ToString();

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

            return(node);
        }
Exemple #3
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFPoint CreatePoint(Node node)
        {
            if (!CheckPropertyError(node, x => x.Position, true))
            {
                return(null);
            }

            Point position = node.Position;
            IFDatabaseOperations databasePoint = d_LusasData.createPoint(
                position.X, position.Y, position.Z);
            IFPoint lusasPoint = d_LusasData.getPointByNumber(d_LusasData.getLargestPointID());


            int adapterIdName = lusasPoint.getID();

            node.SetAdapterId(typeof(LusasId), adapterIdName);


            if (!(node.Tags.Count == 0))
            {
                AssignObjectSet(lusasPoint, node.Tags);
            }

            if (!(node.Support == null))
            {
                IFAttribute lusasSupport = d_LusasData.getAttribute("Support", System.Convert.ToInt32(node.Support.AdapterId <int>(typeof(LusasId))));
                lusasSupport.assignTo(lusasPoint);
            }

            return(lusasPoint);
        }
Exemple #4
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private int DeletePoints(IEnumerable <object> ids)
        {
            int success = 1;

            if (ids != null)
            {
                List <int> indicies = ids.Cast <int>().ToList();

                foreach (int index in indicies)
                {
                    IFPoint lusasPoint = d_LusasData.getPointByNumber(index);
                    if (lusasPoint.getHOFs().Count() > 0)
                    {
                        //Engine.Base.Compute.RecordWarning(index + @" has higher order features(HOFs)
                        //and cannot be deleted");
                    }
                    else
                    {
                        d_LusasData.Delete(lusasPoint);
                    }
                }
            }
            else
            {
                d_LusasData.deletePoints();
            }

            return(success);
        }
Exemple #5
0
        /***************************************************/

        public static Point ToPoint(this IFPoint lusasPoint)
        {
            Point point = new Point {
                X = lusasPoint.getX(), Y = lusasPoint.getY(), Z = lusasPoint.getZ()
            };

            return(point);
        }
Exemple #6
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static Node GetNode(IFLine lusasLine, int nodeIndex, Dictionary <string, Node> nodes)
        {
            Node    node;
            IFPoint lusasPoint = lusasLine.getLOFs()[nodeIndex];

            nodes.TryGetValue(lusasPoint.getID().ToString(), out node);

            return(node);
        }
Exemple #7
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static Point ToPoint(this IFPoint lusasPoint, HashSet <string> groupNames)
        {
            HashSet <string> tags = new HashSet <string>(IsMemberOf(lusasPoint, groupNames));

            Point point = new Point {
                X = lusasPoint.getX(), Y = lusasPoint.getY(), Z = lusasPoint.getZ()
            };

            return(point);
        }
Exemple #8
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <IFPoint> ReadLusasPoints(List <string> ids = null)
        {
            object[]       lusasPoints    = d_LusasData.getObjects("Point");
            List <IFPoint> lusasPointList = new List <IFPoint>();

            for (int i = 0; i < lusasPoints.Count(); i++)
            {
                IFPoint lusasPoint = (IFPoint)lusasPoints[i];
                lusasPointList.Add(lusasPoint);
            }
            return(lusasPointList);
        }
Exemple #9
0
        /***************************************************/

        protected bool Update(IEnumerable <Node> nodes)
        {
            foreach (Node node in nodes)
            {
                IFPoint lusasPoint = d_LusasData.getPointByNumber(node.AdapterId <int>(typeof(LusasId)));

                if (lusasPoint == null)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #10
0
        public List <List <double[]> > getSurfaceCoordinatesFromLusas()
        {
            IFSelection userInp = lusas.getSelection();

            //check if selection is at least one point
            if (userInp.countSurfaces() < 1)
            {
                MessageBox.Show("please select at least one point", "", MessageBoxButtons.OK);
                return(null);
            }

            //create collection to popoulate surfaces
            List <List <double[]> > surfaces = new List <List <double[]> >();

            for (int i = 0; i < userInp.countSurfaces(); i++)
            {
                //gereate array of ids
                List <int> pointIds = new List <int>();

                //generate collection for populating vertices
                List <double[]> vertexes = new List <double[]>();

                IFSurface surface = userInp.getSurface(i);
                object[]  lines   = surface.getLOFs() as object[];
                for (int l = 0; l < lines.Length; l++)
                {
                    IFLine   line   = lines[l] as IFLine;
                    object[] points = line.getLOFs() as object[];
                    for (int k = 0; k < points.Length; k++)
                    {
                        IFPoint point = points[k] as IFPoint;
                        int     id    = point.getID();

                        if (!pointIds.Contains(id))
                        {
                            pointIds.Add(id);
                            double[] position = new double[3];
                            position[0] = point.getX();
                            position[1] = point.getY();
                            position[2] = point.getZ();
                            //point.getXYZ(position[0],position[1],position[2]);
                            vertexes.Add(position);
                        }
                    }
                }
                surfaces.Add(vertexes);
            }
            return(surfaces);
        }
Exemple #11
0
        /***************************************************/

        private IFPoint CreatePoint(Point point)
        {
            if (point != null)
            {
                Node newNode = new Node {
                    Position = new Point {
                        X = point.X, Y = point.Y, Z = point.Z
                    }
                };

                IFPoint newPoint = CreatePoint(newNode);

                return(newPoint);
            }
            return(null);
        }
Exemple #12
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <Node> nodes)
        {
            if (nodes != null)
            {
                CreateTags(nodes);

                ReduceRuntime(true);

                foreach (Node node in nodes)
                {
                    IFPoint lusasPoint = CreatePoint(node);
                }

                ReduceRuntime(false);
            }
            return(true);
        }
Exemple #13
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <Point> ReadPoints(List <string> ids = null)
        {
            object[]     lusasPoints = d_LusasData.getObjects("Point");
            List <Point> points      = new List <Point>();

            if (!(lusasPoints.Count() == 0))
            {
                HashSet <string> groupNames = ReadTags();

                for (int i = 0; i < lusasPoints.Count(); i++)
                {
                    IFPoint lusasPoint = (IFPoint)lusasPoints[i];
                    Point   point      = Adapters.Lusas.Convert.ToPoint(lusasPoint, groupNames);
                    points.Add(point);
                }
            }

            return(points);
        }
Exemple #14
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFLine CreateEdge(Edge edge, IFPoint startPoint, IFPoint endPoint)
        {
            IFLine lusasLine = d_LusasData.createLineByPoints(startPoint, endPoint);

            int adapterIdName = lusasLine.getID();

            edge.SetAdapterId(typeof(LusasId), adapterIdName);

            if (!(edge.Tags.Count == 0))
            {
                AssignObjectSet(lusasLine, edge.Tags);
            }

            if (!(edge.Support == null))
            {
                IFAttribute lusasSupport = d_LusasData.getAttribute("Support", edge.Support.AdapterId <int>(typeof(LusasId)));
                lusasSupport.assignTo(lusasLine);
            }

            return(lusasLine);
        }
Exemple #15
0
        /***************************************************/

        private bool CreateCollection(IEnumerable <Point> points)
        {
            if (points != null)
            {
                List <Point> distinctPoints = Engine.Adapters.Lusas.Query.GetDistinctPoints(points);

                List <Point> existingPoints = ReadPoints();

                List <Point> lusasPoints = distinctPoints.Except(existingPoints).ToList();

                ReduceRuntime(true);

                foreach (Point point in lusasPoints)
                {
                    IFPoint lusasPoint = CreatePoint(point);
                }

                ReduceRuntime(false);
            }
            return(true);
        }
Exemple #16
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static IEnumerable <Node> GetPointAssignments(IEnumerable <IFAssignment> lusasAssignments,
                                                              Dictionary <string, Node> nodes)
        {
            List <Node> assignedNodes = new List <Node>();
            Node        node;

            foreach (IFAssignment lusasAssignment in lusasAssignments)
            {
                if (lusasAssignment.getDatabaseObject() is IFPoint)
                {
                    IFPoint lusasPoint = (IFPoint)lusasAssignment.getDatabaseObject();
                    nodes.TryGetValue(lusasPoint.getID().ToString(), out node);
                    assignedNodes.Add(node);
                }
                else
                {
                    AssignmentWarning(lusasAssignment);
                }
            }

            return(assignedNodes);
        }
Exemple #17
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <Node> ReadNodes(List <string> ids = null)
        {
            object[]    lusasPoints = d_LusasData.getObjects("Point");
            List <Node> nodes       = new List <Node>();

            if (!(lusasPoints.Count() == 0))
            {
                HashSet <string> groupNames = ReadTags();

                IEnumerable <Constraint6DOF>        constraints6DOFList = Read6DOFConstraints();
                Dictionary <string, Constraint6DOF> constraints6DOF     = constraints6DOFList.ToDictionary(
                    x => x.Name.ToString());

                for (int i = 0; i < lusasPoints.Count(); i++)
                {
                    IFPoint lusasPoint = (IFPoint)lusasPoints[i];
                    Node    node       = Adapters.Lusas.Convert.ToNode(lusasPoint, groupNames, constraints6DOF);
                    nodes.Add(node);
                }
            }

            return(nodes);
        }
Exemple #18
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFLine CreateLine(Bar bar)
        {
            if (!CheckPropertyError(bar, b => b.StartNode, true) || !CheckPropertyError(bar, b => b.EndNode, true) ||
                !CheckPropertyError(bar, b => b.StartNode.Position, true) || !CheckPropertyError(bar, b => b.EndNode.Position, true))
            {
                return(null);
            }

            if (
                bar.FEAType == BarFEAType.CompressionOnly ||
                bar.FEAType == BarFEAType.TensionOnly)
            {
                Engine.Base.Compute.RecordError("Lusas does not support " + bar.FEAType.ToString() + " Bars");
                return(null);
            }

            string startNodeId = GetAdapterId <string>(bar.StartNode);
            string endNodeId   = GetAdapterId <string>(bar.EndNode);

            if (string.IsNullOrEmpty(startNodeId) || string.IsNullOrEmpty(endNodeId))
            {
                Engine.Base.Compute.RecordError("Could not find the ids for at least one end node for at least one Bar. Bar not created.");
                return(null);
            }

            IFPoint startPoint = d_LusasData.getPointByNumber(bar.StartNode.AdapterId <int>(typeof(LusasId)));
            IFPoint endPoint   = d_LusasData.getPointByNumber(bar.EndNode.AdapterId <int>(typeof(LusasId)));
            IFLine  lusasLine  = d_LusasData.createLineByPoints(startPoint, endPoint);

            int adapterIdName = lusasLine.getID();

            bar.SetAdapterId(typeof(LusasId), adapterIdName);

            if (bar.Tags.Count != 0)
            {
                AssignObjectSet(lusasLine, bar.Tags);
            }

            if (CheckPropertyWarning(bar, b => b.SectionProperty) && !Engine.Adapters.Lusas.Query.InvalidSectionProperty(bar.SectionProperty))
            {
                if (!Engine.Adapters.Lusas.Query.InvalidSectionProfile(bar.SectionProperty))
                {
                    //Needed in case the SectionProfile is null and was not created
                    if (d_LusasData.existsAttribute("Line Geometric", bar.SectionProperty.AdapterId <int>(typeof(LusasId))))
                    {
                        IFAttribute lusasGeometricLine = d_LusasData.getAttribute("Line Geometric", bar.SectionProperty.AdapterId <int>(typeof(LusasId)));
                        lusasGeometricLine.assignTo(lusasLine);
                    }

                    if (CheckPropertyWarning(bar, b => b.SectionProperty.Material))
                    {
                        if (bar.SectionProperty.Material is IOrthotropic)
                        {
                            Engine.Base.Compute.RecordWarning($"Orthotropic Material {bar.SectionProperty.Material.DescriptionOrName()} cannot be assigned to Bar {bar.AdapterId<int>(typeof(LusasId))}, " +
                                                              $"orthotropic materials can only be applied to 2D and 3D elements in Lusas.");
                        }
                        else if (bar.SectionProperty.Material is IIsotropic)
                        {
                            if (d_LusasData.existsAttribute("Material", bar.SectionProperty.Material.AdapterId <int>(typeof(LusasId))))
                            {
                                IFAttribute lusasMaterial = d_LusasData.getAttribute("Material", bar.SectionProperty.Material.AdapterId <int>(typeof(LusasId)));
                                lusasMaterial.assignTo(lusasLine);
                            }
                        }
                    }
                }
            }

            if (bar.Support != null)
            {
                IFAttribute lusasSupport = d_LusasData.getAttribute("Support", System.Convert.ToInt32(bar.Support.AdapterId <int>(typeof(LusasId))));
                lusasSupport.assignTo(lusasLine);
                IFLocalCoord barLocalAxis = CreateLocalCoordinate(lusasLine);
                barLocalAxis.assignTo(lusasLine);
            }

            if (bar.Fragments.Contains(typeof(MeshSettings1D)))
            {
                IFAssignment meshAssignment = m_LusasApplication.newAssignment();
                meshAssignment.setAllDefaults();
                if (bar.OrientationAngle != 0 && bar.FEAType == BarFEAType.Axial)
                {
                    Engine.Base.Compute.RecordWarning(
                        "Orientation angle not supported in Lusas for " + bar.FEAType +
                        " element types, this information will be lost when pushed to Lusas");
                }

                meshAssignment.setBetaAngle(bar.OrientationAngle);

                MeshSettings1D meshSettings1D = bar.FindFragment <MeshSettings1D>();
                IFMeshAttr     mesh           = d_LusasData.getMesh(
                    meshSettings1D.Name + "\\" + bar.FEAType.ToString() + "|" + CreateReleaseString(bar.Release));
                mesh.assignTo(lusasLine, meshAssignment);
            }

            if (bar.Offset != null)
            {
                Engine.Base.Compute.RecordWarning("Offsets are currently unsupported.");
            }

            return(lusasLine);
        }
Exemple #19
0
        /***************************************************/

        private bool CreateCollection(IEnumerable <Edge> edges)
        {
            if (edges != null)
            {
                List <Point> allPoints = new List <Point>();

                //Check List<Curve> is not null and Curve is not invalid (i.e. not a Line)
                List <Edge> validEdges = edges.Where(x => CheckPropertyError(x, y => y.Curve))
                                         .Where(x => !Engine.Adapters.Lusas.Query.InvalidEdge(x)).ToList();

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

                //Check Curve is not a null
                foreach (Edge edge in validEdges)
                {
                    if (!(edge.Curve == null))
                    {
                        distinctEdges.Add(edge);
                    }
                }

                distinctEdges = Engine.Adapters.Lusas.Query.GetDistinctEdges(distinctEdges);

                foreach (Edge edge in distinctEdges)
                {
                    allPoints.Add(edge.Curve.IStartPoint());
                    allPoints.Add(edge.Curve.IEndPoint());
                }

                List <Point> distinctPoints = Engine.Adapters.Lusas.Query.GetDistinctPoints(allPoints);

                List <Point> existingPoints = ReadPoints();
                List <Point> pointsToPush   = distinctPoints.Except(
                    existingPoints, new PointDistanceComparer()).ToList();

                ReduceRuntime(true);

                foreach (Point point in pointsToPush)
                {
                    IFPoint lusasPoint = CreatePoint(point);
                }

                ReduceRuntime(false);

                List <IFPoint> lusasPoints = ReadLusasPoints();
                List <Point>   points      = new List <Point>();

                foreach (IFPoint point in lusasPoints)
                {
                    points.Add(Adapters.Lusas.Convert.ToPoint(point));
                }

                CreateTags(distinctEdges);

                ReduceRuntime(true);

                foreach (Edge edge in distinctEdges)
                {
                    IFPoint startPoint = lusasPoints[points.FindIndex(
                                                         m => m.Equals(edge.Curve.IStartPoint().ClosestPoint(points)))];
                    IFPoint endPoint = lusasPoints[points.FindIndex(
                                                       m => m.Equals(edge.Curve.IEndPoint().ClosestPoint(points)))];
                    IFLine lusasLine = CreateEdge(edge, startPoint, endPoint);
                }

                ReduceRuntime(false);
            }
            return(true);
        }