HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GABC_GTUtil.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) COPYRIGHTYEAR
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  */
27 
28 #ifndef __GABC_GTUtil__
29 #define __GABC_GTUtil__
30 
31 #include "GABC_API.h"
32 #include "GABC_Util.h"
33 #include <GT/GT_Types.h>
34 #include <Alembic/AbcGeom/All.h>
35 
36 namespace GABC_NAMESPACE
37 {
38 
39 namespace GABC_GTUtil
40 {
41  /// Given an Alembic DataType, determine the corresponding GT_Storage.
42  static inline GT_Storage
43  getGTStorage(const Alembic::AbcGeom::DataType &dtype)
44  {
45  switch (dtype.getPod())
46  {
50  return GT_STORE_UINT8;
55  return GT_STORE_INT32;
58  return GT_STORE_INT64;
60  return GT_STORE_REAL16;
62  return GT_STORE_REAL32;
64  return GT_STORE_REAL64;
66  return GT_STORE_STRING;
67 
71  break;
72  }
73  return GT_STORE_INVALID;
74  }
75 
76  /// Given an Alembic data type interpretation, determine the corresponding
77  /// GT_Type.
78  static inline GT_Type
79  getGTTypeInfo(const char *interp, int tsize)
80  {
81  if (!strcmp(interp, "point"))
82  return GT_TYPE_POINT;
83  // Maya can generate UV attributes with 2 components and tag them as
84  // vectors. Houdini does not understand vectors with two components
85  // so we drop the vector type info to prevent Houdini from applying
86  // undesired transformation to the values.
87  if (tsize == 3 && !strcmp(interp, "vector"))
88  return GT_TYPE_VECTOR;
89  if (!strcmp(interp, "matrix"))
90  return tsize == 9 ? GT_TYPE_MATRIX3 : GT_TYPE_MATRIX;
91  if (!strcmp(interp, "normal"))
92  return GT_TYPE_NORMAL;
93  if (!strcmp(interp, "quat"))
94  return GT_TYPE_QUATERNION;
95  if (!strcmp(interp, "rgb") || !strcmp(interp, "rgba"))
96  return GT_TYPE_COLOR;
97  if (!strcmp(interp, "box"))
98  return tsize == 4 ? GT_TYPE_BOX2 : GT_TYPE_BOX;
99  return GT_TYPE_NONE;
100  }
101 
102 } // end GABC_GTUtil
103 
104 } // end GABC_NAMESPACE
105 
106 #endif
GT_Storage
Definition: GT_Types.h:19
GT_Type
Definition: GT_Types.h:36
#define GABC_NAMESPACE
Definition: GABC_API.h:42