コード例 #1
0
    def __init__(self, shape1, shape2, pnt=None, tol=-1.):
        shape = IntersectShapes(shape1, shape2).shape

        pnt = CheckGeom.to_point(pnt)

        self._found = False
        self._pln = None
        if pnt is None:
            tool = PlaneByEdges(shape, tol)
            self._found = tool.found
            self._pln = tool.plane
        elif CheckGeom.is_point(pnt):
            edges = shape.edges
            pnts = [pnt]
            for edge in edges:
                BRepMesh_IncrementalMesh(edge.object, 0.001)
                loc = TopLoc_Location()
                poly3d = BRep_Tool.Polygon3D_(edge.object, loc)
                if poly3d.NbNodes == 0:
                    continue
                tcol_pnts = poly3d.Nodes()
                for i in range(1, tcol_pnts.Length() + 1):
                    gp_pnt = tcol_pnts.Value(i)
                    pnt = CheckGeom.to_point(gp_pnt)
                    pnts.append(pnt)
            if len(pnts) < 3:
                raise ValueError('Less than three points to fit a plane.')
            if tol < 0.:
                tol = 1.0e-7
            tool = PlaneByApprox(pnts, tol)
            self._found = True
            self._pln = tool.plane
        else:
            raise TypeError('Invalid input.')
コード例 #2
0
ファイル: check.py プロジェクト: gitter-badger/AFEM
    def __init__(self, solid, pnt=None, tol=1.0e-7):
        pnt = CheckGeom.to_point(pnt)

        if not CheckGeom.is_point(pnt):
            self._tool = BRepClass3d_SolidClassifier(solid.object)
        else:
            self._tool = BRepClass3d_SolidClassifier(solid.object, pnt, tol)