fix in revolution primitive (orientation of spline curve)

This commit is contained in:
Joachim Schoeberl 2010-04-06 15:00:19 +00:00
parent 06eb9902be
commit 3c53f52f60
2 changed files with 18 additions and 12 deletions

View File

@ -441,24 +441,20 @@ namespace netgen
int n = int(2.*facets) + 1; int n = int(2.*facets) + 1;
int i,j; for(int i=0; i<=n; i++)
double phi;
Point<3> p;
for(i=0; i<=n; i++)
{ {
Point<2> sp = spline->GetPoint(double(i)/double(n)); Point<2> sp = spline->GetPoint(double(i)/double(n));
for(j=0; j<=n; j++) for(int j=0; j<=n; j++)
{ {
phi = 2.*M_PI*double(j)/double(n); double phi = 2.*M_PI*double(j)/double(n);
p = p0 + sp(0)*v_axis + sp(1)*cos(phi)*v1 + sp(1)*sin(phi)*v2; Point<3> p = p0 + sp(0)*v_axis + sp(1)*cos(phi)*v1 + sp(1)*sin(phi)*v2;
tas.AddPoint(p); tas.AddPoint(p);
} }
} }
for(i=0; i<n; i++) for(int i=0; i<n; i++)
for(j=0; j<n; j++) for(int j=0; j<n; j++)
{ {
int pi = (n+1)*i+j; int pi = (n+1)*i+j;

View File

@ -610,7 +610,6 @@ Vec<D> SplineSeg3<D> :: GetTangent (const double t) const
template<int D> template<int D>
void SplineSeg3<D> :: GetCoeff (Vector & u) const void SplineSeg3<D> :: GetCoeff (Vector & u) const
{ {
Point<D> p;
DenseMatrix a(6, 6); DenseMatrix a(6, 6);
DenseMatrix ata(6, 6); DenseMatrix ata(6, 6);
Vector f(6); Vector f(6);
@ -622,7 +621,7 @@ void SplineSeg3<D> :: GetCoeff (Vector & u) const
double t = 0; double t = 0;
for (int i = 0; i < 5; i++, t += 0.25) for (int i = 0; i < 5; i++, t += 0.25)
{ {
p = GetPoint (t); Point<D> p = GetPoint (t);
a(i, 0) = p(0) * p(0); a(i, 0) = p(0) * p(0);
a(i, 1) = p(1) * p(1); a(i, 1) = p(1) * p(1);
a(i, 2) = p(0) * p(1); a(i, 2) = p(0) * p(1);
@ -638,6 +637,17 @@ void SplineSeg3<D> :: GetCoeff (Vector & u) const
u(5) = 1; u(5) = 1;
a.MultTrans (u, f); a.MultTrans (u, f);
ata.Solve (f, u); ata.Solve (f, u);
// the sign
Point<D> p0 = GetPoint(0);
Vec<D> ht = GetTangent(0);
Vec<2> tang(ht(0), ht(1));
double gradx = 2.*u(0)*p0(0) + u(2)*p0(1) + u(3);
double grady = 2.*u(1)*p0(1) + u(2)*p0(0) + u(4);
Vec<2> gradn (grady, -gradx);
if (tang * gradn < 0) u *= -1;
} }
/* /*