SilverScreen Solid Modeler

prim_triangles_build_cache

prim_triangles_build_cache

Previous topic Next topic  

prim_triangles_build_cache

Previous topic Next topic JavaScript is required for the print function  

 

SilverScreenAPI

 

BOOLEAN prim_triangles_build_cache(OBJECT_NODE *obj, USINT32 cache_flags);

 

OBJECT_NODE *obj;         // A pointer to an OBJECT_NODE

USINT32     cache_flags;  // An unsigned integer value

 

 




Synopsis

#include "silver.h"

 

The prim_triangles_build_cache function builds a triangulation-cache for an object. This can substantially increase the speed of triangulation when many primitives in the same object are being faceted together.

 

 

Parameters

obj is a pointer to the OBJECT_NODE to which the cache is applicable

 

cache_flags is reserved for future use and should be set to zero

 

 

Return Value

prim_triangles_build_cache returns TRUE if the cache was built successfully, and FALSE otherwise

 

 

Remarks

You must call prim_triangles_free_cache when you are finished triangulating primitives in the object. Only one triangulation cache may be active at a time, and calling build again before calling prim_triangles_free_cache will destroy the previous cache. Use of the cache is optional.

 

 

See Also

prim_triangles_collect, prim_triangle_get, prim_triangles_count, prim_triangles_free_cache

 

 

Example

The following code shows how to use a triangulation cache to triangulate every primitive of an object. The 'obj' variable is assumed to have been set to an object entity:

 

C / C++ Code

 

 #include "silver.h"

 #include "ssnodes.h"

 

 

 . . .

 

 OBJECT_NODE        *obj;

 PRIM_NODE          *prim;

 SS_TRIANGLE_HANDLE th;

 SS_TRIANGLE_INFO   ti;

 int                i;

 

 . . .

 

 if ( prim_triangles_build_cache(obj, 0) )

    {

    ss_command("goto block \\");

    ss_command("create object triangle*");

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

 

    for (prim = obj->first_node; prim; prim = prim->next_node)

       {

       if ( th = prim_triangles_collect(obj, prim) )

          {

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

             {

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

                {

                // Create the triangle

 

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

                }

             }

 

          prim_triangles_release(fh);

          }

       }

 

    prim_triangles_free_cache();

    }

 

 . . .