|
1 |
| -/**************************************************************************** |
2 |
| -* VCGLib o o * |
3 |
| -* Visual and Computer Graphics Library o o * |
4 |
| -* _ O _ * |
5 |
| -* Copyright(C) 2004-2012 \/)\/ * |
6 |
| -* Visual Computing Lab /\/| * |
7 |
| -* ISTI - Italian National Research Council | * |
8 |
| -* \ * |
9 |
| -* All rights reserved. * |
10 |
| -* * |
11 |
| -* This program is free software; you can redistribute it and/or modify * |
12 |
| -* it under the terms of the GNU General Public License as published by * |
13 |
| -* the Free Software Foundation; either version 2 of the License, or * |
14 |
| -* (at your option) any later version. * |
15 |
| -* * |
16 |
| -* This program is distributed in the hope that it will be useful, * |
17 |
| -* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
18 |
| -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
19 |
| -* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * |
20 |
| -* for more details. * |
21 |
| -* * |
22 |
| -****************************************************************************/ |
| 1 | +// #include <stdlib.h> |
| 2 | +// #include <vector> |
| 3 | +// #include <emscripten.h> |
| 4 | +// #include <emscripten/bind.h> |
| 5 | +// #include <vcg/complex/complex.h> |
| 6 | +// #include <wrap/io_trimesh/import_off.h> |
| 7 | +// #include <wrap/io_trimesh/export_off.h> |
| 8 | + |
| 9 | +// #include <vcg/complex/algorithms/refine.h> |
| 10 | +// using namespace vcg; |
| 11 | +// using namespace std; |
| 12 | +// using namespace emscripten; |
| 13 | + |
| 14 | + |
| 15 | +// class MyEdge; |
| 16 | +// class MyFace; |
| 17 | +// class MyVertex; |
| 18 | +// struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex> ::AsVertexType, |
| 19 | +// vcg::Use<MyEdge> ::AsEdgeType, |
| 20 | +// vcg::Use<MyFace> ::AsFaceType>{}; |
| 21 | + |
| 22 | +// class MyVertex : public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::Color4b, vcg::vertex::Qualityf, vcg::vertex::BitFlags >{}; |
| 23 | +// class MyFace : public vcg::Face< MyUsedTypes, vcg::face::Normal3f, vcg::face::VertexRef, vcg::face::FFAdj, vcg::face::BitFlags > {}; |
| 24 | +// class MyEdge : public vcg::Edge<MyUsedTypes>{}; |
| 25 | +// class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {}; |
| 26 | + |
| 27 | +// char *buf=0; |
| 28 | +// int size; |
| 29 | +// int vertexNum=0; |
| 30 | + |
| 31 | +// extern "C" { |
| 32 | +// char * allocator(size_t _size) |
| 33 | +// { |
| 34 | +// size = _size; |
| 35 | +// buf = (char *) malloc(size); |
| 36 | +// return buf; |
| 37 | +// } |
| 38 | + |
| 39 | +// int getVertexNumber(){ return vertexNum; } |
| 40 | + |
| 41 | +// int* getVertexes() { |
| 42 | +// MyMesh m; |
| 43 | +// int t0=clock(); |
| 44 | +// int loadmask; |
| 45 | + |
| 46 | +// int ret = tri::io::ImporterOFF<MyMesh>::OpenMem(m,buf,strlen(buf),loadmask); |
| 47 | +// int t1=clock(); |
| 48 | +// if(ret != 0) |
| 49 | +// { |
| 50 | +// printf("Error in opening file\n"); |
| 51 | +// exit(-1); |
| 52 | +// } |
| 53 | +// int t2=clock(); |
| 54 | +// printf("Read mesh %i %i\n",m.FN(),m.VN()); |
| 55 | +// vertexNum=n.VN(); |
| 56 | + |
| 57 | +// return v; |
| 58 | +// } |
| 59 | +// } |
| 60 | + |
| 61 | + |
23 | 62 | #include <stdlib.h>
|
| 63 | +#include <vector> |
24 | 64 | #include <emscripten.h>
|
25 | 65 | #include <emscripten/bind.h>
|
26 |
| -#include <vcg/complex/complex.h> |
27 |
| -#include <wrap/io_trimesh/import_off.h> |
28 |
| -#include <wrap/io_trimesh/export_off.h> |
29 | 66 |
|
30 |
| -#include <vcg/complex/algorithms/refine.h> |
31 |
| -using namespace vcg; |
32 | 67 | using namespace std;
|
33 | 68 | using namespace emscripten;
|
34 | 69 |
|
| 70 | +extern "C" { |
| 71 | +struct vert { |
| 72 | + int x; |
| 73 | + int y; |
| 74 | +}; |
35 | 75 |
|
36 |
| -class MyEdge; |
37 |
| -class MyFace; |
38 |
| -class MyVertex; |
39 |
| -struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex> ::AsVertexType, |
40 |
| - vcg::Use<MyEdge> ::AsEdgeType, |
41 |
| - vcg::Use<MyFace> ::AsFaceType>{}; |
42 |
| - |
43 |
| -class MyVertex : public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::Color4b, vcg::vertex::Qualityf, vcg::vertex::BitFlags >{}; |
44 |
| -class MyFace : public vcg::Face< MyUsedTypes, vcg::face::Normal3f, vcg::face::VertexRef, vcg::face::FFAdj, vcg::face::BitFlags > {}; |
45 |
| -class MyEdge : public vcg::Edge<MyUsedTypes>{}; |
46 |
| -class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {}; |
47 |
| - |
48 |
| -char *buf=0; |
49 |
| -int size; |
50 |
| - |
51 |
| -extern "C" |
52 |
| -{ |
53 |
| - char * allocator(size_t _size) |
54 |
| - { |
55 |
| - size = _size; |
56 |
| - buf = (char *) malloc(size); |
57 |
| - return buf; |
58 |
| - } |
59 |
| - |
| 76 | + int getLength(){ return 6; } |
60 | 77 |
|
61 |
| - int * refine() |
62 |
| - { |
63 |
| - int* v = new int[3]; |
64 |
| - v[0]=1; |
65 |
| - v[1]=2; |
66 |
| - v[2]=4; |
67 |
| - // vector<int> v; |
68 |
| - // v.push_back(2); |
69 |
| - // v.push_back(4); |
70 |
| - // v.push_back(3); |
| 78 | + vert* getVector() { |
| 79 | + vert* v = new vert[3]; |
| 80 | + v[0].x=2; |
| 81 | + v[0].y=22; |
| 82 | + v[1].x=4; |
| 83 | + v[1].y=44; |
| 84 | + v[2].x=6; |
| 85 | + v[2].y=66; |
71 | 86 | return v;
|
72 | 87 | }
|
73 | 88 | }
|
74 | 89 |
|
75 |
| - |
76 |
| - |
77 |
| - // EMSCRIPTEN_BINDINGS(foo){ |
78 |
| - // // // register_vector<int>("v"); |
79 |
| - // emscripten::function("refine",&refine); |
80 |
| - // } |
81 |
| - |
| 90 | + |
82 | 91 |
|
83 | 92 |
|
0 commit comments