IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
simple.cpp
1/** \example core/simple.cpp
2
3 Simple example of using the IMP C++ library.
4
5 This should be equivalent to the first part of the Python example simple.py.
6*/
7
8#include <fstream>
9
10#include <IMP.h>
11#include <IMP/algebra.h>
12#include <IMP/core.h>
13#include <IMP/flags.h>
14
15int main(int argc, char *argv[]) {
16 IMP::setup_from_argv(argc, argv,
17 "Simple example of using the IMP C++ library.");
18
19 IMP_NEW(IMP::Model, m, ());
20
21 // Create two "untyped" particles
22 IMP::ParticleIndex p1 = m->add_particle("p1");
23 IMP::ParticleIndex p2 = m->add_particle("p2");
24
25 // "Decorate" the particles with x,y,z attributes (point-like
26 // particles)
29
30 // Use some XYZ-specific functionality (set coordinates)
31 d1.set_coordinates(IMP::algebra::Vector3D(10.0, 10.0, 10.0));
32 d2.set_coordinates(IMP::algebra::Vector3D(-10.0, -10.0, -10.0));
33 std::cout << d1 << " " << d2 << std::endl;
34
35 return 0;
36}
Include all non-deprecated headers in IMP.
Include all non-deprecated headers in IMP.algebra.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A decorator for a particle with x,y,z coordinates.
Definition XYZ.h:30
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition XYZ.h:51
Include all non-deprecated headers in IMP.core.
Support for shared command line flags.
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
VectorD< 3 > Vector3D
Definition VectorD.h:407
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.