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

Suggestion for clipping #1

Open
ZviHantsis opened this issue Jun 4, 2018 · 1 comment
Open

Suggestion for clipping #1

ZviHantsis opened this issue Jun 4, 2018 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@ZviHantsis
Copy link

ZviHantsis commented Jun 4, 2018

@szaghi
Hello!
I would like to give a couple of suggestions when checking for clipping:

  1. The clip check happens twice - one before allocating and twice after. Instead, maybe create a linked-list of integers type, such that every time that a facet is inside - add the current index to the list. Once done reading the file, (if FILO revert the list by replacing the pointers), and on the second run (after allocating) - you can only check if the index matches the index on the list head. If it does, save the facet and pop-out the head, moving to the next in line. You can verify that reading was done properly if at the end the list has size of 0.
  2. The current way you check if "inside" only includes facets which have all of the vertices inside the bounding box. There are cases where facets will have only several (but not all) vertices inside or even cases where all the vertices are outside, but the facets still intersects the bounding box.
    My suggestion is to use the following (I'm using element instead of facet to make sure that there is no confusion: element = a facet from the STL surface):
Phase 1: Checking the BOUNDING BOX VERTICES relative to the element plane
Based on the normal of the element, check the signed distance of each bounding-box vertex from the plane of the element.
If any of the distances==0.0 then the element is to be included.
If all 8 bounding-box vertices have positive distance or all 8 have negative distance - discard it.

Phase 2: Checking the ELEMENT VERTICES relative to the bounding-box
For each Bounding-Box facet (6 total), count how many element vertices are "outside" 
(based on the face normal, pointing outwards - same algorithm/concept as convex polygon). 
Since this is a AABB, it can be simplified to counting vertex.x<bmin.x, vertex.x>bmax.x and repeat for y,z).
If all of these are less than the element vertex number (3 for triangle) - include it.

(I think this can also be directly expanded to work for any convex bounding polygon and convex element)

@ZviHantsis ZviHantsis changed the title Version 1.0.4 Optional variables issue Suggestion for clipping Jun 4, 2018
@szaghi
Copy link
Owner

szaghi commented Jun 5, 2018

Hi @ZviHantsis

thank you for your feedback.

  1. I am not sure if building and traversing a linked list is more efficient than scanning twice a file, I could consider that change only after I see the need to speedup this phase; indeed, the loading of input files (even huge files) should be always less costly than other surfaces operations, thus I will not focus on refactor it until I see the necessity;

  2. sure, I can consider other criterion for the clipping.

Cheers

@szaghi szaghi added the enhancement New feature or request label Jun 5, 2018
@szaghi szaghi self-assigned this Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants