// Created on: 2004-04-08
// Created by: Sergey ZARITCHNY
-// Copyright (c) 2004-2012 OPEN CASCADE SAS
+// Copyright (c) 2004-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
-#include <BinMNaming_NamedShapeDriver.ixx>
+#include <BinMNaming_NamedShapeDriver.hxx>
+#include <BinObjMgt_Persistent.hxx>
+#include <BinTools_LocationSet.hxx>
+#include <BinTools_ShapeSet.hxx>
+#include <Message_Messenger.hxx>
#include <Standard_DomainError.hxx>
-#include <TNaming_NamedShape.hxx>
-#include <TNaming_Evolution.hxx>
-#include <TNaming_Builder.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Attribute.hxx>
#include <TDF_Label.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_Evolution.hxx>
#include <TNaming_Iterator.hxx>
-#include <CDM_MessageDriver.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <BinTools_ShapeSet.hxx>
+#include <TNaming_NamedShape.hxx>
#include <TopAbs_Orientation.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(BinMNaming_NamedShapeDriver,BinMDF_ADriver)
#define SHAPESET "SHAPE_SECTION"
#define FORMAT_NUMBER 3
case TNaming_SELECTED : return 'S';
case TNaming_REPLACE : return 'M'; // for compatibility case TNaming_REPLACE : return 'R';
default:
- Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown");
+ throw Standard_DomainError("TNaming_Evolution:: Evolution Unknown");
}
- return 'P'; // To avoid compilation error message.
}
//=======================================================================
case 'S': return TNaming_SELECTED;
case 'R': return TNaming_MODIFY; //for compatibility //TNaming_REPLACE;
default:
- Standard_DomainError::Raise("TNaming_Evolution:: Evolution Unknown");
+ throw Standard_DomainError("TNaming_Evolution:: Evolution Unknown");
}
- return TNaming_PRIMITIVE; // To avoid compilation error message.
}
//=======================================================================
static Standard_Character OrientationToChar(const TopAbs_Orientation theOrient)
case TopAbs_INTERNAL : return 'I';
case TopAbs_EXTERNAL : return 'E';
default:
- Standard_DomainError::Raise("TopAbs_Orientation:: Orientation Unknown");
+ throw Standard_DomainError("TopAbs_Orientation:: Orientation Unknown");
}
- return 'F'; // To avoid compilation error message.
}
//=======================================================================
static TopAbs_Orientation CharToOrientation(const Standard_Character theCharOrient)
case 'I': return TopAbs_INTERNAL;
case 'E': return TopAbs_EXTERNAL;
default:
- Standard_DomainError::Raise("TopAbs_Orientation:: Orientation Unknown");
+ throw Standard_DomainError("TopAbs_Orientation:: Orientation Unknown");
}
- return TopAbs_FORWARD; // To avoid compilation error message.
}
//=======================================================================
//=======================================================================
BinMNaming_NamedShapeDriver::BinMNaming_NamedShapeDriver
- (const Handle(CDM_MessageDriver)& theMsgDriver)
+ (const Handle(Message_Messenger)& theMsgDriver)
: BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TNaming_NamedShape)->Name()), myShapeSet(Standard_False),myFormatNb(FORMAT_NUMBER)
{
}
theSource >> aNbShapes;
TDF_Label aLabel = theTarget->Label ();
TNaming_Builder aBuilder (aLabel);
- if (aNbShapes == 0) return Standard_False;
Standard_Integer aVer;
Standard_Boolean ok = theSource >> aVer;
if(!ok) return Standard_False;
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;
-
- 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_PRIMITIVE)
+ if (TranslateFrom (theSource, anOldShape, aShapeSet)) return Standard_False;
+
+ 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:
+ throw Standard_DomainError("TNaming_Evolution:: Evolution Unknown");
}
- anOldShape.Nullify();
- aNewShape.Nullify();
}
return Standard_True;
}
for (TNaming_Iterator SItr (aSAtt); SItr.More (); SItr.Next ()) NbShapes++;
//--------------------------------------------------------------
- if (NbShapes == 0) return;
-
BinTools_ShapeSet& aShapeSet = (BinTools_ShapeSet&) myShapeSet;
TNaming_Evolution anEvol = aSAtt->Evolution();
else
theIS.seekg(aPos); // no shape section is present, try to return to initial point
}
-