diff --git a/src/BinLDrivers/BinLDrivers.cxx b/src/BinLDrivers/BinLDrivers.cxx index 7b16bb0106..487ccca6dd 100755 --- a/src/BinLDrivers/BinLDrivers.cxx +++ b/src/BinLDrivers/BinLDrivers.cxx @@ -36,7 +36,7 @@ static Standard_GUID BinLStorageDriver ("13a56835-8269-11d5-aab2-0050044b1af1"); static Standard_GUID BinLRetrievalDriver("13a56836-8269-11d5-aab2-0050044b1af1"); -#define CURRENT_DOCUMENT_VERSION 6 +#define CURRENT_DOCUMENT_VERSION 7 //======================================================================= //function : Factory diff --git a/src/BinMNaming/BinMNaming_NamingDriver.cxx b/src/BinMNaming/BinMNaming_NamingDriver.cxx index 9484c8d58c..c61a156373 100755 --- a/src/BinMNaming/BinMNaming_NamingDriver.cxx +++ b/src/BinMNaming/BinMNaming_NamingDriver.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -237,12 +238,12 @@ Standard_Boolean BinMNaming_NamingDriver::Paste "Cannot retrieve reference on " "Arguments of Name"); WriteMessage (aMsg); - } + } #ifdef DEB //cout << "CurDocVersion = " << BinMNaming::DocumentVersion() < 3) { + if(BinMNaming::DocumentVersion() > 3) { TCollection_AsciiString entry; ok = theSource >> entry; if(ok) { @@ -259,14 +260,48 @@ Standard_Boolean BinMNaming_NamingDriver::Paste aName.ContextLabel(tLab); } } - } + if(BinMNaming::DocumentVersion() > 4 && BinMNaming::DocumentVersion() < 7) { + // Orientation processing - converting from old format + Handle(TNaming_NamedShape) aNS; + if(anAtt->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + //const TDF_Label& aLab = aNS->Label(); + TNaming_Iterator itL (aNS); + for (; itL.More(); itL.Next()) { + const TopoDS_Shape& S = itL.NewShape(); + if (S.IsNull()) continue; + if(aNS->Evolution() == TNaming_SELECTED) { + if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX && + !itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX ) {//OR-N + TopAbs_Orientation OrientationToApply = itL.OldShape().Orientation(); + aName.Orientation(OrientationToApply); + } + } + } + } + } + if(BinMNaming::DocumentVersion() > 6) { + ok = theSource >> anIndx; + TopAbs_Orientation OrientationToApply(TopAbs_FORWARD); + if(ok) { + OrientationToApply = (TopAbs_Orientation)anIndx; + aName.Orientation(OrientationToApply); +#ifdef DEB + cout << "NamingDriver:: Retrieved Orientation = " << OrientationToApply << " Ok = " << theSource.IsOK() <GetName(),F->ChangeName(),RelocTable); + // Orientation processing + Handle(TNaming_NamedShape) aNS; + if(F->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { +#ifdef DEB_ORIENT + const TDF_Label& aLab = aNS->Label(); + TCollection_AsciiString entry; + TDF_Tool::Entry(aLab, entry); + cout << "Label = " << entry << " Evolution = " <Evolution() << " IsEmpty = " << aNS->IsEmpty() <IsEmpty()) { + TNaming_Iterator itL (aNS); + for (; itL.More(); itL.Next()) { + const TopoDS_Shape& S = itL.NewShape(); + if (S.IsNull()) continue; + if(aNS->Evolution() == TNaming_SELECTED) { + if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX && + !itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX ) {//OR-N + TopAbs_Orientation OrientationToApply = itL.OldShape().Orientation(); +#ifdef DEB_ORIENT + cout <<"Retrieved Orientation = " << OrientationToApply <ChangeName().Orientation(OrientationToApply); + } + } + } + } + } + // } diff --git a/src/MNaming/MNaming_NamingRetrievalDriver_2.cdl b/src/MNaming/MNaming_NamingRetrievalDriver_2.cdl new file mode 100644 index 0000000000..8fa5b9cf6f --- /dev/null +++ b/src/MNaming/MNaming_NamingRetrievalDriver_2.cdl @@ -0,0 +1,53 @@ +-- Created on: 2008-08-15 +-- Created by: Sergey ZARITCHNY +-- Copyright (c) 2008-2012 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. +-- +-- 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. +-- +-- 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. + + +class NamingRetrievalDriver_2 from MNaming inherits ARDriver from MDF + + ---Purpose: + +uses RRelocationTable from MDF, + Attribute from PDF, + Attribute from TDF, + MessageDriver from CDM + +is + + + Create(theMessageDriver : MessageDriver from CDM) + returns mutable NamingRetrievalDriver_2 from MNaming; + + + VersionNumber(me) returns Integer from Standard; + ---Purpose: Returns the version number from which the driver + -- is available: 0. + + SourceType(me) returns Type from Standard; + ---Purpose: Returns the type: Naming from PNaming. + + NewEmpty (me) returns mutable Attribute from TDF; + + + Paste(me; + Source : Attribute from PDF; + Target : mutable Attribute from TDF; + RelocTable : RRelocationTable from MDF); + + +end NamingRetrievalDriver_2; diff --git a/src/MNaming/MNaming_NamingRetrievalDriver_2.cxx b/src/MNaming/MNaming_NamingRetrievalDriver_2.cxx new file mode 100644 index 0000000000..b3c9e8c4f9 --- /dev/null +++ b/src/MNaming/MNaming_NamingRetrievalDriver_2.cxx @@ -0,0 +1,192 @@ +// Created on: 2008-08-15 +// Created by: Sergey ZARITCHNY +// Copyright (c) 2008-2012 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. +// +// 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. +// +// 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. + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : IntegerToShapeEnum +//purpose : +//======================================================================= + +static TopAbs_ShapeEnum IntegerToShapeEnum (const Standard_Integer I) +{ + switch(I) + { + case 0 : return TopAbs_COMPOUND; + case 1 : return TopAbs_COMPSOLID; + case 2 : return TopAbs_SOLID; + case 3 : return TopAbs_SHELL; + case 4 : return TopAbs_FACE; + case 5 : return TopAbs_WIRE; + case 6 : return TopAbs_EDGE; + case 7 : return TopAbs_VERTEX; + default : + return TopAbs_SHAPE; + } + return TopAbs_SHAPE; +} + +//======================================================================= +//function : IntegerToNameType +//purpose : +//======================================================================= + +static TNaming_NameType IntegerToNameType (const Standard_Integer I) +{ + switch(I) + { + case 0 : return TNaming_UNKNOWN; + case 1 : return TNaming_IDENTITY; + case 2 : return TNaming_MODIFUNTIL; + case 3 : return TNaming_GENERATION; + case 4 : return TNaming_INTERSECTION; + case 5 : return TNaming_UNION; + case 6 : return TNaming_SUBSTRACTION; + case 7 : return TNaming_CONSTSHAPE; + case 8 : return TNaming_FILTERBYNEIGHBOURGS; + case 9 : return TNaming_ORIENTATION; + case 10 : return TNaming_WIREIN; + default : + Standard_DomainError::Raise("TNaming_NameType; enum term unknown "); + } + return TNaming_UNKNOWN; +} +//======================================================================= +//function : IntegerToOrientation +//purpose : +//======================================================================= +static TopAbs_Orientation IntegerToOrientation (const Standard_Integer Or) +{ + switch(Or) + { + case 0 : return TopAbs_FORWARD; + case 1 : return TopAbs_REVERSED; + case 2 : return TopAbs_INTERNAL; + case 3 : return TopAbs_EXTERNAL; + default : + Standard_DomainError::Raise("PNaming_Name::myOrientation; enum term unknown "); + } + return TopAbs_FORWARD; +} +//======================================================================= +//function : MNaming_Naming_2 +//purpose : +//======================================================================= + +MNaming_NamingRetrievalDriver_2::MNaming_NamingRetrievalDriver_2( + const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver) +{ +} + +//======================================================================= +//function : VersionNumber +//purpose : +//======================================================================= + +Standard_Integer MNaming_NamingRetrievalDriver_2::VersionNumber() const +{ return 0; } + +//======================================================================= +//function : SourceType +//purpose : +//======================================================================= + +Handle(Standard_Type) MNaming_NamingRetrievalDriver_2::SourceType() const +{ return STANDARD_TYPE(PNaming_Naming_2); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) MNaming_NamingRetrievalDriver_2::NewEmpty() const +{ return new TNaming_Naming (); } + +//======================================================================= +//function : PNamingToTNaming +//purpose : +//======================================================================= + +static void PNamingToTNaming (const Handle(PNaming_Name_2)& PN, + TNaming_Name& TN, + const Handle(MDF_RRelocationTable)& RelocTable) + +{ + TN.Type (IntegerToNameType (PN->Type ())); + TN.ShapeType(IntegerToShapeEnum(PN->ShapeType())); + Handle(TNaming_NamedShape) NS; + Handle(TDF_Data) aData; + if (!PN->Arguments().IsNull()) { + Standard_Integer NbArgs = PN->Arguments()->Length(); + for (Standard_Integer i = 1; i <= NbArgs; i++) { + RelocTable->HasRelocation(PN->Arguments()->Value(i),NS); + TN.Append(NS); + if(aData.IsNull() && !NS.IsNull()) + aData = NS->Label().Data(); + } + } + + Handle(TNaming_NamedShape) StopNS; + if (!PN->StopNamedShape().IsNull()) + RelocTable->HasRelocation(PN->StopNamedShape(),StopNS); + TN.StopNamedShape(StopNS); + TN.Index(PN->Index()); + + TDF_Label tLab; // Null label. + Handle(PCollection_HAsciiString) pEntry = PN->ContextLabel(); + if (!pEntry.IsNull()) { + TCollection_AsciiString entry = pEntry->Convert(); + if(!aData.IsNull()) + TDF_Tool::Label(aData,entry,tLab); + } + TN.ContextLabel(tLab); + TN.Orientation(IntegerToOrientation (PN->Orientation ())); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void MNaming_NamingRetrievalDriver_2::Paste ( + const Handle(PDF_Attribute)& Source, + const Handle(TDF_Attribute)& Target, + const Handle(MDF_RRelocationTable)& RelocTable) const +{ + Handle(PNaming_Naming_2) PF = Handle(PNaming_Naming_2)::DownCast(Source); + Handle(TNaming_Naming) F = Handle(TNaming_Naming)::DownCast(Target); + PNamingToTNaming (PF->GetName(),F->ChangeName(),RelocTable); +} + diff --git a/src/MNaming/MNaming_NamingStorageDriver.cxx b/src/MNaming/MNaming_NamingStorageDriver.cxx index 5836c08b3f..11c55baee8 100755 --- a/src/MNaming/MNaming_NamingStorageDriver.cxx +++ b/src/MNaming/MNaming_NamingStorageDriver.cxx @@ -21,23 +21,24 @@ #include -#include +#include #include #include #include #include #include #include -#include +#include #include #include #include #include #include #include +#include //======================================================================= -//function : IntegerToShapeEnum +//function : ShapeEnumToInteger //purpose : //======================================================================= @@ -59,7 +60,7 @@ static Standard_Integer ShapeEnumToInteger (const TopAbs_ShapeEnum I) } //======================================================================= -//function : IntegerToNameType +//function : NameTypeToInteger //purpose : //======================================================================= @@ -85,6 +86,24 @@ static Standard_Integer NameTypeToInteger (const TNaming_NameType I) return 0; } +//======================================================================= +//function : OrientationToInteger +//purpose : +//======================================================================= + +static Standard_Integer OrientationToInteger (const TopAbs_Orientation Or) +{ + switch(Or) + { + case TopAbs_FORWARD : return 0; + case TopAbs_REVERSED : return 1; + case TopAbs_INTERNAL : return 2; + case TopAbs_EXTERNAL : return 3; + default : + Standard_DomainError::Raise("TNaming_Name::myOrientation; enum term unknown "); + } + return 0; +} //======================================================================= //function : MNaming_NamingStorageDriver //purpose : @@ -117,7 +136,7 @@ Handle(Standard_Type) MNaming_NamingStorageDriver::SourceType() const //======================================================================= Handle(PDF_Attribute) MNaming_NamingStorageDriver::NewEmpty() const -{ return new PNaming_Naming_1 (); } +{ return new PNaming_Naming_2 (); } //======================================================================= @@ -126,10 +145,10 @@ Handle(PDF_Attribute) MNaming_NamingStorageDriver::NewEmpty() const //======================================================================= static void TNamingToPNaming (const TNaming_Name& TN, - Handle(PNaming_Name_1)& PN, + Handle(PNaming_Name_2)& PN, const Handle(MDF_SRelocationTable)& RelocTable) { - PN = new PNaming_Name_1(); + PN = new PNaming_Name_2(); PN->Type (NameTypeToInteger (TN.Type ())); PN->ShapeType(ShapeEnumToInteger(TN.ShapeType())); @@ -161,6 +180,7 @@ static void TNamingToPNaming (const TNaming_Name& TN, } PN->ContextLabel(pEntry); + PN->Orientation(OrientationToInteger(TN.Orientation())); } //======================================================================= @@ -173,9 +193,9 @@ void MNaming_NamingStorageDriver::Paste ( const Handle(PDF_Attribute)& Target, const Handle(MDF_SRelocationTable)& RelocTable) const { - Handle(PNaming_Naming_1) PF = Handle(PNaming_Naming_1)::DownCast(Target); + Handle(PNaming_Naming_2) PF = Handle(PNaming_Naming_2)::DownCast(Target); Handle(TNaming_Naming) F = Handle(TNaming_Naming)::DownCast(Source); - Handle(PNaming_Name_1) PN ; + Handle(PNaming_Name_2) PN ; TNamingToPNaming (F->GetName(), PN ,RelocTable); PF->SetName(PN); } diff --git a/src/PNaming/PNaming.cdl b/src/PNaming/PNaming.cdl index 97271bae4d..1ab6fa296a 100755 --- a/src/PNaming/PNaming.cdl +++ b/src/PNaming/PNaming.cdl @@ -36,6 +36,8 @@ is class Name; class Name_1; + + class Name_2; class NamedShape; @@ -43,6 +45,8 @@ is class Naming_1; + class Naming_2; + class HArray1OfNamedShape instantiates HArray1 from PCollection (NamedShape); end PNaming; diff --git a/src/PNaming/PNaming_Name_2.cdl b/src/PNaming/PNaming_Name_2.cdl new file mode 100644 index 0000000000..f847e60457 --- /dev/null +++ b/src/PNaming/PNaming_Name_2.cdl @@ -0,0 +1,84 @@ +-- Created on: 2008-08-15 +-- Created by: Sergey ZARITCHNY +-- Copyright (c) 2008-2012 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. +-- +-- 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. +-- +-- 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. + + +class Name_2 from PNaming inherits Persistent from Standard + + ---Purpose: +uses + NamedShape from PNaming, + HArray1OfNamedShape from PNaming, + HAsciiString from PCollection + +is + Create returns mutable Name_2 from PNaming; + + Type (me : mutable; T : Integer from Standard); + ---C++: inline + + ShapeType (me : mutable; T : Integer from Standard); + ---C++: inline + + Arguments (me :mutable ; Args : HArray1OfNamedShape from PNaming); + ---C++: inline + + StopNamedShape (me : mutable; arg : NamedShape from PNaming); + ---C++: inline + + Orientation (me : mutable; Or : Integer from Standard); + ---C++: inline + + Type (me) returns Integer from Standard; + ---C++: inline + + ShapeType (me) returns Integer from Standard; + ---C++: inline + + Arguments (me) returns HArray1OfNamedShape from PNaming; + ---C++: inline + + StopNamedShape (me) returns NamedShape from PNaming; + ---C++: inline + + Index(me : mutable; I : Integer from Standard); + ---C++: inline + + Index(me) returns Integer from Standard; + ---C++: inline + + ContextLabel (me) returns HAsciiString from PCollection; + ---C++: return const& + ---C++: inline + + ContextLabel (me : mutable; theLab : HAsciiString from PCollection); + ---C++: inline + + Orientation(me) returns Integer from Standard; + ---C++: inline + +fields + + myType : Integer from Standard; + myShapeType : Integer from Standard; + myArgs : HArray1OfNamedShape from PNaming; + myStop : NamedShape from PNaming; + myIndex : Integer from Standard; + myContextLabel : HAsciiString from PCollection; + myOrientation : Integer from Standard; +end Name_2; diff --git a/src/PNaming/PNaming_Name_2.cxx b/src/PNaming/PNaming_Name_2.cxx new file mode 100644 index 0000000000..310f0af892 --- /dev/null +++ b/src/PNaming/PNaming_Name_2.cxx @@ -0,0 +1,32 @@ +// Created on: 2008-08-15 +// Created by: Sergey ZARITCHNY + +//======================================================================= +//function : PNaming_Name_2 +//purpose : +//======================================================================= + +PNaming_Name_2::PNaming_Name_2() +:myType(0),myShapeType(0),myIndex(0), myOrientation(0) +{ +} diff --git a/src/PNaming/PNaming_Name_2.lxx b/src/PNaming/PNaming_Name_2.lxx new file mode 100644 index 0000000000..aceb49a396 --- /dev/null +++ b/src/PNaming/PNaming_Name_2.lxx @@ -0,0 +1,62 @@ +// Created on: 2008-08-15 +// Created by: Sergey ZARITCHNY +-- Copyright (c) 2008-2012 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. +-- +-- 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. +-- +-- 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. + + + +class Naming_2 from PNaming inherits Attribute from PDF + + ---Purpose: +uses + Name_2 from PNaming + +is + Create + returns mutable Naming_2 from PNaming; + + SetName(me : mutable ; aName : Name_2 from PNaming); + + GetName(me) returns Name_2 from PNaming; + +fields + + myName : Name_2 from PNaming; + +end Naming_2; diff --git a/src/PNaming/PNaming_Naming_2.cxx b/src/PNaming/PNaming_Naming_2.cxx new file mode 100644 index 0000000000..605ec39da1 --- /dev/null +++ b/src/PNaming/PNaming_Naming_2.cxx @@ -0,0 +1,47 @@ +// Created on: 2008-08-15 +// Created by: Sergey ZARITCHNY +// Copyright (c) 2008-2012 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. +// +// 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. +// +// 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. + + +#include + +//======================================================================= +//function : PNaming_Naming_2 +//purpose : +//======================================================================= + +PNaming_Naming_2::PNaming_Naming_2() {} + + +//======================================================================= +//function : SetName +//purpose : +//======================================================================= + +void PNaming_Naming_2::SetName(const Handle(PNaming_Name_2)& Name) +{myName = Name ;} + +//======================================================================= +//function : GetName +//purpose : +//======================================================================= + +Handle(PNaming_Name_2) PNaming_Naming_2::GetName() const +{ + return myName; +} diff --git a/src/TNaming/TNaming_Name.cdl b/src/TNaming/TNaming_Name.cdl index 47876301eb..60370b2b8d 100755 --- a/src/TNaming/TNaming_Name.cdl +++ b/src/TNaming/TNaming_Name.cdl @@ -28,7 +28,8 @@ uses NameType from TNaming, NamedShape from TNaming, ListOfNamedShape from TNaming, - ShapeEnum from TopAbs, + ShapeEnum from TopAbs, + Orientation from TopAbs, Shape from TopoDS, Label from TDF, LabelMap from TDF, @@ -54,7 +55,9 @@ is Index (me : in out; I : Integer from Standard); ContextLabel (me : in out; theLab : Label from TDF); - + + Orientation (me : in out; theOrientation : Orientation from TopAbs); + ---Category: Queriyng -- ======== @@ -75,6 +78,10 @@ is ContextLabel (me) returns Label from TDF; ---C++: return const& + + Orientation (me) returns Orientation from TopAbs; + ---C++: inline + ---C++: return const ---Category: Resolution @@ -98,5 +105,6 @@ fields myIndex : Integer from Standard; myShape : Shape from TopoDS; myContextLabel : Label from TDF; + myOrientation : Orientation from TopAbs; end Name; diff --git a/src/TNaming/TNaming_Name.cxx b/src/TNaming/TNaming_Name.cxx index 1def7712ea..5a76e601cf 100755 --- a/src/TNaming/TNaming_Name.cxx +++ b/src/TNaming/TNaming_Name.cxx @@ -1096,13 +1096,13 @@ static TopoDS_Shape FindShape(const TNaming_DataMapOfShapeMapOfShape& DM) Standard_Boolean isCand(Standard_True); // aS is a Candidate TNaming_DataMapIteratorOfDataMapOfShapeMapOfShape it2(DM); for (;it2.More();it2.Next()) { - const TopoDS_Shape& aKey2 = it2.Key(); - if(aKey2 == aKey1) continue; - const TNaming_MapOfShape& aMap2 = it2.Value(); - if(!aMap2.Contains(aS)) isCand = Standard_False; + const TopoDS_Shape& aKey2 = it2.Key(); + if(aKey2 == aKey1) continue; + const TNaming_MapOfShape& aMap2 = it2.Value(); + if(!aMap2.Contains(aS)) isCand = Standard_False; } - if(isCand) - List.Append(aS); + if(isCand) + List.Append(aS); } break; } @@ -2176,24 +2176,13 @@ const TDF_Label& TNaming_Name::ContextLabel() const { return myContextLabel; } -/* + //======================================================================= //function : Orientation //purpose : Set //======================================================================= - -void TNaming_Name::Orientation(const Standard_Boolean theOrientation) +void TNaming_Name::Orientation(const TopAbs_Orientation theOrientation) { myOrientation = theOrientation; } -//======================================================================= -//function : ContextLabel -//purpose : Get -//======================================================================= - -const Standard_Boolean TNaming_Name::Orientation() const -{ - return myOrientation; -} -*/ diff --git a/src/TNaming/TNaming_Name.lxx b/src/TNaming/TNaming_Name.lxx new file mode 100644 index 0000000000..1c4f939686 --- /dev/null +++ b/src/TNaming/TNaming_Name.lxx @@ -0,0 +1,31 @@ +// File: TNaming_Name.lxx +// Copyright: Open CASCADE 2013 +// Created on: 2013-07-03 +// Created by: Sergey Zaritchny +// Copyright (c) 1999-2013 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. +// +// 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. +// +// 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. + + +//======================================================================= +//function : Orientation +//purpose : Get +//======================================================================= + +inline const TopAbs_Orientation TNaming_Name::Orientation() const +{ + return myOrientation; +} diff --git a/src/TNaming/TNaming_NamedShape.cxx b/src/TNaming/TNaming_NamedShape.cxx index b57ccbfb6a..460781a602 100755 --- a/src/TNaming/TNaming_NamedShape.cxx +++ b/src/TNaming/TNaming_NamedShape.cxx @@ -832,30 +832,6 @@ void TNaming_Builder::Modify(const TopoDS_Shape& oldShape, } -//======================================================================= -//function : DummyShapeToStoreOrientation -//======================================================================= -static const TopoDS_Shape& DummyShapeToStoreOrientation (const TopAbs_Orientation Or) -{ - gp_Pnt aPnt(0,0,0); - static TopoDS_Vertex aVForward, aVRev; - switch(Or) { - case TopAbs_FORWARD: - if(aVForward.IsNull()) { - aVForward = BRepBuilderAPI_MakeVertex (aPnt).Vertex(); - aVForward.Orientation(TopAbs_FORWARD); - } - return aVForward; - case TopAbs_REVERSED: - if(aVRev.IsNull()) { - aVRev = BRepBuilderAPI_MakeVertex (aPnt).Vertex(); - aVRev.Orientation(TopAbs_REVERSED); - } - return aVRev; - } - return aVForward; -} - //======================================================================= //function : Select //purpose : @@ -869,24 +845,13 @@ void TNaming_Builder::Select (const TopoDS_Shape& S, Standard_ConstructionError::Raise("TNaming_Builder : not same evolution"); } - TNaming_RefShape* pos; - - if(S.ShapeType() != TopAbs_VERTEX && - (S.Orientation() == TopAbs_FORWARD || S.Orientation() == TopAbs_REVERSED)) { - const TopoDS_Shape& aV = DummyShapeToStoreOrientation (S.Orientation()); - if (!myShapes->myMap.IsBound(aV)) { - pos = new TNaming_RefShape(aV); - myShapes->myMap.Bind(aV,pos); - } else - pos = myShapes->myMap.ChangeFind(aV); - } else { - if (!myShapes->myMap.IsBound(InS)) { - pos = new TNaming_RefShape(InS); - myShapes->myMap.Bind(InS,pos); - } - else - pos = myShapes->myMap.ChangeFind(InS); + TNaming_RefShape* pos; + if (!myShapes->myMap.IsBound(InS)) { + pos = new TNaming_RefShape(InS); + myShapes->myMap.Bind(InS,pos); } + else + pos = myShapes->myMap.ChangeFind(InS); TNaming_RefShape* pns; if (!myShapes->myMap.IsBound(S)) { diff --git a/src/TNaming/TNaming_Naming.cxx b/src/TNaming/TNaming_Naming.cxx index 8c45b3716e..191dbcaf71 100755 --- a/src/TNaming/TNaming_Naming.cxx +++ b/src/TNaming/TNaming_Naming.cxx @@ -231,6 +231,7 @@ static Handle(TNaming_NamedShape) BuildNS (const TDF_Label& F, TNaming_Name& theName = Naming->ChangeName(); theName.ShapeType(S.ShapeType()); theName.Shape(S); + theName.Orientation(S.Orientation()); theName.Type(Name); TNaming_Builder B(Naming->Label()); B.Select(S,S); @@ -823,6 +824,7 @@ static Standard_Boolean Filter (const TDF_Label& F, TNaming_Name& theName = NF->ChangeName(); theName.ShapeType(S.ShapeType()); theName.Shape(S); + theName.Orientation(S.Orientation()); theName.Type(TNaming_FILTERBYNEIGHBOURGS); theName.Append(NS); theName.StopNamedShape (Until); @@ -1004,6 +1006,7 @@ static Handle(TNaming_NamedShape) BuildName (const TDF_Label& F TNaming_Name& theName = Naming->ChangeName(); theName.ShapeType(Selection.ShapeType()); theName.Shape(Selection); + theName.Orientation(Selection.Orientation()); theName.Type(Ident.Type()); #ifdef MDTV_DEB_MOD cout <<"BuildName: Inserted Naming Att at "; @@ -1124,7 +1127,8 @@ static Handle(TNaming_NamedShape) BuildName (const TDF_Label& F Naming = TNaming_Naming::Insert(F); TNaming_Name& theName = Naming->ChangeName(); theName.ShapeType(Selection.ShapeType()); - theName.Shape(Selection); //szy 21.10.03 + theName.Shape(Selection); + theName.Orientation(Selection.Orientation()); theName.Type(TNaming_GENERATION); theName.Append(TNaming_Tool::NamedShape(Selection,F)); theName.Append(NewNS); @@ -1304,7 +1308,8 @@ static Handle(TNaming_NamedShape) BuildNameWire (const TDF_Label& F.AddAttribute (Naming); TNaming_Name& theName = Naming->ChangeName(); theName.ShapeType(Selection.ShapeType()); - theName.Shape(Selection); + theName.Shape(Selection); + theName.Orientation(Selection.Orientation()); } TNaming_Name& theName = Naming->ChangeName(); @@ -1510,7 +1515,8 @@ static Handle(TNaming_NamedShape) BuildNameShell (const TDF_Label& F, F.AddAttribute (Naming); TNaming_Name& theName = Naming->ChangeName(); theName.ShapeType(Selection.ShapeType()); - theName.Shape(Selection); + theName.Shape(Selection); + theName.Orientation(Selection.Orientation()); } TNaming_Name& theName = Naming->ChangeName(); @@ -1628,6 +1634,7 @@ static void BuildAggregationName (const TDF_Label& F, TNaming_Name& theName = Naming->ChangeName(); theName.ShapeType(S.ShapeType()); theName.Shape(S); + theName.Orientation(S.Orientation()); } #ifdef MDTV_DEB_CC cout <<"BuildAggregationName ==> "; @@ -1660,7 +1667,8 @@ static void BuildAggregationName (const TDF_Label& F, Handle (TNaming_Naming) aNaming = TNaming_Naming::Insert(F); TNaming_Name& aName = aNaming->ChangeName(); aName.ShapeType(aS.ShapeType()); - aName.Shape(aS); + aName.Shape(aS); + theName.Orientation(aS.Orientation()); aName.Type(TNaming_UNION); if (atomTyp != TopAbs_SHAPE) { @@ -1742,6 +1750,7 @@ Handle(TNaming_NamedShape) TNaming_Naming::Name (const TDF_Label& F, theName.ShapeType(S.ShapeType()); theName.Shape(S); theName.Type(TNaming_ORIENTATION); + theName.Orientation(S.Orientation()); if (!TNaming_Selector::IsIdentified (F, S, NS, Geom)) NS = TNaming_Naming::Name(Naming->Label(),S,Context,Geom,0); @@ -1847,6 +1856,7 @@ Handle(TNaming_NamedShape) TNaming_Naming::Name (const TDF_Label& F, theName.ShapeType(S.ShapeType());// modified by vro 05.09.00 theName.Shape(S); + theName.Orientation(S.Orientation()); if(S.ShapeType() != TopAbs_WIRE) theName.Type(TNaming_UNION); diff --git a/src/TNaming/TNaming_NamingTool.cxx b/src/TNaming/TNaming_NamingTool.cxx index a7e408db96..cf4f49b7de 100755 --- a/src/TNaming/TNaming_NamingTool.cxx +++ b/src/TNaming/TNaming_NamingTool.cxx @@ -26,6 +26,8 @@ #include #include #include +#include +#include #ifdef DEB //#define MDTV_DEB_DESC //#define MDTV_DEB_APPLY @@ -173,11 +175,30 @@ void TNaming_NamingTool::CurrentShape(const TDF_LabelMap& Valid, Standard_Boolean YaOrientationToApply(Standard_False); TopAbs_Orientation OrientationToApply(TopAbs_FORWARD); if(Att->Evolution() == TNaming_SELECTED) { - if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX && - !itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) { - YaOrientationToApply = Standard_True; - OrientationToApply = itL.OldShape().Orientation(); - } + if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX) {//OR-N + Handle (TNaming_Naming) aNaming; + Lab.FindAttribute(TNaming_Naming::GetID(), aNaming); + if(!aNaming.IsNull()) { + if(aNaming->GetName().Type() == TNaming_ORIENTATION) { + OrientationToApply = aNaming->GetName().Orientation(); + } else { + Handle (TNaming_Naming) aNaming2; + TDF_ChildIterator it(aNaming->Label()); + for(;it.More();it.Next()) { + const TDF_Label& aLabel = it.Value(); + aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2); + if(!aNaming2.IsNull()) { + if(aNaming2->GetName().Type() == TNaming_ORIENTATION) { + OrientationToApply = aNaming2->GetName().Orientation(); + break; + } + } + } + } + if(OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED) + YaOrientationToApply = Standard_True; + } + } // } TNaming_NewShapeIterator it(itL); if (!it.More()) { diff --git a/src/TNaming/TNaming_Selector.cxx b/src/TNaming/TNaming_Selector.cxx index e897754464..0ca48c6838 100755 --- a/src/TNaming/TNaming_Selector.cxx +++ b/src/TNaming/TNaming_Selector.cxx @@ -403,7 +403,7 @@ Standard_Boolean TNaming_Selector::Select (const TopoDS_Shape& Selection, Handle(TNaming_Naming) N = new TNaming_Naming (); N->ChangeName().Type(TNaming_IDENTITY); N->ChangeName().Append(NS); - + N->ChangeName().Orientation(Selection.Orientation()); #ifdef BUC60862 // inserted by vro 06.09.00: N->ChangeName().ShapeType(Selection.ShapeType()); diff --git a/src/TNaming/TNaming_Tool.cxx b/src/TNaming/TNaming_Tool.cxx index 936b4fee5f..e7823886e3 100755 --- a/src/TNaming/TNaming_Tool.cxx +++ b/src/TNaming/TNaming_Tool.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #endif @@ -143,7 +144,6 @@ static TopoDS_Shape MakeShape (const TopTools_MapOfShape& MS) //function : GetShape //purpose : //======================================================================= - TopoDS_Shape TNaming_Tool::GetShape(const Handle(TNaming_NamedShape)& NS) { TNaming_Iterator itL (NS); @@ -151,14 +151,39 @@ TopoDS_Shape TNaming_Tool::GetShape(const Handle(TNaming_NamedShape)& NS) if(NS->Evolution() == TNaming_SELECTED) { for (; itL.More(); itL.Next()) { if(!itL.NewShape().IsNull()) { - if(itL.NewShape().ShapeType() != TopAbs_VERTEX && - !itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) { - const TopoDS_Shape& aS = itL.NewShape().Oriented(itL.OldShape().Orientation()); - MS.Add(aS); - } else - MS.Add(itL.NewShape()); - } - } + if(itL.NewShape().ShapeType() != TopAbs_VERTEX ) { //OR-N + Handle (TNaming_Naming) aNaming; + NS->Label().FindAttribute(TNaming_Naming::GetID(), aNaming); + if(!aNaming.IsNull()) { + if(aNaming->GetName().Orientation() == TopAbs_FORWARD || + aNaming->GetName().Orientation() == TopAbs_REVERSED) { + TopoDS_Shape aS = itL.NewShape(); + if(aNaming->GetName().Type() == TNaming_ORIENTATION) { + aS.Orientation(aNaming->GetName().Orientation()); + } else { + Handle (TNaming_Naming) aNaming2; + TDF_ChildIterator it(aNaming->Label()); + for(;it.More();it.Next()) { + const TDF_Label& aLabel = it.Value(); + aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2); + if(!aNaming2.IsNull()) { + if(aNaming2->GetName().Type() == TNaming_ORIENTATION) { + aS.Orientation(aNaming2->GetName().Orientation()); + break; + } + } + } + } + MS.Add(aS); + } else + MS.Add(itL.NewShape()); + } else + MS.Add(itL.NewShape()); + } // + else + MS.Add(itL.NewShape()); + } + } } else for (; itL.More(); itL.Next()) { if (!itL.NewShape().IsNull()) MS.Add(itL.NewShape()); @@ -214,15 +239,35 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const Handle(TNaming_NamedShape)& Att) for (; itL.More(); itL.Next()) { const TopoDS_Shape& S = itL.NewShape(); if (S.IsNull()) continue; +//OR-N Standard_Boolean YaOrientationToApply(Standard_False); TopAbs_Orientation OrientationToApply(TopAbs_FORWARD); if(Att->Evolution() == TNaming_SELECTED) { - if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX && - !itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) { - YaOrientationToApply = Standard_True; - OrientationToApply = itL.OldShape().Orientation(); - } - } + if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX) { + Handle (TNaming_Naming) aNaming; + Att->Label().FindAttribute(TNaming_Naming::GetID(), aNaming); + if(!aNaming.IsNull()) { + if(aNaming->GetName().Type() == TNaming_ORIENTATION) { + OrientationToApply = aNaming->GetName().Orientation(); + } else { + Handle (TNaming_Naming) aNaming2; + TDF_ChildIterator it(aNaming->Label()); + for(;it.More();it.Next()) { + const TDF_Label& aLabel = it.Value(); + aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2); + if(!aNaming2.IsNull()) { + if(aNaming2->GetName().Type() == TNaming_ORIENTATION) { + OrientationToApply = aNaming2->GetName().Orientation(); + break; + } + } + } + } + if(OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED) + YaOrientationToApply = Standard_True; + } + } + } // TNaming_NewShapeIterator it(itL); if (!it.More()) { MS.Add(S); @@ -259,15 +304,35 @@ TopoDS_Shape TNaming_Tool::CurrentShape(const Handle(TNaming_NamedShape)& Att, for (; itL.More(); itL.Next()) { const TopoDS_Shape& S = itL.NewShape(); if (S.IsNull()) continue; +//OR-N Standard_Boolean YaOrientationToApply(Standard_False); TopAbs_Orientation OrientationToApply(TopAbs_FORWARD); if(Att->Evolution() == TNaming_SELECTED) { - if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX && - !itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) { - YaOrientationToApply = Standard_True; - OrientationToApply = itL.OldShape().Orientation(); + if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX) { + Handle (TNaming_Naming) aNaming; + Att->Label().FindAttribute(TNaming_Naming::GetID(), aNaming); + if(!aNaming.IsNull()) { + if(aNaming->GetName().Type() == TNaming_ORIENTATION) { + OrientationToApply = aNaming->GetName().Orientation(); + } else { + Handle (TNaming_Naming) aNaming2; + TDF_ChildIterator it(aNaming->Label()); + for(;it.More();it.Next()) { + const TDF_Label& aLabel = it.Value(); + aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2); + if(!aNaming2.IsNull()) { + if(aNaming2->GetName().Type() == TNaming_ORIENTATION) { + OrientationToApply = aNaming2->GetName().Orientation(); + break; + } + } + } + } + if(OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED) + YaOrientationToApply = Standard_True; + } } - } + } // TNaming_NewShapeIterator it(itL); if (!it.More()) { MS.Add(S); diff --git a/src/XmlLDrivers/XmlLDrivers.cxx b/src/XmlLDrivers/XmlLDrivers.cxx index 8d4fc6f217..ebf2113025 100755 --- a/src/XmlLDrivers/XmlLDrivers.cxx +++ b/src/XmlLDrivers/XmlLDrivers.cxx @@ -40,7 +40,7 @@ static Standard_GUID XmlLStorageDriver ("13a56820-8269-11d5-aab2-0050044b1af1"); static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1"); -#define CURRENT_DOCUMENT_VERSION 6 +#define CURRENT_DOCUMENT_VERSION 7 //======================================================================= //function : Factory diff --git a/src/XmlMNaming/XmlMNaming_NamingDriver.cxx b/src/XmlMNaming/XmlMNaming_NamingDriver.cxx index 229b7e9091..f4488a6b33 100755 --- a/src/XmlMNaming/XmlMNaming_NamingDriver.cxx +++ b/src/XmlMNaming/XmlMNaming_NamingDriver.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include //======================================================================= @@ -41,6 +42,7 @@ IMPLEMENT_DOMSTRING (TypeString, "nametype") IMPLEMENT_DOMSTRING (ShapeTypeString, "shapetype") IMPLEMENT_DOMSTRING (ArgumentsString, "arguments") IMPLEMENT_DOMSTRING (ContextLabelString, "contextlabel") +IMPLEMENT_DOMSTRING (OrientString, "orientation") IMPLEMENT_DOMSTRING (NTUnknownString, "unknown") IMPLEMENT_DOMSTRING (NTIdentityString, "identity") @@ -203,6 +205,39 @@ Standard_Boolean XmlMNaming_NamingDriver::Paste else cout << "Retrieving Context Label is NULL" < 4 && XmlMNaming::DocumentVersion() < 7) { + // Orientation processing - converting from old format + Handle(TNaming_NamedShape) aNS; + if (aNg->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + //const TDF_Label& aLab = aNS->Label(); + TNaming_Iterator itL (aNS); + for (; itL.More(); itL.Next()) { + const TopoDS_Shape& S = itL.NewShape(); + if (S.IsNull()) continue; + if(aNS->Evolution() == TNaming_SELECTED) { + if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX && + !itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX ) {//OR-N + TopAbs_Orientation OrientationToApply = itL.OldShape().Orientation(); + aNgName.Orientation(OrientationToApply); + } + } + } + } + } + if(XmlMNaming::DocumentVersion() > 6) { + aDOMStr = anElem.getAttribute(::OrientString()); + if (!aDOMStr.GetInteger(aNb)) + { + aMsgString = TCollection_ExtendedString + ("XmlMNaming_NamingDriver: Cannot retrieve " + "integer value of orientation from \"") + aDOMStr + "\""; + WriteMessage (aMsgString); + return Standard_False; + } + aNgName.Orientation((TopAbs_Orientation)aNb); + } + // or. end } #ifdef DEB else if(XmlMNaming::DocumentVersion() == -1) @@ -287,6 +322,9 @@ void XmlMNaming_NamingDriver::Paste cout << "XmlMNaming_NamingDriver::Store: aDOMString is NULL" <