public static Cut ( System.Windows.Media.Media3D.MeshGeometry3D mesh, System.Windows.Media.Media3D.Point3D p, System.Windows.Media.Media3D.Vector3D n ) : System.Windows.Media.Media3D.MeshGeometry3D | ||
mesh | System.Windows.Media.Media3D.MeshGeometry3D | /// The mesh. /// |
p | System.Windows.Media.Media3D.Point3D | /// The plane origin. /// |
n | System.Windows.Media.Media3D.Vector3D | /// The plane normal. /// |
return | System.Windows.Media.Media3D.MeshGeometry3D |
/// <summary> /// Applies the cutting planes to the model. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="transform"> /// The transform. /// </param> private void ApplyCuttingPlanesToModel(GeometryModel3D model, Transform3D transform) { if (model.Geometry == null) { return; } bool updateRequired = this.forceUpdate; if (!this.IsEnabled) { updateRequired = true; } Geometry3D cutGeometry; if (this.CutGeometries.TryGetValue(model, out cutGeometry)) { if (cutGeometry != model.Geometry) { updateRequired = true; } } Geometry3D originalGeometry; if (!this.OriginalGeometries.TryGetValue(model, out originalGeometry)) { originalGeometry = model.Geometry; updateRequired = true; } this.NewOriginalGeometries.Add(model, originalGeometry); if (!updateRequired) { return; } var g = originalGeometry as MeshGeometry3D; if (this.IsEnabled) { var inverseTransform = transform.Inverse; foreach (var cp in this.CuttingPlanes) { var p = inverseTransform.Transform(cp.Position); var p2 = inverseTransform.Transform(cp.Position + cp.Normal); var n = p2 - p; // var p = transform.Transform(cp.Position); // var n = transform.Transform(cp.Normal); g = MeshGeometryHelper.Cut(g, p, n); } } model.Geometry = g; this.NewCutGeometries.Add(model, g); }
/// <summary> /// Intersects the specified source mesh geometry with the specified plane. /// </summary> /// <param name="source">The source.</param> /// <param name="inverseTransform">The inverse transform of the source.</param> /// <param name="plane">The plane.</param> /// <param name="complement">Cut with the complement set if set to <c>true</c>.</param> /// <returns>The intersected geometry.</returns> private MeshGeometry3D Intersect(MeshGeometry3D source, GeneralTransform3D inverseTransform, Plane3D plane, bool complement) { var p = inverseTransform.Transform(plane.Position); var p2 = inverseTransform.Transform(plane.Position + plane.Normal); var n = p2 - p; if (complement) { n *= -1; } return(MeshGeometryHelper.Cut(source, p, n)); }