Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in Visual Studio 2010 with NX8.5

Status
Not open for further replies.

WilsonBlr

Aerospace
Jun 11, 2014
19


Visual Studio 2010 behaves in a weird manner.
I have a function to extract control points from a surface in which i use UF_MODL_ask_bsurf(). Sometimes VS executes past the code line and prints the control points on console. Some other times it stops at UF_MODL_ask_bsurf(). I cant figure out why? Anybody had this problem before ?

The function was running properly till yesterday. Now I see that it is crashing at UF_MODL_ask_bsurf() again. Is there something with the environment that needs to be set to get this working properly? .
This is an external NX application.

This is the error
====================================================
Failed to handle error condition correctly - exiting
General Fault Exception
====================================================
====================
Fatal error detected
====================


Below is the full code.

Code:
vector<MyPoints> MyLibrary::getNURBSSurfaceControlPoints(int surfTag)
{
	double *ptr;

	cout<< "In sub function : " << endl;

	UF_MODL_bsurface_p_t t_struc_info;
	
	UF_CALL(UF_MODL_ask_bsurf(surfTag, t_struc_info));


	cout<< " ---- output ---- " << endl;

	cout << " Is rational ?? : " << t_struc_info->is_rational << endl;
	cout << " Num poles u : " << t_struc_info->num_poles_u << endl;
	cout << " Num poles v : " << t_struc_info->num_poles_v << endl;
	cout << " Order u : " << t_struc_info->order_u << endl;
	cout << " Order v : " << t_struc_info->order_v << endl;  


	int d_num_poles_u = t_struc_info->num_poles_u;
	int d_num_poles_v = t_struc_info->num_poles_v;
	int d_order_u = t_struc_info->order_u;
	int d_order_v = t_struc_info->order_v;

	cout.flush();

	cout << d_num_poles_u << "  " << d_num_poles_v << endl;

	double (*Values)[4] = t_struc_info->poles;
	double* Xvalues;
	double* Yvalues;
	double* Zvalues;
	double* Wvalues;

	Xvalues = t_struc_info->poles[0];
	Yvalues = t_struc_info->poles[1];
	Zvalues = t_struc_info->poles[2];
	Wvalues = t_struc_info->poles[3];
	
	vector<MyPoints> PolesArray;
	for (int i = 0; i<d_num_poles_u*d_num_poles_v; i++)
	{
		//cout <<"Point No: "<<i <<" ";
		//cout << "X: " << Values[i][0] << " " ;
		//cout << "Y: " << Values[i][1] << " " ;
		//cout << "Z: " << Values[i][2] << " " ;
		//cout << "W: " << Values[i][3] << "  "<<endl ;



		MyPoints Pt; 
		 
		Pt.X = Values[i][0];
		Pt.Y = Values[i][1];
		Pt.Z = Values[i][2];		
		PolesArray.push_back(Pt);
	}
	return PolesArray;
}
 
Replies continue below

Recommended for you

Documentation is your friend. The NX Open C API provides both the answer to your question ("The user should allocate a UF_MODL_bsurface_t structure and pass in a pointer to this structure") and a working example:

C:
UF_MODL_bsurface_t bsurf;
UF_CALL(UF_MODL_ask_bsurf( bsurf_obj_id, &bsurf ));
// ...
UF_CALL(UF_MODL_free_bsurf_data(&bsurf));

Basically, you must allocate/free space for the bsurface data yourself for this function.
 

Hey thanks a ton Bleaker.
That is what I needed. I was using the pointer without allocating memory.

But surprisingly the program executed a few times before and I was able to print the control points, I guess the function UF_MODL_ask_bsurf was also allocating memory internally. Not sure.

Regards
Wilson
 
Yes, the way I understand it, the function takes the pointer and happily allocates memory and writes its data to wherever it is pointing. By passing it an uninitialized pointer you're basically uttering a prayer to the Gods of Chaos. If they are merciful, you hit an unallocated space in the heap and get away with a successful execution and a memory leak. Otherwise... well, let's just thank the Creators for protected mode.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor