1 | /****************************************************************************** |
---|
2 | * OptiStore - A Data Processing Server |
---|
3 | * Copyright (C) 2003 Electronic Visualization Laboratory, |
---|
4 | * University of Illinois at Chicago |
---|
5 | * |
---|
6 | * Authors: Luc Renambot luc@evl.uic.edu |
---|
7 | * Shalini Venkataraman shalini@evl.uic.edu |
---|
8 | * |
---|
9 | * All rights reserved. |
---|
10 | * |
---|
11 | * Redistribution and use in source and binary forms, with or without |
---|
12 | * modification, are permitted provided that the following conditions are met: |
---|
13 | * |
---|
14 | * * Redistributions of source code must retain the above copyright |
---|
15 | * notice, this list of conditions and the following disclaimer. |
---|
16 | * * Redistributions in binary form must reproduce the above |
---|
17 | * copyright notice, this list of conditions and the following disclaimer |
---|
18 | * in the documentation and/or other materials provided with the distribution. |
---|
19 | * * Neither the name of the University of Illinois at Chicago nor |
---|
20 | * the names of its contributors may be used to endorse or promote |
---|
21 | * products derived from this software without specific prior written permission. |
---|
22 | * |
---|
23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
27 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
29 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
34 | * |
---|
35 | * Direct questions, comments etc about OptiStore to luc@evl.uic.edu |
---|
36 | *****************************************************************************/ |
---|
37 | |
---|
38 | #include "private.h" |
---|
39 | #include "directions.h" |
---|
40 | |
---|
41 | typedef struct _NetVertexBuffer |
---|
42 | { |
---|
43 | float *vertex; |
---|
44 | float *normal; |
---|
45 | unsigned int *index; |
---|
46 | unsigned short *length; |
---|
47 | int lengths, nbpts, nbindices; |
---|
48 | //sort of copy constructor |
---|
49 | void copy(struct _NetVertexBuffer* src) { |
---|
50 | nbpts = src->nbpts; |
---|
51 | lengths = src->lengths; |
---|
52 | nbindices = src->nbindices; |
---|
53 | |
---|
54 | vertex = (float*)malloc( nbpts * 3 * sizeof(float) ); |
---|
55 | memcpy(vertex,src->vertex, nbpts * 3 * sizeof(float)); |
---|
56 | |
---|
57 | normal = (float*)malloc( nbpts * 3 * sizeof(float) ); |
---|
58 | memcpy(normal,src->normal,nbpts * 3 * sizeof(float)); |
---|
59 | |
---|
60 | index = (unsigned int*)malloc( nbindices * sizeof(unsigned int) ); |
---|
61 | memcpy(index, src->index,nbindices * sizeof(unsigned int)); |
---|
62 | |
---|
63 | length = (unsigned short*)malloc( lengths * sizeof(unsigned short) ); |
---|
64 | memcpy(length, src->length,lengths * sizeof(unsigned short)); |
---|
65 | } |
---|
66 | void freeArrays() { |
---|
67 | free(vertex); |
---|
68 | free(normal); |
---|
69 | free(index); |
---|
70 | free(length); |
---|
71 | } |
---|
72 | |
---|
73 | } NetVertexBuffer; |
---|
74 | |
---|
75 | typedef struct _NetPointBuffer |
---|
76 | { |
---|
77 | float *vertex; |
---|
78 | int nbpts; |
---|
79 | } NetPointBuffer; |
---|
80 | |
---|
81 | |
---|
82 | //attribute for each data |
---|
83 | typedef struct _DataDesc |
---|
84 | { |
---|
85 | char* name; |
---|
86 | int x,y,z; |
---|
87 | } DataDesc; |
---|
88 | |
---|
89 | //////////////////////////////////////////////////////////// |
---|
90 | |
---|
91 | class cDataManagerClient |
---|
92 | { |
---|
93 | protected: |
---|
94 | QUANTAnet_tcpClient_c *client; |
---|
95 | #if defined(USE_RBUDP) |
---|
96 | QUANTAnet_rbudpReceiver_c *blastee; |
---|
97 | #endif |
---|
98 | |
---|
99 | int port; |
---|
100 | char *hostname; |
---|
101 | int id; |
---|
102 | int num_datasets; |
---|
103 | DataDesc *datasets; |
---|
104 | |
---|
105 | |
---|
106 | private: |
---|
107 | int status, dataSize; |
---|
108 | unsigned int command; |
---|
109 | int sizes[6]; |
---|
110 | NetVertexBuffer *vb; |
---|
111 | NetPointBuffer *pb; |
---|
112 | unsigned char *dataptr; |
---|
113 | unsigned short *gradptr; |
---|
114 | |
---|
115 | |
---|
116 | public: |
---|
117 | |
---|
118 | static int RBUDP_PORT; |
---|
119 | |
---|
120 | cDataManagerClient(char *_hostname = "localhost"); |
---|
121 | ~cDataManagerClient(); |
---|
122 | |
---|
123 | |
---|
124 | void Open(int _port = 6544); |
---|
125 | void Init(); |
---|
126 | void Exit(); |
---|
127 | int Query(); |
---|
128 | |
---|
129 | void Load(int ds); |
---|
130 | void Resample(int sx, int sy, int sz); |
---|
131 | void Crop(int ox, int oy, int oz, int sx, int sy, int sz); |
---|
132 | |
---|
133 | unsigned char* Volume(); |
---|
134 | unsigned short* Gradient(); |
---|
135 | |
---|
136 | int* Histogram(); |
---|
137 | unsigned char* Histogram2D(); |
---|
138 | |
---|
139 | NetVertexBuffer* Isosurface(int isoval, int gaussp, float decim); |
---|
140 | NetPointBuffer* IsoPoints(int isoval, int inc, int maxp); |
---|
141 | |
---|
142 | // Get the name of a dataset |
---|
143 | char *Name(int _idx); |
---|
144 | |
---|
145 | //Given the symbolic name of a volume, returns its index |
---|
146 | //if the volume is not found return -1; |
---|
147 | int Lookup(const char* name) ; |
---|
148 | |
---|
149 | |
---|
150 | //Given the symbolic name of a volume as a wild card, returns list of indices that match |
---|
151 | //if not found, return 0; |
---|
152 | //caller has to free the memory |
---|
153 | int GetMatching(char* wildcard, int *&indexList); |
---|
154 | //get the data dimesions for the data indexed by idx |
---|
155 | void GetDataDims(unsigned int idx, unsigned int& x, unsigned int& y, unsigned int& z); |
---|
156 | }; |
---|