OpenCMISS-Zinc C++ API Documentation
scene.hpp
Go to the documentation of this file.
1 
4 /* OpenCMISS-Zinc Library
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #ifndef CMZN_SCENE_HPP__
10 #define CMZN_SCENE_HPP__
11 
12 #include "opencmiss/zinc/scene.h"
13 #include "opencmiss/zinc/field.hpp"
14 #include "opencmiss/zinc/graphics.hpp"
15 #include "opencmiss/zinc/light.hpp"
16 #include "opencmiss/zinc/nodeset.hpp"
17 #include "opencmiss/zinc/region.hpp"
18 #include "opencmiss/zinc/scenefilter.hpp"
19 #include "opencmiss/zinc/selection.hpp"
20 #include "opencmiss/zinc/spectrum.hpp"
21 #include "opencmiss/zinc/timekeeper.hpp"
22 
23 namespace OpenCMISS
24 {
25 namespace Zinc
26 {
27 
28 class StreaminformationScene;
29 class Sceneviewermodule;
30 class Scenepicker;
31 
38 class Scene
39 {
40 
41 protected:
42  cmzn_scene_id id;
43 
44 public:
45 
46  Scene() : id(0)
47  { }
48 
49  // takes ownership of C handle, responsibility for destroying it
50  explicit Scene(cmzn_scene_id scene_id) : id(scene_id)
51  { }
52 
53  Scene(const Scene& scene) : id(cmzn_scene_access(scene.id))
54  { }
55 
56  Scene& operator=(const Scene& scene)
57  {
58  cmzn_scene_id temp_id = cmzn_scene_access(scene.id);
59  if (0 != id)
60  {
61  cmzn_scene_destroy(&id);
62  }
63  id = temp_id;
64  return *this;
65  }
66 
67  ~Scene()
68  {
69  if (0 != id)
70  {
71  cmzn_scene_destroy(&id);
72  }
73  }
74 
80  bool isValid() const
81  {
82  return (0 != id);
83  }
84 
90  cmzn_scene_id getId() const
91  {
92  return id;
93  }
94 
105  {
106  return cmzn_scene_begin_change(id);
107  }
108 
118  int endChange()
119  {
120  return cmzn_scene_end_change(id);
121  }
122 
148  int convertToPointCloud(const Scenefilter& filter, const Nodeset& nodeset,
149  const Field& coordinateField, double lineDensity, double lineDensityScaleFactor,
150  double surfaceDensity, double surfaceDensityScaleFactor)
151  {
152  return cmzn_scene_convert_to_point_cloud(id, filter.getId(),
153  nodeset.getId(), coordinateField.getId(),
154  lineDensity, lineDensityScaleFactor,
155  surfaceDensity, surfaceDensityScaleFactor);
156  }
157 
172  int convertPointsToNodes(const Scenefilter& filter, const Nodeset& nodeset,
173  const Field& coordinateField)
174  {
175  return cmzn_scene_convert_points_to_nodes(id, filter.getId(),
176  nodeset.getId(), coordinateField.getId());
177  }
178 
186  {
187  return Graphics(cmzn_scene_create_graphics(id,
188  static_cast<cmzn_graphics_type>(graphicsType)));
189  }
190 
199  {
200  return GraphicsContours(cmzn_scene_create_graphics_contours(id));
201  }
202 
210  {
211  return GraphicsLines(cmzn_scene_create_graphics_lines(id));
212  }
213 
223  {
224  return GraphicsPoints(cmzn_scene_create_graphics_points(id));
225  }
226 
233  {
234  return GraphicsStreamlines(cmzn_scene_create_graphics_streamlines(id));
235  }
236 
244  {
245  return GraphicsSurfaces(cmzn_scene_create_graphics_surfaces(id));
246  }
247 
257  {
258  return Selectionnotifier(cmzn_scene_create_selectionnotifier(id));
259  }
260 
279  Graphics findGraphicsByName(const char *name)
280  {
281  return Graphics(cmzn_scene_find_graphics_by_name(id, name));
282  }
283 
296  int getCoordinatesRange(const Scenefilter& filter, double *minimumValuesOut3,
297  double *maximumValuesOut3)
298  {
299  return cmzn_scene_get_coordinates_range(id, filter.getId(),
300  minimumValuesOut3, maximumValuesOut3);
301  }
302 
309  {
310  return Graphics(cmzn_scene_get_first_graphics(id));
311  }
312 
319  Graphics getNextGraphics(const Graphics& refGraphics)
320  {
321  return Graphics(cmzn_scene_get_next_graphics(id, refGraphics.getId()));
322  }
323 
331  {
332  return Graphics(cmzn_scene_get_previous_graphics(id, refGraphics.getId()));
333  }
334 
341  {
342  return cmzn_scene_get_number_of_graphics(id);
343  }
344 
350  inline Region getRegion() const
351  {
352  return Region(cmzn_scene_get_region(id));
353  }
354 
361  {
362  return Fontmodule(cmzn_scene_get_fontmodule(id));
363  }
364 
373  {
374  return Glyphmodule(cmzn_scene_get_glyphmodule(id));
375  }
376 
385  {
386  return Lightmodule(cmzn_scene_get_lightmodule(id));
387  }
388 
398  {
399  return Materialmodule(cmzn_scene_get_materialmodule(id));
400  }
401 
409  {
410  return Scenefiltermodule(cmzn_scene_get_scenefiltermodule(id));
411  }
412 
420 
428  {
429  return Spectrummodule(cmzn_scene_get_spectrummodule(id));
430  }
431 
439  {
440  return Tessellationmodule(cmzn_scene_get_tessellationmodule(id));
441  }
442 
450  {
451  return Timekeepermodule(cmzn_scene_get_timekeepermodule(id));
452  }
453 
460  {
461  return Field(cmzn_scene_get_selection_field(id));
462  }
463 
474  int setSelectionField(const Field& selectionField)
475  {
476  return cmzn_scene_set_selection_field(id, selectionField.getId());
477  }
478 
499  int getSpectrumDataRange(const Scenefilter& filter, const Spectrum& spectrum,
500  int valuesCount, double *minimumValuesOut, double *maximumValuesOut)
501  {
502  return cmzn_scene_get_spectrum_data_range(id, filter.getId(),
503  spectrum.getId(), valuesCount, minimumValuesOut, maximumValuesOut);
504  }
505 
512  {
513  return cmzn_scene_clear_transformation(id);
514  }
515 
521  bool hasTransformation() const
522  {
523  return cmzn_scene_has_transformation(id);
524  }
525 
535  {
536  return Field(cmzn_scene_get_transformation_field(id));
537  }
538 
555  int setTransformationField(const Field& transformationField)
556  {
557  return cmzn_scene_set_transformation_field(id, transformationField.getId());
558  }
559 
574  int getTransformationMatrix(double *valuesOut16) const
575  {
576  return cmzn_scene_get_transformation_matrix(this->getId(), valuesOut16);
577  }
578 
602  int setTransformationMatrix(const double *valuesIn16)
603  {
604  return cmzn_scene_set_transformation_matrix(this->getId(), valuesIn16);
605  }
606 
613  {
614  return cmzn_scene_get_visibility_flag(id);
615  }
616 
624  int setVisibilityFlag(bool visibilityFlag)
625  {
626  return cmzn_scene_set_visibility_flag(id, visibilityFlag);
627  }
628 
640  int moveGraphicsBefore(const Graphics& graphics, const Graphics& refGraphics)
641  {
642  return cmzn_scene_move_graphics_before(id, graphics.getId(), refGraphics.getId());
643  }
644 
651  {
652  return cmzn_scene_remove_all_graphics(id);
653  }
654 
661  int removeGraphics(const Graphics& graphics)
662  {
663  return cmzn_scene_remove_graphics(id, graphics.getId());
664  }
665 
673  {
674  return cmzn_scene_write_description(id);
675  }
676 
686  int readDescription(const char *description, bool overwrite)
687  {
688  return cmzn_scene_read_description(id, description, overwrite);
689  }
690 
698 
709  inline int write(const StreaminformationScene& streaminformationScene);
710 
720  inline int read(const StreaminformationScene& streaminformationScene);
721 
729 
730 };
731 
732 inline bool operator==(const Scene& a, const Scene& b)
733 {
734  return a.getId() == b.getId();
735 }
736 
738 {
739  return Scene(cmzn_region_get_scene(id));
740 }
741 
743 {
744  return Scene(cmzn_graphics_get_scene(id));
745 }
746 
747 inline int Spectrum::autorange(const Scene &scene, const Scenefilter &scenefilter)
748 {
749  return cmzn_spectrum_autorange(id, scene.getId(), scenefilter.getId());
750 }
751 
752 } // namespace Zinc
753 }
754 
755 #endif
Graphics getFirstGraphics()
Definition: scene.hpp:308
int autorange(const Scene &scene, const Scenefilter &scenefilter)
Definition: scene.hpp:747
Graphics getNextGraphics(const Graphics &refGraphics)
Definition: scene.hpp:319
cmzn_scenefilter_id getId() const
Definition: scenefilter.hpp:86
Lines visualise 1-D elements in the model.
Definition: graphics.hpp:848
int setVisibilityFlag(bool visibilityFlag)
Definition: scene.hpp:624
Materialmodule getMaterialmodule()
Definition: scene.hpp:397
Utility object for picking graphics and model objects.
Definition: scenepicker.hpp:32
int endChange()
Definition: scene.hpp:118
Module managing all light objects.
Definition: light.hpp:484
int removeGraphics(const Graphics &graphics)
Definition: scene.hpp:661
Surfaces visualise 2-D elements in the model.
Definition: graphics.hpp:1067
Scenepicker createScenepicker()
Definition: scenepicker.hpp:252
Glyphmodule getGlyphmodule()
Definition: scene.hpp:372
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:51
Graphics createGraphics(Graphics::Type graphicsType)
Definition: scene.hpp:185
int readDescription(const char *description, bool overwrite)
Definition: scene.hpp:686
Module managing all fonts.
Definition: font.hpp:273
cmzn_nodeset_id getId() const
Definition: nodeset.hpp:82
bool isValid() const
Definition: scene.hpp:80
Container/manager for graphics visualising a region.
Definition: scene.hpp:38
int getSpectrumDataRange(const Scenefilter &filter, const Spectrum &spectrum, int valuesCount, double *minimumValuesOut, double *maximumValuesOut)
Definition: scene.hpp:499
Points graphics visualise discrete locations in the model.
Definition: graphics.hpp:875
Lightmodule getLightmodule()
Definition: scene.hpp:384
Tessellationmodule getTessellationmodule()
Definition: scene.hpp:438
char * writeDescription()
Definition: scene.hpp:672
Manages individual user notification of changes to the selection group.
Definition: selection.hpp:158
A hierarchical block/namespace owning domains and fields.
Definition: region.hpp:33
int setSelectionField(const Field &selectionField)
Definition: scene.hpp:474
Base graphics type: produces 3-D graphics visualising domains and fields.
Definition: graphics.hpp:45
cmzn_spectrum_id getId() const
Definition: spectrum.hpp:741
Module managing all scene filters.
Definition: scenefilter.hpp:313
GraphicsPoints createGraphicsPoints()
Definition: scene.hpp:222
A scene-specific stream information object.
Definition: streamscene.hpp:31
int convertToPointCloud(const Scenefilter &filter, const Nodeset &nodeset, const Field &coordinateField, double lineDensity, double lineDensityScaleFactor, double surfaceDensity, double surfaceDensityScaleFactor)
Definition: scene.hpp:148
cmzn_field_id getId() const
Definition: field.hpp:103
Field getTransformationField() const
Definition: scene.hpp:534
bool getVisibilityFlag()
Definition: scene.hpp:612
int setTransformationField(const Field &transformationField)
Definition: scene.hpp:555
GraphicsLines createGraphicsLines()
Definition: scene.hpp:209
int setTransformationMatrix(const double *valuesIn16)
Definition: scene.hpp:602
Module object for creating and managing scene viewers.
Definition: sceneviewer.hpp:1271
Field getSelectionField()
Definition: scene.hpp:459
GraphicsContours createGraphicsContours()
Definition: scene.hpp:198
cmzn_scene_id getId() const
Definition: scene.hpp:90
int read(const StreaminformationScene &streaminformationScene)
Definition: streamscene.hpp:324
GraphicsStreamlines createGraphicsStreamlines()
Definition: scene.hpp:232
Module managing all spectrums.
Definition: spectrum.hpp:1037
Module managing all materials.
Definition: material.hpp:350
Zinc Spectrum maps values of graphics data fields to colours.
Definition: spectrum.hpp:656
Scene getScene()
Definition: scene.hpp:737
Module managing all glyphs.
Definition: glyph.hpp:714
int moveGraphicsBefore(const Graphics &graphics, const Graphics &refGraphics)
Definition: scene.hpp:640
Sceneviewermodule getSceneviewermodule()
Definition: sceneviewer.hpp:1414
int write(const StreaminformationScene &streaminformationScene)
Definition: streamscene.hpp:319
Scenefiltermodule getScenefiltermodule()
Definition: scene.hpp:408
Graphics findGraphicsByName(const char *name)
Definition: scene.hpp:279
Fontmodule getFontmodule()
Definition: scene.hpp:360
Module managing all tessellation objects.
Definition: tessellation.hpp:354
Streamlines visualise the path of a fluid particle tracking along a vector field. ...
Definition: graphics.hpp:904
Spectrummodule getSpectrummodule()
Definition: scene.hpp:427
bool hasTransformation() const
Definition: scene.hpp:521
int removeAllGraphics()
Definition: scene.hpp:650
Module for finding and managing timekeepers.
Definition: timekeeper.hpp:222
int convertPointsToNodes(const Scenefilter &filter, const Nodeset &nodeset, const Field &coordinateField)
Definition: scene.hpp:172
Type
Definition: graphics.hpp:131
The OpenCMISS namespace.
Definition: context.hpp:20
int getCoordinatesRange(const Scenefilter &filter, double *minimumValuesOut3, double *maximumValuesOut3)
Definition: scene.hpp:296
int getTransformationMatrix(double *valuesOut16) const
Definition: scene.hpp:574
StreaminformationScene createStreaminformationScene()
Definition: streamscene.hpp:313
Scene filters determines which graphics are drawn.
Definition: scenefilter.hpp:33
Timekeepermodule getTimekeepermodule()
Definition: scene.hpp:449
int beginChange()
Definition: scene.hpp:104
The contours derived graphics type.
Definition: graphics.hpp:708
Scene getScene()
Definition: scene.hpp:742
cmzn_graphics_id getId() const
Definition: graphics.hpp:153
Region getRegion() const
Definition: scene.hpp:350
Graphics getPreviousGraphics(const Graphics &refGraphics)
Definition: scene.hpp:330
Selectionnotifier createSelectionnotifier()
Definition: scene.hpp:256
int getNumberOfGraphics()
Definition: scene.hpp:340
A set of nodes or points.
Definition: nodeset.hpp:29
GraphicsSurfaces createGraphicsSurfaces()
Definition: scene.hpp:243
int clearTransformation()
Definition: scene.hpp:511