Click or drag to resize
Ab4d.SharpEngine 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
  Ab4d.SharpEngine.UtilitiesSlicer

Namespace: Ab4d.SharpEngine.Utilities
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 4.0.9584+ba1aaa26d4181dd3fa8ed7b6398391d1affa36c8
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(StandardMesh, Boolean), GetProjectedIntersectionPoints(StandardMesh, Boolean, Vector2, Vector2), GetProjectedIntersectionPoints(StandardMesh, Boolean), GetProjectedIntersectionPolylines(StandardMesh, Boolean), GetProjectedIntersectionPolylines(StandardMesh, Boolean, Vector2, Vector2), GetClosedSliceMesh(StandardMesh, Boolean). If those methods are not called, then this property can be set to false to prevent saving intersection positions.
Public propertyDuplicatePositionsPrecisionBitsCount Gets or sets a number of bits in the uint value that are used to hash the positions when the code combines duplicate positions (used to generate closed mesh). See remarks for more info.
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 Vector3 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 Vector3 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 StandardMesh 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 returns 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(StandardMesh, 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(StandardMesh, Boolean, Vector2, Vector2) 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(StandardMesh, 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(StandardMesh, Boolean, Vector2, Vector2), GetProjectedIntersectionPoints(StandardMesh, Boolean) to get individual intersection lines.
Public methodGetProjectedIntersectionPolylines(StandardMesh, Boolean, Vector2, Vector2) 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(StandardMesh, Boolean, Vector2, Vector2), GetProjectedIntersectionPoints(StandardMesh, Boolean) to get individual intersection lines.
Public methodSliceGroupNode(GroupNode, Transform) Slices the specified GroupNode with the specified Plane and returns a GroupNode that is in front of the plane (in the direction of plane's Normal vector). If the specified GroupNode is fully in front of the plane, then the same instance of GroupNode is returned. If the specified GroupNode is fully in back of the plane, then null is returned. If the specified GroupNode intersects the Plane, it is sliced and new front GroupNode object is returned.
Public methodSliceGroupNode(GroupNode, GroupNode, GroupNode) Slices the specified GroupNode with the specified Plane and creates two new GroupNode objects: one GroupNode that is in front of the plane (in the direction of plane's Normal vector) and one GroupNode that is in the back of the plane. If the specified GroupNode is fully in front (or in back) of the Plane, then the same instance of GroupNode is returned (the other returned GroupNode is null). If the specified GroupNode intersects the Plane, it is sliced and new GroupNode objects are created from it.
Public methodSliceGroupNode(GroupNode, Transform, GroupNode, GroupNode) Slices the specified GroupNode with the specified Plane and creates two new GroupNode objects: one GroupNode that is in front of the plane (in the direction of plane's Normal vector) and one GroupNode that is in the back of the plane. If the specified GroupNode is fully in front (or in back) of the Plane, then the same instance of GroupNode is returned (the other returned GroupNode is null). If the specified GroupNode intersects the Plane, it is sliced and new GroupNode objects are created from it.
Public methodSliceMesh(StandardMesh, Transform) Slices the specified StandardMesh with the specified Plane and returns a StandardMesh that is in front of the plane (in the direction of plane's Normal vector). If the specified StandardMesh is fully in front of the plane, then the same instance of StandardMesh is returned. If the specified StandardMesh is fully in back of the plane, then null is returned. If the specified StandardMesh intersects the Plane, it is sliced and new front StandardMesh object is returned.
Public methodSliceMesh(StandardMesh, StandardMesh, StandardMesh) Slices the specified StandardMesh with the specified Plane and creates two new StandardMesh objects: one StandardMesh that is in front of the plane (in the direction of plane's Normal vector) and one StandardMesh that is in the back of the plane. If the specified StandardMesh is fully in front (or in back) of the Plane, then the same instance of StandardMesh is returned (the other returned StandardMesh is null). If the specified StandardMesh intersects the Plane, it is sliced and new StandardMesh objects are created from it.
Public methodSliceMesh(StandardMesh, Transform, StandardMesh, StandardMesh) Slices the specified StandardMesh with the specified Plane and creates two new StandardMesh objects: one StandardMesh that is in front of the plane (in the direction of plane's Normal vector) and one StandardMesh that is in the back of the plane. If the specified StandardMesh is fully in front (or in back) of the Plane, then the same instance of StandardMesh is returned (the other returned StandardMesh is null). If the specified StandardMesh intersects the Plane, it is sliced and new StandardMesh objects are created from it.
Public methodSliceModelNode(ModelNode, Transform) Slices the specified ModelNode with the specified Plane and returns a ModelNode that is in front of the plane (in the direction of plane's Normal vector). If the specified ModelNode is fully in front of the plane, then the same instance of ModelNode is returned. If the specified ModelNode is fully in back of the plane, then null is returned. If the specified ModelNode intersects the Plane, it is sliced and new front ModelNode object is returned.
Public methodSliceModelNode(ModelNode, MeshModelNode, MeshModelNode) Slices the specified ModelNode with the specified Plane and creates two new ModelNode objects: one ModelNode that is in front of the plane (in the direction of plane's Normal vector) and one ModelNode that is in the back of the plane. If the specified ModelNode is fully in front (or in back) of the Plane, then the same instance of ModelNode is returned (the other returned ModelNode is null). If the specified ModelNode intersects the Plane, it is sliced and new ModelNode objects are created from it.
Public methodSliceModelNode(ModelNode, Transform, MeshModelNode, MeshModelNode) Slices the specified ModelNode with the specified Plane and creates two new ModelNode objects: one ModelNode that is in front of the plane (in the direction of plane's Normal vector) and one ModelNode that is in the back of the plane. If the specified ModelNode is fully in front (or in back) of the Plane, then the same instance of ModelNode is returned (the other returned ModelNode is null). If the specified ModelNode intersects the Plane, it is sliced and new ModelNode objects are created from it.
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 methodSliceSceneNode(SceneNode, Transform) Slices the specified SceneNode with the specified Plane and returns a SceneNode that is in front of the plane (in the direction of plane's Normal vector). If the specified SceneNode is fully in front of the plane, then the same instance of SceneNode is returned. If the specified SceneNode is fully in back of the plane, then null is returned. If the specified SceneNode intersects the Plane, it is sliced and new front SceneNode object is returned.
Public methodSliceSceneNode(SceneNode, SceneNode, SceneNode) Slices the specified SceneNode with the specified Plane and creates two new SceneNode objects: one SceneNode that is in front of the plane (in the direction of plane's Normal vector) and one SceneNode that is in the back of the plane. If the specified SceneNode is fully in front (or in back) of the Plane, then the same instance of SceneNode is returned (the other returned SceneNode is null). If the specified SceneNode intersects the Plane, it is sliced and new SceneNode objects are created from it.
Public methodSliceSceneNode(SceneNode, Transform, SceneNode, SceneNode) Slices the specified SceneNode with the specified Plane and creates two new SceneNode objects: one SceneNode that is in front of the plane (in the direction of plane's Normal vector) and one SceneNode that is in the back of the plane. If the specified SceneNode is fully in front (or in back) of the Plane, then the same instance of SceneNode is returned (the other returned SceneNode is null). If the specified SceneNode intersects the Plane, it is sliced and new SceneNode objects are created from it.
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