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>
9 #include <Interface_EntityIterator.hxx>
12 #include <StepShape_FaceBound.hxx>
15 RWStepShape_RWFaceBound::RWStepShape_RWFaceBound () {}
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
25 // --- Number of Parameter Control ---
27 if (!data->CheckNbParams(num,3,ach,"face_bound")) return;
29 // --- inherited field : name ---
31 Handle(TCollection_HAsciiString) aName;
32 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
33 data->ReadString (num,1,"name",ach,aName);
35 // --- own field : bound ---
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);
41 // --- own field : orientation ---
43 Standard_Boolean aOrientation;
44 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
45 data->ReadBoolean (num,3,"orientation",ach,aOrientation);
47 //--- Initialisation of the read entity ---
50 ent->Init(aName, aBound, aOrientation);
54 void RWStepShape_RWFaceBound::WriteStep
55 (StepData_StepWriter& SW,
56 const Handle(StepShape_FaceBound)& ent) const
59 // --- inherited field name ---
63 // --- own field : bound ---
65 SW.Send(ent->Bound());
67 // --- own field : orientation ---
69 SW.SendBoolean(ent->Orientation());
73 void RWStepShape_RWFaceBound::Share(const Handle(StepShape_FaceBound)& ent, Interface_EntityIterator& iter) const
76 iter.GetOneItem(ent->Bound());
81 void RWStepShape_RWFaceBound::Check
82 (const Handle(StepShape_FaceBound)& ent,
83 const Interface_ShareTool& aShto,
84 Handle(Interface_Check)& ach) const
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();
99 // ach.AddWarning("EdgeCurve only once referenced");
101 else if (nbRef ==2) {
102 Handle(StepShape_OrientedEdge) theOE2;
103 Handle(StepShape_OrientedEdge) refOE1 =
104 Handle(StepShape_OrientedEdge)::DownCast(myShRef.Value());
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;
111 // get the FaceBound orientation for theOE2
113 Standard_Boolean sharOE2 = aShto.IsShared(theOE2);
116 cout << "OrientedEdge2 not shared" <<endl;
120 myShRef = aShto.Sharings(theOE2);
121 myShRef.SelectType (STANDARD_TYPE(StepShape_EdgeLoop),Standard_True);
123 Handle(StepShape_EdgeLoop) theEL2 =
124 Handle(StepShape_EdgeLoop)::DownCast(myShRef.Value());
125 Standard_Boolean sharEL2 = aShto.IsShared(theEL2);
128 cout << "EdgeLoop2 not shared" <<endl;
132 myShRef = aShto.Sharings(theEL2);
133 myShRef.SelectType (STANDARD_TYPE(StepShape_FaceBound),Standard_True);
135 Standard_Integer nbRef =
137 myShRef.NbEntities();
139 Handle(StepShape_FaceBound) theFB2 =
140 Handle(StepShape_FaceBound)::DownCast(myShRef.Value());
141 if (!theFB2.IsNull()) {
142 theFBOri2 = theFB2->Orientation();
146 cout << "EdgeLoop not referenced by FaceBound" << endl;
152 // "cumulate" the FaceBound orientation with the OrientedEdge orientation
154 Standard_Boolean theOEOri1 =
155 theFBOri1 ? theOE1->Orientation() : !(theOE1->Orientation());
156 Standard_Boolean theOEOri2 =
157 theFBOri2 ? theOE2->Orientation() : !(theOE2->Orientation());
159 // the orientation of the OrientedEdges must be opposite
161 if(theOEOri1 == theOEOri2) {
162 ach->AddFail("ERROR: non 2-manifold topology");
164 } //end if(nbRef == 2)
165 } //end for(i=1; i<=nbEdg; ...)
166 } //end if(!theEL1.IsNull)
169 cout << "no EdgeLoop in FaceBound" << endl;