0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[occt.git] / src / TopoDSToStep / TopoDSToStep_MakeStepVertex.cxx
1 // Created on: 1994-11-30
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1994-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
18 #include <BRep_Tool.hxx>
19 #include <GeomToStep_MakeCartesianPoint.hxx>
20 #include <gp_Pnt.hxx>
21 #include <Interface_Static.hxx>
22 #include <StdFail_NotDone.hxx>
23 #include <StepGeom_CartesianPoint.hxx>
24 #include <StepShape_TopologicalRepresentationItem.hxx>
25 #include <StepShape_VertexPoint.hxx>
26 #include <TCollection_HAsciiString.hxx>
27 #include <TopoDS_Vertex.hxx>
28 #include <TopoDSToStep_MakeStepVertex.hxx>
29 #include <TopoDSToStep_Tool.hxx>
30 #include <Transfer_FinderProcess.hxx>
31 #include <TransferBRep.hxx>
32 #include <TransferBRep_ShapeMapper.hxx>
33
34 // Processing of non-manifold topology (ssv; 11.11.2010)
35 // ----------------------------------------------------------------------------
36 // Constructors
37 // ----------------------------------------------------------------------------
38 TopoDSToStep_MakeStepVertex::TopoDSToStep_MakeStepVertex()
39 : myError(TopoDSToStep_VertexOther)
40 {
41   done = Standard_False;
42 }
43
44 TopoDSToStep_MakeStepVertex::TopoDSToStep_MakeStepVertex
45 (const TopoDS_Vertex& V, 
46  TopoDSToStep_Tool& T,
47  const Handle(Transfer_FinderProcess)& FP)
48 {
49   done = Standard_False;
50   Init(V, T, FP);
51 }
52
53 // ----------------------------------------------------------------------------
54 // Method  : Init
55 // Purpose :
56 // ----------------------------------------------------------------------------
57
58 void TopoDSToStep_MakeStepVertex::Init(const TopoDS_Vertex& aVertex, 
59                                        TopoDSToStep_Tool& aTool,
60                                        const Handle(Transfer_FinderProcess)& FP)
61 {
62
63   aTool.SetCurrentVertex(aVertex);
64
65   // [BEGIN] Processing non-manifold topology (ssv; 11.11.2010)
66   Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0;
67   if (isNMMode) {
68     Handle(StepShape_VertexPoint) aVP;
69     Handle(TransferBRep_ShapeMapper) aSTEPMapper = TransferBRep::ShapeMapper(FP, aVertex);
70     if ( FP->FindTypedTransient(aSTEPMapper, STANDARD_TYPE(StepShape_VertexPoint), aVP) ) {
71       // Non-manifold topology detected
72       myError  = TopoDSToStep_VertexOther;
73       myResult = aVP;
74       done     = Standard_True;
75       return;
76     }
77   }
78   // [END] Processing non-manifold topology (ssv; 11.11.2010)
79   
80   if (aTool.IsBound(aVertex)) {
81     myError  = TopoDSToStep_VertexOther;
82     done     = Standard_True;
83     myResult = aTool.Find(aVertex);  
84     return;
85   } 
86
87   gp_Pnt P;
88   
89   P = BRep_Tool::Pnt(aVertex);
90   GeomToStep_MakeCartesianPoint MkPoint(P);
91   Handle(StepGeom_CartesianPoint) Gpms = MkPoint.Value();
92   Handle(StepShape_VertexPoint) Vpms =
93     new StepShape_VertexPoint();
94   Handle(TCollection_HAsciiString) aName = 
95     new TCollection_HAsciiString("");
96
97   Vpms->Init(aName, Gpms);
98
99   aTool.Bind(aVertex,Vpms);
100   myError  = TopoDSToStep_VertexDone;
101   done     = Standard_True;
102   myResult = Vpms;
103 }
104
105
106 // ----------------------------------------------------------------------------
107 // Method  : Value
108 // Purpose :
109 // ----------------------------------------------------------------------------
110
111 const Handle(StepShape_TopologicalRepresentationItem)& TopoDSToStep_MakeStepVertex::Value() const 
112 {
113   StdFail_NotDone_Raise_if (!done, "TopoDSToStep_MakeStepVertex::Value() - no result");
114   return myResult;
115 }
116
117 // ----------------------------------------------------------------------------
118 // Method  : Error
119 // Purpose :
120 // ----------------------------------------------------------------------------
121
122 TopoDSToStep_MakeVertexError TopoDSToStep_MakeStepVertex::Error() const 
123 {
124   return myError;
125 }
126