package X3dForAdvancedModeling.Buildings;
/*
Copyright (c) 1995-2022 held by the author(s). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of the Web3D Consortium (https://www.web3d.org)
nor the names of its contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
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 annotations follow, see below for Java source code.
/**
*
Create an arch. Parameters are: clearSpanWidth=4; riseHeight=2; depth=3; topAbutmentHeight=0.5; pierWidth=0.5; pierHeight=1. Modify them with Transform scale or editing the IndexedFileSet node. See the reference file ArchModelingDiagrams.pdf and the ArchScript_more_readable.js script to find further information.
Related links: Arch.java source, Arch catalog page, X3D Resources, X3D Scene Authoring Hints, and X3D Tooltips.
This program uses the
X3D Java Scene Access Interface Library (X3DJSAIL).
It has been produced using the
X3dToJava.xslt
stylesheet to create Java source code from an .x3d
model.
* @author Michele Foti, Don Brutzman
*/
public class Arch
{
/** Default constructor to create this object. */
public Arch ()
{
initialize();
}
/** Create and initialize the X3D model for this object. */
public final void initialize()
{
x3dModel = new X3D().setProfile(X3D.PROFILE_INTERCHANGE).setVersion(X3D.VERSION_3_3)
.setHead(new head()
.addMeta(new meta().setName(meta.NAME_TITLE ).setContent("Arch.x3d"))
.addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("Create an arch. Parameters are: clearSpanWidth=4; riseHeight=2; depth=3; topAbutmentHeight=0.5; pierWidth=0.5; pierHeight=1. Modify them with Transform scale or editing the IndexedFileSet node. See the reference file ArchModelingDiagrams.pdf and the ArchScript_more_readable.js script to find further information."))
.addMeta(new meta().setName(meta.NAME_CREATOR ).setContent("Michele Foti, Don Brutzman"))
.addMeta(new meta().setName(meta.NAME_CREATED ).setContent("15 December 2014"))
.addMeta(new meta().setName(meta.NAME_MODIFIED ).setContent("20 October 2019"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("ArchModelingDiagrams.pdf"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("https://en.wikipedia.org/wiki/Arch"))
.addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://x3dgraphics.com/examples/X3dForAdvancedModeling/Buildings/Arch.x3d"))
.addMeta(new meta().setName(meta.NAME_GENERATOR ).setContent("X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"))
.addMeta(new meta().setName(meta.NAME_LICENSE ).setContent("../license.html")))
.setScene(new Scene()
.addChild(new WorldInfo().setTitle("Arch.x3d"))
.addChild(new Shape("Arch")
.addComments(" note that convex='false' (meaning concave geometry) is crucial for this IFS of a geometric chord to render properly ")
.setGeometry(new IndexedFaceSet("ArchIndex").setDEF("ArchIndex").setConvex(false).setSolid(false).setCoordIndex(getArchIndex_4_13_coordIndex())
.setCoord(new Coordinate("ArchChoord").setPoint(getArchChoord_5_13_point())))
.setAppearance(new Appearance()
.setMaterial(new Material("MaterialNode").setDiffuseColor(1.0,0.75,0.25)))));
}
// end of initialize() method
/** Define subarrays using type int[] */
private int[] getArchIndex_4_13_coordIndex_1()
{
int[] value = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,153,-1,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,144,-1,136,137,0,139,-1,0,139,152,153,-1,152,135,155,153,-1,149,31,153,155,-1,149,31,144,147,-1,134,147,144,145,-1,145,144,62,141,-1,132,133,141,62,-1,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,150,-1,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,143,-1,130,131,63,138,-1,63,138,151,150,-1,150,151,129,154,-1,94,150,154,148,-1,148,94,143,146,-1,142,128,146,143,-1,140,125,143,142,-1,125,126,127,140,-1,0,63,64,1,-1,1,64,65,2,-1,2,65,66,3,-1,3,66,67,4,-1,4,67,68,5,-1,5,68,69,6,-1,6,69,70,7,-1,7,70,71,8,-1,8,71,72,9,-1,9,72,73,10,-1,10,73,74,11,-1,11,74,75,12,-1,12,75,76,13,-1,13,76,77,14,-1,14,77,78,15,-1,15,78,79,16,-1,16,79,80,17,-1,17,80,81,18,-1,18,81,82,19,-1,19,82,83,20,-1,20,83,84,21,-1,21,84,85,22,-1,22,85,86,23,-1,23,86,87,24,-1,24,87,88,25,-1,25,88,89,26,-1,26,89,90,27,-1,27,90,91,28,-1,28,91,92,29,-1,29,92,93,30,-1,30,93,94,31,-1,31,94,95,32,-1,32,95,96,33,-1,33,96,97,34,-1,34,97,98,35,-1,35,98,99,36,-1,36,99,100,37,-1,37,100,101,38,-1,38,101,102,39,-1,39,102,103,40,-1,40,103,104,41,-1,41,104,105,42,-1,42,105,106,43,-1,43,106,107,44,-1,44,107,108,45,-1,45,108,109,46,-1,46,109,110,47,-1,47,110,111,48,-1,48,111,112,49,-1,49,112,113,50,-1,50,113,114,51,-1,51,114,115,52,-1,52,115,116,53,-1,53,116,117,54,-1,54,117,118,55,-1,55,118,119,56,-1,56,119,120,57,-1,57,120,121,58,-1,58,121,122,59,-1,59,122,123,60,-1,60,123,124,61,-1,61,124,125,62,-1,0,63,131,137,-1,131,130,136,137,-1,130,136,139,138,-1,138,139,152,151,-1,151,152,135,129,-1,129,135,155,154,-1,148,154,155,149,-1,148,149,147,146,-1,146,147,134,128,-1,128,134,145,142,-1,140,141,145,142,-1,127,133,141,140,-1,127,126,132,133,-1,126,132,62,125,-1,63,138,139,0,-1,150,151,152,153,-1,150,153,31,94,-1,31,94,143,144,-1,142,143,144,145,-1,140,125,62,141,-1};
return value;
}
/** Define subarrays using type double[] */
private double[] getArchChoord_5_13_point_1()
{
double[] value = {2.0,0.0,0.0,1.9974984355438178,0.1,0.0,1.98997487421324,0.2,0.0,1.977371993328519,0.3,0.0,1.9595917942265423,0.4,0.0,1.9364916731037084,0.5,0.0,1.9078784028338912,0.6,0.0,1.8734993995195193,0.7,0.0,1.833030277982336,0.8,0.0,1.786057109949175,0.9,0.0,1.7320508075688775,1.0,0.0,1.6703293088490067,1.1,0.0,1.60,1.2,0.0,1.5198684153570664,1.3,0.0,1.42828568570857,1.4,0.0,1.3228756555322953,1.5,0.0,1.20,1.6,0.0,1.0535653752852738,1.7,0.0,0.9020947843768965,1.785,0.0,0.7599342076785332,1.85,0.0,0.6244997998398398,1.9,0.0,0.5425633603552677,1.925,0.0,0.4444097208657794,1.95,0.0,0.36181625170796194,1.967,0.0,0.2821347195933173,1.98,0.0,0.19974984355438343,1.99,0.0,0.16718552568927703,1.993,0.0,0.14133294025102578,1.995,0.0,0.10950342460398415,1.997,0.0,0.08942035562443252,1.998,0.0,0.06323764701505419,1.999,0.0,0.0,2.0,0.0,-0.06323764701505419,1.999,0.0,-0.08942035562443252,1.998,0.0,-0.10950342460398415,1.997,0.0,-0.14133294025102578,1.995,0.0,-0.16718552568927703,1.993,0.0,-0.19974984355438343,1.99,0.0,-0.2821347195933173,1.98,0.0,-0.36181625170796194,1.967,0.0,-0.4444097208657794,1.95,0.0,-0.5425633603552677,1.925,0.0,-0.6244997998398398,1.9,0.0,-0.7599342076785332,1.85,0.0,-0.9020947843768965,1.785,0.0,-1.0535653752852738,1.7,0.0,-1.20,1.6,0.0,-1.3228756555322953,1.5,0.0,-1.42828568570857,1.4,0.0,-1.5198684153570664,1.3,0.0,-1.60,1.2,0.0,-1.6703293088490067,1.1,0.0,-1.7320508075688775,1.0,0.0,-1.786057109949175,0.9,0.0,-1.833030277982336,0.8,0.0,-1.8734993995195193,0.7,0.0,-1.9078784028338912,0.6,0.0,-1.9364916731037084,0.5,0.0,-1.9595917942265423,0.4,0.0,-1.977371993328519,0.3,0.0,-1.98997487421324,0.2,0.0,-1.9974984355438178,0.1,0.0,-2.0,0.0,0.0,2.0,0.0,3.0,1.9974984355438178,0.1,3.0,1.98997487421324,0.2,3.0,1.977371993328519,0.3,3.0,1.9595917942265423,0.4,3.0,1.9364916731037084,0.5,3.0,1.9078784028338912,0.6,3.0,1.8734993995195193,0.7,3.0,1.833030277982336,0.8,3.0,1.786057109949175,0.9,3.0,1.7320508075688775,1.0,3.0,1.6703293088490067,1.1,3.0,1.60,1.2,3.0,1.5198684153570664,1.3,3.0,1.42828568570857,1.4,3.0,1.3228756555322953,1.5,3.0,1.20,1.6,3.0,1.0535653752852738,1.7,3.0,0.9020947843768965,1.785,3.0,0.7599342076785332,1.85,3.0,0.6244997998398398,1.9,3.0,0.5425633603552677,1.925,3.0,0.4444097208657794,1.95,3.0,0.36181625170796194,1.967,3.0,0.2821347195933173,1.98,3.0,0.19974984355438343,1.99,3.0,0.16718552568927703,1.993,3.0,0.14133294025102578,1.995,3.0,0.10950342460398415,1.997,3.0,0.08942035562443252,1.998,3.0,0.06323764701505419,1.999,3.0,0.0,2.0,3.0,-0.06323764701505419,1.999,3.0,-0.08942035562443252,1.998,3.0,-0.10950342460398415,1.997,3.0,-0.14133294025102578,1.995,3.0,-0.16718552568927703,1.993,3.0};
return value;
}
private double[] getArchChoord_5_13_point_2()
{
double[] value = {-0.19974984355438343,1.99,3.0,-0.2821347195933173,1.98,3.0,-0.36181625170796194,1.967,3.0,-0.4444097208657794,1.95,3.0,-0.5425633603552677,1.925,3.0,-0.6244997998398398,1.9,3.0,-0.7599342076785332,1.85,3.0,-0.9020947843768965,1.785,3.0,-1.0535653752852738,1.7,3.0,-1.20,1.6,3.0,-1.3228756555322953,1.5,3.0,-1.42828568570857,1.4,3.0,-1.5198684153570664,1.3,3.0,-1.60,1.2,3.0,-1.6703293088490067,1.1,3.0,-1.7320508075688775,1.0,3.0,-1.786057109949175,0.9,3.0,-1.833030277982336,0.8,3.0,-1.8734993995195193,0.7,3.0,-1.9078784028338912,0.6,3.0,-1.9364916731037084,0.5,3.0,-1.9595917942265423,0.4,3.0,-1.977371993328519,0.3,3.0,-1.98997487421324,0.2,3.0,-1.9974984355438178,0.1,3.0,-2.0,0.0,3.0,-2.0,-1.0,3.0,-2.5,-1.0,3.0,-2.5,2.5,3.0,2.5,2.5,3.0,2.5,-1.0,3.0,2.0,-1.0,3.0,-2.0,-1.0,0.0,-2.5,-1.0,0.0,-2.5,2.5,0.0,2.5,2.5,0.0,2.5,-1.0,0.0,2.0,-1.0,0.0,2.5,0.0,3.0,2.5,0.0,0.0,-2.5,0.0,3.0,-2.5,0.0,0.0,-2.5,2.0,3.0,-2.0,2.0,3.0,-2.0,2.0,0.0,-2.5,2.0,0.0,-2.0,2.5,3.0,-2.0,2.5,0.0,0.0,2.5,3.0,0.0,2.5,0.0,2.0,2.0,3.0,2.5,2.0,3.0,2.5,2.0,0.0,2.0,2.0,0.0,2.0,2.5,3.0,2.0,2.5,0.0};
return value;
}
/** Large attribute array: IndexedFaceSet DEF='ArchIndex' coordIndex field, scene-graph level=4, element #13, 626 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 getArchIndex_4_13_coordIndex()
{
MFInt32 ArchIndex_4_13_coordIndex = new MFInt32()/*2.finalize*/
.append(new MFInt32(getArchIndex_4_13_coordIndex_1()));
return ArchIndex_4_13_coordIndex;
}
/** Large attribute array: Coordinate DEF='ArchChoord' point field, scene-graph level=5, element #13, 468 total numbers made up of 156 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 getArchChoord_5_13_point()
{
MFVec3f ArchChoord_5_13_point = new MFVec3f()/*2.finalize*/
.append(new MFVec3f(getArchChoord_5_13_point_1()))
.append(new MFVec3f(getArchChoord_5_13_point_2()));
return ArchChoord_5_13_point;
}
/** The initialized model object, created within initialize() method. */
private X3D x3dModel;
/**
* Provide a
* shallow copy
* of the X3D model.
* @see X3D
* @return Arch 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 X3D.handleArguments(args)
* @see X3D.validationReport()
* @see CommandLine
* @see CommandLine.USAGE
* @see ConfigurationProperties
*/
public static void main(String args[])
{
X3D thisExampleX3dModel = new Arch().getX3dModel();
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: \"X3dForAdvancedModeling.Buildings.Arch\" 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.print("Java program \"X3dForAdvancedModeling.Buildings.Arch\" self-validation test results: ");
String validationResults = thisExampleX3dModel.validationReport();
if (validationResults.startsWith("\n"))
System.out.println();
System.out.println(validationResults.trim());
}
}
}