diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 507447b74..0fcb4a285 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -3011,6 +3011,137 @@ int SketchObject::ExposeInternalGeometry(int GeoId) return incrgeo; //number of added elements } + else if(geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + // First we search what has to be restored + bool focus=false; + int focusgeoid=-1; + bool focus_to_vertex=false; + + const std::vector< Sketcher::Constraint * > &vals = Constraints.getValues(); + + for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); + it != vals.end(); ++it) { + if((*it)->Type == Sketcher::InternalAlignment && (*it)->Second == GeoId) + { + switch((*it)->AlignmentType){ + case Sketcher::ParabolaFocus: + focus=true; + focusgeoid=(*it)->First; + break; + default: + return -1; + } + } + } + + if(focus) { + // look for a line from focusgeoid:start to Geoid:mid_external + std::vector focusgeoidlistgeoidlist; + std::vector focusposidlist; + getDirectlyCoincidentPoints(focusgeoid, Sketcher::start, focusgeoidlistgeoidlist, + focusposidlist); + + std::vector parabgeoidlistgeoidlist; + std::vector parabposidlist; + getDirectlyCoincidentPoints(GeoId, Sketcher::mid, parabgeoidlistgeoidlist, + parabposidlist); + + if (!focusgeoidlistgeoidlist.empty() && !parabgeoidlistgeoidlist.empty()) { + + int i,j; + for(i=0;igetTypeId() == Part::GeomLineSegment::getClassTypeId()) { + + if((focusposidlist[i] == Sketcher::start && parabposidlist[j] == Sketcher::end) || + (focusposidlist[i] == Sketcher::end && parabposidlist[j] == Sketcher::start)) + + focus_to_vertex=true; + } + } + } + } + } + } + + int currentgeoid= getHighestCurveIndex(); + int incrgeo= 0; + + const Part::GeomArcOfParabola *aoh = static_cast(geo); + + Base::Vector3d center = aoh->getCenter(); + Base::Vector3d focusp = aoh->getFocus(); + + std::vector igeo; + std::vector icon; + + if(!focus) + { + Part::GeomPoint *pf1 = new Part::GeomPoint(); + pf1->setPoint(focusp); + + igeo.push_back(pf1); + + Sketcher::Constraint *newConstr = new Sketcher::Constraint(); + newConstr->Type = Sketcher::InternalAlignment; + newConstr->AlignmentType = Sketcher::ParabolaFocus; + newConstr->First = currentgeoid+incrgeo+1; + newConstr->FirstPos = Sketcher::start; + newConstr->Second = GeoId; + + focusgeoid = currentgeoid+incrgeo+1; + + icon.push_back(newConstr); + incrgeo++; + } + + if(!focus_to_vertex) + { + Part::GeomLineSegment *paxis = new Part::GeomLineSegment(); + paxis->setPoints(center,focusp); + + igeo.push_back(paxis); + + Sketcher::Constraint *newConstr = new Sketcher::Constraint(); + newConstr->Type = Sketcher::Coincident; + newConstr->First = focusgeoid; + newConstr->FirstPos = Sketcher::start; + newConstr->Second = currentgeoid+incrgeo+1; // just added line + newConstr->SecondPos = Sketcher::end; + + icon.push_back(newConstr); + + Sketcher::Constraint *newConstr2 = new Sketcher::Constraint(); + newConstr2->Type = Sketcher::Coincident; + newConstr2->First = GeoId; + newConstr2->FirstPos = Sketcher::mid; + newConstr2->Second = currentgeoid+incrgeo+1; // just added line + newConstr2->SecondPos = Sketcher::start; + + icon.push_back(newConstr2); + + incrgeo++; + } + + this->addGeometry(igeo,true); + this->addConstraints(icon); + + for (std::vector::iterator it=igeo.begin(); it != igeo.end(); ++it) + if (*it) + delete *it; + + for (std::vector::iterator it=icon.begin(); it != icon.end(); ++it) + if (*it) + delete *it; + + icon.clear(); + igeo.clear(); + + return incrgeo; //number of added elements + } else return -1; // not supported type } diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 204da362b..6225df3ae 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -4013,10 +4013,10 @@ public: currentgeoid++; - /*Gui::Command::doCommand(Gui::Command::Doc, + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.ExposeInternalGeometry(%d)", sketchgui->getObject()->getNameInDocument(), - currentgeoid);*/ + currentgeoid); } catch (const Base::Exception& e) {