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/grid_minimum.h>
44 #include <pcl/point_types.h>
45 
46 using namespace pcl;
47 
48 PointCloud<PointXYZ> cloud;
49 
50 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(Grid,Minimum)51 TEST (Grid, Minimum)
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 (3);
59 
60   cloud_in[0].x = 0; cloud_in[0].y = 0; cloud_in[0].z = 0.25;
61   cloud_in[1].x = 0.5; cloud_in[1].y = 0.5; cloud_in[1].z = 1;
62   cloud_in[2].x = 1.5; cloud_in[2].y = 1.5; cloud_in[2].z = 0.0;
63 
64   GridMinimum<PointXYZ> gm (1.0f);
65   gm.setInputCloud (cloud_in.makeShared ());
66   gm.filter (cloud_out);
67 
68   EXPECT_EQ (cloud_out[0].z, 0.25f);
69   EXPECT_EQ (cloud_out[1].z, 0.0f);
70   EXPECT_EQ (cloud_out.size (), 2);
71   EXPECT_EQ (gm.getResolution (), 1.0f);
72 
73   gm.setResolution (2.0f);
74   gm.filter (cloud_out);
75 
76   EXPECT_EQ (cloud_out[0].z, 0.0f);
77   EXPECT_EQ (cloud_out.size (), 1);
78   EXPECT_EQ (gm.getResolution (), 2.0f);
79 }
80 
81 /* ---[ */
82 int
main(int argc,char ** argv)83 main (int argc, char** argv)
84 {
85   testing::InitGoogleTest (&argc, argv);
86   return (RUN_ALL_TESTS ());
87 }
88 /* ]--- */
89 
90