MCPcopy Create free account
hub / github.com/GilesBathgate/RapCAD / evaluate

Method evaluate

src/module/datummodule.cpp:32–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32Node* DatumModule::evaluate(const Context& ctx) const
33{
34 auto* xVal=dynamic_cast<NumberValue*>(ctx.getArgument(0,"x"));
35 auto* yVal=dynamic_cast<NumberValue*>(ctx.getArgument(0,"y"));
36 auto* zVal=dynamic_cast<NumberValue*>(ctx.getArgument(0,"z"));
37
38 auto* n=new TransformationNode();
39 n->setChildren(ctx.getInputNodes());
40
41 if(!xVal&&!yVal&&!zVal)
42 return n;
43
44 decimal x=0.0;
45 if(xVal) {
46 x=xVal->getNumber();
47 n->setDatumAxis(TransformationNode::Axis::X);
48 }
49
50 decimal y=0.0;
51 if(yVal) {
52 y=yVal->getNumber();
53 n->setDatumAxis(TransformationNode::Axis::Y);
54 }
55
56 decimal z=0.0;
57 if(zVal) {
58 z=zVal->getNumber();
59 n->setDatumAxis(TransformationNode::Axis::Z);
60 }
61
62 auto* m = new TransformMatrix(
63 1.0,0.0,0.0,x,
64 0.0,1.0,0.0,y,
65 0.0,0.0,1.0,z,
66 0.0,0.0,0.0,1.0
67 );
68 m->setType(TransformType::Translation);
69
70 n->setMatrix(m);
71 return n;
72}

Callers

nothing calls this directly

Calls 7

getArgumentMethod · 0.80
getInputNodesMethod · 0.80
getNumberMethod · 0.80
setDatumAxisMethod · 0.80
setMatrixMethod · 0.80
setChildrenMethod · 0.45
setTypeMethod · 0.45

Tested by

no test coverage detected