Skip to content

Commit

Permalink
Added files shared, etc..
Browse files Browse the repository at this point in the history
  • Loading branch information
rserrano committed Dec 23, 2016
1 parent 7634b18 commit 97606ea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
16 changes: 9 additions & 7 deletions geomodelr/cpp/geomodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,15 @@ class Section {
point2 mn(gx(pt) - distance, gy(pt) - distance);
box bx(mn, mx);
vector<std::pair<int, double>> ret;
for ( auto it = this->polidx->qbegin( geometry::index::intersects(bx) and predicates );
it != this->polidx->qend(); it++ ) {
// Check the actual distance to a polygon.
int idx = it->second;
double poldist = geometry::distance(this->polygons[idx], pt);
if ( poldist <= distance ) {
ret.push_back(std::make_pair(idx, poldist));
if ( this->polidx != nullptr ) {
for ( auto it = this->polidx->qbegin( geometry::index::intersects(bx) and predicates );
it != this->polidx->qend(); it++ ) {
// Check the actual distance to a polygon.
int idx = it->second;
double poldist = geometry::distance(this->polygons[idx], pt);
if ( poldist <= distance ) {
ret.push_back(std::make_pair(idx, poldist));
}
}
}
return ret;
Expand Down
25 changes: 25 additions & 0 deletions geomodelr/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ def nodes_offset(nodes, offset):
for node in nodes:
node[0] = node[0] + offset

def fault_points_index_repr(fault):
pointsd = {}
def ipoint(point):
"""
Gets the index of the point and increases the counter if it does not exist.
"""
tpoint = tuple(point)
if tpoint in pointsd:
ipoint = pointsd[tpoint]
else:
ipoint = len(pointsd)
pointsd[tpoint] = ipoint
return ipoint
itris = []
for triangle in fault:
itris.append( map( ipoint, triangle ) )

points = [ None for i in xrange(len(pointsd)) ]
for p in pointsd:
points[pointsd[p]] = list(p)
return {'triangles': itris, 'points': points}

def faults_points_index_repr(faults):
return { k: fault_points_index_repr(v) for k, v in faults.iteritems() }

# Returns from the geojson data a set of points with indexed lines and polygons.
def points_index_repr(geojson):
lines = []
Expand Down

0 comments on commit 97606ea

Please sign in to comment.