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

Method evaluate

src/module/squaremodule.cpp:31–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31Node* SquareModule::evaluate(const Context& ctx) const
32{
33 Value* sizeVal=getParameterArgument(ctx,0);
34 Value* centerVal=getParameterArgument(ctx,1);
35 bool center=false;
36 if(centerVal)
37 center = centerVal->isTrue();
38
39 decimal x=1.0;
40 decimal y=1.0;
41 if(sizeVal) {
42 VectorValue& size=sizeVal->toVector(2);
43 Point pt = size.getPoint();
44 x=pt.x();
45 y=pt.y();
46 }
47
48 auto* pn=new PrimitiveNode();
49 Primitive* p=pn->createPrimitive();
50 pn->setChildren(ctx.getInputNodes());
51
52 Polygon& pg=p->createPolygon();
53 p->createVertex(Point(0, 0, 0));
54 p->createVertex(Point(x, 0, 0));
55 p->createVertex(Point(x, y, 0));
56 p->createVertex(Point(0, y, 0));
57 pg.append(0);
58 pg.append(1);
59 pg.append(2);
60 pg.append(3);
61
62 if(center) {
63 auto* an=new AlignNode();
64 an->setCenter(true);
65 an->addChild(pn);
66 return an;
67 }
68
69 return pn;
70}

Callers

nothing calls this directly

Calls 12

PointClass · 0.85
getPointMethod · 0.80
xMethod · 0.80
yMethod · 0.80
getInputNodesMethod · 0.80
appendMethod · 0.80
setCenterMethod · 0.80
addChildMethod · 0.80
isTrueMethod · 0.45
createPrimitiveMethod · 0.45
setChildrenMethod · 0.45
createVertexMethod · 0.45

Tested by

no test coverage detected