0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- prepar...
[occt.git] / src / StepToTopoDS / StepToTopoDS_TranslateVertexLoop.cxx
1 // Created on: 1995-01-03
2 // Created by: Frederic MAUPAS/Dieter THIEMANN
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 //:   gka 09.04.99: S4136: eliminate BRepAPI::Precision()
18
19 #include <BRep_Builder.hxx>
20 #include <StdFail_NotDone.hxx>
21 #include <StepShape_Vertex.hxx>
22 #include <StepShape_VertexLoop.hxx>
23 #include <StepToTopoDS_NMTool.hxx>
24 #include <StepToTopoDS_Tool.hxx>
25 #include <StepToTopoDS_TranslateVertex.hxx>
26 #include <StepToTopoDS_TranslateVertexLoop.hxx>
27 #include <TopoDS.hxx>
28 #include <TopoDS_Edge.hxx>
29 #include <TopoDS_Shape.hxx>
30 #include <TopoDS_Vertex.hxx>
31 #include <TopoDS_Wire.hxx>
32 #include <Transfer_TransientProcess.hxx>
33
34 //#include <BRepAPI.hxx>
35 // ============================================================================
36 // Method  : StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop
37 // Purpose : Empty Constructor
38 // ============================================================================
39 StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop()
40 {
41 }
42
43 // ============================================================================
44 // Method  : StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop
45 // Purpose : Constructor with a VertexLoop and a Tool
46 // ============================================================================
47
48 StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop(const Handle(StepShape_VertexLoop)& VL, 
49                                                                    StepToTopoDS_Tool& T,
50                                                                    StepToTopoDS_NMTool& NMTool)
51 {
52   Init(VL, T, NMTool);
53 }
54
55 // ============================================================================
56 // Method  : Init
57 // Purpose : Init  with a VertexLoop and a Tool
58 // ============================================================================
59
60 void StepToTopoDS_TranslateVertexLoop::Init(const Handle(StepShape_VertexLoop)& VL,
61                                             StepToTopoDS_Tool& aTool,
62                                             StepToTopoDS_NMTool& NMTool)
63 {
64   // A Vertex Loop shall be mapped onto a Vertex + Edge + Wire;
65   if (!aTool.IsBound(VL)) {
66     BRep_Builder B;
67     Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
68
69 //:S4136    Standard_Real preci = BRepAPI::Precision();
70     Handle(StepShape_Vertex) Vtx;
71     TopoDS_Vertex V1,V2;
72     TopoDS_Edge E;
73     TopoDS_Wire W;
74     Vtx = VL->LoopVertex();
75     StepToTopoDS_TranslateVertex myTranVtx(Vtx, aTool, NMTool);
76     if (myTranVtx.IsDone()) {
77       V1 = TopoDS::Vertex(myTranVtx.Value());
78       V2 = TopoDS::Vertex(myTranVtx.Value());
79     }
80     else {
81       TP->AddWarning(VL,"VertexLoop not mapped to TopoDS ");
82       myError  = StepToTopoDS_TranslateVertexLoopOther;
83       done     = Standard_False;    
84       return;
85     }
86     V1.Orientation(TopAbs_FORWARD);
87     V2.Orientation(TopAbs_REVERSED);
88     B.MakeEdge(E);
89     B.Add(E, V1);
90     B.Add(E, V2);
91     B.Degenerated(E, Standard_True);
92
93     B.MakeWire(W);
94     W.Closed (Standard_True);
95     B.Add(W, E);
96     aTool.Bind(VL, W);
97     myResult = W;
98     myError  = StepToTopoDS_TranslateVertexLoopDone;
99     done     = Standard_True;
100   }
101   else {
102     myResult = TopoDS::Wire(aTool.Find(VL));
103     myError  = StepToTopoDS_TranslateVertexLoopDone;
104     done     = Standard_True;    
105   }
106 }
107
108 // ============================================================================
109 // Method  : Value
110 // Purpose : Return the mapped Shape
111 // ============================================================================
112
113 const TopoDS_Shape& StepToTopoDS_TranslateVertexLoop::Value() const 
114 {
115   StdFail_NotDone_Raise_if (!done, "StepToTopoDS_TranslateVertexLoop::Value() - no result");
116   return myResult;
117 }
118
119 // ============================================================================
120 // Method  : Error
121 // Purpose : Return the TranslateVertexLoop Error code
122 // ============================================================================
123
124 StepToTopoDS_TranslateVertexLoopError StepToTopoDS_TranslateVertexLoop::Error() const
125 {
126   return myError;
127 }