本文整理汇总了C++中ON_NurbsCurve::SpanCount方法的典型用法代码示例。如果您正苦于以下问题:C++ ON_NurbsCurve::SpanCount方法的具体用法?C++ ON_NurbsCurve::SpanCount怎么用?C++ ON_NurbsCurve::SpanCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ON_NurbsCurve
的用法示例。
在下文中一共展示了ON_NurbsCurve::SpanCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNurbFormParameterFromRadian
bool ON_Arc::GetNurbFormParameterFromRadian(double RadianParameter, double* NurbParameter ) const
{
if(!IsValid() || NurbParameter==NULL)
return false;
ON_Interval ADomain = DomainRadians();
double endtol = 10.0*ON_EPSILON*(fabs(ADomain[0]) + fabs(ADomain[1]));
double del = RadianParameter - ADomain[0];
if(del <= endtol && del >= -ON_SQRT_EPSILON)
{
*NurbParameter=ADomain[0];
return true;
}
else {
del = ADomain[1] - RadianParameter;
if(del <= endtol && del >= -ON_SQRT_EPSILON){
*NurbParameter=ADomain[1];
return true;
}
}
if( !ADomain.Includes(RadianParameter ) )
return false;
ON_NurbsCurve crv;
if( !GetNurbForm(crv))
return false;
//Isolate a bezier that contains the solution
int cnt = crv.SpanCount();
int si =0; //get span index
int ki=0; //knot index
double ang = ADomain[0];
ON_3dPoint cp;
cp = crv.PointAt( crv.Knot(0) ) - Center();
double x = ON_DotProduct(Plane().Xaxis(),cp);
double y = ON_DotProduct(Plane().Yaxis(),cp);
double at = atan2( y, x); //todo make sure we dont go to far
for( si=0, ki=0; si<cnt; si++, ki+=crv.KnotMultiplicity(ki) ){
cp = crv.PointAt( crv.Knot(ki+2)) - Center();
x = ON_DotProduct(Plane().Xaxis(),cp);
y = ON_DotProduct(Plane().Yaxis(),cp);
double at2 = atan2(y,x);
if(at2>at)
ang+=(at2-at);
else
ang += (2*ON_PI + at2 - at);
at = at2;
if( ang>RadianParameter)
break;
}
// Crash Protection trr#55679
if( ki+2>= crv.KnotCount())
{
*NurbParameter=ADomain[1];
return true;
}
ON_Interval BezDomain(crv.Knot(ki), crv.Knot(ki+2));
ON_BezierCurve bez;
if(!crv.ConvertSpanToBezier(ki,bez))
return false;
ON_Xform COC;
COC.ChangeBasis( ON_Plane(),Plane());
bez.Transform(COC); // change coordinates to circles local frame
double a[3]; // Bez coefficients of a quadratic to solve
for(int i=0; i<3; i++)
a[i] = tan(RadianParameter)* bez.CV(i)[0] - bez.CV(i)[1];
//Solve the Quadratic
double descrim = (a[1]*a[1]) - a[0]*a[2];
double squared = a[0]-2*a[1]+a[2];
double tbez;
if(fabs(squared)> ON_ZERO_TOLERANCE){
ON_ASSERT(descrim>=0);
descrim = sqrt(descrim);
tbez = (a[0]-a[1] + descrim)/(a[0]-2*a[1]+a[2]);
if( tbez<0 || tbez>1){
double tbez2 = (a[0]-a[1]-descrim)/(a[0] - 2*a[1] + a[2]);
if( fabs(tbez2 - .5)<fabs(tbez-.5) )
tbez = tbez2;
}
ON_ASSERT(tbez>=-ON_ZERO_TOLERANCE && tbez<=1+ON_ZERO_TOLERANCE);
}
else{
// Quadratic degenerates to linear
tbez = 1.0;
if(a[0]-a[2])
tbez = a[0]/(a[0]-a[2]);
}
//.........这里部分代码省略.........