RMF
alternatives.h
Go to the documentation of this file.
1/**
2 * \file RMF/decorator/alternatives.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_DECORATORS_ALTERNATIVES_H
10#define RMF_DECORATORS_ALTERNATIVES_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/Enum.h>
19#include <RMF/Vector.h>
20
21RMF_ENABLE_WARNINGS
22namespace RMF {
23namespace decorator {
24
25/** See also Alternatives and AlternativesFactory.
26 */
27class RMFEXPORT AlternativesConst : public Decorator {
28 friend class AlternativesFactory;
29 friend class Alternatives;
30 IntsKey types_key_;
31 IntsKey roots_key_;
32 AlternativesConst(NodeConstHandle nh, IntsKey types_key, IntsKey roots_key)
33 : Decorator(nh), types_key_(types_key), roots_key_(roots_key) {}
34 NodeID get_alternative_impl(RepresentationType type, float resolution) const;
35 NodeIDs get_alternatives_impl(RepresentationType type) const;
36
37 public:
38 /** Get the alternative root that best matches the criteria. */
40 double resolution) const;
41
42 /** Get the type of the representation with the given node id. */
44
46 return get_representation_type(id.get_id());
47 }
48
49 /** Get all the alternatives (including this node).
50
51 You can use get_resolution() and get_representation_type() to get info
52 about them. */
54
55 static std::string get_decorator_type_name() { return "AlternativesConst"; }
56 RMF_SHOWABLE(AlternativesConst, "Alternatives: " << get_node());
57};
58
59/** See also AlternativesConst and AlternativesFactory.
60 */
61class RMFEXPORT Alternatives : public AlternativesConst {
62 friend class AlternativesFactory;
63 Alternatives(NodeHandle nh, IntsKey types_key, IntsKey roots_key);
64
65 public:
66 void add_alternative(NodeHandle root, RepresentationType type);
67
68 static std::string get_decorator_type_name() { return "Alternatives"; }
69};
70
71/** Create decorators of type Alternatives.
72
73 See also Alternatives and AlternativesFactory.
74 */
75class RMFEXPORT AlternativesFactory : public Factory {
76 Category cat_;
77 IntsKey types_key_;
78 IntsKey roots_key_;
79
80 public:
81 AlternativesFactory(FileConstHandle fh);
82 AlternativesFactory(FileHandle fh);
83
84 Alternatives get(NodeHandle nh) const {
85 return Alternatives(nh, types_key_, roots_key_);
86 }
88 return AlternativesConst(nh, types_key_, roots_key_);
89 }
90 bool get_is(NodeConstHandle nh) const { return nh.get_has_value(types_key_); }
91 bool get_is_static(NodeConstHandle nh) const {
92 return nh.get_has_value(types_key_);
93 }
94 RMF_SHOWABLE(AlternativesFactory, "AlternativesFactory");
95};
96
97#ifndef RMF_DOXYGEN
98struct AlternativesConstFactory : public AlternativesFactory {
99 AlternativesConstFactory(FileConstHandle fh) : AlternativesFactory(fh) {}
100 AlternativesConstFactory(FileHandle fh) : AlternativesFactory(fh) {}
101};
102#endif
103
104/** Return the canonical resolution of the subtree. */
105RMFEXPORT double get_resolution(NodeConstHandle root);
106
107/** Return a list of (clustered) resolution levels available in the subtree.
108
109 Use this, for example, when making a slider for display.
110*/
113 double accuracy = 0);
114
115} /* namespace decorator */
116} /* namespace RMF */
117RMF_DISABLE_WARNINGS
118
119#endif /* RMF_DECORATORS_ALTERNATIVES_H */
Mostly empty base classes for decorators and factories.
Declaration of RMF::Enum.
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.
A handle for a particular node in the hierarchy.
Definition NodeHandle.h:60
RepresentationType get_representation_type(NodeID id) const
NodeConstHandles get_alternatives(RepresentationType type) const
NodeConstHandle get_alternative(RepresentationType type, double resolution) const
Various constants.
Various general useful macros for IMP.
See Decorators and Attributes for more information.
double get_resolution(NodeConstHandle root)
Floats get_resolutions(NodeConstHandle root, RepresentationType type=PARTICLE, double accuracy=0)
The namespace for all functionality in the library.
Enum< RepresentationTypeTag > RepresentationType
Definition Enum.h:127
ID< CategoryTag > Category
Definition ID.h:110
ID< NodeTag > NodeID
Definition ID.h:106
std::vector< NodeConstHandle > NodeConstHandles
Pass a list of them.
std::vector< NodeID > NodeIDs
Definition ID.h:113
const RepresentationType PARTICLE
ID< IntsTag > IntsKey
Definition keys.h:41
std::vector< Float > Floats
Definition types.h:35