source: trunk/packages/vizservers/nanovis/ConvexPolygon.h @ 3177

Last change on this file since 3177 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 * ConvexPolygon.h: convex polygon class
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16#ifndef _CONVEX_POLYGON_H_
17#define _CONVEX_POLYGON_H_
18
19#include <assert.h>
20#include <vector>
21
22#include "Vector4.h"
23#include "Plane.h"
24
25typedef std::vector<Vector4> VertexVector;
26typedef std::vector<Vector4> TexVector;
27
28class ConvexPolygon
29{
30public:
31    ConvexPolygon()
32    {}
33
34    ConvexPolygon(VertexVector vertices);
35
36    void transform(const Mat4x4& mat);
37
38    void translate(const Vector4& shift);
39
40    // Clips the polygon, retaining the portion where ax + by + cz + d >= 0
41    void clip(Plane& clipPlane, bool copyToTexcoords);
42
43    void emit(bool useTexture);
44
45    void emit(bool useTexture, const Vector3& shift, const Vector3& scale);
46
47    void copyVerticesToTexcoords();
48
49    void setId(int id)
50    {
51        volumeId = id;
52    }
53
54    void appendVertex(const Vector4& vert)
55    {
56        vertices.push_back(vert);
57    }
58
59    void insertVertex(unsigned int index, const Vector4& vert)
60    {
61        assert(index < vertices.size());
62        vertices.insert(vertices.begin() + index, vert);
63    }
64
65    bool isRetained(const Vector4& point, const Vector4& plane)
66    {
67        return ((point * plane) >= 0); 
68    }
69
70    VertexVector vertices;
71    TexVector texcoords;
72    int volumeId;       //which volume this polygon slice belongs to
73};
74
75#endif
Note: See TracBrowser for help on using the repository browser.