void add_builtins () { pushLevel(); add_builtin_types(); add_builtin_functions(); /** * What to do with these? Consts * true * false * maxint * minint * pi */ symbol *booleanTypeDescription = getType ("boolean"); symbol *oddFunctionSymbol = calloc (1, sizeof (symbol)); GPtrArray *oddParam = g_ptr_array_new (); struct function_desc *funcDescription = createFunctionDesc (oddParam, booleanTypeDescription, 1); symbol *oddSymbol = createSymbol ("odd", booleanTypeDescription, OC_FUNC, funcDescription); addSymbol ("odd", oddSymbol); printf ("Type class of odd: %d\n", getTypeClass (oddSymbol)); printf ("Done adding builtins\n"); showAllSymbols(); printf ("done showing all symbols\n"); //exit (EXIT_SUCCESS); }
inline Dart Map3::newDart() { Dart d = Map2::newDart() ; (*m_phi3)[dartIndex(d)] = d ; if(m_isMultiRes) { pushLevel() ; for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i) { setCurrentLevel(i) ; (*m_phi3)[dartIndex(d)] = d ; } popLevel() ; } return d ; }
void LogicPerson::setData(const QString fieldName, QString value) { if(fieldName == "level") { pushLevel(value); } else if(fieldName == "customer_no" or fieldName == "customerNO") { setCustomerNO(value); } else if(fieldName == "card_no" or fieldName == "cardNO") { addCardNO(value); } else if(fieldName == "email") { addEmail(value); } else if(fieldName == "id") { setId(value); } else if(fieldName == "name") { setName(value); } else if(fieldName == "mobile") { addMobile(value); } //jaky,email重复,以删除,问题:tel和mobile是不是应该归一组 else if(fieldName == "tel") { addMobile(value); } }
void SoCapsule::build ( float len, float rt, float rb, int nfaces ) { P.clear(); C.clear(); // set size to zero, just in case float hlen = len/2.0f; int levels = std::ceil(static_cast<float>(nfaces) / 2.0f); float faceAngularHeight = (static_cast<float>(M_PI) / 2.0) / static_cast<float>(levels); float faceAngularLength = (2.0 * static_cast<float>(M_PI)) / static_cast<float>(nfaces); int vertices = 2 + (2*levels + 1)*(nfaces * 6); // Reserve space for the capsule vertices P.reserve(vertices); C.reserve(vertices); // Generate the coordinates for the capsule body std::vector<GsVec> bodyTopCoordinates; std::vector<GsVec> bodyBottomCoordinates; bodyTopCoordinates.reserve(nfaces); bodyBottomCoordinates.reserve(nfaces); // Compute the tube section of the capsule for(int i = 0; i < nfaces; i++) { float p = static_cast<float>(i) * faceAngularLength; bodyTopCoordinates.push_back(GsVec(rt * std::cos(p), hlen, rt * std::sin(p))); bodyBottomCoordinates.push_back(GsVec(rb * std::cos(p), -hlen, rb * std::sin(p))); } pushLevel(P, C, bodyTopCoordinates, bodyBottomCoordinates, nfaces); // Compute the top of the capsule std::vector<GsVec>& previousTopVector = bodyTopCoordinates; std::vector<GsVec> currentTopVector; currentTopVector.reserve(nfaces); for(int j = 1; j < levels; j++) { // theta coordinate float t = static_cast<float>(j) * faceAngularHeight; for(int i = 0; i < nfaces; i++) { // phi coordinate float p = static_cast<float>(i) * faceAngularLength; currentTopVector.push_back(GsVec((rt * std::cos(p)) * std::cos(t), hlen + (rt * std::sin(t)), (rt * std::sin(p)) * std::cos(t))); } pushLevel(P, C, currentTopVector, previousTopVector, nfaces); std::swap(currentTopVector, previousTopVector); currentTopVector.clear(); } // Compute the cap of the capsule GsVec tv(0.0f, hlen + rt, 0.0f); for(int i = 0; i < nfaces; i++) { GsVec a = previousTopVector[i]; GsVec b = (i+1 == nfaces) ? previousTopVector[0] : previousTopVector[i+1]; pushTriangle(P, C, {a, b, tv}); } // Compute the bottom of the capsule std::vector<GsVec>& previousBottomVector = bodyBottomCoordinates; std::vector<GsVec> currentBottomVector; currentBottomVector.reserve(nfaces); for(int j = 1; j < levels; j++) { // theta coordinate float t = static_cast<float>(j) * faceAngularHeight; for(int i = 0; i < nfaces; i++) { // phi coordinate float p = static_cast<float>(i) * faceAngularLength; currentBottomVector.push_back(GsVec((rb * std::cos(p)) * std::cos(t), -hlen - (rb * std::sin(t)), (rb * std::sin(p)) * std::cos(t))); } pushLevel(P, C, currentBottomVector, previousBottomVector, nfaces); std::swap(currentBottomVector, previousBottomVector); currentBottomVector.clear(); } // Compute the cap of the capsule GsVec bv(0.0f, -hlen - rb, 0.0f); for(int i = 0; i < nfaces; i++) { GsVec a = previousBottomVector[i]; GsVec b = (i+1 == nfaces) ? previousBottomVector[0] : previousBottomVector[i+1]; pushTriangle(P, C, {a, bv, b}); } //pushCap(P, C, previousBottomVector, bv, nfaces); // send data to OpenGL buffers: glBindBuffer ( GL_ARRAY_BUFFER, buf[0] ); glBufferData ( GL_ARRAY_BUFFER, P.size()*3*sizeof(float), &P[0], GL_STATIC_DRAW ); glBindBuffer ( GL_ARRAY_BUFFER, buf[1] ); glBufferData ( GL_ARRAY_BUFFER, C.size()*4*sizeof(gsbyte), &C[0], GL_STATIC_DRAW ); // save size so that we can free our buffers and later just draw the OpenGL arrays: _numpoints = P.size(); // free non-needed memory: P.resize(0); C.resize(0); changed = 0; }