1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0028425: Open/save NamedShape changes order of shapes

Changed order of shapes when reading from bin and xml document.

Small correction of test case for issue CR28425
This commit is contained in:
dbv 2017-02-09 14:50:17 +03:00
parent 84eea67f81
commit d057720d07
3 changed files with 96 additions and 30 deletions

View File

@ -187,39 +187,49 @@ Standard_Boolean BinMNaming_NamedShapeDriver::Paste
BinTools_ShapeSet& aShapeSet = (BinTools_ShapeSet&) myShapeSet; BinTools_ShapeSet& aShapeSet = (BinTools_ShapeSet&) myShapeSet;
for (Standard_Integer i = 1; i <= aNbShapes; i++) { NCollection_List<TopoDS_Shape> anOldShapes, aNewShapes;
for (Standard_Integer i = 1; i <= aNbShapes; i++)
{
TopoDS_Shape anOldShape, aNewShape; TopoDS_Shape anOldShape, aNewShape;
if ( anEvol != TNaming_PRIMITIVE )
if(TranslateFrom(theSource, anOldShape, aShapeSet)) return Standard_False;
if (anEvol != TNaming_DELETE) if (anEvol != TNaming_PRIMITIVE)
if(TranslateFrom(theSource, aNewShape, aShapeSet)) return Standard_False; if (TranslateFrom (theSource, anOldShape, aShapeSet)) return Standard_False;
switch (anEvol) { if (anEvol != TNaming_DELETE)
case TNaming_PRIMITIVE : if (TranslateFrom (theSource, aNewShape, aShapeSet)) return Standard_False;
aBuilder.Generated(aNewShape);
break; // Here we add shapes in reverse order because TNaming_Builder also adds them in reverse order.
case TNaming_GENERATED : anOldShapes.Prepend (anOldShape);
aBuilder.Generated(anOldShape, aNewShape); aNewShapes.Prepend (aNewShape);
break; }
case TNaming_MODIFY :
aBuilder.Modify(anOldShape, aNewShape); for (NCollection_List<TopoDS_Shape>::Iterator anOldIt (anOldShapes), aNewIt (aNewShapes);
break; anOldIt.More() && aNewIt.More();
case TNaming_DELETE : anOldIt.Next(), aNewIt.Next())
aBuilder.Delete (anOldShape); {
break; switch (anEvol)
case TNaming_SELECTED : {
aBuilder.Select(aNewShape, anOldShape); case TNaming_PRIMITIVE:
break; aBuilder.Generated (aNewIt.Value ());
case TNaming_REPLACE : break;
aBuilder.Modify(anOldShape, aNewShape); // for compatibility aBuilder.Replace(anOldShape, aNewShape); case TNaming_GENERATED:
break; aBuilder.Generated (anOldIt.Value(), aNewIt.Value());
default : break;
Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown"); case TNaming_MODIFY:
aBuilder.Modify (anOldIt.Value(), aNewIt.Value());
break;
case TNaming_DELETE:
aBuilder.Delete (anOldIt.Value());
break;
case TNaming_SELECTED:
aBuilder.Select (aNewIt.Value(), anOldIt.Value());
break;
case TNaming_REPLACE:
aBuilder.Modify (anOldIt.Value(), aNewIt.Value()); // for compatibility aBuilder.Replace(anOldShape, aNewShape);
break;
default:
Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown");
} }
anOldShape.Nullify();
aNewShape.Nullify();
} }
return Standard_True; return Standard_True;
} }

View File

@ -121,7 +121,7 @@ Standard_Boolean XmlMNaming_NamedShapeDriver::Paste
Standard_Integer upper = NewPShapes.Upper(); Standard_Integer upper = NewPShapes.Upper();
if (OldPShapes.Upper() > upper) upper = OldPShapes.Upper(); if (OldPShapes.Upper() > upper) upper = OldPShapes.Upper();
for (Standard_Integer i = lower; i <= upper; i++) for (Standard_Integer i = upper; i >= lower; --i)
{ {
const XmlMNaming_Shape1 aNewPShape = NewPShapes.Value(i); const XmlMNaming_Shape1 aNewPShape = NewPShapes.Value(i);
const XmlMNaming_Shape1 anOldPShape = OldPShapes.Value(i); const XmlMNaming_Shape1 anOldPShape = OldPShapes.Value(i);

56
tests/bugs/caf/bug28425 Normal file
View File

@ -0,0 +1,56 @@
puts "==========="
puts "OCC28425"
puts "==========="
puts ""
############################################################
# Open/save NamedShape changes order of shapes
############################################################
pload QAcommands
vertex v 1 2 3
box b 10 20 30
# Test bin document
NewDocument D1 BinOcaf
BuildNamedShape D1 0:1 PRIMITIVE v b
GetNewShapes D1 0:1 s
set info [whatis s_1]
if { [regexp "SOLID" $info] != 1 } {
puts "Error: first shape should be solid"
} else {
puts "OK: order of shapes is correct"
}
SaveAs D1 test.cbf
Close D1
Open test.cbf D2
GetNewShapes D2 0:1 s
set info [whatis s_1]
if { [regexp "SOLID" $info] != 1 } {
puts "Error: first shape should be solid"
} else {
puts "OK: order of shapes is correct"
}
Close D2
# Test xml document
NewDocument D1 XmlOcaf
BuildNamedShape D1 0:1 PRIMITIVE v b
GetNewShapes D1 0:1 s
set info [whatis s_1]
if { [regexp "SOLID" $info] != 1 } {
puts "Error: first shape should be solid"
} else {
puts "OK: order of shapes is correct"
}
SaveAs D1 test.xml
Close D1
Open test.xml D2
GetNewShapes D2 0:1 s
set info [whatis s_1]
if { [regexp "SOLID" $info] != 1 } {
puts "Error: first shape should be solid"
} else {
puts "OK: order of shapes is correct"
}
Close D2