Ignore:
Timestamp:
Mar 7, 2012, 12:21:30 PM (13 years ago)
Author:
ldelgass
Message:

Const correctness fixes, pass vector/matrix objects by reference, various
formatting and style cleanups, don't spam syslog and uncomment openlog() call.
Still needs to be compiled with -DWANT_TRACE to get tracing, but now trace
output will be output to file in /tmp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/ConvexPolygon.h

    r2798 r2822  
    1717#define _CONVEX_POLYGON_H_
    1818
     19#include <assert.h>
     20#include <vector>
     21
    1922#include "Vector4.h"
    2023#include "Plane.h"
    21 #include <assert.h>
    22 #include <vector>
    2324
    2425typedef std::vector<Vector4> VertexVector;
    2526typedef std::vector<Vector4> TexVector;
    2627
    27 class ConvexPolygon {
     28class ConvexPolygon
     29{
    2830public:
    2931    VertexVector vertices;
    3032    TexVector texcoords;
    3133    int volume_id;      //which volume this polygon slice belongs to
    32    
    33     ConvexPolygon();
     34
     35    ConvexPolygon()
     36    {}
     37
    3438    ConvexPolygon(VertexVector vertices);
    35    
    36     void transform(Mat4x4 mat);
    37     void translate(Vector4 shift);
    38    
     39
     40    void transform(const Mat4x4& mat);
     41
     42    void translate(const Vector4& shift);
     43
    3944    // Clips the polygon, retaining the portion where ax + by + cz + d >= 0
    40     void clip(Plane &clipPlane, bool copy_to_texcoords);
     45    void clip(Plane& clipPlane, bool copy_to_texcoords);
     46
    4147    void Emit(bool use_texture);
    42     void Emit(bool use_texture, Vector3& shift, Vector3& scale);
     48
     49    void Emit(bool use_texture, const Vector3& shift, const Vector3& scale);
     50
    4351    void copy_vertices_to_texcoords();
    4452
    45     void set_id(int v_id) {
    46         volume_id = v_id;
    47     };
    48     void append_vertex(Vector4 vert) {
    49         vertices.push_back(vert);
     53    void set_id(int v_id)
     54    {
     55        volume_id = v_id;
    5056    }
    51     void insert_vertex(unsigned int index, Vector4 vert) {
    52         assert(index<vertices.size());
    53         vertices.insert(vertices.begin() + index, vert);
     57
     58    void append_vertex(const Vector4& vert)
     59    {
     60        vertices.push_back(vert);
    5461    }
    55     bool is_retained(Vector4 point, Vector4 plane) {
    56         return ((point * plane) >= 0); 
     62
     63    void insert_vertex(unsigned int index, const Vector4& vert)
     64    {
     65        assert(index<vertices.size());
     66        vertices.insert(vertices.begin() + index, vert);
     67    }
     68
     69    bool is_retained(const Vector4& point, const Vector4& plane)
     70    {
     71        return ((point * plane) >= 0); 
    5772    }
    5873};
Note: See TracChangeset for help on using the changeset viewer.