hi everyone,
i am getting this runtime check error,
stack around the variable"line_coords;" is corrupted,
can anyone help me.
Code:
void defGeometry::populateGeometry(int nthPoint1, int nthPoint2)
{ ///////////////////////////////////////////////
//Initializing variables //
//Points that control the split of splines ///
///////////////////////////////////////////////
nthN1Point = nthPoint1;
nthN2Point = nthPoint2;
////////////////////////////////////////////////////////////////
//To determine whether or not its Wicket gate or runner blade //
//If weicket gate then openEnd is ture otherwise if //
//runner blade it is false. //
////////////////////////////////////////////////////////////////
bool openEnd = true;
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,
line;
struct Section Spline1,
Spline2,
Spline3,
Spline4;
UF_CURVE_line_t line_coords;
geometricSection tempGeomSect;
double tangentPoints[4][3];
////////////////////////////////////////////////////////////
//We have created spline2 & spline3 first to get vectors //
//at start & end point of splines to maintain tangency //
//between consuective splines //
////////////////////////////////////////////////////////////
Spline2 = SectionXtractPoints(ActionSide.Sections[i]);
Spline2_tag = createSplineThruPoints(Spline2);
tempGeomSect.section_tags[2]=Spline2_tag;
Spline3 = SectionXtractPoints(ReactionSide.Sections[i]);
Spline3_tag = createSplineThruPoints(Spline3);
tempGeomSect.section_tags[3]=Spline3_tag;
////////////////////////////////////////////////////////////////////////
//call for collecting vectors at start& end point of spline2 & spline3//
////////////////////////////////////////////////////////////////////////
makeTangentPoints(tempGeomSect,tangentPoints);
////////////////////////////////////////////////////////
//CREATE THE NOZE SPLINES 1 AND 4 //
////////////////////////////////////////////////////////
//Only to create the Spline4 //
//We have to reverse the vectors //
//For that we will use two temp vectors of section type/
////////////////////////////////////////////////////////
Spline1 = formSection(ActionSide.Sections[i],ReactionSide.Sections[i],nthN1Point);
Spline1_tag = createSplineThruPoints(Spline1,tangentPoints[0],tangentPoints[2]);
tempGeomSect.section_tags[1]=Spline1_tag;
//////////////////////////////////////////////////////////////////////////////
//If runner blade then we have to do the splie for tail end as well. //
//Other wise if Wicket Gate we need to create a line rather than splitting. //
//////////////////////////////////////////////////////////////////////////////
if(openEnd == false)
{
Section RevActSection = ActionSide.Sections[i];
Section RevReActSection = ReactionSide.Sections[i];
vector<point> tmppts1(RevActSection.Points.rbegin(),RevActSection.Points.rend());
vector<point> tmppts2(RevReActSection.Points.rbegin(),RevReActSection.Points.rend());
RevActSection.Points = tmppts1;
RevReActSection.Points = tmppts2;
Spline4 = formSection(RevActSection,RevReActSection,nthN2Point);
Spline4_tag = createSplineThruPoints(Spline4,tangentPoints[1],tangentPoints[3]);
}
else
{
line_coords.start_point[3]=Spline2.Points[NumberOfPoints-nthN2Point-nthN1Point+1].pt[3];
line_coords.end_point[3] =Spline3.Points[NumberOfPoints-nthN2Point-nthN1Point+1].pt[3];
UF_CURVE_create_line (&line_coords,& line );
}
tempGeomSect.section_tags[4]=Spline4_tag;
UF_CALL(UF_OBJ_set_name(Spline1_tag,"spline11"));
UF_CALL(UF_OBJ_set_name(Spline2_tag,"spline22"));
UF_CALL(UF_OBJ_set_name(Spline3_tag,"spline33"));
UF_CALL(UF_OBJ_set_name(Spline4_tag,"spline44"));
sections.push_back(tempGeomSect);
}
}
Section defGeometry::formSection( struct Section Section1,struct Section Section2,int nthPoint)
{
int j;
struct Section defGeomSecTemp;
for(j=(nthPoint-1);j>=0;j--)
{
defGeomSecTemp.Points.push_back(Section1.Points[j]);
}
for(j=1;j<nthPoint;j++)
{
defGeomSecTemp.Points.push_back(Section2.Points[j]);
}
defGeomSecTemp.NumberOfPoints = defGeomSecTemp.Points.size();
defGeomSecTemp.NumberOfPoints = nthN1Point+nthN2Point-1;
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;
}