Exemple #1
0
//Gets new B-Rep by adding knots to an original B-Rep.
MGRSBRep::MGRSBRep(
	const MGRSBRep& old,		//Original B-Rep.
	const MGKnotArray& uknots,	//Knots to add for u-direction
	const MGKnotArray& vknots)	//Knots to add for v-direction.
:MGSurface(old),m_surface(old.m_surface,uknots,vknots){
		update_mark();
}
Exemple #2
0
MGSBRep& MGSBRep::refine(					//BSUNK
	const MGKnotVector& uknot,	// knot of u-direction
	const MGKnotVector& vknot)	// knot of v-direction
//Change an original B-Rep to new one with subdivided knot configuration.
//Knots t must be subdivided knots.
{
	int refine_kind;
	if(uknot!=m_uknot){
		if(vknot!=m_vknot) refine_kind=3;
		else               refine_kind=1;
	}else if(vknot!=m_vknot) refine_kind=2;
	else               return *this;
	// refine_kind=1:u-knot only, =2:v-knot only, =3:both u and v-knot. 

	unsigned ku=order_u(); size_t lud=bdim_u();
	unsigned kv=order_v(); size_t lvd=bdim_v();
	size_t is1,is2; surface_bcoef().capacity(is1,is2);
	size_t lud2=uknot.bdim(), lvd2=vknot.bdim();
	MGSPointSeq bcoef(lud2,lvd2,3);
	unsigned k=ku; if(k<kv) k=kv;
	double* work1=new double[k*k];
	double* work2=new double[lvd2*2];
	bsunk_(refine_kind,ku,lud,knot_data_u(),kv,lvd,knot_data_v(),coef_data(),
		is1,is2,lud2,uknot.data(),lvd2,vknot.data(),
		lud2,lvd2,work1,work2,&bcoef(0,0,0));
	delete[] work1; delete[] work2;
	m_uknot=uknot; m_vknot=vknot;
	m_surface_bcoef=bcoef;
	update_mark();
	return *this;
}
Exemple #3
0
// Gets new NURBS Surface by computing a part of the original.
//New one is exactly the same as the original except that it is partial.
//If multiple==true(!=0), knot_u(i)=t1 and knot_u(n+i)=t2 for i=0,..., k-1
//will be guaranteed. Here, n=bdim_u(), k=order_u(),
//t1=uvrange(0).low_point(), and t2=uvrange(0).high_point().
//About knot_v(j), the same.
// Both u-range and v-range must be inside the range of old.
MGRSBRep::MGRSBRep(
	const MGBox& uvrange,		//u and v parameter range.
	const MGRSBRep& old,		//Original B-Rep.
	int multiple) //Indicates if start and end knot multiplicities
					//are necessary. =0:unnecessary, !=0:necessary.
:MGSurface(old),m_surface(uvrange,old.m_surface,multiple){
		update_mark();
}
Exemple #4
0
//Approximate an original B-Rep by a new knot configuration.
//The new knot config must be inside the range of the original B-Rep
//parameter. However new knots may be coarse or fine.
MGRSBRep::MGRSBRep(
	const MGRSBRep& old,//Original B-Rep.
	const MGKnotVector& ut,	//knot vector of u-direction
	const MGKnotVector& vt,	//knot vector of v-direction
	int &error)				//Error flag.
:MGSurface(old),m_surface(old.m_surface,ut,vt,error){
		update_mark();
}
Exemple #5
0
//Changing this object's space dimension.
MGSBRep& MGSBRep::change_dimension(
	size_t dim,		// new space dimension
	size_t start1, 		// Destination order of new object.
	size_t start2) 		// Source order of this object.
{
	m_surface_bcoef=MGSPointSeq(dim,surface_bcoef(),start1,start2);
	update_mark();
	return *this;
}
Exemple #6
0
//Change parameter range, be able to change the direction by providing
//t1 greater than t2.
MGRSBRep& MGRSBRep::change_range(
	int is_u,				//if true, (t1,t2) are u-value. if not, v.
	double t1,				//Parameter value for the start of original. 
	double t2)				//Parameter value for the end of original. 
{
	m_surface.change_range(is_u,t1,t2);
	update_mark();
	return *this;
}
Exemple #7
0
void
SoundCTRL::changeLabels()
{
	timeInSeconds = (8 * sound->m_position)/(view->getFormat()->numChannels() * view->getFormat()->sampleRate() * view->getFormat()->bitsPerSample());
	
	int nextMark = view->MarkIndex();
	int nextSubMark = view->SubMarkIndex();

	vector<uint32_t> marks = view->marks();
	vector<uint32_t> subMarks = view->subMarks();

	/*cout << "Subs = [";
	for (int i = 0; i < (int )subMarks.size(); i++)
		cout << subMarks[i] << " ";
	cout << "]" << endl;
	*/
	uint32_t now = update_mark(marks, timeInSeconds);
	//cout << "timeInSeconds: " << timeInSeconds << ", nextMark: "<< nextMark<< "," << "nextSubMark: "<< nextSubMark << ", now = " << now << endl;
	
	if (now != (uint32_t) nextMark)
	{
		view->setMarkIndex(now);
	}

	now = update_mark(subMarks, timeInSeconds);

	//cout << "Novo now = " << now << endl;
	
	if (now != (uint32_t) nextSubMark)
	{
		view->setSubMarkIndex(now);	
	}
	
	emit changeAllMarks();
	emit clock((int) timeInSeconds);
}
Exemple #8
0
// Construct a Line NURBS by changing space dimension and ordering of
//coordinates.
MGRSBRep::MGRSBRep(
	size_t dim,			// New space dimension.
	const MGRSBRep& rsb,// Original Surface B-rep.
	size_t start1, 		// Destination order of new line.
	size_t start2) 		// Source order of original line.
:MGSurface(rsb){
	update_mark();
	size_t dim0=rsb.sdim();
	MGSPointSeq cp1(dim0,rsb.surface_bcoef());//Exclude weights.
	MGSPointSeq cp2(dim,cp1,start1,start2);  //Change order of coordinates.
	MGSPointSeq cp3(dim+1,cp2);			     //Get area for weights.
	for(size_t i=0; i<cp3.length_u(); i++)
	for(size_t j=0; j<cp3.length_v(); j++)
		cp3(i,j,dim)=rsb.surface_bcoef()(i,j,dim0);//Set weights.
	m_surface=MGSBRep(cp3,rsb.knot_vector_u(),rsb.knot_vector_v());
}
Exemple #9
0
//Changing this object's space dimension.
MGRSBRep& MGRSBRep::change_dimension(
	size_t dim,		// new space dimension
	size_t start1, 		// Destination order of new object.
	size_t start2) 		// Source order of this object.
{
	size_t dim0=sdim();
	MGSPointSeq cp1(dim0,surface_bcoef());	//Exclude weights.
	MGSPointSeq cp2(dim,cp1,start1,start2); //Change order of coordinates.
	MGSPointSeq cp3(dim+1,cp2);			    //Get area for weights.
	const MGSPointSeq& sp=surface_bcoef();
	for(size_t i=0; i<cp3.length_u(); i++)
	for(size_t j=0; j<cp3.length_v(); j++)
		cp3(i,j,dim)=sp(i,j,dim0);//Set weights.
	m_surface=MGSBRep(cp3,knot_vector_u(),knot_vector_v());
	update_mark();
	return *this;
}
Exemple #10
0
// Convert from Non ratoinal to Rational form.
MGRSBRep::MGRSBRep(
	const MGSBRep& brep,	//Original SBRep. This can be ordinary SBRep, or 
		//homogeneous form of MGRSBRep. When homogeneous form,
		//the last space dimension elements are weights.
	int homogeneous)		//true(non zero): homogeneous form,
							//false(zero):ordinary SBRep.
:MGSurface(brep), m_surface(brep){
	update_mark();
	if(!homogeneous){
	size_t m=brep.bdim_u(), n=brep.bdim_v(), dimm1=brep.sdim();
	MGSPointSeq cp(m,n,dimm1+1);
	size_t i,j,r;
	for(i=0; i<m; i++){
		for(j=0; j<n; j++){
			for(r=0; r<dimm1; r++) cp(i,j,r)=brep.coef(i,j,r);
			cp(i,j,dimm1)=1.;
		}
	}
	m_surface=MGSBRep(cp, brep.knot_vector_u(), brep.knot_vector_v());
	}
}
Exemple #11
0
int MGSBRep::reduce(		//BSUDEC
	int is_u,		//if true, reduce b-rep dimension of u-direction.
	int ndec)		//Number of B-rep dimension to decrease 
//Change the B-Rep by decreasing B-Rep dimension by ndec. This is
//an approximation of the original B-Rep. Return value is error flag.
{
	assert(ndec>=0);
	if(is_u) assert(bdim_u()-ndec>=order_u());
	else 	 assert(bdim_v()-ndec>=order_v());

	if(ndec<=0) return 0;

	size_t kdec=2; if(is_u) kdec=1;
	unsigned ku=order_u(); size_t lud=bdim_u();
	unsigned kv=order_v(); size_t lvd=bdim_v();
	unsigned maxlen=lud; if(maxlen<lvd) maxlen=lvd;
	size_t is1,is2; surface_bcoef().capacity(is1,is2);
	int lud2, lvd2;
	MGKnotVector tu(ku,lud), tv(kv,lvd);
	MGSPointSeq bcoef(lud,lvd,3);
	int iflag;
	unsigned k=ku; if(k<kv) k=kv;
	double* work1=new double[maxlen*(2*k-1)];
	double* work2=new double[maxlen];
	double* work3=new double[lvd*2];
	bsudec_(
		ku,lud,knot_data_u(),kv,lvd,knot_data_v(),coef_data(),
		kdec,ndec,is1,is2,lud,lvd,work1,work2,work3,
		&lud2,&tu(0),&lvd2,&tv(0),&bcoef(0,0,0),&iflag);
	if(iflag==1){
		tu.set_bdim(lud2); tv.set_bdim(lvd2);
		m_uknot=tu; m_vknot=tv;
		bcoef.set_length(lud2,lvd2);
		m_surface_bcoef=bcoef;
		iflag=0;
	}
	delete[] work1; delete[] work2; delete[] work3;
	update_mark();
	return iflag;
}
Exemple #12
0
MGSBRep& MGSBRep::change_range(
	int is_u,				//if true, (t1,t2) are u-value. if not, v.
	double t1,				//Parameter value for the start of original. 
	double t2)				//Parameter value for the end of original. 
//Change parameter range, be able to change the direction by providing
//t1 greater than t2.
{
	double ts, te;
	if(t1>t2){
		ts=t2; te=t1;
		m_surface_bcoef.reverse(is_u);
		if(is_u) m_uknot.reverse();
		else	 m_vknot.reverse();
	}
	else{
		ts=t1; te=t2;
	}
	if(is_u) m_uknot.change_range(ts,te);
	else	 m_vknot.change_range(ts,te);
	update_mark();
	return *this;
}
Exemple #13
0
// 自身の曲線に与えられたスケールをかける。
//Scale the curve.
MGRSBRep& MGRSBRep::operator*= (double scale){
	m_surface.surface_bcoef().homogeneous_transform(scale);
	update_mark();
	return *this;
}
Exemple #14
0
// 与えられた変換で曲面のトランスフォームを行い自身とする。
MGSBRep& MGSBRep::operator*= ( const MGTransf & tr){
	m_surface_bcoef *= tr;
	update_mark();
	return *this;
}
Exemple #15
0
//Modify the original Surface by extrapolating the specified perimeter.
//The extrapolation is C2 continuous if the order >=4.
//The extrapolation is done so that extrapolating length is "length"
//at the position of the parameter value "param" of the perimeter.
MGRSBRep& MGRSBRep::extend(
	int perimeter,	//perimeter number of the Surface.
					// =0:v=min, =1:u=max, =2:v=max, =3:u=min.
	double param,	// parameter value of above perimeter.
	double length,	//chord length to extend at the parameter param of the perimeter.
	double dk){  //Coefficient of how curvature should vary at
//    extrapolation start point. When dk=0, curvature keeps same, i.e.
//    dK/dS=0. When dk=1, curvature becomes zero at length extrapolated point,
//    i.e. dK/dS=-K/length at extrapolation start point.
//    (S=parameter of arc length, K=Curvature at start point)
//    That is, when dk reaches to 1 from 0, curve changes to flat.

	assert(sdim()<=3);
	assert(perimeter>=0 && perimeter<4);
	
	const size_t ncd=surface_bcoef().sdim();
	int at_start=1;//starting perimeter
	size_t nu, nv;
	size_t order; size_t n,m; MGKnotVector* t;
	if(perimeter==1 || perimeter==3){	// Extrapolate to u-direction
		order=order_u();
		n=bdim_u();
		t=&(knot_vector_u());
		if(perimeter==1)
			at_start=0;//ending perimeter
		m=nv=bdim_v();
	}else{
		// Extrapolate to v-direction
		order=order_v();
		n=bdim_v();
		t=&(knot_vector_v());
		if(perimeter==2)
			at_start=0;//ending perimeter
		m=nu=bdim_u();
	}
	//(nu,nv) are new surface B-Rep dimensions of u and v.
	//(order,n,t) is line B-rep to extrapolate.
	//m is the number of line B-reps to extrapolate.

	MGSPointSeq surf;
	MGRLBRep lbtemp;
	MGKnotVector& t1=lbtemp.knot_vector();
	MGBPointSeq& coeftemp=lbtemp.line_bcoef();
	coeftemp.resize(n,ncd);
	double tse;
	if(at_start)
		tse=t->param_s();
	else
		tse=t->param_e();

	MGPosition uv=perimeter_uv(perimeter,param);//Surface parameter value of param.
	size_t ndu=0,ndv=0;
	if(perimeter==0 || perimeter==2) ndv=1;
	else                             ndu=1;
	double slen=length/(eval(uv,ndu,ndv)).len();

	int nnew; double firstd_len,dlen;
	for(size_t i=0; i<m; i++){
		if(perimeter==0 || perimeter==2){
			for(size_t j=0; j<n; j++)
				for(size_t k=0; k<ncd; k++) coeftemp(j,k)=coef(i,j,k);
		}else{
			for(size_t j=0; j<n; j++)
				for(size_t k=0; k<ncd; k++) coeftemp(j,k)=coef(j,i,k);
		}
		coeftemp.set_length(n);

	//Compute first derivative length at the end of the extrapolating line.
		t1=*t; 
		firstd_len=lbtemp.eval(tse,1).len();
		dlen=firstd_len*slen;
		//std::cout<<"before:"<<lbtemp<<std::endl;///////
		lbtemp.extend(at_start,dlen,dk);
		//std::cout<<"after:"<<lbtemp<<std::endl;///////
		nnew=lbtemp.bdim();
		if(perimeter==0 || perimeter==2){
			if(i==0){
				nv=nnew;
				surf.resize(nu,nv,ncd);
			}
			for(int j=0; j<nnew; j++)
				for(size_t k=0; k<ncd; k++) surf(i,j,k)=coeftemp(j,k);
		}else{
			if(i==0){
				nu=nnew;
				surf.resize(nu,nv,ncd);
			}
			for(int j=0; j<nnew; j++)
				for(size_t k=0; k<ncd; k++) surf(j,i,k)=coeftemp(j,k);
		}
	}

	*t=t1;
	surf.set_length(nu,nv);
	surface_bcoef()=surf;

	update_mark();
	return *this;
}
Exemple #16
0
// 与えられた変換で曲面の変換を行い自身の曲面とする。
MGSBRep& MGSBRep::operator*= ( const MGMatrix& mat){
	m_surface_bcoef *= mat;
	update_mark();
	return *this;
}
Exemple #17
0
// 与えられたスケーリングで曲面の変換を行い自身の曲面とする。
//Scaling.
MGSBRep& MGSBRep::operator*= (double scale){
	m_surface_bcoef *=scale;
	update_mark();
	return *this;
}
Exemple #18
0
//Exchange ordering of the coordinates.
//Exchange coordinates (i) and (j).
MGRLBRep& MGRLBRep::coordinate_exchange(size_t i, size_t j){
	m_line.line_bcoef().coordinate_exchange(i,j);
	update_mark();
	return *this;
}
Exemple #19
0
// 与えられた変換で曲線の変換を行い自身の曲線とする。
//Matrix transformation of the curve.
MGRSBRep& MGRSBRep::operator*=(const MGMatrix& mat){
	m_surface.surface_bcoef().homogeneous_transform(mat);
	update_mark();
	return *this;
}
Exemple #20
0
// 与えられた変換で曲線のトランスフォームを行い自身とする。
//General transformation of the curve.
MGRSBRep& MGRSBRep::operator*= (const MGTransf& tr){
	m_surface.surface_bcoef().homogeneous_transform(tr);
	update_mark();
	return *this;
}