// The core function that returns the answer of the problem (find the time to the ground) int GetTime() { // sort std::sort(segment_, segment_+size_, HeightCompare); // discretization: Discretize(); Construct(1, 0, pos_num_); // dp, segment_[0] as ground for (int i=1; i<size_; ++i) { int l = GetSeg(1, segment_[i].l); int r = GetSeg(1, segment_[i].r); if (d_<segment_[i].y-segment_[l].y && d_<segment_[i].y-segment_[r].y) continue; if ((!(d_<segment_[i].y-segment_[l].y)) && (!(d_<segment_[i].y-segment_[r].y))) { segment_[i].t1 = GetTimeToSeg(segment_[i].x1, segment_[i].y, l); segment_[i].t2 = GetTimeToSeg(segment_[i].x2, segment_[i].y, r); segment_[i].t1 = std::min(segment_[i].t1, segment_[i].t2+segment_[i].x2-segment_[i].x1); segment_[i].t2 = std::min(segment_[i].t2, segment_[i].t1+segment_[i].x2-segment_[i].x1); } else if (!(d_<segment_[i].y-segment_[l].y)) { segment_[i].t1 = GetTimeToSeg(segment_[i].x1, segment_[i].y, l); segment_[i].t2 = segment_[i].t1+segment_[i].x2-segment_[i].x1; } else if (!(d_<segment_[i].y-segment_[r].y)) { segment_[i].t2 = GetTimeToSeg(segment_[i].x2, segment_[i].y, r); segment_[i].t1 = segment_[i].t2+segment_[i].x2-segment_[i].x1; } Update(1, segment_[i].l, segment_[i].r, i); } return GetTimeToSeg(x_, y_, GetSeg(1, pos_)); }
Useless::BitVector& Useless::BitVector::SetSegment ( const Useless::BitVector& src, int where, int num ) { if (!num) num = src.Size(); int start_seg = where / 32; int end_seg = (where+num) / 32; int pos = where; int a = ( ( (where+num)%32 ) >0 )? 1 : 0 ; int grow = end_seg + a - _bits.size(); if ( grow > 0 ) _bits.resize( end_seg + a); int offs = 0; int n = end_seg - start_seg; for (int i=0; i!=n ; ++i ) { int bits = src.GetSeg(offs); SetSeg( pos+offs, bits ); offs+=32; } if ( pos != where + num ) { int bits1, bits2, mask, shift; shift = ( where + num ) - pos; bits1 = src.GetSeg(offs); bits2 = GetSeg(pos); mask = (shift)? (1<<shift) -1 : ~0; bits1 &= mask; bits2 &= ~mask; SetSeg(pos, bits1 | bits2, true); } return (*this); }
void FeatureExtractorThread::Extract() { #ifdef SHOW_PROFILING double startStep, endStep; startStep = GetSeg(); #endif featureDetector_.detect(image_, keyPoints_); #ifdef SHOW_PROFILING endStep = GetSeg(); WriteToLog(" tk FeatureDetection: ", startStep, endStep); startStep = GetSeg(); #endif descriptorExtractor_.compute(image_, keyPoints_, descriptors_); #ifdef SHOW_PROFILING endStep = GetSeg(); WriteToLog(" tk DescriptorExtraction: ", startStep, endStep); #endif }
Useless::BitVector Useless::BitVector::GetSegment ( unsigned int from, unsigned int to) const { int seg = from / 32; unsigned int N = (!to)? Size() : to - from; if (seg >= _bits.size() ) return BitVector(); BitVector out; int i = 0; int val; while( i + 31 < N ) { out.SetSeg( i, GetSeg( from + i ) ); i+=32; } if ( i < N ) { int u = N - i; val = GetSeg( from + i ); if ( u > 0 ) val &= ( (1 << u) - 1 ); out.SetSeg( i, val ); } return out; }
Position Line::YIntersection(double y) { if(!size()) return Position(); for(unsigned i = 0; i < size(); i += degree) if(at(i).y == y) return Position(at(i)); int seg = GetSeg(y); if(seg < 0) return Position(); double high,low; if(at(seg).y < at(seg+degree).y) { high = 1.0; low = 0.0; } else { high = 0.0; low = 1.0; } double close = DBL_MAX; Coord ret; do { double t = (high + low) / 2.0; Coord p = Bezier(&at(seg),degree,t); double d = absol(p.y - y); if(d < close) { ret = p; close = d; } if(p.y > y) high = t; else low = t; } while(absol(high - low) > .01); /* should be adaptive */ return Position(ret); }
void sptam::sptam_node::onImages( const sensor_msgs::ImageConstPtr& l_image_msg, const sensor_msgs::CameraInfoConstPtr& left_info, const sensor_msgs::ImageConstPtr& r_image_msg, const sensor_msgs::CameraInfoConstPtr& right_info ) { ROS_INFO_STREAM("dt: " << (l_image_msg->header.stamp - r_image_msg->header.stamp).toSec()); // Save current Time ros::Time currentTime = l_image_msg->header.stamp; // If using odometry, try to get a new estimate for the current pose. // if not using odometry, camera_to_odom is left blank. tf::StampedTransform camera_to_odom; if ( use_odometry_ ) { if ( not getCameraInOdom(camera_to_odom, currentTime) ) return; TFPose2CameraPose(odom_to_map_ * camera_to_odom, cameraPose_); } else { cv::Point3d currentCameraPosition; cv::Vec4d currentCameraOrientation; motionModel_->PredictNextCameraPose(currentCameraPosition, currentCameraOrientation); cameraPose_ = CameraPose( currentCameraPosition, currentCameraOrientation ); } // If SPTAM has not been initialized yet, do it if ( sptam_ == nullptr ) { ROS_INFO_STREAM("init calib"); loadCameraCalibration(left_info, right_info); } // convert image to OpenCv cv::Mat format cv_bridge::CvImageConstPtr bridgeLeft_ptr = cv_bridge::toCvShare(l_image_msg, "rgb8"); cv_bridge::CvImageConstPtr bridgeRight_ptr = cv_bridge::toCvShare(r_image_msg, "rgb8"); // save images cv::Mat imageLeft = bridgeLeft_ptr->image; cv::Mat imageRight = bridgeRight_ptr->image; #ifdef SHOW_PROFILING double start, end; start = GetSeg(); #endif // SHOW_PROFILING #ifdef SHOW_PROFILING double startStep, endStep; startStep = GetSeg(); #endif FeatureExtractorThread featureExtractorThreadLeft(imageLeft, *featureDetector_, *descriptorExtractor_); FeatureExtractorThread featureExtractorThreadRight(imageRight, *featureDetector_, *descriptorExtractor_); featureExtractorThreadLeft.WaitUntilFinished(); const std::vector<cv::KeyPoint>& keyPointsLeft = featureExtractorThreadLeft.GetKeyPoints(); const cv::Mat& descriptorsLeft = featureExtractorThreadLeft.GetDescriptors(); featureExtractorThreadRight.WaitUntilFinished(); const std::vector<cv::KeyPoint>& keyPointsRight = featureExtractorThreadRight.GetKeyPoints(); const cv::Mat& descriptorsRight = featureExtractorThreadRight.GetDescriptors(); ImageFeatures imageFeaturesLeft = ImageFeatures(imageLeft, keyPointsLeft, descriptorsLeft, mapper_params_.matchingCellSize); ImageFeatures imageFeaturesRight = ImageFeatures(imageRight, keyPointsRight, descriptorsRight, mapper_params_.matchingCellSize); #ifdef SHOW_PROFILING endStep = GetSeg(); WriteToLog(" tk Extract: ", startStep, endStep); #endif // if the map was not initialized, try to build it if( not map_.nMapPoints() ) { ROS_INFO("Trying to intialize map..."); // Create keyFrame StereoFrame* frame = new StereoFrame( cameraPose_, cameraParametersLeft_, stereo_baseline_, cameraParametersRight_, imageFeaturesLeft, imageFeaturesRight, true ); frame->SetId( 0 ); // Set Keyframe ID // Initialize MapMaker // TODO: this bool must be a local variable to do not check not map_.nMapPoints() in the "if" /*bool isMapInitialized = */InitFromStereo( map_, *frame, imageLeft, *rowMatcher_); } // if the map is already initialized, do tracking else { cameraPose_ = sptam_->track(cameraPose_, imageFeaturesLeft, imageFeaturesRight, imageLeft, imageRight); #ifdef SHOW_PROFILING end = GetSeg(); std::cout << GetSeg() << " tk trackingtotal: " << (end - start) << std::endl; std::stringstream message; message << std::fixed << GetSeg() << " tk trackingtotal: " << (end - start) << std::endl; Logger::Write( message.str() ); #endif // fix the error between map and odom to correct the current pose. if ( use_odometry_ ) fixOdomFrame( cameraPose_, camera_to_odom, currentTime ); else // if odometry is disabled, odom_to_map_ actually contains the map->cam transform because I'm too lazy { motionModel_->UpdateCameraPose(cameraPose_.GetPosition(), cameraPose_.GetOrientationQuaternion()); tf::Transform cam_to_map; CameraPose2TFPose(cameraPose_, cam_to_map); tf::StampedTransform base_to_cam; transform_listener_.lookupTransform(camera_frame_, base_frame_, currentTime, base_to_cam); std::lock_guard<std::mutex> lock( odom_to_map_mutex_ ); odom_to_map_ = cam_to_map * base_to_cam; } } // Publish Map To be drawn by rviz visualizer publishMap(); // Publish the camera Pose publishPose( l_image_msg->header.seq, currentTime, cameraPose_ ); }
bool jmp( expr_list *opndx, int *flags ) /* determine the displacement of jmp; */ { int_32 addr; enum fixup_types fixup_type; enum fixup_options fixup_option; enum sym_state state; struct asm_sym *sym; #if defined( _STANDALONE_ ) dir_node *seg; #endif *flags = 0; Code->data[Opnd_Count] = opndx->value; sym = opndx->sym; if( sym == NULL ) { if( Code->info.token == T_CALL ) { Code->info.token = T_CALLF; } else if( Code->info.token == T_JMP ) { Code->info.token = T_JMPF; } if( Code->data[Opnd_Count] > USHRT_MAX ) Code->info.opnd_type[Opnd_Count] = OP_I32; else Code->info.opnd_type[Opnd_Count] = OP_I16; return( RC_OK ); } #if defined( _STANDALONE_ ) if( sym->mem_type == MT_ERROR ) { AsmError( LABEL_NOT_DEFINED ); return( RC_ERROR ); } #endif state = sym->state; #if defined( _STANDALONE_ ) seg = GetSeg( sym ); if( seg == NULL || CurrSeg == NULL || CurrSeg->seg != seg ) { /* jumps to another segment are just like to another file */ state = SYM_EXTERNAL; } #endif if( !Code->mem_type_fixed ) { Code->mem_type = MT_EMPTY; } fixup_option = OPTJ_NONE; fixup_type = FIX_RELOFF8; switch( state ) { case SYM_INTERNAL: #if defined( _STANDALONE_ ) case SYM_PROC: #endif if( ( Code->mem_type == MT_EMPTY || Code->mem_type == MT_SHORT || Code->mem_type == MT_NEAR ) && sym->mem_type != MT_WORD && sym->mem_type != MT_DWORD && sym->mem_type != MT_FWORD && !IS_JMPCALLF( Code->info.token ) ) { #if defined( _STANDALONE_ ) if( ( Code->info.token == T_CALL ) && ( Code->mem_type == MT_EMPTY ) && ( sym->mem_type == MT_FAR ) ) { FarCallToNear(); *flags = SCRAP_INSTRUCTION; return( RC_OK ); } addr = sym->offset; #else addr = sym->addr; #endif addr -= ( AsmCodeAddress + 2 ); // calculate the displacement addr += Code->data[Opnd_Count]; switch( Code->info.token ) { case T_JCXZ: case T_LOOPW: case T_LOOPEW: case T_LOOPZW: case T_LOOPNEW: case T_LOOPNZW: if( Code->use32 ) { // 1 extra byte for OPNSIZ addr--; } break; case T_JECXZ: case T_LOOPD: case T_LOOPED: case T_LOOPZD: case T_LOOPNED: case T_LOOPNZD: if( !Code->use32 ) { // 1 extra byte for OPNSIZ addr--; } break; } if( Code->info.token == T_CALL && Code->mem_type == MT_EMPTY ) { Code->mem_type = MT_NEAR; } if( Code->mem_type != MT_NEAR && Code->info.token != T_CALL && ( addr >= SCHAR_MIN && addr <= SCHAR_MAX ) ) { Code->info.opnd_type[Opnd_Count] = OP_I8; } else { /* near jmp */ if( Code->use32 ) { Code->info.opnd_type[Opnd_Count] = OP_I32; addr -= 3; // 32 bit displacement } else { Code->info.opnd_type[Opnd_Count] = OP_I16; addr -= 1; // 16 bit displacement } if( IS_JMP( Code->info.token ) ) { switch( Code->info.token ) { case T_JMP: case T_JMPF: case T_JCXZ: case T_JECXZ: break; default: // 1 extra byte for opcode ( 0F ) addr--; break; } } } /* store the displacement */ Code->data[Opnd_Count] = addr; switch( Code->info.token ) { case T_JCXZ: case T_JECXZ: case T_LOOP: case T_LOOPE: case T_LOOPNE: case T_LOOPNZ: case T_LOOPZ: case T_LOOPD: case T_LOOPED: case T_LOOPNED: case T_LOOPNZD: case T_LOOPZD: case T_LOOPW: case T_LOOPEW: case T_LOOPNEW: case T_LOOPNZW: case T_LOOPZW: #if defined( _STANDALONE_ ) if( !PhaseError && (Code->info.opnd_type[Opnd_Count] != OP_I8) ) { #else if( (Code->info.opnd_type[Opnd_Count] != OP_I8) ) { #endif AsmError( JUMP_OUT_OF_RANGE ); return( RC_ERROR ); } Code->info.opnd_type[Opnd_Count] = OP_I8; break; } if( (Code->info.cpu&P_CPU_MASK) < P_386 && IS_JMP( Code->info.token ) ) { /* look into jump extension */ switch( Code->info.token ) { case T_JMP: case T_JMPF: break; default: if( Code->info.opnd_type[Opnd_Count] != OP_I8 ) { #if defined( _STANDALONE_ ) if( Code->mem_type == MT_EMPTY ) { jumpExtend( 0 ); *flags = SCRAP_INSTRUCTION; return( RC_OK ); } else if( !PhaseError ) { AsmError( JUMP_OUT_OF_RANGE ); return( RC_ERROR ); } #else AsmError( JUMP_OUT_OF_RANGE ); return( RC_ERROR ); #endif } } } break; } /* otherwise fall through & get handled like external symbols */ case SYM_UNDEFINED: case SYM_EXTERNAL: /* forward ref, or external symbol */ if( Code->mem_type == MT_EMPTY && sym->mem_type != MT_EMPTY ) { switch( sym->mem_type ) { case MT_FAR: if( Code->info.token == T_CALL ) { Code->info.token = T_CALLF; } else if( Code->info.token == T_JMP ) { Code->info.token = T_JMPF; } // fall through case MT_SHORT: case MT_NEAR: Code->mem_type = sym->mem_type; break; #if defined( _STANDALONE_ ) case MT_PROC: if( IS_PROC_FAR() ) { Code->mem_type = MT_FAR; if( Code->info.token == T_CALL ) { Code->info.token = T_CALLF; } else if( Code->info.token == T_JMP ) { Code->info.token = T_JMPF; } } else { Code->mem_type = MT_NEAR; } break; #endif case MT_FWORD: if( ptr_operator( MT_FWORD, true ) ) return( RC_ERROR ); break; default: Code->mem_type = sym->mem_type; } } if( Code->mem_type == MT_FAR ) { if( Code->info.token == T_CALL ) { Code->info.token = T_CALLF; } else if( Code->info.token == T_JMP ) { Code->info.token = T_JMPF; } } switch( Code->info.token ) { case T_CALLF: case T_JMPF: switch( Code->mem_type ) { case MT_SHORT: case MT_NEAR: if( Opnd_Count == OPND1 && Code->mem_type_fixed ) { AsmError( CANNOT_USE_SHORT_OR_NEAR ); return( RC_ERROR ); } /* fall through */ case MT_FAR: case MT_EMPTY: #if defined( _STANDALONE_ ) SET_OPSIZ( Code, SymIs32( sym )); find_frame( sym ); #endif if( Opnd_Count == OPND2 ) { if( IS_OPSIZ_32( Code ) ) { fixup_type = FIX_OFF32; Code->info.opnd_type[Opnd_Count] = OP_I32; } else { fixup_type = FIX_OFF16; Code->info.opnd_type[Opnd_Count] = OP_I16; } } else { if( IS_OPSIZ_32( Code ) ) { fixup_type = FIX_PTR32; Code->info.opnd_type[Opnd_Count] = OP_J48; } else { fixup_type = FIX_PTR16; Code->info.opnd_type[Opnd_Count] = OP_J32; } } break; case MT_BYTE: case MT_WORD: #if defined( _STANDALONE_ ) case MT_SBYTE: case MT_SWORD: #endif AsmError( INVALID_SIZE ); return( RC_ERROR ); case MT_DWORD: case MT_FWORD: #if defined( _STANDALONE_ ) case MT_SDWORD: #endif *flags = INDIRECT_JUMP; return( RC_OK ); case MT_QWORD: case MT_TBYTE: case MT_OWORD: AsmError( INVALID_SIZE ); return( RC_ERROR ); } break; case T_CALL: if( Code->mem_type == MT_SHORT ) { AsmError( CANNOT_USE_SHORT_WITH_CALL ); return( RC_ERROR ); } else if( Code->mem_type == MT_EMPTY ) { #if defined( _STANDALONE_ ) fixup_option = OPTJ_CALL; #else fixup_option = OPTJ_NONE; #endif if( Code->use32 ) { fixup_type = FIX_RELOFF32; Code->info.opnd_type[Opnd_Count] = OP_I32; } else { fixup_type = FIX_RELOFF16; Code->info.opnd_type[Opnd_Count] = OP_I16; } break; } /* fall through */ case T_JMP: switch( Code->mem_type ) { case MT_SHORT: fixup_option = OPTJ_EXPLICIT; fixup_type = FIX_RELOFF8; Code->info.opnd_type[Opnd_Count] = OP_I8; break; case MT_FAR: AsmError( SYNTAX_ERROR ); break; case MT_EMPTY: // forward reference // inline assembler jmp default distance is near // stand-alone assembler jmp default distance is short fixup_option = OPTJ_NONE; #if defined( _STANDALONE_ ) /* guess short if JMP, we will expand later if needed */ fixup_type = FIX_RELOFF8; Code->info.opnd_type[Opnd_Count] = OP_I8; #else if( Code->use32 ) { fixup_type = FIX_RELOFF32; Code->info.opnd_type[Opnd_Count] = OP_I32; } else { fixup_type = FIX_RELOFF16; Code->info.opnd_type[Opnd_Count] = OP_I16; } #endif break; case MT_NEAR: fixup_option = OPTJ_EXPLICIT; if( Code->use32 ) { fixup_type = FIX_RELOFF32; Code->info.opnd_type[Opnd_Count] = OP_I32; } else { fixup_type = FIX_RELOFF16; Code->info.opnd_type[Opnd_Count] = OP_I16; } break; case MT_DWORD: case MT_WORD: #if defined( _STANDALONE_ ) case MT_SDWORD: case MT_SWORD: #endif *flags = INDIRECT_JUMP; return( RC_OK ); #if defined( _STANDALONE_ ) case MT_SBYTE: #endif case MT_BYTE: case MT_FWORD: case MT_QWORD: case MT_TBYTE: case MT_OWORD: AsmError( INVALID_SIZE ); return( RC_ERROR ); } // check_assume( sym, PREFIX_EMPTY ); break; case T_JCXZ: case T_JECXZ: // JCXZ and JECXZ always require SHORT label case T_LOOP: case T_LOOPE: case T_LOOPNE: case T_LOOPNZ: case T_LOOPZ: case T_LOOPD: case T_LOOPED: case T_LOOPNED: case T_LOOPNZD: case T_LOOPZD: case T_LOOPW: case T_LOOPEW: case T_LOOPNEW: case T_LOOPNZW: case T_LOOPZW: #if defined( _STANDALONE_ ) if( ( Code->mem_type != MT_EMPTY ) && ( Code->mem_type != MT_SHORT ) && ( (Options.mode & MODE_IDEAL) == 0 ) ) { #else if( ( Code->mem_type != MT_EMPTY ) && ( Code->mem_type != MT_SHORT ) ) { #endif AsmError( ONLY_SHORT_DISPLACEMENT_IS_ALLOWED ); return( RC_ERROR ); } Code->info.opnd_type[Opnd_Count] = OP_I8; fixup_option = OPTJ_EXPLICIT; fixup_type = FIX_RELOFF8; break; default: if( (Code->info.cpu&P_CPU_MASK) >= P_386 ) { switch( Code->mem_type ) { case MT_SHORT: fixup_option = OPTJ_EXPLICIT; fixup_type = FIX_RELOFF8; Code->info.opnd_type[Opnd_Count] = OP_I8; break; case MT_EMPTY: // forward reference // inline assembler default distance is near // stand-alone assembler default distance is short #if defined( _STANDALONE_ ) fixup_option = OPTJ_JXX; fixup_type = FIX_RELOFF8; Code->info.opnd_type[Opnd_Count] = OP_I8; break; #endif case MT_NEAR: fixup_option = OPTJ_EXPLICIT; if( Code->use32 ) { fixup_type = FIX_RELOFF32; Code->info.opnd_type[Opnd_Count] = OP_I32; } else { fixup_type = FIX_RELOFF16; Code->info.opnd_type[Opnd_Count] = OP_I16; } break; case MT_FAR: #if defined( _STANDALONE_ ) jumpExtend( 1 ); *flags = SCRAP_INSTRUCTION; return( RC_OK ); #endif default: AsmError( ONLY_SHORT_AND_NEAR_DISPLACEMENT_IS_ALLOWED ); return( RC_ERROR ); } } else { // the only mode in 8086, 80186, 80286 is // Jxx SHORT switch( Code->mem_type ) { case MT_EMPTY: #if defined( _STANDALONE_ ) fixup_option = OPTJ_EXTEND; fixup_type = FIX_RELOFF8; Code->info.opnd_type[Opnd_Count] = OP_I8; break; #endif case MT_SHORT: fixup_option = OPTJ_EXPLICIT; fixup_type = FIX_RELOFF8; Code->info.opnd_type[Opnd_Count] = OP_I8; break; default: AsmError( ONLY_SHORT_DISPLACEMENT_IS_ALLOWED ); return( RC_ERROR ); } } } AddFixup( sym, fixup_type, fixup_option ); break; default: /* SYM_STACK */ AsmError( NO_JUMP_TO_AUTO ); return( RC_ERROR ); } return( RC_OK ); } bool ptr_operator( memtype mem_type, bool fix_mem_type ) /******************************************************/ /* determine what should be done with SHORT, NEAR, FAR, BYTE, WORD, DWORD, PTR operator; */ { /* new idea: * when we get a near/far/dword/etc, just set distance / mem_type * operator will be called again with PTR, then we set the opsiz, etc. */ if( Code->info.token == T_LEA ) return( RC_OK ); if( Code->info.token == T_SMSW ) return( RC_OK ); if( mem_type == MT_PTR ) { /* finish deciding what type to make the inst NOW * ie: decide size overrides etc. */ if( Code->use32 && MEM_TYPE( Code->mem_type, WORD ) ) { // if we are in use32 mode, we have to add OPSIZ prefix for // most of the 386 instructions ( except MOVSX and MOVZX ) // when we find WORD PTR if( !IS_BRANCH( Code->info.token ) ) { if( Code->info.opnd_type[OPND1] == OP_MMX ) { /* JBS 2001/02/19 no WORD operands for MMX instructions, only 64-bit or 128-bit so no WORD override needed */ } else { switch( Code->info.token ) { case T_MOVSX: case T_MOVZX: break; default: SET_OPSIZ_ON( Code ); break; } } } } else if( !Code->use32 && MEM_TYPE( Code->mem_type, DWORD ) ) { /* if we are not in use32 mode, we have to add OPSIZ * when we find DWORD PTR * unless we have a LXS ins. * which moves a DWORD ptr into SR:word reg * fixme - can this be done by breaking up the LXS instructions in * asmins.h, and then putting F_32 or F_16 to append * opsize bytes when necessary ? */ if( !IS_BRANCH( Code->info.token ) ) { if( Code->info.opnd_type[OPND1] == OP_MMX ) { /* JBS 2001/02/19 no WORD operands for MMX instructions, only 64-bit or 128-bit so no DWORD override needed */ } else { switch( Code->info.token ) { case T_LDS: case T_LES: case T_LFS: case T_LGS: case T_LSS: /* in these cases, opsize does NOT need to be changed */ break; default: // OPSIZ prefix SET_OPSIZ_ON( Code ); } } } } } else { if( ( mem_type != MT_EMPTY ) && !Code->mem_type_fixed ) { #if defined( _STANDALONE_ ) if( mem_type != MT_STRUCT ) { #endif Code->mem_type = mem_type; if( fix_mem_type ) { Code->mem_type_fixed = true; if( mem_type == MT_FAR ) { if( Code->info.token == T_CALL ) { Code->info.token = T_CALLF; } else if( Code->info.token == T_JMP ) { Code->info.token = T_JMPF; } } } #if defined( _STANDALONE_ ) } #endif } } return( RC_OK ); }
string& CAlnVec::GetColumnVector(string& buffer, TSeqPos aln_pos, TResidueCount * residue_count, bool gaps_in_count) const { buffer.resize(GetNumRows(), GetEndChar()); if (aln_pos > GetAlnStop()) { aln_pos = GetAlnStop(); // out-of-range adjustment } TNumseg seg = GetSeg(aln_pos); TSeqPos delta = aln_pos - GetAlnStart(seg); TSeqPos len = GetLen(seg); TSignedSeqPos pos; for (TNumrow row = 0; row < m_NumRows; row++) { pos = GetStart(row, seg); if (pos >= 0) { // it's a sequence residue bool plus = IsPositiveStrand(row); if (plus) { pos += delta; } else { pos += len - 1 - delta; } CSeqVector& seq_vec = x_GetSeqVector(row); if (GetWidth(row) == 3) { string na_buff, aa_buff; if (plus) { seq_vec.GetSeqData(pos, pos + 3, na_buff); } else { TSeqPos size = seq_vec.size(); seq_vec.GetSeqData(size - pos - 3, size - pos, na_buff); } TranslateNAToAA(na_buff, aa_buff, GetGenCode(row)); buffer[row] = aa_buff[0]; } else { buffer[row] = seq_vec[plus ? pos : seq_vec.size() - pos - 1]; } if (residue_count) { (*residue_count)[FromIupac(buffer[row])]++; } } else { // it's a gap or endchar if (GetEndChar() != (buffer[row] = GetGapChar(row))) { // need to check the where the segment is // only if endchar != gap // this saves a check if there're the same TSegTypeFlags type = GetSegType(row, seg); if (type & fNoSeqOnLeft || type & fNoSeqOnRight) { buffer[row] = GetEndChar(); } } if (gaps_in_count && residue_count) { (*residue_count)[FromIupac(buffer[row])]++; } } } // for row return buffer; }