예제 #1
0
        /// <summary>
        /// creates a <see cref="Face"/> for a <see cref="Solid"/> with <see cref="Model.Solid"/>.
        /// <b>Curves</b>
        ///
        ///
        ///
        ///
        /// Erstell ein massives <see cref="Face"/>. Wenn <b>Solid</b> nicht null ist, wird dieses Face eingebaut in
        /// <b>Solid</b>. <b>Curves</b> spezifizieren einee Liste von Curve3d-Lists. Sie werden als <see cref="Edge.EdgeCurve"/>
        /// in jede <see cref="Edge"/> gesetzt. <b>Curves</b> müssen von der Struktur identisch sein wie Bounds,
        /// d.h. die selbe Länge und jeder Eintrag in Bounds ( Bounds[i] ) muss die selbe Länge haben wie
        /// der entsprechende Eintrag in <b>Curves</b> (Curves[i]).
        /// gesetzt
        /// </summary>
        /// <param name="Solid"><see cref="Solid"/> in which the result<see cref="Face"/> will be integrated.</param>
        /// <param name="Surface"><see cref="Surface"/> belonging to the new <see cref="Face"/>.</param>
        /// <param name="Bounds">list of <see cref="Vertex3dArray"/>, who contains the start and end points of the <see cref="Edge"/>s.</param>
        /// <param name="Curves"><see cref="Curve3D"/>, which are the new <see cref="Edge.EdgeCurve"/>s. Their start points and their end point must correspond to
        /// the parameter Bounds start and end points.</param>
        /// <returns>a <see cref="Face"/>, which will be added to the <b>Solid</b>.</returns>
        public static Face SolidFace(Solid Solid, Surface Surface, Vertex3dArray_2 Bounds, Loca3D Curves)
        {
            if (Bounds.Count == 0)
            {
                return(null);
            }

            Face Result = new Face();

            Result.Surface = Surface;
            for (int i = 0; i < Bounds.Count; i++)
            {
                EdgeLoop Edgeloop = new EdgeLoop();
                Result.Bounds.Add(Edgeloop);
                for (int j = 0; j < Bounds[i].Count; j++)
                {
                    Vertex3d A = Bounds[i][j];
                    Vertex3d B = null;
                    if (j == Bounds[i].Count - 1)
                    {
                        B = Bounds[i][0];
                    }
                    else
                    {
                        B = Bounds[i][j + 1];
                    }

                    Edge E = Edge.SolidEdge(Solid, Result, A, B, Curves[j][i]);

                    Edgeloop.Add(E);
                }
            }
            return(Result);
        }
예제 #2
0
        /// <summary>
        /// Eine statische methode die einen Quader erstellt mit Ursprung <b>Origin</b> und
        /// Größe <b>Size</b>
        /// </summary>
        /// <param name="Origin">Ursprung des Quaders (rechts unten)</param>
        /// <param name="Size">Größe des Quaders</param>
        /// <returns>Ein solider Quader (Model.SolidSurface) </returns>
        public static Solid CreateSolidBox(xyz Origin, xyz Size)
        {
            Solid Box = new Solid();

            Box.Model = Model.Solid;
            Vertex3d A = new Vertex3d(Origin);
            Vertex3d B = new Vertex3d(Origin + new xyz(Size.x, 0, 0));

            Vertex3d C = new Vertex3d(Origin + new xyz(Size.x, Size.y, 0));
            Vertex3d D = new Vertex3d(Origin + new xyz(0, Size.y, 0));



            Vertex3d        E      = new Vertex3d(A.Value + new xyz(0, 0, Size.z));
            Vertex3d        F      = new Vertex3d(B.Value + new xyz(0, 0, Size.z));
            Vertex3d        G      = new Vertex3d(C.Value + new xyz(0, 0, Size.z));
            Vertex3d        H      = new Vertex3d(D.Value + new xyz(0, 0, Size.z));
            Vertex3dArray_2 Border = new Vertex3dArray_2();
            Vertex3dArray   VA     = new Vertex3dArray();

            Border.Add(VA);
            Face Face = null;

            VA.Clear();
            VA.Add(A);
            VA.Add(B);
            VA.Add(C);
            VA.Add(D);
            Face = Face.SolidPlane(Box, Border);
            Box.FaceList.Add(Face);

            VA.Clear();
            VA.Add(A);
            VA.Add(E);
            VA.Add(F);
            VA.Add(B);

            Face = Face.SolidPlane(Box, Border);
            Box.FaceList.Add(Face);

            VA.Clear();
            VA.Add(B);
            VA.Add(F);
            VA.Add(G);
            VA.Add(C);
            Face = Face.SolidPlane(Box, Border);
            Box.FaceList.Add(Face);

            VA.Clear();
            VA.Add(C);
            VA.Add(G);
            VA.Add(H);
            VA.Add(D);
            Face = Face.SolidPlane(Box, Border);
            Box.FaceList.Add(Face);

            VA.Clear();
            VA.Add(D);
            VA.Add(H);
            VA.Add(E);
            VA.Add(A);
            Face = Face.SolidPlane(Box, Border);
            Box.FaceList.Add(Face);

            VA.Clear();
            VA.Add(H);
            VA.Add(G);
            VA.Add(F);
            VA.Add(E);
            Face = Face.SolidPlane(Box, Border);
            Box.FaceList.Add(Face);
            return(Box);
        }
예제 #3
0
        /// <summary>
        /// overrides the <see cref="Solid.Refresh()"/> method.
        /// </summary>
        public override void Refresh()
        {
            VertexList.Clear();
            EdgeList.Clear();
            FaceList.Clear();
            EdgeCurveList.Clear();

            Vertex3d A = new Vertex3d(xyz.Null);
            Vertex3d B = new Vertex3d(new xyz(Size.x, 0, 0));
            Vertex3d C = new Vertex3d(new xyz(Size.x, Size.y, 0));
            Vertex3d D = new Vertex3d(new xyz(0, Size.y, 0));
            Vertex3d E = new Vertex3d(A.Value + new xyz(0, 0, Size.z));
            Vertex3d F = new Vertex3d(B.Value + new xyz(0, 0, Size.z));
            Vertex3d G = new Vertex3d(C.Value + new xyz(0, 0, Size.z));
            Vertex3d H = new Vertex3d(D.Value + new xyz(0, 0, Size.z));

            VertexList.Add(A);
            VertexList.Add(B);
            VertexList.Add(C);
            VertexList.Add(D);
            VertexList.Add(E);
            VertexList.Add(F);
            VertexList.Add(G);
            VertexList.Add(H);

            Vertex3dArray_2 Border = new Vertex3dArray_2();
            Vertex3dArray   VA     = new Vertex3dArray();

            Border.Add(VA);
            Face Face = null;

            VA.Clear();
            VA.Add(A);
            VA.Add(B);
            VA.Add(C);
            VA.Add(D);
            Face = Face.SolidPlane(this, Border);
            // FaceList.Add(Face);

            VA.Clear();
            VA.Add(A);
            VA.Add(E);
            VA.Add(F);
            VA.Add(B);

            Face = Face.SolidPlane(this, Border);
            // FaceList.Add(Face);

            VA.Clear();
            VA.Add(B);
            VA.Add(F);
            VA.Add(G);
            VA.Add(C);
            Face = Face.SolidPlane(this, Border);
            //  FaceList.Add(Face);

            VA.Clear();
            VA.Add(C);
            VA.Add(G);
            VA.Add(H);
            VA.Add(D);
            Face = Face.SolidPlane(this, Border);
            //  FaceList.Add(Face);

            VA.Clear();
            VA.Add(D);
            VA.Add(H);
            VA.Add(E);
            VA.Add(A);
            Face = Face.SolidPlane(this, Border);
            //   FaceList.Add(Face);

            VA.Clear();
            VA.Add(H);
            VA.Add(G);
            VA.Add(F);
            VA.Add(E);
            Face = Face.SolidPlane(this, Border);
            //for (int i = 0; i < FaceList.Count; i++)
            //{
            //    FaceList[i].DrawRelativToSurfaceBase = false;
            //    FaceList[i].Refresh();
            //}
        }
예제 #4
0
        /// <summary>
        /// creates a <see cref="Face"/> for a <see cref="Solid"/> in the <see cref="Model.Solid"/>.
        /// The Curves are all <see cref="Line3D"/>. The <see cref="Face"/> is plane and has as <see cref="Face.Surface"/> a <see cref="PlaneSurface"/>.
        /// </summary>
        /// <param name="Solid">is the target in which the <see cref="Face"/> will be posed.</param>
        /// <param name="Bounds">contains the <see cref="Vertex3d"/> for the <see cref="Line3D"/>.</param>
        /// <returns>a <see cref="Face"/></returns>
        public static Face SolidPlane(Solid Solid, Vertex3dArray_2 Bounds)
        {
            if (Bounds.Count == 0)
            {
                return(null);
            }
            xyz N = new xyz(0, 0, 0);
            xyz P = Bounds[0][0].Value;

            for (int i = 1; i < Bounds[0].Count - 1; i++)
            {
                xyz A = Bounds[0][i].Value;
                xyz B = Bounds[0][i + 1].Value;
                xyz M = N;
                N = N + ((A - P) & (B - P));
            }
            N = N.normalized() * (-1);
            Base Base = Base.UnitBase;

            Base.BaseO = P;
            Base.BaseZ = N;
            if ((Base.BaseZ & new xyz(1, 0, 0)).dist(xyz.Null) > 0.01)
            {
                Base.BaseY = (Base.BaseZ & (new xyz(1, 0, 0))).normalized();
                Base.BaseX = Base.BaseY & Base.BaseZ;
            }
            else
            {
                Base.BaseY = (Base.BaseZ & (new xyz(0, 1, 0))).normalized();
                Base.BaseX = Base.BaseY & Base.BaseZ;
            }

            PlaneSurface Surface = new PlaneSurface();

            Surface.Base = Base;
            //-------------------------------------
            //-------- Create the Face
            Face Result = new Face();

            // ---- With Plane Surface
            Result.Surface = Surface;
            if (Solid != null)
            {
                Solid.FaceList.Add(Result);
            }
            //----- Set the Edges
            for (int i = 0; i < Bounds.Count; i++)
            {
                EdgeLoop Edgeloop = new EdgeLoop();
                Result.Bounds.Add(Edgeloop);
                for (int j = 0; j < Bounds[i].Count; j++)
                {
                    Vertex3d A = Bounds[i][j];
                    Vertex3d B = null;
                    if (j == Bounds[i].Count - 1)
                    {
                        B = Bounds[i][0];
                    }
                    else
                    {
                        B = Bounds[i][j + 1];
                    }
                    Edge E = Edge.SolidEdge(Solid, Result, A, B, new Line3D(A.Value, B.Value));

                    Edgeloop.Add(E);
                }
            }

            Result.RefreshParamCurves();
            return(Result);
        }