int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { Basic basic; try { basic.init (argc, argv); basic.run (); basic.shutdown (); } catch (const CORBA::UserException& ue) { ue._tao_print_exception ("CosEC_Basic user exception: "); return 1; } catch (const CORBA::SystemException& se) { se._tao_print_exception ("CosEC_Basic system exception: "); return 1; } return 0; }
void UFun::simplify() { while (true) { arg->simplify(); // recurse if (arg->getClass() == UFUN) { const UFun & ufun = *(UFun*)arg; if (type == ufun.get_type()) { switch (type) { case NEG: cout << "-(-(x)) == x" << endl; break; case INV: cout << "inv(inv(x)) == x" << endl; break; default: break; }; } if (type == COS and ufun.get_type() == ACOS) { cout << "cos(acos(x) == x" << endl; continue; } } break; } }
void preorder_traversal_stop(const Basic &b, StopVisitor &v) { b.accept(v); if (v.stop_) return; for (const auto &p: b.get_args()) { preorder_traversal_stop(*p, v); if (v.stop_) return; } }
bool Router::handle(Message* msg) { if(msg->msg_id == Packet::MID) { Packet* pkt = (Packet*)msg; Basic* src = msg->src; for(int i = 0; i < pkt->num_hops; ++i) { if(pkt->route[i] == (uint32_t)mac) { num_drop++; num_cycle++; msg->ack(); return true; } } if(pkt->num_hops < VNL_MAX_ROUTE_LENGTH) { pkt->route[pkt->num_hops++] = mac; } else { num_drop++; pkt->ack(); return true; } route(pkt, src, table.find(pkt->dst_addr)); route(pkt, src, table.find(Address(pkt->dst_addr.domain(), (uint64_t)0))); if(hook_dst) { forward(pkt, hook_dst); } if(!pkt->count) { pkt->ack(); } return true; } else if(msg->msg_id == open_t::MID) { open(((open_t*)msg)->data.second, ((open_t*)msg)->data.first); } else if(msg->msg_id == close_t::MID) { close(((close_t*)msg)->data.second, ((close_t*)msg)->data.first); } else if(msg->msg_id == Pipe::connect_t::MID) { Basic* src = ((Pipe::connect_t*)msg)->args; if(src) { lookup[src->get_mac()] = src; ((Pipe::connect_t*)msg)->res = true; } } else if(msg->msg_id == Pipe::close_t::MID) { Basic* src = ((Pipe::close_t*)msg)->data; if(src) { lookup.erase(src->get_mac()); } } else if(msg->msg_id == hook_t::MID) { vnl::pair<Basic*, bool>& data = ((hook_t*)msg)->data; if(!data.second && hook_dst == data.first) { hook_dst = 0; } else if(data.second) { hook_dst = data.first; } } return false; }
TEST(PairTests, PairTest) { auto bound = pq::Bind<Basic>(pq::Type{ZMQ_PAIR}); auto connected = pq::Connect<Basic>(bound.get_port(), pq::Type{ZMQ_PAIR}); { Basic basic; basic.set_value("Hello world"); bound.Send(basic); } { auto basic = connected.Receive(); EXPECT_EQ(std::string{"Hello world"}, basic.value()); } }
TEST(PushPullTests, PushPullTest) { auto push = pq::Bind<Basic>(pq::Type{ZMQ_PUSH}); auto pull = pq::Connect<Basic>(push.get_port(), pq::Type{ZMQ_PULL}); { Basic basic; basic.set_value("Hello world"); push.Send(basic); } { auto basic = pull.Receive(); EXPECT_EQ(std::string{"Hello world"}, basic.value()); } }
TEST(PubSubTests, PubSubTest) { auto pub = pq::Bind<Basic>(pq::Type{ZMQ_PUB}); auto sub = pq::Connect<Basic>(pub.get_port(), pq::Type{ZMQ_SUB}); auto response = std::async(std::launch::async, [] (pq::Socket<Basic>& sub) { return sub.Receive().value(); }, std::ref(sub)); std::this_thread::sleep_for(std::chrono::milliseconds(10)); Basic basic; basic.set_value("Hello world"); pub.Send(basic); EXPECT_EQ(std::string{"Hello world"}, response.get()); }
TEST(PushPullTests, PullNoSendTest) { auto push = pq::Bind<Basic>(pq::Type{ZMQ_PUSH}); auto pull = pq::Connect<Basic>(push.get_port(), pq::Type{ZMQ_PULL}); auto thrown = false; Basic basic; basic.set_value("Hello world"); try { pull.Send(basic); } catch (const std::exception& e) { thrown = true; EXPECT_EQ(std::string{"Operation not supported"}, std::string{e.what()}); } EXPECT_TRUE(thrown); }
/************************************************************************* * FUNCTION DeleteMember * _______________________________________________________________________ * This function receives a basic members vector list and a preferred * members vector list. It then prompts the user for some basic info * and deletes a member from the list. * _______________________________________________________________________ * PRE-CONDITIONS * basicList : Basic member vector has to be previously defined * prefList : Preferred member vector has to be previously defined * * POST-CONDTIONS * This function returns nothing ************************************************************************/ void DeleteMember(vector<Basic>& basicList, // IN - Basic list vector<Preferred>& prefList) // IN - Preferred list { Basic tempBasic; //IN - Temporary basic list Preferred tempPref; //IN - Temporary preferred list int tempId; //IN - Temporary id variable //ErrorCheckInt - Checks a range of integers and outputs a message tempId = ErrorCheckInt(99999, 10000, "Please enter a 5 digit ID: "); tempBasic.findAndDelete(basicList, tempId); tempPref.findAndDelete(prefList, tempId); cout << endl; }
TEST(PairTests, PairReverseNonblockingTest) { auto bound = pq::Bind<Basic>(pq::Type{ZMQ_PAIR}); auto connected = pq::Connect<Basic>(bound.get_port(), pq::Type{ZMQ_PAIR}); { Basic basic; basic.set_value("Hello world"); connected.Send(basic); } { while (true) { auto basic = bound.Receive(false); if (basic.IsInitialized()) { EXPECT_EQ(std::string{"Hello world"}, basic.value()); break; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } }
void UFun::print(std::ostream & os) const { static const char * const type_ops[] = { "-", "inv", "sqrt", "cos", "sin", "tan", "acos", "asin", "atan", }; os << type_ops[type]; os << '('; arg->print(os); os << ')'; }
void Proxy::Init(Context* ctx) { u4 argc = ctx->GetArgCount(); if (argc == 1) { this->property = ctx->GetPropertyArg(0); name.Set(this->property->Name()); WriteBarrier(property); WriteBarrier(name); Function* f = property->Writer() ? property->Writer() : property->Reader(); if (f) { object.Set(f->GetLocation()); WriteBarrier(object); } } else if (argc == 2) { object = ctx->GetArg(0); name = ctx->GetArg(1); WriteBarrier(object); WriteBarrier(name); if (object.tag >= TAG_basic) { Basic* basic = object.val.basic; Value res; if (!basic->GetSlot(name, res)) { } if (res.tag == TAG_property) { this->property = res.val.property; WriteBarrier(property); } else { RaiseException("Attempt to get property %s from object of type %s.", engine->SafeToString(ctx, name), engine->GetTypenameOf(object)); } } } else { ctx->CheckArgCount(2); } }
BOOL Map::_Initialize() { Basic * basic = Basic::CreateImage(NAME, PATH); if (basic == NULL) { return FALSE; } if (mHeight <= 0) { mHeight = basic->GetShowHeight(); } FLOAT height = static_cast<FLOAT>(mHeight); for (INT i = 0; i < MAP_MAX_SIZE; i++) { Basic * basic = Basic::CreateImage(NAME, PATH); basic->SetZIndex(MAP_Z_INDEX); basic->SetSpeed(MAP_DEFAULT_SPEED); basic->SetPosY(i * height); AddChild(basic); mBasics[i] = basic; } return TRUE; }
/************************************************************************* * FUNCTION AddMember * _______________________________________________________________________ * This function receives a basic members vector list and a preferred * members vector list. It then prompts the user for some basic info * and adds a member to the appropriate list. * _______________________________________________________________________ * PRE-CONDITIONS * basicList : Basic member vector has to be previously defined * prefList : Preferred member vector has to be previously defined * * POST-CONDTIONS * This function returns nothing ************************************************************************/ void AddMember(vector<Basic>& basicList, // IN - Basic list vector<Preferred>& prefList)// IN - Preferred list { string tempName; //IN - Temporary name variable int tempId; //IN - Temporary id variable char tempStatus; //IN - Temporary status variable int monthExp; //CALC - Month variable post string conversion int dayExp; //CALC - Day variable post string conversion int yearExp; //CALC - Year variable post string conversion bool invalidId; //CALC - Checks for repeating member numbers do { invalidId = false; tempId = ErrorCheckInt(99999, 10000, "Please enter a 5 digit ID: "); invalidId = CheckUniqueInt(basicList, prefList, tempId); if(invalidId) { cout << "ID number already in use - please try again." << endl; } }while(invalidId); tempStatus = ErrorCheckChar('B', 'P', "Basic or Preferred? (B/P): "); cout << "Please enter a name: "; getline(cin, tempName); cout << "Please enter an expiration date: " << endl; monthExp = ErrorCheckInt(12, 1, "Month: "); dayExp = ErrorCheckInt(31, 1, "Day: "); yearExp = ErrorCheckInt(2031, 2014, "Year: "); //IF - Checks if status is preferred or basic, inputs into correct // list. if(tempStatus == 'P') { Preferred tempPref; //IN - Temporary preferred list tempPref.setName(tempName); tempPref.setNumber(tempId); tempPref.setMemType(1); tempPref.setExp(monthExp, dayExp, yearExp); tempPref.setAmtSpent(0.0); tempPref.setRebate(0.0); prefList.push_back(tempPref); } else if(tempStatus == 'B') { Basic tempBasic; //IN - Temporary basic list tempBasic.setName(tempName); tempBasic.setNumber(tempId); tempBasic.setMemType(0); tempBasic.setExp(monthExp, dayExp, yearExp); tempBasic.setAmtSpent(0.0); basicList.push_back(tempBasic); } }
void myUpdate(Grabber *grabber, void *ptr) { Basic *eye = (Basic *)ptr; // Get depth frame DepthFrame *depthFrame = grabber->getDepthFrame(); if (depthFrame) { eye->update(depthFrame); if (showGUI) { disp->showImage("depth", depthGain); } delete depthFrame; } // Get raw processed frame Ptr<Frame> f = grabber->getRawFrameProcessed(); if (f && f.get()) { ToFRawFrame *frame = dynamic_cast<ToFRawFrame *>(f.get()); if (frame) { eye->update(frame); if (showGUI) { disp->showImage("amplitude", ampGain); disp->showImage("phase", phaseGain); } } } char key = cv::waitKey(1); // Select image when enter keystroke if (key == 'q') eye->runExit(); }
void bvisit(const Basic &x) { *numer_ = x.rcp_from_this(); *denom_ = one; }
//----------------------------------------------------------------------------- // <MultiInstance::HandleMultiChannelCapabilityReport> // Handle a message from the Z-Wave network //----------------------------------------------------------------------------- void MultiInstance::HandleMultiChannelCapabilityReport ( uint8 const* _data, uint32 const _length ) { if( Node* node = GetNodeUnsafe() ) { uint8 endPoint = _data[1] & 0x7f; bool dynamic = ((_data[1] & 0x80)!=0); Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelCapabilityReport from node %d for endpoint %d", GetNodeId(), endPoint ); Log::Write( LogLevel_Info, GetNodeId(), " Endpoint is%sdynamic, and is a %s", dynamic ? " " : " not ", node->GetEndPointDeviceClassLabel( _data[2], _data[3] ).c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " Command classes supported by the endpoint are:" ); // Store the command classes for later use bool afterMark = false; m_endPointCommandClasses.clear(); uint8 numCommandClasses = _length - 5; for( uint8 i = 0; i < numCommandClasses; ++i ) { uint8 commandClassId = _data[i+4]; if( commandClassId == 0xef ) { afterMark = true; continue; } m_endPointCommandClasses.insert( commandClassId ); // Ensure the node supports this command class CommandClass* cc = node->GetCommandClass( commandClassId ); if( !cc ) { cc = node->AddCommandClass( commandClassId ); if( cc && afterMark ) { cc->SetAfterMark(); } } if( cc ) { Log::Write( LogLevel_Info, GetNodeId(), " %s", cc->GetCommandClassName().c_str() ); } } // Create internal library instances for each command class in the list // Also set up mapping from intances to endpoints for encapsulation Basic* basic = static_cast<Basic*>( node->GetCommandClass( Basic::StaticGetCommandClassId() ) ); if( m_endPointsAreSameClass ) // Create all the same instances here { int len; if( m_endPointMap == MultiInstanceMapAll ) // Include the non-endpoint instance { endPoint = 0; len = m_numEndPoints + 1; } else { endPoint = 1; len = m_numEndPoints; } // Create all the command classes for all the endpoints for( uint8 i = 1; i <= len; i++ ) { for( set<uint8>::iterator it = m_endPointCommandClasses.begin(); it != m_endPointCommandClasses.end(); ++it ) { uint8 commandClassId = *it; CommandClass* cc = node->GetCommandClass( commandClassId ); if( cc ) { cc->SetInstance( i ); if( m_endPointMap != MultiInstanceMapAll || i != 1 ) { cc->SetEndPoint( i, endPoint ); } // If we support the BASIC command class and it is mapped to a command class // assigned to this end point, make sure the BASIC command class is also associated // with this end point. if( basic != NULL && basic->GetMapping() == commandClassId ) { basic->SetInstance( i ); if( m_endPointMap != MultiInstanceMapAll || i != 1 ) { basic->SetEndPoint( i, endPoint ); } } } } endPoint++; } } else // Endpoints are different { for( set<uint8>::iterator it = m_endPointCommandClasses.begin(); it != m_endPointCommandClasses.end(); ++it ) { uint8 commandClassId = *it; CommandClass* cc = node->GetCommandClass( commandClassId ); if( cc ) { uint8 i; // Find the next free instance of this class for( i = 1; i <= 127; i++ ) { if( m_endPointMap == MultiInstanceMapAll ) // Include the non-endpoint instance { if( !cc->GetInstances()->IsSet( i ) ) { break; } } // Reuse non-endpoint instances first time we see it else if( i == 1 && cc->GetInstances()->IsSet( i ) && cc->GetEndPoint( i ) == 0 ) { break; } // Find the next free instance else if( !cc->GetInstances()->IsSet( i ) ) { break; } } cc->SetInstance( i ); cc->SetEndPoint( i, endPoint ); // If we support the BASIC command class and it is mapped to a command class // assigned to this end point, make sure the BASIC command class is also associated // with this end point. if( basic != NULL && basic->GetMapping() == commandClassId ) { basic->SetInstance( i ); basic->SetEndPoint( i, endPoint ); } } } } } }
void apply(mpfr_ptr result, const Basic &b) { mpfr_ptr tmp = result_; result_ = result; b.accept(*this); result_ = tmp; }
//----------------------------------------------------------------------------- // <MultiInstance::HandleMultiChannelCapabilityReport> // Handle a message from the Z-Wave network //----------------------------------------------------------------------------- void MultiInstance::HandleMultiChannelCapabilityReport ( uint8 const* _data, uint32 const _length ) { bool dynamic = ((_data[1] & 0x80)!=0); if( Node* node = GetNodeUnsafe() ) { /* if you having problems with Dynamic Devices not correctly * updating the commandclasses, see this email thread: * https://groups.google.com/d/topic/openzwave/IwepxScRAVo/discussion */ if ((m_ignoreUnsolicitedMultiChannelCapabilityReport && (node->GetCurrentQueryStage() != Node::QueryStage_Instances)) && !dynamic && m_endPointCommandClasses.size() > 0) { Log::Write(LogLevel_Error, GetNodeId(), "Recieved a Unsolicited MultiChannelEncap when we are not in QueryState_Instances"); return; } uint8 endPoint = _data[1] & 0x7f; Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelCapabilityReport from node %d for endpoint %d", GetNodeId(), endPoint ); Log::Write( LogLevel_Info, GetNodeId(), " Endpoint is%sdynamic, and is a %s", dynamic ? " " : " not ", node->GetEndPointDeviceClassLabel( _data[2], _data[3] ).c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " Command classes supported by the endpoint are:" ); // Store the command classes for later use bool afterMark = false; m_endPointCommandClasses.clear(); uint8 numCommandClasses = _length - 5; for( uint8 i = 0; i < numCommandClasses; ++i ) { uint8 commandClassId = _data[i+4]; if( commandClassId == 0xef ) { afterMark = true; continue; } m_endPointCommandClasses.insert( commandClassId ); // Ensure the node supports this command class CommandClass* cc = node->GetCommandClass( commandClassId ); if( !cc ) { cc = node->AddCommandClass( commandClassId ); if( cc && afterMark ) { cc->SetAfterMark(); } } if( cc ) { Log::Write( LogLevel_Info, GetNodeId(), " %s", cc->GetCommandClassName().c_str() ); } } // Create internal library instances for each command class in the list // Also set up mapping from intances to endpoints for encapsulation Basic* basic = static_cast<Basic*>( node->GetCommandClass( Basic::StaticGetCommandClassId() ) ); if( m_endPointsAreSameClass ) // Create all the same instances here { int len; if( m_endPointMap == MultiInstanceMapAll ) // Include the non-endpoint instance { endPoint = 0; len = m_numEndPoints + 1; } else { endPoint = 1; len = m_numEndPoints; } // Create all the command classes for all the endpoints for( uint8 i = 1; i <= len; i++ ) { std::cout << "Num Instances: " << len << std::endl; for( set<uint8>::iterator it = m_endPointCommandClasses.begin(); it != m_endPointCommandClasses.end(); ++it ) { uint8 commandClassId = *it; CommandClass* cc = node->GetCommandClass( commandClassId ); if( cc ) { cc->SetInstance( i ); if( m_endPointMap != MultiInstanceMapAll || i != 1 ) { cc->SetEndPoint( i, endPoint ); } // If we support the BASIC command class and it is mapped to a command class // assigned to this end point, make sure the BASIC command class is also associated // with this end point. if( basic != NULL && basic->GetMapping() == commandClassId ) { basic->SetInstance( i ); if( m_endPointMap != MultiInstanceMapAll || i != 1 ) { basic->SetEndPoint( i, endPoint ); } } } } endPoint++; } } else // Endpoints are different { for( set<uint8>::iterator it = m_endPointCommandClasses.begin(); it != m_endPointCommandClasses.end(); ++it ) { uint8 commandClassId = *it; CommandClass* cc = node->GetCommandClass( commandClassId ); if( cc ) { uint8 i; // Find the next free instance of this class for( i = 1; i <= 127; i++ ) { if( m_endPointMap == MultiInstanceMapAll ) // Include the non-endpoint instance { if( !cc->GetInstances()->IsSet( i ) ) { break; } } // Reuse non-endpoint instances first time we see it else if( i == 1 && cc->GetInstances()->IsSet( i ) && cc->GetEndPoint( i ) == 0 ) { break; } // Find the next free instance else if( !cc->GetInstances()->IsSet( i ) ) { break; } } cc->SetInstance( i ); cc->SetEndPoint( i, endPoint ); // If we support the BASIC command class and it is mapped to a command class // assigned to this end point, make sure the BASIC command class is also associated // with this end point. if( basic != NULL && basic->GetMapping() == commandClassId ) { basic->SetInstance( i ); basic->SetEndPoint( i, endPoint ); } } } } } }
void init() { basic.addCylinder2(0.25, 0.5, 1); basic.addCube(0.5); basic.addSphere(0.25); basic.addCylinder(0.25, 1); basic.addCone(0.25, 0.75); basic.addCone2(0.25, 1, 5); basic.addPrism2(0.5, 0.25, 0.25, 6); basic.addPrism(0.25, 1, 3); basic.addPlane(10, 4); basic.addPlane(10, 4); basic.addPlane(10, 4); basic.addPlane(10, 4); basic.addPlane(10, 4); //basic.addCircle(10); basic.objs[12].r[2] = 90; basic.objs[12].t[0] -= 5; basic.objs[11].r[2] = 90; basic.objs[11].t[0] += 5; basic.objs[10].t[1] += 5; basic.objs[9].r[0] = -90; basic.objs[9].t[2] -= 5; basic.objs[8].t[1] -= 5; basic.objs[7].t[0] -= 1; basic.objs[7].t[1] -= 1; basic.objs[7].t[2] -= 1; basic.objs[6].t[0] += 1; basic.objs[6].t[2] += 1; basic.objs[5].t[0] -= 2; basic.objs[4].t[0] += 2; basic.objs[3].t[1] += 2; basic.objs[2].t[2] += 1; basic.objs[2].s[1] = 1; basic.objs[0].t[0] += 1; basic.objs[1].t[0] -= 1; light.addLight(); /*obj2.read("Creature\\Arakkoa\\arakkoa_sage"); for (int i = 0; i < obj2.objs.size(); ++i){ obj2.objs[i].t[1] -= 3; obj2.objs[i].s[0] = 0.5; obj2.objs[i].s[1] = 0.5; obj2.objs[i].s[2] = 0.5; } obj1.read("Tails"); for (int i = 0; i < obj1.objs.size(); ++i){ obj1.objs[i].s[0] = 0.25; obj1.objs[i].s[1] = 0.25; obj1.objs[i].s[2] = 0.25; }*/ /*basic.loadTex(1, "Monet.bmp"); basic.openTex(1); basic.loadTex(2, "Monet.bmp"); basic.openTex(2); basic.loadTex(0, "Monet.bmp"); basic.openTex(0); basic.loadTex(3, "Monet.bmp"); basic.openTex(3); basic.loadTex(4, "Monet.bmp"); basic.openTex(4); basic.loadTex(5, "Monet.bmp"); basic.openTex(5); basic.loadTex(6, "Monet.bmp"); basic.openTex(6); basic.loadTex(7, "Monet.bmp"); basic.openTex(7);*/ for (int i = 0; i < basic.objs.size() - 5; ++i){ basic.loadTex(i, "Monet.bmp"); basic.openTex(i); } ReadObject("Object2.txt", &obj); setConnectivity(obj); for (unsigned int i = 0; i<obj.planeSize; i++) // Loop Through All Object Planes calPlane(obj, obj.planes[i]); obj.t[0] += 2; obj.t[1] -= 2; obj.s[0] = 0.3; obj.s[1] = 0.3; obj.s[2] = 0.3; glShadeModel(GL_SMOOTH); glClearColor(0.2, 0.2, 1.0, 1.0); glClearDepth(1.0f); glClearStencil(0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); /*glLightfv(GL_LIGHT1, GL_POSITION, LightPos); // Set Light1 Position glLightfv(GL_LIGHT1, GL_DIFFUSE, white); glEnable(GL_LIGHT1);*/ // Enable Light1 glEnable(GL_LIGHTING); // Enable Lightins glEnable(GL_NORMALIZE); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); q = gluNewQuadric(); // Initialize Quadratic gluQuadricNormals(q, GL_SMOOTH); // Enable Smooth Normal Generation gluQuadricTexture(q, GL_FALSE); //light.addLight(); //obj2.read("Tails"); }
void redraw() { GLmatrix16f Minv; GLvector4f wlp, lp; lp[0] = LightPos[0]; lp[1] = LightPos[1]; lp[2] = LightPos[2]; lp[3] = LightPos[3]; // Clear Color Buffer, Depth Buffer, Stencil Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClearColor(0.2, 0.2, 1.0, 1.0); glLoadIdentity(); gluLookAt(eye[0], eye[1], eye[2], center[0], center[1], center[2], 0, 1, 0); if (bWire) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } else { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } glShadeModel(GL_SMOOTH); glRotatef(fRotate, 0, 1, 0); /*for (int i = 0; i < obj2.objs.size(); ++i){ glObject &o = obj2.objs[i]; glPushMatrix(); glTranslatef(o.t[0], o.t[1], o.t[2]); glScalef(o.s[0], o.s[1], o.s[2]); glRotatef(o.r[2], 0, 0, 1); glRotatef(o.r[1], 0, 1, 0); glRotatef(o.r[0], 1, 0, 0); drawGLObject(obj2.objs[i]); glPopMatrix(); } for (int i = 0; i < obj1.objs.size(); ++i){ glObject &o = obj1.objs[i]; glPushMatrix(); glTranslatef(o.t[0], o.t[1], o.t[2]); glScalef(o.s[0], o.s[1], o.s[2]); glRotatef(o.r[2], 0, 0, 1); glRotatef(o.r[1], 0, 1, 0); glRotatef(o.r[0], 1, 0, 0); drawGLObject(obj1.objs[i]); glPopMatrix(); }*/ //glGetFloatv(GL_MODELVIEW, Minv); //VMatMult(Minv, lp); glLightfv(GL_LIGHT1, GL_POSITION, lp); light.enableLights(); glObject &o = obj; glPushMatrix(); glTranslatef(o.t[0], o.t[1], o.t[2]); glScalef(o.s[0], o.s[1], o.s[2]); glRotatef(o.r[2], 0, 0, 1); glRotatef(o.r[1], 0, 1, 0); glRotatef(o.r[0], 1, 0, 0); drawGLObject(obj); glPopMatrix(); basic.setDefaultMaterial(); /*glPushMatrix(); glTranslatef(0, 0, -5); glRotatef(-90, 1, 0, 0); glRotatef(45, 0, 1, 0); basic.drawPlane(10, -1); glPopMatrix(); glPushMatrix(); glTranslatef(0, -5, 0); glRotatef(180, 1, 0, 0); glRotatef(45, 0, 1, 0); basic.drawPlane(10, -1); glPopMatrix();*/ basic.drawAll(); //for (int i = 0; i < 2; ++i){ // drawGLObject(obj1.objs[i]); //} //basic.objs[0].r[0] = 180; for (int i = 0; i < basic.objs.size(); ++i) addShadowObject(basic.objs[i], light); for (int i = 0; i < obj1.objs.size(); ++i){ addShadowObject(obj1.objs[i], light); } addShadowObject(obj, light); drawShadow(); glPushMatrix(); glTranslatef(0, -3, 0); glutSolidCube(1.0); glPopMatrix(); //drawGLObject(basic.objs[0]); // Reset Modelview Matrix /*glTranslatef(0.0f, 0.0f, -20.0f); // Zoom Into Screen 20 Units glLightfv(GL_LIGHT1, GL_POSITION, LightPos); // Position Light1 glTranslatef(SpherePos[0], SpherePos[1], SpherePos[2]); // Position The Sphere gluSphere(q, 1.5f, 32, 16); // Draw A Sphere glRotatef(fRotate, 0, 1, 0); obj.t[1] = ObjPos[1]; obj.t[2] = ObjPos[2] - 20; glColor4f(0.7f, 0.4f, 0.0f, 1.0f); // Set Color To An Orange // Reset Modelview Matrix glPushMatrix(); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -20.0f); // Zoom Into The Screen 20 Units DrawGLRoom(); // Draw The Room //glTranslatef(ObjPos[0], ObjPos[1], ObjPos[2]); // Position The Object //glRotatef(xrot, 1.0f, 0.0f, 0.0f); // Spin It On The X Axis By xrot //glRotatef(yrot, 0.0f, 1.0f, 0.0f); // Spin It On The Y Axis By yrot //drawGLObject(obj); // Procedure For Drawing The Loaded Object //castShadow(obj, lp); // Procedure For Casting The Shadow Based On The Silhouette *///addShadowObject(obj, LightPos); /* for (int i = 0; i < 2; ++i){ obj1.objs[i].s[0] = 0.2; obj1.objs[i].s[1] = 0.2; obj1.objs[i].s[2] = 0.2; addShadow(obj1.objs[i], LightPos); } glPopMatrix(); glLoadIdentity(); glColor4f(0.7f, 0.4f, 0.0f, 1.0f); // Set Color To Purplish Blue glDisable(GL_LIGHTING); // Disable Lighting glDepthMask(GL_FALSE); // Disable Depth Mask glTranslatef(LightPos[0], LightPos[1], LightPos[2] - 20); // Translate To Light's Position // Notice We're Still In Local Coordinate System gluSphere(q, 0.2f, 16, 8); // Draw A Little Yellow Sphere (Represents Light) glEnable(GL_LIGHTING); // Enable Lighting glDepthMask(GL_TRUE); // Enable Depth Mask */ //xrot += xspeed; // Increase xrot By xspeed //yrot += yspeed; // Increase yrot By yspeed light.drawLights(); glFlush(); glutSwapBuffers(); }
set_basic apply(const Basic &b) { b.accept(*this); return s; }
void bvisit(const Basic &x) { for (const auto &p: x.get_args()) { p->accept(*this); } }
/************************************************************************* * FUNCTION CompareNamesBasic * _______________________________________________________________________ * This function receives two basic member names and compares them * alphabetically. * _______________________________________________________________________ * PRE-CONDITIONS * first : first has to be previously defined * second : second has to be previously defined * * POST-CONDTIONS * none ************************************************************************/ bool CompareNamesBasic(const Basic& first, // IN - First name to compare const Basic& second) // IN - Second name to compare { return first.getName() < second.getName(); }
void bvisit(const Basic &x) { add_to_gen_set(x.rcp_from_this(), one); }
std::size_t hash_value(const Basic& b) { return b.hashValue(); }
void apply(const Basic &b) { b.accept(*this); }
void postorder_traversal(const Basic &b, Visitor &v) { for (const auto &p: b.get_args()) postorder_traversal(*p, v); b.accept(v); }
std::string StrPrinter::apply(const Basic &b) { b.accept(*this); return str_; }
umap_basic_num apply(const Basic &b) { b.accept(*this); return std::move(gen_set); }