IMP logo
IMP Reference Guide  2.7.0
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 
15 int 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.core.
Include all non-deprecated headers in IMP.algebra.
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition: XYZ.h:51
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
Definition: object_macros.h:64
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
void set_coordinates(const algebra::Vector3D &v)
set all coordinates from a vector
Definition: XYZ.h:62
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Various general useful macros for IMP.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.