Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
>Try to avoid passing arguments by reference. This C++ mechanism is not really >pythonic. Rather create first an empty Handle for the >TopTools_HSequenceOfShape >and get the object once it's created. Thank you very much! This explains many of the problems I had with pythonocc. Björn ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
> Which version of pythonocc are you on? Recently there have been advantages ( >in the SVN version ) that deal with these shortcomings. Are you on a recent >build of pyocc? > If so, would you mind typing svn info? > ( note to Thomas; ideally we should automatically add a __svn_version__ to >each python file ) I will see whether the svn version improved some of the hickups. Currently I am running the 0.4 release. For now I would like to end the discussion. I am sorry for having expressed my feelings in an impolite manner. Given the present state we will need to develop our own python wrappers, but seeing the pythonocc capabilities is already very encouraging, and I am looking forward to future releases. > Are you part of the Freecad project Bjorn, as your email suggests? Not of any of the several published Freecad projects. Some model making friends are working on another free CAD project. Cheers Björn ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
> There may be other ways to create a simple rectangular wire. My problem is > that > ShapeAnalysis_FreeBounds and many other classes don't function in python, and > I > would like to understand why, in order to be able to fix it. There is a very > good reason, why opencascade offers all these algorithms, and in my opinion > pythonocc should a) include functioning bindings or b) hide non-functioning > bindings or c) document which pythonic ways replace opencascades algorithms. > OCC.Utils.Construct.make_wire does *not* replace > ShapeAnalysis_FreeBounds::ConnectEdgesToWires, because make_wire just adds > one > edge after the other, assuming they are ordered and connected. This works for > the simple example, but not in situations which the shapehealing toolkit was > designed for. Its true that the Shape Healing kit uses pretty non-standard operators somewhere in the code, so its not unthinkable that there perhaps are a few hickups there. Which version of pythonocc are you on? Recently there have been advantages ( in the SVN version ) that deal with these shortcomings. Are you on a recent build of pyocc? If so, would you mind typing svn info? ( note to Thomas; ideally we should automatically add a __svn_version__ to each python file ) > I am sorry, I do not want to threaten or give homework, but give feedback > what > should happen so that my coworkers will return to pythonocc again in the > future. > You are welcome to ignore the feedback. I am more used to other open source > projects, where the limitations a clearly communicated and a higher priority > is > given to understand what is causing the limitations instead of providing > hundreds of workarounds. Well, I've written tons of pyocc code, and as in any other software projects there surely are some minor hickups, but there is no doubt that pythonocc is industrial strength. To suggest that there are hundreds of workarounds is neither fair nor accurate. Patches are so much more appreciated than massively overstated critique ;) Are you part of the Freecad project Bjorn, as your email suggests? Cheers, -jelle ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
2010/8/18 Free Cad > >Furthermore, what are the "python bugs added on top" you're talking about? > Is it > > > >the issues already reported here > http://code.google.com/p/pythonocc/issues/list > > >? I'm not sure they are the cause of your unsuccessful attempts. Did you > >identify other issues that have not been reported yet and I would not be > aware > >of? I'm much looking forward to having your feedbacks about it. > Hi Björn, > > Of course, it would be better if all the problems shown in this list were > filed > as bug reports. But since the problems are always "investigated" or "looked > into", but never solved, I don't see the point in extending the list of > bugs. > If you don't have the manpower to fix problems, that's fair. But then say > so, > and people will get involved more deeply instead of abandoning pythonocc > with > bad feelings because after months their problem is still "investigated". > > I found that basically only the foundation classes module is more or less > well > supported by the python bindings. Especially the python bindings of the > modeling > data and modeling algorithms modules seem to be generated automatically > without > any unit tests ever applied. > Many thanks for letting us know your opinion. > > Maybe you can have a look at this one. Please don't tell me that you will > investigate the issue. If it can be solved within a week, I will reconsider > using pythonocc instead of C++, and I will take the time to submit bug > reports > for a bunch of other issues. An ultimatum? It's not usual in free software, especially outside of any commercial relationship. However, it's exciting to be challenged, even if I do not have any idea about who you are (but according to your message, it seems that it would be an honor for us that you use pythonocc). So first introduce yourself, your project and what you aim to bring to the project so that this challenge is a fair deal. > This example should create one wire from a sequence > of four edges. In C++ it works perfectly. Why does pythonocc create zero > wires > in ws? > > from OCC.BRepBuilderAPI import * > from OCC.gp import * > from OCC.TopTools import * > from OCC.TopoDS import * > from OCC.ShapeAnalysis import * > > vs=[[0,0,0],[1,0,0],[1,1,0],[0,1,0]]; > es=TopTools_HSequenceOfShape() > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[0]),gp_Pnt(*vs[1])).Edge()) > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[1]),gp_Pnt(*vs[2])).Edge()) > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[2]),gp_Pnt(*vs[3])).Edge()) > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[3]),gp_Pnt(*vs[0])).Edge()) > ws=TopTools_HSequenceOfShape() > safb=ShapeAnalysis_FreeBounds() > safb.ConnectEdgesToWires(es.GetHandle(),1e-3,False,ws.GetHandle()) > print ws.Length() > > Regards, > Björn > Best Regards, Thomas ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
Thank you, Jelle. There may be other ways to create a simple rectangular wire. My problem is that ShapeAnalysis_FreeBounds and many other classes don't function in python, and I would like to understand why, in order to be able to fix it. There is a very good reason, why opencascade offers all these algorithms, and in my opinion pythonocc should a) include functioning bindings or b) hide non-functioning bindings or c) document which pythonic ways replace opencascades algorithms. OCC.Utils.Construct.make_wire does *not* replace ShapeAnalysis_FreeBounds::ConnectEdgesToWires, because make_wire just adds one edge after the other, assuming they are ordered and connected. This works for the simple example, but not in situations which the shapehealing toolkit was designed for. I am sorry, I do not want to threaten or give homework, but give feedback what should happen so that my coworkers will return to pythonocc again in the future. You are welcome to ignore the feedback. I am more used to other open source projects, where the limitations a clearly communicated and a higher priority is given to understand what is causing the limitations instead of providing hundreds of workarounds. Regards, Björn - Ursprüngliche Mail > Von: Jelle Feringa > An: pythonOCC users mailing list. > Gesendet: Mittwoch, den 18. August 2010, 11:59:50 Uhr > Betreff: Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix > > > vs=[[0,0,0],[1,0,0],[1,1,0],[0,1,0]]; > > es=TopTools_HSequenceOfShape() > > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[0]),gp_Pnt(*vs[1])).Edge()) > > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[1]),gp_Pnt(*vs[2])).Edge()) > > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[2]),gp_Pnt(*vs[3])).Edge()) > > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[3]),gp_Pnt(*vs[0])).Edge()) > > ws=TopTools_HSequenceOfShape() > > safb=ShapeAnalysis_FreeBounds() > > safb.ConnectEdgesToWires(es.GetHandle(),1e-3,False,ws.GetHandle()) > > > Hi Björn, > > I'm getting a little annoyed by a somewhat threatening and demanding tone > on >this list; giving our readers homework ( last thread ) and now threatening to >abandon pythonocc if we do not fix some issue in a week. Be a little more >respectful, please. > > Back to the problem; > > Just to understand your issue in more detail; let me ask you why you would >create in the suggested manner. > There's a pythonic way to do it. > > > ( oops… from OCC.Utils.Construct import * ) > In [25]: vs = map( lambda x: gp_Pnt(*x), [[0,0,0],[1,0,0],[1,1,0],[0,1,0]]) > > In [26]: vs > Out[26]: > [ >, > >, > >, > >] > > In [27]: edg1 = make_edge(vs[0], vs[1]) > > In [28]: edg2 = make_edge(vs[1], vs[2]) > > In [29]: edg2 = make_edge(vs[2], vs[3]) > > In [30]: edg3 = make_edge(vs[2], vs[3]) > > In [31]: edg4 = make_edge(vs[3], vs[0]) > > In [32]: wire = make_wire([edg1,edg2,edg3,edg4]) > > In [33]: wire > Out[33]: *' at 0x102b04040> > > > Take care, be nice, > > -jelle > ___ > Pythonocc-users mailing list > Pythonocc-users@gna.org > https://mail.gna.org/listinfo/pythonocc-users > ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
> vs=[[0,0,0],[1,0,0],[1,1,0],[0,1,0]]; > es=TopTools_HSequenceOfShape() > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[0]),gp_Pnt(*vs[1])).Edge()) > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[1]),gp_Pnt(*vs[2])).Edge()) > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[2]),gp_Pnt(*vs[3])).Edge()) > es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[3]),gp_Pnt(*vs[0])).Edge()) > ws=TopTools_HSequenceOfShape() > safb=ShapeAnalysis_FreeBounds() > safb.ConnectEdgesToWires(es.GetHandle(),1e-3,False,ws.GetHandle()) Hi Björn, I'm getting a little annoyed by a somewhat threatening and demanding tone on this list; giving our readers homework ( last thread ) and now threatening to abandon pythonocc if we do not fix some issue in a week. Be a little more respectful, please. Back to the problem; Just to understand your issue in more detail; let me ask you why you would create in the suggested manner. There's a pythonic way to do it. ( oops… from OCC.Utils.Construct import * ) In [25]: vs = map( lambda x: gp_Pnt(*x), [[0,0,0],[1,0,0],[1,1,0],[0,1,0]]) In [26]: vs Out[26]: [ >, >, >, >] In [27]: edg1 = make_edge(vs[0], vs[1]) In [28]: edg2 = make_edge(vs[1], vs[2]) In [29]: edg2 = make_edge(vs[2], vs[3]) In [30]: edg3 = make_edge(vs[2], vs[3]) In [31]: edg4 = make_edge(vs[3], vs[0]) In [32]: wire = make_wire([edg1,edg2,edg3,edg4]) In [33]: wire Out[33]: > Take care, be nice, -jelle ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
>Furthermore, what are the "python bugs added on top" you're talking about? Is >it > >the issues already reported here >http://code.google.com/p/pythonocc/issues/list >? I'm not sure they are the cause of your unsuccessful attempts. Did you >identify other issues that have not been reported yet and I would not be aware >of? I'm much looking forward to having your feedbacks about it. Of course, it would be better if all the problems shown in this list were filed as bug reports. But since the problems are always "investigated" or "looked into", but never solved, I don't see the point in extending the list of bugs. If you don't have the manpower to fix problems, that's fair. But then say so, and people will get involved more deeply instead of abandoning pythonocc with bad feelings because after months their problem is still "investigated". I found that basically only the foundation classes module is more or less well supported by the python bindings. Especially the python bindings of the modeling data and modeling algorithms modules seem to be generated automatically without any unit tests ever applied. Maybe you can have a look at this one. Please don't tell me that you will investigate the issue. If it can be solved within a week, I will reconsider using pythonocc instead of C++, and I will take the time to submit bug reports for a bunch of other issues. This example should create one wire from a sequence of four edges. In C++ it works perfectly. Why does pythonocc create zero wires in ws? from OCC.BRepBuilderAPI import * from OCC.gp import * from OCC.TopTools import * from OCC.TopoDS import * from OCC.ShapeAnalysis import * vs=[[0,0,0],[1,0,0],[1,1,0],[0,1,0]]; es=TopTools_HSequenceOfShape() es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[0]),gp_Pnt(*vs[1])).Edge()) es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[1]),gp_Pnt(*vs[2])).Edge()) es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[2]),gp_Pnt(*vs[3])).Edge()) es.Append(BRepBuilderAPI_MakeEdge(gp_Pnt(*vs[3]),gp_Pnt(*vs[0])).Edge()) ws=TopTools_HSequenceOfShape() safb=ShapeAnalysis_FreeBounds() safb.ConnectEdgesToWires(es.GetHandle(),1e-3,False,ws.GetHandle()) print ws.Length() Regards, Björn ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
2010/8/16 Free Cad > >Von: Thomas Paviot > >An: pythonOCC users mailing list. > >Gesendet: Samstag, den 14. August 2010, 15:59:25 Uhr > >Betreff: Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix > > > > > > > > > >Dear Bjorn, > > > > > >I tested your sample but did not experiment that much the ShapeFix OCC > module. I > > > >do not have any answer to your question yet, but I will investigate this > issue > >further. In the meantime, you can post to the OCC forum > >(http://www.opencascade.org/org/forum/) where you will meet the whole > >OpenCascade community. > > Dear Thomas, > is my assumption correct that investigating this issue will take months or > years without an upper limit? Similar to other questions that somebody > wanted to > look into? > Dear Björn, Don't know whether or not your assumption is valid, but you're a bit pessimistic ;-) I think I will do without pythonocc, because the complicated opencascade API > with the python bugs added on top make it impossible to get anything done. > I do not agree with your proposition. OpenCascade is indeed a huge and complex API, and topology fixing is not an easy science. "impossible to get anything done" is not true: it's actually possible to get many things done! (just look at the examples). "I didn't manage to get what I need" would certainly be a more appropriate statement. Furthermore, what are the "python bugs added on top" you're talking about? Is it the issues already reported here http://code.google.com/p/pythonocc/issues/list ? I'm not sure they are the cause of your unsuccessful attempts. Did you identify other issues that have not been reported yet and I would not be aware of? I'm much looking forward to having your feedbacks about it. > Happy pythoning! > Björn > > Kind Regards, Thomas ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
>Von: Thomas Paviot >An: pythonOCC users mailing list. >Gesendet: Samstag, den 14. August 2010, 15:59:25 Uhr >Betreff: Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix > > > > >Dear Bjorn, > > >I tested your sample but did not experiment that much the ShapeFix OCC module. >I > >do not have any answer to your question yet, but I will investigate this issue >further. In the meantime, you can post to the OCC forum >(http://www.opencascade.org/org/forum/) where you will meet the whole >OpenCascade community. Dear Thomas, is my assumption correct that investigating this issue will take months or years without an upper limit? Similar to other questions that somebody wanted to look into? I think I will do without pythonocc, because the complicated opencascade API with the python bugs added on top make it impossible to get anything done. Happy pythoning! Björn ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
2010/8/13 Free Cad > > Björn, if you manage to fix this ( confident you will ;) than would you > please > >share this example with > > > > us, such that way may include it in the /examples ? > > > > > Thanks, > > > > -jelle > > I hope that somebody will answer my last question about the basic use of > ShapeUpgrade_WireDivide, because I am not able to solve the problem. > Or maybe somebody else can finish the code for your pythonocc examples. > > Thanks, > Björn > > > Dear Bjorn, I tested your sample but did not experiment that much the ShapeFix OCC module. I do not have any answer to your question yet, but I will investigate this issue further. In the meantime, you can post to the OCC forum (http://www.opencascade.org/org/forum/) where you will meet the whole OpenCascade community. Best Regards, Thomas ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
> Björn, if you manage to fix this ( confident you will ;) than would you > please >share this example with > > us, such that way may include it in the /examples ? > > Thanks, > > -jelle I hope that somebody will answer my last question about the basic use of ShapeUpgrade_WireDivide, because I am not able to solve the problem. Or maybe somebody else can finish the code for your pythonocc examples. Thanks, Björn ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
Dear Jelle, I was able to locate the self-intersection points using ShapeAnalysis_Wire. There was some difficulty, because it needs a face underlying the analysed wire. The function 'faceAroundPlanarWire' below calculates such face assuming that the wire is planar. I would like to understand why a face is needed to find edge intersections? Anyway, the more important question is, how to proceed. The new functions 'fixWire' ' faceAroundPlanarWire' below find the correct self-intersection of the wire in my previous example. But I cannot figure out how to use ShapeUpgrade_WireDivide as you suggested. It seems that I have to call ShapeUpgrade_WireDivide's method 'SetSplitCurve2dTool (const Handle(ShapeUpgrade_SplitCurve2d)&splitCurve2dTool)'. For the ShapeUpgrade_SplitCurve2d I have to call 'SetSplitValues (const Handle(TColStd_HSequenceOfReal)&SplitValues)'. But what are the SplitValues? Is it the curve parameter at the intersection measured for indivual edges? I don't think so, because 'SetSplitSection' does not get any information about *which* edges are intersecting. Are the SplitValues the curve parameter at the intersection measured for the whole wire? To my knowledge there is no notion of the curve of a wire, is it? So how can I get the SplitValues after I got the intersection points (variable pts in function fixWire below)? new code fragments: def faceAroundPlanarWire(wire): topo=Topo(wire) pts=TColgp_HArray1OfPnt(0,topo.number_of_vertices()-1) i=0 for v in topo.vertices(): pts.SetValue(i,bt.Pnt(v)) i+=1 gpbap=GeomPlate_BuildAveragePlane(pts.GetHandle(),pts.Length(),1e-7,1,1) plane=gpbap.Plane() umin,umax,vmin,vmax=gpbap.MinMaxBox() mf=BRepBuilderAPI_MakeFace(plane,umin,umax,vmin,vmax) return mf.Face() def fixWire(wire): f=faceAroundPlanarWire(wire) saw=ShapeAnalysis_Wire() saw.Init(wire,f,1e-6) res=IntRes2d_SequenceOfIntersectionPoint() pts=TColgp_SequenceOfPnt() errs=TColStd_SequenceOfReal() print saw.Precision() for i in range(4): for k in range(i+1,4): print i,k,saw.CheckIntersectingEdges(i,k,res,pts,errs),res.Length(),pts.Length() - I also appreciate any other documentation or examples about the use of the ShapeUpgrade_WireDivide class. The reference documentation does not help, and with google I find nothing better. Thank you Björn - Ursprüngliche Mail > Von: Jelle Feringa > An: pythonOCC users mailing list. > Gesendet: Donnerstag, den 12. August 2010, 11:59:03 Uhr > Betreff: Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix > > Sorry, hit send too soon… > > Have you had a look at > > ShapeUpgrade_WireDivide > > ShapeAnalysis_Wire will help you find out which are intersecting edges. > > Björn, if you manage to fix this ( confident you will ;) than would you > please > > >share this example with us, such that way may include it in the /examples ? > > Thanks, > > -jelle > > On Aug 12, 2010, at 11:20 AM, Free Cad wrote: > > > Hi again, > > can you help me use ShapeFix in the correct way, or suggest other > > solutions >to a > > > problem with self-intersecting wires? > > > > The code below generates an example of such a wire. There is a small loop >close > > > to the point (1.0,1.0,0.0) which is the reason why no face can be made > > from >it, > > > I guess. > > > > The code also shows my attempt to solve the problem using >sf=ShapeFix_Wire(). > > > But sf.Perform() always fails, even if the wire is without problems (using > > vertex definitions as in the line which is commented out). > > > > What is the simplest solution to generate a face from self-intersecting >wires > > > _automatically_? In my example, the small loop could be collapsed to a >single > > > vertex, or the wire could be split into two (the large loop and the small >loop) > > > - both solutions would be fine. > > How about OCC's ShapeHealing functions? Are they more powerful than >ShapeFix? I > > > don't understand the relation between ShapeFix and ShapeHealing. Is >ShapeHealing > > > available in the non-commercial OCC distribution? > > > > > > Thank you > > Björn > > > > --- code example: --- > > from OCC.BRepBuilderAPI import * > > from OCC.gp import * > > from OCC.ShapeFix import * > > from OCC.TopoDS import * > > > > def fixWire(wire): > > sf=ShapeFix_Wire() > > sf.Load(wire) > > sf.SetFixIntersectingEdgesMode(1) > > sf.SetFixNonAdjacentIntersectingEdgesMode(1) > > sf.
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
> This may answer my questions. I will have a look at the suggested classes. > And > of course, I can share the example, when I find a solution. excellent, thanks in advance. ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
Thank you, Jelle. This may answer my questions. I will have a look at the suggested classes. And of course, I can share the example, when I find a solution. Thank you Björn - Ursprüngliche Mail > Von: Jelle Feringa > An: pythonOCC users mailing list. > Gesendet: Donnerstag, den 12. August 2010, 11:59:03 Uhr > Betreff: Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix > > Sorry, hit send too soon… > > Have you had a look at > > ShapeUpgrade_WireDivide > > ShapeAnalysis_Wire will help you find out which are intersecting edges. > > Björn, if you manage to fix this ( confident you will ;) than would you > please >share this example with us, such that way may include it in the /examples ? > > Thanks, > > -jelle > > On Aug 12, 2010, at 11:20 AM, Free Cad wrote: > > > Hi again, > > can you help me use ShapeFix in the correct way, or suggest other > > solutions >to a > > > problem with self-intersecting wires? > > > > The code below generates an example of such a wire. There is a small loop >close > > > to the point (1.0,1.0,0.0) which is the reason why no face can be made > > from >it, > > > I guess. > > > > The code also shows my attempt to solve the problem using >sf=ShapeFix_Wire(). > > > But sf.Perform() always fails, even if the wire is without problems (using > > vertex definitions as in the line which is commented out). > > > > What is the simplest solution to generate a face from self-intersecting >wires > > > _automatically_? In my example, the small loop could be collapsed to a >single > > > vertex, or the wire could be split into two (the large loop and the small >loop) > > > - both solutions would be fine. > > How about OCC's ShapeHealing functions? Are they more powerful than >ShapeFix? I > > > don't understand the relation between ShapeFix and ShapeHealing. Is >ShapeHealing > > > available in the non-commercial OCC distribution? > > > > > > Thank you > > Björn > > > > --- code example: --- > > from OCC.BRepBuilderAPI import * > > from OCC.gp import * > > from OCC.ShapeFix import * > > from OCC.TopoDS import * > > > > def fixWire(wire): > > sf=ShapeFix_Wire() > > sf.Load(wire) > > sf.SetFixIntersectingEdgesMode(1) > > sf.SetFixNonAdjacentIntersectingEdgesMode(1) > > sf.SetFixSelfIntersectingEdgeMode(1) > > if sf.Perform(): > >print 'Fix Successful' > > return sf.Wire() > > else: > >print 'Fix Unsuccessful' > >return wire > > > > def vertex(x,y,z): > > mv=BRepBuilderAPI_MakeVertex(gp_Pnt(x,y,z)) > > return mv.Vertex() > > def edge(v1,v2): > > me=BRepBuilderAPI_MakeEdge(v1,v2) > > return me.Edge() > > def face(w): > > mf=BRepBuilderAPI_MakeFace(w) > > return mf.Face() > > def wire(e1,e2,e3,e4): > > mw=BRepBuilderAPI_MakeWire(e1) > > mw.Add(e2); mw.Add(e3); mw.Add(e4); > > return mw.Wire() > > > > v=[vertex(0,0,0),vertex(1,0,0),vertex(0.95,1,0),vertex(1,1,0)] #self > > intersecting, no face visible > > #v=[vertex(0,0,0),vertex(1,0,0),vertex(1,1,0),vertex(0.9,1,0)] #valid wire > > e=[] > > for i in range(4): > > e.append(edge(v[i-1],v[i])) > > w=wire(e[0],e[1],e[2],e[3]) > > f=face(fixWire(w)) > > > > from OCC.Display.SimpleGui import * > > display, start_display, add_menu, add_function_to_menu = init_display() > > display.DisplayShape([w,f]) > > start_display() > > > > > > > > > > > > ___ > > Pythonocc-users mailing list > > Pythonocc-users@gna.org > > https://mail.gna.org/listinfo/pythonocc-users > > > ___ > Pythonocc-users mailing list > Pythonocc-users@gna.org > https://mail.gna.org/listinfo/pythonocc-users > ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
> Finding out where the intersection lies at and than building 2 faces is a > good >idea it seams to me. Yes, it depends on tolerances. Sometimes small loops are just sampling errors (then it is better to collapse the vertices) and sometimes the faces should be split. But the question is: are there algorithms available in OCC/pythonOCC that perform either of these modifications? I do not want to reinvent the wheel. > * do you have the doxygen documentation? I do have OCC's ShapeFix doxygen documentation. But I don't see what I am doing wrong. Or do you mean pythonOCC's documentation, because it is not 100% compatible with the C++ libraries? Or ShapeHeal documentation? I cannot find it. Thank you Björn - Ursprüngliche Mail > Von: Jelle Feringa > An: pythonOCC users mailing list. > Gesendet: Donnerstag, den 12. August 2010, 11:53:14 Uhr > Betreff: Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix > > Finding out where the intersection lies at and than building 2 faces is a > good >idea it seams to me. > > * do you have the doxygen documentation? > * if I understood correctly, shape healing is made of the Shape* API > > > > On Aug 12, 2010, at 11:20 AM, Free Cad wrote: > > > Hi again, > > can you help me use ShapeFix in the correct way, or suggest other > > solutions >to a > > > problem with self-intersecting wires? > > > > The code below generates an example of such a wire. There is a small loop >close > > > to the point (1.0,1.0,0.0) which is the reason why no face can be made > > from >it, > > > I guess. > > > > The code also shows my attempt to solve the problem using >sf=ShapeFix_Wire(). > > > But sf.Perform() always fails, even if the wire is without problems (using > > vertex definitions as in the line which is commented out). > > > > What is the simplest solution to generate a face from self-intersecting >wires > > > _automatically_? In my example, the small loop could be collapsed to a >single > > > vertex, or the wire could be split into two (the large loop and the small >loop) > > > - both solutions would be fine. > > How about OCC's ShapeHealing functions? Are they more powerful than >ShapeFix? I > > > don't understand the relation between ShapeFix and ShapeHealing. Is >ShapeHealing > > > available in the non-commercial OCC distribution? > > > > > > Thank you > > Björn > > > > --- code example: --- > > from OCC.BRepBuilderAPI import * > > from OCC.gp import * > > from OCC.ShapeFix import * > > from OCC.TopoDS import * > > > > def fixWire(wire): > > sf=ShapeFix_Wire() > > sf.Load(wire) > > sf.SetFixIntersectingEdgesMode(1) > > sf.SetFixNonAdjacentIntersectingEdgesMode(1) > > sf.SetFixSelfIntersectingEdgeMode(1) > > if sf.Perform(): > >print 'Fix Successful' > > return sf.Wire() > > else: > >print 'Fix Unsuccessful' > >return wire > > > > def vertex(x,y,z): > > mv=BRepBuilderAPI_MakeVertex(gp_Pnt(x,y,z)) > > return mv.Vertex() > > def edge(v1,v2): > > me=BRepBuilderAPI_MakeEdge(v1,v2) > > return me.Edge() > > def face(w): > > mf=BRepBuilderAPI_MakeFace(w) > > return mf.Face() > > def wire(e1,e2,e3,e4): > > mw=BRepBuilderAPI_MakeWire(e1) > > mw.Add(e2); mw.Add(e3); mw.Add(e4); > > return mw.Wire() > > > > v=[vertex(0,0,0),vertex(1,0,0),vertex(0.95,1,0),vertex(1,1,0)] #self > > intersecting, no face visible > > #v=[vertex(0,0,0),vertex(1,0,0),vertex(1,1,0),vertex(0.9,1,0)] #valid wire > > e=[] > > for i in range(4): > > e.append(edge(v[i-1],v[i])) > > w=wire(e[0],e[1],e[2],e[3]) > > f=face(fixWire(w)) > > > > from OCC.Display.SimpleGui import * > > display, start_display, add_menu, add_function_to_menu = init_display() > > display.DisplayShape([w,f]) > > start_display() > > > > > > > > > > > > ___ > > Pythonocc-users mailing list > > Pythonocc-users@gna.org > > https://mail.gna.org/listinfo/pythonocc-users > > ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
Sorry, hit send too soon… Have you had a look at ShapeUpgrade_WireDivide ShapeAnalysis_Wire will help you find out which are intersecting edges. Björn, if you manage to fix this ( confident you will ;) than would you please share this example with us, such that way may include it in the /examples ? Thanks, -jelle On Aug 12, 2010, at 11:20 AM, Free Cad wrote: > Hi again, > can you help me use ShapeFix in the correct way, or suggest other solutions > to a > problem with self-intersecting wires? > > The code below generates an example of such a wire. There is a small loop > close > to the point (1.0,1.0,0.0) which is the reason why no face can be made from > it, > I guess. > > The code also shows my attempt to solve the problem using sf=ShapeFix_Wire(). > But sf.Perform() always fails, even if the wire is without problems (using > vertex definitions as in the line which is commented out). > > What is the simplest solution to generate a face from self-intersecting wires > _automatically_? In my example, the small loop could be collapsed to a single > vertex, or the wire could be split into two (the large loop and the small > loop) > - both solutions would be fine. > How about OCC's ShapeHealing functions? Are they more powerful than ShapeFix? > I > don't understand the relation between ShapeFix and ShapeHealing. Is > ShapeHealing > available in the non-commercial OCC distribution? > > > Thank you > Björn > > --- code example: --- > from OCC.BRepBuilderAPI import * > from OCC.gp import * > from OCC.ShapeFix import * > from OCC.TopoDS import * > > def fixWire(wire): > sf=ShapeFix_Wire() > sf.Load(wire) > sf.SetFixIntersectingEdgesMode(1) > sf.SetFixNonAdjacentIntersectingEdgesMode(1) > sf.SetFixSelfIntersectingEdgeMode(1) > if sf.Perform(): >print 'Fix Successful' >return sf.Wire() > else: >print 'Fix Unsuccessful' >return wire > > def vertex(x,y,z): > mv=BRepBuilderAPI_MakeVertex(gp_Pnt(x,y,z)) > return mv.Vertex() > def edge(v1,v2): > me=BRepBuilderAPI_MakeEdge(v1,v2) > return me.Edge() > def face(w): > mf=BRepBuilderAPI_MakeFace(w) > return mf.Face() > def wire(e1,e2,e3,e4): > mw=BRepBuilderAPI_MakeWire(e1) > mw.Add(e2); mw.Add(e3); mw.Add(e4); > return mw.Wire() > > v=[vertex(0,0,0),vertex(1,0,0),vertex(0.95,1,0),vertex(1,1,0)] #self > intersecting, no face visible > #v=[vertex(0,0,0),vertex(1,0,0),vertex(1,1,0),vertex(0.9,1,0)] #valid wire > e=[] > for i in range(4): > e.append(edge(v[i-1],v[i])) > w=wire(e[0],e[1],e[2],e[3]) > f=face(fixWire(w)) > > from OCC.Display.SimpleGui import * > display, start_display, add_menu, add_function_to_menu = init_display() > display.DisplayShape([w,f]) > start_display() > > > > > > ___ > Pythonocc-users mailing list > Pythonocc-users@gna.org > https://mail.gna.org/listinfo/pythonocc-users ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users
Re: [Pythonocc-users] face from self-intersecting wire, ShapeFix
Finding out where the intersection lies at and than building 2 faces is a good idea it seams to me. * do you have the doxygen documentation? * if I understood correctly, shape healing is made of the Shape* API <> On Aug 12, 2010, at 11:20 AM, Free Cad wrote: > Hi again, > can you help me use ShapeFix in the correct way, or suggest other solutions > to a > problem with self-intersecting wires? > > The code below generates an example of such a wire. There is a small loop > close > to the point (1.0,1.0,0.0) which is the reason why no face can be made from > it, > I guess. > > The code also shows my attempt to solve the problem using sf=ShapeFix_Wire(). > But sf.Perform() always fails, even if the wire is without problems (using > vertex definitions as in the line which is commented out). > > What is the simplest solution to generate a face from self-intersecting wires > _automatically_? In my example, the small loop could be collapsed to a single > vertex, or the wire could be split into two (the large loop and the small > loop) > - both solutions would be fine. > How about OCC's ShapeHealing functions? Are they more powerful than ShapeFix? > I > don't understand the relation between ShapeFix and ShapeHealing. Is > ShapeHealing > available in the non-commercial OCC distribution? > > > Thank you > Björn > > --- code example: --- > from OCC.BRepBuilderAPI import * > from OCC.gp import * > from OCC.ShapeFix import * > from OCC.TopoDS import * > > def fixWire(wire): > sf=ShapeFix_Wire() > sf.Load(wire) > sf.SetFixIntersectingEdgesMode(1) > sf.SetFixNonAdjacentIntersectingEdgesMode(1) > sf.SetFixSelfIntersectingEdgeMode(1) > if sf.Perform(): >print 'Fix Successful' >return sf.Wire() > else: >print 'Fix Unsuccessful' >return wire > > def vertex(x,y,z): > mv=BRepBuilderAPI_MakeVertex(gp_Pnt(x,y,z)) > return mv.Vertex() > def edge(v1,v2): > me=BRepBuilderAPI_MakeEdge(v1,v2) > return me.Edge() > def face(w): > mf=BRepBuilderAPI_MakeFace(w) > return mf.Face() > def wire(e1,e2,e3,e4): > mw=BRepBuilderAPI_MakeWire(e1) > mw.Add(e2); mw.Add(e3); mw.Add(e4); > return mw.Wire() > > v=[vertex(0,0,0),vertex(1,0,0),vertex(0.95,1,0),vertex(1,1,0)] #self > intersecting, no face visible > #v=[vertex(0,0,0),vertex(1,0,0),vertex(1,1,0),vertex(0.9,1,0)] #valid wire > e=[] > for i in range(4): > e.append(edge(v[i-1],v[i])) > w=wire(e[0],e[1],e[2],e[3]) > f=face(fixWire(w)) > > from OCC.Display.SimpleGui import * > display, start_display, add_menu, add_function_to_menu = init_display() > display.DisplayShape([w,f]) > start_display() > > > > > > ___ > Pythonocc-users mailing list > Pythonocc-users@gna.org > https://mail.gna.org/listinfo/pythonocc-users ___ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users