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 // ============================================================================
StepToTopoDS_TranslateVertexLoop()39 StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop()
40 : myError(StepToTopoDS_TranslateVertexLoopOther)
41 {
42 }
43
44 // ============================================================================
45 // Method : StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop
46 // Purpose : Constructor with a VertexLoop and a Tool
47 // ============================================================================
48
StepToTopoDS_TranslateVertexLoop(const Handle (StepShape_VertexLoop)& VL,StepToTopoDS_Tool & T,StepToTopoDS_NMTool & NMTool)49 StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop(const Handle(StepShape_VertexLoop)& VL,
50 StepToTopoDS_Tool& T,
51 StepToTopoDS_NMTool& NMTool)
52 {
53 Init(VL, T, NMTool);
54 }
55
56 // ============================================================================
57 // Method : Init
58 // Purpose : Init with a VertexLoop and a Tool
59 // ============================================================================
60
Init(const Handle (StepShape_VertexLoop)& VL,StepToTopoDS_Tool & aTool,StepToTopoDS_NMTool & NMTool)61 void StepToTopoDS_TranslateVertexLoop::Init(const Handle(StepShape_VertexLoop)& VL,
62 StepToTopoDS_Tool& aTool,
63 StepToTopoDS_NMTool& NMTool)
64 {
65 // A Vertex Loop shall be mapped onto a Vertex + Edge + Wire;
66 if (!aTool.IsBound(VL)) {
67 BRep_Builder B;
68 Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
69
70 //:S4136 Standard_Real preci = BRepAPI::Precision();
71 Handle(StepShape_Vertex) Vtx;
72 TopoDS_Vertex V1,V2;
73 TopoDS_Edge E;
74 TopoDS_Wire W;
75 Vtx = VL->LoopVertex();
76 StepToTopoDS_TranslateVertex myTranVtx(Vtx, aTool, NMTool);
77 if (myTranVtx.IsDone()) {
78 V1 = TopoDS::Vertex(myTranVtx.Value());
79 V2 = TopoDS::Vertex(myTranVtx.Value());
80 }
81 else {
82 TP->AddWarning(VL,"VertexLoop not mapped to TopoDS ");
83 myError = StepToTopoDS_TranslateVertexLoopOther;
84 done = Standard_False;
85 return;
86 }
87 V1.Orientation(TopAbs_FORWARD);
88 V2.Orientation(TopAbs_REVERSED);
89 B.MakeEdge(E);
90 B.Add(E, V1);
91 B.Add(E, V2);
92 B.Degenerated(E, Standard_True);
93
94 B.MakeWire(W);
95 W.Closed (Standard_True);
96 B.Add(W, E);
97 aTool.Bind(VL, W);
98 myResult = W;
99 myError = StepToTopoDS_TranslateVertexLoopDone;
100 done = Standard_True;
101 }
102 else {
103 myResult = TopoDS::Wire(aTool.Find(VL));
104 myError = StepToTopoDS_TranslateVertexLoopDone;
105 done = Standard_True;
106 }
107 }
108
109 // ============================================================================
110 // Method : Value
111 // Purpose : Return the mapped Shape
112 // ============================================================================
113
Value() const114 const TopoDS_Shape& StepToTopoDS_TranslateVertexLoop::Value() const
115 {
116 StdFail_NotDone_Raise_if (!done, "StepToTopoDS_TranslateVertexLoop::Value() - no result");
117 return myResult;
118 }
119
120 // ============================================================================
121 // Method : Error
122 // Purpose : Return the TranslateVertexLoop Error code
123 // ============================================================================
124
Error() const125 StepToTopoDS_TranslateVertexLoopError StepToTopoDS_TranslateVertexLoop::Error() const
126 {
127 return myError;
128 }
129