7fd59977 |
1 | //-------------------------------------------------------------------- |
2 | // |
3 | // File Name : IGESDimen_WitnessLine.cxx |
4 | // Date : |
5 | // Author : CKY / Contract Toubro-Larsen |
6 | // Copyright : MATRA-DATAVISION 1993 |
7 | // |
8 | //-------------------------------------------------------------------- |
9 | |
10 | #include <IGESDimen_ToolWitnessLine.ixx> |
11 | #include <IGESData_ParamCursor.hxx> |
12 | #include <gp_XY.hxx> |
13 | #include <gp_Pnt.hxx> |
14 | #include <TColgp_HArray1OfXY.hxx> |
15 | #include <IGESData_LineFontEntity.hxx> |
16 | #include <IGESData_Dump.hxx> |
17 | #include <Interface_Macros.hxx> |
18 | |
19 | |
20 | IGESDimen_ToolWitnessLine::IGESDimen_ToolWitnessLine () { } |
21 | |
22 | |
23 | void IGESDimen_ToolWitnessLine::ReadOwnParams |
24 | (const Handle(IGESDimen_WitnessLine)& ent, |
25 | const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const |
26 | { |
27 | //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down |
28 | |
29 | Standard_Integer datatype; |
30 | Standard_Real zDisplacement; |
31 | Standard_Integer nbval; |
32 | Handle(TColgp_HArray1OfXY) dataPoints; |
33 | |
34 | PR.ReadInteger(PR.Current(), "Interpretation Flag", datatype); //szv#4:S4163:12Mar99 `st=` not needed |
35 | |
36 | Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of data points", nbval); |
37 | if (st && nbval > 0) |
38 | dataPoints = new TColgp_HArray1OfXY(1, nbval); |
39 | else PR.AddFail("Number of data points: Not Positive"); |
40 | |
41 | PR.ReadReal(PR.Current(), "Common Z Displacement", zDisplacement); //szv#4:S4163:12Mar99 `st=` not needed |
42 | |
43 | if (! dataPoints.IsNull()) |
44 | for (Standard_Integer i = 1; i <= nbval; i++) |
45 | { |
46 | gp_XY tempXY; |
47 | PR.ReadXY(PR.CurrentList(1, 2), "Data Points", tempXY); //szv#4:S4163:12Mar99 `st=` not needed |
48 | dataPoints->SetValue(i, tempXY); |
49 | } |
50 | |
51 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
52 | ent->Init(datatype, zDisplacement, dataPoints); |
53 | } |
54 | |
55 | void IGESDimen_ToolWitnessLine::WriteOwnParams |
56 | (const Handle(IGESDimen_WitnessLine)& ent, IGESData_IGESWriter& IW) const |
57 | { |
58 | Standard_Integer upper = ent->NbPoints(); |
59 | IW.Send(ent->Datatype()); |
60 | IW.Send(upper); |
61 | IW.Send(ent->ZDisplacement()); |
62 | for (Standard_Integer i = 1; i <= upper; i++) |
63 | { |
64 | IW.Send((ent->Point(i)).X()); |
65 | IW.Send((ent->Point(i)).Y()); |
66 | } |
67 | } |
68 | |
69 | void IGESDimen_ToolWitnessLine::OwnShared |
70 | (const Handle(IGESDimen_WitnessLine)& /* ent */, Interface_EntityIterator& /* iter */) const |
71 | { |
72 | } |
73 | |
74 | void IGESDimen_ToolWitnessLine::OwnCopy |
75 | (const Handle(IGESDimen_WitnessLine)& another, |
76 | const Handle(IGESDimen_WitnessLine)& ent, Interface_CopyTool& /* TC */) const |
77 | { |
78 | Standard_Integer datatype = another->Datatype(); |
79 | Standard_Integer nbval = another->NbPoints(); |
80 | Standard_Real zDisplacement = another->ZDisplacement(); |
81 | |
82 | Handle(TColgp_HArray1OfXY) dataPoints = new TColgp_HArray1OfXY(1, nbval); |
83 | |
84 | for (Standard_Integer i = 1; i <= nbval; i++) |
85 | { |
86 | gp_Pnt tempPnt = (another->Point(i)); |
87 | gp_XY tempPnt2d(tempPnt.X(), tempPnt.Y()); |
88 | dataPoints->SetValue(i, tempPnt2d); |
89 | } |
90 | ent->Init(datatype, zDisplacement, dataPoints); |
91 | } |
92 | |
93 | Standard_Boolean IGESDimen_ToolWitnessLine::OwnCorrect |
94 | (const Handle(IGESDimen_WitnessLine)& ent) const |
95 | { |
96 | Standard_Boolean res = (ent->RankLineFont() != 1); |
97 | if (res) { |
98 | Handle(IGESData_LineFontEntity) nulfont; |
99 | ent->InitLineFont(nulfont,1); |
100 | } |
101 | if (ent->Datatype() == 1) return res; |
102 | // Forcer DataType = 1 -> reconstruire |
103 | Standard_Integer nb = ent->NbPoints(); |
104 | if (nb == 0) return Standard_False; // rien pu faire (est-ce possible ?) |
105 | Handle(TColgp_HArray1OfXY) pts = new TColgp_HArray1OfXY(1,nb); |
106 | for (Standard_Integer i = 1; i <= nb; i ++) |
107 | pts->SetValue(i,gp_XY (ent->Point(i).X(),ent->Point(i).Y()) ); |
108 | ent->Init (1,ent->ZDisplacement(),pts); |
109 | return Standard_True; |
110 | } |
111 | |
112 | IGESData_DirChecker IGESDimen_ToolWitnessLine::DirChecker |
113 | (const Handle(IGESDimen_WitnessLine)& /* ent */ ) const |
114 | { |
115 | IGESData_DirChecker DC (106, 40); |
116 | DC.Structure(IGESData_DefVoid); |
117 | DC.LineFont(IGESData_DefValue); |
118 | DC.LineWeight(IGESData_DefValue); |
119 | DC.Color(IGESData_DefAny); |
120 | DC.UseFlagRequired(1); |
121 | DC.HierarchyStatusIgnored(); |
122 | return DC; |
123 | } |
124 | |
125 | void IGESDimen_ToolWitnessLine::OwnCheck |
126 | (const Handle(IGESDimen_WitnessLine)& ent, |
127 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
128 | { |
129 | if (ent->RankLineFont() != 1) |
130 | ach->AddFail("Line Font Pattern != 1"); |
131 | if (ent->Datatype() != 1) |
132 | ach->AddFail("Interpretation Flag != 1"); |
133 | if (ent->NbPoints() < 3) |
134 | ach->AddFail("Number of data points < 3"); |
135 | if (ent->NbPoints()%2 == 0) |
136 | ach->AddFail("Number of data points is not odd"); |
137 | } |
138 | |
139 | void IGESDimen_ToolWitnessLine::OwnDump |
140 | (const Handle(IGESDimen_WitnessLine)& ent, const IGESData_IGESDumper& /* dumper */, |
141 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
142 | { |
143 | S << "IGESDimen_WitnessLine" << endl; |
144 | S << "Data Type : " << ent->Datatype() << " "; |
145 | S << "Number of Data Points : " << ent->NbPoints() << " "; |
146 | S << "Common Z displacement : " << ent->ZDisplacement() << endl; |
147 | S << "Data Points : "; |
148 | IGESData_DumpListXYLZ(S ,level,1, ent->NbPoints(),ent->Point, |
149 | ent->Location(), ent->ZDisplacement()); |
150 | S << endl; |
151 | } |