Esempio n. 1
0
    def __init__(self, coords1=[], rad1=1.0, coords2=[], rad2=0.0, transform=[], fixed_points=[], sc = True):
        """conical( coords1:float list, rad1:float, coords2: float list, rad2: float,
        transform:(string, transformation_data) list, fixed_points: float list list , sc:bool).
        
        Creates a conical frustum given the centre of
        the bottom circumference, its radius, the upper circumference
        and its radius. The frustum is transformed following the order
        of the transformations specified in the transform list.
        Calling ai (i = 1,2,...) the axis of the space where the object is
        defined, examples of these transformations are:
        - ("shift", [a1,a2,a3,..]) 
        - ("scale", [a1,a2,a3,...])
        - ("rotate", [a1,a2], phi)
        - ("rotate2d", phi)
        - ("rotate3d", [a1,a2,a3], phi)
        If sc = False the transformations are made wrt the body coordinates,
        wrt the system coordinates otherwise.
        """

        dim = len(coords1) 
        mesh_obj.__init__(self,dim)

        print "cone"
        self.obj = ocaml.body_frustum(coords1,rad1,coords2,rad2)

        self.transformations(transform,sc)
Esempio n. 2
0
    def __init__(self,coords1=[],rad1=1.0,coords2=[],rad2=0.0,shifting=[],
                 outer_box = [], sc = True):
        """conical( coords1:float list, rad1:float, coords2: float list,
        rad2: float, shifting: float list, outer_box:[float list, float list],
        sc:bool).
        Creates a conical frustum given the centre of
        the bottom circumference, its radius, the upper circumference
        and its radius. The frustum is shifted to the position shifting
        wrt the origin of coordinates system. If sc = False, the shift
        is wrt the centre of the ellipsoid
        """
        mesh_obj.__init__(self)
        
        if coords1 == [] and shifting != []:          # only shifting is given
            for i in range(len(shifting)):
                coords1.append(0.0)
                coords2.append(0.0)
            coords2[-1] = 1.0 
            
        elif coords1 != [] and shifting == []:        # only coords is given
            for i in range(len(coords[0])):
                shifting.append(0.0)
        elif coords1 == [] and shifting != []:        # default: 2D
            for i in range(2):
                coords1.append(0.0)
                coords2.append(0.0)
                shifting.append(0.0)
            coords2[-1] = 1.0 
        else:
            pass

        print "cone"
        print coords1, coords2, shifting


        if sc:                                       # system coordinates
            self.obj.append(ocaml.body_shifted_sc(ocaml.body_frustum(coords1,rad1,coords2,rad2),shifting))
        else:                                        # body coordinates
            self.obj.append(ocaml.body_shifted_bc(ocaml.body_frustum(coords1,rad1,coords2,rad2),shifting))


        min_coords = []                              # create bounding box
        max_coords = []

        import Numeric
        c1 = Numeric.array(coords1)
        c2 = Numeric.array(coords2)
        max_dim = max(rad1, rad2, Numeric.sqrt(Numeric.add.reduce((c1-c2)*(c1-c2))))
        
        for i in range(len(shifting)):
            if outer_box == []:
                min_coords.append(shifting[i]-max_dim/2.)
                max_coords.append(shifting[i]+max_dim/2.)
            else:
                min_coords.append(min(length[i]+shifting[i], outer_box[0][i], outer_box[1][i]))
                max_coords.append(max(shifting[i]+max_dim/2.,outer_box[0][i], outer_box[1][i]))

        self.bbox = [min_coords, max_coords]          # update bounding box   
        
        print "bbox"
        print self.bbox
        print "cone.\n"