How to tell if an edge is open or closed?

traveler_hauptman
traveler_hauptman Member, OS Professional, Mentor, Developers Posts: 423 PRO
What is the best way to tell if a single edge is open or closed? It seems like something an edge would know about itself?

Right now I have a big query to do the job:

function isClosed(context is Context, edge is Query) returns boolean
{
var owner = qOwnerBody(edge);
var potential_vertices = qOwnedByBody(owner, EntityType.VERTEX);
var edge_vertices = qVertexAdjacent(edge,EntityType.VERTEX);
var result = size(evaluateQuery(context, qIntersection([potential_vertices,edge_vertices])));
if (result > 0){
return false;
}
return true;
}
and I worry that I'm missing some corner-case.

Any better way?


Comments

  • kevin_o_toole_1
    kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565 image
    edited April 2016
    I think you'd miss the case of an edge that's closed but not continuous... I can't figure out how to make such a thing in Onshape, but it's certainly possible in theory. There may be even weirder cases on imported geometry where a b-rep has a point along an edge on the same body for no real reason (again, I don't know how to make such a thing in Onshape, but it seems likely that b-rep formats we support allow it).

    So let's forget about the b-rep. To define a closed edge purely geometrically, how about:
        return tolerantEquals(
            evEdgeTangentLine(context, { "edge" : edge, "parameter" : 0 }).origin,
            evEdgeTangentLine(context, { "edge" : edge, "parameter" : 1 }).origin
        );
    If you don't want to allow noncontinuous endpoints, you can drop the .origins.
  • traveler_hauptman
    traveler_hauptman Member, OS Professional, Mentor, Developers Posts: 423 PRO
    Nice! Thanks!