void reaccsToFingerprint(struct reaccs_molecule_t *molPtr, std::vector<boost::uint32_t> &res, unsigned int bitFlags = 32767U, bool isQuery = false, bool resetVect = true, unsigned int nBytes = 64) { if (resetVect) res.clear(); char *fingerprint = getFp(molPtr, bitFlags, isQuery, nBytes); for (unsigned int i = 0; i < nBytes; i += 4) { boost::uint32_t word; word = fingerprint[i] | (fingerprint[i + 1] << 8) | (fingerprint[i + 2] << 16) | (fingerprint[i + 3] << 24); res.push_back(word); } MyFree(fingerprint); };
const Vector& PFEMElement2DBubble::getResistingForceIncInertia() { // resize P int ndf = this->getNumDOF(); P.resize(ndf); P.Zero(); // get velocity, accleration Vector v(ndf), vdot(ndf); for(int i=0; i<3; i++) { const Vector& accel = nodes[2*i]->getTrialAccel(); vdot(numDOFs(2*i)) = accel(0); vdot(numDOFs(2*i)+1) = accel(1); const Vector& accel2 = nodes[2*i+1]->getTrialAccel(); // pressure vdot(numDOFs(2*i+1)) = accel2(0); const Vector& vel = nodes[2*i]->getTrialVel(); v(numDOFs(2*i)) = vel(0); v(numDOFs(2*i)+1) = vel(1); const Vector& vel2 = nodes[2*i+1]->getTrialVel(); // pressure v(numDOFs(2*i+1)) = vel2(0); } // bubble force Vector fp(3); getFp(fp); // internal force P.addMatrixVector(1.0, getMass(), vdot, 1.0); P.addMatrixVector(1.0, getDamp(), v, 1.0); // external force Vector F(6); getF(F); for(int i=0; i<3; i++) { P(numDOFs(2*i)) -= F(2*i); P(numDOFs(2*i)+1) -= F(2*i+1); P(numDOFs(2*i+1)) -= fp(i); } //opserr<<"F = "<<F; return P; }
void IE_Exp_AbiWord_1::_setupFile() { // allow people to override this on the command line or otherwise const std::string & prop = (getProperty ("compress")); if (!prop.empty()) m_bIsCompressed = UT_parseBool(prop.c_str (), m_bIsCompressed); if (m_bIsCompressed) { GsfOutput * gzip = gsf_output_gzip_new(getFp (), NULL); m_output = gzip; } else { m_output = 0; } }
void reaccsToFingerprint(struct reaccs_molecule_t *molPtr, ExplicitBitVect &res, unsigned int bitFlags = 32767U, bool isQuery = false, bool resetVect = true, unsigned int nBytes = 64) { PRECONDITION(molPtr, "bad molecule"); PRECONDITION(res.getNumBits() >= nBytes * 8U, "res too small"); if (resetVect) res.clearBits(); char *fingerprint = getFp(molPtr, bitFlags, isQuery, nBytes); for (unsigned int i = 0; i < nBytes; ++i) { char byte = fingerprint[i]; if (byte) { char mask = 1; for (int j = 0; j < 8; ++j) { if (byte & mask) { res.setBit(i * 8 + j); } mask = mask << 1; } } } MyFree(fingerprint); };
/** * This writes out our AbiWord file as an OpenOffice * compound document */ UT_Error IE_Exp_OpenDocument::_writeDocument(void) { ODe_DocumentData docData(getDoc()); ODe_AuxiliaryData auxData; ODe_AbiDocListener* pAbiDocListener = NULL; ODe_AbiDocListenerImpl* pAbiDocListenerImpl = NULL; UT_return_val_if_fail (getFp(), UT_ERROR); PD_DocumentRDFHandle rdf = getDoc()->getDocumentRDF(); auxData.m_additionalRDF = rdf->createScratchModel(); const std::string & prop = getProperty ("uncompressed"); if (!prop.empty() && UT_parseBool (prop.c_str (), false)) { m_odt = GSF_OUTFILE(g_object_ref(G_OBJECT(getFp()))); } else { GError* error = NULL; m_odt = GSF_OUTFILE (gsf_outfile_zip_new (getFp(), &error)); if (error) { UT_DEBUGMSG(("Error writing odt file: %s\n", error->message)); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } } UT_return_val_if_fail(m_odt, UT_ERROR); // Needed to ensure that all *printf writes numbers correctly, // like "45.56mm" instead of "45,56mm". UT_LocaleTransactor numericLocale (LC_NUMERIC, "C"); { GsfOutput * mimetype = gsf_outfile_new_child_full (m_odt, "mimetype", FALSE, "compression-level", 0, (void*)0); if (!mimetype) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } ODe_gsf_output_write(mimetype, 39 /*39 == strlen("application/vnd.oasis.opendocument.text")*/, (const guint8 *)"application/vnd.oasis.opendocument.text"); ODe_gsf_output_close(mimetype); } if (!ODe_MetaDataWriter::writeMetaData(getDoc(), m_odt)) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } if (!ODe_SettingsWriter::writeSettings(getDoc(), m_odt)) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } if (!ODe_PicturesWriter::writePictures(getDoc(), m_odt)) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } if (!ODe_ManifestWriter::writeManifest(getDoc(), m_odt)) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } // Gather all paragraph style names used by heading paragraphs // (ie. all paragraph styles that are used to build up TOCs). pAbiDocListenerImpl = new ODe_HeadingSearcher_Listener(docData.m_styles, auxData); pAbiDocListener = new ODe_AbiDocListener(getDoc(), pAbiDocListenerImpl, false); if (!getDoc()->tellListener(static_cast<PL_Listener *>(pAbiDocListener))) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } pAbiDocListener->finished(); DELETEP(pAbiDocListener); DELETEP(pAbiDocListenerImpl); // Now that we have all paragraph styles that build up the TOCs in the // document (if any), we can build up the TOC bodies. We do this because // OpenOffice.org requires the TOC bodies to be present and filled // when initially opening the document. Without it, it will show // an empty TOC until the user regenerates it, which is not that pretty. // Annoyingly we have to build up the TOC ourselves during export, as // it doesn't exist within AbiWord's PieceTable. Until that changes, this // is the best we can do. if (auxData.m_pTOCContents) { pAbiDocListenerImpl = new ODe_TOC_Listener(auxData); pAbiDocListener = new ODe_AbiDocListener(getDoc(), pAbiDocListenerImpl, false); if (!getDoc()->tellListener(static_cast<PL_Listener *>(pAbiDocListener))) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } pAbiDocListener->finished(); DELETEP(pAbiDocListener); DELETEP(pAbiDocListenerImpl); } // Gather document content and styles if (!docData.doPreListeningWork()) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } pAbiDocListenerImpl = new ODe_Main_Listener(docData, auxData); pAbiDocListener = new ODe_AbiDocListener(getDoc(), pAbiDocListenerImpl, false); if (!getDoc()->tellListener(static_cast<PL_Listener *>(pAbiDocListener))) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } pAbiDocListener->finished(); DELETEP(pAbiDocListener); DELETEP(pAbiDocListenerImpl); if (!docData.doPostListeningWork()) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } // Write RDF. if (!ODe_RDFWriter::writeRDF(getDoc(), m_odt, auxData.m_additionalRDF )) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } // Write content and styles if (!docData.writeStylesXML(m_odt)) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } if (!docData.writeContentXML(m_odt)) { ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_ERROR; } ODe_gsf_output_close(GSF_OUTPUT(m_odt)); return UT_OK; }
UT_Error IE_Exp_EPUB::_writeDocument() { UT_Error errOptions = doOptions(); if (errOptions == UT_SAVE_CANCELLED) //see Bug 10840 { return UT_SAVE_CANCELLED; } else if (errOptions != UT_OK) { return UT_ERROR; } m_root = gsf_outfile_zip_new(getFp(), NULL); if (m_root == NULL) { UT_DEBUGMSG(("ZIP output is null\n")); return UT_ERROR; } m_oebps = gsf_outfile_new_child(m_root, "OEBPS", TRUE); if (m_oebps == NULL) { UT_DEBUGMSG(("Can`t create oebps output object\n")); return UT_ERROR; } // mimetype must a first file in archive GsfOutput *mimetype = gsf_outfile_new_child_full(m_root, "mimetype", FALSE, "compression-level", 0, NULL); gsf_output_write(mimetype, strlen(EPUB_MIMETYPE), (const guint8*) EPUB_MIMETYPE); gsf_output_close(mimetype); // We need to create temporary directory to which // HTML plugin will export our document m_baseTempDir = UT_go_filename_to_uri(g_get_tmp_dir()); m_baseTempDir += G_DIR_SEPARATOR_S; // To generate unique directory name we`ll use document UUID m_baseTempDir += getDoc()->getDocUUIDString(); // We should delete any previous temporary data for this document to prevent // odd files appearing in the container UT_go_file_remove(m_baseTempDir.c_str(), NULL); UT_go_directory_create(m_baseTempDir.c_str(), NULL); if (writeContainer() != UT_OK) { UT_DEBUGMSG(("Failed to write container\n")); return UT_ERROR; } if (writeStructure() != UT_OK) { UT_DEBUGMSG(("Failed to write document structure\n")); return UT_ERROR; } if (writeNavigation() != UT_OK) { UT_DEBUGMSG(("Failed to write navigation\n")); return UT_ERROR; } if (package() != UT_OK) { UT_DEBUGMSG(("Failed to package document\n")); return UT_ERROR; } gsf_output_close(m_oebps); gsf_output_close(GSF_OUTPUT(m_root)); // After doing all job we should delete temporary files UT_go_file_remove(m_baseTempDir.c_str(), NULL); return UT_OK; }
SSATmp* TraceBuilder::genLdLocAddr(uint32_t id) { return gen(LdLocAddr, getLocalType(id).ptr(), LocalId(id), getFp()); }