From: jfa Date: Mon, 28 Jan 2008 11:56:59 +0000 (+0000) Subject: NPAL18620: Pb. of performance with MakeTranslation. Improve transformations to avoid... X-Git-Tag: for_M2008_07022008~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1124a136010334950b26f6a3461a2200d5f72bc8;p=modules%2Fgeom.git NPAL18620: Pb. of performance with MakeTranslation. Improve transformations to avoid accumulation of locations in a shape. --- diff --git a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx index 94f949129..c6655fa58 100644 --- a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 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 +// 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 +// +// 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 +// 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 @@ -49,48 +49,48 @@ //======================================================================= //function : GetID //purpose : -//======================================================================= +//======================================================================= const Standard_GUID& GEOMImpl_RotateDriver::GetID() { static Standard_GUID aRotateDriver("FF1BBB56-5D14-4df2-980B-3A668264EA16"); - return aRotateDriver; + return aRotateDriver; } //======================================================================= //function : GEOMImpl_RotateDriver -//purpose : +//purpose : //======================================================================= -GEOMImpl_RotateDriver::GEOMImpl_RotateDriver() +GEOMImpl_RotateDriver::GEOMImpl_RotateDriver() { } //======================================================================= //function : Execute //purpose : -//======================================================================= +//======================================================================= Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const { - if(Label().IsNull()) return 0; + if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - if(aFunction.IsNull()) return 0; + if (aFunction.IsNull()) return 0; GEOMImpl_IRotate RI(aFunction); gp_Trsf aTrsf; gp_Pnt aCP, aP1, aP2; Standard_Integer aType = aFunction->GetType(); Handle(GEOM_Function) anOriginalFunction = RI.GetOriginal(); - if(anOriginalFunction.IsNull()) return 0; + if (anOriginalFunction.IsNull()) return 0; TopoDS_Shape aShape, anOriginal = anOriginalFunction->GetValue(); - if(anOriginal.IsNull()) return 0; + if (anOriginal.IsNull()) return 0; - if(aType == ROTATE || aType == ROTATE_COPY) { + if (aType == ROTATE || aType == ROTATE_COPY) { Handle(GEOM_Function) anAxis = RI.GetAxis(); - if(anAxis.IsNull()) return 0; + if (anAxis.IsNull()) return 0; TopoDS_Shape A = anAxis->GetValue(); - if(A.IsNull() || A.ShapeType() != TopAbs_EDGE) return 0; + if (A.IsNull() || A.ShapeType() != TopAbs_EDGE) return 0; TopoDS_Edge anEdge = TopoDS::Edge(A); gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); @@ -99,11 +99,17 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const gp_Ax1 anAx1(aP1, aDir); Standard_Real anAngle = RI.GetAngle(); aTrsf.SetRotation(anAx1, anAngle); - - BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); - aShape = aTransformation.Shape(); + + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + //aShape = aTransformation.Shape(); + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + TopLoc_Location aLocRes (aTrsf * aTrsfOrig); + aShape = anOriginal.Located(aLocRes); } - else if(aType == ROTATE_THREE_POINTS || aType == ROTATE_THREE_POINTS_COPY) { + else if (aType == ROTATE_THREE_POINTS || aType == ROTATE_THREE_POINTS_COPY) { Handle(GEOM_Function) aCentPoint = RI.GetCentPoint(); Handle(GEOM_Function) aPoint1 = RI.GetPoint1(); Handle(GEOM_Function) aPoint2 = RI.GetPoint2(); @@ -125,10 +131,16 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const gp_Ax1 anAx1(aCP, aDir); Standard_Real anAngle = aVec1.Angle(aVec2); aTrsf.SetRotation(anAx1, anAngle); - BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); - aShape = aTransformation.Shape(); + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + //aShape = aTransformation.Shape(); + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + TopLoc_Location aLocRes (aTrsf * aTrsfOrig); + aShape = anOriginal.Located(aLocRes); } - else if(aType == ROTATE_1D) { + else if (aType == ROTATE_1D) { //Get direction Handle(GEOM_Function) anAxis = RI.GetAxis(); if(anAxis.IsNull()) return 0; @@ -138,27 +150,34 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge)); - gp_Dir D(gp_Vec(aP1, aP2)) ; + gp_Dir D(gp_Vec(aP1, aP2)); - gp_Ax1 AX1(aP1, D) ; + gp_Ax1 AX1(aP1, D); Standard_Integer nbtimes = RI.GetNbIter1(); - Standard_Real angle = 360.0/nbtimes ; + Standard_Real angle = 360.0/nbtimes; TopoDS_Compound aCompound; BRep_Builder B; B.MakeCompound( aCompound ); - + + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + for (int i = 0; i < nbtimes; i++ ) { - aTrsf.SetRotation(AX1, i*angle*PI180) ; - BRepBuilderAPI_Transform myBRepTransformation(anOriginal, aTrsf, Standard_False) ; - B.Add( aCompound, myBRepTransformation.Shape() ); + aTrsf.SetRotation(AX1, i*angle*PI180); + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aBRepTransformation(anOriginal, aTrsf, Standard_False); + //B.Add(aCompound, aBRepTransformation.Shape()); + TopLoc_Location aLocRes (aTrsf * aTrsfOrig); + B.Add(aCompound, anOriginal.Located(aLocRes)); } - aShape = aCompound ; + aShape = aCompound; } - else if(aType == ROTATE_2D) { - Standard_Real DX, DY, DZ ; + else if (aType == ROTATE_2D) { + Standard_Real DX, DY, DZ; //Get direction Handle(GEOM_Function) anAxis = RI.GetAxis(); @@ -168,77 +187,81 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const TopoDS_Edge anEdge = TopoDS::Edge(A); gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge)); - gp_Dir D(gp_Vec(aP1, aP2)) ; + gp_Dir D(gp_Vec(aP1, aP2)); + + gp_Ax1 AX1(aP1, D); - gp_Ax1 AX1(aP1, D) ; + gp_Trsf aTrsf1; + gp_Trsf aTrsf2; + gp_Pnt P1; + GProp_GProps System; - gp_Trsf theTransformation1 ; - gp_Trsf theTransformation2 ; - gp_Pnt P1 ; - GProp_GProps System ; - - if ( anOriginal.ShapeType() == TopAbs_VERTEX) { + 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() ; + P1 = System.CentreOfMass(); } else if ( anOriginal.ShapeType() == TopAbs_FACE || anOriginal.ShapeType() == TopAbs_SHELL ) { BRepGProp::SurfaceProperties(anOriginal, System); - P1 = System.CentreOfMass() ; + P1 = System.CentreOfMass(); } else { BRepGProp::VolumeProperties(anOriginal, System); - P1 = System.CentreOfMass() ; + P1 = System.CentreOfMass(); } - + Handle(Geom_Line) Line = new Geom_Line(AX1); - GeomAPI_ProjectPointOnCurve aPrjTool( P1, Line ) ; + GeomAPI_ProjectPointOnCurve aPrjTool( P1, Line ); gp_Pnt P2 = aPrjTool.NearestPoint(); - + if ( P1.IsEqual(P2, Precision::Confusion() ) ) return 0; - - gp_Vec Vec(P1.X()-P2.X(), P1.Y()-P2.Y(), P1.Z()-P2.Z()) ; + + gp_Vec Vec(P1.X()-P2.X(), P1.Y()-P2.Y(), P1.Z()-P2.Z()); Vec.Normalize(); - + Standard_Integer nbtimes2 = RI.GetNbIter2(); Standard_Integer nbtimes1 = RI.GetNbIter1(); Standard_Real step = RI.GetStep(); Standard_Real ang = RI.GetAngle(); - gp_Vec myVec ; + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + + gp_Vec aVec; TopoDS_Compound aCompound; BRep_Builder B; B.MakeCompound( aCompound ); for (int i = 0; i < nbtimes2; i++ ) { for (int j = 0; j < nbtimes1; j++ ) { - DX = i * step * Vec.X() ; - DY = i * step * Vec.Y() ; - DZ = i * step * Vec.Z() ; - myVec.SetCoord( DX, DY, DZ ) ; - theTransformation1.SetTranslation(myVec) ; - theTransformation2.SetRotation(AX1, j*ang*PI180) ; - BRepBuilderAPI_Transform myBRepTransformation1(anOriginal, theTransformation1, Standard_False) ; - BRepBuilderAPI_Transform myBRepTransformation2(myBRepTransformation1.Shape(), theTransformation2, Standard_False) ; - B.Add( aCompound, myBRepTransformation2.Shape() ); + DX = i * step * Vec.X(); + DY = i * step * Vec.Y(); + DZ = i * step * Vec.Z(); + aVec.SetCoord( DX, DY, DZ ); + aTrsf1.SetTranslation(aVec); + aTrsf2.SetRotation(AX1, j*ang*PI180); + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aBRepTrsf1 (anOriginal, aTrsf1, Standard_False); + //BRepBuilderAPI_Transform aBRepTrsf2 (aBRepTrsf1.Shape(), aTrsf2, Standard_False); + //B.Add(aCompound, aBRepTrsf2.Shape()); + TopLoc_Location aLocRes (aTrsf2 * aTrsf1 * aTrsfOrig); + B.Add(aCompound, anOriginal.Located(aLocRes)); } } aShape = aCompound; - } else return 0; - - if (aShape.IsNull()) return 0; aFunction->SetValue(aShape); - log.SetTouched(Label()); + log.SetTouched(Label()); return 1; } @@ -247,17 +270,15 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const //======================================================================= //function : GEOMImpl_RotateDriver_Type_ //purpose : -//======================================================================= +//======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_RotateDriver_Type_() { - static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_RotateDriver", @@ -272,8 +293,7 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_RotateDriver_Type_() //======================================================================= //function : DownCast //purpose : -//======================================================================= - +//======================================================================= const Handle(GEOMImpl_RotateDriver) Handle(GEOMImpl_RotateDriver)::DownCast(const Handle(Standard_Transient)& AnObject) { Handle(GEOMImpl_RotateDriver) _anOtherObject; @@ -284,7 +304,5 @@ const Handle(GEOMImpl_RotateDriver) Handle(GEOMImpl_RotateDriver)::DownCast(cons } } - return _anOtherObject ; + return _anOtherObject; } - - diff --git a/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx b/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx index 8bc498a2a..ad967865b 100644 --- a/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 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 +// 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 +// +// 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 +// 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 @@ -42,33 +42,33 @@ //======================================================================= //function : GetID //purpose : -//======================================================================= +//======================================================================= const Standard_GUID& GEOMImpl_TranslateDriver::GetID() { static Standard_GUID aTranslateDriver("FF1BBB03-5D14-4df2-980B-3A668264EA16"); - return aTranslateDriver; + return aTranslateDriver; } //======================================================================= //function : GEOMImpl_TranslateDriver -//purpose : +//purpose : //======================================================================= -GEOMImpl_TranslateDriver::GEOMImpl_TranslateDriver() +GEOMImpl_TranslateDriver::GEOMImpl_TranslateDriver() { } //======================================================================= //function : Execute //purpose : -//======================================================================= +//======================================================================= Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const { - if(Label().IsNull()) return 0; + if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - if(aFunction.IsNull()) return 0; + if (aFunction.IsNull()) return 0; GEOMImpl_ITranslate TI(aFunction); gp_Trsf aTrsf; @@ -76,11 +76,11 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const Standard_Integer aType = aFunction->GetType(); Handle(GEOM_Function) anOriginalFunction = TI.GetOriginal(); - if(anOriginalFunction.IsNull()) return 0; + if (anOriginalFunction.IsNull()) return 0; TopoDS_Shape aShape, anOriginal = anOriginalFunction->GetValue(); - if(anOriginal.IsNull()) return 0; + if (anOriginal.IsNull()) return 0; - if(aType == TRANSLATE_TWO_POINTS || aType == TRANSLATE_TWO_POINTS_COPY) { + if (aType == TRANSLATE_TWO_POINTS || aType == TRANSLATE_TWO_POINTS_COPY) { Handle(GEOM_Function) aPoint1 = TI.GetPoint1(); Handle(GEOM_Function) aPoint2 = TI.GetPoint2(); if(aPoint1.IsNull() || aPoint2.IsNull()) return 0; @@ -93,10 +93,16 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aV2)); aTrsf.SetTranslation(aP1, aP2); - BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); - aShape = aTransformation.Shape(); - - } else if(aType == TRANSLATE_VECTOR || aType == TRANSLATE_VECTOR_COPY) { + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + //aShape = aTransformation.Shape(); + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + TopLoc_Location aLocRes (aTrsf * aTrsfOrig); + aShape = anOriginal.Located(aLocRes); + } + else if (aType == TRANSLATE_VECTOR || aType == TRANSLATE_VECTOR_COPY) { Handle(GEOM_Function) aVector = TI.GetVector(); if(aVector.IsNull()) return 0; TopoDS_Shape aV = aVector->GetValue(); @@ -107,19 +113,31 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge)); aTrsf.SetTranslation(aP1, aP2); - BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); - aShape = aTransformation.Shape(); + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + //aShape = aTransformation.Shape(); + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + TopLoc_Location aLocRes (aTrsf * aTrsfOrig); + aShape = anOriginal.Located(aLocRes); } - else if(aType == TRANSLATE_XYZ || aType == TRANSLATE_XYZ_COPY) { - gp_Vec aVec(TI.GetDX(), TI.GetDY(), TI.GetDZ()); + else if (aType == TRANSLATE_XYZ || aType == TRANSLATE_XYZ_COPY) { + gp_Vec aVec (TI.GetDX(), TI.GetDY(), TI.GetDZ()); aTrsf.SetTranslation(aVec); - BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); - aShape = aTransformation.Shape(); + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aTransformation (anOriginal, aTrsf, Standard_False); + //aShape = aTransformation.Shape(); + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + TopLoc_Location aLocRes (aTrsf * aTrsfOrig); + aShape = anOriginal.Located(aLocRes); } - else if(aType == TRANSLATE_1D) { + else if (aType == TRANSLATE_1D) { Standard_Real DX, DY, DZ, step = TI.GetStep1(); Standard_Integer nbtimes = TI.GetNbIter1(); - gp_Vec myVec ; + gp_Vec aVec; TopoDS_Compound aCompound; BRep_Builder B; B.MakeCompound( aCompound ); @@ -133,21 +151,28 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const gp_Vec Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); Vec.Normalize(); - for (int i = 0; i < nbtimes; i++ ) { - DX = i * step * Vec.X() ; - DY = i * step * Vec.Y() ; - DZ = i * step * Vec.Z() ; - myVec.SetCoord( DX, DY, DZ ) ; - aTrsf.SetTranslation(myVec) ; - BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False) ; - B.Add(aCompound , aTransformation.Shape() ); + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + + for (int i = 0; i < nbtimes; i++) { + DX = i * step * Vec.X(); + DY = i * step * Vec.Y(); + DZ = i * step * Vec.Z(); + aVec.SetCoord( DX, DY, DZ ); + aTrsf.SetTranslation(aVec); + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + //B.Add(aCompound, aTransformation.Shape()); + TopLoc_Location aLocRes (aTrsf * aTrsfOrig); + B.Add(aCompound, anOriginal.Located(aLocRes)); } - aShape = aCompound; + aShape = aCompound; } - else if(aType == TRANSLATE_2D) { + else if (aType == TRANSLATE_2D) { Standard_Integer nbtimes1 = TI.GetNbIter1(), nbtimes2 = TI.GetNbIter2(); Standard_Real DX, DY, DZ, step1 = TI.GetStep1(), step2 = TI.GetStep2(); - gp_Vec myVec ; + gp_Vec aVec; Handle(GEOM_Function) aVector = TI.GetVector(); if(aVector.IsNull()) return 0; TopoDS_Shape aV = aVector->GetValue(); @@ -169,29 +194,35 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const TopoDS_Compound aCompound; BRep_Builder B; B.MakeCompound( aCompound ); - - for (int i = 0; i < nbtimes1; i++ ) { - for (int j = 0; j < nbtimes2; j++ ) { - DX = i * step1 * Vec1.X() + j * step2 * Vec2.X() ; - DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y() ; - DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z() ; - myVec.SetCoord( DX, DY, DZ ) ; - aTrsf.SetTranslation(myVec) ; - BRepBuilderAPI_Transform myBRepTransformation(anOriginal, aTrsf, Standard_False) ; - B.Add(aCompound , myBRepTransformation.Shape() ); + + TopLoc_Location aLocOrig = anOriginal.Location(); + gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + + for (int i = 0; i < nbtimes1; i++) { + for (int j = 0; j < nbtimes2; j++) { + DX = i * step1 * Vec1.X() + j * step2 * Vec2.X(); + DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y(); + DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z(); + aVec.SetCoord( DX, DY, DZ ); + aTrsf.SetTranslation(aVec); + //NPAL18620: performance problem: multiple locations are accumulated + // in shape and need a great time to process + //BRepBuilderAPI_Transform aBRepTransformation(anOriginal, aTrsf, Standard_False); + //B.Add(aCompound, aBRepTransformation.Shape()); + TopLoc_Location aLocRes (aTrsf * aTrsfOrig); + B.Add(aCompound, anOriginal.Located(aLocRes)); } } - aShape = aCompound; + aShape = aCompound; } else return 0; - if (aShape.IsNull()) return 0; aFunction->SetValue(aShape); - log.SetTouched(Label()); + log.SetTouched(Label()); return 1; } @@ -200,17 +231,16 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const //======================================================================= //function : GEOMImpl_TranslateDriver_Type_ //purpose : -//======================================================================= +//======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_TranslateDriver_Type_() { static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_TranslateDriver", @@ -225,8 +255,7 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_TranslateDriver_Type_() //======================================================================= //function : DownCast //purpose : -//======================================================================= - +//======================================================================= const Handle(GEOMImpl_TranslateDriver) Handle(GEOMImpl_TranslateDriver)::DownCast(const Handle(Standard_Transient)& AnObject) { Handle(GEOMImpl_TranslateDriver) _anOtherObject; @@ -237,7 +266,5 @@ const Handle(GEOMImpl_TranslateDriver) Handle(GEOMImpl_TranslateDriver)::DownCas } } - return _anOtherObject ; + return _anOtherObject; } - -