TinyURDF 1.0.0
A Modern C++ Library for Parsing and Visualizing URDF Model Files
Loading...
Searching...
No Matches
cylinder_parser.h
Go to the documentation of this file.
1#ifndef INCLUDE_TINYURDF_GEOMETRY_CYLINDER_PARSER_H_
2#define INCLUDE_TINYURDF_GEOMETRY_CYLINDER_PARSER_H_
3
4// Copyright 2025 Wissem CHIHA
5
6#include <memory>
7#include "parser_base.h"
8#include "geometry_base.h"
9#include "cylinder.h"
10#include "utils.h"
11
16class CylinderParser : public ParserBase<Cylinder> {
17public:
19 p_ = std::make_shared<Cylinder>();
20 }
21
22 void parse(const tinyxml2::XMLElement* xml) override {
24
25 const char* radius_str = xml->Attribute("radius");
26 const char* length_str = xml->Attribute("length");
27 if (radius_str && length_str) {
28 double r, l;
29 str2double(radius_str, r);
30 str2double(length_str, l);
31 p_ = std::make_shared<Cylinder>();
32 p_->setRadius(r);
33 p_->setLength(l);
34 }
35 }
36
37 bool isA(const char* name) override {
38 return p_->isA(name);
39 }
40
41 const char* getTypename() override {
42 return p_->getTypename();
43 }
44
45 void print(std::ostream& os) override {
46 os << "Parsed Cylinder = [";
47 p_->print(os);
48 os << "]";
49 }
50
51 bool empty() const override {
52 return p_ == nullptr;
53 }
54
55 void clear() override {
56 p_->clear();
57 }
58
59 std::shared_ptr<Cylinder> get() override {
60 return p_;
61 }
62
63 ~CylinderParser() = default;
64
65private:
66 std::shared_ptr<Cylinder> p_;
67};
68#endif // INCLUDE_TINYURDF_GEOMETRY_CYLINDER_PARSER_H_
Parser for Cylinder geometry, inherits from ParserBase<Cylinder> and provides the functionality to pa...
Definition cylinder_parser.h:16
bool empty() const override
Definition cylinder_parser.h:51
CylinderParser()
Definition cylinder_parser.h:18
bool isA(const char *name) override
Definition cylinder_parser.h:37
void print(std::ostream &os) override
Definition cylinder_parser.h:45
std::shared_ptr< Cylinder > get() override
Definition cylinder_parser.h:59
void clear() override
Definition cylinder_parser.h:55
void parse(const tinyxml2::XMLElement *xml) override
Definition cylinder_parser.h:22
~CylinderParser()=default
const char * getTypename() override
Definition cylinder_parser.h:41
Definition parser_base.h:16
virtual void parse(const tinyxml2::XMLElement *xml)
Definition parser_base.h:27
void str2double(const char *in, double &num_)
a locale-safe version of string-to-double
Definition utils.cc:14