visualize_helper 0.0.10.29 → 0.0.10.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/visualize_helper/visualize_helper.c +51 -18
- data/lib/visualize_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a43f8362f89d2ee8afeb4b22eacedb3d793fdce
|
4
|
+
data.tar.gz: 5f319c533271e960fc3d8d91c34f53f8747624dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a097988bed352e2e1ac6619a27420dbb75c166b93931aecb634f23d1887a0c568e60f27a87f7aff933b55d1b4502faa760fa374f4da48e7efddfb30cd3040d93
|
7
|
+
data.tar.gz: 0f2bf89d43064f67439042d9af694e2fe55972014b114a3e835cbae4f04131e786e9d45cc62d26b945481cfba0c2bcc916fff3e1dec692fc970fa85f976d0bc5
|
@@ -4,6 +4,19 @@
|
|
4
4
|
#include <stdio.h>
|
5
5
|
#include <math.h>
|
6
6
|
|
7
|
+
void RemoveSpaces(char* source)
|
8
|
+
{
|
9
|
+
char* i = source;
|
10
|
+
char* j = source;
|
11
|
+
while(*j != 0)
|
12
|
+
{
|
13
|
+
*i = *j++;
|
14
|
+
if(*i != ' ')
|
15
|
+
i++;
|
16
|
+
}
|
17
|
+
*i = 0;
|
18
|
+
}
|
19
|
+
|
7
20
|
|
8
21
|
int myCompare (const void * a, const void * b ) {
|
9
22
|
const char *pa = *(const char**)a;
|
@@ -62,8 +75,10 @@ static char* join(VALUE strings){
|
|
62
75
|
string_total_size += strlen(StringValuePtr(string_temp));
|
63
76
|
}
|
64
77
|
|
65
|
-
|
66
|
-
|
78
|
+
|
79
|
+
joined = (char*) malloc(string_total_size +strings_size + 1);
|
80
|
+
string_temp = rb_ary_entry(strings,0);
|
81
|
+
//string_size = strlen(StringValuePtr(string_temp));
|
67
82
|
sprintf(joined,"%s", StringValuePtr(string_temp));
|
68
83
|
|
69
84
|
|
@@ -73,6 +88,7 @@ static char* join(VALUE strings){
|
|
73
88
|
sprintf(joined,"%s,%s", joined, StringValuePtr(string_temp));
|
74
89
|
|
75
90
|
}
|
91
|
+
strcat(joined,"\0");
|
76
92
|
//result = rb_str_new2(joined);
|
77
93
|
//free(joined);
|
78
94
|
//fprintf(f,"%s\n",joined);
|
@@ -85,7 +101,7 @@ static char* join(VALUE strings){
|
|
85
101
|
// Receive an array of unsorted strings with repeated strings and return a single a sorted array with unique elementes or with all
|
86
102
|
// strings = array of strings
|
87
103
|
// unique = 0 or 1 if want to call unique or not
|
88
|
-
static VALUE sort_uniq(VALUE
|
104
|
+
static VALUE sort_uniq(VALUE strings, int unique)
|
89
105
|
{
|
90
106
|
int strings_size = RARRAY_LEN(strings);
|
91
107
|
const char *input[strings_size];
|
@@ -231,7 +247,7 @@ static VALUE remove_entry_from_array (VALUE strings, char* element){
|
|
231
247
|
}
|
232
248
|
|
233
249
|
// Function to generate the boxes and links of each trajectory
|
234
|
-
static VALUE generate_boxes_and_links(VALUE self, VALUE
|
250
|
+
static VALUE generate_boxes_and_links(VALUE self, VALUE aggr, VALUE boxes, VALUE links, VALUE dict, VALUE type_agroupment, VALUE value)
|
235
251
|
{
|
236
252
|
|
237
253
|
char* seq_key_result;
|
@@ -250,9 +266,10 @@ static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE ag
|
|
250
266
|
int aggr_prox_size;
|
251
267
|
int prox;
|
252
268
|
int aggr_size = RARRAY_LEN(aggr);
|
253
|
-
char* link_key;
|
269
|
+
char* link_key = (char*) malloc(1000);
|
254
270
|
char* period_s;
|
255
271
|
char* prox_s;
|
272
|
+
//FILE *f = fopen("/tmp/file.txt", "a");
|
256
273
|
|
257
274
|
for(int period = 0; period < aggr_size; period++ ){
|
258
275
|
seq_key = rb_ary_new();
|
@@ -276,10 +293,10 @@ static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE ag
|
|
276
293
|
// agroup by unique or not
|
277
294
|
if ( strcmp(StringValuePtr(type_agroupment),"s") == 0 ) {
|
278
295
|
//sort with uniq
|
279
|
-
seq_key = sort_uniq(
|
296
|
+
seq_key = sort_uniq(seq_key,1);
|
280
297
|
}else{
|
281
298
|
//sort without uniq
|
282
|
-
seq_key = sort_uniq(
|
299
|
+
seq_key = sort_uniq(seq_key,0);
|
283
300
|
}
|
284
301
|
|
285
302
|
// if there is "no-event" and other one selected, remove the "no-event"
|
@@ -315,15 +332,16 @@ static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE ag
|
|
315
332
|
// agroup by unique or not
|
316
333
|
if ( strcmp(StringValuePtr(type_agroupment),"n") == 0 ) {
|
317
334
|
//sort with uniq
|
318
|
-
prox_key = sort_uniq(
|
319
|
-
}else{
|
320
|
-
//sort without uniq
|
321
|
-
prox_key = prox_key;
|
335
|
+
prox_key = sort_uniq(prox_key,1);
|
322
336
|
}
|
337
|
+
//else{
|
338
|
+
// //sort without uniq
|
339
|
+
// prox_key = prox_key;
|
340
|
+
//}
|
323
341
|
|
324
342
|
//
|
325
343
|
// if there is "no-event" and other one selected, remove the "no-event"
|
326
|
-
length_prox_sorted = (strcmp(StringValuePtr(type_agroupment),"n") == 0 ) ? RARRAY_LEN(prox_key) : RARRAY_LEN(sort_uniq(
|
344
|
+
length_prox_sorted = (strcmp(StringValuePtr(type_agroupment),"n") == 0 ) ? RARRAY_LEN(prox_key) : RARRAY_LEN(sort_uniq(prox_key,1)) ;
|
327
345
|
if (length_prox_sorted != 1) {
|
328
346
|
prox_key = remove_entry_from_array(prox_key,"M-3");
|
329
347
|
}
|
@@ -336,8 +354,16 @@ static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE ag
|
|
336
354
|
prox_s = ( prox == 0 ) ? (char*) malloc(1) : (char*) malloc(floor(log10(abs(prox))) + 1);
|
337
355
|
sprintf(period_s,"%d",period);
|
338
356
|
sprintf(prox_s,"%d",prox);
|
339
|
-
link_key = (char*) malloc( strlen(period_s) + strlen(seq_key_result) + strlen(prox_s) + strlen(prox_key_result) + 3);
|
357
|
+
//link_key = (char*) malloc( strlen(period_s) + strlen(seq_key_result) + strlen(prox_s) + strlen(prox_key_result) + 3);
|
340
358
|
sprintf(link_key,"%s_%s;%s_%s", period_s,seq_key_result,prox_s,prox_key_result);
|
359
|
+
RemoveSpaces(link_key);
|
360
|
+
|
361
|
+
//fprintf(f,"Composicao key:\n");
|
362
|
+
//fprintf(f,"period_s: %s\n",period_s);
|
363
|
+
//fprintf(f,"seq_key: %s\n",seq_key_result);
|
364
|
+
//fprintf(f,"prox_s : %s\n",prox_s);
|
365
|
+
//fprintf(f,"prox_key_result: %s\n",prox_key_result);
|
366
|
+
//fprintf(f,"chave final : %s\n",link_key);
|
341
367
|
|
342
368
|
links_period_value = rb_hash_aref(rb_ary_entry(links,period),rb_str_new2(link_key));
|
343
369
|
if (links_period_value == Qnil) {
|
@@ -346,19 +372,26 @@ static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE ag
|
|
346
372
|
rb_hash_aset(rb_ary_entry(links,period),rb_str_new2(link_key), INT2FIX(FIX2INT(links_period_value) + FIX2INT(value)));
|
347
373
|
}
|
348
374
|
|
349
|
-
free(period_s);
|
350
|
-
free(prox_s);
|
351
|
-
free(link_key);
|
352
375
|
|
353
376
|
}//end prox < aggr_size
|
354
377
|
|
355
378
|
}// end for
|
356
379
|
|
380
|
+
free(period_s);
|
381
|
+
free(prox_s);
|
382
|
+
free(link_key);
|
383
|
+
|
384
|
+
//fclose(f);
|
357
385
|
//return result_final;
|
358
386
|
return Qnil;
|
359
387
|
}
|
360
388
|
|
361
389
|
|
390
|
+
static VALUE join_teste(VALUE self, VALUE strings){
|
391
|
+
|
392
|
+
return rb_str_new2(join(strings));
|
393
|
+
}
|
394
|
+
|
362
395
|
|
363
396
|
// Main function called when the gem is loaded
|
364
397
|
void Init_visualize_helper(void) {
|
@@ -370,11 +403,11 @@ void Init_visualize_helper(void) {
|
|
370
403
|
rb_define_singleton_method(mVisualizeHelper, "min_max_period", min_max_period, 5);
|
371
404
|
|
372
405
|
// Register the method generate_boxes_and_links
|
373
|
-
rb_define_singleton_method(mVisualizeHelper, "generate_boxes_and_links", generate_boxes_and_links,
|
406
|
+
rb_define_singleton_method(mVisualizeHelper, "generate_boxes_and_links", generate_boxes_and_links, 6);
|
374
407
|
|
375
408
|
// Register the method sort
|
376
409
|
rb_define_singleton_method(mVisualizeHelper, "sort_uniq", sort_uniq, 2 );
|
377
410
|
|
378
411
|
// Register the method sort
|
379
|
-
|
412
|
+
rb_define_singleton_method(mVisualizeHelper, "join_teste", join_teste, 1 );
|
380
413
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visualize_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.10.
|
4
|
+
version: 0.0.10.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Ottoni Santiago Machado de Faria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|