bes  Updated for version 3.20.5
TwoDMeshTopology.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5 
6 // Copyright (c) 2002,2003,2011,2012 OPeNDAP, Inc.
7 // Authors: Nathan Potter <ndp@opendap.org>
8 // James Gallagher <jgallagher@opendap.org>
9 // Scott Moe <smeest1@gmail.com>
10 // Bill Howe <billhowe@cs.washington.edu>
11 //
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Lesser General Public
14 // License as published by the Free Software Foundation; either
15 // version 2.1 of the License, or (at your option) any later version.
16 //
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 //
26 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
27 
28 #ifndef _TwoDMeshTopology_h
29 #define _TwoDMeshTopology_h 1
30 
31 #include <gridfields/type.h>
32 #include <gridfields/gridfield.h>
33 #include <gridfields/grid.h>
34 #include <gridfields/cellarray.h>
35 
36 using namespace std;
37 using namespace libdap;
38 
39 namespace libdap {
40 class BaseType;
41 class Array;
42 class MeshDataVariable;
43 class Grid;
44 }
45 
46 namespace ugrid {
47 
53 
54 private:
60  BaseType *d_meshVar;
61 
68  string dimension;
69 
78  vector<libdap::Array *> *nodeCoordinateArrays;
79  string nodeDimensionName;
80  int nodeCount;
81 
112  libdap::Array *faceNodeConnectivityArray;
113  libdap::Array::Dim_iter fncNodesDim, fncFacesDim;
114  string faceDimensionName;
115  int faceCount;
116 
117  vector<MeshDataVariable *> *rangeDataArrays;
118 
131  //string edgeNodeConnectivityArrayName;
142  //string faceEdgeConnectivityArrayName;
143  //Array *faceEdgeConnectivityArray;
155  //string faceFaceConnectivityArrayName;
156  //Array *faceFaceConnectivityArray;
167  // Not used. jhrg 4/15/15 vector<string> *faceCoordinateNames;
168  vector<libdap::Array *> *faceCoordinateArrays;
169 
180  //vector<string> *edgeCoordinateNames;
181  //vector<Array *> *edgeCoordinateArrays;
182  GF::Grid *gridTopology;
183  GF::GridField *d_inputGridField;
184  GF::GridField *resultGridField;
185 
186  vector<int *> *sharedIntArrays;
187  vector<float *> *sharedFloatArrays;
188 
189  vector<GF::Array *> gfArrays;
190 
191  GF::Node *fncCellArray;
192 
193  bool _initialized;
194 
195  void ingestFaceNodeConnectivityArray(libdap::BaseType *meshTopology, libdap::DDS *dds);
196  void ingestNodeCoordinateArrays(libdap::BaseType *meshTopology, libdap::DDS *dds);
197  void ingestFaceCoordinateArrays(libdap::BaseType *meshTopology, libdap::DDS *dds);
198 
199  GF::Node *getFncArrayAsGFCells(libdap::Array *fncVar);
200  int getStartIndex(libdap::Array *array);
201  GF::CellArray *getFaceNodeConnectivityCells();
202 
203  libdap::Array *getGFAttributeAsDapArray(libdap::Array *sourceArray, locationType rank,
204  GF::GridField *resultGridField);
205  libdap::Array *getGridFieldCellArrayAsDapArray(GF::GridField *resultGridField, libdap::Array *sourceFcnArray);
206  // libdap::Array *getNewFncDapArray(libdap::Array *templateArray, int N);
207 
208  void setNodeCoordinateDimension(MeshDataVariable *mdv);
209  void setFaceCoordinateDimension(MeshDataVariable *mdv);
210 
211 public:
213  ~TwoDMeshTopology();
214 
215  void init(string meshVarName, libdap::DDS *dds);
216 
217  string meshVarName() const
218  {
219  return getMeshVariable()->name();
220  }
221 
222  libdap::BaseType *getMeshVariable() const
223  {
224  return d_meshVar;
225  }
226 
227  void buildBasicGfTopology();
228  void applyRestrictOperator(locationType loc, string filterExpression);
229 
230  int getInputGridSize(locationType location);
231  int getResultGridSize(locationType location);
232 
233  void convertResultGridFieldStructureToDapObjects(vector<libdap::BaseType *> *results);
234 
235  void setLocationCoordinateDimension(MeshDataVariable *mdv);
236 
237  void addIndexVariable(locationType location);
238  void getResultIndex(locationType location, void *target);
239 
240  void getResultGFAttributeValues(string attrName, libdap::Type type, locationType rank, void *target);
241 };
242 
243 } // namespace ugrid
244 
245 #endif // _TwoDMeshTopology_h
ugrid::MeshDataVariable
Definition: MeshDataVariable.h:39
Type
Type
Type of JSON value.
Definition: rapidjson.h:603
libdap
Definition: BESDapFunctionResponseCache.h:35
ugrid::TwoDMeshTopology
Definition: TwoDMeshTopology.h:52