1 /*
2  * Software License Agreement (BSD License)
3  *
4  *  Point Cloud Library (PCL) - www.pointclouds.org
5  *  Copyright (c) 2009-2012, Willow Garage, Inc.
6  *  Copyright (c) 2012-, Open Perception, Inc.
7  *  Copyright (c) 2014, RadiantBlue Technologies, Inc.
8  *
9  *  All rights reserved.
10  *
11  *  Redistribution and use in source and binary forms, with or without
12  *  modification, are permitted provided that the following conditions
13  *  are met:
14  *
15  *   * Redistributions of source code must retain the above copyright
16  *     notice, this list of conditions and the following disclaimer.
17  *   * Redistributions in binary form must reproduce the above
18  *     copyright notice, this list of conditions and the following
19  *     disclaimer in the documentation and/or other materials provided
20  *     with the distribution.
21  *   * Neither the name of the copyright holder(s) nor the names of its
22  *     contributors may be used to endorse or promote products derived
23  *     from this software without specific prior written permission.
24  *
25  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  *  POSSIBILITY OF SUCH DAMAGE.
37  *
38  * $Id$
39  *
40  */
41 
42 #include <pcl/test/gtest.h>
43 #include <pcl/filters/local_maximum.h>
44 #include <pcl/point_types.h>
45 
46 using namespace pcl;
47 
48 PointCloud<PointXYZ> cloud;
49 
50 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(Filters,LocalMaximum)51 TEST (Filters, LocalMaximum)
52 {
53   PointCloud<PointXYZ> cloud_in, cloud_out;
54 
55   cloud_in.height = 1;
56   cloud_in.width = 3;
57   cloud_in.is_dense = true;
58   cloud_in.resize (4);
59 
60   cloud_in[0].x = 0;    cloud_in[0].y = 0;    cloud_in[0].z = 0.25;
61   cloud_in[1].x = 0.25; cloud_in[1].y = 0.25; cloud_in[1].z = 0.5;
62   cloud_in[2].x = 0.5;  cloud_in[2].y = 0.5;  cloud_in[2].z = 1;
63   cloud_in[3].x = 5;    cloud_in[3].y = 5;    cloud_in[3].z = 2;
64 
65   LocalMaximum<PointXYZ> lm;
66   lm.setInputCloud (cloud_in.makeShared ());
67   lm.setRadius (1.0f);
68   lm.filter (cloud_out);
69 
70   EXPECT_EQ (0.25f, cloud_out[0].z);
71   EXPECT_EQ (0.50f, cloud_out[1].z);
72   EXPECT_EQ (2.00f, cloud_out[2].z);
73   EXPECT_EQ (3, cloud_out.size ());
74 }
75 
76 /* ---[ */
77 int
main(int argc,char ** argv)78 main (int argc, char** argv)
79 {
80   testing::InitGoogleTest (&argc, argv);
81   return (RUN_ALL_TESTS ());
82 }
83 /* ]--- */
84 
85