<commit_before>package com.jme.scene.model.XMLparser;

import com.jme.scene.*;
import com.jme.scene.model.JointMesh2;
import com.jme.scene.state.*;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.math.Vector2f;
import com.jme.math.FastMath;
import com.jme.renderer.ColorRGBA;
import com.jme.animation.JointController;
import com.jme.animation.KeyframeController;
import com.jme.animation.SpatialTransformer;
import com.jme.light.Light;
import com.jme.light.SpotLight;
import com.jme.light.PointLight;


import java.io.OutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import java.util.*;
import java.net.URL;


/**
 * Started Date: Jun 25, 2004<br><br>
 *
 * This class converts a scenegraph to jME binary format.  Even though this
 * class's name ends with Writer, it does not extend Writer
 *
 * @author <NAME>
 */
public class JmeBinaryWriter {
    private DataOutputStream myOut;
    private static final boolean DEBUG=false;

    /**
     * These are the Spatial,RenderState,Controller that occur twice in the file.  They
     * are saved as shares to better reflect how the file currently is
     */
    private IdentityHashMap sharedObjects=new IdentityHashMap(20);

    /** Contains the address of every Spatial, RenderState, Controller in the scene.  Whenever
     * an address is entered twice, it is sent to sharedObjects
     */
    private IdentityHashMap entireScene=new IdentityHashMap(256);

    private static final Quaternion DEFAULT_ROTATION=new Quaternion();
    private static final Vector3f DEFAULT_TRANSLATION = new Vector3f();
    private static final Vector3f DEFAULT_SCALE = new Vector3f(1,1,1);


    /**
     * Holds properties that modify how JmeBinaryWriter writes a file.
     */
    private HashMap properties=new HashMap();



    /**
     * Creates a new Binary Writer.
     */
    public JmeBinaryWriter(){

    }

    /**
     * Converts a given node to jME's binary format.
     * @param scene The node to save
     * @param bin The OutputStream that will store the binary format
     * @throws IOException If anything wierd happens.
     */
    public void writeScene(Node scene,OutputStream bin) throws IOException {
        myOut=new DataOutputStream(bin);
        sharedObjects.clear();
        entireScene.clear();
        writeHeader();
        findDuplicates(scene);
        writeDuplicates();
        writeNode(scene);
        writeClosing();
        myOut.close();
    }

    /**
     * All objects that are twice in the file are written as shared types.
     * @throws IOException
     */<commit_msg>Issue number:   Obtained from:  Submitted by:   Reviewed by:<commit_after>package com.jme.scene.model.XMLparser;

import com.jme.scene.*;
import com.jme.scene.model.JointMesh2;
import com.jme.scene.state.*;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.math.Vector2f;
import com.jme.math.FastMath;
import com.jme.renderer.ColorRGBA;
import com.jme.animation.JointController;
import com.jme.animation.KeyframeController;
import com.jme.animation.SpatialTransformer;
import com.jme.light.Light;
import com.jme.light.SpotLight;
import com.jme.light.PointLight;


import java.io.OutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import java.util.*;
import java.net.URL;


/**
 * Started Date: Jun 25, 2004<br><br>
 *
 * This class converts a scenegraph to jME binary format.  Even though this
 * class's name ends with Writer, it does not extend Writer
 *
 * @author <NAME>
 */
public class JmeBinaryWriter {
    private DataOutputStream myOut;
    private static final boolean DEBUG=false;

    /**
     * These are the Spatial,RenderState,Controller that occur twice in the file.  They
     * are saved as shares to better reflect how the file currently is
     */
    private IdentityHashMap sharedObjects=new IdentityHashMap(20);

    /** Contains the address of every Spatial, RenderState, Controller in the scene.  Whenever
     * an address is entered twice, it is sent to sharedObjects
     */
    private IdentityHashMap entireScene=new IdentityHashMap(256);

    private static final Quaternion DEFAULT_ROTATION=new Quaternion();
    private static final Vector3f DEFAULT_TRANSLATION = new Vector3f();
    private static final Vector3f DEFAULT_SCALE = new Vector3f(1,1,1);


    /**
     * Holds properties that modify how JmeBinaryWriter writes a file.
     */
    private HashMap properties=new HashMap();



    /**
     * Creates a new Binary Writer.
     */
    public JmeBinaryWriter(){

    }

    /**
     * Converts a given node to jME's binary format.
     * @param scene The node to save
     * @param bin The OutputStream that will store the binary format
     * @throws IOException If anything wierd happens.
     */
    public void writeScene(Node scene,OutputStream bin) throws IOException {
        myOut=new DataOutputStream(bin);
        sharedObjects.clear();
        entireScene.clear();
        writeHeader();
        findDuplicates(scene);
        writeDuplicates();
        writeNode(scene);
        writeClosing();
        myOut.close();
    }

    /**
     * Writes a spatial to jME's binary format.
     * @param spatial The spatial to write.
     * @param jMEFormat The OutputStream to write it too.
     * @throws IOException If anything wierd happens.
     */
    public void writeScene(Spatial spatial, OutputStream jMEFormat) throws IOException {
        if (spatial instanceof Node)
            writeScene((Node)spatial,jMEFormat);
        else if (spatial instanceof Geometry)
            writeScene((Geometry)spatial,jMEFormat);
    }

    /**
     * All objects that are twice in the file are written as shared types.
     * @throws IOException
     */
{'fraction_non_alphanumeric': 0.0890125173852573, 'fraction_numerical': 0.007301808066759388, 'mean_word_length': 3.196207148067104, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3517846', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1624, 'n_words': 523}