1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 //      http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 //
13 #ifndef DRACO_MAYA_DRACO_MAYA_PLUGIN_H_
14 #define DRACO_MAYA_DRACO_MAYA_PLUGIN_H_
15 
16 #include <fstream>
17 
18 #include "draco/compression/decode.h"
19 #include "draco/compression/encode.h"
20 
21 #ifdef DRACO_MAYA_PLUGIN
22 
23 // If compiling with Visual Studio.
24 #if defined(_MSC_VER)
25 #define EXPORT_API __declspec(dllexport)
26 #else
27 // Other platforms don't need this.
28 #define EXPORT_API
29 #endif  // defined(_MSC_VER)
30 
31 namespace draco {
32 namespace maya {
33 
34 enum class EncodeResult {
35   OK = 0,
36   KO_WRONG_INPUT = -1,
37   KO_MESH_ENCODING = -2,
38   KO_FILE_CREATION = -3
39 };
40 enum class DecodeResult {
41   OK = 0,
42   KO_GEOMETRY_TYPE_INVALID = -1,
43   KO_TRIANGULAR_MESH_NOT_FOUND = -2,
44   KO_MESH_DECODING = -3
45 };
46 
47 extern "C" {
48 struct EXPORT_API Drc2PyMesh {
Drc2PyMeshDrc2PyMesh49   Drc2PyMesh()
50       : faces_num(0),
51         faces(nullptr),
52         vertices_num(0),
53         vertices(nullptr),
54         normals_num(0),
55         normals(nullptr),
56         uvs_num(0),
57         uvs_real_num(0),
58         uvs(nullptr) {}
59   int faces_num;
60   int *faces;
61   int vertices_num;
62   float *vertices;
63   int normals_num;
64   float *normals;
65   int uvs_num;
66   int uvs_real_num;
67   float *uvs;
68 };
69 
70 EXPORT_API DecodeResult drc2py_decode(char *data, unsigned int length,
71                                       Drc2PyMesh **res_mesh);
72 EXPORT_API void drc2py_free(Drc2PyMesh **res_mesh);
73 EXPORT_API EncodeResult drc2py_encode(Drc2PyMesh *in_mesh, char *file_path);
74 }  // extern "C"
75 
76 }  // namespace maya
77 }  // namespace draco
78 
79 #endif  // DRACO_MAYA_PLUGIN
80 
81 #endif  // DRACO_MAYA_DRACO_MAYA_PLUGIN_H_
82