Merge pull request #19747 from Shkolik/sketcher_datums_projection
fix #18894 Sketcher: Create external projection geometry not working with datum objects
This commit is contained in:
@@ -113,6 +113,7 @@
|
||||
#include "SolverGeometryExtension.h"
|
||||
|
||||
#include "ExternalGeometryFacade.h"
|
||||
#include <Mod/Part/App/Datums.h>
|
||||
|
||||
|
||||
#undef DEBUG
|
||||
@@ -8272,6 +8273,9 @@ void SketchObject::validateExternalLinks()
|
||||
const Part::Datum* datum = static_cast<const Part::Datum*>(Obj);
|
||||
refSubShape = datum->getShape();
|
||||
}
|
||||
else if (Obj->isDerivedFrom<App::DatumElement>()) {
|
||||
// do nothing - shape will be calculated later during rebuild
|
||||
}
|
||||
else {
|
||||
const Part::Feature* refObj = static_cast<const Part::Feature*>(Obj);
|
||||
const Part::TopoShape& refShape = refObj->Shape.getShape();
|
||||
@@ -9218,6 +9222,35 @@ void SketchObject::rebuildExternalGeometry(std::optional<ExternalToAdd> extToAdd
|
||||
TopoDS_Face f = TopoDS::Face(fBuilder.Shape());
|
||||
refSubShape = f;
|
||||
}
|
||||
else if (Obj->isDerivedFrom<Part::DatumLine>()) {
|
||||
auto* line = static_cast<const Part::DatumLine*>(Obj);
|
||||
Base::Placement plm = line->Placement.getValue();
|
||||
Base::Vector3d base = plm.getPosition();
|
||||
Base::Vector3d dir = line->getDirection();
|
||||
gp_Lin l(gp_Pnt(base.x, base.y, base.z), gp_Dir(dir.x, dir.y, dir.z));
|
||||
BRepBuilderAPI_MakeEdge eBuilder(l);
|
||||
if (!eBuilder.IsDone()) {
|
||||
throw Base::RuntimeError(
|
||||
"Sketcher: addExternal(): Failed to build edge from Part::DatumLine");
|
||||
}
|
||||
|
||||
TopoDS_Edge e = TopoDS::Edge(eBuilder.Shape());
|
||||
refSubShape = e;
|
||||
}
|
||||
else if (Obj->isDerivedFrom<Part::DatumPoint>()) {
|
||||
auto* point = static_cast<const Part::DatumPoint*>(Obj);
|
||||
Base::Placement plm = point->Placement.getValue();
|
||||
Base::Vector3d base = plm.getPosition();
|
||||
gp_Pnt p(base.x, base.y, base.z);
|
||||
BRepBuilderAPI_MakeVertex eBuilder(p);
|
||||
if (!eBuilder.IsDone()) {
|
||||
throw Base::RuntimeError(
|
||||
"Sketcher: addExternal(): Failed to build vertex from Part::DatumPoint");
|
||||
}
|
||||
|
||||
TopoDS_Vertex v = TopoDS::Vertex(eBuilder.Shape());
|
||||
refSubShape = v;
|
||||
}
|
||||
else {
|
||||
throw Base::TypeError(
|
||||
"Datum feature type is not yet supported as external geometry for a sketch");
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "GeometryCreationMode.h"
|
||||
#include "Utils.h"
|
||||
#include "ViewProviderSketch.h"
|
||||
#include <Mod/Part/App/Datums.h>
|
||||
|
||||
|
||||
namespace SketcherGui
|
||||
@@ -97,18 +98,25 @@ public:
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if (pObj->isDerivedFrom<Part::DatumLine>() || pObj->isDerivedFrom<Part::DatumPoint>()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pObj->isDerivedFrom<App::Plane>() || pObj->isDerivedFrom<Part::Datum>()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Base::Tools::isNullOrEmpty(sSubName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string element(sSubName);
|
||||
if ((element.size() > 4 && element.substr(0, 4) == "Edge")
|
||||
|| (element.size() > 6 && element.substr(0, 6) == "Vertex")
|
||||
|| (element.size() > 4 && element.substr(0, 4) == "Face")) {
|
||||
return true;
|
||||
}
|
||||
if (pObj->isDerivedFrom<App::Plane>() || pObj->isDerivedFrom<Part::Datum>()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -159,6 +167,7 @@ public:
|
||||
}
|
||||
std::string subName(msg.pSubName);
|
||||
if (obj->isDerivedFrom<App::Plane>() || obj->isDerivedFrom<Part::Datum>()
|
||||
|| obj->isDerivedFrom<Part::DatumLine>() || obj->isDerivedFrom<Part::DatumPoint>()
|
||||
|| (subName.size() > 4 && subName.substr(0, 4) == "Edge")
|
||||
|| (subName.size() > 6 && subName.substr(0, 6) == "Vertex")
|
||||
|| (subName.size() > 4 && subName.substr(0, 4) == "Face")) {
|
||||
|
||||
Reference in New Issue
Block a user