package Savage.ModelDetailing.HullNumbers;

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

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> 3D Hull Number. </p>
 <p> Related links: Catalog page <a href="../../../../ModelDetailing/HullNumbers/FourIndex.html" target="_blank">Four</a>,  source <a href="../../../../ModelDetailing/HullNumbers/Four.java">Four.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="../../../../ModelDetailing/HullNumbers/Four.x3d">Four.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> 3D Hull Number </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Patrick Sullivan </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 20 February 2006 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 20 October 2019 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> version </i> </td>
			<td> 1.0 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> subject </i> </td>
			<td> Hull Numbers, ship markings </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/ModelDetailing/HullNumbers/Four.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/ModelDetailing/HullNumbers/Four.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../../../../ModelDetailing/HullNumbers/../../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 Patrick Sullivan
 */

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

	/** Create and initialize the X3D model for this object. */
	public final void initialize()
	{
            try { // catch-all
  x3dModel = new X3D().setProfile(X3D.PROFILE_IMMERSIVE).setVersion(X3D.VERSION_3_1)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("Four.x3d"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("3D Hull Number"))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Patrick Sullivan"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("20 February 2006"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("20 October 2019"))
    .addMeta(new meta().setName(meta.NAME_VERSION    ).setContent("1.0"))
    .addMeta(new meta().setName(meta.NAME_SUBJECT    ).setContent("Hull Numbers, ship markings"))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/ModelDetailing/HullNumbers/Four.x3d"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addChild(new WorldInfo().setTitle("Four.x3d"))
    .addChild(new Group("Four")
      .addChild(new Transform("dad_HullNumber4_copy15")
        .addChild(new Shape("HullNumber4_copy15")
          .setAppearance(new Appearance()
            .setMaterial(new Material("white2_mat").setAmbientIntensity(1).setDiffuseColor(1.0,1.0,1.0).setShininess(0).setSpecularColor(1.0,1.0,1.0)))
          .setGeometry(new IndexedFaceSet().setCreaseAngle(0.524).setCoordIndex(getIndexedFaceSet_6_14_coordIndex())
            .setCoord(new Coordinate().setPoint(getCoordinate_7_14_point())))))
      .addChild(new Transform("dad_HullNumber4")
        .addChild(new Shape("HullNumber4")
          .setAppearance(new Appearance()
            .setMaterial(new Material("main_mat").setAmbientIntensity(0.001).setDiffuseColor(.001,.001,.001).setShininess(0).setSpecularColor(.001,.001,.001)))
          .setGeometry(new IndexedFaceSet().setCreaseAngle(0.524).setCoordIndex(getIndexedFaceSet_6_20_coordIndex())
            .setCoord(new Coordinate().setPoint(getCoordinate_7_20_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[] getIndexedFaceSet_6_14_coordIndex_1()
		{
			int[] value = {0,1,2,-1,0,2,3,-1,0,3,4,-1,0,4,5,-1,0,6,7,-1,0,7,8,-1,0,5,9,-1,0,9,6,-1,0,8,10,-1,0,10,1,-1,1,11,12,-1,1,12,13,-1,1,13,2,-1,1,10,14,-1,1,14,11,-1,11,14,15,-1,11,15,12,-1,12,15,16,-1,12,16,13,-1,13,16,17,-1,13,17,2,-1,2,17,18,-1,2,18,3,-1,3,19,20,-1,3,20,4,-1,3,18,21,-1,3,21,19,-1,19,22,20,-1,19,21,23,-1,19,23,22,-1,22,23,24,-1,22,24,20,-1,20,25,26,-1,20,26,4,-1,20,24,27,-1,20,27,25,-1,25,27,28,-1,25,28,26,-1,26,28,29,-1,26,29,4,-1,4,30,31,-1,4,31,5,-1,4,29,32,-1,4,32,30,-1,30,33,34,-1,30,34,35,-1,30,35,36,-1,30,36,31,-1,30,32,37,-1,30,37,33,-1,33,37,38,-1,33,38,34,-1,34,38,39,-1,34,39,35,-1,35,40,41,-1,35,41,36,-1,35,39,42,-1,35,42,40,-1,40,43,44,-1,40,44,41,-1,40,42,45,-1,40,45,43,-1,43,46,6,-1,43,6,44,-1,43,45,47,-1,43,47,46,-1,46,48,6,-1,46,47,49,-1,46,49,48,-1,48,49,7,-1,48,7,6,-1,6,9,44,-1,5,31,50,-1,5,50,51,-1,5,51,52,-1,5,52,9,-1,9,52,53,-1,9,53,44,-1,44,53,54,-1,44,54,41,-1,41,54,55,-1,41,55,36,-1,36,55,50,-1,36,50,31,-1,8,18,17,-1,8,17,10,-1,8,7,52,-1,8,52,51,-1,8,51,29,-1,8,29,18,-1,10,15,14,-1,10,17,16,-1,10,16,15,-1,18,29,24,-1,18,24,21,-1,21,24,23,-1,24,29,28,-1,24,28,27,-1,29,51,50,-1,29,50,32,-1,32,38,37,-1,32,55,39,-1,32,39,38,-1,32,50,55,-1,39,55,54,-1,39,54,42,-1,42,54,53,-1,42,53,45,-1,45,53,7,-1,45,7,47,-1,47,7,49,-1,7,53,52,-1};
			return value;
		}



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


		/** Large attribute array: IndexedFaceSet coordIndex field, scene-graph level=6, element #14, 448 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 getIndexedFaceSet_6_14_coordIndex()
		{
			MFInt32 IndexedFaceSet_6_14_coordIndex = new MFInt32()/*2.finalize*/
				.append(new MFInt32(getIndexedFaceSet_6_14_coordIndex_1()));
			return IndexedFaceSet_6_14_coordIndex;
		}
		/** Large attribute array: Coordinate point field, scene-graph level=7, element #14, 168 total numbers made up of 56 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 getCoordinate_7_14_point()
		{
			MFVec3f Coordinate_7_14_point = new MFVec3f(new double[] {-.1019,.28551,-.04102,-.1019,.15172,-.04102,.24478,.15172,-.04102,.24478,.28551,-.04102,.24478,.5941,-.04102,-.1019,.5941,-.04102,-.4642,.28551,-.04102,-.47423,.28232,-.2,-.11192,.28232,-.2,-.2933,.5941,-.04102,-.11192,.14854,-.2,-.1019,.01793,-.04102,.07144,.01793,-.04102,.24478,.01793,-.04102,-.11192,.01475,-.2,.06142,.01475,-.2,.23476,.01475,-.2,.23476,.14854,-.2,.23476,.28232,-.2,.33463,.28551,-.04102,.42447,.4398,-.04102,.3246,.28232,-.2,.42447,.28551,-.04102,.41445,.28232,-.2,.41445,.43662,-.2,.42447,.5941,-.04102,.33463,.5941,-.04102,.41445,.59092,-.2,.3246,.59092,-.2,.23476,.59092,-.2,.24478,1.03404,-.04102,-.1019,.8192,-.04102,.23476,1.03086,-.2,.24478,1.47398,-.04102,.07144,1.47398,-.04102,-.1019,1.47398,-.04102,-.1019,1.0443,-.04102,.23476,1.4708,-.2,.06142,1.4708,-.2,-.11192,1.4708,-.2,-.4642,1.04332,-.04102,-.2933,.8192,-.04102,-.47423,1.04014,-.2,-.82651,.61266,-.04102,-.48471,.5941,-.04102,-.83653,.60947,-.2,-.82651,.44908,-.04102,-.83653,.4459,-.2,-.82651,.28551,-.04102,-.83653,.28232,-.2,-.11192,.81602,-.2,-.11192,.59092,-.2,-.30333,.59092,-.2,-.49473,.59092,-.2,-.30333,.81602,-.2,-.11192,1.04111,-.2});
			return Coordinate_7_14_point;
		}
		/** Large attribute array: IndexedFaceSet coordIndex field, scene-graph level=6, element #20, 448 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 getIndexedFaceSet_6_20_coordIndex()
		{
			MFInt32 IndexedFaceSet_6_20_coordIndex = new MFInt32()/*2.finalize*/
				.append(new MFInt32(getIndexedFaceSet_6_20_coordIndex_1()));
			return IndexedFaceSet_6_20_coordIndex;
		}
		/** Large attribute array: Coordinate point field, scene-graph level=7, element #20, 168 total numbers made up of 56 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 getCoordinate_7_20_point()
		{
			MFVec3f Coordinate_7_20_point = new MFVec3f(new double[] {.04346,.27076,-.08798,.04346,.13697,-.08798,.39014,.13697,-.08798,.39014,.27076,-.08798,.39014,.57935,-.08798,.04346,.57935,-.08798,-.31884,.27076,-.08798,-.32886,.26758,-.24696,.03344,.26758,-.24696,-.14794,.57935,-.08798,.03344,.13379,-.24696,.04346,.00318,-.08798,.2168,.00318,-.08798,.39014,.00318,-.08798,.03344,0.0,-.24696,.20678,0.0,-.24696,.38012,0.0,-.24696,.38012,.13379,-.24696,.38012,.26758,-.24696,.47999,.27076,-.08798,.56983,.42506,-.08798,.46997,.26758,-.24696,.56983,.27076,-.08798,.55981,.26758,-.24696,.55981,.42188,-.24696,.56983,.57935,-.08798,.47999,.57935,-.08798,.55981,.57617,-.24696,.46997,.57617,-.24696,.38012,.57617,-.24696,.39014,1.0193,-.08798,.04346,.80445,-.08798,.38012,1.01611,-.24696,.39014,1.45924,-.08798,.2168,1.45924,-.08798,.04346,1.45924,-.08798,.04346,1.02955,-.08798,.38012,1.45605,-.24696,.20678,1.45605,-.24696,.03344,1.45605,-.24696,-.31884,1.02857,-.08798,-.14794,.80445,-.08798,-.32886,1.02539,-.24696,-.68115,.59791,-.08798,-.33935,.57935,-.08798,-.69117,.59473,-.24696,-.68115,.43434,-.08798,-.69117,.43115,-.24696,-.68115,.27076,-.08798,-.69117,.26758,-.24696,.03344,.80127,-.24696,.03344,.57617,-.24696,-.15796,.57617,-.24696,-.34937,.57617,-.24696,-.15796,.80127,-.24696,.03344,1.02637,-.24696});
			return Coordinate_7_20_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 Four 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 Four().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.ModelDetailing.HullNumbers.Four\" 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.ModelDetailing.HullNumbers.Four self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

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