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.
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();
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);
theCurvature1 = -theCurvature1;
theCurvature2 = -theCurvature2;
}
+ if (mySurfaceTrsf.IsNegative())
+ {
+ theCurvature1 = -theCurvature1;
+ theCurvature2 = -theCurvature2;
+ }
+
thePrincipalDir1.Transform(mySurfaceTrsf);
thePrincipalDir2.Transform(mySurfaceTrsf);
}
#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>
// 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;
const char* aName = a[0];
Standard_Boolean isBasic = Standard_False;
+ Standard_Boolean isForced = Standard_False;
Standard_Boolean isCopy = Standard_False;
// Check "copy" flag.
}
else {
isBasic = (aName[0] == 'b');
+ isForced = (aName[0] == 'f');
+
aName++;
if (!strcmp(aName,"move")) {
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;
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")) {
}
}
- 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]);
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 {
//
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)
{
__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__,
__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__,
"\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);
}
#include <TopTools_SequenceOfShape.hxx>
#include <GeomLib_CheckCurveOnSurface.hxx>
#include <errno.h>
+#include <BRepTools_TrsfModification.hxx>
+#include <BRepTools_Modifier.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
//=======================================================================
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
#include <Standard_IStream.hxx>
#include <Standard_CString.hxx>
#include <Message_ProgressRange.hxx>
+#include <TopTools_ListOfShape.hxx>
class TopoDS_Face;
class TopoDS_Wire;
//! 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:
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
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;
}
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
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;
}
--- /dev/null
+// 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;
+}
+
--- /dev/null
+// 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
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 );
}
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;
{
TopLoc_Location aResLoc = (res >0 && !newsh.Location().IsIdentity() ?
aLocSh * newsh.Location() : aLocSh);
- newsh.Location(aResLoc);
+ newsh.Location(aResLoc, Standard_False);
}
return res;
}
BRepTools_TrsfModification.hxx
BRepTools_WireExplorer.cxx
BRepTools_WireExplorer.hxx
+BRepTools_PurgeLocations.cxx
+BRepTools_PurgeLocations.hxx
\ No newline at end of file
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;
}
aResult.Convex (aConv);
myShapePos.Bind (aPosition, aResult);
aResult.Orientation (aShapeOrientation);
- aResult.Location (*aShapeLocation);
+ aResult.Location (*aShapeLocation, Standard_False);
return aResult;
}
Standard_Integer l;
BinTools::GetInteger(IS, l);
- S.Location(myLocations.Location(l));
+ S.Location(myLocations.Location(l), Standard_False);
}
}
{
TopoDS_Shape aShape;
if (!XCAFDoc_ShapeTool::GetShape (theLabel, aShape)) return;
- aShape.Move (theLocation);
+ aShape.Move (theLocation, Standard_False);
theMapOfShapeNames.Bind (aShape, thePrevName->Get());
}
}
T.SetScaleFactor(sc);
}
TopLoc_Location L(T);
- res.Move(L);
+ res.Move(L, Standard_False);
}
else {
Message_Msg msg1035("IGES_1035");
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");
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");
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");
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");
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");
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);
}
}
}
// 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;
}
// 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;
}
{
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);
}
}
TopoDS_Compound aCompound;
BRep_Builder aBuilder;
aBuilder.MakeCompound (aCompound);
- aCompound.Location (theShape.Location());
+ aCompound.Location (theShape.Location(), Standard_False);
aShapeToAdd = aCompound;
}
}
context.Bind ( shape, res );
locModified = Standard_True;
}
- res.Location ( L );
+ res.Location ( L, Standard_False );
B.Add ( C, res );
}
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());
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;
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
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);
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;
}
//=======================================================================
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();
//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);
}
//=======================================================================
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
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
}
-
+ static Standard_Real ScalePrec()
+ {
+ return 1.e-14;
+ }
protected:
Standard_Integer l;
IS >> l;
- S.Location(myLocations.Location(l));
+ S.Location(myLocations.Location(l), Standard_False);
}
}
// 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);
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);
myShape = myShapes.Value();
myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
if (!myLocation.IsIdentity())
- myShape.Move(myLocation);
+ myShape.Move(myLocation, Standard_False);
}
}
myShape = myShapes.Value();
myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
if (!myLocation.IsIdentity())
- myShape.Move(myLocation);
+ myShape.Move(myLocation, Standard_False);
}
}
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;
}
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;
}
VrmlData_DataMapOfShapeAppearance * pMapApp)
{
VrmlData_Scene::createShape (theShape, myNodes, pMapApp);
- theShape.Location(myTrsf);
+ theShape.Location(myTrsf, Standard_False);
}
//=======================================================================
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;
}
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);
}
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;
l--;
}
}
- aSHUO_NUSh.Location( SupcompLoc );
+ aSHUO_NUSh.Location( SupcompLoc, Standard_False );
theShape = aSHUO_NUSh;
}
return (!theShape.IsNull());
// 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);
if ( updateComponent(aComponentRefLab, aComponentShape, theUpdated) )
{
isModified = Standard_True;
- aComponentShape.Location(aComponentLoc); // Apply placement
+ aComponentShape.Location(aComponentLoc, Standard_False); // Apply placement
}
}
else
l--;
}
}
- aSHUO_NUSh.Location( SupcompLoc );
+ aSHUO_NUSh.Location( SupcompLoc, Standard_False );
theSHUOShapeSeq.Append( aSHUO_NUSh );
}
return (theSHUOShapeSeq.Length() > 0);
continue;
}
}
- aSubshape.Move (theLoc);
+ aSubshape.Move (theLoc, Standard_False);
XCAFPrs_Style* aMapStyle = theSettings.ChangeSeek (aSubshape);
if (aMapStyle == NULL)
theSettings.Add (aSubshape, aStyle);
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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
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
# 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
# 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
# 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
# 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
# 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