forked from ssg-aero/gbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
70 lines (63 loc) · 1.78 KB
/
main.cpp
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
#include <vector>
#include <array>
#include <gbs/bscurve.h>
#include <gbs/bscinterp.h>
#include <gbs/maths.h>
int main()
{
//using T = double;
//size_t p = 5;
//auto u = make_range<T>(0., 1.,10);
//auto k = build_simple_mult_flat_knots(u, p);
//auto n = k.size() - p - 1;
//points_vector_3d_d poles(n);
//auto dx = 1. / (n - 1);
////T u_ = 0.3;
//BSCurve<T, 3> c1_3d_dp{ poles, k, p };
////c1_3d_dp.value(u_);
//const auto count_max = 10;
//auto count = count_max;
//while (count)
//{
// c1_3d_dp.value(double(count) / double(count_max));
// count--;
//}
using T = double;
using namespace gbs;
size_t p = 3;
std::vector<T> k = { 0., 0., 0., 0., 1., 5. , 6., 8., 8., 8., 8. };
points_vector<T, 3> poles =
{
{0.,1.,0.},
{0.,1.,0.},
{1.,2.,0.},
{2.,3.,0.},
{3.,3.,0.},
{4.,2.,0.},
};
size_t np = 1000000;
auto u = make_range<T>(0., 8., np);
{
const auto t1 = std::chrono::high_resolution_clock::now();
for (auto u_ : u)
{
eval_value_deboor_cox(u_, k, poles, p);
}
const auto t2 = std::chrono::high_resolution_clock::now();
const std::chrono::duration<double, std::milli> ms_ref = t2 - t1;
std::cout << std::fixed
<< " took " << ms_ref.count() << " ms\n";
}
{
const auto t1 = std::chrono::high_resolution_clock::now();
for (auto u_ : u)
{
eval_value_decasteljau(u_, k, poles, p);
}
const auto t2 = std::chrono::high_resolution_clock::now();
const std::chrono::duration<double, std::milli> ms_ref = t2 - t1;
std::cout << std::fixed
<< " took " << ms_ref.count() << " ms\n";
}
return 0;
}