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;
58 //=======================================================================
59 //function : IntegerToNameType
61 //=======================================================================
63 static TNaming_NameType IntegerToNameType (const Standard_Integer I)
67 case 0 : return TNaming_UNKNOWN;
68 case 1 : return TNaming_IDENTITY;
69 case 2 : return TNaming_MODIFUNTIL;
70 case 3 : return TNaming_GENERATION;
71 case 4 : return TNaming_INTERSECTION;
72 case 5 : return TNaming_UNION;
73 case 6 : return TNaming_SUBSTRACTION;
74 case 7 : return TNaming_CONSTSHAPE;
75 case 8 : return TNaming_FILTERBYNEIGHBOURGS;
76 case 9 : return TNaming_ORIENTATION;
77 case 10: return TNaming_WIREIN;
78 case 11: return TNaming_SHELLIN;
80 Standard_DomainError::Raise("TNaming_NameType; enum term unknown ");
82 return TNaming_INTERSECTION;
85 //=======================================================================
86 //function : MNaming_Naming
88 //=======================================================================
90 MNaming_NamingRetrievalDriver::MNaming_NamingRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
94 //=======================================================================
95 //function : VersionNumber
97 //=======================================================================
99 Standard_Integer MNaming_NamingRetrievalDriver::VersionNumber() const
102 //=======================================================================
103 //function : SourceType
105 //=======================================================================
107 Handle(Standard_Type) MNaming_NamingRetrievalDriver::SourceType() const
108 { return STANDARD_TYPE(PNaming_Naming); }
111 //=======================================================================
112 //function : NewEmpty
114 //=======================================================================
116 Handle(TDF_Attribute) MNaming_NamingRetrievalDriver::NewEmpty() const
117 { return new TNaming_Naming (); }
119 //=======================================================================
120 //function : PNamingToTNaming
122 //=======================================================================
124 static void PNamingToTNaming (const Handle(PNaming_Name)& PN,
126 const Handle(MDF_RRelocationTable)& RelocTable)
129 TN.Type (IntegerToNameType (PN->Type ()));
130 TN.ShapeType(IntegerToShapeEnum(PN->ShapeType()));
131 Handle(TNaming_NamedShape) NS;
133 if (!PN->Arguments().IsNull()) {
134 Standard_Integer NbArgs = PN->Arguments()->Length();
135 for (Standard_Integer i = 1; i <= NbArgs; i++) {
136 RelocTable->HasRelocation(PN->Arguments()->Value(i),NS);
141 Handle(TNaming_NamedShape) StopNS;
142 if (!PN->StopNamedShape().IsNull())
143 RelocTable->HasRelocation(PN->StopNamedShape(),StopNS);
144 TN.StopNamedShape(StopNS);
145 TN.Index(PN->Index());
148 //=======================================================================
151 //=======================================================================
153 void MNaming_NamingRetrievalDriver::Paste (
154 const Handle(PDF_Attribute)& Source,
155 const Handle(TDF_Attribute)& Target,
156 const Handle(MDF_RRelocationTable)& RelocTable) const
158 //MDesign_FunctionRetrievalDriver::Paste (Source,Target,RelocTable);
159 Handle(PNaming_Naming) PF = Handle(PNaming_Naming)::DownCast(Source);
160 Handle(TNaming_Naming) F = Handle(TNaming_Naming)::DownCast(Target);
161 PNamingToTNaming (PF->GetName(),F->ChangeName(),RelocTable);