1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef bts_CLUSTER3D_EM_H 18 #define bts_CLUSTER3D_EM_H 19 20 /* ---- includes ----------------------------------------------------------- */ 21 22 #include "b_BasicEm/Context.h" 23 #include "b_BasicEm/MemSeg.h" 24 #include "b_TensorEm/Int16Vec3D.h" 25 #include "b_TensorEm/Flt16Vec3D.h" 26 #include "b_TensorEm/Int16Rect.h" 27 #include "b_TensorEm/Flt16Alt3D.h" 28 29 /* ---- related objects --------------------------------------------------- */ 30 31 /* ---- typedefs ----------------------------------------------------------- */ 32 33 /* ---- constants ---------------------------------------------------------- */ 34 35 /* data format version number */ 36 #define bts_CLUSTER3D_VERSION 100 37 38 /* ---- object definition -------------------------------------------------- */ 39 40 /** 3d vector array */ 41 struct bts_Cluster3D 42 { 43 44 /* ---- private data --------------------------------------------------- */ 45 46 /* ---- public data ---------------------------------------------------- */ 47 48 /** pointer to exclusive memory segment used for allocation */ 49 struct bbs_MemSeg* mspE; 50 51 /** number of allocated vectors */ 52 uint32 allocatedSizeE; 53 54 /** number of vectors */ 55 uint32 sizeE; 56 57 /** format of vectors (bbpE always > 0) */ 58 int32 bbpE; 59 60 /** array of int16 vectors */ 61 struct bts_Int16Vec3D* vecArrE; 62 }; 63 64 /* ---- associated objects ------------------------------------------------- */ 65 66 /* ---- external functions ------------------------------------------------- */ 67 68 /* ---- \ghd{ constructor/destructor } ------------------------------------- */ 69 70 /** initializes cluster */ 71 void bts_Cluster3D_init( struct bbs_Context* cpA, 72 struct bts_Cluster3D* ptrA ); 73 74 /** destroys cluster */ 75 void bts_Cluster3D_exit( struct bbs_Context* cpA, 76 struct bts_Cluster3D* ptrA ); 77 78 /* ---- \ghd{ operators } -------------------------------------------------- */ 79 80 /** copies cluster */ 81 void bts_Cluster3D_copy( struct bbs_Context* cpA, 82 struct bts_Cluster3D* ptrA, 83 const struct bts_Cluster3D* srcPtrA ); 84 85 /** compares cluster */ 86 flag bts_Cluster3D_equal( struct bbs_Context* cpA, 87 const struct bts_Cluster3D* ptrA, 88 const struct bts_Cluster3D* srcPtrA ); 89 90 /* ---- \ghd{ query functions } -------------------------------------------- */ 91 92 /** returns center of gravity */ 93 struct bts_Flt16Vec3D bts_Cluster3D_center( struct bbs_Context* cpA, 94 const struct bts_Cluster3D* ptrA ); 95 96 /** returns bounding box */ 97 struct bts_Int16Rect bts_Cluster3D_boundingBox( struct bbs_Context* cpA, 98 const struct bts_Cluster3D* ptrA ); 99 100 /** returns int32 x-coordinate with given bbp at indexed position */ 101 int32 bts_Cluster3D_int32X( struct bbs_Context* cpA, 102 const struct bts_Cluster3D* ptrA, 103 uint32 indexA, 104 int32 bbpA ); 105 106 /** returns int32 y-coordinate with given bbp at indexed position */ 107 int32 bts_Cluster3D_int32Y( struct bbs_Context* cpA, 108 const struct bts_Cluster3D* ptrA, 109 uint32 indexA, 110 int32 bbpA ); 111 112 /** returns int32 z-coordinate with given bbp at indexed position */ 113 int32 bts_Cluster3D_int32Z( struct bbs_Context* cpA, 114 const struct bts_Cluster3D* ptrA, 115 uint32 indexA, 116 int32 bbpA ); 117 118 /* ---- \ghd{ modify functions } ------------------------------------------- */ 119 120 /** allocates cluster */ 121 void bts_Cluster3D_create( struct bbs_Context* cpA, 122 struct bts_Cluster3D* ptrA, 123 uint32 sizeA, 124 struct bbs_MemSeg* mspA ); 125 126 /** resize cluster (sizeA must be smaller or equal to allocated size)*/ 127 void bts_Cluster3D_size( struct bbs_Context* cpA, 128 struct bts_Cluster3D* ptrA, 129 uint32 sizeA ); 130 131 /** allocates cluster with external memory */ 132 void bts_Cluster3D_assignExternalMemory( struct bbs_Context* cpA, 133 struct bts_Cluster3D* ptrA, 134 struct bts_Int16Vec3D* vecArrA, 135 uint32 sizeA ); 136 137 /** transforms cluster according to alt (function does not change bbp of cluster) */ 138 void bts_Cluster3D_transform( struct bbs_Context* cpA, 139 struct bts_Cluster3D* ptrA, 140 struct bts_Flt16Alt3D altA ); 141 142 /** translates cluster such that gravity center is 0; returns former gravity center */ 143 struct bts_Flt16Vec3D bts_Cluster3D_centerFree( struct bbs_Context* cpA, 144 struct bts_Cluster3D* ptrA ); 145 146 /* ---- \ghd{ memory I/O } ------------------------------------------------- */ 147 148 /** size in words (16-bit) object needs when written to memory */ 149 uint32 bts_Cluster3D_memSize( struct bbs_Context* cpA, 150 const struct bts_Cluster3D* ptrA ); 151 152 /** writes object to memory; returns number of words (16-bit) written */ 153 uint32 bts_Cluster3D_memWrite( struct bbs_Context* cpA, 154 const struct bts_Cluster3D* ptrA, 155 uint16* memPtrA ); 156 157 /** reads object from memory; returns number of words (16-bit) read */ 158 uint32 bts_Cluster3D_memRead( struct bbs_Context* cpA, 159 struct bts_Cluster3D* ptrA, 160 const uint16* memPtrA, 161 struct bbs_MemSeg* mspA ); 162 163 /* ---- \ghd{ exec functions } --------------------------------------------- */ 164 165 #endif /* bts_CLUSTER3D_EM_H */ 166 167