You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.5 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//////////////////////////////////////////////////////////////////////////////
//文件: SegY文件操作类
//主要功能:
//
//程序编写: 2011-4-21
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "rowcol.h"
#include "TInterval.h"
namespace NCube
{
//线道号范围类,用户有可能需要设置线道号显示范围或设置线道号步长
//当在2D剖面中使用时线号将相等
class AFX_EXT_CLASS CRowColRange
{
public:
CRowColRange(void);
~CRowColRange(void);
TIntervalStep<int> getInlRange();
TIntervalStep<int> getCrlRange();
void setInlRange(const TIntervalStep<int>& inl);
void setCrlRange(const TIntervalStep<int>& crl);
void getRange(TIntervalStep<int>& inl, TIntervalStep<int>& crl) const;
int getInlWidth() { return (stop.row-start.row)/step.row + 1; }
int getCrlWidth() { return (stop.col-start.col)/step.col + 1; }
int atInlIndex( int idx ) { return start.row + step.row * idx; }
int atCrlIndex( int idx ) { return start.col + step.col * idx; }
int nearestInlIndex( const double& t ) const;
int nearestCrlIndex( const double& t ) const;
int snapInl( const double& t );
int snapCrl( const double& t );
void Normalise(); //!< Makes sure start<stop and steps are non-zero
bool Next(CRowCol& rc, bool bFirstPos=false); //获得下一道线道号
//!< Returns false if intersection is empty
bool getIntersection(const CRowColRange& in_range, CRowColRange& out_range);
bool operator==( const CRowColRange& hs ) const;
bool operator!=( const CRowColRange& hs ) const { return !(hs==*this); }
inline bool IsIncludes( const CRowCol& rc ) const { return IsInlineOK(rc.row) && IsCrosslineOK(rc.col); }
inline bool IsInlineOK( int inl ) const { return inl >= start.row && inl <= stop.row && !( (inl-start.row) % step.row ); }
inline bool IsCrosslineOK( int crl ) const { return crl >= start.col && crl <= stop.col && !( (crl-start.col) % step.col ); }
inline bool IsInlineOK( float inl ) const
{
if(inl<start.row || inl>stop.row)
return false;
return true;
}
inline bool IsCrosslineOK( float crl ) const
{
if(crl<start.col || crl>stop.col)
return false;
return true;
}
protected:
bool Intersect(
int start1, int stop1, int step1,
int start2, int stop2, int step2,
int& outstart, int& outstop, int& outstep );
public:
CRowCol start;
CRowCol stop;
CRowCol step;
};
//数据体范围
class AFX_EXT_CLASS CCubeRange : public CRowColRange
{
public:
CCubeRange();
~CCubeRange();
void Normalise(); //!< Makes sure start<stop and steps are non-zero
//!< Returns false if intersection is empty
bool getIntersection(const CCubeRange& in_cr, CCubeRange& out_cr);
bool operator==( const CCubeRange& cs ) const;
bool operator!=( const CCubeRange& cs ) const { return !(cs==*this); }
CPoint3D getCenterPoint(bool bSnap);
float atIndexZ( int idx ) { return zRange.atIndex(idx); }
int nearestIndexZ( const double& t ) { return zRange.nearestIndex(t); }
float snapZ( const double& t ) { return zRange.snap(t); }
bool IsZRangeOK( float z ) const;
int getZWidth() { return (int)( (zRange.stop - zRange.start)/zRange.step ) + 1; }
void Write(CFile& fw, const short &ver);
int Read(CFile& fr, const short &ver);
void Serialize(CArchive& ar, const short &ver);
protected:
bool IntersectF(
float start1, float stop1, float step1,
float start2, float stop2, float step2,
float& outstart, float& outstop, float& outstep );
bool inSeries( float v, float start, float step );
public:
TIntervalStep<float> zRange;
};
}//namespace
using namespace NCube;