def __init__(self, name, file_name, treetop, method=1, copy=False): Primitive.__init__(self, name=name) if not os.path.isfile(file_name): raise ValueError("File {} does not exist !".format(file_name)) self.file_name = file_name self.treetop = treetop self.method = method
def __init__(self, name, sketch, revolve_center=None, revolve_axis=None, radius=None, angle=None, copy=False): Primitive.__init__(self, name=name) self.sketch = sketch self.revolve_center = Vector(revolve_center, copy=copy) if revolve_center else Vector.O3() self.revolve_axis = Vector(revolve_axis, copy=copy) if revolve_axis else Vector.Z3() self.radius = Vector(radius, copy=copy) if radius else Vector.X3() self.angle = 180 if angle is None else float(angle)
def __init__(self, name, sketch, base=None, height=None, u_vec=None, v_vec=None, copy=False): Primitive.__init__(self, name=name) self.sketch = sketch self.base = Vector(base, copy=copy) if base else Vector.O3() self.height = Vector(height, copy=copy) if height else Vector.Z3() self.u_vec = Vector(u_vec, copy=copy) if u_vec else Vector.X3() self.v_vec = Vector(v_vec, copy=copy) if v_vec else Vector.Y3()
def __init__(self, name, points=(((0, 0, 0), 0.5, 0.3, 1), ((0, 0, 1), 0.5, 0.3, 1)), copy=False): Primitive.__init__(self, name=name) if isinstance(points, list) and not copy: for i in xrange(0, len(points)): points[i] = PipePoint(points[i]) else: points = [PipePoint(point, copy=copy) for point in points] self.points = points
def __init__(self, name, base=(0, 0, 0), height=(0, 0, 1), n_major=(0, 1, 0), r_major=1, r_minor=0.5, copy=False): Primitive.__init__(self, name=name) self.base = Vector(base, copy=copy) self.height = Vector(height, copy=copy) self.n_major = Vector(n_major, copy=copy) self.r_major = r_major self.r_minor = r_minor
def __init__(self,name, center=(0, 0, 0), a=(1, 0, 0), b=(0, 1, 0), c=(0, 0, 1), n=0, e=0, copy=False): Primitive.__init__(self, name=name) self.center = Vector(center, copy) self.a = Vector(a, copy) self.b = Vector(b, copy) self.c = Vector(c, copy) self.n = n self.e = e
def __init__(self, name, center=(0, 0, 0), n=(0, 0, 1), s_major=(0, 0.5, 0.5), r_revolution=1, r_minor=0.2, copy=False): Primitive.__init__(self, name=name) self.center = Vector(center, copy=copy) self.n = Vector(n, copy=copy) self.s_major = Vector(s_major, copy=copy) self.r_revolution = r_revolution self.r_minor = r_minor
def __init__(self, name, base=(0, 0, 0), height=(0, 0, 1), a_vec=(0, 1, 0), b_mag=0.5, base_neck_ratio=0.2, copy=False): Primitive.__init__(self, name=name) self.base = Vector(base, copy=copy) self.height = Vector(height, copy=copy) self.a_vec = Vector(a_vec, copy=copy) self.b_mag = b_mag self.base_neck_ratio = base_neck_ratio
def __init__(self, name, curves, copy=False): Primitive.__init__(self, name=name) if test_curves(curves): if copy: self.curves = [curve[:] for curve in curves] else: self.curves = curves else: raise BRLCADException("Invalid Curve Data in Ars")
def __init__(self, name, file_name, x_dim=350, y_dim=350, tallness=20, mat=Transform.unit(), copy=False): Primitive.__init__(self, name=name) if not os.path.isfile(file_name): raise ValueError("File {} does not exist !".format(file_name)) self.file_name = file_name self.x_dim = x_dim self.y_dim = y_dim self.tallness = tallness self.mat = Transform(mat, copy=copy, force=True)
def __init__(self, name, base=(0, 0, 0), height=(0, 0, 1), a=(0, 1, 0), b=(0.5, 0, 0), c=(0, 0.5, 0), d=(1, 0, 0), copy=False): Primitive.__init__(self, name=name) self.base = Vector(base, copy=copy) self.height = Vector(height, copy=copy) self.a = Vector(a, copy=copy) self.b = Vector(b, copy=copy) self.c = Vector(c, copy=copy) self.d = Vector(d, copy=copy)
def __init__(self, name, threshold=1, method=2, points=(((1, 1, 1), 1, 0), ((0, 0, 1), 2, 0)), copy=False): Primitive.__init__(self, name=name) if isinstance(points, list) and not copy: for i in xrange(0, len(points)): points[i] = MetaballCtrlPoint(points[i]) else: points = [MetaballCtrlPoint(point, copy=copy) for point in points] self.threshold = threshold if threshold > 0 else 1 self.method = method if method > 0 else 2 self.points = points
def __init__(self, name, dsp_name, data_src="file", width=142, length=150, interpolation=False, cut_direction=1, cell_size=1, unit_elevation=0.005, copy=False): """ :param name: :param data_src: (1)file('f')/(2)object('o') :param dsp_name: name of file/object :param width: width of displacement-map :param length: length of displacement-map :param interpolation: True for normal interpolation :param cut_direction: (1,ad)ad(adaptive),(2,lR)llUR(lower left to upper right) or (3,Lr)ULlr(Upper Left to lower right) :return: """ Primitive.__init__(self, name=name) if isinstance(data_src, str): if data_src[0] == "f" or data_src[0] == "F": self.data_src = 1 elif data_src[0] == "o" or data_src[0] == "O": self.data_src = 2 else: raise BRLCADException("Invalid Data") elif data_src == 1 or data_src == 2: self.data_src = data_src else: raise BRLCADException("Invalid Data") if self.data_src == 1: if not os.path.isfile(dsp_name): raise ValueError("File {} does not exist !".format(dsp_name)) self.dsp_name = dsp_name self.width = width self.length = length self.interpolation = interpolation self.cell_size = cell_size self.unit_elevation = unit_elevation if isinstance(cut_direction, str): if cut_direction[0] == "a" or cut_direction[0] == "A": self.cut_direction = 1 elif cut_direction == "llUR" or cut_direction == "l": self.cut_direction = 2 elif cut_direction == "ULlr" or cut_direction == "L": self.cut_direction = 3 else: raise BRLCADException("Invalid Data") elif cut_direction in range(1, 4): self.cut_direction = cut_direction else: raise BRLCADException("Invalid Data")
def __init__(self, text = '', trafo = None, model = PATHTEXT_ROTATE, start_pos = 0.0, properties = None, duplicate = None): CommonText.__init__(self, text, duplicate = duplicate) Primitive.__init__(self, properties = properties, duplicate = duplicate) if duplicate is not None and isinstance(duplicate, self.__class__): # dont copy paths, update it from parent self.trafo = duplicate.trafo self.model = duplicate.model self.start_pos = duplicate.start_pos else: if trafo is None: self.trafo = Identity else: self.trafo = trafo self.model = model self.start_pos = start_pos self.cache = {}
def __init__(self, name, base=(0, 0, 0), u_vec=(1, 0, 0), v_vec=(0, 1, 0), vertices=None, curves=None, copy=False): Primitive.__init__(self, name=name) self.base = Vector(base, copy=copy) self.u_vec = Vector(u_vec, copy=copy) self.v_vec = Vector(v_vec, copy=copy) if vertices is None: vertices = [] elif not isinstance(vertices, list): vertices = list(vertices) for i in range(0, len(vertices)): vertices[i] = Vector(vertices[i], copy=copy) self.vertices = vertices if curves is None: curves = [] elif not isinstance(curves, list): curves = list(curves) self.curves = curves for i in xrange(0, len(curves)): self.add_curve_segment(curves[i], segment_index=i, copy=copy)
def __init__(self, name, mode=1, orientation=1, flags=0, vertices=None, faces=None, copy=False): Primitive.__init__(self, name=name) self.mode = mode self.orientation = orientation self.flags = flags if vertices is None: vertices = [] elif not isinstance(vertices, list): vertices = list(vertices) for i in range(0, len(vertices)): vertices[i] = Vector(vertices[i], copy=copy) self.vertices = vertices if faces is None: faces = [] elif not isinstance(faces, list): curves = list(faces) self.faces = faces for i in xrange(0, len(faces)): self.add_face(faces[i])
def DrawShape(self, device, rect=None, clip=0): text = self.text; trafos = self.trafos font = self.properties.font; font_size = self.properties.font_size Primitive.DrawShape(self, device) device.BeginComplexText(clip, self.cache) for idx in range(len(trafos)): char = text[idx] if char not in '\r\n':# avoid control chars device.DrawComplexText(text[idx], trafos[idx], font, font_size) device.EndComplexText()
def RemoveTransformation(self): if self.trafo.matrix() != IdentityMatrix: a = self.properties trafo = self.trafo llx, lly, urx, ury = a.font.TextCoordBox(self.text, a.font_size, a) try: undostyle = Primitive.Transform(self, trafo.inverse()) except SingularMatrix: undostyle = None undotrafo = self.set_transformation(Translation(trafo.offset())) return CreateMultiUndo(undostyle, undotrafo) return NullUndo
def __init__(self, name, file_name, x_dim=1, y_dim=1, z_dim=1, low_thresh=0, high_thresh=128, cell_size=(1, 1, 1), mat=Transform.unit(), copy=False): Primitive.__init__(self, name=name) if not os.path.isfile(file_name): raise ValueError("File {} does not exist !".format(file_name)) self.file_name = file_name self.x_dim = x_dim self.y_dim = y_dim self.z_dim = z_dim self.low_thresh = low_thresh self.high_thresh = high_thresh self.cell_size = Vector(cell_size, copy=copy) self.mat = Transform(mat, copy=copy, force=True)
def __init__(self, text='', trafo=None, model=PATHTEXT_ROTATE, start_pos=0.0, properties=None, duplicate=None): CommonText.__init__(self, text, duplicate=duplicate) Primitive.__init__(self, properties=properties, duplicate=duplicate) if duplicate is not None and isinstance(duplicate, self.__class__): # dont copy paths, update it from parent self.trafo = duplicate.trafo self.model = duplicate.model self.start_pos = duplicate.start_pos else: if trafo is None: self.trafo = Identity else: self.trafo = trafo self.model = model self.start_pos = start_pos self.cache = {}
def __init__(self, paths = None, properties = None, duplicate = None): if duplicate is not None: if paths is None: paths = [] for path in duplicate.paths: paths.append(path.Duplicate()) self.paths = tuple(paths) else: # This special case uses the properties kwarg now, I # hope. warn(INTERNAL, 'Bezier object created with paths and duplicte') print_stack() if type(paths) != type(()): paths = (paths,) self.paths = paths elif paths is not None: if type(paths) != type(()): paths = (paths,) self.paths = paths else: self.paths = (CreatePath(),) Primitive.__init__(self, properties = properties, duplicate=duplicate)
def __init__( self, name, file_name, x_dim=1, y_dim=1, z_dim=1, low_thresh=0, high_thresh=128, cell_size=(1, 1, 1), mat=Transform.unit(), copy=False, ): Primitive.__init__(self, name=name) if not os.path.isfile(file_name): raise ValueError("File {} does not exist !".format(file_name)) self.file_name = file_name self.x_dim = x_dim self.y_dim = y_dim self.z_dim = z_dim self.low_thresh = low_thresh self.high_thresh = high_thresh self.cell_size = Vector(cell_size, copy=copy) self.mat = Transform(mat, copy=copy, force=True)
def SaveToFile(self, file): Primitive.SaveToFile(self, file) file.InternalPathText(self.text, self.trafo, self.model, self.start_pos)
def Disconnect(self): self.cache = {} Primitive.Disconnect(self)
def __init__(self, name, base=(0, 0, 0), height=(-1, 0, 0), breadth=(0, 0, 1), half_width=0.5, copy=False): Primitive.__init__(self, name=name) self.base = Vector(base, copy=copy) self.height = Vector(height, copy=copy) self.breadth = Vector(breadth, copy=copy) self.half_width = half_width
def __init__(self, name, base=(0, 0, 0), height=(0, 0, 1), r_base=0.5, r_end=0.2, copy=False): Primitive.__init__(self, name=name) self.base = Vector(base, copy=copy) self.height = Vector(height, copy=copy) self.r_base = r_base self.r_end = r_end
def __init__(self, name, norm=(1, 0, 0), d=1.0, plane=None, copy=False): Primitive.__init__(self, name=name) if plane is not None: self.plane = plane else: self.plane = Plane(Vector(norm), d, copy=copy)
def __init__(self, name, points, copy=False): """ The points parameter is a sequence of 24(=8*3) floats. It doesn't matter in what form the floats are organized (e.g. sequence of 24 floats, sequence of 8 tuples of each 3 floats) the only requirement is that they are 24 in total. They will be interpreted as 8 vertexes, each composed of 3 floats for the (x, y, z) coordinates. The ordering of the vertexes is important, the mapping to the ARB8s corners is like this: V8 V7 +--------------------+ /: /| / : / | / : / | V5/ : V6/ | +--------------------+ | | : | | | ;...............|....+ | ;V4 | /V3 | ; | / | ; | / |; |/ +--------------------+ V1 V2 To have a consistent ARB8, the vertexes of each face must be coplanar. The faces are defined and connected in a specific order, so switching 2 vertexes will result in wrong shape. The faces are numbered to allow access to them (again, the order of the points is important): F1 = (V1, V2, V3, V4) F2 = (V5, V6, V7, V8) F3 = (V1, V2, V6, V5) F4 = (V2, V3, V7, V6) F5 = (V3, V4, V8, V7) F6 = (V4, V1, V5, V8) F2 | F5 V8 | / V7 +-------|------------+ /: | / /| / : / / | / : / | V5/ : V6/ | +--------------------+ -------F4 | : | | F6---|-- ;...............|....+ | ;V4 | /V3 | ; | / | ; / | / |; / | |/ +------/-------------+ V1 / | V2 F3 | F1 This primitive can also represent shapes with 4-7 vertexes, by collapsing certain vertexes in one point. This constructor will accept any number of points between 4-8, and do the necessary mapping of points to collapsed vertexes. The exact mapping of the points parameter to vertexes follows below separately for each of ARB4-ARB7. ARB4 points = (P1, P2, P3, P4) vertexes = (V1=P1, V2=P2, V3=P3, V4=P3, V5=P4, V6=P4, V7=P4, V8=P4) P4(V5,V6,V7,V8) + /|\ / | \ / | \ / | \ / | ,x / |,-'/P3(V3,V4) / ,-| / / ,-' | / /,-' |/ +---------+ P1(V1) P2(V2) ARB5 points = (P1, P2, P3, P4, P5) vertexes = (V1=P1, V2=P2, V3=P3, V4=P4, V5=P5, V6=P5, V7=P5, V8=P5) P5(V5,V6,V7,V8) _.-+~.,_ P4(V4) _.-" ." \ '~.,_ P3(V3) +"---."----\-------"-+ / ." \ / / ." \ / / ." \ / /." \ / +"~~~~~~~~~~~~~~~~~~~+ P1(V1) P2(V2) ARB6 points = (P1, P2, P3, P4, P5, P6) vertexes = (V1=P1, V2=P2, V3=P3, V4=P4, V5=P5, V6=P5, V7=P6 V8=P6) P6(V7,V8) .+ ,"/ \ ," / \ P5(V5,V6) ". ," + \ P4(V4) ," ." \ ". P3(V3) +"---."----\---------+ / ." \ / / ." \ / / ." \ / /." \ / +"~~~~~~~~~~~~~~~~~~~+ P1(V1) P2(V2) ARB7 points = (P1, P2, P3, P4, P5, P6, P7) vertexes = (V1=P1, V2=P2, V3=P3, V4=P4, V5=P5, V6=P6, V7=P7 V8=P5) P7(V7) _,.+ _,.~".'/| _,.-" .- / | _,.-" .- / | P5(V5,V8),-"' .- P6(V6) | +~~~~~~~~~~~~~~~~~~~~+ | | `. .-' | | | `,:..............|....+ | ;P4(V4) | / P3(V3) | ; | / | ; | / |; |/ +~~~~~~~~~~~~~~~~~~~~+ P1(V1) P2(V2) """ #TODO: implement conversion for ARB4-ARB7 # (expand points for the collapsed vertexes) Primitive.__init__(self, name=name) self.point_mat = np.matrix(points, copy=copy)
def DrawShape(self, device, rect=None, clip=0): Primitive.DrawShape(self, device) device.SimpleEllipse(self.trafo, self.start_angle, self.end_angle, self.arc_type, rect, clip)
def __init__(self, name, center=(0, 0, 0), normal=(1, 0, 0), magnitude=1, copy=False): Primitive.__init__(self, name=name) self.center = Vector(center, copy=copy) self.normal = Vector(normal, copy=copy) self.magnitude = magnitude
def __init__(self, name, center, a, b, c, copy=False): Primitive.__init__(self, name=name) self.center = Vector(center, copy=copy) self.a = Vector(a, copy=copy) self.b = Vector(b, copy=copy) self.c = Vector(c, copy=copy)
def __init__(self, name, planes, copy=False): Primitive.__init__(self, name=name) self.planes = [Plane.wrap(x, copy=copy) for x in planes]
def SaveToFile(self, file): Primitive.SaveToFile(self, file) file.Rectangle(self.trafo, self.radius1, self.radius2)
def SaveToFile(self, file): Primitive.SaveToFile(self, file) file.Ellipse(self.trafo, self.start_angle, self.end_angle, self.arc_type)
def __init__(self, name, center=(0, 0, 0), n=(0, 0, 1), r_revolution=1, r_cross=0.2, copy=False): Primitive.__init__(self, name=name) self.center = Vector(center, copy=copy) self.n = Vector(n, copy=copy) self.r_revolution = r_revolution self.r_cross = r_cross