Intersection of two Surfaces
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Intersection of two Surfaces
I want ot compute the intersection curve of two bspline surfaces.
Is there a method to do this the direct way?
at the moment i work around and calculate the intersection of two generated 3d parts and extract the curve.
or another question:
can i force to interpolate a bspline curve to lie on a given face?
my workaround is to make a projection of the bspline to the face.
Is there a method to do this the direct way?
at the moment i work around and calculate the intersection of two generated 3d parts and extract the curve.
or another question:
can i force to interpolate a bspline curve to lie on a given face?
my workaround is to make a projection of the bspline to the face.
Re: Intersection of two Surfaces
Hi,
This should be what you're after :I want ot compute the intersection curve of two bspline surfaces.
Is there a method to do this the direct way?
Code: Select all
list_of_intersection_curves = surface1.intersectSS(surface2)
If you can get the points you want to interpolate in the parametric space of the surface ( with distToShape, for example ), then you can build a 2D BsplineCurve that interpolates these points, and then apply this 2D curve on the Surface :can i force to interpolate a bspline curve to lie on a given face?
my workaround is to make a projection of the bspline to the face.
Code: Select all
from FreeCAD import Base
# the points to interpolate
p0 = Base.Vector2d(0.1,0.1)
p1 = Base.Vector2d(0.4,0.9)
p2 = Base.Vector2d(0.8,0.2)
pts2d = [p0,p1,p2]
bs2d = Part.Geom2d.BSplineCurve2d()
bs2d.interpolate(pts2d)
bs2d.Degree
# Degree = 2
bs2d.getPoles()
# [Vector2 (0.1, 0.1), Vector2 (0.32959173700183053, 1.648359991248584), Vector2 (0.8, 0.2)]
# apply the 2D BScurve on the surface
e1 = bs2d.toShape(the_surface)
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Intersection of two Surfaces
thank you for this intro,
I never used this kind of methods before.
I never used this kind of methods before.
Re: Intersection of two Surfaces
Werner ported the Geom2d package a couple of months ago ( many thanks for that ).
A brand new toolbox to play with ...
A brand new toolbox to play with ...
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Intersection of two Surfaces
very interesting, so I can rethink a lot of ideas.Chris_G wrote:Werner ported the Geom2d package a couple of months ago ( many thanks for that ).
A brand new toolbox to play with ...
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Intersection of two Surfaces
Now we can draw on our models
see: https://forum.freecadweb.org/viewtopic. ... 80#p166688
Code: Select all
def drawcurve():
w=App.ActiveDocument.Drawing_on_MyShoe__Face2.Shape
t=App.ActiveDocument.MyShoe.Shape.Face2
pts=[p.Point for p in w.Vertexes]
sf=t.Surface
pts2da=[sf.parameter(p) for p in pts[1:]]
pts2d=[Base.Vector2d(p[0],p[1]) for p in pts2da]
bs2d = Part.Geom2d.BSplineCurve2d()
bs2d.interpolate(pts2d)
e1 = bs2d.toShape(t)
Part.show(e1)
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Intersection of two Surfaces
Interesting. I have a pen on my laptop, would be interesting to super-quickly draw out mockup models with assistance of this tool...
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Intersection of two Surfaces
https://github.com/microelly2/freecad-nurbs
1. menu nurbs -> create shoe
2. select a face of the MyShoe
3. menu curves-> draw on face
4.move the mouse over the face
5. press "Enter" to register a point
repeat 4,5 - a red polygon is drawn
dialog -> Apply
a black curve is generated
I use the enter key, what is a good key for the pen?
1. menu nurbs -> create shoe
2. select a face of the MyShoe
3. menu curves-> draw on face
4.move the mouse over the face
5. press "Enter" to register a point
repeat 4,5 - a red polygon is drawn
dialog -> Apply
a black curve is generated
I use the enter key, what is a good key for the pen?
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Intersection of two Surfaces
Doesn't work. When I move pen (equivalent to hovering mouse), I see lots of coordinates printed to report view. When I hit Enter, this is printed:microelly2 wrote:4.move the mouse over the face5. press "Enter" to register a pointrepeat 4,5 - a red polygon is drawn
, and then coordinates keep on coming...File "C:\Users\User\AppData\Roaming\FreeCAD\Mod\freecad-nurbs\nurbswb\facedraw.py", line 113, in eventFilter
self.update()
--> File "C:\Users\User\AppData\Roaming\FreeCAD\Mod\freecad-nurbs\nurbswb\facedraw.py", line 249, in update
self.dialog.commit_noclose()
--> AttributeError: 'MyWidget' object has no attribute 'commit_noclose'
No red curve on screen, no activity at all apart from preselection highlighting.
When I click Apply, I get this:
File "C:\Users\User\AppData\Roaming\FreeCAD\Mod\freecad-nurbs\nurbswb\facedraw.py", line 288, in apply
drawcurve(self.ef.wire,self.ef.subobj)
--> File "C:\Users\User\AppData\Roaming\FreeCAD\Mod\freecad-nurbs\nurbswb\facedraw.py", line 271, in drawcurve
bs2d.interpolate(pts2d)
--> OCCError: NCollection_Array1::Create
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Intersection of two Surfaces
there is a enter key and a return key,DeepSOIC wrote: --> File "C:\Users\User\AppData\Roaming\FreeCAD\Mod\freecad-nurbs\nurbswb\facedraw.py", line 249, in update
self.dialog.commit_noclose()
you pressed the return key ( e.key()== QtCore.Qt.Key_Return
do you have a enter key (e.key()== QtCore.Qt.Key_Enter
because there is no point stored
--> OCCError: NCollection_Array1::Create