MNMeshSelectionConverter Class Reference
 
 
 
MNMeshSelectionConverter Class Reference

#include <mnmesh.h>

Inheritance diagram for MNMeshSelectionConverter:
FlagUser MaxHeapOperators

Class Description

When a Mesh object or modifier (such as Editable Mesh, Edit Mesh, or Mesh Select) handles viewport subobject selection, the flow is basically as follows from Editable Mesh.

  • EditTriObject::HitTest is called with window information.

  • It passes the hit region description to Mesh::SubObjectHitTest

  • Mesh::SubObjectHitTest culls some subobjects (say, because they're backfacing), and creates hits for others that are within the hit region.

  • EditTriObject::SelectSubComponent is called with the list of hits, and

    constructs the appropriate BitArray selection.

    The problem was that in cases of Window selection, you want to only select an element or polygon if all the faces of that element or polygon were in the selection region. But since some of these faces could have been culled, they might not have hit records even if they're within the correct region. This would mean, for instance, that a window selection of an entire Sphere would fail to get select its single element, because all the backfaces would not

    have been selected.

    So in order to do this correctly, we need the face culling information. This information is stored and applied in the new MeshSelectionConverter interface, which is part of class Mesh.

    This sort of culling and subobject level translation is not only relevant for Polygon and Element selections, but also for "By Vertex" selections of edges, faces, polygons, or elements.

    Examples of the use of this interface are available in maxsdk/SAMPLES/mesh/editablemesh/triobjed.cpp, and in meshsel.cpp and editmesh.cpp in maxsdk/SAMPLES/modifiers..

    Owner: class Mesh

    InterfaceID: MESHSELECTCONVERT_INTERFACE

Flags:
We have the usual three methods for setting, clearing, and getting flags: void SetFlag (DWORD f, bool value=true) void ClearFlag(DWORD f) bool GetFlag (DWORD f)
We currently only have one flag influencing subobject selection conversion: MESH_SELCONV_REQUIRE_ALL
If set, it implies that, for instance, an element is only selected if all of its (non-culled) faces are selected. If cleared, an element is selected if any of its faces are selected.

Public Member Functions

DllExport void  FaceToElement (MNMesh &mesh, BitArray &faceSel, BitArray &elementSel)
  Converts a face selection to an element selection.
DllExport void  EdgeToBorder (MNMesh &mesh, BitArray &edgeSel, BitArray &borderSel)
DllExport void  VertexToEdge (MNMesh &mesh, BitArray &vertexSel, BitArray &edgeSel)
  Converts a vertex selection to a "By Vertex" edge selection.
DllExport void  VertexToFace (MNMesh &mesh, BitArray &vertexSel, BitArray &faceSel)

Member Function Documentation

DllExport void FaceToElement ( MNMesh mesh,
BitArray faceSel,
BitArray elementSel 
)

Converts a face selection to an element selection.

This method can only produce accurate results with culling if we are certain that the face selection corresponds to the results of the last call to

the owner Mesh's SubObjectHitTest method. (To turn off culling, use GetCull ().ClearAll(). Culling is not relevant if the MESH_SELCONV_REQUIRE_ALL flag

is turned off.)

Parameters:
Mesh & mesh

The mesh that owns this interface

BitArray & faceSel

The face selection representing actual hits in the viewport.

BitArray & elementSel

This is where the output Element selection is stored.

DllExport void EdgeToBorder ( MNMesh mesh,
BitArray edgeSel,
BitArray borderSel 
)
DllExport void VertexToEdge ( MNMesh mesh,
BitArray vertexSel,
BitArray edgeSel 
)

Converts a vertex selection to a "By Vertex" edge selection.

This method can only produce accurate results with culling if we are certain that the vertex selection corresponds to the results of the last call

to the owner Mesh's SubObjectHitTest method. (To turn off culling, use GetCull ().ClearAll(). Culling is not relevant if the MESH_SELCONV_REQUIRE_ALL flag

is turned off.)

Parameters:
Mesh & mesh

The mesh that owns this interface

BitArray & vertexSel

The face selection representing actual hits in the viewport

BitArray & edgeSel

The face selection representing actual hits in the viewport

DllExport void VertexToFace ( MNMesh mesh,
BitArray vertexSel,
BitArray faceSel 
)