Test for 0022778: Bug in BRepMesh
[occt.git] / src / TopOpeBRep / TopOpeBRep_traceSIFF.cxx
1 // Created on: 1997-10-22
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #ifdef DEB
23
24 #include <TopOpeBRep_traceSIFF.hxx>
25 #include <stdio.h>
26 TopOpeBRep_traceSIFF::TopOpeBRep_traceSIFF()
27
28   Reset();
29 }
30
31 void TopOpeBRep_traceSIFF::Reset()
32
33   mybrep1 = ""; 
34   mybrep2 = ""; 
35   myfilename = ""; 
36   myopen = Standard_False;
37 }
38
39 void TopOpeBRep_traceSIFF::Set(const Standard_Boolean b,
40                                Standard_Integer n,
41                                char**a)
42 {
43   if (n < 3 || !b || a == NULL) { 
44     Reset();
45     return;
46   }
47   mybrep1 = a[0];
48   mybrep2 = a[1];
49   myfilename = a[2];
50 }
51
52 void TopOpeBRep_traceSIFF::Set(const TCollection_AsciiString& brep1,
53                                const TCollection_AsciiString& brep2,
54                                const TCollection_AsciiString& filename)
55
56   mybrep1 = brep1; 
57   mybrep2 = brep2; 
58   myfilename = filename;
59 }
60
61 TCollection_AsciiString TopOpeBRep_traceSIFF::Name1(const Standard_Integer I) const
62 {
63   TCollection_AsciiString s = mybrep1 + "_" + I; 
64   return s;
65
66
67 TCollection_AsciiString TopOpeBRep_traceSIFF::Name2(const Standard_Integer I) const
68 {
69   TCollection_AsciiString s = mybrep2 + "_" + I; 
70   return s;
71
72
73 const TCollection_AsciiString& TopOpeBRep_traceSIFF::File() const 
74
75   return myfilename; 
76 }
77
78 Standard_Boolean TopOpeBRep_traceSIFF::Start(const TCollection_AsciiString& s,
79                                              Standard_OStream& OS) 
80 {
81   Standard_CString cs = myfilename.ToCString();
82   myopen = Standard_True;
83   if (!myfilebuf.open(cs,ios::out)) {
84     myopen = Standard_False;
85   }
86   if (!myopen) {
87     return myopen;
88   }
89   ostream osfic(&myfilebuf); osfic.precision(15);
90   if (s.Length()) {
91     OS<<s<<myfilename<<endl;
92   }
93   return myopen;
94 }
95
96 void TopOpeBRep_traceSIFF::Add(const Standard_Integer I1,
97                                const Standard_Integer I2)
98 {
99   if (!myopen) {
100     return;
101   }
102   TCollection_AsciiString n1 = Name1(I1);
103   TCollection_AsciiString n2 = Name2(I2);
104   ostream osfic(&myfilebuf);
105   osfic<<n1<<" "<<n2<<"\n";
106 }
107
108 void TopOpeBRep_traceSIFF::End(const TCollection_AsciiString& s,
109                                Standard_OStream& OS)
110 {
111   if (!myopen) {
112     return;
113   }
114   if (s.Length()) {
115     OS<<s<<myfilename<<endl;
116   }
117   myopen = Standard_False;
118 }  
119 //////////////////////////////////////////////////////////////////////////
120
121 Standard_EXPORT TopOpeBRep_traceSIFF SIFF;
122
123 Standard_EXPORT void TopOpeBRep_SettraceSIFF(const Standard_Boolean b,
124                                              Standard_Integer n,char**a)
125 {
126   SIFF.Set(b,n,a);
127 }
128
129 Standard_EXPORT Standard_Boolean TopOpeBRep_GettraceSIFF()
130 {
131   Standard_Boolean b = (SIFF.File().Length() != 0);
132   return b;
133 }
134
135 // #ifdef DEB
136 #endif