meshlabxml/mlx.py
def run_script(self, log=None, ml_log=None, mlp_out=None, overwrite=False,
                   file_out=None, output_mask=None, script_file=None, print_meshlabserver_output=True):
        """ Run the script
        """

        temp_script = False
        temp_ml_log = False

        if self.__no_file_in:
            # If no input files are provided, create a dummy file
            # with a single vertex and delete it first in the script.
            # This works around the fact that meshlabserver will
            # not run without an input file.
            temp_file_in_file = tempfile.NamedTemporaryFile(delete=False, suffix='.xyz', dir=os.getcwd())
            temp_file_in_file.write(b'0 0 0')
            temp_file_in_file.close()
            self.file_in = [temp_file_in_file.name]

        if not self.filters:
            script_file = None
        elif script_file is None:
            # Create temporary script file
            temp_script = True
            temp_script_file = tempfile.NamedTemporaryFile(delete=False, suffix='.mlx')
            temp_script_file.close()
            self.save_to_file(temp_script_file.name)
            script_file = temp_script_file.name

        if (self.parse_geometry or self.parse_topology or self.parse_hausdorff) and (ml_log is None):
            # create temp ml_log
            temp_ml_log = True
            ml_log_file = tempfile.NamedTemporaryFile(delete=False, suffix='.txt')
            ml_log_file.close()
            ml_log = ml_log_file.name
        if file_out is None:
            file_out = self.file_out

        run(script=script_file, log=log, ml_log=ml_log,
            mlp_in=self.mlp_in, mlp_out=mlp_out, overwrite=overwrite,
            file_in=self.file_in, file_out=file_out, output_mask=output_mask, ml_version=self.ml_version,
            print_meshlabserver_output=print_meshlabserver_output)

        # Parse output
        # TODO: record which layer this is associated with?
        if self.parse_geometry:
            self.geometry = compute.parse_geometry(ml_log, log, print_output=print_meshlabserver_output)
        if self.parse_topology:
            self.topology = compute.parse_topology(ml_log, log, print_output=print_meshlabserver_output)
        if self.parse_hausdorff:
            self.hausdorff_distance = compute.parse_hausdorff(ml_log, log, print_output=print_meshlabserver_output)

        # Delete temp files
        if self.__no_file_in:
            os.remove(temp_file_in_file.name)
        if temp_script:
            os.remove(temp_script_file.name)
        if temp_ml_log:
            os.remove(ml_log_file.name)
def run_script(self, log=None, ml_log=None, mlp_out=None, overwrite=False,
                   file_out=None, output_mask=None, script_file=None, print_meshlabserver_output=True):
        temp_script = False
        temp_ml_log = False

        if self.__no_file_in:
            # If no input files are provided, create a dummy file
            # with a single vertex and delete it first in the script.
            # This works around the fact that meshlabserver will
            # not run without an input file.
            temp_file_in_file = tempfile.NamedTemporaryFile(delete=False, suffix='.xyz', dir=os.getcwd())
            temp_file_in_file.write(b'0 0 0')
            temp_file_in_file.close()
            self.file_in = [temp_file_in_file.name]

        if not self.filters:
            script_file = None
        elif script_file is None:
            # Create temporary script file
            temp_script = True
            temp_script_file = tempfile.NamedTemporaryFile(delete=False, suffix='.mlx')
            temp_script_file.close()
            self.save_to_file(temp_script_file.name)
            script_file = temp_script_file.name

        if (self.parse_geometry or self.parse_topology or self.parse_hausdorff) and (ml_log is None):
            # create temp ml_log
            temp_ml_log = True
            ml_log_file = tempfile.NamedTemporaryFile(delete=False, suffix='.txt')
            ml_log_file.close()
            ml_log = ml_log_file.name
        if file_out is None:
            file_out = self.file_out

        run(script=script_file, log=log, ml_log=ml_log,
            mlp_in=self.mlp_in, mlp_out=mlp_out, overwrite=overwrite,
            file_in=self.file_in, file_out=file_out, output_mask=output_mask, ml_version=self.ml_version,
            print_meshlabserver_output=print_meshlabserver_output)

        # Parse output
        # TODO: record which layer this is associated with?
        if self.parse_geometry:
            self.geometry = compute.parse_geometry(ml_log, log, print_output=print_meshlabserver_output)
        if self.parse_topology:
            self.topology = compute.parse_topology(ml_log, log, print_output=print_meshlabserver_output)
        if self.parse_hausdorff:
            self.hausdorff_distance = compute.parse_hausdorff(ml_log, log, print_output=print_meshlabserver_output)

        # Delete temp files
        if self.__no_file_in:
            os.remove(temp_file_in_file.name)
        if temp_script:
            os.remove(temp_script_file.name)
        if temp_ml_log:
            os.remove(ml_log_file.name)
def run_script ( self , log = None , ml_log = None , mlp_out = None , overwrite = False , file_out = None , output_mask = None , script_file = None , print_meshlabserver_output = True ) : temp_script = False temp_ml_log = False if self . __no_file_in : # If no input files are provided, create a dummy file # with a single vertex and delete it first in the script. # This works around the fact that meshlabserver will # not run without an input file. temp_file_in_file = tempfile . NamedTemporaryFile ( delete = False , suffix = '.xyz' , dir = os . getcwd ( ) ) temp_file_in_file . write ( b'0 0 0' ) temp_file_in_file . close ( ) self . file_in = [ temp_file_in_file . name ] if not self . filters : script_file = None elif script_file is None : # Create temporary script file temp_script = True temp_script_file = tempfile . NamedTemporaryFile ( delete = False , suffix = '.mlx' ) temp_script_file . close ( ) self . save_to_file ( temp_script_file . name ) script_file = temp_script_file . name if ( self . parse_geometry or self . parse_topology or self . parse_hausdorff ) and ( ml_log is None ) : # create temp ml_log temp_ml_log = True ml_log_file = tempfile . NamedTemporaryFile ( delete = False , suffix = '.txt' ) ml_log_file . close ( ) ml_log = ml_log_file . name if file_out is None : file_out = self . file_out run ( script = script_file , log = log , ml_log = ml_log , mlp_in = self . mlp_in , mlp_out = mlp_out , overwrite = overwrite , file_in = self . file_in , file_out = file_out , output_mask = output_mask , ml_version = self . ml_version , print_meshlabserver_output = print_meshlabserver_output ) # Parse output # TODO: record which layer this is associated with? if self . parse_geometry : self . geometry = compute . parse_geometry ( ml_log , log , print_output = print_meshlabserver_output ) if self . parse_topology : self . topology = compute . parse_topology ( ml_log , log , print_output = print_meshlabserver_output ) if self . parse_hausdorff : self . hausdorff_distance = compute . parse_hausdorff ( ml_log , log , print_output = print_meshlabserver_output ) # Delete temp files if self . __no_file_in : os . remove ( temp_file_in_file . name ) if temp_script : os . remove ( temp_script_file . name ) if temp_ml_log : os . remove ( ml_log_file . name )
Run the script
Run the script