Skip to content

Commit

Permalink
[TD]fix crash on Cosmetic line > 10m
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Aug 19, 2024
1 parent 595fbc9 commit 131956e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/App/Cosmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
}

Expand Down
2 changes: 2 additions & 0 deletions src/Mod/TechDraw/App/DrawUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

Expand Down
7 changes: 5 additions & 2 deletions src/Mod/TechDraw/App/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/App/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 131956e

Please sign in to comment.