]> OCCT Git - occt.git/commitdiff
0033326: Data Exchange, IGES Import - Ignoring unit value for validating geometry
authordpasukhi <dpasukhi@opencascade.com>
Wed, 8 Feb 2023 17:42:55 +0000 (17:42 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Wed, 8 Feb 2023 17:58:18 +0000 (17:58 +0000)
Updated IGESToBRep_CurveAndSurface and its childs to work with geometry as is not scaled yet.

src/IGESControl/IGESControl_IGESBoundary.cxx
src/IGESToBRep/IGESToBRep_BRepEntity.cxx
src/IGESToBRep/IGESToBRep_BasicCurve.cxx
src/IGESToBRep/IGESToBRep_BasicSurface.cxx
src/IGESToBRep/IGESToBRep_CurveAndSurface.cxx
src/IGESToBRep/IGESToBRep_TopoCurve.cxx

index bdcae284d958e51c6639bf9df0390c9a441f175b..1fd082252b35b12d869ce6eef6c3372ebd496abe 100644 (file)
@@ -150,6 +150,7 @@ static Standard_Boolean Connect (const Handle(ShapeAnalysis_Wire)& theSAW,
                                                      const Standard_Integer number,
                                                      Handle(ShapeExtend_WireData)& Gsewd) 
 {
+  (void)number;
   Gsewd                                = new ShapeExtend_WireData;//local translation (for mysewd)
   Handle(ShapeExtend_WireData) Gsewd3d = new ShapeExtend_WireData;//local translation (for mysewd3d)
   Handle(ShapeExtend_WireData) Gsewd2d = new ShapeExtend_WireData;//local translation (for mysewd2d)
@@ -384,17 +385,31 @@ static Standard_Boolean Connect (const Handle(ShapeAnalysis_Wire)& theSAW,
     }
   }
   
-  if (number > 1) {
-    okCurve   = okCurve && Connect (saw, mysewd, Gsewd, (len3d > 1) || (len2d > 1), maxtol,
-      distmin, revsewd, revnextsewd);
+  if (!mysewd.IsNull())
+  {
+    okCurve = okCurve && Connect(saw, mysewd, Gsewd, (len3d > 1) || (len2d > 1), maxtol,
+                                 distmin, revsewd, revnextsewd);
+  }
+  else
+  {
+    mysewd = Gsewd;
+  }
+  if (!mysewd3d.IsNull())
+  {
     okCurve3d = okCurve3d && Connect (saw3d, mysewd3d, Gsewd3d, len3d > 1, maxtol,
       distmin, revsewd, revnextsewd);
+  }
+  else
+  {
+    mysewd3d = Gsewd3d;
+  }
+  if (!mysewd2d.IsNull())
+  {
     okCurve2d = okCurve2d && Connect (saw2d, mysewd2d, Gsewd2d, len2d > 1, maxtol,
       distmin, revsewd, revnextsewd);
   }
-  else {
-    mysewd   = Gsewd;
-    mysewd3d = Gsewd3d;
+  else
+  {
     mysewd2d = Gsewd2d;
   }
   return okCurve;
index bac7bedc3555991e2147b3225eeeacdb4f748e6e..38d6cefa26c7be4e21eca88f1b323387f7a4c736 100644 (file)
@@ -252,7 +252,7 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferEdge
            Standard_Real dist2f = p2.Distance ( pf );
            Standard_Real dist1l = p1.Distance ( pl );
            Standard_Real dist2l = p2.Distance ( pl );
-           if ( V1.IsSame(V2) || dist1f + dist2l <= dist1l + dist2f + Precision::Confusion() ) {
+           if ( V1.IsSame(V2) || dist1f + dist2l <= dist1l + dist2f + (Precision::Confusion() / GetUnitFactor()) ) {
              //:77 if (BRepTools::Compare(V1, Vf)) //the part 'else' only if, in fact, edge should be reversed
              V1.Orientation(TopAbs_FORWARD);
              B.Add(E,V1);
@@ -395,7 +395,7 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferLoop(const Handle(IGESSolid_Loop)& s
            Curves2d->SetValue (i, start->ParametricCurve(iedge,i));
        }
        Handle(ShapeExtend_WireData) lsewd;//result of translation of current edge
-       Result = Result & IB->Transfer (okCurve, okCurve3d, okCurve2d,
+       Result = Result && IB->Transfer (okCurve, okCurve3d, okCurve2d,
                                        curve3d, Curves2d, !orientation,
                                        iedge, lsewd);
        if (iedge == 1) sewd = IB->WireData();//initialization
index 5dd82b3e2d96c54606b72172ad1b6bb1594ebe68..3dd0f776dfb0aebc50c3e98cccf76379ca1dc23b 100644 (file)
@@ -343,7 +343,7 @@ Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferConicArc
     //The dimensions should be also obliged:
     //[a]=[b]=[c]=L^-2
     //if ( (Abs(a-c) <= GetEpsGeom()) && (Abs(b) < GetEpsCoeff()))
-    Standard_Real eps2 = Precision::PConfusion() * Precision::PConfusion();
+    Standard_Real eps2 = (Precision::PConfusion() * Precision::PConfusion()) / GetUnitFactor();
     if ( (Abs(a-c) <= eps2) && (Abs(b) < eps2)) {
     
 //                          =================
@@ -358,8 +358,8 @@ Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferConicArc
 
         t1 = ElCLib::Parameter(circ, startPoint);
         t2 = ElCLib::Parameter(circ, endPoint);
-       if (t1 > t2 && (t1 - t2) > Precision::Confusion()) t2 += 2.*M_PI;
-       if (Abs(t1 - t2) <= Precision::Confusion())  { // t1 = t2
+       if (t1 > t2 && (t1 - t2) > Precision::Confusion() / GetUnitFactor()) t2 += 2.*M_PI;
+       if (Abs(t1 - t2) <= Precision::Confusion() / GetUnitFactor())  { // t1 = t2
          Message_Msg msg1160("IGES_1160");
          SendWarning(st, msg1160);      
        }
@@ -388,7 +388,7 @@ Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferConicArc
     
     t1 = ElCLib::Parameter(parab, startPoint);
     t2 = ElCLib::Parameter(parab, endPoint);
-    if (Abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2
+    if (Abs(t1 - t2) <= Precision::Confusion() / GetUnitFactor()) { // t1 = t2
       Message_Msg msg1160("IGES_1160");
       SendWarning(st, msg1160);      
       //AddWarning(st, "The trim of the parabola is not correct.");
@@ -415,8 +415,8 @@ Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferConicArc
       
       t1 = ElCLib::Parameter(elips, startPoint);
       t2 = ElCLib::Parameter(elips, endPoint);
-      if (t2 < t1 && (t1 -t2) > Precision::Confusion()) t2 += 2.*M_PI;
-      if (Abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2   
+      if (t2 < t1 && (t1 -t2) > Precision::Confusion()/ GetUnitFactor()) t2 += 2.*M_PI;
+      if (Abs(t1 - t2) <= Precision::Confusion() / GetUnitFactor()) { // t1 = t2   
        Message_Msg msg1160("IGES_1160");
        SendWarning(st, msg1160);  
        //AddWarning(st, "The trim of the ellipse is not correct, the result will be a ellipse.");
@@ -435,7 +435,7 @@ Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferConicArc
     res = new Geom_Hyperbola(frame, majorRadius, minorRadius);
     
     //pdn taking PConfusion for parameters.
-    if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2   
+    if (Abs(t1 - t2) <= Precision::PConfusion() / GetUnitFactor()) { // t1 = t2   
        Message_Msg msg1160("IGES_1160");
        SendWarning(st, msg1160);  
       }
@@ -512,7 +512,7 @@ Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dConicArc
 
     //#60 rln 29.12.98 PRO17015
     //if ( (Abs(a-c) <= GetEpsGeom()) && (Abs(b) < GetEpsCoeff()))
-    Standard_Real eps2 = Precision::PConfusion() * Precision::PConfusion();
+    Standard_Real eps2 = (Precision::PConfusion() * Precision::PConfusion()) / GetUnitFactor();
     if ( (Abs(a-c) <= eps2) && (Abs(b) < eps2)) {
 
       //                          =================
@@ -531,8 +531,8 @@ Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dConicArc
         t1 = ElCLib::Parameter(circ, startPoint);
         t2 = ElCLib::Parameter(circ, endPoint);
        
-       if (t2 < t1 && (t1 -t2) > Precision::PConfusion()) t2 += 2.*M_PI;
-       if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
+       if (t2 < t1 && (t1 -t2) > Precision::PConfusion() / GetUnitFactor()) t2 += 2.*M_PI;
+       if (Abs(t1 - t2) <= Precision::PConfusion() / GetUnitFactor()) { // t1 = t2
          Message_Msg msg1160("IGES_1160");
          SendWarning(st, msg1160); 
        }
@@ -563,7 +563,7 @@ Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dConicArc
     
     t1  = ElCLib::Parameter(parab, startPoint);
     t2  = ElCLib::Parameter(parab, endPoint);
-    if (Abs(t1 - t2) <= Precision::PConfusion())  { // t1 = t2   
+    if (Abs(t1 - t2) <= Precision::PConfusion()/ GetUnitFactor())  { // t1 = t2   
        Message_Msg msg1160("IGES_1160");
        SendWarning(st, msg1160);  
       }  
@@ -593,8 +593,8 @@ Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dConicArc
       
       t1  = ElCLib::Parameter(elips, startPoint);
       t2  = ElCLib::Parameter(elips, endPoint);
-      if (t2 < t1 && (t1 - t2) > Precision::PConfusion()) t2 += 2.*M_PI;
-      if (Abs(t1 - t2) <= Precision::PConfusion())  { // t1 = t2   
+      if (t2 < t1 && (t1 - t2) > Precision::PConfusion() / GetUnitFactor()) t2 += 2.*M_PI;
+      if (Abs(t1 - t2) <= Precision::PConfusion() / GetUnitFactor())  { // t1 = t2   
        Message_Msg msg1160("IGES_1160");
        SendWarning(st, msg1160);  
       }
@@ -614,7 +614,7 @@ Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dConicArc
     t1 = ElCLib::Parameter(hpr, startPoint);
     t2 = ElCLib::Parameter(hpr, endPoint);
     
-    if (Abs(t1 - t2) <= Precision::PConfusion())   { // t1 = t2   
+    if (Abs(t1 - t2) <= Precision::PConfusion() / GetUnitFactor())   { // t1 = t2   
        Message_Msg msg1160("IGES_1160");
        SendWarning(st, msg1160);  
       }
@@ -684,7 +684,7 @@ Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferCircularArc
   t2 = ElCLib::Parameter(circ, endPoint);
 
   if ( st->IsClosed() && t1>=GetEpsGeom()) t2 = t1 + 2.*M_PI;
-  if (!st->IsClosed() && fabs(t1 - t2) <=Precision::PConfusion()) {    
+  if (!st->IsClosed() && fabs(t1 - t2) <=Precision::PConfusion() / GetUnitFactor()) {
     // micro-arc
     // cky 27 Aout 1996 : t2-t1 vaut distance(start,end)/rayon
     t2 = t1 + startPoint.Distance(endPoint)/st->Radius();
@@ -757,7 +757,7 @@ Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dCircularArc
   t2 = ElCLib::Parameter(circ, endPoint);
     
   if ( st->IsClosed() && t1>=GetEpsGeom()) t2 = t1 + 2.*M_PI;
-  if (!st->IsClosed() && fabs(t1 -t2) <= Precision::PConfusion()) { 
+  if (!st->IsClosed() && fabs(t1 -t2) <= Precision::PConfusion() / GetUnitFactor()) {
     // micro-arc
     // cky 27 Aout 1996 : t2-t1 vaut distance(start,end)/rayon
     t2 = t1 + startPoint.Distance(endPoint)/st->Radius();
@@ -819,7 +819,7 @@ Handle(Geom_BSplineCurve) IGESToBRep_BasicCurve::TransferSplineCurve
 
   //  Checking C2 and C1 continuity :
   //  ===============================
-  IGESConvGeom::IncreaseCurveContinuity (resconv, Min(Precision::Confusion(),epsgeom), GetContinuity());
+  IGESConvGeom::IncreaseCurveContinuity (resconv, Min(Precision::Confusion() / GetUnitFactor(),epsgeom), GetContinuity());
   return resconv;
 }
 
@@ -844,7 +844,7 @@ Handle(Geom2d_BSplineCurve) IGESToBRep_BasicCurve::Transfer2dSplineCurve
   // =================
   // The same Presision as in BSpline 2d is used
   Standard_Real epsGeom = GetEpsGeom();
-  SetEpsGeom(Precision::PConfusion());
+  SetEpsGeom(Precision::PConfusion() / GetUnitFactor());
   Handle(Geom_BSplineCurve) res3d = TransferSplineCurve(st);
   SetEpsGeom(epsGeom);
   if (res3d.IsNull()) 
@@ -1040,7 +1040,7 @@ Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferBSplineCurve
        Epsilon(WeightReference) && polynomial;
       //:39 by abv 15.12.97
       Standard_Real weight = start->Weight(i);
-      if ( weight < Precision::PConfusion() ) {
+      if ( weight < (Precision::PConfusion() / GetUnitFactor())) {
        Message_Msg msg1215("IGES_1215");
        SendFail(start, msg1215);
         // Some weights are not positive
@@ -1104,11 +1104,11 @@ Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferBSplineCurve
   // skl 21.02.2002 (exception in OCC133 and for file
   //                 "/dn04/OS/USINOR/UIdev/src/IsoLim/dat/igs/ps1002-v5.igs")
   Handle(Geom_BSplineCurve) BSplineRes2 = BSplineRes;
-  if (((Udeb-First)>-Precision::PConfusion() &&
-       (Last-Ufin)>-Precision::PConfusion()) && Udeb<=Ufin ) {
+  if (((Udeb-First)>-Precision::PConfusion() / GetUnitFactor() &&
+       (Last-Ufin)>-Precision::PConfusion() / GetUnitFactor()) && Udeb<=Ufin ) {
     try {
       OCC_CATCH_SIGNALS
-      if (Abs(Ufin-Udeb) > Precision::PConfusion())
+      if (Abs(Ufin-Udeb) > Precision::PConfusion() / GetUnitFactor())
         BSplineRes->Segment(Udeb, Ufin);
       res = BSplineRes;
     }
@@ -1249,7 +1249,7 @@ Handle(Geom_Curve)  IGESToBRep_BasicCurve::TransferLine
 
   // modif du 15/10/97  : test moins severe
   // beaucoup de points confondus a GetEpsGeom()*GetUnitFactor()
-  if (!Ps.IsEqual(Pe,Precision::Confusion())) { //:l3 abv 11 Jan 99: GetEpsGeom()*GetUnitFactor()/10.)) {
+  if (!Ps.IsEqual(Pe,Precision::Confusion() / (3 * GetUnitFactor()))) { //:l3 abv 11 Jan 99: GetEpsGeom()*GetUnitFactor()/10.)) {
     gp_Lin line(Ps, gp_Dir(gp_Vec(Ps,Pe)));
     Standard_Real t1 = ElCLib::Parameter(line, Ps);
     Standard_Real t2 = ElCLib::Parameter(line, Pe);
@@ -1299,7 +1299,7 @@ Handle(Geom2d_Curve)  IGESToBRep_BasicCurve::Transfer2dLine
                 start->EndPoint().Y());
   }
 
-  if (!beg.IsEqual(end,Precision::PConfusion())) { //:l3 abv 11 Jan 99: GetEpsCoeff())) {
+  if (!beg.IsEqual(end,Precision::PConfusion() / (2 * GetUnitFactor()))) { //:l3 abv 11 Jan 99: GetEpsCoeff())) {
     gp_Lin2d line2d(beg, gp_Dir2d(gp_Vec2d(beg,end)));
     Standard_Real t1 = ElCLib::Parameter(line2d, beg);
     Standard_Real t2 = ElCLib::Parameter(line2d, end);
@@ -1447,7 +1447,7 @@ Handle(Geom_BSplineCurve)  IGESToBRep_BasicCurve::TransferCopiousData
 
   res = new Geom_BSplineCurve(Pole, Knot, Mult, Degree);
   
-  IGESConvGeom::IncreaseCurveContinuity (res, Max(GetEpsGeom()/10.,Precision::Confusion()), GetContinuity());
+  IGESConvGeom::IncreaseCurveContinuity (res, Max(GetEpsGeom()/10.,Precision::Confusion() / (3 * GetUnitFactor())), GetContinuity());
   return res;
 }
 
@@ -1550,6 +1550,6 @@ Handle(Geom2d_BSplineCurve) IGESToBRep_BasicCurve::Transfer2dCopiousData(const H
   Standard_Real epsGeom = GetEpsGeom();
   Standard_Real anUVResolution = GetUVResolution();
   
-  IGESConvGeom::IncreaseCurveContinuity (res, Max(Precision::Confusion(),epsGeom*anUVResolution), GetContinuity());
+  IGESConvGeom::IncreaseCurveContinuity (res, Max(Precision::Confusion() / (3 * GetUnitFactor()),epsGeom*anUVResolution), GetContinuity());
   return res;
 }
index 8e5b0be91468b8a06622d9feff4ac92edf324206..e7ae69f884b62da88589ae39978150ae5c5474c0 100644 (file)
@@ -312,7 +312,7 @@ Handle(Geom_CylindricalSurface) IGESToBRep_BasicSurface::TransferRigthCylindrica
     // Direction Reading Error : Null IGESEntity
     return res;
   }
-  if (radius < Precision::Confusion()) {
+  if (radius < Precision::Confusion() / GetUnitFactor()) {
     return res;
   }
     
@@ -325,7 +325,7 @@ Handle(Geom_CylindricalSurface) IGESToBRep_BasicSurface::TransferRigthCylindrica
     Handle(IGESGeom_Direction) refdir = start->ReferenceDir();
     gp_Dir Dir = gp_Dir(refdir->Value());
     gp_Dir vc = Dir^ax;
-    if(vc.XYZ().Modulus() < Precision::Confusion()) {
+    if(vc.XYZ().Modulus() < Precision::Confusion() / (3 * GetUnitFactor())) {
       
       return res;
     }
@@ -368,13 +368,13 @@ Handle(Geom_ConicalSurface) IGESToBRep_BasicSurface::TransferRigthConicalSurface
     // Direction Reading Error : Null IGESEntity
     return res;
   }
-  if (angle < Precision::Confusion()||angle > M_PI/2.) {
+  if (angle < Precision::Confusion() / GetUnitFactor() ||angle > M_PI/2.) {
     return res;
   }
   if (radius < 0) {
     return res;
   }
-  if (radius < Precision::Confusion())
+  if (radius < Precision::Confusion() / GetUnitFactor())
     radius = 0.;
   
   gp_Pnt Pt = Point->Value();
@@ -386,7 +386,7 @@ Handle(Geom_ConicalSurface) IGESToBRep_BasicSurface::TransferRigthConicalSurface
     Handle(IGESGeom_Direction) refdir = start->ReferenceDir();
     gp_Dir Dir = gp_Dir(refdir->Value());
     gp_Dir vc = Dir^ax;
-    if(vc.XYZ().Modulus() < Precision::Confusion()) {
+    if(vc.XYZ().Modulus() < Precision::Confusion() / (3 * GetUnitFactor())) {
       
       return res;
     }
@@ -427,7 +427,7 @@ Handle(Geom_SphericalSurface) IGESToBRep_BasicSurface::TransferSphericalSurface
     // Direction Reading Error : Null IGESEntity
     return res;
   }
-  if (radius < Precision::Confusion()){
+  if (radius < Precision::Confusion() / GetUnitFactor()){
    
     return res;
   }
@@ -441,7 +441,7 @@ Handle(Geom_SphericalSurface) IGESToBRep_BasicSurface::TransferSphericalSurface
     Handle(IGESGeom_Direction) refdir = start->ReferenceDir();
     gp_Dir Dir = gp_Dir(refdir->Value());
     gp_Dir vc = Dir^ax;
-    if(vc.XYZ().Modulus() < Precision::Confusion()) {
+    if(vc.XYZ().Modulus() < Precision::Confusion() / (3 * GetUnitFactor())) {
       
       return res;
     }
@@ -483,7 +483,7 @@ Handle(Geom_ToroidalSurface) IGESToBRep_BasicSurface::TransferToroidalSurface
     // Direction Reading Error : Null IGESEntity
     return res;
   }
-  if (major < Precision::Confusion()||minor < Precision::Confusion()){
+  if (major < Precision::Confusion() / GetUnitFactor() || minor < Precision::Confusion() / GetUnitFactor()){
    
     return res;
   }
@@ -497,7 +497,7 @@ Handle(Geom_ToroidalSurface) IGESToBRep_BasicSurface::TransferToroidalSurface
     Handle(IGESGeom_Direction) refdir = start->ReferenceDir();
     gp_Dir Dir = gp_Dir(refdir->Value());
     gp_Dir vc = Dir^ax;
-    if(vc.XYZ().Modulus() < Precision::Confusion()) {
+    if(vc.XYZ().Modulus() < Precision::Confusion() / (3 * GetUnitFactor())) {
       
       return res;
     }
@@ -852,7 +852,7 @@ Handle(Geom_BSplineSurface)  IGESToBRep_BasicSurface::TransferBSplineSurface
                        <= Epsilon(WeightReference)) && polynomial;
          //:39 by abv 15.12.97
          Standard_Real weight = start->Weight(i,j);
-         if ( weight < Precision::PConfusion() ) {
+         if ( weight < Precision::PConfusion() / GetUnitFactor()) {
            Message_Msg msg1215("IGES_1215");
            SendFail (start, msg1215); // Some weights are not positive.
            return res;
index 1f55f6008863a251e949638289caa251aea42e31..94a957d83dfc749bb70567c8e7959b31af69d7ae 100644 (file)
@@ -148,7 +148,7 @@ void IGESToBRep_CurveAndSurface::UpdateMinMaxTol()
   //#74 rln 11.03.99 S4135: Setting maximum tolerances according to
   //static parameter
   myMaxTol = Max (Interface_Static::RVal ("read.maxprecision.val"), myEpsGeom * myUnitFactor);
-  myMinTol = Precision::Confusion();
+  myMinTol = Precision::Confusion() * GetUnitFactor();
 }
 
 //=======================================================================
index da9b15e2e42e2293b3bd1f62609eafdebed269f2..0cc3a43d8c5f6ffdb8a6ee2d748fe907739dbd7d 100644 (file)
@@ -1330,7 +1330,7 @@ TopoDS_Shape IGESToBRep_TopoCurve::TransferBoundaryOnFace(TopoDS_Face&  face,
     } 
     else
       Curves2d = start->ParameterCurves(i);
-    Result = Result & IB->Transfer (okCurve, okCurve3d, okCurve2d,
+    Result = Result && IB->Transfer (okCurve, okCurve3d, okCurve2d,
                                    start->ModelSpaceCurve(i), start->Sense(i) == 2,
                                    Curves2d, i);
   }