package Savage.CommunicationsAndSensors.Beam;

import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.EnvironmentalEffects.*;
import org.web3d.x3d.jsail.fields.*;
import org.web3d.x3d.jsail.Geometry3D.*;
import org.web3d.x3d.jsail.Grouping.*;
import org.web3d.x3d.jsail.Navigation.*;
import org.web3d.x3d.jsail.Networking.*;
import org.web3d.x3d.jsail.Rendering.*;
import org.web3d.x3d.jsail.Scripting.*;
import org.web3d.x3d.jsail.Shape.*;
import org.web3d.x3d.jsail.Text.*;

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> Produce wireframe or transparent beam cones. </p>
 <p> Related links: Catalog page <a href="../../../../CommunicationsAndSensors/Beam/BeamConePrototypeIndex.html" target="_blank">BeamConePrototype</a>,  source <a href="../../../../CommunicationsAndSensors/Beam/BeamConePrototype.java">BeamConePrototype.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="../../../../CommunicationsAndSensors/Beam/BeamConePrototype.x3d">BeamConePrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Don Brutzman </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 7 December 2000 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 12 October 2023 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> Produce wireframe or transparent beam cones. </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/CommunicationsAndSensors/Beam/BeamConePrototype.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConePrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> <a href="http://faculty.nps.edu/brutzman/vrtp/demo/auv/BeamConePrototype.x3d" target="_blank">http://faculty.nps.edu/brutzman/vrtp/demo/auv/BeamConePrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> <a href="https://www.web3d.org/WorkingGroups/vrtp/demo/auv/BeamConePrototype.x3d" target="_blank">https://www.web3d.org/WorkingGroups/vrtp/demo/auv/BeamConePrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> generator </i> </td>
			<td> X3D-Edit 4.0, <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="../../../../CommunicationsAndSensors/Beam/../../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 Don Brutzman
 */

public class BeamConePrototype
{
	/** Default constructor to create this object. */
	public BeamConePrototype ()
	{
	  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_3)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("BeamConePrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Don Brutzman"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("7 December 2000"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("12 October 2023"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("Produce wireframe or transparent beam cones."))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConePrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_REFERENCE  ).setContent("http://faculty.nps.edu/brutzman/vrtp/demo/auv/BeamConePrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_REFERENCE  ).setContent("https://www.web3d.org/WorkingGroups/vrtp/demo/auv/BeamConePrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_GENERATOR  ).setContent("X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addChild(new NavigationInfo("LockedDownInterface2D").setType(new String[] {"NONE"}))
    .addChild(new Background().setSkyColor(new MFColor(new double[] {0.0,0.3,0.5})))
    .addChild(new WorldInfo().setInfo(new String[] {"Produce wireframe or transparent beam cones"}).setTitle("BeamConeProto"))
    .addChild(new Viewpoint().setDescription("Beam Cone").setPosition(0.0,0.0,15.0))
    .addChild(new ProtoDeclare("BeamCone").setName("BeamCone").setAppinfo("Produce wireframe or transparent beam cones. Typical uses include propeller/thruster water flow or line-of-sight sonar/radar/light beams. Negative range values invert base and apex at same relative location. Default: beam with apex at (0 0 0) and base of radius 1 in x-z plane at (1 0 0).")
      .setProtoInterface(new ProtoInterface()
        .addField(new field().setName("name").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue("(unnamed)").setAppinfo("BeamCone name aids in node identification and tracing"))
        .addField(new field().setName("contact").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("(communications) is transmitted signal in contact with receiver or (sensor) is a target return detected?"))
        .addField(new field().setName("range").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("distance in meters along x axis"))
        .addField(new field().setName("defaultRange").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(1).setAppinfo("distance in meters used until eventIn range sent"))
        .addField(new field().setName("wireframe").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(true).setAppinfo("whether wireframe beam is drawn"))
        .addField(new field().setName("solid").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(true).setAppinfo("whether solid beam is drawn"))
        .addField(new field().setName("beamHeightDegrees").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(10).setAppinfo("degrees across vertical y axis"))
        .addField(new field().setName("beamWidthDegrees").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(10).setAppinfo("degrees across horizontal z axis"))
        .addField(new field().setName("contactColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(new SFColor(.8,.1,.1)).setAppinfo("rendering color when contact=true"))
        .addField(new field().setName("noContactColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(new SFColor(.3,.5,.5)).setAppinfo("rendering color when contact=false"))
        .addField(new field().setName("transparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(0).setAppinfo("1 = fully transparent wireframe only"))
        .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(false).setAppinfo("flag to turn on Script tracing"))
        .addComments(" BEAM_CONTROL beam scaling is controlled by range/beamHeightDegrees/beamWidthDegrees/direction inputs "))
      .setProtoBody(new ProtoBody()
        .addChild(new Transform("BEAM_CONTROL")
          .addChild(new Switch("WIREFRAME_SWITCH").setWhichChoice(0)
            .addChild(new WorldInfo().setInfo(new String[] {"initial choice is null node (WorldInfo), meaning no wireframe beam"}))
            .addChild(new Shape()
              .setAppearance(new Appearance()
                .setMaterial(new Material("WIRE_COLOR").setDiffuseColor(.1,.1,.1).setEmissiveColor(.1,.1,.1)
                  .setIS(new IS()
                    .addConnect(new connect().setNodeField("transparency").setProtoField("transparency")))))
              .setGeometry(new IndexedLineSet().setCoordIndex(new int[] {0,13,-1,1,2,3,4,5,6,7,8,9,10,11,12,1,-1,0,1,-1,0,2,-1,0,3,-1,0,4,-1,0,5,-1,0,6,-1,0,7,-1,0,8,-1,0,9,-1,0,10,-1,0,11,-1,0,12,-1})
                .setCoord(new Coordinate().setPoint(new MFVec3f(new double[] {0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.86,0.50,1.0,0.50,0.86,1.0,0.0,1.0,1.0,-0.50,0.86,1.0,-0.86,0.50,1.0,-1.0,0.0,1.0,-0.86,-0.50,1.0,-0.50,-0.86,1.0,0.0,-1.0,1.0,0.50,-0.86,1.0,0.86,-0.50,1.0,0.0,0.0}))))))
          .addChild(new Switch("SOLID_SWITCH").setWhichChoice(0)
            .addChild(new WorldInfo().setInfo(new String[] {"initial choice is null node (WorldInfo), meaning no solid beam"}))
            .addChild(new Transform().setRotation(0.0,0.0,1.0,1.57079).setTranslation(.5,0.0,0.0)
              .addChild(new Shape()
                .setAppearance(new Appearance()
                  .setMaterial(new Material("CONE_COLOR").setDiffuseColor(.1,.1,.1)
                    .setIS(new IS()
                      .addConnect(new connect().setNodeField("transparency").setProtoField("transparency")))))
                .addComments(" solid='false' is harder to recognize properly, use default solid='true' ")
                .setGeometry(new Cone().setBottom(false).setHeight(1))))))
        .addComments(" Non-renderable animation controls ")
        .addChild(new Script("DETECTION").setSourceCode("""
ecmascript:
function initialize ()
{
	beamColor = noContactColor;
	if (wireframe == true) wireframeChoice = 1;
	if (solid     == true) solidChoice     = 1;
	if (traceEnabled)
	{
//		Browser.println ('[BeamCone ' + name + '] trace=' + trace);
		Browser.println ('[BeamCone ' + name + '] wireframeChoice=' + wireframeChoice + ', solidChoice=' + solidChoice);
		Browser.println ('[BeamCone ' + name + '] contactColor=' + contactColor.toString() + ', noContactColor=' + noContactColor.toString());
	}
}
function contact (newDetect, timeStamp)
{
	if (newDetect) beamColor = contactColor;
	else           beamColor = noContactColor;
	if (traceEnabled) Browser.println ('[BeamCone ' + name + '] contact=' + newDetect + ', beamColor=' + beamColor.toString());
}
""")
          .addField(new field().setName("name").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("BeamCone name aids tracing"))
          .addField(new field().setName("contact").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY))
          .addField(new field().setName("wireframe").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
          .addField(new field().setName("solid").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
          .addField(new field().setName("contactColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
          .addField(new field().setName("noContactColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
          .addField(new field().setName("beamColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
          .addField(new field().setName("wireframeChoice").setType(field.TYPE_SFINT32).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
          .addField(new field().setName("solidChoice").setType(field.TYPE_SFINT32).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
          .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("internal flag to turn on Script tracing"))
          .setIS(new IS()
            .addConnect(new connect().setNodeField("name").setProtoField("name"))
            .addConnect(new connect().setNodeField("contact").setProtoField("contact"))
            .addConnect(new connect().setNodeField("wireframe").setProtoField("wireframe"))
            .addConnect(new connect().setNodeField("solid").setProtoField("solid"))
            .addConnect(new connect().setNodeField("contactColor").setProtoField("contactColor"))
            .addConnect(new connect().setNodeField("noContactColor").setProtoField("noContactColor"))
            .addConnect(new connect().setNodeField("traceEnabled").setProtoField("traceEnabled"))))
        .addChild(new Script("BEAM_CALCULATE").setSourceCode("""
ecmascript:
function initialize () {
 // Note that X3D scale factor triplets all equal to zero are not allowed
 if (defaultRange == 0)      defaultRange = .0001;
 if (beamHeightDegrees == 0) beamHeightDegrees = .0001;
 if (beamWidthDegrees  == 0) beamWidthDegrees  = .0001;
 beamHeightFactor= Math.sin ((beamHeightDegrees * 3.141592653 / 180.0) / 2.0);
 beamWidthFactor = Math.sin ((beamWidthDegrees  * 3.141592653 / 180.0) / 2.0);
 beamScale = new SFVec3f ( defaultRange, defaultRange * beamHeightFactor, defaultRange * beamWidthFactor);
}
function range (newRange, timeStamp) {
 beamHeightFactor= Math.sin ((beamHeightDegrees * 3.141592653 / 180.0) / 2.0);
 beamWidthFactor = Math.sin ((beamWidthDegrees  * 3.141592653 / 180.0) / 2.0);
 if (newRange < 0)
 {
   direction     = new SFRotation (0, 1, 0, 3.141592653);
   reverseOffset = new SFVec3f (- newRange, 0, 0);
   beamScale = new SFVec3f (-newRange, -newRange * beamHeightFactor, -newRange * beamWidthFactor);
 }
 else if (newRange == 0)
 {
   direction     = new SFRotation (0, 1, 0, 0);
   reverseOffset = new SFVec3f (0, 0, 0);
   beamScale = new SFVec3f ( .0001, .0001, .0001 );
 }
 else
 {
   direction     = new SFRotation (0, 1, 0, 0);
   reverseOffset = new SFVec3f (0, 0, 0);
   beamScale = new SFVec3f (newRange, newRange * beamHeightFactor, newRange * beamWidthFactor);
 }
}
""")
          .addField(new field().setName("range").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY))
          .addField(new field().setName("defaultRange").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
          .addField(new field().setName("beamHeightDegrees").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
          .addField(new field().setName("beamWidthDegrees").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
          .addField(new field().setName("beamScale").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
          .addField(new field().setName("direction").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
          .addField(new field().setName("reverseOffset").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
          .setIS(new IS()
            .addConnect(new connect().setNodeField("range").setProtoField("range"))
            .addConnect(new connect().setNodeField("defaultRange").setProtoField("defaultRange"))
            .addConnect(new connect().setNodeField("beamHeightDegrees").setProtoField("beamHeightDegrees"))
            .addConnect(new connect().setNodeField("beamWidthDegrees").setProtoField("beamWidthDegrees"))))
        .addChild(new ROUTE().setFromNode("DETECTION").setFromField("beamColor").setToNode("WIRE_COLOR").setToField("emissiveColor"))
        .addChild(new ROUTE().setFromNode("DETECTION").setFromField("beamColor").setToNode("CONE_COLOR").setToField("emissiveColor"))
        .addChild(new ROUTE().setFromNode("DETECTION").setFromField("wireframeChoice").setToNode("WIREFRAME_SWITCH").setToField("whichChoice"))
        .addChild(new ROUTE().setFromNode("DETECTION").setFromField("solidChoice").setToNode("SOLID_SWITCH").setToField("whichChoice"))
        .addChild(new ROUTE().setFromNode("BEAM_CALCULATE").setFromField("beamScale").setToNode("BEAM_CONTROL").setToField("scale"))
        .addChild(new ROUTE().setFromNode("BEAM_CALCULATE").setFromField("direction").setToNode("BEAM_CONTROL").setToField("rotation"))
        .addChild(new ROUTE().setFromNode("BEAM_CALCULATE").setFromField("reverseOffset").setToNode("BEAM_CONTROL").setToField("translation"))))
    .addComments(" Viewable geometry for this scene is anchored text that links to an example showing ExternProtoDeclare usage of BeamCone ")
    .addChild(new Anchor().setDescription("Beam Cone Example").setUrl(new String[] {"BeamConeExample.x3d","https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConeExample.x3d","BeamConeExample.wrl","https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamConeExample.wrl"})
      .addChild(new Shape()
        .setAppearance(new Appearance()
          .setMaterial(new Material().setDiffuseColor(0.0,1.0,1.0).setEmissiveColor(0.0,1.0,1.0)))
        .setGeometry(new Text().setString(new String[] {"BeamConePrototype","is a Prototype definition file.","","To see an example scene","click this text and view","BeamConeExample."})
          .setFontStyle(new FontStyle().setJustify(FontStyle.JUSTIFY_MIDDLE_MIDDLE))))
      .addChild(new Shape()
        .addComments(" transparent Box as text-selection assist ")
        .setGeometry(new Box().setSize(11.0,6.0,.001))
        .setAppearance(new Appearance()
          .setMaterial(new Material().setTransparency(1))))));
            }
            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

	/** 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 BeamConePrototype 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 BeamConePrototype().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.CommunicationsAndSensors.Beam.BeamConePrototype\" 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.CommunicationsAndSensors.Beam.BeamConePrototype self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

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