Allplan Fórum

[Otázka] Project object onto a curve and extract polygon

Tagy:
  • Project
  • Polygon
  • Fill

Hello everyone,

I'm trying to make a script that outlines and fills the projection of a object. The problem so far is when projecting multiple faces onto brep/surface, the order of the points is lost and connecting the with polygon creates distorted fills. Any tips how to fix it?

I have included few images for reference and the script.

"Image 1.jpg" - 3D preview of the scenario- in magenta is the scenario object and the projection in white.
"Image 2.jpg" - 2D result of the script
"Image 3.jpg" - how the final result should look like

Kind regards,
Dobromir

Přílohy (3)

Type: image/jpeg
Staženo 86
Size: 181,91 KiB
Type: image/jpeg
Staženo 42
Size: 53,99 KiB
Type: application/zip
Staženo 738
Size: 17,34 KiB

Show most helpful answer Hide most helpful answer

Some hints:
1. Make a projection matrix from eye to view point
2. Extract all faces from the polhedron, calculate the normal, and if the normal points to the eye point, then flatten the face by multiplying each point of the face in the correct order with that matrix. Caution : The face can have holes! You have to deal with it!
3. The result is a projected 2d-polygon. If the normal is perpendicular to the eye-view-point axis, the polygon is collapsed to a line, and have no area! So you have to filter this cases. Now combine this 2d-polygon with the other visible 2d-face-polygons by doing a boolean union operation. The result is the visible so called silhouette polygone of the polhedron.

This is one "brute force" algorithm for doing this. Another algorithm could be to extract all edges, which two adjacent faces have different visibility from view point. Project this edges to 2d lines and find the outer border of this line collection, to chain it to a closed polygon. Here also have to deal with holes!

This algorithm works only for polyhedren with straight bordered , flat faces. I would not try this with BReps. Good luck!

Some hints:
1. Make a projection matrix from eye to view point
2. Extract all faces from the polhedron, calculate the normal, and if the normal points to the eye point, then flatten the face by multiplying each point of the face in the correct order with that matrix. Caution : The face can have holes! You have to deal with it!
3. The result is a projected 2d-polygon. If the normal is perpendicular to the eye-view-point axis, the polygon is collapsed to a line, and have no area! So you have to filter this cases. Now combine this 2d-polygon with the other visible 2d-face-polygons by doing a boolean union operation. The result is the visible so called silhouette polygone of the polhedron.

This is one "brute force" algorithm for doing this. Another algorithm could be to extract all edges, which two adjacent faces have different visibility from view point. Project this edges to 2d lines and find the outer border of this line collection, to chain it to a closed polygon. Here also have to deal with holes!

This algorithm works only for polyhedren with straight bordered , flat faces. I would not try this with BReps. Good luck!

Thank you for your reply Nemo,
I will need additional hints. I decided to try the last method with the edges that you suggested.
So i extracted all edges and took out their starting points. Since I didn't find any 2D line/polygon node, I just changed the Z coordinates to all points to zero (0). Then the points are sent to 3D polygon node which is then unified.

The problem is that some points are duplicates and their arrangement isn't correct.
Is there any cull or delete duplicates points nodes?
And any tips on how to arrange the point list, so it can work no matter in which direction is facing the object? (I'm guessing I can't just arrange the point X or by Y by value)

Kind regards,
Dobromir

Double points can only occur if the edge to which they belong is vertical.
So you have to test if the normal of the surface is horizontal (fabs(Z-coordinate) < 1.0e-03).
You have to skip these faces, because vertical Edges can only occur on these faces.
If the normal of the surface "points down" (Z-coordinate < -1.0e-03), then the surface is not visible and can be omitted.

Another problem is the alignment. Allplan has problems when coplanar 3D surfaces are to be "unified" and these have opposite normal directions!

Regards.

Jörg