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

Last change on this file since 3464 was 3362, checked in by ldelgass, 12 years ago

Merge nanovis2 branch to trunk

  • Property svn:eol-style set to native
File size: 1.7 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    bool 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    VertexVector vertices;
66    TexVector texcoords;
67    int volumeId;       //which volume this polygon slice belongs to
68};
69
70#endif
Note: See TracBrowser for help on using the repository browser.