1 // Created on: 1997-09-17
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <MNaming_NamingRetrievalDriver.ixx>
24 #include <PNaming_Naming.hxx>
25 #include <PNaming_NamedShape.hxx>
26 #include <PNaming_HArray1OfNamedShape.hxx>
27 #include <PNaming_Name.hxx>
28 #include <TNaming_NamedShape.hxx>
29 #include <Standard_NoSuchObject.hxx>
30 #include <TNaming_Naming.hxx>
31 #include <TNaming_NameType.hxx>
32 #include <TopAbs_ShapeEnum.hxx>
33 #include <CDM_MessageDriver.hxx>
35 //=======================================================================
36 //function : IntegerToShapeEnum
38 //=======================================================================
40 static TopAbs_ShapeEnum IntegerToShapeEnum (const Standard_Integer I)
44 case 0 : return TopAbs_COMPOUND;
45 case 1 : return TopAbs_COMPSOLID;
46 case 2 : return TopAbs_SOLID;
47 case 3 : return TopAbs_SHELL;
48 case 4 : return TopAbs_FACE;
49 case 5 : return TopAbs_WIRE;
50 case 6 : return TopAbs_EDGE;
51 case 7 : return TopAbs_VERTEX;
57 //=======================================================================
58 //function : IntegerToNameType
60 //=======================================================================
62 static TNaming_NameType IntegerToNameType (const Standard_Integer I)
66 case 0 : return TNaming_UNKNOWN;
67 case 1 : return TNaming_IDENTITY;
68 case 2 : return TNaming_MODIFUNTIL;
69 case 3 : return TNaming_GENERATION;
70 case 4 : return TNaming_INTERSECTION;
71 case 5 : return TNaming_UNION;
72 case 6 : return TNaming_SUBSTRACTION;
73 case 7 : return TNaming_CONSTSHAPE;
74 case 8 : return TNaming_FILTERBYNEIGHBOURGS;
75 case 9 : return TNaming_ORIENTATION;
76 case 10: return TNaming_WIREIN;
77 case 11: return TNaming_SHELLIN;
79 Standard_DomainError::Raise("TNaming_NameType; enum term unknown ");
81 return TNaming_INTERSECTION;
84 //=======================================================================
85 //function : MNaming_Naming
87 //=======================================================================
89 MNaming_NamingRetrievalDriver::MNaming_NamingRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
93 //=======================================================================
94 //function : VersionNumber
96 //=======================================================================
98 Standard_Integer MNaming_NamingRetrievalDriver::VersionNumber() const
101 //=======================================================================
102 //function : SourceType
104 //=======================================================================
106 Handle(Standard_Type) MNaming_NamingRetrievalDriver::SourceType() const
107 { return STANDARD_TYPE(PNaming_Naming); }
110 //=======================================================================
111 //function : NewEmpty
113 //=======================================================================
115 Handle(TDF_Attribute) MNaming_NamingRetrievalDriver::NewEmpty() const
116 { return new TNaming_Naming (); }
118 //=======================================================================
119 //function : PNamingToTNaming
121 //=======================================================================
123 static void PNamingToTNaming (const Handle(PNaming_Name)& PN,
125 const Handle(MDF_RRelocationTable)& RelocTable)
128 TN.Type (IntegerToNameType (PN->Type ()));
129 TN.ShapeType(IntegerToShapeEnum(PN->ShapeType()));
130 Handle(TNaming_NamedShape) NS;
132 if (!PN->Arguments().IsNull()) {
133 Standard_Integer NbArgs = PN->Arguments()->Length();
134 for (Standard_Integer i = 1; i <= NbArgs; i++) {
135 RelocTable->HasRelocation(PN->Arguments()->Value(i),NS);
140 Handle(TNaming_NamedShape) StopNS;
141 if (!PN->StopNamedShape().IsNull())
142 RelocTable->HasRelocation(PN->StopNamedShape(),StopNS);
143 TN.StopNamedShape(StopNS);
144 TN.Index(PN->Index());
147 //=======================================================================
150 //=======================================================================
152 void MNaming_NamingRetrievalDriver::Paste (
153 const Handle(PDF_Attribute)& Source,
154 const Handle(TDF_Attribute)& Target,
155 const Handle(MDF_RRelocationTable)& RelocTable) const
157 //MDesign_FunctionRetrievalDriver::Paste (Source,Target,RelocTable);
158 Handle(PNaming_Naming) PF = Handle(PNaming_Naming)::DownCast(Source);
159 Handle(TNaming_Naming) F = Handle(TNaming_Naming)::DownCast(Target);
160 PNamingToTNaming (PF->GetName(),F->ChangeName(),RelocTable);