package Savage.Space.SatelliteLab;

import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.fields.*;
import org.web3d.x3d.jsail.Geometry3D.*;
import org.web3d.x3d.jsail.Rendering.*;
import org.web3d.x3d.jsail.Shape.*;

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> A vibration isolator for the optical deck of the MSADS Assembly. </p>
 <p> Related links: Catalog page <a href="../../../../Space/SatelliteLab/VibrationIsolatorIndex.html" target="_blank">VibrationIsolator</a>,  source <a href="../../../../Space/SatelliteLab/VibrationIsolator.java">VibrationIsolator.java</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a>, and <a href="https://www.web3d.org/x3d/content/X3dTooltips.html" target="_blank">X3D Tooltips</a>. </p>
	<table style="color:black; border:0px solid; border-spacing:10px 0px;">
        <caption>Scene Meta Information</caption>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center; padding:10px 0px;"><i>meta tags</i></td>
			<td style="text-align:left;   padding:10px 0px;">&nbsp; Document Metadata </td>
		</tr>

		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> title </i> </td>
			<td> <a href="../../../../Space/SatelliteLab/VibrationIsolator.x3d">VibrationIsolator.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> A vibration isolator for the optical deck of the MSADS Assembly </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Ron Hatt </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 13 September 2006 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 28 November 2019 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> identifier </i> </td>
			<td> <a href="https://www.web3d.org/x3d/content/examples/Savage/Space/SatelliteLab/VibrationIsolator.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/Space/SatelliteLab/VibrationIsolator.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> generator </i> </td>
			<td> Wings3D, VizX3D </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> generator </i> </td>
			<td> X3D-Edit 3.2, <a href="https://www.web3d.org/x3d/tools/X3D-Edit" target="_blank">https://www.web3d.org/x3d/tools/X3D-Edit</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../../../../Space/SatelliteLab/../../license.html">../../license.html</a> </td>
		</tr>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center;" colspan="2">  &nbsp; </td>
		</tr>
	</table>

	<p>
		This program uses the
		<a href="https://www.web3d.org/specifications/java/X3DJSAIL.html" target="_blank">X3D Java Scene Access Interface Library (X3DJSAIL)</a>.
		It has been produced using the 
		<a href="https://www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">X3dToJava.xslt</a>
		stylesheet
	       (<a href="https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">version control</a>)
                which is used to create Java source code from an original <code>.x3d</code> model.
	</p>

	* @author Ron Hatt
 */

public class VibrationIsolator
{
	/** Default constructor to create this object. */
	public VibrationIsolator ()
	{
	  initialize();
	}

	/** Create and initialize the X3D model for this object. */
	public final void initialize()
	{
            try { // catch-all
  x3dModel = new X3D().setProfile(X3D.PROFILE_INTERCHANGE).setVersion(X3D.VERSION_3_0)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("VibrationIsolator.x3d"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("A vibration isolator for the optical deck of the MSADS Assembly"))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Ron Hatt"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("13 September 2006"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("28 November 2019"))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/Space/SatelliteLab/VibrationIsolator.x3d"))
    .addMeta(new meta().setName(meta.NAME_GENERATOR  ).setContent("Wings3D, VizX3D"))
    .addMeta(new meta().setName(meta.NAME_GENERATOR  ).setContent("X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addChild(new WorldInfo().setTitle("VibrationIsolator.x3d"))
    .addChild(new Shape("VibrationIsolator")
      .setAppearance(new Appearance()
        .setMaterial(new Material().setDiffuseColor(0.2,0.2,0.2)))
      .setGeometry(new IndexedFaceSet("VibrationIsolator_Geo").setDEF("VibrationIsolator_Geo").setCreaseAngle(0.524).setCoordIndex(getVibrationIsolator_Geo_4_14_coordIndex())
        .setCoord(new Coordinate("VibrationIsolator_Coord").setPoint(getVibrationIsolator_Coord_5_14_point())))));
            }
            catch (Exception ex)
            {       
                System.err.println ("*** Further hints on X3DJSAIL errors and exceptions at");
                System.err.println ("*** https://www.web3d.org/specifications/java/X3DJSAIL.html");
                throw (ex);
            }
	}
	// end of initialize() method

		/** Define subarrays using type int[] */
		private int[] getVibrationIsolator_Geo_4_14_coordIndex_1()
		{
			int[] value = {0,1,17,-1,0,17,16,-1,0,15,34,-1,0,34,33,-1,0,16,31,-1,0,31,15,-1,0,33,32,-1,0,32,1,-1,1,2,18,-1,1,18,17,-1,1,32,47,-1,1,47,2,-1,2,3,19,-1,2,19,18,-1,2,47,46,-1,2,46,3,-1,3,4,20,-1,3,20,19,-1,3,46,45,-1,3,45,4,-1,4,5,21,-1,4,21,20,-1,4,45,44,-1,4,44,5,-1,5,6,22,-1,5,22,21,-1,5,44,43,-1,5,43,6,-1,6,7,23,-1,6,23,22,-1,6,43,42,-1,6,42,7,-1,7,8,24,-1,7,24,23,-1,7,42,41,-1,7,41,8,-1,8,9,25,-1,8,25,24,-1,8,41,40,-1,8,40,9,-1,9,10,26,-1,9,26,25,-1,9,40,39,-1,9,39,10,-1,10,11,27,-1,10,27,26,-1,10,39,38,-1,10,38,11,-1,11,12,28,-1,11,28,27,-1,11,38,37,-1,11,37,12,-1,12,13,29,-1,12,29,28,-1,12,37,36,-1,12,36,13,-1,13,14,30,-1,13,30,29,-1,13,36,35,-1,13,35,14,-1,14,15,31,-1,14,31,30,-1,14,35,34,-1,14,34,15,-1,16,17,18,-1,16,18,19,-1,16,19,20,-1,16,20,21,-1,16,21,22,-1,16,22,23,-1,16,23,24,-1,16,24,25,-1,16,25,26,-1,16,26,27,-1,16,27,28,-1,16,28,29,-1,16,29,30,-1,16,30,31,-1,32,33,49,-1,32,49,48,-1,32,48,63,-1,32,63,47,-1,33,34,50,-1,33,50,49,-1,34,35,51,-1,34,51,50,-1,35,36,52,-1,35,52,51,-1,36,37,53,-1,36,53,52,-1,37,38,54,-1,37,54,53,-1,38,39,55,-1,38,55,54,-1,39,40,56,-1,39,56,55,-1,40,41,57,-1,40,57,56,-1,41,42,58,-1,41,58,57,-1,42,43,59,-1,42,59,58,-1,43,44,60,-1,43,60,59,-1,44,45,61,-1,44,61,60,-1,45,46,62,-1,45,62,61,-1,46,47,63,-1,46,63,62,-1,48,49,50,-1,48,50,51,-1,48,51,52,-1,48,52,53,-1,48,53,54,-1,48,54,55,-1,48,55,56,-1,48,56,57,-1,48,57,58,-1,48,58,59,-1,48,59,60,-1,48,60,61,-1,48,61,62,-1,48,62,63,-1};
			return value;
		}


		/** Large attribute array: IndexedFaceSet DEF='VibrationIsolator_Geo' coordIndex field, scene-graph level=4, element #14, 496 total numbers.
		 * Reassemble split array as single method to improve readability and runnability.
		 * Provide large array values via separate methods, hoping to avoid 'code too large' Java compilation errors. 
		 * Individual Java methods (including aggregated initializations) are limited to 64KB.
		 * @see https://stackoverflow.com/questions/2407912/code-too-large-compilation-error-in-java
		 * @see https://stackoverflow.com/questions/11437905/java-too-many-constants-jvm-error
		 */
		private MFInt32 getVibrationIsolator_Geo_4_14_coordIndex()
		{
			MFInt32 VibrationIsolator_Geo_4_14_coordIndex = new MFInt32()/*2.finalize*/
				.append(new MFInt32(getVibrationIsolator_Geo_4_14_coordIndex_1()));
			return VibrationIsolator_Geo_4_14_coordIndex;
		}
		/** Large attribute array: Coordinate DEF='VibrationIsolator_Coord' point field, scene-graph level=5, element #14, 192 total numbers made up of 64 3-tuple values.
		 * Reassemble split array as single method to improve readability and runnability.
		 * Provide large array values via separate methods, hoping to avoid 'code too large' Java compilation errors. 
		 * Individual Java methods (including aggregated initializations) are limited to 64KB.
		 * @see https://stackoverflow.com/questions/2407912/code-too-large-compilation-error-in-java
		 * @see https://stackoverflow.com/questions/11437905/java-too-many-constants-jvm-error
		 */
		private MFVec3f getVibrationIsolator_Coord_5_14_point()
		{
			MFVec3f VibrationIsolator_Coord_5_14_point = new MFVec3f(new double[] {.3,.01,-0.0,.27716,.01,.11481,.21213,.01,.21213,.11481,.01,.27716,-0.0,.01,.3,-.11481,.01,.27716,-.21213,.01,.21213,-.27716,.01,.11481,-.3,.01,0.0,-.27716,.01,-.11481,-.21213,.01,-.21213,-.11481,.01,-.27716,-0.0,.01,-.3,.11481,.01,-.27716,.21213,.01,-.21213,.27716,.01,-.11481,.3,-.01,-0.0,.27716,-.01,.11481,.21213,-.01,.21213,.11481,-.01,.27716,-0.0,-.01,.3,-.11481,-.01,.27716,-.21213,-.01,.21213,-.27716,-.01,.11481,-.3,-.01,0.0,-.27716,-.01,-.11481,-.21213,-.01,-.21213,-.11481,-.01,-.27716,-0.0,-.01,-.3,.11481,-.01,-.27716,.21213,-.01,-.21213,.27716,-.01,-.11481,.21065,.01,.08725,.228,.01,0.0,.21065,.01,-.08725,.16122,.01,-.16122,.08725,.01,-.21065,-0.0,.01,-.228,-.08725,.01,-.21065,-.16122,.01,-.16122,-.21065,.01,-.08725,-.228,.01,0.0,-.21065,.01,.08725,-.16122,.01,.16122,-.08725,.01,.21065,-0.0,.01,.228,.08725,.01,.21065,.16122,.01,.16122,.12217,.17,.05061,.13224,.17,0.0,.12217,.17,-.05061,.09351,.17,-.09351,.05061,.17,-.12217,-0.0,.17,-.13224,-.05061,.17,-.12217,-.09351,.17,-.09351,-.12217,.17,-.05061,-.13224,.17,0.0,-.12217,.17,.05061,-.09351,.17,.09351,-.05061,.17,.12217,-0.0,.17,.13224,.05061,.17,.12217,.09351,.17,.09351});
			return VibrationIsolator_Coord_5_14_point;
		}

	/** The initialized model object, created within initialize() method. */
	private X3D x3dModel;

	/** 
	 * Provide a 
	 * <a href="https://dzone.com/articles/java-copy-shallow-vs-deep-in-which-you-will-swim" target="_blank">shallow copy</a>
	 * of the X3D model.
	 * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html">X3D</a>
	 * @return VibrationIsolator model
	 */
	public X3D getX3dModel()
	{	  
		return x3dModel;
	}
	   
    /** 
     * Default main() method provided for test purposes, uses CommandLine to set global ConfigurationProperties for this object.
     * @param args array of input parameters, provided as arguments
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#handleArguments-java.lang.String:A-">X3D.handleArguments(args)</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#validationReport--">X3D.validationReport()</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html">CommandLine</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html#USAGE">CommandLine.USAGE</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html">ConfigurationProperties</a>
     */
    public static void main(String args[])
    {
        System.out.println("Build this X3D model, showing validation diagnostics...");
        X3D thisExampleX3dModel = new VibrationIsolator().getX3dModel();
//      System.out.println("X3D model construction complete.");
	
        // next handle command line arguments
        boolean hasArguments = (args != null) && (args.length > 0);
        boolean validate = true; // default
        boolean argumentsLoadNewModel = false;
        String  fileName = new String();

        if (args != null)
        {
                for (String arg : args)
                {
                        if (arg.toLowerCase().startsWith("-v") || arg.toLowerCase().contains("validate"))
                        {
                                validate = true; // making sure
                        }
                        if (arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3D) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_CLASSICVRML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3DB) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_VRML97) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_EXI) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_GZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_ZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_HTML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_XHTML))
                        {
                                argumentsLoadNewModel = true;
                                fileName = arg;
                        }
                }
        }
        if      (argumentsLoadNewModel)
                System.out.println("WARNING: \"Savage.Space.SatelliteLab.VibrationIsolator\" model invocation is attempting to load file \"" + fileName + "\" instead of simply validating itself... file loading ignored.");
        else if (hasArguments) // if no arguments provided, this method produces usage warning
                thisExampleX3dModel.handleArguments(args);
	
        if (validate)
        {
            //  System.out.println("--- TODO fix duplicated outputs ---"); // omit when duplicated outputs problem is solved/refactored
		String validationResults = thisExampleX3dModel.validationReport();
            //  System.out.println("-----------------------------------"); // omit when duplicated outputs problem is solved/refactored
                System.out.print("Savage.Space.SatelliteLab.VibrationIsolator self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

                // experimental: test X3DJSAIL output files
                // Space/SatelliteLab/VibrationIsolator_JavaExport.* file validation is checked when building X3D Example Archives
                String filenameX3D  = "Space/SatelliteLab/VibrationIsolator_JavaExport.x3d"; 
                String filenameX3DV = "Space/SatelliteLab/VibrationIsolator_JavaExport.x3dv"; 
                String filenameJSON = "Space/SatelliteLab/VibrationIsolator_JavaExport.json";
                thisExampleX3dModel.toFileX3D        (filenameX3D);
                thisExampleX3dModel.toFileClassicVRML(filenameX3DV);
// TODO         thisExampleX3dModel.toFileJSON       (filenameJSON);
        }
    }
}
