コード例 #1
0
    def pln_on_face(self, face=TopoDS_Face()):
        face_adaptor = BRepAdaptor_Surface(face)
        face_trf = face_adaptor.Trsf()
        face_pln = face_adaptor.Plane()
        #face_dir = face_adaptor.Direction()

        face_umin = face_adaptor.FirstUParameter()
        face_vmin = face_adaptor.FirstVParameter()
        face_umax = face_adaptor.LastUParameter()
        face_vmax = face_adaptor.LastVParameter()
        face_u = (face_umax + face_umin) / 2
        face_v = (face_vmax + face_vmin) / 2
        face_pnt = face_adaptor.Value(face_u, face_v)

        return face_pln
コード例 #2
0
ファイル: mesher_v2.py プロジェクト: neszenz/prototypes
    def sample_interior(face_mesh):
        vertices, _, _, face = face_mesh

        additional_vertices = []

        surface = BRepAdaptor_Surface(face)
        FU = surface.FirstUParameter()
        LU = surface.LastUParameter()
        FV = surface.FirstVParameter()
        LV = surface.LastVParameter()

        U_LENGTH = LU - FU
        V_LENGTH = LV - FV

        if INTERIOR_SAMPLING_METHOD == INTERIOR_GRID:
            for u_index in range(1, GRID_U_SAMPLES + 1):
                for v_index in range(1, GRID_V_SAMPLES + 1):
                    u_offset = U_OFFSET_FACTOR / (GRID_U_SAMPLES + 1)
                    v_offset = V_OFFSET_FACTOR / (GRID_V_SAMPLES + 1)
                    u = FU + ((u_index /
                               (GRID_U_SAMPLES + 1)) + u_offset) * U_LENGTH
                    v = FV + ((v_index /
                               (GRID_V_SAMPLES + 1)) + v_offset) * V_LENGTH

                    sv_add = SuperVertex(u=u, v=v, same_as=vertices[0])
                    sv_add.project_to_XYZ()
                    additional_vertices.append(sv_add)
        elif INTERIOR_SAMPLING_METHOD == INTERIOR_RANDOM:
            for i in range(RANDOM_SAMPLES):
                rand0 = random.randint(
                    1, RANDOM_RESOLUTION - 1) / RANDOM_RESOLUTION
                rand1 = random.randint(
                    1, RANDOM_RESOLUTION - 1) / RANDOM_RESOLUTION
                u = FU + rand0 * U_LENGTH
                v = FV + rand1 * V_LENGTH

                sv_add = SuperVertex(u=u, v=v, same_as=vertices[0])
                sv_add.project_to_XYZ()
                additional_vertices.append(sv_add)
        else:
            raise Exception(
                'sample_interior() error - INTERIOR_SAMPLING_METHOD unknown')

        return additional_vertices
コード例 #3
0
  def makeHelixOnCyl(self):
    bas = BRepAdaptor_Surface(self.face)
    cyl = bas.Cylinder()

    delta_v = bas.LastVParameter() - bas.FirstVParameter()
    v_final = bas.LastVParameter()

    dv_du = self.pitch / (2*pi)
    l = delta_v / sin(atan(dv_du))

    aLine2d = gp_Lin2d(gp_Pnt2d(bas.FirstUParameter(),bas.FirstVParameter()), gp_Dir2d(1,dv_du))
    if not self.reverse_helix:
      aSegment = GCE2d_MakeSegment(aLine2d, 0.0, l)
    else:
      aSegment = GCE2d_MakeSegment(aLine2d, l, 0.0)

    helix_edge = BRepBuilderAPI_MakeEdge(aSegment.Value(), Geom_CylindricalSurface(cyl)).Edge()

    #self.aLine2d = aLine2d
    #self.aSegment = aSegment
    self.helix_edge = helix_edge
    return helix_edge