The PolygonFace object gives access to the geometry polygons of an X3DObject's primitive.
using namespace XSI; Application app; Model root = app.GetActiveSceneRoot(); X3DObject myCube; root.AddGeometry( L"Cube", L"MeshSurface", L"", myCube ); PolygonMesh mesh( myCube.GetActivePrimitive().GetGeometry() ); PolygonFace face( mesh.GetPolygons().GetItem(0) ); app.LogMessage(L"Number of nodes: " + CValue(face.GetNodes().GetCount()).GetAsText() );
#include <xsi_polygonface.h>
Public Member Functions |
|
PolygonFace () | |
~PolygonFace () | |
PolygonFace (const CRef &in_ref) | |
PolygonFace (const PolygonFace &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
PolygonFace & | operator= (const PolygonFace &in_obj) |
PolygonFace & | operator= (const CRef &in_ref) |
CPolygonNodeRefArray | GetNodes () const |
CVertexRefArray | GetVertices () const |
CEdgeRefArray | GetEdges () const |
CVertexRefArray | GetNeighborVertices (LONG in_lDistance=1) const |
CEdgeRefArray | GetNeighborEdges (LONG in_lDistance=1) const |
CPolygonFaceRefArray | GetNeighborPolygons (LONG in_lDistance=1) const |
CPolygonFaceRefArray | GrowNeighborPolygons (LONG in_lDistance=1) const |
CLongArray | GetTriangleSubIndexArray () const |
ULONG | GetTurnInternalEdgeOffset () const |
PolygonFace | ( | ) |
Default constructor.
~PolygonFace | ( | ) |
Default destructor.
PolygonFace | ( | const CRef & | in_ref | ) |
Constructor.
in_ref | constant reference object. |
PolygonFace | ( | const PolygonFace & | in_obj | ) |
Copy constructor.
in_obj | constant class object. |
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | class type. |
Reimplemented from Facet.
siClassID GetClassID | ( | ) | const [virtual] |
PolygonFace& operator= | ( | const PolygonFace & | in_obj | ) |
Creates an object from another object. The newly created object is set to empty if the input object is not compatible.
in_obj | constant class object. |
PolygonFace& operator= | ( | const CRef & | in_ref | ) |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | constant class object. |
Reimplemented from Facet.
CPolygonNodeRefArray GetNodes | ( | ) | const |
Returns an array of PolygonNode objects on this PolygonFace object.
CVertexRefArray GetVertices | ( | ) | const |
Returns an array of Vertex objects on this PolygonFace object.
CEdgeRefArray GetEdges | ( | ) | const |
Returns an array of Edge objects on this PolygonFace object.
CVertexRefArray GetNeighborVertices | ( | LONG | in_lDistance = 1 |
) | const |
Returns an array of Vertex neighbors within a given distance.If the distance is 1 all Vertex objects comprising the current PolygonFace are returned in counter-clockwise order.
in_lDistance | Value representing the degree of neighborhood (eg: degree=2 for a polygon means its adjacent vertices plus the adjacent vertices of the adjacent polygons). |
CEdgeRefArray GetNeighborEdges | ( | LONG | in_lDistance = 1 |
) | const |
Returns an array of Edge neighbors within a given distance. If the distance is 1 all Edge objects comprising the current PolygonFace are returned in counter-clockwise order.
in_lDistance | Value representing the degree of neighborhood (eg: degree=2 for a polygon means its adjacent vertices plus the adjacent vertices of the adjacent polygons). |
CPolygonFaceRefArray GetNeighborPolygons | ( | LONG | in_lDistance = 1 |
) | const |
Returns an array of PolygonFace neighbors within a given distance. If the distance is 1 all PolygonFace objects that share an Edge with the current PolygonFace are returned in counter-clockwise order.
in_lDistance | Value representing the degree of neighborhood (eg: degree=2 for a polygon means its adjacent vertices plus the adjacent vertices of the adjacent polygons). |
CPolygonFaceRefArray GrowNeighborPolygons | ( | LONG | in_lDistance = 1 |
) | const |
Returns an array of PolygonFace objects that are adjacent to this PolygonFace object, within a given distance.
in_lDistance | Value representing the degree of neighborhood (eg: degree=2 for a polygon means its adjacent vertices plus the adjacent vertices of the adjacent polygons). |
CLongArray GetTriangleSubIndexArray | ( | ) | const |
Returns a packed array of triangulation descriptions corresponding to the tesselation of the polygon. The polygon is tesselated into (Facet::NbPoints - 2) triangles, and 3 indices in the range (0..Facet::NbPoints-1) are returned for each triangle. Each index triplet describes a subtriangle of the polygon, and the indices correspond to the vertex or node ordering within the polygon.
Notice that the triangulation of a polygon may change accordingly to the deformation of the geometry.
using namespace XSI; Application app; Model root = app.GetActiveSceneRoot(); X3DObject meshSphereObj; root.AddGeometry( L"Sphere", L"MeshSurface", L"", meshSphereObj ); PolygonMesh meshSphereGeom( meshSphereObj.GetActivePrimitive().GetGeometry() ); CPolygonFaceRefArray polygons = meshSphereGeom.GetPolygons(); LONG i; for(i = 0; i < polygons.GetCount(); i++) { PolygonFace polygon = polygons[i]; LONG nbTriangles = polygon.GetNbPoints()-2; CLongArray polygonNeiVtxIndices = polygon.GetVertices().GetIndexArray(); CLongArray polygonNeiNodIndices = polygon.GetNodes().GetIndexArray(); CLongArray polygonTriSubIndices = polygon.GetTriangleSubIndexArray(); LONG j; for(j = 0; j < nbTriangles; j++) { app.LogMessage(L"SubTriangle " + CString(CValue(j)) + L" of Polygon " + CString(CValue(i)) + L" correspond to vertices (" + CString(CValue(polygonNeiVtxIndices[polygonTriSubIndices[j*3]])) + L", " + CString(CValue(polygonNeiVtxIndices[polygonTriSubIndices[j*3+1]])) + L", " + CString(CValue(polygonNeiVtxIndices[polygonTriSubIndices[j*3+2]])) + L") and nodes (" + CString(CValue(polygonNeiNodIndices[polygonTriSubIndices[j*3]])) + L", " + CString(CValue(polygonNeiNodIndices[polygonTriSubIndices[j*3+1]])) + L", " + CString(CValue(polygonNeiNodIndices[polygonTriSubIndices[j*3+2]])) + L")."); } } // Expected results: //INFO : SubTriangle 0 of Polygon 0 correspond to vertices (9, 2, 0) and nodes (0, 1, 2). //INFO : SubTriangle 0 of Polygon 1 correspond to vertices (2, 9, 10) and nodes (3, 4, 5). //INFO : SubTriangle 1 of Polygon 1 correspond to vertices (2, 10, 3) and nodes (3, 5, 6). //INFO : SubTriangle 0 of Polygon 2 correspond to vertices (3, 10, 11) and nodes (7, 8, 9). //INFO : SubTriangle 1 of Polygon 2 correspond to vertices (3, 11, 4) and nodes (7, 9, 10). //etc.
ULONG GetTurnInternalEdgeOffset | ( | ) | const |
Returns the polygon node used to start the triangle fan of the default triangulation of the polygon. This offset is controlled by applying the turnedgeinpolygons TurnEdge operator .
0
and
NbPoints-1