Utils: getGeoIdsOfEdgesFromNames

This commit is contained in:
Abdullah Tahiri
2023-03-01 14:05:07 +01:00
committed by abdullahtahiriyo
parent 93143c680c
commit b6b897c0bf
2 changed files with 29 additions and 0 deletions

View File

@@ -146,6 +146,32 @@ void SketcherGui::getIdsFromName(const std::string& name, const Sketcher::Sketch
}
}
std::vector<int> SketcherGui::getGeoIdsOfEdgesFromNames(const Sketcher::SketchObject* Obj, const std::vector<std::string> & names)
{
std::vector<int> geoids;
for(const auto & name : names) {
if (name.size() > 4 && name.substr(0, 4) == "Edge") {
geoids.push_back(std::atoi(name.substr(4, 4000).c_str()) - 1);
}
else if (name.size() > 12 && name.substr(0, 12) == "ExternalEdge") {
geoids.push_back(Sketcher::GeoEnum::RefExt + 1 - std::atoi(name.substr(12, 4000).c_str()));
}
else if (name.size() > 6 && name.substr(0, 6) == "Vertex") {
int VtId = std::atoi(name.substr(6, 4000).c_str()) - 1;
int GeoId;
Sketcher::PointPos PosId;
Obj->getGeoVertexIndex(VtId, GeoId, PosId);
const Part::Geometry* geo = Obj->getGeometry(GeoId);
if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()){
geoids.push_back(GeoId);
}
}
}
return geoids;
}
bool SketcherGui::checkBothExternal(int GeoId1, int GeoId2)
{
if (GeoId1 == GeoEnum::GeoUndef || GeoId2 == GeoEnum::GeoUndef)

View File

@@ -72,6 +72,9 @@ std::string getStrippedPythonExceptionString(const Base::Exception&);
void getIdsFromName(const std::string &name, const Sketcher::SketchObject* Obj, int &GeoId, Sketcher::PointPos &PosId);
/// Returns ONLY the geometry elements when the "Edge" is selected (including GeomPoints)
std::vector<int> getGeoIdsOfEdgesFromNames(const Sketcher::SketchObject* Obj, const std::vector<std::string> & names);
bool checkBothExternal(int GeoId1, int GeoId2);
bool isPointOrSegmentFixed(const Sketcher::SketchObject* Obj, int GeoId);