Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find boundary intersections #1454

Closed
xiaodongdong101 opened this issue Jul 21, 2023 · 2 comments
Closed

Find boundary intersections #1454

xiaodongdong101 opened this issue Jul 21, 2023 · 2 comments
Assignees

Comments

@xiaodongdong101
Copy link

Hello,If I know two points on the model surface, can I use those two points to find the intersection with the model boundary?
a1e793910649c1d212d69d2266fb6bf


We can use the following as input: mesh, upper surface, two point coordinates.
Desired result: Find the intersection with the left boundary

@Grantim Grantim self-assigned this Jul 21, 2023
@Grantim
Copy link
Contributor

Grantim commented Jul 21, 2023

Hello!

It is not determined how to prolong ab edge by the surface. I can reccomend defining a plane using surface normal and ab edge.

MeshEdgePoint a,b; // input data
Mesh mesh; // input mesh
UndirectedEdgeBitSet selectedEdges; // input edges to find intersections on

//define plane
auto plane = Plane3f::fromDirAndPt( cross( mesh.edgePoint(b) - mesh.edgePoint(a), mesh.normal( MeshTriPoint(a) ) ), mesh.edgePoint(a) );

// find intersections
std::vector<MeshEdgePoint> intersections;
for ( auto ue : selectedEdges )
{
    float orgD = plane.distance( mesh.orgPt( EdgeId( ue ) ) );
    float destD = plane.distance( mesh.destPt( EdgeId( ue ) ) );
    if ( orgD * destD > 0.0f ) // same sign - no intersection
        continue;
    intersections.push_back( MeshEdgePoint( EdgeId( ue ), std::abs(orgD)/(std::abs(orgD)+std::abs(destD)) ) );
}

@xiaodongdong101
Copy link
Author

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants