NPAL18620: Pb. of performance with MakeTranslation. Improve transformations to avoid accumulation of locations in a shape.

This commit is contained in:
jfa 2008-01-28 11:56:59 +00:00
parent e170a5ac49
commit 1124a13601
2 changed files with 185 additions and 140 deletions

View File

@ -100,8 +100,14 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const
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) {
Handle(GEOM_Function) aCentPoint = RI.GetCentPoint();
@ -125,8 +131,14 @@ 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) {
//Get direction
@ -149,10 +161,17 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const
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() );
//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;
@ -173,8 +192,8 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const
gp_Ax1 AX1(aP1, D);
gp_Trsf theTransformation1 ;
gp_Trsf theTransformation2 ;
gp_Trsf aTrsf1;
gp_Trsf aTrsf2;
gp_Pnt P1;
GProp_GProps System;
@ -208,7 +227,10 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const
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 );
@ -217,23 +239,24 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const
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() );
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);
@ -250,7 +273,6 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const
//=======================================================================
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);
@ -258,7 +280,6 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_RotateDriver_Type_()
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",
sizeof(GEOMImpl_RotateDriver),
@ -273,7 +294,6 @@ 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;
@ -286,5 +306,3 @@ const Handle(GEOMImpl_RotateDriver) Handle(GEOMImpl_RotateDriver)::DownCast(cons
return _anOtherObject;
}

View File

@ -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());
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) {
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();
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();
myVec.SetCoord( DX, DY, DZ ) ;
aTrsf.SetTranslation(myVec) ;
BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False) ;
B.Add(aCompound , aTransformation.Shape() );
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;
}
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();
@ -170,15 +195,22 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const
BRep_Builder B;
B.MakeCompound( aCompound );
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();
myVec.SetCoord( DX, DY, DZ ) ;
aTrsf.SetTranslation(myVec) ;
BRepBuilderAPI_Transform myBRepTransformation(anOriginal, aTrsf, Standard_False) ;
B.Add(aCompound , myBRepTransformation.Shape() );
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;
@ -186,7 +218,6 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const
else return 0;
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
@ -211,7 +242,6 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_TranslateDriver_Type_()
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",
sizeof(GEOMImpl_TranslateDriver),
@ -226,7 +256,6 @@ 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;
@ -239,5 +268,3 @@ const Handle(GEOMImpl_TranslateDriver) Handle(GEOMImpl_TranslateDriver)::DownCas
return _anOtherObject;
}