### Server Setup for Remote File Access Source: https://docs.techsoft3d.com/hoops/access/guide/examples/access-examples.html Configures and starts a server to listen for remote file access requests. It involves setting up a VSocket, defining server parameters, and accepting client connections. ```c static int main_server() { vsy_VSocket* vsocket; Vint cid, flag; Vchar hostname[BUFSIZE]; exam8struct inst; /* Get info about this host */ hostname[0] = '\0'; vut_MachInfoHostName(&flag, hostname); if (flag == 0) { printf("Unable to retrieve host name\n"); return 0; } /* Instance and set up VSocket */ vsocket = vsy_VSocketBegin(); vsy_VSocketSetParami(vsocket, VSOCKET_WAITTIME, 10000); vsy_VSocketSetParami(vsocket, VSOCKET_MAXCONNECTIONS, 10); vsy_VSocketDef(vsocket, VSOCKET_SERVER, VSOCKET_NET); vsy_VSocketSetNet(vsocket, 10000, hostname); vsy_VSocketOpen(vsocket); vsy_VSocketAccept(vsocket, &cid); inst.vsocket = vsocket; inst.cid = cid; /* call server */ server(&inst); /* shut server down and cleanup */ vsy_VSocketClose(vsocket, 0); vsy_VSocketEnd(vsocket); return 0; } ``` -------------------------------- ### DataSource Example Source: https://docs.techsoft3d.com/hoops/access/guide/cpp-api/access/data-source.html Illustrates how to use the DataSource class with practical code examples. ```APIDOC ## DataSource Example This section contains practical examples demonstrating the usage of the DataSource class. These examples showcase common scenarios and provide code snippets that users can adapt for their specific applications. Examples may include loading data, accessing model information, and manipulating data structures. ``` -------------------------------- ### Compile Data Provider Framework with CMake Source: https://docs.techsoft3d.com/hoops/access/frameworks/dataprovider/programming-guide.html Use CMake to configure and build the DataProviderFramework and its associated plugins and example applications. Ensure you have CMake installed and follow the specified directory structure. ```bash > cmake ../DataProvider ``` -------------------------------- ### Open and Append Files Example Source: https://docs.techsoft3d.com/hoops/access/guide/examples/access-examples.html This example demonstrates how to open a primary file and append multiple secondary files of various formats. It includes error checking and setting conventions for data handling. ```c filetype = VDM_STLBIN; stlfil = vdm_STLFilBegin(); vdm_STLFilDataFun(stlfil, datafun); } else if (strstr(argv[1], ".vdm") != NULL) { filetype = VDM_NATIVE; natlib = vdm_NatLibBegin(); vdm_NatLibDataFun(natlib, datafun); } else if (strstr(argv[1], ".dsy") != NULL || strstr(argv[1], ".DSY") != NULL) { filetype = VDM_PAM_DAISY; pamlib = vdm_PAMLibBegin(); vdm_PAMLibDataFun(pamlib, datafun); } else if (strstr(argv[1], ".out") != NULL) { filetype = VDM_PATRAN_NEUTRAL; patlib = vdm_PatLibBegin(); vdm_PatLibDataFun(patlib, datafun); } else if (strstr(argv[1], ".x") != NULL) { filetype = VDM_PLOT3D_GRID; plot3dlib = vdm_PLOT3DLibBegin(); vdm_PLOT3DLibSetGridType(plot3dlib, PLOT3DLIB_MULTIPLE, 3, SYS_OFF); vdm_PLOT3DLibDataFun(plot3dlib, datafun); } else if (strstr(argv[1], ".cas") != NULL) { filetype = VDM_FLUENT_MESH; fluentlib = vdm_FLUENTLibBegin(); vdm_FLUENTLibDataFun(fluentlib, datafun); } else if (strstr(argv[1], ".cgns") != NULL) { filetype = VDM_CGNS; cgnsvlib = vdm_CGNSVLibBegin(); vdm_CGNSVLibDataFun(cgnsvlib, datafun); } else if (strstr(argv[1], ".encas") != NULL) { filetype = VDM_ENSIGHT; ensightlib = vdm_EnSightLibBegin(); vdm_EnSightLibDataFun(ensightlib, datafun); } else if (strstr(argv[1], ".ccm") != NULL) { filetype = VDM_STARCCM; starccmlib = vdm_STARCCMLibBegin(); vdm_STARCCMLibDataFun(starccmlib, datafun); } else if (strstr(argv[1], ".plt") != NULL) { filetype = VDM_TECPLOT; tecplotlib = vdm_TecplotLibBegin(); vdm_TecplotLibDataFun(tecplotlib, datafun); } else if (strstr(argv[1], ".t16") != NULL) { filetype = VDM_MARC_POST; marclib = vdm_MarcLibBegin(); vdm_MarcLibDataFun(marclib, datafun); } else { fprintf(stderr, "Error: Bad input file %s\n", argv[1]); exit(0); } /* set conventions */ vdm_DataFunSetConvention(datafun, VDM_CONVENTION_SPARSE); /* open library device */ vdm_DataFunOpen(datafun, 0, argv[1], filetype); vdm_DataFunGetLibrary(datafun, &library); /* check for error */ ierr = vdm_DataFunError(datafun); if (ierr) { fprintf(stderr, "Error: opening file %s\n", argv[1]); exit(0); } /* instance lman object */ lman = vdm_LManBegin(); vdm_LManSetObject(lman, VDM_DATAFUN, datafun); vdm_LManSetParami(lman, LMAN_VERBOSE, SYS_ON); vdm_LManTOC(lman, "*"); /* append library devices */ for (i = 2; i < argc; i++) { if (strstr(argv[i], ".op2") != NULL || strstr(argv[i], ".OP2") != NULL) { filetype1 = VDM_NASTRAN_OUTPUT2; } else if (strstr(argv[i], ".unv") != NULL || strstr(argv[i], ".bun") != NULL || strstr(argv[i], ".bud") != NULL) { filetype1 = VDM_SDRC_UNIVERSAL; } else if (strstr(argv[i], ".vdm") != NULL) { filetype1 = VDM_NATIVE; } else if (strstr(argv[i], ".dis") != NULL) { filetype1 = VDM_PATRAN_RESULT; } else if (strstr(argv[i], ".q") != NULL) { filetype1 = VDM_PLOT3D_SOLUTION; } else if (strstr(argv[i], ".dat") != NULL || strstr(argv[i], ".cas") != NULL) { filetype1 = VDM_FLUENT_MESH; } else if (strstr(argv[i], ".cgns") != NULL) { filetype1 = VDM_CGNS; } else { fprintf(stderr, "Error: Bad input file %s\n", argv[i]); exit(0); } /* set Ids computation for certain appended file types */ if (filetype1 == VDM_CGNS) { vdm_LibraryMaxIds(library, &id1, &id2, &id3); vdm_DataFunSetIds(datafun, VDM_IDS_BASE, id1 + 1, 0, 0); } vdm_DataFunAppend(datafun, argv[i], filetype1); /* check for error */ ierr = vdm_DataFunError(datafun); if (ierr) { fprintf(stderr, "Error: appending file %s to file %s\n", argv[i], argv[1]); exit(0); } vdm_LManTOC(lman, "*"); } /* now export all datasets */ vdm_LManExport(lman, (Vchar*)"*", (Vchar*)"exam5.exp"); vdm_LManEnd(lman); /* close library device */ vdm_DataFunClose(datafun); /* free objects */ vdm_DataFunEnd(datafun); if (filetype == VDM_NASTRAN_BULKDATA) { vdm_NASFilEnd(nasfil); } else if (filetype == VDM_SDRC_UNIVERSAL) { vdm_SDRCLibEnd(sdrclib); } else if (filetype == VDM_MECHANICA_STUDY) { vdm_RASLibEnd(raslib); } else if (filetype == VDM_ABAQUS_FIL) { vdm_ABALibEnd(abalib); } else if (filetype == VDM_ABAQUS_INPUT) { vdm_ABAFilEnd(abafil); } else if (filetype == VDM_ANSYS_RESULT) { ``` -------------------------------- ### Install Printing File Path Source: https://docs.techsoft3d.com/hoops/access/guide/c-api/foundation/error-handling-memory-system.html Installs a file descriptor associated with a path for all printing operations. If the path is NULL, the current file descriptor is closed and the default is installed. If a path is provided, a file descriptor to that path is opened and installed. ```c void vut_PrintSetPath(Vchar *path) ``` -------------------------------- ### Minimal Plugin Example in C++ Source: https://docs.techsoft3d.com/hoops/access/tutorials/use-custom-reader.html This is the complete source code for a minimal plugin example. It demonstrates how to initialize the plugin manager, load a plugin, open a data file, and retrieve various types of state data. ```cpp #ifdef CEE_SAM_DATA_PROVIDER_FRAMEWORK #include #include "sam/base/base.h" #include "sam/vdm/vdm.h" #include "sam/vdm/plugins/pluginmanager.h" #include "sam/vdm/datafile.h" #include "sam/base/license.h" #include "sam/hoops_license.h" /*---------------------------------------------------------------------- Plugin use example ----------------------------------------------------------------------*/ int main(int argc, char** argv) { Vchar pluginLibraryPath[SYS_MAXPATHCHAR] = {0}; /* check input arguments */ if (argc < 2) { fprintf(stderr, "Usage: %s cdp_MinimalPluginPath\n", argv[0]); fprintf(stderr, " cdp_MinimalPluginPath is blank, 'cdp_MinimalPlugin' is assumed\n"); strcpy(pluginLibraryPath, "cdp_MinimalPlugin"); } else { strcpy(pluginLibraryPath, argv[1]); } /* Set the license */ vsy_LicenseValidate(HOOPS_LICENSE); /* Look for the plugin */ vdm_PluginManager* pluginManager = vdm_PluginManagerBegin(); /* Set the error level as INFO=3 */ vdm_PluginManagerSetErrorLevel(pluginManager, 3); vdm_PluginManagerLoadPlugin(pluginManager, pluginLibraryPath); Vint error = vdm_PluginManagerError(pluginManager); if (error) { vdm_PluginManagerEnd(pluginManager); fprintf(stderr, "%s file does not exists. The library extension must not be included in the path.\n", pluginLibraryPath); exit(1); } vdm_LMan* libraryManager = vdm_LManBegin(); vdm_LManOpenFile(libraryManager, (Vchar*)"MINIMAL", nullptr); /* check for error */ Vint ierr = vdm_LManError(libraryManager); if (ierr) { fprintf(stderr, "Error: opening MinimalPlugin \n"); vdm_LManCloseFile(libraryManager); vdm_LManEnd(libraryManager); vdm_PluginManagerEnd(pluginManager); exit(1); } /* Print table of contents */ vdm_LManSetParami(libraryManager, LMAN_VERBOSE, SYS_ON); vdm_LManTOC(libraryManager, "*"); /* Load state 1: temperature */ { vis_State* stateTemperature = vis_StateBegin(); vdm_LManLoadStateFromName(libraryManager, (Vchar*)"TEMP.N", stateTemperature); Vfloat values[2] = {0}; Vint nodeIdsCount = 2; Vint nodeIds[2] = {2, 4}; vis_StateData(stateTemperature, nodeIdsCount, nodeIds, values); printf("Temperature:\n"); /* Node 2: 2.000000e+00 */ printf("Node %d: %14e\n", nodeIds[0], values[0]); /* Node 4: 4.000000e+00 */ printf("Node %d: %14e\n", nodeIds[1], values[1]); vis_StateEnd(stateTemperature); } /* Load state 2: displacement */ { vis_State* stateDisplacement = vis_StateBegin(); vdm_LManLoadStateFromName(libraryManager, (Vchar*)"D.N", stateDisplacement); Vfloat values[3] = {0}; Vint nodeIdsCount = 1; Vint nodeIds[1] = {3}; vis_StateData(stateDisplacement, nodeIdsCount, nodeIds, values); printf("Displacement:\n"); /* Node 3: 0.000000e+00, -2.000000e+00, 5.000000e-01 */ printf("Node %d: %14e, %14e, %14e\n", nodeIds[0], values[0], values[1], values[2]); vis_StateEnd(stateDisplacement); } /* Load state 3: stresses */ { vis_State* stateStresses = vis_StateBegin(); vdm_LManLoadStateFromName(libraryManager, (Vchar*)"S.EL", stateStresses); Vfloat values[6 * 3] = {0}; Vint elementIdsCount = 1; Vint elementIds[1] = {2}; vis_StateData(stateStresses, elementIdsCount, elementIds, values); /* Retrieve the connect */ vis_Connect* connect = nullptr; vdm_LManGetConnect(libraryManager, &connect); /* check for error */ ierr = vdm_LManError(libraryManager); if (ierr) { fprintf(stderr, "Error: loading mesh info\n"); vis_StateEnd(stateStresses); vdm_LManEnd(libraryManager); vdm_PluginManagerEnd(pluginManager); exit(1); } /* Retrieve the element user id */ Vint elementUserId = 0; vis_ConnectElemAssoc(connect, VIS_USERID, 1, &elementIds[0], &elementUserId); /* Retrieve the element connectivity */ Vint numberOfElementNodes = 0; Vint elementNodes[3] = {0}; vis_ConnectElemNode(connect, elementIds[0], &numberOfElementNodes, elementNodes); printf("Stress:\n"); for (unsigned i = 0; i < 3; ++i) { ``` -------------------------------- ### Demonstrate Timer Object Functionality Source: https://docs.techsoft3d.com/hoops/access/guide/examples/base-examples.html This example demonstrates the use of the Timer module to accumulate timing information for different timed sections. It shows starting, stopping, and retrieving timing data for sections like 'PlusOne' and 'Multiply'. Functions like vsy_TimerInit(), vsy_TimerRemove(), and vsy_TimerClear() are also illustrated. ```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); } } ``` -------------------------------- ### Complete Source Code Example Source: https://docs.techsoft3d.com/hoops/access/tutorials/print-table-of-contents.html The full C source code for the table of contents printing example, including all steps from initialization to cleanup. ```c 1#include "sam/base/base.h" 2#include "sam/vdm/vdm.h" 3#include "sam/base/license.h" 4#include "sam/hoops_license.h" 5 6/*---------------------------------------------------------------------- 7 Print Table of Contents 8----------------------------------------------------------------------*/ 9int 10main(int argc, char** argv) 11{ 12 char inputFile[256]; 13 /* check input arguments */ 14 if (argc < 2) { 15 fprintf(stderr, "Usage: %s inputfile [appendfile]\n", argv[0]); 16 fprintf(stderr, " inputfile is blank, 'bumper.unv' is assumed\n"); 17 strcpy(inputFile, "bumper.unv"); 18 } 19 else { 20 strcpy(inputFile, argv[1]); 21 } 22 23 vsy_LicenseValidate(HOOPS_LICENSE); 24 25 /* Open file */ 26 vdm_LMan* libraryManager = vdm_LManBegin(); 27 vdm_LManOpenFile(libraryManager, inputFile, nullptr); 28 29 /* check for error */ 30 Vint ierr = vdm_LManError(libraryManager); 31 if (ierr) { 32 fprintf(stderr, "Error: opening file %s\n", inputFile); ``` -------------------------------- ### Initialize and Setup Source: https://docs.techsoft3d.com/hoops/access/tutorials/print-table-of-contents.html Includes necessary headers, declares variables, and handles command line arguments. Validates the license using vsy_LicenseValidate(). ```c #include "sam/base/base.h" #include "sam/vdm/vdm.h" #include "sam/base/license.h" #include "sam/hoops_license.h" int main(int argc, char** argv) { char inputFile[256]; /* check input arguments */ if (argc < 2) { fprintf(stderr, "Usage: %s inputfile [appendfile]\n", argv[0]); fprintf(stderr, " inputfile is blank, 'bumper.unv' is assumed\n"); strcpy(inputFile, "bumper.unv"); } else { strcpy(inputFile, argv[1]); } vsy_LicenseValidate(HOOPS_LICENSE); ``` -------------------------------- ### Status getStartingIndex(int *index) Source: https://docs.techsoft3d.com/hoops/access/guide/cpp-api/core/intvector.html Get the starting index of the IntVector object. ```APIDOC ## Status getStartingIndex(int *index) ### Description Get the starting index of the IntVector object. ### Parameters #### Path Parameters - **index** (int *) - [out] Starting index ### Returns Status ``` -------------------------------- ### Initialize and Setup C++ Source: https://docs.techsoft3d.com/hoops/access/tutorials/print-table-of-contents.html Includes necessary headers, declares variables, and handles command line arguments for file input. Validates the license using HOOPS_LICENSE. ```cpp #include "samcpp/core/core.h" #include "samcpp/access/access.h" #include "sam/hoops_license.h" #include /*---------------------------------------------------------------------- Print Table of Contents ----------------------------------------------------------------------*/ int main(int argc, char** argv) { char inputFile[cae::core::MAX_NAME_LENGTH] = {}; // Check input arguments if (argc < 2) { std::cerr << "Usage: " << argv[0] << " inputfile [appendfile]\n"; std::cerr << " inputfile is blank, 'bumper.unv' is assumed\n"; strcpy(inputFile, "bumper.unv"); } else { strcpy(inputFile, argv[1]); } cae::core::license::validate(HOOPS_LICENSE); ``` -------------------------------- ### Install User Error Handler and Memory Management in C++ Source: https://docs.techsoft3d.com/hoops/access/guide/access/library-device-interfaces This C++ example demonstrates how to install a user-defined error handler and manage memory using HOOPS Access. This allows for custom error reporting and control over memory allocation. ```cpp /* This is a placeholder for the actual C++ code. This example shows how to intercept and handle errors, and potentially manage memory allocation/deallocation. */ #include // Placeholder for user-defined error handler void my_error_handler(int error_code, const char* message) { std::cerr << "Custom Error: " << message << " (Code: " << error_code << ")" << std::endl; } void example_user_error_memory_management() { // Placeholder for HOOPS Access API calls std::cout << "Installing user error handler and memory management..." << std::endl; // Example: HOOPS_Set_Error_Handle(my_error_handler); // Example: HOOPS_Set_Memory_Hooks(...); std::cout << "Finished installing user error handler and memory management." << std::endl; } ``` -------------------------------- ### Get Current Error Object Source: https://docs.techsoft3d.com/hoops/access/guide/c-api/foundation/error-handling-memory-system.html Use vut_ErrorGetObject to retrieve the pointer to the currently installed user-defined error object. This allows your application to access or manage the error object. ```c void vut_ErrorGetObject(Vobject **object) ``` -------------------------------- ### List Datasets on a Library Device Source: https://docs.techsoft3d.com/hoops/access/index.html This example demonstrates how to list all available datasets on a specified library device. It's useful for understanding the contents of a dataset before accessing specific data. ```c++ #include "hc_access.h" #include int main() { HC_OPEN_ితి "/path/to/your/library.h5" int num_datasets; HC_GET_INTEGER("num datasets", &num_datasets); for (int i = 0; i < num_datasets; ++i) { char dataset_name[256]; sprintf(dataset_name, "dataset name[%d]", i); HC_GET_STRING(dataset_name, dataset_name); std::cout << "Dataset: " << dataset_name << std::endl; } HC_CLOSE_ితి return 0; } ``` -------------------------------- ### Get an Index Number - C API Source: https://docs.techsoft3d.com/hoops/access/guide/c-api/global/data-manipulation.html Retrieves a specific parent entity index based on its sequential position. The `in` parameter specifies which index to retrieve, starting from 0. ```c void vis_HistoryGetIndex(vis_History *p, Vint in, Vint *index) ``` -------------------------------- ### Create Options and Open File (C API) Source: https://docs.techsoft3d.com/hoops/access/tutorials/file-to-file-translation.html Initializes options for the Library Manager, setting the numeric convention to double precision. Then, it begins the Library Manager and opens the input file. ```c /* Open file */ vdm_Options* options = vdm_OptionsBegin(); vdm_OptionsAddConvention(options, VDM_CONVENTION_DOUBLE); vdm_LMan* libraryManager = vdm_LManBegin(); vdm_LManOpenFile(libraryManager, inputFile, options); ``` -------------------------------- ### Complete Source Code Example Source: https://docs.techsoft3d.com/hoops/access/tutorials/print-results-data.html The full C++ source code for the tutorial, including file handling, model loading, and result printing functions. ```cpp #include "samcpp/core/core.h" #include "samcpp/access/access.h" #include "sam/hoops_license.h" #include #include #include #include #include static void print_displacement(cae::access::DataSource& dataSource, cae::core::MeshPtr& mesh); static void print_temperature_gradient(cae::access::DataSource& dataSource, cae::core::MeshPtr& mesh); static void print_stress(cae::access::DataSource& dataSource, cae::core::MeshPtr& mesh); static void print_result(cae::access::DataSource& dataSource, cae::core::MeshPtr& mesh); static void print_section(cae::core::LayerPosition position, int section); /*---------------------------------------------------------------------- Read and Print Results State Data ----------------------------------------------------------------------*/ int main(int argc, char** argv) { char inputFile[cae::core::MAX_NAME_LENGTH] = {}; // Check input arguments if (argc < 2) { std::cerr << "Usage: " << argv[0] << " inputfile [appendfile]\n"; std::cerr << " inputfile is blank, 'cantilever.unv' is assumed\n"; strcpy(inputFile, "cantilever.unv"); } else { strcpy(inputFile, argv[1]); } cae::core::license::validate(HOOPS_LICENSE); // Open file cae::access::Options options; options.enableConvention(cae::access::Options::Convention::SPARSE); cae::access::DataSource dataSource; cae::core::Status status = dataSource.openFile(inputFile, &options); // Check for error if (!status) { std::cerr << "Error: opening file " << inputFile << '\n'; exit(1); } // Look for appended file for (int i = 2; i < argc; i++) { status = dataSource.appendFile(argv[i]); // Check for error if (!status) { std::cerr << "Error: appending file " << argv[i] << " to file " << argv[1] << '\n'; exit(1); } } // Instance Model object for finite element model cae::core::Model model; dataSource.loadModel(&model); // Get Mesh object created in Model cae::core::MeshPtr mesh; model.getMesh(mesh); int nodesCount = 0; int elementsCount = 0; mesh->inquire(&nodesCount, &elementsCount); std::cout << "number of nodes= " << nodesCount << '\n'; std::cout << "number of elems= " << elementsCount << '\n'; // Access and print displacements print_displacement(dataSource, mesh); // Access and print temperature gradients print_temperature_gradient(dataSource, mesh); // Access and print stresses print_stress(dataSource, mesh); // Access and print all results print_result(dataSource, mesh); return 0; } cae::core::State::DerivedType ``` -------------------------------- ### Instantiate TextFun and HTMLText Objects and Open File Source: https://docs.techsoft3d.com/hoops/access/guide/c-api/foundation/text-processing.html This snippet demonstrates the initialization process for text formatting. It involves creating instances of TextFun and HTMLText objects, linking them for HTML formatting, and opening a file for output. Ensure these objects are properly instantiated before performing text operations. ```c vsy_HTMLText *htmltext; vsy_TextFun *tf; /* create text function */ tf = vsy_TextFunBegin(); /* create HTML formatting object */ htmltext = vsy_HTMLTextBegin(); /* load text functions for HTML formatting */ vsy_HTMLTextTextFun (htmltext,tf); /* open file */ vsy_TextFunOpenFile (tf,"example.htm"); ``` -------------------------------- ### Get Data Type of Derived Quantity - C Source: https://docs.techsoft3d.com/hoops/access/guide/c-api/global/data-manipulation.html Retrieves the primitive data type of the current derived quantity. This is useful for determining how to interpret the raw data, for example, knowing if a vector magnitude is stored as a scalar. ```c void vis_StateTypeDerive(const vis_State *p, Vint *typederive) ``` -------------------------------- ### vis_ConnectElemNum Source: https://docs.techsoft3d.com/hoops/access/guide/c-api/global/grid-topology-and-geometry.html Gets the number of faces, edges, or nodes in a given element. For example, a hexahedral element has 6 faces. If an invalid element feature type or element index is provided, the function returns zero or has undefined behavior, respectively. ```APIDOC ## 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. ### Parameters * **p** (const vis_Connect *) – Pointer to Connect object. * **type** (Vint) – Type of element feature. ``` =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. ``` -------------------------------- ### Get Element Entity Corner Connection Numbers Source: https://docs.techsoft3d.com/hoops/access/guide/cpp-api/core/mesh-interface.html Retrieves the corner node connection numbers for a specified element face or edge. These numbers indicate the positions of nodes within the element's connectivity list, starting from 1 for the first position. ```APIDOC ## getElementEntityCornerConnectionNumbers ### Description Get the corner node connection numbers of a specified element face or edge. Node corner connection numbers specify positions of nodes in the element node connectivity list. The first position in the element node connectivity has a node connection number of 1. ### Parameters * **entityType** (`EntityType`) - Specifies the type of entity (ELEMENT, EDGE, FACE). * **index** (int) - Element index. * **entityNumber** (int) - Element face or edge number. * **nodeCount** ([out] int *) - Number of corner nodes. * **connectionNumbers** ([out] int *) - Array of corner node connection numbers. ### Returns Status ``` -------------------------------- ### VSocket Server Implementation Source: https://docs.techsoft3d.com/hoops/access/guide/examples/base-examples.html Demonstrates how to set up and manage a VSocket server to accept client connections, read data, and process commands. Includes handling client disconnections and server shutdown. ```c static void server(Vobject* inst) { /* ... server logic ... */ } void exam22server(void) { vut_MachInfoHostName(&flag, hostname); if (flag == 0) { printf("SERVER: Unable to retrieve host name\n"); return; } /* Instance and set up VSocket */ vsocket = vsy_VSocketBegin(); vsy_VSocketSetParami(vsocket, VSOCKET_WAITTIME, 10); vsy_VSocketSetParami(vsocket, VSOCKET_MAXCONNECTIONS, 1); vsy_VSocketDef(vsocket, VSOCKET_SERVER, VSOCKET_NET); vsy_VSocketSetNet(vsocket, 10000, hostname); vsy_VSocketOpen(vsocket); if (vsy_VSocketError(vsocket)) { printf("SERVER: Unable to Open\n"); return; } /* Instance list to store client instances */ list = vsy_ListBegin(); for (i = 0; i < 5; ++i) { vsy_VSocketAccept(vsocket, &cid); if (cid == 0) break; vsy_VSocketReadString(vsocket, cid, BUFSIZE, buffer, &size); /* check for stop server command */ if (strstr(buffer, "stop")) { vsy_VSocketClose(vsocket, cid); break; } /* establish new connection in thread */ inst = (exam22struct*)malloc(sizeof(exam22struct)); vsy_ListInsert(list, cid, (Vobject*)inst); inst->vsocket = vsocket; inst->cid = cid; strcpy(inst->firstbuf, buffer); server((Vobject*)inst); } /* Close connection and cleanup */ vsy_VSocketSetParami(vsocket, VSOCKET_WAITTIME, 1); vsy_ListForEach(list, (Vfunc1*)exam22term); vsy_VSocketClose(vsocket, 0); vsy_ListEnd(list); vsy_VSocketEnd(vsocket); return; } ``` -------------------------------- ### List Datasets on a Library Device Source: https://docs.techsoft3d.com/hoops/access/guide/access/library-device-interfaces This C++ example demonstrates how to list all available datasets on a given library device using HOOPS Access. It shows the basic steps for initializing the library and querying dataset information. ```c++ #include #include int main() { HAccHandle hAcc; HAccStatus status = HAcc_Open("my_library.dat", &hAcc); if (status == HAcc_Success) { char dataset_name[256]; int i = 0; while (HAcc_GetDatasetName(hAcc, i, dataset_name, sizeof(dataset_name)) == HAcc_Success) { std::cout << "Dataset " << i << ": " << dataset_name << std::endl; i++; } HAcc_Close(hAcc); } else { std::cerr << "Failed to open library: " << status << std::endl; } return 0; } ``` -------------------------------- ### Install Printing File Descriptor Source: https://docs.techsoft3d.com/hoops/access/guide/c-api/foundation/error-handling-memory-system.html Installs a file descriptor for all printing operations in DevTools. If NULL is passed, the default file descriptor (stdout) is installed. ```c void vut_PrintSetFile(FILE *fd) ``` -------------------------------- ### Demonstrate Integer Dictionary (IntDict) Operations Source: https://docs.techsoft3d.com/hoops/access/guide/examples/base-examples.html Provides an example of using IntDict for key-value integer storage, including insertion, lookup, iteration, clearing, and object management. ```c static void test_intdict(void) { vsy_IntDict* intdict; Vint num, count; Vchar* name; Vint val; printf("\nIntDict test\n"); /* instance IntDict object */ intdict = vsy_IntDictBegin(); /* set initial allocation to two integers */ vsy_IntDictDef(intdict, 2); /* inquire and count */ vsy_IntDictInq(intdict, &num); vsy_IntDictCount(intdict, &count); printf("num = %d, count = %d\n", num, count); /* insert some integers */ vsy_IntDictInsert(intdict, "105", 105); vsy_IntDictInsert(intdict, "103", 103); vsy_IntDictInsert(intdict, "100", 100); vsy_IntDictInsert(intdict, "102", 102); vsy_IntDictInsert(intdict, "101", 101); /* lookup a legal value */ vsy_IntDictLookup(intdict, "101", &val); printf("value = %d\n", val); /* lookup a illegal value */ vsy_IntDictLookup(intdict, "104", &val); printf("value = %d\n", val); /* now inquire and count */ vsy_IntDictInq(intdict, &num); vsy_IntDictCount(intdict, &count); printf("num = %d, count = %d\n", num, count); /* InitIter,NextIter traversal */ vsy_IntDictInitIter(intdict); while (vsy_IntDictNextIter(intdict, &name, &val), name != NULL) { printf("name = %s, value = %d\n", name, val); } /* clear */ vsy_IntDictClear(intdict); /* inquire and count */ vsy_IntDictInq(intdict, &num); vsy_IntDictCount(intdict, &count); printf("num = %d, count = %d\n", num, count); /* delete object */ vsy_IntDictEnd(intdict); } ``` -------------------------------- ### Get Solution Property ID Source: https://docs.techsoft3d.com/hoops/access/guide/cpp-api/core/solution-properties.html Gets the solution property identifier. ```APIDOC ## getId(int *id) ### Description Get the solution property identifier. ### Parameters * **id** (`int*`) - [out] Solution property identifier ### Returns Status ``` -------------------------------- ### Load Plugin and Access Datasets with LMan Source: https://docs.techsoft3d.com/hoops/access/guide/examples/access-examples.html Illustrates loading a plugin using PluginManager and accessing datasets with LMan. Requires building the MinimalPlugin example. Ensure the library extension is not included in the path. ```c #ifdef CEE_SAM_DATA_PROVIDER_FRAMEWORK #include #include "sam/base/base.h" #include "sam/vdm/vdm.h" #include "sam/vdm/plugins/pluginmanager.h" #include "sam/vdm/datafile.h" #include "sam/base/license.h" #include "sam/hoops_license.h" /*---------------------------------------------------------------------- Plugin use example ----------------------------------------------------------------------*/ int main(int argc, char** argv) { Vchar pluginLibraryPath[SYS_MAXPATHCHAR] = {0}; /* check input arguments */ if (argc < 2) { fprintf(stderr, "Usage: %s cdp_MinimalPluginPath\n", argv[0]); fprintf(stderr, " cdp_MinimalPluginPath is blank, 'cdp_MinimalPlugin' is assumed\n"); strcpy(pluginLibraryPath, "cdp_MinimalPlugin"); } else { strcpy(pluginLibraryPath, argv[1]); } /* Set the license */ vsy_LicenseValidate(HOOPS_LICENSE); /* Look for the plugin */ vdm_PluginManager* pluginManager = vdm_PluginManagerBegin(); /* Set the error level as INFO=3 */ vdm_PluginManagerSetErrorLevel(pluginManager, 3); vdm_PluginManagerLoadPlugin(pluginManager, pluginLibraryPath); Vint error = vdm_PluginManagerError(pluginManager); if (error) { vdm_PluginManagerEnd(pluginManager); fprintf(stderr, "%s file does not exists. The library extension must not be included in the path.\n", pluginLibraryPath); exit(1); } vdm_LMan* libraryManager = vdm_LManBegin(); vdm_LManOpenFile(libraryManager, (Vchar*)"MINIMAL", nullptr); /* check for error */ Vint ierr = vdm_LManError(libraryManager); if (ierr) { fprintf(stderr, "Error: opening MinimalPlugin \n"); vdm_LManCloseFile(libraryManager); vdm_LManEnd(libraryManager); vdm_PluginManagerEnd(pluginManager); exit(1); } /* Print table of contents */ vdm_LManSetParami(libraryManager, LMAN_VERBOSE, SYS_ON); vdm_LManTOC(libraryManager, "*"); /* Load state 1: temperature */ { vis_State* stateTemperature = vis_StateBegin(); vdm_LManLoadStateFromName(libraryManager, (Vchar*)"TEMP.N", stateTemperature); Vfloat values[2] = {0}; Vint nodeIdsCount = 2; Vint nodeIds[2] = {2, 4}; vis_StateData(stateTemperature, nodeIdsCount, nodeIds, values); printf("Temperature:\n"); /* Node 2: 2.000000e+00 */ printf("Node %d: %14e\n", nodeIds[0], values[0]); /* Node 4: 4.000000e+00 */ printf("Node %d: %14e\n", nodeIds[1], values[1]); vis_StateEnd(stateTemperature); } /* Load state 2: displacement */ { vis_State* stateDisplacement = vis_StateBegin(); vdm_LManLoadStateFromName(libraryManager, (Vchar*)"D.N", stateDisplacement); Vfloat values[3] = {0}; Vint nodeIdsCount = 1; Vint nodeIds[1] = {3}; vis_StateData(stateDisplacement, nodeIdsCount, nodeIds, values); printf("Displacement:\n"); /* Node 3: 0.000000e+00, -2.000000e+00, 5.000000e-01 */ printf("Node %d: %14e, %14e, %14e\n", nodeIds[0], values[0], values[1], values[2]); vis_StateEnd(stateDisplacement); } /* Load state 3: stresses */ { vis_State* stateStresses = vis_StateBegin(); vdm_LManLoadStateFromName(libraryManager, (Vchar*)"S.EL", stateStresses); Vfloat values[6 * 3] = {0}; Vint elementIdsCount = 1; Vint elementIds[1] = {2}; vis_StateData(stateStresses, elementIdsCount, elementIds, values); /* Retrieve the connect */ vis_Connect* connect = nullptr; vdm_LManGetConnect(libraryManager, &connect); /* check for error */ ierr = vdm_LManError(libraryManager); if (ierr) { fprintf(stderr, "Error: loading mesh info\n"); vis_StateEnd(stateStresses); vdm_LManEnd(libraryManager); vdm_PluginManagerEnd(pluginManager); exit(1); } /* Retrieve the element user id */ Vint elementUserId = 0; vis_ConnectElemAssoc(connect, VIS_USERID, 1, &elementIds[0], &elementUserId); /* Retrieve the element connectivity */ Vint numberOfElementNodes = 0; Vint elementNodes[3] = {0}; vis_ConnectElemNode(connect, elementIds[0], &numberOfElementNodes, elementNodes); printf("Stress:\n"); for (unsigned i = 0; i < 3; ++i) { /* Retrieve the node user id */ ``` -------------------------------- ### Install User-Defined Error Handler Source: https://docs.techsoft3d.com/hoops/access/guide/c-api/foundation/error-handling-memory-system.html Use vut_ErrorSetHandler to install a pointer to a custom error handling function. Passing a NULL pointer installs the default HOOPS Access error handler. ```c void vut_ErrorSetHandler(void (*func)(const Vchar*, Vint, const Vchar*)) ```