| 32 | } |
| 33 | |
| 34 | Node* PrismModule::evaluate(const Context& ctx) const |
| 35 | { |
| 36 | auto* heightVal = dynamic_cast<NumberValue*>(getParameterArgument(ctx,0)); |
| 37 | decimal h=1.0; |
| 38 | if(heightVal) |
| 39 | h=heightVal->getNumber(); |
| 40 | |
| 41 | int s=3; |
| 42 | auto* sidesVal = dynamic_cast<NumberValue*>(getParameterArgument(ctx,1)); |
| 43 | if(sidesVal) |
| 44 | s=sidesVal->toInteger(); |
| 45 | |
| 46 | auto* pn=new PrimitiveNode(); |
| 47 | Primitive* p=pn->createPrimitive(); |
| 48 | pn->setChildren(ctx.getInputNodes()); |
| 49 | |
| 50 | if(h==0.0||s<=0.0) |
| 51 | return pn; |
| 52 | |
| 53 | decimal r=1.0; |
| 54 | decimal a=1.0; |
| 55 | auto* apothemVal = dynamic_cast<NumberValue*>(getParameterArgument(ctx,2)); |
| 56 | if(apothemVal) { |
| 57 | a=apothemVal->getNumber(); |
| 58 | r=a/r_cos(r_pi()/s); |
| 59 | } else { |
| 60 | NumberValue* radiusVal = dynamic_cast<NumberValue*>(ctx.getArgument(2,"radius")); |
| 61 | if(radiusVal) { |
| 62 | r=radiusVal->getNumber(); |
| 63 | a=r*r_cos(r_pi()/s); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | Value* centerVal = getParameterArgument(ctx,3); |
| 68 | bool center=false; |
| 69 | if(centerVal) |
| 70 | center=centerVal->isTrue(); |
| 71 | |
| 72 | decimal z1=0.0; |
| 73 | decimal z2=h; |
| 74 | |
| 75 | const QList<Point> p1=getPolygon(a,r,s,z1); |
| 76 | const QList<Point> p2=getPolygon(a,r,s,z2); |
| 77 | |
| 78 | if(r>0.0) { |
| 79 | int n=0; |
| 80 | Polygon& pg0=p->createPolygon(); |
| 81 | for(const auto& pt: p1) { |
| 82 | p->createVertex(pt); |
| 83 | pg0.append(n++); |
| 84 | } |
| 85 | |
| 86 | Polygon& pg1=p->createPolygon(); |
| 87 | for(const auto& pt: p2) { |
| 88 | p->createVertex(pt); |
| 89 | pg1.prepend(n++); |
| 90 | } |
| 91 |
nothing calls this directly
no test coverage detected