Navigation Menu

Skip to content

Commit

Permalink
Sketcher: BSpline box selection
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo committed Jan 14, 2017
1 parent 512fd62 commit 9bf1e8f
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -2346,9 +2346,37 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &

} else if ((*it)->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) {
const Part::GeomBSplineCurve *spline = static_cast<const Part::GeomBSplineCurve *>(*it);
std::vector<Base::Vector3d> poles = spline->getPoles();
VertexId += poles.size();
// TODO
//std::vector<Base::Vector3d> poles = spline->getPoles();
VertexId += 2;

Plm.multVec(spline->getStartPoint(), pnt1);
Plm.multVec(spline->getEndPoint(), pnt2);
pnt1 = proj(pnt1);
pnt2 = proj(pnt2);

bool pnt1Inside = polygon.Contains(Base::Vector2d(pnt1.x, pnt1.y));
bool pnt2Inside = polygon.Contains(Base::Vector2d(pnt2.x, pnt2.y));
if (pnt1Inside) {
std::stringstream ss;
ss << "Vertex" << VertexId;
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
}

if (pnt2Inside) {
std::stringstream ss;
ss << "Vertex" << VertexId + 1;
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
}

// This is a rather approximated approach. No it does not guarantie that the whole curve is boxed, specially
// for periodic curves, but it works reasonably well. Including all poles, which could be done, generally
// forces the user to select much more than the curve (all the poles) and it would not select the curve in cases
// where it is indeed comprised in the box.
if (pnt1Inside && pnt2Inside) {
std::stringstream ss;
ss << "Edge" << GeoId + 1;
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
}
}
}

Expand Down

0 comments on commit 9bf1e8f

Please sign in to comment.