0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / RWStepShape / RWStepShape_RWFaceBound.cxx
1
2 #include <RWStepShape_RWFaceBound.ixx>
3 #include <StepShape_Loop.hxx>
4 #include <StepShape_EdgeLoop.hxx>
5 #include <StepShape_OrientedEdge.hxx>
6 #include <StepShape_Edge.hxx>
7
8
9 #include <Interface_EntityIterator.hxx>
10
11
12 #include <StepShape_FaceBound.hxx>
13
14
15 RWStepShape_RWFaceBound::RWStepShape_RWFaceBound () {}
16
17 void RWStepShape_RWFaceBound::ReadStep
18         (const Handle(StepData_StepReaderData)& data,
19          const Standard_Integer num,
20          Handle(Interface_Check)& ach,
21          const Handle(StepShape_FaceBound)& ent) const
22 {
23
24
25         // --- Number of Parameter Control ---
26
27         if (!data->CheckNbParams(num,3,ach,"face_bound")) return;
28
29         // --- inherited field : name ---
30
31         Handle(TCollection_HAsciiString) aName;
32         //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
33         data->ReadString (num,1,"name",ach,aName);
34
35         // --- own field : bound ---
36
37         Handle(StepShape_Loop) aBound;
38         //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
39         data->ReadEntity(num, 2,"bound", ach, STANDARD_TYPE(StepShape_Loop), aBound);
40
41         // --- own field : orientation ---
42
43         Standard_Boolean aOrientation;
44         //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
45         data->ReadBoolean (num,3,"orientation",ach,aOrientation);
46
47         //--- Initialisation of the read entity ---
48
49
50         ent->Init(aName, aBound, aOrientation);
51 }
52
53
54 void RWStepShape_RWFaceBound::WriteStep
55         (StepData_StepWriter& SW,
56          const Handle(StepShape_FaceBound)& ent) const
57 {
58
59         // --- inherited field name ---
60
61         SW.Send(ent->Name());
62
63         // --- own field : bound ---
64
65         SW.Send(ent->Bound());
66
67         // --- own field : orientation ---
68
69         SW.SendBoolean(ent->Orientation());
70 }
71
72
73 void RWStepShape_RWFaceBound::Share(const Handle(StepShape_FaceBound)& ent, Interface_EntityIterator& iter) const
74 {
75
76         iter.GetOneItem(ent->Bound());
77 }
78
79
80
81 void RWStepShape_RWFaceBound::Check
82   (const Handle(StepShape_FaceBound)& ent,
83    const Interface_ShareTool& aShto,
84    Handle(Interface_Check)& ach) const
85 {
86   Standard_Boolean theFBOri2 = Standard_True;
87   Standard_Boolean theFBOri1 = ent->Orientation();
88   Handle(StepShape_EdgeLoop) theEL1 =
89     Handle(StepShape_EdgeLoop)::DownCast(ent->Bound());
90   if (!theEL1.IsNull()) {
91     Standard_Integer nbEdg = theEL1->NbEdgeList();
92     for(Standard_Integer i=1; i<=nbEdg; i++) {
93       Handle(StepShape_OrientedEdge) theOE1 = theEL1->EdgeListValue(i);
94       Handle(StepShape_Edge) theEdg1 = theOE1->EdgeElement();
95       Interface_EntityIterator myShRef = aShto.Sharings(theEdg1);
96       myShRef.SelectType (STANDARD_TYPE(StepShape_OrientedEdge),Standard_True);
97       Standard_Integer nbRef = myShRef.NbEntities();
98       if(nbRef == 1) {
99         //      ach.AddWarning("EdgeCurve only once referenced");
100       }
101       else if (nbRef ==2) {
102         Handle(StepShape_OrientedEdge) theOE2;
103         Handle(StepShape_OrientedEdge) refOE1 = 
104           Handle(StepShape_OrientedEdge)::DownCast(myShRef.Value());
105         myShRef.Next();
106         Handle(StepShape_OrientedEdge) refOE2 = 
107           Handle(StepShape_OrientedEdge)::DownCast(myShRef.Value());
108         if(theOE1 == refOE1) theOE2 = refOE2;
109         else if(theOE1 == refOE2) theOE2 = refOE1;
110         
111         // get the FaceBound orientation for theOE2
112         
113         Standard_Boolean sharOE2 = aShto.IsShared(theOE2);
114         if(!sharOE2){
115 #ifdef DEB
116           cout << "OrientedEdge2 not shared" <<endl;
117 #endif
118         }
119         else {
120           myShRef = aShto.Sharings(theOE2);
121           myShRef.SelectType (STANDARD_TYPE(StepShape_EdgeLoop),Standard_True);
122           myShRef.Start();
123           Handle(StepShape_EdgeLoop) theEL2 =
124             Handle(StepShape_EdgeLoop)::DownCast(myShRef.Value());
125           Standard_Boolean sharEL2 = aShto.IsShared(theEL2);
126           if(!sharEL2){
127 #ifdef DEB
128             cout << "EdgeLoop2 not shared" <<endl;
129 #endif
130           }
131           else {
132             myShRef = aShto.Sharings(theEL2);
133             myShRef.SelectType (STANDARD_TYPE(StepShape_FaceBound),Standard_True);
134             myShRef.Start();
135             Handle(StepShape_FaceBound) theFB2 =
136               Handle(StepShape_FaceBound)::DownCast(myShRef.Value());
137             if (!theFB2.IsNull()) {
138               theFBOri2 = theFB2->Orientation();
139             }
140             else {
141 #ifdef DEB
142               cout << "EdgeLoop not referenced by FaceBound" << endl;
143 #endif
144             }
145           }
146         }
147         
148         // "cumulate" the FaceBound orientation with the OrientedEdge orientation
149         
150         Standard_Boolean theOEOri1 =
151           theFBOri1 ? theOE1->Orientation() : !(theOE1->Orientation());
152         Standard_Boolean theOEOri2 =
153           theFBOri2 ? theOE2->Orientation() : !(theOE2->Orientation());
154         
155         // the orientation of the OrientedEdges must be opposite
156         
157         if(theOEOri1 == theOEOri2) {
158           ach->AddFail("ERROR: non 2-manifold topology");
159         } 
160       } //end if(nbRef == 2)
161     } //end for(i=1; i<=nbEdg; ...)
162   } //end if(!theEL1.IsNull)
163   else {
164 #ifdef DEB
165     cout << "no EdgeLoop in FaceBound" << endl;
166 #endif
167   }
168 }