0023766: Shape orientation processing mechanism redesign
authorszy <szy@opencascade.com>
Thu, 15 Aug 2013 11:36:08 +0000 (15:36 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 15 Aug 2013 13:23:43 +0000 (17:23 +0400)
Added missed file.
Added missed MDF_Tool.cxx.
Adding test cases for issue CR23766

31 files changed:
src/BinLDrivers/BinLDrivers.cxx
src/BinMNaming/BinMNaming_NamingDriver.cxx
src/MDF/MDF_Tool.cxx
src/MNaming/MNaming.cdl
src/MNaming/MNaming.cxx
src/MNaming/MNaming_NamingRetrievalDriver_1.cxx
src/MNaming/MNaming_NamingRetrievalDriver_2.cdl [new file with mode: 0644]
src/MNaming/MNaming_NamingRetrievalDriver_2.cxx [new file with mode: 0644]
src/MNaming/MNaming_NamingStorageDriver.cxx
src/PNaming/PNaming.cdl
src/PNaming/PNaming_Name_2.cdl [new file with mode: 0644]
src/PNaming/PNaming_Name_2.cxx [new file with mode: 0644]
src/PNaming/PNaming_Name_2.lxx [new file with mode: 0644]
src/PNaming/PNaming_Naming_2.cdl [new file with mode: 0644]
src/PNaming/PNaming_Naming_2.cxx [new file with mode: 0644]
src/TNaming/TNaming_Name.cdl
src/TNaming/TNaming_Name.cxx
src/TNaming/TNaming_Name.lxx [new file with mode: 0644]
src/TNaming/TNaming_NamedShape.cxx
src/TNaming/TNaming_Naming.cxx
src/TNaming/TNaming_NamingTool.cxx
src/TNaming/TNaming_Selector.cxx
src/TNaming/TNaming_Tool.cxx
src/XmlLDrivers/XmlLDrivers.cxx
src/XmlMNaming/XmlMNaming_NamingDriver.cxx
tests/bugs/caf/bug23766_1 [new file with mode: 0755]
tests/bugs/caf/bug23766_2 [new file with mode: 0755]
tests/bugs/caf/bug23766_3 [new file with mode: 0755]
tests/bugs/caf/bug23766_4 [new file with mode: 0755]
tests/bugs/caf/bug23766_5 [new file with mode: 0755]
tests/bugs/caf/bug23766_6 [new file with mode: 0755]

index 7b16bb01067003543c436b01d91114cb5255ab14..487ccca6dd2bc464cc58d10d86e7e8c34c34319c 100755 (executable)
@@ -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
index 9484c8d58cebf03c9d97eb609e22b50e552bd589..c61a156373cb45f20215e7bbaef00d54582729df 100755 (executable)
@@ -26,6 +26,7 @@
 #include <TColStd_Array1OfInteger.hxx>
 #include <CDM_MessageDriver.hxx>
 #include <TDF_Attribute.hxx>
+#include  <TNaming_Iterator.hxx>
 #include <TNaming_NameType.hxx>
 #include <TNaming_Naming.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -237,12 +238,12 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
                                           "Cannot retrieve reference on "
                                           "Arguments of Name");
        WriteMessage (aMsg);
-      }
+         }
 
 #ifdef DEB
       //cout << "CurDocVersion = " << BinMNaming::DocumentVersion() <<endl;
 #endif
-      if(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()  <<endl;
+#endif
+         } else {
+          aMsg = TCollection_ExtendedString("BinMNaming_NamingDriver: "
+                                            "Cannot retrieve Name Orientation ");
+         WriteMessage (aMsg);
+         }
+       }
+       }
 #ifdef DEB
       else if(BinMNaming::DocumentVersion() == -1)
        cout << "Current DocVersion field is not initialized. "  <<endl;
       else 
        cout << "Current DocVersion = " << BinMNaming::DocumentVersion() <<endl;
 #endif
-    }
+       }
   }
   return ok;
 }
@@ -332,4 +367,8 @@ void BinMNaming_NamingDriver::Paste (const Handle(TDF_Attribute)&  theSource,
   if(!aName.ContextLabel().IsNull())
     TDF_Tool::Entry(aName.ContextLabel(), entry);
   theTarget << entry;
+
+//7. keep Orientation
+  theTarget << (Standard_Integer)aName.Orientation();
+
 }
index 92bf22ec82a461b4414ff4199f42be82ca667434..84652b8627da31023d06ae644f19394c8649254a 100755 (executable)
 #define DeclareConstAndSpeedCast(V,T,Vdown) const Handle(T)& Vdown = (Handle(T)&) V
 #define SpeedCast(V,T,Vdown) Vdown = *((Handle(T)*)& V)
 
+#include <NCollection_List.hxx>
+typedef struct {
+       Handle(PDF_Attribute) pAtt;
+       Handle(TDF_Attribute) tAtt;
+} ATTR;
+typedef NCollection_List<ATTR> MDF_AttributeList;
+typedef MDF_AttributeList::Iterator MDF_ListIteratorOfAttributeList;
+
 #undef DEB_MDF_TOOL
 
 // Persistent structure:
@@ -364,7 +372,7 @@ void MDF_Tool::ReadLabels
 //purpose  : PERSISTENT -> TRANSIENT
 //           Reads the persistent attributes content.
 //=======================================================================
-
+//#define DEB_ORIENT
 void MDF_Tool::ReadAttributes
 (const MDF_TypeARDriverMap& aDriverMap,
  const Handle(MDF_RRelocationTable)& aReloc) 
@@ -374,18 +382,50 @@ void MDF_Tool::ReadAttributes
   const PTColStd_PersistentTransientMap& attMap = aReloc->AttributeTable();
   PTColStd_DataMapIteratorOfPersistentTransientMap itr(attMap);
   Handle(TDF_Attribute) tAtt;
+  MDF_AttributeList attNList;
+  Standard_Boolean isName1(Standard_False);
+  ATTR pairAtt;
   for ( ; itr.More(); itr.Next()) {
     DeclareConstAndSpeedCast(itr.Key(),PDF_Attribute,pAtt);
     if (!pAtt.IsNull()) { // See above...
       const Handle(Standard_Type)& type = pAtt->DynamicType();
+         
+         if(!strcmp (type->Name(), "PNaming_Naming_1") ) {
+#ifdef DEB_ORIENT
+                 cout << "TYPE = " << type->Name() << endl;
+#endif
+                 isName1 = Standard_True;
+         } else isName1 = Standard_False;
+
       if (aDriverMap.IsBound(type)) {
-       SpeedCast(itr.Value(),TDF_Attribute,tAtt);
-       const Handle(MDF_ARDriver)& driver = aDriverMap.Find(type);
-       driver->Paste(pAtt, tAtt, aReloc);
+           SpeedCast(itr.Value(),TDF_Attribute,tAtt);
+           const Handle(MDF_ARDriver)& driver = aDriverMap.Find(type);
+               if(isName1) {
+                 pairAtt.pAtt = pAtt;
+                 pairAtt.tAtt = tAtt;
+                 attNList.Append(pairAtt);
+               }
+               else 
+             driver->Paste(pAtt, tAtt, aReloc);
       }
     }
   }
 
+// post processing for compartibiliy with previous versions (24.07.2013)
+  if(attNList.Extent()) {
+    MDF_ListIteratorOfAttributeList listIt(attNList);
+       for(;listIt.More();listIt.Next()) {
+               const  Handle(PDF_Attribute)& pAtt = listIt.Value().pAtt;
+               if (!pAtt.IsNull()) { 
+          const Handle(Standard_Type)& type = pAtt->DynamicType();
+                 if (aDriverMap.IsBound(type)) {               
+               const Handle(MDF_ARDriver)& driver = aDriverMap.Find(type);             
+               driver->Paste(pAtt, listIt.Value().tAtt, aReloc);
+                 }
+               }
+       }
+  }
+//
   TDF_AttributeList attList;
   for (itr.Initialize(attMap); itr.More(); itr.Next()) {
     SpeedCast(itr.Value(),TDF_Attribute,tAtt);
index 1b9dcaf004af63982affa10afaf96f11631e78ee..260b15f7c83dee2cd5aadec51d3ce050d44ddb9c 100755 (executable)
@@ -38,7 +38,10 @@ is
 
     class NamingRetrievalDriver_1;   
     --  New fields added
-    
+
+    class NamingRetrievalDriver_2;   
+    --  New fields added
+
     class NamedShapeStorageDriver;   
 
     class NamingStorageDriver;
index 527e3432e177b8c24dd92c786ce51c851eddc389..9fead00818a6f0515285d150d390da9af1a5c48d 100755 (executable)
@@ -32,6 +32,7 @@
 #include <MNaming_NamingStorageDriver.hxx>
 #include <MNaming_NamingRetrievalDriver.hxx>
 #include <MNaming_NamingRetrievalDriver_1.hxx>
+#include <MNaming_NamingRetrievalDriver_2.hxx>
 #include <CDM_MessageDriver.hxx>
 
 //=======================================================================
@@ -58,4 +59,5 @@ void MNaming::AddRetrievalDrivers
   aDriverSeq->Append(new MNaming_NamedShapeRetrievalDriver(theMsgDriver)); 
   aDriverSeq->Append(new MNaming_NamingRetrievalDriver(theMsgDriver));
   aDriverSeq->Append(new MNaming_NamingRetrievalDriver_1(theMsgDriver));
+  aDriverSeq->Append(new MNaming_NamingRetrievalDriver_2(theMsgDriver));
 }
index 48971bdd30c86a4fb577fda4533da5197669b106..d27de9c3faa67934e6723278ad58d93653d1d276 100755 (executable)
@@ -31,6 +31,7 @@
 #include <Standard_NoSuchObject.hxx>
 #include <TNaming_Naming.hxx>
 #include <TNaming_NameType.hxx>
+#include <TNaming_Iterator.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 #include <CDM_MessageDriver.hxx>
 
@@ -51,9 +52,10 @@ static TopAbs_ShapeEnum IntegerToShapeEnum (const Standard_Integer I)
     case  5 : return TopAbs_WIRE;
     case  6 : return TopAbs_EDGE;
     case  7 : return TopAbs_VERTEX;
-      default : 
-        return TopAbs_SHAPE;
+      default :
+       return TopAbs_SHAPE;
     }
+  return TopAbs_SHAPE;
 }
 
 //=======================================================================
@@ -77,7 +79,7 @@ static  TNaming_NameType IntegerToNameType (const Standard_Integer I)
     case  9 : return TNaming_ORIENTATION;
     case  10 : return TNaming_WIREIN;
       default :
-        Standard_DomainError::Raise("TNaming_NameType; enum term unknown ");
+       Standard_DomainError::Raise("TNaming_NameType; enum term unknown ");
     }
   return TNaming_INTERSECTION;
 }
@@ -161,14 +163,42 @@ static void PNamingToTNaming (const Handle(PNaming_Name_1)& PN,
 //function : Paste
 //purpose  : 
 //=======================================================================
-
+//#define DEB_ORIENT
 void MNaming_NamingRetrievalDriver_1::Paste (
   const Handle(PDF_Attribute)&        Source,
   const Handle(TDF_Attribute)&        Target,
   const Handle(MDF_RRelocationTable)& RelocTable) const
 {
   Handle(PNaming_Naming_1) PF = Handle(PNaming_Naming_1)::DownCast(Source);
-  Handle(TNaming_Naming) F  = Handle(TNaming_Naming)::DownCast(Target);  
+  Handle(TNaming_Naming) F  = Handle(TNaming_Naming)::DownCast(Target); 
   PNamingToTNaming (PF->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 = " <<aNS->Evolution() << " IsEmpty = " << aNS->IsEmpty() <<endl;
+#endif
+       if(!aNS->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 <<endl;
+#endif 
+            F->ChangeName().Orientation(OrientationToApply);
+          }
+        }
+      }
+       }
+  }
+  // 
 }
 
diff --git a/src/MNaming/MNaming_NamingRetrievalDriver_2.cdl b/src/MNaming/MNaming_NamingRetrievalDriver_2.cdl
new file mode 100644 (file)
index 0000000..8fa5b9c
--- /dev/null
@@ -0,0 +1,53 @@
+-- Created on: 2008-08-15
+-- Created by: Sergey ZARITCHNY <szy@opencascade.com>
+-- 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 (file)
index 0000000..b3c9e8c
--- /dev/null
@@ -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 <MNaming_NamingRetrievalDriver_2.ixx>
+#include <PNaming_Naming_2.hxx>
+#include <PNaming_NamedShape.hxx>
+#include <PNaming_HArray1OfNamedShape.hxx>
+#include <PNaming_Name_2.hxx>
+#include <PCollection_HAsciiString.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Tool.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <Standard_NoSuchObject.hxx>
+#include <TNaming_Naming.hxx>
+#include <TNaming_NameType.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <CDM_MessageDriver.hxx>
+
+//=======================================================================
+//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);
+}
+
index 5836c08b3f5ef36a68337c6e23ea8cdb9106b4c6..11c55baee88bb476528911a72b1669f58bf07a25 100755 (executable)
 
 
 #include <MNaming_NamingStorageDriver.ixx>
-#include <PNaming_Naming_1.hxx>
+#include <PNaming_Naming_2.hxx>
 #include <PCollection_HAsciiString.hxx>
 #include <Standard_NoSuchObject.hxx>
 #include <TDF_Tool.hxx>
 #include <TNaming_Naming.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TNaming_Name.hxx>
-#include <PNaming_Name_1.hxx>
+#include <PNaming_Name_2.hxx>
 #include <PNaming_NamedShape.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_ListOfNamedShape.hxx>
 #include <TNaming_ListIteratorOfListOfNamedShape.hxx>
 #include <CDM_MessageDriver.hxx>
 #include <PNaming_HArray1OfNamedShape.hxx>
+#include <TopAbs_Orientation.hxx>
 
 //=======================================================================
-//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);
 }
index 97271bae4d4dbbab6c2ada9208cdff94fe27af10..1ab6fa296a241372c7b2fe37726bc1a4a8ec5d8d 100755 (executable)
@@ -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 (file)
index 0000000..f847e60
--- /dev/null
@@ -0,0 +1,84 @@
+-- Created on: 2008-08-15
+-- Created by: Sergey ZARITCHNY <szy@opencascade.com>
+-- 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 (file)
index 0000000..310f0af
--- /dev/null
@@ -0,0 +1,32 @@
+// Created on: 2008-08-15
+// Created by: Sergey ZARITCHNY <szy@op
+// 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 <PNaming_Name_2.ixx>
+
+//=======================================================================
+//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 (file)
index 0000000..aceb49a
--- /dev/null
@@ -0,0 +1,62 @@
+// Created on: 2008-08-15
+// Created by: Sergey ZARITCHNY <szy@op
+// 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.
+
+
+
+inline   void PNaming_Name_2::Type(const Standard_Integer T) 
+{myType = T;}
+
+inline   void PNaming_Name_2::ShapeType(const Standard_Integer T) 
+{myShapeType = T;}
+
+inline   void PNaming_Name_2::Arguments(const Handle(PNaming_HArray1OfNamedShape)& Args)
+{myArgs = Args;}
+
+inline   void PNaming_Name_2::StopNamedShape(const Handle(PNaming_NamedShape)& NS)
+{myStop = NS;}
+
+inline   void PNaming_Name_2::Index(const Standard_Integer I) 
+{myIndex = I;}
+
+inline   Standard_Integer PNaming_Name_2::Type() const
+{return myType;}
+
+inline   Standard_Integer PNaming_Name_2::ShapeType() const 
+{return myShapeType;}
+
+inline   Handle_PNaming_HArray1OfNamedShape PNaming_Name_2::Arguments() const
+{return myArgs;}
+
+inline   Handle_PNaming_NamedShape PNaming_Name_2::StopNamedShape() const
+{return myStop;}
+
+inline   Standard_Integer PNaming_Name_2::Index() const
+{return myIndex;}
+
+inline  void PNaming_Name_2::ContextLabel(const Handle(PCollection_HAsciiString)& theLabel)
+{myContextLabel = theLabel;}
+
+inline   const Handle(PCollection_HAsciiString)& PNaming_Name_2::ContextLabel() const 
+{return myContextLabel;}
+
+inline   void PNaming_Name_2::Orientation(const Standard_Integer Or) 
+{myOrientation = Or;}
+
+inline   Standard_Integer PNaming_Name_2::Orientation() const 
+{return myOrientation;}
\ No newline at end of file
diff --git a/src/PNaming/PNaming_Naming_2.cdl b/src/PNaming/PNaming_Naming_2.cdl
new file mode 100644 (file)
index 0000000..3fe8686
--- /dev/null
@@ -0,0 +1,40 @@
+-- Created on: 2008-08-15
+-- Created by: Sergey ZARITCHNY <szy@opencascade.com>
+-- 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 (file)
index 0000000..605ec39
--- /dev/null
@@ -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 <PNaming_Naming_2.ixx>
+
+//=======================================================================
+//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;
+}
index 47876301ebb75335f5e95a52dd9e0cd38a33e1d4..60370b2b8de33fb53875526088f09d3ab7eb9344 100755 (executable)
@@ -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;
index 1def7712eadbec47d17fc66d7e38e128416fbdde..5a76e601cfce84cb784e826bedf4c98835e4e188 100755 (executable)
@@ -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 (file)
index 0000000..1c4f939
--- /dev/null
@@ -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;
+}
index b57ccbfb6a9a7ddd8a0f70c07c5979ade67d0bff..460781a602f31ef49064d1bce6fa164d9d9ad993 100755 (executable)
@@ -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)) {
index 8c45b3716e349320392b6bb900fac54c9086f022..191dbcaf71266cd4ddc6e8f1a627e2a5c7f0974e 100755 (executable)
@@ -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);
 
index a7e408db961202536f5e8996883b3ed3e2f4c839..cf4f49b7de9e65175b1e3ea179f3663a11244126 100755 (executable)
@@ -26,6 +26,8 @@
 #include <TopTools_MapIteratorOfMapOfShape.hxx>
 #include <TNaming_OldShapeIterator.hxx>
 #include <TNaming_Tool.hxx>
+#include <TNaming_Naming.hxx>
+#include <TDF_ChildIterator.hxx>
 #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()) {
index e8977544648ddf996a287adc0995f852dd71bae7..0ca48c68385c7a799b63cc40bd72019394f379bb 100755 (executable)
@@ -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());
index 936b4fee5f24ad942fd465e003ea60d0c739e9c2..e7823886e33fb5d8de9a900d845119ef8e53ad6e 100755 (executable)
@@ -41,6 +41,7 @@
 #include <TDF_AttributeMap.hxx>
 #include <TDF_Tool.hxx>
 #include <TDF_MapIteratorOfAttributeMap.hxx>
+#include <TDF_ChildIterator.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TNaming_ListIteratorOfListOfNamedShape.hxx>
 #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);
index 8d4fc6f21751f3bb95c2840716d47b7d86b2238c..ebf2113025f2fb89a857c6321d72e79c9a72850d 100755 (executable)
@@ -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
index 229b7e9091adc7aef4208d0de85e1b4d7a2469d4..f4488a6b33984400ca6584a82ae619df00602912 100755 (executable)
@@ -26,6 +26,7 @@
 #include <TNaming_Naming.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_ListIteratorOfListOfNamedShape.hxx>
+#include <TNaming_Iterator.hxx>
 #include <TDF_Tool.hxx>
 
 //=======================================================================
@@ -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" <<endl;
 #endif
+
+    if(XmlMNaming::DocumentVersion() > 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" <<endl;
 #endif
 
+  // orientation
+  anElem.setAttribute(::OrientString(), (Standard_Integer)aNgName.Orientation());
+
 }
 
 //=======================================================================
diff --git a/tests/bugs/caf/bug23766_1 b/tests/bugs/caf/bug23766_1
new file mode 100755 (executable)
index 0000000..166ff12
--- /dev/null
@@ -0,0 +1,32 @@
+puts "==========="
+puts "OCC23766"
+puts "==========="
+puts ""
+############################################################
+# Shape orientation processing mechanism redesign
+############################################################
+
+# test to check compatibility of old cbf format
+
+Open [locate_data_file bug23766_ttt1_old.cbf] D
+
+GetShape D 0:1:2:1:2 E1
+set info1 [whatis E1]
+
+## to be FORWARD:
+if { [regexp "FORWARD" $info1] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info2 [whatis E2]
+
+## to be REVERSED:
+if { [regexp "REVERSED" $info2] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}
+
diff --git a/tests/bugs/caf/bug23766_2 b/tests/bugs/caf/bug23766_2
new file mode 100755 (executable)
index 0000000..65245b3
--- /dev/null
@@ -0,0 +1,31 @@
+puts "==========="
+puts "OCC23766"
+puts "==========="
+puts ""
+############################################################
+# Shape orientation processing mechanism redesign
+############################################################
+
+# test to check compatibility of old std format
+
+Open [locate_data_file bug23766_ttt1_old.std] D
+
+GetShape D 0:1:2:1:2 E1
+set info1 [whatis E1]
+
+## to be FORWARD:
+if { [regexp "FORWARD" $info1] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info2 [whatis E2]
+
+## to be REVERSED:
+if { [regexp "REVERSED" $info2] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}
diff --git a/tests/bugs/caf/bug23766_3 b/tests/bugs/caf/bug23766_3
new file mode 100755 (executable)
index 0000000..f6fe29e
--- /dev/null
@@ -0,0 +1,31 @@
+puts "==========="
+puts "OCC23766"
+puts "==========="
+puts ""
+############################################################
+# Shape orientation processing mechanism redesign
+############################################################
+
+# test to check compatibility of old xml format
+
+Open [locate_data_file bug23766_ttt1_old.xml] D
+
+GetShape D 0:1:2:1:2 E1
+set info1 [whatis E1]
+
+## to be FORWARD:
+if { [regexp "FORWARD" $info1] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info2 [whatis E2]
+
+## to be REVERSED:
+if { [regexp "REVERSED" $info2] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}
diff --git a/tests/bugs/caf/bug23766_4 b/tests/bugs/caf/bug23766_4
new file mode 100755 (executable)
index 0000000..cb460fa
--- /dev/null
@@ -0,0 +1,77 @@
+puts "=========="
+puts "OCC23766"
+puts "=========="
+puts ""
+########################################################
+# Shape orientation processing mechanis, redesign
+########################################################
+
+## test for keeping Orientation (cbf)
+
+erase
+NewDocument D BinOcaf
+
+#1 - create box
+NewCommand D
+set B2 [AddObject D];                  ## add object
+set F2 [AddFunction D $B2 Box];                ## add function
+BoxDX D $B2 190;                       ## set argumets of this function
+BoxDY D $B2 290
+BoxDZ D $B2 390
+InitLogBook D;                         ## initialize (clean) internal maps of labels
+AddDriver D Box Attach         
+ComputeFun D $F2;                      ## compute the function
+GetShape D $F2:2 Box2;                 ## check result
+
+#2 - make selections keeping orientation
+explode Box2 F
+explode Box2_1 E
+explode Box2_3 E
+don Box2_1_1 Box2_3_4
+set Sel1 [AttachShape D Box2_1_1 ${B2} ${B2} 1]; ## set attachment
+set Sel2 [AttachShape D Box2_3_4 ${B2} ${B2} 1]; ## set attachment
+
+#3 - check orientation of the selected shapes
+GetShape D 0:1:2:1:2 E1
+set info1 [whatis E1]
+## to be: E1 is a shape EDGE FORWARD Modified Orientable
+if { [regexp "FORWARD" $info1] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info2 [whatis E2]
+## to be: E2 is a shape EDGE REVERSED Modified Orientable
+if { [regexp "REVERSED" $info2] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}
+
+#4 -  test persistence: check orientation after retrieving (to be the same as before)
+file delete -force ${imagedir}/bug23766_ttt1.cbf
+NewCommand D
+SaveAs D ${imagedir}/bug23766_ttt1.cbf
+Close D
+##unset D
+Open ${imagedir}/bug23766_ttt1.cbf D
+GetShape D 0:1:2:1:2 E1
+set info3 [whatis E1]
+## to be: E1 is a shape EDGE FORWARD Modified Orientable
+if { [regexp "FORWARD" $info3] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info4 [whatis E2]
+## to be: E2 is a shape EDGE REVERSED Modified Orientable
+if { [regexp "REVERSED" $info4] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}
+
diff --git a/tests/bugs/caf/bug23766_5 b/tests/bugs/caf/bug23766_5
new file mode 100755 (executable)
index 0000000..643dbe0
--- /dev/null
@@ -0,0 +1,75 @@
+puts "=========="
+puts "OCC23766"
+puts "=========="
+puts ""
+########################################################
+# Shape orientation processing mechanis, redesign
+########################################################
+
+## test for keeping Orientation (std)
+
+erase
+NewDocument D MDTV-Standard
+#1 - create box
+NewCommand D
+set B2 [AddObject D];                  ## add object
+set F2 [AddFunction D $B2 Box];                ## add function
+BoxDX D $B2 190;                       ## set argumets of this function
+BoxDY D $B2 290
+BoxDZ D $B2 390
+InitLogBook D;                         ## initialize (clean) internal maps of labels
+AddDriver D Box Attach         
+ComputeFun D $F2;                      ## compute the function
+GetShape D $F2:2 Box2;                 ## check result
+
+#2 - make selections keeping orientation
+explode Box2 F
+explode Box2_1 E
+explode Box2_3 E
+don Box2_1_1 Box2_3_4
+set Sel1 [AttachShape D Box2_1_1 ${B2} ${B2} 1]; ## set attachment keeping orientation of the edge
+set Sel2 [AttachShape D Box2_3_4 ${B2} ${B2} 1]; ## set attachment keeping orientation of the edge
+
+#3 - check orientation of the selected shapes
+GetShape D 0:1:2:1:2 E1
+set info1 [whatis E1]
+## to be: E1 is a shape EDGE FORWARD Modified Orientable
+if { [regexp "FORWARD" $info1] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info2 [whatis E2]
+## to be: E2 is a shape EDGE REVERSED Modified Orientable
+if { [regexp "REVERSED" $info2] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}
+
+#4 -  test persistence: check orientation after retrieving (to be the same as before)
+file delete -force ${imagedir}/bug23766_ttt1.std
+NewCommand D
+SaveAs D ${imagedir}/bug23766_ttt1.std
+Close D
+##unset D
+Open ${imagedir}/bug23766_ttt1.std D
+GetShape D 0:1:2:1:2 E1
+set info3 [whatis E1]
+## to be: E1 is a shape EDGE FORWARD Modified Orientable
+if { [regexp "FORWARD" $info3] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info4 [whatis E2]
+## to be: E2 is a shape EDGE REVERSED Modified Orientable
+if { [regexp "REVERSED" $info4] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}
diff --git a/tests/bugs/caf/bug23766_6 b/tests/bugs/caf/bug23766_6
new file mode 100755 (executable)
index 0000000..7a6e433
--- /dev/null
@@ -0,0 +1,76 @@
+puts "=========="
+puts "OCC23766"
+puts "=========="
+puts ""
+########################################################
+# Shape orientation processing mechanis, redesign
+########################################################
+
+## test for keeping Orientation (xml)
+
+erase
+NewDocument D XmlOcaf
+
+#1 - create box
+NewCommand D
+set B2 [AddObject D];                  ## add object
+set F2 [AddFunction D $B2 Box];                ## add function
+BoxDX D $B2 190;                       ## set argumets of this function
+BoxDY D $B2 290
+BoxDZ D $B2 390
+InitLogBook D;                         ## initialize (clean) internal maps of labels
+AddDriver D Box Attach 
+ComputeFun D $F2;                      ## compute the function
+GetShape D $F2:2 Box2;                 ## check result
+
+#2 - make selections keeping orientation
+explode Box2 F
+explode Box2_1 E
+explode Box2_3 E
+don Box2_1_1 Box2_3_4
+set Sel1 [AttachShape D Box2_1_1 ${B2} ${B2} 1]; ## set attachment
+set Sel2 [AttachShape D Box2_3_4 ${B2} ${B2} 1]; ## set attachment
+
+#3 - check orientation of the selected shapes
+GetShape D 0:1:2:1:2 E1
+set info1 [whatis E1]
+## to be: E1 is a shape EDGE FORWARD Modified Orientable
+if { [regexp "FORWARD" $info1] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info2 [whatis E2]
+## to be: E2 is a shape EDGE REVERSED Modified Orientable
+if { [regexp "REVERSED" $info2] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}
+
+#4 -  test persistence: check orientation after retrieving (to be the same as before)
+file delete -force ${imagedir}/bug23766_ttt1.xml
+NewCommand D
+SaveAs D ${imagedir}/bug23766_ttt1.xml
+Close D
+##unset D
+Open ${imagedir}/bug23766_ttt1.xml D
+GetShape D 0:1:2:1:2 E1
+set info3 [whatis E1]
+## to be: E1 is a shape EDGE FORWARD Modified Orientable
+if { [regexp "FORWARD" $info3] != 1 } {
+    puts "Error: orientation of E1 is incorrect"
+} else {
+    puts "OK: orientation of E1 is correct"
+}
+
+GetShape D 0:1:3:1:2 E2
+set info4 [whatis E2]
+## to be: E2 is a shape EDGE REVERSED Modified Orientable
+if { [regexp "REVERSED" $info4] != 1 } {
+    puts "Error: orientation of E2 is incorrect"
+} else {
+    puts "OK: orientation of E2 is correct"
+}