void OCC_Connect::MergeVertices(TopoDS_Shape &shape1,TopoDS_Shape &shape2) const { TopTools_IndexedMapOfShape imap, omap; TopExp::MapShapes(shape1,TopAbs_VERTEX,imap); TopExp::MapShapes(shape2,TopAbs_VERTEX,imap); BRepTools_ReShape replacer; for(int i=0;i<imap.Extent();i++) { for(int j=0;j<omap.Extent();j++) { TopoDS_Vertex orig=TopoDS::Vertex(imap(i+1)); TopoDS_Vertex repl=TopoDS::Vertex(omap(j+1)); if(BRepTools::Compare(orig,repl)) { repl.Orientation(orig.Orientation()); replacer.Replace(orig,repl); // FIXME, tolerance and point should be updated goto skip; } } omap.Add(imap(i+1)); skip:; } TopoDS_Shape t=shape1; shape1=replacer.Apply(t); t=shape2; shape2=replacer.Apply(t); }
bool ImapByeResponse::meaningful() const { if ( imap()->state() == IMAP::Logout ) return false; if ( imap()->Connection::state() == Connection::Closing ) return false; if ( imap()->Connection::state() == Connection::Inactive ) return false; return true; }
IntegerSet Command::set( bool parseMsns = false ) { IntegerSet result; ImapSession *s = 0; if ( imap() ) s = imap()->session(); uint n1 = 0, n2 = 0; bool done = false; while ( ok() && !done ) { char c = nextChar(); if ( c == '*' ) { step(); n1 = 0; if ( s ) n1 = s->largestUid(); else error( Bad, "Need a mailbox session to use * as an UID/MSN" ); } else if ( c >= '1' && c <= '9' ) { if ( parseMsns ) n1 = msn(); else n1 = nzNumber(); } else { error( Bad, "number or '*' expected, saw: " + following() ); } c = nextChar(); if ( c == ':' ) { if ( n2 ) error( Bad, "saw colon after range (" + fn( n1 ) + ":" + fn( n2 ) + "), saw:" + following() ); n2 = n1; n1 = 0; step(); } else if ( ok() ) { if ( n2 ) result.add( n1, n2 ); else result.add( n1 ); n1 = 0; n2 = 0; if ( c == ',' ) step(); else done = true; } }; return result; }
void Logout::execute() { imap()->endSession(); respond( "BYE logout" ); imap()->setState( IMAP::Logout ); // close the connection after the next event loop iteration // instead of at once, to avoid problems with squirrelmail. // squirrelmail reacts to the EOF before it has reacted to the // prior BYE, if they arrive in the same packet. imap()->setTimeoutAfter( 1 ); finish(); }
void Command::setState( State s ) { if ( d->state == s ) return; d->state = s; switch( s ) { case Retired: log( "Retired", Log::Debug ); break; case Unparsed: // this is the initial state, it should never be called. break; case Blocked: log( "Deferring execution", Log::Debug ); break; case Executing: (void)::gettimeofday( &d->started, 0 ); if ( d->permittedStates & ( 1 << imap()->state() ) ) { log( "Executing", Log::Debug ); d->session = imap()->session(); if ( d->session ) d->session->emitUpdates( 0 ); } else { error( Bad, "" ); } break; case Finished: if ( d->name != "idle" ) { struct timeval end; (void)::gettimeofday( &end, 0 ); long elapsed = ( end.tv_sec - d->started.tv_sec ) * 1000000 + ( end.tv_usec - d->started.tv_usec ); Log::Severity level = Log::Debug; if ( elapsed > 3000 ) level = Log::Info; EString m; m.append( "Execution time " ); m.append( fn( ( elapsed + 499 ) / 1000 ) ); m.append( "ms" ); log( m, level ); } log( "Finished", Log::Debug ); break; } imap()->unblockCommands(); }
void Command::finish() { if ( state() == Retired ) return; if ( d->usesRelativeMailbox ) imap()->setPrefersAbsoluteMailboxes( false ); else if ( d->usesAbsoluteMailbox ) imap()->setPrefersAbsoluteMailboxes( true ); if ( d->mailboxGroup && d->mailbox ) d->mailboxGroup->remove( d->mailbox ); setState( Finished ); }
uint Command::msn() { Mailbox *m; ImapSession *session = imap()->session(); if ( !session || ( m = session->mailbox() ) == 0 ) { error( Bad, "Need mailbox to parse MSN" ); return 1; } d->usesMsn = true; uint star = session->count(); uint r = star; if ( nextChar() == '*' ) { step(); if ( star == 0 ) error( Bad, "* is not valid as MSN in an empty mailbox" ); } else { r = nzNumber(); } if ( r > star ) { respond( "OK MSN " + fn( r ) + " is too large. " "I hope you mean " + fn( star ) + " and will act accordingly." ); r = star; } return session->uid( r ); }
void Command::emitResponses() { if ( state() == Retired ) return; Session * s = imap()->session(); if ( s && !s->initialised() ) return; imap()->emitResponses(); if ( !d->untagged.isEmpty() ) return; setState( Retired ); // we don't have a tag if we're an implicit Fetch or Store used by // ImapSession. if ( d->tag.isEmpty() ) return; EString t = tag(); if ( !d->error ) { t.append( " OK " ); } else if ( d->errorCode == Bad ) { imap()->recordSyntaxError(); t.append( " BAD " ); } else { t.append( " NO " ); } if ( !d->respTextCode.isEmpty() ) { t.append( "[" ); t.append( d->respTextCode ); t.append( "] " ); } if ( d->error ) { t.append( d->errorText ); } else { t.append( "done" ); } log( t ); t.append( "\r\n" ); imap()->enqueue( t ); }
MailboxGroup * Command::mailboxGroup() { if ( d->mailbox && !d->checkedMailboxGroup ) { d->mailboxGroup = imap()->mostLikelyGroup( d->mailbox, 3 ); d->checkedMailboxGroup = true; } return d->mailboxGroup; }
void Command::shrink( IntegerSet * set ) { ImapSession * s = imap()->session(); if ( !s || !set || set->isEmpty() ) return; set->remove( s->expunged() ); *set = set->intersection( s->messages() ); }
void Command::requireRight( Mailbox * m, Permissions::Right r ) { if ( !m ) return; if ( !d->checker ) d->checker = new PermissionsChecker; Permissions * p = 0; if ( imap()->state() == IMAP::Selected && m == imap()->session()->mailbox() ) p = imap()->session()->permissions(); else p = d->checker->permissions( m, imap()->user() ); if ( !p ) p = new Permissions( m, imap()->user(), this ); d->checker->require( p, r ); }
bool IdentifyLiaisonTunnel::doILT4( EdgeArray& edges ) { if( !isInitNetworkOk() ) return false; if( airEdges.isEmpty() ) return false; NodeFilter nf( dg, true ); BuildNodeFilter( dg, airEdges, sn, tn, nf ); IntMap imap( dg ); Init_IMap( dg, ef, nf, airEdges, imap ); // 记录节点的入度和出度 // 过滤阻断分支 IntMap inDeg( dg ), outDeg( dg ); InitDegMap( dg, ef, inDeg, outDeg ); bool bQuit = false; while( !bQuit ) { bQuit = true; for( Digraph::ArcIt e( dg ); e != INVALID; ++e ) { if( !ef[e] || datas[e]->et == ET_VIRTUAL ) continue; Digraph::Node u = dg.source( e ); Digraph::Node v = dg.target( e ); if( imap[u]*imap[v] <= 0 ) continue; if( outDeg[u] - 1 <= 0 || inDeg[v] - 1 <= 0 ) continue; if( imap[v] < 0 ) { bool ret = false; // 回风区,考察节点的入边是否有新风流入 for( Digraph::InArcIt ie( dg, v ); ie != INVALID; ++ie ) { if( imap[dg.source( ie )] > 0 ) { ret = true; break; } } if( ret ) continue; } outDeg[u] = outDeg[u] - 1; inDeg[v] = inDeg[v] - 1; edges.append( e ); bQuit = false; } } return true; }
void Command::error( Error e, const EString & t ) { if ( d->error ) return; if ( !imap() ) return; if ( d->permittedStates & ( 1 << imap()->state() ) ) { d->errorCode = e; d->errorText = t; } else if ( !t.isEmpty() && imap()->state() != IMAP::NotAuthenticated ) { d->errorCode = e; d->errorText = t; } else { d->errorCode = Bad; switch ( imap()->state() ) { case IMAP::NotAuthenticated: d->errorText = "Not permitted before authentication"; break; case IMAP::Authenticated: d->errorText = "Not permitted without mailbox"; break; case IMAP::Selected: d->errorText = "Not permitted while a mailbox is selected"; break; case IMAP::Logout: d->errorText = "Not permitted during logout"; // in this case we give the client a NO, not a BAD, since // the logout might be initiated by us. d->errorCode = No; break; }; } d->error = true; if ( d->transaction ) d->transaction->rollback(); finish(); }
void Command::space() { d->args->require( " " ); if ( d->args->nextChar() != ' ' ) return; while ( d->args->nextChar() == ' ' ) d->args->step(); (void)new ImapResponse( imap(), "BAD Illegal space seen before this text: " + following() ); }
main(int argc, char *argv[ ]) { if (argc > 1) disk = argv[1]; fd = open(disk, O_RDONLY); if (fd < 0){ printf("open %s failed\n", disk); exit(1); } imap(); }
EString Command::imapQuoted( Mailbox * m, Mailbox * r ) { Mailbox * base = 0; bool rel = false; if ( r ) base = r; else if ( imap()->user() ) base = imap()->user()->home(); // find out whether this name can be expressed as a relative name if ( base ) { Mailbox * p = m; while ( p && p != base ) p = p->parent(); if ( p ) rel = true; else rel = false; } // if it can, should it? does the client use relative names? if ( rel ) { if ( r ) ; // yes, we've explicitly been told to else if ( d->usesRelativeMailbox ) ; // yes, the client likes relative mailboxes else if ( d->usesAbsoluteMailbox ) rel = false; // no, the client sent an absolute name else if ( imap()->user() && imap()->user()->inbox() == m ) rel = true; // the client sent 'inbox' else if ( imap()->prefersAbsoluteMailboxes() ) rel = false; // past commands used absolute names } // find the actual name to return UString n = m->name(); if ( rel && base != Mailbox::root() ) n = n.mid( base->name().length() + 1 ); MUtf7Codec c; return imapQuoted( c.fromUnicode( n ), AString ); }
bool IdentifyLiaisonTunnel::doILT2( EdgeArray& edges ) { if( !isInitNetworkOk() ) return false; if( airEdges.isEmpty() ) return false; NodeFilter nf( dg, true ); BuildNodeFilter( dg, airEdges, sn, tn, nf ); // 记录节点属于哪个区域(0-用风区, 1-进风区, -1-回风区) IntMap imap( dg ); Init_IMap( dg, ef, nf, airEdges, imap ); // 查找联络巷 FindILTEdges( dg, datas, imap, edges ); return true; }
UString Command::mailboxName() { EString n = astring(); if ( n.endsWith( "/" ) ) n = n.mid( 0, n.length() - 1 ); User * u = imap()->user(); if ( u && n.lower() == "inbox" ) { return u->inbox()->name(); } MUtf7Codec m; UString un( m.toUnicode( n ) ); UString r; if ( !m.wellformed() ) { AsciiCodec a; un = a.toUnicode( n ); if ( !a.valid() ) { error( Bad, "Mailbox name misparsed both as ASCII and mUTF-7: " + m.error() + " (mUTF7) + " + a.error() + " (ASCII)" ); return r; } } if ( un.startsWith( "/" ) ) { if ( u && un[u->home()->name().length()] == '/' && un.startsWith( u->home()->name() ) ) d->usesAbsoluteMailbox = true; } else if ( !u ) { error( Bad, "Relative mailbox name is invalid before login" ); return r; } else { d->usesRelativeMailbox = true; r.append( u->home()->name() ); r.append( "/" ); } r.append( un ); if ( !Mailbox::validName( r ) ) { error( Bad, "Syntax error in mailbox name: " + n ); return r; } return r; }
main(int argc, char *argv[]) { int fd; if (argc > 1) device = argv[1]; fd = open(device, O_RDONLY); if (fd < 0){ printf("open %s failed\n", device); exit(1); } super(fd); gd(fd); bmap(fd); imap(fd); inode(fd); dir(fd); }
void Unselect::execute() { if ( state() == Executing ) imap()->setSession( 0 ); finish(); }
auto operator()(Container&& container) const { // explicit return type in lambda so reference types are preserved return imap([](auto&& group) -> impl::iterator_deref<Container> { return *std::begin(group.second); }, groupby(std::forward<Container>(container))); }
int main(int argc, char * argv[]) { try { ::libmaus::util::ArgInfo arginfo(argc,argv); ::libmaus::util::TempFileRemovalContainer::setup(); ::std::vector<std::string> const & inputfilenames = arginfo.restargs; char const * fasuffixes[] = { ".fa", ".fasta", 0 }; std::string deftmpname = libmaus::util::OutputFileNameTools::endClipLcp(inputfilenames,&fasuffixes[0]) + ".fa.tmp"; while ( ::libmaus::util::GetFileSize::fileExists(deftmpname) ) deftmpname += "_"; std::string defoutname = libmaus::util::OutputFileNameTools::endClipLcp(inputfilenames,&fasuffixes[0]) + ".fa.recoded"; while ( ::libmaus::util::GetFileSize::fileExists(defoutname) ) defoutname += "_"; std::string const tempfilename = arginfo.getValue<std::string>("tempfilename",deftmpname); std::string const outfilename = arginfo.getValue<std::string>("outputfilename",defoutname); std::string const indexfilename = tempfilename + ".index"; unsigned int const addterm = arginfo.getValue<unsigned int>("addterm",0); unsigned int const termadd = addterm ? 1 : 0; ::libmaus::util::TempFileRemovalContainer::addTempFile(tempfilename); ::libmaus::util::TempFileRemovalContainer::addTempFile(indexfilename); std::cerr << "temp file name " << tempfilename << std::endl; std::cerr << "output file name " << outfilename << std::endl; /* uint64_t const numseq = */ ::libmaus::fastx::FastAReader::rewriteFiles(inputfilenames,tempfilename,indexfilename); uint64_t curpos = 0; ::libmaus::aio::CheckedOutputStream COS(outfilename); // 0,A,C,G,T,N // map forward ::libmaus::autoarray::AutoArray<char> cmap(256,false); std::fill(cmap.begin(),cmap.end(),5+termadd); cmap['\n'] = 0 + termadd; cmap['a'] = cmap['A'] = 1 + termadd; cmap['c'] = cmap['C'] = 2 + termadd; cmap['g'] = cmap['G'] = 3 + termadd; cmap['t'] = cmap['T'] = 4 + termadd; cmap['n'] = cmap['N'] = 5 + termadd; // map to reverse complement ::libmaus::autoarray::AutoArray<char> rmap(256,false); std::fill(rmap.begin(),rmap.end(),5+termadd); rmap['\n'] = 0 + termadd; rmap['a'] = rmap['A'] = 4 + termadd; rmap['c'] = rmap['C'] = 3 + termadd; rmap['g'] = rmap['G'] = 2 + termadd; rmap['t'] = rmap['T'] = 1 + termadd; rmap['n'] = rmap['N'] = 5 + termadd; // reverse complement for mapped data ::libmaus::autoarray::AutoArray<char> xmap(256,false); std::fill(xmap.begin(),xmap.end(),5+termadd); xmap[0] = 0 + termadd; xmap[1] = 4 + termadd; xmap[2] = 3 + termadd; xmap[3] = 2 + termadd; xmap[4] = 1 + termadd; xmap[5] = 5 + termadd; ::libmaus::autoarray::AutoArray<char> imap(256,false); for ( uint64_t i = 0; i < imap.size(); ++i ) imap[i] = static_cast<char>(i); ::libmaus::fastx::FastAReader::RewriteInfoDecoder::unique_ptr_type infodec(new ::libmaus::fastx::FastAReader::RewriteInfoDecoder(indexfilename)); ::libmaus::fastx::FastAReader::RewriteInfo info; uint64_t maxseqlen = 0; while ( infodec->get(info) ) maxseqlen = std::max(maxseqlen,info.seqlen); std::cerr << "[V] max seq len " << maxseqlen << std::endl; ::libmaus::fastx::FastAReader::RewriteInfoDecoder::unique_ptr_type tinfodec(new ::libmaus::fastx::FastAReader::RewriteInfoDecoder(indexfilename)); infodec = UNIQUE_PTR_MOVE(tinfodec); if ( maxseqlen <= 256*1024 ) { ::libmaus::aio::CheckedInputStream CIS(tempfilename); ::libmaus::autoarray::AutoArray<uint8_t> B(maxseqlen+1,false); while ( infodec->get(info) ) { // skip id CIS.ignore(info.idlen+2); // read sequence plus following terminator CIS.read(reinterpret_cast<char *>(B.begin()), info.seqlen+1); // map for ( uint64_t i = 0; i < info.seqlen+1; ++i ) B[i] = cmap[B[i]]; // write COS.write(reinterpret_cast<char const *>(B.begin()),info.seqlen+1); // remap for ( uint64_t i = 0; i < info.seqlen+1; ++i ) B[i] = xmap[B[i]]; // reverse std::reverse(B.begin(),B.begin()+info.seqlen); // write COS.write(reinterpret_cast<char const *>(B.begin()),info.seqlen+1); } } else { while ( infodec->get(info) ) { // std::cerr << info.valid << "\t" << info.idlen << "\t" << info.seqlen << "\t" << info.getIdPrefix() << std::endl; uint64_t const seqbeg = curpos + (info.idlen+2); uint64_t const seqend = seqbeg + info.seqlen; ::libmaus::aio::CheckedInputStream CIS(tempfilename); CIS.seekg(seqbeg); ::libmaus::util::GetFileSize::copyMap(CIS,COS,cmap.begin(),seqend-seqbeg+1); ::libmaus::aio::CircularReverseWrapper CRW(tempfilename,seqend); ::libmaus::util::GetFileSize::copyMap(CRW,COS,rmap.begin(),seqend-seqbeg+1); curpos += (info.idlen+2) + (info.seqlen+1); } } if ( addterm ) COS.put(0); return EXIT_SUCCESS; } catch(std::exception const & ex) { std::cerr << ex.what() << std::endl; return EXIT_FAILURE; } }
void ImapByeResponse::setSent() { if ( imap()->session() ) imap()->endSession(); imap()->setState( IMAP::Logout ); }
void writeFrames(const Kinect::FrameSource::IntrinsicParameters& ip,const Kinect::FrameBuffer& color,const Kinect::MeshBuffer& mesh,const char* lwoFileName) { /* Create the texture file name: */ std::string textureFileName(lwoFileName,Misc::getExtension(lwoFileName)); textureFileName.append("-color.png"); /* Write the color frame as a texture image: */ { Images::RGBImage texImage(color.getSize(0),color.getSize(1)); Images::RGBImage::Color* tiPtr=texImage.modifyPixels(); const unsigned char* cfPtr=reinterpret_cast<const unsigned char*>(color.getBuffer()); for(int y=0;y<color.getSize(1);++y) for(int x=0;x<color.getSize(0);++x,++tiPtr,cfPtr+=3) *tiPtr=Images::RGBImage::Color(cfPtr); Images::writeImageFile(texImage,textureFileName.c_str()); } /* Open the LWO file: */ IO::FilePtr lwoFile=IO::openFile(lwoFileName,IO::File::WriteOnly); lwoFile->setEndianness(Misc::BigEndian); /* Create the LWO file structure via the FORM chunk: */ { IFFChunkWriter form(lwoFile,"FORM"); form.write<char>("LWO2",4); /* Create the TAGS chunk: */ { IFFChunkWriter tags(&form,"TAGS"); tags.writeString("ColorImage"); tags.writeChunk(); } /* Create the LAYR chunk: */ { IFFChunkWriter layr(&form,"LAYR"); layr.write<Misc::UInt16>(0U); layr.write<Misc::UInt16>(0x0U); for(int i=0;i<3;++i) layr.write<Misc::Float32>(0.0f); layr.writeString("DepthImage"); layr.writeChunk(); } /* Create an index map for all vertices to omit unused vertices: */ unsigned int* indices=new unsigned int[mesh.numVertices]; for(unsigned int i=0;i<mesh.numVertices;++i) indices[i]=~0x0U; unsigned int numUsedVertices=0; /* Create the PNTS, BBOX and VMAP chunks in one go: */ { typedef Kinect::FrameSource::IntrinsicParameters::PTransform PTransform; typedef PTransform::Point Point; typedef Geometry::Box<Point::Scalar,3> Box; IFFChunkWriter bbox(&form,"BBOX"); IFFChunkWriter pnts(&form,"PNTS"); IFFChunkWriter vmap(&form,"VMAP"); /* Write the VMAP header: */ vmap.write<char>("TXUV",4); vmap.write<Misc::UInt16>(2U); vmap.writeString("ColorImageUV"); /* Process all triangle vertices: */ Box pBox=Box::empty; const Kinect::MeshBuffer::Vertex* vertices=mesh.getVertices(); const Kinect::MeshBuffer::Index* tiPtr=mesh.getTriangleIndices(); for(unsigned int i=0;i<mesh.numTriangles*3;++i,++tiPtr) { /* Check if the triangle vertex doesn't already have an index: */ if(indices[*tiPtr]==~0x0U) { /* Assign an index to the triangle vertex: */ indices[*tiPtr]=numUsedVertices; /* Transform the mesh vertex to camera space using the depth projection matrix: */ Point dp(vertices[*tiPtr].position.getXyzw()); Point cp=ip.depthProjection.transform(dp); /* Transform the depth-space point to texture space using the color projection matrix: */ Point tp=ip.colorProjection.transform(dp); /* Add the point to the bounding box: */ pBox.addPoint(cp); /* Store the point and its texture coordinates: */ pnts.writePoint(cp); vmap.writeVarIndex(numUsedVertices); for(int i=0;i<2;++i) vmap.write<Misc::Float32>(tp[i]); ++numUsedVertices; } } /* Write the bounding box: */ bbox.writeBox(pBox); /* Write the BBOX, PNTS, and VMAP chunks: */ bbox.writeChunk(); pnts.writeChunk(); vmap.writeChunk(); } /* Create the POLS chunk: */ { IFFChunkWriter pols(&form,"POLS"); pols.write<char>("FACE",4); const Kinect::MeshBuffer::Index* tiPtr=mesh.getTriangleIndices(); for(unsigned int triangleIndex=0;triangleIndex<mesh.numTriangles;++triangleIndex,tiPtr+=3) { pols.write<Misc::UInt16>(3U); for(int i=0;i<3;++i) pols.writeVarIndex(indices[tiPtr[2-i]]); } pols.writeChunk(); } /* Delete the vertex index map: */ delete[] indices; /* Create the PTAG chunk: */ { IFFChunkWriter ptag(&form,"PTAG"); ptag.write<char>("SURF",4); for(unsigned int triangleIndex=0;triangleIndex<mesh.numTriangles;++triangleIndex) { ptag.writeVarIndex(triangleIndex); ptag.write<Misc::UInt16>(0U); } ptag.writeChunk(); } /* Create the CLIP chunk: */ { IFFChunkWriter clip(&form,"CLIP"); clip.write<Misc::UInt32>(1U); /* Create the STIL chunk: */ { IFFChunkWriter stil(&clip,"STIL",true); stil.writeString(textureFileName.c_str()); stil.writeChunk(); } clip.writeChunk(); } /* Create the SURF chunk: */ { IFFChunkWriter surf(&form,"SURF"); surf.writeString("ColorImage"); surf.writeString(""); /* Create the SIDE subchunk: */ { IFFChunkWriter side(&surf,"SIDE",true); side.write<Misc::UInt16>(3U); side.writeChunk(); } /* Create the SMAN subchunk: */ { IFFChunkWriter sman(&surf,"SMAN",true); sman.write<Misc::Float32>(Math::rad(90.0f)); sman.writeChunk(); } /* Create the COLR subchunk: */ { IFFChunkWriter colr(&surf,"COLR",true); colr.writeColor(1.0f,1.0f,1.0f); colr.writeVarIndex(0U); colr.writeChunk(); } /* Create the DIFF subchunk: */ { IFFChunkWriter diff(&surf,"DIFF",true); diff.write<Misc::Float32>(1.0f); diff.writeVarIndex(0U); diff.writeChunk(); } /* Create the LUMI subchunk: */ { IFFChunkWriter lumi(&surf,"LUMI",true); lumi.write<Misc::Float32>(0.0f); lumi.writeVarIndex(0U); lumi.writeChunk(); } /* Create the BLOK subchunk: */ { IFFChunkWriter blok(&surf,"BLOK",true); /* Create the IMAP subchunk: */ { IFFChunkWriter imap(&blok,"IMAP",true); imap.writeString("1"); /* Create the CHAN subchunk: */ { IFFChunkWriter chan(&imap,"CHAN",true); chan.write<char>("COLR",4); chan.writeChunk(); } imap.writeChunk(); } /* Create the PROJ subchunk: */ { IFFChunkWriter proj(&blok,"PROJ",true); proj.write<Misc::UInt16>(5U); proj.writeChunk(); } /* Create the IMAG subchunk: */ { IFFChunkWriter imag(&blok,"IMAG",true); imag.writeVarIndex(1U); imag.writeChunk(); } /* Create the VMAP subchunk: */ { IFFChunkWriter vmap(&blok,"VMAP",true); vmap.writeString("ColorImageUV"); vmap.writeChunk(); } blok.writeChunk(); } /* Write the SURF chunk: */ surf.writeChunk(); } /* Write the FORM chunk: */ form.writeChunk(); } }
void Select::execute() { if ( state() != Executing ) return; if ( Flag::id( "\\Deleted" ) == 0 ) { // should only happen when we flush the entire database during // testing, so we don't bother being accurate or fast, but // simply try again in a second. (void)new Timer( this, 1 ); return; } if ( !d->permissions ) { if ( d->condstore ) imap()->setClientSupports( IMAP::Condstore ); if ( d->annotate ) imap()->setClientSupports( IMAP::Annotate ); if ( d->mailbox->deleted() ) error( No, d->mailbox->name().ascii() + " is deleted" ); if ( !ok() ) { finish(); return; } d->permissions = new Permissions( d->mailbox, imap()->user(), this ); } if ( d->permissions && !d->session ) { if ( !d->permissions->ready() ) return; if ( !d->permissions->allowed( Permissions::Read ) ) { error( No, d->mailbox->name().ascii() + " is not accessible" ); finish(); return; } if ( !d->readOnly && !d->permissions->allowed( Permissions::KeepSeen ) ) d->readOnly = true; } if ( !::firstUnseenCache ) ::firstUnseenCache = new SelectData::FirstUnseenCache; if ( mailboxGroup() && !d->sessionPreloader ) { d->sessionPreloader = new SessionPreloader( mailboxGroup()->contents(), this ); d->sessionPreloader->execute(); IntegerSet s; List<Mailbox>::Iterator i( mailboxGroup()->contents() ); while ( i ) { if ( !::firstUnseenCache->find( i, i->nextModSeq() ) ) s.add( i->id() ); ++i; } if ( s.count() > 2 ) { d->cacheFirstUnseen = new Query( "select min(uid) as uid, mailbox, " "max(modseq) as modseq " "from mailbox_messages mm " "where mailbox=any($1) and not seen " "group by mailbox", this ); d->cacheFirstUnseen->bind( 1, s ); d->cacheFirstUnseen->execute(); } } if ( d->sessionPreloader ) { while ( d->cacheFirstUnseen && d->cacheFirstUnseen->hasResults() ) { Row * r = d->cacheFirstUnseen->nextRow(); Mailbox * m = Mailbox::find( r->getInt( "mailbox" ) ); ::firstUnseenCache->insert( m, 1 + r->getBigint( "modseq" ), r->getInt( "uid" ) ); } if ( d->cacheFirstUnseen && !d->cacheFirstUnseen->done() ) return; if ( !d->sessionPreloader->done() ) return; } if ( !d->session ) { d->session = new ImapSession( imap(), d->mailbox, d->readOnly ); d->session->setPermissions( d->permissions ); imap()->beginSession( d->session ); } if ( !d->session->initialised() ) return; if ( d->session->isEmpty() ) d->needFirstUnseen = false; else if ( ::firstUnseenCache && ::firstUnseenCache->find( d->mailbox, d->session->nextModSeq() ) ) d->needFirstUnseen = false; else d->needFirstUnseen = true; if ( d->needFirstUnseen && !d->firstUnseen ) { d->firstUnseen = new Query( "select uid from mailbox_messages mm " "where mailbox=$1 and not seen " "order by uid limit 1", this ); d->firstUnseen->bind( 1, d->mailbox->id() ); d->firstUnseen->execute(); } if ( d->firstUnseen && !d->firstUnseen->done() ) return; d->session->emitUpdates( 0 ); // emitUpdates often calls Imap::runCommands, which calls this // function, which will then change its state to Finished. so // check that and don't repeat the last few responses. if ( state() != Executing ) return; respond( "OK [UIDVALIDITY " + fn( d->session->uidvalidity() ) + "]" " uid validity" ); if ( d->firstUnseen ) { if ( !::firstUnseenCache ) ::firstUnseenCache = new SelectData::FirstUnseenCache; Row * r = d->firstUnseen->nextRow(); if ( r ) ::firstUnseenCache->insert( d->mailbox, d->session->nextModSeq(), r->getInt( "uid" ) ); } if ( ::firstUnseenCache ) { uint unseen = ::firstUnseenCache->find( d->mailbox, d->session->nextModSeq() ); if ( unseen ) respond( "OK [UNSEEN " + fn( d->session->msn( unseen ) ) + "] first unseen" ); } if ( imap()->clientSupports( IMAP::Condstore ) && !d->session->isEmpty() ) { uint nms = d->session->nextModSeq(); if ( nms < 2 ) nms = 2; respond( "OK [HIGHESTMODSEQ " + fn( nms-1 ) + "] highest modseq" ); } if ( imap()->clientSupports( IMAP::Annotate ) ) { Permissions * p = d->session->permissions(); if ( p && p->allowed( Permissions::WriteSharedAnnotation ) ) respond( "OK [ANNOTATIONS 262144] Arbitrary limit" ); else respond( "OK [ANNOTATIONS READ-ONLY] Missing 'n' right" ); } if ( d->session->readOnly() ) setRespTextCode( "READ-ONLY" ); else setRespTextCode( "READ-WRITE" ); finish(); }
void ImapSession::emitUpdates( Transaction * t ) { if ( d->emitting ) return; d->emitting = true; bool work = false; Scope x( d->l ); IntegerSet e; e.add( expunged() ); e.remove( d->expungesReported ); if ( !e.isEmpty() ) { d->expungesReported.add( e ); if ( imap()->clientSupports( IMAP::QResync ) ) { (void)new ImapVanishedResponse( e, this ); work = true; } else { while ( !e.isEmpty() ) { (void)new ImapExpungeResponse( e.smallest(), this ); work = true; e.remove( e.smallest() ); } } } emitFlagUpdates( t ); if ( d->uidnext < uidnext() ) { if ( !d->existsResponse ) { d->existsResponse = new ImapSessionData::ExistsResponse( this, d ); work = true; } if ( !d->recentResponse ) { d->recentResponse = new ImapSessionData::RecentResponse( this, d ); work = true; } if ( !d->uidnextResponse ) { d->uidnextResponse = new ImapSessionData::UidnextResponse( this, d ); work = true; } } if ( imap()->clientSupports( IMAP::Condstore ) && d->nms < nextModSeq() && !d->highestModseqResponse ) { d->highestModseqResponse = new ImapSessionData::HighestModseqResponse( this, d ); work = true; } if ( d->changed.isEmpty() ) d->cms = d->nms; if ( work ) d->i->unblockCommands(); d->i->emitResponses(); d->emitting = false; }
void TestIt(long p, long r, long c, long _k, long w, long L, Vec<long>& mvec, Vec<long>& gens, Vec<long>& ords, long useCache) { if (lsize(mvec)<1) { // use default values mvec.SetLength(3); gens.SetLength(3); ords.SetLength(3); mvec[0] = 7; mvec[1] = 3; mvec[2] = 221; gens[0] = 3979; gens[1] = 3095; gens[2] = 3760; ords[0] = 6; ords[1] = 2; ords[2] = -8; } if (!noPrint) cout << "*** TestIt" << (dry? " (dry run):" : ":") << " p=" << p << ", r=" << r << ", c=" << c << ", k=" << _k << ", w=" << w << ", L=" << L << ", mvec=" << mvec << ", " << ", useCache = " << useCache << endl; setTimersOn(); setDryRun(false); // Need to get a "real context" to test ThinEvalMap // mvec is supposed to include the prime-power factorization of m long nfactors = mvec.length(); for (long i = 0; i < nfactors; i++) for (long j = i+1; j < nfactors; j++) assert(GCD(mvec[i], mvec[j]) == 1); // multiply all the prime powers to get m itself long m = computeProd(mvec); assert(GCD(p, m) == 1); // build a context with these generators and orders vector<long> gens1, ords1; convert(gens1, gens); convert(ords1, ords); FHEcontext context(m, p, r, gens1, ords1); buildModChain(context, L, c); if (!noPrint) { context.zMStar.printout(); // print structure of Zm* /(p) to cout cout << endl; } long d = context.zMStar.getOrdP(); long phim = context.zMStar.getPhiM(); long nslots = phim/d; setDryRun(dry); // Now we can set the dry-run flag if desired FHESecKey secretKey(context); const FHEPubKey& publicKey = secretKey; secretKey.GenSecKey(w); // A Hamming-weight-w secret key addSome1DMatrices(secretKey); // compute key-switching matrices that we need addFrbMatrices(secretKey); // compute key-switching matrices that we need // GG defines the plaintext space Z_p[X]/GG(X) ZZX GG; GG = context.alMod.getFactorsOverZZ()[0]; EncryptedArray ea(context, GG); zz_p::init(context.alMod.getPPowR()); Vec<zz_p> val0(INIT_SIZE, nslots); for (auto& x: val0) random(x); vector<ZZX> val1; val1.resize(nslots); for (long i = 0; i < nslots; i++) { val1[i] = conv<ZZX>(conv<ZZ>(rep(val0[i]))); } Ctxt ctxt(publicKey); ea.encrypt(ctxt, publicKey, val1); resetAllTimers(); FHE_NTIMER_START(ALL); // Compute homomorphically the transformation that takes the // coefficients packed in the slots and produces the polynomial // corresponding to cube if (!noPrint) CheckCtxt(ctxt, "init"); if (!noPrint) cout << "build ThinEvalMap\n"; ThinEvalMap map(ea, /*minimal=*/false, mvec, /*invert=*/false, /*build_cache=*/false); // compute the transformation to apply if (!noPrint) cout << "apply ThinEvalMap\n"; if (useCache) map.upgrade(); map.apply(ctxt); // apply the transformation to ctxt if (!noPrint) CheckCtxt(ctxt, "ThinEvalMap"); if (!noPrint) cout << "check results\n"; if (!noPrint) cout << "build ThinEvalMap\n"; ThinEvalMap imap(ea, /*minimal=*/false, mvec, /*invert=*/true, /*build_cache=*/false); // compute the transformation to apply if (!noPrint) cout << "apply ThinEvalMap\n"; if (useCache) imap.upgrade(); imap.apply(ctxt); // apply the transformation to ctxt if (!noPrint) { CheckCtxt(ctxt, "ThinEvalMap"); cout << "check results\n"; } #if 1 /* create dirty version of ctxt */ Vec<zz_pX> dirty_val0; dirty_val0.SetLength(nslots); for (long i = 0; i < nslots; i++) { random(dirty_val0[i], d); SetCoeff(dirty_val0[i], 0, val0[i]); } vector<ZZX> dirty_val1; dirty_val1.resize(nslots); for (long i = 0; i < nslots; i++) { dirty_val1[i] = conv<ZZX>(dirty_val0[i]); } Ctxt dirty_ctxt(publicKey); ea.encrypt(dirty_ctxt, publicKey, dirty_val1); EvalMap dirty_map(ea, /*minimal=*/false, mvec, /*invert=*/false, /*build_cache=*/false); dirty_map.apply(dirty_ctxt); imap.apply(dirty_ctxt); #endif vector<ZZX> val2; ea.decrypt(ctxt, secretKey, val2); if (val1 == val2) cout << "ThinEvalMap: GOOD\n"; else cout << "ThinEvalMap: BAD\n"; #if 1 vector<ZZX> dirty_val2; ea.decrypt(dirty_ctxt, secretKey, dirty_val2); if (val1 == dirty_val2) cout << "ThinEvalMap: GOOD\n"; else cout << "ThinEvalMap: BAD\n"; #endif FHE_NTIMER_STOP(ALL); if (!noPrint) { cout << "\n*********\n"; printAllTimers(); cout << endl; } }
void Status::execute() { if ( state() != Executing ) return; // first part. set up. if ( !permitted() ) return; Session * session = imap()->session(); Mailbox * current = 0; if ( session ) current = session->mailbox(); // second part. see if anything has happened, and feed the cache if // so. make sure we feed the cache at once. if ( d->unseenCount || d->recentCount || d->messageCount ) { if ( d->unseenCount && !d->unseenCount->done() ) return; if ( d->messageCount && !d->messageCount->done() ) return; if ( d->recentCount && !d->recentCount->done() ) return; } if ( !::cache ) ::cache = new StatusData::StatusCache; if ( d->unseenCount ) { while ( d->unseenCount->hasResults() ) { Row * r = d->unseenCount->nextRow(); StatusData::CacheItem * ci = ::cache->find( r->getInt( "mailbox" ) ); if ( ci ) { ci->hasUnseen = true; ci->unseen = r->getInt( "unseen" ); } } } if ( d->recentCount ) { while ( d->recentCount->hasResults() ) { Row * r = d->recentCount->nextRow(); StatusData::CacheItem * ci = ::cache->find( r->getInt( "mailbox" ) ); if ( ci ) { ci->hasRecent = true; ci->recent = r->getInt( "recent" ); } } } if ( d->messageCount ) { while ( d->messageCount->hasResults() ) { Row * r = d->messageCount->nextRow(); StatusData::CacheItem * ci = ::cache->find( r->getInt( "mailbox" ) ); if ( ci ) { ci->hasMessages = true; ci->messages = r->getInt( "messages" ); } } } // third part. are we processing the first command in a STATUS // loop? if so, see if we ought to preload the cache. if ( mailboxGroup() && d->cacheState < 3 ) { IntegerSet mailboxes; if ( d->cacheState < 1 ) { // cache state 0: decide which messages List<Mailbox>::Iterator i( mailboxGroup()->contents() ); while ( i ) { StatusData::CacheItem * ci = ::cache->provide( i ); bool need = false; if ( d->unseen || d->recent || d->messages ) need = true; if ( ci->hasUnseen || ci->hasRecent || ci->hasMessages ) need = false; if ( need ) mailboxes.add( i->id() ); ++i; } if ( mailboxes.count() < 3 ) d->cacheState = 3; } if ( d->cacheState == 1 ) { // state 1: send queries if ( d->unseen ) { d->unseenCount = new Query( "select mailbox, count(uid)::int as unseen " "from mailbox_messages " "where mailbox=any($1) and not seen " "group by mailbox", this ); d->unseenCount->bind( 1, mailboxes ); d->unseenCount->execute(); } if ( d->recent ) { d->recentCount = new Query( "select id as mailbox, " "uidnext-first_recent as recent " "from mailboxes where id=any($1)", this ); d->recentCount->bind( 1, mailboxes ); d->recentCount->execute(); } if ( d->messages ) { d->messageCount = new Query( "select count(*)::int as messages, mailbox " "from mailbox_messages where mailbox=any($1) " "group by mailbox", this ); d->messageCount->bind( 1, mailboxes ); d->messageCount->execute(); } d->cacheState = 2; } if ( d->cacheState == 2 ) { // state 2: mark the cache as complete. IntegerSet mailboxes; List<Mailbox>::Iterator i( mailboxGroup()->contents() ); while ( i ) { StatusData::CacheItem * ci = ::cache->find( i->id() ); if ( ci && d->unseenCount ) ci->hasUnseen = true; if ( ci && d->recentCount ) ci->hasRecent = true; if ( ci && d->messageCount ) ci->hasMessages = true; ++i; } // and drop the queries d->cacheState = 3; d->unseenCount = 0; d->recentCount = 0; d->messageCount = 0; } } // the cache item we'll actually read from StatusData::CacheItem * i = ::cache->provide( d->mailbox ); // fourth part: send individual queries if there's anything we need if ( d->unseen && !d->unseenCount && !i->hasUnseen ) { d->unseenCount = new Query( "select $1::int as mailbox, " "count(uid)::int as unseen " "from mailbox_messages " "where mailbox=$1 and not seen", this ); d->unseenCount->bind( 1, d->mailbox->id() ); d->unseenCount->execute(); } if ( !d->recent ) { // nothing doing } else if ( d->mailbox == current ) { // we'll pick it up from the session } else if ( i->hasRecent ) { // the cache has it } else if ( !d->recentCount ) { d->recentCount = new Query( "select id as mailbox, " "uidnext-first_recent as recent " "from mailboxes where id=$1", this ); d->recentCount->bind( 1, d->mailbox->id() ); d->recentCount->execute(); } if ( !d->messages ) { // we don't need to collect } else if ( d->mailbox == current ) { // we'll pick it up } else if ( i->hasMessages ) { // the cache has it } else if ( d->messages && !d->messageCount ) { d->messageCount = new Query( "select count(*)::int as messages, " "$1::int as mailbox " "from mailbox_messages where mailbox=$1", this ); d->messageCount->bind( 1, d->mailbox->id() ); d->messageCount->execute(); } if ( d->unseenCount || d->recentCount || d->messageCount ) { if ( d->unseenCount && !d->unseenCount->done() ) return; if ( d->messageCount && !d->messageCount->done() ) return; if ( d->recentCount && !d->recentCount->done() ) return; } // fifth part: return the payload. EStringList status; if ( d->messages && i->hasMessages ) status.append( "MESSAGES " + fn( i->messages ) ); else if ( d->messages && d->mailbox == current ) status.append( "MESSAGES " + fn( session->messages().count() ) ); if ( d->recent && i->hasRecent ) status.append( "RECENT " + fn( i->recent ) ); else if ( d->recent && d->mailbox == current ) status.append( "RECENT " + fn( session->recent().count() ) ); if ( d->uidnext ) status.append( "UIDNEXT " + fn( d->mailbox->uidnext() ) ); if ( d->uidvalidity ) status.append( "UIDVALIDITY " + fn( d->mailbox->uidvalidity() ) ); if ( d->unseen && i->hasUnseen ) status.append( "UNSEEN " + fn( i->unseen ) ); if ( d->modseq ) { int64 hms = d->mailbox->nextModSeq(); // don't like this. an empty mailbox will have a STATUS HMS of // 1 before it receives its first message, and also 1 after. if ( hms > 1 ) hms--; status.append( "HIGHESTMODSEQ " + fn( hms ) ); } respond( "STATUS " + imapQuoted( d->mailbox ) + " (" + status.join( " " ) + ")" ); finish(); }
void Thread::execute() { if ( state() != Executing ) return; if ( !d->session ) d->session = session(); if ( !d->find ) { EStringList * want = new EStringList; want->append( "uid" ); want->append( "message" ); want->append( "m.idate" ); want->append( "m.thread_root" ); want->append( "tmid.value as messageid" ); want->append( "tref.value as references" ); EString ts; if ( d->threadAlg == ThreadData::References ) { want->append( "tsubj.value as subject" ); ts = "left join header_fields tsubj on" " (m.id=tsubj.message and" " tsubj.field=" + fn( HeaderField::Subject ) + " and tsubj.part='') "; } d->find = d->s->query( imap()->user(), d->session->mailbox(), d->session, this, false, want ); EString j = d->find->string(); // we need to get the References and Message-Id fields as well const char * x = "left join"; if ( !j.contains( x ) ) x = "where"; j.replace( x, "left join header_fields tref on" " (m.id=tref.message and" " tref.field=" + fn( HeaderField::References ) + " and tref.part='') " "left join header_fields tmid on" " (m.id=tmid.message and" " tmid.field=" + fn( HeaderField::MessageId ) + " and tmid.part='') " + ts + x ); d->find->setString( j ); d->find->execute(); return; } while ( d->find->hasResults() ) { Row * r = d->find->nextRow(); ThreadData::Node * n = new ThreadData::Node; n->uid = r->getInt( "uid" ); n->idate = r->getInt( "idate" ); if ( !r->isNull( "thread_root" ) ) n->threadRoot = r->getInt( "thread_root" ); if ( !r->isNull( "references" ) ) n->references = r->getEString( "references" ); if ( !r->isNull( "messageid" ) ) n->messageId = r->getEString( "messageid" ); if ( !r->isNull( "subject" ) ) n->subject = Message::baseSubject( r->getUString( "subject" ) ); d->result.append( n ); if ( !n->messageId.isEmpty() ) d->nodes.insert( n->messageId, n ); } if ( !d->find->done() ) return; List<ThreadData::Node>::Iterator ri( d->result ); if ( d->threadAlg == ThreadData::OrderedSubject ) { UDict<ThreadData::Node> roots; while ( ri ) { ThreadData::Node * n = ri; ++ri; ThreadData::Node * root = roots.find( n->subject ); if ( root ) n->parent = root; else roots.insert( n->subject, n ); } } else { while ( ri ) { ThreadData::Node * n = ri; ++ri; EStringList l; int lt = 0; while ( lt >= 0 ) { lt = n->references.find( '<', lt ); if ( lt >= 0 ) { int gt = n->references.find( '>', lt ); if ( gt > 0 ) l.append( n->references.mid( lt, gt + 1 - lt ) ); lt = gt; } } l.append( n->messageId ); EStringList::Iterator s( l ); ThreadData::Node * parent = 0; while ( s ) { if ( !s->isEmpty() ) { ThreadData::Node * n = d->nodes.find( *s ); if ( !n ) { n = new ThreadData::Node; n->messageId = *s; n->threadRoot = n->threadRoot; d->nodes.insert( *s, n ); } if ( parent && !n->parent && parent->root() != n ) n->parent = parent; parent = n; } ++s; }; } // merge big threads where the start has been deleted, or // isn't part of the search expression. Dict<ThreadData::Node>::Iterator i( d->nodes ); Map<ThreadData::Node> roots; while ( i ) { ThreadData::Node * n = i; ++i; if ( !n->parent ) { ThreadData::Node * found = roots.find( n->threadRoot ); if ( !found ) roots.insert( n->threadRoot, n ); else if ( found && n != found ) n->parent = found; } } // if thread=references is used, we need to jump through extra hoops if ( d->threadAlg == ThreadData::References ) { Dict<ThreadData::Node>::Iterator i( d->nodes ); UDict<ThreadData::Node> subjects; while ( i ) { if ( !i->parent ) { ThreadData::Node * potential = subjects.find( i->subject ); if ( potential ) i->parent = potential; else subjects.insert( i->subject, i ); } ++i; } } } // set up child lists and the root list Dict<ThreadData::Node>::Iterator i( d->nodes ); while ( i ) { ThreadData::Node * n = i; ++i; while ( n ) { if ( !n->added ) { n->added = true; if ( n->parent ) n->parent->children.append( n ); else d->roots.append( n ); } n = n->parent; } } // we need to sort root nodes (and children) by idate, so we // extend the definition until sorting works: a non-message's // idate is the oldest idate of a direct descendant. i = Dict<ThreadData::Node>::Iterator( d->nodes ); while ( i ) { ThreadData::Node * n = i; ++i; uint idate = n->idate; while ( n ) { if ( n->uid ) idate = n->idate; else if ( !n->idate || n->idate > idate ) n->idate = idate; n = n->parent; } } waitFor( new ThreadResponse( d ) ); finish(); }
void OCC_Connect::MergeEdges(TopoDS_Shape &shape1, TopoDS_Shape &shape2) const { TopTools_IndexedMapOfShape imap, omap; TopExp::MapShapes(shape1,TopAbs_EDGE,imap); TopExp::MapShapes(shape2,TopAbs_EDGE,imap); BRepTools_ReShape replacer; for(int i=0;i<imap.Extent();i++) { for(int j=0;j<omap.Extent();j++) { TopoDS_Edge orig=TopoDS::Edge(imap(i+1)); TopoDS_Edge repl=TopoDS::Edge(omap(j+1)); TopoDS_Vertex o1, o2, r1, r2; TopExp::Vertices(orig,o1,o2,true); TopExp::Vertices(repl,r1,r2,true); if(o1.IsSame(o2)) { if(!BRep_Tool::Degenerated(orig)) { if(verbose&Cutting) { cout << "Same vertex in edge\n"; BRepTools::Dump(orig,cout); } replacer.Remove(orig); goto skip; } else if(o1.IsSame(r1) && o1.IsSame(r2) && CanMergeCurve(orig,repl) ) { if(verbose&Cutting) { cout << "Degenerated edge, replace " << i+1 << " with " << j+1 << '\n'; BRepTools::Dump(orig,cout); BRepTools::Dump(repl,cout); } // FIXME, update tolerance BRepTools::Dump(repl.Complemented(),cout); replacer.Replace(orig,repl.Complemented()); goto skip; } cout << i+1 << " Degenerated\n"; } if(o1.IsSame(r1) && o2.IsSame(r2) && CanMergeCurve(orig,repl)) { if(verbose&Cutting) { cout << "Same order of vertices, replace " << i+1 << " with " << j+1 << '\n'; BRepTools::Dump(orig,cout); BRepTools::Dump(repl,cout); } // FIXME, update tolerance replacer.Replace(orig,repl); goto skip; } if(o1.IsSame(r2) && o2.IsSame(r1) && CanMergeCurve(orig,repl)) { if(verbose&Cutting) { cout << "Reversed order of vertices, replace " << i+1 << " with " << j+1 << '\n'; BRepTools::Dump(orig,cout); BRepTools::Dump(repl,cout); } // FIXME, update tolerance replacer.Replace(orig,repl.Complemented()); goto skip; } } if(verbose&Cutting) cout << "Adding " << i+1 << " as " << omap.Extent()+1<<" to keep map\n"; omap.Add(imap(i+1)); skip:; } TopoDS_Shape t=shape1; shape1=replacer.Apply(t); t=shape2; shape2=replacer.Apply(t); }