Exemplo n.º 1
0
 def test_points_from_intersection(self):
     '''Test: points from intersection'''
     PL = gp_Pln(gp_Ax3(gp_XOY()))
     MinorRadius, MajorRadius = 5, 8
     EL = gp_Elips(gp_YOZ(), MajorRadius, MinorRadius)
     ICQ = IntAna_IntConicQuad(EL, PL, precision_Angular(),
                               precision_Confusion())
     if ICQ.IsDone():
         NbResults = ICQ.NbPoints()
         if NbResults > 0:
             for i in range(1, NbResults + 1):
                 P = ICQ.Point(i)
                 self.assertIsInstance(P, gp_Pnt)
     aPlane = GC_MakePlane(PL).Value()
     aSurface = Geom_RectangularTrimmedSurface(aPlane, -8., 8., -12., 12.,
                                               True, True)
     self.assertIsNotNone(aSurface)
     self.assertFalse(aSurface.IsNull())
     anEllips = GC_MakeEllipse(EL).Value()
     self.assertIsInstance(anEllips, Geom_Ellipse)
     if ICQ.IsDone():
         NbResults = ICQ.NbPoints()
         if NbResults > 0:
             for i in range(1, NbResults + 1):
                 P = ICQ.Point(i)
                 self.assertIsInstance(P, gp_Pnt)
Exemplo n.º 2
0
def points_from_intersection():
    '''
    @param display:
    '''
    plane = gp_Pln(gp_Ax3(gp_XOY()))
    minor_radius, major_radius = 5., 8.
    ellips = gp_Elips(gp_YOZ(), major_radius, minor_radius)
    intersection = IntAna_IntConicQuad(ellips, plane, precision_Angular(),
                                       precision_Confusion())
    a_plane = GC_MakePlane(plane).Value()
    a_surface = Geom_RectangularTrimmedSurface(a_plane, -8., 8., -12., 12.,
                                               True, True)
    display.DisplayShape(a_surface, update=True)

    anEllips = GC_MakeEllipse(ellips).Value()
    display.DisplayShape(anEllips)

    if intersection.IsDone():
        nb_results = intersection.NbPoints()
        if nb_results > 0:
            for i in range(1, nb_results + 1):
                P = intersection.Point(i)
                pstring = "P%i" % i
                display.DisplayShape(P)
                display.DisplayMessage(P, pstring)
def draft_angle(event=None):
    S = BRepPrimAPI_MakeBox(200., 300., 150.).Shape()
    adraft = BRepOffsetAPI_DraftAngle(S)
    topExp = TopExp_Explorer()
    topExp.Init(S, TopAbs_FACE)
    while topExp.More():
        face = topods_Face(topExp.Current())
        surf = Handle_Geom_Plane_DownCast(BRep_Tool_Surface(face)).GetObject()
        dirf = surf.Pln().Axis().Direction()
        ddd = gp_Dir(0, 0, 1)
        if dirf.IsNormal(ddd, precision_Angular()):
            adraft.Add(face, ddd, math.radians(15), gp_Pln(gp_Ax3(gp_XOY())))
        topExp.Next()
    adraft.Build()
    display.DisplayShape(adraft.Shape(), update=True)
 def test_points_from_intersection(self):
     '''Test: points from intersection'''
     PL = gp_Pln(gp_Ax3(gp_XOY()))
     MinorRadius, MajorRadius = 5, 8
     EL = gp_Elips(gp_YOZ(), MajorRadius, MinorRadius)
     ICQ = IntAna_IntConicQuad(EL, PL, precision_Angular(), precision_Confusion())
     if ICQ.IsDone():
         NbResults = ICQ.NbPoints()
         if NbResults > 0:
             for i in range(1, NbResults + 1):
                 P = ICQ.Point(i)
                 self.assertIsInstance(P, gp_Pnt)
     aPlane = GC_MakePlane(PL).Value()
     aSurface = Geom_RectangularTrimmedSurface(aPlane, - 8., 8., - 12., 12., True, True)
     self.assertIsNotNone(aSurface)
     self.assertFalse(aSurface.IsNull())
     anEllips = GC_MakeEllipse(EL).Value()
     self.assertIsInstance(anEllips, Geom_Ellipse)
     if ICQ.IsDone():
         NbResults = ICQ.NbPoints()
         if NbResults > 0:
             for i in range(1, NbResults + 1):
                 P = ICQ.Point(i)
                 self.assertIsInstance(P, gp_Pnt)
Exemplo n.º 5
0
my_renderer = JupyterRenderer()

# Generation of a box

# In[4]:

S = BRepPrimAPI_MakeBox(20., 30., 15.).Shape()

# Apply a draft angle.

# In[5]:

adraft = BRepOffsetAPI_DraftAngle(S)
topExp = TopExp_Explorer()
topExp.Init(S, TopAbs_FACE)
while topExp.More():
    face = topods_Face(topExp.Current())
    surf = Geom_Plane.DownCast(BRep_Tool_Surface(face))
    dirf = surf.Pln().Axis().Direction()
    ddd = gp_Dir(0, 0, 1)
    if dirf.IsNormal(ddd, precision_Angular()):
        adraft.Add(face, ddd, math.radians(15), gp_Pln(gp_Ax3(gp_XOY())))
    topExp.Next()
adraft.Build()
shp = adraft.Shape()

# In[6]:

my_renderer.DisplayShape(shp, render_edges=True, update=True)