36 #ifndef GEOTESSPOSITION_OBJECT_H
37 #define GEOTESSPOSITION_OBJECT_H
67 class GeoTessInterpolatorType;
151 void updatePosition2D(
int layerid,
const double*
const uVector);
170 void checkTessellation(
const int& tid)
172 if (triangle[tid] < 0)
175 triangle[tid] = grid.getTriangle(tid, 0, 0);
176 getContainingTriangle(tid);
188 void updateRadius(
int lid,
double rad)
190 if ((radius < 0.) || (rad != radius) || (lid != layerId))
194 tessid = layerTessIds[lid];
195 checkTessellation(tessid);
196 clearRadialCoefficients();
200 void clearRadialCoefficients()
202 for (
int i=0; i<(int)radialIndexes.size(); ++i)
204 radialIndexes[i].clear();
205 radialCoefficients[i].clear();
215 void updateRadialCoefficients()
219 if (radialIndexes.size() < vertices[tessid].size())
221 radialIndexes.resize(vertices[tessid].size());
222 radialCoefficients.resize(vertices[tessid].size());
227 if (radialIndexes[0].size() == 0)
229 vector<int>& v = vertices[tessid];
230 for (
int i = 0; i < (int)v.size(); ++i)
231 modlProfiles[v[i]][layerId]->setInterpolationCoefficients(radialInterpolatorType,
232 radialIndexes[i], radialCoefficients[i], radius, radiusOutOfRangeAllowed);
240 static const double TWALK_TOLERANCE;
252 void getContainingTriangle(
int tid);
262 int biggerTriangle(
int t1,
int t2)
264 const int* tv = grid.getTriangleVertexIndexes(t1);
265 double dot1 = GeoTessUtils::dot(grid.getVertex(tv[0]), grid.getVertex(tv[1]))
266 + GeoTessUtils::dot(grid.getVertex(tv[1]), grid.getVertex(tv[2]))
267 + GeoTessUtils::dot(grid.getVertex(tv[2]), grid.getVertex(tv[0]));
269 tv = grid.getTriangleVertexIndexes(t2);
270 double dot2 = GeoTessUtils::dot(grid.getVertex(tv[0]), grid.getVertex(tv[1]))
271 + GeoTessUtils::dot(grid.getVertex(tv[1]), grid.getVertex(tv[2]))
272 + GeoTessUtils::dot(grid.getVertex(tv[2]), grid.getVertex(tv[0]));
274 return dot2 > dot1 ? t1 : t2;
299 vector<double> layerRadii;
318 vector< vector< int> > vertices;
325 vector< vector< double> > linearCoefficients;
338 vector< vector< double> > hCoefficients;
354 vector<vector<int> > radialIndexes;
373 vector<vector<double> > radialCoefficients;
397 double const*
const* gridVertices;
398 int const*
const* gridTriangles;
399 int const* gridDescendants;
400 const vector<vector<Edge*> >& gridEdges;
401 const int* layerTessIds;
418 bool radiusOutOfRangeAllowed;
423 double unitVector[3];
428 int getTriangle(
int tid)
429 { checkTessellation(tid);
return triangle[tid]; };
435 virtual void update2D(
int tid) =
ABSTRACT;
453 m += (long)(layerRadii.capacity() *
sizeof(double));
456 m += (long)(vertices.capacity()*
sizeof(vector<int>));
457 for (
int i=0; i<(int)vertices.size(); ++i)
458 m += (
long)(vertices[i].capacity()*
sizeof(int));
461 m += (long)(linearCoefficients.capacity()*
sizeof(vector<double>));
462 for (
int i=0; i<(int)linearCoefficients.size(); ++i)
463 m += (
long)(linearCoefficients[i].capacity()*
sizeof(double));
466 m += (long)(hCoefficients.capacity()*
sizeof(vector<double>));
467 for (
int i=0; i<(int)hCoefficients.size(); ++i)
468 m += (
long)(hCoefficients[i].capacity()*
sizeof(double));
471 m += (long)(radialIndexes.capacity()*
sizeof(vector<int>));
472 for (
int i=0; i<(int)radialIndexes.size(); ++i)
473 m += (
long)(radialIndexes[i].capacity()*
sizeof(int));
476 m += (long)(radialCoefficients.capacity()*
sizeof(vector<double>));
477 for (
int i=0; i<(int)radialCoefficients.size(); ++i)
478 m += (
long)(radialCoefficients[i].capacity()*
sizeof(double));
606 void set(
double lat,
double lon,
double depth)
608 double uVector[3] = {0.0, 0.0, 0.0};
609 GeoTessUtils::getVectorDegrees(lat, lon, uVector);
610 double newRadius = GeoTessUtils::getEarthRadius(uVector) - depth;
611 set(uVector, newRadius);
626 void set(
const double*
const uVector,
const double& newRadius)
628 updatePosition2D(nLayers - 1, uVector);
630 int lid = getLayerId(newRadius);
632 updatePosition2D(lid, uVector);
633 updateRadius(lid, newRadius);
653 void set(
int layid,
double lat,
double lon,
double depth)
656 set(lat, lon, depth);
660 GeoTessUtils::getVectorDegrees(lat, lon, uVector);
661 updatePosition2D(layid, uVector);
662 updateRadius(layid, GeoTessUtils::getEarthRadius(uVector) - depth);
676 void set(
int layid,
const double*
const uVector,
double rad)
682 updatePosition2D(layid, uVector);
683 if (rad >= 0.0) updateRadius(layid, rad);
694 void setTop(
int layid,
const double*
const uVector)
696 updatePosition2D(layid, uVector);
697 updateRadius(layid, getRadiusTop(layid));
710 updatePosition2D(layid, uVector);
711 updateRadius(layid, getRadiusBottom(layid));
726 os << endl <<
"ERROR in GeoTessPosition::setRadius" << endl
727 <<
"Geographic position has not been specified." << endl;
730 updateRadius(layid, rad);
745 os << endl <<
"ERROR in GeoTessPosition::setRadius" << endl
746 <<
"Geographic position has not been specified." << endl;
749 updateRadius(getLayerId(rad), rad);
765 setRadius(layer, getEarthRadius()-depth);
776 setRadius(getEarthRadius()-depth);
789 os << endl <<
"ERROR in GeoTessPosition::setRadius" << endl
790 <<
"Geographic position has not been specified." << endl;
793 tessid = layerTessIds[layid];
794 checkTessellation(tessid);
795 updateRadius(layid, getRadiusTop(layid));
809 os << endl <<
"ERROR in GeoTessPosition::setRadius" << endl
810 <<
"Geographic position has not been specified." << endl;
813 tessid = layerTessIds[layid];
814 checkTessellation(tessid);
815 updateRadius(layid, getRadiusBottom(layid));
842 if (earthRadius < 0.)
843 earthRadius = GeoTessUtils::getEarthRadius(unitVector);
862 { u[0] = unitVector[0]; u[1] = unitVector[1]; u[2] = unitVector[2]; };
884 const vector<int>&
getVertices()
const {
return vertices[tessid]; };
901 return grid.
getVertex(getIndexOfClosestVertex());
911 {
return vertices[tessid][index]; }
920 coefficients.clear();
921 vector<int>& vtx = vertices[tessid];
922 vector<double>& hc = hCoefficients[tessid];
923 for (
int i = 0; i < (int) vtx.size(); ++i)
924 modlProfiles[vtx[i]][layerId]->getCoefficients(coefficients, radius, hc[i]);
938 maxTessLevel[layerTessIds[layid]] = maxTess;
939 triangle[layerTessIds[layid]] = -1;
940 checkTessellation(tessid);
953 {
return maxTessLevel[layerTessIds[layid]]; }
971 int getTessLevel(
const int& tId) { checkTessellation(tId);
return tessLevels[tId]; }
979 {
return getRadiusTop(layerId); };
987 {
return getRadiusBottom(layerId); };
996 return getEarthRadius() - getRadiusTop(layerId);
1006 return getEarthRadius() - getRadiusBottom(layerId);
1017 return getEarthRadius() - getRadiusTop(layid);
1028 return getEarthRadius() - getRadiusBottom(layid);
1039 return getRadiusTop(layid) - getRadiusBottom(layid);
1049 return getRadiusTop() - getRadiusBottom();
1065 {
return getEarthRadius() - radius; };
1089 for (
int i=0; i<nLayers; ++i)
1090 if (rad <= getRadiusTop(i))
1093 for (
int i=nLayers-1; i>=0; --i)
1094 if (getLayerThickness(i) > 0)
1130 errorValue = errVal;
1142 vector<int>& vtid = vertices[tessid];
1143 vector<double>& htid = hCoefficients[tessid];
1144 for (
int v = 0; v < (int) vtid.size(); ++v)
1145 if (htid[v] > 0.999999999)
1176 vector<int>& vtx = vertices[tessid];
1177 vector<double>& htid = hCoefficients[tessid];
1179 for (
int i = 0; i < (int) vtx.size(); ++i)
1180 modlProfiles[vtx[i]][layerId]->getWeights(weights, dkm, radius, htid[i]);
1192 return hCoefficients[tessid];
1205 return hCoefficients[tessid][index];
1225 return radiusOutOfRangeAllowed;
1245 if (allowed != radiusOutOfRangeAllowed)
1246 clearRadialCoefficients();
1248 radiusOutOfRangeAllowed = allowed;
1261 if (isNotReferenced())
1264 os << endl <<
"ERROR in Polygon::removeReference" << endl
1265 <<
"Reference count (" << refCount <<
") is already zero." << endl;
#define ABSTRACT
Global constant used to make pure virtual functions readable.
An exception class for all GeoTess objects.
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
const double * getVertex(int vertex) const
int getNTessellations() const
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR,...
Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Eart...
GeoTessPointMap * getPointMap()
Information about an interpolated point at an arbitrary position in a model.
virtual double getValue(int attribute)
void set(int layid, const double *const uVector, double rad)
void setDepth(double depth)
void set(const double *const uVector, const double &newRadius)
void setBottom(int layid, const double *const uVector)
static GeoTessPosition * getGeoTessPosition(GeoTessModel *model, const GeoTessInterpolatorType &horizontalType)
void setTop(int layid, const double *const uVector)
int getTessLevel(const int &tId)
static GeoTessPosition * getGeoTessPosition(GeoTessModel *model, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType)
void setRadius(double rad)
bool isRadiusOutOfRangeAllowed()
void getCoefficients(map< int, double > &coefficients)
void setRadius(int layid, double rad)
virtual const GeoTessInterpolatorType & getInterpolatorType() const
int getMaxTessLevel(int layid)
virtual ~GeoTessPosition()
const vector< int > & getVertices() const
const vector< double > & getHorizontalCoefficients() const
double getHorizontalCoefficient(int index) const
void copyVector(double *u)
double getRadiusTop(int layid)
int getLayerId(double rad)
void setMaxTessLevel(int layid, int maxTess)
void setDepth(int layer, double depth)
void setRadiusOutOfRangeAllowed(bool allowed)
double getDepthTop(int layid)
void setModel(GeoTessModel *newModel)
double getLayerThickness()
GeoTessModel * getModel()
double getDepthBottom(int layid)
void set(int layid, double lat, double lon, double depth)
double getRadiusBottom(int layid)
void setErrorValue(double errVal)
static GeoTessPosition * getGeoTessPosition(GeoTessModel *model)
double getLayerThickness(int layid)
const double * getClosestVertex() const
void set(double lat, double lon, double depth)
void setBottom(int layid)
int getIndexOfClosestVertex() const
void getWeights(map< int, double > &weights, double dkm)
Abstract class that manages the radii and data values that span a single layer associated with a sing...