SilverScreen Solid Modeler

prim_triangles_collect

prim_triangles_collect

Previous topic Next topic  

prim_triangles_collect

Previous topic Next topic JavaScript is required for the print function  

 

SilverScreenAPI

 

SS_TRIANGLE_HANDLE prim_triangles_collect(OBJECT_NODE *obj, PRIM_NODE *prim, USINT32 flags);

 

OBJECT_NODE *obj;   // A pointer to the OBJECT_NODE parent of prim

PRIM_NODE   *prim;  // A pointer to a PRIM_NODE

USINT32     flags;  // An unsigned integer value

 

 




Synopsis

#include "silver.h"

 

The prim_triangles_collect function triangulates a primitive, that is it represents a primitive by an approximation of triangles.

 

 

Parameters

obj is the object entity that contains prim

 

prim is the primitive that is to be triangulated

 

flags is reserved for future use and should be zero

 

 

Return Value

prim_triangles_collect returns a handle that can be used to retrieve information about prim's triangle approximation if successful, otherwise it returns NULL

 

 

Remarks

You must call prim_triangles_release with a handle you obtained from prim_triangles_collect when you are finished with it.

 

If the primitive has holes, those holes will be represented in the approximation

 

 

See Also

prim_triangle_get, prim_triangles_count, prim_triangles_release

 

 

Example

The following example allows the user to select a polygon from the current drawing, then generates an object with a prefix of "triangle" in the root block that contains the polygons triangulation:

 

C / C++ Code

 

 #include "silver.h"

 #include "ssnodes.h"

 

 

 void main(void)

    {

    char               prim_path[512];

    OBJECT_NODE        *obj;

    PRIM_NODE          *prim;

    SS_TRIANGLE_HANDLE th;

    SS_TRIANGLE_INFO   ti;

    int                i;

 

 

    if ( ! pick_primitive("Select a polygon to triangulate",

                           BITS_POLYGON, prim_path) )

       exit(-1);

 

    prim = get_prim(prim_path, &obj);

 

    if ( th = prim_triangles_collect(obj, prim, 0) )

       {

       ss_command("goto block \\");

       ss_command("create object triangle*");

 

       ss_command("pen current color light-red linestyle solid width 1");

 

       for (i = 1; i <= prim_triangles_count(th); i++)

          {

          if ( prim_triangle_get(th, i, &ti) )

             {

             // Create the facet lines

 

             draw_triangle(&ti.points[0], &ti.points[1], &ti.points[2]);

             }

          }

 

       prim_triangles_release(th);

       }

    }