X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_RotateDriver.cxx;h=f2c57ac76621a8e2ff2c91650e7fd0ef83c1b96e;hb=de2617e3f55fc12bac2da61fcbaf2d96f1e38926;hp=c610d78a30540a69d02f7050cabfd560844bee7d;hpb=0b6826bc5f36b5420f41af1475e1a79371a25323;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx index c610d78a3..f2c57ac76 100644 --- a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #include #include @@ -204,35 +205,45 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const gp_Ax1 AX1(aP1, D); - gp_Trsf aTrsf1; gp_Trsf aTrsf2; - gp_Pnt P1; - GProp_GProps System; - if (anOriginal.ShapeType() == TopAbs_VERTEX) { - P1 = BRep_Tool::Pnt(TopoDS::Vertex( anOriginal )); - } - else if ( anOriginal.ShapeType() == TopAbs_EDGE || anOriginal.ShapeType() == TopAbs_WIRE ) { - BRepGProp::LinearProperties(anOriginal, System); - P1 = System.CentreOfMass(); - } - else if ( anOriginal.ShapeType() == TopAbs_FACE || anOriginal.ShapeType() == TopAbs_SHELL ) { - BRepGProp::SurfaceProperties(anOriginal, System); - P1 = System.CentreOfMass(); - } - else { - BRepGProp::VolumeProperties(anOriginal, System); - P1 = System.CentreOfMass(); - } + gp_XYZ aDir2 = RI.GetDir2(); // can be set by previous execution + if (aDir2.Modulus() < gp::Resolution()) { + // Calculate direction as vector from the axis to the shape's center + gp_Pnt P1; + GProp_GProps System; - Handle(Geom_Line) Line = new Geom_Line(AX1); - GeomAPI_ProjectPointOnCurve aPrjTool( P1, Line ); - gp_Pnt P2 = aPrjTool.NearestPoint(); + if (anOriginal.ShapeType() == TopAbs_VERTEX) { + P1 = BRep_Tool::Pnt(TopoDS::Vertex( anOriginal )); + } + else if ( anOriginal.ShapeType() == TopAbs_EDGE || anOriginal.ShapeType() == TopAbs_WIRE ) { + BRepGProp::LinearProperties(anOriginal, System); + P1 = System.CentreOfMass(); + } + else if ( anOriginal.ShapeType() == TopAbs_FACE || anOriginal.ShapeType() == TopAbs_SHELL ) { + BRepGProp::SurfaceProperties(anOriginal, System); + P1 = System.CentreOfMass(); + } + else { + BRepGProp::VolumeProperties(anOriginal, System); + P1 = System.CentreOfMass(); + } + + Handle(Geom_Line) Line = new Geom_Line(AX1); + GeomAPI_ProjectPointOnCurve aPrjTool( P1, Line ); + gp_Pnt P2 = aPrjTool.NearestPoint(); - if ( P1.IsEqual(P2, Precision::Confusion() ) ) return 0; + if ( P1.IsEqual(P2, Precision::Confusion() ) ) return 0; + + aDir2 = gp_XYZ(P1.X()-P2.X(), P1.Y()-P2.Y(), P1.Z()-P2.Z()); + + // Attention: this abnormal action is done for good working of + // TransformLikeOther(), used by RestoreSubShapes functionality + RI.SetDir2(aDir2); + } - gp_Vec Vec (P1.X()-P2.X(), P1.Y()-P2.Y(), P1.Z()-P2.Z()); + gp_Vec Vec (aDir2); Vec.Normalize(); Standard_Integer nbtimes2 = RI.GetNbIter2();