I am developing an External Application that works on geometries with NURBS surfaces. I am looking to create a mesh using a heuristic approach. For this I need to query points on the surfaces using the parametric values. I use the routines below that give me the correct result but seem to use a lot of memory and does not seem to deallocate any memory after the routine ends. I call this piece of code recursively and each pass just blocks more memory. What might I be missing here? Is there a more efficient way to do this using C++ API instead of the C API.
UF_EVALSF_p_t evaluator;
int deriv_flag=UF_MODL_EVAL;
double uv_pairs[2];
//
UF_MODL_SRF_VALUE_t surf_evals;
//uf_list_p_t tFaces;
tag_t tFeature = NULL_TAG; // Feature tag
// initialize evaluator
UF_CALL(UF_EVALSF_initialize(m_Tag, &evaluator));
UF_EVALSF_pc_t pc_evaluator=evaluator;
//
uv_pairs[0]=paramUValue;
uv_pairs[1]=paramVValue;
//
UF_CALL(UF_EVALSF_evaluate(pc_evaluator,deriv_flag,uv_pairs,&surf_evals));
//
MyPoint Pt;
Pt.X = surf_evals.srf_pos[0];
Pt.Y = surf_evals.srf_pos[1];
Pt.Z = surf_evals.srf_pos[2];
//
UF_CALL(UF_EVALSF_free(&evaluator));
Thanks for all the help!!!
re: memory issues
When I started reading, I was going to suggest that you call the appropriate "free" function to free the memory; but I see that you are already doing that.
If it is not freeing the memory as it should be, the best course of action would be to contact GTAC (Siemens NX technical support). They may have some advice on what exactly is happening and why. If it is a bug in the software, they will be able to fix it (probably in a future version).
Surface evaluators
The call to UF_EVALSF_free should free up the allocated memory in NX's internal pool, but this memory might not be immediately returned to Windows, so Windows will see it as still in use.
Maybe this is obvious ... you only have to call UF_EVALSF_initialize once, and then you can call UF_EVALSF_evaluate as many times as you like. So, you should only require memory for one UF_EVALSF_p_t structure, which won't be very large.