ElementDocumentWrapper::ElementDocumentWrapper(PyObject* self, const char* tag) : ElementWrapper< ElementDocument >(self, tag) { Rocket::Core::String module_id(32, "document_%x", this); // Create a new module module = PyModule_New(module_id.CString()); module_namespace = PyModule_GetDict(module); // Merging main into the module PyObject* builtins = PyImport_AddModule("__main__"); PyObject* builtins_dict = PyModule_GetDict( builtins); PyDict_Merge(module_namespace, builtins_dict, 0); }
void FE_Utils::create_uses_multiple_stuff (AST_Component *c, AST_Uses *u, const char *prefix) { ACE_CString struct_name (prefix); if (!struct_name.empty ()) { struct_name += '_'; } struct_name += u->local_name ()->get_string (); struct_name += "Connection"; Identifier struct_id (struct_name.c_str ()); UTL_ScopedName sn (&struct_id, 0); // In case this call comes from the backend. We // will pop the scope before returning. idl_global->scopes ().push (c); AST_Structure *connection = idl_global->gen ()->create_structure (&sn, 0, 0); struct_id.destroy (); /// If the field type is a param holder, we want /// to use the lookup to create a fresh one, /// since the field will own it and destroy it. UTL_ScopedName *fn = u->uses_type ()->name (); AST_Decl *d = idl_global->root ()->lookup_by_name (fn, true, false); AST_Type *ft = AST_Type::narrow_from_decl (d); Identifier object_id ("objref"); UTL_ScopedName object_name (&object_id, 0); AST_Field *object_field = idl_global->gen ()->create_field (ft, &object_name, AST_Field::vis_NA); (void) DeclAsScope (connection)->fe_add_field (object_field); object_id.destroy (); Identifier local_id ("Cookie"); UTL_ScopedName local_name (&local_id, 0); Identifier module_id ("Components"); UTL_ScopedName scoped_name (&module_id, &local_name); d = c->lookup_by_name (&scoped_name, true); local_id.destroy (); module_id.destroy (); if (d == 0) { // This would happen if we haven't included Components.idl. idl_global->err ()->lookup_error (&scoped_name); return; } AST_ValueType *cookie = AST_ValueType::narrow_from_decl (d); Identifier cookie_id ("ck"); UTL_ScopedName cookie_name (&cookie_id, 0); AST_Field *cookie_field = idl_global->gen ()->create_field (cookie, &cookie_name, AST_Field::vis_NA); (void) DeclAsScope (connection)->fe_add_field (cookie_field); cookie_id.destroy (); (void) c->fe_add_structure (connection); ACE_CDR::ULong bound = 0; AST_Expression *bound_expr = idl_global->gen ()->create_expr (bound, AST_Expression::EV_ulong); AST_Sequence *sequence = idl_global->gen ()->create_sequence (bound_expr, connection, 0, 0, 0); ACE_CString seq_string (struct_name); seq_string += 's'; Identifier seq_id (seq_string.c_str ()); UTL_ScopedName seq_name (&seq_id, 0); AST_Typedef *connections = idl_global->gen ()->create_typedef (sequence, &seq_name, 0, 0); seq_id.destroy (); (void) c->fe_add_typedef (connections); // In case this call comes from the backend. idl_global->scopes ().pop (); }
void ReadITT::loadData(const char *moleculepath) { //char *moleculepath; FILE *molecule_fp = fopen(moleculepath, "r"); if (molecule_fp == NULL) { sendError("Cannot open file %s", moleculepath); return; } std::cout << "Reading file " << moleculepath << "..." << std::endl; // read in the data // read the molecule structure first structure = new MoleculeStructure(molecule_fp); // now we will read in the simulation data // we will perform a first scan to determine the // number of timesteps and the maximum number of // molecules appearing in a timestep // getting number of molecule types int noOfTypes = structure->getNumberOfMolecules(); // getting the count of atoms per molecule std::vector<int> atomsPerType(noOfTypes); for (int i = 0; i < noOfTypes; i++) { std::vector<int> noOfAtoms; if (structure->getMolIDs(i + 1, &noOfAtoms)) atomsPerType[i] = noOfAtoms.size(); } //printf("noOfTypes: %d, atomsPerType[i]: %d\n", noOfTypes, atomsPerType[0]); printf("getting number of timesteps and\nnumber of atoms per timestep\n\n"); char buf[512]; int maxAtomCount = 0; // vector holding the number of atoms in every timestep std::vector<int> anzAtoms; while (fgets(buf, LINE_SIZE, molecule_fp) != NULL && ((m_bLookAhead == 0) || (m_bLookAhead == 1 && anzAtoms.size() < m_iLookAhead))) { // skip blank lines and comments if (*buf == '\0') // read the next line continue; // store the data according to the parts... if (*buf == '!') { int type; if (sscanf(buf, "%*s %d", &type) == 1) // counting number of atoms per timestep anzAtoms.back() += atomsPerType[type - 1]; } else if (*buf == '#') { float tmpf; if (sscanf(buf, "%*s %f", &tmpf) == 1) { // adding a now frame initialised with 0 atoms if (!anzAtoms.empty()) { if (anzAtoms.back() > maxAtomCount) maxAtomCount = anzAtoms.back(); } anzAtoms.push_back(0); } } else continue; } int noOfTimesteps = anzAtoms.size(); fprintf(stderr, "number of timesteps:\t\t\t%d\n", noOfTimesteps); fprintf(stderr, "maximum number of atoms per timestep:\t%d\n\n", maxAtomCount); //reset file pointer to beginning fseek(molecule_fp, 0, SEEK_SET); // getting prefix of output object names const char *obj_points = m_portPoints->getObjName(); const char *obj_lines_name = m_portVolumeBox->getObjName(); const char *obj_atomcolors = m_portColors->getObjName(); const char *obj_radii = m_portRadii->getObjName(); printf("reading timestep data...\n\n"); float cubeSize = 0.0; float *fcoordx = NULL, *fcoordy = NULL, *fcoordz = NULL; float *fRadii = NULL; int *pc = NULL; coDoPoints **dataPoints = new coDoPoints *[noOfTimesteps]; coDoLines **dataLines = new coDoLines *[noOfTimesteps]; coDoRGBA **dataColors = new coDoRGBA *[noOfTimesteps]; coDoFloat **dataRadii = new coDoFloat *[noOfTimesteps]; int molCount = -1; int currentFrame = -1; //quite the same as numberOfTimesteps... int currAtom = -1; while (fgets(buf, LINE_SIZE, molecule_fp) != NULL && ((m_bLookAhead == 0 && currentFrame < noOfTimesteps) || (m_bLookAhead == 1 && currentFrame < m_iLookAhead))) { int type; float x, y, z; float q0, q1, q2, q3; // skip blank lines and comments if (*buf == '\0') continue; else if (*buf == '#') { molCount = -1; currAtom = -1; ++currentFrame; if (sscanf(buf, "%*s %f", &cubeSize) != 1) { cubeSize = 0.0; continue; } // generate timestep dependent name of actual object stringstream obj_points_current; obj_points_current << obj_points << "_" << currentFrame; stringstream obj_lines_current; obj_lines_current << obj_lines_name << "_" << currentFrame; stringstream obj_atomcolors_current; obj_atomcolors_current << obj_atomcolors << "_" << currentFrame; stringstream obj_radii_current; obj_radii_current << obj_radii << "_" << currentFrame; // generate objects for actual timestep dataPoints[currentFrame] = new coDoPoints(obj_points_current.str().c_str(), anzAtoms[currentFrame]); dataLines[currentFrame] = createBox(obj_lines_current.str().c_str(), 0, 0, 0, cubeSize, cubeSize, cubeSize); dataColors[currentFrame] = new coDoRGBA(obj_atomcolors_current.str().c_str(), anzAtoms[currentFrame]); dataRadii[currentFrame] = new coDoFloat(obj_radii_current.str().c_str(), anzAtoms[currentFrame]); // get references to internal data structure dataPoints[currentFrame]->getAddresses(&fcoordx, &fcoordy, &fcoordz); dataRadii[currentFrame]->getAddress(&fRadii); dataColors[currentFrame]->getAddress(&pc); continue; } else if (*buf == '!') { int n = sscanf(buf, "%*s %d %f %f %f %f %f %f %f", &type, &x, &y, &z, &q0, &q1, &q2, &q3); //printf("n: %d\n", n); if (n == 4) { x = x / 10.; y = y / 10.; z = z / 10.; q0 = 0.0f; q1 = 0.0f; q2 = 0.0f; q3 = 1000.0f; } else if (n == 7) { q0 = q0 / 1000.; q1 = q1 / 1000.; q2 = q2 / 1000.; q3 = sqrt(1.0f - q0 * q0 - q1 * q1 - q2 * q2); } else if (n == 8) { q0 = q0 / 1000.; q1 = q1 / 1000.; q2 = q2 / 1000.; q3 = q3 / 1000.; } else { printf("badly formed line\n"); continue; } ++molCount; } else { continue; } //getting the rotation matrix of quaternion components coMatrix quatRot; quatRot.fromQuat(q1, q2, q3, q0); std::vector<int> liIDgroup; structure->getMolIDs(type, &liIDgroup); int typeSize = liIDgroup.size(); //printf("typeSize: %d\n", typeSize); for (int j = 0; j < typeSize; ++j) { ++currAtom; //printf("noOfTimesteps: %d,\tmolCount: %d\n", noOfTimesteps, molCount); //getting the midpoint of a component of the molecule float molX, molY, molZ; structure->getXYZ(liIDgroup[j], &molX, &molY, &molZ); //Setting point of molecule coVector pointOfMolecule(molX, molY, molZ, 1.0f); //Transform point of molecule pointOfMolecule = pointOfMolecule * (quatRot); //Modified point float fpos[3]; pointOfMolecule.get(fpos); /*Translating and storing of the component of the molecule according to the midpoint of the whole molecule*/ fcoordx[currAtom] = fpos[0] + (x / 1000. * cubeSize); fcoordy[currAtom] = fpos[1] + (y / 1000. * cubeSize); fcoordz[currAtom] = fpos[2] + (z / 1000. * cubeSize); //Getting radius of the molecule component float size; structure->getSigma(liIDgroup[j], &size); fRadii[currAtom] = size / 2.; //Setting the color of the molecule component if (structure->getVersion() == 0) { int color; structure->getColor(liIDgroup[j], &color); //printf("color: %d,\tliIDgroup[j]: %d\n", color, liIDgroup[j]); static const uint32_t lut[16] = { 0xddddddff, // grau 0x202020ff, // schwarz 0xff0000ff, // rot 0xff7f00ff, // orange 0xffff00ff, // gelb 0xb2ff00ff, // zitron 0x00ff00ff, // gruen 0x00ff7fff, // tuerkis 0x00ffffff, // cyan 0x007fffff, // wasser 0x0000ffff, // blau 0x7f00ffff, // lila 0xff00ffff, // magenta 0xff007fff, // kirsch 0xddddddff, // blau 0x202020ff, // blau }; pc[currAtom] = lut[color & 0x0f]; } else { int fColorR, fColorG, fColorB, fColorA; structure->getColorRGBA(liIDgroup[j], &fColorR, &fColorG, &fColorB, &fColorA); dataColors[currentFrame]->setIntRGBA(currAtom, fColorR, fColorG, fColorB, fColorA); } } } fclose(molecule_fp); fprintf(stderr, "file operation complete!\n\n"); fprintf(stderr, "packing and sending data to covise.\n\n"); coDoSet *setPoints = new coDoSet(m_portPoints->getObjName(), noOfTimesteps, (coDistributedObject **)dataPoints); coDoSet *setLines = new coDoSet(m_portVolumeBox->getObjName(), noOfTimesteps, (coDistributedObject **)dataLines); coDoSet *setColors = new coDoSet(m_portColors->getObjName(), noOfTimesteps, (coDistributedObject **)dataColors); coDoSet *setRadii = new coDoSet(m_portRadii->getObjName(), noOfTimesteps, (coDistributedObject **)dataRadii); // Set timestep attribute: stringstream timestep; timestep << "0 " << noOfTimesteps - 1; setPoints->addAttribute("TIMESTEP", timestep.str().c_str()); setLines->addAttribute("TIMESTEP", timestep.str().c_str()); setColors->addAttribute("TIMESTEP", timestep.str().c_str()); setRadii->addAttribute("TIMESTEP", timestep.str().c_str()); CoString module_id("!"); module_id += CoString(Covise::get_module()) + CoString("\n") + Covise::get_instance() + CoString("\n"); module_id += CoString(Covise::get_host()) + CoString("\n"); setPoints->addAttribute("ITTFEEDBACK", module_id.c_str()); #if 0 // Create Feedback coFeedback feedback("FileBrowserParam"); feedback.addPara(m_pParamFile); feedback.apply(setPoints); #endif // Assign sets to output ports: m_portPoints->setCurrentObject(setPoints); m_portVolumeBox->setCurrentObject(setLines); m_portColors->setCurrentObject(setColors); m_portRadii->setCurrentObject(setRadii); fprintf(stderr, "ready!"); delete structure; }
void module::moudle_info(boost::shared_ptr<boost::unordered_map<std::string, boost::any> > & info){ (*info)["module_name"] = module_name(); (*info)["module_id"] = module_id(); (*info)["module_func"] = _module_func; }