Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
min_merge.cpp
1
2
/***************************************************************************
3
* min_merge.cpp - Laser min merge data filter
4
*
5
* Created: Wed Mar 16 21:46:36 2011
6
* Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include "min_merge.h"
24
25
#include <core/exception.h>
26
#include <cstring>
27
28
/** @class LaserMinMergeDataFilter "min_merge.h"
29
* Merge multiple laser data arrays into one.
30
* For each value in the output array takes the minimum value of all input
31
* arrays.
32
* @author Tim Niemueller
33
*/
34
35
/** Constructor.
36
* @param in_data_size number of entries input value arrays
37
* @param in vector of input arrays
38
*/
39
LaserMinMergeDataFilter::LaserMinMergeDataFilter
(
unsigned
int
in_data_size,
40
std::vector<LaserDataFilter::Buffer *> &in)
41
:
LaserDataFilter
(in_data_size, in, 1)
42
{
43
}
44
45
46
void
47
LaserMinMergeDataFilter::filter
()
48
{
49
const
unsigned
int
vecsize =
in
.size();
50
if
(vecsize == 0)
return
;
51
52
out
[0]->frame =
in
[0]->frame;
53
54
copy_to_outbuf
(
out
[0],
in
[0]);
55
float
*outbuf =
out
[0]->values;
56
57
for
(
unsigned
int
a = 1; a < vecsize; ++a) {
58
if
(
in
[a]->frame !=
out
[0]->frame) {
59
throw
fawkes::Exception
(
"MinMerge frame mismatch: two frames with different frame IDs "
60
"(first has %s but input buffer %u has %s)"
,
61
out
[0]->frame.c_str(), a,
in
[a]->frame.c_str());
62
}
63
float
*inbuf =
in
[a]->values;
64
for
(
unsigned
int
i = 0; i < (
const
unsigned
int)
out_data_size
; ++i) {
65
if
( (outbuf[i] == 0) || ((inbuf[i] != 0) && (inbuf[i] < outbuf[i])) ) {
66
outbuf[i] = inbuf[i];
67
}
68
}
69
}
70
}
src
plugins
laser-filter
filters
min_merge.cpp
Generated by
1.8.1.1