1 |
francois |
1061 |
// nUtil - An utility Library for gnurbs |
2 |
|
|
// Copyright (C) 2008-2019 Eric Bechet |
3 |
|
|
// |
4 |
|
|
// See the LICENSE file for contributions and license information. |
5 |
|
|
// Please report all bugs and problems to <bechet@cadxfem.org>. |
6 |
|
|
// |
7 |
|
|
|
8 |
|
|
#include "ndata.h" |
9 |
|
|
|
10 |
|
|
int my_stricmp ( const char *s1, const char*s2 ) |
11 |
|
|
{ |
12 |
|
|
int c1, c2; |
13 |
|
|
int cmp = 0; |
14 |
|
|
|
15 |
|
|
if (s1 && s2) |
16 |
|
|
for (;;) |
17 |
|
|
{ |
18 |
|
|
c1 = *s1++; |
19 |
|
|
c2 = *s2++; |
20 |
|
|
if (c1 && c2) |
21 |
|
|
{ |
22 |
|
|
c1 = tolower(c1)&0xFF; // 8 bits |
23 |
|
|
c2 = tolower(c2)&0xFF; // only |
24 |
|
|
if (c1 < c2) |
25 |
|
|
{ |
26 |
|
|
cmp = -1; |
27 |
|
|
break; |
28 |
|
|
} |
29 |
|
|
else if (c1 > c2) |
30 |
|
|
{ |
31 |
|
|
cmp = 1; |
32 |
|
|
break; |
33 |
|
|
} |
34 |
|
|
} |
35 |
|
|
else |
36 |
|
|
{ |
37 |
|
|
if (c1) |
38 |
|
|
cmp = 1; |
39 |
|
|
else if (c2) |
40 |
|
|
cmp = -1; |
41 |
|
|
break; |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
return cmp; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
std::ostream& operator<<(std::ostream& stream, |
48 |
|
|
const data_container& data) |
49 |
|
|
{ |
50 |
|
|
data.print(stream); |
51 |
|
|
return stream; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
int data_container::read(std::istream& stream) |
55 |
|
|
{ |
56 |
|
|
std::string buf; |
57 |
|
|
stream >> buf ; |
58 |
|
|
if (my_stricmp(buf.c_str(),"points")==0) // ok |
59 |
|
|
{ |
60 |
|
|
int npts; |
61 |
|
|
stream >> npts; |
62 |
|
|
// std::cout << "points " << npts << std::endl; |
63 |
|
|
points.resize(npts); |
64 |
|
|
for(int i=0;i<npts;++i) |
65 |
|
|
{ |
66 |
|
|
point p; |
67 |
|
|
int szbuf; |
68 |
|
|
stream >> p.pts[0] >> p.pts[1] >> p.pts[2] >> szbuf; |
69 |
|
|
if (szbuf) |
70 |
|
|
{ |
71 |
|
|
char str[szbuf+1];str[szbuf]=0x0; |
72 |
|
|
stream.read(str,1); |
73 |
|
|
stream.get(str,szbuf+1); |
74 |
|
|
std::string s(str); |
75 |
|
|
p.info=s; |
76 |
|
|
} |
77 |
|
|
// std::cout << p.pts << " " << p.info << std::endl; |
78 |
|
|
points[i]=p; |
79 |
|
|
} |
80 |
|
|
} |
81 |
|
|
else |
82 |
|
|
return -1; |
83 |
|
|
stream >> buf ; |
84 |
|
|
if (my_stricmp(buf.c_str(),"proppoints")==0) // ok |
85 |
|
|
{ |
86 |
|
|
int npts; |
87 |
|
|
stream >> npts; |
88 |
|
|
// std::cout << "proppoints " << npts << std::endl; |
89 |
|
|
proppoints.resize(npts); |
90 |
|
|
for(int i=0;i<npts;++i) |
91 |
|
|
{ |
92 |
|
|
int R,G,B,A,Re,Ge,Be,Ae,edgeon,teston; |
93 |
|
|
double thickness,edgethickness,pointsize; |
94 |
|
|
std::pair<properties,int> pp; |
95 |
|
|
stream >> buf >> pp.second >> R >> G >> B >> A >> pp.first.thickness >> pp.first.pointsize >> edgeon>> pp.first.edgethickness>> Re >> Ge >> Be >> Ae >> teston >> pp.first.nb_uid ; |
96 |
|
|
for (int ii=0;ii<pp.first.nb_uid;++ii) stream >> pp.first.uids[ii]; |
97 |
|
|
pp.first.c=color(R,G,B,A); |
98 |
|
|
pp.first.edgecolor=color(Re,Ge,Be,Ae); |
99 |
|
|
pp.first.edgeon=edgeon; |
100 |
|
|
pp.first.teston=teston; |
101 |
|
|
// std::cout << "from " << pp.second << std::endl; |
102 |
|
|
proppoints[i]=pp; |
103 |
|
|
} |
104 |
|
|
} |
105 |
|
|
else |
106 |
|
|
return -1; |
107 |
|
|
|
108 |
|
|
stream >> buf ; |
109 |
|
|
if (my_stricmp(buf.c_str(),"lines")==0) // ok |
110 |
|
|
{ |
111 |
|
|
int nl; |
112 |
|
|
stream >> nl; |
113 |
|
|
// std::cout << "lines " << nl << std::endl; |
114 |
|
|
lines.resize(nl); |
115 |
|
|
for(int i=0;i<nl;++i) |
116 |
|
|
{ |
117 |
|
|
line l; |
118 |
|
|
int szbuf; |
119 |
|
|
stream >> l.pts[0][0] >> l.pts[0][1] >> l.pts[0][2] >> l.pts[1][0] >> l.pts[1][1] >> l.pts[1][2] >> szbuf; |
120 |
|
|
if (szbuf) |
121 |
|
|
{ |
122 |
|
|
char str[szbuf+1];str[szbuf]=0x0; |
123 |
|
|
stream.read(str,1); |
124 |
|
|
stream.get(str,szbuf+1); |
125 |
|
|
std::string s(str); |
126 |
|
|
l.info=s; |
127 |
|
|
} |
128 |
|
|
// std::cout << l.pts[0] << " " << l.pts[1] << " " << l.info << std::endl; |
129 |
|
|
lines[i]=l; |
130 |
|
|
} |
131 |
|
|
} |
132 |
|
|
else |
133 |
|
|
return -1; |
134 |
|
|
stream >> buf ; |
135 |
|
|
if (my_stricmp(buf.c_str(),"proplines")==0) // ok |
136 |
|
|
{ |
137 |
|
|
int npts; |
138 |
|
|
stream >> npts; |
139 |
|
|
// std::cout << "proplines " << npts << std::endl; |
140 |
|
|
proplines.resize(npts); |
141 |
|
|
for(int i=0;i<npts;++i) |
142 |
|
|
{ |
143 |
|
|
int R,G,B,A,Re,Ge,Be,Ae,edgeon,teston; |
144 |
|
|
double thickness,edgethickness,pointsize; |
145 |
|
|
std::pair<properties,int> pp; |
146 |
|
|
stream >> buf >> pp.second >> R >> G >> B >> A >> pp.first.thickness >> pp.first.pointsize >> edgeon>> pp.first.edgethickness>> Re >> Ge >> Be >> Ae >> teston >> pp.first.nb_uid ; |
147 |
|
|
for (int ii=0;ii<pp.first.nb_uid;++ii) stream >> pp.first.uids[ii]; |
148 |
|
|
pp.first.c=color(R,G,B,A); |
149 |
|
|
pp.first.edgecolor=color(Re,Ge,Be,Ae); |
150 |
|
|
pp.first.edgeon=edgeon; |
151 |
|
|
pp.first.teston=teston; |
152 |
|
|
// std::cout << "from " << pp.second << std::endl; |
153 |
|
|
proplines[i]=pp; |
154 |
|
|
} |
155 |
|
|
} |
156 |
|
|
else |
157 |
|
|
return -1; |
158 |
|
|
|
159 |
|
|
|
160 |
|
|
stream >> buf ; |
161 |
|
|
if (my_stricmp(buf.c_str(),"triangles")==0) // ok |
162 |
|
|
{ |
163 |
|
|
int nt; |
164 |
|
|
stream >> nt; |
165 |
|
|
// std::cout << "triangles " << nt << std::endl; |
166 |
|
|
triangles.resize(nt); |
167 |
|
|
for(int i=0;i<nt;++i) |
168 |
|
|
{ |
169 |
|
|
triangle t; |
170 |
|
|
int szbuf; |
171 |
|
|
stream >> t.pts[0][0] >> t.pts[0][1] >> t.pts[0][2] >> t.pts[1][0] >> t.pts[1][1] >> t.pts[1][2] >> t.pts[2][0] >> t.pts[2][1] >> t.pts[2][2] >>szbuf; |
172 |
|
|
if (szbuf) |
173 |
|
|
{ |
174 |
|
|
char str[szbuf+1];str[szbuf]=0x0; |
175 |
|
|
stream.read(str,1); |
176 |
|
|
stream.get(str,szbuf+1); |
177 |
|
|
std::string s(str); |
178 |
|
|
t.info=s; |
179 |
|
|
} |
180 |
|
|
// std::cout << t.pts[0] << " " << t.pts[1] << " " << t.pts[2] << " " << t.info << std::endl; |
181 |
|
|
triangles[i]=t; |
182 |
|
|
} |
183 |
|
|
} |
184 |
|
|
else |
185 |
|
|
return -1; |
186 |
|
|
stream >> buf ; |
187 |
|
|
if (my_stricmp(buf.c_str(),"proptriangles")==0) // ok |
188 |
|
|
{ |
189 |
|
|
int npts; |
190 |
|
|
stream >> npts; |
191 |
|
|
// std::cout << "proptriangles " << npts << std::endl; |
192 |
|
|
proptriangles.resize(npts); |
193 |
|
|
for(int i=0;i<npts;++i) |
194 |
|
|
{ |
195 |
|
|
int R,G,B,A,Re,Ge,Be,Ae,edgeon,teston; |
196 |
|
|
double thickness,edgethickness,pointsize; |
197 |
|
|
std::pair<properties,int> pp; |
198 |
|
|
stream >> buf >> pp.second >> R >> G >> B >> A >> pp.first.thickness >> pp.first.pointsize >> edgeon>> pp.first.edgethickness>> Re >> Ge >> Be >> Ae >> teston >> pp.first.nb_uid ; |
199 |
|
|
for (int ii=0;ii<pp.first.nb_uid;++ii) stream >> pp.first.uids[ii]; |
200 |
|
|
pp.first.c=color(R,G,B,A); |
201 |
|
|
pp.first.edgecolor=color(Re,Ge,Be,Ae); |
202 |
|
|
pp.first.edgeon=edgeon; |
203 |
|
|
pp.first.teston=teston; |
204 |
|
|
// std::cout << "from " << pp.second << std::endl; |
205 |
|
|
proptriangles[i]=pp; |
206 |
|
|
} |
207 |
|
|
} |
208 |
|
|
else |
209 |
|
|
return -1; |
210 |
|
|
stream >> buf ; |
211 |
|
|
if (my_stricmp(buf.c_str(),"quads")==0) // ok |
212 |
|
|
{ |
213 |
|
|
int nt; |
214 |
|
|
stream >> nt; |
215 |
|
|
// std::cout << "quads " << nt << std::endl; |
216 |
|
|
quads.resize(nt); |
217 |
|
|
for(int i=0;i<nt;++i) |
218 |
|
|
{ |
219 |
|
|
quad t; |
220 |
|
|
int szbuf; |
221 |
|
|
stream >> t.pts[0][0] >> t.pts[0][1] >> t.pts[0][2] >> t.pts[1][0] >> t.pts[1][1] >> t.pts[1][2] >> t.pts[2][0] >> t.pts[2][1] >> t.pts[2][2] >> t.pts[3][0] >> t.pts[3][1] >> t.pts[3][2] >>szbuf; |
222 |
|
|
if (szbuf) |
223 |
|
|
{ |
224 |
|
|
char str[szbuf+1];str[szbuf]=0x0; |
225 |
|
|
stream.read(str,1); |
226 |
|
|
stream.get(str,szbuf+1); |
227 |
|
|
std::string s(str); |
228 |
|
|
t.info=s; |
229 |
|
|
} |
230 |
|
|
// std::cout << t.pts[0] << " " << t.pts[1] << " " << t.pts[2] << " " << t.pts[3] << " " << t.info << std::endl; |
231 |
|
|
quads[i]=t; |
232 |
|
|
} |
233 |
|
|
} |
234 |
|
|
else |
235 |
|
|
return -1; |
236 |
|
|
stream >> buf ; |
237 |
|
|
if (my_stricmp(buf.c_str(),"propquads")==0) // ok |
238 |
|
|
{ |
239 |
|
|
int npts; |
240 |
|
|
stream >> npts; |
241 |
|
|
// std::cout << "propquads " << npts << std::endl; |
242 |
|
|
propquads.resize(npts); |
243 |
|
|
for(int i=0;i<npts;++i) |
244 |
|
|
{ |
245 |
|
|
int R,G,B,A,Re,Ge,Be,Ae,edgeon,teston; |
246 |
|
|
double thickness,edgethickness,pointsize; |
247 |
|
|
std::pair<properties,int> pp; |
248 |
|
|
stream >> buf >> pp.second >> R >> G >> B >> A >> pp.first.thickness >> pp.first.pointsize >> edgeon>> pp.first.edgethickness>> Re >> Ge >> Be >> Ae >> teston >> pp.first.nb_uid ; |
249 |
|
|
for (int ii=0;ii<pp.first.nb_uid;++ii) stream >> pp.first.uids[ii]; |
250 |
|
|
pp.first.c=color(R,G,B,A); |
251 |
|
|
pp.first.edgecolor=color(Re,Ge,Be,Ae); |
252 |
|
|
pp.first.edgeon=edgeon; |
253 |
|
|
pp.first.teston=teston; |
254 |
|
|
// std::cout << "from " << pp.second << std::endl; |
255 |
|
|
propquads[i]=pp; |
256 |
|
|
} |
257 |
|
|
} |
258 |
|
|
else |
259 |
|
|
return -1; |
260 |
|
|
for(int i=0;i<3;++i) |
261 |
|
|
{ |
262 |
|
|
int n,nb; |
263 |
|
|
stream >> buf >> n >> nb; |
264 |
|
|
// std::cout << "texts " << n << " " << nb << std::endl; |
265 |
|
|
if ((my_stricmp(buf.c_str(),"texts")==0)&&(n==i)) // ok |
266 |
|
|
{ |
267 |
|
|
texts[i].resize(nb); |
268 |
|
|
for(int p=0;p< nb;++p) |
269 |
|
|
{ |
270 |
|
|
point pt;int R,G,B,A,szbuf; |
271 |
|
|
stream >> pt.pts[0] >> pt.pts[1] >> pt.pts[2] >> R >> G >> B >> A >> szbuf; |
272 |
|
|
if (szbuf) |
273 |
|
|
{ |
274 |
|
|
char str[szbuf+1];str[szbuf]=0x0; |
275 |
|
|
stream.read(str,1); |
276 |
|
|
stream.get(str,szbuf+1); |
277 |
|
|
std::string s(str); |
278 |
|
|
pt.info=s; |
279 |
|
|
} |
280 |
|
|
// std::cout << pt.pts << " " << pt.info << std::endl; |
281 |
|
|
texts[i][p]=std::pair<point,color>(pt,color(R,G,B,A)); |
282 |
|
|
} |
283 |
|
|
} |
284 |
|
|
else return -1; |
285 |
|
|
} |
286 |
|
|
return 0; |
287 |
|
|
} |
288 |
|
|
|
289 |
|
|
|
290 |
|
|
void data_container::unhide() const |
291 |
|
|
{ |
292 |
|
|
for(int p=0;p< points.size();++p) |
293 |
|
|
{ |
294 |
|
|
points[p].drawable=true; |
295 |
|
|
} |
296 |
|
|
for(int p=0;p< lines.size();++p) |
297 |
|
|
{ |
298 |
|
|
lines[p].drawable=true; |
299 |
|
|
} |
300 |
|
|
for(int p=0;p< triangles.size();++p) |
301 |
|
|
{ |
302 |
|
|
triangles[p].drawable=true; |
303 |
|
|
} |
304 |
|
|
for(int p=0;p< quads.size();++p) |
305 |
|
|
{ |
306 |
|
|
quads[p].drawable=true; |
307 |
|
|
} |
308 |
|
|
|
309 |
|
|
|
310 |
|
|
} |
311 |
|
|
|
312 |
|
|
|
313 |
|
|
void data_container::print(std::ostream& stream) const |
314 |
|
|
{ |
315 |
|
|
stream << "points " << points.size() << std::endl; |
316 |
|
|
for(int p=0;p< points.size();++p) |
317 |
|
|
{ |
318 |
|
|
stream << points[p].pts << " " << points[p].info.length() << " " << points[p].info << std::endl; |
319 |
|
|
} |
320 |
|
|
stream << "proppoints " << proppoints.size() << std::endl; |
321 |
|
|
for(int p=0;p< proppoints.size();++p) |
322 |
|
|
{ |
323 |
|
|
stream << "from " << proppoints[p].second << std::endl; |
324 |
|
|
properties pr=proppoints[p].first; |
325 |
|
|
stream << (int)pr.c.R << " " << (int)pr.c.G << " " <<(int) pr.c.B << " " << (int)pr.c.A << " " ; |
326 |
|
|
stream << pr.thickness << " " << pr.pointsize << " " << pr.edgeon << " " << pr.edgethickness << " "; |
327 |
|
|
stream << (int)pr.edgecolor.R << " " <<(int)pr.edgecolor.G << " " <<(int)pr.edgecolor.B << " " <<(int)pr.edgecolor.A << " "; |
328 |
|
|
stream << pr.teston << " " << pr.nb_uid << " "; |
329 |
|
|
for (int i=0;i<pr.nb_uid;++i) stream << pr.uids[i] << " "; |
330 |
|
|
stream << std::endl; |
331 |
|
|
} |
332 |
|
|
|
333 |
|
|
stream << "lines " << lines.size() << std::endl; |
334 |
|
|
for(int p=0;p< lines.size();++p) |
335 |
|
|
{ |
336 |
|
|
stream << lines[p].pts[0] << " " << lines[p].pts[1]<< " " << lines[p].info.length() << " " << lines[p].info << std::endl; |
337 |
|
|
} |
338 |
|
|
stream << "proplines " << proplines.size() << std::endl; |
339 |
|
|
for(int p=0;p< proplines.size();++p) |
340 |
|
|
{ |
341 |
|
|
stream << "from " << proplines[p].second << std::endl; |
342 |
|
|
properties pr=proplines[p].first; |
343 |
|
|
stream << (int)pr.c.R << " " << (int)pr.c.G << " " <<(int) pr.c.B << " " << (int)pr.c.A << " " ; |
344 |
|
|
stream << pr.thickness << " " << pr.pointsize << " " << pr.edgeon << " " << pr.edgethickness << " "; |
345 |
|
|
stream << (int)pr.edgecolor.R << " " <<(int)pr.edgecolor.G << " " <<(int)pr.edgecolor.B << " " <<(int)pr.edgecolor.A << " "; |
346 |
|
|
stream << pr.teston << " " << pr.nb_uid << " "; |
347 |
|
|
for (int i=0;i<pr.nb_uid;++i) stream << pr.uids[i] << " "; |
348 |
|
|
stream << std::endl; |
349 |
|
|
} |
350 |
|
|
|
351 |
|
|
stream << "triangles " << triangles.size() << std::endl; |
352 |
|
|
for(int p=0;p< triangles.size();++p) |
353 |
|
|
{ |
354 |
|
|
stream << triangles[p].pts[0] << " " << triangles[p].pts[1] << " " << triangles[p].pts[2]<< " " << triangles[p].info.length() <<" " << triangles[p].info << std::endl; |
355 |
|
|
} |
356 |
|
|
stream << "proptriangles " << proptriangles.size() << std::endl; |
357 |
|
|
for(int p=0;p< proptriangles.size();++p) |
358 |
|
|
{ |
359 |
|
|
stream << "from " << proptriangles[p].second << std::endl; |
360 |
|
|
properties pr=proptriangles[p].first; |
361 |
|
|
stream << (int)pr.c.R << " " << (int)pr.c.G << " " <<(int) pr.c.B << " " << (int)pr.c.A << " " ; |
362 |
|
|
stream << pr.thickness << " " << pr.pointsize << " " << pr.edgeon << " " << pr.edgethickness << " "; |
363 |
|
|
stream << (int)pr.edgecolor.R << " " <<(int)pr.edgecolor.G << " " <<(int)pr.edgecolor.B << " " <<(int)pr.edgecolor.A << " "; |
364 |
|
|
stream << pr.teston << " " << pr.nb_uid << " "; |
365 |
|
|
for (int i=0;i<pr.nb_uid;++i) stream << pr.uids[i] << " "; |
366 |
|
|
stream << std::endl; |
367 |
|
|
} |
368 |
|
|
|
369 |
|
|
stream << "quads " << quads.size() << std::endl; |
370 |
|
|
for(int p=0;p< quads.size();++p) |
371 |
|
|
{ |
372 |
|
|
stream << quads[p].pts[0] << " " << quads[p].pts[1] << " " << quads[p].pts[2]<< " " << quads[p].pts[3]<< " "<< quads[p].info.length() << " " << quads[p].info << std::endl; |
373 |
|
|
} |
374 |
|
|
stream << "propquads " << propquads.size() << std::endl; |
375 |
|
|
for(int p=0;p< propquads.size();++p) |
376 |
|
|
{ |
377 |
|
|
stream << "from " << propquads[p].second << std::endl; |
378 |
|
|
properties pr=propquads[p].first; |
379 |
|
|
stream << (int)pr.c.R << " " << (int)pr.c.G << " " <<(int) pr.c.B << " " << (int)pr.c.A << " " ; |
380 |
|
|
stream << pr.thickness << " " << pr.pointsize << " " << pr.edgeon << " " << pr.edgethickness << " "; |
381 |
|
|
stream << (int)pr.edgecolor.R << " " <<(int)pr.edgecolor.G << " " <<(int)pr.edgecolor.B << " " <<(int)pr.edgecolor.A << " "; |
382 |
|
|
stream << pr.teston << " " << pr.nb_uid << " "; |
383 |
|
|
for (int i=0;i<pr.nb_uid;++i) stream << pr.uids[i] << " "; |
384 |
|
|
stream << std::endl; |
385 |
|
|
} |
386 |
|
|
for(int i=0;i<3;++i) |
387 |
|
|
{ |
388 |
|
|
stream << "texts " << i << " " << texts[i].size() << std::endl; |
389 |
|
|
for(int p=0;p< texts[i].size();++p) |
390 |
|
|
{ |
391 |
|
|
stream << texts[i][p].first.pts << " " << (int) texts[i][p].second.R << " " << (int) texts[i][p].second.G << " " << (int) texts[i][p].second.B << " " << (int) texts[i][p].second.A<< " " << texts[i][p].first.info.length() << " " << texts[i][p].first.info << std::endl; |
392 |
|
|
} |
393 |
|
|
} |
394 |
|
|
} |
395 |
|
|
|
396 |
|
|
data_container::data_container(void) |
397 |
|
|
{ |
398 |
|
|
setcolorpoints(color()); |
399 |
|
|
setcolorlines(color()); |
400 |
|
|
setcolortriangles(color()); |
401 |
|
|
setcolorquads(color()); |
402 |
|
|
} |
403 |
|
|
|
404 |
|
|
data_container::data_container(const data_container &other) |
405 |
|
|
{ |
406 |
|
|
merge(other); |
407 |
|
|
} |
408 |
|
|
|
409 |
|
|
void data_container::merge(const data_container &other) |
410 |
|
|
{ |
411 |
|
|
int size1,propsize1; |
412 |
|
|
|
413 |
|
|
size1=points.size(); |
414 |
|
|
points.reserve(points.size() + other.points.size() ); |
415 |
|
|
points.insert(points.end(), other.points.begin(), other.points.end()); |
416 |
|
|
proppoints.reserve(proppoints.size() + other.proppoints.size() ); |
417 |
|
|
propsize1=proppoints.size(); |
418 |
|
|
proppoints.insert(proppoints.end(), other.proppoints.begin(), other.proppoints.end()); |
419 |
|
|
if (size1) |
420 |
|
|
for (int i=propsize1;i<proppoints.size();++i) // adjust links to properties! |
421 |
|
|
proppoints[i].second+=size1; |
422 |
|
|
|
423 |
|
|
size1=lines.size(); |
424 |
|
|
lines.reserve(lines.size() + other.lines.size() ); |
425 |
|
|
lines.insert(lines.end(), other.lines.begin(), other.lines.end()); |
426 |
|
|
proplines.reserve(proplines.size() + other.proplines.size() ); |
427 |
|
|
propsize1=proplines.size(); |
428 |
|
|
proplines.insert(proplines.end(), other.proplines.begin(), other.proplines.end()); |
429 |
|
|
if (size1) |
430 |
|
|
for (int i=propsize1;i<proplines.size();++i) // adjust links to properties! |
431 |
|
|
proplines[i].second+=size1; |
432 |
|
|
|
433 |
|
|
|
434 |
|
|
size1=triangles.size(); |
435 |
|
|
triangles.reserve(triangles.size() + other.triangles.size() ); |
436 |
|
|
triangles.insert(triangles.end(), other.triangles.begin(), other.triangles.end()); |
437 |
|
|
proptriangles.reserve(proptriangles.size() + other.proptriangles.size() ); |
438 |
|
|
propsize1=proptriangles.size(); |
439 |
|
|
proptriangles.insert(proptriangles.end(), other.proptriangles.begin(), other.proptriangles.end()); |
440 |
|
|
if (size1) |
441 |
|
|
for (int i=propsize1;i<proptriangles.size();++i) // adjust links to properties! |
442 |
|
|
proptriangles[i].second+=size1; |
443 |
|
|
|
444 |
|
|
size1=quads.size(); |
445 |
|
|
quads.reserve(quads.size() + other.quads.size() ); |
446 |
|
|
quads.insert(quads.end(), other.quads.begin(), other.quads.end()); |
447 |
|
|
propquads.reserve(propquads.size() + other.propquads.size() ); |
448 |
|
|
propsize1=propquads.size(); |
449 |
|
|
propquads.insert(propquads.end(), other.propquads.begin(), other.propquads.end()); |
450 |
|
|
if (size1) |
451 |
|
|
for (int i=propsize1;i<propquads.size();++i) // adjust links to properties! |
452 |
|
|
propquads[i].second+=size1; |
453 |
|
|
|
454 |
|
|
for (int i=0;i<3;++i) |
455 |
|
|
{ |
456 |
|
|
texts[i].reserve(texts[i].size() + other.texts[i].size() ); |
457 |
|
|
texts[i].insert(texts[i].end(), other.texts[i].begin(), other.texts[i].end()); |
458 |
|
|
} |
459 |
|
|
} |
460 |
|
|
|
461 |
|
|
|
462 |
|
|
void data_container::clear(void) |
463 |
|
|
{ |
464 |
|
|
points.clear(); |
465 |
|
|
lines.clear(); |
466 |
|
|
triangles.clear(); |
467 |
|
|
quads.clear(); |
468 |
|
|
proppoints.clear(); |
469 |
|
|
proplines.clear(); |
470 |
|
|
proptriangles.clear(); |
471 |
|
|
propquads.clear(); |
472 |
|
|
setcolorpoints(color()); |
473 |
|
|
setcolorlines(color()); |
474 |
|
|
setcolortriangles(color()); |
475 |
|
|
setcolorquads(color()); |
476 |
|
|
} |
477 |
|
|
|
478 |
|
|
const color& data_container::getcolorpoints(int i) const |
479 |
|
|
{ |
480 |
|
|
return proppoints[i].first.c; |
481 |
|
|
} |
482 |
|
|
|
483 |
|
|
const color& data_container::getcolorlines(int i) const |
484 |
|
|
{ |
485 |
|
|
return proplines[i].first.c; |
486 |
|
|
} |
487 |
|
|
|
488 |
|
|
const color& data_container::getcolortriangles(int i) const |
489 |
|
|
{ |
490 |
|
|
return proptriangles[i].first.c; |
491 |
|
|
} |
492 |
|
|
|
493 |
|
|
const color& data_container::getcolorquads(int i) const |
494 |
|
|
{ |
495 |
|
|
return propquads[i].first.c; |
496 |
|
|
} |
497 |
|
|
|
498 |
|
|
const properties& data_container::getproppoints(int i) const |
499 |
|
|
{ |
500 |
|
|
return proppoints[i].first; |
501 |
|
|
} |
502 |
|
|
|
503 |
|
|
const properties& data_container::getproplines(int i) const |
504 |
|
|
{ |
505 |
|
|
return proplines[i].first; |
506 |
|
|
} |
507 |
|
|
|
508 |
|
|
const properties& data_container::getproptriangles(int i) const |
509 |
|
|
{ |
510 |
|
|
return proptriangles[i].first; |
511 |
|
|
} |
512 |
|
|
|
513 |
|
|
const properties& data_container::getpropquads(int i) const |
514 |
|
|
{ |
515 |
|
|
return propquads[i].first; |
516 |
|
|
} |
517 |
|
|
|
518 |
|
|
|
519 |
|
|
const properties data_container::getproppoints() const |
520 |
|
|
{ |
521 |
|
|
if (getnumproppoints()!=0) |
522 |
|
|
return proppoints[getnumproppoints()-1].first; |
523 |
|
|
else |
524 |
|
|
return properties(); |
525 |
|
|
} |
526 |
|
|
|
527 |
|
|
const properties data_container::getproplines() const |
528 |
|
|
{ |
529 |
|
|
if (getnumproplines()!=0) |
530 |
|
|
return proplines[getnumproplines()-1].first; |
531 |
|
|
else |
532 |
|
|
return properties(); |
533 |
|
|
} |
534 |
|
|
|
535 |
|
|
const properties data_container::getproptriangles() const |
536 |
|
|
{ |
537 |
|
|
if (getnumproptriangles()!=0) |
538 |
|
|
return proptriangles[getnumproptriangles()-1].first; |
539 |
|
|
else |
540 |
|
|
return properties(); |
541 |
|
|
} |
542 |
|
|
|
543 |
|
|
const properties data_container::getpropquads() const |
544 |
|
|
{ |
545 |
|
|
if (getnumpropquads()!=0) |
546 |
|
|
return propquads[getnumpropquads()-1].first; |
547 |
|
|
else |
548 |
|
|
return properties(); |
549 |
|
|
} |
550 |
|
|
|
551 |
|
|
|
552 |
|
|
|
553 |
|
|
|
554 |
|
|
int data_container::getindexpoints(int i) const |
555 |
|
|
{ |
556 |
|
|
return proppoints[i].second; |
557 |
|
|
} |
558 |
|
|
|
559 |
|
|
int data_container::getindexlines(int i) const |
560 |
|
|
{ |
561 |
|
|
return proplines[i].second; |
562 |
|
|
} |
563 |
|
|
|
564 |
|
|
int data_container::getindextriangles(int i) const |
565 |
|
|
{ |
566 |
|
|
return proptriangles[i].second; |
567 |
|
|
} |
568 |
|
|
|
569 |
|
|
int data_container::getindexquads(int i) const |
570 |
|
|
{ |
571 |
|
|
return propquads[i].second; |
572 |
|
|
} |
573 |
|
|
|
574 |
|
|
int data_container::getnumproppoints(void) const |
575 |
|
|
{ |
576 |
|
|
return proppoints.size(); |
577 |
|
|
} |
578 |
|
|
|
579 |
|
|
int data_container::getnumproplines(void) const |
580 |
|
|
{ |
581 |
|
|
return proplines.size(); |
582 |
|
|
} |
583 |
|
|
|
584 |
|
|
int data_container::getnumproptriangles(void) const |
585 |
|
|
{ |
586 |
|
|
return proptriangles.size(); |
587 |
|
|
} |
588 |
|
|
|
589 |
|
|
int data_container::getnumpropquads(void) const |
590 |
|
|
{ |
591 |
|
|
return propquads.size(); |
592 |
|
|
} |
593 |
|
|
|
594 |
|
|
void data_container::setcolorpoints(color c) |
595 |
|
|
{ |
596 |
|
|
properties p=getproppoints(); |
597 |
|
|
p.c=c; |
598 |
|
|
setproppoints(p); |
599 |
|
|
} |
600 |
|
|
|
601 |
|
|
void data_container::setcolorlines(color c) |
602 |
|
|
{ |
603 |
|
|
properties p=getproplines(); |
604 |
|
|
p.c=c; |
605 |
|
|
setproplines(p); |
606 |
|
|
} |
607 |
|
|
|
608 |
|
|
void data_container::setcolortriangles(color c) |
609 |
|
|
{ |
610 |
|
|
properties p=getproptriangles(); |
611 |
|
|
p.c=c; |
612 |
|
|
setproptriangles(p); |
613 |
|
|
} |
614 |
|
|
|
615 |
|
|
void data_container::setcolorquads(color c) |
616 |
|
|
{ |
617 |
|
|
properties p=getpropquads(); |
618 |
|
|
p.c=c; |
619 |
|
|
setpropquads(p); |
620 |
|
|
} |
621 |
|
|
|
622 |
|
|
void data_container::setproppoints(properties p) |
623 |
|
|
{ |
624 |
|
|
proppoints.push_back(std::make_pair(p,points.size())); |
625 |
|
|
} |
626 |
|
|
|
627 |
|
|
void data_container::setproplines(properties p) |
628 |
|
|
{ |
629 |
|
|
proplines.push_back(std::make_pair(p,lines.size())); |
630 |
|
|
} |
631 |
|
|
|
632 |
|
|
|
633 |
|
|
void data_container::setproptriangles(properties p) |
634 |
|
|
{ |
635 |
|
|
proptriangles.push_back(std::make_pair(p,triangles.size())); |
636 |
|
|
} |
637 |
|
|
|
638 |
|
|
void data_container::setpropquads(properties p) |
639 |
|
|
{ |
640 |
|
|
propquads.push_back(std::make_pair(p,quads.size())); |
641 |
|
|
} |
642 |
|
|
|
643 |
|
|
void data_container::setpropall(properties p) |
644 |
|
|
{ |
645 |
|
|
proppoints.push_back(std::make_pair(p,points.size())); |
646 |
|
|
proplines.push_back(std::make_pair(p,lines.size())); |
647 |
|
|
proptriangles.push_back(std::make_pair(p,triangles.size())); |
648 |
|
|
propquads.push_back(std::make_pair(p,quads.size())); |
649 |
|
|
} |
650 |
|
|
|
651 |
|
|
int data_container::add_point(const point& src) |
652 |
|
|
{ |
653 |
|
|
points.push_back(src); |
654 |
|
|
return points.size()-1; |
655 |
|
|
} |
656 |
|
|
|
657 |
|
|
int data_container::add_point(const npoint3& src) |
658 |
|
|
{ |
659 |
|
|
point p;p.pts=src; |
660 |
|
|
points.push_back(p); |
661 |
|
|
return points.size()-1; |
662 |
|
|
} |
663 |
|
|
|
664 |
|
|
int data_container::add_line(const line& src) |
665 |
|
|
{ |
666 |
|
|
lines.push_back(src); |
667 |
|
|
return lines.size()-1; |
668 |
|
|
} |
669 |
|
|
|
670 |
|
|
int data_container::add_triangle(const triangle& src) |
671 |
|
|
{ |
672 |
|
|
triangles.push_back(src); |
673 |
|
|
return triangles.size()-1; |
674 |
|
|
} |
675 |
|
|
|
676 |
|
|
int data_container::add_quad(const quad& src) |
677 |
|
|
{ |
678 |
|
|
quads.push_back(src); |
679 |
|
|
return quads.size()-1; |
680 |
|
|
} |
681 |
|
|
|
682 |
|
|
int data_container::add_text(int num,const std::pair<point,color>& src) |
683 |
|
|
{ |
684 |
|
|
texts[num].push_back(src); |
685 |
|
|
return texts[num].size()-1; |
686 |
|
|
} |
687 |
|
|
int data_container::nb_points(void) const |
688 |
|
|
{ |
689 |
|
|
return points.size(); |
690 |
|
|
} |
691 |
|
|
|
692 |
|
|
int data_container::nb_lines(void) const |
693 |
|
|
{ |
694 |
|
|
return lines.size(); |
695 |
|
|
} |
696 |
|
|
|
697 |
|
|
int data_container::nb_triangles(void) const |
698 |
|
|
{ |
699 |
|
|
return triangles.size(); |
700 |
|
|
} |
701 |
|
|
|
702 |
|
|
int data_container::nb_quads(void) const |
703 |
|
|
{ |
704 |
|
|
return quads.size(); |
705 |
|
|
} |
706 |
|
|
|
707 |
|
|
int data_container::nb_texts(int num) const |
708 |
|
|
{ |
709 |
|
|
return texts[num].size(); |
710 |
|
|
} |
711 |
|
|
|
712 |
|
|
const point& data_container::get_point(int i) const |
713 |
|
|
{ |
714 |
|
|
return points[i]; |
715 |
|
|
} |
716 |
|
|
|
717 |
|
|
const line& data_container::get_line(int i) const |
718 |
|
|
{ |
719 |
|
|
return lines[i]; |
720 |
|
|
} |
721 |
|
|
|
722 |
|
|
const triangle& data_container::get_triangle(int i) const |
723 |
|
|
{ |
724 |
|
|
return triangles[i]; |
725 |
|
|
} |
726 |
|
|
|
727 |
|
|
const quad& data_container::get_quad(int i) const |
728 |
|
|
{ |
729 |
|
|
return quads[i]; |
730 |
|
|
} |
731 |
|
|
const point& data_container::get_text(int num,int i) const |
732 |
|
|
{ |
733 |
|
|
return texts[num][i].first; |
734 |
|
|
} |
735 |
|
|
const color& data_container::get_text_color(int num,int i) const |
736 |
|
|
{ |
737 |
|
|
return texts[num][i].second; |
738 |
|
|
} |
739 |
|
|
|
740 |
|
|
point& data_container::get_point(int i) |
741 |
|
|
{ |
742 |
|
|
return points[i]; |
743 |
|
|
} |
744 |
|
|
|
745 |
|
|
line& data_container::get_line(int i) |
746 |
|
|
{ |
747 |
|
|
return lines[i]; |
748 |
|
|
} |
749 |
|
|
|
750 |
|
|
triangle& data_container::get_triangle(int i) |
751 |
|
|
{ |
752 |
|
|
return triangles[i]; |
753 |
|
|
} |
754 |
|
|
|
755 |
|
|
quad& data_container::get_quad(int i) |
756 |
|
|
{ |
757 |
|
|
return quads[i]; |
758 |
|
|
} |
759 |
|
|
point& data_container::get_text(int num,int i) |
760 |
|
|
{ |
761 |
|
|
return texts[num][i].first; |
762 |
|
|
} |
763 |
|
|
color& data_container::get_text_color(int num,int i) |
764 |
|
|
{ |
765 |
|
|
return texts[num][i].second; |
766 |
|
|
} |