0020063: NETGEN regression

roll back fix of OCCSurface::GetNormalVector() in occmeshsurf.cpp
This commit is contained in:
eap 2008-11-25 17:09:32 +00:00
parent 168242d9ab
commit e98bb6ea4f

View File

@ -875,140 +875,6 @@ diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.cpp netgen-4.5.new/libsrc/occ/o
namespace netgen
@@ -40,6 +42,7 @@
*/
+ n=0;
GeomLProp_SLProps lprop(occface,geominfo.u,geominfo.v,1,1e-5);
double setu=geominfo.u,setv=geominfo.v;
@@ -49,57 +52,78 @@
double ustep = 0.01*(umax-umin);
double vstep = 0.01*(vmax-vmin);
- n=0;
-
- while(setu < umax && (lprop.D1U().Magnitude() < 1e-5 || lprop.D1V().Magnitude() < 1e-5))
- setu += ustep;
- if(setu < umax)
- {
- lprop.SetParameters(setu,setv);
- n(0)+=lprop.Normal().X();
- n(1)+=lprop.Normal().Y();
- n(2)+=lprop.Normal().Z();
- }
- setu = geominfo.u;
- while(setu > umin && (lprop.D1U().Magnitude() < 1e-5 || lprop.D1V().Magnitude() < 1e-5))
- setu -= ustep;
- if(setu > umin)
- {
- lprop.SetParameters(setu,setv);
- n(0)+=lprop.Normal().X();
- n(1)+=lprop.Normal().Y();
- n(2)+=lprop.Normal().Z();
- }
- setu = geominfo.u;
-
- while(setv < vmax && (lprop.D1U().Magnitude() < 1e-5 || lprop.D1V().Magnitude() < 1e-5))
- setv += ustep;
- if(setv < vmax)
- {
- lprop.SetParameters(setu,setv);
- n(0)+=lprop.Normal().X();
- n(1)+=lprop.Normal().Y();
- n(2)+=lprop.Normal().Z();
- }
- setv = geominfo.v;
- while(setv > vmin && (lprop.D1U().Magnitude() < 1e-5 || lprop.D1V().Magnitude() < 1e-5))
- setv -= ustep;
- if(setv > vmin)
- {
- lprop.SetParameters(setu,setv);
- n(0)+=lprop.Normal().X();
- n(1)+=lprop.Normal().Y();
- n(2)+=lprop.Normal().Z();
- }
- setv = geominfo.v;
-
+ if ( lprop.D1V().Magnitude() < 1e-5 )
+ {
+ while(setu < umax && (lprop.D1V().Magnitude() < 1e-5 || !lprop.IsNormalDefined())) {
+ setu += ustep;
+ if(setu < umax)
+ lprop.SetParameters(setu,setv);
+ }
+ if (lprop.D1V().Magnitude() < 1e-5 || !lprop.IsNormalDefined()) {
+ setu = geominfo.u;
+ while(setu > umin && (lprop.D1V().Magnitude() < 1e-5 || !lprop.IsNormalDefined())) {
+ setu -= ustep;
+ if(setu > umin)
+ lprop.SetParameters(setu,setv);
+ }
+ }
+ ustep = 0;
+ vstep = 0.1*(vmax-vmin);
+ setv = vmin;
+ }
+ else
+ {
+ while(setv < vmax && (lprop.D1U().Magnitude() < 1e-5 || !lprop.IsNormalDefined())) {
+ setv += vstep;
+ if(setv < vmax)
+ lprop.SetParameters(setu,setv);
+ }
+ if (lprop.D1U().Magnitude() < 1e-5 || !lprop.IsNormalDefined()) {
+ setv = geominfo.v;
+ while(setv > vmin && (lprop.D1U().Magnitude() < 1e-5 || !lprop.IsNormalDefined())) {
+ setv -= vstep;
+ if(setv > vmin)
+ lprop.SetParameters(setu,setv);
+ }
+ }
+ vstep = 0;
+ ustep = 0.1*(umax-umin);
+ setu = umin;
+ }
+
+ if ( !lprop.IsNormalDefined() )
+ return;
+ gp_Vec N1 = lprop.Normal();
+
+ const double angleTol = PI / 180.;
+ while(setu < umax && setv < vmax) {
+ lprop.SetParameters(setu,setv);
+ if ( lprop.IsNormalDefined() ) {
+ gp_Vec Ni = lprop.Normal();
+ double angle = N1.Angle(Ni);
+ if ( angle > angleTol ) {
+ //cout << "Too large angle: " << angle * 180. / PI << endl;
+ return;
+ }
+ n(0)+=Ni.X();
+ n(1)+=Ni.Y();
+ n(2)+=Ni.Z();
+ setu += ustep;
+ setv += vstep;
+ }
+ }
n.Normalize();
+// (*testout) << "u " << geominfo.u << " v " << geominfo.v
+// <<" p " << lprop.Value().X()<<" "<<lprop.Value().Y()<<" "<<lprop.Value().Z()<<" "
+// <<" n " << n(0)<< " "<<n(1)<< " "<<n(2)<< " "<<endl;
}
else
{
- n(0)=lprop.Normal().X();
- n(1)=lprop.Normal().Y();
- n(2)=lprop.Normal().Z();
+ if ( lprop.IsNormalDefined() ) {
+ n(0)=lprop.Normal().X();
+ n(1)=lprop.Normal().Y();
+ n(2)=lprop.Normal().Z();
+ }
}
if(glob_testout)
@@ -411,11 +413,16 @@
}