7fd59977 |
1 | // File: StepToTopoDS_TranslateVertex.cxx |
2 | // Created: Tue Jan 3 15:00:17 1995 |
3 | // Author: Frederic MAUPAS |
4 | // <fma@stylox> |
5 | //: gka 09.04.99: S4136: eliminate BRepAPI::Precision() |
6 | |
7 | #include <StepToTopoDS_TranslateVertex.ixx> |
8 | #include <StepToGeom_MakeCartesianPoint.hxx> |
9 | #include <TopoDS.hxx> |
10 | |
11 | #include <TopoDS_Vertex.hxx> |
12 | #include <BRep_Builder.hxx> |
13 | //#include <BRepAPI.hxx> |
14 | |
15 | #include <StepGeom_Point.hxx> |
16 | #include <StepGeom_CartesianPoint.hxx> |
17 | #include <StepShape_VertexPoint.hxx> |
18 | #include <StepShape_Vertex.hxx> |
19 | |
20 | #include <Geom_CartesianPoint.hxx> |
21 | #include <Precision.hxx> |
22 | |
23 | // For I-DEAS-like processing (ssv; 15.11.2010) |
24 | #include <TCollection_HAsciiString.hxx> |
25 | |
26 | // ============================================================================ |
27 | // Method : StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex |
28 | // Purpose : Empty Constructor |
29 | // ============================================================================ |
30 | |
31 | StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex() |
32 | { |
33 | done = Standard_False; |
34 | } |
35 | |
36 | // ============================================================================ |
37 | // Method : StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex |
38 | // Purpose : Constructor with a Vertex and a Tool |
39 | // ============================================================================ |
40 | |
41 | StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex(const Handle(StepShape_Vertex)& V, |
42 | StepToTopoDS_Tool& T, |
43 | StepToTopoDS_NMTool& NMTool) |
44 | { |
45 | Init(V, T, NMTool); |
46 | } |
47 | |
48 | // ============================================================================ |
49 | // Method : Init |
50 | // Purpose : Init with a Vertex and a Tool |
51 | // ============================================================================ |
52 | |
53 | void StepToTopoDS_TranslateVertex::Init(const Handle(StepShape_Vertex)& aVertex, |
54 | StepToTopoDS_Tool& aTool, |
55 | StepToTopoDS_NMTool& NMTool) |
56 | { |
57 | if (!aTool.IsBound(aVertex)) { |
58 | |
59 | // [BEGIN] Proceed with non-manifold topology (ssv; 14.11.2010) |
60 | if ( NMTool.IsActive() && NMTool.IsBound(aVertex) ) { |
61 | myResult = NMTool.Find(aVertex); |
62 | myError = StepToTopoDS_TranslateVertexDone; |
63 | done = Standard_True; |
64 | return; |
65 | } |
66 | // [END] Proceed with non-manifold topology (ssv; 14.11.2010) |
67 | |
68 | // [BEGIN] Proceed with I-DEAS-like STP (ssv; 15.11.2010) |
69 | const Handle(TCollection_HAsciiString) aVName = aVertex->Name(); |
70 | if ( NMTool.IsActive() && NMTool.IsIDEASCase() && |
71 | !aVName.IsNull() && !aVName->IsEmpty() && NMTool.IsBound(aVName->String()) ) { |
72 | myResult = NMTool.Find(aVName->String()); |
73 | myError = StepToTopoDS_TranslateVertexDone; |
74 | done = Standard_True; |
75 | return; |
76 | } |
77 | // [END] Proceed with I-DEAS-like STP (ssv; 15.11.2010) |
78 | |
79 | //:S4136 Standard_Real preci = BRepAPI::Precision(); |
80 | const Handle(StepShape_VertexPoint) VP = Handle(StepShape_VertexPoint)::DownCast(aVertex); |
81 | const Handle(StepGeom_Point) P = VP->VertexGeometry(); |
82 | const Handle(StepGeom_CartesianPoint) P1 = Handle(StepGeom_CartesianPoint)::DownCast(P); |
83 | Handle(Geom_CartesianPoint) P2; |
84 | StepToGeom_MakeCartesianPoint::Convert(P1,P2); |
85 | BRep_Builder B; |
86 | TopoDS_Vertex V; |
87 | B.MakeVertex(V, P2->Pnt(), Precision::Confusion()); //:S4136: preci |
88 | aTool.Bind(aVertex,V); |
89 | |
90 | // Register Vertex in NM tool (ssv; 14.11.2010) |
91 | if ( NMTool.IsActive() ) { |
92 | NMTool.Bind(aVertex, V); |
93 | if ( NMTool.IsIDEASCase() && !aVName.IsNull() && !aVName->IsEmpty() ) |
94 | NMTool.Bind(aVName->String(), V); |
95 | } |
96 | |
97 | myResult = V; |
98 | } |
99 | else { |
100 | myResult = TopoDS::Vertex(aTool.Find(aVertex)); |
101 | } |
102 | myError = StepToTopoDS_TranslateVertexDone; |
103 | done = Standard_True; |
104 | } |
105 | |
106 | // ============================================================================ |
107 | // Method : Value |
108 | // Purpose : Return the mapped Shape |
109 | // ============================================================================ |
110 | |
111 | const TopoDS_Shape& StepToTopoDS_TranslateVertex::Value() const |
112 | { |
113 | StdFail_NotDone_Raise_if(!done,""); |
114 | return myResult; |
115 | } |
116 | |
117 | // ============================================================================ |
118 | // Method : Error |
119 | // Purpose : Return the TranslateVertex Error Code |
120 | // ============================================================================ |
121 | |
122 | StepToTopoDS_TranslateVertexError StepToTopoDS_TranslateVertex::Error() const |
123 | { |
124 | return myError; |
125 | } |