コード例 #1
0
STATUS	NcEndOfCutFeedRateMove::generateDisplayList()
{

	double travellength = sqrt( (mStartZ - Z) * (mStartZ - Z) +
								 (mStartX - X) * (mStartX - X));

	mCodeExecutionTime = (travellength / (F * mSpindleSpeed)) * 60;

	mTotalCycleTime = mTotalCycleTime + mCodeExecutionTime;

	Profile *gProfile = new Profile();
	gProfile->type = CGAUX;
	gProfile->typeTool = CT00;
	mPartProfileList->push_back(gProfile);
	
	int n = MAX_LINEAR_SUBDIV;
	int no_pts=(n);
	//profile->P.resize(profile->no_pts);
	/*profile->allocate();*/
	vector<NcVector> profile(no_pts);
	profile[0] = NcVector(mStartZ,mStartX,0);
	//profile->P[0][1] = mStartX;
	//profile->P[0][2] = 0;

	profile[n-1] = NcVector(Z,X,0);
	//profile->P[n-1][1] = X;
	//profile->P[n-1][2] = 0;

	double u = 0.0;
	double du = 1.0 / (double)(n-1);

	for(int i=0; i < n-1; i++, u+=du)
	{
		
			profile[i] = profile[0] * (1-u) + profile[n-1] * (u);
	}

	GLuint newlistindex = glGenLists(1);
	//profile->mAssociated2DDLIndexes->push_back(newlistindex);
	gProfile->addProfileDisplayListIndex(newlistindex);
	mCumulativeDLList.push_back(newlistindex);
	mListIndex++;
	mLocalIndex = mListIndex;

	glNewList(newlistindex, GL_COMPILE);	
		glColor3d(0.0, 1.0, 0.0);
		
		glBegin(GL_LINE_STRIP);
			for(int i = 0; i < n; i++)
				glVertex3f(profile[i][0], profile[i][1], profile[i][2]);
		glEnd();

	glEndList();
	gProfile->setProfile(profile);
	return OK;
}
コード例 #2
0
ファイル: G03.cpp プロジェクト: cctech-labs/discretesimulator
STATUS	G03::generateDisplayList()
{
	Profile *gProfile = new Profile();
	gProfile->type = CG03;
	gProfile->typeTool = CT01;
	mPartProfileList->push_back(gProfile);

	double cx, cy, x, y;
	double x2, y2;
	double st_angle = 0, end_angle = 0;
	double r;
	double theta, dtheta;
	double arc_pts[MAX_ANG_SUBDIV][2];
	x2 = Z;
	y2 = X;

	int no_pts = MAX_ANG_SUBDIV; /* To be modified in future*/
	/*profile->P.resize(MAX_ANG_SUBDIV);*/
	//profile->allocate();
	vector<NcVector> profile(no_pts);
	cx = mStartZ + K;
	cy = mStartX + I;
	r = sqrt((x2 - cx) * (x2 - cx) + (y2 - cy) * (y2 - cy));
	x = mStartZ - cx;
	y = mStartX - cy;
	st_angle = cal_angle(x,y);
	x = x2 - cx;
	y = y2 - cy;

	end_angle = cal_angle(x, y);
	
	if(st_angle > end_angle)
		end_angle = end_angle + 360; 

	dtheta = (end_angle - st_angle) / (double)(MAX_ANG_SUBDIV - 1);

	double arclengthcut = ((end_angle - st_angle) * (NC_PI / 180.0)) * r;
	double feed = F ;
	double sspeed = mSpindleSpeed;
	mCodeExecutionTime =  ( arclengthcut / (F * mSpindleSpeed) ) * 60;

	mTotalCycleTime = mTotalCycleTime + mCodeExecutionTime;

	mHours = (int)(mTotalCycleTime / 3600);
	int min = mTotalCycleTime % 3600;
	mMinutes = (int)(min / 60);
	int sec = min % 60;
	mSeconds = sec;
	
	theta = st_angle;

	for(int i = 0; i < MAX_ANG_SUBDIV; theta = theta + dtheta, i++)
	{
		float x, y;
		x = cx + r * cos(theta * NC_PI / 180.0);
		y = cy + r * sin(theta * NC_PI / 180.0);
		arc_pts[i][0] = x;
		arc_pts[i][1] = y;
		profile[i] = NcVector(x,y,0);
		/*profile->P[i][1] = y;
		profile->P[i][2] = 0;*/
	}

	GLuint newlistindex = glGenLists(1);
	/*profile->mAssociated2DDLIndexes->push_back(newlistindex);*/
	gProfile->addProfileDisplayListIndex(newlistindex);

	mCumulativeDLList.push_back(newlistindex);
	mListIndex++;
	mLocalIndex = mListIndex;

	glNewList(newlistindex, GL_COMPILE);
		glColor3d(0,1,0);
	
		for(int i = 1; i < MAX_ANG_SUBDIV; i++)
		{
			glBegin(GL_LINES);
			glVertex3f(arc_pts[i-1][0],arc_pts[i-1][1],0);
			glVertex3f(arc_pts[i][0],arc_pts[i][1],0);
			glEnd();
		}
		
	glEndList();	
	gProfile->setProfile(profile);
	return OK;
}
コード例 #3
0
ファイル: G01.cpp プロジェクト: cctech-labs/discretesimulator
STATUS	G01::generateDisplayList()
{
	//time in seconds taking units as turning length = mm, feedrate = mm/rev
	//spindle speed = rev / min
	double turninglength = fabs(fabs(Z) - fabs(mStartZ));
	double feed = F ;
	double sspeed = mSpindleSpeed;
	mCodeExecutionTime =  ( turninglength / (F * mSpindleSpeed) ) * 60;

	mTotalCycleTime = mTotalCycleTime + mCodeExecutionTime;

	mHours = (int)(mTotalCycleTime / 3600);
	int min = mTotalCycleTime % 3600;
	mMinutes = (int)(min / 60);
	int sec = min % 60;
	mSeconds = sec;

	Profile *gProfile = new Profile();
	gProfile->type = CG01;
	if(mIsAuxillaryPath == true)
		gProfile->typeTool = CT00;
	else if(mIsAuxillaryPath == false)
		gProfile->typeTool = CT01;

	mPartProfileList->push_back(gProfile);
	
	int n = MAX_LINEAR_SUBDIV;
	vector<NcVector> profile(n);
	/*profile->P.resize(n);
	profile->no_pts = n;*/
	//profile->allocate();

	profile[0]= NcVector(mStartZ,mStartX,0);
	/*profile->P[0][1] = mStartX;
	profile->P[0][2] = 0;*/

	profile[n-1]=NcVector(Z,X,0);
	/*profile->P[n-1][1] = X;
	profile->P[n-1][2] = 0;*/

	double u = 0.0;
	double du = 1.0 / (double)(n-1);

	for(int i=0; i < n-1; i++, u+=du)
	{
			
			profile[i] = profile[0] * (1-u) + profile[n-1] * (u);
	}

	GLuint newlistindex = glGenLists(1);
	//profile->mAssociated2DDLIndexes->push_back(newlistindex);
	gProfile->addProfileDisplayListIndex(newlistindex);
	mCumulativeDLList.push_back(newlistindex);
	mListIndex++;
	mLocalIndex = mListIndex;

	glNewList(newlistindex, GL_COMPILE);	
		glColor3d(0.0, 1.0, 0.0);
		
		
		glBegin(GL_LINE_STRIP);
			for(int i = 0; i < n; i++)
				glVertex3f(profile[i][0], profile[i][1], profile[i][2]);
		glEnd();

	
	glEndList();
	gProfile->setProfile(profile);
	return OK;
}