Skip to content

Commit

Permalink
Sketcher: Decrease multiplicity command adaptation to unique identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Apr 8, 2017
1 parent 2a4d5a4 commit 391eaff
Showing 1 changed file with 29 additions and 39 deletions.
68 changes: 29 additions & 39 deletions src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)

bool applied = false;

boost::uuids::uuid bsplinetag;

int GeoId;
Sketcher::PointPos PosId;
getIdsFromName(SubNames[0], Obj, GeoId, PosId);
Expand All @@ -707,6 +709,8 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)
for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) {
if((*it)->Type == Sketcher::InternalAlignment && (*it)->First == GeoId && (*it)->AlignmentType == Sketcher::BSplineKnotPoint)
{
bsplinetag = Obj->getGeometry((*it)->Second)->getTag();

try {
Gui::Command::doCommand(
Doc,"App.ActiveDocument.%s.modifyBSplineKnotMultiplicity(%d,%d,%d) ",
Expand All @@ -730,49 +734,35 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)

}

// Grab the new GeoId of the knot after possible modifications
bool isnewGeoId = true;
selection = getSelection().getSelectionEx();

if (selection.size() != 1)
isnewGeoId = false;


const std::vector<std::string> &SubNames2 = selection[0].getSubNames();

if(SubNames.size() == 1)
isnewGeoId = false;

if(isnewGeoId) {
if(applied)
{
// find new geoid for bspline as GeoId might have changed
const std::vector< Part::Geometry * > &gvals = Obj->getInternalGeometry();

getIdsFromName(SubNames2[0], Obj, GeoId, PosId);
int ngeoid = 0;
bool ngfound = false;

if(isSimpleVertex(Obj, GeoId, PosId) && applied) {

const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();

for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) {
if((*it)->Type == Sketcher::InternalAlignment && (*it)->First == GeoId && (*it)->AlignmentType == Sketcher::BSplineKnotPoint)
{
try {
Obj->solve();

// add internalalignment for new pole
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.exposeInternalGeometry(%d)",
selection[0].getFeatName(),
(*it)->Second);
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
getSelection().clearSelection();
}

break; // we have already found our knot.

}
for (std::vector<Part::Geometry *>::const_iterator geo = gvals.begin(); geo != gvals.end(); geo++, ngeoid++) {
if ((*geo) && (*geo)->getTag() == bsplinetag) {
ngfound = true;
break;
}
}


if(ngfound) {
try {
// add internalalignment for new pole
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.exposeInternalGeometry(%d)",
selection[0].getFeatName(),
ngeoid);
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
getSelection().clearSelection();
}

}
}

Expand Down

0 comments on commit 391eaff

Please sign in to comment.