#include <mnmesh.h>
Provides a number of utility functions for working with MNMesh.
Public Member Functions | |
MNMeshUtilities (MNMesh *mesh) | |
Constructor. More... | |
DllExport bool | GetBorderFromEdge (int edge, Tab< int > &border) |
Given a one-sided edge in the MNMesh, retrieves the border loop which that edge forms with other one-sided edges. More... | |
DllExport bool | AutoSmooth (float threshold, DWORD faceFlag) |
Applies new smoothing groups to the MNMesh, smoothing between any faces that share an edge with an edge angle less than "threshold". More... | |
DllExport bool | AutoSmoothIsland (float threshold, DWORD faceFlag) |
Applies new smoothing groups to the MNMesh, smoothing between any faces that share an edge with an edge angle less than "threshold", but unsmooths any edges on the border of the flagged face group. More... | |
DllExport bool | FlipHingeAngle (Point3 &origin, Point3 &axis, int hingeEdge, DWORD faceFlag) |
Indicates whether the hinge angle should be multiplied by -1, based on the local topology and geometry of the mesh. More... | |
DllExport bool | HingeFromEdge (Point3 &origin, Point3 &axis, float angle, int segments, MNFaceClusters &fclust, int clusterID) |
New version of old "MNMesh::LiftFaceClusterFromEdge" method which doesn't require a hinge edge. More... | |
DllExport bool | MakeFlaggedPlanar (int selLev, DWORD flag, float *softSel, Point3 *delta=NULL) |
Determines an average plane of the flagged subobjects, and moves vertices toward it according to their soft selection value. More... | |
DllExport bool | MoveVertsToPlane (Point3 &norm, float offset, float *softSel, Point3 *delta=NULL) |
Moves soft-selected vertices toward the plane given according to their soft selection value, or produces an array of offsets which would do so. More... | |
DllExport bool | CollapseEdges (DWORD edgeFlag) |
Edge-based collapse function - all edges with the given flag will be collapsed, which means their vertex endpoints will be joined into a single vertex. More... | |
DllExport bool | CollapseEdges (DWORD edgeFlag, Tab< int > &pointDest) |
Edge-based collapse function - all edges with the given flag will be collapsed, which means their vertex endpoints will be joined into a single vertex. More... | |
DllExport void | ConstrainDeltaToEdges (Tab< Point3 > *deltaIn, Tab< Point3 > *deltaOut) |
Constrains the vectors given for each vertex so that they are limited to travel along a neighboring edge. More... | |
DllExport void | ConstrainDeltaToFaces (Tab< Point3 > *deltaIn, Tab< Point3 > *deltaOut) |
Constrains the vectors given for each vertex so that they are limited to travel along a neighboring face. More... | |
DllExport bool | ExtrudeOpenEdges (DWORD edgeFlag, bool clearFlagOnOldEdges, bool useTracking) |
Extrude method which creates new faces along open edges. More... | |
DllExport bool | BridgeBorders (int edge1, int twist1, int edge2, int twist2, float smoothThresh, int segments, float taper, float bias) |
Creates a bridge between two border loops. More... | |
DllExport bool | BridgePolygons (int face1, int twist1, int face2, int twist2, float smoothThresh, int segments, float taper, float bias) |
Creates a bridge between two polygons. More... | |
DllExport bool | BridgePolygonClusters (DWORD polyFlag, float smoothThresh, int segments, float taper, float bias, int twist1, int twist2) |
Creates bridges between polygon clusters. More... | |
DllExport bool | BridgePolygonsClusters_2015 (DWORD polyFlag, float smoothThresh, int segments, float taper, float bias, int twist1, int twist2) |
Identical to BridgePolygonsClusters but should only be used to load parametric bridges from 2015 and lower. More... | |
DllExport bool | BridgeSelectedBorders (DWORD edgeFlag, float smoothThresh, int segments, float taper, float bias, int twist1, int twist2) |
Creates bridges between flagged borders. More... | |
DllExport int | FindDefaultBridgeTwist (int face1, int face2) |
Returns a good default twist for face2, when bridging between face1 and face2 with no twist for face1. More... | |
DllExport bool | TurnDiagonal (int face, int diagonal) |
"Turns" the diagonal by removing it and creating a new one going across it. More... | |
DllExport bool | Relax (DWORD vertexFlag, float *softSel, float relaxAmount, int relaxIters, bool holdBoundaryPts, bool holdOuterPts, Point3 *delta=NULL) |
This is a new version of the MNMesh::Relax method, which is designed to move all vertices a little closer to their neighbors. More... | |
DllExport int | SelectPolygonsByAngle (int startPolygon, float angle, BitArray &polySel) |
Starting with the polygon given, this algorithm creates a BitArray selection of all polygons it can get to without crossing any edges whose angle is greater than the angle given. More... | |
DllExport void | CutPrepare () |
This method is used at the beginning of a series of cuts. More... | |
DllExport void | CutCleanup () |
This method is used after a series of cuts, to "clean up" any extra edges which are necessary to have. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from MaxHeapOperators | |
static UtilExport void * | operator new (size_t size) |
Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e) |
Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new (size_t size, const char *filename, int line) |
New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, int block_type, const char *filename, int line) |
New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e, const char *filename, int line) |
New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new (size_t size, unsigned long flags) |
New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e, unsigned long flags) |
New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size, const char *filename, int line) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, int block_type, const char *filename, int line) |
New operator used to allocate arrays of objects. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size, unsigned long flags) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e, unsigned long flags) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void | operator delete (void *ptr) |
Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e) |
Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete (void *ptr, const char *filename, int line) |
Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, int block_type, const char *filename, int line) |
Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line) |
Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete (void *ptr, unsigned long flags) |
Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags) |
Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr) |
Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e) |
Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, int block_type, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr, unsigned long flags) |
Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags) |
Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, void *placement_ptr) |
Placement new operator. More... | |
static UtilExport void | operator delete (void *ptr, void *placement_ptr) |
Placement delete operator. More... | |
|
inline |
Constructor.
Takes MNMesh pointer, which is the mesh that is operated upon in all MNMeshUtilities methods.
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
Given a one-sided edge in the MNMesh, retrieves the border loop which that edge forms with other one-sided edges.
The border loop produced will be in sequential order going CCW around the hole, starting with the edge given.
edge | The edge to start from. (If it is not a border edge, the "border" table will be left empty. |
border | A reference to a table into which the border loop edge indices can be written. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool AutoSmooth | ( | float | threshold, |
DWORD | faceFlag | ||
) |
Applies new smoothing groups to the MNMesh, smoothing between any faces that share an edge with an edge angle less than "threshold".
threshold | The threshold angle for smoothing across edges, in radians. |
faceFlag | If nonzero, this indicates that only faces with this flag set should have their smoothing groups affected. (If faceFlag has multiple bits set, any flag matches are considered a match.) |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool AutoSmoothIsland | ( | float | threshold, |
DWORD | faceFlag | ||
) |
Applies new smoothing groups to the MNMesh, smoothing between any faces that share an edge with an edge angle less than "threshold", but unsmooths any edges on the border of the flagged face group.
If faceFlag is zero, this works just like AutoSmooth – no border to leave unsmoothed.
threshold | The threshold angle for smoothing across edges, in radians. |
faceFlag | If nonzero, this indicates that only faces with this flag set should have their smoothing groups affected. (If faceFlag has multiple bits set, any flag matches are considered a match.) |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
Indicates whether the hinge angle should be multiplied by -1, based on the local topology and geometry of the mesh.
When users pick hinge edges, they may pick edges oriented in either direction, with the result that rotating around the edge by the hinge angle can produce inconsistent results. This method analyses the hinge orientation and indicates whether a correction should occur.
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool HingeFromEdge | ( | Point3 & | origin, |
Point3 & | axis, | ||
float | angle, | ||
int | segments, | ||
MNFaceClusters & | fclust, | ||
int | clusterID | ||
) |
New version of old "MNMesh::LiftFaceClusterFromEdge" method which doesn't require a hinge edge.
Does a "hinged extrusion", where selected face clusters are rotated around a hinge axis, and new faces are created connecting the selected faces to the unselected ones.
origin | The origin point for the hinge |
axis | The axis direction for the hinge |
angle | The amount to rotate, in radians |
segments | The number of segments for the sides of the extrusion |
fclust | The current set of Face Clusters |
clusterID | The ID of the cluster to rotate |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
Determines an average plane of the flagged subobjects, and moves vertices toward it according to their soft selection value.
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool MoveVertsToPlane | ( | Point3 & | norm, |
float | offset, | ||
float * | softSel, | ||
Point3 * | delta = NULL |
||
) |
Moves soft-selected vertices toward the plane given according to their soft selection value, or produces an array of offsets which would do so.
(Similar to MNMesh::MoveVertsToPlane, but with soft selection support.)
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool CollapseEdges | ( | DWORD | edgeFlag | ) |
Edge-based collapse function - all edges with the given flag will be collapsed, which means their vertex endpoints will be joined into a single vertex.
edgeFlag | The edge flag that marks the edges to be collapsed. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
Edge-based collapse function - all edges with the given flag will be collapsed, which means their vertex endpoints will be joined into a single vertex.
The pointDest Tab is populated with information about which vertices were collapsed and which vertices they were collapsed onto. If pointDest[i] >= 0, vertex i was collapsed onto vertex pointDest[i]. If pointDest[i] == -1, vertex i was not collapsed. If pointDest[i] < -1, (-pointDest[i]) vertices were collapsed onto vertex i (including itself).
edgeFlag | The edge flag that marks the edges to be collapsed. |
pointDest | The Tab in which to return the collapse information. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
Constrains the vectors given for each vertex so that they are limited to travel along a neighboring edge.
It's acceptable for deltaIn to be equal to deltaOut.
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
Constrains the vectors given for each vertex so that they are limited to travel along a neighboring face.
It's acceptable for deltaIn to be equal to deltaOut.
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool ExtrudeOpenEdges | ( | DWORD | edgeFlag, |
bool | clearFlagOnOldEdges, | ||
bool | useTracking | ||
) |
Extrude method which creates new faces along open edges.
edgeFlag | The edges which should be extruded. (Non-open edges that have this flag set always have it cleared.) |
clearFlagOnOldEdges | If true, the "edgeFlag" is cleared on the edges used as the base of the extrusion. |
useTracking | If true, the new edges at the "top" of the extrusion have their "track" data member set to the edge at the base of their extrusion. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool BridgeBorders | ( | int | edge1, |
int | twist1, | ||
int | edge2, | ||
int | twist2, | ||
float | smoothThresh, | ||
int | segments, | ||
float | taper, | ||
float | bias | ||
) |
Creates a bridge between two border loops.
edge1 | An edge on the first border loop |
twist1 | The twist for the first border loop. (The edge which is "twist1" edges around the loop from "edge1" will be bridged to the edge which is "twist2" edges around the loop from "edge2". |
edge2 | An edge on the second border loop |
twist2 | The twist for the second border loop. (The edge which is "twist1" edges around the loop from "edge1" will be bridged to the edge which is "twist2" edges around the loop from "edge2". |
smoothThresh | The threshold angle, in radians, for smoothing between successive columns of the bridge. |
segments | The number of segments for the bridge |
taper | The amount that the bridge should taper in |
bias | The bias for the location of the most tapered-in spot on the bridge. Range: -100 to 100, with 0 indicating that the taper should fall naturally in the middle of the bridge. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool BridgePolygons | ( | int | face1, |
int | twist1, | ||
int | face2, | ||
int | twist2, | ||
float | smoothThresh, | ||
int | segments, | ||
float | taper, | ||
float | bias | ||
) |
Creates a bridge between two polygons.
face1 | The first polygon |
twist1 | The twist for the first polygon. (The twist1'th edge of polygon face1 will be bridged to the twist2'th edge on polygon face2.) |
face2 | The second polygon |
twist2 | The twist for the second polygon. (The twist1'th edge of polygon face1 will be bridged to the twist2'th edge on polygon face2.) |
smoothThresh | The threshold angle, in radians, for smoothing between successive columns of the bridge. |
segments | The number of segments for the bridge |
taper | The amount that the bridge should taper in |
bias | The bias for the location of the most tapered-in spot on the bridge. Range: -100 to 100, with 0 indicating that the taper should fall naturally in the middle of the bridge. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool BridgePolygonClusters | ( | DWORD | polyFlag, |
float | smoothThresh, | ||
int | segments, | ||
float | taper, | ||
float | bias, | ||
int | twist1, | ||
int | twist2 | ||
) |
Creates bridges between polygon clusters.
polyFlag | The flag indicating faces in the clusters. |
smoothThresh | The threshold angle, in radians, for smoothing between successive columns of the bridge. |
segments | The number of segments for the bridge |
taper | The amount that the bridge should taper in |
bias | The bias for the location of the most tapered-in spot on the bridge. Range: -100 to 100, with 0 indicating that the taper should fall naturally in the middle of the bridge. |
twist1 | The twist for each "start" cluster. |
twist2 | The twist for each "end" cluster. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool BridgePolygonsClusters_2015 | ( | DWORD | polyFlag, |
float | smoothThresh, | ||
int | segments, | ||
float | taper, | ||
float | bias, | ||
int | twist1, | ||
int | twist2 | ||
) |
Identical to BridgePolygonsClusters but should only be used to load parametric bridges from 2015 and lower.
DllExport bool BridgeSelectedBorders | ( | DWORD | edgeFlag, |
float | smoothThresh, | ||
int | segments, | ||
float | taper, | ||
float | bias, | ||
int | twist1, | ||
int | twist2 | ||
) |
Creates bridges between flagged borders.
edgeFlag | Any borders with at least one edge that has this flag set will be considered for bridging. (Only borders that match up in pairs will be bridged, of course.) |
smoothThresh | The threshold angle, in radians, for smoothing between successive columns of the bridge. |
segments | The number of segments for the bridge |
taper | The amount that the bridge should taper in |
bias | The bias for the location of the most tapered-in spot on the bridge. Range: -100 to 100, with 0 indicating that the taper should fall naturally in the middle of the bridge. |
twist1 | The twist for each "start" cluster. |
twist2 | The twist for each "end" cluster. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
Returns a good default twist for face2, when bridging between face1 and face2 with no twist for face1.
Default twist is based on an analysis of local geometry.
face1 | The first polygon |
face2 | The second polygon |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
"Turns" the diagonal by removing it and creating a new one going across it.
This is like the traditional "Turn Edge" in Editable Mesh. (Any "diagonal" in a polygon separates two triangles. If you remove that diagonal, you're left with a quad; this algorithm replaces the original diagonal with the diagonal you'd get by connecting the other two vertices of that quad.)
face | The polygon face in which to turn the diagonal |
diagonal | The index of the diagonal to turn. A polygon of degree "deg" has (deg-3) diagonals. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
DllExport bool Relax | ( | DWORD | vertexFlag, |
float * | softSel, | ||
float | relaxAmount, | ||
int | relaxIters, | ||
bool | holdBoundaryPts, | ||
bool | holdOuterPts, | ||
Point3 * | delta = NULL |
||
) |
This is a new version of the MNMesh::Relax method, which is designed to move all vertices a little closer to their neighbors.
Neighbors are defined as vertices that share an edge. This variation on the Relax method also accepts a soft selection.
vertexFlag | If "softSel" is NULL, only vertices with this flag set are relaxed. |
softSel | This is an optional soft selection. It may be NULL. If not, it should point to an array of MNMesh::numv floats representing the selection value for each vertex. |
relaxAmount | This indicates the proportion of relaxing. If it's zero, nothing happens; if it's one, each vertex is moved to the average of its neighbors. Values of less than zero or more than one are accepted, but lead to unstable results. The default in Editable Poly is .5f. |
relaxIters | This is the number of iterations of relax. This is the number of times the relaxation is applied. The more iterations, the more relaxed the result. |
holdBoundaryPts | If true, "boundary" points should be held in place, unaffected by the Relax. "boundary" points are defined as those that are used by more edges than faces, which basically means they're on some sort of border of the mesh. This is turned on by default in Editable Poly, because if it's off, boundary points recede into the mesh very quickly. |
holdOuterPts | If true, "outer" points should be held in place. "outer" points are defined as those where the sum of all the face angles is less than 2Pi (360 degrees). This basically means the point is some sort of outer corner. All the points on a 1-segment Box or on a Geosphere are "outer" points. On a multiple-segment plane, none of the interior points are "outer" points. This parameter is most important in models like the Geosphere, which could relax down into nothing if outer points are not fixed in place. |
delta | If non-NULL, this should point to an array into which the effect of this relax should be placed, in the form of a Point3 offset per vertex. |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
Starting with the polygon given, this algorithm creates a BitArray selection of all polygons it can get to without crossing any edges whose angle is greater than the angle given.
startPolygon | The polygon to start on. If this polygon is already set in "polySel", nothing will happen. |
angle | The maximum crossable edge angle, in radians |
polySel | The BitArray where polygons should be selected |
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
This method is used at the beginning of a series of cuts.
It sets things up so that "CutCleanup" will work.
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly
This method is used after a series of cuts, to "clean up" any extra edges which are necessary to have.
while cutting, but which aren't what the user actually intended to create. "CutPrepare" should be called at the beginning of the series of cuts.
Example: See example usage in the Editable Poly object, in maxsdk/samples/mesh/EditablePoly