coloring_points_processor.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include "Eigen/Core"
21 #include "glog/logging.h"
22 
23 namespace cartographer {
24 namespace io {
25 
26 std::unique_ptr<ColoringPointsProcessor>
28  common::LuaParameterDictionary* const dictionary,
29  PointsProcessor* const next) {
30  const string frame_id = dictionary->GetString("frame_id");
31  const std::vector<double> color_values =
32  dictionary->GetDictionary("color")->GetArrayValuesAsDoubles();
33  const Color color = {{static_cast<uint8_t>(color_values[0]),
34  static_cast<uint8_t>(color_values[1]),
35  static_cast<uint8_t>(color_values[2])}};
36  return common::make_unique<ColoringPointsProcessor>(color, frame_id, next);
37 }
38 
40  const string& frame_id,
41  PointsProcessor* const next)
42  : color_(color), frame_id_(frame_id), next_(next) {}
43 
44 void ColoringPointsProcessor::Process(std::unique_ptr<PointsBatch> batch) {
45  if (batch->frame_id == frame_id_) {
46  batch->colors.clear();
47  for (size_t i = 0; i < batch->points.size(); ++i) {
48  batch->colors.push_back(color_);
49  }
50  }
51  next_->Process(std::move(batch));
52 }
53 
55  return next_->Flush();
56 }
57 
58 } // namespace io
59 } // namespace cartographer
virtual void Process(std::unique_ptr< PointsBatch > points_batch)=0
ColoringPointsProcessor(const Color &color, const string &frame_id, PointsProcessor *next)
void Process(std::unique_ptr< PointsBatch > batch) override
std::array< uint8_t, 3 > Color
Definition: points_batch.h:31
virtual FlushResult Flush()=0
std::unique_ptr< LuaParameterDictionary > GetDictionary(const string &key)
static std::unique_ptr< ColoringPointsProcessor > FromDictionary(common::LuaParameterDictionary *dictionary, PointsProcessor *next)


cartographer
Author(s):
autogenerated on Mon Jun 10 2019 12:51:38