Beispiel #1
0
        private Block BuildBlock()
        {
            Block myBlock = new Block("ArrowWithAttributes");

            Line     l = new Line(0, 0, 10, 0);
            Triangle t = new Triangle(new Point3D(0, -1.5), new Point3D(0, 1.5), new Point3D(1.5, 0));

            t.Translate(10, 0, 0);
            l.ColorMethod = t.ColorMethod = colorMethodType.byParent;

            devDept.Eyeshot.Entities.Attribute a1 = new devDept.Eyeshot.Entities.Attribute(5, 0.2, 0, "att1", "Top Text", 0.8);
            a1.Alignment = devDept.Eyeshot.Entities.Text.alignmentType.BottomCenter;

            devDept.Eyeshot.Entities.Attribute a2 = new devDept.Eyeshot.Entities.Attribute(5, -0.4, 0, "att2", "Bottom Text", 0.8);
            a2.Alignment = devDept.Eyeshot.Entities.Text.alignmentType.TopCenter;

            l.ColorMethod              =
                t.ColorMethod          =
                    a1.ColorMethod     =
                        a2.ColorMethod = colorMethodType.byParent;

            myBlock.Entities.Add(l);
            myBlock.Entities.Add(t);
            myBlock.Entities.Add(a1);
            myBlock.Entities.Add(a2);

            return(myBlock);
        }
Beispiel #2
0
        private BlockReference BuildBlockReference(string newName, IList <Entity> entities)
        {
            // Creates a new BlockReference from the given list of entities
            Block bl = new Block(newName);

            bl.Entities.AddRange(entities);

            model1.Blocks.Add(bl);

            BlockReference br = new BlockReference(new Identity(), newName);

            br.ColorMethod = colorMethodType.byParent;
            return(br);
        }
Beispiel #3
0
        private BlockReference CreateBlockReference(string partName, String fileName)
        {
            devDept.Eyeshot.Translators.ReadFile readFile = new devDept.Eyeshot.Translators.ReadFile(fileName);
            readFile.DoWork();

            Entity entity = readFile.Entities[0];

            ((Mesh)entity).NormalAveragingMode = Mesh.normalAveragingType.Averaged;
            entity.ColorMethod = colorMethodType.byParent;

            Block bl = new Block(partName, Point3D.Origin);

            bl.Entities.Add(entity);
            model1.Blocks.Add(bl);

            BlockReference br = new BlockReference(new Identity(), partName);

            br.ColorMethod = colorMethodType.byParent;
            return(br);
        }
Beispiel #4
0
        private void BuildAssembly()
        {
            model1.AntiAliasing = (antiAliasingCheckBox.IsChecked == true) ? true : false;
            model1.Rendered.PlanarReflections = (planarCheckBox.IsChecked == true) ? true : false;
            model1.UseShaders = (shadersCheckBox.IsChecked == true) ? true : false;
            model1.WriteDepthForTransparents = (depthCheckBox.IsChecked == true) ? true : false;
            model1.Flat.ShowEdges            = (edgesCheckBox.IsChecked == true) ? true : false;
            model1.HiddenLines.ShowEdges     = (edgesCheckBox.IsChecked == true) ? true : false;
            model1.Rendered.ShowEdges        = (edgesCheckBox.IsChecked == true) ? true : false;
            model1.Shaded.ShowEdges          = (edgesCheckBox.IsChecked == true) ? true : false;
            model1.Wireframe.ShowEdges       = (edgesCheckBox.IsChecked == true) ? true : false;

            _entityList.Clear();
            model1.Entities.Clear();
            model1.Blocks.Clear();

            if (model1.Materials.Count > 0)
            {
                if (!transparencyCheckBox.IsChecked == true)
                {
                    model1.Materials[_wallMatName].Diffuse = System.Drawing.Color.FromArgb(25, 150, 25);
                }
                else
                {
                    model1.Materials[_wallMatName].Diffuse = System.Drawing.Color.FromArgb(100, 25, 150, 25);
                }
            }

            // Variables for unique Mesh (SingleMesh)
            List <Point3D>       globalVerts = new List <Point3D>();
            List <IndexTriangle> globalTris  = new List <IndexTriangle>();
            int offset = globalVerts.Count;

            // Pillar column block
            devDept.Eyeshot.Block column = new devDept.Eyeshot.Block("squareCol");
            // creates a gray box
            Mesh m1 = Mesh.CreateBox(COLUMN_B, COLUMN_H, COLUMN_L);

            // apply texture if Texture is true
            if (textureCheckBox.IsChecked == true)
            {
                m1.ApplyMaterial("Bricks", textureMappingType.Cubic, 1, 1);
            }
            else
            {
                m1.ColorMethod  = colorMethodType.byEntity;
                m1.Color        = System.Drawing.Color.LightGray;
                m1.MaterialName = _concreteMatName;
            }

            for (int i = 0; i < m1.Vertices.Length; i++)
            {
                globalVerts.Add(m1.Vertices[i]);
            }
            for (int i = 0; i < m1.Triangles.Length; i++)
            {
                globalTris.Add(new ColorTriangle(offset + m1.Triangles[i].V1, offset + m1.Triangles[i].V2,
                                                 offset + m1.Triangles[i].V3, System.Drawing.Color.Gray));
            }

            Plane p = new Plane(new Vector3D(0, 1, 0));

            devDept.Eyeshot.Entities.Attribute at = new devDept.Eyeshot.Entities.Attribute(p,
                                                                                           new Point3D(-(TEXT_HEIGHT + TEXT_PAD), COLUMN_B / 2, COLUMN_L / 2), "Name", "Frame", TEXT_HEIGHT);
            at.Alignment  = devDept.Eyeshot.Entities.Text.alignmentType.BaselineCenter;
            at.UpsideDown = true;
            column.Entities.Add(at);

            column.Entities.Add(m1);

            // adds the block to the master block dictionary
            model1.Blocks.Add(column);

            BlockReference reference;

            // Beam
            devDept.Eyeshot.Block beam = new devDept.Eyeshot.Block("beam");
            // creates a gray box
            Mesh m2 = Mesh.CreateBox(BEAM_B, BEAM_L, BEAM_H);

            m2.ColorMethod  = colorMethodType.byEntity;
            m2.Color        = System.Drawing.Color.LightGray;
            m2.MaterialName = _concreteMatName;

            offset = globalVerts.Count;
            for (int i = 0; i < m2.Vertices.Length; i++)
            {
                globalVerts.Add(m2.Vertices[i]);
            }
            for (int i = 0; i < m2.Triangles.Length; i++)
            {
                globalTris.Add(new ColorTriangle(offset + m2.Triangles[i].V1, offset + m2.Triangles[i].V2,
                                                 offset + m2.Triangles[i].V3, System.Drawing.Color.Gray));
            }

            beam.Entities.Add(m2);

            p  = new Plane(new Vector3D(1, 0, 0));
            at = new devDept.Eyeshot.Entities.Attribute(p, new Point3D(BEAM_B / 2, BEAM_L / 2, BEAM_H + TEXT_PAD), "Name",
                                                        "Frame", TEXT_HEIGHT);
            at.Alignment   = devDept.Eyeshot.Entities.Text.alignmentType.BaselineCenter;
            at.Color       = System.Drawing.Color.Green;
            at.ColorMethod = colorMethodType.byEntity;
            beam.Entities.Add(at);

            // adds the block to the master block dictionary
            model1.Blocks.Add(beam);

            // Shell
            devDept.Eyeshot.Block shell = new devDept.Eyeshot.Block("shell");
            double shellB = BEAM_L / _shellSubValue;
            double shellH = COLUMN_L / _shellSubValue;

            // Mesh
            Mesh m3 = Mesh.CreateBox(shellB, SHELL_TICKNESS, shellH);

            m3.ColorMethod  = colorMethodType.byEntity;
            m3.Color        = System.Drawing.Color.LightGreen;
            m3.MaterialName = "wallMat";
            shell.Entities.Add(m3);

            // adds the block to the master block dictionary
            model1.Blocks.Add(shell);

            for (int k = 0; k < _floorsValue; k++)
            {
                for (int j = 0; j <= _bayYValue; j++)
                {
                    for (int i = 0; i <= _bayXValue; i++)
                    {
                        if (pillarsCheckBox.IsChecked == true)
                        {
                            reference = new BlockReference(i * BEAM_L - COLUMN_B / 2, j * BEAM_L - COLUMN_H / 2, k * COLUMN_L,
                                                           "squareCol", 1, 1, 1, 0);
                            if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh)
                            {
                                Mesh mm = (Mesh)model1.Blocks["squareCol"].Entities[1].Clone();
                                mm.Translate(i * BEAM_L - COLUMN_B / 2, j * BEAM_L - COLUMN_H / 2, k * COLUMN_L);
                                offset = globalVerts.Count;
                                globalVerts.AddRange(mm.Vertices);
                                for (int n = 0; n < mm.Triangles.Length; n++)
                                {
                                    globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1,
                                                                     offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.Gray));
                                }
                            }

                            if (labelCheckBox.IsChecked == true)
                            {
                                reference.Attributes.Add("Name", string.Format("Pillar_{0},{1},{2}", i, j, k));
                            }
                            _entityList.Add(reference);
                        }

                        if (showBeamXCheckBox.IsChecked == true)
                        {
                            if (j <= _bayYValue && i < _bayXValue)
                            {
                                // Parallel beams to X
                                Transformation t = new Transformation();
                                t.Rotation(-Math.PI / 2, Vector3D.AxisZ);
                                Transformation t2 = new Transformation();
                                t2.Translation(i * BEAM_L, j * BEAM_L + BEAM_B / 2, (k + 1) * COLUMN_L - BEAM_H / 2);
                                reference = new BlockReference(t2 * t, "beam");

                                if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh)
                                {
                                    Mesh mm = (Mesh)model1.Blocks["beam"].Entities[0].Clone();
                                    mm.TransformBy(t2 * t);

                                    offset = globalVerts.Count;
                                    globalVerts.AddRange(mm.Vertices);
                                    for (int n = 0; n < mm.Triangles.Length; n++)
                                    {
                                        globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1,
                                                                         offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.Gray));
                                    }
                                }

                                if (labelCheckBox.IsChecked == true)
                                {
                                    reference.Attributes.Add("Name", string.Format("Beam_{0},{1},{2}", i, j, k));
                                }
                                _entityList.Add(reference);
                            }
                        }

                        if (showBeamYCheckBox.IsChecked == true)
                        {
                            if (i <= _bayXValue && j < _bayYValue)
                            {
                                // Parallel beams to X
                                Transformation t = new Transformation();
                                t.Translation(i * BEAM_L - BEAM_B / 2, j * BEAM_L, (k + 1) * COLUMN_L - BEAM_H / 2);
                                reference = new BlockReference(t, "beam");

                                if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh)
                                {
                                    Mesh mm = (Mesh)model1.Blocks["beam"].Entities[0].Clone();
                                    mm.TransformBy(t);
                                    offset = globalVerts.Count;
                                    globalVerts.AddRange(mm.Vertices);
                                    for (int n = 0; n < mm.Triangles.Length; n++)
                                    {
                                        globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1,
                                                                         offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.Gray));
                                    }
                                }
                                if (labelCheckBox.IsChecked == true)
                                {
                                    reference.Attributes.Add("Name", string.Format("Beam_{0},{1},{2}", i, j, k));
                                }
                                _entityList.Add(reference);
                            }
                        }

                        if (shellCheckBox.IsChecked == true)
                        {
                            if ((j == 0 || j == _bayYValue) && i < _bayXValue)
                            {
                                for (int i1 = 0; i1 < _shellSubValue; i1++)
                                {
                                    for (int j1 = 0; j1 < _shellSubValue; j1++)
                                    {
                                        Transformation t = new Transformation();
                                        t.Translation(i * BEAM_L + i1 * shellB, j * BEAM_L - SHELL_TICKNESS / 2,
                                                      k * COLUMN_L + j1 * shellH);
                                        reference = new BlockReference(t, "shell");

                                        if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh)
                                        {
                                            Mesh mm = (Mesh)model1.Blocks["shell"].Entities[0].Clone();
                                            mm.TransformBy(t);
                                            offset = globalVerts.Count;
                                            globalVerts.AddRange(mm.Vertices);
                                            for (int n = 0; n < mm.Triangles.Length; n++)
                                            {
                                                globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1,
                                                                                 offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3,
                                                                                 System.Drawing.Color.FromArgb(123, System.Drawing.Color.LightGreen)));
                                            }
                                        }
                                        _entityList.Add(reference);
                                    }
                                }
                            }
                        }
                        if (nodesCheckBox.IsChecked == true)
                        {
                            Joint joint1 = new Joint(i * BEAM_L, j * BEAM_L, k * COLUMN_L, 40, 2);
                            joint1.Color       = System.Drawing.Color.Blue;
                            joint1.ColorMethod = colorMethodType.byEntity;
                            Joint joint2 = new Joint(i * BEAM_L, j * BEAM_L, (k + 1) * COLUMN_L, 40, 2);
                            joint2.Color       = System.Drawing.Color.Blue;
                            joint2.ColorMethod = colorMethodType.byEntity;
                            _entityList.Add(joint1);
                            _entityList.Add(joint2);
                        }
                    }

                    if (shellCheckBox.IsChecked == true)
                    {
                        if (j == 0)
                        {
                            for (int l = 0; l < _bayYValue; l++)
                            {
                                for (int i1 = 0; i1 < _shellSubValue; i1++)
                                {
                                    for (int j1 = 0; j1 < _shellSubValue; j1++)
                                    {
                                        Transformation t = new Transformation();
                                        t.Translation(l * BEAM_L + i1 * shellB, j * BEAM_L - SHELL_TICKNESS / 2,
                                                      k * COLUMN_L + j1 * shellH);
                                        Transformation t2 = new Transformation();
                                        t2.Rotation(Math.PI / 2, Vector3D.AxisZ);
                                        reference = new BlockReference(t2 * t, "shell");

                                        if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh)
                                        {
                                            Mesh mm = (Mesh)model1.Blocks["shell"].Entities[0].Clone();
                                            mm.TransformBy(t2 * t);
                                            offset = globalVerts.Count;
                                            globalVerts.AddRange(mm.Vertices);
                                            for (int n = 0; n < mm.Triangles.Length; n++)
                                            {
                                                globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1,
                                                                                 offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3,
                                                                                 System.Drawing.Color.FromArgb(123, System.Drawing.Color.LightGreen)));
                                            }
                                        }
                                        _entityList.Add(reference);
                                    }
                                }
                            }
                        }
                        if (j == _bayYValue)
                        {
                            for (int l = 0; l < _bayYValue; l++)
                            {
                                for (int i1 = 0; i1 < _shellSubValue; i1++)
                                {
                                    for (int j1 = 0; j1 < _shellSubValue; j1++)
                                    {
                                        Transformation t = new Transformation();
                                        t.Translation(l * BEAM_L + i1 * shellB, -SHELL_TICKNESS / 2, k * COLUMN_L + j1 * shellH);
                                        Transformation t2 = new Transformation();
                                        t2.Rotation(Math.PI / 2, Vector3D.AxisZ);
                                        Transformation t3 = new Transformation();
                                        t3.Translation(_bayXValue * BEAM_L, 0, 0);
                                        reference = new BlockReference(t3 * t2 * t, "shell");

                                        if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh)
                                        {
                                            Mesh mm = (Mesh)model1.Blocks["shell"].Entities[0].Clone();
                                            mm.TransformBy(t3 * t2 * t);
                                            offset = globalVerts.Count;
                                            globalVerts.AddRange(mm.Vertices);
                                            for (int n = 0; n < mm.Triangles.Length; n++)
                                            {
                                                globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1,
                                                                                 offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3,
                                                                                 System.Drawing.Color.FromArgb(123, System.Drawing.Color.LightGreen)));
                                            }
                                        }
                                        _entityList.Add(reference);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            _buildingMesh             = new Mesh(globalVerts, globalTris);
            _buildingMesh.ColorMethod = colorMethodType.byEntity;
            model1.Entities.AddRange(_entityList);

            switch ((structureType)structureModeEnumButton.Value)
            {
            case structureType.Flattened:
            {
                Entity[] entList = model1.Entities.Explode();
                model1.Entities.Clear();
                model1.Entities.AddRange(entList);
                model1.Invalidate();
                break;
            }

            case structureType.SingleMesh:
            {
                model1.Entities.Clear();
                model1.Entities.Add(_buildingMesh);
                model1.Invalidate();
                break;
            }

            case structureType.Assembly:
            {
                model1.Invalidate();
                break;
            }
            }
            TreeViewUtility.PopulateTree(treeView1, model1.Entities.ToList(), model1.Blocks);
        }