polyeder.c++ 1.89 KB
#include "polyeder.h"

polyeder::polyeder(const polygon& p, const vertex_list& vl) : 
          container<polygon>(p), vl(vl) {
    for(unsigned i=0; i<count; i++) {
        content[i].set_vertex_list(&this->vl);
        content[i]._init_normal_();
        content[i].set_polyeder(this);
    }
}

polyeder::polyeder(const polygon* p, unsigned c, const vertex_list& vl) : 
          container<polygon>(p, c), vl(vl) {
    for(unsigned i=0; i<count; i++) {
        content[i].set_vertex_list(&this->vl);
        content[i]._init_normal_();
        content[i].set_polyeder(this);
    }
}

polyeder::polyeder(const polyeder& p) : 
          container<polygon>(p), vl(p.vl) {
    for(unsigned i=0; i<count; i++) {
        content[i].set_vertex_list(&this->vl);
        content[i].set_polyeder(this);
    }
}

const polyeder& polyeder::operator=(const polyeder& p) {
    if(this==&p)
        return *this;

    container<polygon>::operator=(p);
    vl=p.vl;

    for(unsigned i=0; i<count; i++) {
        content[i].set_vertex_list(&vl);
        content[i].set_polyeder(this);
    }

    return *this;
}

void polyeder::transform(const Mmn<double>& tm, int p) {
    for(unsigned i=0; i<count; i++) {
        content[i].transform(tm, p);
    }
}

void polyeder::transform_normals(const Mmn<double>& tm, int p) {
    for(unsigned i=0; i<count; i++) {
        content[i].transform_normal(tm, p);
    }
}

void polyeder::reset(void) {
    vl.reset();

    for(unsigned i=0; i<count; i++) {
        content[i].reset();
    }
}

void polyeder::trans_poly(unsigned i, const Mmn<double>& tm, int p) {
    content[i].transform(tm, p);
}

void polyeder::project_2d(double lcx, double sw, double sh, 
                          double ph_ar, double sy, int p) {
    for(unsigned i=0; i<count; i++) {
        content[i].project_2d(lcx, sw, sh, ph_ar, sy, p+1);
    }
    for(unsigned i=0; i<vl.card(); i++) {
        vl[i].set_trans_stage(p);
    }
}