Commit ddf4b0f9 authored by schultezub's avatar schultezub
Browse files

fixed WholeTFGeometryManipulator::insideGeometry()

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@316 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent bf230b50
......@@ -156,7 +156,7 @@ namespace TUMVis {
TFGeometry* g = _selectedGeometry->getGeometry();
std::vector<TFGeometry::KeyPoint>& kpts = g->getKeyPoints();
TFGeometry::KeyPoint kp(static_cast<float>(e->x()) / static_cast<float>(_canvas->width()), tgt::col4(255));
std::vector<TFGeometry::KeyPoint>::const_iterator lb = std::lower_bound(kpts.begin(), kpts.end(), kp);
std::vector<TFGeometry::KeyPoint>::const_iterator lb = std::upper_bound(kpts.begin(), kpts.end(), kp);
if (lb != kpts.end()) {
kp._color = lb->_color;
}
......
......@@ -219,35 +219,33 @@ namespace TUMVis {
updateHelperPoints();
}
namespace {
struct XComparer {
bool operator() (const tgt::vec2& left, const tgt::vec2& right) {
return left.x < right.x;
};
};
}
bool WholeTFGeometryManipulator::insideGeometry(const tgt::vec2& position) const {
if (_helperPoints.size() < 3)
if (_helperPoints.size() < 2)
return false;
// simple approach: check for left turn for every triple of points
for (std::vector<tgt::vec2>::const_iterator it = _helperPoints.begin()+1; it != _helperPoints.end(); ++it) {
if (! AlgorithmicGeometry::rightTurn2D(*(it-1), *it, position))
return false;
}
std::vector<tgt::vec2>::const_iterator lb = std::upper_bound(_helperPoints.begin(), _helperPoints.end(), position, XComparer());
if (lb == _helperPoints.begin() || lb == _helperPoints.end())
return false;
return true;
return AlgorithmicGeometry::rightTurn2D(*(lb-1), *lb, position);
}
void WholeTFGeometryManipulator::updateHelperPoints() {
_helperPoints.clear();
const std::vector<TFGeometry::KeyPoint>& keyPoints = _geometry->getKeyPoints();
if (keyPoints.front()._color.w > 0) {
_helperPoints.push_back(tgt::vec2(keyPoints.front()._position, 0.f));
}
for (std::vector<TFGeometry::KeyPoint>::const_iterator it = keyPoints.begin(); it != keyPoints.end(); ++it) {
float y = static_cast<float>(it->_color.a) / 255.f;
_helperPoints.push_back(tgt::vec2(it->_position, y));
}
if (keyPoints.back()._color.w > 0) {
_helperPoints.push_back(tgt::vec2(keyPoints.back()._position, 0.f));
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment