public static void fprintf(PrintStream ps, String msg, Object... args) {
    ps.printf(msg, args);
} public static double atof(String s) {
    return Double.parseDouble(s.trim());
} public static int atoi(String s) {
    return Integer.parseInt(s.trim());
} public static int strcmp(byte[] s1, String s2) {
    return trim(MyDefs.stringFromByteArray(s1)).compareTo(trim(s2));
} public static final int LAS_TOOLS_FORMAT_BIN     = 3; public static final int LAS_TOOLS_FORMAT_DEFAULT = 0; public static final int LAS_TOOLS_FORMAT_LAS     = 1; public static final int LAS_TOOLS_FORMAT_LAZ     = 2; public static final int LAS_TOOLS_FORMAT_QFIT    = 4; public static final int LAS_TOOLS_FORMAT_TXT     = 6; public static final int LAS_TOOLS_FORMAT_VRML    = 5; public static final int LAS_TOOLS_IO_OBUFFER_SIZE   = 262144; public static final int LASZIP_CHUNK_SIZE_DEFAULT           = 50000; public static final char LASZIP_COMPRESSOR_DEFAULT = LASZIP_COMPRESSOR_CHUNKED; public static final char LASZIP_COMPRESSOR_NONE              = 0;
import java.io.File;
import java.io.PrintStream;
import static com.github.mreutegg.laszip4j.clib.Cstdio.fprintf;
import static com.github.mreutegg.laszip4j.clib.Cstdlib.atof;
import static com.github.mreutegg.laszip4j.clib.Cstdlib.atoi;
import static com.github.mreutegg.laszip4j.clib.Cstring.strcmp;
import static com.github.mreutegg.laszip4j.laslib.LasDefinitions.LAS_TOOLS_FORMAT_BIN;
import static com.github.mreutegg.laszip4j.laslib.LasDefinitions.LAS_TOOLS_FORMAT_DEFAULT;
import static com.github.mreutegg.laszip4j.laslib.LasDefinitions.LAS_TOOLS_FORMAT_LAS;
import static com.github.mreutegg.laszip4j.laslib.LasDefinitions.LAS_TOOLS_FORMAT_LAZ;
import static com.github.mreutegg.laszip4j.laslib.LasDefinitions.LAS_TOOLS_FORMAT_QFIT;
import static com.github.mreutegg.laszip4j.laslib.LasDefinitions.LAS_TOOLS_FORMAT_TXT;
import static com.github.mreutegg.laszip4j.laslib.LasDefinitions.LAS_TOOLS_FORMAT_VRML;
import static com.github.mreutegg.laszip4j.laslib.LasDefinitions.LAS_TOOLS_IO_OBUFFER_SIZE;
import static com.github.mreutegg.laszip4j.laszip.LASzip.LASZIP_CHUNK_SIZE_DEFAULT;
import static com.github.mreutegg.laszip4j.laszip.LASzip.LASZIP_COMPRESSOR_CHUNKED;
import static com.github.mreutegg.laszip4j.laszip.LASzip.LASZIP_COMPRESSOR_NONE;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
/*
 * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality
 *
 * This is free software; you can redistribute and/or modify it under the
 * terms of the GNU Lesser General Licence as published by the Free Software
 * Foundation. See the LICENSE.txt file for more information.
 *
 * This software is distributed WITHOUT ANY WARRANTY and without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
package com.github.mreutegg.laszip4j.laslib;



public class LASwriteOpener {

    private static final PrintStream stderr = System.err;
    private static final PrintStream stdout = System.out;
    
    private int io_obuffer_size;
    private String directory;
    private String file_name;
    private String appendix;
    private int cut;                // unsigned
    private boolean opts;
    private boolean optx;
    private String parse_string;
    private String separator;
    private float scale_rgb;
    private int format;             // unsigned
    private boolean specified;
    private boolean force;
    private int chunk_size;         // unsigned
    private boolean use_stdout;
    private boolean use_nil;
    private boolean buffered;

    public boolean is_piped()
    {
        return ((file_name == null) && use_stdout);
    }

    public LASwriter open(LASheader header)
    {
        if (use_nil)
        {
            LASwriterLAS laswriterlas = new LASwriterLAS();
            if (!laswriterlas.open(header, (format == LAS_TOOLS_FORMAT_LAZ ? LASZIP_COMPRESSOR_CHUNKED : LASZIP_COMPRESSOR_NONE), 2, chunk_size))