graphReducer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Filename: graphReducer.h
  2. // Created by: drose (26Apr00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef GRAPHREDUCER_H
  19. #define GRAPHREDUCER_H
  20. #include <pandabase.h>
  21. #include "nodeRelation.h"
  22. #include <typedObject.h>
  23. ///////////////////////////////////////////////////////////////////
  24. // Class : GraphReducer
  25. // Description : A generic interface to simplify a graph in various
  26. // ways, generally as a performance optimization. This
  27. // class is designed for generic graphs; also see the
  28. // SceneGraphReducer (which inherits from this class)
  29. // for a specific class to optimize renderable scene
  30. // graphs.
  31. ////////////////////////////////////////////////////////////////////
  32. class EXPCL_PANDA GraphReducer {
  33. public:
  34. GraphReducer(TypeHandle graph_type);
  35. virtual ~GraphReducer();
  36. void set_max_children(int count);
  37. int flatten(Node *root, bool combine_siblings);
  38. protected:
  39. int r_flatten(Node *root, bool combine_siblings);
  40. int flatten_siblings(Node *root);
  41. virtual bool consider_arc(NodeRelation *arc);
  42. virtual bool consider_siblings(Node *parent,
  43. NodeRelation *arc1, NodeRelation *arc2);
  44. virtual bool flatten_arc(NodeRelation *arc);
  45. virtual NodeRelation *collapse_siblings(Node *parent, NodeRelation *arc1,
  46. NodeRelation *arc2);
  47. virtual Node *collapse_nodes(Node *node1, Node *node2, bool siblings);
  48. virtual void choose_name(Node *preserve, Node *source1, Node *source2);
  49. protected:
  50. void move_children(Node *to, Node *from);
  51. void copy_children(Node *to, Node *from);
  52. protected:
  53. int _max_children;
  54. TypeHandle _graph_type;
  55. };
  56. #endif