[x3d-public] X3DJSAIL progress report: need USE

Don Brutzman brutzman at nps.edu
Tue Mar 21 01:45:43 PDT 2017


John, thanks for noting omissions and errors in USE handling.

Now fixed and deployed.  "Smoke test" https://en.wikipedia.org/wiki/Smoke_testing_(software)
as usual is found at

	http://www.web3d.org/specifications/java/X3DJSAIL.html#Examples
	http://www.web3d.org/specifications/java/examples/HelloWorldProgram.java
	http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.txt
	http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d

		worldInfoNode.setTitle ("HelloWorldProgram produced by X3D Java SAI Library (X3DJSAIL)");
		worldInfoCopy1.setUSE(worldInfoDEFname); // setUSE via string
		worldInfoCopy2.setUSE(worldInfoNode);    // setUSE via node
//		worldInfoCopy2.addComments("test exception at runtime"); // test sat: cannot add content to USE node
		scene.addChildren(worldInfoNode);
		scene.addChildren(worldInfoCopy1);
		scene.addChildren(worldInfoCopy2);

resulting in correct output

         <WorldInfo DEF='WorldInfoDEF' title='HelloWorldProgram produced by X3D Java SAI Library (X3DJSAIL)'/>
         <WorldInfo USE='WorldInfoDEF'/>
         <WorldInfo USE='WorldInfoDEF'/>

Also worked to add run-time exception if adding comments to USE nodes, will think about further exceptions if adding child nodes to USE nodes... Trying not to get too draconian while constructing, since sometimes work is needed on multiple nodes to create a valid subgraph.

This error (USE node with children elements) is now caught by the validation() method found on each object.

Per your suggestion, have also added a second setUSE method customized for each node type, letting a programmer create a USE node by giving the method a reference to the DEFnode (as opposed to a DEF string).  Example internal code:

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CADGeometry/CADLayerObject.html#setUSE-org.web3d.x3d.jsail.CADGeometry.CADLayerObject-

	/**
	 * Assign a USE reference to another DEF node of same node type, similar to {@link #setUSE(String)}.
	 * @param DEFnode must have a DEF value defined
	 // return void (no pipelining) since no further operations expected on USE node
	 */
	public void setUSE(CADLayerObject DEFnode)
	{
		if (DEFnode.getDEF().isEmpty())
		{
			String errorNotice = "setUSE(DEFnode) invoked on CADLayerObject" +
				" that has no DEF name defined";
			validationResult.append(errorNotice).append("\n");
			throw new org.web3d.x3d.sai.InvalidFieldValueException(errorNotice);
		}
		setUSE(DEFnode.getDEF());
	}

Better and better.  Have fun with X3DJSAIL!  8)


On 3/20/2017 4:18 PM, John Carlson wrote:
> Now will setUSE take an SFString or an X3Node pointing at the other node?   For example:
>
> X3DNode defNode;
>
> ...
>
> defNode = new TransformObject()
>           .setDEF("defNode")
> ...
> new TransformObject ()
>           .setUSE(defNode)
> ...
> Or
> ...
> new TransformObject ()
>            .setUSE(defNode.getDEF())
>
> Which usage is preferred?
>
> John
>
>
> On Mar 20, 2017 11:03 AM, "Don Brutzman" <brutzman at nps.edu <mailto:brutzman at nps.edu>> wrote:
>
>     Great catch.  A lot of logic is under the hood regarding handling.
>
>     I added an example USE to HelloWorldProgram.java and found that it compiled and ran OK but is not in the serializer output.  Will work on that.
>
>     On 3/20/2017 5:20 AM, John Carlson wrote:
>
>         Does this update include USE field output?   I will check your TXT file.

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list