Hi Tomasz, You can try to use BRepAlgo_Fuse to merge your aBSplineSurface2 and aBSplineSurface3 shapes.
Cheers, Thomas TOMASZ GARSTKA a écrit : > I have just defined onother interesting test case. I have two surfaces > that are in contact with each other. Is there a possibility of joining > them together so that after importing them to another package there > is no boundry in between them? > > Here is the code I have modyfied: > > > #!/usr/bin/env python > ##Copyright 2009 Jelle Ferina (jelleferi...@gmail.com > <mailto:jelleferi...@gmail.com>) > ## > ##This file is part of pythonOCC. > ## > ##pythonOCC is free software: you can redistribute it and/or modify > ##it under the terms of the GNU General Public License as published by > ##the Free Software Foundation, either version 3 of the License, or > ##(at your option) any later version. > ## > ##pythonOCC is distributed in the hope that it will be useful, > ##but WITHOUT ANY WARRANTY; without even the implied warranty of > ##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > ##GNU General Public License for more details. > ## > ##You should have received a copy of the GNU General Public License > ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. > ''' > refactor: > range(1,NbSol+1) -> range(NbSol) > "a string"+`i` -> "a string %s" % (i) > > TODO: > *curves3d_from_points doesnt work well; missing a spline > *make_text is a TOTAL joke... completely unacceptable... > *in the bspline example, the conversion from a list to TColgp_* > fails somehow... > usually the call to _Tcol_* seems to work, not here though... > *630: circle not rendered > *pipes gives terrible results... > *1109 converting list to TCol* flips... > ''' > from OCC.gp import * > from OCC.Geom2d import * > from OCC.Geom2dAdaptor import * > from OCC.Geom2dAPI import * > from OCC.GCPnts import * > > # gui > #from examples_gui import display, loop > from OCC.Geom import * > from OCC.GeomAPI import * > from OCC.Precision import * > # stands for intersections analytical > from OCC.IntAna import * > from OCC.GC import * > from OCC.GCE2d import * > from OCC.Geom2dConvert import * > from OCC.TopAbs import * > from OCC.GccEnt import * > from OCC.gce import * > from OCC.GccAna import * > from OCC.Quantity import * > from OCC.GeomConvert import * > from OCC.TColGeom import * > from OCC.BRepBuilderAPI import * > from OCC.Graphic2d import * > from OCC.TCollection import * > from OCC.Graphic3d import * > from OCC.BRepPrimAPI import * > from OCC.AIS import * > from OCC.Prs3d import * > from OCC.TColgp import * > from OCC.GeomFill import * > from OCC import IGESControl > from OCC.Display.wxSamplesGui import display > import time, sys > > #=============================================================================== > # Utility functions > #=============================================================================== > > def _Tcol_dim_1(li, _type): > '''function factory for 1-dimensional TCol* types''' > pts = _type(0, len(li)-1) > for n,i in enumerate(li): > pts.SetValue(n,i) > pts.thisown = False > return pts > def _Tcol_dim_2(li, _type): > '''function factory for 2-dimensional TCol* types''' > length_nested = len(li[0])-1 > pts = _type(0, len(li)-1, 0, length_nested) > pts.thisown = False > return pts > for n1,i in enumerate(li): > for n2,j in enumerate(i): > pts.SetValue(n1,n2,j) > return pts > def point_list_to_TColgp_Array1OfPnt(li): > pts = TColgp_Array1OfPnt(0, len(li)-1) > for n,i in enumerate(li): > pts.SetValue(n,i) > return pts > def point2d_list_to_TColgp_Array1OfPnt2d(li): > return _Tcol_dim_1(li, TColgp_Array1OfPnt2d) > # graphic; point annotations > #def circle_marker(pnt): > # aGraphObj = Graphic2d_GraphicObject() > # return Graphic2d_CircleMarker(aGraphObj.GetHandle(), i.X(), > i.Y(), 0, 0, 1) > # > #def text_marker_2d(txt): > # aGraphObj = Graphic2d_GraphicObject() > # string = TCollection_ExtendedString('jelle') > # return Graphic2d_Text(aGraphObj.GetHandle(), string, 0, 1) > # > #def text_marker_3d(txt): > # pass > # This is all crap that should not be here. > # It should be cleaned up the moment we have a Visual3d wrapper > > def make_text(string, pnt, height): > ''' > render a bunch of text > @param string: string to be rendered > @param pnt: location of the string > @param myGroup:OCC.Graphic3d.Graphic3d_Group instance > @param height: max height > ''' > global display > # returns a Handle_Visual3d_ViewManager instance > # the only thing is that you need the Visual3d class to make this > work well > # now we have to make a presenation for a stupid sphere as a > workaround to get to the object > # viewer = > display.GetContext().GetObject().CurrentViewer().GetObject().Viewer() > # hstruct = Graphic3d_Structure(viewer) > #=============================================================================== > # STOOPID!! > # The reason for recreating is that myGroup is gone after an > EraseAll call > #=============================================================================== > stupid_sphere = BRepPrimAPI_MakeSphere(1,1,1,1) > prs_sphere = AIS_Shape(stupid_sphere.Shape()) > d_ctx = display.GetContext().GetObject() > prsMgr = d_ctx.CollectorPrsMgr().GetObject() > d_ctx.Display(prs_sphere.GetHandle(), 1) > aPresentation = > prsMgr.CastPresentation(prs_sphere.GetHandle()).GetObject() > global myGroup > myGroup = > Prs3d_Root().CurrentGroup(aPresentation.Presentation()).GetObject() > #=============================================================================== > # FINE > #=============================================================================== > _string = TCollection_ExtendedString(string) > if isinstance( pnt, gp.gp_Pnt2d): > _vertex = Graphic3d_Vertex(pnt.X(), pnt.Y(), 0) > else: > _vertex = Graphic3d_Vertex(pnt.X(), pnt.Y(), pnt.Z()) > myGroup.Text(_string, _vertex, height) > > def make_edge2d(shape): > spline = BRepBuilderAPI_MakeEdge2d(shape) > spline.Build() > spline.thisown = False > return spline.Shape() > def make_edge(shape): > spline = BRepBuilderAPI_MakeEdge(shape) > spline.Build() > spline.thisown = False > return spline.Shape() > def make_vertex(pnt): > if isinstance(pnt, gp.gp_Pnt2d): > vertex = BRepBuilderAPI_MakeVertex( gp_Pnt(pnt.X(), pnt.Y(), 0)) > else: > vertex = BRepBuilderAPI_MakeVertex( pnt ) > vertex.Build() > vertex.thisown = False > return vertex.Shape() > def make_face(shape): > face = BRepBuilderAPI_MakeFace(shape) > face.Build() > face.thisown = False > return face.Shape() > > #=============================================================================== > # Examples > #=============================================================================== > def surface_from_curves(event=None): > ''' > @param display: > ''' > display.EraseAll() > array = [] > array.append(gp_Pnt(0,0,0 > )) > array.append(gp_Pnt(10,0,5 > )) > array.append(gp_Pnt(20,0,0 > )) > > aaa = point_list_to_TColgp_Array1OfPnt(array) > SPL1 = GeomAPI_PointsToBSpline(aaa).Curve() > SPL1_c = SPL1.GetObject() > > a2 = [] > > a2.append(gp_Pnt(20,0,0)) > > > > a2.append(gp_Pnt(20,10,-5)) > > > > a2.append(gp_Pnt(20,20,0)) > > > bbb = point_list_to_TColgp_Array1OfPnt(a2) > SPL2 = GeomAPI_PointsToBSpline(bbb).Curve() > SPL2_c = SPL2.GetObject() > > a3 = [] > > a3.append(gp_Pnt(20,20,0)) > > > > a3.append(gp_Pnt(10,20,5)) > > > > a3.append(gp_Pnt(0,20,0)) > > > ccc = point_list_to_TColgp_Array1OfPnt(a3) > SPL3 = GeomAPI_PointsToBSpline(ccc).Curve() > SPL3_c = SPL3.GetObject() > a4 = [] > > a4.append(gp_Pnt(0,20,0)) > > > > a4.append(gp_Pnt(0,10,-5)) > > > a4.append(gp_Pnt(0,0,0)) > > > ddd = point_list_to_TColgp_Array1OfPnt(a4) > SPL4 = GeomAPI_PointsToBSpline(ddd).Curve() > SPL4_c = SPL4.GetObject() > > > a5= [] > > a5.append(gp_Pnt(20,-20,0)) > > > > a5.append(gp_Pnt(10,-20,0)) > > > a5.append(gp_Pnt(0,-20,0)) > > eee = point_list_to_TColgp_Array1OfPnt(a5) > SPL5 = GeomAPI_PointsToBSpline(eee).Curve() > SPL5_c = SPL5.GetObject() > > > a6= [] > > a6.append(gp_Pnt(20,-20,0)) > > > > a6.append(gp_Pnt(20,0,0)) > > > fff = point_list_to_TColgp_Array1OfPnt(a6) > SPL6 = GeomAPI_PointsToBSpline(fff).Curve() > SPL6_c = SPL6.GetObject() > a7= [] > > a7.append(gp_Pnt(0,0,0)) > > > > a7.append(gp_Pnt(0,-20,0)) > > > ggg = point_list_to_TColgp_Array1OfPnt(a7) > SPL7 = GeomAPI_PointsToBSpline(ggg).Curve() > SPL7_c = SPL7.GetObject() > > > > aGeomFill3 = GeomFill_BSplineCurves(SPL5, > SPL6, > SPL1, > SPL7, > GeomFill_CoonsStyle) > aGeomFill2 = GeomFill_BSplineCurves(SPL1, > SPL2, > SPL3, > SPL4, > GeomFill_CoonsStyle) > > > > #SPL3 = > Handle_Geom_BSplineCurve().DownCast(SPL1_c.Translated(gp_Vec(10,0,0))) > #SPL4 = > Handle_Geom_BSplineCurve().DownCast(SPL2_c.Translated(gp_Vec(10,0,0))) > #aGeomFill2 = GeomFill_BSplineCurves(SPL3, > # SPL4, > # GeomFill_CoonsStyle) > > #SPL5 = > Handle_Geom_BSplineCurve().DownCast(SPL1_c.Translated(gp_Vec(20,0,0))) > #SPL6 = > Handle_Geom_BSplineCurve().DownCast(SPL2_c.Translated(gp_Vec(20,0,0))) > #aGeomFill3 = GeomFill_BSplineCurves(SPL5, > # SPL6, > # GeomFill_CurvedStyle) > > #aBSplineSurface1 = aGeomFill1.Surface() > #display.DisplayShape(make_face(aBSplineSurface1)) > aBSplineSurface2 = aGeomFill2.Surface() > display.DisplayShape(make_face(aBSplineSurface2)) > > aBSplineSurface3 = aGeomFill3.Surface() > display.DisplayShape(make_face(aBSplineSurface3)) > # def export(event=None): > > # > # Export result to IGES file > # > > i = IGESControl.IGESControl_Controller() > i.Init() > iges_writer = IGESControl.IGESControl_Writer() > iges_writer.AddShape(make_face(aBSplineSurface2)) > iges_writer.AddShape(make_face(aBSplineSurface3)) > iges_writer.Write("./surface_two_surf.iges") > > > #aBSplineSurface3 = aGeomFill3.Surface() > #display.DisplayShape(make_face(aBSplineSurface3)) > > # annotate > #make_text("GeomFill_StretchStyle", SPL1_c.StartPoint(), 6) > #make_text("GeomFill_CoonsStyle", SPL3.GetObject().StartPoint(), 6) > #make_text("GeomFill_CurvedStyle", SPL5.GetObject().StartPoint(), 6) > > #for i in range(0,3): > # aCurve1 = > ISession_Curve(Geom_Curve().DownCast(SPL1.Translated(gp_Vec(i * 10,0,0)))) > # display.interactive_context.SetDisplayMode(aCurve1,0,1) > # display.interactive_context.SetColor(aCurve1,Quantity_NOC_RED,1) > # aCurve1.Attributes().LineAspect().SetColor(Quantity_NOC_RED) > # display.interactive_context.Display(aCurve1,1) > # aCurve2 = > ISession_Curve(Geom_Curve().DownCast(SPL2.Translated(gp_Vec(i * 10,0,0)))) > # display.interactive_context.SetDisplayMode(aCurve2,0,1) > # > display.interactive_context.SetColor(aCurve2,Quantity_NOC_GREEN,1) > # aCurve1.Attributes().LineAspect().SetColor(Quantity_NOC_GREEN) > # display.interactive_context.Display(aCurve2,1) > > def exit(event=None): > sys.exit() > if __name__ == '__main__': > from OCC.Display.wxSamplesGui import add_function_to_menu, > add_menu, start_display > add_menu('geometry') > for f in [surface_from_curves, > exit > ]: > add_function_to_menu('geometry', f) > start_display() > > > > > > > > > Thanks, > > > Tomasz > > > > > > > > > > > > Date: Sat, 18 Apr 2009 14:00:42 +0200 > > From: thomas.pav...@free.fr > > To: tomasz_gars...@hotmail.com; pythonocc-users@gna.org > > Subject: Re: [Pythonocc-users] new geometry demos > > > > Hi Tomasz, > > > > Could you be more precise with the error message you get? How did you > > obtain SPL1, SPL2, SPL3 and SPL4? > > > > Cheers, > > > > Thomas > > > > TOMASZ GARSTKA a écrit : > > > Hi, > > > I am trying to define a surface based on 4 splines. In the new > > > geometry demos you show how do do this with two splines. When I try > > > to aplly this method using 4 splines: > > > > > > aGeomFill1 = GeomFill_BSplineCurves(SPL1, > > > SPL2, > > > SPL3, > > > SPL4 > > > GeomFill_StretchStyle) > > > > > > i am ending up with an error message. > > > > > > Thanks > > > > > > Tomasz > > > > > > > > > > > > > > > > > > > > > > Date: Mon, 23 Mar 2009 17:21:50 +0100 > > > > From: thomas.pav...@free.fr > > > > To: tomasz_gars...@hotmail.com > > > > CC: pythonocc-users@gna.org > > > > Subject: Re: [Pythonocc-users] new geometry demos > > > > > > > > Hi Tomasz, > > > > > > > > The md0.1 release is only one month old but is already widely > > > deprecated. The geo_examples.py you try to run is not included in the > > > pythonOCC-md0.1 demos. Where does this file come from?? > > > > > > > > Note that if you want to run the samples that have been recently > > > added, you'll need to compile your own pythonOCC. Or wait for the > next > > > release... > > > > > > > > Cheers, > > > > > > > > Thomas > > > > > > > > >I am having a small problem running new geometry demos. > > > > > > > > > >I am getting the follwing error message: > > > > > > > > > >Traceback (most recent call last): > > > > >File > > > > "E:\tomasz\opencascade\occ_demo\pythonOCC-md0.1-demos\tests\geo_examples.py", > > > > line 33, in <module> > > > > >from OCC.IntAna import * > > > > >ImportError: No module named IntAna > > > > > > > > > >when I hash this line "from OCC.GC import * " I can get to GUI but > > > most of the selections result in error. > > > > > > > > > >Any comments, > > > > > > > > > > > > > > >Thanks, > > > > > > > > > > > > > > >Tomasz > > > > > > > > > >> Date: Mon, 23 Mar 2009 05:59:45 +0100 > > > > >> From: thomas.pav...@free.fr > > > > >> To: jelleferi...@gmail.com > > > > >> CC: pythonocc-users@gna.org > > > > >> Subject: Re: [Pythonocc-users] new geometry demos > > > > >> > > > > >> Hi, > > > > >> > > > > >> Jelle's geometry demos are now available on SVN repository (rev. > > > 177). > > > > >> > > > > >> Thomas > > > > >> > > > > >> Jelle Feringa a écrit : > > > > >> > > > > > >> > Hi, > > > > >> > > > > > >> > I'm pretty much done converting the geometry demos of the > > > Standard MFC > > > > >> > examples that come with OCC. > > > > >> > Pretty good news, that means that together with the demos > Thomas > > > > >> > already completed we're getting a nice set of examples. > > > > >> > > > > > >> > We'll add the demo to the SVN one of these days, it still > needs > > > polish > > > > >> > ( its using Display calls that are out of sync with the SVN > > > version, > > > > >> > undifferentiated graphics, there are some really ugly > functions > > > ) but > > > > >> > here you have some idea of what it is about. > > > > >> > > > > > >> > I hope to start working on the pythonic API of pythonOCC soon, > > > though > > > > >> > not before finishing a lot of demos, I guess its a better > order. > > > > >> > If anyone feels like helping out on converting the demos on > > > > >> > http://www.opencascade.org/showroom/demos/ that would be > > > wonderful ( > > > > >> > I'm starting on the left column ). > > > > >> > Getting the demos out is important, since it'll help > communicating > > > > >> > what pythonOCC is about a lot. > > > > >> > After converting existing demos its time to get creative and > > > think of > > > > >> > a bunch of original ones. > > > > >> > > > > > >> > Cheers, > > > > >> > > > > > >> > -jelle > > > > >> > > > > > > > > ------------------------------------------------------------------------ > > > Share your photos with Windows Live Photos – Free. Try it Now! > > > <http://clk.atdmt.com/UKM/go/134665338/direct/01/> > > ------------------------------------------------------------------------ > Get the New Internet Explore 8 Optimised for MSN. Download Now > <http://extras.uk.msn.com/internet-explorer-8/?ocid=T010MSN07A0716U> _______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users