RMF
shape.h
Go to the documentation of this file.
1/**
2 * \file RMF/decorator/shape.h
3 * \brief Helper functions for manipulating RMF files.
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef RMF_SHAPE_DECORATORS_H
10#define RMF_SHAPE_DECORATORS_H
11
12#include <RMF/config.h>
14#include <RMF/NodeHandle.h>
15#include <RMF/FileHandle.h>
16#include <RMF/Decorator.h>
17#include <RMF/constants.h>
18#include <RMF/Vector.h>
19#include <RMF/internal/paths.h>
20#include <array>
21#include <boost/lexical_cast.hpp>
22
23RMF_ENABLE_WARNINGS
24namespace RMF {
25namespace decorator {
26
27
28 /** See also Colored and ColoredFactory.
29 */
30 class ColoredConst: public Decorator {
31 friend class ColoredFactory;
32 protected:
33 Vector3Key rgb_color_;
34 ColoredConst(NodeConstHandle nh,
35 Vector3Key rgb_color):
36 Decorator(nh),
37rgb_color_(rgb_color) {
38 }
39 public:
40
41 Vector3 get_rgb_color() const {
42 try {
43 return get_node().get_value(rgb_color_);
44 } RMF_DECORATOR_CATCH( );
45 }
46 Vector3 get_frame_rgb_color() const {
47 try {
48 return get_node().get_frame_value(rgb_color_);
49 } RMF_DECORATOR_CATCH( );
50 }
51 Vector3 get_static_rgb_color() const {
52 try {
53 return get_node().get_static_value(rgb_color_);
54 } RMF_DECORATOR_CATCH( );
55 }
56
57 static std::string get_decorator_type_name() {
58 return "ColoredConst";
59 }
60 RMF_SHOWABLE(ColoredConst, "Colored: " << get_node());
61 };
62 /** See also ColoredFactory.
63 */
64 class Colored: public ColoredConst {
65 friend class ColoredFactory;
66 Colored(NodeHandle nh,
67 Vector3Key rgb_color):
68 ColoredConst(nh, rgb_color) {
69 }
70 public:
71
72 void set_rgb_color(Vector3 v) {
73 try {
74 get_node().set_value(rgb_color_, v);
75 } RMF_DECORATOR_CATCH( );
76 }
77 void set_frame_rgb_color(Vector3 v) {
78 try {
79 get_node().set_frame_value(rgb_color_, v);
80 } RMF_DECORATOR_CATCH( );
81 }
82 void set_static_rgb_color(Vector3 v) {
83 try {
84 get_node().set_static_value(rgb_color_, v);
85 } RMF_DECORATOR_CATCH( );
86 }
87
88 static std::string get_decorator_type_name() {
89 return "Colored";
90 }
91 };
92
93
94 /** Create decorators of type Colored.
95 */
96 class ColoredFactory: public Factory {
97 Category cat_;
98Vector3Key rgb_color_;
99
100 public:
101 ColoredFactory(FileConstHandle fh):
102 cat_(fh.get_category("shape")),
103 rgb_color_(fh.get_key<Vector3Tag>(cat_, "rgb color")) {
104 }
105 ColoredFactory(FileHandle fh):
106 cat_(fh.get_category("shape")),
107 rgb_color_(fh.get_key<Vector3Tag>(cat_, "rgb color")) {
108 }
109 /** Get a ColoredConst for nh.*/
111 RMF_USAGE_CHECK((nh.get_type() == RMF::REPRESENTATION||nh.get_type() == RMF::ORGANIZATIONAL||nh.get_type() == RMF::ALIAS||nh.get_type() == RMF::FEATURE||nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
112 + boost::lexical_cast<std::string>(nh.get_type())
113 + "\" in decorator type Colored");
114 return ColoredConst(nh, rgb_color_);
115 }
116 /** Get a Colored for nh.*/
118 RMF_USAGE_CHECK((nh.get_type() == RMF::REPRESENTATION||nh.get_type() == RMF::ORGANIZATIONAL||nh.get_type() == RMF::ALIAS||nh.get_type() == RMF::FEATURE||nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
119 + boost::lexical_cast<std::string>(nh.get_type())
120 + "\" in decorator type Colored");
121 return Colored(nh, rgb_color_);
122 }
123 /** Check whether nh has all the attributes required to be a
124 ColoredConst.*/
125 bool get_is(NodeConstHandle nh) const {
127 && !nh.get_value(rgb_color_).get_is_null();
128 }
129 bool get_is_static(NodeConstHandle nh) const {
131 && !nh.get_static_value(rgb_color_).get_is_null();
132 }
133 RMF_SHOWABLE(ColoredFactory, "ColoredFactory");
134 };
135 #ifndef RMF_DOXYGEN
136struct ColoredConstFactory: public ColoredFactory {
137 ColoredConstFactory(FileConstHandle fh):
138 ColoredFactory(fh) {
139 }
140 ColoredConstFactory(FileHandle fh):
141 ColoredFactory(fh) {
142 }
143
144};
145 #endif
146
147
148
149
150 /** See also Ball and BallFactory.
151 */
152 class BallConst: public Decorator {
153 friend class BallFactory;
154 protected:
155 Vector3Key coordinates_;
156FloatKey radius_;
157 BallConst(NodeConstHandle nh,
158 Vector3Key coordinates,
159FloatKey radius):
160 Decorator(nh),
161coordinates_(coordinates),
162radius_(radius) {
163 }
164 public:
165
166 Vector3 get_coordinates() const {
167 try {
168 return get_node().get_value(coordinates_);
169 } RMF_DECORATOR_CATCH( );
170 }
171 Vector3 get_frame_coordinates() const {
172 try {
173 return get_node().get_frame_value(coordinates_);
174 } RMF_DECORATOR_CATCH( );
175 }
176 Vector3 get_static_coordinates() const {
177 try {
178 return get_node().get_static_value(coordinates_);
179 } RMF_DECORATOR_CATCH( );
180 }
181
182
183 Float get_radius() const {
184 try {
185 return get_node().get_value(radius_);
186 } RMF_DECORATOR_CATCH( );
187 }
188 Float get_frame_radius() const {
189 try {
190 return get_node().get_frame_value(radius_);
191 } RMF_DECORATOR_CATCH( );
192 }
193 Float get_static_radius() const {
194 try {
195 return get_node().get_static_value(radius_);
196 } RMF_DECORATOR_CATCH( );
197 }
198
199 static std::string get_decorator_type_name() {
200 return "BallConst";
201 }
202 RMF_SHOWABLE(BallConst, "Ball: " << get_node());
203 };
204 /** See also BallFactory.
205 */
206 class Ball: public BallConst {
207 friend class BallFactory;
208 Ball(NodeHandle nh,
209 Vector3Key coordinates,
210FloatKey radius):
211 BallConst(nh, coordinates,
212radius) {
213 }
214 public:
215
216 void set_coordinates(Vector3 v) {
217 try {
218 get_node().set_value(coordinates_, v);
219 } RMF_DECORATOR_CATCH( );
220 }
221 void set_frame_coordinates(Vector3 v) {
222 try {
223 get_node().set_frame_value(coordinates_, v);
224 } RMF_DECORATOR_CATCH( );
225 }
226 void set_static_coordinates(Vector3 v) {
227 try {
228 get_node().set_static_value(coordinates_, v);
229 } RMF_DECORATOR_CATCH( );
230 }
231
232
233 void set_radius(Float v) {
234 try {
235 get_node().set_value(radius_, v);
236 } RMF_DECORATOR_CATCH( );
237 }
238 void set_frame_radius(Float v) {
239 try {
240 get_node().set_frame_value(radius_, v);
241 } RMF_DECORATOR_CATCH( );
242 }
243 void set_static_radius(Float v) {
244 try {
245 get_node().set_static_value(radius_, v);
246 } RMF_DECORATOR_CATCH( );
247 }
248
249 static std::string get_decorator_type_name() {
250 return "Ball";
251 }
252 };
253
254
255 /** Create decorators of type Ball.
256 */
257 class BallFactory: public Factory {
258 Category cat_;
259Vector3Key coordinates_;
260FloatKey radius_;
261
262
263 public:
264 BallFactory(FileConstHandle fh):
265 cat_(fh.get_category("shape")),
266 coordinates_(fh.get_key<Vector3Tag>(cat_, "coordinates")), radius_(fh.get_key<FloatTag>(cat_, "radius")) {
267 }
268 BallFactory(FileHandle fh):
269 cat_(fh.get_category("shape")),
270 coordinates_(fh.get_key<Vector3Tag>(cat_, "coordinates")), radius_(fh.get_key<FloatTag>(cat_, "radius")) {
271 }
272 /** Get a BallConst for nh.*/
274 RMF_USAGE_CHECK((nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
275 + boost::lexical_cast<std::string>(nh.get_type())
276 + "\" in decorator type Ball");
277 return BallConst(nh, coordinates_,
278radius_);
279 }
280 /** Get a Ball for nh.*/
281 Ball get(NodeHandle nh) const {
282 RMF_USAGE_CHECK((nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
283 + boost::lexical_cast<std::string>(nh.get_type())
284 + "\" in decorator type Ball");
285 return Ball(nh, coordinates_,
286radius_);
287 }
288 /** Check whether nh has all the attributes required to be a
289 BallConst.*/
290 bool get_is(NodeConstHandle nh) const {
291 return (nh.get_type() == RMF::GEOMETRY)
292 && !nh.get_value(coordinates_).get_is_null();
293 }
294 bool get_is_static(NodeConstHandle nh) const {
295 return (nh.get_type() == RMF::GEOMETRY)
296 && !nh.get_static_value(coordinates_).get_is_null()
297 && !nh.get_static_value(radius_).get_is_null();
298 }
299 RMF_SHOWABLE(BallFactory, "BallFactory");
300 };
301 #ifndef RMF_DOXYGEN
302struct BallConstFactory: public BallFactory {
303 BallConstFactory(FileConstHandle fh):
304 BallFactory(fh) {
305 }
306 BallConstFactory(FileHandle fh):
307 BallFactory(fh) {
308 }
309
310};
311 #endif
312
313
314
315
316 /** See also Ellipsoid and EllipsoidFactory.
317 */
318 class EllipsoidConst: public Decorator {
319 friend class EllipsoidFactory;
320 protected:
321 Vector3Key axis_lengths_;
322Vector4Key orientation_;
323Vector3Key coordinates_;
324 EllipsoidConst(NodeConstHandle nh,
325 Vector3Key axis_lengths,
326Vector4Key orientation,
327Vector3Key coordinates):
328 Decorator(nh),
329axis_lengths_(axis_lengths),
330orientation_(orientation),
331coordinates_(coordinates) {
332 }
333 public:
334
335 Vector3 get_axis_lengths() const {
336 try {
337 return get_node().get_value(axis_lengths_);
338 } RMF_DECORATOR_CATCH( );
339 }
340 Vector3 get_frame_axis_lengths() const {
341 try {
342 return get_node().get_frame_value(axis_lengths_);
343 } RMF_DECORATOR_CATCH( );
344 }
345 Vector3 get_static_axis_lengths() const {
346 try {
347 return get_node().get_static_value(axis_lengths_);
348 } RMF_DECORATOR_CATCH( );
349 }
350
351
352 Vector4 get_orientation() const {
353 try {
354 return get_node().get_value(orientation_);
355 } RMF_DECORATOR_CATCH( );
356 }
357 Vector4 get_frame_orientation() const {
358 try {
359 return get_node().get_frame_value(orientation_);
360 } RMF_DECORATOR_CATCH( );
361 }
362 Vector4 get_static_orientation() const {
363 try {
364 return get_node().get_static_value(orientation_);
365 } RMF_DECORATOR_CATCH( );
366 }
367
368
369 Vector3 get_coordinates() const {
370 try {
371 return get_node().get_value(coordinates_);
372 } RMF_DECORATOR_CATCH( );
373 }
374 Vector3 get_frame_coordinates() const {
375 try {
376 return get_node().get_frame_value(coordinates_);
377 } RMF_DECORATOR_CATCH( );
378 }
379 Vector3 get_static_coordinates() const {
380 try {
381 return get_node().get_static_value(coordinates_);
382 } RMF_DECORATOR_CATCH( );
383 }
384
385 static std::string get_decorator_type_name() {
386 return "EllipsoidConst";
387 }
388 RMF_SHOWABLE(EllipsoidConst, "Ellipsoid: " << get_node());
389 };
390 /** See also EllipsoidFactory.
391 */
392 class Ellipsoid: public EllipsoidConst {
393 friend class EllipsoidFactory;
394 Ellipsoid(NodeHandle nh,
395 Vector3Key axis_lengths,
396Vector4Key orientation,
397Vector3Key coordinates):
398 EllipsoidConst(nh, axis_lengths,
399orientation,
400coordinates) {
401 }
402 public:
403
404 void set_axis_lengths(Vector3 v) {
405 try {
406 get_node().set_value(axis_lengths_, v);
407 } RMF_DECORATOR_CATCH( );
408 }
409 void set_frame_axis_lengths(Vector3 v) {
410 try {
411 get_node().set_frame_value(axis_lengths_, v);
412 } RMF_DECORATOR_CATCH( );
413 }
414 void set_static_axis_lengths(Vector3 v) {
415 try {
416 get_node().set_static_value(axis_lengths_, v);
417 } RMF_DECORATOR_CATCH( );
418 }
419
420
421 void set_orientation(Vector4 v) {
422 try {
423 get_node().set_value(orientation_, v);
424 } RMF_DECORATOR_CATCH( );
425 }
426 void set_frame_orientation(Vector4 v) {
427 try {
428 get_node().set_frame_value(orientation_, v);
429 } RMF_DECORATOR_CATCH( );
430 }
431 void set_static_orientation(Vector4 v) {
432 try {
433 get_node().set_static_value(orientation_, v);
434 } RMF_DECORATOR_CATCH( );
435 }
436
437
438 void set_coordinates(Vector3 v) {
439 try {
440 get_node().set_value(coordinates_, v);
441 } RMF_DECORATOR_CATCH( );
442 }
443 void set_frame_coordinates(Vector3 v) {
444 try {
445 get_node().set_frame_value(coordinates_, v);
446 } RMF_DECORATOR_CATCH( );
447 }
448 void set_static_coordinates(Vector3 v) {
449 try {
450 get_node().set_static_value(coordinates_, v);
451 } RMF_DECORATOR_CATCH( );
452 }
453
454 static std::string get_decorator_type_name() {
455 return "Ellipsoid";
456 }
457 };
458
459
460 /** Create decorators of type Ellipsoid.
461 */
462 class EllipsoidFactory: public Factory {
463 Category cat_;
464Vector3Key axis_lengths_;
465Vector4Key orientation_;
466Vector3Key coordinates_;
467
468
469
470 public:
471 EllipsoidFactory(FileConstHandle fh):
472 cat_(fh.get_category("shape")),
473 axis_lengths_(fh.get_key<Vector3Tag>(cat_, "axis lengths")), orientation_(fh.get_key<Vector4Tag>(cat_, "orientation")), coordinates_(fh.get_key<Vector3Tag>(cat_, "coordinates")) {
474 }
475 EllipsoidFactory(FileHandle fh):
476 cat_(fh.get_category("shape")),
477 axis_lengths_(fh.get_key<Vector3Tag>(cat_, "axis lengths")), orientation_(fh.get_key<Vector4Tag>(cat_, "orientation")), coordinates_(fh.get_key<Vector3Tag>(cat_, "coordinates")) {
478 }
479 /** Get a EllipsoidConst for nh.*/
481 RMF_USAGE_CHECK((nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
482 + boost::lexical_cast<std::string>(nh.get_type())
483 + "\" in decorator type Ellipsoid");
484 return EllipsoidConst(nh, axis_lengths_,
485orientation_,
486coordinates_);
487 }
488 /** Get a Ellipsoid for nh.*/
490 RMF_USAGE_CHECK((nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
491 + boost::lexical_cast<std::string>(nh.get_type())
492 + "\" in decorator type Ellipsoid");
493 return Ellipsoid(nh, axis_lengths_,
494orientation_,
495coordinates_);
496 }
497 /** Check whether nh has all the attributes required to be a
498 EllipsoidConst.*/
499 bool get_is(NodeConstHandle nh) const {
500 return (nh.get_type() == RMF::GEOMETRY)
501 && !nh.get_value(axis_lengths_).get_is_null();
502 }
503 bool get_is_static(NodeConstHandle nh) const {
504 return (nh.get_type() == RMF::GEOMETRY)
505 && !nh.get_static_value(axis_lengths_).get_is_null()
506 && !nh.get_static_value(orientation_).get_is_null()
507 && !nh.get_static_value(coordinates_).get_is_null();
508 }
509 RMF_SHOWABLE(EllipsoidFactory, "EllipsoidFactory");
510 };
511 #ifndef RMF_DOXYGEN
512struct EllipsoidConstFactory: public EllipsoidFactory {
513 EllipsoidConstFactory(FileConstHandle fh):
514 EllipsoidFactory(fh) {
515 }
516 EllipsoidConstFactory(FileHandle fh):
517 EllipsoidFactory(fh) {
518 }
519
520};
521 #endif
522
523
524
525
526 /** See also Cylinder and CylinderFactory.
527 */
528 class CylinderConst: public Decorator {
529 friend class CylinderFactory;
530 protected:
531 FloatKey radius_;
532Vector3sKey coordinates_list_;
533 CylinderConst(NodeConstHandle nh,
534 FloatKey radius,
535Vector3sKey coordinates_list):
536 Decorator(nh),
537radius_(radius),
538coordinates_list_(coordinates_list) {
539 }
540 public:
541
542 Float get_radius() const {
543 try {
544 return get_node().get_value(radius_);
545 } RMF_DECORATOR_CATCH( );
546 }
547 Float get_frame_radius() const {
548 try {
549 return get_node().get_frame_value(radius_);
550 } RMF_DECORATOR_CATCH( );
551 }
552 Float get_static_radius() const {
553 try {
554 return get_node().get_static_value(radius_);
555 } RMF_DECORATOR_CATCH( );
556 }
557
558
559 Vector3s get_coordinates_list() const {
560 try {
561 return get_node().get_value(coordinates_list_);
562 } RMF_DECORATOR_CATCH( );
563 }
564 Vector3s get_frame_coordinates_list() const {
565 try {
566 return get_node().get_frame_value(coordinates_list_);
567 } RMF_DECORATOR_CATCH( );
568 }
569 Vector3s get_static_coordinates_list() const {
570 try {
571 return get_node().get_static_value(coordinates_list_);
572 } RMF_DECORATOR_CATCH( );
573 }
574
575 static std::string get_decorator_type_name() {
576 return "CylinderConst";
577 }
578 RMF_SHOWABLE(CylinderConst, "Cylinder: " << get_node());
579 };
580 /** See also CylinderFactory.
581 */
582 class Cylinder: public CylinderConst {
583 friend class CylinderFactory;
584 Cylinder(NodeHandle nh,
585 FloatKey radius,
586Vector3sKey coordinates_list):
587 CylinderConst(nh, radius,
588coordinates_list) {
589 }
590 public:
591
592 void set_radius(Float v) {
593 try {
594 get_node().set_value(radius_, v);
595 } RMF_DECORATOR_CATCH( );
596 }
597 void set_frame_radius(Float v) {
598 try {
599 get_node().set_frame_value(radius_, v);
600 } RMF_DECORATOR_CATCH( );
601 }
602 void set_static_radius(Float v) {
603 try {
604 get_node().set_static_value(radius_, v);
605 } RMF_DECORATOR_CATCH( );
606 }
607
608
609 void set_coordinates_list(Vector3s v) {
610 try {
611 get_node().set_value(coordinates_list_, v);
612 } RMF_DECORATOR_CATCH( );
613 }
614 void set_frame_coordinates_list(Vector3s v) {
615 try {
616 get_node().set_frame_value(coordinates_list_, v);
617 } RMF_DECORATOR_CATCH( );
618 }
619 void set_static_coordinates_list(Vector3s v) {
620 try {
621 get_node().set_static_value(coordinates_list_, v);
622 } RMF_DECORATOR_CATCH( );
623 }
624
625 static std::string get_decorator_type_name() {
626 return "Cylinder";
627 }
628 };
629
630
631 /** Create decorators of type Cylinder.
632 */
633 class CylinderFactory: public Factory {
634 Category cat_;
635FloatKey radius_;
636Vector3sKey coordinates_list_;
637
638
639 public:
640 CylinderFactory(FileConstHandle fh):
641 cat_(fh.get_category("shape")),
642 radius_(fh.get_key<FloatTag>(cat_, "radius")), coordinates_list_(fh.get_key<Vector3sTag>(cat_, "coordinates list")) {
643 }
644 CylinderFactory(FileHandle fh):
645 cat_(fh.get_category("shape")),
646 radius_(fh.get_key<FloatTag>(cat_, "radius")), coordinates_list_(fh.get_key<Vector3sTag>(cat_, "coordinates list")) {
647 }
648 /** Get a CylinderConst for nh.*/
650 RMF_USAGE_CHECK((nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
651 + boost::lexical_cast<std::string>(nh.get_type())
652 + "\" in decorator type Cylinder");
653 return CylinderConst(nh, radius_,
654coordinates_list_);
655 }
656 /** Get a Cylinder for nh.*/
658 RMF_USAGE_CHECK((nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
659 + boost::lexical_cast<std::string>(nh.get_type())
660 + "\" in decorator type Cylinder");
661 return Cylinder(nh, radius_,
662coordinates_list_);
663 }
664 /** Check whether nh has all the attributes required to be a
665 CylinderConst.*/
666 bool get_is(NodeConstHandle nh) const {
667 return (nh.get_type() == RMF::GEOMETRY)
668 && !nh.get_value(radius_).get_is_null()
669 && !nh.get_value(coordinates_list_).get_is_null();
670 }
671 bool get_is_static(NodeConstHandle nh) const {
672 return (nh.get_type() == RMF::GEOMETRY)
673 && !nh.get_static_value(radius_).get_is_null()
674 && !nh.get_static_value(coordinates_list_).get_is_null();
675 }
676 RMF_SHOWABLE(CylinderFactory, "CylinderFactory");
677 };
678 #ifndef RMF_DOXYGEN
679struct CylinderConstFactory: public CylinderFactory {
680 CylinderConstFactory(FileConstHandle fh):
681 CylinderFactory(fh) {
682 }
683 CylinderConstFactory(FileHandle fh):
684 CylinderFactory(fh) {
685 }
686
687};
688 #endif
689
690
691
692
693 /** See also Segment and SegmentFactory.
694 */
695 class SegmentConst: public Decorator {
696 friend class SegmentFactory;
697 protected:
698 Vector3sKey coordinates_list_;
699 SegmentConst(NodeConstHandle nh,
700 Vector3sKey coordinates_list):
701 Decorator(nh),
702coordinates_list_(coordinates_list) {
703 }
704 public:
705
706 Vector3s get_coordinates_list() const {
707 try {
708 return get_node().get_value(coordinates_list_);
709 } RMF_DECORATOR_CATCH( );
710 }
711 Vector3s get_frame_coordinates_list() const {
712 try {
713 return get_node().get_frame_value(coordinates_list_);
714 } RMF_DECORATOR_CATCH( );
715 }
716 Vector3s get_static_coordinates_list() const {
717 try {
718 return get_node().get_static_value(coordinates_list_);
719 } RMF_DECORATOR_CATCH( );
720 }
721
722 static std::string get_decorator_type_name() {
723 return "SegmentConst";
724 }
725 RMF_SHOWABLE(SegmentConst, "Segment: " << get_node());
726 };
727 /** See also SegmentFactory.
728 */
729 class Segment: public SegmentConst {
730 friend class SegmentFactory;
731 Segment(NodeHandle nh,
732 Vector3sKey coordinates_list):
733 SegmentConst(nh, coordinates_list) {
734 }
735 public:
736
737 void set_coordinates_list(Vector3s v) {
738 try {
739 get_node().set_value(coordinates_list_, v);
740 } RMF_DECORATOR_CATCH( );
741 }
742 void set_frame_coordinates_list(Vector3s v) {
743 try {
744 get_node().set_frame_value(coordinates_list_, v);
745 } RMF_DECORATOR_CATCH( );
746 }
747 void set_static_coordinates_list(Vector3s v) {
748 try {
749 get_node().set_static_value(coordinates_list_, v);
750 } RMF_DECORATOR_CATCH( );
751 }
752
753 static std::string get_decorator_type_name() {
754 return "Segment";
755 }
756 };
757
758
759 /** Create decorators of type Segment.
760 */
761 class SegmentFactory: public Factory {
762 Category cat_;
763Vector3sKey coordinates_list_;
764
765 public:
766 SegmentFactory(FileConstHandle fh):
767 cat_(fh.get_category("shape")),
768 coordinates_list_(fh.get_key<Vector3sTag>(cat_, "coordinates list")) {
769 }
770 SegmentFactory(FileHandle fh):
771 cat_(fh.get_category("shape")),
772 coordinates_list_(fh.get_key<Vector3sTag>(cat_, "coordinates list")) {
773 }
774 /** Get a SegmentConst for nh.*/
776 RMF_USAGE_CHECK((nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
777 + boost::lexical_cast<std::string>(nh.get_type())
778 + "\" in decorator type Segment");
779 return SegmentConst(nh, coordinates_list_);
780 }
781 /** Get a Segment for nh.*/
783 RMF_USAGE_CHECK((nh.get_type() == RMF::GEOMETRY), std::string("Bad node type. Got \"")
784 + boost::lexical_cast<std::string>(nh.get_type())
785 + "\" in decorator type Segment");
786 return Segment(nh, coordinates_list_);
787 }
788 /** Check whether nh has all the attributes required to be a
789 SegmentConst.*/
790 bool get_is(NodeConstHandle nh) const {
791 return (nh.get_type() == RMF::GEOMETRY)
792 && !nh.get_value(coordinates_list_).get_is_null();
793 }
794 bool get_is_static(NodeConstHandle nh) const {
795 return (nh.get_type() == RMF::GEOMETRY)
796 && !nh.get_static_value(coordinates_list_).get_is_null();
797 }
798 RMF_SHOWABLE(SegmentFactory, "SegmentFactory");
799 };
800 #ifndef RMF_DOXYGEN
801struct SegmentConstFactory: public SegmentFactory {
802 SegmentConstFactory(FileConstHandle fh):
803 SegmentFactory(fh) {
804 }
805 SegmentConstFactory(FileHandle fh):
806 SegmentFactory(fh) {
807 }
808
809};
810 #endif
811
812
813
814} /* namespace decorator */
815} /* namespace RMF */
816RMF_DISABLE_WARNINGS
817
818#endif /* RMF_SHAPE_DECORATORS_H */
Mostly empty base classes for decorators and factories.
Declaration for RMF::FileHandle.
Declaration of NodeHandle.
Represent coordinates.
The base class for Factories.
Definition Decorator.h:46
A handle for a read-only RMF file.
A handle for an RMF file.
Definition FileHandle.h:54
A handle for a particular node in a read-only hierarchy.
NodeType get_type() const
get the type of this node
A handle for a particular node in the hierarchy.
Definition NodeHandle.h:60
bool get_is(NodeConstHandle nh) const
Definition shape.h:290
BallConst get(NodeConstHandle nh) const
Definition shape.h:273
Ball get(NodeHandle nh) const
Definition shape.h:281
Colored get(NodeHandle nh) const
Definition shape.h:117
ColoredConst get(NodeConstHandle nh) const
Definition shape.h:110
bool get_is(NodeConstHandle nh) const
Definition shape.h:125
Cylinder get(NodeHandle nh) const
Definition shape.h:657
CylinderConst get(NodeConstHandle nh) const
Definition shape.h:649
bool get_is(NodeConstHandle nh) const
Definition shape.h:666
EllipsoidConst get(NodeConstHandle nh) const
Definition shape.h:480
Ellipsoid get(NodeHandle nh) const
Definition shape.h:489
bool get_is(NodeConstHandle nh) const
Definition shape.h:499
SegmentConst get(NodeConstHandle nh) const
Definition shape.h:775
bool get_is(NodeConstHandle nh) const
Definition shape.h:790
Segment get(NodeHandle nh) const
Definition shape.h:782
Various constants.
Various general useful macros for IMP.
See Decorators and Attributes for more information.
The namespace for all functionality in the library.
const NodeType ALIAS
std::vector< Vector3 > Vector3s
Definition types.h:52
Vector< 4U > Vector4
Definition types.h:50
ID< Vector4Tag > Vector4Key
Definition keys.h:41
const NodeType FEATURE
Store information about some feature of the system.
ID< Vector3Tag > Vector3Key
Definition keys.h:41
Vector< 3U > Vector3
Definition types.h:48
const NodeType GEOMETRY
Store a geometric object.
ID< CategoryTag > Category
Definition ID.h:110
float Float
Definition types.h:33
const NodeType ORGANIZATIONAL
A node that is purely there for organizational purposes.
ID< FloatTag > FloatKey
Definition keys.h:41
ID< Vector3sTag > Vector3sKey
Definition keys.h:41
const NodeType REPRESENTATION
Represent part of a molecule.