RMF
Toggle main menu visibility
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>
13
#include <
RMF/infrastructure_macros.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
21
RMF_ENABLE_WARNINGS
22
namespace
RMF
{
23
namespace
decorator
{
24
25
/** See also Alternatives and AlternativesFactory.
26
*/
27
class
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. */
39
NodeConstHandle
get_alternative
(
RepresentationType
type,
40
double
resolution)
const
;
41
42
/** Get the type of the representation with the given node id. */
43
RepresentationType
get_representation_type
(
NodeID
id
)
const
;
44
45
RepresentationType
get_representation_type
(
NodeConstHandle
id
)
const
{
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. */
53
NodeConstHandles
get_alternatives
(
RepresentationType
type)
const
;
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
*/
61
class
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
*/
75
class
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
}
87
AlternativesConst
get(
NodeConstHandle
nh)
const
{
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
98
struct
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. */
105
RMFEXPORT
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
*/
111
RMFEXPORT
Floats
get_resolutions
(
NodeConstHandle
root,
112
RepresentationType
type =
PARTICLE
,
113
double
accuracy = 0);
114
115
}
/* namespace decorator */
116
}
/* namespace RMF */
117
RMF_DISABLE_WARNINGS
118
119
#endif
/* RMF_DECORATORS_ALTERNATIVES_H */
Decorator.h
Mostly empty base classes for decorators and factories.
Enum.h
Declaration of RMF::Enum.
FileHandle.h
Declaration for RMF::FileHandle.
NodeHandle.h
Declaration of NodeHandle.
Vector.h
Represent coordinates.
RMF::Factory
The base class for Factories.
Definition
Decorator.h:46
RMF::FileConstHandle
A handle for a read-only RMF file.
Definition
FileConstHandle.h:78
RMF::FileHandle
A handle for an RMF file.
Definition
FileHandle.h:54
RMF::NodeConstHandle
A handle for a particular node in a read-only hierarchy.
Definition
NodeConstHandle.h:86
RMF::NodeHandle
A handle for a particular node in the hierarchy.
Definition
NodeHandle.h:60
RMF::decorator::AlternativesConst
Definition
alternatives.h:27
RMF::decorator::AlternativesConst::get_representation_type
RepresentationType get_representation_type(NodeID id) const
RMF::decorator::AlternativesConst::get_alternatives
NodeConstHandles get_alternatives(RepresentationType type) const
RMF::decorator::AlternativesConst::get_alternative
NodeConstHandle get_alternative(RepresentationType type, double resolution) const
RMF::decorator::AlternativesFactory
Definition
alternatives.h:75
RMF::decorator::Alternatives
Definition
alternatives.h:61
constants.h
Various constants.
infrastructure_macros.h
Various general useful macros for IMP.
RMF::decorator
See Decorators and Attributes for more information.
Definition
CoordinateTransformer.h:22
RMF::decorator::get_resolution
double get_resolution(NodeConstHandle root)
RMF::decorator::get_resolutions
Floats get_resolutions(NodeConstHandle root, RepresentationType type=PARTICLE, double accuracy=0)
RMF
The namespace for all functionality in the library.
Definition
BufferConstHandle.h:21
RMF::RepresentationType
Enum< RepresentationTypeTag > RepresentationType
Definition
Enum.h:127
RMF::Category
ID< CategoryTag > Category
Definition
ID.h:110
RMF::NodeID
ID< NodeTag > NodeID
Definition
ID.h:106
RMF::NodeConstHandles
std::vector< NodeConstHandle > NodeConstHandles
Pass a list of them.
Definition
NodeConstHandle.h:69
RMF::NodeIDs
std::vector< NodeID > NodeIDs
Definition
ID.h:113
RMF::PARTICLE
const RepresentationType PARTICLE
RMF::IntsKey
ID< IntsTag > IntsKey
Definition
keys.h:41
RMF::Floats
std::vector< Float > Floats
Definition
types.h:35