### C: Install User Error Handler and Memory Management Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples This C code snippet shows how to install custom error handling and memory management functions. It defines `user_ErrorHandler`, `user_malloc`, `user_realloc`, and `user_free` to intercept and log system events. The `main` function demonstrates installing these handlers using `vut_ErrorSetHandler` and `vut_MemorySetFunctions`, triggering errors with `vsy_ListInsert`, and then resetting the error handler to default. ```c #include #include "sam/base/base.h" #include "sam/base/license.h" #include "sam/hoops_license.h" /* list of system error types */ static Vint errortable[SYS_ERROR_MAX] = {SYS_ERROR_VALUE, SYS_ERROR_ENUM, SYS_ERROR_OBJECTTYPE, SYS_ERROR_MEMORY, SYS_ERROR_NULLOBJECT, SYS_ERROR_FILE, SYS_ERROR_COMPUTE, SYS_ERROR_OPERATION, SYS_ERROR_OVERFLOW, SYS_ERROR_UNDERFLOW, SYS_ERROR_UNKNOWN, SYS_ERROR_FORMAT, SYS_ERROR_SEVERE, SYS_ERROR_LOAD}; static const Vchar* errorname[SYS_ERROR_MAX] = { "SYS_ERROR_VALUE", "SYS_ERROR_ENUM", "SYS_ERROR_OBJECTTYPE", "SYS_ERROR_MEMORY", "SYS_ERROR_NULLOBJECT", "SYS_ERROR_FILE", "SYS_ERROR_COMPUTE", "SYS_ERROR_OPERATION", "SYS_ERROR_OVERFLOW", "SYS_ERROR_UNDERFLOW", "SYS_ERROR_UNKNOWN", "SYS_ERROR_FORMAT", "SYS_ERROR_SEVERE", "SYS_ERROR_LOAD"}; static void user_ErrorHandler(const Vchar* funcname, Vint errorflag, const Vchar* message) { printf("\n"); if (funcname) { printf("function : %s\n", funcname); } if (errorflag > 0 && errorflag <= SYS_ERROR_MAX) { printf("error : %s\n", vut_ErrorString(errorflag)); } if (strlen(message)) { printf("message : %s\n", message); } } static void* user_malloc(size_t siz) { printf("\n"); printf("malloc %lu bytes\n", (unsigned long)siz); return (malloc(siz)); } static void* user_realloc(void* ptr, size_t siz) { printf("\n"); printf("realloc %p ptr, %lu bytes\n", ptr, (unsigned long)siz); return (realloc(ptr, siz)); } static void user_free(void* ptr) { printf("\n"); printf("free %p ptr\n", ptr); free(ptr); } /*---------------------------------------------------------------------- Install user error handler and memory management ----------------------------------------------------------------------*/ int main() { Vint i; vsy_List* list; Vint num; Vint ierr; vsy_LicenseValidate(HOOPS_LICENSE); /* print DevTools version string */ printf("version= %s\n", vut_Name(NAME_VERSION, 0)); /* install user error handler */ vut_ErrorSetHandler(user_ErrorHandler); /* install user memory management */ vut_MemorySetFunctions(user_malloc, user_realloc, user_free); /* instance object */ list = vsy_ListBegin(); /* insert some numbers */ /* index= -1 produces an error */ vsy_ListInsert(list, -1, (void*)1); vsy_ListInsert(list, 10, (void*)10); vsy_ListInsert(list, 20, (void*)20); /* count objects */ vsy_ListCount(list, &num); printf("\n"); printf("num= %d\n", num); printf("\n"); /* reinstall default error handler */ vut_ErrorSetHandler(NULL); /* insert an object */ /* index= -2 produces an error */ vsy_ListInsert(list, -2, (void*)2); /* query object for error and search */ ierr = vsy_ListError(list); /* in general, errors are non-zero */ if (ierr) { for (i = 0; i < SYS_ERROR_MAX; i++) { if (ierr == errortable[i]) { printf("\nError, ierr= %d, name= %s\n", ierr, errorname[i]); break; } } } /* delete object */ vsy_ListEnd(list); return 0; } ``` -------------------------------- ### Modernize Example 7 with Simplified C API Source: https://docs.techsoft3d.com/hoops/mesh/release-notes/2x/2-11 Example 7 has undergone modernization using a simplified C API. The library manager functions are now employed for reading input files, leading to a more streamlined and efficient implementation. ```c // Example 7 is modernized with library manager functions. ``` -------------------------------- ### Start and Join a Single Task (C) Source: https://docs.techsoft3d.com/hoops/mesh/guide/foundation/system Functions for starting individual tasks and waiting for their completion. `vsy_PTaskStart` initiates a task and returns a task ID. `vsy_PTaskJoin` pauses execution until the specified task ID completes. Invalid task IDs will generate an error. ```c void vsy_PTaskStart(vsy_PTask *p, Vfunc1 *func, Vobject *data, Vint *taskid); void vsy_PTaskJoin(vsy_PTask *p, Vint taskid); ``` -------------------------------- ### Modernize Example 1 with Simplified C API (HOOPS-Access) Source: https://docs.techsoft3d.com/hoops/mesh/release-notes/2x/2-11 Example 1 has been updated with a new simplified C API. This modernization effort focuses on improving the integration with HOOPS-Access by utilizing updated library manager functions for file input. ```c // Modernized the example1.cpp with new simplified C API. ``` -------------------------------- ### Modernize Example 14 with Simplified C API Source: https://docs.techsoft3d.com/hoops/mesh/release-notes/2x/2-11 Example 14 has been modernized by replacing the use of datafun with the library manager to read input files. This update utilizes a simplified C API for improved code readability and maintainability. ```c // Replaced the use of datafun with library manager to read the input file in exam14_minimalplugin. ``` -------------------------------- ### Get Transparency Factors Source: https://docs.techsoft3d.com/hoops/mesh/guide/legacy/vis/color-and-transparency Retrieves a series of transparency factors from the transparency map, starting at a specified map index. ```c void vis_TransMapGetTrans(vis_TransMap *transmap, Vint nmapindex, Vint imapindex, Vfloat t[]) ``` -------------------------------- ### Main Application Entry Point (C) Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples The main function serves as the entry point for the application. It validates the HOOPS license and then proceeds to either launch child processes (servers) or connect as a client based on the number of command-line arguments. Platform-specific process creation is handled using preprocessor directives. ```c int main(int argc, char* argv[]) { Vchar sys[BUFSIZE]; Vint n; vsy_LicenseValidate(HOOPS_LICENSE); #ifdef VKI_ARCH_WIN32 STARTUPINFO si; PROCESS_INFORMATION pi; #endif /* Check input */ if (argc == 1) { for (n = 1; n <= 3; n++) { #ifdef VKI_ARCH_WIN32 sprintf(sys, "%s %d", argv[0], n); ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); if (!CreateProcess(NULL, sys, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { printf("SERVER: Unable to start child process %d\n", n); exit(0); } #else sprintf(sys, "%s %d &", argv[0], n); #if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-result" #endif system(sys); #if defined(__GNUC__) #pragma GCC diagnostic pop #endif #endif } main_server(); } else if (argc == 2) { sscanf(argv[1], "%d", &n); if (n == 1 || n == 2) { main_client(n); } else { /* Wait 10 seconds before stopping server */ printf("SERVER: Waiting 10 seconds to launch stop server...\n"); #ifdef VKI_ARCH_WIN32 Sleep(10000); #else sleep(10); #endif main_stop(); } } return 0; } ``` -------------------------------- ### Get Transparency Indices Source: https://docs.techsoft3d.com/hoops/mesh/guide/legacy/vis/color-and-transparency Retrieves a series of transparency indices from the transparency map, starting at a specified map index. ```c void vis_TransMapGetIndex(vis_TransMap *transmap, Vint nmapindex, Vint imapindex, Vint index[]) ``` -------------------------------- ### C: Demonstrate Timer Object Functionality Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples This C code snippet demonstrates the core functionalities of the Timer module, including starting, stopping, and retrieving timing information for named sections. It also shows how to initialize, remove, and clear timed sections, and the overall timer object. Dependencies include 'sam/base/base.h' and license headers. ```c #include #include "sam/base/base.h" #include "sam/base/license.h" #include "sam/hoops_license.h" static void print_time(vsy_Timer* timer); #if defined(__clang__) && (__clang_major__ >= 14) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-but-set-variable" #endif /*---------------------------------------------------------------------- Test and demonstrate Timer ----------------------------------------------------------------------*/ int main() { Vint i; Vdouble a; vsy_Timer* timer; vsy_LicenseValidate(HOOPS_LICENSE); printf("\nTimer test\n"); /* instance object */ timer = vsy_TimerBegin(); /* start timing addition */ vsy_TimerStart(timer, "PlusOne"); a = 0; for (i = 0; i < 10000000; i++) { a += 1.; } /* stop and print */ vsy_TimerStop(timer, "PlusOne"); print_time(timer); /* start timing multiplication */ vsy_TimerStart(timer, "Multiply"); a = 1; for (i = 0; i < 10000000; i++) { a *= 1.0000001; } /* stop and print */ vsy_TimerStop(timer, "Multiply"); print_time(timer); /* restart timing addition */ vsy_TimerStart(timer, "PlusOne"); a = 0; for (i = 0; i < 20000000; i++) { a += 1.; } /* print before stopping */ print_time(timer); /* stop and print */ vsy_TimerStop(timer, "PlusOne"); print_time(timer); /* initialize and print */ vsy_TimerInit(timer, "PlusOne"); print_time(timer); /* remove and print */ vsy_TimerRemove(timer, "Multiply"); print_time(timer); /* clear all */ vsy_TimerClear(timer); print_time(timer); /* delete object */ vsy_TimerEnd(timer); return 0; } #if defined(__clang__) && (__clang_major__ >= 14) #pragma clang diagnostic pop #endif /*---------------------------------------------------------------------- print utility ----------------------------------------------------------------------*/ static void print_time(vsy_Timer* timer) { Vchar* name; Vint num, run; Vfloat usr, sys, ela; printf("Current timer state\n"); /* iterate through all times */ vsy_TimerInitIter(timer); while (vsy_TimerNextIter(timer, &name), name) { vsy_TimerEval(timer, name, &num, &run, &usr, &sys, &ela); printf(" name: %s, num= %d, run= %d, cpu= %f, sys= %f, ela= %f\n", name, num, run, usr, sys, ela); } } ``` -------------------------------- ### Get Starting Index of Integer Vector - C Source: https://docs.techsoft3d.com/hoops/mesh/guide/foundation/numeric-type-collections Retrieves the initial index of an IntVec object. This function is useful for understanding the structure or offset of the data within the vector, particularly when dealing with vectors that do not necessarily start at index zero. ```c void vsy_IntVecGetStartingIndex(vsy_IntVec *p, Vint *index) { // Implementation details not provided in the source text. } ``` -------------------------------- ### Demonstrate Property Sets with C Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples This C code illustrates the functionality of the `vsy_PropSet` module. It covers instantiation, insertion of different property types (integers, floats, strings, vectors, objects), counting properties, and iterating to display them. It requires the `sam/base/base.h` and related headers for HOOPS license validation and PropSet operations. ```c #include #include "sam/base/base.h" #include "sam/base/license.h" #include "sam/hoops_license.h" static void print_propset(vsy_PropSet* propset, Vchar* stg); /*---------------------------------------------------------------------- Test and demonstrate property sets ----------------------------------------------------------------------*/ int main() { vsy_PropSet* propset; Vint ivalue[16]; Vdouble dvalue[16]; Vobject* pvalue[16]; Vint count; vsy_LicenseValidate(HOOPS_LICENSE); printf("\nPropSet test\n"); /* instance object */ propset = vsy_PropSetBegin(); /* insert some properties */ vsy_PropSetInserti(propset, "integer", 1); vsy_PropSetInsertf(propset, "float", 2.); ivalue[0] = 10; ivalue[1] = 11; ivalue[2] = 12; vsy_PropSetInsertiv(propset, "integer vector", 3, ivalue); vsy_PropSetInsertc(propset, "string", (Vchar*)"Test and demonstrate property set"); dvalue[0] = 100.; dvalue[1] = 101.; vsy_PropSetInsertdv(propset, "double vector", 2, dvalue); pvalue[0] = (void*)1; pvalue[1] = (void*)2; vsy_PropSetInsertpv(propset, "object vector", 2, pvalue); vsy_PropSetCount(propset, &count); printf("number of properties = %d\n", count); print_propset(propset, (Vchar*)"Property Set"); /* delete object */ vsy_PropSetEnd(propset); return 0; } /*---------------------------------------------------------------------- print utility ----------------------------------------------------------------------*/ static void print_propset(vsy_PropSet* propset, Vchar* stg) { Vchar* name; Vint type, num, size; Vint i; Vint ivalue[16]; Vfloat fvalue[16]; Vdouble dvalue[16]; Vobject* pvalue[16]; Vchar cvalue[256]; /* print a title */ printf("\n%s\n", stg); /* print values of all entries */ vsy_PropSetInitIter(propset); while (vsy_PropSetNextIter(propset, &name), name != NULL) { vsy_PropSetLookup(propset, name, &type, &num, &size); printf("\nProperty name = %s\n", name); printf(" type = %d\n", type); printf(" num = %d\n", num); printf(" size = %d\n", size); if (type == SYS_INTEGER) { vsy_PropSetLookupInteger(propset, name, ivalue); for (i = 0; i < num; i++) { printf(" prop[%2d] = %d\n", i, ivalue[i]); } } else if (type == SYS_FLOAT) { vsy_PropSetLookupFloat(propset, name, fvalue); for (i = 0; i < num; i++) { printf(" prop[%2d] = %f\n", i, fvalue[i]); } } else if (type == SYS_DOUBLE) { vsy_PropSetLookupDouble(propset, name, dvalue); for (i = 0; i < num; i++) { printf(" prop[%2d] = %f\n", i, dvalue[i]); } } else if (type == SYS_OBJECT) { vsy_PropSetLookupObject(propset, name, pvalue); for (i = 0; i < num; i++) { printf(" prop[%2d] = %p\n", i, pvalue[i]); } } else if (type == SYS_STRING) { vsy_PropSetLookupString(propset, name, cvalue); printf(" prop = %s\n", cvalue); } } } ``` -------------------------------- ### Demonstrate HashTable in C Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples Illustrates the use of the HashTable collection module in C. It covers initialization, insertion, removal, key retrieval, and traversal of elements. Assumes basic C environment and HOOPS SAM library. ```c #include #include "sam/base/base.h" #include "sam/base/license.h" #include "sam/hoops_license.h" static void test_hashtable(void); static void test_vhashtable(void); static void test_intvhash(void); static void test_list(void); static void test_stack(void); static void test_dictionary(void); static void print_integer(Vint* n); /*---------------------------------------------------------------------- Test and demonstrate collection objects ----------------------------------------------------------------------*/ int main() { vsy_LicenseValidate(HOOPS_LICENSE); test_hashtable(); test_vhashtable(); test_intvhash(); test_list(); test_stack(); test_dictionary(); return 0; } /*---------------------------------------------------------------------- HashTable ----------------------------------------------------------------------*/ static void test_hashtable(void) { Vint i; vsy_HashTable* htab; Vint num, count, key, keys[10]; Vchar* str; printf("\nHashTable test\n"); /* instance HashTable object */ htab = vsy_HashTableBegin(); /* set initial allocation to two objects */ vsy_HashTableDef(htab, 2); /* inquire and count */ vsy_HashTableInq(htab, &num); vsy_HashTableCount(htab, &count); printf("num = %d, count = %d\n", num, count); /* insert some simple "string" objects */ vsy_HashTableInsert(htab, 3, (Vobject*)"three"); vsy_HashTableInsert(htab, 0, (Vobject*)"zero"); vsy_HashTableInsert(htab, 2, (Vobject*)"two"); vsy_HashTableInsert(htab, 1, (Vobject*)"one"); /* count and find maximum key */ vsy_HashTableCount(htab, &count); vsy_HashTableMaxKey(htab, &key); printf("count= %d, max key= %d\n", count, key); /* get all keys */ vsy_HashTableAllKeys(htab, keys); for (i = 0; i < count; i++) { printf("key = %d\n", keys[i]); } /* remove a couple */ vsy_HashTableRemove(htab, 2); vsy_HashTableRemove(htab, 0); /* add some */ vsy_HashTableInsert(htab, 4, (Vobject*)"four"); vsy_HashTableInsert(htab, 15, (Vobject*)"fifteen"); /* now inquire and count */ vsy_HashTableInq(htab, &num); vsy_HashTableCount(htab, &count); printf("num = %d, count = %d\n", num, count); /* InitIter,NextIter traversal */ vsy_HashTableInitIter(htab); while (vsy_HashTableNextIter(htab, &key, (Vobject**)&str), str != NULL) { printf("key = %d, string = %s\n", key, str); } /* delete object */ vsy_HashTableEnd(htab); } /*---------------------------------------------------------------------- VHashTable ----------------------------------------------------------------------*/ static void test_vhashtable(void) { vsy_VHashTable* htab; Vint size, num, count, key[3]; Vchar* str; printf("\nVHashTable test\n"); /* instance HashTable object */ htab = vsy_VHashTableBegin(); /* set initial allocation to three keys and two objects */ vsy_VHashTableDef(htab, 3, 2); /* inquire and count */ vsy_VHashTableInq(htab, &size, &num); vsy_VHashTableCount(htab, &count); printf("size = %d, num = %d, count = %d\n", size, num, count); /* insert some simple "string" objects */ key[0] = 1; key[1] = 2; key[2] = 3; vsy_VHashTableInsert(htab, key, (Vobject*)"three"); key[2] = 0; vsy_VHashTableInsert(htab, key, (Vobject*)"zero"); key[2] = 2; vsy_VHashTableInsert(htab, key, (Vobject*)"two"); key[2] = 1; vsy_VHashTableInsert(htab, key, (Vobject*)"one"); /* count */ vsy_VHashTableCount(htab, &count); printf("count= %d\n", count); /* remove a couple */ key[2] = 2; vsy_VHashTableRemove(htab, key); key[2] = 0; vsy_VHashTableRemove(htab, key); /* add some */ key[2] = 4; vsy_VHashTableInsert(htab, key, (Vobject*)"four"); key[2] = 15; vsy_VHashTableInsert(htab, key, (Vobject*)"fifteen"); /* now inquire and count */ vsy_VHashTableInq(htab, &size, &num); vsy_VHashTableCount(htab, &count); printf("size = %d, num = %d, count = %d\n", size, num, count); /* InitIter,NextIter traversal */ vsy_VHashTableInitIter(htab); while (vsy_VHashTableNextIter(htab, key, (Vobject**)&str), str != NULL) { printf("key = %d %d %d, string = %s\n", key[0], key[1], key[2], str); } ``` -------------------------------- ### vis_ConnectElemNum - Get Element Feature Count Source: https://docs.techsoft3d.com/hoops/mesh/guide/global/grid-topology-and-geometry Retrieves the number of faces, edges, or nodes in a given element. For example, the number of faces in a hexahedral element is 6. ```APIDOC ## POST /vis_ConnectElemNum ### Description Get the number of faces, edges or nodes in an element. For example, the number of faces in a hexahedral element is _6_. If an improper element feature, _type_ , is input then _num_ is returned as zero. If an improper element _index_ is input then the operation of this function is undefined. ### Method POST ### Endpoint /vis_ConnectElemNum ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **p** (vis_Connect *) - Pointer to Connect object. - **type** (Vint) - Type of element feature. Possible values: - SYS_FACE: Element face - SYS_EDGE: Element edge - SYS_NODE: Element node - **index** (Vint) - Element index to get number of faces, edges or nodes - **num** (Vint *) - **[out]** Number of faces, edges or nodes in element. ### Request Example ```json { "p": "", "type": "SYS_FACE", "index": 123, "num": null } ``` ### Response #### Success Response (200) - **num** (Vint) - Number of faces, edges or nodes in element. #### Response Example ```json { "num": 6 } ``` ``` -------------------------------- ### Create and Format a Text Table Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples This section illustrates the creation of a text table with specific width and border settings. It then proceeds to define table rows and columns, setting alignment, color, and content for each cell. ```c /* table */ vsy_TextFunSetMode(tf, SYS_TEXT_CENTER, SYS_ON); vsy_TextFunTableWidth(tf, 60); vsy_TextFunBorderWidth(tf, 4); vsy_TextFunFormInit(tf, SYS_TEXT_TABLE); /* row 1 */ vsy_TextFunFormInit(tf, SYS_TEXT_ROW); vsy_TextFunColumnAlign(tf, SYS_TEXT_LEFT); vsy_TextFunTableColor(tf, red); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "Aligned left"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunColumnAlign(tf, SYS_TEXT_MIDDLE); vsy_TextFunTableColor(tf, grn); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "Aligned middle"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunColumnAlign(tf, SYS_TEXT_RIGHT); vsy_TextFunTableColor(tf, blu); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "Aligned right"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunFormTerm(tf, SYS_TEXT_ROW); /* row 2 */ vsy_TextFunTableColor(tf, offwht); vsy_TextFunFormInit(tf, SYS_TEXT_ROW); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "row 2 col 1"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "row 2 col 2"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "row 2 col 3"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunFormTerm(tf, SYS_TEXT_ROW); /* row 3 */ vsy_TextFunTableColor(tf, altwht); vsy_TextFunFormInit(tf, SYS_TEXT_ROW); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "row 3 col 1"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "row 3 col 2"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunFormInit(tf, SYS_TEXT_COLUMN); vsy_TextFunSpace(tf, 3); vsy_TextFunString(tf, "row 3 col 3"); vsy_TextFunSpace(tf, 3); vsy_TextFunFormTerm(tf, SYS_TEXT_COLUMN); vsy_TextFunFormTerm(tf, SYS_TEXT_ROW); vsy_TextFunTableColor(tf, back); vsy_TextFunFormTerm(tf, SYS_TEXT_TABLE); ``` -------------------------------- ### Get Next Property Name in PropSet Iteration Source: https://docs.techsoft3d.com/hoops/mesh/guide/foundation/utilities Retrieves the name of the next property during a PropSet iteration. When all properties have been visited, it returns a NULL pointer. Iteration must be started with vsy_PropSetInitIter(). ```c void vsy_PropSetNextIter(vsy_PropSet *p, Vchar **name) ``` -------------------------------- ### Dictionary Operations: Insert, Lookup, and End (C) Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples Demonstrates the use of `vsy_DictionaryInsert`, `vsy_DictionaryLookup`, and `vsy_DictionaryEnd` functions for managing a dictionary. It shows how to insert string values, retrieve them, and properly terminate the dictionary. Assumes `dict`, `name`, and `str` are previously defined and initialized. ```c vsy_DictionaryInsert(dict, "Three", (Vobject*)"3"); vsy_DictionaryLookup(dict, "Three", (Vobject**)&str); printf("name = %s, string = %s\n", "Three", str); /* delete object */ vsy_DictionaryEnd(dict); ``` -------------------------------- ### Set and Get Pseudocolor Indices (C) Source: https://docs.techsoft3d.com/hoops/mesh/guide/legacy/vis/color-and-transparency Enables setting and retrieving pseudocolor indices within a ColorMap. Indices are set sequentially starting from a specified map index. This is used for pseudocolor maps where indices map to specific colors. ```C void vis_ColorMapSetIndex (vis_ColorMap *p, Vint nmapindex, Vint imapindex, Vint index[]) // ... description ... void vis_ColorMapGetIndex (vis_ColorMap *colormap, Vint nmapindex, Vint imapindex, Vint index[]) ``` -------------------------------- ### Demonstrate Heap Object Functionality in C Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples This C code demonstrates the usage of the `vsy_Heap` module for managing a minimum priority queue. It includes functions for inserting elements, redefining priorities, removing the minimum element, and clearing the heap. The example requires headers from the `sam/base` library and HOOPS license validation. ```c #include #include "sam/base/base.h" #include "sam/base/license.h" #include "sam/hoops_license.h" /*---------------------------------------------------------------------- Test and Demonstrate Heap object ----------------------------------------------------------------------*/ int main() { vsy_Heap* heap; Vint id; Vdouble val; vsy_LicenseValidate(HOOPS_LICENSE); /* instance object */ heap = vsy_HeapBegin(); /* set up heap to return minimum */ vsy_HeapDef(heap, 10, 0); vsy_HeapInsert(heap, 1, 20.); vsy_HeapInsert(heap, 3, 30.); vsy_HeapInsert(heap, 6, 10.); vsy_HeapInsert(heap, 7, 10.001); /* redefine index 6 */ vsy_HeapInsert(heap, 6, 40.001); /* query for minimum and remove */ vsy_HeapRefRemove(heap, &id, &val); printf("\n"); printf("minimum id= %d, val= %e\n", id, val); /* query for minimum */ vsy_HeapRef(heap, &id, &val); printf("\n"); printf("minimum id= %d, val= %e\n", id, val); /* insert new minimum */ vsy_HeapInsert(heap, 2, 5.); vsy_HeapRef(heap, &id, &val); printf("\n"); printf("minimum id= %d, val= %e\n", id, val); /* remove index 1 */ vsy_HeapRemove(heap, 1); /* remove two, if 1 has been removed the 3 is new min */ vsy_HeapRefRemove(heap, &id, &val); vsy_HeapRefRemove(heap, &id, &val); printf("\n"); printf("minimum id= %d, val= %e\n", id, val); /* clear */ vsy_HeapClear(heap); /* check */ vsy_HeapRef(heap, &id, &val); printf("minimum id= %d\n", id); /* delete object */ vsy_HeapEnd(heap); return 0; } ``` -------------------------------- ### Get Mesh Growth Rate Parameter Source: https://docs.techsoft3d.com/hoops/mesh/guide/mesh/3d-curve-and-surface-mesh-generation Retrieves the current value of a double precision mesh parameter. The growth rate parameter, for example, governs how element sizes can increase between adjacent elements. An improper parameter type may result in VIS_ERROR_ENUM. ```c void msh_CurvMeshGetParamd (msh_CurvMesh *curvmesh, Vint ptype, Vdouble *dparam) ``` -------------------------------- ### Create DiscElem Instance in C Source: https://docs.techsoft3d.com/hoops/mesh/guide/legacy/vis/rigid-mass-spring-and-gap-elements Creates an instance of a DiscElem object. This function is the starting point for defining and drawing spring and dashpot elements. It requires prior setup of topology, special type, and local coordinate system. ```c vis_DiscElemBegin() ``` -------------------------------- ### Test Dictionary: Insert, Remove, and Iterate Key-Value Pairs Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples Demonstrates the Dictionary data structure, including initialization, defining capacity, insertion of string keys with object values, removal of entries, and iteration through the dictionary. It shows how to manage key-value pairs and retrieve them. ```c static void test_dictionary(void) { vsy_Dictionary* dict; Vint num, count; Vchar* name; Vchar* str; printf("\nDictionary test\n"); /* instance Dictionary object */ dict = vsy_DictionaryBegin(); /* set initial allocation to two objects */ vsy_DictionaryDef(dict, 2); /* inquire and count */ vsy_DictionaryInq(dict, &num); vsy_DictionaryCount(dict, &count); printf("num = %d, count = %d\n", num, count); /* insert some simple "string" objects */ vsy_DictionaryInsert(dict, "Three", (Vobject*)"three"); vsy_DictionaryInsert(dict, "Zero", (Vobject*)"zero"); vsy_DictionaryInsert(dict, "Two", (Vobject*)"two"); vsy_DictionaryInsert(dict, "One", (Vobject*)"one"); /* remove a couple */ vsy_DictionaryRemove(dict, "Two"); vsy_DictionaryRemove(dict, "Zero"); /* add some */ vsy_DictionaryInsert(dict, "Four", (Vobject*)"four"); vsy_DictionaryInsert(dict, "Fifteen", (Vobject*)"fifteen"); /* now inquire and count */ vsy_DictionaryInq(dict, &num); vsy_DictionaryCount(dict, &count); printf("num = %d, count = %d\n", num, count); /* InitIter,NextIter traversal */ vsy_DictionaryInitIter(dict); while (vsy_DictionaryNextIter(dict, &name, (Vobject**)&str), str != NULL) { ``` -------------------------------- ### Create and Configure Levels Object - C/C++ Source: https://docs.techsoft3d.com/hoops/mesh/guide/legacy/vis/color-and-transparency This C/C++ code snippet demonstrates the creation and basic configuration of a Levels object. It begins an instance, defines the number of levels and scaling method, sets the field value range, generates the levels, and sets a map index for a specific level. ```C/C++ levels = vis_LevelsBegin (); vis_LevelsDef (levels,LEVELS_LINEAR,3); vis_LevelsSetMinMax (levels,0.,1.); vis_LevelsGenerate (levels,LEVELS_PADENDS); vis_LevelsSetIndex (levels,0,5); ``` -------------------------------- ### Get Derived Quantity Information in C Source: https://docs.techsoft3d.com/hoops/mesh/guide/global/data-manipulation These functions retrieve information about derived quantities within a vis_State object. vis_StateGetDerive gets the derived quantity, vis_StateNumDerive gets the number of components, and vis_StateTypeDerive gets the primitive data type. ```c void vis_StateGetDerive(const vis_State *p, Vint *derive) { ... } void vis_StateNumDerive(const vis_State *p, Vint *ncmp) { ... } void vis_StateTypeDerive(const vis_State *p, Vint *typederive) { ... } ``` -------------------------------- ### Demonstrate PQueue Object Functionality in C Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples This C code snippet demonstrates the core functionalities of the PQueue module. It covers inserting elements with priority values, redefining priorities, querying for minimum and maximum values, removing elements, and clearing the priority queue. It requires the HOOPS license and specific SAM base headers. ```c #include #include "sam/base/base.h" #include "sam/base/license.h" #include "sam/hoops_license.h" /*---------------------------------------------------------------------- Test and Demonstrate PQueue object ----------------------------------------------------------------------*/ int main() { vsy_PQueue* pqueue; Vint id; Vdouble val; vsy_LicenseValidate(HOOPS_LICENSE); /* instance object */ pqueue = vsy_PQueueBegin(); /* configure to degrees from 0. to 60. */ vsy_PQueueDef(pqueue, 0, 1024); vsy_PQueueRange(pqueue, 0., 60.); vsy_PQueueInsert(pqueue, 1, 20.); vsy_PQueueInsert(pqueue, 3, 30.); vsy_PQueueInsert(pqueue, 6, 10.); vsy_PQueueInsert(pqueue, 7, 10.001); /* redefine index 6 */ vsy_PQueueInsert(pqueue, 6, 40.001); /* query for minimum and remove */ vsy_PQueueMinMax(pqueue, 0, &id, &val); vsy_PQueueRemove(pqueue, id); printf("\n"); printf("minimum id= %d, val= %e\n", id, val); /* query for minimum */ vsy_PQueueMinMax(pqueue, 0, &id, &val); printf("\n"); printf("minimum id= %d, val= %e\n", id, val); /* insert new minimum */ vsy_PQueueInsert(pqueue, 2, 5.); vsy_PQueueMinMax(pqueue, 0, &id, &val); printf("\n"); printf("minimum id= %d, val= %e\n", id, val); /* query for maximum */ vsy_PQueueMinMax(pqueue, 1, &id, &val); printf("\n"); printf("maximum id= %d, val= %e\n", id, val); /* clear */ vsy_PQueueClear(pqueue); /* check */ vsy_PQueueMinMax(pqueue, 1, &id, &val); printf("maximum id= %d\n", id); /* delete object */ vsy_PQueueEnd(pqueue); return 0; } ``` -------------------------------- ### vis_ConnectNumPartName Source: https://docs.techsoft3d.com/hoops/mesh/guide/global/grid-topology-and-geometry Get the number of part names defined. Use `vis_ConnectIthPartName()` to get a specific part name and associated part identifier. ```APIDOC ## vis_ConnectNumPartName ### Description Get the number of part names defined. ### Method void ### Endpoint vis_ConnectNumPartName(vis_Connect *p, Vint *numpartname) ### Parameters #### Path Parameters - **p** (vis_Connect *) - Required - Pointer to Connect object. - **numpartname** (Vint *) - Out - Number of part names. ``` -------------------------------- ### Get Element Location in VisContext Source: https://docs.techsoft3d.com/hoops/mesh/guide/legacy/vis/attributes Retrieves the element location from a visualization context. This function is used to get the current element location settings. It is paired with `vis_VisContextSetElemLoc()`. ```c void vis_VisContextGetElemLoc(vis_VisContext *p, Vint *elemloc) { // Implementation details omitted } ``` -------------------------------- ### Get Type C Function Source: https://docs.techsoft3d.com/hoops/mesh/guide/global/entity-sets-and-identifier-translation Retrieves the general type integer associated with a HOOPS Mesh group object. This C function is used to get the category of an entity and is related to `vis_GroupSetType()`. ```c void `vis_GroupGetType`(vis_Group *p, Vint *type) ``` -------------------------------- ### C: LinkList Object Management Source: https://docs.techsoft3d.com/hoops/mesh/guide/examples/base-examples This C code snippet demonstrates the functionality of the LinkList object. It covers defining the list's capacity, adding and removing elements, referencing specific elements, iterating through the list, and clearing all elements. Dependencies include sam/base/base.h, sam/base/license.h, and hoops_license.h. ```c #include #include "sam/base/base.h" #include "sam/base/license.h" #include "sam/hoops_license.h" /*---------------------------------------------------------------------- Test and demonstrate LinkList ----------------------------------------------------------------------*/ int main() { Vint index, i1, i2, i3, i4; Vint num, nbytes, count; vsy_LinkList* linklist; Vdouble* d; printf("\nLinkList test\n"); vsy_LicenseValidate(HOOPS_LICENSE); /* instance LinkList object */ linklist = vsy_LinkListBegin(); /* set initial allocation to four objects */ vsy_LinkListDef(linklist, 4, sizeof(Vdouble)); /* inquire and count */ vsy_LinkListInq(linklist, &num, &nbytes); vsy_LinkListCount(linklist, &count); printf("num = %d, nbytes= %d, count = %d\n", num, nbytes, count); /* insert some double objects */ vsy_LinkListAdd(linklist, &i1, (Vobject**)&d); *d = 1000.; vsy_LinkListAdd(linklist, &i2, (Vobject**)&d); *d = 2000.; vsy_LinkListAdd(linklist, &i3, (Vobject**)&d); *d = 3000.; vsy_LinkListAdd(linklist, &i4, (Vobject**)&d); *d = 4000.; /* inquire and count */ vsy_LinkListInq(linklist, &num, &nbytes); vsy_LinkListCount(linklist, &count); printf("num = %d, nbytes= %d, count = %d\n", num, nbytes, count); /* InitIter,NextIter traversal */ vsy_LinkListInitIter(linklist); while (vsy_LinkListNextIter(linklist, &index, (Vobject**)&d), d != NULL) { printf("index = %d, double = %e\n", index, *d); } /* remove a couple */ vsy_LinkListRemove(linklist, i1); vsy_LinkListRemove(linklist, i2); /* lookup */ vsy_LinkListRef(linklist, i3, (Vobject**)&d); printf("index = %d, double = %e\n", i3, *d); vsy_LinkListRef(linklist, i4, (Vobject**)&d); printf("index = %d, double = %e\n", i4, *d); /* now inquire and count */ vsy_LinkListInq(linklist, &num, &nbytes); vsy_LinkListCount(linklist, &count); printf("num = %d, nbytes= %d, count = %d\n", num, nbytes, count); /* InitIter,NextIter traversal */ vsy_LinkListInitIter(linklist); while (vsy_LinkListNextIter(linklist, &index, (Vobject**)&d), d != NULL) { printf("index = %d, double = %e\n", index, *d); } /* clear */ vsy_LinkListClear(linklist); /* inquire and count */ vsy_LinkListInq(linklist, &num, &nbytes); vsy_LinkListCount(linklist, &count); printf("num = %d, nbytes= %d, count = %d\n", num, nbytes, count); /* delete object */ vsy_LinkListEnd(linklist); return 0; } ``` -------------------------------- ### Guide Placement of Unconnected Points with Hints Source: https://docs.techsoft3d.com/hoops/mesh/guide/mesh/3d-curve-and-surface-mesh-generation Utilizes `msh_SurfMeshSetTriHint()` to guide the placement of unconnected points within the triangulation. This is crucial for ensuring points close to preserved edges are correctly integrated. ```c // Set a hint for an unconnected point to guide its placement near an edge // Assuming point_index and edge_hint are defined appropriately msh_SurfMeshSetTriHint(mesh, point_index, edge_hint); ``` -------------------------------- ### Install User-Defined Error Handler (C) Source: https://docs.techsoft3d.com/hoops/mesh/guide/foundation/error-handling-memory-system Installs a pointer to a user-defined error handler function. If a NULL pointer is provided, the default HOOPS Mesh error handler is installed. The error handler receives the calling function's name, an error flag, and a message string. ```c void vut_ErrorSetHandler(void (*func)(const Vchar*, Vint, const Vchar*)); ```