예제 #1
0
def getShapeSkin(pntStart, wires, pntEnd):

    # Initialize and build
    skiner = BRepOffsetAPI_ThruSections()
    skiner.SetSmoothing(True)
    #skiner.SetMaxDegree(5)

    vstart = BRepBuilderAPI_MakeVertex(pntStart).Vertex()
    skiner.AddVertex(vstart)

    for wire in wires:
        skiner.AddWire(wire)

    vend = BRepBuilderAPI_MakeVertex(pntEnd).Vertex()
    skiner.AddVertex(vend)

    skiner.Build()

    return skiner.Shape()
예제 #2
0
    def getDaoSkinningSurface(self, offset):

        limitPoints = self.getCached('getDaoOffsetPoints', offset)
        beginPoint = limitPoints['Begin']
        endPoint = limitPoints['End']

        skinner = BRepOffsetAPI_ThruSections(True)
        skinner.SetSmoothing(True)

        beginVertex = BRepBuilderAPI_MakeVertex(beginPoint).Vertex()
        skinner.AddVertex(beginVertex)

        ks = self.aSkinningSlicesKs
        for i in range(len(ks)):
            sliceWire = self.getCached('getDaoSliceWire', offset, ks[i])
            skinner.AddWire(sliceWire)

        endVertex = BRepBuilderAPI_MakeVertex(endPoint).Vertex()
        skinner.AddVertex(endVertex)

        skinner.Build()
        surface = skinner.Shape()

        return surface
예제 #3
0
class LoftShape(object):
    """
    Loft a shape using a sequence of sections.

    :param sections: The sections of the loft. These
        are usually wires but the first and last section can be vertices.
        Edges are converted to wires before adding to the loft tool.
    :type sections: collections.Sequence(afem.topology.entities.Vertex or
        afem.topology.entities.Edge or afem.topology.entities.Wire)
    :param bool is_solid: If *True* the tool will build a solid, otherwise
        it will build a shell.
    :param bool make_ruled: If *True* the faces between sections will be ruled
        surfaces, otherwise they are smoothed out by approximation.
    :param float pres3d: Defines the precision for the approximation algorithm.
    :param bool check_compatibility: Option to check the orientation of the
        sections to avoid twisted results and update to have the same number
        of edges.
    :param bool use_smoothing: Option to use approximation algorithm.
    :param OCC.Core.Approx.Approx_ParametrizationType par_type: Parametrization
        type.

    :param OCC.Core.GeomAbs.GeomAbs_Shape continuity: The desired continuity.
    :param int max_degree: The maximum degree for the approximation
        algorithm.

    :raise TypeError: If any of the sections cannot be added to the tool
        because they are of the wrong type.
    """
    def __init__(self,
                 sections,
                 is_solid=False,
                 make_ruled=False,
                 pres3d=1.0e-6,
                 check_compatibility=None,
                 use_smoothing=None,
                 par_type=None,
                 continuity=None,
                 max_degree=None):
        self._tool = BRepOffsetAPI_ThruSections(is_solid, make_ruled, pres3d)

        if check_compatibility is not None:
            self._tool.CheckCompatibility(check_compatibility)

        if use_smoothing is not None:
            self._tool.SetSmoothing(use_smoothing)

        if par_type is not None:
            self._tool.SetParType(par_type)

        if continuity is not None:
            self._tool.SetContinuity(continuity)

        if max_degree is not None:
            self._tool.SetMaxDegree(max_degree)

        for section in sections:
            if section.is_vertex:
                self._tool.AddVertex(section.object)
            elif section.is_edge:
                wire = Wire.by_edge(section)
                self._tool.AddWire(wire.object)
            elif section.is_wire:
                self._tool.AddWire(section.object)
            else:
                raise TypeError('Invalid shape type in loft.')

        self._tool.Build()

    @property
    def is_done(self):
        """
        :return: *True* if done, *False* if not.
        :rtype: bool
        """
        return self._tool.IsDone()

    @property
    def shape(self):
        """
        :return: The lofted shape.
        :rtype: afem.topology.entities.Shape
        """
        return Shape.wrap(self._tool.Shape())

    @property
    def first_shape(self):
        """
        :return: The first/bottom shape of the loft if a solid was
            constructed.
        :rtype: afem.topology.entities.Shape
        """
        return Shape.wrap(self._tool.FirstShape())

    @property
    def last_shape(self):
        """
        :return: The last/top shape of the loft if a solid was constructed.
        :rtype: afem.topology.entities.Shape
        """
        return Shape.wrap(self._tool.LastShape())

    @property
    def max_degree(self):
        """
        :return: The max degree used in the approximation algorithm
        :rtype: int
        """
        return self._tool.MaxDegree()

    def generated_face(self, edge):
        """
        Get a face(s) generated by the edge. If the ruled option was used,
        then this returns each face generated by the edge. If the smoothing
        option was used, then this returns the face generated by the edge.

        :param afem.topology.entities.Edge edge: The edge.

        :return: The face(s) generated by the edge.
        :rtype: afem.topology.entities.Shape
        """
        return Shape.wrap(self._tool.GeneratedFace(edge.object))
예제 #4
0
    fc1 = obj.make_FaceByOrder(pts)
    fc1.Location(set_loc(gp_Ax3(), ax1))
    print(fc1)
    obj.display.DisplayShape(br1)
    obj.display.DisplayShape(fc1)

    ax2 = gp_Ax3()
    ax2.SetLocation(gp_Pnt(0, 0, 25))
    pt2 = np.loadtxt(obj.rootname + "_pln2.txt")
    print(pt2)
    pts = []
    for xyz in pt2 + [pt2[0]]:
        pts.append(gp_Pnt(*xyz))
    br2 = make_polygon(pts, closed=True)
    br2.Location(set_loc(gp_Ax3(), ax2))
    fc2 = obj.make_FaceByOrder(pts)
    fc2.Location(set_loc(gp_Ax3(), ax2))
    print(fc2)
    obj.display.DisplayShape(br2)
    obj.display.DisplayShape(fc2)

    api = BRepOffsetAPI_ThruSections()
    api.SetSmoothing(True)
    api.AddWire(br1)
    api.AddWire(br2)
    api.Build()
    shp = api.Shape()
    obj.display.DisplayShape(shp)
    #obj.export_stp(shp)
    obj.show()