pythonCascade Sample Problems

 Geometry: Distance between geometric objects

 

        array1 = []

        array1.append(gp_Pnt (-5,1,2))

        array1.append(gp_Pnt(-5,2,2))            

        array1.append(gp_Pnt(-5.3,3,1))

        array1.append(gp_Pnt(-5,4,1))

        array1.append(gp_Pnt(-5,5,2))

        SPL1 = GeomAPI_PointsToBSpline(array1).Curve()

                                                                                     

        array2 = []                                    

        array2.append(gp_Pnt(4,1,2))

        array2.append(gp_Pnt(4,2,2))

        array2.append(gp_Pnt(3.7,3,1))

        array2.append(gp_Pnt(4,4,1))

        array2.append(gp_Pnt(4,5,2))

        SPL2 = GeomAPI_PointsToBSpline(array2).Curve()

            

        Type = GeomFill_StretchStyle

 

        aGeomFill1 = GeomFill_BSplineCurves(SPL1,SPL2,Type)

        aSurf1 = aGeomFill1.Surface()

 

        array3 = []

 

        array3.append([gp_Pnt (-4,-4,5),gp_Pnt (-4,-2,5),gp_Pnt (-4,0,4),gp_Pnt (-4,2,5),gp_Pnt (-4,4,5)])

        array3.append([gp_Pnt (-2,-4,4),gp_Pnt (-2,-2,4),gp_Pnt (-2,0,4),gp_Pnt (-2,2,4),gp_Pnt (-2,5,4)])

        array3.append([gp_Pnt (0,-4,3.5),gp_Pnt (0,-2,3.5),gp_Pnt (0,0,3.5),gp_Pnt (0,2,3.5),gp_Pnt (0,5,3.5)])

        array3.append([gp_Pnt (2,-4,4),gp_Pnt (2,-2,4),gp_Pnt (2,0,3.5),gp_Pnt (2,2,5),gp_Pnt (2,5,4)])

        array3.append([gp_Pnt (4,-4,5),gp_Pnt (4,-2,5),gp_Pnt (4,0,5),gp_Pnt (4,2,6),gp_Pnt (4,5,5)])

 

                      

        aSurf2 = GeomAPI_PointsToBSplineSurface(array3).Surface()

 

        ESS = GeomAPI_ExtremaSurfaceSurface(aSurf1,aSurf2)

        dist = ESS.LowerDistance()

        P1,P2 = ESS.NearestPoints()

 

        NbExtrema = ESS.NbExtrema()

        for k in range(1,NbExtrema+1):

            P3,P4 = ESS.Points(k)                                     

            aCurve= GC_MakeSegment(P3,P4).Value()

            self.DisplayCurve(aCurve,1)

    

        self.DisplaySurface(aSurf1,1,color = Quantity_NOC_GREEN)

        self.DisplaySurface(aSurf2,1,color = Quantity_NOC_HOTPINK)

        self.DisplayCurve(SPL1,0,Quantity_NOC_RED)

        self.DisplayCurve(SPL2,0,Quantity_NOC_AZURE)

 

        self.DisplayPoint(P1,"P1",0,0,0,0,0.5)

        self.DisplayPoint(P2,"P2",0,0,0,0,0.5)