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 std::string frame_id = dictionary->GetString("frame_id");
31  const std::vector<double> color_values =
32  dictionary->GetDictionary("color")->GetArrayValuesAsDoubles();
33  const Uint8Color color = {{static_cast<uint8>(color_values[0]),
34  static_cast<uint8>(color_values[1]),
35  static_cast<uint8>(color_values[2])}};
36  return common::make_unique<ColoringPointsProcessor>(ToFloatColor(color),
37  frame_id, next);
38 }
39 
41  const std::string& frame_id,
42  PointsProcessor* const next)
43  : color_(color), frame_id_(frame_id), next_(next) {}
44 
45 void ColoringPointsProcessor::Process(std::unique_ptr<PointsBatch> batch) {
46  if (batch->frame_id == frame_id_) {
47  batch->colors.clear();
48  for (size_t i = 0; i < batch->points.size(); ++i) {
49  batch->colors.push_back(color_);
50  }
51  }
52  next_->Process(std::move(batch));
53 }
54 
56  return next_->Flush();
57 }
58 
59 } // namespace io
60 } // namespace cartographer
virtual void Process(std::unique_ptr< PointsBatch > points_batch)=0
FloatColor ToFloatColor(const Uint8Color &color)
Definition: color.h:47
void Process(std::unique_ptr< PointsBatch > batch) override
std::array< uint8, 3 > Uint8Color
Definition: color.h:28
std::array< float, 3 > FloatColor
Definition: color.h:29
virtual FlushResult Flush()=0
ColoringPointsProcessor(const FloatColor &color, const std::string &frame_id, PointsProcessor *next)
std::unique_ptr< LuaParameterDictionary > GetDictionary(const std::string &key)
static std::unique_ptr< ColoringPointsProcessor > FromDictionary(common::LuaParameterDictionary *dictionary, PointsProcessor *next)
uint8_t uint8
Definition: port.h:34


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58