Beispiel #1
0
    def compute_geometries(self,root_path, pov_dir):
        """

        :param root_path: Path where to store the files **.geo** generated

        When we generate a new :class:`.StepImporter` we will refill a list(**shapes_simples**) whit the :class:`.SimpleShape` contained in the file **.stp**

        For each :class:`.SimpleShape` in the list **shapes_simples**:

            We call the method :func:`.write_geometries` to generate a file **.geo** representative of its geometry,the content of the file is identified by the index+1 (>0) of the position of the :class:`.SimpleShape` in the list of **SimpleShapes**  and by the attribue id of :class:`.StepImporter`

        Returns the list of the path of the generated **.geo** files

        """
        files_index=""
        self.povs = []

        for index, shape in enumerate(self.shapes_simples):
            name=get_available_name(root_path,self.fileName+".geo")
            path=os.path.join(root_path, name)
            identifier="_"+str(index+1)+"_"+str(self.id)
            writer = GeometryWriter(shape, 0.3)
            pov_filename = os.path.join(pov_dir, os.path.basename(path + ".inc"))
            writer.write_geometries(identifier, path, pov_filename)
            files_index+="GEO:"+name+" , "+str(index+1)+"\n"
            if writer.triangle_count:
                self.povs.append((os.path.basename(name + ".inc"), identifier))

        return files_index
Beispiel #2
0
    def compute_geometries(self, root_path, pov_dir):
        """

        :param root_path: Path where to store the files **.geo** generated

        When we generate a new :class:`.StepImporter` we will refill a list(**shapes_simples**) whit the :class:`.SimpleShape` contained in the file **.stp**

        For each :class:`.SimpleShape` in the list **shapes_simples**:

            We call the method :func:`.write_geometries` to generate a file **.geo** representative of its geometry,the content of the file is identified by the index+1 (>0) of the position of the :class:`.SimpleShape` in the list of **SimpleShapes**  and by the attribue id of :class:`.StepImporter`

        Returns the list of the path of the generated **.geo** files

        """
        files_index = ""
        self.povs = []

        for index, shape in enumerate(self.shapes_simples):
            name = get_available_name(root_path, self.fileName + ".geo")
            path = os.path.join(root_path, name)
            identifier = "_" + str(index + 1) + "_" + str(self.id)
            writer = GeometryWriter(shape, 0.3)
            pov_filename = os.path.join(pov_dir,
                                        os.path.basename(path + ".inc"))
            writer.write_geometries(identifier, path, pov_filename)
            files_index += "GEO:" + name + " , " + str(index + 1) + "\n"
            if writer.triangle_count:
                self.povs.append((os.path.basename(name + ".inc"), identifier))

        return files_index
Beispiel #3
0
def write_arbrefile(product, fileName, location):
    """
    :param product: :class:`.Product` relative to the structure of assemblies of a file **.stp**
    :param fileName: Name of the file **.stp** for which we are going to generate the file **.arb**
    :param location: Path where to store the file **.arb** generated
    """
    data = product.to_list()
    name = get_available_name(location, fileName + ".arb")
    path = os.path.join(location, name)
    directory = os.path.dirname(path.encode())
    if not os.path.exists(directory):
        os.makedirs(directory)
    output = open(path.encode(), "w")
    output.write(json.dumps(data))
    output.close()
    decomposable = "true" if product.links and product.is_decomposable else "false"
    return "ARB:%s\nDecomposable:%s\n" % (name, decomposable)
Beispiel #4
0
def write_arbrefile(product,fileName,location):
    """
    :param product: :class:`.Product` relative to the structure of assemblies of a file **.stp**
    :param fileName: Name of the file **.stp** for which we are going to generate the file **.arb**
    :param location: Path where to store the file **.arb** generated
    """
    data = product.to_list()
    name = get_available_name(location,fileName+".arb")
    path = os.path.join(location, name)
    directory = os.path.dirname(path.encode())
    if not os.path.exists(directory):
        os.makedirs(directory)
    output = open(path.encode(), "w")
    output.write(json.dumps(data))
    output.close()
    decomposable = "true" if product.links and product.is_decomposable else "false"
    return "ARB:%s\nDecomposable:%s\n" % (name, decomposable)