4 #ifndef YARP_THRIFT_GENERATOR_STRUCT_SurfaceMesh 5 #define YARP_THRIFT_GENERATOR_STRUCT_SurfaceMesh 7 #include <yarp/os/Wire.h> 8 #include <yarp/os/idl/WireTypes.h> 9 #include <iCub/data3D/PointXYZ.h> 10 #include <iCub/data3D/Polygon.h> 11 #include <iCub/data3D/RGBA.h> 20 class iCub::data3D::SurfaceMesh :
public yarp::os::idl::WirePortable {
24 std::vector<PointXYZ> points;
25 std::vector<RGBA> rgbColour;
26 std::vector<Polygon> polygons;
29 SurfaceMesh() : meshName(
"") {
33 SurfaceMesh(
const std::string& meshName,
const std::vector<PointXYZ> & points,
const std::vector<RGBA> & rgbColour,
const std::vector<Polygon> & polygons) : meshName(meshName), points(points), rgbColour(rgbColour), polygons(polygons) {
37 SurfaceMesh(
const SurfaceMesh& __alt) : WirePortable(__alt) {
38 this->meshName = __alt.meshName;
39 this->points = __alt.points;
40 this->rgbColour = __alt.rgbColour;
41 this->polygons = __alt.polygons;
45 const SurfaceMesh& operator = (
const SurfaceMesh& __alt) {
46 this->meshName = __alt.meshName;
47 this->points = __alt.points;
48 this->rgbColour = __alt.rgbColour;
49 this->polygons = __alt.polygons;
54 bool read(yarp::os::idl::WireReader& reader);
55 bool read(yarp::os::ConnectionReader& connection);
56 bool write(yarp::os::idl::WireWriter& writer);
57 bool write(yarp::os::ConnectionWriter& connection);
60 bool write_meshName(yarp::os::idl::WireWriter& writer);
61 bool nested_write_meshName(yarp::os::idl::WireWriter& writer);
62 bool write_points(yarp::os::idl::WireWriter& writer);
63 bool nested_write_points(yarp::os::idl::WireWriter& writer);
64 bool write_rgbColour(yarp::os::idl::WireWriter& writer);
65 bool nested_write_rgbColour(yarp::os::idl::WireWriter& writer);
66 bool write_polygons(yarp::os::idl::WireWriter& writer);
67 bool nested_write_polygons(yarp::os::idl::WireWriter& writer);
68 bool read_meshName(yarp::os::idl::WireReader& reader);
69 bool nested_read_meshName(yarp::os::idl::WireReader& reader);
70 bool read_points(yarp::os::idl::WireReader& reader);
71 bool nested_read_points(yarp::os::idl::WireReader& reader);
72 bool read_rgbColour(yarp::os::idl::WireReader& reader);
73 bool nested_read_rgbColour(yarp::os::idl::WireReader& reader);
74 bool read_polygons(yarp::os::idl::WireReader& reader);
75 bool nested_read_polygons(yarp::os::idl::WireReader& reader);
79 yarp::os::ConstString toString();
82 typedef yarp::os::idl::Unwrapped<iCub::data3D::SurfaceMesh > unwrapped;
84 class Editor :
public yarp::os::Wire,
public yarp::os::PortWriter {
90 obj =
new SurfaceMesh;
92 yarp().setOwner(*
this);
95 Editor(SurfaceMesh& obj) {
99 yarp().setOwner(*
this);
102 bool edit(SurfaceMesh& obj,
bool dirty =
true) {
103 if (obj_owned)
delete this->obj;
111 if (obj_owned)
delete obj;
114 bool isValid()
const {
118 SurfaceMesh& state() {
return *obj; }
120 void begin() { group++; }
124 if (group==0&&is_dirty) communicate();
126 void set_meshName(
const std::string& meshName) {
128 obj->meshName = meshName;
129 mark_dirty_meshName();
133 void set_points(
const std::vector<PointXYZ> & points) {
135 obj->points = points;
140 void set_points(
int index,
const PointXYZ& elem) {
142 obj->points[index] = elem;
147 void set_rgbColour(
const std::vector<RGBA> & rgbColour) {
148 will_set_rgbColour();
149 obj->rgbColour = rgbColour;
150 mark_dirty_rgbColour();
154 void set_rgbColour(
int index,
const RGBA& elem) {
155 will_set_rgbColour();
156 obj->rgbColour[index] = elem;
157 mark_dirty_rgbColour();
161 void set_polygons(
const std::vector<Polygon> & polygons) {
163 obj->polygons = polygons;
164 mark_dirty_polygons();
168 void set_polygons(
int index,
const Polygon& elem) {
170 obj->polygons[index] = elem;
171 mark_dirty_polygons();
175 const std::string& get_meshName() {
176 return obj->meshName;
178 const std::vector<PointXYZ> & get_points() {
181 const std::vector<RGBA> & get_rgbColour() {
182 return obj->rgbColour;
184 const std::vector<Polygon> & get_polygons() {
185 return obj->polygons;
187 virtual bool will_set_meshName() {
return true; }
188 virtual bool will_set_points() {
return true; }
189 virtual bool will_set_rgbColour() {
return true; }
190 virtual bool will_set_polygons() {
return true; }
191 virtual bool did_set_meshName() {
return true; }
192 virtual bool did_set_points() {
return true; }
193 virtual bool did_set_rgbColour() {
return true; }
194 virtual bool did_set_polygons() {
return true; }
198 bool read(yarp::os::ConnectionReader& connection);
199 bool write(yarp::os::ConnectionWriter& connection);
208 if (group!=0)
return;
209 if (yarp().canWrite()) {
217 void mark_dirty_meshName() {
218 if (is_dirty_meshName)
return;
220 is_dirty_meshName =
true;
223 void mark_dirty_points() {
224 if (is_dirty_points)
return;
226 is_dirty_points =
true;
229 void mark_dirty_rgbColour() {
230 if (is_dirty_rgbColour)
return;
232 is_dirty_rgbColour =
true;
235 void mark_dirty_polygons() {
236 if (is_dirty_polygons)
return;
238 is_dirty_polygons =
true;
241 void dirty_flags(
bool flag) {
243 is_dirty_meshName = flag;
244 is_dirty_points = flag;
245 is_dirty_rgbColour = flag;
246 is_dirty_polygons = flag;
247 dirty_count = flag ? 4 : 0;
251 bool is_dirty_meshName;
252 bool is_dirty_points;
253 bool is_dirty_rgbColour;
254 bool is_dirty_polygons;