21 #include <rapidxml.hpp> 22 #include <rapidxml_utils.hpp> 48 auto cropBoxPtrList = boost::make_shared<std::vector<CropBoxWrapperPtr>>();
50 debugHelperPtr->write(std::stringstream() <<
"Path to CropBoxList xml file: " << xml_path,
53 rapidxml::file<> xmlFile(xml_path.c_str());
54 rapidxml::xml_document<> doc;
55 doc.parse<0>(xmlFile.data());
57 rapidxml::xml_node<> *root_node = doc.first_node();
59 rapidxml::xml_node<> *child_node = root_node->first_node();
64 rapidxml::xml_node<> * min_pt = child_node->first_node(
"min_pt");
65 rapidxml::xml_attribute<> *
x = min_pt->first_attribute(
"x");
66 rapidxml::xml_attribute<> *
y = min_pt->first_attribute(
"y");
67 rapidxml::xml_attribute<> *
z = min_pt->first_attribute(
"z");
70 double x_ = boost::lexical_cast<
double>(x->value());
71 double y_ = boost::lexical_cast<
double>(y->value());
72 double z_ = boost::lexical_cast<
double>(z->value());
73 Eigen::Vector4f pt_min(x_,y_,z_,1);
74 bufferCropBoxPtr->setMin(pt_min);
77 rapidxml::xml_node<> * max_pt = child_node->first_node(
"max_pt");
78 x = max_pt->first_attribute(
"x");
79 y = max_pt->first_attribute(
"y");
80 z = max_pt->first_attribute(
"z");
83 double x_ = boost::lexical_cast<
double>(x->value());
84 double y_ = boost::lexical_cast<
double>(y->value());
85 double z_ = boost::lexical_cast<
double>(z->value());
86 Eigen::Vector4f pt_max(x_,y_,z_,1);
87 bufferCropBoxPtr->setMax(pt_max);
90 rapidxml::xml_node<> * rotation = child_node->first_node(
"rotation");
91 x = rotation->first_attribute(
"x");
92 y = rotation->first_attribute(
"y");
93 z = rotation->first_attribute(
"z");
96 double x_ = boost::lexical_cast<
double>(x->value());
97 double y_ = boost::lexical_cast<
double>(y->value());
98 double z_ = boost::lexical_cast<
double>(z->value());
99 Eigen::Vector3f rotation(x_,y_,z_);
100 bufferCropBoxPtr->setRotation(rotation);
103 rapidxml::xml_node<> * translation = child_node->first_node(
"translation");
104 x = translation->first_attribute(
"x");
105 y = translation->first_attribute(
"y");
106 z = translation->first_attribute(
"z");
109 double x_ = boost::lexical_cast<
double>(x->value());
110 double y_ = boost::lexical_cast<
double>(y->value());
111 double z_ = boost::lexical_cast<
double>(z->value());
112 Eigen::Vector3f translation(x_,y_,z_);
113 bufferCropBoxPtr->setTranslation(translation);
116 int normalsCount = 0;
117 auto normals = boost::make_shared<std::vector<SimpleVector3>>();
119 sprintf(search,
"normal_%d", normalsCount);
120 rapidxml::xml_node<> * normalsXML = child_node->first_node(search);
121 while (normalsXML !=
nullptr) {
122 x = normalsXML->first_attribute(
"x");
123 y = normalsXML->first_attribute(
"y");
124 z = normalsXML->first_attribute(
"z");
127 double x_ = boost::lexical_cast<
double>(x->value());
128 double y_ = boost::lexical_cast<
double>(y->value());
129 double z_ = boost::lexical_cast<
double>(z->value());
131 normals->push_back(normal);
134 std::fill(search, search +
sizeof(search)/
sizeof(search[0]), 0);
135 sprintf(search,
"normal_%d", normalsCount);
136 normalsXML = child_node->first_node(search);
140 cropBoxPtrList->push_back(cropBoxWrapperPtr);
141 child_node = child_node->next_sibling();
144 }
catch(std::runtime_error err) {
146 }
catch (rapidxml::parse_error err) {
149 return cropBoxPtrList;
boost::shared_ptr< std::vector< SimpleVector3 > > getCropBoxNormalsList()
static boost::shared_ptr< std::vector< CropBoxWrapperPtr > > readCropBoxDataFromXMLFile(const std::string &xml_path)
readCropBoxDataFromXMLFile reads the given xml file and returns a list of CropBoxWrapper.
boost::shared_ptr< CropBoxWrapper > CropBoxWrapperPtr
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
CropBoxWrapper(CropBoxPtr cropBoxPtr, boost::shared_ptr< std::vector< SimpleVector3 >> cropBoxNormalsListPtr)
void setCropBoxNormalsList(boost::shared_ptr< std::vector< SimpleVector3 >> cropBoxNormalsListPtr)
TFSIMD_FORCE_INLINE const tfScalar & y() const
pcl::CropBox< ObjectPoint > CropBox
this namespace contains all generally usable classes.
static boost::shared_ptr< DebugHelper > getInstance()
TFSIMD_FORCE_INLINE const tfScalar & x() const
TFSIMD_FORCE_INLINE const tfScalar & z() const
void setCropBox(CropBoxPtr cropBoxPtr)
#define ROS_ERROR_STREAM(args)
ROSCPP_DECL bool search(const std::string &ns, const std::string &key, std::string &result)
boost::shared_ptr< std::vector< SimpleVector3 > > mCropBoxNormalsListPtr