auto import from //depot/cupcake/@135843
[android/platform/external/neven.git] / Embedded / common / src / b_TensorEm / IdCluster2D.h
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_ID_CLUSTER2D_EM_H
18 #define bts_ID_CLUSTER2D_EM_H
19
20 /* ---- includes ----------------------------------------------------------- */
21
22 #include "b_BasicEm/Context.h"
23 #include "b_BasicEm/Int16Arr.h"
24 #include "b_TensorEm/Cluster2D.h"
25
26 /* ---- related objects  --------------------------------------------------- */
27
28 /* ---- typedefs ----------------------------------------------------------- */
29
30 /* ---- constants ---------------------------------------------------------- */
31
32 /* data format version number */
33 #define bts_ID_CLUSTER2D_VERSION 100
34
35 /* ---- object definition -------------------------------------------------- */
36
37 /** 2d vector array with node id information */
38 struct bts_IdCluster2D 
39 {
40
41         /* ---- private data --------------------------------------------------- */
42
43         /* ---- public data ---------------------------------------------------- */
44
45         /* vector array */
46         struct bts_Cluster2D clusterE;
47
48         /** array of id numbers */
49         struct bbs_Int16Arr idArrE;
50 };
51
52 /* ---- associated objects ------------------------------------------------- */
53
54 /* ---- external functions ------------------------------------------------- */
55
56 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
57
58 /** initializes cluster */
59 void bts_IdCluster2D_init( struct bbs_Context* cpA,
60                                                    struct bts_IdCluster2D* ptrA );
61
62 /** destroys cluster */
63 void bts_IdCluster2D_exit( struct bbs_Context* cpA,
64                                                    struct bts_IdCluster2D* ptrA );
65
66 /* ---- \ghd{ operators } -------------------------------------------------- */
67
68 /** copies cluster */
69 void bts_IdCluster2D_copy( struct bbs_Context* cpA,
70                                                    struct bts_IdCluster2D* ptrA, 
71                                                    const struct bts_IdCluster2D* srcPtrA );
72
73 /** compares cluster */
74 flag bts_IdCluster2D_equal( struct bbs_Context* cpA,
75                                                     const struct bts_IdCluster2D* ptrA, 
76                                                         const struct bts_IdCluster2D* srcPtrA );
77
78 /* ---- \ghd{ query functions } -------------------------------------------- */
79
80 /** returns center of gravity */
81 struct bts_Flt16Vec2D bts_IdCluster2D_center( struct bbs_Context* cpA,
82                                                                                           const struct bts_IdCluster2D* ptrA );
83
84 /** returns bounding box */
85 struct bts_Int16Rect bts_IdCluster2D_boundingBox( struct bbs_Context* cpA,
86                                                                                                   const struct bts_IdCluster2D* ptrA );
87
88 /* ---- \ghd{ modify functions } ------------------------------------------- */
89
90 /** allocates cluster */
91 void bts_IdCluster2D_create( struct bbs_Context* cpA,
92                                                          struct bts_IdCluster2D* ptrA, 
93                                                          uint32 sizeA,
94                                                      struct bbs_MemSeg* mspA );
95
96 /** resize cluster (sizeA must be smaller or equal to allocated size)*/
97 void bts_IdCluster2D_size( struct bbs_Context* cpA,
98                                                    struct bts_IdCluster2D* ptrA, 
99                                                    uint32 sizeA );
100
101 /** transforms cluster according to alt (function does not change bbp of cluster) */
102 void bts_IdCluster2D_transform( struct bbs_Context* cpA,
103                                                             struct bts_IdCluster2D* ptrA, 
104                                                                 struct bts_Flt16Alt2D altA );
105
106 /** copies src cluster and simultaneously transforms vectors according to alt using dstBbpA as resulting cluster format */
107 void bts_IdCluster2D_copyTransform( struct bbs_Context* cpA,
108                                                                     struct bts_IdCluster2D* ptrA, 
109                                                                         const struct bts_IdCluster2D* srcPtrA, 
110                                                                         struct bts_Flt16Alt2D altA, 
111                                                                         uint32 dstBbpA );
112
113 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
114
115 /** size object needs when written to memory */
116 uint32 bts_IdCluster2D_memSize( struct bbs_Context* cpA,
117                                                             const struct bts_IdCluster2D* ptrA );
118
119 /** writes object to memory; returns number of bytes written */
120 uint32 bts_IdCluster2D_memWrite( struct bbs_Context* cpA,
121                                                                  const struct bts_IdCluster2D* ptrA, 
122                                                                  uint16* memPtrA );
123
124 /** reads object from memory; returns number of bytes read */
125 uint32 bts_IdCluster2D_memRead( struct bbs_Context* cpA,
126                                                             struct bts_IdCluster2D* ptrA, 
127                                                             const uint16* memPtrA,
128                                                         struct bbs_MemSeg* mspA );
129
130 /* ---- \ghd{ exec functions } --------------------------------------------- */
131
132 /* This function extracts equivalent 2d sub clusters which positions 
133  * correponts to those nodes that have a non-negative id occurring 
134  * in both input clusters. 
135  * Note: Nodes with negative ids are ignored
136  *       Non-Negative ids must not occur twice in one cluster.
137  */
138 void bts_IdCluster2D_convertToEqivalentClusters( struct bbs_Context* cpA,
139                                                                                                  const struct bts_IdCluster2D* inCluster1PtrA,
140                                                                                                  const struct bts_IdCluster2D* inCluster2PtrA,
141                                                                                                  struct bts_Cluster2D* outCluster1PtrA,
142                                                                                                  struct bts_Cluster2D* outCluster2PtrA );
143
144 /** Computes the best affine linear transformation from *srcPtrA to *dstPtrA using matching id values.
145  *  Constrains of trafo are given by altTypeA
146  *
147  *  This function selects and matches nodes with corresponsing non-negative id values of source 
148  *  an destination clusters. Nodes with negative id values are ignored. Id values >= 0 must be unique 
149  *  per node.
150  */
151 struct bts_Flt16Alt2D bts_IdCluster2D_alt( struct bbs_Context* cpA,
152                                                                                    const struct bts_IdCluster2D* srcPtrA,
153                                                                                    struct bts_IdCluster2D* dstPtrA,
154                                                                                    enum bts_AltType altTypeA,
155                                                                                    struct bts_Cluster2D* tmpPtr1A,   /* temporary cluster 1 */
156                                                                                    struct bts_Cluster2D* tmpPtr2A ); /* temporary cluster 2 */
157                                                                                    
158
159 #endif /* bts_ID_CLUSTER2D_EM_H */
160