コード例 #1
0
 public static void Split(MeshGeometry3D mesh, Plane3D plane, out MeshGeometry3D above, out MeshGeometry3D below)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
 public static void Split(MeshGeometry3D mesh, Plane3D plane, out MeshGeometry3D above, out MeshGeometry3D below)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
        /// <summary>
        /// Chamfers the specified corner (experimental code).
        /// </summary>
        /// <param name="p">The corner point.</param>
        /// <param name="d">The chamfer distance.</param>
        /// <param name="eps">The corner search limit distance.</param>
        /// <param name="chamferPoints">If this parameter is provided, the collection will be filled with the generated chamfer points.</param>
        public void ChamferCorner(Point3D p, double d, double eps = 1e-6, ICollection<Point3D> chamferPoints = null)
        {
            NoSharedVertices();

            normals = null;
            textureCoordinates = null;

            var cornerNormal = FindCornerNormal(p, eps);

            var newCornerPoint = p - cornerNormal * d;
            int index0 = positions.Count;
            positions.Add(newCornerPoint);

            var plane = new Plane3D(newCornerPoint, cornerNormal);

            int ntri = triangleIndices.Count;

            for (int i = 0; i < ntri; i += 3)
            {
                int i0 = i;
                int i1 = i + 1;
                int i2 = i + 2;
                var p0 = positions[triangleIndices[i0]];
                var p1 = positions[triangleIndices[i1]];
                var p2 = positions[triangleIndices[i2]];
                double d0 = (p - p0).LengthSquared;
                double d1 = (p - p1).LengthSquared;
                double d2 = (p - p2).LengthSquared;
                double mind = Math.Min(d0, Math.Min(d1, d2));
                if (mind > eps)
                    continue;
                if (d1 < eps)
                {
                    i0 = i + 1;
                    i1 = i + 2;
                    i2 = i;
                }
                if (d2 < eps)
                {
                    i0 = i + 2;
                    i1 = i;
                    i2 = i + 1;
                }

                p0 = positions[triangleIndices[i0]];
                p1 = positions[triangleIndices[i1]];
                p2 = positions[triangleIndices[i2]];

                // p0 is the corner vertex (at index i0)
                // find the intersections between the chamfer plane and the two edges connected to the corner
                var p01 = plane.LineIntersection(p0, p1);
                var p02 = plane.LineIntersection(p0, p2);

                if (p01 == Plane3D.InPlane || p01 == Plane3D.NoIntersection)
                    continue;
                if (p02 == Plane3D.InPlane || p02 == Plane3D.NoIntersection)
                    continue;

                if (chamferPoints != null)
                {
                    // add the chamfered points
                    if (!chamferPoints.Contains(p01))
                        chamferPoints.Add(p01);
                    if (!chamferPoints.Contains(p02))
                        chamferPoints.Add(p02);
                }

                int i01 = i0;
                // change the original triangle to use the first chamfer point
                positions[triangleIndices[i01]] = p01;

                int i02 = positions.Count;
                positions.Add(p02);
                // add a new triangle for the other chamfer point
                triangleIndices.Add(i01);
                triangleIndices.Add(i2);
                triangleIndices.Add(i02);

                // add a triangle connecting the chamfer points and the new corner point
                triangleIndices.Add(index0);
                triangleIndices.Add(i01);
                triangleIndices.Add(i02);
            }

            NoSharedVertices();
        }