973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
42cf5bc1 |
14 | |
15 | #include <Interface_Check.hxx> |
16 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
17 | #include <Interface_InterfaceMismatch.hxx> |
42cf5bc1 |
18 | #include <Standard_Type.hxx> |
ec357c5c |
19 | #include <StepData_ESDescr.hxx> |
42cf5bc1 |
20 | #include <StepData_Field.hxx> |
21 | #include <StepData_FieldListN.hxx> |
22 | #include <StepData_Simple.hxx> |
7fd59977 |
23 | |
92efcf78 |
24 | IMPLEMENT_STANDARD_RTTIEXT(StepData_Simple,StepData_Described) |
25 | |
b311480e |
26 | StepData_Simple::StepData_Simple (const Handle(StepData_ESDescr)& descr) |
7fd59977 |
27 | : StepData_Described (descr) , thefields (descr->NbFields()) { } |
28 | |
29 | Handle(StepData_ESDescr) StepData_Simple::ESDescr () const |
30 | { return Handle(StepData_ESDescr)::DownCast (Description()); } |
31 | |
32 | Standard_CString StepData_Simple::StepType () const |
33 | { return ESDescr()->TypeName(); } |
34 | |
35 | |
36 | Standard_Boolean StepData_Simple::IsComplex () const |
37 | { return Standard_False; } |
38 | |
39 | Standard_Boolean StepData_Simple::Matches (const Standard_CString steptype) const |
40 | { return ESDescr()->Matches (steptype); } |
41 | |
42 | Handle(StepData_Simple) StepData_Simple::As (const Standard_CString steptype) const |
43 | { |
44 | Handle(StepData_Simple) nulent; |
45 | if (Matches(steptype)) return this; |
46 | return nulent; |
47 | } |
48 | |
49 | |
50 | Standard_Boolean StepData_Simple::HasField (const Standard_CString name) const |
51 | { |
52 | Standard_Integer num = ESDescr()->Rank (name); |
53 | return (num > 0); |
54 | } |
55 | |
56 | const StepData_Field& StepData_Simple::Field (const Standard_CString name) const |
57 | { |
58 | Standard_Integer num = ESDescr()->Rank (name); |
9775fa61 |
59 | if (num == 0) throw Interface_InterfaceMismatch("StepData_Simple : Field"); |
7fd59977 |
60 | return FieldNum (num); |
61 | } |
62 | |
63 | StepData_Field& StepData_Simple::CField (const Standard_CString name) |
64 | { |
65 | Standard_Integer num = ESDescr()->Rank (name); |
9775fa61 |
66 | if (num == 0) throw Interface_InterfaceMismatch("StepData_Simple : Field"); |
7fd59977 |
67 | return CFieldNum (num); |
68 | } |
69 | |
70 | Standard_Integer StepData_Simple::NbFields () const |
71 | { return thefields.NbFields(); } |
72 | |
73 | const StepData_Field& StepData_Simple::FieldNum (const Standard_Integer num) const |
74 | { return thefields.Field(num); } |
75 | |
76 | StepData_Field& StepData_Simple::CFieldNum (const Standard_Integer num) |
77 | { return thefields.CField(num); } |
78 | |
79 | const StepData_FieldListN& StepData_Simple::Fields () const |
80 | { return thefields; } |
81 | |
82 | StepData_FieldListN& StepData_Simple::CFields () |
83 | { return thefields; } |
84 | |
85 | |
302f96fb |
86 | void StepData_Simple::Check(Handle(Interface_Check)& /*ach*/) const |
7fd59977 |
87 | { |
88 | } // qq chose ? cf la description |
89 | |
90 | |
91 | void StepData_Simple::Shared (Interface_EntityIterator& list) const |
92 | { |
93 | Standard_Integer i, nb = thefields.NbFields(); |
94 | for (i = 1; i <= nb; i ++) { |
95 | const StepData_Field& fi = thefields.Field(i); |
96 | Standard_Integer j1,j2,l1,l2; l1 = l2 = 1; |
97 | if (fi.Arity() >= 1) l1 = fi.Length(1); |
98 | if (fi.Arity() > 1) l2 = fi.Length(2); |
99 | for (j1 = 1; j1 <= l1; j1 ++) { |
100 | for (j2 = 1; j2 <= l2; j2 ++) { |
101 | Handle(Standard_Transient) ent = fi.Entity(j1,j2); |
102 | if (!ent.IsNull()) list.AddItem(ent); |
103 | } |
104 | } |
105 | } |
106 | } |