Beispiel #1
0
        /// <summary>
        /// Build a set of specific elements by their IDs
        /// </summary>
        /// <param name="ids">Set of element IDs</param>
        /// <returns>Set of elements</returns>
        public ElementSet BuildElements(IntSet ids)
        {
            var elements = new ElementSet();

            if (!IsValid())
            {
                return(elements);
            }

            List <ElementCreator> creators = new List <ElementCreator>();
            ElementParams         parameters;

            foreach (int id in ids)
            {
                parameters.ID          = id;
                parameters.TypeName    = db.getElementTypeName(id);
                parameters.Nodes       = db.getElementNodes(id);
                parameters.Dim         = db.getElementDim(id);
                parameters.CornerNodes = db.getElementCornerNodes(id);
                parameters.PropertyID  = db.getElementPropertyId(id);

                var creator = ElementCreator.GetElementCreatorByParams(parameters);
                creators.Add(creator);
            }

            foreach (var creator in creators)
            {
                var element = creator.BuildElement();
                elements.Add(element);
            }

            return(elements);
        }
Beispiel #2
0
        /// <summary>
        /// Returns the specific creator of the element using the data contained in the passed parameters
        /// </summary>
        /// <param name="parameters">Element parameters</param>
        /// <returns>A specific instance of the element creator</returns>
        public static ElementCreator GetElementCreatorByParams(ElementParams parameters)
        {
            ElementCreator creator = null;
            var            type    = parameters.TypeName;

            // TODO: Hide the implementation of selecting a specific creator, so that the registration of a specific type occurs somewhere in a separate place
            if (type == "CQUAD4")
            {
                creator = new CQUAD4Creator(parameters);
            }
            else if (type == "CTRIA3")
            {
                creator = new CTRIA3Creator(parameters);
            }
            else
            {
                throw new ArgumentOutOfRangeException("Unknown type of element");
            }

            // TODO: Insert new type of elements

            return(creator);
        }