0025923: Remove small wires on face read from STEP
[occt.git] / src / MNaming / MNaming_NamingRetrievalDriver.cxx
CommitLineData
b311480e 1// Created on: 1997-09-17
2// Created by: Isabelle GRIGNON
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <MNaming_NamingRetrievalDriver.ixx>
18#include <PNaming_Naming.hxx>
19#include <PNaming_NamedShape.hxx>
20#include <PNaming_HArray1OfNamedShape.hxx>
21#include <PNaming_Name.hxx>
22#include <TNaming_NamedShape.hxx>
23#include <Standard_NoSuchObject.hxx>
24#include <TNaming_Naming.hxx>
25#include <TNaming_NameType.hxx>
26#include <TopAbs_ShapeEnum.hxx>
27#include <CDM_MessageDriver.hxx>
28
29//=======================================================================
30//function : IntegerToShapeEnum
31//purpose :
32//=======================================================================
33
34static TopAbs_ShapeEnum IntegerToShapeEnum (const Standard_Integer I)
35{
36 switch(I)
37 {
38 case 0 : return TopAbs_COMPOUND;
39 case 1 : return TopAbs_COMPSOLID;
40 case 2 : return TopAbs_SOLID;
41 case 3 : return TopAbs_SHELL;
42 case 4 : return TopAbs_FACE;
43 case 5 : return TopAbs_WIRE;
44 case 6 : return TopAbs_EDGE;
45 case 7 : return TopAbs_VERTEX;
d3f26155 46 default :
47 return TopAbs_SHAPE;
7fd59977 48 }
7fd59977 49}
50
51//=======================================================================
52//function : IntegerToNameType
53//purpose :
54//=======================================================================
55
56static TNaming_NameType IntegerToNameType (const Standard_Integer I)
57{
58 switch(I)
59 {
60 case 0 : return TNaming_UNKNOWN;
61 case 1 : return TNaming_IDENTITY;
62 case 2 : return TNaming_MODIFUNTIL;
63 case 3 : return TNaming_GENERATION;
64 case 4 : return TNaming_INTERSECTION;
65 case 5 : return TNaming_UNION;
66 case 6 : return TNaming_SUBSTRACTION;
67 case 7 : return TNaming_CONSTSHAPE;
68 case 8 : return TNaming_FILTERBYNEIGHBOURGS;
1ec8a59e 69 case 9 : return TNaming_ORIENTATION;
70 case 10: return TNaming_WIREIN;
71 case 11: return TNaming_SHELLIN;
7fd59977 72 default :
73 Standard_DomainError::Raise("TNaming_NameType; enum term unknown ");
74 }
75 return TNaming_INTERSECTION;
76}
77
78//=======================================================================
79//function : MNaming_Naming
80//purpose :
81//=======================================================================
82
83MNaming_NamingRetrievalDriver::MNaming_NamingRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
84{
85}
86
87//=======================================================================
88//function : VersionNumber
89//purpose :
90//=======================================================================
91
92Standard_Integer MNaming_NamingRetrievalDriver::VersionNumber() const
93{ return 0; }
94
95//=======================================================================
96//function : SourceType
97//purpose :
98//=======================================================================
99
100Handle(Standard_Type) MNaming_NamingRetrievalDriver::SourceType() const
101{ return STANDARD_TYPE(PNaming_Naming); }
102
103
104//=======================================================================
105//function : NewEmpty
106//purpose :
107//=======================================================================
108
109Handle(TDF_Attribute) MNaming_NamingRetrievalDriver::NewEmpty() const
110{ return new TNaming_Naming (); }
111
112//=======================================================================
113//function : PNamingToTNaming
114//purpose :
115//=======================================================================
116
117static void PNamingToTNaming (const Handle(PNaming_Name)& PN,
118 TNaming_Name& TN,
119 const Handle(MDF_RRelocationTable)& RelocTable)
120
121{
122 TN.Type (IntegerToNameType (PN->Type ()));
123 TN.ShapeType(IntegerToShapeEnum(PN->ShapeType()));
124 Handle(TNaming_NamedShape) NS;
125
126 if (!PN->Arguments().IsNull()) {
127 Standard_Integer NbArgs = PN->Arguments()->Length();
128 for (Standard_Integer i = 1; i <= NbArgs; i++) {
129 RelocTable->HasRelocation(PN->Arguments()->Value(i),NS);
130 TN.Append(NS);
131 }
132 }
133
134 Handle(TNaming_NamedShape) StopNS;
135 if (!PN->StopNamedShape().IsNull())
136 RelocTable->HasRelocation(PN->StopNamedShape(),StopNS);
137 TN.StopNamedShape(StopNS);
138 TN.Index(PN->Index());
139}
140
141//=======================================================================
142//function : Paste
143//purpose :
144//=======================================================================
145
146void MNaming_NamingRetrievalDriver::Paste (
147 const Handle(PDF_Attribute)& Source,
148 const Handle(TDF_Attribute)& Target,
149 const Handle(MDF_RRelocationTable)& RelocTable) const
150{
151 //MDesign_FunctionRetrievalDriver::Paste (Source,Target,RelocTable);
152 Handle(PNaming_Naming) PF = Handle(PNaming_Naming)::DownCast(Source);
153 Handle(TNaming_Naming) F = Handle(TNaming_Naming)::DownCast(Target);
154 PNamingToTNaming (PF->GetName(),F->ChangeName(),RelocTable);
155}
156
157
158