Consider a serpentine wall, it's lied down and called one side of the wall as frontside and another side as backside.
How can we get the faces in the two sides?
It's easy for our eyes to select the faces stand for frontside and backside. Like a box cover laid on the table, we can easily point out its front and back.
But how about in python script?
How to get faces in two sides of a serpentine wall?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: How to get faces in two sides of a serpentine wall?
I would try the following:
Let us assume:
- all the line segment vectors of the center line (red dotted) are connected in the same direction (end point of a segment vector is start point of the next segment)
- the unit normal vector of the center face of a wall segment be n (line segment vector dot height (e.g. (0,1,0) when line segments are in x-z-plane)
- a0 is the vector from origin to the starting point of the line segment
- <.,.> be the scalar product (dot product) of two vectors
- x is denoting any point in the upper or lower region
Then
A = <n,a0> is the normal distance of the face to the origin
the normal distance of the point x to the current center face is
d = B-A
with B = <n,x>
Is d >0 then the point is in the lower region (backside) , if d<0 it is in the upper region (frontside)
Let us assume:
- all the line segment vectors of the center line (red dotted) are connected in the same direction (end point of a segment vector is start point of the next segment)
- the unit normal vector of the center face of a wall segment be n (line segment vector dot height (e.g. (0,1,0) when line segments are in x-z-plane)
- a0 is the vector from origin to the starting point of the line segment
- <.,.> be the scalar product (dot product) of two vectors
- x is denoting any point in the upper or lower region
Then
A = <n,a0> is the normal distance of the face to the origin
the normal distance of the point x to the current center face is
d = B-A
with B = <n,x>
Is d >0 then the point is in the lower region (backside) , if d<0 it is in the upper region (frontside)
Re: How to get faces in two sides of a serpentine wall?
Does your script know where the dividing line is? I'm guessing it might not be the case, if you're trying to separate a polyline into backside/frontside.
The constant thickness is what our eyes and brain process really fast from the picture.
I would try:
-determine which edges are 'thicknesses' (black lines, left most and rightmost in your picture). in your case they are the smallest edges, and there are two of them, so:
-----sort all edges by length
-----find the smallest. make sure there are two.
-----these are your end pieces
-sort through the other edges for one that has a point that matches an endpoint of a 'thickness' edge
-keep sorting through edges to rebuild the polyline one point at a time.
-eventually you'll reach the other 'thickness' piece:
-----every line you found between the two thicknesses is part of 'front' or 'back'
-keep going back to the beginning.
The constant thickness is what our eyes and brain process really fast from the picture.
I would try:
-determine which edges are 'thicknesses' (black lines, left most and rightmost in your picture). in your case they are the smallest edges, and there are two of them, so:
-----sort all edges by length
-----find the smallest. make sure there are two.
-----these are your end pieces
-sort through the other edges for one that has a point that matches an endpoint of a 'thickness' edge
-keep sorting through edges to rebuild the polyline one point at a time.
-eventually you'll reach the other 'thickness' piece:
-----every line you found between the two thicknesses is part of 'front' or 'back'
-keep going back to the beginning.