[TD]fix crash on Cosmetic line > 10m

This commit is contained in:
wandererfan
2024-08-18 10:06:59 -04:00
committed by WandererFan
parent 595fbc9c1b
commit 131956e201
4 changed files with 9 additions and 4 deletions

View File

@@ -77,7 +77,7 @@ CosmeticEdge::CosmeticEdge(const Base::Vector3d& pt1, const Base::Vector3d& pt2)
}
CosmeticEdge::CosmeticEdge(const TopoDS_Edge& e) :
CosmeticEdge(TechDraw::BaseGeom::baseFactory(e))
CosmeticEdge(TechDraw::BaseGeom::baseFactory(e, true))
{
}

View File

@@ -1130,6 +1130,8 @@ PyObject* DrawUtil::colorToPyTuple(App::Color color)
}
//check for crazy edge. This is probably a geometry error of some sort.
// note that cosmetic edges are stored as unscaled, so this test will be checking 1:1 lengths.
// a 1:1 length of > 10m is perfectly reasonable, so this check causes trouble with cosmetics.
bool DrawUtil::isCrazy(TopoDS_Edge e)
{

View File

@@ -474,13 +474,16 @@ std::string BaseGeom::geomTypeName()
}
//! Convert 1 OCC edge into 1 BaseGeom (static factory method)
BaseGeomPtr BaseGeom::baseFactory(TopoDS_Edge edge)
// this should not return nullptr as things will break later on.
// regular geometry is stored scaled, but cosmetic geometry is stored in 1:1 scale, so the crazy edge
// check is not appropriate.
BaseGeomPtr BaseGeom::baseFactory(TopoDS_Edge edge, bool isCosmetic)
{
if (edge.IsNull()) {
Base::Console().Message("BG::baseFactory - input edge is NULL \n");
}
//weed out rubbish edges before making geometry
if (!validateEdge(edge)) {
if (!isCosmetic && !validateEdge(edge)) {
return nullptr;
}

View File

@@ -109,7 +109,7 @@ class TechDrawExport BaseGeom : public std::enable_shared_from_this<BaseGeom>
double minDist(Base::Vector3d p);
Base::Vector3d nearPoint(Base::Vector3d p);
Base::Vector3d nearPoint(const BaseGeomPtr p);
static BaseGeomPtr baseFactory(TopoDS_Edge edge);
static BaseGeomPtr baseFactory(TopoDS_Edge edge, bool isCosmetic=false);
static bool validateEdge(TopoDS_Edge edge);
static TopoDS_Edge completeEdge(const TopoDS_Edge &edge);
bool closed();