Face or line or vertex inside a solid
-
-
For a tested_face intersect it with the solid_object's entities - put the results into a temporary+group's entities, so you cab check if there are any and erase that group.
If there are intersection entities then it intersects.
Now it could still be fully inside the solid OR fully outside the object.
You cab text if the bounding boxes intersect but that's not a certainty.
Hide everything except the object and test the faces vertices with a model.raytest([vpoint, Z_AXIS], true)
If there's no result it's outside of the object.
If there's a result that includes the object then it's either inside the object or below the object [or 'below' some part of it - e.g. it's a hollow donut ring on its side].
If it's 'below' the object then the face the ray hits will have face.normal.z<0
If it's inside the object then the face the ray hits will have face.normal.z>0
If it hits an edge rather than a face there will be two edge faces... you can get the normals of those faces and the angles they make with the Z_AXIS...
If both angles <= 90.degrees then the tested face is inside the object, otherwise it's outside.
You might also want to test for the face having a vertex being coplanar with one of the object's faces... i.e. neither inside or outside the object - if "on==in" you need an extra set of tests...
To do that iterate all of the object's entities to collect the faces and then test each of the vpoints with face.classify_point(vpoint) and from the result you can tell if the tested_face's vertices fall on any of the object's faces [or their edges/vertices]...
It's NOT easy BUT it is doable... -
You'd have to do multiple tests for each point and then the raytest[0] point etc.
You'll have to hide everything else first ?
Test it - if it works post some code... -
Hello Tig,
I have also thought about rays.
What do you think about this solution:
If the tested object and a solid are not intersecting.
If a ray from a tested object hits faces of a solid odd number of times ,the tested object is inside the solid.
If the ray hits an edge or a vertex,repeat the ray test in other direction.
David
Advertisement