0027457: Modeling - Raise exception if scaled transformation is used for shape location
authorifv <ifv@opencascade.com>
Mon, 5 Apr 2021 08:15:45 +0000 (11:15 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 20 Aug 2021 17:18:06 +0000 (20:18 +0300)
Implementation of raising exception while using scale and mirror transformation in shape location
TopLoc/TopLoc_Location.hxx
TopoDS/TopoDS_Shape.hxx

Implementation of new tools for removing forbidden locations from shapes:
BRepTools/BRepTools_PurgeLocations.cxx
BRepTools/BRepTools_PurgeLocations.hxx
BRepTools/BRepTools.cxx
BRepTools/BRepTools.hxx

Draw commands for transforming shapes are corrected, new draw commands: purgeloc, checkloc added
BRepTest/BRepTest_BasicCommands.cxx

Fixing unstable test bug xde bug24759
StepToGeom/StepToGeom.cxx

All other C++ commits are modification of algorithms used mainly in import/export operations in order to allows these operations if shape locations contains scale and mirror transformations.

New test for command purgeloc added
tests/bugs/moddata_3/bug27457
tests/bugs/moddata_3/bug27457_1
tests/bugs/moddata_3/bug27457_2

Some test corrected according to modifications.

41 files changed:
src/BRep/BRep_Tool.cxx
src/BRepBuilderAPI/BRepBuilderAPI_Transform.cxx
src/BRepLib/BRepLib.cxx
src/BRepTest/BRepTest_BasicCommands.cxx
src/BRepTools/BRepTools.cxx
src/BRepTools/BRepTools.hxx
src/BRepTools/BRepTools_Modifier.cxx
src/BRepTools/BRepTools_PurgeLocations.cxx [new file with mode: 0644]
src/BRepTools/BRepTools_PurgeLocations.hxx [new file with mode: 0644]
src/BRepTools/BRepTools_ReShape.cxx
src/BRepTools/FILES
src/BinTools/BinTools_ShapeReader.cxx
src/BinTools/BinTools_ShapeSet.cxx
src/IGESCAFControl/IGESCAFControl_Writer.cxx
src/IGESToBRep/IGESToBRep_CurveAndSurface.cxx
src/IGESToBRep/IGESToBRep_TopoSurface.cxx
src/RWGltf/RWGltf_GltfJsonParser.cxx
src/RWMesh/RWMesh_CafReader.cxx
src/ShapeCustom/ShapeCustom.cxx
src/ShapeFix/ShapeFix_Shape.cxx
src/ShapeProcess/ShapeProcess_OperLibrary.cxx
src/ShapeProcess/ShapeProcess_ShapeContext.cxx
src/StepToGeom/StepToGeom.cxx
src/TopExp/TopExp.cxx
src/TopExp/TopExp.hxx
src/TopLoc/TopLoc_Location.hxx
src/TopTools/TopTools_ShapeSet.cxx
src/TopoDS/TopoDS_Builder.cxx
src/TopoDS/TopoDS_Iterator.cxx
src/TopoDS/TopoDS_Shape.hxx
src/VrmlData/VrmlData_Group.cxx
src/XCAFDoc/XCAFDoc_ShapeTool.cxx
src/XCAFPrs/XCAFPrs.cxx
tests/bugs/modalg_6/bug28394_2
tests/bugs/moddata_3/bug27457 [new file with mode: 0644]
tests/bugs/moddata_3/bug27457_1 [new file with mode: 0644]
tests/bugs/moddata_3/bug27457_2 [new file with mode: 0644]
tests/v3d/bugs/bug22240
tests/v3d/bugs/bug30630_1
tests/v3d/bugs/bug30630_2
tests/v3d/bugs/bug30630_3

index 7e2f0f4..5d308fc 100644 (file)
@@ -992,8 +992,8 @@ void  BRep_Tool::UVPoints(const TopoDS_Edge& E,
     TopExp::Vertices(E,Vf,Vl);
 
     TopLoc_Location Linverted = L.Inverted();
-    Vf.Move(Linverted);
-    Vl.Move(Linverted);
+    Vf.Move(Linverted, Standard_False);
+    Vl.Move(Linverted, Standard_False);
     Standard_Real u,v;
     gp_Pln pln = GP->Pln();
 
index 8c722fe..8052e97 100644 (file)
@@ -57,10 +57,7 @@ BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& S,
 void BRepBuilderAPI_Transform::Perform(const TopoDS_Shape& S,
                                const Standard_Boolean Copy)
 {
-//  myUseModif = Copy || myTrsf.IsNegative(); bug gp_Trsf.
-  myUseModif = Copy || 
-    myTrsf.ScaleFactor()*myTrsf.HVectorialPart().Determinant() < 0. ||
-      Abs(Abs(myTrsf.ScaleFactor()) - 1) > gp::Resolution();
+  myUseModif = Copy || myTrsf.IsNegative() || (Abs(Abs(myTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
   if (myUseModif) {
     Handle(BRepTools_TrsfModification) theModif = 
       Handle(BRepTools_TrsfModification)::DownCast(myModification);
index 9079366..18733f8 100644 (file)
@@ -1991,6 +1991,12 @@ public:
       theCurvature1 = -theCurvature1;
       theCurvature2 = -theCurvature2;
     }
+    if (mySurfaceTrsf.IsNegative())
+    {
+      theCurvature1 = -theCurvature1;
+      theCurvature2 = -theCurvature2;
+    }
+
     thePrincipalDir1.Transform(mySurfaceTrsf);
     thePrincipalDir2.Transform(mySurfaceTrsf);
   }
index 0658307..aecc356 100644 (file)
@@ -56,7 +56,8 @@
 #include <Draw_Marker3D.hxx>
 #include <Draw_MarkerShape.hxx>
 #include <BRepPrimAPI_MakeBox.hxx>
-
+#include <BRepTools_PurgeLocations.hxx>
+#include <BRepTools.hxx>
 #include <Standard_Dump.hxx>
 
 #include <stdio.h>
@@ -116,7 +117,7 @@ static Standard_Integer addpcurve(Draw_Interpretor& , Standard_Integer n, const
 // transform
 //=======================================================================
 
-static Standard_Integer transform(Draw_Interpretor& ,Standard_Integer n,const char** a)
+static Standard_Integer transform(Draw_Interpretor&,Standard_Integer n,const char** a)
 {
   if (n <= 1) return 1;
 
@@ -125,6 +126,7 @@ static Standard_Integer transform(Draw_Interpretor& ,Standard_Integer n,const ch
   const char* aName = a[0];
 
   Standard_Boolean isBasic = Standard_False;
+  Standard_Boolean isForced = Standard_False;
   Standard_Boolean isCopy = Standard_False;
 
   // Check "copy" flag.
@@ -137,6 +139,8 @@ static Standard_Integer transform(Draw_Interpretor& ,Standard_Integer n,const ch
   }
   else {
     isBasic = (aName[0] == 'b');
+    isForced = (aName[0] == 'f');
+
     aName++;
 
     if (!strcmp(aName,"move")) {
@@ -145,6 +149,7 @@ static Standard_Integer transform(Draw_Interpretor& ,Standard_Integer n,const ch
       if (SL.IsNull()) return 0;
       T = SL.Location().Transformation();
       last = n-1;
+      isBasic = Standard_True;
     }
     else if (!strcmp(aName,"translate")) {
       if (n < 5) return 1;
@@ -162,6 +167,7 @@ static Standard_Integer transform(Draw_Interpretor& ,Standard_Integer n,const ch
       if (n < 8) return 1;
       T.SetMirror(gp_Ax2(gp_Pnt(Draw::Atof(a[n-6]),Draw::Atof(a[n-5]),Draw::Atof(a[n-4])),
                   gp_Vec(Draw::Atof(a[n-3]),Draw::Atof(a[n-2]),Draw::Atof(a[n-1]))));
+
       last = n-6;
     }
     else if (!strcmp(aName,"scale")) {
@@ -171,7 +177,12 @@ static Standard_Integer transform(Draw_Interpretor& ,Standard_Integer n,const ch
     }
   }
 
-  if (T.Form() == gp_Identity || isBasic) {
+  if (T.Form() == gp_Identity || isBasic || isForced) {
+    Standard_Boolean isExeption = Standard_True;
+    if (isForced)
+    {
+      isExeption = Standard_False;
+    }
     TopLoc_Location L(T);
     for (Standard_Integer i = 1; i < last; i++) {
       TopoDS_Shape S = DBRep::Get(a[i]);
@@ -181,7 +192,25 @@ static Standard_Integer transform(Draw_Interpretor& ,Standard_Integer n,const ch
         return 1;
       }
       else
-        DBRep::Set(a[i],S.Located(L));
+      {
+        try
+        {
+          if (!strcmp(aName, "move") || !strcmp(aName, "reset"))
+          {
+            DBRep::Set(a[i], S.Located(L, isExeption));
+          }
+          else
+          {
+            DBRep::Set(a[i], S.Moved(L, isExeption));
+          }
+        }
+        catch (const Standard_DomainError&)
+        {
+          TCollection_AsciiString aScale(T.ScaleFactor());
+          Message::SendWarning() << "Operation is not done: " << aName << " is not a valid transformation - scale = " << aScale;
+          return 0;
+        }
+      }
     }
   }
   else {
@@ -1385,6 +1414,63 @@ static Standard_Integer issubshape(Draw_Interpretor& di,
   //
   return 0;
 }
+//=======================================================================
+//function : purgeloc
+//purpose  : 
+//=======================================================================
+static Standard_Integer purgeloc(Draw_Interpretor& di, Standard_Integer /*n*/, const char** a)
+{
+
+  TopoDS_Shape aShapeBase = DBRep::Get(a[2]);
+  if (aShapeBase.IsNull()) return 1;
+
+
+  BRepTools_PurgeLocations aRemLoc;
+  Standard_Boolean isDone = aRemLoc.Perform(aShapeBase);
+  TopoDS_Shape Result = aRemLoc.GetResult();
+
+  DBRep::Set(a[1], Result);
+  if (isDone)
+  {
+    di << "All problematic locations are purged \n";
+  }
+  else
+  {
+    di << "Not all problematic locations are purged \n";
+  }
+  return 0;
+}
+//=======================================================================
+//function : checkloc
+//purpose  : 
+//=======================================================================
+
+static Standard_Integer checkloc(Draw_Interpretor& di, Standard_Integer /*n*/, const char** a)
+{
+
+  TopoDS_Shape aShapeBase = DBRep::Get(a[1]);
+  if (aShapeBase.IsNull()) return 1;
+
+  TopTools_ListOfShape aLS;
+  BRepTools::CheckLocations(aShapeBase, aLS);
+  if (aLS.IsEmpty())
+  {
+    di << "There are no problematic shapes" << "\n";
+    return 0;
+  }
+  TopTools_ListIteratorOfListOfShape anIt(aLS);
+  Standard_Integer i;
+  for (i = 1; anIt.More(); anIt.Next(), ++i)
+  {
+    TCollection_AsciiString aName(a[1]);
+    aName += "_";
+    aName.AssignCat(i);
+    DBRep::Set(aName.ToCString(), anIt.Value());
+    di << aName << " ";
+  }
+  di << "\n";
+  return 0;
+}
 
 void  BRepTest::BasicCommands(Draw_Interpretor& theCommands)
 {
@@ -1441,6 +1527,11 @@ void  BRepTest::BasicCommands(Draw_Interpretor& theCommands)
                  __FILE__,
                  transform,g);
 
+  theCommands.Add("fmove",
+                  "fmove name1 name2 ... name, set location from name",
+                  __FILE__,
+                  transform, g);
+
   theCommands.Add("btranslate",
                  "btranslate name1 name2 ... dx dy dz",
                  __FILE__,
@@ -1456,11 +1547,21 @@ void  BRepTest::BasicCommands(Draw_Interpretor& theCommands)
                  __FILE__,
                  transform,g);
 
+  theCommands.Add("fmirror",
+                  "fmirror name x y z dx dy dz",
+                  __FILE__,
+                   transform, g);
+
   theCommands.Add("bscale",
                  "bscale name x y z scale",
                  __FILE__,
                  transform,g);
 
+  theCommands.Add("fscale",
+                  "fscale name x y z scale",
+                  __FILE__,
+                  transform, g);
+
   theCommands.Add("precision",
                  "precision [preci]",
                  __FILE__,
@@ -1593,4 +1694,13 @@ void  BRepTest::BasicCommands(Draw_Interpretor& theCommands)
                   "\t\tCheck if the shape is sub-shape of other shape and get its index in the shape.",
                   __FILE__,
                   issubshape, g);
+  theCommands.Add("purgeloc",
+    "purgeloc res shape ",
+    __FILE__,
+    purgeloc, g);
+
+  theCommands.Add("checkloc",
+    "checkloc shape ",
+    __FILE__,
+    checkloc, g);
 }
index 8f0c3b3..99b3828 100644 (file)
@@ -65,6 +65,9 @@
 #include <TopTools_SequenceOfShape.hxx>
 #include <GeomLib_CheckCurveOnSurface.hxx>
 #include <errno.h>
+#include <BRepTools_TrsfModification.hxx>
+#include <BRepTools_Modifier.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
 
 //=======================================================================
@@ -1518,3 +1521,33 @@ void BRepTools::RemoveInternals (TopoDS_Shape& theS,
 
   removeInternals (theS, pMKeep);
 }
+
+//=======================================================================
+//function : CheckLocations
+//purpose  : 
+//=======================================================================
+
+void BRepTools::CheckLocations(const TopoDS_Shape& theS,
+                               TopTools_ListOfShape& theProblemShapes)
+{
+  if (theS.IsNull()) return;
+
+  TopTools_IndexedMapOfShape aMapS;
+  TopExp::MapShapes(theS, aMapS, Standard_False, Standard_False);
+
+  Standard_Integer i;
+  for (i = 1; i <= aMapS.Extent(); ++i)
+  {
+    const TopoDS_Shape& anS = aMapS(i);
+    const TopLoc_Location& aLoc = anS.Location();
+    const gp_Trsf& aTrsf = aLoc.Transformation();
+    Standard_Boolean isBadTrsf = aTrsf.IsNegative() ||
+      (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
+
+    if (isBadTrsf)
+    {
+      theProblemShapes.Append(anS);
+    }
+  }
+
+}
\ No newline at end of file
index babe873..968fd90 100644 (file)
@@ -29,6 +29,7 @@
 #include <Standard_IStream.hxx>
 #include <Standard_CString.hxx>
 #include <Message_ProgressRange.hxx>
+#include <TopTools_ListOfShape.hxx>
 
 class TopoDS_Face;
 class TopoDS_Wire;
@@ -358,9 +359,14 @@ public:
   //! removal is not going to break topological connectivity between sub-shapes.
   //! The flag <theForce> if set to true disables the connectivity check and clears
   //! the given shape from all sub-shapes with internal orientation.
-  Standard_EXPORT static void RemoveInternals (TopoDS_Shape& theS,
-                                               const Standard_Boolean theForce = Standard_False);
-
+  Standard_EXPORT static void RemoveInternals(TopoDS_Shape& theS,
+    const Standard_Boolean theForce = Standard_False);
+
+  //! Check all locations of shape according criterium:
+  //! aTrsf.IsNegative() || (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec())
+  //! All sub-shapes having such locations are put in list theProblemShapes
+  Standard_EXPORT static void CheckLocations(const TopoDS_Shape& theS,
+                                             TopTools_ListOfShape& theProblemShapes);
 
 protected:
 
index deeb1ee..f4cf6f3 100644 (file)
@@ -272,7 +272,7 @@ Standard_Boolean BRepTools_Modifier::Rebuild
         RevWires = aNSinfo.myRevWires;
         B.MakeFace(TopoDS::Face(result),aNSinfo.mySurface,
           aNSinfo.myLoc.Predivided(S.Location()),aNSinfo.myToler);
-        result.Location(S.Location());
+        result.Location(S.Location(), Standard_False);
         if (aNSinfo.myRevFace) 
           ResOr = TopAbs_REVERSED;
         // set specifics flags of a Face
@@ -288,7 +288,7 @@ Standard_Boolean BRepTools_Modifier::Rebuild
         else
         { // create new face with bare triangulation
           B.MakeFace(TopoDS::Face(result), aTriangulation);
-          result.Location(S.Location());
+          result.Location(S.Location(), Standard_False);
         }
         rebuild = Standard_True;
       }
@@ -313,7 +313,7 @@ Standard_Boolean BRepTools_Modifier::Rebuild
             aNCinfo.myLoc.Predivided(S.Location()),aNCinfo.myToler);
          No3DCurve = Standard_False;
        }
-       result.Location(S.Location());
+       result.Location(S.Location(), Standard_False);
 //     result.Orientation(S.Orientation());
 
        // set specifics flags of an Edge
@@ -332,7 +332,7 @@ Standard_Boolean BRepTools_Modifier::Rebuild
         else
         { // create new edge with bare polygon
           B.MakeEdge(TopoDS::Edge(result), aPolygon);
-          result.Location(S.Location());
+          result.Location(S.Location(), Standard_False);
         }
         rebuild = Standard_True;
       }
diff --git a/src/BRepTools/BRepTools_PurgeLocations.cxx b/src/BRepTools/BRepTools_PurgeLocations.cxx
new file mode 100644 (file)
index 0000000..1bc807a
--- /dev/null
@@ -0,0 +1,220 @@
+// Copyright (c) 2021 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <BRepTools_PurgeLocations.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <NCollection_Vector.hxx>
+#include <BRepTools.hxx>
+#include <StdFail_NotDone.hxx>
+#include <BRepTools_TrsfModification.hxx>
+#include <BRepTools_Modifier.hxx>
+#include <TopLoc_Datum3D.hxx>
+
+//=======================================================================
+//function : BRepTools_PurgeLocations
+//purpose  : 
+//=======================================================================
+BRepTools_PurgeLocations::BRepTools_PurgeLocations() :
+  myDone(Standard_False)
+{
+}
+
+//=======================================================================
+//function : Perform
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean BRepTools_PurgeLocations::Perform(const TopoDS_Shape& theShape)
+{
+  myShape = theShape;
+  myMapShapes.Clear();
+  myLocations.Clear();
+  myDone = Standard_True;
+  AddShape(myShape);
+
+  //Check locations;
+  Standard_Integer ind;
+  NCollection_Vector<Standard_Integer> aBadTrsfInds;
+  for (ind = 1; ; ++ind)
+  {
+    const TopLoc_Location& aLoc = myLocations.Location(ind);
+
+    if (aLoc.IsIdentity())
+      break;
+
+    const gp_Trsf& aTrsf = aLoc.Transformation();
+    Standard_Boolean isBadTrsf = aTrsf.IsNegative() ||
+      (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
+    if (isBadTrsf)
+    {
+      aBadTrsfInds.Append(ind);
+    }
+  }
+
+  if (aBadTrsfInds.IsEmpty())
+  {
+    return myDone;
+  }
+
+  Standard_Integer aNbShapes = myMapShapes.Extent();
+  myMapNewShapes.Clear();
+  Standard_Integer inds;
+  for (inds = 1; inds <= aNbShapes; ++inds)
+  {
+    const TopoDS_Shape& anS = myMapShapes(inds);
+    Standard_Integer aLocInd = myLocations.Index(anS.Location());
+    if(aLocInd == 0)
+    {
+      continue;
+    }
+    Standard_Integer il;
+    for (il = 0; il < aBadTrsfInds.Size(); ++il)
+    {
+      if (aBadTrsfInds(il) == aLocInd)
+      {
+        TopoDS_Shape aTrS;
+        Standard_Boolean isDone = PurgeLocation(anS, aTrS);
+        myDone = myDone && isDone;
+        myMapNewShapes.Bind(anS, aTrS);
+        break;
+      }
+
+    }
+  }
+
+  if (myReShape.IsNull())
+  {
+    myReShape = new BRepTools_ReShape;
+  }
+  else
+  {
+    myReShape->Clear();
+  }
+  TopTools_DataMapIteratorOfDataMapOfShapeShape anIter(myMapNewShapes);
+  for (; anIter.More(); anIter.Next())
+  {
+    const TopoDS_Shape& anOldS = anIter.Key();
+    const TopoDS_Shape& aNewS = anIter.Value();
+    myReShape->Replace(anOldS, aNewS);
+  }
+
+  myShape = myReShape->Apply(myShape);
+
+  return myDone;
+
+}
+
+//=======================================================================
+//function : PurgeLocation
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean BRepTools_PurgeLocations::PurgeLocation(const TopoDS_Shape& theS, TopoDS_Shape& theRes)
+{
+  Standard_Boolean isDone = Standard_True;
+  TopLoc_Location aRefLoc = theS.Location();
+  Standard_Boolean isEmpty = aRefLoc.IsIdentity();
+  if (isEmpty)
+  {
+    theRes = theS;
+    return isDone;
+  }
+
+  TopLoc_Location aNullLoc;
+  theRes = theS.Located(aNullLoc);
+
+  while (!isEmpty)
+  {
+    const Handle(TopLoc_Datum3D)& aFD = aRefLoc.FirstDatum();
+    gp_Trsf aTrsf = aFD->Trsf();
+    Standard_Integer aFP = aRefLoc.FirstPower();
+    Standard_Boolean isBad = aTrsf.IsNegative() || (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
+    TopLoc_Location aLoc(aFD);
+    aLoc = aLoc.Powered(aFP);
+    aTrsf = aLoc.Transformation();
+    if (isBad)
+    {
+      Handle(BRepTools_TrsfModification) aModification = new BRepTools_TrsfModification(aTrsf);
+      BRepTools_Modifier aModifier(theRes, aModification);
+      if (aModifier.IsDone())
+      {
+        theRes = aModifier.ModifiedShape(theRes);
+      }
+      else
+      {      
+        isDone = Standard_False;
+        theRes = theRes.Moved(aLoc);
+      }
+    }
+    else
+    {
+      theRes = theRes.Moved(aLoc);
+    }
+
+    aRefLoc = aRefLoc.NextLocation();
+    isEmpty = aRefLoc.IsIdentity();
+  }
+
+  return isDone;
+}
+
+//=======================================================================
+//function : AddShape
+//purpose  : 
+//=======================================================================
+
+void BRepTools_PurgeLocations::AddShape(const TopoDS_Shape& theS) 
+{
+  myMapShapes.Add(theS);
+  myLocations.Add(theS.Location());
+
+  TopoDS_Iterator It(theS, Standard_False, Standard_False);
+  while (It.More()) {
+    AddShape(It.Value());
+    It.Next();
+  }
+}
+
+//=======================================================================
+//function : GetResult
+//purpose  : 
+//=======================================================================
+
+const TopoDS_Shape& BRepTools_PurgeLocations::GetResult() const
+{
+  return myShape;
+}
+
+//=======================================================================
+//function : IsDone
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean  BRepTools_PurgeLocations::IsDone() const
+{
+  return myDone;
+}
+
+//=======================================================================
+//function : ModifiedShape
+//purpose  : 
+//=======================================================================
+
+TopoDS_Shape  BRepTools_PurgeLocations::ModifiedShape(const TopoDS_Shape& theInitShape) const
+{
+  TopoDS_Shape aShape = theInitShape;
+  if (myMapNewShapes.IsBound(theInitShape))
+    aShape = myMapNewShapes.Find(theInitShape);
+  return aShape;
+}
+
diff --git a/src/BRepTools/BRepTools_PurgeLocations.hxx b/src/BRepTools/BRepTools_PurgeLocations.hxx
new file mode 100644 (file)
index 0000000..4f63283
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (c) 2021 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BRepTools_PurgeLocations_HeaderFile
+#define _BRepTools_PurgeLocations_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+#include <BRepTools_ReShape.hxx>
+#include <TopTools_LocationSet.hxx>
+
+class TopoDS_Shape;
+
+class BRepTools_PurgeLocations;
+
+//! Removes location datums, which satisfy conditions:
+//! aTrsf.IsNegative() || (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec())
+//! from all locations of shape and its subshapes
+class BRepTools_PurgeLocations
+{
+
+public:
+  
+  Standard_EXPORT BRepTools_PurgeLocations();
+   
+  //! Removes all locations correspodingly to criterium from theShape.
+  Standard_EXPORT Standard_Boolean Perform(const TopoDS_Shape& theShape);
+
+  //! Returns shape with removed locations.
+  Standard_EXPORT const TopoDS_Shape& GetResult() const;
+
+  Standard_EXPORT Standard_Boolean  IsDone() const;
+
+  //! Returns modified shape obtained from initial shape.
+  TopoDS_Shape ModifiedShape(const TopoDS_Shape& theInitShape) const;
+
+private:
+
+  void AddShape(const TopoDS_Shape& theS);
+  Standard_Boolean PurgeLocation(const TopoDS_Shape& theS, TopoDS_Shape& theRes);
+
+  Standard_Boolean myDone;
+  TopoDS_Shape myShape;
+  TopTools_IndexedMapOfShape myMapShapes;
+  TopTools_LocationSet myLocations;
+  TopTools_DataMapOfShapeShape myMapNewShapes;
+  Handle(BRepTools_ReShape) myReShape;
+
+};
+
+#endif // _BRepTools_PurgeLocations_HeaderFile
index 4eb968e..63c00a0 100644 (file)
@@ -174,7 +174,7 @@ void BRepTools_ReShape::replace (const TopoDS_Shape& ashape,
 
   if (myConsiderLocation) {
     //sln 29.11.01 Bug22: Change location of 'newshape' in accordance with location of 'shape'
-    newshape.Location(newshape.Location().Multiplied(shape.Location().Inverted()));
+    newshape.Location(newshape.Location().Multiplied(shape.Location().Inverted()), Standard_False);
     TopLoc_Location nullLoc; 
     shape.Location ( nullLoc );
   }
@@ -243,8 +243,8 @@ TopoDS_Shape BRepTools_ReShape::Value (const TopoDS_Shape& ashape) const
   if (myConsiderLocation) {
     //sln 29.11.01 Bug22: Recalculate location of resulting shape in accordance with
     //whether result is from map or not
-    if(fromMap) res.Location(ashape.Location()*res.Location());
-    else res.Location(ashape.Location());
+    if(fromMap) res.Location(ashape.Location()*res.Location(), Standard_False);
+    else res.Location(ashape.Location(), Standard_False);
   }
 
   return res;
@@ -300,7 +300,7 @@ Standard_Integer BRepTools_ReShape::Status(const TopoDS_Shape& ashape,
   {
     TopLoc_Location aResLoc = (res >0 && !newsh.Location().IsIdentity() ? 
       aLocSh * newsh.Location() : aLocSh);
-    newsh.Location(aResLoc);
+    newsh.Location(aResLoc, Standard_False);
   }
   return res;
 }
index bebdc48..60a0c86 100644 (file)
@@ -26,3 +26,5 @@ BRepTools_TrsfModification.cxx
 BRepTools_TrsfModification.hxx
 BRepTools_WireExplorer.cxx
 BRepTools_WireExplorer.hxx
+BRepTools_PurgeLocations.cxx
+BRepTools_PurgeLocations.hxx
\ No newline at end of file
index bf23f99..c797b4f 100644 (file)
@@ -90,7 +90,7 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape (BinTools_IStream& theStream)
       aResult = ReadShape (theStream);
       theStream.GoTo (aCurrent); // returns to the current position
     }
-    aResult.Location (*ReadLocation (theStream));
+    aResult.Location (*ReadLocation (theStream), Standard_False);
     aResult.Orientation (TopAbs_Orientation (theStream.ReadByte()));
     return aResult;
   }
@@ -323,7 +323,7 @@ TopoDS_Shape BinTools_ShapeReader::ReadShape (BinTools_IStream& theStream)
   aResult.Convex (aConv);
   myShapePos.Bind (aPosition, aResult);
   aResult.Orientation (aShapeOrientation);
-  aResult.Location (*aShapeLocation);
+  aResult.Location (*aShapeLocation, Standard_False);
   return aResult;
 }
 
index 19f4a7b..5df9100 100644 (file)
@@ -526,7 +526,7 @@ void BinTools_ShapeSet::ReadSubs(TopoDS_Shape& S, Standard_IStream& IS,
 
     Standard_Integer l;
     BinTools::GetInteger(IS, l);
-    S.Location(myLocations.Location(l));
+    S.Location(myLocations.Location(l), Standard_False);
   }
 }
 
index a67ad2b..81802e8 100644 (file)
@@ -102,7 +102,7 @@ namespace
     {
       TopoDS_Shape aShape;
       if (!XCAFDoc_ShapeTool::GetShape (theLabel, aShape)) return;
-      aShape.Move (theLocation);
+      aShape.Move (theLocation, Standard_False);
       theMapOfShapeNames.Bind (aShape, thePrevName->Get());
     }
   }
index f04f750..70a41e7 100644 (file)
@@ -514,7 +514,7 @@ TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry
          T.SetScaleFactor(sc);
        }
       TopLoc_Location L(T);
-      res.Move(L);
+      res.Move(L, Standard_False);
     }
     else {
       Message_Msg msg1035("IGES_1035");
index 41db4bd..de7552e 100644 (file)
@@ -325,7 +325,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferTopoBasicSurface
     if (IGESData_ToolLocation::ConvertLocation
        (GetEpsilon(),st->CompoundLocation(),trsf,GetUnitFactor())) { 
       TopLoc_Location locFace(trsf);
-      res.Move(locFace);
+      res.Move(locFace, Standard_False);
     }
     else {
       Message_Msg msg1035("IGES_1035");
@@ -651,7 +651,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferRuledSurface
     if (IGESData_ToolLocation::ConvertLocation
        (GetEpsilon(),st->CompoundLocation(), trsf,GetUnitFactor())) { 
       TopLoc_Location shapeLoc(trsf);
-      res.Move(shapeLoc);
+      res.Move(shapeLoc, Standard_False);
     }
     else {
       Message_Msg msg1035("IGES_1035");
@@ -819,7 +819,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferSurfaceOfRevolution
     if (IGESData_ToolLocation::ConvertLocation
        (GetEpsilon(), st->CompoundLocation(), trsf, GetUnitFactor())) { 
       TopLoc_Location shapeLoc(trsf);
-      res.Move(shapeLoc);
+      res.Move(shapeLoc, Standard_False);
     }
     else {
       Message_Msg msg1035("IGES_1035");
@@ -959,7 +959,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferTabulatedCylinder
     if (IGESData_ToolLocation::ConvertLocation
        (GetEpsilon(),st->CompoundLocation(), trsf, GetUnitFactor())) { 
       TopLoc_Location shapeLoc(trsf);
-      res.Move(shapeLoc);
+      res.Move(shapeLoc, Standard_False);
     }
     else {
       Message_Msg msg1035("IGES_1035");
@@ -1115,7 +1115,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferOffsetSurface
     if (IGESData_ToolLocation::ConvertLocation
        (GetEpsilon(),st->CompoundLocation(),trsf, GetUnitFactor())) { 
       TopLoc_Location loc2(trsf);
-      res.Move(loc2);
+      res.Move(loc2, Standard_False);
     }
     else {
       Message_Msg msg1035("IGES_1035");
@@ -1256,7 +1256,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferTrimmedSurface
           aMat.Value(2, 1), aMat.Value(2, 2), aMat.Value(2, 3), aTrans.Y(),
           aMat.Value(3, 1), aMat.Value(3, 2), aMat.Value(3, 3), aTrans.Z());
         TopLoc_Location aLoc(aT);
-        face.Move(aLoc);
+        face.Move(aLoc, Standard_False);
       }
     }
   }
@@ -1399,7 +1399,7 @@ TopoDS_Shape IGESToBRep_TopoSurface::TransferPlane
 //   il reste a la mettre en position
   if (trsf.Form() != gp_Identity) {
     TopLoc_Location loc(trsf);
-    res.Location(loc);
+    res.Location(loc, Standard_False);
   }
   return res;
 }
@@ -1476,14 +1476,14 @@ TopoDS_Shape  IGESToBRep_TopoSurface::TransferPerforate
 //    Ne pas oublier de composer la transformation locale a ce Wire
     if (trsi.Form() != gp_Identity) {
       TopLoc_Location locw(trsi);
-      wire.Location(locw);
+      wire.Location(locw, Standard_False);
     }
     B.Add (res,wire);
   }
 //    Enfin, appliquer la trsf globale
   if (trsf.Form() != gp_Identity) {
     TopLoc_Location loc(trsf);
-    res.Location(loc);
+    res.Location(loc, Standard_False);
   }
   return res;
 }
index c082c5c..c1bb491 100644 (file)
@@ -1865,11 +1865,11 @@ void RWGltf_GltfJsonParser::bindNamedShape (TopoDS_Shape& theShape,
   {
     if (!theShape.Location().IsIdentity())
     {
-      theShape.Location (theLoc * theShape.Location());
+      theShape.Location (theLoc * theShape.Location(), Standard_False);
     }
     else
     {
-      theShape.Location (theLoc);
+      theShape.Location (theLoc, Standard_False);
     }
   }
 
index a5df98a..eb10ed2 100644 (file)
@@ -305,7 +305,7 @@ Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (CafDocumentTools& theTools,
       TopoDS_Compound aCompound;
       BRep_Builder aBuilder;
       aBuilder.MakeCompound (aCompound);
-      aCompound.Location (theShape.Location());
+      aCompound.Location (theShape.Location(), Standard_False);
       aShapeToAdd = aCompound;
     }
   }
index 83188af..7577849 100644 (file)
@@ -76,7 +76,7 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
         context.Bind ( shape, res );
         locModified = Standard_True;
       }
-      res.Location ( L );
+      res.Location ( L, Standard_False );
       B.Add ( C, res );
     }
 
index 60da7f0..55df4bb 100644 (file)
@@ -120,14 +120,14 @@ Standard_Boolean ShapeFix_Shape::Perform(const Message_ProgressRange& theProgres
   TopoDS_Shape aShapeNullLoc = myShape;
   aShapeNullLoc.Location(nullLoc);
   if(myMapFixingShape.Contains(aShapeNullLoc)) {
-    myShape.Location(L);
+    myShape.Location(L, Standard_False);
     myResult = Context()->Apply(myShape);
     status = Standard_True;
     return status;
   }
   else myMapFixingShape.Add(aShapeNullLoc);
   //---------------------------------------
-  myShape.Location(L);
+  myShape.Location(L, Standard_False);
   TopoDS_Shape S = Context()->Apply(myShape);
   if ( NeedFix (  myFixVertexPositionMode ) )
     ShapeFix::FixVertexPosition(S,Precision(),Context());
index e6c9564..ede8305 100644 (file)
@@ -86,7 +86,7 @@ TopoDS_Shape ShapeProcess_OperLibrary::ApplyModifier (const TopoDS_Shape &S,
        map.Bind ( shape, res );
       }
       if ( ! res.IsSame ( shape ) ) locModified = Standard_True;
-      res.Location ( L );
+      res.Location ( L, Standard_False );
       B.Add ( C, res );
     }
     if ( ! locModified ) return S;
index 53381db..135f14b 100644 (file)
@@ -190,8 +190,8 @@ static void RecModif (const TopoDS_Shape &S,
   if ( ! r.IsNull() ) {
     TopoDS_Shape res = r;
     
-    if ( repl.IsBound ( r.Located(aShLoc) ) ) {
-      res = repl.Find (  r.Located(aShLoc) );
+    if ( repl.IsBound ( r.Located(aShLoc, Standard_False) ) ) {
+      res = repl.Find (  r.Located(aShLoc, Standard_False) );
       // it is supposed that map is created for r having FORWARD orientation
       // hence, if it is reversed, result should be reversed too
       // INTERNAL or EXTERNAL orientations are not allowed
@@ -330,7 +330,7 @@ void ShapeProcess_ShapeContext::RecordModification (const Handle(ShapeBuild_ReSh
   if ( myMap.IsBound(myShape) ) 
   {
     myResult = myMap.Find ( myShape );
-    myResult.Location(myShape.Location());
+    myResult.Location(myShape.Location(), Standard_False);
   }
 #ifdef OCCT_DEBUG
 //  std::cout << "ReShape: " << std::endl; DumpMap (myMap);
index ec9e51b..9c4a0f7 100644 (file)
@@ -1231,11 +1231,16 @@ Handle(Geom_Direction) StepToGeom::MakeDirection (const Handle(StepGeom_Directio
     const Standard_Real X = SD->DirectionRatiosValue(1);
     const Standard_Real Y = SD->DirectionRatiosValue(2);
     const Standard_Real Z = SD->DirectionRatiosValue(3);
+    //5.08.2021. Unstable test bugs xde bug24759: Y is very large value - FPE in SquareModulus
+    if (Precision::IsInfinite(X) || Precision::IsInfinite(Y) || Precision::IsInfinite(Z))
+    {
+      return 0;
+    }
     // sln 22.10.2001. CTS23496: Direction is not created if it has null magnitude
     if (gp_XYZ(X, Y, Z).SquareModulus() > gp::Resolution()*gp::Resolution())
     {
       return new Geom_Direction(X, Y, Z);
-    }
+    }  
   }
   return 0;
 }
index 58dc97c..c5f2eb4 100644 (file)
@@ -52,10 +52,11 @@ void TopExp::MapShapes(const TopoDS_Shape& S,
 //=======================================================================
 
 void TopExp::MapShapes(const TopoDS_Shape& S,
-                      TopTools_IndexedMapOfShape& M)
+                      TopTools_IndexedMapOfShape& M,
+  const Standard_Boolean cumOri, const Standard_Boolean cumLoc)
 {
   M.Add(S);
-  TopoDS_Iterator It(S);
+  TopoDS_Iterator It(S, cumOri, cumLoc);
   while (It.More()) {
     MapShapes(It.Value(),M);
     It.Next();
@@ -67,11 +68,13 @@ void TopExp::MapShapes(const TopoDS_Shape& S,
 //purpose  : 
 //=======================================================================
 void TopExp::MapShapes(const TopoDS_Shape& S,
-                       TopTools_MapOfShape& M)
+                       TopTools_MapOfShape& M, 
+  const Standard_Boolean cumOri, const Standard_Boolean cumLoc)
 {
   M.Add(S);
-  for (TopoDS_Iterator it(S); it.More(); it.Next())
-    MapShapes(it.Value(), M);
+  TopoDS_Iterator It(S, cumOri, cumLoc);
+  for (; It.More(); It.Next())
+    MapShapes(It.Value(), M);
 }
 
 //=======================================================================
index e6e515e..c2961ed 100644 (file)
@@ -58,10 +58,22 @@ public:
   Standard_EXPORT static void MapShapes (const TopoDS_Shape& S, const TopAbs_ShapeEnum T, TopTools_IndexedMapOfShape& M);
   
   //! Stores in the map <M> all  the sub-shapes of <S>.
-  Standard_EXPORT static void MapShapes (const TopoDS_Shape& S, TopTools_IndexedMapOfShape& M);
+  //! - If cumOri is true, the function composes all
+  //! sub-shapes with the orientation of S.
+  //! - If cumLoc is true, the function multiplies all
+  //! sub-shapes by the location of S, i.e. it applies to
+  //! each sub-shape the transformation that is associated with S.
+  Standard_EXPORT static void MapShapes (const TopoDS_Shape& S, TopTools_IndexedMapOfShape& M,
+    const Standard_Boolean cumOri = Standard_True, const Standard_Boolean cumLoc = Standard_True);
 
   //! Stores in the map <M> all  the sub-shapes of <S>.
-  Standard_EXPORT static void MapShapes (const TopoDS_Shape& S, TopTools_MapOfShape& M);
+  //! - If cumOri is true, the function composes all
+  //! sub-shapes with the orientation of S.
+  //! - If cumLoc is true, the function multiplies all
+  //! sub-shapes by the location of S, i.e. it applies to
+  //! each sub-shape the transformation that is associated with S.
+  Standard_EXPORT static void MapShapes (const TopoDS_Shape& S, TopTools_MapOfShape& M,
+    const Standard_Boolean cumOri = Standard_True, const Standard_Boolean cumLoc = Standard_True);
 
   //! Stores in the map <M> all the subshape of <S> of
   //! type <TS>  for each one append  to  the list all
index 002a034..cc953d7 100644 (file)
@@ -31,7 +31,6 @@ class Standard_ConstructionError;
 class gp_Trsf;
 class TopLoc_Datum3D;
 
-
 //! A Location is a composite transition. It comprises a
 //! series of elementary reference coordinates, i.e.
 //! objects of type TopLoc_Datum3D, and the powers to
@@ -156,7 +155,10 @@ Standard_Boolean operator != (const TopLoc_Location& Other) const
   }
 
 
-
+  static Standard_Real ScalePrec()
+  {
+    return  1.e-14;
+  }
 
 protected:
 
index be91dcf..62d6553 100644 (file)
@@ -814,7 +814,7 @@ void  TopTools_ShapeSet::Read(TopoDS_Shape& S,
 
     Standard_Integer l;
     IS >> l;
-    S.Location(myLocations.Location(l));
+    S.Location(myLocations.Location(l), Standard_False);
   }
 }
 
index b27b941..a0c946a 100644 (file)
@@ -105,7 +105,7 @@ void TopoDS_Builder::Add (TopoDS_Shape& aShape,
       // and the Relative Location
       const TopLoc_Location& aLoc=aShape.Location();
       if (!aLoc.IsIdentity())
-        S.Move(aLoc.Inverted());
+        S.Move(aLoc.Inverted(), Standard_False);
       //
       // Set the TShape as modified.
       aShape.TShape()->Modified(Standard_True);
@@ -135,7 +135,7 @@ void TopoDS_Builder::Remove (TopoDS_Shape& aShape,
   TopoDS_Shape S = aComponent;
   if (aShape.Orientation() == TopAbs_REVERSED)
     S.Reverse();
-  S.Location(S.Location().Predivided(aShape.Location()));
+  S.Location(S.Location().Predivided(aShape.Location()), Standard_False);
 
   TopoDS_ListOfShape& L = aShape.TShape()->myShapes;
   TopoDS_ListIteratorOfListOfShape It(L);
index ca51b61..141711a 100644 (file)
@@ -47,7 +47,7 @@ void TopoDS_Iterator::Initialize(const TopoDS_Shape& S,
     myShape = myShapes.Value();
     myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
     if (!myLocation.IsIdentity())
-      myShape.Move(myLocation);
+      myShape.Move(myLocation, Standard_False);
   }
 }
 
@@ -63,6 +63,6 @@ void TopoDS_Iterator::Next()
     myShape = myShapes.Value();
     myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
     if (!myLocation.IsIdentity())
-      myShape.Move(myLocation);
+      myShape.Move(myLocation, Standard_False);
   }
 }
index d44175f..be92f62 100644 (file)
@@ -91,14 +91,26 @@ public:
   const TopLoc_Location& Location() const { return myLocation; }
 
   //! Sets the shape local coordinate system.
-  void Location (const TopLoc_Location& theLoc) { myLocation = theLoc; }
+  void Location (const TopLoc_Location& theLoc, const Standard_Boolean theRaiseExc = Standard_True)
+  {
+    const gp_Trsf& aTrsf = theLoc.Transformation();
+    if ((Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec() || aTrsf.IsNegative()) && theRaiseExc)
+    {
+      //Exception
+      throw Standard_DomainError("Location with scaling transformation is forbidden");
+    }
+    else
+    {
+      myLocation = theLoc;
+    }
+  }
 
   //! Returns a  shape  similar to <me> with   the local
   //! coordinate system set to <Loc>.
-  TopoDS_Shape Located (const TopLoc_Location& theLoc) const
+  TopoDS_Shape Located (const TopLoc_Location& theLoc, const Standard_Boolean theRaiseExc = Standard_True) const
   {
     TopoDS_Shape aShape (*this);
-    aShape.Location (theLoc);
+    aShape.Location (theLoc, theRaiseExc);
     return aShape;
   }
 
@@ -176,13 +188,25 @@ public:
   void Convex (Standard_Boolean theIsConvex) { myTShape->Convex (theIsConvex); }
 
   //! Multiplies the Shape location by thePosition.
-  void Move (const TopLoc_Location& thePosition) { myLocation = thePosition * myLocation; }
+  void Move(const TopLoc_Location& thePosition, const Standard_Boolean theRaiseExc = Standard_True)
+  {
+    const gp_Trsf& aTrsf = thePosition.Transformation();
+    if ((Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec() || aTrsf.IsNegative()) && theRaiseExc)
+    {
+      //Exception
+      throw Standard_DomainError("Moving with scaling transformation is forbidden");
+    }
+    else
+    {
+      myLocation = thePosition * myLocation;
+    }
+   }
 
   //! Returns a shape similar to <me> with a location multiplied by thePosition.
-  TopoDS_Shape Moved (const TopLoc_Location& thePosition) const
+  TopoDS_Shape Moved (const TopLoc_Location& thePosition, const Standard_Boolean theRaiseExc = Standard_True) const
   {
     TopoDS_Shape aShape (*this);
-    aShape.Move (thePosition);
+    aShape.Move (thePosition, theRaiseExc);
     return aShape;
   }
 
index af43b05..7229dfd 100644 (file)
@@ -411,7 +411,7 @@ void VrmlData_Group::Shape (TopoDS_Shape&                       theShape,
                             VrmlData_DataMapOfShapeAppearance * pMapApp)
 {
   VrmlData_Scene::createShape (theShape, myNodes, pMapApp);
-  theShape.Location(myTrsf);
+  theShape.Location(myTrsf, Standard_False);
 }
 
 //=======================================================================
index 0598161..294c974 100644 (file)
@@ -333,7 +333,7 @@ Standard_Boolean XCAFDoc_ShapeTool::GetShape (const TDF_Label& L, TopoDS_Shape&
   if ( L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node) && Node->HasFather() && 
        L.FindAttribute(XCAFDoc_Location::GetID(), LocationAttribute)) {
     if ( ! GetShape(Node->Father()->Label(), S) ) return Standard_False;
-    S.Move ( LocationAttribute->Get() );
+    S.Move ( LocationAttribute->Get(), Standard_False );
     return Standard_True;
   }
 
@@ -537,7 +537,7 @@ static Standard_Boolean prepareAssembly (const TopoDS_Shape& theShape,
         gp_Trsf aTrsf;
         aTrsf.SetScale(gp_Pnt(0,0,0), 1);
         aLoc = TopLoc_Location( aTrsf );
-        aNewScomp.Location( aLoc );
+        aNewScomp.Location( aLoc, Standard_False );
       }
       B.Add(theOUTShape, aNewScomp);
     }
@@ -1585,7 +1585,7 @@ static Standard_Boolean checkForShape (const TopoDS_Shape& theShape,
   TopoDS_Shape aCopySh = theCurSh;
   aCompLoc = aCompLoc.Multiplied( theCurSh.Location() );
   aSupLoc = aSupLoc.Multiplied( aCompLoc );
-  aCopySh.Location( aSupLoc );
+  aCopySh.Location( aSupLoc, Standard_False );
   if ( aCopySh.IsSame( theShape ) ) {
     theLabels.Prepend( theUserL );
     return Standard_True;
@@ -1676,7 +1676,7 @@ static Standard_Boolean getShapesOfSHUO (TopLoc_IndexedMapOfLocation& theaPrevLo
         l--;
       }
     }
-    aSHUO_NUSh.Location( SupcompLoc );
+    aSHUO_NUSh.Location( SupcompLoc, Standard_False );
     theShape = aSHUO_NUSh;
   }
   return (!theShape.IsNull());
@@ -1958,7 +1958,7 @@ void XCAFDoc_ShapeTool::makeSubShape (const TDF_Label& theMainShapeL,
       // Identical location and empty location are not the same for ShapeTool, so try to process both
       // in case of aSubLoc is not identical, the second Add try will not affect algorithm.
       Standard_Boolean isNewSubL;
-      isNewSubL = AddSubShape(thePart, aChildShape.Located(aSubLoc), aSubLabel);
+      isNewSubL = AddSubShape(thePart, aChildShape.Located(aSubLoc, Standard_False), aSubLabel);
       if (aSubLabel.IsNull())
       {
         isNewSubL = AddSubShape(thePart, aChildShape.Located(TopLoc_Location()), aSubLabel);
@@ -2051,7 +2051,7 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
       if ( updateComponent(aComponentRefLab, aComponentShape, theUpdated) )
       {
         isModified = Standard_True;
-        aComponentShape.Location(aComponentLoc); // Apply placement
+        aComponentShape.Location(aComponentLoc, Standard_False); // Apply placement
       }
     }
     else
index 54d449c..e7ff3a3 100644 (file)
@@ -95,7 +95,7 @@ static Standard_Boolean getShapesOfSHUO (TopLoc_IndexedMapOfLocation& theaPrevLo
         l--;
       }
     }
-    aSHUO_NUSh.Location( SupcompLoc );
+    aSHUO_NUSh.Location( SupcompLoc, Standard_False );
     theSHUOShapeSeq.Append( aSHUO_NUSh );
   }
   return (theSHUOShapeSeq.Length() > 0);
@@ -295,7 +295,7 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
         continue;
       }
     }
-    aSubshape.Move (theLoc);
+    aSubshape.Move (theLoc, Standard_False);
     XCAFPrs_Style* aMapStyle = theSettings.ChangeSeek (aSubshape);
     if (aMapStyle == NULL)
       theSettings.Add (aSubshape, aStyle);
index 14fd44d..9e806fd 100644 (file)
@@ -10,7 +10,7 @@ set GoodNbExtremas 4
 
 circle c1 5 5 10 0 1 1 20
 mkedge e1 c1
-bmirror e1 e1 5 5 10 1 0 0
+tmirror e1 e1 5 5 10 1 0 0
 mkcurve c1 e1
 
 cvalue c1 0.63 x1 y1 z1
diff --git a/tests/bugs/moddata_3/bug27457 b/tests/bugs/moddata_3/bug27457
new file mode 100644 (file)
index 0000000..e2c750d
--- /dev/null
@@ -0,0 +1,33 @@
+puts "========="
+puts "0027457: Modeling Data - Raise if scaled transformation is used for shape location"
+puts "========="
+puts ""
+
+box b 1 1 1
+fscale b 0 0 0 2
+set chsh [checkshape b f]
+regexp {Shapes with problems : ([0-9]+)} $chsh full NbSh
+if { $NbSh > 1 } {
+  puts "Number of faulty shapes : $NbSh"
+} else {
+  puts "Error: fscale does not produce wrong shape"
+}
+
+set Nbloc 0
+set chloc [checkloc b]
+set Nbloc [llength $chloc]
+if { $Nbloc > 0 } {
+  puts "Number of problematic locations : $Nbloc"
+} else {
+  puts "Error: fscale does not produce wrong location"
+}
+checkprops b -v 8.
+
+box b1 1 1 1
+bscale b1 0 0 0 2
+checkprops b1 -v 1.
+
+smallview
+donly b b1
+fit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/moddata_3/bug27457_1 b/tests/bugs/moddata_3/bug27457_1
new file mode 100644 (file)
index 0000000..91bcd04
--- /dev/null
@@ -0,0 +1,32 @@
+puts "========="
+puts "0027457: Modeling Data - Raise if scaled transformation is used for shape location"
+puts "         Testing tool for purging locations"
+puts "========="
+puts ""
+
+restore [locate_data_file bug27457_1.brep] s
+set chsh [checkshape s b]
+regexp {Shapes with problems : ([0-9]+)} $chsh full NbSh
+puts "Number of faulty shapes : $NbSh"
+
+set Nbloc 0
+set chloc [checkloc s]
+set Nbloc [llength $chloc]
+puts "Number of problematic locations : $Nbloc"
+
+set Purge_status [purgeloc s1 s]
+checkshape s1 
+
+set Nbloc1 0
+
+set chloc1 [checkloc s1]
+if { ! [regexp {There are no problematic shapes} $chloc1 full str]} {
+  puts "Error - not all problematic locations are purged"
+  set Nbloc1 [llength $chloc1]
+  puts "Number of problematic locations : $Nbloc1"
+} 
+
+smallview
+donly s1
+fit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/moddata_3/bug27457_2 b/tests/bugs/moddata_3/bug27457_2
new file mode 100644 (file)
index 0000000..672d05d
--- /dev/null
@@ -0,0 +1,32 @@
+puts "========="
+puts "0027457: Modeling Data - Raise if scaled transformation is used for shape location"
+puts "         Testing tool for purging locations"
+puts "========="
+puts ""
+
+restore [locate_data_file bug27457_2.brep] s
+set chsh [checkshape s b]
+regexp {Shapes with problems : ([0-9]+)} $chsh full NbSh
+puts "Number of faulty shapes : $NbSh"
+
+set Nbloc 0
+set chloc [checkloc s]
+set Nbloc [llength $chloc]
+puts "Number of problematic locations : $Nbloc"
+
+set Purge_status [purgeloc s1 s]
+checkshape s1 
+
+set Nbloc1 0
+
+set chloc1 [checkloc s1]
+if { ! [regexp {There are no problematic shapes} $chloc1 full str]} {
+  puts "Error - not all problematic locations are purged"
+  set Nbloc1 [llength $chloc1]
+  puts "Number of problematic locations : $Nbloc1"
+} 
+
+smallview
+donly s1
+fit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
index 8476555..a831cbd 100644 (file)
@@ -6,7 +6,7 @@ puts ""
 pload MODELING VISUALIZATION
 restore [locate_data_file bug22240_Pump_Nut.brep] a
 restore [locate_data_file bug22240_Pump_Nut.brep] b
-bscale b 0 0 0 2.
+tscale b 0 0 0 2.
 vinit View1
 vdisplay a b
 vsetdispmode a 1
index 9fa8bfb..9b67535 100644 (file)
@@ -22,7 +22,7 @@ verase b
 
 # Box with mirror transformation
 box a 1 1 1
-bmirror a 0 0 0 1 0 0
+fmirror a 0 0 0 1 0 0
 explode a sh
 renamevar a_1 a
 vdisplay -dispMode 1 a
@@ -37,7 +37,7 @@ verase a
 
 # Box with mirror transformation and reversed face
 box c 1 1 1
-bmirror c 0 0 0 1 0 0
+fmirror c 0 0 0 1 0 0
 orientation c R
 explode c sh
 renamevar c_1 c
index 6018a32..634223f 100644 (file)
@@ -13,7 +13,7 @@ vcamera -persp
 
 # Simple box
 box b 1 1 1
-bmirror b 0 0 0 0 0 1
+fmirror b 0 0 0 0 0 1
 vdisplay -dispMode 1 b
 vaspects b -setBackFaceColor RED
 box bb 0.5 0.5 -0.5 0.1 0.1 0.1
index 6bf0e08..596698e 100644 (file)
@@ -20,7 +20,7 @@ verase b
 
 # Box with mirror transformation
 box a 1 1 1
-bmirror a 0 0 0 1 0 0
+fmirror a 0 0 0 1 0 0
 vdisplay -dispMode 1 a
 vaspects a -setBackFaceColor RED
 vfit
@@ -33,7 +33,7 @@ verase a
 
 # Box with mirror transformation and reversed face
 box c 1 1 1
-bmirror c 0 0 0 1 0 0
+fmirror c 0 0 0 1 0 0
 orientation c R
 vdisplay -dispMode 1 c
 vaspects c -setBackFaceColor RED