IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
primitive_geometries.h
Go to the documentation of this file.
1/**
2 * \file IMP/display/primitive_geometries.h
3 * \brief Implement geometry for the basic shapes from IMP.algebra.
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 */
7
8#ifndef IMPDISPLAY_PRIMITIVE_GEOMETRIES_H
9#define IMPDISPLAY_PRIMITIVE_GEOMETRIES_H
10
11#include <IMP/display/display_config.h>
12#include "declare_Geometry.h"
13#include "geometry_macros.h"
20#include <IMP/algebra/Plane3D.h>
24#ifdef IMP_DISPLAY_USE_IMP_CGAL
25#include <IMP/cgal/internal/polyhedrons.h>
26#endif
27
28IMPDISPLAY_BEGIN_NAMESPACE
29
30/** \brief Display a sphere.
31*/
32IMP_DISPLAY_GEOMETRY_DECL(SphereGeometry, SphereGeometries, algebra::Sphere3D);
33/** \brief Display a cylinder.
34*/
37/** \brief Display a ellipsoid.
38*/
41/** \brief Display a point.
42*/
43IMP_DISPLAY_GEOMETRY_DECL(PointGeometry, PointGeometries, algebra::Vector3D);
44/** \brief Display a segment.
45*/
48/** If CGAL is available, then any simple, planar polygon can be
49 used. Otherwise, the polygons should be simple, planar and convex.
50*/
53/** \brief Display a triangle.
54*/
57/** \brief Display a bounding box.
58*/
59IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DECL(
60 BoundingBoxGeometry, BoundingBoxGeometries, algebra::BoundingBoxD<3>);
61
62/** \brief Display a reference frame.
63*/
64IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DECL(ReferenceFrameGeometry,
65 ReferenceFrameGeometries,
67
68//! A text label for a ball in space
69/** You can use the offset if the thing being labeled has a radius.
70 */
71class IMPDISPLAYEXPORT LabelGeometry : public Geometry {
73 std::string text_;
74
75 public:
76 LabelGeometry(const algebra::Sphere3D &loc, std::string text);
77 LabelGeometry(const algebra::Vector3D &loc, std::string text);
78 std::string get_text() const { return text_; }
79 const algebra::Sphere3D &get_location() const { return loc_; }
80 virtual IMP::display::Geometries get_components() const override;
81 IMP_OBJECT_METHODS(LabelGeometry);
82};
83
84//! Display a surface mesh
85/** Faces are delimited by -1s in the list of indices.
86*/
87class IMPDISPLAYEXPORT SurfaceMeshGeometry : public Geometry {
88 const algebra::Vector3Ds vertices_;
89 const Ints faces_;
90
91 protected:
92 SurfaceMeshGeometry(const std::pair<algebra::Vector3Ds, Ints> &m,
93 std::string name = "SurfaceMesh %1%");
94
95 public:
96 SurfaceMeshGeometry(const algebra::Vector3Ds &vertices, const Ints &faces);
97 const algebra::Vector3Ds &get_vertexes() const { return vertices_; }
98 const Ints &get_faces() const { return faces_; }
99 virtual IMP::display::Geometries get_components() const override;
100 IMP_OBJECT_METHODS(SurfaceMeshGeometry);
101};
102
103#ifdef IMP_DISPLAY_USE_IMP_CGAL
104//! Display a plane as truncated to a bounding box
105/** This requires CGAL.
106 */
107class IMPDISPLAYEXPORT PlaneGeometry : public Geometry {
108 algebra::Plane3D plane_;
110
111 public:
112 PlaneGeometry(const algebra::Plane3D &loc, const algebra::BoundingBox3D &box);
113 virtual IMP::display::Geometries get_components() const override;
114 IMP_OBJECT_METHODS(PlaneGeometry);
115};
116
117//! Display an isosurface of a density map
118/** This requires CGAL.
119 */
120class IsosurfaceGeometry : public SurfaceMeshGeometry {
121 public:
122 template <int D, class Storage, class Value>
123 IsosurfaceGeometry(const algebra::GridD<D, Storage, Value> &grid, double iso)
124 : SurfaceMeshGeometry(cgal::internal::get_iso_surface(grid, iso),
125 "IsosurfaceGeometry %1%") {}
126#ifdef SWIG
127 IsosurfaceGeometry(
129 grid,
130 double iso);
131 IsosurfaceGeometry(const algebra::GridD<
133 double iso);
134#endif
135};
136
137//! Display an isosurface of a density map
138/** This requires CGAL.
139 */
140class IMPDISPLAYEXPORT SkinSurfaceGeometry : public SurfaceMeshGeometry {
141 public:
142 SkinSurfaceGeometry(const algebra::Sphere3Ds &balls);
143};
144
145#endif
146
147IMPDISPLAY_END_NAMESPACE
148
149#endif /* IMPDISPLAY_PRIMITIVE_GEOMETRIES_H */
A bounding box in D dimensions.
Represent a cylinder in 3D.
Simple 3D ellipsoid class.
Simple 3D plane class.
A reference frame in 3D.
Simple implementation of segments in 3D.
Simple 3D sphere class.
Represent a triangle in 3D.
Simple 3D vector class.
An axis-aligned bounding box.
Represent a cylinder in 3D.
Definition Cylinder3D.h:27
Represent an ellipsoid in 3D.
Definition Ellipsoid3D.h:23
A voxel grid in d-dimensional space.
Definition GridD.h:81
Represent a plane in 3D.
Definition Plane3D.h:21
A reference frame in 3D.
Simple implementation of segments in 3D.
Definition Segment3D.h:24
Represent a triangle in 3D.
Definition Triangle3D.h:23
virtual IMP::display::Geometries get_components() const override
Return a set of geometry composing this one.
virtual IMP::display::Geometries get_components() const override
Return a set of geometry composing this one.
virtual IMP::display::Geometries get_components() const override
Return a set of geometry composing this one.
Implement geometry for the basic shapes from IMP.algebra.
macros for display classes
#define IMP_DISPLAY_GEOMETRY_DECL(Name, Names, Type)
Define a geometric object using an IMP::algebra one.
BoundingBoxD< 3 > BoundingBox3D
Typedef for Python.
SphereD< 3 > Sphere3D
Typedef for Python.
Definition SphereD.h:103
IMP::Vector< Sphere3D > Sphere3Ds
Definition SphereD.h:103
IMP::Vector< IMP::Pointer< Geometry > > Geometries
Vector< VectorD< 3 > > Vector3Ds
Definition VectorD.h:409
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition types.h:48
VectorD< 3 > Vector3D
Definition VectorD.h:407
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
All grids that are in the Python API should be defined here.