summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/drawpath3.h
blob: 25e9ffadf6dd42af2102c71966cbeb09354dd050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*****
 * drawpath3.h
 *
 * Stores a path3 that has been added to a picture.
 *****/

#ifndef DRAWPATH3_H
#define DRAWPATH3_H

#include "drawelement.h"
#include "path3.h"

namespace camp {

class drawPath3 : public drawElement {
protected:
  const path3 g;
  bool straight;
  RGBAColour color;
  bool invisible;
  triple Min,Max;
  Triple *controls;
public:
  drawPath3(path3 g, const pen&p) :
    g(g), straight(g.piecewisestraight()), color(rgba(p)),
    invisible(p.invisible()), Min(g.min()), Max(g.max()), controls(NULL) {}
    
  drawPath3(const vm::array& t, const drawPath3 *s) :
    g(camp::transformed(t,s->g)), straight(s->straight), color(s->color),
    invisible(s->invisible), Min(g.min()), Max(g.max()), controls(NULL) {}
  
  virtual ~drawPath3() {
    if(controls) delete controls;
  }

  bool is3D() {return true;}
  
  void bounds(bbox3& B) {
    B.add(Min);
    B.add(Max);
  }
  
  void bounds(pair &b, double (*m)(double, double),
              double (*x)(const triple&, double*),
              double (*y)(const triple&, double*),
              double *t, bool &first) {
    pair z=g.bounds(m,x,y,t);
    if(first) {
      b=z;
      first=false;
    } else b=pair(m(b.getx(),z.getx()),m(b.gety(),z.gety()));
  }
  
  bool write(prcfile *out);
  
  void render(GLUnurbs*, double, const triple&, const triple&, double,
              bool transparent);

  drawElement *transformed(const vm::array& t);
};

}

#endif