public void TestComponents()
        {
            SODesignAlternative alternative = new SODesignAlternative("default");

            // Components should not be null
            Assert.NotNull(alternative.Components);

            // Components should be empty on the start
            Assert.IsEmpty(alternative.Components);

            // Add a component
            SOComponent component = new SOComponent("default");
            alternative.AddComponent(component);

            // Components should no longer be empty
            Assert.IsNotEmpty(alternative.Components);
            Assert.AreEqual(1, alternative.Components.Length);

            // Component should match
            Assert.AreEqual(component, alternative.Components[0]);

            // Clear the components
            alternative.ClearComponents();

            // Components should be empty on the start
            Assert.IsEmpty(alternative.Components);
        }
 /// <summary>
 /// Adds a subcomponent to this component
 /// </summary>
 /// <param name="component">Subcomponent to add</param>
 public void AddSubComponent(SOComponent component)
 {
     if (this.m_Components == null)
     {
         this.ReInitSubComponents();
     }
     this.m_Components.Add(component);
 }
        /// <summary>
        /// Overriding the RunDesigner method.
        /// This method will be run by the framework to make the design.
        /// </summary>
        public override void RunDesigner()
        {
            // It is important that you run the base designer
            base.RunDesigner();

            // Adding a structure and two beams with the designer
            SOComponent structure = new SOComponent("structure");

            this.CurrentDesignAlternative.AddComponent(structure);
            structure.AddPart(new Beam_HE200A());
            structure.AddPart(new Beam_HE200A());
        }
        /// <summary>
        /// Overriding the RunDesigner method.
        /// This method will be run by the framework to make the design.
        /// </summary>
        public override void RunDesigner()
        {
            // It is important that you run the base designer
            base.RunDesigner();

            SOComponent component = new SOComponent("structure");
            this.CurrentDesignAlternative.AddComponent(component);

            for (int i = 0; i < this.m_NumberOfBeams; i++)
            {
                component.AddPart(new Beam_HE300A());
            }
        }
        public void TestClear()
        {
            SOComponent component = new SOComponent("0001");

            // Components should not be null
            Assert.NotNull(component.Parts);

            // Components should be empty on the start
            Assert.IsEmpty(component.SubComponents);
            Assert.IsEmpty(component.Parts);

            // Add a subcomponent to the component
            SOComponent subcomponent = new SOComponent("0001");
            component.AddSubComponent(subcomponent);

            // Components should no longer be empty
            Assert.IsNotEmpty(component.SubComponents);
            Assert.AreEqual(1, component.SubComponents.Length);
            Assert.IsInstanceOf(typeof(SOComponent), component.SubComponents[0]);
            Assert.AreEqual(subcomponent, component.SubComponents[0]);

            // Add a part to the component
            SOPart part = new SOPart("0001", new SOMaterial("steel"), 1, "kg");
            component.AddPart(part);

            // Parts should no longer be empty
            Assert.IsNotEmpty(component.Parts);
            Assert.AreEqual(1, component.Parts.Length);
            Assert.IsInstanceOf(typeof(SOPart), component.Parts[0]);
            Assert.AreEqual(part, component.Parts[0]);

            // Clear the component
            component.Clear();

            // Components should be empty
            Assert.IsEmpty(component.SubComponents);

            // Parts should be empty
            Assert.IsEmpty(component.Parts);
        }
        public void TestFlattenedComponents()
        {
            SODesignAlternative alternative = new SODesignAlternative("default");

            // Components should not be null
            Assert.NotNull(alternative.Components);

            // Components should be empty on the start
            Assert.IsEmpty(alternative.Components);

            // Add a component
            SOComponent component1 = new SOComponent("0001");
            SOComponent component2 = new SOComponent("0002");
            SOComponent component3 = new SOComponent("0003");
            SOComponent component4 = new SOComponent("0004");
            SOComponent component5 = new SOComponent("0005");
            alternative.AddComponent(component1);
            component1.AddSubComponent(component2);
            component2.AddSubComponent(component3);
            component1.AddSubComponent(component4);
            alternative.AddComponent(component5);

            // FlattenedComponents should contain a list of 5 components now
            Assert.IsNotEmpty(alternative.FlattenedComponents);
            Assert.AreEqual(5, alternative.FlattenedComponents.Length);
        }
        public void TestSubComponents()
        {
            SOComponent component = new SOComponent("0001");

            // Components should not be null
            Assert.NotNull(component.SubComponents);

            // Components should be empty on the start
            Assert.IsEmpty(component.SubComponents);

            // Add a subcomponent to the component
            SOComponent subcomponent = new SOComponent("0001");
            component.AddSubComponent(subcomponent);

            // Components should no longer be empty
            Assert.IsNotEmpty(component.SubComponents);
            Assert.AreEqual(1, component.SubComponents.Length);
            Assert.IsInstanceOf(typeof(SOComponent), component.SubComponents[0]);
            Assert.AreEqual(subcomponent, component.SubComponents[0]);

            // Clear the subcomponents
            component.ClearSubComponents();

            // Components should be empty
            Assert.IsEmpty(component.SubComponents);
        }
        public void TestPassOnFlattenedSubComponents()
        {
            // set up
            SOComponent component0 = new SOComponent("0000");
            SOComponent component1 = new SOComponent("0001");
            SOComponent component2 = new SOComponent("0002");
            SOComponent component3 = new SOComponent("0003");
            SOComponent component4 = new SOComponent("0004");
            SOComponent component5 = new SOComponent("0005");
            component0.AddSubComponent(component1);
            component1.AddSubComponent(component2);
            component2.AddSubComponent(component3);
            component1.AddSubComponent(component4);
            component0.AddSubComponent(component5);

            // get the flattened list
            List<SOComponent> flattenedList = null;
            component0.PassOnFlattenedSubComponents(ref flattenedList);

            // flattened list should contain 5 items
            Assert.IsNotEmpty(flattenedList);
            Assert.AreEqual(5, flattenedList.Count);
        }
 /// <summary>
 /// Adds a subcomponent to this component
 /// </summary>
 /// <param name="component">Subcomponent to add</param>
 public void AddSubComponent(SOComponent component)
 {
     if (this.m_Components == null) { this.ReInitSubComponents(); }
     this.m_Components.Add(component);
 }
        /// <summary>
        /// Overriding the RunDesigner method.
        /// This method will be run by the framework to make the design.
        /// </summary>
        public override void RunDesigner()
        {
            // It is important that you run the base designer
            base.RunDesigner();

            // Adding a structure and two beams with the designer
            SOComponent structure = new SOComponent("structure");
            this.CurrentDesignAlternative.AddComponent(structure);

            for (int i = 0; i < this.NumberOfFrames; i++)
            {
                // Set up the points
                SOPoint3d point1 = new SOPoint3d(basePoint.X + ((double)i * Spacing), basePoint.Y, basePoint.Z);
                SOPoint3d point2 = new SOPoint3d(basePoint.X + ((double)i * Spacing), basePoint.Y, basePoint.Z + Height);
                SOPoint3d point3 = new SOPoint3d(basePoint.X + ((double)i * Spacing), basePoint.Y + Span, basePoint.Z);
                SOPoint3d point4 = new SOPoint3d(basePoint.X + ((double)i * Spacing), basePoint.Y + Span, basePoint.Z + Height);

                // Adding a beam layer to the structure
                SOComponent beam = new SOComponent("beams");
                structure.AddSubComponent(beam);

                // Adding a beam to the beam layer
                beam.AddPart(new Beam_HE400A(point2, point4));

                // Adding a set of columns to the structure
                SOComponent columns = new SOComponent("columns");
                structure.AddSubComponent(columns);

                // Adding two columns to the column set
                columns.AddPart(new Beam_HE320A(point1, point2));
                columns.AddPart(new Beam_HE320A(point3, point4));

                this.points1.Add(point1);
                this.points2.Add(point2);
                this.points3.Add(point3);
                this.points4.Add(point4);
            }
        }