Example #1
0
def shapeOfMaxSize(list_of_shapes):
    """shapeOfMaxSize(list_of_shapes): finds the shape that has the largest mass in the list and returns it. The shapes in the list must be of same dimension."""
    #first, check if shapes can be compared by size
    ShapeMerge.dimensionOfShapes(list_of_shapes)
    
    rel_precision = 1e-8
    
    #find it!
    max_size = -1e100 # max size encountered so far
    count_max = 0 # number of shapes with size equal to max_size
    shape_max = None # shape of max_size
    for sh in list_of_shapes:
        v = abs(Part.cast_to_shape(sh).Mass)
        if v > max_size*(1 + rel_precision) :
            max_size = v
            shape_max = sh
            count_max = 1
        elif (1-rel_precision) * max_size <= v and v <= (1+rel_precision) * max_size :
            count_max = count_max + 1
    if count_max > 1 :
        raise ValueError("There is more than one largest piece!")
    return shape_max
Example #2
0
def shapeOfMaxSize(list_of_shapes):
    """shapeOfMaxSize(list_of_shapes): finds the shape that has the largest mass in the list and returns it. The shapes in the list must be of same dimension."""
    #first, check if shapes can be compared by size
    ShapeMerge.dimensionOfShapes(list_of_shapes)

    rel_precision = 1e-8

    #find it!
    max_size = -1e100 # max size encountered so far
    count_max = 0 # number of shapes with size equal to max_size
    shape_max = None # shape of max_size
    for sh in list_of_shapes:
        v = abs(Part.cast_to_shape(sh).Mass)
        if v > max_size*(1 + rel_precision) :
            max_size = v
            shape_max = sh
            count_max = 1
        elif (1-rel_precision) * max_size <= v and v <= (1+rel_precision) * max_size :
            count_max = count_max + 1
    if count_max > 1 :
        raise ValueError("There is more than one largest piece!")
    return shape_max
 def clean(self):
     """Clean faces by removing splitter edges."""
     r = self.wrapped.removeSplitter()
     # removeSplitter() returns a generic Shape type, cast to actual type of object
     r = FreeCADPart.cast_to_shape(r)
     return Shape.cast(r)
Example #4
0
 def clean(self):
     """Clean faces by removing splitter edges."""
     r = self.wrapped.removeSplitter()
     # removeSplitter() returns a generic Shape type, cast to actual type of object
     r = FreeCADPart.cast_to_shape(r)
     return Shape.cast(r)