Warnings on vc14 were eliminated
[occt.git] / src / TopOpeBRep / TopOpeBRep_traceSIFF.cxx
CommitLineData
b311480e 1// Created on: 1997-10-22
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1997-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.
7fd59977 16
0797d9d3 17#ifdef OCCT_DEBUG
7fd59977 18
19#include <TopOpeBRep_traceSIFF.hxx>
20#include <stdio.h>
21TopOpeBRep_traceSIFF::TopOpeBRep_traceSIFF()
22{
23 Reset();
24}
25
26void TopOpeBRep_traceSIFF::Reset()
27{
28 mybrep1 = "";
29 mybrep2 = "";
30 myfilename = "";
31 myopen = Standard_False;
32}
33
34void TopOpeBRep_traceSIFF::Set(const Standard_Boolean b,
35 Standard_Integer n,
36 char**a)
37{
38 if (n < 3 || !b || a == NULL) {
39 Reset();
40 return;
41 }
42 mybrep1 = a[0];
43 mybrep2 = a[1];
44 myfilename = a[2];
45}
46
47void TopOpeBRep_traceSIFF::Set(const TCollection_AsciiString& brep1,
48 const TCollection_AsciiString& brep2,
49 const TCollection_AsciiString& filename)
50{
51 mybrep1 = brep1;
52 mybrep2 = brep2;
53 myfilename = filename;
54}
55
56TCollection_AsciiString TopOpeBRep_traceSIFF::Name1(const Standard_Integer I) const
57{
58 TCollection_AsciiString s = mybrep1 + "_" + I;
59 return s;
60}
61
62TCollection_AsciiString TopOpeBRep_traceSIFF::Name2(const Standard_Integer I) const
63{
64 TCollection_AsciiString s = mybrep2 + "_" + I;
65 return s;
66}
67
68const TCollection_AsciiString& TopOpeBRep_traceSIFF::File() const
69{
70 return myfilename;
71}
72
73Standard_Boolean TopOpeBRep_traceSIFF::Start(const TCollection_AsciiString& s,
74 Standard_OStream& OS)
75{
76 Standard_CString cs = myfilename.ToCString();
77 myopen = Standard_True;
78 if (!myfilebuf.open(cs,ios::out)) {
79 myopen = Standard_False;
80 }
81 if (!myopen) {
82 return myopen;
83 }
84 ostream osfic(&myfilebuf); osfic.precision(15);
85 if (s.Length()) {
86 OS<<s<<myfilename<<endl;
87 }
88 return myopen;
89}
90
91void TopOpeBRep_traceSIFF::Add(const Standard_Integer I1,
92 const Standard_Integer I2)
93{
94 if (!myopen) {
95 return;
96 }
97 TCollection_AsciiString n1 = Name1(I1);
98 TCollection_AsciiString n2 = Name2(I2);
99 ostream osfic(&myfilebuf);
100 osfic<<n1<<" "<<n2<<"\n";
101}
102
103void TopOpeBRep_traceSIFF::End(const TCollection_AsciiString& s,
104 Standard_OStream& OS)
105{
106 if (!myopen) {
107 return;
108 }
109 if (s.Length()) {
110 OS<<s<<myfilename<<endl;
111 }
112 myopen = Standard_False;
113}
114//////////////////////////////////////////////////////////////////////////
115
1d0a9d4d 116TopOpeBRep_traceSIFF SIFF;
7fd59977 117
118Standard_EXPORT void TopOpeBRep_SettraceSIFF(const Standard_Boolean b,
119 Standard_Integer n,char**a)
120{
121 SIFF.Set(b,n,a);
122}
123
124Standard_EXPORT Standard_Boolean TopOpeBRep_GettraceSIFF()
125{
126 Standard_Boolean b = (SIFF.File().Length() != 0);
127 return b;
128}
129
0797d9d3 130// #ifdef OCCT_DEBUG
7fd59977 131#endif