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