| 71 | |
| 72 | |
| 73 | NAN_METHOD(ShapeFactory::makeBox) |
| 74 | { |
| 75 | // could be : |
| 76 | // 3 numbers dx,dy,dz |
| 77 | // 2 points p1,p2 |
| 78 | // 1 point + 3 numbers dx,dy,dz |
| 79 | //TODO 1 object with { x: 1,y: 2,z: 3, dw: |
| 80 | |
| 81 | v8::Local<v8::Value> pJhis = Solid::NewInstance(); |
| 82 | Solid* pThis = Nan::ObjectWrap::Unwrap<Solid>(Nan::To<v8::Object>(pJhis).ToLocalChecked()); |
| 83 | |
| 84 | double dx = 10; |
| 85 | double dy = 10; |
| 86 | double dz = 10; |
| 87 | |
| 88 | try { |
| 89 | |
| 90 | if (info.Length() == 3 && info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsNumber()) { |
| 91 | |
| 92 | dx = extract_double(info[0]); |
| 93 | dy = extract_double(info[1]); |
| 94 | dz = extract_double(info[2]); |
| 95 | BRepPrimAPI_MakeBox tool(dx, dy, dz); |
| 96 | pThis->setShape(tool.Shape()); |
| 97 | registerMakeBoxFaces(pThis, tool); |
| 98 | } |
| 99 | else if (info.Length() == 2) { |
| 100 | |
| 101 | gp_Pnt p1; |
| 102 | ReadPoint(info[0], &p1); |
| 103 | |
| 104 | gp_Pnt p2; |
| 105 | ReadPoint(info[1], &p2); |
| 106 | |
| 107 | BRepPrimAPI_MakeBox tool(p1, p2); |
| 108 | pThis->setShape(tool.Shape()); |
| 109 | registerMakeBoxFaces(pThis, tool); |
| 110 | |
| 111 | |
| 112 | } |
| 113 | else if (info.Length() == 3) { |
| 114 | |
| 115 | gp_Pnt p1; |
| 116 | ReadPoint(info[0], &p1); |
| 117 | |
| 118 | ReadDouble(info[2], dx); |
| 119 | ReadDouble(info[3], dy); |
| 120 | ReadDouble(info[4], dz); |
| 121 | |
| 122 | BRepPrimAPI_MakeBox tool(p1, dx, dy, dz); |
| 123 | pThis->setShape(tool.Shape()); |
| 124 | registerMakeBoxFaces(pThis, tool); |
| 125 | } |
| 126 | else { |
| 127 | return Nan::ThrowError("invalid arguments in makeBox"); |
| 128 | } |
| 129 | } |
| 130 | catch (Standard_Failure&) { |
nothing calls this directly
no test coverage detected