Panda3D
Public Member Functions | Static Public Member Functions

EggPolygon Class Reference

A single polygon. More...

#include "eggPolygon.h"

Inheritance diagram for EggPolygon:
EggPrimitive EggNode EggAttributes EggRenderMode EggNamedObject MemoryBase EggObject Namable TypedReferenceCount MemoryBase TypedObject ReferenceCount MemoryBase MemoryBase

List of all members.

Public Member Functions

 EggPolygon (const string &name="")
 EggPolygon (const EggPolygon &copy)
bool calculate_normal (LNormald &result, CoordinateSystem cs=CS_default) const
 Calculates the true polygon normal--the vector pointing out of the front of the polygon--based on the vertices.
virtual bool cleanup ()
 Cleans up modeling errors in whatever context this makes sense.
virtual TypeHandle force_init_type ()
virtual TypeHandle get_type () const
bool is_planar () const
 Returns true if all of the polygon's vertices lie within the same plane, false otherwise.
EggPolygonoperator= (const EggPolygon &copy)
 PT (EggPolygon) triangulate_in_place(bool convex_also)
bool recompute_polygon_normal (CoordinateSystem cs=CS_default)
 Recalculates the normal according to the order of the vertices, and sets it.
bool triangulate_into (EggGroupNode *container, bool convex_also) const
 Subdivides the polygon into triangles and adds each one to the indicated container.
virtual void write (ostream &out, int indent_level) const
 Writes the polygon to the indicated output stream in Egg format.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Detailed Description

A single polygon.

Definition at line 26 of file eggPolygon.h.


Member Function Documentation

bool EggPolygon::calculate_normal ( LNormald result,
CoordinateSystem  cs = CS_default 
) const

Calculates the true polygon normal--the vector pointing out of the front of the polygon--based on the vertices.

This does not return or change the polygon's normal as set via set_normal().

The return value is true if the normal is computed correctly, or false if the polygon is degenerate and does not have at least three noncollinear vertices.

Definition at line 57 of file eggPolygon.cxx.

References EggVertex::get_pos3(), EggPrimitive::get_vertex(), LVecBase3d::normalize(), and LVector3d::zero().

Referenced by cleanup(), is_planar(), and recompute_polygon_normal().

bool EggPolygon::cleanup ( ) [virtual]

Cleans up modeling errors in whatever context this makes sense.

For instance, for a polygon, this calls remove_doubled_verts(true). For a point, it calls remove_nonunique_verts(). Returns true if the primitive is valid, or false if it is degenerate.

Reimplemented from EggPrimitive.

Definition at line 36 of file eggPolygon.cxx.

References calculate_normal(), and EggPrimitive::remove_doubled_verts().

Referenced by DXFToEggLayer::add_polygon().

bool EggPolygon::is_planar ( ) const

Returns true if all of the polygon's vertices lie within the same plane, false otherwise.

Definition at line 96 of file eggPolygon.cxx.

References LVecBase3d::almost_equal(), calculate_normal(), and LPlaned::dist_to_plane().

bool EggPolygon::recompute_polygon_normal ( CoordinateSystem  cs = CS_default) [inline]

Recalculates the normal according to the order of the vertices, and sets it.

Returns true if the normal is computed correctly, or false if the polygon is degenerate and does not have a normal.

Definition at line 54 of file eggPolygon.I.

References calculate_normal().

Referenced by EggGroupNode::recompute_polygon_normals().

bool EggPolygon::triangulate_into ( EggGroupNode container,
bool  convex_also 
) const [inline]

Subdivides the polygon into triangles and adds each one to the indicated container.

If the polygon is already a triangle, adds an exact copy of the polygon to the container. Does not remove the polygon from its existing parent or modify it in any way.

Returns true if the triangulation is successful, or false if there was some error (in which case the container may contain some partial triangulation).

If convex_also is true, both concave and convex polygons will be subdivided into triangles; otherwise, only concave polygons will be subdivided, and convex polygons will be copied unchanged into the container.

Definition at line 84 of file eggPolygon.I.

Referenced by EggToDXFLayer::write_3d_face().

void EggPolygon::write ( ostream &  out,
int  indent_level 
) const [virtual]

Writes the polygon to the indicated output stream in Egg format.

Implements EggPrimitive.

Definition at line 174 of file eggPolygon.cxx.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations