Panda3D
eggPolygon.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file eggPolygon.h
10  * @author drose
11  * @date 1999-01-16
12  */
13 
14 #ifndef EGGPOLYGON_H
15 #define EGGPOLYGON_H
16 
17 #include "pandabase.h"
18 
19 #include "eggPrimitive.h"
20 
21 /**
22  * A single polygon.
23  */
24 class EXPCL_PANDA_EGG EggPolygon : public EggPrimitive {
25 PUBLISHED:
26  INLINE explicit EggPolygon(const std::string &name = "");
27  INLINE EggPolygon(const EggPolygon &copy);
28  INLINE EggPolygon &operator = (const EggPolygon &copy);
29 
30  virtual EggPolygon *make_copy() const override;
31 
32  virtual bool cleanup() override;
33 
34  bool calculate_normal(LNormald &result, CoordinateSystem cs = CS_default) const;
35  bool is_planar() const;
36 
37  INLINE bool recompute_polygon_normal(CoordinateSystem cs = CS_default);
38 
39  INLINE bool triangulate_into(EggGroupNode *container, bool convex_also) const;
40  PT(EggPolygon) triangulate_in_place(bool convex_also);
41 
42  virtual void write(std::ostream &out, int indent_level) const override;
43 
44 private:
45  bool decomp_concave(EggGroupNode *container, int asum, int x, int y) const;
46  bool triangulate_poly(EggGroupNode *container, bool convex_also);
47 
48 public:
49 
50  static TypeHandle get_class_type() {
51  return _type_handle;
52  }
53  static void init_type() {
54  EggPrimitive::init_type();
55  register_type(_type_handle, "EggPolygon",
56  EggPrimitive::get_class_type());
57  }
58  virtual TypeHandle get_type() const override {
59  return get_class_type();
60  }
61  virtual TypeHandle force_init_type() override {
62  init_type();
63  return get_class_type();
64  }
65 
66 private:
67  static TypeHandle _type_handle;
68 
69 };
70 
71 #include "eggPolygon.I"
72 
73 #endif
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Definition: eggPrimitive.h:47
virtual bool cleanup()
Cleans up modeling errors in whatever context this makes sense.
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single polygon.
Definition: eggPolygon.h:24
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81