From: Marko Luukkainen Date: Mon, 26 Aug 2019 12:14:10 +0000 (+0300) Subject: SCL Test models for Plant3d X-Git-Tag: v1.43.0~202 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F59%2F3159%2F1;p=simantics%2F3d.git SCL Test models for Plant3d gitlab #28 Change-Id: I3beaec931fd327f56fd78da7f188836ad0a843cb --- diff --git a/org.simantics.plant3d/scl/Plant3d/Test/Test1.scl b/org.simantics.plant3d/scl/Plant3d/Test/Test1.scl new file mode 100644 index 00000000..879a540a --- /dev/null +++ b/org.simantics.plant3d/scl/Plant3d/Test/Test1.scl @@ -0,0 +1,97 @@ +import "Plant3d/Utils/P3DUtil" +import "Simantics/DB" +import "Plant3d/Utils/Loader" +import "G3D/SCLUtil" +import "JavaBuiltin" +import "G3D/Math/Tuple3d" as T3D +import "G3D/Math/Vector3d" as V3D +import "G3D/Scenegraph/G3DNode" as G3D +import "Plant3d/Scenegraph/P3DRootNode" as P3R +import "Plant3d/Scenegraph/P3DNode" as P3N +import "Plant3d/Scenegraph/Equipment" as E +import "Plant3d/Scenegraph/PipelineComponent" as PC +import "Plant3d/Scenegraph/EndComponent" as EC +import "Plant3d/Scenegraph/InlineComponent" as IC +import "Plant3d/Scenegraph/TurnComponent" as TC +import "Plant3d/Utils/P3DScriptNodeMap" as P3S +import "Plant3d/Utils/P3DUtil" as P3DUtil +import "Plant3d/Utils/ComponentUtils" as CU +import "http://www.simantics.org/Layer0-1.1" as L0 + +doTest :: () +doTest = do + + myModel = syncWrite(\_ -> do + myModel = P3DUtil.createModel "Test1" + claim (resource "http://Projects/Development%20Project") L0.ConsistsOf myModel + myModel) + p3dmap = load myModel + rootMaybe = javaSafeCoerce (P3S.getRootNode p3dmap) :: Maybe P3R.P3DRootNode + root = fromJust rootMaybe + pump = CU.createEquipmentWithURI root "http://www.simantics.org/Plant3D-0.1/Builtin/Pump" + P3N.setName pump "My Pump" + P3S.commit p3dmap "Created a pump" + P3S.update p3dmap + n1 = CU.createDefaultNozzle root pump + P3S.commit p3dmap "Created a nozzle" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce n1) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 1.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 90.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 2.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 180.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 1.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 180.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 4.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 180.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 4.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 270.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 1.85) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 270.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 1.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + + tank = CU.createEquipmentWithURI root "http://www.simantics.org/Plant3D-0.1/Builtin/HorizontalTank" + P3N.setName tank "My Tank" + G3D.setPosition tank (V3D.createVector3d 0.0 0.0 3.0) + P3S.commit p3dmap "Created a tank" + P3S.update p3dmap + n2 = CU.createDefaultNozzle root tank + G3D.setPosition n2 (V3D.createVector3d 0.6 0.3 0.0) + P3S.commit p3dmap "Created a nozzle" + P3S.update p3dmap + + CU.connect pipe (unsafeCoerce n2) + P3S.commit p3dmap "Connected a pipe to a nozzle" + P3S.update p3dmap + () \ No newline at end of file diff --git a/org.simantics.plant3d/scl/Plant3d/Test/Test1b.scl b/org.simantics.plant3d/scl/Plant3d/Test/Test1b.scl new file mode 100644 index 00000000..a5f9b81c --- /dev/null +++ b/org.simantics.plant3d/scl/Plant3d/Test/Test1b.scl @@ -0,0 +1,98 @@ +import "Plant3d/Utils/P3DUtil" +import "Simantics/DB" +import "Plant3d/Utils/Loader" +import "G3D/SCLUtil" +import "JavaBuiltin" +import "G3D/Math/Tuple3d" as T3D +import "G3D/Math/Vector3d" as V3D +import "G3D/Scenegraph/G3DNode" as G3D +import "Plant3d/Scenegraph/P3DRootNode" as P3R +import "Plant3d/Scenegraph/P3DNode" as P3N +import "Plant3d/Scenegraph/Equipment" as E +import "Plant3d/Scenegraph/PipelineComponent" as PC +import "Plant3d/Scenegraph/EndComponent" as EC +import "Plant3d/Scenegraph/InlineComponent" as IC +import "Plant3d/Scenegraph/TurnComponent" as TC +import "Plant3d/Utils/P3DScriptNodeMap" as P3S +import "Plant3d/Utils/P3DUtil" as P3DUtil +import "Plant3d/Utils/ComponentUtils" as CU +import "http://www.simantics.org/Layer0-1.1" as L0 + + +doTest :: () +doTest = do + + myModel = syncWrite(\_ -> do + myModel = P3DUtil.createModel "Test1b" + claim (resource "http://Projects/Development%20Project") L0.ConsistsOf myModel + myModel) + p3dmap = load myModel + rootMaybe = javaSafeCoerce (P3S.getRootNode p3dmap) :: Maybe P3R.P3DRootNode + root = fromJust rootMaybe + pump = CU.createEquipmentWithURI root "http://www.simantics.org/Plant3D-0.1/Builtin/Pump" + P3N.setName pump "My Pump" + P3S.commit p3dmap "Created a pump" + P3S.update p3dmap + n1 = CU.createDefaultNozzle root pump + P3S.commit p3dmap "Created a nozzle" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce n1) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 1.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 90.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 2.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 180.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 1.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 180.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 4.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 180.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 4.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 270.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 1.85) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + elbow = CU.addComponent root (unsafeCoerce pipe) (CU.createFixedTurn "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow90" PC.NEXT PC.NEXT) + TC.setRotationAngle (unsafeCoerce elbow) (Just 270.0) + P3S.commit p3dmap "Created a elbow" + P3S.update p3dmap + pipe = CU.addComponent root (unsafeCoerce elbow) (CU.createVariableLength "http://www.simantics.org/Plant3D-0.1/Builtin/Straight" PC.NEXT PC.NEXT 1.0) + P3S.commit p3dmap "Created a pipe" + P3S.update p3dmap + + tank = CU.createEquipmentWithURI root "http://www.simantics.org/Plant3D-0.1/Builtin/HorizontalTank" + P3N.setName tank "My Tank" + G3D.setPosition tank (V3D.createVector3d 0.0 0.0 3.0) + P3S.commit p3dmap "Created a tank" + P3S.update p3dmap + n2 = CU.createDefaultNozzle root tank + G3D.setPosition n2 (V3D.createVector3d 0.6 0.3 0.0) + P3S.commit p3dmap "Created a nozzle" + P3S.update p3dmap + + CU.connect (unsafeCoerce n2) pipe + P3S.commit p3dmap "Connected a pipe to a nozzle" + P3S.update p3dmap + () \ No newline at end of file