Esempio n. 1
0
        public Hull(CreateHullData setup)
        {
            Point3DCollection points = new Point3DCollection();
            double            height = 0;
            double            width  = 0;
            double            Z      = 0;

            Bulkheads = new List <Bulkhead>();

            if (setup.IncludeBow)
            {
                Z     = 0;
                width = 0;
                for (int ii = 0; ii < setup.NumChines + 1; ii++)
                {
                    points.Add(new Point3D(width, height, Z));
                    height += setup.Height / setup.NumChines;
                }
                Bulkheads.Add(new Bulkhead(points, Bulkhead.BulkheadType.BOW));
            }

            // Vertical bulkheads
            while (Bulkheads.Count < setup.NumBulkheads - 1)
            {
                points.Clear();
                Z      = Bulkheads.Count * setup.Length / setup.NumBulkheads;
                width  = 0;
                height = 0;
                for (int ii = 0; ii < setup.NumChines + 1; ii++)
                {
                    points.Add(new Point3D(width, height, Z));
                    width  += setup.Width / setup.NumChines;
                    height += setup.Height / setup.NumChines;
                }
                Bulkheads.Add(new Bulkhead(points, Bulkhead.BulkheadType.VERTICAL));
            }

            // Transom
            points.Clear();
            Z      = Bulkheads.Count * setup.Length / setup.NumBulkheads;
            width  = 0;
            height = 0;
            for (int ii = 0; ii < setup.NumChines + 1; ii++)
            {
                points.Add(new Point3D(width, height, Z + height * Math.Cos(Math.PI / 180 * setup.TransomAngle)));
                width  += setup.Width / setup.NumChines;
                height += setup.Height / setup.NumChines;
            }
            Bulkheads.Add(new Bulkhead(points, Bulkhead.BulkheadType.TRANSOM));
        }
Esempio n. 2
0
 /// <summary>
 ///     Sets the coordinates of all the individual lines in the visual.
 /// </summary>
 /// <param name="args">
 ///     The <c>DependencyPropertyChangedEventArgs</c> object associated
 ///     with the property-changed event that resulted in this method
 ///     being called.
 /// </param>
 /// <param name="lines">
 ///     The <c>Point3DCollection</c> to be filled.
 /// </param>
 /// <remarks>
 ///     <para>
 ///         Classes that derive from <c>WireBase</c> override this
 ///         method to fill the <c>lines</c> collection.
 ///         It is custmary for implementations of this method to clear
 ///         the <c>lines</c> collection first before filling it.
 ///         Each pair of successive members of the <c>lines</c>
 ///         collection indicate one straight line.
 ///     </para>
 ///     <para>
 ///         The <c>WireLine</c> class implements this method by
 ///         clearing the <c>lines</c> collection and then adding
 ///         <c>Point1</c> and <c>Point2</c> to the collection.
 ///     </para>
 /// </remarks>
 protected override void Generate(DependencyPropertyChangedEventArgs args,
                                  Point3DCollection lines)
 {
     lines.Clear();
     lines.Add(Point1);
     lines.Add(Point2);
 }
Esempio n. 3
0
        /// <summary>
        ///     Sets the coordinates of all the individual lines in the visual.
        /// </summary>
        /// <param name="args">
        ///     The <c>DependencyPropertyChangedEventArgs</c> object associated
        ///     with the property-changed event that resulted in this method
        ///     being called.
        /// </param>
        /// <param name="lines">
        ///     The <c>Point3DCollection</c> to be filled.
        /// </param>
        /// <remarks>
        ///     <para>
        ///         Classes that derive from <c>WireBase</c> override this
        ///         method to fill the <c>lines</c> collection.
        ///         It is custmary for implementations of this method to clear
        ///         the <c>lines</c> collection first before filling it.
        ///         Each pair of successive members of the <c>lines</c>
        ///         collection indicate one straight line.
        ///     </para>
        /// </remarks>
        protected override void Generate(DependencyPropertyChangedEventArgs args,
                                         Point3DCollection lines)
        {
            lines.Clear();

            if (Data == null)
            {
                return;
            }

            Transform3D xform = Data.Transform;

            foreach (PathFigure3D fig in Data.Figures)
            {
                PathFigure3D figFlattened = fig.GetFlattenedPathFigure();
                Point3D      pointStart   = xform.Transform(figFlattened.StartPoint);

                foreach (PathSegment3D seg in figFlattened.Segments)
                {
                    PolyLineSegment3D segPoly = seg as PolyLineSegment3D;

                    for (int i = 0; i < segPoly.Points.Count; i++)
                    {
                        lines.Add(pointStart);
                        Point3D point = xform.Transform(segPoly.Points[i]);
                        lines.Add(point);
                        pointStart = point;
                    }
                }
            }
        }
        void OnRendering(object sender, EventArgs args)
        {
            // Detach collection from MeshGeometry3D.
            Point3DCollection points = mesh.Positions;

            mesh.Positions = null;
            points.Clear();

            // Calculation rotation quaternion.
            double angle = 360.0 * (stopwatch.Elapsed.TotalSeconds %
                                    secondsPerCycle) / secondsPerCycle;
            Quaternion qRotate    = new Quaternion(axis, angle);
            Quaternion qConjugate = qRotate;

            qConjugate.Conjugate();

            // Apply rotation to each point.
            foreach (Point3D point in pointsCuboid)
            {
                Quaternion qPoint = new Quaternion(point.X, point.Y, point.Z, 0);
                qPoint -= qCenter;
                Quaternion qRotatedPoint = qRotate * qPoint * qConjugate;
                qRotatedPoint += qCenter;
                points.Add(new Point3D(qRotatedPoint.X, qRotatedPoint.Y,
                                       qRotatedPoint.Z));
            }

            // Re-attach collections to MeshGeometry3D.
            mesh.Positions = points;
        }
Esempio n. 5
0
        public void VerformteGeometrie(Model3DGroup modelGroup)
        {
            var mesh = new MeshGeometry3D();

            foreach (var item in modell.Elemente)
            {
                var punkte = new Point3DCollection();
                punktDictionary.Clear();
                punkte.Clear();
                foreach (var knotenId in item.Value.NodeIds)
                {
                    if (modell.Knoten.TryGetValue(knotenId, out var knoten))
                    {
                        punkte.Add(new Point3D(knoten.Coordinates[0] + knoten.NodalDof[0] * überhöhungVerformung,
                                               -knoten.Coordinates[2] - knoten.NodalDof[2] * überhöhungVerformung,
                                               knoten.Coordinates[1] + knoten.NodalDof[1] * überhöhungVerformung));
                    }
                }

                ErzeugQuader(mesh, punkte);

                // Erzeugung des Drahtmodells, thickness (Wichte der kanten) = 0.02
                const double kantenwichte       = 0.02;
                var          verformung         = mesh.ToWireframe(kantenwichte);
                var          verformungMaterial = new DiffuseMaterial(Brushes.Red);
                verformungsModell = new GeometryModel3D(verformung, verformungMaterial);
                modelGroup.Children.Add(verformungsModell);

                verformungen.Add(verformungsModell);
            }
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        /// <param name="lines"></param>
        protected override void Generate(DependencyPropertyChangedEventArgs args,
                                         Point3DCollection lines)
        {
            Point3DCollection vertices = Positions;
            Int32Collection   indices  = TriangleIndices;

            lines.Clear();

            if (vertices != null && vertices.Count > 0 &&
                indices != null && indices.Count > 0)
            {
                // Check that this doesn't overflow !!!!!!
                // -----------------------------------------

                // Special logic if there are no indices !!!!
                // -------------------------------------------

                for (int i = 0; i < indices.Count; i += 3)
                {
                    lines.Add(vertices[indices[i + 0]]);
                    lines.Add(vertices[indices[i + 1]]);

                    lines.Add(vertices[indices[i + 1]]);
                    lines.Add(vertices[indices[i + 2]]);

                    lines.Add(vertices[indices[i + 2]]);
                    lines.Add(vertices[indices[i + 0]]);
                }
            }
        }
Esempio n. 7
0
        protected override void Triangulate(DependencyPropertyChangedEventArgs args,
                                            Point3DCollection vertices,
                                            Vector3DCollection normals,
                                            Int32Collection indices,
                                            PointCollection textures)
        {
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            MeshGeometry3D mesh = MeshGenerator.Geometry;

            foreach (Point3D vertex in mesh.Positions)
            {
                vertices.Add(vertex);
            }

            foreach (Vector3D normal in mesh.Normals)
            {
                normals.Add(normal);
            }

            foreach (int index in mesh.TriangleIndices)
            {
                indices.Add(index);
            }

            foreach (Point texture in mesh.TextureCoordinates)
            {
                textures.Add(texture);
            }
        }
Esempio n. 8
0
        public void ShowPosition()
        {
            GrblViewModel model = (GrblViewModel)DataContext;

            Machine.ToolPosition = null;

            positionPoints.Clear();

            if (Machine.Limits.X == 0d)
            {
                Machine.SetLimits(GrblSettings.GetDouble(GrblSetting.AxisSetting_XMaxTravel),
                                  GrblSettings.GetDouble(GrblSetting.AxisSetting_YMaxTravel),
                                  GrblSettings.GetDouble(GrblSetting.AxisSetting_ZMaxTravel));
            }

            positionPoints.Add(new Point3D(Math.Min(model.Position.X, model.ProgramLimits.MinX) - 5d, model.Position.Y, model.Position.Z));
            positionPoints.Add(new Point3D(Machine.Limits.X, model.Position.Y, model.Position.Z));

            positionPoints.Add(new Point3D(model.Position.X, Math.Min(model.Position.Y, model.ProgramLimits.MinY) - 5d, model.Position.Z));
            positionPoints.Add(new Point3D(model.Position.X, Machine.Limits.Y, model.Position.Z));

            positionPoints.Add(new Point3D(model.Position.X, model.Position.Y, Math.Min(model.Position.Z, model.ProgramLimits.MinZ) - 5d));
            positionPoints.Add(new Point3D(model.Position.X, model.Position.Y, Machine.Limits.Z));

            Machine.ToolPosition = positionPoints;
            var orgpos = Machine.StartPosition;

            Machine.SetStartPosition(model.Position.X, model.Position.Y, model.Position.Z);

            if (Machine.RapidLines != null && Machine.RapidLines.Count > 0 && Machine.RapidLines[0].Equals(orgpos))
            {
                Machine.RapidLines.RemoveAt(0);
                Machine.RapidLines.Insert(0, Machine.StartPosition);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 只显示,不做居中
        /// </summary>
        /// <param name="rpList"></param>
        /// <param name="Path"></param>
        /// <param name="startLine"></param>
        /// <param name="Length"></param>
        /// <param name="filterMultiple"></param>
        /// <returns></returns>
        public static bool ReadTxtPoint3Ds(ref Point3DCollection rpList, string Path, int startLine, int Length, int filterMultiple = 1)
        {
            if (filterMultiple < 1)
            {
                filterMultiple = 1;
            }

            if (File.Exists(Path))
            {
                //using (StreamReader sr = new StreamReader("scan\\clipped_pointsShoes.pcd"))
                using (StreamReader sr = new StreamReader(Path))
                {
                    rpList.Clear();
                    String line;
                    int    i = 0;
                    while ((line = sr.ReadLine()) != null)//按行读取 line为每行的数据
                    {
                        i++;
                        if (i < startLine)
                        {
                            continue;
                        }
                        if (i % filterMultiple == 0)
                        {
                            string[] parts = line.Trim().Split(' ');
                            if (parts.Length != Length && parts.Length != 3 && parts.Length != 6)
                            {
                                continue;
                            }
                            Point3D rp = new Point3D();
                            rp.X = -double.Parse(parts[0]);
                            rp.Y = -double.Parse(parts[1]);
                            rp.Z = double.Parse(parts[2]);

                            rpList.Add(rp);
                        }
                    }

                    if (rpList.Count() > 0)
                    {
                        //Point3D rp1 = rpList[0];
                        //rpList.Add(rp1);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(true);
            }



            return(true);
        }
Esempio n. 10
0
 public void ClearAll()
 {
     points.Clear();
     lines.Clear();
     meshes.Clear();
     xAxisPoints.Clear();
     yAxisPoints.Clear();
     zAxisPoints.Clear();
 }
Esempio n. 11
0
        /// <summary>
        ///     Sets the coordinates of all the individual lines in the visual.
        /// </summary>
        /// <param name="args">
        ///     The <c>DependencyPropertyChangedEventArgs</c> object associated
        ///     with the property-changed event that resulted in this method
        ///     being called.
        /// </param>
        /// <param name="lines">
        ///     The <c>Point3DCollection</c> to be filled.
        /// </param>
        /// <remarks>
        ///     <para>
        ///         Classes that derive from <c>WireBase</c> override this
        ///         method to fill the <c>lines</c> collection.
        ///         It is custmary for implementations of this method to clear
        ///         the <c>lines</c> collection first before filling it.
        ///         Each pair of successive members of the <c>lines</c>
        ///         collection indicate one straight line.
        ///     </para>
        ///     <para>
        ///         The <c>WireLines</c> class implements this method by
        ///         clearing the <c>lines</c> collection and then copying
        ///         its own <c>Lines</c> collection to it.
        ///     </para>
        /// </remarks>
        protected override void Generate(DependencyPropertyChangedEventArgs args,
                                         Point3DCollection lines)
        {
            lines.Clear();

            foreach (Point3D point in Lines)
            {
                lines.Add(point);
            }
        }
Esempio n. 12
0
        public static void Reverse(Point3DCollection curve)
        {
            Point3DCollection copied = curve.Clone();

            curve.Clear();
            foreach (Point3D p in copied.Reverse())
            {
                curve.Add(p);
            }
            copied = null;
        }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        /// <param name="vertices"></param>
        /// <param name="normals"></param>
        /// <param name="indices"></param>
        /// <param name="textures"></param>
        protected override void Triangulate(DependencyPropertyChangedEventArgs args,
                                            Point3DCollection vertices,
                                            Vector3DCollection normals,
                                            Int32Collection indices,
                                            PointCollection textures)
        {
            // Clear all four collections.
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            // Fill the vertices, normals, and textures collections.
            for (int stack = 0; stack <= Stacks; stack++)
            {
                double phi   = Math.PI / 2 - stack * Math.PI / Stacks;
                double y     = Radius * Math.Sin(phi);
                double scale = -Radius *Math.Cos(phi);

                for (int slice = 0; slice <= Slices; slice++)
                {
                    double theta = slice * 2 * Math.PI / Slices;
                    double x     = scale * Math.Sin(theta);
                    double z     = scale * Math.Cos(theta);

                    Vector3D normal = new Vector3D(x, y, z);
                    normals.Add(normal);
                    vertices.Add(normal.ToPoint3D());
                    textures.Add(new Point((double)slice / Slices,
                                           (double)stack / Stacks));
                }
            }

            // Fill the indices collection.
            for (int stack = 0; stack < Stacks; stack++)
            {
                for (int slice = 0; slice < Slices; slice++)
                {
                    if (stack != 0)
                    {
                        indices.Add((stack + 0) * (Slices + 1) + slice);
                        indices.Add((stack + 1) * (Slices + 1) + slice);
                        indices.Add((stack + 0) * (Slices + 1) + slice + 1);
                    }

                    if (stack != Stacks - 1)
                    {
                        indices.Add((stack + 0) * (Slices + 1) + slice + 1);
                        indices.Add((stack + 1) * (Slices + 1) + slice);
                        indices.Add((stack + 1) * (Slices + 1) + slice + 1);
                    }
                }
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Reset scene to start configuration
 /// </summary>
 /// <param name="systemState">Actual system state</param>
 public void ResetSimulation(SystemState systemState)
 {
     frame = 0;
     UpdateState(systemState);
     UpdateCamera(systemState);
     cartTrajectoryPoints.Clear();
     pendulumTrajectoryPoints.Clear();
     cartTrajectoryPoints.Add(new Point3D(systemState.StateX.Position, systemState.StateY.Position, CartTrajectoryHeight));
     pendulumTrajectoryPoints.Add(pendulum.MassLinkPoint);
     WindArrow.Visible = false;
 }
Esempio n. 15
0
/*
 *      // Static method called for any property change.
 *      static void PropertyChanged(DependencyObject obj,
 *                                  DependencyPropertyChangedEventArgs args)
 *      {
 *          (obj as TorusMesh).PropertyChanged(args);
 *      }
 */
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        /// <param name="vertices"></param>
        /// <param name="normals"></param>
        /// <param name="indices"></param>
        /// <param name="textures"></param>
        protected override void Triangulate(DependencyPropertyChangedEventArgs args,
                                            Point3DCollection vertices,
                                            Vector3DCollection normals,
                                            Int32Collection indices,
                                            PointCollection textures)
        {
            // Clear all four collections.
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            // Fill the vertices, normals, and textures collections.
            for (int stack = 0; stack <= Stacks; stack++)
            {
                double phi = stack * 2 * Math.PI / Stacks;

                double  xCenter     = Radius * Math.Sin(phi);
                double  yCenter     = Radius * Math.Cos(phi);
                Point3D pointCenter = new Point3D(xCenter, yCenter, 0);

                for (int slice = 0; slice <= Slices; slice++)
                {
                    double theta = slice * 2 * Math.PI / Slices + Math.PI;
                    double x     = (Radius + TubeRadius * Math.Cos(theta)) * Math.Sin(phi);
                    double y     = (Radius + TubeRadius * Math.Cos(theta)) * Math.Cos(phi);
                    double z     = -TubeRadius *Math.Sin(theta);

                    Point3D point = new Point3D(x, y, z);

                    vertices.Add(point);
                    normals.Add(point - pointCenter);
                    textures.Add(new Point((double)slice / Slices,
                                           (double)stack / Stacks));
                }
            }

            // Fill the indices collection.
            for (int stack = 0; stack < Stacks; stack++)
            {
                for (int slice = 0; slice < Slices; slice++)
                {
                    indices.Add((stack + 0) * (Slices + 1) + slice);
                    indices.Add((stack + 1) * (Slices + 1) + slice);
                    indices.Add((stack + 0) * (Slices + 1) + slice + 1);

                    indices.Add((stack + 0) * (Slices + 1) + slice + 1);
                    indices.Add((stack + 1) * (Slices + 1) + slice);
                    indices.Add((stack + 1) * (Slices + 1) + slice + 1);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        ///     Sets the coordinates of all the individual lines in the visual.
        /// </summary>
        /// <param name="args">
        ///     The <c>DependencyPropertyChangedEventArgs</c> object associated
        ///     with the property-changed event that resulted in this method
        ///     being called.
        /// </param>
        /// <param name="lines">
        ///     The <c>Point3DCollection</c> to be filled.
        /// </param>
        /// <remarks>
        ///     <para>
        ///         Classes that derive from <c>WireBase</c> override this
        ///         method to fill the <c>lines</c> collection.
        ///         It is custmary for implementations of this method to clear
        ///         the <c>lines</c> collection first before filling it.
        ///         Each pair of successive members of the <c>lines</c>
        ///         collection indicate one straight line.
        ///     </para>
        ///     <para>
        ///         The <c>WirePolyline</c> class implements this method by
        ///         clearing the <c>lines</c> collection and then breaking
        ///         down its <c>Points</c> collection into individual lines
        ///         and then adding the start and end points to the collection.
        ///     </para>
        /// </remarks>
        protected override void Generate(DependencyPropertyChangedEventArgs args,
                                         Point3DCollection lines)
        {
            Point3DCollection points = Points;

            lines.Clear();

            for (int i = 0; i < points.Count - 1; i++)
            {
                lines.Add(points[i]);
                lines.Add(points[i + 1]);
            }
        }
Esempio n. 17
0
        private void pointsList_KeyDown(object sender, KeyEventArgs e)
        {
            ListBox listBox = (ListBox)sender;

            if (e.Key == Key.Delete)
            {
                int selectedIndex = listBox.SelectedIndex;
                point3Ds.RemoveAt(selectedIndex);
                PointsList();
                trianglesList.Items.Clear();
                triangles3Ds.Clear();
            }
        }
Esempio n. 18
0
 /// <summary>
 /// Duplicate two Point3DCollection objects.
 /// </summary>
 /// <param name="from">Original collection.</param>
 /// <param name="to">Recipient collection.</param>
 public static void ClonePoints(Point3DCollection from, Point3DCollection to)
 {
     if (from == null)
     {
         throw new ArgumentNullException("from");
     }
     if (to == null)
     {
         throw new ArgumentNullException("to");
     }
     to.Clear();
     CopyPoints(from, to);
 }
Esempio n. 19
0
        void SegmentsPropertyChanged()
        {
            PolyLineSegment3D polyseg = figFlattened.Segments[0] as PolyLineSegment3D;
            Point3DCollection points  = polyseg.Points;

            polyseg.Points = null;

            points.Clear();
            Point3D ptStart = StartPoint;

            foreach (PathSegment3D seg in Segments)
            {
                if (seg is LineSegment3D)
                {
                    LineSegment3D segLine = seg as LineSegment3D;
                    points.Add(segLine.Point);
                    ptStart = segLine.Point;
                }
                else if (seg is PolyLineSegment3D)
                {
                    PolyLineSegment3D segPoly = seg as PolyLineSegment3D;

                    foreach (Point3D pt in segPoly.Points)
                    {
                        points.Add(pt);
                        ptStart = pt;
                    }
                }

                else if (seg is BezierSegment3D)
                {
                    BezierSegment3D segBez = seg as BezierSegment3D;
                    ConvertBezier(points, ptStart, segBez.Point1, segBez.Point2, segBez.Point3);
                    ptStart = segBez.Point3;
                }

                else if (seg is PolyBezierSegment3D)
                {
                    PolyBezierSegment3D segPoly = seg as PolyBezierSegment3D;

                    for (int i = 0; i < segPoly.Points.Count; i += 3)
                    {
                        ConvertBezier(points, ptStart, segPoly.Points[i], segPoly.Points[i + 1], segPoly.Points[i + 2]);
                        ptStart = segPoly.Points[i + 2];
                    }
                }
            }
            polyseg.Points = points;
        }
Esempio n. 20
0
 public void resetData()
 {
     //Clear the buffers
     foreach (List <int> sublist in history)
     {
         sublist.Clear();
     }
     foreach (List <int> sublist in inverse_history)
     {
         sublist.Clear();
     }
     pointHist.Clear();
     point3DHist.Clear();
     data_history.Clear();
 }
Esempio n. 21
0
        protected override void Triangulate(DependencyPropertyChangedEventArgs args,
                                            Point3DCollection vertices,
                                            Vector3DCollection normals,
                                            Int32Collection indices,
                                            PointCollection textures)
        {
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            // Variables for vertices collection.
            Vector3D UL      = (Vector3D)UpperLeft;
            Vector3D UR      = (Vector3D)UpperRight;
            Vector3D LL      = (Vector3D)LowerLeft;
            Vector3D LR      = (Vector3D)LowerRight;
            int      product = Slices * Stacks;

            // Variables for textures collection
            Point  ptOrigin  = new Point(0, 0);
            Vector vectSlice = (new Point(1, 0) - ptOrigin) / Slices;
            Vector vectStack = (new Point(0, 1) - ptOrigin) / Stacks;

            for (int stack = 0; stack <= Stacks; stack++)
            {
                for (int slice = 0; slice <= Slices; slice++)
                {
                    vertices.Add((Point3D)(((Stacks - stack) * (Slices - slice) * UL +
                                            stack * (Slices - slice) * LL +
                                            (Stacks - stack) * slice * UR +
                                            stack * slice * LR) / product));

                    textures.Add(ptOrigin + stack * vectStack + slice * vectSlice);

                    if (slice < Slices && stack < Stacks)
                    {
                        indices.Add((Slices + 1) * stack + slice);
                        indices.Add((Slices + 1) * (stack + 1) + slice);
                        indices.Add((Slices + 1) * stack + slice + 1);

                        indices.Add((Slices + 1) * stack + slice + 1);
                        indices.Add((Slices + 1) * (stack + 1) + slice);
                        indices.Add((Slices + 1) * (stack + 1) + slice + 1);
                    }
                }
            }
        }
Esempio n. 22
0
        protected override void Generate(DependencyPropertyChangedEventArgs args,
                                         Point3DCollection lines)
        {
            lines.Clear();

            txtgen.Font                = Font;
            txtgen.FontSize            = FontSize;
            txtgen.Rounding            = Rounding;
            txtgen.Thickness           = Thickness;
            txtgen.BaselineDirection   = BaselineDirection;
            txtgen.Origin              = Origin;
            txtgen.UpDirection         = UpDirection;
            txtgen.VerticalAlignment   = VerticalAlignment;
            txtgen.HorizontalAlignment = HorizontalAlignment;

            txtgen.Generate(lines, Text);
        }
Esempio n. 23
0
        public void UnverformteGeometrie(Model3DGroup modelGroup, bool volumen)
        {
            var mesh = new MeshGeometry3D();

            foreach (var item in modell.Elemente)
            {
                var punkte = new Point3DCollection();
                punktDictionary.Clear();
                punkte.Clear();
                foreach (var knotenId in item.Value.NodeIds)
                {
                    if (modell.Knoten.TryGetValue(knotenId, out var knoten))
                    {
                        punkte.Add(new Point3D(knoten.Coordinates[0], -knoten.Coordinates[2], knoten.Coordinates[1]));
                    }
                }

                ErzeugQuader(mesh, punkte);

                if (volumen)
                {
                    // Erzeugung des Oberflächenmodells
                    // Darstellung des Materials des Oberflächenmodells in LightGreen
                    var surfaceMaterial = new DiffuseMaterial(Brushes.LightGreen);
                    oberflächenModell = new GeometryModel3D(mesh, surfaceMaterial)
                    {
                        BackMaterial = surfaceMaterial
                    };
                    // Sichtbarkeit der Oberfläche von beiden Seiten
                    // Hinzufügen des Modells zur Modellgruppe
                    modelGroup.Children.Add(oberflächenModell);

                    oberflächen.Add(oberflächenModell);
                }

                // Erzeugung des Drahtmodells, thickness (Wichte der kanten) = 0.02
                const double kantenwichte      = 0.02;
                var          wireframe         = mesh.ToWireframe(kantenwichte);
                var          wireframeMaterial = new DiffuseMaterial(Brushes.Black);
                drahtModell = new GeometryModel3D(wireframe, wireframeMaterial);
                modelGroup.Children.Add(drahtModell);

                kanten.Add(drahtModell);
            }
        }
Esempio n. 24
0
        public void ClearViewport()
        {
            Machine.Clear();
            linePoints.Clear();
            rapidPoints.Clear();
            retractPoints.Clear();

            if (Machine.BoundingBox != null)
            {
                viewport.Children.Remove(Machine.BoundingBox);
            }

            if (Machine.Grid != null)
            {
                viewport.Children.Remove(Machine.Grid);
            }

            viewport.Children.Remove(Machine.Axes);
            Machine.Axes.Children.Clear();
        }
Esempio n. 25
0
        void Recalculate()
        {
            GeometryModel3D   model  = Content as GeometryModel3D;
            MeshGeometry3D    mesh   = model.Geometry as MeshGeometry3D;
            Point3DCollection points = mesh.Positions;

            mesh.Positions = null;
            points.Clear();

            Int32Collection indices = mesh.TriangleIndices;

            mesh.TriangleIndices = null;
            indices.Clear();

            int indicesBase         = 0;
            Point3DCollection lines = LineCollection;

            for (int line = 0; line < lines.Count - 1; line += 2)
            {
                Point3D pt1 = lines[line + 0];
                Point3D pt2 = lines[line + 1];

                DoLine(pt1, pt2, points, indices, ref indicesBase);

                if (line == 0 &&
                    (ArrowEnds & ArrowEnds.Start) == ArrowEnds.Start)
                {
                    DoArrow(pt2, pt1, points, indices, ref indicesBase);
                }

                if (line > lines.Count - 4 &&
                    (ArrowEnds & ArrowEnds.End) == ArrowEnds.End)
                {
                    DoArrow(pt1, pt2, points, indices, ref indicesBase);
                }
            }

            mesh.TriangleIndices = indices;
            mesh.Positions       = points;
        }
Esempio n. 26
0
        public static Point3DCollection RotatePoint3DCollection(Point3DCollection p, Matrix3D m)
        {
            /*Matrix3D m = new Matrix3D(
             *  1,0, 0, 0,
             *  0,1, 0, 0,
             *  0, 0, 1, 0,
             *  1, 0, 0, 1); //last column */

            int pcSize = p.Count;

            Point3D[] k = new Point3D[pcSize];
            p.CopyTo(k, 0);
            p.Clear();

            m.Transform(k);

            for (int i = 0; i < pcSize; i++)
            {
                p.Add(k[i]);
            }

            return(p);
        }
Esempio n. 27
0
        /// <summary>
        /// Clear out points/triangles and regenerates
        /// </summary>
        ///<param name = "grid" ></ param >
        private void InitializePointsAndTriangles()
        {
            _ptBuffer1.Clear();
            _ptBuffer2.Clear();
            _triangleIndices.Clear();

            int nCurrIndex = 0;     // March through 1-D arrays

            for (int row = 0; row < _dimension; row++)
            {
                for (int col = 0; col < _dimension; col++)
                {
                    // In grid, X/Y values are just row/col numbers
                    _ptBuffer1.Add(new Point3D(col, 0.0, row));

                    // Completing new square, add 2 triangles
                    if ((row > 0) && (col > 0))
                    {
                        // Triangle 1
                        _triangleIndices.Add(nCurrIndex - _dimension - 1);
                        _triangleIndices.Add(nCurrIndex);
                        _triangleIndices.Add(nCurrIndex - _dimension);

                        // Triangle 2
                        _triangleIndices.Add(nCurrIndex - _dimension - 1);
                        _triangleIndices.Add(nCurrIndex - 1);
                        _triangleIndices.Add(nCurrIndex);
                    }

                    nCurrIndex++;
                }
            }

            // 2nd buffer exists only to have 2nd set of Z values
            _ptBuffer2 = _ptBuffer1.Clone();
        }
        public override void UpdateGeometric()
        {
            if (model == null)
            {
                return;
            }

            positions.Clear();
            indices.Clear();
            texcoords.Clear();

            for (int i = 0; i < particles.Count; ++i)
            {
                int      positionIndex = i * 4;
                int      indexIndex    = i * 6;
                Particle p             = particles[i];

                ComputePositions(p, positions);

                texcoords.Add(new System.Windows.Point(0.0, 0.0));
                texcoords.Add(new System.Windows.Point(0.0, 1.0));
                texcoords.Add(new System.Windows.Point(1.0, 1.0));
                texcoords.Add(new System.Windows.Point(1.0, 0.0));

                indices.Add(positionIndex);
                indices.Add(positionIndex + 2);
                indices.Add(positionIndex + 1);
                indices.Add(positionIndex);
                indices.Add(positionIndex + 3);
                indices.Add(positionIndex + 2);
            }

            //((MeshGeometry3D)model.Geometry).Positions = positions;
            //((MeshGeometry3D)model.Geometry).TriangleIndices = indices;
            //((MeshGeometry3D)model.Geometry).TextureCoordinates = texcoords;
        }
Esempio n. 29
0
        /// <summary>
        /// Noktaları / üçgenleri temizleyin ve yeniler
        /// </summary>
        /// <param name="grid"></param>
        private void InitializePointsAndTriangles()
        {
            _ptBuffer1.Clear();
            _ptBuffer2.Clear();
            _triangleIndices.Clear();

            int nCurrIndex = 0;     // March through 1-D arrays

            for (int row = 0; row < _dimension; row++)
            {
                for (int col = 0; col < _dimension; col++)
                {
                    //ızgarada, X / Y değerleri yalnızca satır / sütun sayılarıdır
                    _ptBuffer1.Add(new Point3D(col, 0.0, row));

                    // Yeni kare tamamlandığında, 2 üçgen ekleyin
                    if ((row > 0) && (col > 0))
                    {
                        // Triangle 1
                        _triangleIndices.Add(nCurrIndex - _dimension - 1);
                        _triangleIndices.Add(nCurrIndex);
                        _triangleIndices.Add(nCurrIndex - _dimension);

                        // Triangle 2
                        _triangleIndices.Add(nCurrIndex - _dimension - 1);
                        _triangleIndices.Add(nCurrIndex - 1);
                        _triangleIndices.Add(nCurrIndex);
                    }

                    nCurrIndex++;
                }
            }

            //2. tampon, yalnızca 2. Z değeri setine sahip
            _ptBuffer2 = _ptBuffer1.Clone();
        }
Esempio n. 30
0
        public int GetPoints(int total_points, Point3DCollection points)
        {
            points.Clear();

            // B[1-4, segment, axis]
            double[,,] B = new double[4, m_numPoints - 1, 3];

            // Compute the coefficients
            for (int seg = 0; seg < m_numPoints - 1; seg++)
            {
                for (int axis = 0; axis < 3; axis++)
                {
                    double tmax = m_chordLength[seg];
                    B[0, seg, axis] = GetCoord(m_points[seg], axis);
                    B[1, seg, axis] = m_b_matrix[seg, axis];
                    B[2, seg, axis] = 3 / (tmax * tmax) * (GetCoord(m_points[seg + 1], axis) - GetCoord(m_points[seg], axis))
                                      - 2 / tmax * m_b_matrix[seg, axis]
                                      - 1.0 / tmax * m_b_matrix[seg + 1, axis];
                    B[3, seg, axis] = 2 / (tmax * tmax * tmax) * (GetCoord(m_points[seg], axis) - GetCoord(m_points[seg + 1], axis))
                                      + 1.0 / (tmax * tmax) * m_b_matrix[seg, axis]
                                      + 1.0 / (tmax * tmax) * m_b_matrix[seg + 1, axis];
                }
            }

            int pointsPerSegment = (total_points - 1) / (m_numPoints - 1);

            int index = 0;

            for (int seg = 0; seg < m_numPoints - 1; seg++)
            {
                double tmax = m_chordLength[seg];

                for (int point = 0; point < pointsPerSegment; point++)
                {
                    double t = point * tmax / pointsPerSegment;

                    Point3D loc = new Point3D();

                    loc.X = B[0, seg, 0] +
                            B[1, seg, 0] * t +
                            B[2, seg, 0] * t * t +
                            B[3, seg, 0] * t * t * t;

                    loc.Y = B[0, seg, 1] +
                            B[1, seg, 1] * t +
                            B[2, seg, 1] * t * t +
                            B[3, seg, 1] * t * t * t;

                    loc.Z = B[0, seg, 2] +
                            B[1, seg, 2] * t +
                            B[2, seg, 2] * t * t +
                            B[3, seg, 2] * t * t * t;

                    points.Add(loc);
                    index++;
                }
            }

            // Set the end point
            points.Add(m_points[m_numPoints - 1]);

            return(index + 1);
        }