def test_harray1_harray2_hsequence(self):
     """ Check that special wrappers for harray1, harray2 and hsequence.
     Only check that related classes can be instanciated.
     """
     TopTools_HArray1OfShape(0, 3)
     TopTools_HArray2OfShape(0, 3, 0, 3)
     TopTools_HSequenceOfShape()
Esempio n. 2
0
    def __init__(self, edges, tol=None, shared=False):
        # Build
        hedges = TopTools_HSequenceOfShape()
        for e in edges:
            hedges.Append(e.object)

        if tol is None:
            tol = max([e.tol_max for e in edges])

        hwires = ShapeAnalysis_FreeBounds.ConnectEdgesToWires_(
            hedges, tol, shared)

        wires = []
        for i in range(1, hwires.Length() + 1):
            w = Wire(hwires.Value(i))
            wires.append(w)

        self._wires = wires
Esempio n. 3
0
def _get_list_from_compound(compound, sequence_type):
    assert isinstance(sequence_type, CompoundSequenceType)
    assert isinstance(compound, TopoDS_Compound) or isinstance(
        compound, TopoDS_Solid)
    compound_ = copy.deepcopy(compound)

    if isinstance(compound, TopoDS_Compound):
        se_exp = ShapeExtend_Explorer()
        shape_sequence = se_exp.SeqFromCompound(compound_, True)
        solids_sequence = TopTools_HSequenceOfShape()
        # Only the solids seem to be populated properly.
        # Need to use TopologyExplorer to get other features
        se_exp.DispatchList(shape_sequence, TopTools_HSequenceOfShape(),
                            TopTools_HSequenceOfShape(),
                            TopTools_HSequenceOfShape(),
                            TopTools_HSequenceOfShape(),
                            TopTools_HSequenceOfShape(), solids_sequence,
                            TopTools_HSequenceOfShape(),
                            TopTools_HSequenceOfShape())

        solids = [
            solids_sequence.Value(i)
            for i in range(1,
                           solids_sequence.Length() + 1)
        ]  # Indices start at 1 :(
    else:
        solids = [compound]

    faces = [f for solid in solids for f in TopologyExplorer(solid).faces()]

    if sequence_type == CompoundSequenceType.FACE:
        return faces
    elif sequence_type == CompoundSequenceType.SOLID:
        return solids
    else:
        raise ValueError("Invalid sequence type")