×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Error in Visual Studio 2010 with NX8.5

Error in Visual Studio 2010 with NX8.5

Error in Visual Studio 2010 with NX8.5

(OP)


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;
} 

RE: Error in Visual Studio 2010 with NX8.5

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:

CODE --> 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.

RE: Error in Visual Studio 2010 with NX8.5

(OP)

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

RE: Error in Visual Studio 2010 with NX8.5

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources