Click or drag to resize
AB4D logo

Slicer Class

Slicer class can slice 3D model with a 3D plane and generate front and back models. It can also generate the sliced polygon lines and sliced mesh that line on the slice plane. This class use internal collections so the same instance cannot be used in multiple threads (create one Slicer instance per thread for multi-threaded slicing).
Inheritance Hierarchy
SystemObject
  Ab3d.UtilitiesSlicer

Namespace: Ab3d.Utilities
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 12.0.9484.2048
Syntax
C#
public class Slicer

The Slicer type exposes the following members.

Constructors
 NameDescription
Public methodSlicer Constructor with default Plane with Normal: (0, 1, 0) and D: 0.
Public methodSlicer(Plane) Constructor
Top
Properties
 NameDescription
Public propertyCloseSlicedMeshes Gets or sets a Boolean that specifies if the sliced meshes are closed so that the inner triangles are not visible. Default value is false.
Public propertyCollectIntersectionPoints Gets or sets a Boolean that specified is this Slicer class collects the intersection positions between the 3D model and 3D plane. By default, this value is set to true. This allows calling GetIntersectionPoints(MeshGeometry3D, Boolean), GetProjectedIntersectionPoints(MeshGeometry3D, Boolean, Rect), GetProjectedIntersectionPoints(MeshGeometry3D, Boolean), GetProjectedIntersectionPolylines(MeshGeometry3D, Boolean), GetProjectedIntersectionPolylines(MeshGeometry3D, Boolean, Rect), GetClosedSliceMesh(MeshGeometry3D, Boolean). If those methods are not called, then this property can be set to false to prevent saving intersection positions.
Public propertyFixPolylineOrientation Gets or sets a Boolean that specifies if polygon orientation is fixed so that the outer polygons are defined in clock-wise direction and inner polygons are defined in counter-clockwise direction. This is required to correctly triangulate shapes with holes.
Public propertyHasBrokenIntersectionPolylines Gets a Boolean that is set to true after calling any Slice method when the intersected mesh cannot form a closed polygon and close the mesh.
Public propertyPlane Plane that is used to slice the 3D models.
Public propertyPlaneUpVector PlaneUpVector is a Vector3D that defines the y-axis direction of the plane. This value is automatically calculated from the Plane's normal, but can be set by the user to provide a custom direction.
Public propertyPlaneWidthVector PlaneWidthVector is a Vector3D that defines the x-axis direction of the plane. This value is automatically calculated from the Plane's normal, but can be set by the user to provide a custom direction.
Top
Methods
 NameDescription
Public methodGetClosedSliceMesh GetClosedSliceMesh can be called after any Slice method is called and returns a MeshGeometry3D that lies on the plane. When the closed intersection polygon cannot be created, then the HasBrokenIntersectionPolylines is set to true. In this case this method return null.
Public methodGetIntersectionPoints GetIntersectionPoints can be called after any Slice method is called and returns the 3D intersection points for the specified mesh.
Public methodGetProjectedIntersectionPoints(MeshGeometry3D, Boolean) GetProjectedIntersectionPoints can be called after any Slice method is called and returns the 2D intersection points that lie on the plane. Each intersection line is defined by two consecutive points.
Public methodGetProjectedIntersectionPoints(MeshGeometry3D, Boolean, Rect) GetProjectedIntersectionPoints can be called after any Slice method is called and returns the 2D intersection points that lie on the plane. Each intersection line is defined by two consecutive points.
Public methodGetProjectedIntersectionPolylines(MeshGeometry3D, Boolean) GetProjectedIntersectionPolylines can be called after any Slice method is called and returns an array of 2D intersection polygon lines that lie on the plane. The polygon is defined by connected points. When the closed polygon cannot be created, then the HasBrokenIntersectionPolylines is set to true. In this case you need to call GetProjectedIntersectionPoints(MeshGeometry3D, Boolean, Rect), GetProjectedIntersectionPoints(MeshGeometry3D, Boolean) to get individual intersection lines.
Public methodGetProjectedIntersectionPolylines(MeshGeometry3D, Boolean, Rect) GetProjectedIntersectionPolylines can be called after any Slice method is called and returns an array of 2D intersection polygon lines that lie on the plane. The polygon is defined by connected points. When the closed polygon cannot be created, then the HasBrokenIntersectionPolylines is set to true. In this case you need to call GetProjectedIntersectionPoints(MeshGeometry3D, Boolean, Rect), GetProjectedIntersectionPoints(MeshGeometry3D, Boolean) to get individual intersection lines.
Public methodSliceGeometryModel3D(GeometryModel3D, Transform3D) Slices the 3D model defined by GeometryModel3D with this Plane. If the geometryModel3D is fully in front of the Plane (in the direction of plane's Normal vector), then the same geometryModel3D is returned. If geometryModel3D intersects the plane, then a new sliced GeometryModel3D is returned. If geometryModel3D is in the back of the plane, then null is returned.
Public methodSliceGeometryModel3D(GeometryModel3D, GeometryModel3D, GeometryModel3D) Slices the 3D model defined by GeometryModel3D with this Plane and creates two new GeometryModel3D objects: one with model that are in front of the plane (in the direction of plane's Normal vector) and one with model in the back of the plane. If model is fully in front (or in back) of the Plane, the the same instance of GeometryModel3D is used. If the model intersects the Plane, it is sliced and new models are created from it.
Public methodSliceGeometryModel3D(GeometryModel3D, Transform3D, GeometryModel3D, GeometryModel3D) Slices the 3D model defined by GeometryModel3D with this Plane and creates two new GeometryModel3D objects: one with model that are in front of the plane (in the direction of plane's Normal vector) and one with model in the back of the plane. If model is fully in front (or in back) of the Plane, the the same instance of GeometryModel3D is used. If the model intersects the Plane, it is sliced and new models are created from it.
Public methodSliceMeshGeometry3D(MeshGeometry3D, Transform3D) Slices the MeshGeometry3D with this Plane. If the meshGeometry3D is fully in front of the Plane (in the direction of plane's Normal vector), then the same meshGeometry3D is returned. If meshGeometry3D intersects the plane, then a new sliced MeshGeometry3D is returned. If meshGeometry3D is in the back of the plane, then null is returned.
Public methodSliceMeshGeometry3D(MeshGeometry3D, MeshGeometry3D, MeshGeometry3D) Slices the MeshGeometry3D with this Plane and creates two new MeshGeometry3D objects: one with MeshGeometry3D that are in front of the plane (in the direction of plane's Normal vector) and one with MeshGeometry3D in the back of the plane. If MeshGeometry3D is fully in front (or in back) of the Plane, the the same instance of MeshGeometry3D is used. If the MeshGeometry3D intersects the Plane, it is sliced and new MeshGeometry3D objects are created from it.
Public methodSliceMeshGeometry3D(MeshGeometry3D, Transform3D, MeshGeometry3D, MeshGeometry3D) Slices the MeshGeometry3D with this Plane and creates two new MeshGeometry3D objects: one with MeshGeometry3D that are in front of the plane (in the direction of plane's Normal vector) and one with MeshGeometry3D in the back of the plane. If MeshGeometry3D is fully in front (or in back) of the Plane, the the same instance of MeshGeometry3D is used. If the MeshGeometry3D intersects the Plane, it is sliced and new MeshGeometry3D objects are created from it.
Public methodSliceModel3D(Model3D, Transform3D) Slices the 3D models defined by model3D (GeometryModel3D or Model3DGroup) with this Plane and returns a new ModelVisual3D with models that are in front of the plane (in the direction of plane's Normal vector). The models that are fully in front of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSliceModel3D(Model3D, Model3D, Model3D) Slices the 3D models defined by model3D (GeometryModel3D or Model3DGroup) with this Plane and creates two new Model3D objects: one with models that are in front of the plane (in the direction of plane's Normal vector) and one with models in the back of the plane. The models that are fully in front (or in back) of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSliceModel3D(Model3D, Transform3D, Model3D, Model3D) Slices the 3D models defined by model3D (GeometryModel3D or Model3DGroup) with this Plane and creates two new Model3D objects: one with models that are in front of the plane (in the direction of plane's Normal vector) and one with models in the back of the plane. The models that are fully in front (or in back) of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSliceModel3DGroup(Model3DGroup, Transform3D) Slices the 3D models defined by Model3DGroup with this Plane and returns a new Model3DGroup with models that are in front of the plane (in the direction of plane's Normal vector). The models that are fully in front of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSliceModel3DGroup(Model3DGroup, Model3DGroup, Model3DGroup) Slices the 3D models defined by Model3DGroup with this Plane and creates two new Model3DGroup objects: one with models that are in front of the plane (in the direction of plane's Normal vector) and one with models in the back of the plane. The models that are fully in front (or in back) of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSliceModel3DGroup(Model3DGroup, Transform3D, Model3DGroup, Model3DGroup) Slices the 3D models defined by Model3DGroup with this Plane and creates two new Model3DGroup objects: one with models that are in front of the plane (in the direction of plane's Normal vector) and one with models in the back of the plane. The models that are fully in front (or in back) of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSliceModelVisual3D(ModelVisual3D, Transform3D) Slices the 3D models defined by ModelVisual3D with this Plane and returns a new ModelVisual3D with models that are in front of the plane (in the direction of plane's Normal vector). The models that are fully in front of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSliceModelVisual3D(ModelVisual3D, ModelVisual3D, ModelVisual3D) Slices the 3D models defined by ModelVisual3D with this Plane and creates two new ModelVisual3D objects: one with models that are in front of the plane (in the direction of plane's Normal vector) and one with models in the back of the plane. The models that are fully in front (or in back) of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSliceModelVisual3D(ModelVisual3D, Transform3D, ModelVisual3D, ModelVisual3D) Slices the 3D models defined by ModelVisual3D with this Plane and creates two new ModelVisual3D objects: one with models that are in front of the plane (in the direction of plane's Normal vector) and one with models in the back of the plane. The models that are fully in front (or in back) of the Plane are not changed (the same instances are used). The models that intersect the Plane are sliced and new models are created from them.
Public methodSlicePolygon Slices the polygon specified with polygonPositions with this Plane and adds the positions that are in front of the plane to the frontPositions list and positions in the back of the plane to the backPositions list.
Public methodSliceTriangle Slices the triangle specified with p1, p2 and p3 with this Plane and adds the positions that are in front of the plane to the frontPositions list and positions in the back of the plane to the backPositions list. When triangulate is true, this method creates 4 triangles; when triangulate is false, this method creates 1 triangle and 1 four-sided polygon.
Public methodTransformPlane Transforms the Plane that is used by this Slicer.
Top
See Also