Thread: debug problem

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    78

    Smile debug problem

    when i try to debug this program
    in the log file i am getting this error
    "An attempt was made to initialise an object in the null part"

    i think problem lies in the function "formSection"



    Code:
    #pragma warning(disable:4786)
    #pragma warning(disable:4996)
    #include <vector>
    
    #include "common.h"
    #include"defGeometry.h"
    
    #include <uf.h>
    #include<uf_vec.h>
    #include<uf_curve.h>
    #include<uf_part.h>
    
    using namespace std;
    
    void defGeometry::populateGeometry(int nthPoint1, int nthPoint2)
    {
    	//Initializing variables
    	//Points that controll the split of splines
    
    	nthN1Point = nthPoint1;
    	nthN2Point = nthPoint2;
    
    	for(int i=0;i<ActionSide.NumberOfSections;i++)
    	{
    		tag_t	Spline1_tag=NULL_TAG,
    				Spline2_tag=NULL_TAG,
    				Spline3_tag=NULL_TAG,
    				Spline4_tag=NULL_TAG;
    
    		struct Section Spline1,
    					   Spline2,
    					   Spline3,
    					   Spline4;
    		geometricSection tempGeomSect;
    		
    		Spline1 = formSection(ActionSide.Sections[i],ReactionSide.Sections[i]);
    		Spline1_tag = createSplineThruPoints(Spline1);
    		
    		Spline2 = SectionXtractPoints(ActionSide.Sections[i]);
    		Spline2_tag = createSplineThruPoints(Spline2);
    
    		Spline3 = SectionXtractPoints(ReactionSide.Sections[i]);
    		Spline3_tag = createSplineThruPoints(Spline3);
    
    		/*Spline4 = formSection(ReactionSide.Sections[i],ActionSide.Sections[i]);
    		Spline4_tag = createSplineThruPoints(Spline4);*/
    
    		tempGeomSect.section_tags["spline1"] =Spline1_tag;
    		tempGeomSect.section_tags["spline2"] =Spline2_tag;
    		tempGeomSect.section_tags["spline3"] =Spline3_tag;
    		tempGeomSect.section_tags["spline4"] =Spline4_tag;
    
    		sections.push_back(tempGeomSect);
    		//This is temp function need to be deleted
    		//UF_PART_save();
    	}
    }
    Section defGeometry::formSection( struct Section Section1,struct Section Section2)
    {
    	int j;
    	
    	struct Section defGeomSecTemp;
    	
    	for(j=nthN1Point;j>=0;j--)
    	{
    		defGeomSecTemp.Points.push_back(Section1.Points[j]);
    	}
    	
    	for(j=1;j<nthN2Point;j++)
    	{
    		defGeomSecTemp.Points.push_back(Section2.Points[j]);
    	}
    	
    	defGeomSecTemp.NumberOfPoints = defGeomSecTemp.Points.size();
    	defGeomSecTemp.NumberOfPoints = nthN1Point+nthN2Point;
    	//nthN1Point=NumberOfPoints-(nthN1Point+nthN2Point-2)+nthN1Point;
    	//nthN2Point=NumberOfPoints-(nthN1Point+nthN2Point-2)+nthN2Point;
    
    
    	return  defGeomSecTemp;
    }
    Section defGeometry::SectionXtractPoints(struct Section Section1)
    {
    	int j;
    	struct Section defGeomSecTemp;
    	for(j=nthN1Point-1;j<NumberOfPoints-nthN2Point+1;j++)
    	{
    	  defGeomSecTemp.Points.push_back(Section1.Points[j]);
    	}
    	defGeomSecTemp.NumberOfPoints=NumberOfPoints-(nthN1Point+nthN2Point-2);
    
    	return defGeomSecTemp;
    }
    
    tag_t defGeometry::createSplineThruPoints(struct Section thruSplineData)
    {
    	int	degree=3,
    		periodicity=0,
    		save_def_data = 0;
    	
    	double *p_par=NULL;
    	
    	tag_t thruSplineTag=NULL_TAG, ReplacedSpline=NULL_TAG;
    	
    	UF_CURVE_pt_slope_crvatr_t point_data[1000];
    	
    	for(int i=0; i<thruSplineData.NumberOfPoints; i++)
    	{
    		UF_VEC3_copy(thruSplineData.Points[i].pt,point_data[i].point);
    		point_data[i].slope_type = UF_CURVE_SLOPE_AUTO;
    		point_data[i].crvatr_type = UF_CURVE_CRVATR_NONE;
    	}
    	UF_CALL(UF_CURVE_create_spline_thru_pts(degree, periodicity,thruSplineData.NumberOfPoints,\
    											point_data,	p_par,save_def_data,&thruSplineTag));
    	
    	if(!thruSplineTag)
    	{
    		sysLogPrint("Failed to create spline %s", thruSplineData.Name);
    		return NULL_TAG;
    	}
    	
    	return thruSplineTag;
    }
    Last edited by chintugavali; 12-27-2007 at 12:44 AM.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Where in the code does it write that message to the log file?
    Code:
    defGeomSecTemp.Points.push_back(Section1.Points[j]);
    How do you know how many elements Points contains?

    BTW, since this is C++, not C, you don't need to say "struct" every time you declare a struct variable... You can just say:
    Code:
    Section defGeomSecTemp;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  2. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  5. Help, Debug Problem
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 02-26-2002, 03:50 PM