source: branches/1.3/src/core/RpDXWriterFInterface.cc @ 5675

Last change on this file since 5675 was 5675, checked in by ldelgass, 9 years ago

merge r5673 from trunk (eol-style)

  • Property svn:eol-style set to native
File size: 7.8 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Fortran Rappture DXWriter Bindings Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
8 *
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13
14#include <cstring>
15#include <fstream>
16#include "RpDXWriterFInterface.h"
17#include "RpFortranCommon.h"
18#include "RpBindingsDict.h"
19#include "RpDXWriterFStubs.c"
20
21#define RP_OK 0
22#define RP_ERROR 1
23
24/**********************************************************************/
25// FUNCTION: rp_dxwriter()
26/// Open a new Rappture::DXWriter object and return its handle.
27/**
28 */
29
30int rp_dxwriter() {
31
32    Rappture::DXWriter* dxwriter = NULL;
33    int handle = -1;
34
35    // create a Rappture::DXWriter object and store in dictionary
36    dxwriter = new Rappture::DXWriter();
37
38    if (dxwriter) {
39        handle = storeObject_Void(dxwriter);
40    }
41
42    return handle;
43}
44
45/**********************************************************************/
46// FUNCTION: rp_dxwriter_origin()
47/// change the origin of the dx object.
48/**
49 */
50int rp_dxwriter_origin(int* handle,     /* integer handle of dxwriter */
51                        double *o         /* array of origin values per axis */
52                        )
53{
54    size_t retVal = RP_ERROR;
55    Rappture::DXWriter* dxwriter = NULL;
56
57    if ((handle) && (*handle != 0)) {
58        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
59        if (dxwriter) {
60            dxwriter->origin(o);
61            retVal = RP_OK;
62        }
63    }
64
65    return retVal;
66}
67
68/**********************************************************************/
69// FUNCTION: rp_dxwriter_delta()
70/// change the delta of the dx object.
71/**
72 */
73int rp_dxwriter_delta(int* handle,     /* integer handle of dxwriter */
74                        double *d         /* array of delta values per axis */
75                        )
76{
77    size_t retVal = RP_ERROR;
78    Rappture::DXWriter* dxwriter = NULL;
79
80    if ((handle) && (*handle != 0)) {
81        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
82        if (dxwriter) {
83            dxwriter->delta(d);
84            retVal = RP_OK;
85        }
86    }
87
88    return retVal;
89}
90
91/**********************************************************************/
92// FUNCTION: rp_dxwriter_counts()
93/// change the counts of the position grid in the dx object.
94/**
95 */
96int rp_dxwriter_counts(int* handle,     /* integer handle of dxwriter */
97                        size_t *p         /* array of counts per axis */
98                        )
99{
100    size_t retVal = RP_ERROR;
101    Rappture::DXWriter* dxwriter = NULL;
102
103    if ((handle) && (*handle != 0)) {
104        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
105        if (dxwriter) {
106            dxwriter->counts(p);
107            retVal = RP_OK;
108        }
109    }
110
111    return retVal;
112}
113
114/**********************************************************************/
115// FUNCTION: rp_dxwriter_append()
116/// append data to the dxwriter object.
117/**
118 */
119int rp_dxwriter_append(int* handle,     /* integer handle of dxwriter */
120                        double *value         /* single data value*/
121                        )
122{
123    size_t retVal = RP_ERROR;
124    Rappture::DXWriter* dxwriter = NULL;
125
126    if ((handle) && (*handle != 0)) {
127        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
128        if (dxwriter) {
129            dxwriter->append(value);
130            retVal = RP_OK;
131        }
132    }
133
134    return retVal;
135}
136
137/**********************************************************************/
138// FUNCTION: rp_dxwriter_data()
139/// append data to the dxwriter object.
140/**
141 */
142int rp_dxwriter_data(int* handle,     /* integer handle of dxwriter */
143                        double *value,        /* array of data values */
144                        size_t *nmemb        /* number of members in array value*/
145                        )
146{
147    size_t retVal = RP_ERROR;
148    Rappture::DXWriter* dxwriter = NULL;
149
150    if ((handle) && (*handle != 0)) {
151        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
152        if (dxwriter) {
153            dxwriter->data(value,*nmemb);
154            retVal = RP_OK;
155        }
156    }
157
158    return retVal;
159}
160
161/**********************************************************************/
162// FUNCTION: rp_dxwriter_pos()
163/// append position to the dxwriter object.
164/**
165 */
166int rp_dxwriter_pos(int* handle,     /* integer handle of dxwriter */
167                        double *position,     /* array of positions */
168                        size_t *nmemb        /* number of members in array value*/
169                        )
170{
171    size_t retVal = RP_ERROR;
172    Rappture::DXWriter* dxwriter = NULL;
173
174    if ((handle) && (*handle != 0)) {
175        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
176        if (dxwriter) {
177            dxwriter->pos(position,*nmemb);
178            retVal = RP_OK;
179        }
180    }
181
182    return retVal;
183}
184
185/**********************************************************************/
186// FUNCTION: rp_dxwriter_write()
187/// write the dx file to disk.
188/**
189 */
190int rp_dxwriter_write(int* handle,     /* integer handle of dxwriter */
191                        char *fname,     /* filename to hold dx file text */
192                        size_t str_len /* size of str */
193                        )
194{
195    size_t retVal = RP_ERROR;
196    Rappture::DXWriter* dxwriter = NULL;
197
198    if ((handle) && (*handle != 0)) {
199        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
200        if (dxwriter) {
201            dxwriter->write((const char*)fname);
202            retVal = RP_OK;
203            /*
204            if (dxwriter->size() > (str_len)) {
205                dxwriter->write((const char*)fname);
206                retVal = RP_OK;
207            } else {
208                // string too small
209                retVal = RP_ERROR;
210            }
211            */
212        }
213    }
214
215    return retVal;
216}
217
218/**********************************************************************/
219// FUNCTION: rp_dxwriter_size()
220/// return the size of the dx file text
221/**
222 */
223int rp_dxwriter_size(int* handle,    /* integer handle of dxwriter */
224                        size_t* s    /* return value */
225                        )
226{
227    size_t retVal = RP_ERROR;
228    Rappture::DXWriter* dxwriter = NULL;
229
230    if ((handle) && (*handle != 0)) {
231        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
232        if (dxwriter) {
233            *s = dxwriter->size();
234            retVal = RP_OK;
235        }
236    }
237
238    return retVal;
239}
240
241/**********************************************************************/
242// FUNCTION: rp_dxwriter_rank()
243/// change the rank of the dx file text
244/**
245 */
246int rp_dxwriter_rank(int* handle,    /* integer handle of dxwriter */
247                        size_t* rank /* return value */
248                        )
249{
250    size_t retVal = RP_ERROR;
251    Rappture::DXWriter* dxwriter = NULL;
252
253    if ((handle) && (*handle != 0)) {
254        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
255        if (dxwriter) {
256            *rank = dxwriter->rank();
257            retVal = RP_OK;
258        }
259    }
260
261    return retVal;
262}
263
264/**********************************************************************/
265// FUNCTION: rp_dxwriter_shape()
266/// change the shape of the dx file text
267/**
268 */
269int rp_dxwriter_shape(int* handle,    /* integer handle of dxwriter */
270                        size_t* shape      /* return value */
271                        )
272{
273    size_t retVal = RP_ERROR;
274    Rappture::DXWriter* dxwriter = NULL;
275
276    if ((handle) && (*handle != 0)) {
277        dxwriter = (Rappture::DXWriter*) getObject_Void(*handle);
278        if (dxwriter) {
279            *shape = dxwriter->shape();
280            retVal = RP_OK;
281        }
282    }
283
284    return retVal;
285}
Note: See TracBrowser for help on using the repository browser.