Normand Briere
2019-09-07 3e5c2d344e04e0adb6a210c5c6302bfbfd8af102
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class Lathe extends Biparam implements java.io.Serializable
{
 
    Lathe()
    {
        inPnt = new cVector();
        name = "Lathe";
        spline = new Spline();
        uDivs = 32;
        vDivs = 16;
        minUDivs = 3;
        minVDivs = 1;
        endcaps = false;
        retile();
        recalculate();
    }
   
    Object3D deepCopy()
    {
        Lathe l = new Lathe();
        deepCopySelf(l);
        return l;
    }
 
    protected void deepCopyNode(Object3D other)
    {
        super.deepCopyNode(other);
        Lathe l = (Lathe)other;
        l.spline = (Spline)spline.deepCopy();
    }
 
    void generatePOV(StringBuffer buffer)
    {
        generateNameComment(buffer);
        generateIndent(buffer);
        buffer.append("lathe {\n");
        spline.generatePOV(buffer);
        generateTransform(buffer);
        generateIndent(buffer);
        buffer.append("}\n");
    }
 
    Vertex biparamFunction(double u, double v)
    {
        Vertex temp = spline.paramFunction(v);
        if (u < 0)
        {
            temp./*pos.*/x = temp./*pos.*/z = 0;
        } else
        {
            double mat[][] = LA.newMatrix();
            LA.matYRotate(mat, 6.283185 * u);
            LA.xformPos(temp/*.pos*/, mat, temp/*.pos*/);
        }
        return temp;
    }
 
    void createEditWindow(GroupEditor callee, boolean newWindow)
    {
        if(newWindow)
            objectUI = new LatheEditor(this, deepCopy(), callee);
        else
            objectUI = new LatheEditor(this, callee);
        editWindow = objectUI.GetEditor();
    }
 
    void getBounds(cVector minima, cVector maxima, boolean xform)
    {
        spline.getBounds(minima, maxima, true);
        maxima.z = maxima.x;
        minima.z = minima.x = -maxima.x;
        if (xform)
            transformBounds(minima, maxima);
    }
 
    boolean inside(double x, double y, double z, boolean xform)
    {
        if (xform)
            untransform(x, y, z, inPnt);
        else
            LA.setVector(inPnt, x, y, z);
        double rad = (double)Math.sqrt(inPnt.x * inPnt.x + inPnt.z * inPnt.z);
        int count = spline.intersectHorizontal(rad, inPnt.y);
        return count % 2 == 1;
    }
 
    Spline spline;
    protected cVector inPnt;
}