# source:nanovis/branches/1.1/ConvexPolygon.h@4804

Last change on this file since 4804 was 3502, checked in by ldelgass, 7 years ago

• Property svn:eol-style set to `native`
File size: 1.9 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-2013  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 <vrmath/Vector3f.h>
23#include <vrmath/Vector4f.h>
24#include <vrmath/Matrix4x4d.h>
25
26#include "Plane.h"
27
28typedef std::vector<vrmath::Vector4f> VertexVector;
29typedef std::vector<vrmath::Vector4f> TexVector;
30
31class ConvexPolygon
32{
33public:
34    ConvexPolygon()
35    {}
36
37    ConvexPolygon(VertexVector vertices);
38
39    void transform(const vrmath::Matrix4x4d& mat);
40
41    void translate(const vrmath::Vector4f& shift);
42
43    // Clips the polygon, retaining the portion where ax + by + cz + d >= 0
44    bool clip(nv::Plane& clipPlane, bool copyToTexcoords);
45
46    void emit(bool useTexture);
47
48    void emit(bool useTexture, const vrmath::Vector3f& shift, const vrmath::Vector3f& scale);
49
50    void copyVerticesToTexcoords();
51
52    void setId(int id)
53    {
54        volumeId = id;
55    }
56
57    void appendVertex(const vrmath::Vector4f& vert)
58    {
59        vertices.push_back(vert);
60    }
61
62    void insertVertex(unsigned int index, const vrmath::Vector4f& vert)
63    {
64        assert(index < vertices.size());
65        vertices.insert(vertices.begin() + index, vert);
66    }
67
68    VertexVector vertices;
69    TexVector texcoords;
70    int volumeId;       //which volume this polygon slice belongs to
71};
72
73#endif
Note: See TracBrowser for help on using the repository browser.