b311480e |
1 | // Created on: 1995-01-03 |
2 | // Created by: Frederic MAUPAS/Dieter THIEMANN |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | //: gka 09.04.99: S4136: eliminate BRepAPI::Precision() |
18 | |
19 | #include <StepToTopoDS_TranslateVertexLoop.ixx> |
20 | |
21 | #include <BRep_Builder.hxx> |
22 | //#include <BRepAPI.hxx> |
23 | |
24 | #include <StepShape_Vertex.hxx> |
25 | #include <StepToTopoDS_TranslateVertex.hxx> |
26 | #include <TopoDS.hxx> |
27 | #include <TopoDS_Wire.hxx> |
28 | #include <TopoDS_Vertex.hxx> |
29 | #include <TopoDS_Edge.hxx> |
30 | #include <Transfer_TransientProcess.hxx> |
31 | |
32 | // ============================================================================ |
33 | // Method : StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop |
34 | // Purpose : Empty Constructor |
35 | // ============================================================================ |
36 | |
37 | StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop() |
38 | { |
39 | } |
40 | |
41 | // ============================================================================ |
42 | // Method : StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop |
43 | // Purpose : Constructor with a VertexLoop and a Tool |
44 | // ============================================================================ |
45 | |
46 | StepToTopoDS_TranslateVertexLoop::StepToTopoDS_TranslateVertexLoop(const Handle(StepShape_VertexLoop)& VL, |
47 | StepToTopoDS_Tool& T, |
48 | StepToTopoDS_NMTool& NMTool) |
49 | { |
50 | Init(VL, T, NMTool); |
51 | } |
52 | |
53 | // ============================================================================ |
54 | // Method : Init |
55 | // Purpose : Init with a VertexLoop and a Tool |
56 | // ============================================================================ |
57 | |
58 | void StepToTopoDS_TranslateVertexLoop::Init(const Handle(StepShape_VertexLoop)& VL, |
59 | StepToTopoDS_Tool& aTool, |
60 | StepToTopoDS_NMTool& NMTool) |
61 | { |
62 | // A Vertex Loop shall be mapped onto a Vertex + Edge + Wire; |
63 | if (!aTool.IsBound(VL)) { |
64 | BRep_Builder B; |
65 | Handle(Transfer_TransientProcess) TP = aTool.TransientProcess(); |
66 | |
67 | //:S4136 Standard_Real preci = BRepAPI::Precision(); |
68 | Handle(StepShape_Vertex) Vtx; |
69 | TopoDS_Vertex V1,V2; |
70 | TopoDS_Edge E; |
71 | TopoDS_Wire W; |
72 | Vtx = VL->LoopVertex(); |
73 | StepToTopoDS_TranslateVertex myTranVtx(Vtx, aTool, NMTool); |
74 | if (myTranVtx.IsDone()) { |
75 | V1 = TopoDS::Vertex(myTranVtx.Value()); |
76 | V2 = TopoDS::Vertex(myTranVtx.Value()); |
77 | } |
78 | else { |
79 | TP->AddWarning(VL,"VertexLoop not mapped to TopoDS "); |
80 | myError = StepToTopoDS_TranslateVertexLoopOther; |
81 | done = Standard_False; |
82 | return; |
83 | } |
84 | V1.Orientation(TopAbs_FORWARD); |
85 | V2.Orientation(TopAbs_REVERSED); |
86 | B.MakeEdge(E); |
87 | B.Add(E, V1); |
88 | B.Add(E, V2); |
89 | B.Degenerated(E, Standard_True); |
90 | |
91 | B.MakeWire(W); |
ab860031 |
92 | W.Closed (Standard_True); |
7fd59977 |
93 | B.Add(W, E); |
94 | aTool.Bind(VL, W); |
95 | myResult = W; |
96 | myError = StepToTopoDS_TranslateVertexLoopDone; |
97 | done = Standard_True; |
98 | } |
99 | else { |
100 | myResult = TopoDS::Wire(aTool.Find(VL)); |
101 | myError = StepToTopoDS_TranslateVertexLoopDone; |
102 | done = Standard_True; |
103 | } |
104 | } |
105 | |
106 | // ============================================================================ |
107 | // Method : Value |
108 | // Purpose : Return the mapped Shape |
109 | // ============================================================================ |
110 | |
111 | const TopoDS_Shape& StepToTopoDS_TranslateVertexLoop::Value() const |
112 | { |
113 | StdFail_NotDone_Raise_if(!done,""); |
114 | return myResult; |
115 | } |
116 | |
117 | // ============================================================================ |
118 | // Method : Error |
119 | // Purpose : Return the TranslateVertexLoop Error code |
120 | // ============================================================================ |
121 | |
122 | StepToTopoDS_TranslateVertexLoopError StepToTopoDS_TranslateVertexLoop::Error() const |
123 | { |
124 | return myError; |
125 | } |