Sketch Inside/Outside Curve
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Sketch Inside/Outside Curve
I am trying to do some processing on a sketch, when scanning a sketches geometry is there an easy way of determining if a curve is an inside or outside curve?
see screenshot
see screenshot
Last edited by keithsloan52 on Mon Dec 06, 2021 1:50 pm, edited 2 times in total.
- Shalmeneser
- Veteran
- Posts: 9554
- Joined: Wed Dec 23, 2020 12:04 am
- Location: Fr
Re: Sketch Inside/Outside Curve
Coming from outside, each time you cross a line, change color (B/W).
If the center is the same color of outside area : outside.
If ...
but center of inside curve can be in the outside area.
If the center is the same color of outside area : outside.
If ...
but center of inside curve can be in the outside area.
- Attachments
-
- Capture du 2021-12-03 00-06-58.png (3.77 KiB) Viewed 2148 times
Re: Sketch Inside/Outside Curve
I guess the question is concave/convexShalmeneser wrote: ↑Thu Dec 02, 2021 11:05 pm Coming from outside, each time you cross a line, change color (B/W).
If the center is the same color of outside area : outside.
If ...
but center of inside curve can be in the outside area.
- Shalmeneser
- Veteran
- Posts: 9554
- Joined: Wed Dec 23, 2020 12:04 am
- Location: Fr
Re: Sketch Inside/Outside Curve
Find upper-left point then turn clockwise along the border. One side is inside, other side is outside.
Re: Sketch Inside/Outside Curve
No, it works with these as well. It is only critical if you by a bad coincidence cross a border at a point on the curve to be tested. Starting from the outside count the border trsnsitions. If the number is odd you are inside, if it is even, you are outside. Herer is a rough example using Sketcher
red: Sketch to be tested
white: outside
blue: inside.
- Attachments
-
- SnipScreenshot-9487a0.png (35.92 KiB) Viewed 2056 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Sketch Inside/Outside Curve
I know this My point is that I guess that OP question is actually to be able to determine if a curve is concave or convex.chrisb wrote: ↑Fri Dec 03, 2021 9:30 am No, it works with these as well. It is only critical if you by a bad coincidence cross a border at a point on the curve to be tested. Starting from the outside count the border trsnsitions. If the number is odd you are inside, if it is even, you are outside. Herer is a rough example using Sketcher
red: Sketch to be tested
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Sketch Inside/Outside Curve
The OP wants to be able to determine from the information available from scanning the sketch.openBrain wrote: ↑Fri Dec 03, 2021 9:34 amI know this My point is that I guess that OP question is actually to be able to determine if a curve is concave or convex.chrisb wrote: ↑Fri Dec 03, 2021 9:30 am No, it works with these as well. It is only critical if you by a bad coincidence cross a border at a point on the curve to be tested. Starting from the outside count the border trsnsitions. If the number is odd you are inside, if it is even, you are outside. Herer is a rough example using Sketcher
red: Sketch to be tested
I know the theory about does it cross a line etc, but how to program it?
To help me understand what my options are the code that scans the sketch has
Code: Select all
if case('Part::GeomArcOfCircle') :
print('ArcofCircle')
print(dir(gs))
print(gs.StartPoint)
print(gs.EndPoint)
print(gs.Center)
print(gs.Radius)
print(gs.centerOfCurvature)
print(gs.curvature)
print(gs)
Code: Select all
09:51:40 ArcofCircle
09:51:40 ['AngleXU', 'Axis', 'Center', 'Circle', 'Content', 'Continuity', 'EndPoint', 'FirstParameter', 'LastParameter', 'Location', 'MemSize', 'Module', 'Radius', 'Rotation', 'StartPoint', 'Tag', 'TypeId', 'XAxis', 'YAxis', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'approximateBSpline', 'centerOfCurvature', 'clone', 'continuityWith', 'copy', 'curvature', 'deleteExtensionOfName', 'deleteExtensionOfType', 'discretize', 'dumpContent', 'getAllDerivedFrom', 'getD0', 'getD1', 'getD2', 'getD3', 'getDN', 'getExtensionOfName', 'getExtensionOfType', 'getExtensions', 'hasExtensionOfName', 'hasExtensionOfType', 'intersect', 'intersect2d', 'intersectCC', 'intersectCS', 'isClosed', 'isDerivedFrom', 'isPeriodic', 'length', 'makeRuledSurface', 'mirror', 'normal', 'parameter', 'parameterAtDistance', 'period', 'restoreContent', 'reverse', 'reversedParameter', 'rotate', 'scale', 'setExtension', 'setParameterRange', 'tangent', 'toBSpline', 'toNurbs', 'toShape', 'transform', 'translate', 'trim', 'value']
09:51:40 Vector (6.171572889881885, 2.4369546850601067e-16, 0.0)
09:51:40 Vector (11.999999999999998, -0.999999999972443, 0.0)
09:51:40 Vector (9.171572889881885, 4.14020057e-08, 0.0)
09:51:40 3.0
09:51:40 <built-in method centerOfCurvature of Part.ArcOfCircle object at 0x7fed22754de8>
09:51:40 <built-in method curvature of Part.ArcOfCircle object at 0x7fed22754de8>
Also on the bases that one has to perform an algorithm on line crossing etc what do the various intersect?? functions do?
What does the function curvature return?
Re: Sketch Inside/Outside Curve
For the outer wire this can work:
Create a face from the sketch: face = Part.makeFace(sketch.Shape, "Part::FaceMakerSimple").
Get an ordered_vertexes_list: face.OuterWire.OrderedVertexes.
For each arc check the order of edge.firstVertex() and edge.lastVertex() in ordered_vertexes_list.
If the order is first->last the arc is convex.
To check if a point is inside the face you can use its isInside() method.
Create a face from the sketch: face = Part.makeFace(sketch.Shape, "Part::FaceMakerSimple").
Get an ordered_vertexes_list: face.OuterWire.OrderedVertexes.
For each arc check the order of edge.firstVertex() and edge.lastVertex() in ordered_vertexes_list.
If the order is first->last the arc is convex.
To check if a point is inside the face you can use its isInside() method.
Re: Sketch Inside/Outside Curve
Interesting topic and @Roy_043's approach to problem to read
@Roy_043 indicates the solution apply to outerwire. Just some random thoughts. Sketch.Shape.Wires should return all wires in a Sketch e.g.
Test if the wire one by one if it is closed; then test the wires if they are 'inside' or 'outside' against the outerwire ( pick a point along the wire and test by algorithm discussed above?). Then test the concerned curve with @Roy_043's approach - but the reverse of the logic is true?
https://towardsdatascience.com/is-the-p ... 4b86472119
@Roy_043 indicates the solution apply to outerwire. Just some random thoughts. Sketch.Shape.Wires should return all wires in a Sketch e.g.
Code: Select all
>>> s.Shape.Wires
[<Wire object at 0x557e08a1ef10>, <Wire object at 0x557e08a18f90>, <Wire object at 0x557e08a19010>]
https://towardsdatascience.com/is-the-p ... 4b86472119
Re: Sketch Inside/Outside Curve
Something similar to some modelling discussion on this page:
https://dev.opencascade.org/doc/occt-7. ... algos.html
when dealing with Interior/Exterior and following
It seems that OCCT has some methods (functions in C++ ??) to deal with them, but I don't know if and how they are implemented in FreeCAD.
Regards
Carlo D.
https://dev.opencascade.org/doc/occt-7. ... algos.html
when dealing with Interior/Exterior and following
It seems that OCCT has some methods (functions in C++ ??) to deal with them, but I don't know if and how they are implemented in FreeCAD.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/