summaryrefslogtreecommitdiff
path: root/cad/src/experimental/oleksandr/cppsurface.cpp
blob: 8c498742a87d799bc1ea03b8c4b6a8f26212b2ed (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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2006-2007 Nanorex, Inc.  See LICENSE file for details. 
/*
  Name: cppsurface.cpp
  Author: Oleksandr Shevchenko
  Description: CPP functions to call from C 
*/

#include "cppsurface.h"
#include "surface.h"
#include "hierarchy.h"
#include "collisiondetector.h"

Surface * s;
Surface * s0;
Surface * s1;
Hierarchy * h0;
Hierarchy * h1;

void cppAdd(double x, double y, double z, double r, int p)
{
	s->Add(x,y,z,r,p);
}
void cppCreateSurface()
{
	s->CreateSurface();
}
void cppCollisionDetection(double delta)  
{
	s0 = new Surface();
	s1 = new Surface();
	h0 = new Hierarchy();
	h1 = new Hierarchy();

	s0->Add(0,0,0,1,0);
	s0->CreateSurface();
	s1->Add(0,0,0,1,0);
	s1->CreateSurface();

	Triple t0(-delta,0,0);
	Triple t1(delta,0,0);
	RotationMatrix m0,m1;
	h0->Initialize(s0);
	h0->Behavior(&m0,&t0);
	h1->Initialize(s1);
	h1->Behavior(&m1,&t1);

	CollisionDetector cd;
	cd.CheckCollision(h0,h1);
	cd.Select(1);

	s->CreateSurface(s0,s1,delta); 

	delete h0;
	delete h1;

	delete s0;
	delete s1;
}
void cppAllocate()
{
	s = new Surface();
}
void cppFree()
{
	delete s;
}
int cppNp()
{
    return s->Np();
}
int cppNt()
{
    return s->Nt();
}
double cppPx(int i)
{
    return s->Px(i);
}
double cppPy(int i)
{
    return s->Py(i);
}
double cppPz(int i)
{
    return s->Pz(i);
}
double cppNx(int i)
{
    return s->Nx(i);
}
double cppNy(int i)
{
    return s->Ny(i);
}
double cppNz(int i)
{
    return s->Nz(i);
}
int cppC(int i)
{
    return s->C(i); 
}
int cppI(int i)
{
    return s->I(i);
}
void cppLevel(int i)
{
	s->Level(i);
}
int cppType()
{
	return s->Type();
}
void cppMethod(int i)
{
	s->Method(i);
}