BoxShape::BoxShape( const float4& halfExtent ) : ShapeBase( SHAPE_BOX ) { m_halfExtent = halfExtent; m_vtx[0] = make_float4( -halfExtent.x, -halfExtent.y, halfExtent.z ); m_vtx[1] = make_float4( halfExtent.x, -halfExtent.y, halfExtent.z ); m_vtx[2] = make_float4( halfExtent.x, -halfExtent.y, -halfExtent.z ); m_vtx[3] = make_float4( -halfExtent.x, -halfExtent.y, -halfExtent.z ); m_vtx[4] = make_float4( -halfExtent.x, halfExtent.y, halfExtent.z ); m_vtx[5] = make_float4( halfExtent.x, halfExtent.y, halfExtent.z ); m_vtx[6] = make_float4( halfExtent.x, halfExtent.y, -halfExtent.z ); m_vtx[7] = make_float4( -halfExtent.x, halfExtent.y, -halfExtent.z ); m_tris[0] = make_int4(0,3,2); m_tris[1] = make_int4(0,2,1); m_tris[2] = make_int4(4,0,1); m_tris[3] = make_int4(4,1,5); m_tris[4] = make_int4(5,1,2); m_tris[5] = make_int4(5,2,6); m_tris[6] = make_int4(6,2,3); m_tris[7] = make_int4(6,3,7); m_tris[8] = make_int4(7,3,0); m_tris[9] = make_int4(7,0,4); m_tris[10] = make_int4(7,4,5); m_tris[11] = make_int4(7,5,6); m_normals[0] = createEquation( m_vtx[0], m_vtx[3], m_vtx[1] ); m_normals[1] = createEquation( m_vtx[4], m_vtx[0], m_vtx[1] ); m_normals[2] = createEquation( m_vtx[5], m_vtx[1], m_vtx[2] ); m_normals[3] = createEquation( m_vtx[6], m_vtx[2], m_vtx[3] ); m_normals[4] = createEquation( m_vtx[7], m_vtx[3], m_vtx[4] ); m_normals[5] = createEquation( m_vtx[7], m_vtx[4], m_vtx[5] ); }
BOOL CALLBACK DialogWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_CLOSE) { DestroyWindow(window); calculatorClosed = true; return true; } else if (message == WM_COMMAND) { if (LOWORD(wParam) == IDC_ADD) { _beginthread(calculateThread, 0, static_cast<void*>(createEquation(window, '+'))); return true; } else if (LOWORD(wParam) == IDC_AVERAGE) { _beginthread(calculateThread, 0, static_cast<void*>(createEquation(window, 'a'))); return true; } else if (LOWORD(wParam) == IDC_BINARY) { char* numberSystem = new char; *numberSystem = 'b'; _beginthread(convertNumberSystemThread, 0, numberSystem); return true; } else if (LOWORD(wParam) == IDC_CENT_TO_FEET) { char* conversion = new char; *conversion = 'f'; _beginthread(convertScaleThread, 0, conversion); return true; } else if (LOWORD(wParam) == IDC_DECIMAL) { char* numberSystem = new char; *numberSystem = 'd'; _beginthread(convertNumberSystemThread, 0, numberSystem); return true; } else if (LOWORD(wParam) == IDC_DIVIDE) { _beginthread(calculateThread, 0, static_cast<void*>(createEquation(window, '/'))); return true; } else if (LOWORD(wParam) == IDC_FEET_TO_CENT) { char* conversion = new char; *conversion = 'c'; _beginthread(convertScaleThread, 0, conversion); return true; } else if (LOWORD(wParam) == IDC_KILO_TO_POUND) { char* conversion = new char; *conversion = 'p'; _beginthread(convertScaleThread, 0, conversion); return true; } else if (LOWORD(wParam) == IDC_MULTIPLY) { _beginthread(calculateThread, 0, static_cast<void*>(createEquation(window, '*'))); return true; } else if (LOWORD(wParam) == IDC_PERCENTAGE) { _beginthread(calculateThread, 0, static_cast<void*>(createEquation(window, '%'))); return true; } else if (LOWORD(wParam) == IDC_POUND_TO_KILO) { char* conversion = new char; *conversion = 'k'; _beginthread(convertScaleThread, 0, conversion); return true; } else if (LOWORD(wParam) == IDC_SUBTRACT) { _beginthread(calculateThread, 0, static_cast<void*>(createEquation(window, '-'))); return true; } } return false; }
QString ComplexShapeHandler::handle_gd(QXmlStreamReader* reader) { QXmlStreamAttributes attrs = reader->attributes(); QString name = attrs.value("name").toString(); QString function = attrs.value("fmla").toString(); QString returnString = QString("<draw:equation draw:name=\"%1\" draw:formula=\"%2\"/>").arg(name).arg(createEquation(function)); reader->readNext(); return returnString; }
void Foam::equationReader::removePowExponents ( const label index, tokenList& tl, PtrList<equationOperation>& map, labelList& opLvl, labelList& pl ) const { // Remove pow(a,b) exponent part 'b' from an equation and create a sub- // equation. label tokenI(0); while (tokenI < map.size()) { if (map[tokenI].operation() == equationOperation::otpow) { // Found a 'pow('. Look for ','; fail on ')', or end of list // pl checks ensure the ',' or ')' relate to the 'pow(', and not // another function / parethesis const label powFoundAt(tokenI); const label pLvl(pl[tokenI]); while ((opLvl[tokenI] != 5) || (pl[tokenI] != pLvl)) { if ( ((opLvl[tokenI] == -4) && (pl[tokenI] == pLvl)) || (tokenI == (map.size() - 1)) ) { OStringStream description; description << "pow() function takes two arguments."; fatalParseError ( index, tl, powFoundAt, tokenI, "equationReader::removePowExponents", description ); } tokenI++; } // Found 'pow( ... ,' look for ')', fail on list end const label commaFoundAt(tokenI); while ((opLvl[tokenI] != -4) || (pl[tokenI] != pLvl)) { if (tokenI == (map.size() - 1)) { OStringStream description; description << "Can't find closing parenthesis for " << "pow() function."; fatalParseError ( index, tl, powFoundAt, tokenI, "equationReader::removePowExponents", description ); } tokenI++; } const label closeFoundAt(tokenI); // Ignore if the exponent is only 1 token if ((closeFoundAt - commaFoundAt) > 2) { // Now create sub-equation OStringStream subEqnStream; for ( label subTokenI(commaFoundAt + 1); subTokenI < closeFoundAt; subTokenI++ ) { if ( tl[subTokenI].isPunctuation() && (tl[subTokenI].pToken() == token::COLON)) { subEqnStream << "^"; } else { subEqnStream << tl[subTokenI]; } } string subEqnRawText(subEqnStream.str()); const equation& eqn(operator[](index)); equation subEqn ( eqn.name() + "_powExponent_" + name(powFoundAt), subEqnRawText, eqn.overrideDimensions(), eqn.changeDimensions() ); bool eqnCreated(false); for (label eqnI(0); eqnI < size(); eqnI++) { const equation& eqnTest(operator[](eqnI)); if (eqnTest.name() == subEqn.name()) { clearEquation(eqnI); eqnTest.setRawText(subEqn.rawText()); eqnTest.setOverrideDimensions ( subEqn.overrideDimensions() ); eqnTest.setChangeDimensions ( eqnTest.changeDimensions() ); eqnCreated = true; } } if (!eqnCreated) { createEquation(subEqn); } // Change commaFoundAt + 1 entry to reflect new subEquation // reference tl[commaFoundAt + 1] = token(subEqn.name()); map.set ( commaFoundAt + 1, new equationOperation(findSource(subEqn.name())) ); opLvl[commaFoundAt + 1] = 0; pl[commaFoundAt + 1] = pl[commaFoundAt]; // Remove the subEquation from tl, map, opLvl and pl label tokensRemoved(closeFoundAt - (commaFoundAt + 2)); label newSize(map.size() - tokensRemoved); for ( label subTokenI(commaFoundAt + 2); subTokenI < newSize; subTokenI++ ) { tl[subTokenI] = tl[subTokenI + tokensRemoved]; map[subTokenI] = map[subTokenI + tokensRemoved]; opLvl[subTokenI] = opLvl[subTokenI + tokensRemoved]; pl[subTokenI] = pl[subTokenI + tokensRemoved]; } tl.setSize(newSize); map.setSize(newSize); opLvl.setSize(newSize); pl.setSize(newSize); } } tokenI++; } }