Skip to content

Commit

Permalink
Fixed CS bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
rserrano committed May 9, 2017
1 parent cc5fa5e commit 09a0b6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
20 changes: 5 additions & 15 deletions geomodelr/cpp/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,23 +211,13 @@ class Model {
wstring unit = s.units[cls.first];
return std::make_tuple(unit, cls.second);
};
static int side = -1;
// For a cut below the lowest or above the highest.
if ( a_idx <= 0 or a_idx >= this->sections.size() ) {
if ( side != 1 ) {
side = 1;
std::cerr << "It's in a side, idx: " << a_idx << "\n";
}
const Section& s = ( a_idx <=0 ) ? *(this->sections.front()) : *(this->sections.back());
return closest_single(s);
} else {
if ( side != 2 ) {
side = 2;
std::cerr << "Not in a side, idx: " << a_idx << "\n";
}
if ( a_idx <= 0 ) {
return closest_single(*this->sections.front());
}
if ( a_idx >= this->sections.size() ) {
return closest_single(*this->sections.back());
}


auto closest_middle = [&]( const point2& pt_a, const point2& pt_b ) {
// Finally evaluate the full transition.
std::tuple<int, int, double> clst = this->closest_between(a_idx, pt_a, pt_b, mp.second, predicates);
Expand Down
12 changes: 6 additions & 6 deletions geomodelr/cpp/section.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef GEOMODELR_SECTION_HPP
#define GEOMODELR_SECTION_HPP
#include "basic.hpp"
#include<set>

class Model;
class Match;
Expand Down Expand Up @@ -73,19 +74,20 @@ class Section {
int knear = 1;

bool new_to_check;
std::set<int> checked;

do {
int n = 0;
new_to_check = false;
for ( auto it = this->polidx->qbegin( geometry::index::nearest(p, knear) and geometry::index::satisfies(predicates) );
it != this->polidx->qend(); it++ ) {
// Skip already checked.
if ( n < knear/2 )
int idx = g2(*it);
if ( checked.find( idx ) != checked.end() )
{
n++;
continue;
}
checked.insert(idx);
// Check if new polygons where checked.

new_to_check = true;

// Check the maximum distance from the box to the point.
Expand All @@ -94,9 +96,7 @@ class Section {
maxboxdist = std::max(boxdist, maxboxdist);

// Then check the minimum actual distance to a polygon.
int idx = g2(*it);
double dist = geometry::distance(p, this->polygons[idx]);

if ( dist < mindist ) {
mindist = dist;
minidx = idx;
Expand Down
20 changes: 12 additions & 8 deletions geomodelr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@

# The utils file contains scripts that can be used by users to
# make calculations of their models.

from model import GeologicalModel
from shared import ModelException
import random
import numpy as np
from scipy.spatial import cKDTree
from skimage import measure
try:
from scipy.spatial import cKDTree
from stl import mesh
except ImportError:
pass
try:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
except ImportError:
pass

import itertools
import gc
import numpy as np
from skimage import measure
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from stl import mesh

def srttri( t ):
t = sorted(t)
return tuple(t)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def if_env(**kwargs):
license='AGPL',
packages=['geomodelr'],
ext_modules=[cppextension],
install_requires=['numpy', 'scipy', 'shapely', 'scikit-image', 'numpy-stl'],
install_requires=['numpy', 'scipy', 'shapely'],# 'scikit-image', 'numpy-stl'],
keywords=['geology', 'geological modelling', 'cross sections', 'geomodelr'],
entry_points = {
'console_scripts': [
Expand Down

0 comments on commit 09a0b6d

Please sign in to comment.