Debian Codegraph @

cuneiform_src/Kern/lns32/src/sbambuk.h

raw
1 /*
2 Copyright (c) 1993-2008, Cognitive Technologies
3 All rights reserved.
4
5 Разрешается повторное распространение и использование как в виде исходного кода,
6 так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
7
8 * При повторном распространении исходного кода должны оставаться указанное
9 выше уведомление об авторском праве, этот список условий и последующий
10 отказ от гарантий.
11 * При повторном распространении двоичного кода в документации и/или в
12 других материалах, поставляемых при распространении, должны сохраняться
13 указанная выше информация об авторском праве, этот список условий и
14 последующий отказ от гарантий.
15 * Ни название Cognitive Technologies, ни имена ее сотрудников не могут
16 быть использованы в качестве средства поддержки и/или продвижения
17 продуктов, основанных на этом ПО, без предварительного письменного
18 разрешения.
19
20 ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
21 ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
22 ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
23 ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
24 МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
25 НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
26 ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
27 НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
28 СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
29 ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
30 НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
31 ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
32
33 Redistribution and use in source and binary forms, with or without modification,
34 are permitted provided that the following conditions are met:
35
36 * Redistributions of source code must retain the above copyright notice,
37 this list of conditions and the following disclaimer.
38 * Redistributions in binary form must reproduce the above copyright notice,
39 this list of conditions and the following disclaimer in the documentation
40 and/or other materials provided with the distribution.
41 * Neither the name of the Cognitive Technologies nor the names of its
42 contributors may be used to endorse or promote products derived from this
43 software without specific prior written permission.
44
45 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57 /*
58 Getting source bitmap and creating horisontal and vertical
59 segments page bambuks simultaneously.
60
61 Entry point is constructor
62 THVSegBambuk( PTBMPReadBuffer reader, int h_filter_len, int v_filter_len ).
63
64 09-06-93 05:43pm, Basil
65 */
66
67 #ifndef __SBAMBUK_H
68 # define __SBAMBUK_H
69
70 #ifndef __LNSLANG_H
71 # include "lnslang.h"
72 #endif
73
74
75 // _TYPEDEFFAR( TBlackSeg )
76 // _TYPEDEFFAR( TSegBambuk )
77 // _TYPEDEFFAR( THVSegBambuk)
78 #ifndef __BAMBUK_H
79 # include "bambuk.h"
80 #endif
81 #ifndef __XYDIM_H
82 # include "xydim.h"
83 #endif
84 #ifndef __ERROBJ_H
85 # include "errobj.h"
86 #endif
87 #ifndef __TGREADER_H // under windows tiger lib
88 # include "tgreader.h"
89 #endif
90
91 #ifndef __PROCLINE_H
92 # include "procline.h"
93 #endif
94 #ifndef __FLTBUF_H
95 # include "fltbuf.h"
96 #endif
97
98 #ifndef __PARALINE_H
99 # include "paraline.h"
100 #endif
101
102 #define H_FLT_LEN (int)16
103 // #define V_FLT_LEN (int)16
104
105
106 /*
107 * TBlackSeg **********************************************
108
109 Simple black segment (or "interval") of bitmap line
110
111 */
112
113 struct TBlackSeg
114 {
115 int left;
116 int right;
117 BHandle dashHandle; // handle of proper component dash
118 BHandle nLower; // link to lower segments in raster line
119 // this is indexes of proper Bambuk array elements
120 };
121
122 typedef TBlackSeg * FarBlackSeg;
123
124 /*
125 * TSegBambuk **********************************************
126
127 TSegBambuk is bambuk of bitmap rows(or columns) of BlackSegments
128 Has some methods of building which differs for horisontal and
129 vertical cases.
130
131 Objects of this class used as source when RasterBambuk is builded
132 (no matter was this SegBambuk object created by vertical or
133 horisontal methods)
134 */
135
136 class TSegBambuk :
137 //public TBambuk< TBlackSeg >
138 public THugeBambuk< TBlackSeg >
139 {
140 private:
141 BHandle curHEntry;
142 int segLimit;
143 public:
144 BHandle segCount;
145
146 TSegBambuk( void ):
147 THugeBambuk< TBlackSeg >(),
148 //TBambuk< TBlackSeg >(),
149 curHEntry(0),
150 segLimit(0),
151 segCount(0)
152 {};
153
154 TSegBambuk( BHandle max_members, BEntry max_entries ):
155 THugeBambuk< TBlackSeg >(max_members, max_entries),
156 //TBambuk< TBlackSeg >(max_members, max_entries),
157 curHEntry(0),
158 segLimit(0),
159 segCount(0)
160 {};
161
162 Bool isOk( void )
163 {
164 return (THugeBambuk< TBlackSeg >::isOk());
165 //return (TBambuk< TBlackSeg >::isOk());
166 };
167
168 /** horisontal building routines **/
169 void hInitProcess( int left, int right, int h_filter_len )
170 {
171 SetupHConverter( left, right, h_filter_len, (TSegBambuk*)this, TRUE);
172 curHEntry = 0;
173 segLimit = (right - left + 1) / (h_filter_len+1);
174 };
175
176 Bool hUpdate( void* new_line )
177 {
178 assert( segLimit );
179 if (memberRestCount() < segLimit)
180 {
181
182 if (!GrowMembers())
183 return WRONG();
184 if (memberRestCount() < segLimit)
185 return WRONG();
186 }
187 ConvertBWLine( new_line );
188 curHEntry++;
189 return TRUE;
190 };
191
192 void addHorisontal( int32_t left, int32_t right )
193 {
194 BHandle new_member = addMember( curHEntry );
195 segCount++;
196
197 //========================= 06-21-95 02:27pm, just for optimization
198 TBlackSeg & bs = ((*this)[new_member]);
199 bs.left = left;
200 bs.right = right;
201 bs.dashHandle = NULLBHandle;
202 bs.nLower = NULLBHandle;
203 //========================= 06-21-95 02:27pm ======================
204 /**
205 THIS[new_member].left = left;
206 THIS[new_member].right = right;
207 THIS[new_member].dashHandle = NULLBHandle;
208 THIS[new_member].nLower = NULLBHandle;
209 **/
210 };
211
212 /** vertical building routines **/
213 Bool /*TSegBambuk::*/vUpdate( int32_t* new_line,
214 int32_t* cur16,
215 int32_t* prev16,
216 int cur_row
217 // int width_dword ??
218 );
219 Bool /*TSegBambuk::*/vUpdateFirst( int32_t* new_line,
220 int32_t* cur16,
221 int cur_row // at this version == 16
222 );
223 Bool /*TSegBambuk::*/vUpdateLast( int32_t* cur16,
224 int32_t* last16,
225 int bottom_row
226 );
227
228 };
229
230
231 /*
232 * THVSegBambuk **********************************************
233
234 THVSegBambuk object associates vertical and horisontal TSegBambuk's of
235 the bitmap.
236 Main feature is simultaneous creating of horisontal and vertical
237 vertions of TSegBambuk's objects by single pass of source bitmap
238
239 After HVBambuk has builded horisontal and vertical rasters can be
240 processed independently.
241
242 */
243
244 class THVSegBambuk : public TXYDim, public TErrObj
245 {
246 public :
247 int xres, yres;
248 TSegBambuk hBambuk; // "bambuk" of horisontal segments
249 TSegBambuk vBambuk; // "bambuk" of vertical segments
250 private:
251 #ifdef __TGREADER_H // 01-29-94 04:19pm, Basil
252 public:
253 THVSegBambuk( TigerReader & reader );
254 private:
255 Bool makeIt( TigerReader * reader,
256 TFltBuf* filter
257 );
258 #endif //__TGREADER_H
259
260 }; // THVSegBambuk
261
262 #endif // __SBAMBUK_H