mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56: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:
parent
84eea67f81
commit
d057720d07
@ -187,39 +187,49 @@ Standard_Boolean BinMNaming_NamedShapeDriver::Paste
|
||||
|
||||
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;
|
||||
|
||||
if ( anEvol != TNaming_PRIMITIVE )
|
||||
if(TranslateFrom(theSource, anOldShape, aShapeSet)) return Standard_False;
|
||||
|
||||
if (anEvol != TNaming_DELETE)
|
||||
if(TranslateFrom(theSource, aNewShape, aShapeSet)) return Standard_False;
|
||||
if (anEvol != TNaming_PRIMITIVE)
|
||||
if (TranslateFrom (theSource, anOldShape, aShapeSet)) return Standard_False;
|
||||
|
||||
switch (anEvol) {
|
||||
case TNaming_PRIMITIVE :
|
||||
aBuilder.Generated(aNewShape);
|
||||
break;
|
||||
case TNaming_GENERATED :
|
||||
aBuilder.Generated(anOldShape, aNewShape);
|
||||
break;
|
||||
case TNaming_MODIFY :
|
||||
aBuilder.Modify(anOldShape, aNewShape);
|
||||
break;
|
||||
case TNaming_DELETE :
|
||||
aBuilder.Delete (anOldShape);
|
||||
break;
|
||||
case TNaming_SELECTED :
|
||||
aBuilder.Select(aNewShape, anOldShape);
|
||||
break;
|
||||
case TNaming_REPLACE :
|
||||
aBuilder.Modify(anOldShape, aNewShape); // for compatibility aBuilder.Replace(anOldShape, aNewShape);
|
||||
break;
|
||||
default :
|
||||
Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown");
|
||||
if (anEvol != TNaming_DELETE)
|
||||
if (TranslateFrom (theSource, aNewShape, aShapeSet)) return Standard_False;
|
||||
|
||||
// Here we add shapes in reverse order because TNaming_Builder also adds them in reverse order.
|
||||
anOldShapes.Prepend (anOldShape);
|
||||
aNewShapes.Prepend (aNewShape);
|
||||
}
|
||||
|
||||
for (NCollection_List<TopoDS_Shape>::Iterator anOldIt (anOldShapes), aNewIt (aNewShapes);
|
||||
anOldIt.More() && aNewIt.More();
|
||||
anOldIt.Next(), aNewIt.Next())
|
||||
{
|
||||
switch (anEvol)
|
||||
{
|
||||
case TNaming_PRIMITIVE:
|
||||
aBuilder.Generated (aNewIt.Value ());
|
||||
break;
|
||||
case TNaming_GENERATED:
|
||||
aBuilder.Generated (anOldIt.Value(), aNewIt.Value());
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ Standard_Boolean XmlMNaming_NamedShapeDriver::Paste
|
||||
Standard_Integer upper = NewPShapes.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 anOldPShape = OldPShapes.Value(i);
|
||||
|
56
tests/bugs/caf/bug28425
Normal file
56
tests/bugs/caf/bug28425
Normal 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
|
Loading…
x
Reference in New Issue
Block a user