SilverScreen Solid Modeler

prim_facets_build_cache

prim_facets_build_cache

Previous topic Next topic  

prim_facets_build_cache

Previous topic Next topic JavaScript is required for the print function  

 

SilverScreenAPI

 

BOOLEAN prim_facets_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_facets_build_cache function builds a facet-cache for an object. This can substantially increase the speed of faceting 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_facets_build_cache returns TRUE if the cache was built successfully, and FALSE otherwise

 

 

Remarks

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

 

 

See Also

prim_facets_collect, prim_facet_get, prim_facets_release, prim_facets_free_cache

 

 

Example

The following code shows how to use a facets cache to facet 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_FACET_HANDLE   fh;

 SS_FACET_INFO     fi;

 int               i;

 

 . . .

 

 if ( prim_facets_build_cache(obj, 0) )

    {

    ss_command("goto block \\");

    ss_command("create object facet*");

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

 

 

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

       {

       if ( fh = prim_facets_collect(obj, prim) )

          {

          for (i = 1; i <= prim_facets_count(fh); i++)

             {

             if ( prim_facet_get(fh, i, &fi) )

                {

                // Create the facet lines

 

                ss_command("draw line %z %z", &fi.points[0], &fi.points[1]);

                }

             }

          prim_facets_release(fh);

          }

       }

 

    prim_facets_free_cache();

    }

 

 . . .