OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
tessellation.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_TESSELLATION_HPP__
10 #define CMZN_TESSELLATION_HPP__
11 
12 #include "opencmiss/zinc/tessellation.h"
13 #include "opencmiss/zinc/context.hpp"
14 
15 namespace OpenCMISS
16 {
17 namespace Zinc
18 {
19 
20 class Tessellationmodulenotifier;
21 
31 {
32 protected:
33  cmzn_tessellation_id id;
34 
35 public:
36 
37  Tessellation() : id(0)
38  { }
39 
40  // takes ownership of C handle, responsibility for destroying it
41  explicit Tessellation(cmzn_tessellation_id in_tessellation_id) :
42  id(in_tessellation_id)
43  { }
44 
45  Tessellation(const Tessellation& tessellation) :
46  id(cmzn_tessellation_access(tessellation.id))
47  { }
48 
49  Tessellation& operator=(const Tessellation& tessellation)
50  {
51  cmzn_tessellation_id temp_id = cmzn_tessellation_access(tessellation.id);
52  if (0 != id)
53  {
54  cmzn_tessellation_destroy(&id);
55  }
56  id = temp_id;
57  return *this;
58  }
59 
60  ~Tessellation()
61  {
62  if (0 != id)
63  {
64  cmzn_tessellation_destroy(&id);
65  }
66  }
67 
73  {
74  CHANGE_FLAG_NONE = CMZN_TESSELLATION_CHANGE_FLAG_NONE,
76  CHANGE_FLAG_ADD = CMZN_TESSELLATION_CHANGE_FLAG_ADD,
78  CHANGE_FLAG_REMOVE = CMZN_TESSELLATION_CHANGE_FLAG_REMOVE,
80  CHANGE_FLAG_IDENTIFIER = CMZN_TESSELLATION_CHANGE_FLAG_IDENTIFIER,
82  CHANGE_FLAG_DEFINITION = CMZN_TESSELLATION_CHANGE_FLAG_DEFINITION,
84  CHANGE_FLAG_FULL_RESULT = CMZN_TESSELLATION_CHANGE_FLAG_FULL_RESULT,
86  CHANGE_FLAG_FINAL = CMZN_TESSELLATION_CHANGE_FLAG_FINAL
89  };
90 
95  typedef int ChangeFlags;
96 
102  bool isValid() const
103  {
104  return (0 != id);
105  }
106 
112  cmzn_tessellation_id getId() const
113  {
114  return id;
115  }
116 
123  bool isManaged()
124  {
125  return cmzn_tessellation_is_managed(id);
126  }
127 
140  int setManaged(bool value)
141  {
142  return cmzn_tessellation_set_managed(id, value);
143  }
144 
153  {
154  return cmzn_tessellation_get_circle_divisions(id);
155  }
156 
166  int setCircleDivisions(int circleDivisions)
167  {
168  return cmzn_tessellation_set_circle_divisions(id, circleDivisions);
169  }
170 
177  char *getName()
178  {
179  return cmzn_tessellation_get_name(id);
180  }
181 
189  int setName(const char *name)
190  {
191  return cmzn_tessellation_set_name(id, name);
192  }
193 
207  int getMinimumDivisions(int valuesCount, int *valuesOut)
208  {
209  return cmzn_tessellation_get_minimum_divisions(id, valuesCount, valuesOut);
210  }
211 
224  int setMinimumDivisions(int valuesCount, const int *valuesIn)
225  {
226  return cmzn_tessellation_set_minimum_divisions(id, valuesCount, valuesIn);
227  }
228 
242  int getRefinementFactors(int valuesCount, int *valuesOut)
243  {
244  return cmzn_tessellation_get_refinement_factors(id, valuesCount, valuesOut);
245  }
246 
264  int setRefinementFactors(int valuesCount, const int *valuesIn)
265  {
266  return cmzn_tessellation_set_refinement_factors(id, valuesCount, valuesIn);
267  }
268 
269 };
270 
271 inline bool operator==(const Tessellation& a, const Tessellation& b)
272 {
273  return a.getId() == b.getId();
274 }
275 
276 
285 {
286 private:
287 
288  cmzn_tessellationiterator_id id;
289 
290 public:
291 
292  Tessellationiterator() : id(0)
293  { }
294 
295  // takes ownership of C handle, responsibility for destroying it
296  explicit Tessellationiterator(cmzn_tessellationiterator_id iterator_id) :
297  id(iterator_id)
298  { }
299 
300  Tessellationiterator(const Tessellationiterator& tessellationiterator) :
301  id(cmzn_tessellationiterator_access(tessellationiterator.id))
302  { }
303 
304  Tessellationiterator& operator=(const Tessellationiterator& tessellationiterator)
305  {
306  cmzn_tessellationiterator_id temp_id = cmzn_tessellationiterator_access(tessellationiterator.id);
307  if (0 != id)
308  {
309  cmzn_tessellationiterator_destroy(&id);
310  }
311  id = temp_id;
312  return *this;
313  }
314 
316  {
317  if (0 != id)
318  {
319  cmzn_tessellationiterator_destroy(&id);
320  }
321  }
322 
328  bool isValid() const
329  {
330  return (0 != id);
331  }
332 
342  {
343  return Tessellation(cmzn_tessellationiterator_next(id));
344  }
345 };
346 
355 {
356 protected:
357  cmzn_tessellationmodule_id id;
358 
359 public:
360 
361  Tessellationmodule() : id(0)
362  { }
363 
364  // takes ownership of C handle, responsibility for destroying it
365  explicit Tessellationmodule(cmzn_tessellationmodule_id in_tessellationmodule_id) :
366  id(in_tessellationmodule_id)
367  { }
368 
369  Tessellationmodule(const Tessellationmodule& tessellationModule) :
370  id(cmzn_tessellationmodule_access(tessellationModule.id))
371  { }
372 
373  Tessellationmodule& operator=(const Tessellationmodule& tessellationModule)
374  {
375  cmzn_tessellationmodule_id temp_id = cmzn_tessellationmodule_access(
376  tessellationModule.id);
377  if (0 != id)
378  {
379  cmzn_tessellationmodule_destroy(&id);
380  }
381  id = temp_id;
382  return *this;
383  }
384 
386  {
387  if (0 != id)
388  {
389  cmzn_tessellationmodule_destroy(&id);
390  }
391  }
392 
398  bool isValid() const
399  {
400  return (0 != id);
401  }
402 
408  cmzn_tessellationmodule_id getId() const
409  {
410  return id;
411  }
412 
420  {
421  return Tessellation(cmzn_tessellationmodule_create_tessellation(id));
422  }
423 
437  {
438  return Tessellationiterator(cmzn_tessellationmodule_create_tessellationiterator(id));
439  }
440 
448  {
449  return Tessellation(cmzn_tessellationmodule_find_tessellation_by_name(id, name));
450  }
451 
462  {
463  return cmzn_tessellationmodule_begin_change(id);
464  }
465 
475  int endChange()
476  {
477  return cmzn_tessellationmodule_end_change(id);
478  }
479 
489  {
490  return Tessellation(cmzn_tessellationmodule_get_default_tessellation(id));
491  }
492 
500  int setDefaultTessellation(const Tessellation& tessellation)
501  {
502  return cmzn_tessellationmodule_set_default_tessellation(id, tessellation.getId());
503  }
504 
515  {
516  return Tessellation(cmzn_tessellationmodule_get_default_points_tessellation(id));
517  }
518 
527  {
528  return cmzn_tessellationmodule_set_default_points_tessellation(id, tessellation.getId());
529  }
530 
538  int readDescription(const char *description)
539  {
540  return cmzn_tessellationmodule_read_description(this->id, description);
541  }
542 
550  {
551  return cmzn_tessellationmodule_write_description(this->id);
552  }
553 
561 };
562 
563 
571 {
572 protected:
573  cmzn_tessellationmoduleevent_id id;
574 
575 public:
576 
577  Tessellationmoduleevent() : id(0)
578  { }
579 
580  // takes ownership of C handle, responsibility for destroying it
581  explicit Tessellationmoduleevent(cmzn_tessellationmoduleevent_id in_tessellationmodule_event_id) :
582  id(in_tessellationmodule_event_id)
583  { }
584 
585  Tessellationmoduleevent(const Tessellationmoduleevent& tessellationmoduleEvent) :
586  id(cmzn_tessellationmoduleevent_access(tessellationmoduleEvent.id))
587  { }
588 
589  Tessellationmoduleevent& operator=(const Tessellationmoduleevent& tessellationmoduleEvent)
590  {
591  cmzn_tessellationmoduleevent_id temp_id = cmzn_tessellationmoduleevent_access(tessellationmoduleEvent.id);
592  if (0 != id)
593  cmzn_tessellationmoduleevent_destroy(&id);
594  id = temp_id;
595  return *this;
596  }
597 
599  {
600  if (0 != id)
601  {
602  cmzn_tessellationmoduleevent_destroy(&id);
603  }
604  }
605 
611  bool isValid() const
612  {
613  return (0 != id);
614  }
615 
621  cmzn_tessellationmoduleevent_id getId() const
622  {
623  return id;
624  }
625 
636  {
637  return cmzn_tessellationmoduleevent_get_tessellation_change_flags(id, tessellation.getId());
638  }
639 
648  {
649  return cmzn_tessellationmoduleevent_get_summary_tessellation_change_flags(id);
650  }
651 
652 };
653 
663 {
664 friend class Tessellationmodulenotifier;
665 private:
666  Tessellationmodulecallback(const Tessellationmodulecallback&); // not implemented
667  Tessellationmodulecallback& operator=(const Tessellationmodulecallback&); // not implemented
668 
669  static void C_callback(cmzn_tessellationmoduleevent_id tessellationmoduleevent_id, void *callbackVoid)
670  {
671  Tessellationmoduleevent tessellationmoduleevent(cmzn_tessellationmoduleevent_access(tessellationmoduleevent_id));
672  Tessellationmodulecallback *callback = reinterpret_cast<Tessellationmodulecallback *>(callbackVoid);
673  (*callback)(tessellationmoduleevent);
674  }
675 
676  virtual void operator()(const Tessellationmoduleevent &tessellationmoduleevent) = 0;
677 
678 protected:
680  { }
681 
682 public:
683  virtual ~Tessellationmodulecallback()
684  { }
685 };
686 
693 {
694 protected:
695  cmzn_tessellationmodulenotifier_id id;
696 
697 public:
698 
700  { }
701 
702  // takes ownership of C handle, responsibility for destroying it
703  explicit Tessellationmodulenotifier(cmzn_tessellationmodulenotifier_id in_tessellationmodulenotifier_id) :
704  id(in_tessellationmodulenotifier_id)
705  { }
706 
707  Tessellationmodulenotifier(const Tessellationmodulenotifier& tessellationmoduleNotifier) :
708  id(cmzn_tessellationmodulenotifier_access(tessellationmoduleNotifier.id))
709  { }
710 
711  Tessellationmodulenotifier& operator=(const Tessellationmodulenotifier& tessellationmoduleNotifier)
712  {
713  cmzn_tessellationmodulenotifier_id temp_id = cmzn_tessellationmodulenotifier_access(tessellationmoduleNotifier.id);
714  if (0 != id)
715  {
716  cmzn_tessellationmodulenotifier_destroy(&id);
717  }
718  id = temp_id;
719  return *this;
720  }
721 
723  {
724  if (0 != id)
725  {
726  cmzn_tessellationmodulenotifier_destroy(&id);
727  }
728  }
729 
735  bool isValid() const
736  {
737  return (0 != id);
738  }
739 
745  cmzn_tessellationmodulenotifier_id getId() const
746  {
747  return id;
748  }
749 
761  {
762  return cmzn_tessellationmodulenotifier_set_callback(id, callback.C_callback, static_cast<void*>(&callback));
763  }
764 
772  {
773  return cmzn_tessellationmodulenotifier_clear_callback(id);
774  }
775 };
776 
778 {
779  return Tessellationmodulenotifier(cmzn_tessellationmodule_create_tessellationmodulenotifier(id));
780 }
781 
782 
784 {
785  return Tessellationmodule(cmzn_context_get_tessellationmodule(id));
786 }
787 
788 } // namespace Zinc
789 }
790 
791 #endif
int endChange()
Definition: tessellation.hpp:475
cmzn_tessellation_id getId() const
Definition: tessellation.hpp:112
char * getName()
Definition: tessellation.hpp:177
bool isValid() const
Definition: tessellation.hpp:102
cmzn_tessellationmodulenotifier_id getId() const
Definition: tessellation.hpp:745
ChangeFlag
Definition: tessellation.hpp:72
Manages individual user notification of changes with a tessellation module.
Definition: tessellation.hpp:692
char * writeDescription()
Definition: tessellation.hpp:549
Tessellation getDefaultTessellation()
Definition: tessellation.hpp:488
int clearCallback()
Definition: tessellation.hpp:771
bool isValid() const
Definition: tessellation.hpp:735
Tessellation::ChangeFlags getTessellationChangeFlags(const Tessellation &tessellation) const
Definition: tessellation.hpp:635
cmzn_tessellationmoduleevent_id getId() const
Definition: tessellation.hpp:621
Tessellation next()
Definition: tessellation.hpp:341
bool isManaged()
Definition: tessellation.hpp:123
int setCircleDivisions(int circleDivisions)
Definition: tessellation.hpp:166
int getMinimumDivisions(int valuesCount, int *valuesOut)
Definition: tessellation.hpp:207
cmzn_tessellationmodule_id getId() const
Definition: tessellation.hpp:408
Base class functor for tessellation module notifier callbacks.
Definition: tessellation.hpp:662
An iterator for looping through all the tessellations in a tessellation module.
Definition: tessellation.hpp:284
bool isValid() const
Definition: tessellation.hpp:398
int setMinimumDivisions(int valuesCount, const int *valuesIn)
Definition: tessellation.hpp:224
Tessellation createTessellation()
Definition: tessellation.hpp:419
int setCallback(Tessellationmodulecallback &callback)
Definition: tessellation.hpp:760
int beginChange()
Definition: tessellation.hpp:461
Tessellation findTessellationByName(const char *name)
Definition: tessellation.hpp:447
The tessellation controls the number of polygons or line segments.
Definition: tessellation.hpp:30
Definition: tessellation.hpp:76
Tessellation getDefaultPointsTessellation()
Definition: tessellation.hpp:514
int setRefinementFactors(int valuesCount, const int *valuesIn)
Definition: tessellation.hpp:264
int readDescription(const char *description)
Definition: tessellation.hpp:538
Tessellationiterator createTessellationiterator()
Definition: tessellation.hpp:436
Module managing all tessellation objects.
Definition: tessellation.hpp:354
int ChangeFlags
Definition: tessellation.hpp:95
int getRefinementFactors(int valuesCount, int *valuesOut)
Definition: tessellation.hpp:242
int getCircleDivisions()
Definition: tessellation.hpp:152
bool isValid() const
Definition: tessellation.hpp:611
Information about changes to tessellations in the tessellation module.
Definition: tessellation.hpp:570
int setDefaultPointsTessellation(const Tessellation &tessellation)
Definition: tessellation.hpp:526
Tessellationmodulenotifier createTessellationmodulenotifier()
Definition: tessellation.hpp:777
bool isValid() const
Definition: tessellation.hpp:328
Tessellationmodule getTessellationmodule()
Definition: tessellation.hpp:783
Tessellation::ChangeFlags getSummaryTessellationChangeFlags() const
Definition: tessellation.hpp:647
int setManaged(bool value)
Definition: tessellation.hpp:140
int setDefaultTessellation(const Tessellation &tessellation)
Definition: tessellation.hpp:500
int setName(const char *name)
Definition: tessellation.hpp:189