3ds Max C++ API Reference
MNFaceClusters Class Reference

Used for grouping faces in an MNMesh into clusters for applying transformations. More...

#include <mnmesh.h>

+ Inheritance diagram for MNFaceClusters:

Public Member Functions

DllExport MNFaceClusters (MNMesh &mesh, DWORD clusterFlags)
 Creates clusters from distinct selected components. More...
 
DllExport MNFaceClusters (MNMesh &mesh, float angle, DWORD clusterFlags, const Point3 *faceNormals=nullptr)
 This method will create face cluster lists based on the specified MNMesh. More...
 
int operator[] (int i) const
 Index operator for accessing cluster data. More...
 
DllExport void MakeVertCluster (MNMesh &mesh, Tab< int > &vclust)
 This method will create a table indicating which face cluster each vertex in the mesh is in. More...
 
DllExport void GetNormalsCenters (MNMesh &mesh, Tab< Point3 > &norm, Tab< Point3 > &ctr)
 Computes average normals and centers for each of the face clusters. More...
 
DllExport void GetBorder (const MNMesh &mesh, int clustID, Tab< int > &cbord) const
 This method will finds the edge list that borders this cluster. More...
 
DllExport void GetOutlineVectors (MNMesh &m, Tab< Point3 > &cnorms, Tab< Point3 > &odir)
 This method will retrieve the "outline" direction for the border of the cluster. More...
 

Public Attributes

Tab< intclust
 The cluster number, one for each face. More...
 
int count
 The total number of clusters in the MNMesh. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator 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 voidoperator 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 voidoperator 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 voidoperator 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 voidoperator 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 voidoperator 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 voidoperator 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 voidoperator 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 voidoperator 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 voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator 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 voidoperator 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 voidoperator 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 voidoperator 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...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

Used for grouping faces in an MNMesh into clusters for applying transformations.

Depending on the constructor used, it may group faces into clusters based on minimal angles between faces, on face selections, or on both. The class contains a list of face "clusters" for a given mesh. A typical application would be in Editable Poly, where the user has selected two separate groups of faces on different parts of the mesh and wants to extrude them both, or rotate both around their local centers. Each "cluster" is a contiguous group of selected faces. This class is only defined in relation to some MNMesh.

For convenient caching, it is recommended that you use this class through the MNTempData class.

All methods of this class are implemented by the system.

See also
MNTempData, MNMesh

Constructor & Destructor Documentation

◆ MNFaceClusters() [1/2]

DllExport MNFaceClusters ( MNMesh mesh,
DWORD  clusterFlags 
)

Creates clusters from distinct selected components.

This method will create face cluster lists based on the specified MNMesh. Each contiguous group of selected faces is grouped into a cluster.

Parameters:
MNMesh &mesh

The mesh these clusters are based on.

DWORD clusterFlags

The face flags to cluster the faces by.

For instance, if this value was set to MN_SEL, then faces would be clustered by their selection.

◆ MNFaceClusters() [2/2]

DllExport MNFaceClusters ( MNMesh mesh,
float  angle,
DWORD  clusterFlags,
const Point3 faceNormals = nullptr 
)

This method will create face cluster lists based on the specified MNMesh.

Cluster boundaries will be determined by the angle between faces and optionally by the face flags.

Parameters:
MNMesh &mesh

The mesh these clusters are based on.

float angle

The minimum edge angle (in radians) used to define a separation between clusters.

DWORD clusterFlags

The face flags to cluster the faces by.

For instance, if this value was set to MN_SEL, then faces would be clustered by their selection. If this value is set to 0, then the clusters are based only on edge angles.

const Point3* faceNormals

Optional performance option to pass in the precomputed list of normals

Member Function Documentation

◆ operator[]()

int operator[] ( int  i) const
inline

Index operator for accessing cluster data.

5467  {
5468  return (i < clust.Count()) ? clust[i] : -1;
5469  }
Tab< int > clust
The cluster number, one for each face.
Definition: mnmesh.h:5429
int Count() const
Retrieves the number of items in the Tab.
Definition: tab.h:219

◆ MakeVertCluster()

DllExport void MakeVertCluster ( MNMesh mesh,
Tab< int > &  vclust 
)

This method will create a table indicating which face cluster each vertex in the mesh is in.

Parameters:
MNMesh &mesh

The mesh this face cluster is based on.

Tab<int> & vclust

The table of vertex clusters. This is set to size mesh.VNum(). Values of UNDEFINED (0xffffffff) in the table indicate that a vertex is not in any cluster. If a vertex is in two clusters (because it's a point where corners of two clusters touch), the higher-indexed face's cluster is dominant.

◆ GetNormalsCenters()

DllExport void GetNormalsCenters ( MNMesh mesh,
Tab< Point3 > &  norm,
Tab< Point3 > &  ctr 
)

Computes average normals and centers for each of the face clusters.

Parameters:
MNMesh &mesh

The mesh this face cluster is based on.

Tab<Point3> & norm

The tables where the normals should be put. Each of these tables has its size set to the number of clusters, and is indexed by cluster.

Tab<Point3> & ctr

The tables where the centers should be put. Each of these tables has its size set to the number of clusters, and is indexed by cluster.

◆ GetBorder()

DllExport void GetBorder ( const MNMesh mesh,
int  clustID,
Tab< int > &  cbord 
) const

This method will finds the edge list that borders this cluster.

This edge list is a set of closed loops of edges, which may be empty. For instance, if the mesh is a sphere, and all the faces are in the cluster, there are no border edges for the cluster. But if one horizontal row of faces, such as the faces just above the equator, are in the cluster, then the edges above those faces form one loop, while the edges below form another.

Parameters:
MNMesh &mesh

The mesh this face cluster is based on.

int clustID

The ID of the cluster we want to get the border of.

Tab<int> & cbord

The table for putting the border output. This table is set up as follows: each border loop is represented by a series of edge indices, followed by a -1 to indicate a separation between loops. So a result of size 10 with data 1, 4, 6, 9, -1, 2, 10, 15, 14, -1, would indicate two border loops consisting of four edges each. The order of the edges in the loops is chosen so that as you look from outside the mesh and follow the path of the edges, the face cluster will always be on the left.

◆ GetOutlineVectors()

DllExport void GetOutlineVectors ( MNMesh m,
Tab< Point3 > &  cnorms,
Tab< Point3 > &  odir 
)

This method will retrieve the "outline" direction for the border of the cluster.

This is the direction used in the "Outline" feature in Editable Poly face level, as well as in the Bevel command mode.

Parameters:
MNMesh &m

The mesh this face cluster is based on.

Tab<Point3> & cnorms

The cluster normals, as computed in the GetNormalsCenters method. (This data is input, not output.)

Tab<Point3> & odir

This is where the outline vectors are stored. This table is set to size mesh.VNum(), and stores one direction vector for each vertex. Most direction vectors are usually zero, since most vertices are not on the cluster's border. All vectors are scaled so that moving along them moves the cluster's border edges by one unit. (For instance, the length of a vector at a right angle between two border edges would be sqrt(2), so that each edge can move by 1 unit "out" from the cluster.)

Member Data Documentation

◆ clust

Tab<int> clust

The cluster number, one for each face.

Note that non-selected faces have UNDEFINED for their id.

◆ count

int count

The total number of clusters in the MNMesh.