Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

How to tell if an edge is open or closed?

traveler_hauptmantraveler_hauptman Member, OS Professional, Mentor, Developers Posts: 419 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_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    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_hauptmantraveler_hauptman Member, OS Professional, Mentor, Developers Posts: 419 PRO
    Nice! Thanks!
Sign In or Register to comment.