Beispiel #1
0
        public static WedgeVolume CreateVolume(TriFace f1, TriFace f2, QuadFace f3, QuadFace f4, QuadFace f5)
        {
            WedgeVolume vol = new WedgeVolume(IDCounter.ClaimID());

            List <Face> faces = new List <Face>()
            {
                f1, f2, f3, f4, f5
            };
            List <Edge>   edges    = new List <Edge>();
            List <Vertex> vertices = new List <Vertex>();

            foreach (Face f in faces)
            {
                if (vol.Face1 == null && f is TriFace)
                {
                    vol.Face1 = f as TriFace;
                }
                else if (vol.Face2 == null && f is TriFace)
                {
                    vol.Face2 = f as TriFace;
                }
                else if (vol.Face3 == null && f is QuadFace)
                {
                    vol.Face3 = f as QuadFace;
                }
                else if (vol.Face4 == null && f is QuadFace)
                {
                    vol.Face4 = f as QuadFace;
                }
                else if (vol.Face5 == null && f is QuadFace)
                {
                    vol.Face5 = f as QuadFace;
                }
                else
                {
                    Console.WriteLine("Error during volume #" + vol.ID + "creation: Not expected face type.");
                }

                if (f.Volume1 == null)
                {
                    f.Volume1 = vol;
                }
                else if (f.Volume2 == null)
                {
                    f.Volume2 = vol;
                }
                else
                {
                    Console.WriteLine("Error during volume #" + vol.ID + "creation: Face #" + f.ID + " already has");
                }

                if (f is TriFace)
                {
                    if (!edges.Contains((f as TriFace).Edge1))
                    {
                        edges.Add((f as TriFace).Edge1);
                    }
                    if (!edges.Contains((f as TriFace).Edge2))
                    {
                        edges.Add((f as TriFace).Edge2);
                    }
                    if (!edges.Contains((f as TriFace).Edge3))
                    {
                        edges.Add((f as TriFace).Edge3);
                    }
                    if (!vertices.Contains((f as TriFace).Vertex1))
                    {
                        vertices.Add((f as TriFace).Vertex1);
                    }
                    if (!vertices.Contains((f as TriFace).Vertex2))
                    {
                        vertices.Add((f as TriFace).Vertex2);
                    }
                    if (!vertices.Contains((f as TriFace).Vertex3))
                    {
                        vertices.Add((f as TriFace).Vertex3);
                    }
                }

                if (f is QuadFace)
                {
                    if (!edges.Contains((f as QuadFace).Edge1))
                    {
                        edges.Add((f as QuadFace).Edge1);
                    }
                    if (!edges.Contains((f as QuadFace).Edge2))
                    {
                        edges.Add((f as QuadFace).Edge2);
                    }
                    if (!edges.Contains((f as QuadFace).Edge3))
                    {
                        edges.Add((f as QuadFace).Edge3);
                    }
                    if (!edges.Contains((f as QuadFace).Edge4))
                    {
                        edges.Add((f as QuadFace).Edge4);
                    }
                    if (!vertices.Contains((f as QuadFace).Vertex1))
                    {
                        vertices.Add((f as QuadFace).Vertex1);
                    }
                    if (!vertices.Contains((f as QuadFace).Vertex2))
                    {
                        vertices.Add((f as QuadFace).Vertex2);
                    }
                    if (!vertices.Contains((f as QuadFace).Vertex3))
                    {
                        vertices.Add((f as QuadFace).Vertex3);
                    }
                    if (!vertices.Contains((f as QuadFace).Vertex4))
                    {
                        vertices.Add((f as QuadFace).Vertex4);
                    }
                }
            }

            vol.Vertex1 = vertices[0];
            if (!vol.Vertex1.Volumes.Contains(vol))
            {
                vol.Vertex1.Volumes.Add(vol);
            }
            vol.Vertex2 = vertices[1];
            if (!vol.Vertex2.Volumes.Contains(vol))
            {
                vol.Vertex2.Volumes.Add(vol);
            }
            vol.Vertex3 = vertices[2];
            if (!vol.Vertex3.Volumes.Contains(vol))
            {
                vol.Vertex3.Volumes.Add(vol);
            }
            vol.Vertex4 = vertices[3];
            if (!vol.Vertex4.Volumes.Contains(vol))
            {
                vol.Vertex4.Volumes.Add(vol);
            }
            vol.Vertex5 = vertices[4];
            if (!vol.Vertex5.Volumes.Contains(vol))
            {
                vol.Vertex5.Volumes.Add(vol);
            }
            vol.Vertex6 = vertices[5];
            if (!vol.Vertex6.Volumes.Contains(vol))
            {
                vol.Vertex6.Volumes.Add(vol);
            }

            vol.Edge1 = edges[0];
            if (!vol.Edge1.Volumes.Contains(vol))
            {
                vol.Edge1.Volumes.Add(vol);
            }
            vol.Edge2 = edges[1];
            if (!vol.Edge2.Volumes.Contains(vol))
            {
                vol.Edge2.Volumes.Add(vol);
            }
            vol.Edge3 = edges[2];
            if (!vol.Edge3.Volumes.Contains(vol))
            {
                vol.Edge3.Volumes.Add(vol);
            }
            vol.Edge4 = edges[3];
            if (!vol.Edge4.Volumes.Contains(vol))
            {
                vol.Edge4.Volumes.Add(vol);
            }
            vol.Edge5 = edges[4];
            if (!vol.Edge5.Volumes.Contains(vol))
            {
                vol.Edge5.Volumes.Add(vol);
            }
            vol.Edge6 = edges[5];
            if (!vol.Edge6.Volumes.Contains(vol))
            {
                vol.Edge6.Volumes.Add(vol);
            }
            vol.Edge7 = edges[6];
            if (!vol.Edge7.Volumes.Contains(vol))
            {
                vol.Edge7.Volumes.Add(vol);
            }
            vol.Edge8 = edges[7];
            if (!vol.Edge8.Volumes.Contains(vol))
            {
                vol.Edge8.Volumes.Add(vol);
            }
            vol.Edge9 = edges[8];
            if (!vol.Edge9.Volumes.Contains(vol))
            {
                vol.Edge9.Volumes.Add(vol);
            }

            vol.CalculateCenter();
            vol.CalculateSurface();
            vol.CalculateVolume();

            return(vol);
        }
Beispiel #2
0
        public static WedgeVolume CreateVolume(Vertex v1, Vertex v2, Vertex v3, Vertex v4, Vertex v5, Vertex v6)
        {
            WedgeVolume vol = new WedgeVolume(IDCounter.ClaimID());

            return(vol);
        }