diff --git a/src/DNaming/DNaming_ToolsCommands.cxx b/src/DNaming/DNaming_ToolsCommands.cxx index 7bb5597f21..33e198ab32 100755 --- a/src/DNaming/DNaming_ToolsCommands.cxx +++ b/src/DNaming/DNaming_ToolsCommands.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -146,6 +147,61 @@ static Standard_Integer DNaming_TCopyShape (Draw_Interpretor& di, return 1; } +//======================================================================= +//function : DNaming_TCopyTool +//purpose : CopyTool Shape1 [Shape2 ...] +// - for test TNaming_CopyShape::CopyTool mechanism +//======================================================================= + +static Standard_Integer DNaming_TCopyTool (Draw_Interpretor& di, + Standard_Integer nb, + const char** arg) +{ + if (nb < 2) { + di << "Usage: CopyTool Shape1 [Shape2] ..." << "\n"; + return 1; + } + + Standard_Integer i; + TCollection_AsciiString aCopyNames; + BRep_Builder aBuilder; + TColStd_IndexedDataMapOfTransientTransient aMap; + TopoDS_Shape aResult; + + for (i = 1; i < nb; i++) { + TopoDS_Shape aShape = DBRep::Get(arg[i]); + + if (aShape.IsNull()) { + BRepTools::Read(aShape, arg[i], aBuilder); + } + + if (aShape.IsNull()) { + di << arg[i] << " is neither a shape nor a BREP file. Skip it." << "\n"; + continue; + } + + // Perform copying. + TNaming_CopyShape::CopyTool(aShape, aMap, aResult); + + // Draw result. + TCollection_AsciiString aName(arg[i]); + + aName.AssignCat("_c"); + DBRep::Set(aName.ToCString(), aResult); + + // Compose all names of copies. + if (!aCopyNames.IsEmpty()) { + aCopyNames.AssignCat(" "); + } + + aCopyNames.AssignCat(aName); + } + + di << aCopyNames.ToCString() << "\n"; + + return 0; +} + //======================================================================= //function : ToolsCommands //purpose : @@ -163,6 +219,10 @@ void DNaming::ToolsCommands (Draw_Interpretor& theCommands) "CopyShape (Shape1 [Shape2] ...)", __FILE__, DNaming_TCopyShape, g); + theCommands.Add ("CopyTool", + "CopyTool Shape1 [Shape2] ...", + __FILE__, DNaming_TCopyTool, g); + theCommands.Add ("CheckSame", "CheckSame (Shape1 Shape2 ExploMode[F|E|V])", __FILE__, DNaming_CheckHasSame, g); diff --git a/src/TNaming/TNaming_CopyShape.cxx b/src/TNaming/TNaming_CopyShape.cxx index 3cd0939fb7..249c6167f4 100755 --- a/src/TNaming/TNaming_CopyShape.cxx +++ b/src/TNaming/TNaming_CopyShape.cxx @@ -51,6 +51,7 @@ void TNaming_CopyShape::Translate( const TopoDS_Shape& aShape, TopoDS_Shape& aResult, const Handle(TNaming_TranslateTool)& TrTool) { + aResult.Nullify(); if (aShape.IsNull()) return; diff --git a/tests/bugs/caf/bug24263_2 b/tests/bugs/caf/bug24263_2 new file mode 100644 index 0000000000..ec99d7c41d --- /dev/null +++ b/tests/bugs/caf/bug24263_2 @@ -0,0 +1,12 @@ +puts "==========" +puts "OCC24263" +puts "==========" +puts "" +################################################### +# TNaming_CopyShape::CopyTool failure +################################################### + +box b 100 100 100 +explode b F + +CopyTool b_1 b