void prt( LPTSTR lps ) { TCHAR tbuf[MAXIO+8]; DWORD dwl = strlen(lps); DWORD off = 0; DWORD dwi; PTSTR pb = tbuf; TCHAR c, d; d = 0; for(dwi = 0; dwi < dwl; dwi++) { c = lps[dwi]; if( c == '\n' ) { if( d != '\r' ) pb[off++] = '\r'; } else if( c == '\r' ) { if( lps[dwi+1] != '\n' ) { pb[off++] = c; c = '\n'; } } pb[off++] = c; if(off >= MAXIO) { pb[off] = 0; oi(pb); off = 0; } d = c; } if(off) { pb[off] = 0; oi(pb); } }
/*static*/ void TextExpansion :: TryToRemoveExpansion ( ProjChar* pProjCh_ToParse ) { /* PRECONDITION */ { GLOBALASSERT( pProjCh_ToParse ); } /* CODE */ { List<SCString*> List_pSCString = SCString :: Parse ( pProjCh_ToParse ); for ( LIF<SCString*> oi(&List_pSCString); !oi.done(); oi.next() ) { TryToRemoveExpansion ( oi() ); oi() -> R_Release(); } } }
/*static*/ void TextExpansion :: AddExpansion ( ProjChar* pProjCh_ToParse ) { /* PRECONDITION */ { GLOBALASSERT( pProjCh_ToParse ); } /* CODE */ { List<SCString*> List_pSCString = SCString :: Parse ( pProjCh_ToParse ); if ( List_pSCString . size () == 2) { TextExpansion* pTextExp_New = new TextExpansion ( List_pSCString[0], // pSCString_Short List_pSCString[1] // pSCString_Expansion ); { SCString* pSCString_Temp = new SCString("EXPANSION DEFINED: "); // LOCALISEME(); SCString* pSCString_Feedback = new SCString ( pSCString_Temp, pTextExp_New -> pSCString_Description_Val ); pSCString_Temp -> R_Release(); pSCString_Feedback -> SendToScreen(); pSCString_Feedback -> R_Release(); } } else { SCString* pSCString_Feedback = new SCString("EXPECTING TWO ARGUMENTS"); // LOCALISEME(); pSCString_Feedback -> SendToScreen(); pSCString_Feedback -> R_Release(); } for ( LIF<SCString*> oi(&List_pSCString); !oi.done(); oi.next() ) { oi() -> R_Release(); } } }
virtual void SkipClassMember(CObjectIStream& in, const CObjectTypeInfoMI& passed_info) { cout << in.GetStackPath() << endl; #if 1 DefaultSkip(in, passed_info); #else // get information about the member // typeinfo of the parent class (Bioseq) CObjectTypeInfo oti = passed_info.GetClassType(); // typeinfo of the member (SET OF Seq-annot) CObjectTypeInfo omti = passed_info.GetMemberType(); // index of the member in parent class (4) TMemberIndex mi = passed_info.GetMemberIndex(); // information about the member, including its name (annot) const CMemberInfo* minfo = passed_info.GetMemberInfo(); #if 1 // or read the whole SET OF Seq-annot at once CObjectInfo oi(passed_info); DefaultRead(in, oi); cout << MSerial_AsnText << oi << endl; #endif #if 0 // or read CSeq_annot objects one by one and write them into stdout unique_ptr<CObjectOStream> out(CObjectOStream::Open(eSerial_AsnText, "stdout", eSerial_StdWhenStd)); COStreamContainer o(*out, passed_info); for ( CIStreamContainerIterator i(in, passed_info); i; ++i ) { CSeq_annot annot; i >> annot; // NOTE: this does not produce well formed text ASN, because of missing typeinfo name // this would work though if we copied data into existing ASN stream // where typeinfo name ("file header") is not required o << annot; // if we needed well formed text ASN, we could write it like this: // cout << MSerial_AsnText << annot; } #endif #if 0 // or read the whole SET OF Seq-annot at once CBioseq::TAnnot annot; CObjectInfo oi(&annot, passed_info.GetMemberType().GetTypeInfo()); in.ReadObject(oi); // write them one by one for( const auto& e: annot) { cout << MSerial_AsnText << *e << endl; } // or write them all at once unique_ptr<CObjectOStream> out(CObjectOStream::Open(eSerial_AsnText, "stdout", eSerial_StdWhenStd)); out->WriteObject(oi); #endif #endif }
/*static*/ void TextExpansion :: ListAll(void) { for ( LIF<TextExpansion*> oi(&List_pTextExp); !oi.done(); oi.next() ) { oi() -> Display(); } }
// service to ensure line endings in windows only static void prt( char * ps ) { static char _s_buf[1024]; char * pb = _s_buf; size_t i, j, k; char c, d; i = strlen(ps); k = 0; d = 0; if(i) { k = 0; d = 0; for( j = 0; j < i; j++ ) { c = ps[j]; if( c == 0x0d ) { if( (j+1) < i ) { if( ps[j+1] != 0x0a ) { pb[k++] = c; c = 0x0a; } } else { pb[k++] = c; c = 0x0a; } } else if( c == 0x0a ) { if( d != 0x0d ) { pb[k++] = 0x0d; } } pb[k++] = c; d = c; if( k >= MXIO ) { pb[k] = 0; oi(pb); k = 0; } } // for length of string if( k ) { //if( ( gbCheckCrLf ) && // ( d != 0x0a ) ) { // add Cr/Lf pair //pb[k++] = 0x0d; //pb[k++] = 0x0a; //pb[k] = 0; //} pb[k] = 0; oi( pb ); } } }
string RegexReplace::replace(const string &str) const { ostringstream t(std::ios::out); ostream_iterator<char, char> oi(t); boost::regex_replace(oi, str.begin(), str.end(), exp, formatter, boost::match_default | boost::format_all); return t.str(); }
void NFABuilder::patch_mid(OutListT& src, const InListT& dst, uint32_t dstskip) { // Make an edge from each vertex in src to each vertex in dst. Edges // to vertices in dst before dstskip go before the insertion point in // src, edges to vertices in dst after dstskip go after the insertion // point in src. const InListT::const_iterator skip_stop( dstskip < dst.size() ? dst.begin() + dstskip : dst.end()); for (OutListT::iterator oi(src.begin()); oi != src.end(); ++oi) { uint32_t pos = oi->second; InListT::const_iterator ii(dst.begin()); // make edges before dstskip, inserting before src insertion point for ( ; ii != dst.end() && ii < skip_stop; ++ii) { Fsm->insertEdge(oi->first, *ii, pos++); } // save the new insertion point for dst const uint32_t spos = pos; // make edges after dstskip, inserting after src insertion point for ( ; ii != dst.end(); ++ii) { Fsm->insertEdge(oi->first, *ii, pos++); } // set the new insertion point for dst oi->second = spos; } }
void Process::AcquireSimulationSymbols( void ) { HDF5IterateGroups scan; scan.SetOnHandleObject( MakeDelegate( this, &Process::HandleHDF5Object ) ); scan.SetOnHandleGroup( MakeDelegate( this, &Process::HandleHDF5Group ) ); scan.Start( m_sPathForSeries ); if ( 0 != m_mapStrikeInfo.size() ) throw std::runtime_error( "Process::AcquireSimulationSymbols strikes already set" ); for ( strikes_iterator_t iter = m_mapStrikes.begin(); iter != m_mapStrikes.end(); ++ iter ) { StrikeInfo oi( iter->first ); m_mapStrikeInfo[ iter->first ] = oi; StrikeInfo& poi = m_mapStrikeInfo.find( iter->first )->second; poi.AssignCall( iter->second.first ); // change simulator sometime to accept these mid run m_sim->AddQuoteHandler( iter->second.first, MakeDelegate( poi.Call(), &CNakedCall::HandleQuote ) ); m_sim->AddTradeHandler( iter->second.first, MakeDelegate( poi.Call(), &CNakedCall::HandleTrade ) ); m_sim->AddGreekHandler( iter->second.first, MakeDelegate( poi.Call(), &CNakedCall::HandleGreek ) ); poi.AssignPut( iter->second.second ); // change simulator sometime to accept these mid run m_sim->AddQuoteHandler( iter->second.second, MakeDelegate( poi.Put(), &CNakedPut::HandleQuote ) ); m_sim->AddTradeHandler( iter->second.second, MakeDelegate( poi.Put(), &CNakedPut::HandleTrade ) ); m_sim->AddGreekHandler( iter->second.second, MakeDelegate( poi.Put(), &CNakedPut::HandleGreek ) ); m_vCrossOverPoints.push_back( iter->first ); } m_ss.str( "" ); m_ss << "Simulation Symbols Acquired." << std::endl; OutputDebugString( m_ss.str().c_str() ); }
virtual void CopyObject(CObjectStreamCopier& copier, const CObjectTypeInfo& passed_info) { cout << copier.In().GetStackPath() << endl; #if 1 DefaultCopy(copier, passed_info); #else #if 1 // or skip the object copier.In().SkipObject(passed_info.GetTypeInfo()); #endif #if 0 // or read object CSeq_annot annot; copier.In().ReadObject(&annot, CSeq_annot::GetTypeInfo()); cout << MSerial_AsnText << annot << endl; // and maybe write it as well copier.Out().WriteObject(&annot, CSeq_annot::GetTypeInfo()); #endif #if 0 // or read object and write it CObjectInfo oi(passed_info.GetTypeInfo()); copier.In().ReadObject(oi); copier.Out().WriteObject(oi); #endif // typeinfo of the object (Seq-annot) TTypeInfo ti = passed_info.GetTypeInfo(); #endif }
std::shared_ptr<Bucket> Bucket::merge(BucketManager& bucketManager, std::shared_ptr<Bucket> const& oldBucket, std::shared_ptr<Bucket> const& newBucket, std::vector<std::shared_ptr<Bucket>> const& shadows, bool keepDeadEntries) { // This is the key operation in the scheme: merging two (read-only) // buckets together into a new 3rd bucket, while calculating its hash, // in a single pass. assert(oldBucket); assert(newBucket); Bucket::InputIterator oi(oldBucket); Bucket::InputIterator ni(newBucket); std::vector<Bucket::InputIterator> shadowIterators(shadows.begin(), shadows.end()); auto timer = bucketManager.getMergeTimer().TimeScope(); Bucket::OutputIterator out(bucketManager.getTmpDir(), keepDeadEntries); BucketEntryIdCmp cmp; while (oi || ni) { if (!ni) { // Out of new entries, take old entries. maybe_put(cmp, out, oi, shadowIterators); ++oi; } else if (!oi) { // Out of old entries, take new entries. maybe_put(cmp, out, ni, shadowIterators); ++ni; } else if (cmp(*oi, *ni)) { // Next old-entry has smaller key, take it. maybe_put(cmp, out, oi, shadowIterators); ++oi; } else if (cmp(*ni, *oi)) { // Next new-entry has smaller key, take it. maybe_put(cmp, out, ni, shadowIterators); ++ni; } else { // Old and new are for the same key, take new. maybe_put(cmp, out, ni, shadowIterators); ++oi; ++ni; } } return out.getBucket(bucketManager); }
int main(int argc, const char** argv) { try{ e1.assign(expression_text); e2.assign(pre_expression); for(int i = 1; i < argc; ++i) { std::cout << "Processing file " << argv[i] << std::endl; std::ifstream fs(argv[i]); std::string in; load_file(in, fs); fs.close(); std::string out_name = std::string(argv[i]) + std::string(".htm"); std::ofstream os(out_name.c_str()); os << header_text; // strip '<' and '>' first by outputting to a // temporary string stream std::ostringstream t(std::ios::out | std::ios::binary); std::ostream_iterator<char> oi(t); boost::regex_replace(oi, in.begin(), in.end(), e2, pre_format, boost::match_default | boost::format_all); // then output to final output stream // adding syntax highlighting: std::string s(t.str()); std::ostream_iterator<char> out(os); boost::regex_replace(out, s.begin(), s.end(), e1, format_string, boost::match_default | boost::format_all); os << footer_text; os.close(); } } catch(...) { return -1; } return 0; }
MtpObjectsModel::ObjectInfo MtpObjectsModel::getInfoById(mtp::u32 objectId) const { mtp::msg::ObjectInfo oi(_session->GetObjectInfo(objectId)); qint64 size = oi.ObjectCompressedSize; if (size == mtp::MaxObjectSize) size = _session->GetObjectIntegerProperty(objectId, mtp::ObjectProperty::ObjectSize); return ObjectInfo(fromUtf8(oi.Filename), oi.ObjectFormat, size); }
// class method SAWYER_EXPORT std::string Grammar::unescape(const std::string &s) { std::ostringstream out(std::ios::out | std::ios::binary); std::ostream_iterator<char, char> oi(out); boost::regex re("(@([@{}]))|(@~)"); const char *fmt = "(?1\\2)(?3)"; boost::regex_replace(oi, s.begin(), s.end(), re, fmt, boost::match_default|boost::format_all); return out.str(); }
int direct_out_it( char *cp ) { #ifdef _MSC_VER prt(cp); #else oi(cp); #endif return (int)strlen(cp); }
/*static*/ void ConsoleVariable :: ListAllVariables(void) { SCString* pSCString_Temp = new SCString("LIST OF ALL CONSOLE VARIABLES:"); pSCString_Temp -> SendToScreen(); pSCString_Temp ->R_Release(); for ( LIF<ConsoleVariable*> oi(&List_pConsoleVar); !oi.done(); oi.next() ) { oi() -> Display(); } }
void dbg() { std::cout << "ring: "; std::ostream_iterator<typename D::Msg> oi(std::cout, ", "); std::copy(D::ring.begin(), D::ring.end(), oi); std::cout << std::endl; std::cout << "cursor: " << D::cursor << std::endl; }
void MainPanel::FileSetup() { gedString oi("ok"); oi = "Actor -> Collision (Any side of LeftWire)"; for(int i = 0; i < listFile->Count(); i++) { gedString *s = (gedString *)listFile->GetItemData(i); delete s; } listFile->RemoveAll(); listFile->AddText("New Game"); listFile->AddText("Load"); listFile->AddText("Merge"); listFile->AddText("Save"); #ifdef USE_SYSTEM_FILE_DIALOG if(Tutorial::IsOff()) { listFile->AddText("Save As..."); } #endif listFile->AddText("Export"); if(Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION)) { RecentFileList mru; bool bFirstSep = false; for(int i = 0; i < mru.GetSize(); i++) { if(!mru.GetFullPath(i).empty()) { if(!bFirstSep) { listFile->AddSeparator(); bFirstSep = true; } int iData = listFile->AddText(mru.GetDisplayName(i)); listFile->SetItemData(iData, new gedString(mru.GetFullPath(i))); } } if(bFirstSep) { listFile->AddSeparator(); } } listFile->AddText("Exit"); }
/* service to ensure line endings in windows only */ static void prt( char * ps ) { static char _s_buf[1024]; char * pb = _s_buf; size_t i, j, k; char c, d; i = strlen(ps); k = 0; d = 0; if(i) { k = 0; d = 0; for( j = 0; j < i; j++ ) { c = ps[j]; if( c == 0x0d ) { if( (j+1) < i ) { if( ps[j+1] != 0x0a ) { pb[k++] = c; c = 0x0a; } } else { pb[k++] = c; c = 0x0a; } } else if( c == 0x0a ) { if( d != 0x0d ) { pb[k++] = 0x0d; } } pb[k++] = c; d = c; if( k >= MXIO ) { pb[k] = 0; oi(pb); k = 0; } } /* for length of string */ if( k ) { pb[k] = 0; oi( pb ); } } }
int fill_iterator_main() { yasli::vector<int> v; int a = 100; yasli_nstd::fill_iterator<const int> b(100); yasli_nstd::fill_iterator<const int> e(100,3); v.insert(v.end(), b, e ); std::ostream_iterator<int> oi(std::cout, " "); std::copy(v.begin(),v.end(), oi ); return 0; }
void test_function_value_or() { test_function_value_or_for<int>(); test_function_value_or_for<double>(); test_function_value_or_for<IntWrapper>(); optional<int> oi(1); BOOST_CHECK(oi.value_or(FatToIntConverter(2)) == 1); BOOST_CHECK(FatToIntConverter::conversions == 0); oi = boost::none; BOOST_CHECK(oi.value_or(FatToIntConverter(2)) == 2); BOOST_CHECK(FatToIntConverter::conversions == 1); }
ExecStatus ChannelBool<View>::propagate(Space& home, const ModEventDelta&) { running = true; if (zeros.size() > 0) { BndSetRanges zi(zeros); GECODE_ME_CHECK(y.excludeI(home, zi)); zeros.init(home); } if (ones.size() > 0) { BndSetRanges oi(ones); GECODE_ME_CHECK(y.includeI(home, oi)); ones.init(home); } running = false; if (delta.glbMin() != 1 || delta.glbMax() != 0) { if (!delta.glbAny()) { for (int i=delta.glbMin(); i<=delta.glbMax(); i++) GECODE_ME_CHECK(x[i].one(home)); } else { GlbRanges<View> glb(y); for (Iter::Ranges::ToValues<GlbRanges<View> > gv(glb); gv(); ++gv) { GECODE_ME_CHECK(x[gv.val()].one(home)); } } } if (delta.lubMin() != 1 || delta.lubMax() != 0) { if (!delta.lubAny()) { for (int i=delta.lubMin(); i<=delta.lubMax(); i++) GECODE_ME_CHECK(x[i].zero(home)); } else { int cur = 0; for (LubRanges<View> lub(y); lub(); ++lub) { for (; cur < lub.min(); cur++) { GECODE_ME_CHECK(x[cur].zero(home)); } cur = lub.max() + 1; } for (; cur < x.size(); cur++) { GECODE_ME_CHECK(x[cur].zero(home)); } } } new (&delta) SetDelta(); return y.assigned() ? home.ES_SUBSUMED(*this) : ES_FIX; }
/* STDAPI StringCchVPrintf( OUT LPTSTR pszDest, * IN size_t cchDest, IN LPCTSTR pszFormat, IN va_list argList ); */ int MCDECL sprtf( const char *pf, ... ) { static char _s_sprtfbuf[M_MAX_SPRTF+4]; char * pb = _s_sprtfbuf; int i; va_list arglist; va_start(arglist, pf); i = vsnprintf( pb, M_MAX_SPRTF, pf, arglist ); va_end(arglist); #ifdef _MSC_VER prt(pb); /* ensure CR/LF */ #else oi(pb); #endif return i; }
void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port) { LLMemType mt(LLMemType::MTYPE_OBJECT); #ifdef ORPHAN_SPAM llinfos << "Orphaning object " << childp->getID() << " with parent " << parent_id << llendl; #endif // We're an orphan, flag things appropriately. childp->mOrphaned = TRUE; if (childp->mDrawable.notNull()) { bool make_invisible = true; LLViewerObject *parentp = (LLViewerObject *)childp->getParent(); if (parentp) { if (parentp->getRegion() != childp->getRegion()) { // This is probably an object flying across a region boundary, the // object probably ISN'T being reparented, but just got an object // update out of order (child update before parent). make_invisible = false; //llinfos << "Don't make object handoffs invisible!" << llendl; } } if (make_invisible) { // Make sure that this object becomes invisible if it's an orphan childp->mDrawable->setState(LLDrawable::FORCE_INVISIBLE); } } // Unknown parent, add to orpaned child list U64 parent_info = getIndex(parent_id, ip, port); if (-1 == mOrphanParents.find(parent_info)) { mOrphanParents.put(parent_info); } LLViewerObjectList::OrphanInfo oi(parent_info, childp->mID); if (-1 == mOrphanChildren.find(oi)) { mOrphanChildren.put(oi); mNumOrphans++; } }
int main( ) { Algebraic_real_1 real( 1 ); //CGAL::Qt::Converter< Algebraic_kernel_d_2 > testConverter; //CGAL::Qt::Converter< CKvA_2 > testConverter; //CGAL::Qt::Converter< Cartesian > testConverter; Kernel_point_2 testPt( 1, 2 ); Point_2 testPt2( testPt.x( ), testPt.y( ) ); Traits traits; Construct_curve_2 constructCurve = traits.construct_curve_2_object( ); Curve_2 curve = constructCurve( makeParabola( ) ); Make_x_monotone_2 mm = traits.make_x_monotone_2_object( ); std::vector< CGAL::Object > curves; mm( curve, std::back_inserter( curves ) ); std::cout << curves.size( ) << std::endl; X_monotone_curve_2 c1; CGAL::assign( c1, curves[ 0 ] ); double lb = -3; double ub = 3; double step = 6.0 / 1000; for ( int i = 0; i < 1000; ++i ) { X_monotone_curve_2 c2 = makeVerticalLine( lb + step * i ); CGAL::Object o; CGAL::Oneset_iterator< CGAL::Object > oi( o ); Intersect_2 intersect = traits.intersect_2_object( ); intersect( c1, c2, oi ); std::pair< Point_2, Multiplicity > res; CGAL::assign( res, o ); std::pair< double, double > approx = res.first.to_double( ); std::cout << approx.first << " " << approx.second << std::endl; } return 0; }
NTSTATUS name_object( object_t *obj, const OBJECT_ATTRIBUTES *oa ) { if (!oa) return STATUS_SUCCESS; obj->attr = oa->Attributes; if (!oa->ObjectName) return STATUS_SUCCESS; if (!oa->ObjectName->Buffer) return STATUS_SUCCESS; if (!oa->ObjectName->Length) return STATUS_SUCCESS; trace("name_object_t %pus\n", oa->ObjectName); name_object_t oi( obj ); oi.Attributes = oa->Attributes; oi.root = oa->RootDirectory; oi.path.set( *oa->ObjectName ); return open_root( obj, oi ); }
void Process::AddOptionToStrikeInfo( pInstrument_t pInstrument ) { double dblStrike = pInstrument->GetStrike(); mapStrikeInfo_iter_t iter = m_mapStrikeInfo.find( dblStrike ); if ( m_mapStrikeInfo.end() == iter ) { StrikeInfo oi( dblStrike ); m_mapStrikeInfo[ dblStrike ] = oi; m_vCrossOverPoints.push_back( dblStrike ); } switch ( pInstrument->GetOptionSide() ) { case ou::tf::OptionSide::Call: m_mapStrikeInfo[ dblStrike ].AssignCall( pInstrument ); break; case ou::tf::OptionSide::Put: m_mapStrikeInfo[ dblStrike ].AssignPut( pInstrument ); break; } m_ss.str(""); m_ss << "Option " << pInstrument->GetInstrumentName() << std::endl; OutputDebugString( m_ss.str().c_str() ); }
template <class T> std::ostream& operator<<(std::ostream& o, const many<T>& m) { std::ostream_iterator<T> oi(o, " "); std::copy(m.begin(), m.end(), oi); return o; }
void analyze::applyFilter(RichParameterSet* pars) { starlab::LineSegments * bbox_lines = new starlab::LineSegments(1); std::vector<starlab::LineSegments*> dir_lines(3, new starlab::LineSegments(2)); starlab::PolygonSoup * ps = new starlab::PolygonSoup; std::vector< std::vector<double> > colors = starlab::randomColors(12); mainWindow()->setStatusBarMessage("Finding connected pieces.."); QApplication::processEvents(); std::vector< SurfaceMesh::SurfaceMeshModel* > pieces = connectedPieces( mesh() ); std::vector<Vector3> all_points; std::vector<MinOBB::OBB> obb( pieces.size() ); mainWindow()->setStatusBarMessage("Finding OBBs.."); QApplication::processEvents(); QElapsedTimer timer; timer.start(); if( pars->getBool("IsParallel") ) { int N = pieces.size(); #pragma omp parallel for for(int i = 0; i < N; i++) { Vector3VertexProperty points = pieces[i]->vertex_coordinates(); std::vector<Vector3> all_points; for(auto v: pieces[i]->vertices()) all_points.push_back( points[v] ); obb[i] = MinOBB::OBB( all_points, true ); } } else { for(size_t pi = 0; pi < pieces.size(); pi++) { auto piece = pieces[pi]; Vector3VertexProperty points = piece->vertex_coordinates(); std::vector<Vector3> all_points; for(auto v: piece->vertices()) all_points.push_back( points[v] ); bool isAddJitter = true; obb[pi] = MinOBB::OBB( all_points, isAddJitter ); std::vector<Vector3> dir(3); for(int i = 0; i < 3; i++){ dir[0][i] = obb[pi].bb.dir_1[i]; dir[1][i] = obb[pi].bb.dir_2[i]; dir[2][i] = obb[pi].bb.dir_3[i]; } std::vector<Vector3> c = obb[pi].corners<Vector3>(); bbox_lines->addLines( (QVector<Vector3>() << c[0] << c[1] << c[5] << c[4] << c[0]).toStdVector(), Qt::black ); bbox_lines->addLines( (QVector<Vector3>() << c[0] << c[1] << c[3] << c[2] << c[0]).toStdVector(), Qt::black ); bbox_lines->addLines( (QVector<Vector3>() << c[6] << c[7] << c[3] << c[2] << c[6]).toStdVector(), Qt::black ); bbox_lines->addLines( (QVector<Vector3>() << c[6] << c[7] << c[5] << c[4] << c[6]).toStdVector(), Qt::black ); Vector3 mean(0,0,0); for(auto p: c) mean += p; mean /= c.size(); dir_lines[0]->addLine(mean, Vector3(mean + dir[0] * 0.5 * obb[pi].bb.length(0)), Qt::red); dir_lines[1]->addLine(mean, Vector3(mean + dir[1] * 0.5 * obb[pi].bb.length(1)), Qt::green); dir_lines[2]->addLine(mean, Vector3(mean + dir[2] * 0.5 * obb[pi].bb.length(2)), Qt::blue); if( pars->getBool("VisualizeBoxes") ){ std::vector< std::vector<Vector3> > face = obb[pi].faces<Vector3>(); for(size_t i = 0; i < face.size(); i++){ ps->addPoly((QVector<starlab::QVector3>() << face[i][2] << face[i][1] << face[i][0]), QColor::fromRgbF(colors[i][0],colors[i][1],colors[i][2], 0.1)); } } } } if( pars->getBool("Visualize") ) { drawArea()->addRenderObject(bbox_lines); for(size_t i = 0; i < dir_lines.size(); i++) drawArea()->addRenderObject( dir_lines[i] ); drawArea()->addRenderObject(ps); } mainWindow()->setStatusBarMessage( QString("Done finding OBBs. (%1 ms)").arg(timer.elapsed())); QApplication::processEvents(); Structure::Graph * graph = new Structure::Graph(); for(size_t bi = 0; bi < obb.size(); bi++) { MinOBB::OBB::OBBOX<Vector3> oi( obb[bi].bb ); std::vector<Vector3> dir(3); for(int i = 0; i < 3; i++){ dir[0][i] = obb[bi].bb.dir_1[i]; dir[1][i] = obb[bi].bb.dir_2[i]; dir[2][i] = obb[bi].bb.dir_3[i]; } Vector3 delta = dir[2] * oi.HalfSize[2]; Vector3 from = oi.Center + delta; Vector3 to = oi.Center - delta; NURBS::NURBSCurved curve = NURBS::NURBSCurved::createCurve(from, to); Structure::Curve * n = new Structure::Curve(curve, QString("node%1").arg(bi)); graph->addNode( n ); } mainWindow()->setStatusBarMessage("Now finding edges.."); QApplication::processEvents(); starlab::LineSegments * graphLines = new starlab::LineSegments(4); for(size_t i = 0; i < obb.size(); i++){ MinOBB::OBB::OBBOX<Vector3> oi( obb[i].bb ); for(size_t j = i + 1; j < obb.size(); j++){ MinOBB::OBB::OBBOX<Vector3> oj( obb[j].bb ); bool isIsect = MinOBB::OBB::testObbObb<Vector3>( oi, oj ); if( isIsect ) { graph->addEdge(QString("node%1").arg(i), QString("node%1").arg(j)); if( pars->getBool("VisualizeGraph") ) graphLines->addLine( oi.Center, oj.Center, Qt::magenta ); } } } drawArea()->addRenderObject( graphLines ); graph->saveToFile("graph.xml"); }
/*static*/ void TextExpansion :: TryToRemoveExpansion ( SCString* pSCString_Word ) { // assumed the word is already parsed/doesn't contain whitespace /* PRECONDITION */ { GLOBALASSERT( pSCString_Word ); } /* CODE */ { TextExpansion* pTextExp_ToKill = NULL; // Find the one to be removed; removed later to avoid confusing the // list iteration code for ( LIF<TextExpansion*> oi(&List_pTextExp); ( !( oi.done() || pTextExp_ToKill ) ); oi.next() ) { if ( STRUTIL_SC_Strequal ( oi() -> pSCString_Short_Val -> pProjCh(), pSCString_Word -> pProjCh() ) ) { pTextExp_ToKill = oi(); continue; } if ( STRUTIL_SC_Strequal ( oi() -> pSCString_Expansion_Val -> pProjCh(), pSCString_Word -> pProjCh() ) ) { pTextExp_ToKill = oi(); continue; } } if ( pTextExp_ToKill ) { { SCString* pSCString_Temp = new SCString("EXPANSION REMOVED: "); // LOCALISEME(); SCString* pSCString_Feedback = new SCString ( pSCString_Temp, pTextExp_ToKill -> pSCString_Description_Val ); pSCString_Temp -> R_Release(); pSCString_Feedback -> SendToScreen(); pSCString_Feedback -> R_Release(); } delete pTextExp_ToKill; } else { // unrecognised } } }