Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -21,9 +21,13 @@
|
||||
#elif _WIN32
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#elif __APPLE__
|
||||
#elif __APPLE__
|
||||
#ifdef BUSH_USE_AGL
|
||||
#include <OpenGL/gl.h> //Cocoa
|
||||
#else
|
||||
#include <GL/gl.h> //Macports X11 GL.
|
||||
#endif
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,20 +19,20 @@ public:
|
||||
virtual void resizeGL(int a_w,int a_h){
|
||||
//::printf("debug : resize : %d %d\n",a_w,a_h);
|
||||
#if QT_VERSION < 0x050000
|
||||
#else
|
||||
#else
|
||||
m_width = a_w;
|
||||
m_height = a_h;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
//virtual void paintGL();
|
||||
virtual void paintGL() {
|
||||
#if QT_VERSION < 0x050000
|
||||
//::printf("debug : exlib::Qt::plots_glarea::paintGL %d %d\n",width(),height());
|
||||
m_viewer.set_size(width(),height());
|
||||
#else
|
||||
#else
|
||||
//::printf("debug : exlib::Qt::plots_glarea::paintGL %d %d\n",m_width,m_height);
|
||||
m_viewer.set_size(m_width,m_height);
|
||||
#endif
|
||||
#endif
|
||||
m_viewer.render();
|
||||
}
|
||||
|
||||
@@ -45,11 +45,11 @@ public:
|
||||
protected:
|
||||
tools::sg::GL_plots_viewer& m_viewer;
|
||||
#if QT_VERSION < 0x050000
|
||||
#else
|
||||
#else
|
||||
protected:
|
||||
int m_width;
|
||||
int m_height;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -37,7 +37,7 @@ class Component {
|
||||
typedef std::pair<std::string,Callbacks> NamedCallbacks;
|
||||
#ifdef TOOLS_MEM
|
||||
TOOLS_SCLASS(exlib::WinTk::Component)
|
||||
#endif
|
||||
#endif
|
||||
public:
|
||||
Component(const std::string& aType):fType(aType),fWindow(0),fParent(0){
|
||||
#ifdef TOOLS_MEM
|
||||
@@ -68,16 +68,16 @@ public:
|
||||
const std::string& type() const {return fType;}
|
||||
HWND nativeWindow() {return fWindow;}
|
||||
Component* parent() const {return fParent;}
|
||||
virtual void show() {
|
||||
virtual void show() {
|
||||
//if(!fWindow) return;
|
||||
//::ShowWindow(fWindow,SW_SHOWDEFAULT);
|
||||
}
|
||||
void hide() {
|
||||
void hide() {
|
||||
if(!fWindow) return;
|
||||
::ShowWindow(fWindow,SW_HIDE);
|
||||
}
|
||||
|
||||
virtual bool size(unsigned int& aWidth,unsigned int& aHeight) {
|
||||
|
||||
virtual bool size(unsigned int& aWidth,unsigned int& aHeight) {
|
||||
aWidth = 0;
|
||||
aHeight = 0;
|
||||
if(!fWindow) return false;
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
aHeight = rect.bottom-rect.top;
|
||||
return true;
|
||||
}
|
||||
virtual bool position(int& aX,int& aY) {
|
||||
virtual bool position(int& aX,int& aY) {
|
||||
aX = 0;
|
||||
aY = 0;
|
||||
if(!fWindow) return false;
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
aY = rect.top;
|
||||
return true;
|
||||
}
|
||||
Component* findFather(const std::string& aType) {
|
||||
Component* findFather(const std::string& aType) {
|
||||
if(aType==type()) return this;
|
||||
Component* parent = fParent;
|
||||
while(parent) {
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool setBackground(double aR,double aG,double aB){
|
||||
bool setBackground(double aR,double aG,double aB){
|
||||
if(!fWindow) return false;
|
||||
|
||||
int r = int(aR*255.0);
|
||||
@@ -116,45 +116,45 @@ public:
|
||||
if((g<0)||(g>255)) return false;
|
||||
int b = int(aB*255.0);
|
||||
if((b<0)||(b>255)) return false;
|
||||
|
||||
|
||||
/*
|
||||
//COLORREF cr = RGB(r,g,b);
|
||||
HBRUSH brush = ::CreateSolidBrush(RGB(r,g,b));
|
||||
::printf("debug : WinTk::Component::setBackground : brush %lu\n",brush);
|
||||
|
||||
|
||||
HBRUSH prev = (HBRUSH)::GetClassLongPtr(fWindow,GCLP_HBRBACKGROUND);
|
||||
::printf("debug : WinTk::Component::setBackground : prev brush %lu\n",prev);
|
||||
|
||||
|
||||
{WNDCLASSEX wc;
|
||||
::GetClassInfoEx(::GetModuleHandle(NULL),WC_STATIC,&wc);
|
||||
::printf("debug : prev brush xxx %lu\n",wc.hbrBackground);}
|
||||
|
||||
ULONG_PTR stat =
|
||||
|
||||
ULONG_PTR stat =
|
||||
::SetClassLongPtr(fWindow,GCLP_HBRBACKGROUND,(LONG_PTR)brush);
|
||||
if(prev && !stat) {
|
||||
::printf("debug : WinTk::Component::setBackground : SetClassLongPtr failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
{ULONG_PTR stat =
|
||||
|
||||
{ULONG_PTR stat =
|
||||
::SetClassLongPtr(fWindow,GCLP_HBRBACKGROUND,(LONG_PTR)brush);
|
||||
::printf("debug : WinTk::Component::setBackground : SetClassLongPtr failed.yyy %lu.\n",stat);}
|
||||
|
||||
|
||||
{WNDCLASSEX wc;
|
||||
::GetClassInfoEx(::GetModuleHandle(NULL),WC_STATIC,&wc);
|
||||
::printf("debug : prev brush yyy %lu\n",wc.hbrBackground);}
|
||||
|
||||
|
||||
if(!::InvalidateRect(fWindow,NULL,TRUE)) {
|
||||
::printf("debug : WinTk::Component::setBackground : InvalidateRect failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//::DeleteObject(brush);
|
||||
return true;
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
public:
|
||||
public:
|
||||
void addCallback(const std::string& aName,Callback aFunction,void* aTag) {
|
||||
NamedCallbacks* cbks = 0;
|
||||
std::vector<NamedCallbacks>::iterator it;
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
protected:
|
||||
static void wm__destroy(HWND aWindow) {
|
||||
static void wm__destroy(HWND aWindow) {
|
||||
Component* This = (Component*)::GetWindowLongPtr(aWindow,GWLP_USERDATA);
|
||||
if(This) { //How to be sure that we have a Component* ???
|
||||
if(This->fWindow!=aWindow) {
|
||||
@@ -249,10 +249,10 @@ protected:
|
||||
static LRESULT CALLBACK containerProc(HWND aWindow,UINT aMessage,WPARAM aWParam,LPARAM aLParam) {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Some child send notification message to their parent (instead of sending
|
||||
// the message to themselves !). This procedure is used by containers
|
||||
// the message to themselves !). This procedure is used by containers
|
||||
// to forward these messages to the child.
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
switch(aMessage) {
|
||||
switch(aMessage) {
|
||||
case WM_PARENTNOTIFY:{
|
||||
if(aWParam==WM_CREATE) {
|
||||
::PostMessage(aWindow,WM_TK_CHILDCREATED,TK_KEY,0);
|
||||
@@ -283,8 +283,8 @@ protected:
|
||||
}
|
||||
}return 0;
|
||||
case WM_COMMAND:
|
||||
case WM_VSCROLL:
|
||||
case WM_HSCROLL:{
|
||||
case WM_VSCROLL:
|
||||
case WM_HSCROLL:{
|
||||
::SendMessage((HWND)aLParam,aMessage,aWParam,(LPARAM)0);
|
||||
}return 0;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ protected:
|
||||
#undef WM_TK_CHILDDELETED
|
||||
#undef TK_KEY
|
||||
protected:
|
||||
void destroy() {
|
||||
void destroy() {
|
||||
if(hasCallbacks("delete")) {
|
||||
CallbackData data;
|
||||
executeCallbacks("delete",data);
|
||||
@@ -305,7 +305,7 @@ protected:
|
||||
fWindow = 0;
|
||||
}
|
||||
}
|
||||
void rubberDrawLine(POINT& aBegin,POINT& aEnd) {
|
||||
void rubberDrawLine(POINT& aBegin,POINT& aEnd) {
|
||||
if(!fWindow) return;
|
||||
HPEN pen = ::CreatePen(PS_SOLID,5,RGB(0,0,0));
|
||||
HDC hdc = ::GetWindowDC(fWindow);
|
||||
@@ -319,7 +319,7 @@ protected:
|
||||
::ReleaseDC(fWindow,hdc);
|
||||
::DeletePen(pen);
|
||||
}
|
||||
void rubberDrawRect(POINT& aBegin,POINT& aEnd) {
|
||||
void rubberDrawRect(POINT& aBegin,POINT& aEnd) {
|
||||
if(!fWindow) return;
|
||||
HPEN pen = ::CreatePen(PS_SOLID,0,RGB(0,0,0));
|
||||
HDC hdc = ::GetWindowDC(fWindow);
|
||||
@@ -374,11 +374,11 @@ public:
|
||||
::RegisterClass(&wc);
|
||||
done = true;
|
||||
}
|
||||
|
||||
|
||||
fWindow = ::CreateWindow(sWindowClassName,
|
||||
NULL,
|
||||
aMask, //WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT,
|
||||
400,400,
|
||||
NULL,NULL,
|
||||
::GetModuleHandle(NULL),
|
||||
@@ -386,7 +386,7 @@ public:
|
||||
if(!fWindow) return;
|
||||
::SetWindowLongPtr(fWindow,GWLP_USERDATA,LONG_PTR(this));
|
||||
}
|
||||
virtual ~Shell() {
|
||||
virtual ~Shell() {
|
||||
if(fAcceleratorTable) {
|
||||
::DestroyAcceleratorTable(fAcceleratorTable);
|
||||
fAcceleratorTable = 0;
|
||||
@@ -396,19 +396,19 @@ public:
|
||||
protected:
|
||||
Shell(Shell& a_from):Component(a_from) {}
|
||||
Shell& operator=(Shell&) {return *this;}
|
||||
public:
|
||||
virtual void show() {
|
||||
public:
|
||||
virtual void show() {
|
||||
if(!fWindow) return;
|
||||
::SetForegroundWindow(fWindow);
|
||||
::ShowWindow(fWindow,SW_SHOWDEFAULT);
|
||||
::UpdateWindow(fWindow);
|
||||
::DrawMenuBar(fWindow);
|
||||
}
|
||||
void setTitle(const std::string& aString) {
|
||||
void setTitle(const std::string& aString) {
|
||||
if(!fWindow) return;
|
||||
::SetWindowText(fWindow,aString.c_str());
|
||||
}
|
||||
void setGeometry(int aX,int aY,unsigned int aWidth,unsigned int aHeight) {
|
||||
void setGeometry(int aX,int aY,unsigned int aWidth,unsigned int aHeight) {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Given width, height is the desired client area.
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
@@ -418,7 +418,7 @@ public:
|
||||
hborder += ::GetSystemMetrics(SM_CYMENU);
|
||||
::MoveWindow(fWindow,aX,aY,aWidth,hborder + aHeight,TRUE);
|
||||
}
|
||||
void setSize(unsigned int aWidth,unsigned int aHeight) {
|
||||
void setSize(unsigned int aWidth,unsigned int aHeight) {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Given width, height is the desired client area.
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
@@ -431,17 +431,17 @@ public:
|
||||
void setFocusWindow(HWND aWindow) {fFocusWindow = aWindow;}
|
||||
HWND focusWindow() {return fFocusWindow;}
|
||||
|
||||
void setSetFocusCallback(SetFocusCallback aCallback,void* aTag) {
|
||||
void setSetFocusCallback(SetFocusCallback aCallback,void* aTag) {
|
||||
fSetFocusCallback = aCallback;
|
||||
fSetFocusTag = aTag;
|
||||
}
|
||||
void callSetFocusCallback() {
|
||||
void callSetFocusCallback() {
|
||||
if(!fSetFocusCallback) return;
|
||||
fSetFocusCallback(this,fSetFocusTag);
|
||||
}
|
||||
HACCEL nativeAcceleratorTable() {return fAcceleratorTable;}
|
||||
|
||||
bool addAccelerator(const std::string& aString,int aID) {
|
||||
bool addAccelerator(const std::string& aString,int aID) {
|
||||
//printf("debug : accel : %s %d\n",aString.c_str(),aID);
|
||||
// aString should be of the form : "a" or "Ctrl+a".
|
||||
ACCEL acc;
|
||||
@@ -469,7 +469,7 @@ public:
|
||||
} else {
|
||||
return false;
|
||||
}}
|
||||
|
||||
|
||||
if(!fAcceleratorTable) {
|
||||
fAcceleratorTable = ::CreateAcceleratorTable(&acc,1);
|
||||
} else {
|
||||
@@ -532,16 +532,16 @@ private:
|
||||
S_VK(F22)
|
||||
S_VK(F23)
|
||||
S_VK(F24)
|
||||
|
||||
|
||||
//FIXME : handle other keys ? NUMPAD[0-9]
|
||||
|
||||
|
||||
#undef S_VK
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK proc(HWND aWindow,UINT aMessage,WPARAM aWParam,LPARAM aLParam) {
|
||||
switch (aMessage) {
|
||||
switch (aMessage) {
|
||||
// Same logic as containerProc :
|
||||
case WM_NOTIFY:{ //Coming from a child (combobox, scrollbar, toolbar).
|
||||
NMHDR* nmhdr = (NMHDR*)aLParam;
|
||||
@@ -589,7 +589,7 @@ private:
|
||||
} return 0;
|
||||
case WM_COMMAND:{ //Coming from a menu item, a toolbar !
|
||||
if(aLParam) {
|
||||
// From a toolbar ; send it back to it :
|
||||
// From a toolbar ; send it back to it :
|
||||
::SendMessage((HWND)aLParam,aMessage,aWParam,0);
|
||||
} else {
|
||||
//if(HIWORD(aWParam)==1) { //From an accelerator.
|
||||
@@ -650,7 +650,7 @@ public:
|
||||
::RegisterClass(&wc);
|
||||
done = true;
|
||||
}
|
||||
|
||||
|
||||
// The WS_BORDER is needed. Else probleme of size at startup.
|
||||
RECT rect;
|
||||
::GetClientRect(parent,&rect);
|
||||
@@ -665,14 +665,14 @@ public:
|
||||
NULL);
|
||||
if(!fWindow) return;
|
||||
::SetWindowLongPtr(fWindow,GWLP_USERDATA,LONG_PTR(this));
|
||||
|
||||
|
||||
// initialize OpenGL rendering :
|
||||
fHDC = ::GetDC(fWindow);
|
||||
if( fHDC && SetWindowPixelFormat(fHDC) ) {
|
||||
fContext = ::wglCreateContext(fHDC);
|
||||
}
|
||||
}
|
||||
virtual ~OpenGLArea() {
|
||||
virtual ~OpenGLArea() {
|
||||
if(wglGetCurrentContext()!=NULL) wglMakeCurrent(NULL,NULL);
|
||||
if(fContext) {
|
||||
wglDeleteContext(fContext);
|
||||
@@ -687,7 +687,7 @@ public:
|
||||
bool write_gl2ps(const std::string&,const std::string&);
|
||||
private:
|
||||
static LRESULT CALLBACK proc(HWND aWindow,UINT aMessage,WPARAM aWParam,LPARAM aLParam) {
|
||||
switch (aMessage) {
|
||||
switch (aMessage) {
|
||||
case WM_PAINT:{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC = BeginPaint(aWindow,&ps);
|
||||
@@ -698,12 +698,12 @@ private:
|
||||
if(hdc && context) {
|
||||
::wglMakeCurrent(hdc,context);
|
||||
// User OpenGL paint code :
|
||||
|
||||
|
||||
CallbackData data;
|
||||
data.wparam = aWParam;
|
||||
data.lparam = aLParam;
|
||||
This->executeCallbacks("paint",data);
|
||||
|
||||
|
||||
::SwapBuffers(hdc);
|
||||
}
|
||||
}
|
||||
@@ -756,11 +756,11 @@ private:
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags =
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DOUBLEBUFFER |
|
||||
PFD_STEREO_DONTCARE;
|
||||
pfd.dwFlags =
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DOUBLEBUFFER |
|
||||
PFD_STEREO_DONTCARE;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 32;
|
||||
pfd.cRedBits = 8;
|
||||
@@ -771,7 +771,7 @@ private:
|
||||
pfd.cBlueShift = 0;
|
||||
pfd.cAlphaBits = 0;
|
||||
pfd.cAlphaShift = 0;
|
||||
pfd.cAccumBits = 64;
|
||||
pfd.cAccumBits = 64;
|
||||
pfd.cAccumRedBits = 16;
|
||||
pfd.cAccumGreenBits = 16;
|
||||
pfd.cAccumBlueBits = 16;
|
||||
@@ -784,19 +784,19 @@ private:
|
||||
pfd.dwLayerMask = 0;
|
||||
pfd.dwVisibleMask = 0;
|
||||
pfd.dwDamageMask = 0;
|
||||
|
||||
|
||||
int pixelIndex = ::ChoosePixelFormat(aHdc,&pfd);
|
||||
if (pixelIndex==0) {
|
||||
// Let's choose a default index.
|
||||
pixelIndex = 1;
|
||||
if (::DescribePixelFormat(aHdc,
|
||||
pixelIndex,
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
pixelIndex = 1;
|
||||
if (::DescribePixelFormat(aHdc,
|
||||
pixelIndex,
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
&pfd)==0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (::SetPixelFormat(aHdc,pixelIndex,&pfd)==FALSE) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace WinTk {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool GetClassName(HWND aWindow,std::string& a_value) {
|
||||
inline bool GetClassName(HWND aWindow,std::string& a_value) {
|
||||
if(!aWindow) {a_value.clear();return false;}
|
||||
char className[256];
|
||||
::GetClassName(aWindow,className,128);
|
||||
@@ -38,7 +38,7 @@ inline HWND GetChildByClassName(HWND aWindow,const std::string& aClassName) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void SetGeometry(HWND aWindow,int aX,int aY,unsigned int aWidth,unsigned int aHeight) {
|
||||
inline void SetGeometry(HWND aWindow,int aX,int aY,unsigned int aWidth,unsigned int aHeight) {
|
||||
if(!aWindow) return;
|
||||
std::string className;
|
||||
GetClassName(aWindow,className);
|
||||
@@ -51,7 +51,7 @@ inline void SetGeometry(HWND aWindow,int aX,int aY,unsigned int aWidth,unsigned
|
||||
}
|
||||
}
|
||||
|
||||
inline void GetSize(HWND aWindow,int& aWidth,int& aHeight) {
|
||||
inline void GetSize(HWND aWindow,int& aWidth,int& aHeight) {
|
||||
RECT rect;
|
||||
::GetWindowRect(aWindow,&rect);
|
||||
aWidth = rect.right-rect.left;
|
||||
@@ -232,7 +232,7 @@ namespace WinTk {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
inline bool TreeGetItemLabel(HWND aWindow,HTREEITEM aItem,std::string& a_value) {
|
||||
inline bool TreeGetItemLabel(HWND aWindow,HTREEITEM aItem,std::string& a_value) {
|
||||
TCHAR text[256];
|
||||
TV_ITEM item;
|
||||
item.hItem = aItem;
|
||||
@@ -244,7 +244,7 @@ inline bool TreeGetItemLabel(HWND aWindow,HTREEITEM aItem,std::string& a_value)
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool TreeIsItemBranch(HWND aWindow,HTREEITEM aItem) {
|
||||
inline bool TreeIsItemBranch(HWND aWindow,HTREEITEM aItem) {
|
||||
TV_ITEM item;
|
||||
item.hItem = aItem;
|
||||
item.mask = TVIF_CHILDREN;
|
||||
@@ -252,7 +252,7 @@ inline bool TreeIsItemBranch(HWND aWindow,HTREEITEM aItem) {
|
||||
return item.cChildren?true:false;
|
||||
}
|
||||
|
||||
inline bool TreeIsItemExpanded(HWND aWindow,HTREEITEM aItem) {
|
||||
inline bool TreeIsItemExpanded(HWND aWindow,HTREEITEM aItem) {
|
||||
TV_ITEM item;
|
||||
item.hItem = aItem;
|
||||
item.mask = TVIS_EXPANDED;
|
||||
@@ -295,7 +295,7 @@ inline void TreeGetItemXML(HWND aWindow,HTREEITEM aItem,std::string& a_value) {
|
||||
if (TreeView_GetChild(aWindow,aItem)) {
|
||||
TreeGetItemXML(aWindow,TreeView_GetChild(aWindow,aItem),ss);
|
||||
a_value += ss;
|
||||
}
|
||||
}
|
||||
a_value += spaceRoot + "</treeItem>";
|
||||
aItem = TreeView_GetNextSibling(aWindow,aItem);
|
||||
}
|
||||
@@ -459,7 +459,7 @@ inline HBITMAP ConvertXpmToDIB(HDC aDC,const std::vector<std::string>& aXPM,int&
|
||||
|
||||
bool found = true;
|
||||
for (int l = 0; l < numchars; l++) {
|
||||
if (charlookuptable[(k * numchars) + l]
|
||||
if (charlookuptable[(k * numchars) + l]
|
||||
!= line[(j * numchars) + l]) {
|
||||
found = false;
|
||||
break;
|
||||
@@ -478,7 +478,7 @@ inline HBITMAP ConvertXpmToDIB(HDC aDC,const std::vector<std::string>& aXPM,int&
|
||||
g = glookuptable[k];
|
||||
b = blookuptable[k];
|
||||
}
|
||||
|
||||
|
||||
if(pixelsize==4) {
|
||||
((unsigned char*)dest)[y + x + 0] = b;
|
||||
((unsigned char*)dest)[y + x + 1] = g;
|
||||
@@ -489,22 +489,22 @@ inline HBITMAP ConvertXpmToDIB(HDC aDC,const std::vector<std::string>& aXPM,int&
|
||||
((unsigned char*)dest)[y + x + 1] = g;
|
||||
((unsigned char*)dest)[y + x + 2] = r;
|
||||
}
|
||||
|
||||
|
||||
// next pixel
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(!done) {
|
||||
//printf("debug : xpm : can'tread pixels.\n");
|
||||
::DeleteObject(hbmp);
|
||||
hbmp = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
,m_SESSION_EXIT_STEER_atom(None)
|
||||
{
|
||||
copy_dispatchers(a_from.m_dispatchers);
|
||||
if(!initialize()) {} //throw
|
||||
if(!initialize()) {} //throw
|
||||
}
|
||||
base_session& operator=(const base_session& a_from){
|
||||
if(&a_from==this) return *this;
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
clear_dispatchers();
|
||||
finalize();
|
||||
copy_dispatchers(a_from.m_dispatchers);
|
||||
if(!initialize()) {} //throw
|
||||
if(!initialize()) {} //throw
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void finalize() {
|
||||
if(!m_display) return;
|
||||
::XCloseDisplay(m_display);
|
||||
@@ -116,11 +116,11 @@ public:
|
||||
bool is_valid() const {return m_display?true:false;}
|
||||
|
||||
Display* display() const {return m_display;}
|
||||
|
||||
|
||||
bool steer() {
|
||||
if(!m_display) return false;
|
||||
|
||||
while(true) {
|
||||
while(true) {
|
||||
XEvent xevent;
|
||||
::XNextEvent(m_display,&xevent);
|
||||
if(xevent.type==ClientMessage) {
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
}
|
||||
dispatch(xevent);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
if(!m_display) return false;
|
||||
//::glXWaitX();
|
||||
::XSync(m_display,False);
|
||||
while(true) {
|
||||
while(true) {
|
||||
XEvent xevent;
|
||||
if(::XPending(m_display)) {
|
||||
::XNextEvent(m_display,&xevent);
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
if(xevent.xclient.data.l[0]==(long)m_SESSION_EXIT_STEER_atom) {
|
||||
a_to_exit = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
dispatch(xevent);
|
||||
a_to_exit = false;
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
| ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
|
||||
| PointerMotionMask
|
||||
| KeyPressMask;
|
||||
|
||||
|
||||
swa.background_pixel = ::XWhitePixel(m_display,m_monitor);
|
||||
|
||||
Window window = ::XCreateWindow(m_display,
|
||||
@@ -332,40 +332,40 @@ public:
|
||||
void add_dispatcher(dispatcher* a_dispatcher) {
|
||||
m_dispatchers.push_back(a_dispatcher); //take ownership.
|
||||
}
|
||||
|
||||
|
||||
void invalidate_dispatchers_with_window(Window a_win){
|
||||
tools_vforit(dispatcher*,m_dispatchers,it) {
|
||||
tools_vforit(dispatcher*,m_dispatchers,it) {
|
||||
if((*it)->window()==a_win) (*it)->invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void remove_dispatchers_with_window(Window a_win){
|
||||
tools_vforit_npp(dispatcher*,m_dispatchers,it) {
|
||||
tools_vforit_npp(dispatcher*,m_dispatchers,it) {
|
||||
if((*it)->window()==a_win) {
|
||||
dispatcher* obj = *it;
|
||||
it = m_dispatchers.erase(it);
|
||||
it = m_dispatchers.erase(it);
|
||||
delete obj;
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dispatch(XEvent& a_event) {
|
||||
{tools_vforit_npp(dispatcher*,m_dispatchers,it) {
|
||||
{tools_vforit_npp(dispatcher*,m_dispatchers,it) {
|
||||
if(!(*it)->is_valid()) {
|
||||
dispatcher* obj = *it;
|
||||
it = m_dispatchers.erase(it);
|
||||
it = m_dispatchers.erase(it);
|
||||
delete obj;
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}}
|
||||
tools_vforit(dispatcher*,m_dispatchers,it) {
|
||||
tools_vforit(dispatcher*,m_dispatchers,it) {
|
||||
if((*it)->is_valid()) {
|
||||
if((*it)->dispatch(a_event)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected:
|
||||
@@ -392,18 +392,18 @@ protected:
|
||||
Window m_window;
|
||||
};
|
||||
static Bool wait_for(Display*,XEvent* a_event,char* a_arg){
|
||||
wait_what* arg = (wait_what*)a_arg;
|
||||
return (a_event->type == arg->m_event_type) &&
|
||||
wait_what* arg = (wait_what*)a_arg;
|
||||
return (a_event->type == arg->m_event_type) &&
|
||||
(a_event->xmap.window == arg->m_window);
|
||||
}
|
||||
*/
|
||||
|
||||
void clear_dispatchers() {
|
||||
tools_vforit_npp(dispatcher*,m_dispatchers,it) {
|
||||
tools_vforit_npp(dispatcher*,m_dispatchers,it) {
|
||||
dispatcher* obj = *it;
|
||||
it = m_dispatchers.erase(it);
|
||||
it = m_dispatchers.erase(it);
|
||||
delete obj;
|
||||
}
|
||||
}
|
||||
m_dispatchers.clear();
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ protected:
|
||||
clear_dispatchers();
|
||||
tools_vforcit(dispatcher*,a_from,it) {
|
||||
m_dispatchers.push_back((*it)->copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace X11 {
|
||||
|
||||
class session : public base_session {
|
||||
typedef base_session parent;
|
||||
public:
|
||||
public:
|
||||
//virtual bool make_current(Window a_window) const {
|
||||
// if(!m_display) return false;
|
||||
// if(::glXMakeCurrent(m_display,a_window,m_ctx)==False) {
|
||||
@@ -47,13 +47,13 @@ public:
|
||||
,m_ctx(0)
|
||||
,m_colormap(0)
|
||||
{
|
||||
if(!initialize_gl()) {} //throw
|
||||
if(!initialize_gl()) {} //throw
|
||||
}
|
||||
session& operator=(const session& a_from){
|
||||
if(&a_from==this) return *this;
|
||||
parent::operator=(a_from);
|
||||
finalize_gl();
|
||||
if(!initialize_gl()) {} //throw
|
||||
if(!initialize_gl()) {} //throw
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
@@ -64,9 +64,9 @@ protected:
|
||||
m_ctx = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
{int glxMajor, glxMinor;
|
||||
::glXQueryVersion(m_display,&glxMajor,&glxMinor);
|
||||
::glXQueryVersion(m_display,&glxMajor,&glxMinor);
|
||||
if(glxMajor<=0) {
|
||||
m_out << "tools::X11::session::initialize : bad GLX-Version " << glxMajor << "." << glxMinor << std::endl;
|
||||
::XCloseDisplay(m_display);
|
||||
@@ -95,7 +95,7 @@ protected:
|
||||
//m_out << "tools::X11::session::initialize :"
|
||||
// << " DefaultScreen(m_display): " << DefaultScreen(m_display) << "."
|
||||
// << std::endl;
|
||||
|
||||
|
||||
static const int atbs[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
@@ -154,7 +154,7 @@ protected:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void finalize_gl() {
|
||||
if(!m_display) return;
|
||||
if(m_ctx) {
|
||||
@@ -181,11 +181,11 @@ public:
|
||||
| ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
|
||||
| PointerMotionMask
|
||||
| KeyPressMask;
|
||||
|
||||
|
||||
swa.colormap = m_colormap;
|
||||
swa.border_pixel = 0L;
|
||||
|
||||
Window window = ::XCreateWindow(m_display,
|
||||
Window window = ::XCreateWindow(m_display,
|
||||
::XRootWindow(m_display,m_monitor),
|
||||
a_x,a_y,a_width,a_height,
|
||||
0,
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
InputOutput,
|
||||
m_vinfo->visual,
|
||||
CWBorderPixel|CWColormap|CWEventMask,&swa);
|
||||
|
||||
|
||||
if(window==0L) {
|
||||
m_out << "tools::X11::session::create_window :"
|
||||
<< " can't create a X11 window."
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
}
|
||||
virtual Window window() const {return m_win;}
|
||||
public:
|
||||
simple_dispatcher(base_session& a_session,Window a_win)
|
||||
simple_dispatcher(base_session& a_session,Window a_win)
|
||||
:parent()
|
||||
,m_session(a_session)
|
||||
,m_win(a_win)
|
||||
|
||||
@@ -77,7 +77,7 @@ OpenGLAreaClassRec openGLAreaClassRec = {
|
||||
XtInheritAcceptFocus, /* assign input focus to widget */
|
||||
XtVersion, /* version of intrinsics used */
|
||||
NULL, /* list of callback offsets */
|
||||
XtInheritTranslations, /* translations */
|
||||
XtInheritTranslations, /* translations */
|
||||
XtInheritQueryGeometry, /* return preferred geometry */
|
||||
XtInheritDisplayAccelerator, /* display your accelerator */
|
||||
NULL /* pointer to extension record */
|
||||
@@ -92,9 +92,9 @@ OpenGLAreaClassRec openGLAreaClassRec = {
|
||||
},
|
||||
/* OpenGLArea */
|
||||
{
|
||||
NULL
|
||||
NULL
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
WidgetClass openGLAreaWidgetClass = (WidgetClass) &openGLAreaClassRec;
|
||||
@@ -112,7 +112,7 @@ static void InitializeWidget(Widget a_request,Widget This,ArgList a_args,Cardina
|
||||
athis.visual = CopyFromParent;
|
||||
athis.installColormap = False;
|
||||
athis.glContext = NULL;
|
||||
|
||||
|
||||
{Display* display;
|
||||
Screen* screen;
|
||||
int iscreen;
|
||||
@@ -120,7 +120,7 @@ static void InitializeWidget(Widget a_request,Widget This,ArgList a_args,Cardina
|
||||
display = XtDisplay(This);
|
||||
screen = XtScreen(This);
|
||||
iscreen = XScreenNumberOfScreen(screen);
|
||||
|
||||
|
||||
{int error,event;
|
||||
if(glXQueryExtension(display,&error,&event)==0) {
|
||||
CWarn ("X server does not have OpenGL extensions.\n");
|
||||
@@ -171,8 +171,8 @@ static void InitializeWidget(Widget a_request,Widget This,ArgList a_args,Cardina
|
||||
None
|
||||
};
|
||||
vinfo = glXChooseVisual (display,iscreen,atbs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(vinfo==NULL) {
|
||||
CWarn ("Can't choose a visual.\n");
|
||||
@@ -185,7 +185,7 @@ static void InitializeWidget(Widget a_request,Widget This,ArgList a_args,Cardina
|
||||
athis.installColormap = False;
|
||||
} else {
|
||||
This->core.colormap =
|
||||
XCreateColormap (display,XRootWindow(display,iscreen),vinfo->visual, AllocNone);
|
||||
XCreateColormap (display,XRootWindow(display,iscreen),vinfo->visual, AllocNone);
|
||||
athis.installColormap = True;
|
||||
}
|
||||
if(This->core.colormap==0L) {
|
||||
@@ -250,9 +250,9 @@ static void DestroyWidget(Widget This) {
|
||||
#define IFMOD(a_field) if(athis.a_field != acur.a_field)
|
||||
static Boolean SetValues(Widget a_current,Widget a_request,Widget This,ArgList a_args,Cardinal* a_argn) {
|
||||
IFMOD(doubleBufferOn) {
|
||||
/* Can't change buffering here if X window is created.
|
||||
/* Can't change buffering here if X window is created.
|
||||
With OpenGL, buffering fix parameter of the X window.
|
||||
Buffering must be choosen before the execution of the
|
||||
Buffering must be choosen before the execution of the
|
||||
Realize method that create the window. */
|
||||
if(XtIsRealized(This) && (athis.installColormap==True)) {
|
||||
CWarn("Can't change buffering after \"realization\" of the widget.\n");
|
||||
@@ -279,7 +279,7 @@ static void ChangeWidgetSize(Widget This) {
|
||||
printf("debug : OpenGLArea : ChangeWidgetSize : end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void DrawWidget(Widget This,XEvent* a_event,Region a_region) {
|
||||
#ifdef DEBUG
|
||||
printf("debug : OpenGLArea : DrawWidget : %s\n",XtName(This));
|
||||
@@ -354,28 +354,28 @@ int OpenGLAreaWrite_gl2ps(Widget This,const char* aFileName,const char* opts) {
|
||||
|
||||
inlib_c_gl2ps_set_gl_funcs(&s_OpenGL_funcs);
|
||||
|
||||
options = TOOLS_GL2PS_OCCLUSION_CULL
|
||||
| TOOLS_GL2PS_BEST_ROOT
|
||||
options = TOOLS_GL2PS_OCCLUSION_CULL
|
||||
| TOOLS_GL2PS_BEST_ROOT
|
||||
| TOOLS_GL2PS_SILENT
|
||||
| TOOLS_GL2PS_DRAW_BACKGROUND;
|
||||
sort = TOOLS_GL2PS_BSP_SORT;
|
||||
//sort = TOOLS_GL2PS_SIMPLE_SORT;
|
||||
|
||||
|
||||
vp[0] = 0;
|
||||
vp[1] = 0;
|
||||
vp[2] = This->core.width;
|
||||
vp[3] = This->core.height;
|
||||
|
||||
inlib_c_gl2psBeginPage("title","exlib_Xt_OpenGLArea",
|
||||
vp,TOOLS_GL2PS_EPS,sort,options,
|
||||
TOOLS_GL_RGBA,0, NULL,0,0,0,bufsize,
|
||||
inlib_c_gl2psBeginPage("title","exlib_Xt_OpenGLArea",
|
||||
vp,TOOLS_GL2PS_EPS,sort,options,
|
||||
TOOLS_GL_RGBA,0, NULL,0,0,0,bufsize,
|
||||
file,aFileName);
|
||||
|
||||
|
||||
{XoAnyCallbackStruct value;
|
||||
value.reason = XoCR_PAINT;
|
||||
value.event = 0;
|
||||
XtCallCallbacks(This,XoNpaintCallback,(XtPointer)&value);}
|
||||
|
||||
|
||||
inlib_c_gl2psEndPage();
|
||||
|
||||
inlib_c_gl2ps_reset_gl_funcs();
|
||||
@@ -417,7 +417,7 @@ static void EventHandler(Widget This,XtPointer a_tag,XEvent* a_event ,Boolean* a
|
||||
/*------------------------------------------------------------------------*/
|
||||
/*------------------------------------------------------------------------*/
|
||||
static void XWidgetInstallColormap(Widget This) {
|
||||
/*
|
||||
/*
|
||||
From Mesa/widgets/GLwDrawingArea.c/post_colormap routine.
|
||||
Could use also XtSetWMColormapWindows.
|
||||
*/
|
||||
@@ -458,7 +458,7 @@ static void XWidgetInstallColormap(Widget This) {
|
||||
if(ws!=NULL) XFree(ws);
|
||||
ws = (Window*)malloc ( 2 * sizeof(Window));
|
||||
} else {
|
||||
ws = (Window*)realloc (ws,(wn + 2) * sizeof(Window));
|
||||
ws = (Window*)realloc (ws,(wn + 2) * sizeof(Window));
|
||||
}
|
||||
if(ws==NULL) return;
|
||||
if(found==-1) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef tools_Xt_OpenGLAreaP_h
|
||||
#define tools_Xt_OpenGLAreaP_h
|
||||
#define tools_Xt_OpenGLAreaP_h
|
||||
|
||||
#include "OpenGLArea.h"
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ inline Pixel XWidgetGetPixelResource(Widget aWidget,const std::string& aName){
|
||||
|
||||
inline Pixel XWidgetConvertStringToPixel(Widget aWidget,const std::string& aString){
|
||||
if(aString.empty()) return 0L;
|
||||
if( (aString=="None") || (aString=="none") )
|
||||
if( (aString=="None") || (aString=="none") )
|
||||
return XWidgetGetPixelResource(aWidget,std::string(XtNbackground));
|
||||
XrmValue from,to;
|
||||
from.size = aString.size()+1;
|
||||
@@ -74,7 +74,7 @@ inline bool XWidgetSendMessage(Widget aWidget,long a_1,long a_2) {
|
||||
event.data.l[2] = 0L;
|
||||
event.data.l[3] = 0L;
|
||||
event.data.l[4] = 0L;
|
||||
if(XSendEvent(event.display,event.window,False,0L,(XEvent*)&event)==0)
|
||||
if(XSendEvent(event.display,event.window,False,0L,(XEvent*)&event)==0)
|
||||
return false;
|
||||
XFlush(event.display);
|
||||
return true;
|
||||
@@ -86,7 +86,7 @@ inline void XClassGetName(WidgetClass aClass,std::string& a_value){
|
||||
a_value = std::string((char*)aClass->core_class.class_name);
|
||||
}
|
||||
inline Boolean XClassIsSubclass(WidgetClass aClass,WidgetClass aParent){
|
||||
for (WidgetClass wc = aClass; wc != NULL; wc = wc->core_class.superclass)
|
||||
for (WidgetClass wc = aClass; wc != NULL; wc = wc->core_class.superclass)
|
||||
if (wc == aParent) return True;
|
||||
return False;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ inline void XWidgetGetChildren(Widget aWidget,std::vector<Widget>& aList){
|
||||
aList.clear();
|
||||
if(!XtIsComposite(aWidget)) return;
|
||||
CompositePart* cwp = &(((CompositeWidget)aWidget)->composite);
|
||||
for (unsigned int count=0;count<cwp->num_children;count++)
|
||||
for (unsigned int count=0;count<cwp->num_children;count++)
|
||||
aList.push_back(cwp->children[count]);
|
||||
}
|
||||
inline void XWidgetGetPopupChildren(Widget aWidget,std::vector<Widget>& aList){
|
||||
@@ -142,7 +142,7 @@ inline Widget XWidgetFindChild(Widget aWidget,const std::string& aName){
|
||||
if(!XtIsComposite(aWidget)) return 0;
|
||||
CompositePart* cwp = &(((CompositeWidget)aWidget)->composite);
|
||||
for (unsigned int count=0;count<cwp->num_children;count++) {
|
||||
if(aName==std::string(XtName(cwp->children[count])))
|
||||
if(aName==std::string(XtName(cwp->children[count])))
|
||||
return cwp->children[count];
|
||||
}
|
||||
return 0;
|
||||
@@ -151,7 +151,7 @@ inline Widget XWidgetFindChild(Widget aWidget,const std::string& aName){
|
||||
#include <ostream>
|
||||
|
||||
inline void XWidgetPrintChildren(Widget aWidget,std::ostream& a_out){
|
||||
int number = XWidgetGetChildrenNumber(aWidget);
|
||||
int number = XWidgetGetChildrenNumber(aWidget);
|
||||
a_out << "XWidgetPrintChildren :"
|
||||
<< " " << (unsigned long)aWidget
|
||||
<< " number " << number
|
||||
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
|
||||
// reading :
|
||||
void start() {m_index = -1;set_columns_index(0);}
|
||||
bool next() {
|
||||
bool next() {
|
||||
// a tuple loop is of the form :
|
||||
// tuple.start();
|
||||
// while(tuple.next()) {
|
||||
@@ -539,7 +539,7 @@ public:
|
||||
<< " can't create aida_col<T> " << sout(a_name) << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
m_cols.push_back(col);
|
||||
return col;
|
||||
}
|
||||
@@ -614,7 +614,7 @@ public:
|
||||
}}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
bool column_max(unsigned int a_col,T& a_value) {
|
||||
a_value = T();
|
||||
@@ -637,7 +637,7 @@ public:
|
||||
}}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -755,13 +755,13 @@ inline bool create_cols_from_vals(ntuple& a_ntu,
|
||||
|
||||
} else {
|
||||
if(a_verbose){
|
||||
std::string stype;
|
||||
std::string stype;
|
||||
(*it).s_type(stype);
|
||||
std::string sval;
|
||||
std::string sval;
|
||||
(*it).tos(sval);
|
||||
a_ntu.out() << "tools::aida::create_cols_from_vals :"
|
||||
<< " " << stype << " : "
|
||||
<< (*it).label() << " : "
|
||||
<< " " << stype << " : "
|
||||
<< (*it).label() << " : "
|
||||
<< sval
|
||||
<< std::endl;
|
||||
}
|
||||
@@ -802,13 +802,13 @@ inline bool create_cols_from_vals(ntuple& a_ntu,
|
||||
}
|
||||
|
||||
if(!col) {
|
||||
std::string stype;
|
||||
std::string stype;
|
||||
(*it).s_type(stype);
|
||||
std::string sval;
|
||||
std::string sval;
|
||||
(*it).tos(sval);
|
||||
a_ntu.out() << "tools::aida::create_cols_from_vals :"
|
||||
<< " failed for " << stype << " : "
|
||||
<< (*it).label() << " : "
|
||||
<< " failed for " << stype << " : "
|
||||
<< (*it).label() << " : "
|
||||
<< sval
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -828,14 +828,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
if(a_type==s_aida_type((char)0)) {
|
||||
char v = 0;
|
||||
if(a_s.size()&&!to<char>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<char>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -844,14 +844,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else*/ if(a_type==s_aida_type((short)0)) {
|
||||
short v = 0;
|
||||
if(a_s.size()&&!to<short>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<short>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -860,14 +860,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((int)0)) {
|
||||
int v = 0;
|
||||
if(a_s.size()&&!to<int>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<int>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -876,14 +876,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((int64)0)) {
|
||||
int64 v = 0;
|
||||
if(a_s.size()&&!to<int64>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<int64>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -892,14 +892,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((float)0)) {
|
||||
float v = 0;
|
||||
if(a_s.size()&&!to<float>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<float>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -909,14 +909,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((double)0)) {
|
||||
double v = 0;
|
||||
if(a_s.size()&&!to<double>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<double>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -925,21 +925,21 @@ inline bool create_col(ntuple& a_ntu,
|
||||
/* } else if(a_type==s_aida_type((unsigned char)0)) { //byte
|
||||
unsigned int v = 0;
|
||||
if(a_s.size()&&!to<unsigned int>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(v>=256) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to byte."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<unsigned char>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -948,14 +948,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((unsigned short)0)) {
|
||||
unsigned short v = 0;
|
||||
if(a_s.size()&&!to<unsigned short>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<unsigned short>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -964,14 +964,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((unsigned int)0)) {
|
||||
unsigned int v = 0;
|
||||
if(a_s.size()&&!to<unsigned int>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<unsigned int>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -980,14 +980,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((uint64)0)) {
|
||||
uint64 v = 0;
|
||||
if(a_s.size()&&!to<uint64>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<uint64>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -998,14 +998,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((bool)true)) {
|
||||
bool v = false;
|
||||
if(a_s.size()&&!to(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<bool>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -1013,7 +1013,7 @@ inline bool create_col(ntuple& a_ntu,
|
||||
|
||||
} else if(a_type==s_aida_type(std::string())) {
|
||||
if(!a_ntu.create_col<std::string>(a_name,a_s)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -1022,14 +1022,14 @@ inline bool create_col(ntuple& a_ntu,
|
||||
} else if(a_type==s_aida_type((int64)0)) {
|
||||
int64 v = 0;
|
||||
if(a_s.size()&&!to<int64>(a_s,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't convert def " << sout(a_s)
|
||||
<< " to a " << a_type
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(!a_ntu.create_col<int64>(a_name,v)) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " can't create column of type " << sout(a_type)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -1039,13 +1039,13 @@ inline bool create_col(ntuple& a_ntu,
|
||||
// we expect a booking string on a_s.
|
||||
|
||||
if(!a_is_ntu) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " mismatch a_is_ntu/a_type."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(a_s.empty()) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " empty booking string."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -1053,7 +1053,7 @@ inline bool create_col(ntuple& a_ntu,
|
||||
|
||||
columns::finder f(a_ntu.out(),a_s);
|
||||
if(!f.find_variables()) {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " find_variables() failed for " << sout(a_s) << "."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -1078,7 +1078,7 @@ inline bool create_col(ntuple& a_ntu,
|
||||
//FIXME : double[]
|
||||
|
||||
} else {
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
a_ntu.out() << "tools::aida::create_col :"
|
||||
<< " col type " << sout(a_type)
|
||||
<< " not yet handled."
|
||||
<< std::endl;
|
||||
@@ -1190,12 +1190,12 @@ protected:
|
||||
static bool find_is(const base_ntu& a_ntu,const base_col* a_col,
|
||||
std::vector<unsigned int>& a_is,
|
||||
bool& a_found){
|
||||
// search the indices to reach the sub leaf a_col from the main a_ntu.
|
||||
// search the indices to reach the sub leaf a_col from the main a_ntu.
|
||||
// Note : it is assumed that a_is is empty and a_found = false before
|
||||
// calling with function.
|
||||
|
||||
|
||||
const std::vector<base_col*>& cols = a_ntu.columns();
|
||||
|
||||
|
||||
// look if a_col is a leaf col of a_ntu :
|
||||
{unsigned int index = 0;
|
||||
tools_vforcit(base_col*,cols,it) {
|
||||
@@ -1206,7 +1206,7 @@ protected:
|
||||
}
|
||||
index++;
|
||||
}}
|
||||
|
||||
|
||||
// go down sub ntu :
|
||||
{unsigned int index = 0;
|
||||
tools_vforcit(base_col*,cols,it) {
|
||||
@@ -1222,7 +1222,7 @@ protected:
|
||||
index++;
|
||||
}}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
protected:
|
||||
bool _looper(base_ntu& a_sub,
|
||||
const std::vector<unsigned int>& a_is,
|
||||
@@ -1230,7 +1230,7 @@ protected:
|
||||
bool& a_stop) {
|
||||
if(a_depth>=a_is.size()) return false;
|
||||
|
||||
unsigned int coli = a_is[a_depth];
|
||||
unsigned int coli = a_is[a_depth];
|
||||
const std::vector<base_col*>& cols = a_sub.columns();
|
||||
if(coli>=cols.size()) return false;
|
||||
|
||||
@@ -1322,7 +1322,7 @@ public:
|
||||
m_S2 = T();
|
||||
m_counter = 0;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
public:
|
||||
bool process() {
|
||||
m_counter = 0;
|
||||
@@ -1375,13 +1375,13 @@ inline base_col* find_leaf_column(const base_ntu& a_ntu,const std::string& a_nam
|
||||
base_ntu* sub = col->get_to_fill(); //it holds the "sub" cols schema.
|
||||
if(!sub) return 0;
|
||||
base_col* fcol = find_leaf_column(*sub,a_name);
|
||||
if(fcol) return fcol;
|
||||
if(fcol) return fcol;
|
||||
} else {
|
||||
if((*it)->name()==a_name) return *it;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool to_vector(base_ntu& a_ntu,std::vector<double>& a_vec,unsigned int a_col = 0) {
|
||||
|
||||
@@ -42,13 +42,13 @@ public:
|
||||
std::string s(a_argv[index]);
|
||||
std::string::size_type pos = s.find('=');
|
||||
if(pos==std::string::npos) {
|
||||
m_args.push_back(arg(s,""));
|
||||
m_args.push_back(arg(s,""));
|
||||
} else {
|
||||
std::string key = s.substr(0,pos);
|
||||
pos++;
|
||||
std::string value = s.substr(pos,s.size()-pos);
|
||||
m_args.push_back(arg(key,value));
|
||||
}
|
||||
m_args.push_back(arg(key,value));
|
||||
}
|
||||
}
|
||||
}
|
||||
args(const std::vector<std::string>& a_args,bool a_strip = false){
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
mem::increment(s_class().c_str());
|
||||
#endif
|
||||
std::vector<std::string> _args;
|
||||
words(a_args,a_sep,false,_args);
|
||||
words(a_args,a_sep,false,_args);
|
||||
add(_args,a_strip);
|
||||
}
|
||||
virtual ~args(){
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
if((*it).first==a_key) a_vals.push_back((*it).second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool find(const std::string& a_string,bool& a_value,const bool& a_def = false) const {
|
||||
std::string s;
|
||||
if(!find(a_string,s)) {a_value = a_def;return false;}
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
if(!find(a_string,_s)) {a_value = a_def;return false;}
|
||||
return to<aT>(_s,a_value,a_def);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TOOLS_DEPRECATED
|
||||
std::vector<std::string> tovector() const {
|
||||
// Return a vector of string <name=value>
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
strip(left,both,' ');
|
||||
strip(right,both,' ');
|
||||
}
|
||||
m_args.push_back(arg(left,right));
|
||||
m_args.push_back(arg(left,right));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,8 @@ public:
|
||||
return int(nbeg) - int(m_args.size());
|
||||
}
|
||||
|
||||
void remove_first(){m_args.erase(m_args.begin());}
|
||||
void remove_first(){if(m_args.size()) m_args.erase(m_args.begin());}
|
||||
void remove_last(){if(m_args.size()) m_args.erase(m_args.end()-1);}
|
||||
|
||||
bool last(std::string& a_key,std::string& a_value) const {
|
||||
a_key.clear();
|
||||
@@ -268,7 +269,7 @@ public:
|
||||
a_value = m_args.back().second;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool prog_name(std::string& a_value) const {
|
||||
if(m_args.empty()) {a_value.clear();return false;}
|
||||
if(m_args[0].second.size()) {a_value.clear();return false;}
|
||||
@@ -280,8 +281,8 @@ public:
|
||||
std::string slast;
|
||||
std::string s;
|
||||
if((m_args.size()>1) //first arg is the program name !
|
||||
&& last(slast,s)
|
||||
&& (slast.find('-')!=0)
|
||||
&& last(slast,s)
|
||||
&& (slast.find('-')!=0)
|
||||
&& (s.empty()) ) {
|
||||
a_file = slast; //Last argument is not an option.
|
||||
return true;
|
||||
@@ -295,8 +296,8 @@ public:
|
||||
std::string slast;
|
||||
std::string s;
|
||||
if((m_args.size()>1) //first arg is the program name !
|
||||
&& last(slast,s)
|
||||
&& (slast.find('-')!=0)
|
||||
&& last(slast,s)
|
||||
&& (slast.find('-')!=0)
|
||||
&& (s.empty()) ) {
|
||||
a_file = slast; //Last argument is not an option.
|
||||
if(a_remove) m_args.erase(m_args.end()-1);
|
||||
@@ -306,13 +307,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void not_hyphens(std::vector<std::string>& a_not_hyphens,bool a_skip_first = false) const {
|
||||
a_not_hyphens.clear();
|
||||
// Get the serie of trailing args not beginning with '-'
|
||||
// and without a value (not of the form [-]xxx=yyy).
|
||||
// and without a value (not of the form [-]xxx=yyy).
|
||||
// Note that an argument like that in between arguments
|
||||
// is NOT taken into account.
|
||||
// is NOT taken into account.
|
||||
if(m_args.empty()) return;
|
||||
std::vector<arg>::const_iterator it = m_args.begin();
|
||||
if(a_skip_first) it++;
|
||||
@@ -328,7 +329,7 @@ public:
|
||||
void files(std::vector<std::string>& a_files,bool a_skip_first = true) const { //true and not false as in the upper.
|
||||
return not_hyphens(a_files,a_skip_first);
|
||||
}
|
||||
|
||||
|
||||
bool first_not_hyphen(std::string& a_first,bool a_skip_first = false) const {
|
||||
std::vector<std::string> _ss;
|
||||
not_hyphens(_ss,a_skip_first);
|
||||
@@ -343,7 +344,7 @@ public:
|
||||
// If using with :
|
||||
// int argc;
|
||||
// char** argv;
|
||||
// args.argcv(argc,argv);
|
||||
// args.argcv(argc,argv);
|
||||
// you can delete with :
|
||||
// args::delete_argcv(argc,argv);
|
||||
if(m_args.empty()) {a_argc = 0;a_argv = 0;return true;}
|
||||
@@ -385,7 +386,7 @@ public:
|
||||
tools_vforcit(std::string,a_knowns,it2) {
|
||||
if((*it).first==(*it2)) {
|
||||
found = true;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found) return false; //one option not in a_knowns.
|
||||
@@ -456,8 +457,8 @@ protected:
|
||||
|
||||
inline bool check_args(const std::vector<std::string>& a_args,unsigned int a_number,std::ostream& a_out){
|
||||
if(a_args.size()==a_number) return true;
|
||||
a_out << "bad argument number."
|
||||
<< " Given " << (unsigned int)a_args.size()
|
||||
a_out << "bad argument number."
|
||||
<< " Given " << (unsigned int)a_args.size()
|
||||
<< " whilst " << a_number << " expected."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -478,8 +479,8 @@ inline bool check_min(const std::vector<std::string>& a_args,unsigned int a_numb
|
||||
}
|
||||
return true;
|
||||
}
|
||||
a_out << "bad argument number."
|
||||
<< " Given " << (unsigned int)a_args.size()
|
||||
a_out << "bad argument number."
|
||||
<< " Given " << (unsigned int)a_args.size()
|
||||
<< " whilst at least " << a_number << " expected."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -487,8 +488,8 @@ inline bool check_min(const std::vector<std::string>& a_args,unsigned int a_numb
|
||||
|
||||
inline bool check_min_args(const std::vector<std::string>& aArgs,unsigned int a_number,std::ostream& a_out){
|
||||
if(aArgs.size()>=a_number) return true;
|
||||
a_out << "bad argument number."
|
||||
<< " Given " << (unsigned int)aArgs.size()
|
||||
a_out << "bad argument number."
|
||||
<< " Given " << (unsigned int)aArgs.size()
|
||||
<< " whilst at least " << a_number << " expected."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -496,8 +497,8 @@ inline bool check_min_args(const std::vector<std::string>& aArgs,unsigned int a_
|
||||
|
||||
inline bool check_or_args(const std::vector<std::string>& aArgs,unsigned int a_1,unsigned int a_2,std::ostream& a_out){
|
||||
if((aArgs.size()==a_1)||(aArgs.size()==a_2)) return true;
|
||||
a_out << "bad argument number."
|
||||
<< " Given " << (unsigned int)aArgs.size()
|
||||
a_out << "bad argument number."
|
||||
<< " Given " << (unsigned int)aArgs.size()
|
||||
<< " whilst " << a_1 << " or " << a_2 << " expected."
|
||||
<< std::endl;
|
||||
return false;
|
||||
|
||||
@@ -39,16 +39,16 @@ public:
|
||||
#endif
|
||||
configure(a_orders);
|
||||
}
|
||||
array(unsigned int a_dimension,unsigned int a_order) {
|
||||
array(unsigned int a_dimension,unsigned int a_order) {
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment(s_class().c_str());
|
||||
#endif
|
||||
// A hypercube of dimension "a_dimension" and size "a_order".
|
||||
uints_t _orders(a_dimension);
|
||||
for(unsigned int index=0;index<a_dimension;index++)
|
||||
for(unsigned int index=0;index<a_dimension;index++)
|
||||
_orders[index] = a_order;
|
||||
configure(_orders);
|
||||
}
|
||||
}
|
||||
virtual ~array() {
|
||||
#ifdef TOOLS_MEM
|
||||
mem::decrement(s_class().c_str());
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
public: //operators:
|
||||
array& operator*=(const T& a_T) {multiply(a_T);return *this;}
|
||||
array& operator*=(const T& a_T) {multiply(a_T);return *this;}
|
||||
bool operator==(const array& a_array) const {
|
||||
return equal(a_array);
|
||||
}
|
||||
@@ -83,17 +83,17 @@ public: //operators:
|
||||
array a(*this);
|
||||
a.multiply(a_T);
|
||||
return a;
|
||||
}
|
||||
}
|
||||
// the below would need exception to do it properly.
|
||||
//array operator+(const array& a_array) const {
|
||||
// array a(*this);
|
||||
// if(!a.add(a_array)) {} //throw
|
||||
// return a;
|
||||
//}
|
||||
//array& operator+=(const array& a_array) {
|
||||
//}
|
||||
//array& operator+=(const array& a_array) {
|
||||
// if(!add(a_array)) {} //throw
|
||||
// return *this;
|
||||
//}
|
||||
//}
|
||||
public:
|
||||
void copy(const array& a_from) {
|
||||
m_orders = a_from.m_orders;
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
m_vector.assign(_size,zero());
|
||||
m_offsets.resize(dim,0);
|
||||
m_offsets[0] = 1;
|
||||
for(size_t iaxis=1;iaxis<dim;iaxis++)
|
||||
for(size_t iaxis=1;iaxis<dim;iaxis++)
|
||||
m_offsets[iaxis] = m_offsets[iaxis-1] * m_orders[iaxis-1];
|
||||
m_is.resize(dim);
|
||||
m_is.assign(dim,0);
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
cons_vec_it_t it = m_vector.begin();
|
||||
cons_vec_it_t ait = a_array.m_vector.begin();
|
||||
for(;it!=m_vector.end();++it,++ait) {
|
||||
T diff = (*it) - (*ait);
|
||||
T diff = (*it) - (*ait);
|
||||
if(diff<0) diff *= -1;
|
||||
if(diff>=aEpsilon) return false;
|
||||
}
|
||||
@@ -305,7 +305,7 @@ public:
|
||||
(*it) = zero(); //PAW convention.
|
||||
status = false;
|
||||
} else {
|
||||
T _value = (*it);
|
||||
T _value = (*it);
|
||||
(*it) = v_one/_value;
|
||||
}
|
||||
}
|
||||
@@ -316,7 +316,7 @@ public:
|
||||
a_offset = 0;
|
||||
if(a_is.size()!=dim) return false;
|
||||
if(dim==0) return false;
|
||||
for(size_t iaxis=0;iaxis<dim;iaxis++) {
|
||||
for(size_t iaxis=0;iaxis<dim;iaxis++) {
|
||||
unsigned int i = a_is[iaxis];
|
||||
if(i>=m_orders[iaxis]) {
|
||||
a_offset = 0;
|
||||
@@ -330,7 +330,7 @@ public:
|
||||
if(a_offset>=m_vector.size()) return false;
|
||||
size_t dim = m_orders.size();
|
||||
unsigned int off = a_offset;
|
||||
for(int iaxis=int(dim)-1;iaxis>=0;iaxis--) {
|
||||
for(int iaxis=int(dim)-1;iaxis>=0;iaxis--) {
|
||||
a_is[iaxis] = off/m_offsets[iaxis];
|
||||
off -= a_is[iaxis] * m_offsets[iaxis];
|
||||
}
|
||||
@@ -341,7 +341,7 @@ public:
|
||||
if(a_cut.size()!=dim) return false;
|
||||
if(!indices(a_index,const_cast<uints_t&>(m_is))) return false;
|
||||
bool good = true;
|
||||
for(size_t iaxis=0;iaxis<dim;iaxis++) {
|
||||
for(size_t iaxis=0;iaxis<dim;iaxis++) {
|
||||
if(m_is[iaxis]<a_cut[iaxis].first) {good = false;break;}
|
||||
if(m_is[iaxis]>a_cut[iaxis].second) {good = false;break;}
|
||||
}
|
||||
@@ -355,21 +355,21 @@ public:
|
||||
}
|
||||
public:
|
||||
static T zero() {
|
||||
//return (T)0;
|
||||
//return T(0);
|
||||
return T();
|
||||
//return (T)0;
|
||||
//return T(0);
|
||||
return T();
|
||||
}
|
||||
static T one() {
|
||||
//return (T)1;
|
||||
return T(1);
|
||||
//return (T)1;
|
||||
return T(1);
|
||||
}
|
||||
static T minus_one() {
|
||||
//return (T)-1;
|
||||
return T(-1);
|
||||
//return (T)-1;
|
||||
return T(-1);
|
||||
}
|
||||
static T two() {
|
||||
//return (T)2;
|
||||
return T(2);
|
||||
//return (T)2;
|
||||
return T(2);
|
||||
}
|
||||
protected:
|
||||
uints_t m_orders;
|
||||
@@ -393,7 +393,7 @@ inline bool contract(
|
||||
,unsigned int aIB
|
||||
,array<T>& aR
|
||||
){
|
||||
// Contract a tensor (aA) with a vector (aB)
|
||||
// Contract a tensor (aA) with a vector (aB)
|
||||
// on indice aIA of aA and aIB of aB.
|
||||
// aA.dimension must be > 1.
|
||||
// aB.dimension must be > 1.
|
||||
@@ -411,7 +411,7 @@ inline bool contract(
|
||||
|
||||
if((rdima+rdimb)==0) {
|
||||
std::vector<unsigned int> rorders(1);
|
||||
rorders[0] = 1;
|
||||
rorders[0] = 1;
|
||||
if(!aR.configure(rorders)) return false;
|
||||
const std::vector<T>& vA = aA.vector();
|
||||
const std::vector<T>& vB = aB.vector();
|
||||
@@ -425,14 +425,14 @@ inline bool contract(
|
||||
|
||||
std::vector<unsigned int> rorders(rdima+rdimb);
|
||||
unsigned int index;
|
||||
for(index=0;index<aIA;index++)
|
||||
for(index=0;index<aIA;index++)
|
||||
rorders[index] = aA.orders()[index];
|
||||
for(index=aIA;index<rdima;index++)
|
||||
for(index=aIA;index<rdima;index++)
|
||||
rorders[index] = aA.orders()[index+1];
|
||||
|
||||
for(index=0;index<aIB;index++)
|
||||
for(index=0;index<aIB;index++)
|
||||
rorders[rdima+index] = aB.orders()[index];
|
||||
for(index=aIB;index<rdimb;index++)
|
||||
for(index=aIB;index<rdimb;index++)
|
||||
rorders[rdima+index] = aB.orders()[index+1];
|
||||
|
||||
if(!aR.configure(rorders)) return false;
|
||||
@@ -505,9 +505,9 @@ inline bool swap(
|
||||
T value = vvec[offset];
|
||||
|
||||
if(!aV.indices(offset,vis)) return false;
|
||||
unsigned int i = vis[aI1];
|
||||
vis[aI1] = vis[aI2];
|
||||
vis[aI2] = i;
|
||||
unsigned int i = vis[aI1];
|
||||
vis[aI1] = vis[aI2];
|
||||
vis[aI2] = i;
|
||||
if(!aR.set_value(vis,value)) return false;
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ inline bool swap(
|
||||
}
|
||||
|
||||
//NOTE : print is a Python keyword.
|
||||
template <class T>
|
||||
template <class T>
|
||||
inline void dump(std::ostream& a_out,const tools::array<T>& a_array,const std::string& a_title){
|
||||
if(a_title.size()) a_out << a_title << std::endl;
|
||||
const std::vector<T>& vec = a_array.vector();
|
||||
@@ -525,7 +525,7 @@ inline void dump(std::ostream& a_out,const tools::array<T>& a_array,const std::s
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class T>
|
||||
inline void diff(std::ostream& a_out,const array<T>& aA,const array<T>& aB,T a_epsilon){
|
||||
if(aA.orders()!=aB.orders()) {
|
||||
a_out << "tools::arrays::diff : not same orders" << std::endl;
|
||||
@@ -536,7 +536,7 @@ inline void diff(std::ostream& a_out,const array<T>& aA,const array<T>& aB,T a_e
|
||||
std::vector<unsigned int> is(dim);
|
||||
unsigned int vsize = aA.vector().size();
|
||||
for(unsigned int index=0;index<vsize;index++) {
|
||||
T diff = aA.vector()[index]-aB.vector()[index];
|
||||
T diff = aA.vector()[index]-aB.vector()[index];
|
||||
if(diff<0) diff *= -1;
|
||||
if(diff>=a_epsilon) {
|
||||
aA.indices(index,is);
|
||||
@@ -582,7 +582,7 @@ public:
|
||||
if(!good) continue;
|
||||
// All indicies are different.
|
||||
unsigned int n = 0;
|
||||
for(unsigned int iaxis=0;iaxis<a_order;) {
|
||||
for(unsigned int iaxis=0;iaxis<a_order;) {
|
||||
unsigned int ival = is[iaxis];
|
||||
if(ival!=iaxis) {
|
||||
// Swap and add one permutation :
|
||||
|
||||
@@ -35,6 +35,32 @@ inline void buf2lines(char* a_buffer,std::vector<std::string>& a_lines) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void buf2lines(size_t a_size,const char* a_buffer,std::vector<std::string>& a_lines) {
|
||||
a_lines.clear();
|
||||
if(!a_size) return;
|
||||
std::string line;
|
||||
char* pos = (char*)a_buffer;
|
||||
const char* end = a_buffer+a_size-1;
|
||||
while(true) {
|
||||
if(pos>end) {
|
||||
if(line.size()) a_lines.push_back(line);
|
||||
return;
|
||||
}
|
||||
if((*pos=='\r')&&((pos+1)<=end)&&(*(pos+1)=='\n')) {
|
||||
a_lines.push_back(line);
|
||||
line.clear();
|
||||
pos += 2;
|
||||
} else if(*pos=='\n') {
|
||||
a_lines.push_back(line);
|
||||
line.clear();
|
||||
pos++;
|
||||
} else {
|
||||
line += *pos;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include <string.h> //memcpy
|
||||
@@ -49,10 +75,10 @@ inline bool strings2buf(size_t a_number,const char** a_strings,size_t& a_size,ch
|
||||
// For {}, it produces "0".
|
||||
a_size = 0;
|
||||
for(size_t index=0;index<a_number;index++) a_size += ::strlen(a_strings[index])+1;
|
||||
a_size++;
|
||||
a_size++;
|
||||
a_buffer = new char[a_size];
|
||||
if(!a_buffer) {a_size = 0;return false;}
|
||||
char* pos = a_buffer;
|
||||
char* pos = a_buffer;
|
||||
size_t array_size;
|
||||
for(size_t index=0;index<a_number;index++) {
|
||||
const char* s = a_strings[index];
|
||||
@@ -60,7 +86,7 @@ inline bool strings2buf(size_t a_number,const char** a_strings,size_t& a_size,ch
|
||||
::memcpy(pos,s,array_size);
|
||||
pos += array_size;
|
||||
}
|
||||
*pos = '\0';
|
||||
*pos = '\0';
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
@@ -72,10 +98,10 @@ inline bool strings2buf(const std::vector<std::string>& a_strings,size_t& a_size
|
||||
size_t number = a_strings.size();
|
||||
a_size = 0;
|
||||
for(size_t index=0;index<number;index++) a_size += a_strings[index].size()+1;
|
||||
a_size++;
|
||||
a_size++;
|
||||
a_buffer = new char[a_size];
|
||||
if(!a_buffer) {a_size = 0;return false;}
|
||||
char* pos = a_buffer;
|
||||
char* pos = a_buffer;
|
||||
size_t array_size;
|
||||
for(size_t index=0;index<number;index++) {
|
||||
const std::string& s = a_strings[index];
|
||||
@@ -83,7 +109,7 @@ inline bool strings2buf(const std::vector<std::string>& a_strings,size_t& a_size
|
||||
::memcpy(pos,s.c_str(),array_size);
|
||||
pos += array_size;
|
||||
}
|
||||
*pos = '\0';
|
||||
*pos = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,30 +9,30 @@
|
||||
|
||||
// Contour.h: interface for the ccontour class.
|
||||
//
|
||||
// ccontour implements Contour plot algorithm descrided in
|
||||
// ccontour implements Contour plot algorithm descrided in
|
||||
// IMPLEMENTATION OF
|
||||
// AN IMPROVED CONTOUR
|
||||
// PLOTTING ALGORITHM
|
||||
// BY
|
||||
// BY
|
||||
//
|
||||
// MICHAEL JOSEPH ARAMINI
|
||||
// MICHAEL JOSEPH ARAMINI
|
||||
//
|
||||
// B.S., Stevens Institute of Technology, 1980
|
||||
// B.S., Stevens Institute of Technology, 1980
|
||||
// See http://www.ultranet.com/~aramini/thesis.html
|
||||
//
|
||||
// Ported to C++ by Jonathan de Halleux.
|
||||
//
|
||||
// Using ccontour :
|
||||
//
|
||||
// ccontour is not directly usable. The user has to
|
||||
// 1. derive the function ExportLine that is
|
||||
// ccontour is not directly usable. The user has to
|
||||
// 1. derive the function ExportLine that is
|
||||
// supposed to draw/store the segment of the contour
|
||||
// 2. Set the function draw contour of. (using SetFieldFn
|
||||
// The function must be declared as follows
|
||||
// double (*myF)(double x , double y);
|
||||
//
|
||||
// History:
|
||||
// 31-07-2002:
|
||||
// 31-07-2002:
|
||||
// - A lot of contribution from Chenggang Zhou (better strip compressions, merging, area, weight),
|
||||
// - Got rid of ugly MFC lists for STL.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
namespace tools {
|
||||
|
||||
class ccontour
|
||||
class ccontour
|
||||
{
|
||||
#ifdef TOOLS_MEM
|
||||
static const std::string& s_class() {
|
||||
@@ -83,7 +83,7 @@ protected: //G.Barrand
|
||||
virtual void CleanMemory();
|
||||
// generates contour
|
||||
// Before calling this functions you must
|
||||
// 1. derive the function ExportLine that is
|
||||
// 1. derive the function ExportLine that is
|
||||
// supposed to draw/store the segment of the contour
|
||||
// 2. Set the function draw contour of. (using SetFieldFn
|
||||
// The function must be declared as follows
|
||||
@@ -95,7 +95,7 @@ public: //G.Barrand
|
||||
void set_first_grid(int iCol, int iRow);
|
||||
// Set the dimension of the base grid
|
||||
void set_secondary_grid(int iCol, int iRow);
|
||||
// Sets the region [left, right, bottom,top] to generate contour
|
||||
// Sets the region [left, right, bottom,top] to generate contour
|
||||
void set_limits(double pLimits[4]);
|
||||
// Sets the isocurve values
|
||||
void set_planes(const std::vector<double>& vPlanes);
|
||||
@@ -150,7 +150,7 @@ private:
|
||||
mem::decrement(s_class().c_str());
|
||||
#endif
|
||||
}
|
||||
protected:
|
||||
protected:
|
||||
CFnStr(const CFnStr&){}
|
||||
CFnStr& operator=(const CFnStr&){return *this;}
|
||||
public:
|
||||
@@ -189,8 +189,8 @@ protected:
|
||||
private:
|
||||
//G.Barrand : have the below in the class.
|
||||
// A simple test function
|
||||
static double ContourTestFunction(double x,double y,void*) {
|
||||
return 0.5*(::cos(x+3.14/4)+::sin(y+3.14/4));
|
||||
static double ContourTestFunction(double x,double y,void*) {
|
||||
return 0.5*(::cos(x+3.14/4)+::sin(y+3.14/4));
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -212,10 +212,10 @@ protected:
|
||||
|
||||
// implementation :
|
||||
//
|
||||
// Code get on the web at :
|
||||
// Code get on the web at :
|
||||
// http://www.codeproject.com/cpp/contour.asp
|
||||
//
|
||||
// G.Barrand
|
||||
//
|
||||
// G.Barrand
|
||||
//
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -282,7 +282,7 @@ inline void ccontour::generate()
|
||||
const int cols=m_iColSec+1;
|
||||
const int rows=m_iRowSec+1;
|
||||
//double xoff,yoff;
|
||||
|
||||
|
||||
// Initialize memroy if needed
|
||||
InitMemory();
|
||||
|
||||
@@ -295,7 +295,7 @@ inline void ccontour::generate()
|
||||
oldx3 = 0;
|
||||
x3 = (cols-1)/m_iRowFir;
|
||||
x4 = ( 2*(cols-1) )/m_iRowFir;
|
||||
for (x = oldx3; x <= x4; x++)
|
||||
for (x = oldx3; x <= x4; x++)
|
||||
{ /* allocate new columns needed
|
||||
*/
|
||||
if (x >= cols)
|
||||
@@ -308,17 +308,17 @@ inline void ccontour::generate()
|
||||
}
|
||||
|
||||
y4 = 0;
|
||||
for (j = 0; j < m_iColFir; j++)
|
||||
for (j = 0; j < m_iColFir; j++)
|
||||
{
|
||||
y3 = y4;
|
||||
y4 = ((j+1)*(rows-1))/m_iColFir;
|
||||
Cntr1(oldx3, x3, y3, y4);
|
||||
}
|
||||
|
||||
for (i = 1; i < m_iRowFir; i++)
|
||||
for (i = 1; i < m_iRowFir; i++)
|
||||
{
|
||||
y4 = 0;
|
||||
for (j = 0; j < m_iColFir; j++)
|
||||
for (j = 0; j < m_iColFir; j++)
|
||||
{
|
||||
y3 = y4;
|
||||
y4 = ((j+1)*(rows-1))/m_iColFir;
|
||||
@@ -326,27 +326,27 @@ inline void ccontour::generate()
|
||||
}
|
||||
|
||||
y4 = 0;
|
||||
for (j = 0; j < m_iColFir; j++)
|
||||
for (j = 0; j < m_iColFir; j++)
|
||||
{
|
||||
y3 = y4;
|
||||
y4 = ((j+1)*(rows-1))/m_iColFir;
|
||||
Pass2(oldx3,x3,y3,y4);
|
||||
}
|
||||
|
||||
if (i < (m_iRowFir-1))
|
||||
if (i < (m_iRowFir-1))
|
||||
{ /* re-use columns no longer needed */
|
||||
oldx3 = x3;
|
||||
x3 = x4;
|
||||
x4 = ((i+2)*(cols-1))/m_iRowFir;
|
||||
for (x = x3+1; x <= x4; x++)
|
||||
for (x = x3+1; x <= x4; x++)
|
||||
{
|
||||
if (xlow < oldx3)
|
||||
if (xlow < oldx3)
|
||||
{
|
||||
if (m_ppFnData[x])
|
||||
delete[] m_ppFnData[x];
|
||||
m_ppFnData[x] = m_ppFnData[xlow];
|
||||
m_ppFnData[ xlow++ ] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (m_ppFnData[x]==NULL)
|
||||
m_ppFnData[x] = new CFnStr[rows];
|
||||
@@ -358,7 +358,7 @@ inline void ccontour::generate()
|
||||
}
|
||||
|
||||
y4 = 0;
|
||||
for (j = 0; j < m_iColFir; j++)
|
||||
for (j = 0; j < m_iColFir; j++)
|
||||
{
|
||||
y3 = y4;
|
||||
y4 = ((j+1)*(rows-1))/m_iColFir;
|
||||
@@ -370,7 +370,7 @@ inline void ccontour::Cntr1(int x1, int x2, int y1, int y2)
|
||||
{
|
||||
double f11, f12, f21, f22, f33;
|
||||
int x3, y3, i, j;
|
||||
|
||||
|
||||
if ((x1 == x2) || (y1 == y2)) /* if not a real cell, punt */
|
||||
return;
|
||||
f11 = Field(x1, y1);
|
||||
@@ -387,7 +387,7 @@ inline void ccontour::Cntr1(int x1, int x2, int y1, int y2)
|
||||
if (f33 < f21) i++; else if (f33 > f21) j++;
|
||||
if (f33 < f22) i++; else if (f33 > f22) j++;
|
||||
if ((i > 2) || (j > 2)) /* should we divide cell? */
|
||||
{
|
||||
{
|
||||
/* subdivide cell */
|
||||
Cntr1(x1, x3, y1, y3);
|
||||
Cntr1(x3, x2, y1, y3);
|
||||
@@ -408,7 +408,7 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
double v, f11, f12, f21, f22, f33, fold, fnew, f;
|
||||
double xoff=m_pLimits[0];
|
||||
double yoff=m_pLimits[2];
|
||||
|
||||
|
||||
if ((x1 == x2) || (y1 == y2)) /* if not a real cell, punt */
|
||||
return;
|
||||
f11 = FnctData(x1,y1)->m_dFnVal;
|
||||
@@ -416,7 +416,7 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
f21 = FnctData(x2,y1)->m_dFnVal;
|
||||
f22 = FnctData(x2,y2)->m_dFnVal;
|
||||
if ((x2 > x1+1) || (y2 > y1+1)) /* is cell divisible? */
|
||||
{
|
||||
{
|
||||
x3 = (x1+x2)/2;
|
||||
y3 = (y1+y2)/2;
|
||||
f33 = FnctData(x3, y3)->m_dFnVal;
|
||||
@@ -425,8 +425,8 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
if (f33 < f12) i++; else if (f33 > f12) j++;
|
||||
if (f33 < f21) i++; else if (f33 > f21) j++;
|
||||
if (f33 < f22) i++; else if (f33 > f22) j++;
|
||||
if ((i > 2) || (j > 2)) /* should we divide cell? */
|
||||
{
|
||||
if ((i > 2) || (j > 2)) /* should we divide cell? */
|
||||
{
|
||||
/* subdivide cell */
|
||||
Pass2(x1, x3, y1, y3);
|
||||
Pass2(x3, x2, y1, y3);
|
||||
@@ -436,7 +436,7 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)m_vPlanes.size(); i++)
|
||||
for (i = 0; i < (int)m_vPlanes.size(); i++)
|
||||
{
|
||||
v = m_vPlanes[i];
|
||||
j = 0;
|
||||
@@ -444,14 +444,14 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
if (f11 > v) j |= 2;
|
||||
if (f22 > v) j |= 4;
|
||||
if (f12 > v) j |= 010;
|
||||
if ((f11 > v) ^ (f12 > v))
|
||||
if ((f11 > v) ^ (f12 > v))
|
||||
{
|
||||
if ((FnctData(x1,y1)->m_sLeftLen != 0) &&
|
||||
(FnctData(x1,y1)->m_sLeftLen < FnctData(x1,y1)->m_sRightLen))
|
||||
(FnctData(x1,y1)->m_sLeftLen < FnctData(x1,y1)->m_sRightLen))
|
||||
{
|
||||
old = y1;
|
||||
fold = f11;
|
||||
while (1)
|
||||
while (1)
|
||||
{
|
||||
iNew = old+FnctData(x1,old)->m_sLeftLen;
|
||||
fnew = FnctData(x1,iNew)->m_dFnVal;
|
||||
@@ -461,20 +461,20 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
fold = fnew;
|
||||
}
|
||||
yy0 = ((old-y1)+(iNew-old)*(v-fold)/(fnew-fold))/(y2-y1);
|
||||
}
|
||||
}
|
||||
else
|
||||
yy0 = (v-f11)/(f12-f11);
|
||||
|
||||
left = (int)(y1+(y2-y1)*yy0+0.5);
|
||||
}
|
||||
if ((f21 > v) ^ (f22 > v))
|
||||
if ((f21 > v) ^ (f22 > v))
|
||||
{
|
||||
if ((FnctData(x2,y1)->m_sRightLen != 0) &&
|
||||
(FnctData(x2,y1)->m_sRightLen < FnctData(x2,y1)->m_sLeftLen))
|
||||
(FnctData(x2,y1)->m_sRightLen < FnctData(x2,y1)->m_sLeftLen))
|
||||
{
|
||||
old = y1;
|
||||
fold = f21;
|
||||
while (1)
|
||||
while (1)
|
||||
{
|
||||
iNew = old+FnctData(x2,old)->m_sRightLen;
|
||||
fnew = FnctData(x2,iNew)->m_dFnVal;
|
||||
@@ -484,13 +484,13 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
fold = fnew;
|
||||
}
|
||||
yy1 = ((old-y1)+(iNew-old)*(v-fold)/(fnew-fold))/(y2-y1);
|
||||
}
|
||||
}
|
||||
else
|
||||
yy1 = (v-f21)/(f22-f21);
|
||||
|
||||
right = (int)(y1+(y2-y1)*yy1+0.5);
|
||||
}
|
||||
if ((f21 > v) ^ (f11 > v))
|
||||
if ((f21 > v) ^ (f11 > v))
|
||||
{
|
||||
if ((FnctData(x1,y1)->m_sBotLen != 0) &&
|
||||
(FnctData(x1,y1)->m_sBotLen < FnctData(x1,y1)->m_sTopLen)) {
|
||||
@@ -505,13 +505,13 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
fold = fnew;
|
||||
}
|
||||
xx0 = ((old-x1)+(iNew-old)*(v-fold)/(fnew-fold))/(x2-x1);
|
||||
}
|
||||
}
|
||||
else
|
||||
xx0 = (v-f11)/(f21-f11);
|
||||
|
||||
bot = (int)(x1+(x2-x1)*xx0+0.5);
|
||||
}
|
||||
if ((f22 > v) ^ (f12 > v))
|
||||
if ((f22 > v) ^ (f12 > v))
|
||||
{
|
||||
if ((FnctData(x1,y2)->m_sTopLen != 0) &&
|
||||
(FnctData(x1,y2)->m_sTopLen < FnctData(x1,y2)->m_sBotLen)) {
|
||||
@@ -526,14 +526,14 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
fold = fnew;
|
||||
}
|
||||
xx1 = ((old-x1)+(iNew-old)*(v-fold)/(fnew-fold))/(x2-x1);
|
||||
}
|
||||
}
|
||||
else
|
||||
xx1 = (v-f12)/(f22-f12);
|
||||
|
||||
top = (int)(x1+(x2-x1)*xx1+0.5);
|
||||
}
|
||||
|
||||
switch (j)
|
||||
switch (j)
|
||||
{
|
||||
case 7:
|
||||
case 010:
|
||||
@@ -589,7 +589,7 @@ inline void ccontour::Pass2(int x1, int x2, int y1, int y2)
|
||||
inline double ccontour::Field(int x, int y) /* evaluate funct if we must,*/
|
||||
{
|
||||
double x1, y1;
|
||||
|
||||
|
||||
if (FnctData(x,y)->m_sTopLen != -1) /* is it already in the array */
|
||||
return(FnctData(x,y)->m_dFnVal);
|
||||
|
||||
@@ -604,15 +604,15 @@ inline double ccontour::Field(int x, int y) /* evaluate funct if we must,*/
|
||||
}
|
||||
|
||||
inline void ccontour::set_planes(const std::vector<double>& vPlanes)
|
||||
{
|
||||
{
|
||||
// cleaning memory
|
||||
CleanMemory();
|
||||
|
||||
m_vPlanes = vPlanes;
|
||||
}
|
||||
|
||||
inline void ccontour::set_field_fcn(double (*_pFieldFcn)(double, double,void*),void* aData)
|
||||
{
|
||||
inline void ccontour::set_field_fcn(double (*_pFieldFcn)(double, double,void*),void* aData)
|
||||
{
|
||||
m_pFieldFcnData = aData;
|
||||
m_pFieldFcn=_pFieldFcn;
|
||||
}
|
||||
@@ -639,7 +639,7 @@ inline void ccontour::set_limits(double pLimits[])
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
m_pLimits[i]=pLimits[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void ccontour::get_limits(double pLimits[])
|
||||
|
||||
@@ -8,13 +8,13 @@ namespace tools {
|
||||
|
||||
// some char ASCII code :
|
||||
// \0 : 0
|
||||
// \n = LF : 10
|
||||
// \n = LF : 10
|
||||
// \r = CR : 13
|
||||
// \t = HT : 9
|
||||
// , : 44
|
||||
|
||||
inline bool is_upper(char a_char) {
|
||||
// do it myself: due to problem with ctype.h and
|
||||
// do it myself: due to problem with ctype.h and
|
||||
// isxxx macros on different platforms.
|
||||
switch(a_char) {
|
||||
case 'A':return true;
|
||||
@@ -98,15 +98,15 @@ inline bool is_digit(char a_char) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool is_letter(char a_char) {
|
||||
inline bool is_letter(char a_char) {
|
||||
return (is_lower(a_char)||is_upper(a_char)) ? true : false;
|
||||
}
|
||||
|
||||
//inline bool is_alpha(char a_char) {
|
||||
//inline bool is_alpha(char a_char) {
|
||||
// return (is_lower(a_char)||is_upper(a_char)||is_digit(a_char)) ? true : false;
|
||||
//}
|
||||
|
||||
inline bool is_printable(char a_char) {
|
||||
inline bool is_printable(char a_char) {
|
||||
if(is_lower(a_char)||is_upper(a_char)||is_digit(a_char)) return true;
|
||||
switch(a_char) {
|
||||
case ' ':return true;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace tools {
|
||||
|
||||
// some char ASCII code :
|
||||
// \0 : 0
|
||||
// \n = LF : 10
|
||||
// \n = LF : 10
|
||||
// \r = CR : 13
|
||||
// \t = HT : 9
|
||||
// , : 44
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef std::list<unsigned int> cline_strip;
|
||||
typedef std::list<cline_strip*> cline_strip_list;
|
||||
typedef std::vector<cline_strip_list> cline_strip_list_vector;
|
||||
|
||||
class clist_contour : public ccontour
|
||||
class clist_contour : public ccontour
|
||||
{
|
||||
public: //ccontour
|
||||
// Adding segment to line strips
|
||||
@@ -70,11 +70,11 @@ protected:
|
||||
// returns true if contour is touching boundary
|
||||
bool OnBoundary(cline_strip* pStrip);
|
||||
// L.Garnier : check specials case for CompactStrip
|
||||
bool SpecialCompactStripCase(double,double,double,double,double);
|
||||
bool SpecialCompactStripCase(double,double,double,double,double);
|
||||
|
||||
private:
|
||||
// array of line strips
|
||||
cline_strip_list_vector m_vStripLists;
|
||||
cline_strip_list_vector m_vStripLists;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
private:
|
||||
@@ -124,10 +124,10 @@ inline void clist_contour::generate()
|
||||
inline void clist_contour::InitMemory()
|
||||
{
|
||||
ccontour::InitMemory();
|
||||
|
||||
|
||||
cline_strip_list::iterator pos;
|
||||
cline_strip* pStrip;
|
||||
|
||||
|
||||
if (!m_vStripLists.empty())
|
||||
{
|
||||
UINT i;
|
||||
@@ -153,7 +153,7 @@ inline void clist_contour::InitMemory()
|
||||
inline void clist_contour::CleanMemory()
|
||||
{
|
||||
ccontour::CleanMemory();
|
||||
|
||||
|
||||
cline_strip_list::iterator pos;
|
||||
cline_strip* pStrip;
|
||||
UINT i;
|
||||
@@ -176,13 +176,13 @@ inline void clist_contour::ExportLine(int iPlane,int x1, int y1, int x2, int y2)
|
||||
{
|
||||
_ASSERT_(iPlane>=0,"clist_contour::ExportLine::0");
|
||||
_ASSERT_(iPlane<(int)get_number_of_planes(),"clist_contour::ExportLine::1");
|
||||
|
||||
|
||||
// check that the two points are not at the beginning or end of the some line strip
|
||||
UINT i1=y1*(m_iColSec+1)+x1;
|
||||
UINT i2=y2*(m_iColSec+1)+x2;
|
||||
|
||||
|
||||
cline_strip* pStrip;
|
||||
|
||||
|
||||
cline_strip_list::iterator pos;
|
||||
bool added = false;
|
||||
for(pos=m_vStripLists[iPlane].begin(); pos!=m_vStripLists[iPlane].end() && !added; pos++)
|
||||
@@ -211,7 +211,7 @@ inline void clist_contour::ExportLine(int iPlane,int x1, int y1, int x2, int y2)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// segment was not part of any line strip, creating new one
|
||||
pStrip=new cline_strip;
|
||||
pStrip->insert(pStrip->begin(),i1);
|
||||
@@ -219,15 +219,15 @@ inline void clist_contour::ExportLine(int iPlane,int x1, int y1, int x2, int y2)
|
||||
m_vStripLists[iPlane].insert(m_vStripLists[iPlane].begin(),pStrip);
|
||||
}
|
||||
|
||||
inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2,double aHeight)
|
||||
inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2,double aHeight)
|
||||
{
|
||||
|
||||
cline_strip::iterator pos;
|
||||
cline_strip::reverse_iterator rpos;
|
||||
|
||||
|
||||
if (pStrip2->empty())
|
||||
return false;
|
||||
|
||||
|
||||
double x[4], y[4], weldDist;
|
||||
int index;
|
||||
index = pStrip1->front();
|
||||
@@ -242,12 +242,12 @@ inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2
|
||||
index = pStrip2->back();
|
||||
x[3] = get_xi(index);
|
||||
y[3] = get_yi(index);
|
||||
|
||||
|
||||
weldDist = 10*(m_dDx*m_dDx+m_dDy*m_dDy);
|
||||
|
||||
|
||||
if (((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2])< weldDist)
|
||||
|| SpecialCompactStripCase(x[1],x[2],y[1],y[2],aHeight)) // L.Garnier
|
||||
|
||||
|
||||
{
|
||||
for (pos=pStrip2->begin(); pos!=pStrip2->end();pos++)
|
||||
{
|
||||
@@ -258,7 +258,7 @@ inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2
|
||||
pStrip2->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (((x[3]-x[0])*(x[3]-x[0])+(y[3]-y[0])*(y[3]-y[0])< weldDist)
|
||||
|| SpecialCompactStripCase(x[3],x[0],y[3],y[0],aHeight)) // L.Garnier
|
||||
{
|
||||
@@ -271,7 +271,7 @@ inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2
|
||||
pStrip2->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (((x[1]-x[3])*(x[1]-x[3])+(y[1]-y[3])*(y[1]-y[3])< weldDist)
|
||||
|| SpecialCompactStripCase(x[1],x[3],y[1],y[3],aHeight)) // L.Garnier
|
||||
{
|
||||
@@ -307,7 +307,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
|
||||
cline_strip::reverse_iterator rpos;
|
||||
if (pStrip2->empty())
|
||||
return false;
|
||||
|
||||
|
||||
int index;
|
||||
|
||||
// debugging stuff
|
||||
@@ -325,7 +325,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
|
||||
pStrip2->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (pStrip2->front()==pStrip1->back())
|
||||
{
|
||||
pStrip2->pop_front();
|
||||
@@ -339,7 +339,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
|
||||
pStrip2->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (pStrip2->back()==pStrip1->front())
|
||||
{
|
||||
pStrip2->pop_back();
|
||||
@@ -353,7 +353,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
|
||||
pStrip2->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (pStrip2->back()==pStrip1->back())
|
||||
{
|
||||
pStrip2->pop_back();
|
||||
@@ -367,7 +367,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
|
||||
pStrip2->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -378,8 +378,8 @@ inline bool clist_contour::compact_strips ()
|
||||
UINT i;
|
||||
cline_strip_list::iterator pos,pos2;
|
||||
cline_strip_list newList;
|
||||
bool again, changed;
|
||||
|
||||
bool again, changed;
|
||||
|
||||
const double weldDist = 10*(m_dDx*m_dDx+m_dDy*m_dDy);
|
||||
|
||||
if(!_ASSERT_RET_(m_vStripLists.size() == get_number_of_planes(),"clist_contour::compact_strips ::0")) return false;
|
||||
@@ -390,7 +390,7 @@ inline bool clist_contour::compact_strips ()
|
||||
while(again)
|
||||
{
|
||||
// REPEAT COMPACT PROCESS UNTILL LAST PROCESS MAKES NO CHANGE
|
||||
|
||||
|
||||
again=false;
|
||||
// building compacted list
|
||||
if(!_ASSERT_RET_(newList.empty(),"clist_contour::compact_strips ::1")) return false;
|
||||
@@ -411,7 +411,7 @@ inline bool clist_contour::compact_strips ()
|
||||
else
|
||||
newList.insert(newList.begin(),pStrip);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// deleting old list
|
||||
m_vStripLists[i].clear();
|
||||
@@ -421,7 +421,7 @@ inline bool clist_contour::compact_strips ()
|
||||
{
|
||||
pStrip2=(*pos2);
|
||||
cline_strip::iterator pos1 = pStrip2->begin(),pos3;
|
||||
while (pos1!=pStrip2->end())
|
||||
while (pos1!=pStrip2->end())
|
||||
{
|
||||
pos3 = pos1;
|
||||
pos3++;
|
||||
@@ -442,19 +442,19 @@ inline bool clist_contour::compact_strips ()
|
||||
else
|
||||
pos1++;
|
||||
}
|
||||
|
||||
|
||||
//if (!(pStrip2->front()==pStrip2->back() && pStrip2->size()==2))
|
||||
if (pStrip2->size()!=1)
|
||||
if (pStrip2->size()!=1)
|
||||
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStrip2 );
|
||||
else
|
||||
else
|
||||
delete pStrip2;
|
||||
}
|
||||
// emptying temp list
|
||||
newList.clear();
|
||||
|
||||
|
||||
} // OF WHILE(AGAIN) (LAST COMPACT PROCESS MADE NO CHANGES)
|
||||
|
||||
|
||||
|
||||
if (m_vStripLists[i].empty())
|
||||
continue;
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@@ -462,23 +462,23 @@ inline bool clist_contour::compact_strips ()
|
||||
int index,count;
|
||||
size_t Nstrip,j;
|
||||
|
||||
Nstrip = m_vStripLists[i].size();
|
||||
Nstrip = m_vStripLists[i].size();
|
||||
std::vector<bool> closed(Nstrip);
|
||||
double x,y;
|
||||
|
||||
// First let's find the open and closed lists in m_vStripLists
|
||||
for(pos2 = m_vStripLists[i].begin(), j=0, count=0; pos2 != m_vStripLists[i].end(); pos2++, j++)
|
||||
for(pos2 = m_vStripLists[i].begin(), j=0, count=0; pos2 != m_vStripLists[i].end(); pos2++, j++)
|
||||
{
|
||||
pStrip = (*pos2);
|
||||
|
||||
// is it open ?
|
||||
if (pStrip->front() != pStrip->back())
|
||||
if (pStrip->front() != pStrip->back())
|
||||
{
|
||||
index = pStrip->front();
|
||||
x = get_xi(index); y = get_yi(index);
|
||||
index = pStrip->back();
|
||||
x -= get_xi(index); y -= get_yi(index);
|
||||
|
||||
|
||||
// is it "almost closed" ?
|
||||
if ((x*x+y*y < weldDist) ||
|
||||
SpecialCompactStripCase(get_xi(pStrip->front()), // L.Garnier
|
||||
@@ -487,63 +487,63 @@ inline bool clist_contour::compact_strips ()
|
||||
get_yi(pStrip->back()),
|
||||
planeHeight))
|
||||
{
|
||||
closed[j] = true;
|
||||
closed[j] = true;
|
||||
// close it !!! Added by L.Garnier
|
||||
pStrip->push_back(pStrip->front());
|
||||
//
|
||||
}
|
||||
else
|
||||
{
|
||||
closed[j] = false;
|
||||
else
|
||||
{
|
||||
closed[j] = false;
|
||||
// updating not closed counter...
|
||||
count ++;
|
||||
count ++;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
closed[j] = true;
|
||||
}
|
||||
|
||||
|
||||
// is there any open strip ?
|
||||
if (count > 1)
|
||||
{
|
||||
if (count > 1)
|
||||
{
|
||||
// Merge the open strips into NewList
|
||||
pos = m_vStripLists[i].begin();
|
||||
for(j=0;j<Nstrip;j++)
|
||||
for(j=0;j<Nstrip;j++)
|
||||
{
|
||||
if (closed[j] == false )
|
||||
if (closed[j] == false )
|
||||
{
|
||||
pStrip = (*pos);
|
||||
newList.insert(newList.begin(),pStrip);
|
||||
newList.insert(newList.begin(),pStrip);
|
||||
pos = m_vStripLists[i].erase(pos);
|
||||
}
|
||||
else
|
||||
else
|
||||
pos ++;
|
||||
}
|
||||
|
||||
|
||||
// are they open strips to process ?
|
||||
while(newList.size()>1)
|
||||
while(newList.size()>1)
|
||||
{
|
||||
pStripBase = newList.front();
|
||||
|
||||
|
||||
// merge the rest to pStripBase
|
||||
again = true;
|
||||
while (again)
|
||||
while (again)
|
||||
{
|
||||
again = false;
|
||||
pos = newList.begin();
|
||||
for(pos++; pos!=newList.end();)
|
||||
pos = newList.begin();
|
||||
for(pos++; pos!=newList.end();)
|
||||
{
|
||||
pStrip = (*pos);
|
||||
changed = ForceMerge(pStripBase,pStrip,planeHeight);
|
||||
if (changed)
|
||||
{
|
||||
if (changed)
|
||||
{
|
||||
again = true;
|
||||
delete pStrip;
|
||||
pos = newList.erase(pos);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
pos ++;
|
||||
}
|
||||
}
|
||||
} // while(again)
|
||||
|
||||
index = pStripBase->front();
|
||||
@@ -568,15 +568,15 @@ inline bool clist_contour::compact_strips ()
|
||||
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
|
||||
newList.pop_front();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (OnBoundary(pStripBase))
|
||||
else
|
||||
{
|
||||
if (OnBoundary(pStripBase))
|
||||
{
|
||||
_TRACE_(_TT("# open strip ends on boundary, continue.\n"));
|
||||
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
|
||||
newList.pop_front();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
_PROBLEM_(_TT("unpaird open strip at 1!\n"));
|
||||
//exit(0);
|
||||
@@ -586,27 +586,27 @@ inline bool clist_contour::compact_strips ()
|
||||
} // while(newList.size()>1);
|
||||
|
||||
|
||||
if (newList.size() ==1)
|
||||
if (newList.size() ==1)
|
||||
{
|
||||
pStripBase = newList.front();
|
||||
index = pStripBase->front(); // L.Garnier
|
||||
x = get_xi(index); y = get_yi(index); // L.Garnier
|
||||
index = pStripBase->back(); // L.Garnier
|
||||
x -= get_xi(index); y -= get_yi(index); // L.Garnier
|
||||
|
||||
|
||||
// is it "almost closed", give last chance...5*weldDist
|
||||
if (x*x+y*y < 3*weldDist) // L.Garnier
|
||||
{
|
||||
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
|
||||
newList.pop_front();
|
||||
}
|
||||
else if (OnBoundary(pStripBase))
|
||||
else if (OnBoundary(pStripBase))
|
||||
{
|
||||
_TRACE_(_TT("# open strip ends on boundary, continue.\n"));
|
||||
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
|
||||
newList.pop_front();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
_PROBLEM_(_TT("unpaird open strip at 2!\n"));
|
||||
DumpPlane(i);
|
||||
@@ -614,16 +614,16 @@ inline bool clist_contour::compact_strips ()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
newList.clear();
|
||||
|
||||
}
|
||||
else if (count == 1)
|
||||
|
||||
}
|
||||
else if (count == 1)
|
||||
{
|
||||
pos = m_vStripLists[i].begin();
|
||||
for(j=0;j<Nstrip;j++)
|
||||
for(j=0;j<Nstrip;j++)
|
||||
{
|
||||
if (closed[j] == false )
|
||||
if (closed[j] == false )
|
||||
{
|
||||
pStripBase = (*pos);
|
||||
break;
|
||||
@@ -634,19 +634,19 @@ inline bool clist_contour::compact_strips ()
|
||||
x = get_xi(index); y = get_yi(index); // L.Garnier
|
||||
index = pStripBase->back(); // L.Garnier
|
||||
x -= get_xi(index); y -= get_yi(index); // L.Garnier
|
||||
|
||||
|
||||
// is it "almost closed", give last chance...5*weldDist
|
||||
if (x*x+y*y < 2*weldDist) // L.Garnier
|
||||
{
|
||||
//close it!!
|
||||
pStripBase->push_back(pStripBase->front()); // L.Garnier
|
||||
}
|
||||
else if (OnBoundary(pStripBase))
|
||||
else if (OnBoundary(pStripBase))
|
||||
{
|
||||
_TRACE_(_TT("# open strip ends on boundary, continue.\n"));
|
||||
pStripBase->push_back(pStripBase->front()); // L.Garnier
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
_TRACE_(_TT("unpaird open strip at 3!"));
|
||||
DumpPlane(i);
|
||||
@@ -660,26 +660,26 @@ inline bool clist_contour::compact_strips ()
|
||||
}
|
||||
|
||||
|
||||
inline bool clist_contour::OnBoundary(cline_strip* pStrip)
|
||||
inline bool clist_contour::OnBoundary(cline_strip* pStrip)
|
||||
{
|
||||
bool e1,e2;
|
||||
|
||||
int index = pStrip->front();
|
||||
double x = get_xi(index), y = get_yi(index);
|
||||
if (x==m_pLimits[0] || x == m_pLimits[1] ||
|
||||
if (x==m_pLimits[0] || x == m_pLimits[1] ||
|
||||
y == m_pLimits[2] || y == m_pLimits[3])
|
||||
e1 = true;
|
||||
else
|
||||
else
|
||||
e1 = false;
|
||||
|
||||
|
||||
index = pStrip->back();
|
||||
x = get_xi(index); y = get_yi(index);
|
||||
if (x==m_pLimits[0] || x == m_pLimits[1] ||
|
||||
if (x==m_pLimits[0] || x == m_pLimits[1] ||
|
||||
y == m_pLimits[2] || y == m_pLimits[3])
|
||||
e2 = true;
|
||||
else
|
||||
else
|
||||
e2 = false;
|
||||
|
||||
|
||||
return (e1 && e2);
|
||||
}
|
||||
|
||||
@@ -688,11 +688,11 @@ inline void clist_contour::DumpPlane(UINT iPlane) const
|
||||
cline_strip_list::const_iterator pos;
|
||||
UINT i;
|
||||
cline_strip* pStrip;
|
||||
|
||||
|
||||
/*_ASSERT_(iPlane>=0,"clist_contour::DumpPlane");*/
|
||||
_ASSERT_(iPlane<get_number_of_planes(),"clist_contour::DumpPlane::0");
|
||||
_TRACE_(_TT("Level : %d"),get_plane(iPlane));
|
||||
|
||||
|
||||
_TRACE_(_TT("Number of strips : %d\r\n"),m_vStripLists[iPlane].size());
|
||||
_TRACE_(_TT("i np start end xstart ystart xend yend\r\n"));
|
||||
for (pos = m_vStripLists[iPlane].begin(), i=0; pos != m_vStripLists[iPlane].end(); pos++, i++)
|
||||
@@ -705,38 +705,38 @@ inline void clist_contour::DumpPlane(UINT iPlane) const
|
||||
}
|
||||
}
|
||||
|
||||
inline double clist_contour::Area(cline_strip* Line)
|
||||
inline double clist_contour::Area(cline_strip* Line)
|
||||
{
|
||||
// if Line is not closed, return 0;
|
||||
|
||||
|
||||
double Ar = 0, x, y, x0,y0,x1, y1;
|
||||
int index;
|
||||
|
||||
|
||||
cline_strip::iterator pos;
|
||||
pos = Line->begin();
|
||||
index = (*pos);
|
||||
x0 = x = get_xi(index);
|
||||
y0 = y = get_yi(index);
|
||||
|
||||
|
||||
pos ++;
|
||||
|
||||
for(;pos!=Line->end();pos++)
|
||||
|
||||
for(;pos!=Line->end();pos++)
|
||||
{
|
||||
index = (*pos);
|
||||
index = (*pos);
|
||||
x1 = get_xi(index);
|
||||
y1 = get_yi(index);
|
||||
// Ar += (x1-x)*(y1+y);
|
||||
Ar += (y1-y)*(x1+x)-(x1-x)*(y1+y);
|
||||
x = x1;
|
||||
y = y1;
|
||||
|
||||
y = y1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Ar += (x0-x)*(y0+y);
|
||||
Ar += (y0-y)*(x0+x)-(x0-x)*(y0+y);
|
||||
// if not closed curve, return 0;
|
||||
if ((x0-x)*(x0-x) + (y0-y)*(y0-y)>20*(m_dDx*m_dDx+m_dDy*m_dDy))
|
||||
if ((x0-x)*(x0-x) + (y0-y)*(y0-y)>20*(m_dDx*m_dDx+m_dDy*m_dDy))
|
||||
{
|
||||
Ar = 0;
|
||||
_TRACE_(_TT("# open curve!\n"));
|
||||
@@ -747,38 +747,38 @@ inline double clist_contour::Area(cline_strip* Line)
|
||||
return Ar;
|
||||
}
|
||||
|
||||
inline double clist_contour:: EdgeWeight(cline_strip* pLine, double R)
|
||||
inline double clist_contour:: EdgeWeight(cline_strip* pLine, double R)
|
||||
{
|
||||
cline_strip::iterator pos;
|
||||
int count = 0,index;
|
||||
double x,y;
|
||||
for(pos = pLine->begin(); pos!=pLine->end(); pos++)
|
||||
for(pos = pLine->begin(); pos!=pLine->end(); pos++)
|
||||
{
|
||||
index = (*pos);
|
||||
x = get_xi(index);
|
||||
x = get_xi(index);
|
||||
y = get_yi(index);
|
||||
if (fabs(x) > R || fabs(y) > R)
|
||||
if (fabs(x) > R || fabs(y) > R)
|
||||
count ++;
|
||||
}
|
||||
return (double)count/pLine->size();
|
||||
}
|
||||
|
||||
/*
|
||||
inline bool clist_contour::PrintContour(std::ostream& a_out)
|
||||
inline bool clist_contour::PrintContour(std::ostream& a_out)
|
||||
{
|
||||
std::streamsize old_prec = a_out.precision(3);
|
||||
a_out << std::setprecision(10);
|
||||
|
||||
|
||||
UINT i, index;
|
||||
cline_strip* pStrip;
|
||||
cline_strip::iterator pos2;
|
||||
cline_strip_list::iterator pos;
|
||||
|
||||
|
||||
for(i=0;i<get_number_of_planes();i++) {
|
||||
for(pos = m_vStripLists[i].begin();pos!=m_vStripLists[i].end();pos++)
|
||||
for(pos = m_vStripLists[i].begin();pos!=m_vStripLists[i].end();pos++)
|
||||
{
|
||||
pStrip = (*pos);
|
||||
for(pos2 = pStrip->begin();pos2!=pStrip->end();pos2++)
|
||||
for(pos2 = pStrip->begin();pos2!=pStrip->end();pos2++)
|
||||
{
|
||||
index = (*pos2);
|
||||
a_out << get_xi(index)<<"\t"<<get_yi(index)<<"\n";
|
||||
@@ -788,7 +788,7 @@ inline bool clist_contour::PrintContour(std::ostream& a_out)
|
||||
}
|
||||
a_out.precision(old_prec);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -800,9 +800,9 @@ inline cline_strip_list* clist_contour::get_lines(unsigned int iPlane) {
|
||||
}
|
||||
|
||||
// Added by L.Garnier
|
||||
inline bool clist_contour::SpecialCompactStripCase(double aXfront,double aXback,double aYfront,double aYback,double actualHeight)
|
||||
inline bool clist_contour::SpecialCompactStripCase(double aXfront,double aXback,double aYfront,double aYback,double actualHeight)
|
||||
{
|
||||
// To solve the case of a list of strips
|
||||
// To solve the case of a list of strips
|
||||
// which appeared to be open but should correspond to a closed
|
||||
// contour.
|
||||
// With the today generate() algorithm, it appears that we fall
|
||||
@@ -810,7 +810,7 @@ inline bool clist_contour::SpecialCompactStripCase(double aXfront,double aXback,
|
||||
// are on a horizontal or vertical line.
|
||||
// (case where front()->x == back()->x or front()->y == back()->y).
|
||||
// We try to detect in this method this situation and decide to close
|
||||
// or not the line. To do that we check the heigth of intermediate
|
||||
// or not the line. To do that we check the heigth of intermediate
|
||||
// points to see if there are on the same contour; if so we close
|
||||
// the line (and return true), if not we do nothing (and return false).
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_cmathT
|
||||
#define tools_cmathT
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace tools {
|
||||
|
||||
//NOTE : const <type>& in args to be compatible and efficient with inlib::symbol.
|
||||
|
||||
//float
|
||||
inline float _pow(const float& a_x,const float& a_y) {return ::powf(a_x,a_y);}
|
||||
inline float _exp(const float& a_x) {return ::expf(a_x);}
|
||||
inline float _log(const float& a_x) {return ::logf(a_x);}
|
||||
inline float _sqrt(const float& a_x) {return ::sqrtf(a_x);}
|
||||
inline float _cos(const float& a_x) {return ::cosf(a_x);}
|
||||
inline float _sin(const float& a_x) {return ::sinf(a_x);}
|
||||
inline float _fabs(const float& a_x) {return ::fabsf(a_x);}
|
||||
inline float _tan(const float& a_x) {return ::tanf(a_x);}
|
||||
inline void _half_pi(float& a_v) {a_v = float(1.5707963267948965580E0);}
|
||||
inline void _pi(float& a_v) {a_v = float(3.1415926535897931160E0);}
|
||||
//inline float _conj(const float& a_x) {return a_x;}
|
||||
|
||||
//double
|
||||
inline double _pow(const double& a_x,const double& a_y) {return ::pow(a_x,a_y);}
|
||||
inline double _exp(const double& a_x) {return ::exp(a_x);}
|
||||
inline double _log(const double& a_x) {return ::log(a_x);}
|
||||
inline double _sqrt(const double& a_x) {return ::sqrt(a_x);}
|
||||
inline double _cos(const double& a_x) {return ::cos(a_x);}
|
||||
inline double _sin(const double& a_x) {return ::sin(a_x);}
|
||||
inline double _fabs(const double& a_x) {return ::fabs(a_x);}
|
||||
inline double _tan(const double& a_x) {return ::tan(a_x);}
|
||||
inline void _half_pi(double& a_v) {a_v = 1.5707963267948965580E0;}
|
||||
inline void _pi(double& a_v) {a_v = 3.1415926535897931160E0;}
|
||||
//inline double _conj(const double& a_x) {return a_x;}
|
||||
|
||||
//long double
|
||||
#ifndef ANDROID
|
||||
inline long double _pow(const long double& a_x,const long double& a_y) {return ::powl(a_x,a_y);}
|
||||
inline long double _exp(const long double& a_x) {return ::expl(a_x);}
|
||||
inline long double _log(const long double& a_x) {return ::logl(a_x);}
|
||||
inline long double _sqrt(const long double& a_x) {return ::sqrtl(a_x);}
|
||||
inline long double _cos(const long double& a_x) {return ::cosl(a_x);}
|
||||
inline long double _sin(const long double& a_x) {return ::sinl(a_x);}
|
||||
inline long double _fabs(const long double& a_x) {return ::fabsl(a_x);}
|
||||
inline long double _tan(const long double& a_x) {return ::tanl(a_x);}
|
||||
inline void _half_pi(long double& a_v) {a_v = 1.5707963267948965580E0;}
|
||||
inline void _pi(long double& a_v) {a_v = 3.1415926535897931160E0;}
|
||||
//inline long double _conj(const long double& a_x) {return a_x;}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -25,22 +25,22 @@ inline void cmem_free(T*& a_p){
|
||||
template <class T>
|
||||
inline T* cmem_alloc(size_t a_num){
|
||||
if(a_num<=0) return 0;
|
||||
T* p = (T*)::malloc(a_num*sizeof(T));
|
||||
T* p = (T*)::malloc(a_num*sizeof(T));
|
||||
if(!p) return 0;
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment("cmem");
|
||||
#endif
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T* cmem_alloc_copy(const T* a_from,size_t a_num){
|
||||
if(a_num<=0) return 0;
|
||||
T* p = (T*)::malloc(a_num*sizeof(T));
|
||||
T* p = (T*)::malloc(a_num*sizeof(T));
|
||||
if(!p) return 0;
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment("cmem");
|
||||
#endif
|
||||
#endif
|
||||
//::memcpy(p,a_from,a_num*sizeof(T));
|
||||
for(size_t i=0;i<a_num;i++) p[i] = a_from[i];
|
||||
return p;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace tools {
|
||||
|
||||
class colorf : public vec4f {
|
||||
class colorf : public vec4f {
|
||||
typedef vec4f parent;
|
||||
public: //for SWIG
|
||||
typedef unsigned char uchar;
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
colorf(float a_r,float a_g,float a_b,float a_a = 1,bool a_inc = true):parent(a_r,a_g,a_b,a_a,a_inc){}
|
||||
#else
|
||||
colorf(float a_r,float a_g,float a_b,float a_a = 1):parent(a_r,a_g,a_b,a_a){}
|
||||
#endif
|
||||
#endif
|
||||
virtual ~colorf() {}
|
||||
public:
|
||||
colorf(const colorf& a_from):parent(a_from){}
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
static colorf lightblue() {return colorf(0.675792F,0.843763F,0.898451F);}
|
||||
static colorf lightsteelblue() {return colorf(0.68751F,0.765637F,0.867201F);}
|
||||
static colorf mediumblue() {return colorf(0,0,0.800793F);}
|
||||
|
||||
|
||||
//10-19
|
||||
static colorf mediumslateblue() {return colorf(0.480476F,0.406256F,0.929702F);}
|
||||
static colorf midnightblue() {return colorf(0.0976577F,0.0976577F,0.437507F);}
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
static colorf coral() {return colorf(0.996109F,0.496101F,0.312505F);}
|
||||
static colorf cyan() {return colorf(0,1,1);}
|
||||
static colorf firebrick() {return colorf(0.695323F,0.132815F,0.132815F);}
|
||||
|
||||
|
||||
//20-29
|
||||
static colorf brown() {return colorf(0.644541F,0.164065F,0.164065F);}
|
||||
static colorf gold() {return colorf(0.996109F,0.839857F,0);}
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
static colorf limegreen() {return colorf(0.195315F,0.800793F,0.195315F);}
|
||||
static colorf mediumseagreen() {return colorf(0.234379F,0.699229F,0.441413F);}
|
||||
static colorf mediumspringgreen() {return colorf(0,0.976577F,0.601572F);}
|
||||
|
||||
|
||||
//30-39
|
||||
static colorf palegreen() {return colorf(0.593759F,0.980484F,0.593759F);}
|
||||
static colorf seagreen() {return colorf(0.17969F,0.542977F,0.339849F);}
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
static colorf red() {return colorf(1,0,0);}
|
||||
static colorf indianred() {return colorf(0.800793F,0.35938F,0.35938F);}
|
||||
static colorf mediumvioletred() {return colorf(0.777356F,0.0820325F,0.519539F);}
|
||||
|
||||
|
||||
//50-59
|
||||
static colorf orangered() {return colorf(0.996109F,0.269535F,0);}
|
||||
static colorf violetred() {return colorf(0.812512F,0.125002F,0.562509F);}
|
||||
|
||||
@@ -25,7 +25,7 @@ TOOLS_COLORFS_STAT(darkslateblue)
|
||||
TOOLS_COLORFS_STAT(lightblue)
|
||||
TOOLS_COLORFS_STAT(lightsteelblue)
|
||||
TOOLS_COLORFS_STAT(mediumblue)
|
||||
|
||||
|
||||
//10-19
|
||||
TOOLS_COLORFS_STAT(mediumslateblue)
|
||||
TOOLS_COLORFS_STAT(midnightblue)
|
||||
@@ -37,7 +37,7 @@ TOOLS_COLORFS_STAT(steelblue)
|
||||
TOOLS_COLORFS_STAT(coral)
|
||||
TOOLS_COLORFS_STAT(cyan)
|
||||
TOOLS_COLORFS_STAT(firebrick)
|
||||
|
||||
|
||||
//20-29
|
||||
TOOLS_COLORFS_STAT(brown)
|
||||
TOOLS_COLORFS_STAT(gold)
|
||||
@@ -49,7 +49,7 @@ TOOLS_COLORFS_STAT(forestgreen)
|
||||
TOOLS_COLORFS_STAT(limegreen)
|
||||
TOOLS_COLORFS_STAT(mediumseagreen)
|
||||
TOOLS_COLORFS_STAT(mediumspringgreen)
|
||||
|
||||
|
||||
//30-39
|
||||
TOOLS_COLORFS_STAT(palegreen)
|
||||
TOOLS_COLORFS_STAT(seagreen)
|
||||
@@ -73,7 +73,7 @@ TOOLS_COLORFS_STAT(plum)
|
||||
TOOLS_COLORFS_STAT(red)
|
||||
TOOLS_COLORFS_STAT(indianred)
|
||||
TOOLS_COLORFS_STAT(mediumvioletred)
|
||||
|
||||
|
||||
//50-59
|
||||
TOOLS_COLORFS_STAT(orangered)
|
||||
TOOLS_COLORFS_STAT(violetred)
|
||||
|
||||
@@ -23,7 +23,7 @@ TOOLS_COLORS_SET(darkslateblue,0.281254F,0.238285F,0.542977F)
|
||||
TOOLS_COLORS_SET(lightblue,0.675792F,0.843763F,0.898451F)
|
||||
TOOLS_COLORS_SET(lightsteelblue,0.68751F,0.765637F,0.867201F)
|
||||
TOOLS_COLORS_SET(mediumblue,0,0,0.800793F)
|
||||
|
||||
|
||||
//10-19
|
||||
TOOLS_COLORS_SET(mediumslateblue,0.480476F,0.406256F,0.929702F)
|
||||
TOOLS_COLORS_SET(midnightblue,0.0976577F,0.0976577F,0.437507F)
|
||||
@@ -35,7 +35,7 @@ TOOLS_COLORS_SET(steelblue,0.273442F,0.50782F,0.703136F)
|
||||
TOOLS_COLORS_SET(coral,0.996109F,0.496101F,0.312505F)
|
||||
TOOLS_COLORS_SET(cyan,0,1,1)
|
||||
TOOLS_COLORS_SET(firebrick,0.695323F,0.132815F,0.132815F)
|
||||
|
||||
|
||||
//20-29
|
||||
TOOLS_COLORS_SET(brown,0.644541F,0.164065F,0.164065F)
|
||||
TOOLS_COLORS_SET(gold,0.996109F,0.839857F,0)
|
||||
@@ -47,7 +47,7 @@ TOOLS_COLORS_SET(forestgreen,0.132815F,0.542977F,0.132815F)
|
||||
TOOLS_COLORS_SET(limegreen,0.195315F,0.800793F,0.195315F)
|
||||
TOOLS_COLORS_SET(mediumseagreen,0.234379F,0.699229F,0.441413F)
|
||||
TOOLS_COLORS_SET(mediumspringgreen,0,0.976577F,0.601572F)
|
||||
|
||||
|
||||
//30-39
|
||||
TOOLS_COLORS_SET(palegreen,0.593759F,0.980484F,0.593759F)
|
||||
TOOLS_COLORS_SET(seagreen,0.17969F,0.542977F,0.339849F)
|
||||
@@ -71,7 +71,7 @@ TOOLS_COLORS_SET(plum,0.863294F,0.62501F,0.863294F)
|
||||
TOOLS_COLORS_SET(red,1,0,0)
|
||||
TOOLS_COLORS_SET(indianred,0.800793F,0.35938F,0.35938F)
|
||||
TOOLS_COLORS_SET(mediumvioletred,0.777356F,0.0820325F,0.519539F)
|
||||
|
||||
|
||||
//50-59
|
||||
TOOLS_COLORS_SET(orangered,0.996109F,0.269535F,0)
|
||||
TOOLS_COLORS_SET(violetred,0.812512F,0.125002F,0.562509F)
|
||||
@@ -114,7 +114,7 @@ TOOLS_COLORS_STAT(darkslateblue,0.281254F,0.238285F,0.542977F)
|
||||
TOOLS_COLORS_STAT(lightblue,0.675792F,0.843763F,0.898451F)
|
||||
TOOLS_COLORS_STAT(lightsteelblue,0.68751F,0.765637F,0.867201F)
|
||||
TOOLS_COLORS_STAT(mediumblue,0,0,0.800793F)
|
||||
|
||||
|
||||
//10-19
|
||||
TOOLS_COLORS_STAT(mediumslateblue,0.480476F,0.406256F,0.929702F)
|
||||
TOOLS_COLORS_STAT(midnightblue,0.0976577F,0.0976577F,0.437507F)
|
||||
@@ -126,7 +126,7 @@ TOOLS_COLORS_STAT(steelblue,0.273442F,0.50782F,0.703136F)
|
||||
TOOLS_COLORS_STAT(coral,0.996109F,0.496101F,0.312505F)
|
||||
TOOLS_COLORS_STAT(cyan,0,1,1)
|
||||
TOOLS_COLORS_STAT(firebrick,0.695323F,0.132815F,0.132815F)
|
||||
|
||||
|
||||
//20-29
|
||||
TOOLS_COLORS_STAT(brown,0.644541F,0.164065F,0.164065F)
|
||||
TOOLS_COLORS_STAT(gold,0.996109F,0.839857F,0)
|
||||
@@ -138,7 +138,7 @@ TOOLS_COLORS_STAT(forestgreen,0.132815F,0.542977F,0.132815F)
|
||||
TOOLS_COLORS_STAT(limegreen,0.195315F,0.800793F,0.195315F)
|
||||
TOOLS_COLORS_STAT(mediumseagreen,0.234379F,0.699229F,0.441413F)
|
||||
TOOLS_COLORS_STAT(mediumspringgreen,0,0.976577F,0.601572F)
|
||||
|
||||
|
||||
//30-39
|
||||
TOOLS_COLORS_STAT(palegreen,0.593759F,0.980484F,0.593759F)
|
||||
TOOLS_COLORS_STAT(seagreen,0.17969F,0.542977F,0.339849F)
|
||||
@@ -162,7 +162,7 @@ TOOLS_COLORS_STAT(plum,0.863294F,0.62501F,0.863294F)
|
||||
TOOLS_COLORS_STAT(red,1,0,0)
|
||||
TOOLS_COLORS_STAT(indianred,0.800793F,0.35938F,0.35938F)
|
||||
TOOLS_COLORS_STAT(mediumvioletred,0.777356F,0.0820325F,0.519539F)
|
||||
|
||||
|
||||
//50-59
|
||||
TOOLS_COLORS_STAT(orangered,0.996109F,0.269535F,0)
|
||||
TOOLS_COLORS_STAT(violetred,0.812512F,0.125002F,0.562509F)
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
} else if(c=='{') {
|
||||
tree* _tree = new tree(prev,s);
|
||||
s.clear();
|
||||
|
||||
|
||||
prev = _tree;
|
||||
} else if(c=='}') {
|
||||
if(s.size()) {
|
||||
@@ -124,7 +124,7 @@ namespace columns {
|
||||
inline void delete_columns(std::vector<value>& a_vars) {
|
||||
tools_vforit(value,a_vars,it) {
|
||||
if((*it).type()==value::VOID_STAR) {
|
||||
std::vector<value>* vars =
|
||||
std::vector<value>* vars =
|
||||
(std::vector<value>*)(*it).get_void_star();
|
||||
delete_columns(*vars);
|
||||
delete vars;
|
||||
@@ -141,8 +141,8 @@ inline void copy_columns(const std::vector<value>& a_from,std::vector<value>& a_
|
||||
value v((void*)vars);
|
||||
v.set_label((*it).label());
|
||||
a_to.push_back(v);
|
||||
std::vector<value>* p =
|
||||
(std::vector<value>*)(*it).get_void_star();
|
||||
std::vector<value>* p =
|
||||
(std::vector<value>*)(*it).get_void_star();
|
||||
copy_columns(*p,*vars);
|
||||
} else {
|
||||
a_to.push_back(*it);
|
||||
@@ -163,14 +163,14 @@ inline void dump_columns(std::ostream& a_out,const std::vector<value>& a_vars,co
|
||||
// << "ITuple : " << (*it).label() << " : end "
|
||||
// << std::endl;
|
||||
} else {
|
||||
std::string stype;
|
||||
std::string stype;
|
||||
(*it).s_type(stype);
|
||||
std::string sval;
|
||||
std::string sval;
|
||||
(*it).tos(sval);
|
||||
|
||||
a_out << a_margin
|
||||
<< stype << " : "
|
||||
<< (*it).label() << " : "
|
||||
<< stype << " : "
|
||||
<< (*it).label() << " : "
|
||||
<< sval
|
||||
<< std::endl;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ inline void dump_columns(std::ostream& a_out,const std::vector<value>& a_vars,co
|
||||
class finder : public columns::parser {
|
||||
typedef columns::parser parent;
|
||||
public:
|
||||
finder(std::ostream& a_out,const std::string& a_script)
|
||||
finder(std::ostream& a_out,const std::string& a_script)
|
||||
:m_out(a_out)
|
||||
,m_script(a_script)
|
||||
//,fSuccess(false)
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
bool find_variables() {
|
||||
clear();
|
||||
if(m_script.empty()) return false; //keep old version logic.
|
||||
if(!parse(m_script)) return false;
|
||||
if(!parse(m_script)) return false;
|
||||
//dump(m_out);
|
||||
//analyse m_top :
|
||||
if(!analyse(m_top,m_stack)) {clear();return false;}
|
||||
@@ -267,14 +267,14 @@ protected:
|
||||
strip(swords[1]);
|
||||
|
||||
if(swords[0]=="ITuple") {
|
||||
|
||||
|
||||
//create a value::VOID_STAR :
|
||||
value* v = new value((void*)0);
|
||||
v->set_label(swords[1]);
|
||||
return v;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
value::e_type type;
|
||||
if(!s2type(swords[0],type)){
|
||||
m_out << "tools::columns::finder::analyse_dcl :"
|
||||
@@ -335,7 +335,7 @@ protected:
|
||||
strip(swords[1]);
|
||||
|
||||
if(swords[0]=="ITuple") {
|
||||
|
||||
|
||||
//create a value::VOID_STAR :
|
||||
value* v = new value((void*)0);
|
||||
v->set_label(swords[1]);
|
||||
@@ -372,7 +372,7 @@ protected:
|
||||
}
|
||||
|
||||
value* v = new value();
|
||||
v->set_type(m_cur_type);
|
||||
v->set_type(m_cur_type);
|
||||
v->set_label(swords[0]);
|
||||
return v;
|
||||
|
||||
@@ -395,23 +395,23 @@ protected:
|
||||
protected:
|
||||
static bool s2type(const std::string& a_s,value::e_type& a_type){
|
||||
if(a_s=="float") {
|
||||
a_type = value::FLOAT;
|
||||
a_type = value::FLOAT;
|
||||
} else if(a_s=="double") {
|
||||
a_type = value::DOUBLE;
|
||||
a_type = value::DOUBLE;
|
||||
//} else if(a_s=="char") {
|
||||
// a_type = value::CHAR;
|
||||
// a_type = value::CHAR;
|
||||
} else if(a_s=="short") {
|
||||
a_type = value::SHORT;
|
||||
a_type = value::SHORT;
|
||||
} else if(a_s=="int") {
|
||||
a_type = value::INT;
|
||||
a_type = value::INT;
|
||||
} else if(a_s=="long") {
|
||||
a_type = value::INT64;
|
||||
a_type = value::INT64;
|
||||
} else if((a_s=="bool")||(a_s=="boolean")) {
|
||||
a_type = value::BOOL;
|
||||
a_type = value::BOOL;
|
||||
} else if((a_s=="string")||(a_s=="java.lang.String")){
|
||||
a_type = value::STRING;
|
||||
a_type = value::STRING;
|
||||
//} else if(a_s=="byte") {
|
||||
// a_type = value::UNSIGNED_CHAR;
|
||||
// a_type = value::UNSIGNED_CHAR;
|
||||
|
||||
} else if(a_s=="float[]") {
|
||||
a_type = value::ARRAY_FLOAT;
|
||||
@@ -434,13 +434,13 @@ protected:
|
||||
|
||||
// not AIDA :
|
||||
//} else if(a_s=="uchar") {
|
||||
// a_type = value::UNSIGNED_CHAR;
|
||||
// a_type = value::UNSIGNED_CHAR;
|
||||
} else if(a_s=="ushort") {
|
||||
a_type = value::UNSIGNED_SHORT;
|
||||
a_type = value::UNSIGNED_SHORT;
|
||||
} else if(a_s=="uint") {
|
||||
a_type = value::UNSIGNED_INT;
|
||||
a_type = value::UNSIGNED_INT;
|
||||
} else if(a_s=="ulong") {
|
||||
a_type = value::UNSIGNED_INT64;
|
||||
a_type = value::UNSIGNED_INT64;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -450,62 +450,62 @@ protected:
|
||||
if(a_type==value::FLOAT) {
|
||||
float v = 0;
|
||||
if(a_v.size()) {if(!to<float>(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
} else if(a_type==value::DOUBLE) {
|
||||
double v = 0;
|
||||
if(a_v.size()) {if(!to<double>(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
//} else if(a_type==value::CHAR) {
|
||||
// char v = 0;
|
||||
// if(a_v.size()) {if(!to<char>(a_v,v)) return 0;}
|
||||
// return new value(v);
|
||||
// return new value(v);
|
||||
} else if(a_type==value::SHORT) {
|
||||
short v = 0;
|
||||
if(a_v.size()) {if(!to<short>(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
} else if(a_type==value::INT) {
|
||||
int v = 0;
|
||||
if(a_v.size()) {if(!to<int>(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
|
||||
} else if(a_type==value::INT64) {
|
||||
int64 v = 0;
|
||||
if(a_v.size()) {if(!to<int64>(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
} else if(a_type==value::BOOL) {
|
||||
bool v = false;
|
||||
if(a_v.size()) {if(!to(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
|
||||
} else if(a_type==value::STRING) {
|
||||
if( (a_v.size()>=2) && (a_v[0]=='"') && (a_v[a_v.size()-1]=='"') ){
|
||||
return new value(a_v.substr(1,a_v.size()-2));
|
||||
} else {
|
||||
return new value(a_v);
|
||||
return new value(a_v);
|
||||
}
|
||||
|
||||
//} else if(a_type==value::UNSIGNED_CHAR) {
|
||||
// unsigned short v = 0;
|
||||
// if(a_v.size()) {if(!to<unsigned short>(a_v,v)) return 0;}
|
||||
// return new value((unsigned char)v);
|
||||
// return new value((unsigned char)v);
|
||||
|
||||
} else if(a_type==value::UNSIGNED_SHORT) {
|
||||
unsigned short v = 0;
|
||||
if(a_v.size()) {if(!to<unsigned short>(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
} else if(a_type==value::UNSIGNED_INT) {
|
||||
unsigned int v = 0;
|
||||
if(a_v.size()) {if(!to<unsigned int>(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
|
||||
} else if(a_type==value::UNSIGNED_INT64) {
|
||||
uint64 v = 0;
|
||||
if(a_v.size()) {if(!to<uint64>(a_v,v)) return 0;}
|
||||
return new value(v);
|
||||
return new value(v);
|
||||
|
||||
} else if(a_type==value::ARRAY_FLOAT) {
|
||||
if(a_v.size()) return 0;
|
||||
value* v = new value();
|
||||
value* v = new value();
|
||||
v->set_type(value::ARRAY_FLOAT);
|
||||
return v;
|
||||
} else if(a_type==value::ARRAY_DOUBLE) {
|
||||
|
||||
@@ -30,15 +30,15 @@ inline const std::string& s_cstr() {
|
||||
inline char* str_dup(const char* a_cstr
|
||||
#ifdef TOOLS_MEM
|
||||
,bool a_inc = true
|
||||
#endif
|
||||
#endif
|
||||
) {
|
||||
#ifdef TOOLS_MEM
|
||||
if(a_inc) {
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_dup \"%s\"\n",a_cstr);
|
||||
#endif
|
||||
#endif
|
||||
mem::increment(s_cstr().c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ::strcpy((char*)::malloc(::strlen(a_cstr)+1),a_cstr);
|
||||
}
|
||||
@@ -46,15 +46,15 @@ inline char* str_dup(const char* a_cstr
|
||||
inline char* str_from_buffer(const char* a_buffer,size_t a_len
|
||||
#ifdef TOOLS_MEM
|
||||
,bool a_inc = true
|
||||
#endif
|
||||
#endif
|
||||
) {
|
||||
#ifdef TOOLS_MEM
|
||||
if(a_inc) {
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_from_buffer.\n");
|
||||
#endif
|
||||
#endif
|
||||
mem::increment(s_cstr().c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
char* s = (char*)::malloc(a_len+1);
|
||||
if(s==NULL) return NULL;
|
||||
@@ -68,7 +68,7 @@ inline void str_del(char*& a_cstr) {
|
||||
#ifdef TOOLS_MEM
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_del \"%s\"\n",a_cstr);
|
||||
#endif
|
||||
#endif
|
||||
mem::decrement(s_cstr().c_str());
|
||||
#endif
|
||||
::free(a_cstr);
|
||||
@@ -81,10 +81,10 @@ inline char* str_new(size_t a_l = 0,char a_char = ' ') {
|
||||
#ifdef TOOLS_MEM
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_new : len %lu\n",a_l);
|
||||
#endif
|
||||
#endif
|
||||
mem::increment(s_cstr().c_str());
|
||||
#endif
|
||||
char* pos = s;
|
||||
char* pos = s;
|
||||
for(size_t c=0;c<a_l;c++,pos++) *pos = a_char;
|
||||
*(s+a_l) = 0;
|
||||
return s;
|
||||
@@ -97,7 +97,7 @@ inline bool str_cat(char*& a_1,const char a_c) {
|
||||
#ifdef TOOLS_MEM
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_cat \"%s\", char %d\n",a_1,a_c);
|
||||
#endif
|
||||
#endif
|
||||
mem::increment(s_cstr().c_str());
|
||||
#endif
|
||||
::memcpy(s,a_1,l1);
|
||||
@@ -107,7 +107,7 @@ inline bool str_cat(char*& a_1,const char a_c) {
|
||||
#ifdef TOOLS_MEM
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_cat : dec\n");
|
||||
#endif
|
||||
#endif
|
||||
mem::decrement(s_cstr().c_str());
|
||||
#endif
|
||||
a_1 = s;
|
||||
@@ -122,7 +122,7 @@ inline bool str_cat(char*& a_1,const char* a_2) {
|
||||
#ifdef TOOLS_MEM
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_cat \"%s\" \"%s\"\n",a_1,a_2);
|
||||
#endif
|
||||
#endif
|
||||
mem::increment(s_cstr().c_str());
|
||||
#endif
|
||||
::memcpy(s,a_1,l1);
|
||||
@@ -132,7 +132,7 @@ inline bool str_cat(char*& a_1,const char* a_2) {
|
||||
#ifdef TOOLS_MEM
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_cat : dec\n");
|
||||
#endif
|
||||
#endif
|
||||
mem::decrement(s_cstr().c_str());
|
||||
#endif
|
||||
a_1 = s;
|
||||
@@ -146,9 +146,9 @@ inline void str_rev(char* a_s) {
|
||||
char* end = a_s+l-1;
|
||||
for(size_t i=0;i<hl;i++) {
|
||||
char c = *end;
|
||||
*end = *beg;
|
||||
*end = *beg;
|
||||
*beg = c;
|
||||
beg++;end--;
|
||||
beg++;end--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ inline char* str_sub(const char* a_s,
|
||||
#ifdef TOOLS_MEM
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_sub \"%s\"\n",a_s);
|
||||
#endif
|
||||
#endif
|
||||
mem::increment(s_cstr().c_str());
|
||||
#endif
|
||||
//abcdefgh l=8
|
||||
@@ -187,7 +187,7 @@ inline char* str_rep(const char* a_s,unsigned int a_pos,unsigned int a_sz,const
|
||||
unsigned int num = a_sz<lan?a_sz:(unsigned int)lan;
|
||||
//abcdefghij : l = 10
|
||||
//0123456789
|
||||
// p
|
||||
// p
|
||||
size_t le = las-(a_pos+a_sz);
|
||||
size_t ls = a_pos+num+le;
|
||||
char* s = (char*)::malloc(ls+1);
|
||||
@@ -195,7 +195,7 @@ inline char* str_rep(const char* a_s,unsigned int a_pos,unsigned int a_sz,const
|
||||
#ifdef TOOLS_MEM
|
||||
#ifdef TOOLS_CSTR_DEBUG_MEM
|
||||
::printf("debug : str_rep \"%s\"\n",a_s);
|
||||
#endif
|
||||
#endif
|
||||
mem::increment(s_cstr().c_str());
|
||||
#endif
|
||||
::memcpy(s,a_s,a_pos);
|
||||
@@ -273,10 +273,10 @@ inline size_t str_lcpy(char *dst, const char *src, size_t siz) {
|
||||
// Copy src to string dst of size siz. At most siz-1 characters
|
||||
// will be copied. Always NUL terminates (unless siz == 0).
|
||||
// Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
|
||||
|
||||
// code taken from CERN-ROOT/core/clib to compile exlib/tests/h2root.cpp.
|
||||
// strlcpy, strlcat are in string.h on BSD based systems.
|
||||
|
||||
|
||||
// Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>.
|
||||
|
||||
/*register*/ char* d = dst;
|
||||
@@ -308,7 +308,7 @@ inline size_t str_lcat(char *dst, const char *src, size_t siz) {
|
||||
|
||||
// code taken from CERN-ROOT/core/clib to compile exlib/tests/h2root.cpp.
|
||||
// strlcpy, strlcat are in string.h on BSD based systems.
|
||||
|
||||
|
||||
// Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>.
|
||||
|
||||
/*register*/ char* d = dst;
|
||||
@@ -342,7 +342,7 @@ inline bool str_2ds(char* a_s,const char* a_sep,VECTOR& a_v) {
|
||||
double d;
|
||||
for (tok = ::strtok(a_s,a_sep);tok && *tok;tok = ::strtok(NULL,a_sep)) {
|
||||
if(!str_2d(tok,d)) {a_v.clear();return false;}
|
||||
a_v.push_back(d);
|
||||
a_v.push_back(d);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
bool is_log(bool a_v) {if(m_is_log==a_v) return false;m_is_log = a_v;return true;}
|
||||
bool min_value(float a_v) {if(m_min_value==a_v) return false;m_min_value = a_v;return true;}
|
||||
bool max_value(float a_v) {if(m_max_value==a_v) return false;m_max_value = a_v;return true;}
|
||||
#endif
|
||||
#endif
|
||||
float min_value() const {return m_min_value;}
|
||||
float max_value() const {return m_max_value;}
|
||||
bool is_log() const {return m_is_log;}
|
||||
@@ -43,18 +43,18 @@ public:
|
||||
float mylow, myhigh;
|
||||
int N_NICE = 4;
|
||||
static const float nice[/*N_NICE*/4] = { 1.0,2.0,2.5,5.0 };
|
||||
|
||||
|
||||
if (m_min_value > m_max_value) {
|
||||
float low = m_min_value;
|
||||
m_min_value = m_max_value;
|
||||
m_max_value = low;
|
||||
m_max_value = low;
|
||||
} else if (m_min_value == m_max_value) {
|
||||
float value = m_min_value;
|
||||
float value = m_min_value;
|
||||
m_min_value = value - 1;
|
||||
m_max_value = value + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//if (m_steps <= 0) { //if letting the if and m_steps as a field, twice this function do not give the same result.
|
||||
_axis = 1;
|
||||
unsigned int m_steps = 10;
|
||||
@@ -65,65 +65,65 @@ public:
|
||||
// we don't have to go > *m_max_value.
|
||||
//
|
||||
float w = (m_max_value - m_min_value)/((float)m_steps);
|
||||
float mag = ffloor(flog10(w));
|
||||
float mag = ffloor(flog10(w));
|
||||
int i = 0;
|
||||
do {
|
||||
step = nice[i] * fpow(10.0,mag);
|
||||
step = nice[i] * fpow(10.0,mag);
|
||||
mylow = ffloor(m_min_value/step) * step;
|
||||
//myhigh = _axis==1 ? fceil(m_max_value/step) * step : mylow + step * m_steps;
|
||||
//myhigh = _axis==1 ? fceil(m_max_value/step) * step : mylow + step * m_steps;
|
||||
myhigh = fceil(m_max_value/step) * step; //quiet Coverity.
|
||||
i++;
|
||||
if (i>=N_NICE) {i = 0;mag++;}
|
||||
}
|
||||
while ( ( (_axis==1) && (myhigh < m_max_value)) ||
|
||||
while ( ( (_axis==1) && (myhigh < m_max_value)) ||
|
||||
( (_axis==0) && (myhigh <= m_max_value)) );
|
||||
|
||||
|
||||
float range = myhigh - mylow;
|
||||
|
||||
// we now have decided on a range. Try to move
|
||||
|
||||
// we now have decided on a range. Try to move
|
||||
// m_min_value/m_max_value a little
|
||||
// to end up on a nice number.
|
||||
//
|
||||
// first check if either end is near 0.0
|
||||
if ( !m_is_log && (m_min_value >= 0.0) &&
|
||||
(( (_axis==1) && (range>=m_max_value) ) ||
|
||||
( (_axis==0) && (range>m_max_value) )) ) {
|
||||
if ( !m_is_log && (m_min_value >= 0.0) &&
|
||||
(( (_axis==1) && (range>=m_max_value) ) ||
|
||||
( (_axis==0) && (range>m_max_value) )) ) {
|
||||
m_min_value = 0.0;
|
||||
m_max_value = range;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (( (_axis==1) && (m_max_value<=0.0) ) ||
|
||||
( (_axis==0) && (m_max_value<0.0) ))
|
||||
&& (-range<=m_min_value)) {
|
||||
|
||||
if ( (( (_axis==1) && (m_max_value<=0.0) ) ||
|
||||
( (_axis==0) && (m_max_value<0.0) ))
|
||||
&& (-range<=m_min_value)) {
|
||||
m_max_value = 0.0;
|
||||
m_min_value = -range;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// try to round *m_min_value.
|
||||
// correction
|
||||
if( m_is_log && (m_min_value<=0.0)) m_min_value = 1.0;
|
||||
|
||||
|
||||
i = N_NICE-1;
|
||||
mag = myhigh != 0.0 ? fceil(flog10(ffabs(myhigh))) : fceil(flog10(ffabs(mylow)));
|
||||
|
||||
|
||||
do {
|
||||
step = nice[i] * fpow(10.0,mag);
|
||||
step = nice[i] * fpow(10.0,mag);
|
||||
mylow = ffloor(m_min_value/step) * step;
|
||||
myhigh = mylow + range;
|
||||
myhigh = mylow + range;
|
||||
i--;
|
||||
if (i<0) {
|
||||
i = N_NICE-1;
|
||||
mag--;
|
||||
}
|
||||
}
|
||||
while (( m_is_log && (mylow <= 0.0) ) ||
|
||||
( (_axis==1) && (myhigh < m_max_value) ) ||
|
||||
}
|
||||
while (( m_is_log && (mylow <= 0.0) ) ||
|
||||
( (_axis==1) && (myhigh < m_max_value) ) ||
|
||||
( (_axis==0) && (myhigh <= m_max_value) ) );
|
||||
|
||||
|
||||
m_min_value = mylow;
|
||||
m_max_value = myhigh;
|
||||
m_max_value = myhigh;
|
||||
}
|
||||
protected:
|
||||
float m_min_value;
|
||||
|
||||
@@ -177,7 +177,7 @@ inline bool read_bytes(const std::string& a_file,char*& a_buffer,long& a_length)
|
||||
a_buffer[filesize] = 0;
|
||||
a_length = filesize;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool write_bytes(const std::string& a_file,const char* a_buffer,size_t a_length){
|
||||
FILE* file = ::fopen(a_file.c_str(),"wb");
|
||||
@@ -189,7 +189,7 @@ inline bool write_bytes(const std::string& a_file,const char* a_buffer,size_t a_
|
||||
size_t nitem = ::fwrite((char*)a_buffer,a_length,(size_t)1,file);
|
||||
::fclose(file);
|
||||
return (nitem!=1?false:true);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool num_csv_doubles(const std::string& a_string,char& a_sep,unsigned int& a_number){
|
||||
if(a_string.empty()) {a_sep=0;a_number=0;return true;} //it is ok.
|
||||
@@ -235,7 +235,7 @@ inline bool num_csv_doubles(const std::string& a_string,char& a_sep,unsigned int
|
||||
pos = end+1;
|
||||
if(pos>mx) break;
|
||||
}
|
||||
|
||||
|
||||
a_sep = sep;
|
||||
a_number = number;
|
||||
return true;
|
||||
@@ -269,7 +269,7 @@ inline bool is_hippo(const std::string& a_file,bool& a_is){
|
||||
if(end==pos) {all_doubles=false;break;}
|
||||
}
|
||||
a_is = all_doubles?false:true; //all_double=false then we assume the second line is labels of columns.
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// NOTE : the below is_csv() does not take into account a column with strings.
|
||||
@@ -315,10 +315,10 @@ inline bool is_csv(const std::vector<std::string>& a_txt,bool& a_is){
|
||||
if(it==a_txt.begin()) {
|
||||
first_coln = coln;
|
||||
} else {
|
||||
if(coln!=first_coln) return true;
|
||||
if(coln!=first_coln) return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//a_sep = sep;
|
||||
a_is = true;
|
||||
return true;
|
||||
@@ -358,11 +358,18 @@ inline bool is_kumac(const std::string& a_file,bool& a_is){
|
||||
}
|
||||
|
||||
inline bool is_insh(const std::string& a_file,bool& a_is){
|
||||
// look at suffix. Some file can't be guessed.
|
||||
if(suffix(a_file)=="insh") {a_is = true;return true;}
|
||||
//try to guess ?
|
||||
// have a first line : #!insh ?
|
||||
a_is = false;
|
||||
unsigned char head[6];
|
||||
{unsigned int num = 6;
|
||||
if(!signature(a_file,head,num)) {a_is = false;return false;}
|
||||
if(num!=6) {a_is = false;return true;}}
|
||||
if(head[0]!='#') {a_is = false;return true;}
|
||||
if(head[1]!='!') {a_is = false;return true;}
|
||||
if(head[2]!='i') {a_is = false;return true;}
|
||||
if(head[3]!='n') {a_is = false;return true;}
|
||||
if(head[4]!='s') {a_is = false;return true;}
|
||||
if(head[5]!='h') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -526,10 +533,10 @@ inline bool std_remove(std::vector<std::string>& a_files) {
|
||||
inline bool std_rename(const std::string& a_from,const std::string& a_to) {
|
||||
//NOTE : a_from must not be a path !
|
||||
// Darwin is ok with a path but not Linux !
|
||||
// For example :
|
||||
// For example :
|
||||
// ::rename("/tmp/tmp01","x");
|
||||
// return -1 on Linux.
|
||||
// To do the upper then someone must use move.
|
||||
// To do the upper then someone must use move.
|
||||
// But there is no move in the standard lib C !
|
||||
return (::rename(a_from.c_str(),a_to.c_str()) == 0 ? true : false);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ TOOLS_GLOBAL_STRING(format_py)
|
||||
TOOLS_GLOBAL_STRING(format_kumac)
|
||||
TOOLS_GLOBAL_STRING(format_insh)
|
||||
TOOLS_GLOBAL_STRING(format_shp)
|
||||
TOOLS_GLOBAL_STRING(format_simbad)
|
||||
|
||||
#define TOOLS_GLOBAL_EXT(a_name)\
|
||||
inline const std::string& s_ext_##a_name() {\
|
||||
@@ -83,6 +84,7 @@ TOOLS_GLOBAL_EXT(py)
|
||||
TOOLS_GLOBAL_EXT(kumac)
|
||||
TOOLS_GLOBAL_EXT(insh)
|
||||
TOOLS_GLOBAL_EXT(shp)
|
||||
TOOLS_GLOBAL_EXT(simbad)
|
||||
|
||||
#undef TOOLS_GLOBAL_EXT
|
||||
|
||||
@@ -119,6 +121,7 @@ inline void formats(std::vector<std::string>& a_v) {
|
||||
a_v.push_back(s_format_kumac());
|
||||
a_v.push_back(s_format_insh());
|
||||
a_v.push_back(s_format_shp());
|
||||
a_v.push_back(s_format_simbad());
|
||||
}
|
||||
|
||||
inline std::string ext_fmt(const std::string& a_ext) {
|
||||
@@ -155,6 +158,7 @@ inline std::string ext_fmt(const std::string& a_ext) {
|
||||
if(a_ext==s_ext_kumac()) return s_format_kumac();
|
||||
if(a_ext==s_ext_insh()) return s_format_insh();
|
||||
if(a_ext==s_ext_shp()) return s_format_shp();
|
||||
if(a_ext==s_ext_simbad()) return s_format_simbad();
|
||||
return s_format_guessed();
|
||||
}
|
||||
|
||||
@@ -189,7 +193,8 @@ inline bool need_placement(const std::string& a_format) {
|
||||
//if(a_format==s_format_py()) return true;
|
||||
//if(a_format==s_format_kumac()) return true;
|
||||
//if(a_format==s_format_insh()) return true;
|
||||
//if(a_format==s_format_shp()) return true; //load in dynamic_sg.
|
||||
//if(a_format==s_format_shp()) return true; //load in static_sg.
|
||||
//if(a_format==s_format_simbad()) return true; //load in arg sep.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ inline bool is_zip(const std::string& a_file,bool& a_is){
|
||||
if(head[1]!='K') {a_is = false;return true;}
|
||||
if(head[2]!=3) {a_is = false;return true;}
|
||||
if(head[3]!=4) {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ inline bool is_jpeg(const std::string& a_file,bool& a_is){
|
||||
if(head[1]!=216) {a_is = false;return true;}
|
||||
if(head[2]!=255) {a_is = false;return true;}
|
||||
//if(head[3]!=224) {a_is = false;return true;} //LRI.jpg is 225 !
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ inline bool is_png(const std::string& a_file,bool& a_is){
|
||||
if(head[1]!='P') {a_is = false;return true;}
|
||||
if(head[2]!='N') {a_is = false;return true;}
|
||||
if(head[3]!='G') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ inline bool is_root(const std::string& a_file,bool& a_is){
|
||||
if(head[1]!='o') {a_is = false;return true;}
|
||||
if(head[2]!='o') {a_is = false;return true;}
|
||||
if(head[3]!='t') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ inline bool is_iv(const std::string& a_file,bool& a_is){
|
||||
if(head[6]!='t') {a_is = false;return true;}
|
||||
if(head[7]!='o') {a_is = false;return true;}
|
||||
if(head[8]!='r') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ inline bool is_wrl(const std::string& a_file,bool& a_is){
|
||||
if(head[2]!='R') {a_is = false;return true;}
|
||||
if(head[3]!='M') {a_is = false;return true;}
|
||||
if(head[4]!='L') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ inline bool is_dcm(const std::string& a_file,bool& a_is){
|
||||
if(head[129]!='I') {a_is = false;return true;}
|
||||
if(head[130]!='C') {a_is = false;return true;}
|
||||
if(head[131]!='M') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ inline bool is_scenarios(const std::string& a_file,bool& a_is){
|
||||
if(head[7]!='i') {a_is = false;return true;}
|
||||
if(head[8]!='o') {a_is = false;return true;}
|
||||
if(head[9]!='s') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ inline bool is_slides(const std::string& a_file,bool& a_is){
|
||||
if(head[4]!='d') {a_is = false;return true;}
|
||||
if(head[5]!='e') {a_is = false;return true;}
|
||||
if(head[6]!='s') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ inline bool is_fits(const std::string& a_file,bool& a_is){
|
||||
if(head[3]!='P') {a_is = false;return true;}
|
||||
if(head[4]!='L') {a_is = false;return true;}
|
||||
if(head[5]!='E') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ inline bool is_hdf(const std::string& a_file,bool& a_is){
|
||||
if(head[1]!='H') {a_is = false;return true;}
|
||||
if(head[2]!='D') {a_is = false;return true;}
|
||||
if(head[3]!='F') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,26 @@ inline bool is_ps(const std::string& a_file,bool& a_is){
|
||||
if(head[1]!='!') {a_is = false;return true;}
|
||||
if(head[2]!='P') {a_is = false;return true;}
|
||||
if(head[3]!='S') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool is_simbad(const std::string& a_file,bool& a_is){
|
||||
unsigned char head[10];
|
||||
{unsigned int num = 10;
|
||||
if(!signature(a_file,head,num)) {a_is = false;return false;}
|
||||
if(num!=10) {a_is = false;return true;}}
|
||||
if(head[0]!=':') {a_is = false;return true;}
|
||||
if(head[1]!=':') {a_is = false;return true;}
|
||||
if(head[2]!='s') {a_is = false;return true;}
|
||||
if(head[3]!='c') {a_is = false;return true;}
|
||||
if(head[4]!='r') {a_is = false;return true;}
|
||||
if(head[5]!='i') {a_is = false;return true;}
|
||||
if(head[6]!='p') {a_is = false;return true;}
|
||||
if(head[7]!='t') {a_is = false;return true;}
|
||||
if(head[8]!=':') {a_is = false;return true;}
|
||||
if(head[9]!=':') {a_is = false;return true;}
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -335,7 +354,7 @@ inline bool is_shp(const std::string& a_file,bool& a_is){
|
||||
unsigned int _sz = (static_cast<unsigned int>(head[24])<<24)|(head[25]<<16)|(head[26]<<8)|head[27];
|
||||
if(_sz<(UINT_MAX/2)) _sz *= 2;
|
||||
else _sz = (UINT_MAX/2)*2;
|
||||
a_is = sz==long(_sz)?true:false;
|
||||
a_is = sz==long(_sz)?true:false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ inline bool find_with_dirs(std::ostream& a_out,
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,7 +75,7 @@ inline bool find_with_env(std::ostream& a_out,
|
||||
// << std::endl;
|
||||
a_path = a_file;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
a_out << "tools::find_with_env : env variable " << sout(a_env) << " not defined." << std::endl;
|
||||
a_path.clear();
|
||||
return false;
|
||||
|
||||
@@ -26,7 +26,7 @@ inline bool size(const std::string& a_file,long& a_size){
|
||||
inline bool is_empty(const std::string& a_file){
|
||||
long sz;
|
||||
if(!size(a_file,sz)) return true; //if not existing, consider it empty.
|
||||
return (sz==0L)?true:false;
|
||||
return (sz==0L)?true:false;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace tools {
|
||||
inline void get_lines(const std::string& a_string,std::vector<std::string>& a_lines){
|
||||
// a_string is a list separated by "\n" or "\\n".
|
||||
// For "xxx\n\nxxx", {"xxx","","xxx"} will be created.
|
||||
// WARNING : if a_string is a Windows file name, it may
|
||||
// WARNING : if a_string is a Windows file name, it may
|
||||
// contains a \n which is not a delimiter ; like ..\data\ntuples.hbook.
|
||||
a_lines.clear();
|
||||
size_t length = a_string.length();
|
||||
@@ -24,9 +24,9 @@ inline void get_lines(const std::string& a_string,std::vector<std::string>& a_li
|
||||
size_t pos = 0;
|
||||
length++;
|
||||
for(size_t count=0;count<length;count++) {
|
||||
if( (cstring[count]=='\n') ||
|
||||
(cstring[count]=='\0') ||
|
||||
( (cstring[count]=='\\') && (cstring[count+1]=='n') ) ) {
|
||||
if( (cstring[count]=='\n') ||
|
||||
(cstring[count]=='\0') ||
|
||||
( (cstring[count]=='\\') && (cstring[count+1]=='n') ) ) {
|
||||
char shift_one = (cstring[count]=='\n' ? 1 : 0);
|
||||
cstring[count] = '\0';
|
||||
a_lines.push_back(cstring+pos);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Pure header version of gl2ps-1.4.0 done automatically from
|
||||
// the original source by using the bush/upgrade/tools_gl2ps script.
|
||||
// The code had been "namespace protected" by changing :
|
||||
// gl2ps_<xxx> to tools_gl2ps_<xxx>
|
||||
// gl2ps_<xxx> to tools_gl2ps_<xxx>
|
||||
// and :
|
||||
// TOOLS_GL2PS_<xxx> to TOOLS_TOOLS_GL2PS_<xxx>
|
||||
//
|
||||
@@ -5293,6 +5293,9 @@ static void tools_gl2psPrintSVGPrimitive(void *data)
|
||||
case TOOLS_GL2PS_LINE_CAP_SQUARE:
|
||||
sprintf (lcap, "%s", "square");
|
||||
break;
|
||||
default: /*G.Barrand : to quiet Coverity :*/
|
||||
sprintf (lcap, "%s", "butt");
|
||||
break;
|
||||
}
|
||||
switch (prim->linejoin){
|
||||
case TOOLS_GL2PS_LINE_JOIN_MITER:
|
||||
@@ -5304,6 +5307,9 @@ static void tools_gl2psPrintSVGPrimitive(void *data)
|
||||
case TOOLS_GL2PS_LINE_JOIN_BEVEL:
|
||||
sprintf (ljoin, "%s", "bevel");
|
||||
break;
|
||||
default: /*G.Barrand : to quiet Coverity :*/
|
||||
sprintf (ljoin, "%s", "miter");
|
||||
break;
|
||||
}
|
||||
tools_gl2psPrintf("stroke-linecap=\"%s\" stroke-linejoin=\"%s\" ",
|
||||
lcap, ljoin);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#elif defined(ANDROID)
|
||||
#elif _WIN32
|
||||
#include <GL/glext.h>
|
||||
#elif __APPLE__
|
||||
#elif __APPLE__
|
||||
#include <OpenGL/glext.h> //Cocoa
|
||||
#else
|
||||
#include <GL/glext.h>
|
||||
|
||||
@@ -49,10 +49,10 @@ inline void cvt_2to3(size_t a_npt,const float* a_xys,float*& a_xyzs) {
|
||||
}
|
||||
|
||||
|
||||
inline void triangle_fan_to_triangles(size_t a_npt,const float* a_fxyzs,float*& a_xyzs) {
|
||||
// a_xyzs = (a_npt-2)*3*3
|
||||
inline void triangle_fan_to_triangles(size_t a_npt,const float* a_xyzs,float*& a_pxyzs) {
|
||||
// a_pxyzs = (a_npt-2)*3*3
|
||||
|
||||
const float* vpos = a_fxyzs;
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
@@ -67,17 +67,17 @@ inline void triangle_fan_to_triangles(size_t a_npt,const float* a_fxyzs,float*&
|
||||
x3 = *vpos;vpos++;
|
||||
y3 = *vpos;vpos++;
|
||||
z3 = *vpos;vpos++;
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = z1;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = z2;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = z2;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x3;a_xyzs++;
|
||||
*a_xyzs = y3;a_xyzs++;
|
||||
*a_xyzs = z3;a_xyzs++;
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = z3;a_pxyzs++;
|
||||
|
||||
x2 = x3;
|
||||
y2 = y3;
|
||||
@@ -86,10 +86,72 @@ inline void triangle_fan_to_triangles(size_t a_npt,const float* a_fxyzs,float*&
|
||||
|
||||
}
|
||||
|
||||
inline void triangle_strip_to_triangles(size_t a_npt,const float* a_fxyzs,float*& a_xyzs) {
|
||||
// a_xyzs = (a_npt-2)*3*3
|
||||
inline void triangle_fan_to_triangles_texture(size_t a_npt,const float* a_xyzs,const float* a_tcs,float*& a_pxyzs,float*& a_ptcs) {
|
||||
// a_pxyzs = (a_npt-2)*3*3
|
||||
|
||||
const float* vpos = a_fxyzs;
|
||||
// a_ptcs = (a_npt-2)*3*2
|
||||
|
||||
const float* vpos = a_xyzs;
|
||||
const float* tpos = a_tcs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
float z1 = *vpos;vpos++;
|
||||
|
||||
float tx1 = *tpos;tpos++;
|
||||
float ty1 = *tpos;tpos++;
|
||||
|
||||
float x2 = *vpos;vpos++;
|
||||
float y2 = *vpos;vpos++;
|
||||
float z2 = *vpos;vpos++;
|
||||
|
||||
float tx2 = *tpos;tpos++;
|
||||
float ty2 = *tpos;tpos++;
|
||||
|
||||
float x3,y3,z3,tx3,ty3;
|
||||
for(size_t i=2;i<a_npt;i++) {
|
||||
x3 = *vpos;vpos++;
|
||||
y3 = *vpos;vpos++;
|
||||
z3 = *vpos;vpos++;
|
||||
|
||||
tx3 = *tpos;tpos++;
|
||||
ty3 = *tpos;tpos++;
|
||||
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx1;a_ptcs++;
|
||||
*a_ptcs = ty1;a_ptcs++;
|
||||
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = z2;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx2;a_ptcs++;
|
||||
*a_ptcs = ty2;a_ptcs++;
|
||||
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = z3;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx3;a_ptcs++;
|
||||
*a_ptcs = ty3;a_ptcs++;
|
||||
|
||||
x2 = x3;
|
||||
y2 = y3;
|
||||
z2 = z3;
|
||||
|
||||
tx2 = tx3;
|
||||
ty2 = ty3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline void triangle_strip_to_triangles(size_t a_npt,const float* a_xyzs,float*& a_pxyzs) {
|
||||
// a_pxyzs = (a_npt-2)*3*3
|
||||
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
@@ -107,29 +169,29 @@ inline void triangle_strip_to_triangles(size_t a_npt,const float* a_fxyzs,float*
|
||||
z3 = *vpos;vpos++;
|
||||
|
||||
if(flip) {
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = z1;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x3;a_xyzs++;
|
||||
*a_xyzs = y3;a_xyzs++;
|
||||
*a_xyzs = z3;a_xyzs++;
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = z3;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = z2;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = z2;a_pxyzs++;
|
||||
} else {
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = z1;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = z2;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = z2;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x3;a_xyzs++;
|
||||
*a_xyzs = y3;a_xyzs++;
|
||||
*a_xyzs = z3;a_xyzs++;
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = z3;a_pxyzs++;
|
||||
}
|
||||
|
||||
x1 = x2;
|
||||
@@ -144,24 +206,113 @@ inline void triangle_strip_to_triangles(size_t a_npt,const float* a_fxyzs,float*
|
||||
}
|
||||
}
|
||||
|
||||
inline void triangle_fan_to_triangles(size_t a_npt,
|
||||
const float* a_fxyzs,const float* a_fnms,
|
||||
float*& a_xyzs,float*& a_nms) {
|
||||
triangle_fan_to_triangles(a_npt,a_fxyzs,a_xyzs);
|
||||
triangle_fan_to_triangles(a_npt,a_fnms,a_nms);
|
||||
inline void triangle_strip_to_triangles_texture(size_t a_npt,const float* a_xyzs,const float* a_tcs,float*& a_pxyzs,float*& a_ptcs) {
|
||||
// a_pxyzs = (a_npt-2)*3*3
|
||||
// a_ptcs = (a_npt-2)*3*2
|
||||
|
||||
const float* vpos = a_xyzs;
|
||||
const float* tpos = a_tcs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
float z1 = *vpos;vpos++;
|
||||
|
||||
float tx1 = *tpos;tpos++;
|
||||
float ty1 = *tpos;tpos++;
|
||||
|
||||
float x2 = *vpos;vpos++;
|
||||
float y2 = *vpos;vpos++;
|
||||
float z2 = *vpos;vpos++;
|
||||
|
||||
float tx2 = *tpos;tpos++;
|
||||
float ty2 = *tpos;tpos++;
|
||||
|
||||
float x3,y3,z3,tx3,ty3;
|
||||
bool flip = false;
|
||||
for(size_t i=2;i<a_npt;i++) {
|
||||
x3 = *vpos;vpos++;
|
||||
y3 = *vpos;vpos++;
|
||||
z3 = *vpos;vpos++;
|
||||
|
||||
tx3 = *tpos;tpos++;
|
||||
ty3 = *tpos;tpos++;
|
||||
|
||||
if(flip) {
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx1;a_ptcs++;
|
||||
*a_ptcs = ty1;a_ptcs++;
|
||||
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = z3;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx3;a_ptcs++;
|
||||
*a_ptcs = ty3;a_ptcs++;
|
||||
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = z2;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx2;a_ptcs++;
|
||||
*a_ptcs = ty2;a_ptcs++;
|
||||
} else {
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx1;a_ptcs++;
|
||||
*a_ptcs = ty1;a_ptcs++;
|
||||
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = z2;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx2;a_ptcs++;
|
||||
*a_ptcs = ty2;a_ptcs++;
|
||||
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = z3;a_pxyzs++;
|
||||
|
||||
*a_ptcs = tx3;a_ptcs++;
|
||||
*a_ptcs = ty3;a_ptcs++;
|
||||
}
|
||||
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
z1 = z2;
|
||||
|
||||
tx1 = tx2;
|
||||
ty1 = ty2;
|
||||
|
||||
x2 = x3;
|
||||
y2 = y3;
|
||||
z2 = z3;
|
||||
|
||||
tx2 = tx3;
|
||||
ty2 = ty3;
|
||||
|
||||
flip = flip?false:true;
|
||||
}
|
||||
}
|
||||
|
||||
inline void triangle_strip_to_triangles(size_t a_npt,
|
||||
const float* a_fxyzs,const float* a_fnms,
|
||||
float*& a_xyzs,float*& a_nms) {
|
||||
// a_xyzs, a_nms = (a_npt-2)*3*3
|
||||
triangle_strip_to_triangles(a_npt,a_fxyzs,a_xyzs);
|
||||
triangle_strip_to_triangles(a_npt,a_fnms,a_nms);
|
||||
inline void triangle_fan_to_triangles_nms(size_t a_npt,const float* a_xyzs,const float* a_nms,float*& a_pxyzs,float*& a_pnms) {
|
||||
triangle_fan_to_triangles(a_npt,a_xyzs,a_pxyzs);
|
||||
triangle_fan_to_triangles(a_npt,a_nms,a_pnms);
|
||||
}
|
||||
|
||||
inline void triangle_fan_to_triangles_2to3(size_t a_npt,const float* a_xys,float*& a_xyzs) {
|
||||
inline void triangle_strip_to_triangles_nms(size_t a_npt,const float* a_xyzs,const float* a_nms,float*& a_pxyzs,float*& a_pnms) {
|
||||
// a_pxyzs, a_pnms = (a_npt-2)*3*3
|
||||
triangle_strip_to_triangles(a_npt,a_xyzs,a_pxyzs);
|
||||
triangle_strip_to_triangles(a_npt,a_nms,a_pnms);
|
||||
}
|
||||
|
||||
const float* vpos = a_xys;
|
||||
inline void triangle_fan_to_triangles_2to3(size_t a_npt,const float* a_xyzs,float*& a_pxyzs) {
|
||||
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
@@ -174,17 +325,17 @@ inline void triangle_fan_to_triangles_2to3(size_t a_npt,const float* a_xys,float
|
||||
x3 = *vpos;vpos++;
|
||||
y3 = *vpos;vpos++;
|
||||
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x3;a_xyzs++;
|
||||
*a_xyzs = y3;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
x2 = x3;
|
||||
y2 = y3;
|
||||
@@ -192,9 +343,9 @@ inline void triangle_fan_to_triangles_2to3(size_t a_npt,const float* a_xys,float
|
||||
|
||||
}
|
||||
|
||||
inline void triangle_strip_to_triangles_2to3(size_t a_npt,const float* a_xys,float*& a_xyzs) {
|
||||
inline void triangle_strip_to_triangles_2to3(size_t a_npt,const float* a_xyzs,float*& a_pxyzs) {
|
||||
|
||||
const float* vpos = a_xys;
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
@@ -209,29 +360,29 @@ inline void triangle_strip_to_triangles_2to3(size_t a_npt,const float* a_xys,flo
|
||||
y3 = *vpos;vpos++;
|
||||
|
||||
if(flip) {
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x3;a_xyzs++;
|
||||
*a_xyzs = y3;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
} else {
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x3;a_xyzs++;
|
||||
*a_xyzs = y3;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x3;a_pxyzs++;
|
||||
*a_pxyzs = y3;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
}
|
||||
|
||||
x1 = x2;
|
||||
@@ -245,9 +396,9 @@ inline void triangle_strip_to_triangles_2to3(size_t a_npt,const float* a_xys,flo
|
||||
|
||||
}
|
||||
|
||||
inline void line_strip_to_lines_2to3(size_t a_npt,const float* a_xys,float*& a_xyzs) {
|
||||
inline void line_strip_to_lines_2to3(size_t a_npt,const float* a_xyzs,float*& a_pxyzs) {
|
||||
|
||||
const float* vpos = a_xys;
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
@@ -257,13 +408,13 @@ inline void line_strip_to_lines_2to3(size_t a_npt,const float* a_xys,float*& a_x
|
||||
x2 = *vpos;vpos++;
|
||||
y2 = *vpos;vpos++;
|
||||
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = 0;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = 0;a_pxyzs++;
|
||||
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
@@ -271,10 +422,10 @@ inline void line_strip_to_lines_2to3(size_t a_npt,const float* a_xys,float*& a_x
|
||||
|
||||
}
|
||||
|
||||
inline void line_strip_to_lines(size_t a_npt,const float* a_xys,float*& a_xyzs) {
|
||||
// a_xyzs = (a_npt-1)*2*3
|
||||
inline void line_strip_to_lines(size_t a_npt,const float* a_xyzs,float*& a_pxyzs) {
|
||||
// a_pxyzs = (a_npt-1)*2*3
|
||||
|
||||
const float* vpos = a_xys;
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
@@ -286,13 +437,13 @@ inline void line_strip_to_lines(size_t a_npt,const float* a_xys,float*& a_xyzs)
|
||||
y2 = *vpos;vpos++;
|
||||
z2 = *vpos;vpos++;
|
||||
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = z1;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = z2;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = z2;a_pxyzs++;
|
||||
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
@@ -301,10 +452,10 @@ inline void line_strip_to_lines(size_t a_npt,const float* a_xys,float*& a_xyzs)
|
||||
|
||||
}
|
||||
|
||||
inline void line_loop_to_lines(size_t a_npt,const float* a_xys,float*& a_xyzs) {
|
||||
// a_xyzs = a_npt*2*3
|
||||
inline void line_loop_to_lines(size_t a_npt,const float* a_xyzs,float*& a_pxyzs) {
|
||||
// a_pxyzs = a_npt*2*3
|
||||
|
||||
const float* vpos = a_xys;
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
@@ -320,35 +471,55 @@ inline void line_loop_to_lines(size_t a_npt,const float* a_xys,float*& a_xyzs) {
|
||||
y2 = *vpos;vpos++;
|
||||
z2 = *vpos;vpos++;
|
||||
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = z1;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x2;a_xyzs++;
|
||||
*a_xyzs = y2;a_xyzs++;
|
||||
*a_xyzs = z2;a_xyzs++;
|
||||
*a_pxyzs = x2;a_pxyzs++;
|
||||
*a_pxyzs = y2;a_pxyzs++;
|
||||
*a_pxyzs = z2;a_pxyzs++;
|
||||
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
z1 = z2;
|
||||
}
|
||||
|
||||
*a_xyzs = x1;a_xyzs++;
|
||||
*a_xyzs = y1;a_xyzs++;
|
||||
*a_xyzs = z1;a_xyzs++;
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
|
||||
*a_xyzs = x0;a_xyzs++;
|
||||
*a_xyzs = y0;a_xyzs++;
|
||||
*a_xyzs = z0;a_xyzs++;
|
||||
*a_pxyzs = x0;a_pxyzs++;
|
||||
*a_pxyzs = y0;a_pxyzs++;
|
||||
*a_pxyzs = z0;a_pxyzs++;
|
||||
|
||||
}
|
||||
|
||||
/// for DirectX_action :
|
||||
inline void triangle_fan_to_triangles_2to3(size_t a_npt,const float* a_xys,
|
||||
float a_r,float a_g,float a_b,float a_a,
|
||||
float*& a_xyz_rgbas) {
|
||||
inline void line_loop_to_line_strip(size_t a_npt,const float* a_xyzs,float*& a_pxyzs) {
|
||||
// a_pxyzs = (a_npt+1)*3
|
||||
|
||||
const float* vpos = a_xys;
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
float z1 = *vpos;vpos++;
|
||||
|
||||
for(size_t i=0;i<a_npt;i++) {
|
||||
*a_pxyzs = *vpos;vpos++;a_pxyzs++;
|
||||
*a_pxyzs = *vpos;vpos++;a_pxyzs++;
|
||||
*a_pxyzs = *vpos;vpos++;a_pxyzs++;
|
||||
}
|
||||
|
||||
*a_pxyzs = x1;a_pxyzs++;
|
||||
*a_pxyzs = y1;a_pxyzs++;
|
||||
*a_pxyzs = z1;a_pxyzs++;
|
||||
}
|
||||
|
||||
/// for DirectX_action :
|
||||
inline void triangle_fan_to_triangles_2to3(size_t a_npt,const float* a_xyzs,
|
||||
float a_r,float a_g,float a_b,float a_a,
|
||||
float*& a_pxyz_rgbas) {
|
||||
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
float x1 = *vpos;vpos++;
|
||||
float y1 = *vpos;vpos++;
|
||||
@@ -361,33 +532,33 @@ inline void triangle_fan_to_triangles_2to3(size_t a_npt,const float* a_xys,
|
||||
x3 = *vpos;vpos++;
|
||||
y3 = *vpos;vpos++;
|
||||
|
||||
*a_xyz_rgbas = x1;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = y1;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = 0;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = x1;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = y1;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = 0;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = a_r;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_g;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_b;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_a;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_r;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_g;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_b;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_a;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = x2;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = y2;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = 0;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = x2;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = y2;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = 0;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = a_r;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_g;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_b;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_a;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_r;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_g;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_b;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_a;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = x3;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = y3;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = 0;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = x3;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = y3;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = 0;a_pxyz_rgbas++;
|
||||
|
||||
*a_pxyz_rgbas = a_r;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_g;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_b;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_a;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = a_r;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_g;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_b;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_a;a_xyz_rgbas++;
|
||||
|
||||
x2 = x3;
|
||||
y2 = y3;
|
||||
}
|
||||
@@ -395,7 +566,7 @@ inline void triangle_fan_to_triangles_2to3(size_t a_npt,const float* a_xys,
|
||||
|
||||
inline void triangle_fan_to_triangles(size_t a_npt,const float* a_xyzs,
|
||||
float a_r,float a_g,float a_b,float a_a,
|
||||
float*& a_xyz_rgbas) {
|
||||
float*& a_pxyz_rgbas) {
|
||||
|
||||
const float* vpos = a_xyzs;
|
||||
|
||||
@@ -413,33 +584,33 @@ inline void triangle_fan_to_triangles(size_t a_npt,const float* a_xyzs,
|
||||
y3 = *vpos;vpos++;
|
||||
z3 = *vpos;vpos++;
|
||||
|
||||
*a_xyz_rgbas = x1;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = y1;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = z1;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = x1;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = y1;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = z1;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = a_r;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_g;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_b;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_a;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_r;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_g;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_b;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_a;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = x2;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = y2;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = z2;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = x2;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = y2;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = z2;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = a_r;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_g;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_b;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_a;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_r;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_g;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_b;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_a;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = x3;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = y3;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = z3;a_xyz_rgbas++;
|
||||
*a_pxyz_rgbas = x3;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = y3;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = z3;a_pxyz_rgbas++;
|
||||
|
||||
*a_pxyz_rgbas = a_r;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_g;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_b;a_pxyz_rgbas++;
|
||||
*a_pxyz_rgbas = a_a;a_pxyz_rgbas++;
|
||||
|
||||
*a_xyz_rgbas = a_r;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_g;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_b;a_xyz_rgbas++;
|
||||
*a_xyz_rgbas = a_a;a_xyz_rgbas++;
|
||||
|
||||
x2 = x3;
|
||||
y2 = y3;
|
||||
z2 = z3;
|
||||
|
||||
@@ -18,7 +18,7 @@ inline bool is_gzip(const std::string& a_file,bool& a_is){
|
||||
if(head[1]!=139) {a_is = false;return true;}
|
||||
//if(head[2]!=8) {a_is = false;return true;}
|
||||
//if(head[3]!=8) {a_is = false;return true;}
|
||||
a_is = true;
|
||||
a_is = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ inline bool gzip_usize(const std::string& a_file,unsigned int& a_usz){
|
||||
FILE* file = ::fopen(a_file.c_str(),"rb");
|
||||
if(!file) {a_usz=0;return false;}
|
||||
::fseek(file,-4,SEEK_END);
|
||||
unsigned char buf[4];
|
||||
unsigned char buf[4];
|
||||
size_t n = ::fread(buf,1,4,file);
|
||||
::fclose(file);
|
||||
if(n!=4) {a_usz=0;return false;}
|
||||
|
||||
@@ -17,11 +17,11 @@ class base_handle {
|
||||
static const std::string s_v("tools::handle");
|
||||
return s_v;
|
||||
}
|
||||
public:
|
||||
public:
|
||||
virtual void* object() const = 0;
|
||||
virtual base_handle* copy() = 0; //can't be const.
|
||||
virtual void disown() = 0;
|
||||
public:
|
||||
public:
|
||||
base_handle(){
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment(s_class().c_str());
|
||||
@@ -57,11 +57,11 @@ private:
|
||||
template <class T>
|
||||
class handle : public base_handle {
|
||||
typedef base_handle parent;
|
||||
public:
|
||||
public:
|
||||
virtual void* object() const {return m_obj;}
|
||||
virtual base_handle* copy() {return new handle<T>(*this);}
|
||||
virtual void disown() {m_owner = false;}
|
||||
public:
|
||||
public:
|
||||
handle(T* a_obj,bool a_owner = true):parent(),m_obj(a_obj),m_owner(a_owner){}
|
||||
handle(const std::string& a_class,T* a_obj,bool a_owner = true):parent(a_class),m_obj(a_obj),m_owner(a_owner){}
|
||||
virtual ~handle(){if(m_owner) delete m_obj;}
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
} else {
|
||||
m_owner = false;
|
||||
}
|
||||
//a_from.m_obj = 0; //we do not remove the obj ref in a_from.
|
||||
//a_from.m_obj = 0; //we do not remove the obj ref in a_from.
|
||||
}
|
||||
private:
|
||||
// in principle the below are not used.
|
||||
|
||||
@@ -5,25 +5,25 @@
|
||||
#define tools_hatcher
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* hatcher is a class to draw Hatch in a 3D polyline plane
|
||||
* A hatch is caracterise by a direction (dirAngle), a spacing to get
|
||||
* A hatch is caracterise by a direction (dirAngle), a spacing to get
|
||||
* second hatch,
|
||||
* an offset, and a stripWidth :
|
||||
* - offset value : between 0-1, This value set the offset of
|
||||
* the hatch.0 meen that the hatch will touch the first point
|
||||
* of the polyline, and 1 meen that first hatch will be draw
|
||||
* at a 'spacing' distance to first point
|
||||
* - offsetVec : the 3D point from where a hatch had to pass. This is
|
||||
* - offsetVec : the 3D point from where a hatch had to pass. This is
|
||||
* very usefull to have hach continuing in different polygones
|
||||
*
|
||||
* The compute_polyline() method<br>
|
||||
* The compute_polyline() method<br>
|
||||
* By default:
|
||||
* - spacing = .1;
|
||||
* - dirAngle = PI/4;
|
||||
* - offsetValue = 0;
|
||||
* - stripWidth=0.0;
|
||||
*
|
||||
*
|
||||
* A way to get all points and vertices and to draw them can be :
|
||||
* <pre>
|
||||
* iindex =0;
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
,fFirstNumHatch(0)
|
||||
,fNumberHatchToDraw(0)
|
||||
,fFirstPolyline(true)
|
||||
,fResolveResult(UNDEFINED)
|
||||
,fResolveResult(RESOLVE_UNDEFINED)
|
||||
{}
|
||||
virtual ~hatcher() {}
|
||||
protected:
|
||||
@@ -108,7 +108,7 @@ protected:
|
||||
fResolveResult = a_from.fResolveResult;
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* draw the hatch into the polyline bounding box given in argument
|
||||
* You have to get all compute points by the get_points() method
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
void set_offset(float a) {fOffsetValue = a;} //set the offset value for this hatch.
|
||||
void set_offset_point(vec3f a) {fOffset = a;} //set the offset Point for this hatch.
|
||||
void set_precision_factor(float a) {fPrecisionFactor = a;} //set the precision factor for computing (0.0001 is default).
|
||||
|
||||
|
||||
bool set_strip_width(float a) {
|
||||
// set the strip width value(0 is default and means no strip).
|
||||
if (a<0 || a>1) {
|
||||
@@ -164,13 +164,13 @@ public:
|
||||
* to draw it, you have to use a tesselisation algorithm first
|
||||
*/
|
||||
const std::vector<vec3f>& points() {return fPoints;}
|
||||
|
||||
|
||||
//size_t number_of_vertices() const {return fVertices.size();} //get the number of vertices compute for this hatch.
|
||||
/** vector of numbers of vertices */
|
||||
const std::vector<unsigned int>& vertices() {return fVertices;}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/**
|
||||
* draw the hatch into the polyline bounding box given in argument
|
||||
* @return FALSE if :
|
||||
@@ -179,12 +179,12 @@ protected:
|
||||
*/
|
||||
bool compute_single_polyline (vec3f* listPoints,unsigned int number);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Compute a vector system equation aA+bB=C
|
||||
* return SbVec2f(0,0) if there is an error
|
||||
* set the resolveResult variable to the error code :
|
||||
* COLINEAR if A and B are
|
||||
* COLINEAR if A and B are
|
||||
* PRECISION_ERROR if there is a lack of precision in computing
|
||||
* Z_ERROR if there s no solution for Z
|
||||
* UNDEFINED never throw
|
||||
@@ -199,7 +199,7 @@ protected:
|
||||
|
||||
/** Spacing vector between two hatch */
|
||||
float fShift; // Absloute distance between two hatch in the polyline plan */
|
||||
|
||||
|
||||
/** The angle (given in radians) is the one between the first
|
||||
* line (point 1-point0) and the hatch lines, in the polyline plan.
|
||||
* Given in the direct axis ((point1-point0),(lastPoint-point0),
|
||||
@@ -208,16 +208,16 @@ protected:
|
||||
* perform correct hatching between the polylines
|
||||
*/
|
||||
float fDirAngle;
|
||||
|
||||
/** between 0-1. This value set the offset of the hatch.0 meen
|
||||
* that the hatch will touch the first point of the polyline,
|
||||
|
||||
/** between 0-1. This value set the offset of the hatch.0 meen
|
||||
* that the hatch will touch the first point of the polyline,
|
||||
* and 1 meen that first hatch will be draw
|
||||
* at a 'spacing' distance to first point
|
||||
*/
|
||||
float fOffsetValue;
|
||||
|
||||
/** first point of the hatch.
|
||||
* offset = firstPolylinePoint+ShiftVec*offsetValue
|
||||
/** first point of the hatch.
|
||||
* offset = firstPolylinePoint+ShiftVec*offsetValue
|
||||
*/
|
||||
vec3f fOffset;
|
||||
|
||||
@@ -226,12 +226,12 @@ protected:
|
||||
|
||||
/** factor for compute error between two points */
|
||||
float fPrecisionFactor;
|
||||
|
||||
|
||||
/** hatch direction Vector */
|
||||
vec3f fDirVec;
|
||||
|
||||
/** strip with size : set to 0 by default
|
||||
* between 0 and 1.0 means no strip, 0.5 means strip size is
|
||||
* between 0 and 1.0 means no strip, 0.5 means strip size is
|
||||
* half of distance between two hatches
|
||||
*/
|
||||
float fStripWidth;
|
||||
@@ -241,7 +241,7 @@ protected:
|
||||
|
||||
/** vector vertices number */
|
||||
std::vector<unsigned int> fVertices;
|
||||
|
||||
|
||||
/** conflict line table */
|
||||
std::vector< std::vector<int> > fConflictNumHatchLineTab;
|
||||
|
||||
@@ -256,11 +256,11 @@ protected:
|
||||
|
||||
bool fFirstPolyline;
|
||||
enum ResolveErrors{
|
||||
OK = 0,
|
||||
COLINEAR,
|
||||
Z_ERROR,
|
||||
PRECISION_ERROR,
|
||||
UNDEFINED
|
||||
RESOLVE_OK = 0,
|
||||
RESOLVE_COLINEAR,
|
||||
RESOLVE_Z_ERROR,
|
||||
RESOLVE_PRECISION_ERROR,
|
||||
RESOLVE_UNDEFINED
|
||||
};
|
||||
ResolveErrors fResolveResult;
|
||||
};
|
||||
|
||||
@@ -44,22 +44,22 @@ inline bool hatcher::check_polyline(vec3f* listPoints,unsigned int aNumber){
|
||||
AB.setValue(listPoints[1+firstOffset].getValue()[0]-listPoints[0].getValue()[0],
|
||||
listPoints[1+firstOffset].getValue()[1]-listPoints[0].getValue()[1],
|
||||
listPoints[1+firstOffset].getValue()[2]-listPoints[0].getValue()[2]); // Vector A->B
|
||||
|
||||
|
||||
fResolveResult = COLINEAR;
|
||||
|
||||
|
||||
fResolveResult = RESOLVE_COLINEAR;
|
||||
unsigned int test = aNumber;
|
||||
while ((fResolveResult !=0) && (test>2+firstOffset)) {
|
||||
test--;
|
||||
AC.setValue(listPoints[test].getValue()[0]-listPoints[0].getValue()[0],
|
||||
listPoints[test].getValue()[1]-listPoints[0].getValue()[1],
|
||||
listPoints[test].getValue()[2]-listPoints[0].getValue()[2]);
|
||||
|
||||
|
||||
// test if AB != AC*i
|
||||
resolve_system( AB,
|
||||
AC,
|
||||
vec3f(.0f,.0f,.0f));
|
||||
}
|
||||
if (fResolveResult == COLINEAR) {
|
||||
if (fResolveResult == RESOLVE_COLINEAR) {
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
::printf("hatcher::check_polyline : ERROR all the point you give are colinear!\n\n");
|
||||
for (unsigned int a =0;a<aNumber;a++) {
|
||||
@@ -83,7 +83,7 @@ inline bool hatcher::check_polyline(vec3f* listPoints,unsigned int aNumber){
|
||||
falsePoints++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (falsePoints !=0) {
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
::printf("hatcher::check_polyline : ERROR there is %d points on the polyline witch are not on the same plan!\n\n",falsePoints);
|
||||
@@ -113,12 +113,12 @@ inline bool hatcher::check_polyline(vec3f* listPoints,unsigned int aNumber){
|
||||
// - All points are not in the same plan
|
||||
// - There is a precision error on one or more point
|
||||
// Compute a first sequence of hacth, store results, compute a second sequence
|
||||
// and match all results to get the correct strip points
|
||||
// and match all results to get the correct strip points
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/** Compute stripWidth
|
||||
* We have to use the conflictNumHatchLineTab, hatchNumber,listHatchStartPoint tables
|
||||
* also the HatchShiftToMacthPoint tab.
|
||||
* and the hatch line just compute below
|
||||
* also the HatchShiftToMacthPoint tab.
|
||||
* and the hatch line just compute below
|
||||
* We try to made a polyline with all points witch are on the current hatch and on the next hacth
|
||||
* (distant of stripwidth form current hatch)
|
||||
* conflictNumHatchLineTab give us something like this for current and next hatch
|
||||
@@ -134,10 +134,10 @@ inline bool hatcher::check_polyline(vec3f* listPoints,unsigned int aNumber){
|
||||
* current next current next
|
||||
* ,4 ,4
|
||||
* '0 B(0,1) '5
|
||||
* ,1
|
||||
* ,1
|
||||
* '3 ,3
|
||||
* ,5 '2
|
||||
* '2
|
||||
* ,5 '2
|
||||
* '2
|
||||
*
|
||||
* Now we have to match a way to traverse all of theses lines. We have 3 solutions to go from
|
||||
* one line to another :
|
||||
@@ -145,7 +145,7 @@ inline bool hatcher::check_polyline(vec3f* listPoints,unsigned int aNumber){
|
||||
* - go to the same line but on another hatch
|
||||
* - go to the next tach point
|
||||
* If there is no solution, we have to close the polyline strip and go to another point until
|
||||
* all are compute
|
||||
* all are compute
|
||||
*/
|
||||
|
||||
/** first, we have to match 7 different cases
|
||||
@@ -165,7 +165,7 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
std::vector<bool> firstComputePointsEnable; // table of already compute points for first hatch
|
||||
std::vector<bool> secondComputePointsEnable;// table of already compute points for second hatch
|
||||
std::vector< std::vector<int> > firstComputeConflictNumHatchLineTab; // copy firstComputeConflictNumHatchLineTab in
|
||||
|
||||
|
||||
int firstComputeFirstNumHatch =0;
|
||||
unsigned int firstComputeNumberHatchToDraw =0;
|
||||
float firstHatchShiftToMatchFirstPoint = FLT_MAX; // use in one case when there is no intersection points: to test we have to fill all the polygone
|
||||
@@ -187,14 +187,14 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
firstComputeConflictNumHatchLineTab[a].clear();
|
||||
for (unsigned int b=0;b<fConflictNumHatchLineTab[a].size();b++){
|
||||
firstComputeConflictNumHatchLineTab[a].push_back(fConflictNumHatchLineTab[a][b]);
|
||||
}
|
||||
}
|
||||
}
|
||||
firstComputeFirstNumHatch = fFirstNumHatch;
|
||||
firstComputeNumberHatchToDraw = fNumberHatchToDraw;
|
||||
firstHatchShiftToMatchFirstPoint = fHatchShiftToMatchPointVec[0];
|
||||
firstHatchShiftToMatchFirstPoint = fHatchShiftToMatchPointVec[0];
|
||||
//change the offset vector
|
||||
fOffset = fOffset+fShiftVec*fStripWidth;
|
||||
|
||||
|
||||
//call compute for second set of hatch
|
||||
if ( !compute_single_polyline (tabPoints,aNumber))
|
||||
return false;
|
||||
@@ -204,13 +204,13 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
secondComputePoints.push_back(fPoints[a]);
|
||||
}
|
||||
|
||||
secondHatchShiftToMatchFirstPoint = fHatchShiftToMatchPointVec[0];
|
||||
secondHatchShiftToMatchFirstPoint = fHatchShiftToMatchPointVec[0];
|
||||
|
||||
|
||||
|
||||
// initialize values
|
||||
fPoints.clear();
|
||||
fVertices.clear();
|
||||
|
||||
|
||||
int specialCase=1;
|
||||
|
||||
//first hatch, case 1
|
||||
@@ -256,11 +256,11 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
firstComputeConflictNumHatchLineTab[0].clear();
|
||||
firstComputeNumberHatchToDraw ++;
|
||||
specialCase =5;
|
||||
|
||||
|
||||
} //second hatch, case 6
|
||||
else if (floorf(firstHatchShiftToMatchFirstPoint) != floorf(secondHatchShiftToMatchFirstPoint)) {
|
||||
specialCase =6;
|
||||
|
||||
|
||||
//fill all the polygone !
|
||||
fVertices.push_back(aNumber);
|
||||
for (unsigned int a =0;a<aNumber;a++){
|
||||
@@ -272,17 +272,17 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
specialCase =7;
|
||||
return true;
|
||||
} else {
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
::printf("hatcher::drawStripPolyline : WARNING there is a case witch was not done in the algotithm...possibly some drawing problems.\n\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool result;
|
||||
bool find; // temp variable
|
||||
int firstHatchComputePoint = 0; //first point number
|
||||
int secondHatchComputePoint = 0; //first point number
|
||||
int firstHatchComputePoint = 0; //first point number
|
||||
int secondHatchComputePoint = 0; //first point number
|
||||
unsigned int lineNumber;
|
||||
unsigned int firstPointTabInd =0;
|
||||
unsigned int secondPointTabInd=0;
|
||||
@@ -291,7 +291,7 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
unsigned int indTmp;
|
||||
unsigned int oldSolution;
|
||||
for (unsigned int indHatch =0;indHatch<firstComputeNumberHatchToDraw;indHatch++) {
|
||||
|
||||
|
||||
|
||||
currentHatch =0; // 0 is first, 1 is second
|
||||
solution =99; //default for beginning
|
||||
@@ -303,7 +303,7 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
firstComputePointsEnable.push_back(false);}
|
||||
for (unsigned int a=0;a<fConflictNumHatchLineTab[indHatch].size();a++){
|
||||
secondComputePointsEnable.push_back(false);}
|
||||
|
||||
|
||||
if ((indHatch == 0) && ((specialCase ==2) || (specialCase ==3) || (specialCase ==5))) {
|
||||
for (unsigned int a=0;a<firstComputeConflictNumHatchLineTab[indHatch].size();a++){
|
||||
firstComputePointsEnable[a] = true;
|
||||
@@ -314,18 +314,18 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
secondComputePointsEnable[a] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
result = false;
|
||||
while (result == false) {
|
||||
|
||||
|
||||
|
||||
//find a uncompute point for this set of hatch
|
||||
result =true;
|
||||
unsigned int b=0;
|
||||
while ((result == true) && (b<firstComputeConflictNumHatchLineTab[indHatch].size())) {
|
||||
if (firstComputePointsEnable[b] == false) {
|
||||
result =false;
|
||||
firstHatchComputePoint = b;
|
||||
result =false;
|
||||
firstHatchComputePoint = b;
|
||||
lineNumber = firstComputeConflictNumHatchLineTab[indHatch][b];
|
||||
fPoints.push_back(firstComputePoints[b+firstPointTabInd]);
|
||||
fVertices.push_back(1);
|
||||
@@ -336,11 +336,11 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
}
|
||||
if (result ==true) {
|
||||
//find a uncompute point for this set of hatch
|
||||
|
||||
|
||||
while ((result == true) && (b<fConflictNumHatchLineTab[indHatch].size())) {
|
||||
if (secondComputePointsEnable[b] == false) {
|
||||
result =false;
|
||||
secondHatchComputePoint = b;
|
||||
secondHatchComputePoint = b;
|
||||
lineNumber = fConflictNumHatchLineTab[indHatch][b];
|
||||
fPoints.push_back(secondComputePoints[b+secondPointTabInd]);
|
||||
fVertices.push_back(1);
|
||||
@@ -428,8 +428,8 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
}
|
||||
}
|
||||
} // end of current hatch
|
||||
|
||||
//test of second hatch if currentHatch is second
|
||||
|
||||
//test of second hatch if currentHatch is second
|
||||
if ((oldSolution != 0) && (solution !=2) && (currentHatch !=0)) {
|
||||
|
||||
if (oldSolution != 3){ // could go to first solution
|
||||
@@ -503,11 +503,11 @@ inline bool hatcher::compute_polyline (vec3f* tabPoints,unsigned int aNumber) {
|
||||
// } // if result
|
||||
} // while result
|
||||
for (unsigned int a =0;a<fVertices.size();a++){
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
if (fVertices[a] <4) ::printf("hatcher::drawStripPolyline : WARNING A strip polyline has been compute with less than 3 points, it could be an error in the algorithm or a special case.\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
firstPointTabInd += firstComputeConflictNumHatchLineTab[indHatch].size();
|
||||
secondPointTabInd += fConflictNumHatchLineTab[indHatch].size();
|
||||
} //end for
|
||||
@@ -561,20 +561,20 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
listPoints[1].getValue()[1]-listPoints[0].getValue()[1],
|
||||
listPoints[1].getValue()[2]-listPoints[0].getValue()[2]); // Vector A->B
|
||||
|
||||
fResolveResult = COLINEAR;
|
||||
fResolveResult = RESOLVE_COLINEAR;
|
||||
unsigned int test = numberOfPolylinePoints-1;
|
||||
while ((fResolveResult !=0) && (test>1)) {
|
||||
test--;
|
||||
AC.setValue(listPoints[test].getValue()[0]-listPoints[0].getValue()[0],
|
||||
listPoints[test].getValue()[1]-listPoints[0].getValue()[1],
|
||||
listPoints[test].getValue()[2]-listPoints[0].getValue()[2]);
|
||||
|
||||
|
||||
// test if AB != AC*i
|
||||
resolve_system( AB,
|
||||
AC,
|
||||
vec3f(.0f,.0f,.0f));
|
||||
}
|
||||
if (fResolveResult == COLINEAR) {
|
||||
if (fResolveResult == RESOLVE_COLINEAR) {
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
::printf("hatcher::drawPolyline : ERROR all the point you give are colinear!\n\n");
|
||||
for (unsigned int a =0;a<aNumber;a++) {
|
||||
@@ -592,20 +592,20 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
// Normal plane Vector = AB x AC
|
||||
///////////////////////////////////////////////////////////////
|
||||
if (fFirstPolyline) {
|
||||
|
||||
|
||||
fFirstPolyline = false;
|
||||
|
||||
|
||||
fNormal.setValue(AB[1]*AC[2]-AB[2]*AC[1],
|
||||
AB[2]*AC[0]-AB[0]*AC[2],
|
||||
AB[0]*AC[1]-AB[1]*AC[0]);
|
||||
|
||||
|
||||
|
||||
|
||||
// ABPerp Vector = normal x AB
|
||||
vec3f ABPerpVector;
|
||||
ABPerpVector.setValue(fNormal[1]*AB[2]-fNormal[2]*AB[1],
|
||||
fNormal[2]*AB[0]-fNormal[0]*AB[2],
|
||||
fNormal[0]*AB[1]-fNormal[1]*AB[0]);
|
||||
|
||||
|
||||
float normAB =(float)sqrt(std::pow(AB[0],2)+
|
||||
std::pow(AB[1],2)+
|
||||
std::pow(AB[2],2));
|
||||
@@ -616,7 +616,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
float j = std::tan(fDirAngle)*normAB/normABPerpVector;
|
||||
|
||||
if (normABPerpVector == 0){ // never done (should be test before)
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
::printf("hatcher::drawPolyline : ERROR Impossible to compute the dir vector for hatch. Normal for this plan is null (normal for : point[0],point[1],lastPoint) point[0], point[1], last point are probably aligned\n\n");
|
||||
#endif
|
||||
delete [] listPoints;
|
||||
@@ -631,16 +631,16 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
} else {
|
||||
fDirVec = fDirVec/fDirVec.getValue()[0];
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// creation of the shiftVec thanks to the shift field
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
vec3f dirShiftVector;
|
||||
dirShiftVector.setValue(fNormal[1]*fDirVec.getValue()[2]-fNormal[2]*fDirVec.getValue()[1],
|
||||
fNormal[2]*fDirVec.getValue()[0]-fNormal[0]*fDirVec.getValue()[2],
|
||||
fNormal[0]*fDirVec.getValue()[1]-fNormal[1]*fDirVec.getValue()[0]);
|
||||
|
||||
|
||||
// normalize vector to match the shift size
|
||||
float param = 1.0f;
|
||||
param = (float)sqrt((std::pow(fShift,2))/(
|
||||
@@ -654,12 +654,12 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
fOffset = listPoints[0]+fShiftVec*fOffsetValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// START to compute
|
||||
// START to compute
|
||||
// We compute each line one by one to know witch hatch will be draw thrue this line
|
||||
// we try to know the result of
|
||||
// we try to know the result of
|
||||
// (origin_point_of_hatch)+i*(directionVector)+j*(shiftVector) = each_point_of_polyline
|
||||
// We will be interest only on j factor for the moment. This factor represent the offset
|
||||
// between the Origin point of the hatch and the compute point of the polyline
|
||||
@@ -670,7 +670,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
// hatchShiftToMatchPoint 5 7 2 6 7 8 5 ...2 5
|
||||
// min = 1 max = 8 -> 8 hatch to draw
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
fHatchShiftToMatchPointVec.resize(numberOfPolylinePoints+1);
|
||||
float minShiftHatch =FLT_MAX;
|
||||
float maxShiftHatch =-FLT_MAX;
|
||||
@@ -699,7 +699,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
}
|
||||
}
|
||||
// for the first point to close the polyline
|
||||
fHatchShiftToMatchPointVec[numberOfPolylinePoints] = fHatchShiftToMatchPointVec[0];
|
||||
fHatchShiftToMatchPointVec[numberOfPolylinePoints] = fHatchShiftToMatchPointVec[0];
|
||||
fFirstNumHatch = (int)(ceilf(minShiftHatch));
|
||||
fNumberHatchToDraw = (int)(floorf(maxShiftHatch)-fFirstNumHatch+1);
|
||||
if ((int)(floorf(maxShiftHatch)-fFirstNumHatch+1) <0) fNumberHatchToDraw =0;
|
||||
@@ -708,7 +708,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
std::vector<vec3f> listHatchStartPoint;
|
||||
std::vector<vec3f> listHatchEndPoint;
|
||||
std::vector<int> numberOfStartEndPointsVec;
|
||||
|
||||
|
||||
fConflictNumHatchLineTab.resize(moreNumberHatchToDraw);
|
||||
|
||||
// initialize tab
|
||||
@@ -718,12 +718,12 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
listHatchEndPoint.push_back(vec3f(.0f,.0f,.0f));
|
||||
fConflictNumHatchLineTab[a].clear();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Compute the normalize shift vector for all lines
|
||||
// the normal Vector for point 3 to 4 will be listNormalvec[2]
|
||||
/////////////////////////////////////////////
|
||||
|
||||
|
||||
for (int a=0;a<numberOfPolylinePoints-1;a++) {
|
||||
res = resolve_system(fDirVec.getValue(),
|
||||
vec3f(listPoints[a].getValue()[0]-listPoints[a+1].getValue()[0],
|
||||
@@ -736,7 +736,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
res[1]*(listPoints[a+1].getValue()[2]-listPoints[a].getValue()[2])
|
||||
));
|
||||
}
|
||||
else if (fResolveResult ==Z_ERROR ) { // never done (should be test before)
|
||||
else if (fResolveResult == RESOLVE_Z_ERROR ) { // never done (should be test before)
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
::printf("hatcher::drawPolyline : ERROR one or more of your polyline points are not on the same plan !\n\n");
|
||||
#endif
|
||||
@@ -748,27 +748,27 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
// listNormalVec.append(new vec3f(FLT_MAX,FLT_MAX,FLT_MAX));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Compute the hatchShiftToMatchPointVec table to try to get the start
|
||||
// and end point of each hatch
|
||||
// if there is more than one start/end point, we will resolve it later. For the moment,
|
||||
// we put confict points into a table
|
||||
// HatchNumber 1 2 3 4 5 6 7 8 9
|
||||
// listHatchStartPoint 1,0,0 1,1,0 0,0,1 0,1,0 1,1,0 0,2,0 1,1,4
|
||||
// listHatchEndPoint ..............
|
||||
// conflictNumHatchLineTab 5 6 7
|
||||
// listHatchStartPoint 1,0,0 1,1,0 0,0,1 0,1,0 1,1,0 0,2,0 1,1,4
|
||||
// listHatchEndPoint ..............
|
||||
// conflictNumHatchLineTab 5 6 7
|
||||
// line Number is 0 for (point[0]->point[1])
|
||||
// We put each line number into the conflict table to be sure to get all the lines
|
||||
// in conflict. When we will thest the value of the conflicy table, it should
|
||||
// be greater than 2 to have a conflict
|
||||
/////////////////////////////////////////////
|
||||
|
||||
|
||||
vec3f newPoint;
|
||||
int minHatch;
|
||||
int maxHatch;
|
||||
int maxHatch;
|
||||
int hatchIndice =0;
|
||||
|
||||
|
||||
for (int indPolyline=0;indPolyline<numberOfPolylinePoints-1;indPolyline++) {
|
||||
minHatch = (int)(ceilf(fHatchShiftToMatchPointVec[indPolyline]));
|
||||
maxHatch = (int)(floorf(fHatchShiftToMatchPointVec[indPolyline+1]));
|
||||
@@ -793,7 +793,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
// the start point will be :
|
||||
// Point_of_the_line + normalVec *
|
||||
//(number_of_hatch_to_compute - number_of_hatch_corresponding_to_first_point_of_line)
|
||||
//
|
||||
//
|
||||
if ( (listNormalVec[indPolyline][0] != FLT_MAX)
|
||||
&& (listNormalVec[indPolyline][1] != FLT_MAX)
|
||||
&& (listNormalVec[indPolyline][2] != FLT_MAX)) {
|
||||
@@ -837,7 +837,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
float nextPointConflictHatchNumber = -FLT_MAX;
|
||||
float currentPointConflictHatchNumber = -FLT_MAX;
|
||||
std::vector<unsigned int> orderConflictLineNumber;
|
||||
|
||||
|
||||
for (unsigned int hatchNumber =0;hatchNumber<fNumberHatchToDraw;hatchNumber++) {
|
||||
if ( fConflictNumHatchLineTab[hatchNumber].size() <= 2) {
|
||||
if (!listHatchStartPoint[hatchNumber].equals(listHatchEndPoint[hatchNumber],FLT_EPSILON*FLT_EPSILON*10)) {
|
||||
@@ -851,7 +851,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
// Compute the equation on the conflict line (called ABVec ):
|
||||
// i*dirVec - j*ABVec = A-(offset + shiftVec * numberHatchToDraw)
|
||||
// and store the i parameter
|
||||
// then we
|
||||
// then we
|
||||
|
||||
listConflictPoints.clear();
|
||||
listCoefDirHatch.clear();
|
||||
@@ -877,7 +877,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
res[1] = -res[1];
|
||||
listConflictPoints.push_back(vec3f(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictLineNumber]]+ABVec*res[1]));
|
||||
}
|
||||
else if (fResolveResult != COLINEAR){
|
||||
else if (fResolveResult != RESOLVE_COLINEAR){
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
printf("hatcher : Precision error during compute on hatch number%d\n\n",hatchNumber);
|
||||
#endif
|
||||
@@ -904,9 +904,9 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
for (unsigned int conflictLineNumber=0;conflictLineNumber<fConflictNumHatchLineTab[hatchNumber].size();conflictLineNumber++ ) {
|
||||
}
|
||||
}
|
||||
if (listCoefDirHatch.size() != 0) { // all points are resolve_system errors (COLINEAR or Z_ERROR
|
||||
if (listCoefDirHatch.size() != 0) { // all points are resolve_system errors (RESOLVE_COLINEAR or RESOLVE_Z_ERROR
|
||||
|
||||
// now, we have to sort all coef dir from minus to max
|
||||
// now, we have to sort all coef dir from minus to max
|
||||
// and at the same time, reorder the conflict ponts and the conflict line number
|
||||
// this algorithm is not optimum...
|
||||
valid = false;
|
||||
@@ -928,7 +928,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
fConflictNumHatchLineTab[hatchNumber][sort+1] = tempInt;
|
||||
valid= false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// once dir coef have been sort, we could draw lines !!
|
||||
@@ -1003,7 +1003,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
bool nextPointCrossLine = false;
|
||||
// if the conflict is on a line point, we have to look the hatch number
|
||||
// of the previous and next point to see if the hatch had to be draw or not
|
||||
|
||||
|
||||
// test if conflictPoint == first line point
|
||||
if (listConflictPoints[conflictNumber].equals(listPoints[fConflictNumHatchLineTab[hatchNumber][conflictNumber]].getValue(),FLT_EPSILON*FLT_EPSILON*10)) {
|
||||
// we look second point hatchNumber
|
||||
@@ -1029,7 +1029,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
}
|
||||
else { // case of two lines have intersection point on a hatch
|
||||
// it is the same case as a "end of line" and a "begin of line" conflict
|
||||
nextPointConflictHatchNumber = -1;
|
||||
nextPointConflictHatchNumber = -1;
|
||||
nextPointCrossLine = true;
|
||||
}
|
||||
|
||||
@@ -1047,12 +1047,12 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
fPoints.push_back(listConflictPoints[conflictNumber].getValue());
|
||||
orderConflictLineNumber.push_back(fConflictNumHatchLineTab[hatchNumber][conflictNumber]);
|
||||
drawEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// we draw
|
||||
else if( ( (currentPointConflictHatchNumber -
|
||||
fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber]]) *
|
||||
(nextPointConflictHatchNumber -
|
||||
(nextPointConflictHatchNumber -
|
||||
fHatchShiftToMatchPointVec[fConflictNumHatchLineTab[hatchNumber][conflictNumber]]))
|
||||
<=FLT_EPSILON) {
|
||||
// try to see if we are trying to draw a hatch OVER a contour
|
||||
@@ -1113,7 +1113,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
fConflictNumHatchLineTab[hatchNumber].clear();
|
||||
for(unsigned int a=0;a<orderConflictLineNumber.size();a++) {
|
||||
fConflictNumHatchLineTab[hatchNumber].push_back(orderConflictLineNumber[a]);}
|
||||
|
||||
|
||||
// test if it is correct
|
||||
} // end resolve system errors
|
||||
} // end conflict
|
||||
@@ -1143,7 +1143,7 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
// Compute a vector system equation aA+bB=C
|
||||
// return vec2f(0,0) if there is an error
|
||||
// set the resolveResult variable to the error code :
|
||||
// COLINEAR if A and B are
|
||||
// COLINEAR if A and B are
|
||||
// PRECISION_ERROR if there is a lack of precision in computing
|
||||
// Z_ERROR if there s no solution for Z
|
||||
// UNDEFINED never throw
|
||||
@@ -1152,8 +1152,8 @@ inline bool hatcher::compute_single_polyline (vec3f* tabPoints,unsigned int aNum
|
||||
|
||||
inline vec2f hatcher::resolve_system(const vec3f& A,const vec3f& B,const vec3f& C) {
|
||||
|
||||
fResolveResult = UNDEFINED;
|
||||
|
||||
fResolveResult = RESOLVE_UNDEFINED;
|
||||
|
||||
double Ax = A[0];
|
||||
double Ay = A[1];
|
||||
double Az = A[2];
|
||||
@@ -1173,32 +1173,32 @@ inline vec2f hatcher::resolve_system(const vec3f& A,const vec3f& B,const vec3f&
|
||||
tmp = Cx; Cx = Cy; Cy = Cz; Cz = tmp;
|
||||
|
||||
bDiv = (By*Ax-Ay*Bx);
|
||||
|
||||
|
||||
if (ffabs(float(bDiv)) <=FLT_EPSILON) {
|
||||
// we have to test in a other order
|
||||
tmp = Ax; Ax = Ay; Ay = Az; Az = tmp;
|
||||
tmp = Bx; Bx = By; By = Bz; Bz = tmp;
|
||||
tmp = Cx; Cx = Cy; Cy = Cz; Cz = tmp;
|
||||
|
||||
|
||||
bDiv = (By*Ax-Ay*Bx);
|
||||
if (ffabs(float(bDiv)) <=FLT_EPSILON) {
|
||||
fResolveResult = COLINEAR;
|
||||
fResolveResult = RESOLVE_COLINEAR;
|
||||
return vec2f(0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double b= (Cy*Ax-Ay*Cx)/bDiv;
|
||||
double a= -(Cy*Bx-By*Cx)/bDiv;
|
||||
double a= -(Cy*Bx-By*Cx)/bDiv;
|
||||
double bid = ffabs(float(a*Az+b*Bz - Cz));
|
||||
|
||||
|
||||
if (bid <= FLT_EPSILON) {
|
||||
fResolveResult = OK;
|
||||
fResolveResult = RESOLVE_OK;
|
||||
return vec2f((float)a,(float)b);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
double minBoxValue = 1;
|
||||
|
||||
|
||||
double minXValue =FLT_MAX;
|
||||
double minYValue =FLT_MAX;
|
||||
double minZValue =FLT_MAX;
|
||||
@@ -1211,7 +1211,7 @@ inline vec2f hatcher::resolve_system(const vec3f& A,const vec3f& B,const vec3f&
|
||||
if ((A[2] !=0) && ((A[2]) <minZValue)) minZValue = (A[2]);
|
||||
if ((B[2] !=0) && ((B[2]) <minZValue)) minZValue = (B[2]);
|
||||
if ((C[2] !=0) && ((C[2]) <minZValue)) minZValue = (C[2]);
|
||||
|
||||
|
||||
|
||||
double maxXValue =-FLT_MAX;
|
||||
double maxYValue =-FLT_MAX;
|
||||
@@ -1225,17 +1225,17 @@ inline vec2f hatcher::resolve_system(const vec3f& A,const vec3f& B,const vec3f&
|
||||
if ((A[2] !=0) && ((A[2]) >maxZValue)) maxZValue = (A[2]);
|
||||
if ((B[2] !=0) && ((B[2]) >maxZValue)) maxZValue = (B[2]);
|
||||
if ((C[2] !=0) && ((C[2]) >maxZValue)) maxZValue = (C[2]);
|
||||
|
||||
|
||||
if (((maxXValue-minXValue) <= (maxYValue-minYValue)) && ((maxXValue-minXValue) <= (maxZValue-minZValue))) { minBoxValue = maxXValue-minXValue; }
|
||||
else
|
||||
else
|
||||
if (((maxYValue-minYValue) <= (maxXValue-minXValue)) && ((maxYValue-minYValue) <= (maxZValue-minZValue))) { minBoxValue = maxYValue-minYValue; }
|
||||
else
|
||||
{ minBoxValue = maxZValue-minZValue; }
|
||||
|
||||
|
||||
minBoxValue *= fPrecisionFactor;
|
||||
|
||||
|
||||
if (bid <= minBoxValue) {
|
||||
fResolveResult = OK;
|
||||
fResolveResult = RESOLVE_OK;
|
||||
return vec2f((float)a,(float)b);
|
||||
}
|
||||
else {
|
||||
@@ -1243,14 +1243,14 @@ inline vec2f hatcher::resolve_system(const vec3f& A,const vec3f& B,const vec3f&
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
printf("hatcher : ***** PRECISON ERROR ON Z ******* compare %f > %f res :%f %f test %f %f bDiv %e\n\n",bid,100*minBoxValue,a,b,a*Ax+b*Bx-Cx,a*Ay+b*By-Cy,bDiv);
|
||||
#endif
|
||||
fResolveResult = Z_ERROR;
|
||||
fResolveResult = RESOLVE_Z_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef TOOLS_HATCHER_DEBUG
|
||||
printf("hatcher : ***** PRECISON ERROR ******* compare %f > %f res :%f %f test %f %f bDiv %e\n\n",bid,100*minBoxValue,a,b,a*Ax+b*Bx-Cx,a*Ay+b*By-Cy,bDiv);
|
||||
#endif
|
||||
fResolveResult = PRECISION_ERROR;
|
||||
fResolveResult = RESOLVE_PRECISION_ERROR;
|
||||
}
|
||||
//return vec2f(0,0); //G.Barrand : commented out to quiet Coverity.
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ inline bool write_array(hid_t a_loc,const std::string& a_name,
|
||||
cpt = ::H5Pcreate(H5P_DATASET_CREATE);
|
||||
if(cpt<0) return false;
|
||||
if(a_chunked) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ inline bool write_array(hid_t a_loc,const std::string& a_name,
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -87,9 +87,9 @@ inline bool write_array(hid_t a_loc,const std::string& a_name,
|
||||
if(a_chunked) {
|
||||
hsize_t mx_dims[1];
|
||||
mx_dims[0] = H5S_UNLIMITED; //extendable.
|
||||
file_space = ::H5Screate_simple(1,dims,mx_dims);
|
||||
file_space = ::H5Screate_simple(1,dims,mx_dims);
|
||||
} else {
|
||||
file_space = ::H5Screate_simple(1,dims,NULL);
|
||||
file_space = ::H5Screate_simple(1,dims,NULL);
|
||||
}
|
||||
if(file_space<0) {if(cpt>=0) ::H5Pclose(cpt);return false;}
|
||||
dataset = tools_H5Dcreate(a_loc,a_name.c_str(),a_file_type,file_space,cpt);
|
||||
@@ -98,7 +98,7 @@ inline bool write_array(hid_t a_loc,const std::string& a_name,
|
||||
if(dataset<0) return false;}
|
||||
|
||||
if(H5Dwrite(dataset,a_mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,a_array)<0) {
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return false;
|
||||
}
|
||||
::H5Dclose(dataset);
|
||||
@@ -116,7 +116,7 @@ inline bool write_vlen(hid_t a_loc,const std::string& a_name,
|
||||
cpt = ::H5Pcreate(H5P_DATASET_CREATE);
|
||||
if(cpt<0) return false;
|
||||
if(a_chunked) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ inline bool write_vlen(hid_t a_loc,const std::string& a_name,
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -150,9 +150,9 @@ inline bool write_vlen(hid_t a_loc,const std::string& a_name,
|
||||
if(a_chunked) {
|
||||
hsize_t mx_dims[1];
|
||||
mx_dims[0] = H5S_UNLIMITED; //extendable.
|
||||
file_space = ::H5Screate_simple(1,dims,mx_dims);
|
||||
file_space = ::H5Screate_simple(1,dims,mx_dims);
|
||||
} else {
|
||||
file_space = ::H5Screate_simple(1,dims,NULL);
|
||||
file_space = ::H5Screate_simple(1,dims,NULL);
|
||||
}
|
||||
if(file_space<0) {if(cpt>=0) ::H5Pclose(cpt);return false;}
|
||||
|
||||
@@ -165,14 +165,14 @@ inline bool write_vlen(hid_t a_loc,const std::string& a_name,
|
||||
if(dataset<0) return false;}
|
||||
|
||||
hid_t mem_type = ::H5Tvlen_create(a_mem_type);
|
||||
|
||||
|
||||
hvl_t wdata[1];
|
||||
wdata[0].len = a_size;
|
||||
wdata[0].p = (void*)a_array;
|
||||
|
||||
|
||||
if(H5Dwrite(dataset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata)<0) {
|
||||
::H5Tclose(mem_type);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return false;
|
||||
}
|
||||
::H5Tclose(mem_type);
|
||||
@@ -200,7 +200,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
|
||||
cpt = ::H5Pcreate(H5P_DATASET_CREATE);
|
||||
if(cpt<0) return false;
|
||||
if(a_chunked) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
|
||||
if(a_create) {
|
||||
hsize_t dims[1];
|
||||
dims[0] = a_size;
|
||||
file_space = ::H5Screate_simple(1,dims,NULL);
|
||||
file_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(file_space<0) {
|
||||
if(cpt>=0) ::H5Pclose(cpt);
|
||||
return false;
|
||||
@@ -265,9 +265,9 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
file_space = H5Dget_space(dataset);
|
||||
file_space = H5Dget_space(dataset);
|
||||
if(file_space<0) {
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
if(cpt>=0) ::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
|
||||
count[0] = number;
|
||||
if(H5Sselect_hyperslab(file_space,H5S_SELECT_SET,offset,NULL,count,NULL)<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
if(cpt>=0) ::H5Pclose(cpt);
|
||||
return false;
|
||||
}}
|
||||
@@ -287,7 +287,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
|
||||
|
||||
hsize_t dims[1];
|
||||
dims[0] = number;
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
@@ -297,7 +297,7 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
|
||||
|
||||
if(H5Dwrite(dataset,a_mem_type,mem_space,file_space,H5P_DEFAULT,a_array)<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
if(cpt>=0) ::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -314,8 +314,8 @@ inline bool write_append_array_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid
|
||||
unsigned int a_number,const T a_array[]) {
|
||||
hsize_t old_size = 0;
|
||||
|
||||
{hid_t dataspace = H5Dget_space(a_dataset);
|
||||
if(dataspace<0) return false;
|
||||
{hid_t dataspace = H5Dget_space(a_dataset);
|
||||
if(dataspace<0) return false;
|
||||
hsize_t dims[1];
|
||||
if(H5Sget_simple_extent_dims(dataspace,dims,NULL)<0) {
|
||||
::H5Sclose(dataspace);
|
||||
@@ -329,7 +329,7 @@ inline bool write_append_array_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid
|
||||
// if(H5Dextend(dataset,exts)<0) {
|
||||
if(H5Dset_extent(a_dataset,exts)<0) return false;}
|
||||
|
||||
hid_t file_space = H5Dget_space(a_dataset);
|
||||
hid_t file_space = H5Dget_space(a_dataset);
|
||||
if(file_space<0) return false;
|
||||
|
||||
{hsize_t offset[1];
|
||||
@@ -343,7 +343,7 @@ inline bool write_append_array_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid
|
||||
|
||||
hsize_t dims[1];
|
||||
dims[0] = a_number;
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
return false;
|
||||
@@ -366,8 +366,8 @@ inline bool write_append_vlen_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid_
|
||||
unsigned int a_number,const T a_array[]) {
|
||||
hsize_t old_size = 0;
|
||||
|
||||
{hid_t dataspace = H5Dget_space(a_dataset);
|
||||
if(dataspace<0) return false;
|
||||
{hid_t dataspace = H5Dget_space(a_dataset);
|
||||
if(dataspace<0) return false;
|
||||
hsize_t dims[1];
|
||||
if(H5Sget_simple_extent_dims(dataspace,dims,NULL)<0) {
|
||||
::H5Sclose(dataspace);
|
||||
@@ -381,7 +381,7 @@ inline bool write_append_vlen_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid_
|
||||
// if(H5Dextend(dataset,exts)<0) {
|
||||
if(H5Dset_extent(a_dataset,exts)<0) return false;}
|
||||
|
||||
hid_t file_space = H5Dget_space(a_dataset);
|
||||
hid_t file_space = H5Dget_space(a_dataset);
|
||||
if(file_space<0) return false;
|
||||
|
||||
{hsize_t offset[1];
|
||||
@@ -395,18 +395,18 @@ inline bool write_append_vlen_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid_
|
||||
|
||||
hsize_t dims[1];
|
||||
dims[0] = 1;
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
return false;
|
||||
}
|
||||
|
||||
hid_t mem_type = ::H5Tvlen_create(a_mem_type);
|
||||
|
||||
|
||||
hvl_t wdata[1];
|
||||
wdata[0].len = a_number;
|
||||
wdata[0].p = (void*)a_array;
|
||||
|
||||
|
||||
if(H5Dwrite(a_dataset,mem_type,mem_space,file_space,H5P_DEFAULT,wdata)<0) {
|
||||
::H5Tclose(mem_type);
|
||||
::H5Sclose(mem_space);
|
||||
@@ -427,7 +427,7 @@ inline bool write_append_array(hid_t a_loc,const std::string& a_name,hid_t a_fil
|
||||
hid_t dataset = tools_H5Dopen(a_loc,a_name.c_str());
|
||||
if(dataset<0) return false;
|
||||
bool status = write_append_array_dataset(dataset,a_file_type,a_mem_type,a_number,a_array);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ inline bool write_array_struct(
|
||||
){
|
||||
hsize_t dims[1];
|
||||
dims[0] = a_size;
|
||||
hid_t dataspace = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t dataspace = ::H5Screate_simple(1,dims,NULL);
|
||||
if(dataspace<0) return false;
|
||||
|
||||
hid_t dataset = tools_H5Dcreate(a_loc,a_name.c_str(),a_create_type,dataspace,H5P_DEFAULT);
|
||||
@@ -453,12 +453,12 @@ inline bool write_array_struct(
|
||||
}
|
||||
|
||||
if(H5Dwrite(dataset,aWriteType,H5S_ALL,H5S_ALL,H5P_DEFAULT,a_array)<0) {
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
::H5Sclose(dataspace);
|
||||
return false;
|
||||
}
|
||||
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
::H5Sclose(dataspace);
|
||||
|
||||
return true;
|
||||
@@ -476,7 +476,7 @@ inline bool read_scalar(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,T
|
||||
return false;
|
||||
}
|
||||
|
||||
hid_t mem_space = ::H5Screate(H5S_SCALAR);
|
||||
hid_t mem_space = ::H5Screate(H5S_SCALAR);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
@@ -550,7 +550,7 @@ inline bool read_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,un
|
||||
return true; //It is ok.
|
||||
}
|
||||
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
@@ -631,8 +631,8 @@ inline bool read_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,uns
|
||||
a_array = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
@@ -666,9 +666,9 @@ inline bool read_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,uns
|
||||
for(hsize_t index=0;index<len;index++,pos++,_data++) *pos = *_data;
|
||||
}
|
||||
a_size = len;
|
||||
|
||||
|
||||
::H5Dvlen_reclaim(mem_type,mem_space,H5P_DEFAULT,rdata);
|
||||
|
||||
|
||||
::H5Tclose(mem_type);
|
||||
::H5Sclose(mem_space);
|
||||
::H5Sclose(file_space);
|
||||
@@ -734,7 +734,7 @@ inline bool read_sub_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_typ
|
||||
}
|
||||
|
||||
// abcdef
|
||||
// 012345
|
||||
// 012345
|
||||
int remain = sz-a_offset;
|
||||
if(remain<=0) {
|
||||
::H5Sclose(file_space);
|
||||
@@ -743,7 +743,7 @@ inline bool read_sub_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_typ
|
||||
a_array = 0;
|
||||
return a_number?false:true;
|
||||
}
|
||||
|
||||
|
||||
int number = (int(a_number)<=remain) ? int(a_number) : remain;
|
||||
if(number<=0) {
|
||||
::H5Sclose(file_space);
|
||||
@@ -766,7 +766,7 @@ inline bool read_sub_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_typ
|
||||
}}
|
||||
|
||||
dims[0] = number;
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
@@ -850,7 +850,7 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
|
||||
}
|
||||
|
||||
// abcdef
|
||||
// 012345
|
||||
// 012345
|
||||
int remain = sz-a_offset;
|
||||
if(remain<=0) {
|
||||
::H5Sclose(file_space);
|
||||
@@ -859,7 +859,7 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
|
||||
a_array = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
{hsize_t offset[1];
|
||||
offset[0] = a_offset;
|
||||
hsize_t count[1];
|
||||
@@ -873,7 +873,7 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
|
||||
}}
|
||||
|
||||
dims[0] = 1;
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
@@ -907,9 +907,9 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
|
||||
for(hsize_t index=0;index<len;index++,pos++,_data++) *pos = *_data;
|
||||
}
|
||||
a_size = len;
|
||||
|
||||
|
||||
::H5Dvlen_reclaim(mem_type,mem_space,H5P_DEFAULT,rdata);
|
||||
|
||||
|
||||
::H5Tclose(mem_type);
|
||||
::H5Sclose(mem_space);
|
||||
::H5Sclose(file_space);
|
||||
@@ -994,7 +994,7 @@ inline bool read_array_struct(
|
||||
return false;
|
||||
}}
|
||||
|
||||
hid_t memspace = ::H5Screate_simple(dimn,dims,NULL);
|
||||
hid_t memspace = ::H5Screate_simple(dimn,dims,NULL);
|
||||
if(memspace<0) {
|
||||
delete [] dims;
|
||||
::H5Sclose(dataspace);
|
||||
@@ -1064,7 +1064,7 @@ inline bool read_struct(hid_t a_loc,const std::string& a_name,hid_t aReadType,T&
|
||||
::H5Dclose(dataset);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class TYPE>
|
||||
inline bool write_scalar(hid_t a_loc,const std::string& a_name,const TYPE& aData) {
|
||||
hid_t scalar = ::H5Screate(H5S_SCALAR);
|
||||
@@ -1076,7 +1076,7 @@ inline bool write_scalar(hid_t a_loc,const std::string& a_name,const TYPE& aData
|
||||
return false;
|
||||
}
|
||||
|
||||
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
@@ -1088,22 +1088,22 @@ inline bool write_scalar(hid_t a_loc,const std::string& a_name,const TYPE& aData
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(::H5Dwrite(dataset,to_T_mem_type(TYPE()),H5S_ALL,H5S_ALL,H5P_DEFAULT,&aData)<0) {
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline bool write_struct(hid_t a_loc,const std::string& a_name,
|
||||
inline bool write_struct(hid_t a_loc,const std::string& a_name,
|
||||
hid_t a_create_type,hid_t aWriteType,const T& aData) {
|
||||
hid_t scalar = ::H5Screate(H5S_SCALAR);
|
||||
if(scalar<0) return false;
|
||||
@@ -1114,7 +1114,7 @@ inline bool write_struct(hid_t a_loc,const std::string& a_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
@@ -1130,13 +1130,13 @@ inline bool write_struct(hid_t a_loc,const std::string& a_name,
|
||||
if(H5Dwrite(dataset,aWriteType,H5S_ALL,H5S_ALL,H5P_DEFAULT,&aData)<0) {
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return false;
|
||||
}
|
||||
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1288,7 +1288,7 @@ inline bool write_scalar_atb(hid_t aDS,const std::string& a_name,const TYPE& aDa
|
||||
if(has_attr==1) {
|
||||
if(H5Adelete(aDS,a_name.c_str())<0) return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t scalar = ::H5Screate(H5S_SCALAR);
|
||||
if(scalar<0) return false;
|
||||
|
||||
@@ -1297,16 +1297,16 @@ inline bool write_scalar_atb(hid_t aDS,const std::string& a_name,const TYPE& aDa
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(H5Awrite(aid,to_T_mem_type(TYPE()),&aData)<0) {
|
||||
::H5Sclose(scalar);
|
||||
::H5Aclose(aid);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
::H5Sclose(scalar);
|
||||
::H5Aclose(aid);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1321,7 +1321,7 @@ namespace hdf5 {
|
||||
inline bool write_strings(hid_t a_loc,const std::string& a_name,
|
||||
size_t a_number,const char** a_strings,
|
||||
unsigned int a_chunked = 0,unsigned int a_compress = 0) {
|
||||
size_t sz;char* buffer;
|
||||
size_t sz;char* buffer;
|
||||
if(!tools::strings2buf(a_number,a_strings,sz,buffer)) return false;
|
||||
sz--;
|
||||
bool status = hdf5::write_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),
|
||||
@@ -1333,7 +1333,7 @@ inline bool write_strings(hid_t a_loc,const std::string& a_name,
|
||||
inline bool write_strings(hid_t a_loc,const std::string& a_name,
|
||||
const std::vector<std::string>& a_strings,
|
||||
unsigned int a_chunked = 0,unsigned int a_compress = 0) {
|
||||
size_t sz;char* buffer;
|
||||
size_t sz;char* buffer;
|
||||
if(!tools::strings2buf(a_strings,sz,buffer)) return false;
|
||||
sz--;
|
||||
bool status = hdf5::write_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),
|
||||
@@ -1343,7 +1343,7 @@ inline bool write_strings(hid_t a_loc,const std::string& a_name,
|
||||
}
|
||||
|
||||
inline bool write_append_strings(hid_t a_loc,const std::string& a_name,size_t a_number,const char** a_strings) {
|
||||
size_t sz;char* buffer;
|
||||
size_t sz;char* buffer;
|
||||
if(!tools::strings2buf(a_number,a_strings,sz,buffer)) return false;
|
||||
sz--;
|
||||
bool status = hdf5::write_append_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),(unsigned int)sz,buffer);
|
||||
@@ -1352,7 +1352,7 @@ inline bool write_append_strings(hid_t a_loc,const std::string& a_name,size_t a_
|
||||
}
|
||||
|
||||
inline bool write_append_strings(hid_t a_loc,const std::string& a_name,const std::vector<std::string>& a_strings) {
|
||||
size_t sz;char* buffer;
|
||||
size_t sz;char* buffer;
|
||||
if(!tools::strings2buf(a_strings,sz,buffer)) return false;
|
||||
sz--;
|
||||
bool status = hdf5::write_append_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),(unsigned int)sz,buffer);
|
||||
|
||||
@@ -41,7 +41,7 @@ inline herr_t group_exists_visit(hid_t a_id,const char* a_name,void* a_tag){ //a
|
||||
inline bool group_exists(hid_t a_file_id,const std::string& a_name) {
|
||||
group_exists_struct visitor(a_name);
|
||||
::H5Giterate(a_file_id,".",NULL,group_exists_visit,&visitor);
|
||||
return visitor.m_found;
|
||||
return visitor.m_found;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -63,7 +63,7 @@ inline bool write_hdata(hid_t a_loc,const histo_data_t& a_hdata) {
|
||||
if(!write_std_vec<double>(a_loc,"bin_Sw2",a_hdata.m_bin_Sw2)) return false;
|
||||
if(!write_std_vec_vec<double>(a_loc,"bin_Sxw",a_hdata.m_bin_Sxw)) return false;
|
||||
if(!write_std_vec_vec<double>(a_loc,"bin_Sx2w",a_hdata.m_bin_Sx2w)) return false;
|
||||
|
||||
|
||||
// axes :
|
||||
{std::string name,saxis;
|
||||
for(unsigned int iaxis=0;iaxis<a_hdata.m_dimension;iaxis++) {
|
||||
@@ -76,15 +76,15 @@ inline bool write_hdata(hid_t a_loc,const histo_data_t& a_hdata) {
|
||||
if(!write_scalar<double>(a_loc,name+"maximum_value",_axis.m_maximum_value)) return false;
|
||||
if(!write_scalar<bool>(a_loc,name+"fixed",_axis.m_fixed)) return false;
|
||||
if(!write_scalar<double>(a_loc,name+"bin_width",_axis.m_bin_width)) return false;
|
||||
if(!write_std_vec<double>(a_loc,name+"edges",_axis.m_edges)) return false;
|
||||
if(!write_std_vec<double>(a_loc,name+"edges",_axis.m_edges)) return false;
|
||||
}}
|
||||
|
||||
|
||||
// etc :
|
||||
if(!write_std_vec<double>(a_loc,"in_range_plane_Sxyw",a_hdata.m_in_range_plane_Sxyw)) return false;
|
||||
|
||||
|
||||
// m_annotations :
|
||||
if(!write_std_map_ss(a_loc,"annotations",a_hdata.m_annotations)) return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ inline bool write_histo(std::ostream& a_out,hid_t a_loc,const std::string& a_nam
|
||||
}
|
||||
|
||||
if(!write_hdata(histo,a_histo.dac())) {::H5Gclose(histo);return false;}
|
||||
|
||||
|
||||
::H5Gclose(histo);
|
||||
|
||||
a_histo.not_a_profile(); //trick to be sure to use this function on an histo and not a profile.
|
||||
@@ -151,7 +151,7 @@ inline bool write_profile(std::ostream& a_out,hid_t a_loc,const std::string& a_n
|
||||
return false;
|
||||
}
|
||||
|
||||
typename PROFILE::pd_t pdata = a_histo.get_histo_data();
|
||||
typename PROFILE::pd_t pdata = a_histo.get_histo_data();
|
||||
|
||||
if(!write_hdata(histo,pdata)) {::H5Gclose(histo);return false;}
|
||||
|
||||
@@ -175,10 +175,10 @@ inline bool read_hdata(hid_t a_loc,histo_data_t& a_hdata) {
|
||||
if(!read_std_vec<unsigned int>(a_loc,"bin_entries",a_hdata.m_bin_entries)) return false;
|
||||
if(!read_std_vec<double>(a_loc,"bin_Sw",a_hdata.m_bin_Sw)) return false;
|
||||
if(!read_std_vec<double>(a_loc,"bin_Sw2",a_hdata.m_bin_Sw2)) return false;
|
||||
|
||||
|
||||
if(!read_std_vec_vec<double>(a_loc,"bin_Sxw",a_hdata.m_bin_Sxw)) return false;
|
||||
if(!read_std_vec_vec<double>(a_loc,"bin_Sx2w",a_hdata.m_bin_Sx2w)) return false;
|
||||
|
||||
|
||||
// axes :
|
||||
{a_hdata.m_axes.resize(a_hdata.m_dimension);
|
||||
std::string name,saxis;
|
||||
@@ -192,15 +192,15 @@ inline bool read_hdata(hid_t a_loc,histo_data_t& a_hdata) {
|
||||
if(!read_scalar<double>(a_loc,name+"maximum_value",_axis.m_maximum_value)) return false;
|
||||
if(!read_scalar<bool>(a_loc,name+"fixed",_axis.m_fixed)) return false;
|
||||
if(!read_scalar<double>(a_loc,name+"bin_width",_axis.m_bin_width)) return false;
|
||||
if(!read_std_vec<double>(a_loc,name+"edges",_axis.m_edges)) return false;
|
||||
if(!read_std_vec<double>(a_loc,name+"edges",_axis.m_edges)) return false;
|
||||
}}
|
||||
|
||||
|
||||
// etc :
|
||||
if(!read_std_vec<double>(a_loc,"in_range_plane_Sxyw",a_hdata.m_in_range_plane_Sxyw)) return false;
|
||||
|
||||
|
||||
// m_annotations :
|
||||
if(!read_std_map_ss(a_loc,"annotations",a_hdata.m_annotations)) return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -227,11 +227,11 @@ inline bool read_histo(std::ostream& a_out,hid_t a_loc,const std::string& a_name
|
||||
if(a_verb_class) {
|
||||
a_out << "tools::hdf5::read_histo :"
|
||||
<< " read class " << tools::sout(sclass) << " not " << tools::sout(HISTO::s_class()) << std::endl;
|
||||
}
|
||||
}
|
||||
::H5Gclose(histo);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int v;
|
||||
if(!read_atb(histo,"version",v)) {
|
||||
a_out << "tools::hdf5::read_histo : read_atb version failed." << std::endl;
|
||||
@@ -244,9 +244,9 @@ inline bool read_histo(std::ostream& a_out,hid_t a_loc,const std::string& a_name
|
||||
if(!read_hdata(histo,hdata)) {::H5Gclose(histo);return false;}
|
||||
|
||||
::H5Gclose(histo);
|
||||
|
||||
|
||||
hdata.update_fast_getters();
|
||||
|
||||
|
||||
a_histo = new HISTO;
|
||||
a_histo->copy_from_data(hdata);
|
||||
a_histo->not_a_profile(); //trick to be sure to use this function on an histo and not a profile.
|
||||
@@ -278,7 +278,7 @@ inline bool read_profile(std::ostream& a_out,hid_t a_loc,const std::string& a_na
|
||||
::H5Gclose(histo);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int v;
|
||||
if(!read_atb(histo,"version",v)) {
|
||||
a_out << "tools::hdf5::read_profile : read_atb version failed." << std::endl;
|
||||
@@ -298,9 +298,9 @@ inline bool read_profile(std::ostream& a_out,hid_t a_loc,const std::string& a_na
|
||||
if(!read_scalar<double>(histo,"max_v",pdata.m_max_v)) {::H5Gclose(histo);return false;}
|
||||
|
||||
::H5Gclose(histo);
|
||||
|
||||
|
||||
pdata.update_fast_getters();
|
||||
|
||||
|
||||
a_histo = new PROFILE;
|
||||
a_histo->copy_from_data(pdata);
|
||||
return true;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define tools_H5Gcreate H5Gcreate
|
||||
#define tools_H5Gopen H5Gopen
|
||||
#define tools_H5Aiterate H5Aiterate
|
||||
#define tools_H5free_memory free
|
||||
#else
|
||||
#define tools_H5Dopen H5Dopen1
|
||||
#define tools_H5Dcreate H5Dcreate1
|
||||
@@ -29,6 +30,7 @@
|
||||
#define tools_H5Gcreate H5Gcreate1
|
||||
#define tools_H5Gopen H5Gopen1
|
||||
#define tools_H5Aiterate H5Aiterate1
|
||||
#define tools_H5free_memory H5free_memory
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,8 +30,8 @@ inline bool read_header(hid_t a_file,std::string& a_writer,int& a_data_schema_ve
|
||||
}
|
||||
::H5Gclose(header);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -90,14 +90,14 @@ public:
|
||||
m_basket_pos = 0;
|
||||
m_basket_end = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(m_want_new_basket_size) {
|
||||
delete [] m_basket;
|
||||
m_basket = new T[m_want_new_basket_size];
|
||||
m_basket_pos = 0;
|
||||
m_basket_size = m_want_new_basket_size;
|
||||
m_want_new_basket_size = 0;
|
||||
}
|
||||
}
|
||||
tools::uint64 remain = m_branch.entries()-m_branch.pos();
|
||||
size_t n = tools::mn<size_t>((size_t)remain,m_basket_size);
|
||||
if(!m_branch.read_page<T>(n,m_basket)) {
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
m_basket_pos = 0;
|
||||
m_basket_end = n;
|
||||
m_basket_end = n;
|
||||
}
|
||||
m_ref = m_basket[m_basket_pos];
|
||||
m_basket_pos++;
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
if(&a_from==this) return *this;
|
||||
m_name = a_from.m_name;
|
||||
m_basket_size = a_from.m_basket_size;
|
||||
m_basket_pos = 0;
|
||||
m_basket_pos = 0;
|
||||
m_basket_end = 0;
|
||||
m_want_new_basket_size = 0;
|
||||
return *this;
|
||||
@@ -257,9 +257,9 @@ public:
|
||||
TOOLS_CLASS_STRING_VALUE(vector_int,vector<int>)
|
||||
TOOLS_CLASS_STRING_VALUE(vector_float,vector<float>)
|
||||
TOOLS_CLASS_STRING_VALUE(vector_double,vector<double>)
|
||||
|
||||
|
||||
TOOLS_CLASS_STRING_VALUE(string,string)
|
||||
|
||||
|
||||
TOOLS_CLASS_STRING_VALUE(vector_int64,vector<tools::int64>)
|
||||
TOOLS_CLASS_STRING_VALUE(vector_uchar,vector<tools::uchar>)
|
||||
TOOLS_CLASS_STRING_VALUE(vector_ushort,vector<tools::ushort>)
|
||||
@@ -434,7 +434,7 @@ public:
|
||||
m_name = a_from.m_name;
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
public:
|
||||
//const std::vector<T>& ref() const {return m_ref;}
|
||||
protected:
|
||||
std::vector<T>& m_ref;
|
||||
@@ -472,7 +472,7 @@ public:
|
||||
parent::operator=(a_from);
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
public:
|
||||
//bool get_entry(std::vector<T>& a_v) const {
|
||||
// a_v = m_tmp;
|
||||
// return true;
|
||||
@@ -635,7 +635,7 @@ public:
|
||||
m_name = a_from.m_name;
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
public:
|
||||
//const std::string& ref() const {return m_ref;}
|
||||
protected:
|
||||
std::string& m_ref;
|
||||
@@ -687,7 +687,7 @@ public:
|
||||
protected:
|
||||
std::string m_tmp;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
ntuple(std::ostream& a_out,hid_t a_group,const std::string& a_name,
|
||||
unsigned int a_compress,size_t /*a_basket_size*//* = 32000*/)
|
||||
@@ -712,22 +712,22 @@ public:
|
||||
if(!col) {tools::safe_clear<icol>(m_cols);return;}\
|
||||
m_cols.push_back(col);\
|
||||
}
|
||||
|
||||
|
||||
TOOLS_HDF5_NTUPLE_READ_CREATE_COL(char)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(short)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(int)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(tools::int64)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(float)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(double)
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(tools::byte)
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(tools::byte)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(tools::ushort)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(tools::uint32)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(tools::uint64)
|
||||
|
||||
//else TOOLS_HDF5_NTUPLE_READ_CREATE_COL(bool) //use byte=uchar.
|
||||
|
||||
|
||||
else
|
||||
if((*it)->form()==s_string()) {
|
||||
column_string* col = new column_string(*this,*(*it),false,(*it)->name(),0);
|
||||
@@ -739,10 +739,10 @@ public:
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_VEC_COL(short,short)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_VEC_COL(int,int)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_VEC_COL(int64,tools::int64)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_VEC_COL(float,float)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_VEC_COL(double,double)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_VEC_COL(uchar,tools::uchar)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_VEC_COL(ushort,tools::ushort)
|
||||
else TOOLS_HDF5_NTUPLE_READ_CREATE_VEC_COL(uint32,tools::uint32)
|
||||
@@ -771,11 +771,11 @@ public:
|
||||
if(!initialize(a_out,a_bd)) {}
|
||||
}
|
||||
|
||||
ntuple(std::ostream& a_out,hid_t a_group,const tools::ntuple_booking& a_bkg,
|
||||
ntuple(std::ostream& a_out,hid_t a_group,const tools::ntuple_booking& a_bkg,
|
||||
unsigned int a_compress,size_t a_basket_size/* = 32000*/)
|
||||
:store(a_out,a_group,a_bkg.name(),true,a_compress) //true=write
|
||||
,m_title(a_bkg.title())
|
||||
{
|
||||
{
|
||||
const std::vector<tools::column_booking>& cols = a_bkg.columns();
|
||||
tools_vforcit(tools::column_booking,cols,it){
|
||||
|
||||
@@ -820,22 +820,22 @@ public:
|
||||
return;\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
TOOLS_HDF5_NTUPLE_CREATE_COL(char)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(short)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(int)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(tools::int64)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(float)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(double)
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(tools::byte)
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(tools::byte)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(tools::ushort)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(tools::uint32)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_COL(tools::uint64)
|
||||
|
||||
//else TOOLS_HDF5_NTUPLE_CREATE_COL(bool) //use byte=uchar.
|
||||
|
||||
|
||||
else if((*it).cls_id()==tools::_cid(std::string())) {
|
||||
if(!create_column_string((*it).name(),a_basket_size)) {
|
||||
m_out << "tools::hdf5::ntuple :"
|
||||
@@ -849,10 +849,10 @@ public:
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_VEC_COL(short)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_VEC_COL(int)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_VEC_COL(tools::int64)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_VEC_COL(float)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_VEC_COL(double)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_VEC_COL(tools::uchar)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_VEC_COL(tools::ushort)
|
||||
else TOOLS_HDF5_NTUPLE_CREATE_VEC_COL(tools::uint32)
|
||||
@@ -868,7 +868,7 @@ public:
|
||||
<< std::endl;
|
||||
tools::safe_clear<icol>(m_cols);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef TOOLS_HDF5_NTUPLE_CREATE_COL
|
||||
#undef TOOLS_HDF5_NTUPLE_CREATE_VEC_COL
|
||||
@@ -885,9 +885,9 @@ public:
|
||||
bool initialize(std::ostream& a_out,const tools::ntuple_binding& a_bd = tools::ntuple_binding()) {
|
||||
tools::safe_clear<icol>(m_cols);
|
||||
{tools_vforcit(pages*,m_pagess,it) (*it)->reset_pos();}
|
||||
|
||||
|
||||
tools_vforcit(pages*,m_pagess,it) {
|
||||
|
||||
|
||||
#define TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(a__type) \
|
||||
if((*it)->form()==tools::stype(a__type())) {\
|
||||
a__type* user_var = a_bd.find_variable<a__type>((*it)->name());\
|
||||
@@ -901,7 +901,7 @@ public:
|
||||
m_cols.push_back(col);\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
#define TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(a__vec_type,a__type) \
|
||||
if((*it)->form()==s_vector_##a__vec_type()) {\
|
||||
std::vector<a__type>* user_var = a_bd.find_variable< std::vector<a__type> >((*it)->name());\
|
||||
@@ -921,17 +921,17 @@ public:
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(short)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(int)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(tools::int64)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(float)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(double)
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(tools::byte)
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(tools::byte)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(tools::ushort)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(tools::uint32)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(tools::uint64)
|
||||
|
||||
//else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_COL(bool) //use byte=uchar.
|
||||
|
||||
|
||||
else
|
||||
if((*it)->form()==s_string()) {
|
||||
std::string* user_var = a_bd.find_variable<std::string>((*it)->name());
|
||||
@@ -945,15 +945,15 @@ public:
|
||||
m_cols.push_back(col);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(char,char)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(short,short)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(int,int)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(int64,tools::int64)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(float,float)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(double,double)
|
||||
|
||||
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(uchar,tools::uchar)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(ushort,tools::ushort)
|
||||
else TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(uint32,tools::uint32)
|
||||
@@ -975,9 +975,9 @@ public:
|
||||
#undef TOOLS_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const std::string& title() const {return m_title;}
|
||||
|
||||
|
||||
const std::vector<icol*>& columns() const {return m_cols;}
|
||||
std::vector<icol*>& columns() {return m_cols;}
|
||||
|
||||
@@ -1024,7 +1024,7 @@ public:
|
||||
m_cols.push_back(col);
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
column_ref<T>* find_column_ref(const std::string& a_name) {
|
||||
icol* col = tools::find_named<icol>(m_cols,a_name);
|
||||
@@ -1037,7 +1037,7 @@ public:
|
||||
if(!col) return 0;
|
||||
return tools::id_cast<icol, column<T> >(*col);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
std_vector_column_ref<T>* find_std_vector_column_ref(const std::string& a_name) {
|
||||
icol* col = tools::find_named<icol>(m_cols,a_name);
|
||||
@@ -1050,13 +1050,13 @@ public:
|
||||
if(!col) return 0;
|
||||
return tools::id_cast<icol, std_vector_column<T> >(*col);
|
||||
}
|
||||
|
||||
|
||||
column_string* find_column_string(const std::string& a_name) {
|
||||
icol* col = tools::find_named<icol>(m_cols,a_name);
|
||||
if(!col) return 0;
|
||||
return tools::id_cast<icol, column_string >(*col);
|
||||
}
|
||||
|
||||
|
||||
bool add_row() { //write.
|
||||
if(m_cols.empty()) return false;
|
||||
bool status = true;
|
||||
@@ -1074,7 +1074,7 @@ public:
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool set_basket_size(size_t a_size) {
|
||||
tools_vforit(icol*,m_cols,it) {if(!(*it)->set_basket_size(a_size)) return false;}
|
||||
return true;
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
return;
|
||||
}
|
||||
if(!read_scalar<tools::uint64>(m_group,s_entries(),m_entries)) {
|
||||
m_out << "pages::pages : read_scalar(entries) failed." << std::endl;
|
||||
m_out << "pages::pages : read_scalar(entries) failed." << std::endl;
|
||||
::H5Gclose(m_group);
|
||||
m_group = -1;
|
||||
return;
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
if(!write_scalar<tools::uint64>(m_group,s_entries(),m_entries)) {
|
||||
m_out << "pages::~pages : write_scalar(entries) failed." << std::endl;
|
||||
}
|
||||
if(m_dataset>=0) ::H5Dclose(m_dataset);
|
||||
if(m_dataset>=0) ::H5Dclose(m_dataset);
|
||||
}
|
||||
::H5Gclose(m_group);
|
||||
#ifdef TOOLS_MEM
|
||||
@@ -92,7 +92,7 @@ protected:
|
||||
pages& operator=(const pages&){return *this;}
|
||||
public:
|
||||
bool is_valid() const {return m_group<0?false:true;}
|
||||
|
||||
|
||||
const std::string& name() const {return m_name;}
|
||||
const std::string& form() const {return m_form;}
|
||||
//int type() const {return m_type;}
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
tools::uint64 entries() const {return m_entries;}
|
||||
tools::uint64 pos() const {return m_pos;}
|
||||
void reset_pos() {m_pos = 0;}
|
||||
|
||||
|
||||
template <class TYPE>
|
||||
bool write_page(size_t a_size,const TYPE* a_array) {
|
||||
if(!m_pos) {
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
m_entries = m_pos;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class TYPE>
|
||||
bool read_page(size_t a_size,TYPE* a_array) {
|
||||
//it is assumed that a_array can contain a_size*sizeof(TYPE) bytes.
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
TYPE* wpos = (TYPE*)a_array;
|
||||
for(size_t i=0;i<n;i++,rpos++,wpos++) *wpos = *rpos;
|
||||
for(size_t i=n;i<_size;i++,rpos++,wpos++) *wpos = TYPE();}
|
||||
|
||||
|
||||
delete [] array;
|
||||
|
||||
m_pos += n;
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
m_entries++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
bool write_string(const std::string& a_string) {return write_vlen<char>(a_string.size(),a_string.c_str());}
|
||||
|
||||
@@ -234,15 +234,15 @@ public:
|
||||
delete [] _data;
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
bool write_strings(size_t a_number,void* a_array) {
|
||||
size_t sz = m_size*a_number;
|
||||
char* buffer = new char[sz];
|
||||
{char* pos = buffer;
|
||||
for(size_t index=0;index<sz;index++,pos++) *pos = ' ';}
|
||||
|
||||
for(size_t index=0;index<sz;index++,pos++) *pos = ' ';}
|
||||
|
||||
{char** strings = (char**)a_array;
|
||||
char* pos = buffer;
|
||||
size_t ls;
|
||||
@@ -253,8 +253,8 @@ public:
|
||||
*(pos+m_size-1) = 0;
|
||||
pos += m_size;
|
||||
}}
|
||||
|
||||
if(!m_pos) {
|
||||
|
||||
if(!m_pos) {
|
||||
unsigned int chunked = 32*m_size; //<size>A strings.
|
||||
if(!write_array<char>(m_group,s_pages(),sz,buffer,chunked,m_compress)) {
|
||||
m_out << "pages::write_strings : write_strings() failed. Pos " << m_pos << std::endl;
|
||||
@@ -295,11 +295,11 @@ public:
|
||||
::memcpy(strings[index],pos,m_size*sizeof(char));
|
||||
pos += m_size;
|
||||
}}
|
||||
delete [] array;
|
||||
delete [] array;
|
||||
m_pos += n;
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
protected:
|
||||
std::ostream& m_out;
|
||||
std::string m_name;
|
||||
|
||||
@@ -153,7 +153,7 @@ protected:
|
||||
public:
|
||||
std::ostream& out() const {return m_out;}
|
||||
//bool fill(tools::uint32 &a_n){a_n = 0;return true;}
|
||||
|
||||
|
||||
bool entries(tools::uint64& a_entries) const {
|
||||
if(m_pagess.empty()) {a_entries = 0;return true;}
|
||||
a_entries = m_pagess.front()->entries();
|
||||
@@ -165,9 +165,9 @@ public:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
pages* create_pages(const std::string& a_name,const std::string& a_form) {
|
||||
//::printf("debug : create_pages %s %s\n",a_name.c_str(),a_form.c_str());
|
||||
pages* _pages = new pages(m_out,m_group,a_name,a_form,m_write,m_compress);
|
||||
|
||||
@@ -127,20 +127,20 @@ inline hid_t compound_mem_type(hid_t a_file_type){
|
||||
//printf("debug : members : %d (%d) : %s : begin\n",index,mn,mname);
|
||||
|
||||
{H5T_class_t mclass = H5Tget_class(mtype);
|
||||
if( (mclass==H5T_INTEGER) ||
|
||||
if( (mclass==H5T_INTEGER) ||
|
||||
(mclass==H5T_STRING) ||
|
||||
(mclass==H5T_FLOAT) ) {
|
||||
hid_t mmem_type = basic_mem_type(mtype);
|
||||
if(mmem_type<0) {
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
if(H5Tinsert(mem_type,mname,moffset,mmem_type)<0) {
|
||||
::H5Tclose(mmem_type);
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
@@ -154,7 +154,7 @@ inline hid_t compound_mem_type(hid_t a_file_type){
|
||||
delete [] dims;
|
||||
delete [] perms;
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
@@ -163,7 +163,7 @@ inline hid_t compound_mem_type(hid_t a_file_type){
|
||||
delete [] dims;
|
||||
delete [] perms;
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
@@ -173,7 +173,7 @@ inline hid_t compound_mem_type(hid_t a_file_type){
|
||||
delete [] perms;
|
||||
::H5Tclose(base_type);
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
@@ -184,7 +184,7 @@ inline hid_t compound_mem_type(hid_t a_file_type){
|
||||
if(array_type<0) {
|
||||
::H5Tclose(mmem_type);
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
@@ -193,7 +193,7 @@ inline hid_t compound_mem_type(hid_t a_file_type){
|
||||
if(H5Tinsert(mem_type,mname,moffset,array_type)<0) {
|
||||
::H5Tclose(array_type);
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
@@ -203,27 +203,27 @@ inline hid_t compound_mem_type(hid_t a_file_type){
|
||||
hid_t mmem_type = compound_mem_type(mtype);
|
||||
if(mem_type<0) {
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
if(H5Tinsert(mem_type,mname,moffset,mmem_type)<0) {
|
||||
::H5Tclose(mmem_type);
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}
|
||||
::H5Tclose(mmem_type);
|
||||
} else {
|
||||
::H5Tclose(mtype);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
::H5Tclose(mem_type);
|
||||
return failure();
|
||||
}}
|
||||
::H5Tclose(mtype);
|
||||
//printf("debug : compound_mem_type : %d (%d) : %s : end\n",index,mn,mname);
|
||||
if(mname) ::free(mname);
|
||||
if(mname) tools_H5free_memory(mname);
|
||||
}
|
||||
|
||||
return mem_type;
|
||||
@@ -323,7 +323,7 @@ inline bool write_atb(hid_t a_id,const std::string& a_name,const std::string& a_
|
||||
if(has_attr==1) {
|
||||
if(H5Adelete(a_id,a_name.c_str())<0) return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t datatype = string_datatype(a_data.size()+1);
|
||||
if(datatype<0) return false;
|
||||
|
||||
@@ -332,28 +332,28 @@ inline bool write_atb(hid_t a_id,const std::string& a_name,const std::string& a_
|
||||
::H5Tclose(datatype);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t aid = tools_H5Acreate(a_id,a_name.c_str(),datatype,scalar,H5P_DEFAULT);
|
||||
if(aid<0) {
|
||||
::H5Sclose(scalar);
|
||||
::H5Tclose(datatype);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(H5Awrite(aid,datatype,a_data.c_str())<0) {
|
||||
::H5Aclose(aid);
|
||||
::H5Sclose(scalar);
|
||||
::H5Tclose(datatype);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
::H5Aclose(aid);
|
||||
::H5Sclose(scalar);
|
||||
::H5Tclose(datatype);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool write_bool(hid_t a_loc,const std::string& a_name,bool a_data) {
|
||||
hid_t scalar = ::H5Screate(H5S_SCALAR);
|
||||
if(scalar<0) return false;
|
||||
@@ -363,7 +363,7 @@ inline bool write_bool(hid_t a_loc,const std::string& a_name,bool a_data) {
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
@@ -375,21 +375,21 @@ inline bool write_bool(hid_t a_loc,const std::string& a_name,bool a_data) {
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
unsigned char data = a_data?1:0;
|
||||
if(::H5Dwrite(dataset,H5T_NATIVE_UCHAR,H5S_ALL,H5S_ALL,H5P_DEFAULT,&data)<0) {
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool write_string(hid_t a_loc,const std::string& a_name,const std::string& a_string) {
|
||||
hid_t scalar = ::H5Screate(H5S_SCALAR);
|
||||
if(scalar<0) return false;
|
||||
@@ -400,7 +400,7 @@ inline bool write_string(hid_t a_loc,const std::string& a_name,const std::string
|
||||
return false;
|
||||
}
|
||||
|
||||
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(compact,H5D_COMPACT)<0) {
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
@@ -413,7 +413,7 @@ inline bool write_string(hid_t a_loc,const std::string& a_name,const std::string
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t dataset = tools_H5Dcreate(a_loc,a_name.c_str(),file_type,scalar,compact);
|
||||
if(dataset<0) {
|
||||
::H5Pclose(compact);
|
||||
@@ -421,21 +421,21 @@ inline bool write_string(hid_t a_loc,const std::string& a_name,const std::string
|
||||
::H5Tclose(file_type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t mem_type = file_type;
|
||||
if(H5Dwrite(dataset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,a_string.c_str())<0) {
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(file_type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
::H5Pclose(compact);
|
||||
::H5Sclose(scalar);
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(file_type);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ inline bool write_string_dataset(hid_t a_loc,const std::string& a_name,
|
||||
cpt = ::H5Pcreate(H5P_DATASET_CREATE);
|
||||
if(cpt<0) return false;
|
||||
if(a_chunked) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -458,7 +458,7 @@ inline bool write_string_dataset(hid_t a_loc,const std::string& a_name,
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -485,9 +485,9 @@ inline bool write_string_dataset(hid_t a_loc,const std::string& a_name,
|
||||
if(a_chunked) {
|
||||
hsize_t mx_dims[1];
|
||||
mx_dims[0] = H5S_UNLIMITED; //extendable.
|
||||
file_space = ::H5Screate_simple(1,dims,mx_dims);
|
||||
file_space = ::H5Screate_simple(1,dims,mx_dims);
|
||||
} else {
|
||||
file_space = ::H5Screate_simple(1,dims,NULL);
|
||||
file_space = ::H5Screate_simple(1,dims,NULL);
|
||||
}
|
||||
if(file_space<0) {if(cpt>=0) ::H5Pclose(cpt);::H5Tclose(file_type);return false;}}
|
||||
|
||||
@@ -500,16 +500,16 @@ inline bool write_string_dataset(hid_t a_loc,const std::string& a_name,
|
||||
}
|
||||
|
||||
hid_t mem_type = file_type;
|
||||
|
||||
|
||||
const char* wdata[1];
|
||||
wdata[0] = a_string.c_str();
|
||||
|
||||
|
||||
if(H5Dwrite(dataset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata)<0) {
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(file_type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
::H5Tclose(file_type);
|
||||
::H5Dclose(dataset);
|
||||
|
||||
@@ -525,8 +525,8 @@ inline bool write_string_dataset(hid_t a_loc,const std::string& a_name,
|
||||
inline bool write_append_string_dataset(hid_t a_dataset,const std::string& a_string) {
|
||||
hsize_t old_size = 0;
|
||||
|
||||
{hid_t dataspace = H5Dget_space(a_dataset);
|
||||
if(dataspace<0) return false;
|
||||
{hid_t dataspace = H5Dget_space(a_dataset);
|
||||
if(dataspace<0) return false;
|
||||
hsize_t dims[1];
|
||||
if(H5Sget_simple_extent_dims(dataspace,dims,NULL)<0) {
|
||||
::H5Sclose(dataspace);
|
||||
@@ -534,13 +534,13 @@ inline bool write_append_string_dataset(hid_t a_dataset,const std::string& a_str
|
||||
}
|
||||
old_size = dims[0];
|
||||
::H5Sclose(dataspace);}
|
||||
|
||||
|
||||
{hsize_t exts[1];
|
||||
exts[0] = old_size+1;
|
||||
// if(H5Dextend(dataset,exts)<0) {
|
||||
if(H5Dset_extent(a_dataset,exts)<0) return false;}
|
||||
|
||||
hid_t file_space = H5Dget_space(a_dataset);
|
||||
hid_t file_space = H5Dget_space(a_dataset);
|
||||
if(file_space<0) return false;
|
||||
|
||||
{hsize_t offset[1];
|
||||
@@ -554,7 +554,7 @@ inline bool write_append_string_dataset(hid_t a_dataset,const std::string& a_str
|
||||
|
||||
hsize_t dims[1];
|
||||
dims[0] = 1;
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
return false;
|
||||
@@ -566,10 +566,10 @@ inline bool write_append_string_dataset(hid_t a_dataset,const std::string& a_str
|
||||
::H5Sclose(file_space);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const char* wdata[1];
|
||||
wdata[0] = a_string.c_str();
|
||||
|
||||
|
||||
if(H5Dwrite(a_dataset,mem_type,mem_space,file_space,H5P_DEFAULT,wdata)<0) {
|
||||
::H5Tclose(mem_type);
|
||||
::H5Sclose(mem_space);
|
||||
@@ -602,14 +602,14 @@ inline bool write_array_string(hid_t a_loc,const std::string& a_name,const std::
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t file_type = string_datatype(sz);
|
||||
if(file_type<0) {
|
||||
delete [] buffer;
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t dataset = tools_H5Dcreate(a_loc,a_name.c_str(),file_type,scalar,H5P_DEFAULT);
|
||||
if(dataset<0) {
|
||||
delete [] buffer;
|
||||
@@ -617,19 +617,19 @@ inline bool write_array_string(hid_t a_loc,const std::string& a_name,const std::
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t mem_type = file_type;
|
||||
if(H5Dwrite(dataset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,buffer)<0) {
|
||||
delete [] buffer;
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(file_type);
|
||||
::H5Sclose(scalar);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
delete [] buffer;
|
||||
|
||||
::H5Dclose(dataset);
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(file_type);
|
||||
::H5Sclose(scalar);
|
||||
return true;
|
||||
@@ -644,7 +644,7 @@ inline bool write_object(hid_t a_loc,const std::string& a_name,hid_t a_file_type
|
||||
cpt = ::H5Pcreate(H5P_DATASET_CREATE);
|
||||
if(cpt<0) return false;
|
||||
if(chunked) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_CHUNKED)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -655,7 +655,7 @@ inline bool write_object(hid_t a_loc,const std::string& a_name,hid_t a_file_type
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
if(H5Pset_layout(cpt,H5D_COMPACT)<0) {
|
||||
::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
@@ -669,7 +669,7 @@ inline bool write_object(hid_t a_loc,const std::string& a_name,hid_t a_file_type
|
||||
} else {
|
||||
cpt = H5P_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
hsize_t dims[1];
|
||||
dims[0] = 1;
|
||||
hid_t simple = ::H5Screate_simple(1,dims,NULL);
|
||||
@@ -684,31 +684,31 @@ inline bool write_object(hid_t a_loc,const std::string& a_name,hid_t a_file_type
|
||||
if(cpt>=0) ::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t dataset = tools_H5Dcreate(a_loc,a_name.c_str(),a_file_type,simple,cpt);
|
||||
if(dataset<0) {
|
||||
::H5Tclose(mem_type);
|
||||
::H5Tclose(mem_type);
|
||||
::H5Sclose(simple);
|
||||
if(cpt>=0) ::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(H5Dwrite(dataset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,a_data)<0) {
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(mem_type);
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(mem_type);
|
||||
::H5Sclose(simple);
|
||||
if(cpt>=0) ::H5Pclose(cpt);
|
||||
return false;
|
||||
}
|
||||
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(mem_type);
|
||||
|
||||
::H5Dclose(dataset);
|
||||
::H5Tclose(mem_type);
|
||||
::H5Sclose(simple);
|
||||
if(cpt>=0) ::H5Pclose(cpt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool read_string(hid_t a_loc,const std::string& a_name,std::string& a_string) {
|
||||
// From H5LTread_dataset_string.
|
||||
hid_t dataset = tools_H5Dopen(a_loc,a_name.c_str());
|
||||
@@ -731,7 +731,7 @@ inline bool read_string(hid_t a_loc,const std::string& a_name,std::string& a_str
|
||||
a_string.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
size_t sz = H5Tget_size(file_type);
|
||||
::H5Tclose(file_type);
|
||||
if(!sz) {
|
||||
@@ -740,7 +740,7 @@ inline bool read_string(hid_t a_loc,const std::string& a_name,std::string& a_str
|
||||
return false;
|
||||
}
|
||||
|
||||
// We could have use file_type since, for string,
|
||||
// We could have use file_type since, for string,
|
||||
// file type is the same than memory type.
|
||||
hid_t mem_type = string_datatype(sz);
|
||||
if(mem_type<0) {
|
||||
@@ -813,7 +813,7 @@ inline bool read_sub_string(hid_t a_loc,const std::string& a_name,unsigned int a
|
||||
}
|
||||
|
||||
// abcdef
|
||||
// 012345
|
||||
// 012345
|
||||
int remain = sz-a_offset;
|
||||
if(remain<=0) {
|
||||
::H5Sclose(file_space);
|
||||
@@ -821,7 +821,7 @@ inline bool read_sub_string(hid_t a_loc,const std::string& a_name,unsigned int a
|
||||
a_string.clear();
|
||||
return false;
|
||||
}}
|
||||
|
||||
|
||||
{hsize_t offset[1];
|
||||
offset[0] = a_offset;
|
||||
hsize_t count[1];
|
||||
@@ -834,7 +834,7 @@ inline bool read_sub_string(hid_t a_loc,const std::string& a_name,unsigned int a
|
||||
}}
|
||||
|
||||
dims[0] = 1;
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
|
||||
if(mem_space<0) {
|
||||
::H5Sclose(file_space);
|
||||
::H5Dclose(dataset);
|
||||
@@ -891,13 +891,13 @@ inline bool read_sub_string(hid_t a_loc,const std::string& a_name,unsigned int a
|
||||
}
|
||||
|
||||
char* buff = rdata[0];
|
||||
|
||||
|
||||
size_t len = ::strlen(buff);
|
||||
a_string.resize(len,0);
|
||||
for(size_t index=0;index<len;index++) a_string[index] = buff[index];
|
||||
|
||||
::H5Dvlen_reclaim(mem_type,mem_space, H5P_DEFAULT,rdata);
|
||||
|
||||
|
||||
::H5Tclose(mem_type);
|
||||
::H5Sclose(mem_space);
|
||||
::H5Sclose(file_space);
|
||||
@@ -913,7 +913,7 @@ inline bool read_object(hid_t a_loc,const std::string& a_name,size_t& a_size,cha
|
||||
a_data = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t file_type = H5Dget_type(dataset);
|
||||
if(file_type<0) {
|
||||
::H5Dclose(dataset);
|
||||
@@ -921,7 +921,7 @@ inline bool read_object(hid_t a_loc,const std::string& a_name,size_t& a_size,cha
|
||||
a_data = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
H5T_class_t t_class = H5Tget_class(file_type);
|
||||
if(t_class!=H5T_COMPOUND) {
|
||||
::H5Tclose(file_type);
|
||||
@@ -930,7 +930,7 @@ inline bool read_object(hid_t a_loc,const std::string& a_name,size_t& a_size,cha
|
||||
a_data = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
size_t sz = H5Tget_size(file_type);
|
||||
if(!sz) {
|
||||
::H5Tclose(file_type);
|
||||
@@ -939,7 +939,7 @@ inline bool read_object(hid_t a_loc,const std::string& a_name,size_t& a_size,cha
|
||||
a_data = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t mem_type = compound_mem_type(file_type);
|
||||
if(mem_type<0) {
|
||||
::H5Tclose(file_type);
|
||||
@@ -948,9 +948,9 @@ inline bool read_object(hid_t a_loc,const std::string& a_name,size_t& a_size,cha
|
||||
a_data = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
::H5Tclose(file_type);
|
||||
|
||||
|
||||
hid_t dataspace = H5Dget_space(dataset);
|
||||
if(dataspace<0) {
|
||||
::H5Tclose(mem_type);
|
||||
@@ -959,7 +959,7 @@ inline bool read_object(hid_t a_loc,const std::string& a_name,size_t& a_size,cha
|
||||
a_data = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
hid_t scalar = ::H5Screate(H5S_SCALAR);
|
||||
if(scalar<0) {
|
||||
::H5Sclose(dataspace);
|
||||
@@ -981,14 +981,14 @@ inline bool read_object(hid_t a_loc,const std::string& a_name,size_t& a_size,cha
|
||||
a_data = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
::H5Sclose(scalar);
|
||||
::H5Sclose(dataspace);
|
||||
::H5Tclose(mem_type);
|
||||
::H5Dclose(dataset);
|
||||
|
||||
|
||||
a_size = sz;
|
||||
a_data = buffer;
|
||||
a_data = buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1009,7 +1009,7 @@ inline bool read_array_string(hid_t a_loc,const std::string& a_name,std::vector<
|
||||
::H5Dclose(dataset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
size_t sz = H5Tget_size(file_type);
|
||||
::H5Tclose(file_type);
|
||||
if(!sz) {
|
||||
@@ -1017,7 +1017,7 @@ inline bool read_array_string(hid_t a_loc,const std::string& a_name,std::vector<
|
||||
return false;
|
||||
}
|
||||
|
||||
// We could have use file_type since, for string,
|
||||
// We could have use file_type since, for string,
|
||||
// file type is the same than memory type.
|
||||
hid_t mem_type = string_datatype(sz);
|
||||
if(mem_type<0) {
|
||||
@@ -1042,7 +1042,7 @@ inline bool read_array_string(hid_t a_loc,const std::string& a_name,std::vector<
|
||||
delete [] buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
int& a_number,int* a_mx_point,
|
||||
float* aX,float* aY,float& a_width){
|
||||
|
||||
// Latin correspondance with HPLSOF
|
||||
// Latin correspondance with HPLSOF
|
||||
// ABCDEFGHIJKLMNOPQRSTUVWXYZ done with H_ROMAN UPPER
|
||||
// abcdefghijklmnopqrstuvwxyz done with H_ROMAN LOWER
|
||||
// 0123456789 done with H_DIGIT
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
case 'X':extract(H_ROMAN,H_UPPER,'X',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'Y':extract(H_ROMAN,H_UPPER,'Y',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'Z':extract(H_ROMAN,H_UPPER,'Z',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
|
||||
|
||||
case 'a':extract(H_ROMAN,H_LOWER,'A',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'b':extract(H_ROMAN,H_LOWER,'B',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'c':extract(H_ROMAN,H_LOWER,'C',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
case 'x':extract(H_ROMAN,H_LOWER,'X',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'y':extract(H_ROMAN,H_LOWER,'Y',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'z':extract(H_ROMAN,H_LOWER,'Z',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
|
||||
|
||||
case '0':extract(H_DIGIT,H_UPPER,'0',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '1':extract(H_DIGIT,H_UPPER,'1',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '2':extract(H_DIGIT,H_UPPER,'2',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
case '7':extract(H_DIGIT,H_UPPER,'7',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '8':extract(H_DIGIT,H_UPPER,'8',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '9':extract(H_DIGIT,H_UPPER,'9',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
|
||||
|
||||
case '.':extract(H_MATH,H_UPPER,'.',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case ',':extract(H_MATH,H_UPPER,',',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '/':extract(H_MATH,H_UPPER,'/',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
case '+':extract(H_MATH,H_UPPER,'+',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '=':extract(H_MATH,H_UPPER,'=',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '*':extract(H_MATH,H_UPPER,'*',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
|
||||
|
||||
case '$':extract(H_SPECIAL,H_UPPER,'D',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '!':extract(H_SPECIAL,H_UPPER,'E',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '#':extract(H_SPECIAL,H_UPPER,'F',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
case '}':extract(H_SPECIAL,H_UPPER,'Q',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '%':extract(H_SPECIAL,H_UPPER,'Y',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case '&':extract(H_SPECIAL,H_UPPER,'W',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
|
||||
|
||||
case '_':
|
||||
a_number = 1;
|
||||
a_mx_point[0] = 2;
|
||||
@@ -145,12 +145,12 @@ public:
|
||||
aY[1] = 0;
|
||||
a_width = a_scale;
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
|
||||
case ' ':
|
||||
a_number = 0;
|
||||
a_width = a_scale/2;
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
a_number = 0;
|
||||
a_width = a_scale;
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
case 'X':extract(H_GREEK,H_UPPER,'X',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'Y':extract(H_GREEK,H_UPPER,'Y',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'Z':extract(H_GREEK,H_UPPER,'Z',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
|
||||
|
||||
case 'a':extract(H_GREEK,H_LOWER,'A',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'b':extract(H_GREEK,H_LOWER,'B',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'c':extract(H_GREEK,H_LOWER,'C',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
@@ -215,11 +215,11 @@ public:
|
||||
case 'x':extract(H_GREEK,H_LOWER,'X',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'y':extract(H_GREEK,H_LOWER,'Y',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
case 'z':extract(H_GREEK,H_LOWER,'Z',a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
|
||||
|
||||
default : latin_char_points(a_char,a_scale,a_number,a_mx_point,aX,aY,a_width);break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
static void extract(int aType,int aCase,char aC,float a_scale, //input
|
||||
int& aN,int* a_mx_point,
|
||||
@@ -228,7 +228,7 @@ private:
|
||||
int npoly,ichr,iw,idif,ibit,kx,ky,iy0,ix0,dky,ipoint;
|
||||
float scale,size;
|
||||
float max_x;
|
||||
|
||||
|
||||
ichr = 1;
|
||||
if (aType==H_DIGIT) {
|
||||
switch(aC) {
|
||||
@@ -354,9 +354,9 @@ private:
|
||||
case '*':ichr=105;break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (aCase==H_LOWER) ichr += 105;
|
||||
|
||||
|
||||
// scale :
|
||||
size = a_scale;
|
||||
if(size<0.001) size = 0.25F;
|
||||
@@ -364,7 +364,7 @@ private:
|
||||
dky = 21;
|
||||
if (aType==H_SPECIAL) rescale(ichr,iy0,dky);
|
||||
scale = size/dky;
|
||||
|
||||
|
||||
iw = hs(ichr-1) - 1;
|
||||
kx = (hx(iw) % 64 ) - 32;
|
||||
ky = (hy(iw) % 64 ) - 32;
|
||||
@@ -402,10 +402,10 @@ private:
|
||||
aN = npoly;
|
||||
a_width = max_x;
|
||||
}
|
||||
|
||||
|
||||
static void rescale(int aIchr,int& aIy0,int& aDky){
|
||||
int iw,ibit,idif,kx,ky,kymin,kymax;
|
||||
|
||||
|
||||
iw = hs(aIchr-1) - 1;
|
||||
kymin = 100;
|
||||
kymax = -100;
|
||||
@@ -718,7 +718,7 @@ private: //data
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ inline bool is_out(const std::vector< axis<TC,TO> >& a_axes,TO a_offset) {
|
||||
TO offset = a_offset;
|
||||
int index;
|
||||
typename std::vector< axis<TC,TO> >::size_type dimension = a_axes.size();
|
||||
for(int iaxis=int(dimension)-1;iaxis>=0;iaxis--) {
|
||||
for(int iaxis=int(dimension)-1;iaxis>=0;iaxis--) {
|
||||
index = int(offset/a_axes[iaxis].m_offset);
|
||||
if(index==0) return true;
|
||||
if(index==(int(a_axes[iaxis].m_number_of_bins)+1)) return true;
|
||||
@@ -30,7 +30,7 @@ template <class TC,class TO>
|
||||
inline void get_indices(const std::vector< axis<TC,TO> >& a_axes,TO a_offset,std::vector<int>& a_is) {
|
||||
TO offset = a_offset;
|
||||
typename std::vector< axis<TC,TO> >::size_type dimension = a_axes.size();
|
||||
{for(int iaxis=int(dimension)-1;iaxis>=0;iaxis--) {
|
||||
{for(int iaxis=int(dimension)-1;iaxis>=0;iaxis--) {
|
||||
a_is[iaxis] = int(offset/a_axes[iaxis].m_offset);
|
||||
offset -= a_is[iaxis] * a_axes[iaxis].m_offset;
|
||||
}}
|
||||
@@ -57,7 +57,7 @@ inline bool get_offset(const std::vector< axis<TC,TO> >& a_axes,const std::vecto
|
||||
typename std::vector< axis<TC,TO> >::size_type dimension = a_axes.size();
|
||||
typename axis<TC,TO>::bn_t ibin;
|
||||
typedef unsigned int dim_t;
|
||||
for(dim_t iaxis=0;iaxis<dimension;iaxis++) {
|
||||
for(dim_t iaxis=0;iaxis<dimension;iaxis++) {
|
||||
if(!a_axes[iaxis].in_range_to_absolute_index(a_is[iaxis],ibin)) {
|
||||
a_offset = 0;
|
||||
return false;
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
return true;
|
||||
} else if( a_value >= m_maximum_value) {
|
||||
a_index = m_number_of_bins+1;
|
||||
return true;
|
||||
return true;
|
||||
} else {
|
||||
if(m_fixed) {
|
||||
a_index = (bn_t)((a_value - m_minimum_value)/m_bin_width)+1;
|
||||
@@ -203,14 +203,14 @@ public:
|
||||
m_fixed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool is_compatible(const axis& a_axis) const {
|
||||
if(m_number_of_bins!=a_axis.m_number_of_bins) return false;
|
||||
if(m_minimum_value!=a_axis.m_minimum_value) return false;
|
||||
if(m_maximum_value!=a_axis.m_maximum_value) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
axis()
|
||||
:m_offset(0)
|
||||
@@ -256,7 +256,7 @@ public:
|
||||
if(m_edges!=a_from.m_edges) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const axis& a_from) const {return equals(a_from);}
|
||||
bool operator!=(const axis& a_from) const {return !equals(a_from);}
|
||||
|
||||
|
||||
@@ -107,42 +107,42 @@ public:
|
||||
void hprint(std::ostream& a_out) {
|
||||
// A la HPRINT.
|
||||
a_out << parent::dimension() << parent::title() << std::endl;
|
||||
a_out
|
||||
a_out
|
||||
<< " * ENTRIES = " << parent::all_entries()
|
||||
<< " * ALL CHANNELS = " << parent::sum_bin_heights()
|
||||
<< " * UNDERFLOW = " << bin_height(axis_t::UNDERFLOW_BIN)
|
||||
<< " * OVERFLOW = " << bin_height(axis_t::OVERFLOW_BIN)
|
||||
<< std::endl;
|
||||
a_out
|
||||
a_out
|
||||
<< " * BIN WID = " << axis().bin_width(0)
|
||||
<< " * MEAN VALUE = " << mean()
|
||||
<< " * R . M . S = " << rms()
|
||||
<< std::endl;
|
||||
|
||||
|
||||
// Some bins :
|
||||
bn_t bins = axis().bins();
|
||||
a_out
|
||||
<< " * ENTRIES[0] = "
|
||||
<< bin_entries(0)
|
||||
<< " * HEIGHT[0] = "
|
||||
<< bin_height(0)
|
||||
<< " * ERROR[0] = "
|
||||
<< bin_error(0)
|
||||
a_out
|
||||
<< " * ENTRIES[0] = "
|
||||
<< bin_entries(0)
|
||||
<< " * HEIGHT[0] = "
|
||||
<< bin_height(0)
|
||||
<< " * ERROR[0] = "
|
||||
<< bin_error(0)
|
||||
<< std::endl;
|
||||
a_out
|
||||
<< " * ENTRIES[N/2] = "
|
||||
<< bin_entries(bins/2)
|
||||
<< " * HEIGHT[N/2] = "
|
||||
a_out
|
||||
<< " * ENTRIES[N/2] = "
|
||||
<< bin_entries(bins/2)
|
||||
<< " * HEIGHT[N/2] = "
|
||||
<< bin_height(bins/2)
|
||||
<< " * ERROR[N/2] = "
|
||||
<< " * ERROR[N/2] = "
|
||||
<< bin_error(bins/2)
|
||||
<< std::endl;
|
||||
a_out
|
||||
<< " * ENTRIES[N-1] = "
|
||||
<< bin_entries(bins-1)
|
||||
<< " * HEIGHT[N-1] = "
|
||||
a_out
|
||||
<< " * ENTRIES[N-1] = "
|
||||
<< bin_entries(bins-1)
|
||||
<< " * HEIGHT[N-1] = "
|
||||
<< bin_height(bins-1)
|
||||
<< " * ERROR[N-1] = "
|
||||
<< " * ERROR[N-1] = "
|
||||
<< bin_error(bins-1)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
@@ -212,15 +212,15 @@ public:
|
||||
void hprint(std::ostream& a_out) {
|
||||
// A la HPRINT.
|
||||
a_out << parent::dimension() << parent::title() << std::endl;
|
||||
a_out
|
||||
a_out
|
||||
<< " * ENTRIES = " << parent::all_entries() << std::endl;
|
||||
|
||||
|
||||
// 6 | 7 | 8
|
||||
// -----------
|
||||
// 3 | 4 | 5
|
||||
// -----------
|
||||
// 0 | 1 | 2
|
||||
|
||||
|
||||
TW height_0 = bin_height(axis_t::UNDERFLOW_BIN,
|
||||
axis_t::UNDERFLOW_BIN);
|
||||
TW height_2 = bin_height(axis_t::OVERFLOW_BIN,
|
||||
@@ -229,62 +229,62 @@ public:
|
||||
axis_t::OVERFLOW_BIN);
|
||||
TW height_8 = bin_height(axis_t::OVERFLOW_BIN,
|
||||
axis_t::OVERFLOW_BIN);
|
||||
|
||||
|
||||
bn_t i,j;
|
||||
|
||||
|
||||
TW height_1 = 0;
|
||||
TW height_7 = 0;
|
||||
for(i=0;i<axis_x().bins();i++){
|
||||
height_1 += bin_height(i,axis_t::UNDERFLOW_BIN);
|
||||
height_7 += bin_height(i,axis_t::OVERFLOW_BIN);
|
||||
}
|
||||
|
||||
|
||||
TW height_3 = 0;
|
||||
TW height_5 = 0;
|
||||
for(j=0;j<axis_y().bins();j++){
|
||||
height_3 += bin_height(axis_t::UNDERFLOW_BIN,j);
|
||||
height_5 += bin_height(axis_t::OVERFLOW_BIN,j);
|
||||
}
|
||||
|
||||
|
||||
TW height_4 = 0;
|
||||
for(i=0;i<axis_x().bins();i++){
|
||||
for(j=0;j<axis_y().bins();j++){
|
||||
height_4 += bin_height(i,j);
|
||||
}
|
||||
}
|
||||
|
||||
a_out
|
||||
|
||||
a_out
|
||||
<< " " << height_6 << " " << height_7 << " " << height_8 << std::endl;
|
||||
a_out
|
||||
a_out
|
||||
<< " " << height_3 << " " << height_4 << " " << height_5 << std::endl;
|
||||
a_out
|
||||
a_out
|
||||
<< " " << height_0 << " " << height_1 << " " << height_2 << std::endl;
|
||||
|
||||
|
||||
// Some bins :
|
||||
bn_t xbins = axis_x().bins();
|
||||
bn_t ybins = axis_y().bins();
|
||||
a_out
|
||||
<< " * ENTRIES[0,0] = "
|
||||
<< bin_entries(0,0)
|
||||
<< " * HEIGHT[0,0] = "
|
||||
<< bin_height(0,0)
|
||||
<< " * ERROR[0,0] = "
|
||||
<< bin_error(0,0)
|
||||
a_out
|
||||
<< " * ENTRIES[0,0] = "
|
||||
<< bin_entries(0,0)
|
||||
<< " * HEIGHT[0,0] = "
|
||||
<< bin_height(0,0)
|
||||
<< " * ERROR[0,0] = "
|
||||
<< bin_error(0,0)
|
||||
<< std::endl;
|
||||
a_out
|
||||
<< " * ENTRIES[N/2,N/2] = "
|
||||
<< bin_entries(xbins/2,ybins/2)
|
||||
<< " * HEIGHT[N/2,N/2] = "
|
||||
a_out
|
||||
<< " * ENTRIES[N/2,N/2] = "
|
||||
<< bin_entries(xbins/2,ybins/2)
|
||||
<< " * HEIGHT[N/2,N/2] = "
|
||||
<< bin_height(xbins/2,ybins/2)
|
||||
<< " * ERROR[N/2,N/2] = "
|
||||
<< " * ERROR[N/2,N/2] = "
|
||||
<< bin_error(xbins/2,ybins/2)
|
||||
<< std::endl;
|
||||
a_out
|
||||
<< " * ENTRIES[N-1,N-1] = "
|
||||
<< bin_entries(xbins-1,ybins-1)
|
||||
<< " * HEIGHT[N-1,N-1] = "
|
||||
a_out
|
||||
<< " * ENTRIES[N-1,N-1] = "
|
||||
<< bin_entries(xbins-1,ybins-1)
|
||||
<< " * HEIGHT[N-1,N-1] = "
|
||||
<< bin_height(xbins-1,ybins-1)
|
||||
<< " * ERROR[N-1,N-1] = "
|
||||
<< " * ERROR[N-1,N-1] = "
|
||||
<< bin_error(xbins-1,ybins-1)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
if(!parent::m_dimension) return 0;
|
||||
bn_t ibin;
|
||||
if(!parent::m_axes[0].in_range_to_absolute_index(aI,ibin)) return 0;
|
||||
bn_t jbin,kbin,offset;
|
||||
bn_t jbin,kbin,offset;
|
||||
bn_t ybins = parent::m_axes[1].bins()+2;
|
||||
bn_t zbins = parent::m_axes[2].bins()+2;
|
||||
TO yoffset = parent::m_axes[1].m_offset;
|
||||
@@ -302,9 +302,9 @@ public:
|
||||
void hprint(std::ostream& a_out) {
|
||||
// A la HPRINT.
|
||||
a_out << parent::dimension() << parent::title() << std::endl;
|
||||
a_out
|
||||
a_out
|
||||
<< " * ENTRIES = " << parent::all_entries() << std::endl;
|
||||
|
||||
|
||||
}
|
||||
public:
|
||||
b3(const std::string& a_title,
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
TH max_bin_height() const {
|
||||
TH value = 0;
|
||||
bool first = true;
|
||||
@@ -189,7 +189,7 @@ public:
|
||||
a_value = value;
|
||||
return first?false:true; //return true if at least one bin with entries processed.
|
||||
}
|
||||
|
||||
|
||||
bool max_bin_height_with_entries(TH& a_value) const {
|
||||
TH value = 0;
|
||||
bool first = true;
|
||||
@@ -261,7 +261,7 @@ public: //histo_data
|
||||
a_sw2 += parent::m_bin_Sw2[ibin];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TW get_all_Sw() const {
|
||||
TW sw = 0;
|
||||
@@ -314,12 +314,12 @@ protected:
|
||||
parent::m_in_range_Sw2 = 0;
|
||||
parent::m_in_range_Sxw.resize(a_dim,0);
|
||||
parent::m_in_range_Sx2w.resize(a_dim,0);
|
||||
|
||||
|
||||
// Some checks :
|
||||
if(!a_dim) return false;
|
||||
parent::m_axes.resize(a_dim);
|
||||
// Setup axes :
|
||||
for(dim_t iaxis=0;iaxis<a_dim;iaxis++) {
|
||||
for(dim_t iaxis=0;iaxis<a_dim;iaxis++) {
|
||||
if(!parent::m_axes[iaxis].configure(aNumbers[iaxis],aMins[iaxis],aMaxs[iaxis])) {
|
||||
// do not do :
|
||||
// m_axes.clear()
|
||||
@@ -330,7 +330,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
parent::m_dimension = a_dim;
|
||||
|
||||
base_allocate(); //set m_bin_number.
|
||||
@@ -364,13 +364,13 @@ protected:
|
||||
if(!a_dim) return false;
|
||||
parent::m_axes.resize(a_dim);
|
||||
// Setup axes :
|
||||
for(dim_t iaxis=0;iaxis<a_dim;iaxis++) {
|
||||
for(dim_t iaxis=0;iaxis<a_dim;iaxis++) {
|
||||
if(!parent::m_axes[iaxis].configure(a_edges[iaxis])) {
|
||||
//m_axes.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
parent::m_dimension = a_dim;
|
||||
|
||||
base_allocate(); //set m_bin_number.
|
||||
@@ -411,14 +411,14 @@ protected:
|
||||
empty.resize(parent::m_dimension,0);
|
||||
parent::m_bin_Sxw.resize(n_bin,empty);
|
||||
parent::m_bin_Sx2w.resize(n_bin,empty);
|
||||
|
||||
|
||||
parent::m_bin_number = n_bin; // All bins : [in-range, underflow, outflow] bins.
|
||||
|
||||
|
||||
parent::m_axes[0].m_offset = 1;
|
||||
for(iaxis=1;iaxis<parent::m_dimension;iaxis++) {
|
||||
parent::m_axes[iaxis].m_offset = parent::m_axes[iaxis-1].m_offset * (parent::m_axes[iaxis-1].bins()+2);
|
||||
}
|
||||
|
||||
|
||||
parent::m_in_range_plane_Sxyw.resize(dim_planes(parent::m_dimension),0);
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ public: //annotations :
|
||||
a_out << " * ANNOTATIONS :" << std::endl;
|
||||
annotations_t::const_iterator it;
|
||||
for(it=parent::m_annotations.begin();it!=parent::m_annotations.end();++it) {
|
||||
//out << " * (" << index << ") "
|
||||
//out << " * (" << index << ") "
|
||||
a_out << " * " << (*it).first << " = " << (*it).second << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -510,14 +510,14 @@ protected:
|
||||
parent::update_fast_getters();
|
||||
}
|
||||
|
||||
bool base_multiply(const base_histo& a_histo) {
|
||||
bool base_multiply(const base_histo& a_histo) {
|
||||
//ill-defined operation. We keep that because of the "ill-defined past".
|
||||
|
||||
// We build a new histo with one entry in each bin of weight :
|
||||
// We build a new histo with one entry in each bin of weight :
|
||||
// this.w * a_histo.w
|
||||
// The current histo is overriden with this new histo.
|
||||
// The m_bin_Sw2 computation is consistent with FreeHEP and CERN-ROOT.
|
||||
|
||||
|
||||
if(!is_compatible(a_histo)) return false;
|
||||
|
||||
std::vector<int> is(parent::m_dimension);
|
||||
@@ -546,12 +546,12 @@ protected:
|
||||
|
||||
bool base_divide(const base_histo& a_histo) {
|
||||
//ill-defined operation. We keep that because of the "ill-defined past".
|
||||
|
||||
// We build a new histo with one entry in each bin of weight :
|
||||
|
||||
// We build a new histo with one entry in each bin of weight :
|
||||
// this.w / a_histo.w
|
||||
// The current histo is overriden with this new histo.
|
||||
// The m_bin_Sw2 computation is consistent with FreeHEP and ROOT.
|
||||
|
||||
|
||||
if(!is_compatible(a_histo)) return false;
|
||||
|
||||
std::vector<int> is(parent::m_dimension);
|
||||
|
||||
@@ -27,17 +27,17 @@ public:
|
||||
}
|
||||
|
||||
unsigned int dimension() const {return 1;}
|
||||
bool reset() {
|
||||
bool reset() {
|
||||
clear();
|
||||
delete m_histo;
|
||||
m_histo = 0;
|
||||
return true;
|
||||
}
|
||||
unsigned int entries() const {
|
||||
unsigned int entries() const {
|
||||
return m_histo ? m_histo->all_entries() : (unsigned int)m_ws.size();
|
||||
}
|
||||
public:
|
||||
double sum_of_weights() const {
|
||||
double sum_of_weights() const {
|
||||
return (m_histo ? m_histo->sum_bin_heights() : m_Sw);
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ public:
|
||||
|
||||
public:
|
||||
bool fill(double aX,double aW = 1){
|
||||
if(!m_histo && (m_limit!=UNLIMITED()) &&
|
||||
if(!m_histo && (m_limit!=UNLIMITED()) &&
|
||||
((int)m_xs.size()>=m_limit)){
|
||||
convert_to_histogram();
|
||||
}
|
||||
|
||||
|
||||
if(m_histo) {
|
||||
return m_histo->fill(aX,aW);
|
||||
} else {
|
||||
@@ -98,10 +98,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
double lower_edge() const {
|
||||
double lower_edge() const {
|
||||
return (m_histo ? m_histo->axis().lower_edge() : m_lower_x);
|
||||
}
|
||||
double upper_edge() const {
|
||||
double upper_edge() const {
|
||||
return (m_histo ? m_histo->axis().upper_edge() : m_upper_x);
|
||||
}
|
||||
double value(unsigned int a_index) const {return (m_histo ?0:m_xs[a_index]);}
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
,m_Sxw(0),m_Sx2w(0)
|
||||
,m_cnv_x_num(0),m_cnv_x_min(0),m_cnv_x_max(0),m_histo(0)
|
||||
{}
|
||||
|
||||
|
||||
c1d(const std::string& a_title,int aLimit = base_cloud::UNLIMITED())
|
||||
:base_cloud(aLimit)
|
||||
,m_lower_x(0),m_upper_x(0)
|
||||
|
||||
@@ -210,10 +210,10 @@ void c2d::clear(){
|
||||
}
|
||||
|
||||
inline
|
||||
bool c2d::convert(
|
||||
bool c2d::convert(
|
||||
unsigned int a_bins_x,double a_lower_edge_x,double a_upper_edge_x
|
||||
,unsigned int a_bins_y,double a_lower_edge_y,double a_upper_edge_y
|
||||
) {
|
||||
,unsigned int a_bins_y,double a_lower_edge_y,double a_upper_edge_y
|
||||
) {
|
||||
if(m_histo) return true; // Done.
|
||||
m_histo = new histo::h2d(base_cloud::title(),
|
||||
a_bins_x,a_lower_edge_x,a_upper_edge_x,
|
||||
@@ -263,7 +263,7 @@ bool c2d::scale(double a_scale) {
|
||||
}
|
||||
|
||||
inline
|
||||
bool c2d::reset() {
|
||||
bool c2d::reset() {
|
||||
clear();
|
||||
delete m_histo;
|
||||
m_histo = 0;
|
||||
@@ -286,7 +286,7 @@ bool c2d::fill(double aX,double aY,double aW){
|
||||
m_lower_x = aX;
|
||||
m_upper_x = aX;
|
||||
}
|
||||
if(m_ys.size()) {
|
||||
if(m_ys.size()) {
|
||||
m_lower_y = mn<double>(aY,m_lower_y);
|
||||
m_upper_y = mx<double>(aY,m_upper_y);
|
||||
} else {
|
||||
@@ -300,7 +300,7 @@ bool c2d::fill(double aX,double aY,double aW){
|
||||
double xw = aX * aW;
|
||||
m_Sxw += xw;
|
||||
m_Sx2w += aX * xw;
|
||||
double yw = aY * aW;
|
||||
double yw = aY * aW;
|
||||
m_Syw += yw;
|
||||
m_Sy2w += aY * yw;
|
||||
return true;
|
||||
@@ -308,7 +308,7 @@ bool c2d::fill(double aX,double aY,double aW){
|
||||
}
|
||||
|
||||
inline
|
||||
bool c2d::convert(const std::vector<double>& a_edges_x,const std::vector<double>& a_edges_y) {
|
||||
bool c2d::convert(const std::vector<double>& a_edges_x,const std::vector<double>& a_edges_y) {
|
||||
if(m_histo) return true;
|
||||
m_histo = new histo::h2d(base_cloud::title(),
|
||||
a_edges_x,a_edges_y);
|
||||
@@ -333,7 +333,7 @@ bool c2d::set_conversion_parameters(
|
||||
}
|
||||
|
||||
inline
|
||||
const h2d& c2d::histogram() const {
|
||||
const h2d& c2d::histogram() const {
|
||||
if(!m_histo) const_cast<c2d&>(*this).convert_to_histogram();
|
||||
return *m_histo;
|
||||
}
|
||||
|
||||
@@ -260,11 +260,11 @@ void c3d::clear(){
|
||||
}
|
||||
|
||||
inline
|
||||
bool c3d::convert(
|
||||
bool c3d::convert(
|
||||
unsigned int a_bins_x,double a_lower_edge_x,double a_upper_edge_x
|
||||
,unsigned int a_bins_y,double a_lower_edge_y,double a_upper_edge_y
|
||||
,unsigned int a_bins_z,double a_lower_edge_z,double a_upper_edge_z
|
||||
) {
|
||||
,unsigned int a_bins_y,double a_lower_edge_y,double a_upper_edge_y
|
||||
,unsigned int a_bins_z,double a_lower_edge_z,double a_upper_edge_z
|
||||
) {
|
||||
if(m_histo) return true; // Done.
|
||||
m_histo = new histo::h3d(base_cloud::title(),
|
||||
a_bins_x,a_lower_edge_x,a_upper_edge_x,
|
||||
@@ -339,13 +339,13 @@ bool c3d::set_conversion_parameters(
|
||||
|
||||
|
||||
inline
|
||||
const h3d& c3d::histogram() const {
|
||||
const h3d& c3d::histogram() const {
|
||||
if(!m_histo) const_cast<c3d&>(*this).convert_to_histogram();
|
||||
return *m_histo;
|
||||
}
|
||||
|
||||
inline
|
||||
bool c3d::reset() {
|
||||
bool c3d::reset() {
|
||||
clear();
|
||||
delete m_histo;
|
||||
m_histo = 0;
|
||||
@@ -368,14 +368,14 @@ bool c3d::fill(double aX,double aY,double aZ,double aW){
|
||||
m_lower_x = aX;
|
||||
m_upper_x = aX;
|
||||
}
|
||||
if(m_ys.size()) {
|
||||
if(m_ys.size()) {
|
||||
m_lower_y = mn<double>(aY,m_lower_y);
|
||||
m_upper_y = mx<double>(aY,m_upper_y);
|
||||
} else {
|
||||
m_lower_y = aY;
|
||||
m_upper_y = aY;
|
||||
}
|
||||
if(m_zs.size()) {
|
||||
if(m_zs.size()) {
|
||||
m_lower_z = mn<double>(aZ,m_lower_z);
|
||||
m_upper_z = mx<double>(aZ,m_upper_z);
|
||||
} else {
|
||||
@@ -390,7 +390,7 @@ bool c3d::fill(double aX,double aY,double aZ,double aW){
|
||||
double xw = aX * aW;
|
||||
m_Sxw += xw;
|
||||
m_Sx2w += aX * xw;
|
||||
double yw = aY * aW;
|
||||
double yw = aY * aW;
|
||||
m_Syw += yw;
|
||||
m_Sy2w += aY * yw;
|
||||
double zw = aZ * aW;
|
||||
@@ -401,11 +401,11 @@ bool c3d::fill(double aX,double aY,double aZ,double aW){
|
||||
}
|
||||
|
||||
inline
|
||||
bool c3d::convert(
|
||||
bool c3d::convert(
|
||||
const std::vector<double>& a_edges_x
|
||||
,const std::vector<double>& a_edges_y
|
||||
,const std::vector<double>& a_edges_z
|
||||
) {
|
||||
) {
|
||||
if(m_histo) return true;
|
||||
m_histo = new histo::h3d(base_cloud::title(),
|
||||
a_edges_x,a_edges_y,a_edges_z);
|
||||
@@ -416,53 +416,53 @@ bool c3d::convert(
|
||||
}
|
||||
|
||||
inline
|
||||
double c3d::sum_of_weights() const {
|
||||
double c3d::sum_of_weights() const {
|
||||
return (m_histo ? m_histo->sum_bin_heights() : m_Sw);
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned int c3d::entries() const {
|
||||
unsigned int c3d::entries() const {
|
||||
return m_histo ? m_histo->all_entries() : (unsigned int)m_ws.size();
|
||||
}
|
||||
|
||||
inline
|
||||
double c3d::lower_edge_x() const {
|
||||
double c3d::lower_edge_x() const {
|
||||
return m_histo ? m_histo->axis_x().lower_edge() : m_lower_x;
|
||||
}
|
||||
inline
|
||||
double c3d::lower_edge_y() const {
|
||||
double c3d::lower_edge_y() const {
|
||||
return m_histo ? m_histo->axis_y().lower_edge() : m_lower_y;
|
||||
}
|
||||
inline
|
||||
double c3d::lower_edge_z() const {
|
||||
double c3d::lower_edge_z() const {
|
||||
return m_histo ? m_histo->axis_z().lower_edge() : m_lower_z;
|
||||
}
|
||||
inline
|
||||
double c3d::upper_edge_x() const {
|
||||
double c3d::upper_edge_x() const {
|
||||
return m_histo ? m_histo->axis_x().upper_edge() : m_upper_x;
|
||||
}
|
||||
inline
|
||||
double c3d::upper_edge_y() const {
|
||||
double c3d::upper_edge_y() const {
|
||||
return m_histo ? m_histo->axis_y().upper_edge() : m_upper_y;
|
||||
}
|
||||
inline
|
||||
double c3d::upper_edge_z() const {
|
||||
double c3d::upper_edge_z() const {
|
||||
return m_histo ? m_histo->axis_z().upper_edge() : m_upper_z;
|
||||
}
|
||||
inline
|
||||
double c3d::value_x(unsigned int a_index) const {
|
||||
double c3d::value_x(unsigned int a_index) const {
|
||||
return m_histo ? 0 : m_xs[a_index];
|
||||
}
|
||||
inline
|
||||
double c3d::value_y(unsigned int a_index) const {
|
||||
double c3d::value_y(unsigned int a_index) const {
|
||||
return m_histo ? 0 : m_ys[a_index];
|
||||
}
|
||||
inline
|
||||
double c3d::value_z(unsigned int a_index) const {
|
||||
double c3d::value_z(unsigned int a_index) const {
|
||||
return m_histo ? 0 : m_zs[a_index];
|
||||
}
|
||||
inline
|
||||
double c3d::weight(unsigned int a_index) const {
|
||||
double c3d::weight(unsigned int a_index) const {
|
||||
return m_histo ? 0 : m_ws[a_index];
|
||||
}
|
||||
inline
|
||||
|
||||
@@ -152,21 +152,21 @@ public:
|
||||
void clear() {m_points.clear();}
|
||||
size_t size() const {return m_points.size();}
|
||||
|
||||
const data_point& point(size_t a_index) const {
|
||||
const data_point& point(size_t a_index) const {
|
||||
//WARNING : no check done on a_index.
|
||||
return m_points[a_index];
|
||||
}
|
||||
data_point& point(size_t a_index) {
|
||||
data_point& point(size_t a_index) {
|
||||
//WARNING : no check done on a_index.
|
||||
return m_points[a_index];
|
||||
}
|
||||
|
||||
data_point& add_point() {
|
||||
data_point& add_point() {
|
||||
m_points.push_back(data_point(m_dim));
|
||||
return m_points.back();
|
||||
}
|
||||
|
||||
bool remove_point(size_t a_index) {
|
||||
bool remove_point(size_t a_index) {
|
||||
bool done = false;
|
||||
if(a_index<m_points.size()){
|
||||
std::vector<data_point>::iterator it = m_points.begin();
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
return done;
|
||||
}
|
||||
|
||||
bool lower_extent(unsigned int a_coord,double& a_value) const {
|
||||
bool lower_extent(unsigned int a_coord,double& a_value) const {
|
||||
if(m_points.empty()||(a_coord>=m_dim)){
|
||||
a_value = 0;
|
||||
return false;
|
||||
@@ -190,8 +190,8 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool upper_extent(unsigned int a_coord,double& a_value) const {
|
||||
|
||||
bool upper_extent(unsigned int a_coord,double& a_value) const {
|
||||
if(m_points.empty()||(a_coord>=m_dim)){
|
||||
a_value = 0;
|
||||
return false;
|
||||
@@ -204,8 +204,8 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void scale(double a_scale) {
|
||||
|
||||
void scale(double a_scale) {
|
||||
std::vector<data_point>::iterator it;
|
||||
for(it=m_points.begin();it!=m_points.end();++it) {
|
||||
for(unsigned int coord=0;coord<m_dim;coord++) {
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void scale_value(double a_scale) {
|
||||
void scale_value(double a_scale) {
|
||||
std::vector<data_point>::iterator it;
|
||||
for(it=m_points.begin();it!=m_points.end();++it) {
|
||||
for(unsigned int coord=0;coord<m_dim;coord++) {
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void scale_errors(double a_scale) {
|
||||
void scale_errors(double a_scale) {
|
||||
std::vector<data_point>::iterator it;
|
||||
for(it=m_points.begin();it!=m_points.end();++it) {
|
||||
for(unsigned int coord=0;coord<m_dim;coord++) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
parent::m_bin_entries[offset]++;
|
||||
parent::m_bin_Sw[offset] += aWeight;
|
||||
parent::m_bin_Sw2[offset] += aWeight * aWeight;
|
||||
|
||||
|
||||
TC xw = aX * aWeight;
|
||||
TC x2w = aX * xw;
|
||||
parent::m_bin_Sxw[offset][0] += xw;
|
||||
@@ -150,10 +150,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool multiply(const h1& a_histo) {
|
||||
bool multiply(const h1& a_histo) {
|
||||
return parent::base_multiply(a_histo);
|
||||
}
|
||||
|
||||
|
||||
bool divide(const h1& a_histo) {
|
||||
return parent::base_divide(a_histo);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
if(!a_factor) return false;
|
||||
|
||||
// actual bin number must be a multiple of a_factor.
|
||||
|
||||
|
||||
const axis_t& _axis = parent::axis();
|
||||
|
||||
bn_t n = _axis.bins();
|
||||
@@ -220,14 +220,14 @@ public:
|
||||
*this = *new_h;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool equals_TH(const h1& a_from,const TW& a_prec,TW(*a_fabs)(TW)) const {
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,true)) return false;
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,true)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void not_a_profile() const {}
|
||||
|
||||
|
||||
public: //CERN-ROOT API (for MEMPHYS sim).
|
||||
bool Fill(TC aX,TW aWeight = 1) {return fill(aX,aWeight);}
|
||||
|
||||
|
||||
@@ -41,33 +41,33 @@ public:
|
||||
|
||||
bool fill(TC aX,TC aY,TW aWeight = 1) {
|
||||
if(parent::m_dimension!=2) return false;
|
||||
|
||||
|
||||
bn_t ibin,jbin;
|
||||
if(!parent::m_axes[0].coord_to_absolute_index(aX,ibin)) return false;
|
||||
if(!parent::m_axes[1].coord_to_absolute_index(aY,jbin)) return false;
|
||||
TO offset = ibin + jbin * parent::m_axes[1].m_offset;
|
||||
|
||||
|
||||
parent::m_bin_entries[offset]++;
|
||||
parent::m_bin_Sw[offset] += aWeight;
|
||||
parent::m_bin_Sw2[offset] += aWeight * aWeight;
|
||||
|
||||
|
||||
TC xw = aX * aWeight;
|
||||
TC x2w = aX * xw;
|
||||
parent::m_bin_Sxw[offset][0] += xw;
|
||||
parent::m_bin_Sx2w[offset][0] += x2w;
|
||||
|
||||
|
||||
TC yw = aY * aWeight;
|
||||
TC y2w = aY * yw;
|
||||
parent::m_bin_Sxw[offset][1] += yw;
|
||||
parent::m_bin_Sx2w[offset][1] += y2w;
|
||||
|
||||
|
||||
bool inRange = true;
|
||||
if(ibin==0) inRange = false;
|
||||
else if(ibin==(parent::m_axes[0].m_number_of_bins+1)) inRange = false;
|
||||
|
||||
|
||||
if(jbin==0) inRange = false;
|
||||
else if(jbin==(parent::m_axes[1].m_number_of_bins+1)) inRange = false;
|
||||
|
||||
|
||||
parent::m_all_entries++;
|
||||
if(inRange) {
|
||||
parent::m_in_range_plane_Sxyw[0] += aX * aY * aWeight;
|
||||
@@ -76,17 +76,17 @@ public:
|
||||
parent::m_in_range_entries++;
|
||||
parent::m_in_range_Sw += aWeight;
|
||||
parent::m_in_range_Sw2 += aWeight*aWeight;
|
||||
|
||||
|
||||
parent::m_in_range_Sxw[0] += xw;
|
||||
parent::m_in_range_Sx2w[0] += x2w;
|
||||
|
||||
parent::m_in_range_Sxw[1] += yw;
|
||||
parent::m_in_range_Sx2w[1] += y2w;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool set_bin_content(bn_t a_ibin,bn_t a_jbin,
|
||||
TN a_entries,TW a_Sw,TW a_Sw2,
|
||||
TC a_Sxw,TC a_Sx2w,TC a_Syw,TC a_Sy2w) {
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
a_Sx2w = parent::m_bin_Sx2w[offset][0];
|
||||
a_Syw = parent::m_bin_Sxw[offset][1];
|
||||
a_Sy2w = parent::m_bin_Sx2w[offset][1];
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -184,24 +184,24 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool multiply(const h2& a_histo) {
|
||||
bool multiply(const h2& a_histo) {
|
||||
return parent::base_multiply(a_histo);
|
||||
}
|
||||
|
||||
|
||||
bool divide(const h2& a_histo) {
|
||||
return parent::base_divide(a_histo);
|
||||
}
|
||||
|
||||
bool equals_TH(const h2& a_from,const TW& a_prec,TW(*a_fabs)(TW)) const {
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,true)) return false;
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,true)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void not_a_profile() const {}
|
||||
|
||||
|
||||
public: //CERN-ROOT API
|
||||
bool Fill(TC aX,TC aY,TW aWeight = 1) {return fill(aX,aY,aWeight);}
|
||||
|
||||
|
||||
public:
|
||||
h2(const std::string& a_title,bn_t aXnumber,TC aXmin,TC aXmax,bn_t aYnumber,TC aYmin,TC aYmax)
|
||||
:parent(a_title,aXnumber,aXmin,aXmax,aYnumber,aYmin,aYmax)
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
const std::string& s_cls() const {return s_class();}
|
||||
public:
|
||||
h2d():parent("",10,0,1,10,0,1){} //for I/O when reading.
|
||||
|
||||
|
||||
h2d(const std::string& a_title,
|
||||
unsigned int aXnumber,double aXmin,double aXmax,
|
||||
unsigned int aYnumber,double aYmin,double aYmax)
|
||||
|
||||
@@ -41,42 +41,42 @@ public:
|
||||
|
||||
bool fill(TC aX,TC aY,TC aZ,TW aWeight = 1) {
|
||||
if(parent::m_dimension!=3) return false;
|
||||
|
||||
|
||||
bn_t ibin,jbin,kbin;
|
||||
if(!parent::m_axes[0].coord_to_absolute_index(aX,ibin)) return false;
|
||||
if(!parent::m_axes[1].coord_to_absolute_index(aY,jbin)) return false;
|
||||
if(!parent::m_axes[2].coord_to_absolute_index(aZ,kbin)) return false;
|
||||
TO offset = ibin + jbin * parent::m_axes[1].m_offset + kbin * parent::m_axes[2].m_offset;
|
||||
|
||||
|
||||
parent::m_bin_entries[offset]++;
|
||||
parent::m_bin_Sw[offset] += aWeight;
|
||||
parent::m_bin_Sw2[offset] += aWeight * aWeight;
|
||||
|
||||
|
||||
TC xw = aX * aWeight;
|
||||
TC x2w = aX * xw;
|
||||
parent::m_bin_Sxw[offset][0] += xw;
|
||||
parent::m_bin_Sx2w[offset][0] += x2w;
|
||||
|
||||
|
||||
TC yw = aY * aWeight;
|
||||
TC y2w = aY * yw;
|
||||
parent::m_bin_Sxw[offset][1] += yw;
|
||||
parent::m_bin_Sx2w[offset][1] += y2w;
|
||||
|
||||
|
||||
TC zw = aZ * aWeight;
|
||||
TC z2w = aZ * zw;
|
||||
parent::m_bin_Sxw[offset][2] += zw;
|
||||
parent::m_bin_Sx2w[offset][2] += z2w;
|
||||
|
||||
|
||||
bool inRange = true;
|
||||
if(ibin==0) inRange = false;
|
||||
else if(ibin==(parent::m_axes[0].m_number_of_bins+1)) inRange = false;
|
||||
|
||||
|
||||
if(jbin==0) inRange = false;
|
||||
else if(jbin==(parent::m_axes[1].m_number_of_bins+1)) inRange = false;
|
||||
|
||||
|
||||
if(kbin==0) inRange = false;
|
||||
else if(kbin==(parent::m_axes[2].m_number_of_bins+1)) inRange = false;
|
||||
|
||||
|
||||
parent::m_all_entries++;
|
||||
if(inRange) {
|
||||
parent::m_in_range_plane_Sxyw[0] += aX * aY * aWeight;
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
parent::m_in_range_entries++;
|
||||
parent::m_in_range_Sw += aWeight;
|
||||
parent::m_in_range_Sw2 += aWeight*aWeight;
|
||||
|
||||
|
||||
parent::m_in_range_Sxw[0] += xw;
|
||||
parent::m_in_range_Sx2w[0] += x2w;
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
parent::m_in_range_Sxw[2] += zw;
|
||||
parent::m_in_range_Sx2w[2] += z2w;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -219,24 +219,24 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool multiply(const h3& a_histo) {
|
||||
bool multiply(const h3& a_histo) {
|
||||
return parent::base_multiply(a_histo);
|
||||
}
|
||||
|
||||
|
||||
bool divide(const h3& a_histo) {
|
||||
return parent::base_divide(a_histo);
|
||||
}
|
||||
|
||||
bool equals_TH(const h3& a_from,const TW& a_prec,TW(*a_fabs)(TW)) const {
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,true)) return false;
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,true)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void not_a_profile() const {}
|
||||
|
||||
public: //CERN-ROOT API
|
||||
bool Fill(TC aX,TC aY,TC aZ,TW aWeight = 1) {return fill(aX,aY,aZ,aWeight);}
|
||||
|
||||
|
||||
public:
|
||||
/*
|
||||
// Slices :
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
const std::string& s_cls() const {return s_class();}
|
||||
public:
|
||||
h3d():parent("",10,0,1,10,0,1,10,0,1){} //for I/O when reading.
|
||||
|
||||
|
||||
h3d(const std::string& a_title,
|
||||
unsigned int aXnumber,double aXmin,double aXmax,
|
||||
unsigned int aYnumber,double aYmin,double aYmax,
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
const std::string& s_cls() const {return s_class();}
|
||||
public:
|
||||
h3df():parent("",10,0,1,10,0,1,10,0,1){} //for I/O when reading.
|
||||
|
||||
|
||||
h3df(const std::string& a_title,
|
||||
unsigned int aXnumber,float aXmin,float aXmax,
|
||||
unsigned int aYnumber,float aYmin,float aYmax,
|
||||
|
||||
@@ -130,15 +130,15 @@ public:
|
||||
if(m_axes!=a_from.m_axes) return false;
|
||||
if(!vectors_are_equal(m_in_range_plane_Sxyw,a_from.m_in_range_plane_Sxyw,a_prec,a_fabs)) return false;
|
||||
if(m_annotations!=a_from.m_annotations) return false;
|
||||
|
||||
|
||||
if(m_all_entries!=a_from.m_all_entries) return false;
|
||||
if(m_in_range_entries!=a_from.m_in_range_entries) return false;
|
||||
|
||||
|
||||
if(!numbers_are_equal(m_in_range_Sw,a_from.m_in_range_Sw,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_in_range_Sw2,a_from.m_in_range_Sw2,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_in_range_Sxw,a_from.m_in_range_Sxw,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_in_range_Sx2w,a_from.m_in_range_Sx2w,a_prec,a_fabs)) return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
bool equals_TH(const histo_data& a_from,const TW& a_prec,TW(*a_fabs)(TW),bool a_cmp_bin_Sw2) const {
|
||||
@@ -155,10 +155,10 @@ public:
|
||||
if(m_axes!=a_from.m_axes) return false;
|
||||
if(!vectors_are_equal(m_in_range_plane_Sxyw,a_from.m_in_range_plane_Sxyw,a_prec,a_fabs)) return false;
|
||||
//if(m_annotations!=a_from.m_annotations) return false;
|
||||
|
||||
|
||||
if(m_all_entries!=a_from.m_all_entries) return false;
|
||||
//if(m_in_range_entries!=a_from.m_in_range_entries) return false;
|
||||
|
||||
|
||||
if(!numbers_are_equal(m_in_range_Sw,a_from.m_in_range_Sw,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_in_range_Sw2,a_from.m_in_range_Sw2,a_prec,a_fabs)) return false;
|
||||
//if(!vectors_are_equal(m_in_range_Sxw,a_from.m_in_range_Sxw,a_prec,a_fabs)) return false;
|
||||
|
||||
@@ -255,7 +255,7 @@ inline void histo_data_duiuid_assign(histo_data<double,unsigned int,unsigned int
|
||||
{a_hd.m_annotations.clear();
|
||||
for(unsigned int i=0;i<a_c.m_number_of_annotations;i++) {
|
||||
a_hd.m_annotations[a_c.m_annotations[2*i+0]] = a_c.m_annotations[2*i+1];
|
||||
}}
|
||||
}}
|
||||
|
||||
a_hd.m_all_entries = a_c.m_all_entries;
|
||||
a_hd.m_in_range_entries = a_c.m_in_range_entries;
|
||||
|
||||
@@ -31,19 +31,19 @@ protected:
|
||||
}
|
||||
public:
|
||||
bool equals(const p1& a_from,const TW& a_prec,TW(*a_fabs)(TW)) const {
|
||||
if(!parent::equals(a_from,a_prec,a_fabs)) return false;
|
||||
if(!parent::equals(a_from,a_prec,a_fabs)) return false;
|
||||
if(m_cut_v!=a_from.m_cut_v) return false;
|
||||
if(!numbers_are_equal(m_min_v,a_from.m_min_v,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_max_v,a_from.m_max_v,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_max_v,a_from.m_max_v,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_bin_Svw,a_from.m_bin_Svw,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_bin_Sv2w,a_from.m_bin_Sv2w,a_prec,a_fabs)) return false;
|
||||
return true;
|
||||
}
|
||||
bool equals_TH(const p1& a_from,const TW& a_prec,TW(*a_fabs)(TW)) const {
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,false)) return false;
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,false)) return false;
|
||||
if(m_cut_v!=a_from.m_cut_v) return false;
|
||||
if(!numbers_are_equal(m_min_v,a_from.m_min_v,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_max_v,a_from.m_max_v,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_max_v,a_from.m_max_v,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_bin_Svw,a_from.m_bin_Svw,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_bin_Sv2w,a_from.m_bin_Sv2w,a_prec,a_fabs)) return false;
|
||||
return true;
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
// Stat_t contsum = cont/sum;
|
||||
// Stat_t eprim2 = TMath::Abs(err2/sum - contsum*contsum);
|
||||
// eprim = TMath::Sqrt(eprim2);
|
||||
// ... ???
|
||||
// ... ???
|
||||
// if (fErrorMode == kERRORMEAN) return eprim/TMath::Sqrt(sum);
|
||||
|
||||
TW sw = parent::m_bin_Sw[offset]; //ROOT sum
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
parent::m_bin_entries[offset]++;
|
||||
parent::m_bin_Sw[offset] += aWeight;
|
||||
parent::m_bin_Sw2[offset] += aWeight * aWeight;
|
||||
|
||||
|
||||
TC xw = aX * aWeight;
|
||||
TC x2w = aX * xw;
|
||||
parent::m_bin_Sxw[offset][0] += xw;
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
// Profile part :
|
||||
m_bin_Svw[offset] = a_Svw;
|
||||
m_bin_Sv2w[offset] = a_Sv2w;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
// Profile part :
|
||||
a_Svw = m_bin_Svw[offset];
|
||||
a_Sv2w = m_bin_Sv2w[offset];
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -253,16 +253,16 @@ public:
|
||||
bool add(const p1& a_histo){
|
||||
parent::base_add(a_histo);
|
||||
for(bn_t ibin=0;ibin<parent::m_bin_number;ibin++) {
|
||||
m_bin_Svw[ibin] += a_histo.m_bin_Svw[ibin];
|
||||
m_bin_Sv2w[ibin] += a_histo.m_bin_Sv2w[ibin];
|
||||
m_bin_Svw[ibin] += a_histo.m_bin_Svw[ibin];
|
||||
m_bin_Sv2w[ibin] += a_histo.m_bin_Sv2w[ibin];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool subtract(const p1& a_histo){
|
||||
parent::base_subtract(a_histo);
|
||||
for(bn_t ibin=0;ibin<parent::m_bin_number;ibin++) {
|
||||
m_bin_Svw[ibin] -= a_histo.m_bin_Svw[ibin];
|
||||
m_bin_Sv2w[ibin] -= a_histo.m_bin_Sv2w[ibin];
|
||||
m_bin_Svw[ibin] -= a_histo.m_bin_Svw[ibin];
|
||||
m_bin_Sv2w[ibin] -= a_histo.m_bin_Sv2w[ibin];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ public:
|
||||
if(!a_factor) return false;
|
||||
|
||||
// actual bin number must be a multiple of a_factor.
|
||||
|
||||
|
||||
const axis_t& _axis = parent::axis();
|
||||
|
||||
bn_t n = _axis.bins();
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
{}
|
||||
|
||||
p1d(const std::string& a_title,const std::vector<double>& a_edges,double aVmin,double aVmax)
|
||||
:parent(a_title,a_edges,aVmin,aVmax)
|
||||
:parent(a_title,a_edges,aVmin,aVmax)
|
||||
{}
|
||||
|
||||
virtual ~p1d(){}
|
||||
|
||||
@@ -23,19 +23,19 @@ protected:
|
||||
}
|
||||
public:
|
||||
bool equals(const p2& a_from,const TW& a_prec,TW(*a_fabs)(TW)) const {
|
||||
if(!parent::equals(a_from,a_prec,a_fabs)) return false;
|
||||
if(!parent::equals(a_from,a_prec,a_fabs)) return false;
|
||||
if(m_cut_v!=a_from.m_cut_v) return false;
|
||||
if(!numbers_are_equal(m_min_v,a_from.m_min_v,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_max_v,a_from.m_max_v,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_max_v,a_from.m_max_v,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_bin_Svw,a_from.m_bin_Svw,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_bin_Sv2w,a_from.m_bin_Sv2w,a_prec,a_fabs)) return false;
|
||||
return true;
|
||||
}
|
||||
bool equals_TH(const p2& a_from,const TW& a_prec,TW(*a_fabs)(TW)) const {
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,false)) return false;
|
||||
if(!parent::equals_TH(a_from,a_prec,a_fabs,false)) return false;
|
||||
if(m_cut_v!=a_from.m_cut_v) return false;
|
||||
if(!numbers_are_equal(m_min_v,a_from.m_min_v,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_max_v,a_from.m_max_v,a_prec,a_fabs)) return false;
|
||||
if(!numbers_are_equal(m_max_v,a_from.m_max_v,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_bin_Svw,a_from.m_bin_Svw,a_prec,a_fabs)) return false;
|
||||
if(!vectors_are_equal(m_bin_Sv2w,a_from.m_bin_Sv2w,a_prec,a_fabs)) return false;
|
||||
return true;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
virtual TH bin_error(int aI,int aJ) const { //TH should be the same as TV
|
||||
TO offset;
|
||||
if(!parent::_find_offset(aI,aJ,offset)) return 0;
|
||||
|
||||
|
||||
//FIXME Is it correct ?
|
||||
// TProfile::GetBinError with kERRORMEAN mode does :
|
||||
// Stat_t cont = fArray[bin]; //Svw (see TProfile::Fill)
|
||||
@@ -55,9 +55,9 @@ public:
|
||||
// Stat_t contsum = cont/sum;
|
||||
// Stat_t eprim2 = TMath::Abs(err2/sum - contsum*contsum);
|
||||
// eprim = TMath::Sqrt(eprim2);
|
||||
// ... ???
|
||||
// ... ???
|
||||
// if (fErrorMode == kERRORMEAN) return eprim/TMath::Sqrt(sum);
|
||||
|
||||
|
||||
TW sw = parent::m_bin_Sw[offset]; //ROOT sum
|
||||
if(sw==0) return 0;
|
||||
TV svw = m_bin_Svw[offset]; //ROOT cont
|
||||
@@ -125,33 +125,33 @@ public:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bn_t ibin,jbin;
|
||||
if(!parent::m_axes[0].coord_to_absolute_index(aX,ibin)) return false;
|
||||
if(!parent::m_axes[1].coord_to_absolute_index(aY,jbin)) return false;
|
||||
bn_t offset = ibin + jbin * parent::m_axes[1].m_offset;
|
||||
|
||||
|
||||
parent::m_bin_entries[offset]++;
|
||||
parent::m_bin_Sw[offset] += aWeight;
|
||||
parent::m_bin_Sw2[offset] += aWeight * aWeight;
|
||||
|
||||
|
||||
TC xw = aX * aWeight;
|
||||
TC x2w = aX * xw;
|
||||
parent::m_bin_Sxw[offset][0] += xw;
|
||||
parent::m_bin_Sx2w[offset][0] += x2w;
|
||||
|
||||
|
||||
TC yw = aY * aWeight;
|
||||
TC y2w = aY * yw;
|
||||
parent::m_bin_Sxw[offset][1] += yw;
|
||||
parent::m_bin_Sx2w[offset][1] += y2w;
|
||||
|
||||
|
||||
bool inRange = true;
|
||||
if(ibin==0) inRange = false;
|
||||
else if(ibin==(parent::m_axes[0].m_number_of_bins+1)) inRange = false;
|
||||
|
||||
|
||||
if(jbin==0) inRange = false;
|
||||
else if(jbin==(parent::m_axes[1].m_number_of_bins+1)) inRange = false;
|
||||
|
||||
|
||||
parent::m_all_entries++;
|
||||
if(inRange) {
|
||||
parent::m_in_range_plane_Sxyw[0] += aX * aY * aWeight;
|
||||
@@ -160,26 +160,26 @@ public:
|
||||
parent::m_in_range_entries++;
|
||||
parent::m_in_range_Sw += aWeight;
|
||||
parent::m_in_range_Sw2 += aWeight*aWeight;
|
||||
|
||||
|
||||
parent::m_in_range_Sxw[0] += xw;
|
||||
parent::m_in_range_Sx2w[0] += x2w;
|
||||
|
||||
parent::m_in_range_Sxw[1] += yw;
|
||||
parent::m_in_range_Sx2w[1] += y2w;
|
||||
}
|
||||
|
||||
|
||||
// Profile part :
|
||||
TV vw = aV * aWeight;
|
||||
m_bin_Svw[offset] += vw;
|
||||
m_bin_Sv2w[offset] += aV * vw;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TV bin_rms_value(int aI,int aJ) const {
|
||||
TO offset;
|
||||
if(!parent::_find_offset(aI,aJ,offset)) return 0;
|
||||
|
||||
|
||||
TW sw = parent::m_bin_Sw[offset];
|
||||
if(sw==0) return 0;
|
||||
TV svw = m_bin_Svw[offset];
|
||||
@@ -191,16 +191,16 @@ public:
|
||||
bool add(const p2& a_histo){
|
||||
parent::base_add(a_histo);
|
||||
for(bn_t ibin=0;ibin<parent::m_bin_number;ibin++) {
|
||||
m_bin_Svw[ibin] += a_histo.m_bin_Svw[ibin];
|
||||
m_bin_Sv2w[ibin] += a_histo.m_bin_Sv2w[ibin];
|
||||
m_bin_Svw[ibin] += a_histo.m_bin_Svw[ibin];
|
||||
m_bin_Sv2w[ibin] += a_histo.m_bin_Sv2w[ibin];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool subtract(const p2& a_histo){
|
||||
parent::base_subtract(a_histo);
|
||||
for(bn_t ibin=0;ibin<parent::m_bin_number;ibin++) {
|
||||
m_bin_Svw[ibin] -= a_histo.m_bin_Svw[ibin];
|
||||
m_bin_Sv2w[ibin] -= a_histo.m_bin_Sv2w[ibin];
|
||||
m_bin_Svw[ibin] -= a_histo.m_bin_Svw[ibin];
|
||||
m_bin_Sv2w[ibin] -= a_histo.m_bin_Sv2w[ibin];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
,m_cut_v(true)
|
||||
,m_min_v(aVmin)
|
||||
,m_max_v(aVmax)
|
||||
{
|
||||
{
|
||||
m_bin_Svw.resize(parent::m_bin_number,0);
|
||||
m_bin_Sv2w.resize(parent::m_bin_number,0);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ template <class H2,class H1>
|
||||
inline bool fill_slice_x(const H2& a_from,int aJbeg,int aJend,H1& a_to) {
|
||||
|
||||
if(!a_from.dimension()) return false;
|
||||
|
||||
|
||||
typedef typename H2::bn_t bn_t;
|
||||
|
||||
bn_t jbeg;
|
||||
@@ -31,9 +31,9 @@ inline bool fill_slice_x(const H2& a_from,int aJbeg,int aJend,H1& a_to) {
|
||||
typedef typename H1::hd_t hd_t;
|
||||
hd_t hdata = a_to.dac();
|
||||
|
||||
bn_t aoffset,offset,jbin;
|
||||
bn_t aoffset,offset,jbin;
|
||||
bn_t yoffset = a_from.axis_y().m_offset;
|
||||
|
||||
|
||||
typedef typename H2::num_entries_t TN;
|
||||
typedef typename H2::weight_t TW;
|
||||
typedef typename H2::coordinate_t TC;
|
||||
@@ -99,7 +99,7 @@ inline bool fill_slice_y(const H2& a_from,int aIbeg,int aIend,H1& a_to) {
|
||||
typedef typename H1::hd_t hd_t;
|
||||
hd_t hdata = a_to.dac();
|
||||
|
||||
bn_t aibin,aoffset,offset,ibin;
|
||||
bn_t aibin,aoffset,offset,ibin;
|
||||
bn_t yoffset = a_from.axis_y().m_offset;
|
||||
|
||||
typedef typename H2::num_entries_t TN;
|
||||
@@ -156,7 +156,7 @@ inline H1* projection_y(const H2& a_from,const std::string& a_title) {
|
||||
template <class H2,class P1>
|
||||
inline bool fill_profile_x(const H2& a_from,int aJbeg,int aJend,P1& a_to) {
|
||||
if(!a_from.dimension()) return false;
|
||||
|
||||
|
||||
typedef typename H2::bn_t bn_t;
|
||||
|
||||
bn_t jbeg;
|
||||
@@ -170,9 +170,9 @@ inline bool fill_profile_x(const H2& a_from,int aJbeg,int aJend,P1& a_to) {
|
||||
typedef typename P1::pd_t pd_t;
|
||||
pd_t hdata = a_to.get_histo_data();
|
||||
|
||||
bn_t aoffset,offset,jbin;
|
||||
bn_t aoffset,offset,jbin;
|
||||
bn_t yoffset = a_from.axis_y().m_offset;
|
||||
|
||||
|
||||
typedef typename H2::num_entries_t TN;
|
||||
typedef typename H2::weight_t TW;
|
||||
typedef typename H2::coordinate_t TC;
|
||||
@@ -230,7 +230,7 @@ inline bool fill_profile_y(const H2& a_from,int aIbeg,int aIend,P1& a_to) {
|
||||
typedef typename P1::pd_t pd_t;
|
||||
pd_t hdata = a_to.get_histo_data();
|
||||
|
||||
bn_t aibin,aoffset,offset,ibin;
|
||||
bn_t aibin,aoffset,offset,ibin;
|
||||
bn_t yoffset = a_from.axis_y().m_offset;
|
||||
|
||||
typedef typename H2::num_entries_t TN;
|
||||
@@ -293,13 +293,13 @@ inline bool fill_slice_yz(const H3& a_from,int aIbeg,int aIend,H2& a_to) {
|
||||
|
||||
typedef typename H2::hd_t hd_t;
|
||||
hd_t hdata = a_to.dac();
|
||||
|
||||
bn_t aibin,ajbin,aoffset,offset,ibin;
|
||||
|
||||
|
||||
bn_t aibin,ajbin,aoffset,offset,ibin;
|
||||
|
||||
bn_t ayoffset = hdata.m_axes[1].m_offset;
|
||||
bn_t yoffset = a_from.axis_y().m_offset;
|
||||
bn_t zoffset = a_from.axis_z().m_offset;
|
||||
|
||||
|
||||
bn_t axbins = hdata.m_axes[0].bins()+2;
|
||||
bn_t aybins = hdata.m_axes[1].bins()+2;
|
||||
|
||||
@@ -344,7 +344,7 @@ inline bool fill_slice_yz(const H3& a_from,int aIbeg,int aIend,H2& a_to) {
|
||||
|
||||
template <class H3,class H2>
|
||||
inline bool fill_slice_xy(const H3& a_from,int aKbeg,int aKend,H2& a_to) {
|
||||
|
||||
|
||||
if(!a_from.dimension()) return false;
|
||||
|
||||
typedef typename H3::bn_t bn_t;
|
||||
@@ -354,20 +354,20 @@ inline bool fill_slice_xy(const H3& a_from,int aKbeg,int aKend,H2& a_to) {
|
||||
bn_t kend;
|
||||
if(!a_from.axis_z().in_range_to_absolute_index(aKend,kend)) return false;
|
||||
if(kbeg>kend) return false;
|
||||
|
||||
|
||||
if(a_from.axis_x().bins()!=a_to.axis_x().bins()) return false;
|
||||
if(a_from.axis_y().bins()!=a_to.axis_y().bins()) return false;
|
||||
|
||||
typedef typename H2::hd_t hd_t;
|
||||
hd_t hdata = a_to.dac();
|
||||
|
||||
|
||||
bn_t kbin;
|
||||
bn_t aibin,ajbin,aoffset,offset;
|
||||
|
||||
bn_t aibin,ajbin,aoffset,offset;
|
||||
|
||||
bn_t ayoffset = hdata.m_axes[1].m_offset;
|
||||
bn_t yoffset = a_from.axis_y().m_offset;
|
||||
bn_t zoffset = a_from.axis_z().m_offset;
|
||||
|
||||
|
||||
bn_t axbins = hdata.m_axes[0].bins()+2;
|
||||
bn_t aybins = hdata.m_axes[1].bins()+2;
|
||||
|
||||
@@ -412,7 +412,7 @@ inline bool fill_slice_xy(const H3& a_from,int aKbeg,int aKend,H2& a_to) {
|
||||
|
||||
template <class H3,class H2>
|
||||
inline bool fill_slice_xz(const H3& a_from,int aJbeg,int aJend,H2& a_to) {
|
||||
|
||||
|
||||
if(!a_from.dimension()) return false;
|
||||
|
||||
typedef typename H3::bn_t bn_t;
|
||||
@@ -425,16 +425,16 @@ inline bool fill_slice_xz(const H3& a_from,int aJbeg,int aJend,H2& a_to) {
|
||||
|
||||
if(a_from.axis_x().bins()!=a_to.axis_x().bins()) return false;
|
||||
if(a_from.axis_z().bins()!=a_to.axis_y().bins()) return false;
|
||||
|
||||
|
||||
typedef typename H2::hd_t hd_t;
|
||||
hd_t hdata = a_to.dac();
|
||||
|
||||
bn_t aibin,ajbin,aoffset,offset,jbin;
|
||||
|
||||
bn_t aibin,ajbin,aoffset,offset,jbin;
|
||||
|
||||
bn_t ayoffset = hdata.m_axes[1].m_offset;
|
||||
bn_t yoffset = a_from.axis_y().m_offset;
|
||||
bn_t zoffset = a_from.axis_z().m_offset;
|
||||
|
||||
|
||||
bn_t axbins = hdata.m_axes[0].bins()+2;
|
||||
bn_t aybins = hdata.m_axes[1].bins()+2;
|
||||
|
||||
@@ -457,7 +457,7 @@ inline bool fill_slice_xz(const H3& a_from,int aJbeg,int aJend,H2& a_to) {
|
||||
//offset3D = ibin + jbin * m_axes[1].m_offset + kbin*m_axes[2].m_offset;
|
||||
// hdata booked with x-z then :
|
||||
offset = aibin + jbin * yoffset + ajbin * zoffset;
|
||||
|
||||
|
||||
// Bin :
|
||||
hdata.m_bin_entries[aoffset] += af_bin_entries[offset];
|
||||
hdata.m_bin_Sw[aoffset] += af_bin_Sw[offset];
|
||||
@@ -469,7 +469,7 @@ inline bool fill_slice_xz(const H3& a_from,int aJbeg,int aJend,H2& a_to) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hdata.m_in_range_plane_Sxyw.assign(a_to.number_of_planes(),0); //ill-defined.
|
||||
|
||||
hdata.update_fast_getters();
|
||||
|
||||
@@ -37,7 +37,7 @@ inline void hls_to_rgb(T hue,T light,T satur,T& a_r,T& a_g,T& a_b){
|
||||
|
||||
if (satur > 0) rs = satur;
|
||||
if (rs > 1) rs = 1;
|
||||
|
||||
|
||||
if (rl <= T(0.5)) {
|
||||
rm2 = rl*(1 + rs);
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// Take care, all the below is highly disgusting...
|
||||
// (You can even find.. gotos !)
|
||||
//
|
||||
// Except for the public methods we let the style "as it".
|
||||
// Except for the public methods we let the style "as it".
|
||||
|
||||
#include "mnmx"
|
||||
#include "lina/vec3f"
|
||||
@@ -72,7 +72,7 @@ class axis {
|
||||
|
||||
// Ok, you really want to read all that. You had been warned...
|
||||
|
||||
enum {
|
||||
enum {
|
||||
TAxis_kTickPlus = (1<<(9)),
|
||||
TAxis_kTickMinus = (1<<(10)),
|
||||
TAxis_kAxisRange = (1<<(11)),
|
||||
@@ -89,7 +89,7 @@ class axis {
|
||||
TAxis_kMoreLogLabels = (1<<(23)),
|
||||
TAxis_kDecimals = (1<<(11))
|
||||
}; //in fBits2
|
||||
|
||||
|
||||
enum {
|
||||
kIsOnHeap = 0x01000000, // object is on heap
|
||||
kNotDeleted = 0x02000000, // object has not been deleted
|
||||
@@ -99,7 +99,7 @@ class axis {
|
||||
|
||||
static int GetTextFont() { return 132;}
|
||||
|
||||
static double TMath_ATan2(double y, double x) {
|
||||
static double TMath_ATan2(double y, double x) {
|
||||
if (x != 0) return ::atan2(y, x);
|
||||
if (y == 0) return 0;
|
||||
if (y > 0) return half_pi();
|
||||
@@ -111,7 +111,7 @@ class axis {
|
||||
//static long TMath_Abs(long d) { return (d >= 0) ? d : -d; }
|
||||
//static float TMath_Abs(float d) { return (d >= 0) ? d : -d; }
|
||||
static double TMath_Abs(double d) { return (d >= 0) ? d : -d; }
|
||||
|
||||
|
||||
static void TGaxis_Rotate(
|
||||
double X, double Y, double CFI, double SFI
|
||||
,double XT, double YT, double &U, double &V)
|
||||
@@ -138,12 +138,12 @@ private: //to discourage inheriting that.
|
||||
axis(const axis& a_from):m_out(a_from.m_out){}
|
||||
axis& operator=(const axis&){return *this;}
|
||||
public:
|
||||
void set_title(const std::string& aTitle) {
|
||||
void set_title(const std::string& aTitle) {
|
||||
fTitle = aTitle;
|
||||
}
|
||||
private:
|
||||
bool testBit(unsigned int f) {
|
||||
return (bool) ((fBits & f) != 0);
|
||||
bool testBit(unsigned int f) {
|
||||
return (bool) ((fBits & f) != 0);
|
||||
}
|
||||
|
||||
static void TGaxis_LabelsLimits(std::ostream& a_out,const char *label,
|
||||
@@ -290,7 +290,7 @@ public:
|
||||
// Time representation.
|
||||
// --------------------
|
||||
//
|
||||
// Axis labels may be considered as times, plotted in a defined
|
||||
// Axis labels may be considered as times, plotted in a defined
|
||||
// time format.
|
||||
// The format is set with SetTimeFormat().
|
||||
// wmin and wmax are considered as two time values in seconds.
|
||||
@@ -301,11 +301,11 @@ public:
|
||||
//
|
||||
// chopt='t': Plot times with a defined format instead of values
|
||||
//
|
||||
|
||||
|
||||
aLinesAxis.clear();
|
||||
aLinesGrid.clear();
|
||||
aTexts.clear();
|
||||
|
||||
|
||||
double alfa, beta, ratio1, ratio2, grid_side;
|
||||
double axis_lengthN = 0;
|
||||
double axis_length0 = 0;
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
char LABEL[256];
|
||||
char CHTEMP[256];
|
||||
double rangeOffset = 0;
|
||||
|
||||
|
||||
double epsilon = 1e-5;
|
||||
const double kPI = pi(); //GB
|
||||
double textSize = 0.05; //GB
|
||||
@@ -367,26 +367,26 @@ public:
|
||||
BinLow3 = 0; //GB
|
||||
first = 0; //GB
|
||||
last = 0; //GB
|
||||
|
||||
|
||||
double rwmi = wmin;
|
||||
double rwma = wmax;
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","start");
|
||||
|
||||
bool noExponent = testBit(TAxis_kNoExponent);
|
||||
|
||||
|
||||
// If MoreLogLabels = true more Log Intermediate Labels are drawn.
|
||||
bool MoreLogLabels = testBit(TAxis_kMoreLogLabels);
|
||||
|
||||
|
||||
// the following parameters correspond to the pad range in NDC
|
||||
// and the WC coordinates in the pad
|
||||
|
||||
|
||||
double padh = 1;//FIXME gPad->GetWh()*gPad->GetAbsHNDC();
|
||||
double RWxmin = 0;
|
||||
double RWxmax = 1;
|
||||
double RWymin = 0;
|
||||
double RWymax = 1;
|
||||
|
||||
|
||||
SETOPT(aCHOPT,'G',OptionLog);
|
||||
SETOPT(aCHOPT,'B',OptionBlank);
|
||||
SETOPT(aCHOPT,'V',OptionVert);
|
||||
@@ -410,7 +410,7 @@ public:
|
||||
SETOPT(aCHOPT,'X',OptionX);
|
||||
SETOPT(aCHOPT,'t',OptionTime);
|
||||
SETOPT(aCHOPT,'.',OptionDot);
|
||||
|
||||
|
||||
if (testBit(TAxis_kTickPlus)) OptionPlus = 2;
|
||||
if (testBit(TAxis_kTickMinus)) OptionMinus = 2;
|
||||
if (testBit(TAxis_kCenterLabels)) OptionM = 1;
|
||||
@@ -422,26 +422,26 @@ public:
|
||||
ndiv = fAxis->GetLast()-fAxis->GetFirst()+1;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// Set the grid length
|
||||
|
||||
|
||||
if (OptionGrid) {
|
||||
if (gridlength == 0) gridlength = 0.8;
|
||||
/*FIXME
|
||||
linegrid = new TLine();
|
||||
linegrid->SetLineColor(gStyle->GetGridColor());
|
||||
if (linegrid->GetLineColor() == 0)
|
||||
if (linegrid->GetLineColor() == 0)
|
||||
linegrid->SetLineColor(GetLineColor());
|
||||
linegrid->SetLineStyle(gStyle->GetGridStyle());
|
||||
linegrid->SetLineWidth(gStyle->GetGridWidth());*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (OptionTime) {
|
||||
//printf("debug : SbAxisHPLOT::paint : fTimeFormat : \"%s\"\n",
|
||||
// fTimeFormat.c_str());
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0000");
|
||||
// Determine time format
|
||||
std::string timeformat;
|
||||
@@ -451,7 +451,7 @@ public:
|
||||
} else {
|
||||
timeformat = fTimeFormat;
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0001");
|
||||
// determine the time offset and correct for time offset not being integer
|
||||
double timeoffset = 0;
|
||||
@@ -460,7 +460,7 @@ public:
|
||||
int LnF = int(fTimeFormat.size());
|
||||
std::string stringtimeoffset = fTimeFormat.substr(IdF+2,LnF-(IdF+2));
|
||||
int yy, mm, dd, hh, mi, ss;
|
||||
if (::sscanf(stringtimeoffset.c_str(),
|
||||
if (::sscanf(stringtimeoffset.c_str(),
|
||||
"%d-%d-%d %d:%d:%d", &yy, &mm, &dd, &hh, &mi, &ss) == 6) {
|
||||
struct tm tp;
|
||||
struct tm* tptest;
|
||||
@@ -532,18 +532,18 @@ public:
|
||||
int NN2 = mx<int>(N2A,1)*NN3;
|
||||
int NN1 = mx<int>(N1A,1)*NN2+1;
|
||||
int Nticks= NN1;
|
||||
|
||||
|
||||
// Axis bining optimization is ignored if:
|
||||
// - the first and the last label are equal
|
||||
// - the number of divisions is 0
|
||||
// - less than 1 primary division is requested
|
||||
// - logarithmic scale is requested
|
||||
|
||||
|
||||
if (wmin == wmax || ndiv == 0 || N1A <= 1 || OptionLog) {
|
||||
OptionNoopt = 1;
|
||||
OptionInt = 0;
|
||||
}
|
||||
|
||||
|
||||
// Axis bining optimization
|
||||
if ( (wmax-wmin) < 1 && OptionInt) {
|
||||
out_error(m_out,"PaintAxis", "option I not available");
|
||||
@@ -551,17 +551,17 @@ public:
|
||||
}
|
||||
//out_error(m_out,"android_debug","0002");
|
||||
if (!OptionNoopt || OptionInt ) {
|
||||
|
||||
|
||||
// Primary divisions optimization
|
||||
// When integer labelling is required, Optimize is invoked first
|
||||
// and only if the result is not an integer labelling, AdjustBinSize
|
||||
// and only if the result is not an integer labelling, AdjustBinSize
|
||||
// is invoked.
|
||||
|
||||
|
||||
optimizeLimits(wmin,wmax,N1A,
|
||||
BinLow,BinHigh,nbins,BinWidth,
|
||||
aCHOPT);
|
||||
if (OptionInt) {
|
||||
if (BinLow != double(int(BinLow)) ||
|
||||
if (BinLow != double(int(BinLow)) ||
|
||||
BinWidth != double(int(BinWidth))) {
|
||||
adjustBinSize(wmin,wmax,N1A,BinLow,BinHigh,nbins,BinWidth);
|
||||
}
|
||||
@@ -597,7 +597,7 @@ public:
|
||||
wmin = BinLow;
|
||||
wmax = BinHigh;
|
||||
}
|
||||
|
||||
|
||||
// Secondary divisions optimization
|
||||
int NB2 = N2A;
|
||||
if (!OptionNoopt && N2A > 1 && BinWidth > 0) {
|
||||
@@ -605,7 +605,7 @@ public:
|
||||
BinLow2,BinHigh2,NB2,BinWidth2,
|
||||
aCHOPT);
|
||||
}
|
||||
|
||||
|
||||
// Tertiary divisions optimization
|
||||
int NB3 = N3A;
|
||||
if (!OptionNoopt && N3A > 1 && BinWidth2 > 0) {
|
||||
@@ -621,10 +621,10 @@ public:
|
||||
NN1 = mx<int>(N1A,1)*NN2+1;
|
||||
Nticks = NN1;
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0003");
|
||||
// Coordinates are normalized
|
||||
|
||||
|
||||
ratio1 = 1/(RWxmax-RWxmin);
|
||||
ratio2 = 1/(RWymax-RWymin);
|
||||
X0 = ratio1*(xmin-RWxmin);
|
||||
@@ -637,22 +637,22 @@ public:
|
||||
YY0 = ratio2*(Yymin-RWymin);
|
||||
YY1 = ratio2*(Yymax-RWymin);
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0004");
|
||||
if ((X0 == X1) && (Y0 == Y1)) {
|
||||
out_error(m_out,"PaintAxis", "length of axis is 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Return wmin, wmax and the number of primary divisions
|
||||
if (OptionX) {
|
||||
ndiv = N1A;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int maxDigits = 5;
|
||||
//FIXME if (fAxis) maxDigits = fMaxDigits;
|
||||
|
||||
|
||||
/*FIXME
|
||||
TLatex *textaxis = new TLatex();
|
||||
lineaxis->SetLineColor(GetLineColor());
|
||||
@@ -660,21 +660,21 @@ public:
|
||||
lineaxis->SetLineWidth(GetLineWidth());
|
||||
textaxis->SetTextColor(GetTextColor());
|
||||
textaxis->SetTextFont(GetTextFont());
|
||||
|
||||
|
||||
if (!gPad->IsBatch()) {
|
||||
float chupxvsav, chupyvsav;
|
||||
gVirtualX->GetCharacterUp(chupxvsav, chupyvsav);
|
||||
gVirtualX->SetClipOFF(gPad->GetCanvasID());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// Compute length of axis
|
||||
double axis_length = ::sqrt((X1-X0)*(X1-X0)+(Y1-Y0)*(Y1-Y0));
|
||||
if (axis_length == 0) {
|
||||
out_error(m_out,"PaintAxis", "length of axis is 0");
|
||||
return; //goto L210;
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0005");
|
||||
if (!OptionNoopt || OptionInt) {
|
||||
axis_lengthN = ::sqrt((XX1-XX0)*(XX1-XX0)+(YY1-YY0)*(YY1-YY0));
|
||||
@@ -694,7 +694,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0006");
|
||||
if (X0 == X1) {
|
||||
phi = 0.5*kPI;
|
||||
@@ -714,13 +714,13 @@ public:
|
||||
asinphi = TMath_Abs(sinphi);
|
||||
if (acosphi <= epsilon) { acosphi = 0; cosphi = 0; }
|
||||
if (asinphi <= epsilon) { asinphi = 0; sinphi = 0; }
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0007");
|
||||
// Mside positive, tick marks on positive side
|
||||
// Mside negative, tick marks on negative side
|
||||
// Mside zero, tick marks on both sides
|
||||
// Default is positive except for vertical axis
|
||||
|
||||
|
||||
Mside=1;
|
||||
if (X0 == X1 && Y1 > Y0) Mside = -1;
|
||||
if (OptionPlus) Mside = 1;
|
||||
@@ -734,24 +734,24 @@ public:
|
||||
if (OptionEqual) Lside=1;
|
||||
}
|
||||
XLside = Lside;
|
||||
|
||||
|
||||
// Tick marks size
|
||||
double tick_side;
|
||||
if(XMside >= 0) tick_side = 1;
|
||||
else tick_side = -1;
|
||||
|
||||
|
||||
double atick[3];
|
||||
if (OptionSize) atick[0] = tick_side*axis_length*fTickSize;
|
||||
else atick[0] = tick_side*axis_length*0.03;
|
||||
|
||||
|
||||
atick[1] = 0.5*atick[0];
|
||||
atick[2] = 0.5*atick[1];
|
||||
|
||||
|
||||
// Set the side of the grid
|
||||
if ((X0 == X1) && (Y1 > Y0)) grid_side =-1;
|
||||
else grid_side = 1;
|
||||
|
||||
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0008");
|
||||
// Compute Values if Function is given
|
||||
/*GB if(fFunction) {
|
||||
@@ -763,7 +763,7 @@ public:
|
||||
rwmi = t;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// Draw the axis if needed...
|
||||
if (!OptionBlank) {
|
||||
xpl1 = X0;
|
||||
@@ -775,16 +775,16 @@ public:
|
||||
aLinesAxis.push_back((float)xpl2);
|
||||
aLinesAxis.push_back((float)ypl2);
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0009");
|
||||
// No bining
|
||||
|
||||
|
||||
if (ndiv == 0) return; //goto L210;
|
||||
if (wmin == wmax) {
|
||||
out_error(m_out,"PaintAxis", "wmin (%f) == wmax (%f)", wmin, wmax);
|
||||
return; //goto L210;
|
||||
}
|
||||
|
||||
|
||||
// Draw axis title if it exists
|
||||
if (!drawGridOnly && fTitle.size()) {
|
||||
textSize = fTitleSize;
|
||||
@@ -830,13 +830,13 @@ public:
|
||||
fTitle,textAlign));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0010");
|
||||
// Labels preparation:
|
||||
// Get character height
|
||||
// Compute the labels orientation in case of overlaps
|
||||
// with alphanumeric labels for horizontal axis).
|
||||
|
||||
|
||||
charheight = fLabelSize;
|
||||
if (OptionText) charheight *= 0.66666;
|
||||
//FIXME textaxis->SetTextFont(fLabelFont);
|
||||
@@ -901,7 +901,7 @@ public:
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0011");
|
||||
// Now determine orientation of labels on axis
|
||||
/*FIXME
|
||||
@@ -913,7 +913,7 @@ public:
|
||||
if (OptionPara) gVirtualX->SetCharacterUp(-sinphi,cosphi);
|
||||
if (OptionDown) gVirtualX->SetCharacterUp(cosphi,sinphi);
|
||||
}*/
|
||||
|
||||
|
||||
// Now determine text alignment
|
||||
Xalign = 2;
|
||||
Yalign = 1;
|
||||
@@ -929,7 +929,7 @@ public:
|
||||
if (cosphi*sinphi < 0) Xalign = 3;
|
||||
}
|
||||
textAlign = 10*Xalign+Yalign;
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0012");
|
||||
// Position of labels in Y
|
||||
if (X0 == X1) {
|
||||
@@ -954,7 +954,7 @@ public:
|
||||
else Ylabel = -fLabelOffset;
|
||||
}
|
||||
if (OptionText) Ylabel /= 2;
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0013");
|
||||
// Draw the linear tick marks if needed...
|
||||
if (!OptionLog) {
|
||||
@@ -1011,7 +1011,7 @@ public:
|
||||
aLinesAxis.push_back((float)xpl2);
|
||||
aLinesAxis.push_back((float)ypl2);
|
||||
}
|
||||
|
||||
|
||||
if (OptionGrid) {
|
||||
if (ltick == 0) {
|
||||
if (OptionNoopt && !OptionInt) {
|
||||
@@ -1034,7 +1034,7 @@ public:
|
||||
}
|
||||
Xtick0 = 0;
|
||||
Xtick1 = Xtick;
|
||||
|
||||
|
||||
if ((!OptionNoopt || OptionInt) && axis_length0) {
|
||||
int Nticks0;
|
||||
/*GB if (fFunction) Nticks0 = int((BinLow-wmin)/DXtick);
|
||||
@@ -1073,7 +1073,7 @@ public:
|
||||
aLinesAxis.push_back((float)xpl2);
|
||||
aLinesAxis.push_back((float)ypl2);
|
||||
}
|
||||
|
||||
|
||||
if (OptionGrid) {
|
||||
if (ltick == 0) {
|
||||
TGaxis_Rotate(Xtick0,0,cosphi,sinphi,XX0,YY0,xpl2,ypl2);
|
||||
@@ -1089,7 +1089,7 @@ public:
|
||||
Xtick0 -= DXtick;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((!OptionNoopt || OptionInt) && axis_length1) {
|
||||
int Nticks1;
|
||||
/*GB if (fFunction) Nticks1 = int((wmax-BinHigh)/DXtick);
|
||||
@@ -1128,7 +1128,7 @@ public:
|
||||
aLinesAxis.push_back((float)xpl2);
|
||||
aLinesAxis.push_back((float)ypl2);
|
||||
}
|
||||
|
||||
|
||||
if (OptionGrid) {
|
||||
if (ltick == 0) {
|
||||
TGaxis_Rotate(Xtick1,0,cosphi,sinphi,XX0,YY0 ,xpl2,ypl2);
|
||||
@@ -1146,7 +1146,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0014");
|
||||
// Draw the numeric labels if needed...
|
||||
if (!drawGridOnly && !OptionUnlab) {
|
||||
@@ -1161,12 +1161,12 @@ public:
|
||||
DWlabel = (wmax-wmin)/double(N1A);
|
||||
if (OptionNoopt && !OptionInt) DXlabel = axis_length/double(N1A);
|
||||
else DXlabel = axis_lengthN/double(N1A);
|
||||
|
||||
|
||||
char CHCODED[8];
|
||||
int NEXE = 0;
|
||||
bool FLEXE = false;
|
||||
if (!OptionText && !OptionTime) {
|
||||
|
||||
|
||||
// We have to decide what format to generate
|
||||
// for numeric labels only)
|
||||
// Test the magnitude, decide format
|
||||
@@ -1175,9 +1175,9 @@ public:
|
||||
bool FLEXPO = false;
|
||||
bool FLEXNE = false;
|
||||
WW = mx<double>(TMath_Abs(wmin),TMath_Abs(wmax));
|
||||
|
||||
|
||||
// First case : (wmax-wmin)/N1A less than 0.001
|
||||
// 0.001 fMaxDigits of 5 (fMaxDigits) characters).
|
||||
// 0.001 fMaxDigits of 5 (fMaxDigits) characters).
|
||||
// Then we use x 10 n
|
||||
// format. If AF >=0 x10 n cannot be used
|
||||
double xmicros = 0.00099;
|
||||
@@ -1205,9 +1205,9 @@ public:
|
||||
NF = int(AF)+1;
|
||||
if (!noExponent && NF > maxDigits) FLEXPO = true;
|
||||
if (!noExponent && NF < -maxDigits) FLEXNE = true;
|
||||
|
||||
|
||||
// Use x 10 n format. (only powers of 3 allowed)
|
||||
|
||||
|
||||
if (FLEXPO) {
|
||||
FLEXE = true;
|
||||
while (1) {
|
||||
@@ -1218,7 +1218,7 @@ public:
|
||||
if (NEXE%3 == 0 && WW <= ::pow(10.,maxDigits-1)) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (FLEXNE) {
|
||||
FLEXE = true;
|
||||
RNE = 1/::pow(10.,maxDigits-2);
|
||||
@@ -1230,7 +1230,7 @@ public:
|
||||
if (NEXE%3 == 0 && WW >= RNE) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NA = 0;
|
||||
for (i=maxDigits-1; i>0; i--) {
|
||||
if (TMath_Abs(WW) < ::pow(10.,i)) NA = maxDigits-i;
|
||||
@@ -1244,13 +1244,13 @@ public:
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
|
||||
IF2 = NA;
|
||||
IF1 = mx<int>(NF+NA,maxDigits)+1;
|
||||
L110:
|
||||
if (mn<double>(wmin,wmax) < 0)IF1 = IF1+1;
|
||||
IF1 = mn<int>(IF1,32);
|
||||
|
||||
|
||||
// In some cases, IF1 and IF2 are too small....
|
||||
while (DWlabel < ::pow(10.,-IF2)) {
|
||||
IF1++;
|
||||
@@ -1262,9 +1262,9 @@ public:
|
||||
if(IF2)snpf(CHCODED,sizeof(CHCODED),"%%%d.%df",IF1,IF2);
|
||||
else snpf(CHCODED,sizeof(CHCODED),"%%%d.%df",IF1+1,1);
|
||||
}
|
||||
|
||||
|
||||
// We draw labels
|
||||
|
||||
|
||||
snpf(CHTEMP,sizeof(CHTEMP),"%g",DWlabel);
|
||||
|
||||
size_t ndecimals = 0;
|
||||
@@ -1286,14 +1286,14 @@ public:
|
||||
Xlabel = DXlabel*k;
|
||||
}
|
||||
if (OptionM) Xlabel += 0.5*DXlabel;
|
||||
|
||||
|
||||
if (!OptionText && !OptionTime) {
|
||||
snpf(LABEL,sizeof(LABEL),&CHCODED[0],Wlabel);
|
||||
LABEL[28] = 0;
|
||||
Wlabel += DWlabel;
|
||||
|
||||
|
||||
TGaxis_LabelsLimits(m_out,LABEL,first,last); //Eliminate blanks
|
||||
|
||||
|
||||
if (LABEL[first] == '.') { //check if '.' is preceeded by a digit
|
||||
::strcpy(CHTEMP, "0");
|
||||
::strcat(CHTEMP, &LABEL[first]);
|
||||
@@ -1306,7 +1306,7 @@ public:
|
||||
::strcpy(LABEL, CHTEMP);
|
||||
first = 1; last = int(::strlen(LABEL));
|
||||
}
|
||||
|
||||
|
||||
// We eliminate the non significant 0 after '.'
|
||||
if (ndecimals) {
|
||||
char *adot = ::strchr(LABEL,'.');
|
||||
@@ -1319,9 +1319,9 @@ public:
|
||||
if (!OptionDot) { LABEL[last] = 0; last--;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Generate the time labels
|
||||
|
||||
|
||||
if (OptionTime) {
|
||||
double timed = Wlabel + (int)(timeoffset) - rangeOffset;
|
||||
time_t timelabel = (time_t)((long)(timed));
|
||||
@@ -1334,33 +1334,33 @@ public:
|
||||
std::string timeformattmp;
|
||||
if (timeformat.size() < 220) timeformattmp = timeformat;
|
||||
else timeformattmp = "#splitline{Format}{too long}";
|
||||
|
||||
|
||||
// Appends fractionnal part if seconds displayed
|
||||
if (DWlabel<0.9) {
|
||||
double tmpdb;
|
||||
size_t tmplast;
|
||||
snpf(LABEL,sizeof(LABEL),"%%S%7.5f",modf(timed,&tmpdb));
|
||||
tmplast = ::strlen(LABEL)-1;
|
||||
|
||||
|
||||
// We eliminate the non significiant 0 after '.'
|
||||
while (LABEL[tmplast] == '0') {
|
||||
LABEL[tmplast] = 0; tmplast--;
|
||||
}
|
||||
|
||||
|
||||
//FIXME timeformattmp.ReplaceAll("%S",LABEL);
|
||||
// Replace the "0." at the begining by "s"
|
||||
//FIXME timeformattmp.ReplaceAll("%S0.","%Ss");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
::strftime(LABEL,256,timeformattmp.c_str(),utctis);
|
||||
::strcpy(CHTEMP,&LABEL[0]);
|
||||
first = 0; last=int(::strlen(LABEL))-1;
|
||||
Wlabel = wTimeIni + (k+1)*DWlabel;
|
||||
}
|
||||
|
||||
|
||||
// We generate labels (numeric or alphanumeric).
|
||||
|
||||
|
||||
if (OptionNoopt && !OptionInt)
|
||||
TGaxis_Rotate (Xlabel,Ylabel,cosphi,sinphi,X0,Y0,XX,YY);
|
||||
else TGaxis_Rotate (Xlabel,Ylabel,cosphi,sinphi,XX0,YY0,XX,YY);
|
||||
@@ -1397,7 +1397,7 @@ public:
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
// Text alignment is down
|
||||
int LNLEN = 0;
|
||||
if (!OptionText) LNLEN = last-first+1;
|
||||
@@ -1418,9 +1418,9 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// We use the format x 10 ** n
|
||||
|
||||
|
||||
if (FLEXE && !OptionText && NEXE) {
|
||||
//G.Barrand ::sprintf(LABEL,"#times10^{%d}", NEXE);
|
||||
snpf(LABEL,sizeof(LABEL),
|
||||
@@ -1437,9 +1437,9 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Log axis
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","0015");
|
||||
if (OptionLog && ndiv) {
|
||||
unsigned int xi1=0,xi2 = 0,wi = 0,yi1=0,yi2,hi = 0;
|
||||
@@ -1469,7 +1469,7 @@ public:
|
||||
int IH2 = 1+int(H2);
|
||||
int NBININ = IH2-IH1+1;
|
||||
double AXMUL = (X11-X00)/(H2SAV-XMNLOG);
|
||||
|
||||
|
||||
// Plot decade and intermediate tick marks
|
||||
decade = IH1-2;
|
||||
int labelnumber = IH1;
|
||||
@@ -1512,7 +1512,7 @@ public:
|
||||
aLinesAxis.push_back((float)xpl2);
|
||||
aLinesAxis.push_back((float)ypl2);
|
||||
}
|
||||
|
||||
|
||||
if (OptionGrid) {
|
||||
TGaxis_Rotate(Xone,0,cosphi,sinphi,X0,Y0,xpl2,ypl2);
|
||||
TGaxis_Rotate(Xone,grid_side*gridlength,cosphi,sinphi,X0,Y0,
|
||||
@@ -1522,9 +1522,9 @@ public:
|
||||
aLinesGrid.push_back((float)xpl2);
|
||||
aLinesGrid.push_back((float)ypl2);
|
||||
}
|
||||
|
||||
|
||||
if (!drawGridOnly && !OptionUnlab) {
|
||||
|
||||
|
||||
// We generate labels (numeric only).
|
||||
if (noExponent) {
|
||||
double rlab = ::pow(10.,labelnumber);
|
||||
@@ -1589,7 +1589,7 @@ public:
|
||||
}
|
||||
L160:
|
||||
for (k=2;k<10;k++) {
|
||||
|
||||
|
||||
// Plot intermediate tick marks
|
||||
//double Xone; //rm shadow warning.
|
||||
Xone = X00+AXMUL*(::log10(double(k))+double(decade)-XMNLOG);
|
||||
@@ -1623,10 +1623,10 @@ public:
|
||||
aLinesAxis.push_back((float)xpl2);
|
||||
aLinesAxis.push_back((float)ypl2);
|
||||
}
|
||||
|
||||
|
||||
// Draw the intermediate LOG labels if requested
|
||||
|
||||
if (MoreLogLabels && !OptionUnlab &&
|
||||
|
||||
if (MoreLogLabels && !OptionUnlab &&
|
||||
!drawGridOnly && !overlap) {
|
||||
if (noExponent) {
|
||||
double rlab = double(k)*::pow(10.,labelnumber-1);
|
||||
@@ -1683,8 +1683,8 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the intermediate LOG grid if only three
|
||||
|
||||
// Draw the intermediate LOG grid if only three
|
||||
// decades are requested
|
||||
if (OptionGrid && NBININ <= 5 && ndiv > 100) {
|
||||
TGaxis_Rotate(Xone,0,cosphi,sinphi,X0,Y0,xpl2, ypl2);
|
||||
@@ -1701,12 +1701,12 @@ public:
|
||||
L200:
|
||||
int kuku=0; if (kuku) { }
|
||||
} //endif (OptionLog && ndiv)
|
||||
|
||||
|
||||
|
||||
|
||||
//out_error(m_out,"android_debug","end");
|
||||
//L210:
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void TGaxis_SetDecimals(bool dot)
|
||||
{
|
||||
@@ -1716,11 +1716,11 @@ public:
|
||||
// is also stripped, unless this option is specified.
|
||||
// One can disable the option by calling axis.SetDecimals(true).
|
||||
// Note the bit is set in fBits (as opposed to fBits2 in TAxis!)
|
||||
|
||||
|
||||
if (dot) SetBit(TAxis_kDecimals);
|
||||
else ResetBit(TAxis_kDecimals);
|
||||
}
|
||||
|
||||
|
||||
void TGaxis_SetMaxDigits(int maxd)
|
||||
{
|
||||
// static function to set fMaxDigits for axis with the bin content
|
||||
@@ -1730,18 +1730,18 @@ public:
|
||||
//For example, to accept 6 digits number like 900000 on an axis
|
||||
//call TGaxis::SetMaxDigits(6). The default value is 5.
|
||||
//fMaxDigits must be greater than 0.
|
||||
|
||||
|
||||
fMaxDigits = maxd;
|
||||
if (maxd < 1) fMaxDigits = 1;
|
||||
}
|
||||
|
||||
|
||||
void TGaxis_SetMoreLogLabels(bool more)
|
||||
{
|
||||
// Set the kMoreLogLabels bit flag
|
||||
// When this option is selected more labels are drawn when in log scale
|
||||
// and there is a small number of decades (<3).
|
||||
// Note that this option is automatically inherited from TAxis
|
||||
|
||||
|
||||
if (more) SetBit(TAxis_kMoreLogLabels);
|
||||
else ResetBit(TAxis_kMoreLogLabels);
|
||||
}
|
||||
@@ -1751,16 +1751,16 @@ public:
|
||||
// By default, an exponent of the form 10^N is used when the label values
|
||||
// are either all very small or very large.
|
||||
// One can disable the exponent by calling axis.SetNoExponent(true).
|
||||
|
||||
|
||||
if (noExponent) SetBit(TAxis_kNoExponent);
|
||||
else ResetBit(TAxis_kNoExponent);
|
||||
}
|
||||
void TGaxis_SetOption(const std::string& option)
|
||||
void TGaxis_SetOption(const std::string& option)
|
||||
{
|
||||
fCHOPT = option;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void set_time_format(const std::string& a_format)
|
||||
// Change the format used for time plotting
|
||||
// ========================================
|
||||
@@ -1788,7 +1788,7 @@ public:
|
||||
// fTimeFormat.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::string::size_type IdF = fTimeFormat.find("%F");
|
||||
if (IdF!=std::string::npos) {
|
||||
size_t LnF = fTimeFormat.size();
|
||||
@@ -1799,54 +1799,54 @@ public:
|
||||
// fTimeFormat.c_str());
|
||||
} else {
|
||||
fTimeFormat = a_format;
|
||||
|
||||
|
||||
// In CERN-ROOT :
|
||||
//SetTimeOffset(gStyle->GetTimeOffset());
|
||||
//TAxis::fTimeOffset = 788918400; // UTC time at 01/01/95
|
||||
//double UTC_time_1995_01_01__00_00_00 = 788918400; //CERN-ROOT
|
||||
//setTimeOffset(UTC_time_1995_01_01__00_00_00);
|
||||
|
||||
|
||||
//Be consistent with SoAxis::timeOffset being 0.
|
||||
double UTC_time_1970_01_01__00_00_00 = 0; //UNIX
|
||||
set_time_offset(UTC_time_1970_01_01__00_00_00);
|
||||
|
||||
|
||||
//::printf("debug : SbAxisHPLOT::setTimeFormat : 002 : \"%s\"\n",
|
||||
// fTimeFormat.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void set_time_offset(double toffset,bool a_is_gmt = false) {
|
||||
// Change the time offse t
|
||||
|
||||
|
||||
std::string::size_type IdF = fTimeFormat.find("%F");
|
||||
if (IdF!=std::string::npos) {
|
||||
fTimeFormat = fTimeFormat.substr(0,IdF);
|
||||
}
|
||||
fTimeFormat += "%F";
|
||||
|
||||
|
||||
time_t timeoff = (time_t)((long)(toffset));
|
||||
struct tm* utctis = ::gmtime(&timeoff);
|
||||
|
||||
|
||||
char tmp[256];
|
||||
::strftime(tmp,256,"%Y-%m-%d %H:%M:%S",utctis);
|
||||
fTimeFormat += tmp;
|
||||
|
||||
|
||||
// append the decimal part of the time offset
|
||||
double ds = toffset-(int)toffset;
|
||||
if(ds!= 0) {
|
||||
snpf(tmp,sizeof(tmp),"s%g",ds);
|
||||
fTimeFormat += tmp;
|
||||
}
|
||||
|
||||
|
||||
// If the time is GMT, stamp fTimeFormat
|
||||
if (a_is_gmt) fTimeFormat += " GMT";
|
||||
|
||||
|
||||
//::printf("debug : SbAxisHPLOT::setTimeOffset : \"%s\"\n",
|
||||
// fTimeFormat.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1865,7 +1865,7 @@ private:
|
||||
// BinLow,BinHigh : New WMIN,WMAX .
|
||||
// nold : Old NDIV .
|
||||
// nbins : New NDIV .
|
||||
|
||||
|
||||
int lwid, kwid;
|
||||
int ntemp = 0;
|
||||
int jlog = 0;
|
||||
@@ -1873,10 +1873,10 @@ private:
|
||||
double alb, awidth, sigfig;
|
||||
double timemulti = 1;
|
||||
int roundmode =0;
|
||||
|
||||
|
||||
int OptionTime;
|
||||
SETOPT(aCHOPT,'t',OptionTime);
|
||||
|
||||
|
||||
double AL = mn<double>(A1,A2);
|
||||
double AH = mx<double>(A1,A2);
|
||||
if (AL == AH) AH = AL+1;
|
||||
@@ -1884,16 +1884,16 @@ private:
|
||||
if (nold == -1 && BinWidth > 0 ) goto L90;
|
||||
ntemp = (int)mx<double>(nold,2);
|
||||
if (ntemp < 1) ntemp = 1;
|
||||
|
||||
|
||||
L20:
|
||||
awidth = (AH-AL)/double(ntemp);
|
||||
timemulti = 1;
|
||||
if (awidth >= FLT_MAX) goto LOK; //in float.h
|
||||
if (awidth <= 0) goto LOK;
|
||||
|
||||
|
||||
// If time representation, bin width should be rounded to seconds
|
||||
// minutes, hours or days
|
||||
|
||||
|
||||
if (OptionTime && awidth>=60) { // if width in seconds, treat it as normal
|
||||
// width in minutes
|
||||
awidth /= 60; timemulti *=60;
|
||||
@@ -1920,7 +1920,7 @@ private:
|
||||
}
|
||||
}
|
||||
// Get nominal bin width in exponential for m
|
||||
|
||||
|
||||
jlog = int(::log10(awidth));
|
||||
if (jlog <-200 || jlog > 200) {
|
||||
BinLow = 0;
|
||||
@@ -1933,11 +1933,11 @@ private:
|
||||
sigfig = awidth* ::pow(10.,-jlog) -1e-10;
|
||||
//in the above statement, it is important to substract 1e-10
|
||||
//to avoid precision problems if the tests below
|
||||
|
||||
|
||||
// Round mantissa
|
||||
|
||||
|
||||
switch (roundmode) {
|
||||
|
||||
|
||||
// Round mantissa up to 1, 1.5, 2, 3, or 6 in case of minutes
|
||||
case 1: // case 60
|
||||
if (sigfig <= 1) siground = 1;
|
||||
@@ -1949,7 +1949,7 @@ private:
|
||||
else siground = 6;
|
||||
break;
|
||||
case 2: // case 12 and 24
|
||||
|
||||
|
||||
// Round mantissa up to 1, 1.2, 2, 2.4, 3 or 6 in case of hours or months
|
||||
if (sigfig <= 1 && jlog==0) siground = 1;
|
||||
else if (sigfig <= 1.2 && jlog==1) siground = 1.2;
|
||||
@@ -1960,7 +1960,7 @@ private:
|
||||
else if (jlog==0) siground = 12;
|
||||
else siground = 2.4;
|
||||
break;
|
||||
|
||||
|
||||
//- Round mantissa up to 1, 1.4, 2, or 7 in case of days (weeks)
|
||||
case 3: // case 30
|
||||
if (sigfig <= 1 && jlog==0) siground = 1;
|
||||
@@ -1969,7 +1969,7 @@ private:
|
||||
else siground = 7;
|
||||
break;
|
||||
default :
|
||||
|
||||
|
||||
// Round mantissa up to 1, 2, 2.5, 5, or 10 in case of decimal number
|
||||
if (sigfig <= 1) siground = 1;
|
||||
else if (sigfig <= 2) siground = 2;
|
||||
@@ -1978,12 +1978,12 @@ private:
|
||||
else {siground = 1; jlog++; }
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
BinWidth = siground* ::pow(10.,jlog);
|
||||
if (OptionTime) BinWidth *= timemulti;
|
||||
|
||||
|
||||
// Get new bounds from new width BinWidth
|
||||
|
||||
|
||||
L90:
|
||||
alb = AL/BinWidth;
|
||||
if (TMath_Abs(alb) > 1e9) {
|
||||
@@ -2008,12 +2008,12 @@ private:
|
||||
goto LOK;
|
||||
}
|
||||
if (2*nbins == nold && !OptionTime) {ntemp++; goto L20; }
|
||||
|
||||
|
||||
LOK:
|
||||
double oldBinLow = BinLow;
|
||||
double oldBinHigh = BinHigh;
|
||||
int oldnbins = nbins;
|
||||
|
||||
|
||||
double atest = BinWidth*0.0001;
|
||||
//if (TMath_Abs(BinLow-A1) >= atest) { BinLow += BinWidth; nbins--; } //replaced by Damir in 3.10/02
|
||||
//if (TMath_Abs(BinHigh-A2) >= atest) { BinHigh -= BinWidth; nbins--; } //by the next two lines
|
||||
@@ -2059,10 +2059,10 @@ private:
|
||||
int width = int(BinWidth/5) + 1;
|
||||
BinWidth = 5*width;
|
||||
BinLow = int(A1/BinWidth)*BinWidth ;
|
||||
|
||||
|
||||
// We determine BinLow to have one tick mark at 0
|
||||
// if there are negative labels.
|
||||
|
||||
|
||||
if (A1 < 0) {
|
||||
for (int ic=0; ic<1000; ic++) {
|
||||
double rbl = BinLow/BinWidth;
|
||||
@@ -2078,8 +2078,8 @@ private:
|
||||
XB += BinWidth;
|
||||
nbins++;
|
||||
}
|
||||
BinHigh = XB - BinWidth;
|
||||
}
|
||||
BinHigh = XB - BinWidth;
|
||||
}
|
||||
void setLabelOffset(float aValue) { fLabelOffset = aValue;}
|
||||
void setLabelSize(float aValue) { fLabelSize = aValue;}
|
||||
void setTitleOffset(float aValue) { fTitleOffset = aValue;}
|
||||
@@ -2089,8 +2089,8 @@ public:
|
||||
|
||||
private:
|
||||
std::ostream& m_out;
|
||||
//int fMaxDigits; //!Number of digits above which the 10>N notation is used
|
||||
private:
|
||||
//int fMaxDigits; //!Number of digits above which the 10>N notation is used
|
||||
private:
|
||||
//TObject :
|
||||
unsigned int fBits; //bit field status word
|
||||
float fTickSize; //Size of primary tick mark in NDC
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace tools {
|
||||
namespace image {
|
||||
|
||||
// give a set of cols*rows same size rgb-image and build
|
||||
// give a set of cols*rows same size rgb-image and build
|
||||
// a big image :
|
||||
inline unsigned char* concatenate(unsigned char** a_buffers,
|
||||
unsigned int a_w,unsigned int a_h,
|
||||
@@ -41,8 +41,8 @@ inline unsigned char* concatenate(unsigned char** a_buffers,
|
||||
|
||||
unsigned int wbw3 = wbw*a_bpp;
|
||||
unsigned int aw3 = a_w*a_bpp;
|
||||
|
||||
//copy tiles :
|
||||
|
||||
//copy tiles :
|
||||
unsigned int index = 0;
|
||||
for(unsigned int j=0;j<a_rows;j++) {
|
||||
for(unsigned int i=0;i<a_cols;i++) {
|
||||
@@ -55,7 +55,7 @@ inline unsigned char* concatenate(unsigned char** a_buffers,
|
||||
|
||||
for(unsigned int r=0;r<a_h;r++) {
|
||||
unsigned char* pos = rb + (j*hbh+r+a_bh)*a_rw*a_bpp + (i*wbw+a_bw)*a_bpp;
|
||||
unsigned char* ptile = tile+r*aw3;
|
||||
unsigned char* ptile = tile+r*aw3;
|
||||
for(unsigned int c=0;c<aw3;c++,pos++,ptile++) *pos = *ptile;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ inline unsigned char* concatenate(std::ostream& a_out,
|
||||
unsigned int w1 = 0;
|
||||
unsigned int h1 = 0;
|
||||
unsigned int bpp1 = 0;
|
||||
|
||||
|
||||
typedef unsigned char* buffer_t;
|
||||
buffer_t* bs = new buffer_t[number];
|
||||
{for(unsigned int i=0;i<number;i++) {bs[i] = 0;}}
|
||||
@@ -187,7 +187,7 @@ inline unsigned char* concatenate(std::ostream& a_out,
|
||||
{for(unsigned int i=0;i<number;i++) {delete [] bs[i];}}
|
||||
a_bpp = a_w = a_h = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
{for(unsigned int i=0;i<number;i++) {delete [] bs[i];}}
|
||||
|
||||
@@ -205,7 +205,7 @@ inline bool convert(std::ostream& a_out,
|
||||
reader a_reader,
|
||||
const std::string& a_sout,
|
||||
writer a_writer){
|
||||
|
||||
|
||||
FILE* fin = ::fopen(a_sin.c_str(),"rb");
|
||||
if(!fin) {
|
||||
a_out << "tools::image::convert :"
|
||||
@@ -294,7 +294,7 @@ public:
|
||||
if((*it)->is(file)) {
|
||||
unsigned char* buffer = _open(*(*it),file,a_w,a_h,a_bpp);
|
||||
end_file(file);
|
||||
return buffer;
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
end_file(file);
|
||||
@@ -371,7 +371,7 @@ protected:
|
||||
// sw = 2;
|
||||
// sh = sw/aspect;
|
||||
//}
|
||||
|
||||
|
||||
unsigned int sw = 2;
|
||||
unsigned int sh = 2;
|
||||
while(true) {
|
||||
@@ -379,10 +379,10 @@ protected:
|
||||
sw *=2;
|
||||
sh *=2;
|
||||
}
|
||||
|
||||
|
||||
unsigned int sx = (a_w-sw)/2;
|
||||
unsigned int sy = (a_h-sh)/2;
|
||||
|
||||
|
||||
buffer = a_reader.read_part
|
||||
(m_out,a_path,sx,sy,sw,sh,a_w,a_h,a_bpp);
|
||||
} else {
|
||||
@@ -391,7 +391,7 @@ protected:
|
||||
} else {
|
||||
buffer = a_reader.read(m_out,a_path,a_w,a_h,a_bpp);
|
||||
}
|
||||
|
||||
|
||||
if(!buffer) {
|
||||
m_out << "tools::image::iterator_reader::_open :"
|
||||
<< " for file " << sout(a_path)
|
||||
@@ -400,7 +400,7 @@ protected:
|
||||
a_w = 0;a_h = 0;a_bpp = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ protected:
|
||||
tools_vforcit(ireader*,a_from,it) m_readers.push_back((*it)->copy());
|
||||
}
|
||||
protected:
|
||||
std::ostream& m_out;
|
||||
std::ostream& m_out;
|
||||
unsigned int m_limit;
|
||||
std::vector<ireader*> m_readers;
|
||||
};
|
||||
|
||||
@@ -215,7 +215,8 @@ public:
|
||||
unsigned int height() const {return m_h;}
|
||||
unsigned int bytes_per_pixel() const {return m_n;}
|
||||
unsigned int bpp() const {return m_n;}
|
||||
T* buffer() const {return m_buffer;}
|
||||
const T* buffer() const {return m_buffer;}
|
||||
T* buffer() {return m_buffer;}
|
||||
bool owner() const {return m_owner;}
|
||||
unsigned int size() const {return m_w*m_h*m_n*sizeof(T);} //bytes.
|
||||
public:
|
||||
@@ -241,7 +242,7 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
unsigned int nw = m_w*a_factor;
|
||||
unsigned int nh = m_h*a_factor;
|
||||
unsigned int sz = nh*nw*m_n;
|
||||
@@ -249,18 +250,18 @@ public:
|
||||
a_res.make_empty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
T* nb = new T[sz];
|
||||
if(!nb) {
|
||||
a_res.make_empty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for(unsigned int j=0;j<m_h;j++) {
|
||||
for(unsigned int i=0;i<m_w;i++) {
|
||||
//position in the original image.
|
||||
T* pos = m_buffer + j * (m_w * m_n) + i*m_n;
|
||||
|
||||
|
||||
for(unsigned int fr=0;fr<a_factor;fr++) {
|
||||
for(unsigned int fc=0;fc<a_factor;fc++) {
|
||||
//position in the new image.
|
||||
@@ -270,10 +271,10 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
a_res.set(nw,nh,m_n,nb,true);
|
||||
return true;
|
||||
}
|
||||
@@ -287,13 +288,13 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
unsigned int sz = a_h*a_w*m_n;
|
||||
if(!sz) {
|
||||
a_res.make_empty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
T* rb = new T[sz];
|
||||
if(!rb) {
|
||||
a_res.make_empty();
|
||||
@@ -318,9 +319,9 @@ public:
|
||||
for(unsigned int j=0;j<a_h;j++) {
|
||||
for(unsigned int i=0;i<a_w;i++) {
|
||||
|
||||
// take mean value of wfac*hfac pixels :
|
||||
// take mean value of wfac*hfac pixels :
|
||||
{for(unsigned int ipix=0;ipix<m_n;ipix++) pixels[ipix] = 0;}
|
||||
|
||||
|
||||
for(unsigned int fr=0;fr<hfac;fr++) {
|
||||
hpos = m_buffer + (j*hfac+fr)*(m_w*m_n);
|
||||
for(unsigned int fc=0;fc<wfac;fc++) {
|
||||
@@ -354,13 +355,13 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
size_t sz = a_h*a_w*m_n;
|
||||
if(!sz) {
|
||||
a_res.make_empty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
T* rb = new T[sz];
|
||||
if(!rb) {
|
||||
a_res.make_empty();
|
||||
@@ -395,7 +396,7 @@ public:
|
||||
hhpos = m_buffer + j*hfac*mstride;
|
||||
for(i=0;i<a_w;i++) {
|
||||
|
||||
// take mean value of wfac*hfac pixels :
|
||||
// take mean value of wfac*hfac pixels :
|
||||
|
||||
i0 = i*wfacstride;
|
||||
|
||||
@@ -447,7 +448,7 @@ public:
|
||||
if(!_buffer) return false;
|
||||
|
||||
unsigned int i,j,ipix,imn;
|
||||
unsigned int mwn = m_w*m_n;
|
||||
unsigned int mwn = m_w*m_n;
|
||||
T* _pos;T* pos;
|
||||
TTO* _rpos;TTO* rpos;
|
||||
|
||||
@@ -457,12 +458,12 @@ public:
|
||||
for(i=0;i<m_w;i++) {
|
||||
imn = i*m_n;
|
||||
pos = _pos + imn;
|
||||
rpos = _rpos + imn;
|
||||
for(ipix=0;ipix<m_n;ipix++,pos++,rpos++) *rpos = *pos;
|
||||
rpos = _rpos + imn;
|
||||
for(ipix=0;ipix<m_n;ipix++,pos++,rpos++) *rpos = *pos;
|
||||
}
|
||||
}
|
||||
|
||||
a_res.set(m_w,m_h,m_n,_buffer,true);
|
||||
|
||||
a_res.set(m_w,m_h,m_n,_buffer,true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -472,22 +473,22 @@ public:
|
||||
a_res.make_empty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 012345
|
||||
unsigned int rw = min_of<unsigned int>(m_w-a_sx,a_sw);
|
||||
unsigned int rh = min_of<unsigned int>(m_h-a_sy,a_sh);
|
||||
unsigned int rw = min_of<unsigned int>(m_w-a_sx,a_sw);
|
||||
unsigned int rh = min_of<unsigned int>(m_h-a_sy,a_sh);
|
||||
unsigned int sz = rh*rw*m_n;
|
||||
if(!sz) {
|
||||
a_res.make_empty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
T* rb = new T[sz];
|
||||
if(!rb) {
|
||||
a_res.make_empty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
unsigned int rstride = rw * m_n;
|
||||
T* rpos = rb;
|
||||
|
||||
@@ -515,7 +516,7 @@ public:
|
||||
::memcpy(rpos,pos,rstride*sizeof(T));
|
||||
}
|
||||
|
||||
a_res.set(rw,rh,m_n,rb,true);
|
||||
a_res.set(rw,rh,m_n,rb,true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -539,7 +540,7 @@ public:
|
||||
while(true) {if(rw>=m_w) break;rw *=2;}
|
||||
unsigned int rh = 2;
|
||||
while(true) {if(rh>=m_h) break;rh *=2;}
|
||||
|
||||
|
||||
if((rw==m_w)&&(rh==m_h)) { //exact match.
|
||||
if(a_res_force_owner) {
|
||||
a_res.copy(m_w,m_h,m_n,m_buffer);
|
||||
@@ -550,7 +551,7 @@ public:
|
||||
}
|
||||
|
||||
// we expand the image and fill new spaces with a_pixel.
|
||||
|
||||
|
||||
T* rb = 0;
|
||||
bool res_set = true;
|
||||
if(a_res.owner()&&(a_res.size()==(rh*rw*m_n))) {
|
||||
@@ -564,8 +565,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int num = rw*m_n;
|
||||
|
||||
unsigned int num = rw*m_n;
|
||||
|
||||
// initialize with given color :
|
||||
{T* pos = rb;
|
||||
@@ -576,12 +577,12 @@ public:
|
||||
for(unsigned int j=1;j<rh;j++,pos+=num) { //j=0 -> bottom.
|
||||
::memcpy(pos,rb,sz);
|
||||
}}
|
||||
|
||||
|
||||
// center :
|
||||
unsigned int col = (rw-m_w)/2;
|
||||
unsigned int row = (rh-m_h)/2;
|
||||
|
||||
unsigned int mnum = m_w*m_n;
|
||||
unsigned int col = (rw-m_w)/2;
|
||||
unsigned int row = (rh-m_h)/2;
|
||||
|
||||
unsigned int mnum = m_w*m_n;
|
||||
|
||||
// copy original image in a centered part of the new one :
|
||||
{T* pos = m_buffer;
|
||||
@@ -592,17 +593,17 @@ public:
|
||||
}}
|
||||
|
||||
if(res_set) a_res.set(rw,rh,m_n,rb,true);
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// then m_w>=2 and m_h>=2
|
||||
|
||||
|
||||
// find closest power of two lower than m_w, m_h :
|
||||
unsigned int sw = 2;
|
||||
while(true) {if((sw*2)>m_w) break;sw *=2;}
|
||||
unsigned int sh = 2;
|
||||
while(true) {if((sh*2)>m_h) break;sh *=2;}
|
||||
|
||||
|
||||
if((sw==m_w)&&(sh==m_h)) { //exact match.
|
||||
if(a_res_force_owner) {
|
||||
a_res.copy(m_w,m_h,m_n,m_buffer);
|
||||
@@ -611,13 +612,13 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
unsigned int sx = (m_w-sw)/2;
|
||||
unsigned int sy = (m_h-sh)/2;
|
||||
|
||||
|
||||
return get_part(sx,sy,sw,sh,a_res);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool check_gl_limit(unsigned int a_GL_MAX_TEXTURE_SIZE,img<T>& a_res) const {
|
||||
@@ -670,16 +671,16 @@ public:
|
||||
for(unsigned int i=0;i<m_w;i++) {
|
||||
//position in the original image.
|
||||
T* pos = m_buffer + j * (m_w * m_n) + i*m_n;
|
||||
|
||||
|
||||
T* rpos = a_res.m_buffer + j * (m_w * a_n) + i*a_n;
|
||||
|
||||
|
||||
for(unsigned int ipix=0;ipix<a_n;ipix++) {
|
||||
*(rpos+ipix) = *pos;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -724,26 +725,26 @@ public:
|
||||
for(unsigned int i=0;i<m_w;i++) {
|
||||
//position in the original image.
|
||||
T* pos = m_buffer + j * (m_w * m_n) + i*m_n;
|
||||
|
||||
|
||||
T* rpos = a_res.m_buffer + j * (m_w * a_n) + i*a_n;
|
||||
|
||||
|
||||
for(unsigned int ipix=0;ipix<a_n;ipix++) {
|
||||
*(rpos+ipix) = *(pos+ipix);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rgb2rgba(img<T>& a_res,const T& a_pixel) const {
|
||||
if(m_n!=3) return false;
|
||||
|
||||
unsigned int a_n = 4;
|
||||
unsigned int n = 4;
|
||||
|
||||
a_res.make_empty();
|
||||
unsigned int sz = m_w*m_h*a_n;
|
||||
unsigned int sz = m_w*m_h*n;
|
||||
if(!sz) return false;
|
||||
|
||||
a_res.m_buffer = new T[sz];
|
||||
@@ -751,23 +752,41 @@ public:
|
||||
a_res.m_owner = true;
|
||||
a_res.m_w = m_w;
|
||||
a_res.m_h = m_h;
|
||||
a_res.m_n = a_n;
|
||||
a_res.m_n = n;
|
||||
|
||||
for(unsigned int j=0;j<m_h;j++) {
|
||||
for(unsigned int i=0;i<m_w;i++) {
|
||||
//position in the original image.
|
||||
T* pos = m_buffer + j * (m_w * m_n) + i*m_n;
|
||||
|
||||
T* rpos = a_res.m_buffer + j * (m_w * a_n) + i*a_n;
|
||||
|
||||
for(unsigned int ipix=0;ipix<m_n;ipix++) {
|
||||
*(rpos+ipix) = *(pos+ipix);
|
||||
}
|
||||
|
||||
T* rpos = a_res.m_buffer + j * (m_w * n) + i*n;
|
||||
|
||||
*(rpos+0) = *(pos+0);
|
||||
*(rpos+1) = *(pos+1);
|
||||
*(rpos+2) = *(pos+2);
|
||||
*(rpos+3) = a_pixel;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rgba2bgra() {
|
||||
if(m_n!=4) return false;
|
||||
for(unsigned int j=0;j<m_h;j++) {
|
||||
for(unsigned int i=0;i<m_w;i++) {
|
||||
T* pos = m_buffer + j * (m_w * m_n) + i*m_n;
|
||||
T r = *(pos+0);
|
||||
T g = *(pos+1);
|
||||
T b = *(pos+2);
|
||||
T a = *(pos+3);
|
||||
*(pos+0) = b;
|
||||
*(pos+1) = g;
|
||||
*(pos+2) = r;
|
||||
*(pos+3) = a;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -800,16 +819,16 @@ public:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned int wbw = aw + 2*a_bw;
|
||||
unsigned int hbh = ah + 2*a_bh;
|
||||
|
||||
|
||||
unsigned int rw = wbw * a_cols;
|
||||
unsigned int rh = hbh * a_rows;
|
||||
unsigned int rn = an;
|
||||
|
||||
|
||||
//printf("debug : %d %d\n",rw,rh);
|
||||
|
||||
|
||||
// on big concatenated image the below may fail :
|
||||
unsigned int rsz = rh*rw*rn;
|
||||
T* rb = new T[rsz];
|
||||
@@ -817,7 +836,7 @@ public:
|
||||
a_res.make_empty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool has_border = a_bw||a_bh?true:false;
|
||||
if(has_border) {
|
||||
::memset(rb,a_bc,rsz*sizeof(T));
|
||||
@@ -829,34 +848,34 @@ public:
|
||||
unsigned int rwn = rw*an;
|
||||
unsigned int i,j,r;
|
||||
//unsigned int c;
|
||||
T* tile;T* pos;T* ptile;T* _pos;
|
||||
T* pos;T* ptile;T* _pos;
|
||||
|
||||
//copy tiles :
|
||||
//copy tiles :
|
||||
unsigned int index = 0;
|
||||
for(j=0;j<a_rows;j++) {
|
||||
for(i=0;i<a_cols;i++) {
|
||||
// index = a_cols*j+i
|
||||
tile = a_imgs[index].buffer();
|
||||
|
||||
const T* tile = a_imgs[index].buffer();
|
||||
|
||||
//if(has_border) {
|
||||
// for(unsigned int r=0;r<hbh;r++) {
|
||||
// T* pos = rb + (j*hbh+r)*rwn + i*wbwn;
|
||||
// ::memset(pos,a_bc,wbwn*sizeof(T));
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
_pos = rb + (j*hbh+a_bh)*rwn + (i*wbw+a_bw)*rn;
|
||||
{for(r=0;r<ah;r++) {
|
||||
// pos = _pos + r*rwn;
|
||||
// ptile = tile + r*awn;
|
||||
// ptile = tile + r*awn;
|
||||
// for(c=0;c<awn;c++,pos++,ptile++) *pos = *ptile;
|
||||
::memcpy(_pos+r*rwn,tile+r*awn,awn*sizeof(T)); //optimize. (bof, we do not gain a lot).
|
||||
}}
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
a_res.set(rw,rh,rn,rb,true);
|
||||
return true;
|
||||
}
|
||||
@@ -883,7 +902,7 @@ inline void tex_expand_size(unsigned int a_w,unsigned int& a_h,
|
||||
a_ew = 2;
|
||||
while(true) {if(a_ew>=a_w) break;a_ew *=2;}
|
||||
a_eh = 2;
|
||||
while(true) {if(a_eh>=a_h) break;a_eh *=2;}
|
||||
while(true) {if(a_eh>=a_h) break;a_eh *=2;}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
virtual bool read_std_vec_vec(std_vec_vec_string_t&) = 0;
|
||||
public: //helpers
|
||||
template <class T>
|
||||
bool read_std_vec(std::vector<T>& a_x) {
|
||||
bool read_std_vec(std::vector<T>& a_x) {
|
||||
uint32 n;
|
||||
T* v;
|
||||
if(!read_vec(n,v)) return false;
|
||||
|
||||
@@ -47,7 +47,7 @@ inline bool write_file(FILE* a_file,int a_quality,unsigned char* a_buffer,unsign
|
||||
int row_stride = a_width * cinfo.input_components;
|
||||
|
||||
while (cinfo.next_scanline < cinfo.image_height) {
|
||||
JSAMPROW row_pointer =
|
||||
JSAMPROW row_pointer =
|
||||
a_buffer+(cinfo.image_height-1-cinfo.next_scanline) * row_stride;
|
||||
::jpeg_write_scanlines(&cinfo, &row_pointer, 1);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ inline unsigned char* read_file(FILE* a_file,unsigned int& a_width,unsigned int&
|
||||
a_height = 0;
|
||||
a_bpp = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME : iPad : the below crashes on LHCb_artist_16384_4096_80.jpg.
|
||||
|
||||
@@ -236,7 +236,7 @@ inline bool infos(std::ostream& a_out,const std::string& a_file,unsigned int& a_
|
||||
a_height = 0;
|
||||
a_bpp = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FILE* file = ::fopen(a_file.c_str(),"rb");
|
||||
if(!file) {
|
||||
@@ -279,7 +279,7 @@ inline unsigned char* read(std::ostream& a_out,const std::string& a_file,unsigne
|
||||
a_height = 0;
|
||||
a_bpp = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
FILE* file = ::fopen(a_file.c_str(),"rb");
|
||||
if(!file) {
|
||||
@@ -310,7 +310,7 @@ inline unsigned char* read(std::ostream& a_out,const std::string& a_file,unsigne
|
||||
a_width = w;
|
||||
a_height = h;
|
||||
a_bpp = bpp;
|
||||
return buffer;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
inline unsigned char* read_part(std::ostream& a_out,
|
||||
@@ -327,7 +327,7 @@ inline unsigned char* read_part(std::ostream& a_out,
|
||||
a_rh = 0;
|
||||
a_rbpp = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
FILE* file = ::fopen(a_file.c_str(),"rb");
|
||||
if(!file) {
|
||||
@@ -377,8 +377,8 @@ inline unsigned char* read_part(std::ostream& a_out,
|
||||
}
|
||||
|
||||
// 012345
|
||||
a_rw = tools::mn<unsigned int>(w-a_sx,a_sw);
|
||||
a_rh = tools::mn<unsigned int>(h-a_sy,a_sh);
|
||||
a_rw = tools::mn<unsigned int>(w-a_sx,a_sw);
|
||||
a_rh = tools::mn<unsigned int>(h-a_sy,a_sh);
|
||||
a_rbpp = cinfo.output_components;
|
||||
|
||||
if(!a_rw||!a_rh||!a_rbpp){
|
||||
@@ -400,7 +400,7 @@ inline unsigned char* read_part(std::ostream& a_out,
|
||||
a_rh = 0;
|
||||
a_rbpp = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char* line = new unsigned char[row_stride];
|
||||
if(!line) {
|
||||
@@ -412,7 +412,7 @@ inline unsigned char* read_part(std::ostream& a_out,
|
||||
a_rh = 0;
|
||||
a_rbpp = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME : iPad : the below crashes on LHCb_artist_16384_4096_80.jpg.
|
||||
|
||||
@@ -451,11 +451,11 @@ inline unsigned char* read_part(std::ostream& a_out,
|
||||
|
||||
delete [] line;
|
||||
|
||||
return image_buffer;
|
||||
return image_buffer;
|
||||
}
|
||||
|
||||
inline bool write(std::ostream& a_out,
|
||||
const std::string& a_file,
|
||||
const std::string& a_file,
|
||||
unsigned char* a_buffer,
|
||||
unsigned int a_width,
|
||||
unsigned int a_height,
|
||||
@@ -505,7 +505,7 @@ inline bool concatenate(std::ostream& a_out,
|
||||
unsigned char a_bc,
|
||||
const std::string& a_file,int a_quality) {
|
||||
unsigned int wa,ha,bppa;
|
||||
unsigned char* ba =
|
||||
unsigned char* ba =
|
||||
tools::image::concatenate
|
||||
(a_out,a_files,a_cols,a_rows,a_bw,a_bh,a_bc,read,wa,ha,bppa);
|
||||
if(!ba) {
|
||||
@@ -514,7 +514,7 @@ inline bool concatenate(std::ostream& a_out,
|
||||
<< std::endl;
|
||||
delete [] ba;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FILE* file = ::fopen(a_file.c_str(),"wb");
|
||||
if(!file) {
|
||||
@@ -612,7 +612,7 @@ public:
|
||||
// << " file " << a_file << " is not jpeg."
|
||||
// << std::endl;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// m_FILE = ::fopen(a_file.c_str(),"rb");
|
||||
// if(!m_FILE) {
|
||||
// m_out << "tools::jpeg::jpeg_data::open :"
|
||||
@@ -620,7 +620,7 @@ public:
|
||||
// << std::endl;
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// m_cinfo.err = ::jpeg_std_error(&m_jerr.pub);
|
||||
// m_jerr.pub.error_exit = exlib_jpeg_exlib_jpeg_exlib_jpeg_error_exit;
|
||||
// if(::setjmp(m_jerr.setjmp_buffer)) {
|
||||
@@ -637,7 +637,7 @@ public:
|
||||
// ::jpeg_read_header(&m_cinfo,TRUE);
|
||||
//
|
||||
// ::jpeg_start_decompress(&m_cinfo);
|
||||
//
|
||||
//
|
||||
// if(m_cinfo.output_components!=3) {
|
||||
// m_out << "tools::jpeg::jpeg_data::open :"
|
||||
// << " file " << a_file << " dont't have three components."
|
||||
@@ -646,10 +646,10 @@ public:
|
||||
// m_FILE = 0;
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// m_row_stride = m_cinfo.output_width * m_cinfo.output_components;
|
||||
//
|
||||
// unsigned char* buffer =
|
||||
//
|
||||
// unsigned char* buffer =
|
||||
// new unsigned char[m_row_stride * m_cinfo.output_height];
|
||||
// if(!buffer) {
|
||||
// m_out << "tools::jpeg::jpeg_data::open :"
|
||||
@@ -659,7 +659,7 @@ public:
|
||||
// m_FILE = 0;
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// tools::img_byte::set(m_cinfo.output_width,m_cinfo.output_height,
|
||||
// buffer,true);
|
||||
// m_pos = buffer + m_row_stride * m_cinfo.output_height;
|
||||
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
}
|
||||
|
||||
bool get_cube_size(T_t& a_dx,T_t& a_dy,T_t& a_dz,T_t(*a_sqrt)(T_t)) const {
|
||||
if(!get_size(a_dx,a_dy,a_dz)) return false;
|
||||
if(!get_size(a_dx,a_dy,a_dz)) return false;
|
||||
if((a_dx<=zero())&&(a_dy<=zero())&&(a_dz<=zero())) return false;
|
||||
if((a_dx<=zero())&&(a_dy<=zero())) { //dz not 0 :
|
||||
a_dx = T_t(0.1)*a_dz;
|
||||
|
||||
@@ -44,7 +44,7 @@ inline bool is_inside(const VEC2& a_P,const std::vector<VEC2>& a_V) {
|
||||
--wn; // have a valid down intersect
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ((wn!=0)?true:false);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ inline bool inside(const std::pair<T,T>& a_P,const std::vector< std::pair<T,T> >
|
||||
--wn; // have a valid down intersect
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ((wn!=0)?true:false);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ inline bool intersect(const VEC2& P1,const VEC2& Q1,const VEC2& P2,const VEC2& Q
|
||||
// (Q1-P1)*r - (Q2-P2)*s = P2-P1
|
||||
// r*(Q1-P1).v0 - s*(Q2-P2).v0 = (P2-P1).v0 //x
|
||||
// r*(Q1-P1).v1 - s*(Q2-P2).v1 = (P2-P1).v1 //y
|
||||
|
||||
|
||||
// a*r + b*s = c
|
||||
// d*r + e*s = f
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ protected:
|
||||
// f(s) = a s**3 + b s**2 + c s + d
|
||||
// f'(s) = 3 a s**2 + 2 b s + c
|
||||
|
||||
// f(0) = d = p0
|
||||
// f'(0) = c = v0
|
||||
// f(0) = d = p0
|
||||
// f'(0) = c = v0
|
||||
|
||||
// f(1) = a + b + v0 + p0 = p1
|
||||
// f'(1) = 3 a + 2 b + v0 = v1
|
||||
@@ -91,7 +91,7 @@ protected:
|
||||
T a_x = -2*a_p1_x + a_v0_x + 2*a_p0_x + a_v1_x;
|
||||
T a_y = -2*a_p1_y + a_v0_y + 2*a_p0_y + a_v1_y;
|
||||
T a_z = -2*a_p1_z + a_v0_z + 2*a_p0_z + a_v1_z;
|
||||
m_a.set_value(a_x,a_y,a_z);
|
||||
m_a.set_value(a_x,a_y,a_z);
|
||||
|
||||
T b_x = 3*(a_p1_x - a_v0_x - a_p0_x) - (a_v1_x - a_v0_x);
|
||||
T b_y = 3*(a_p1_y - a_v0_y - a_p0_y) - (a_v1_y - a_v0_y);
|
||||
@@ -151,10 +151,10 @@ public:
|
||||
for(size_t i = 0; i < n; i++) {
|
||||
VEC3 v0 = m_data[m_cur][i];
|
||||
VEC3 v1 = m_data[m_cur][i+1];
|
||||
|
||||
|
||||
T d0 = plane.distance(v0);
|
||||
T d1 = plane.distance(v1);
|
||||
|
||||
|
||||
if (d0 >= 0.0f && d1 < 0.0f) { // exit plane
|
||||
VEC3 dir = v1-v0;
|
||||
// we know that v0 != v1 since we got here
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
|
||||
protected:
|
||||
void out_point(const VEC3& a_p) {m_data[m_cur ^ 1].push_back(a_p);}
|
||||
|
||||
|
||||
protected:
|
||||
std::vector<VEC3> m_data[2];
|
||||
unsigned int m_cur;
|
||||
|
||||
@@ -95,24 +95,24 @@ public:
|
||||
VEC3 D0 = m_dir;
|
||||
VEC3 D1 = a_line.m_dir;
|
||||
VEC3 D0N = D0;
|
||||
|
||||
|
||||
T c[3], d[3];
|
||||
|
||||
|
||||
for(unsigned int i=0;i<3;i++) {
|
||||
d[i] = D1[i] - D0N[i]*(D0[0]*D1[0] + D0[1]*D1[1] + D0[2]*D1[2]);
|
||||
c[i] = P1[i] - P0[i] + D0N[i]*(D0[0]*P0[0] + D0[1]*P0[1] + D0[2]*P0[2]);
|
||||
}
|
||||
|
||||
|
||||
T den = d[0]*d[0]+d[1]*d[1]+d[2]*d[2];
|
||||
if(den==T()) return false;
|
||||
|
||||
T t = -(c[0]*d[0]+c[1]*d[1]+c[2]*d[2]) / den;
|
||||
|
||||
|
||||
a_on_line = a_line.m_pos + a_line.m_dir * t;
|
||||
closest_point(a_on_line,a_on_this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool intersect(const line<T>& a_line,VEC3& a_out,const T& a_prec) const {
|
||||
VEC3 p,q;
|
||||
if(!closest_points(a_line,p,q)) return false;
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
protected:
|
||||
VEC3 m_pos;
|
||||
VEC3 m_dir; //normalized.
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
mat(
|
||||
#ifdef TOOLS_MEM
|
||||
bool a_inc = true
|
||||
#endif
|
||||
#endif
|
||||
) {
|
||||
#ifdef TOOLS_MEM
|
||||
if(a_inc) mem::increment(s_class().c_str());
|
||||
@@ -155,7 +155,7 @@ protected:
|
||||
private:static void check_instantiation() {nmat<float> dummy(2);}
|
||||
};
|
||||
|
||||
template <class T,unsigned int D>
|
||||
template <class T,unsigned int D>
|
||||
inline nmat<T> copy(const mat<T,D>& a_from) {
|
||||
unsigned int D2 = D*D;
|
||||
nmat<T> v(D);
|
||||
@@ -182,7 +182,7 @@ inline void multiply(VECTOR& a_vec,const typename VECTOR::value_type::elem_t& a_
|
||||
/// related to complex numbers : //////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class MAT>
|
||||
template <class MAT>
|
||||
inline void conjugate(MAT& a_m,typename MAT::elem_t (*a_conj)(const typename MAT::elem_t&)) {
|
||||
typedef typename MAT::elem_t T;
|
||||
T* pos = const_cast<T*>(a_m.data());
|
||||
@@ -192,7 +192,7 @@ inline void conjugate(MAT& a_m,typename MAT::elem_t (*a_conj)(const typename MAT
|
||||
}
|
||||
}
|
||||
|
||||
template <class MAT>
|
||||
template <class MAT>
|
||||
inline bool is_real(MAT& a_m,typename MAT::elem_t::value_type (*a_imag)(const typename MAT::elem_t&)) {
|
||||
typedef typename MAT::elem_t T;
|
||||
T* pos = const_cast<T*>(a_m.data());
|
||||
@@ -201,7 +201,7 @@ inline bool is_real(MAT& a_m,typename MAT::elem_t::value_type (*a_imag)(const ty
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class MAT,class PREC>
|
||||
template <class MAT,class PREC>
|
||||
inline bool is_real_prec(MAT& a_m,typename MAT::elem_t::value_type (*a_imag)(const typename MAT::elem_t&),
|
||||
const PREC& a_prec,PREC(*a_fabs)(const typename MAT::elem_t::value_type&)) {\
|
||||
typedef typename MAT::elem_t T;
|
||||
@@ -220,7 +220,7 @@ inline bool is_imag(MAT& a_m,typename MAT::elem_t::value_type (*a_real)(const ty
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class CMAT,class RMAT>
|
||||
template <class CMAT,class RMAT>
|
||||
inline bool to_real(const CMAT& a_c,RMAT& a_r,typename CMAT::elem_t::value_type (*a_real)(const typename CMAT::elem_t&)) {
|
||||
if(a_r.dimension()!=a_c.dimension()) return false;
|
||||
typedef typename CMAT::elem_t CT;
|
||||
@@ -232,7 +232,7 @@ inline bool to_real(const CMAT& a_c,RMAT& a_r,typename CMAT::elem_t::value_type
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class RMAT,class CMAT>
|
||||
template <class RMAT,class CMAT>
|
||||
inline bool to_complex(const RMAT& a_r,CMAT& a_c) {
|
||||
if(a_c.dimension()!=a_r.dimension()) return false;
|
||||
typedef typename RMAT::elem_t RT;
|
||||
@@ -244,7 +244,7 @@ inline bool to_complex(const RMAT& a_r,CMAT& a_c) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class MAT>
|
||||
template <class MAT>
|
||||
inline void dagger(MAT& a_m,typename MAT::elem_t (*a_conj)(const typename MAT::elem_t&)) {
|
||||
conjugate<MAT>(a_m,a_conj);
|
||||
a_m.transpose();
|
||||
@@ -259,17 +259,17 @@ inline bool decomplex(const CMAT& a_c,RMAT& a_r,
|
||||
// | -Y X |
|
||||
typedef typename CMAT::elem_t CT; //std::complex<double>
|
||||
typedef typename RMAT::elem_t RT; //double
|
||||
|
||||
|
||||
unsigned int cdim = a_c.dimension();
|
||||
if(a_r.dimension()!=2*cdim) {a_r.set_zero();return false;}
|
||||
RT value;unsigned int r,c;
|
||||
if(a_r.dimension()!=2*cdim) {a_r.set_zero();return false;}
|
||||
RT value;unsigned int r,c;
|
||||
for(r=0;r<cdim;r++) {
|
||||
for(c=0;c<cdim;c++) {
|
||||
const CT& cvalue = a_c.value(r,c);
|
||||
value = a_real(cvalue);
|
||||
value = a_real(cvalue);
|
||||
a_r.set_value(r,c,value);
|
||||
a_r.set_value(r+cdim,c+cdim,value);
|
||||
value = a_imag(cvalue);
|
||||
value = a_imag(cvalue);
|
||||
a_r.set_value(r,c+cdim,value);
|
||||
a_r.set_value(r+cdim,c,-value);
|
||||
}
|
||||
@@ -466,7 +466,7 @@ inline nmat<T> operator*(const nmat<T>& a_m,const T& a_fac) {
|
||||
}
|
||||
*/
|
||||
|
||||
template <class MAT,class REAL>
|
||||
template <class MAT,class REAL>
|
||||
inline bool mat_fabs(const MAT& a_in,MAT& a_ou,REAL(*a_fabs)(const typename MAT::elem_t&)) {
|
||||
if(a_in.dimension()!=a_ou.dimension()) {a_ou.set_zero();return false;}
|
||||
typedef typename MAT::elem_t T;
|
||||
|
||||
@@ -84,12 +84,12 @@ public:
|
||||
|
||||
//NOTE : Z(x,y, z,1) = -2z/(f-n)+tz = [-2z-f-n]/(f-n)
|
||||
// W(x,y, z,1) = 1 -> Z/W = Z
|
||||
// Z(x,y,-n,1) = -1
|
||||
// Z(x,y,-f,1) = 1
|
||||
// Z(x,y,-n,1) = -1
|
||||
// Z(x,y,-f,1) = 1
|
||||
|
||||
// Z(x,y,-(f+n)/2,1) = 0
|
||||
|
||||
// X(x,0, z,1) = 2x/(r-l)+tx = [2x-r-l]/(r-l)
|
||||
// X(x,0, z,1) = 2x/(r-l)+tx = [2x-r-l]/(r-l)
|
||||
// X(r,0, z,1) = 1
|
||||
|
||||
// the view direction is then (0,0,1) in the final projection.
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
|
||||
// Z(x,y,-2fn/(f+n),1) = 0
|
||||
// -> Z/W = 0
|
||||
|
||||
|
||||
// Z(x,y,-f,1) = -[-ff-fn+2fn]/(f-n) = -[fn-ff]/(f-n) = f
|
||||
// W(x,y,-f,1) = f
|
||||
// -> Z/W(x,y,-f,1) = 1
|
||||
@@ -152,6 +152,12 @@ public:
|
||||
a_z = pr::m_vec[14];
|
||||
}
|
||||
|
||||
void no_translate() {
|
||||
pr::m_vec[12] = 0;
|
||||
pr::m_vec[13] = 0;
|
||||
pr::m_vec[14] = 0;
|
||||
}
|
||||
|
||||
//void set_translate_only(const T& a_x,const T& a_y,const T& a_z) {
|
||||
// pr::m_vec[12] = a_x;
|
||||
// pr::m_vec[13] = a_y;
|
||||
@@ -352,8 +358,8 @@ protected:
|
||||
static void _set_rotate(const T& a_x,const T& a_y,const T& a_z,const T& a_angle,T v[],T(*a_sin)(T),T(*a_cos)(T)) {
|
||||
//WARNING : (a_x,a_y,a_z) must be a normalized vector.
|
||||
// v[] = exp(-a_angle*n(a_x,a_y,a_z)*Rs). It models the rotation of an object in the same coordinate system (active rotation).
|
||||
T si = a_sin(a_angle);
|
||||
T co = a_cos(a_angle);
|
||||
T si = a_sin(a_angle);
|
||||
T co = a_cos(a_angle);
|
||||
T x = a_x;
|
||||
T y = a_y;
|
||||
T z = a_z;
|
||||
@@ -394,7 +400,7 @@ public:
|
||||
//pr::m_vec[1] = 10;pr::m_vec[5] = 11;pr::m_vec[ 9] = 12;pr::m_vec[13] = 13;
|
||||
//pr::m_vec[2] = 20;pr::m_vec[6] = 21;pr::m_vec[10] = 22;pr::m_vec[14] = 23;
|
||||
//pr::m_vec[3] = 30;pr::m_vec[7] = 31;pr::m_vec[11] = 32;pr::m_vec[15] = 33;
|
||||
|
||||
|
||||
T tv_0 = tv[0];
|
||||
T tv_1 = tv[1];
|
||||
T tv_2 = tv[2];
|
||||
@@ -453,6 +459,13 @@ public:
|
||||
tv[15] = tv_15;
|
||||
}
|
||||
|
||||
template <class MAT3>
|
||||
void set_mat3(MAT3& a_m3) {
|
||||
a_m3.set_matrix(pr::m_vec[0],pr::m_vec[4],pr::m_vec[ 8], //1 row
|
||||
pr::m_vec[1],pr::m_vec[5],pr::m_vec[ 9], //2 row
|
||||
pr::m_vec[2],pr::m_vec[6],pr::m_vec[10]); //3 row
|
||||
}
|
||||
|
||||
private:static void check_instantiation() {mat4<float> dummy;}
|
||||
};
|
||||
|
||||
@@ -489,14 +502,10 @@ namespace tools {
|
||||
template <class T>
|
||||
inline std::ostream& operator<<(std::ostream& a_out,const mat4<T>& a_mtx){
|
||||
const T* v = a_mtx.data();
|
||||
a_out << v[0] << "," << v[4] << "," << v[ 8] << "," << v[12]
|
||||
<< std::endl
|
||||
<< v[1] << "," << v[5] << "," << v[ 9] << "," << v[13]
|
||||
<< std::endl
|
||||
<< v[2] << "," << v[6] << "," << v[10] << "," << v[14]
|
||||
<< std::endl
|
||||
<< v[3] << "," << v[7] << "," << v[11] << "," << v[15]
|
||||
<< std::endl;
|
||||
a_out << v[0] << "," << v[4] << "," << v[ 8] << "," << v[12] << std::endl
|
||||
<< v[1] << "," << v[5] << "," << v[ 9] << "," << v[13] << std::endl
|
||||
<< v[2] << "," << v[6] << "," << v[10] << "," << v[14] << std::endl
|
||||
<< v[3] << "," << v[7] << "," << v[11] << "," << v[15] << std::endl;
|
||||
return a_out;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,16 +19,16 @@ public:
|
||||
// Construct a plane given 3 points.
|
||||
// Orientation is computed by taking (p1 - p0) x (p2 - p0) and
|
||||
// pointing the normal in that direction.
|
||||
|
||||
|
||||
VEC3 P = a_p1;
|
||||
P.subtract(a_p0);
|
||||
VEC3 P2 = a_p2;
|
||||
P2.subtract(a_p0);
|
||||
P.cross(P2,m_normal);
|
||||
if(!m_normal.normalize()) {} //throw
|
||||
m_distance =
|
||||
m_normal.v0() * a_p0.v0() +
|
||||
m_normal.v1() * a_p0.v1() +
|
||||
m_distance =
|
||||
m_normal.v0() * a_p0.v0() +
|
||||
m_normal.v1() * a_p0.v1() +
|
||||
m_normal.v2() * a_p0.v2();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
// Offset a plane by a given distance.
|
||||
m_distance += a_distance;
|
||||
}
|
||||
|
||||
|
||||
bool intersect(const line<VEC3>& a_line,VEC3& a_intersection) const {
|
||||
// Intersect line and plane, returning true if there is an intersection
|
||||
// false if line is parallel to plane
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
//a_intersection = pos + t * dir;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool is_in_half_space(const VEC3& a_point) const {
|
||||
// Returns true if the given point is within the half-space
|
||||
// defined by the plane
|
||||
@@ -84,11 +84,11 @@ public:
|
||||
pos.add(a_point);
|
||||
return (m_normal.dot(pos) >= T() ? true : false);
|
||||
}
|
||||
|
||||
|
||||
const VEC3& normal() const {return m_normal;}
|
||||
|
||||
T distance_from_origin() const {return m_distance;}
|
||||
|
||||
|
||||
T distance(const VEC3& a_point) const {
|
||||
// Return the distance from point to plane. Positive distance means
|
||||
// the point is in the plane's half space.
|
||||
@@ -106,9 +106,9 @@ public:
|
||||
// Orientation is given by the normal vector n.
|
||||
m_normal = a_normal;
|
||||
if(!m_normal.normalize()) {} //throw
|
||||
m_distance =
|
||||
m_normal.v0() * a_point.v0() +
|
||||
m_normal.v1() * a_point.v1() +
|
||||
m_distance =
|
||||
m_normal.v0() * a_point.v0() +
|
||||
m_normal.v1() * a_point.v1() +
|
||||
m_normal.v2() * a_point.v2();
|
||||
}
|
||||
|
||||
|
||||
@@ -96,12 +96,12 @@ public:
|
||||
|
||||
// Optimize by doing 1 div and 4 muls instead of 4 divs.
|
||||
T inv = one() / length;
|
||||
|
||||
|
||||
a_r.m_quat.set_value(-m_quat.v0() * inv,
|
||||
-m_quat.v1() * inv,
|
||||
-m_quat.v2() * inv,
|
||||
m_quat.v3() * inv);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
bool set_value(const VEC3& a_from,const VEC3& a_to,T(*a_sqrt)(T),T(*a_fabs)(T)) {
|
||||
// code taken from coin3d/SbRotation.
|
||||
//NOTE : coin3d/SbMatrix logic is transposed relative to us.
|
||||
|
||||
|
||||
VEC3 from(a_from);
|
||||
if(from.normalize()==T()) return false;
|
||||
VEC3 to(a_to);
|
||||
@@ -210,10 +210,10 @@ public:
|
||||
unsigned int k = (j+1)%3;
|
||||
|
||||
T _s = a_sqrt((a_m.value(i,i) - (a_m.value(j,j) + a_m.value(k,k))) + a_m.v33());
|
||||
|
||||
|
||||
m_quat.set_value(i,_s * half());
|
||||
_s = half() / _s;
|
||||
|
||||
|
||||
m_quat.v3((a_m.value(k,j) - a_m.value(j,k)) * _s);
|
||||
m_quat.set_value(j,(a_m.value(j,i) + a_m.value(i,j)) * _s);
|
||||
m_quat.set_value(k,(a_m.value(k,i) + a_m.value(i,k)) * _s);
|
||||
@@ -228,7 +228,7 @@ public:
|
||||
void value(MAT4& a_m) const {
|
||||
//Return this rotation in the form of a matrix.
|
||||
//NOTE : in coin3d/SbRotation, it looks as if "w <-> -w", but coin3d/SbMatrix logic is transposed relative to us.
|
||||
|
||||
|
||||
const T x = m_quat.v0();
|
||||
const T y = m_quat.v1();
|
||||
const T z = m_quat.v2();
|
||||
@@ -240,19 +240,19 @@ public:
|
||||
a_m.v01(2*x*y - 2*w*z);
|
||||
a_m.v02(2*x*z + 2*w*y);
|
||||
a_m.v03(0);
|
||||
|
||||
|
||||
// second row :
|
||||
a_m.v10(2*x*y + 2*w*z);
|
||||
a_m.v11(w*w - x*x + y*y - z*z);
|
||||
a_m.v12(2*y*z - 2*w*x);
|
||||
a_m.v13(0);
|
||||
|
||||
|
||||
// third row :
|
||||
a_m.v20(2*x*z - 2*w*y);
|
||||
a_m.v21(2*y*z + 2*w*x);
|
||||
a_m.v22(w*w - x*x - y*y + z*z);
|
||||
a_m.v23(0);
|
||||
|
||||
|
||||
// fourth row :
|
||||
a_m.v30(0);
|
||||
a_m.v31(0);
|
||||
@@ -264,7 +264,7 @@ public:
|
||||
T value_3(MAT3& a_m) const {
|
||||
//Return this rotation in the form of a 3D matrix.
|
||||
//NOTE : in coin3d/SbRotation, it looks as if "w <-> -w", but coin3d/SbMatrix logic is transposed relative to us.
|
||||
|
||||
|
||||
const T x = m_quat.v0();
|
||||
const T y = m_quat.v1();
|
||||
const T z = m_quat.v2();
|
||||
@@ -275,17 +275,17 @@ public:
|
||||
a_m.v00(w*w + x*x - y*y - z*z);
|
||||
a_m.v01(2*x*y - 2*w*z);
|
||||
a_m.v02(2*x*z + 2*w*y);
|
||||
|
||||
|
||||
// second row :
|
||||
a_m.v10(2*x*y + 2*w*z);
|
||||
a_m.v11(w*w - x*x + y*y - z*z);
|
||||
a_m.v12(2*y*z - 2*w*x);
|
||||
|
||||
|
||||
// third row :
|
||||
a_m.v20(2*x*z - 2*w*y);
|
||||
a_m.v21(2*y*z + 2*w*x);
|
||||
a_m.v22(w*w - x*x - y*y + z*z);
|
||||
|
||||
|
||||
// fourth row :
|
||||
//a_m.v30(0);
|
||||
//a_m.v31(0);
|
||||
@@ -299,20 +299,20 @@ public:
|
||||
const T y = m_quat.v1();
|
||||
const T z = m_quat.v2();
|
||||
const T w = m_quat.v3();
|
||||
|
||||
|
||||
// first row :
|
||||
T v0 = (w*w + x*x - y*y - z*z) * a_in.v0()
|
||||
+ (2*x*y - 2*w*z) * a_in.v1()
|
||||
+ (2*x*z + 2*w*y) * a_in.v2();
|
||||
|
||||
|
||||
T v1 = (2*x*y + 2*w*z) * a_in.v0()
|
||||
+(w*w - x*x + y*y - z*z) * a_in.v1()
|
||||
+ (2*y*z - 2*w*x) * a_in.v2();
|
||||
|
||||
|
||||
T v2 = (2*x*z - 2*w*y) * a_in.v0()
|
||||
+ (2*y*z + 2*w*x) * a_in.v1()
|
||||
+(w*w - x*x - y*y + z*z) * a_in.v2();
|
||||
|
||||
|
||||
a_out.set_value(v0,v1,v2);
|
||||
}
|
||||
|
||||
@@ -321,20 +321,20 @@ public:
|
||||
const T y = m_quat.v1();
|
||||
const T z = m_quat.v2();
|
||||
const T w = m_quat.v3();
|
||||
|
||||
|
||||
// first row :
|
||||
T v0 = (w*w + x*x - y*y - z*z) * a_v.v0()
|
||||
+ (2*x*y - 2*w*z) * a_v.v1()
|
||||
+ (2*x*z + 2*w*y) * a_v.v2();
|
||||
|
||||
|
||||
T v1 = (2*x*y + 2*w*z) * a_v.v0()
|
||||
+(w*w - x*x + y*y - z*z) * a_v.v1()
|
||||
+ (2*y*z - 2*w*x) * a_v.v2();
|
||||
|
||||
|
||||
T v2 = (2*x*z - 2*w*y) * a_v.v0()
|
||||
+ (2*y*z + 2*w*x) * a_v.v1()
|
||||
+(w*w - x*x - y*y + z*z) * a_v.v2();
|
||||
|
||||
|
||||
a_v.set_value(v0,v1,v2);
|
||||
}
|
||||
|
||||
@@ -343,20 +343,20 @@ public:
|
||||
const T y = m_quat.v1();
|
||||
const T z = m_quat.v2();
|
||||
const T w = m_quat.v3();
|
||||
|
||||
|
||||
// first row :
|
||||
T v0 = (w*w + x*x - y*y - z*z) * a_x
|
||||
+ (2*x*y - 2*w*z) * a_y
|
||||
+ (2*x*z + 2*w*y) * a_z;
|
||||
|
||||
|
||||
T v1 = (2*x*y + 2*w*z) * a_x
|
||||
+(w*w - x*x + y*y - z*z) * a_y
|
||||
+ (2*y*z - 2*w*x) * a_z;
|
||||
|
||||
|
||||
T v2 = (2*x*z - 2*w*y) * a_x
|
||||
+ (2*y*z + 2*w*x) * a_y
|
||||
+(w*w - x*x - y*y + z*z) * a_z;
|
||||
|
||||
|
||||
a_x = v0;
|
||||
a_y = v1;
|
||||
a_z = v2;
|
||||
|
||||
@@ -86,9 +86,9 @@ public:
|
||||
void value(T& a0,T& a1) const {
|
||||
a0 = m_data[0];
|
||||
a1 = m_data[1];
|
||||
}
|
||||
}
|
||||
|
||||
//bool set_value(unsigned int a_index,const T& a_value) {
|
||||
//bool set_value(unsigned int a_index,const T& a_value) {
|
||||
// if(a_index>=2) return false;
|
||||
// m_[a_index] = a_value;
|
||||
// return true;
|
||||
@@ -106,13 +106,13 @@ public:
|
||||
}
|
||||
|
||||
T dot(const vec2& aV) const {
|
||||
return (m_data[0] * aV.m_data[0] +
|
||||
return (m_data[0] * aV.m_data[0] +
|
||||
m_data[1] * aV.m_data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
T cross(const vec2& aV) const {
|
||||
return (m_data[0] * aV.m_data[1] - m_data[1] * aV.m_data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
bool equal(const vec2& aV) const {
|
||||
if(m_data[0]!=aV.m_data[0]) return false;
|
||||
@@ -130,22 +130,22 @@ public:
|
||||
void add(const vec2& a_v) {
|
||||
m_data[0] += a_v.m_data[0];
|
||||
m_data[1] += a_v.m_data[1];
|
||||
}
|
||||
}
|
||||
|
||||
void add(const T& a0,const T& a1) {
|
||||
m_data[0] += a0;
|
||||
m_data[1] += a1;
|
||||
}
|
||||
}
|
||||
|
||||
void subtract(const vec2& a_v) {
|
||||
m_data[0] -= a_v.m_data[0];
|
||||
m_data[1] -= a_v.m_data[1];
|
||||
}
|
||||
}
|
||||
|
||||
void subtract(const T& a0,const T& a1) {
|
||||
m_data[0] -= a0;
|
||||
m_data[1] -= a1;
|
||||
}
|
||||
}
|
||||
|
||||
public: //operators
|
||||
T& operator[](size_t a_index) {
|
||||
@@ -160,17 +160,17 @@ public: //operators
|
||||
vec2 operator+(const vec2& a_v) const {
|
||||
return vec2(m_data[0]+a_v.m_data[0],
|
||||
m_data[1]+a_v.m_data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
vec2 operator-(const vec2& a_v) const {
|
||||
return vec2(m_data[0]-a_v.m_data[0],
|
||||
m_data[1]-a_v.m_data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
vec2 operator*(const T& a_v) const {
|
||||
return vec2(m_data[0]*a_v,
|
||||
m_data[1]*a_v);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const vec2& a_v) const {return equal(a_v);}
|
||||
bool operator!=(const vec2& a_v) const {return !operator==(a_v);}
|
||||
@@ -184,7 +184,7 @@ public: //for iv2sg
|
||||
void getValue(T& a0,T& a1) const {
|
||||
a0 = m_data[0];
|
||||
a1 = m_data[1];
|
||||
}
|
||||
}
|
||||
void setValue(const T& a0,const T& a1) {
|
||||
m_data[0] = a0;
|
||||
m_data[1] = a1;
|
||||
|
||||
@@ -32,25 +32,25 @@ public: //operators
|
||||
vec2f operator*(float a_v) const {
|
||||
return vec2f(m_data[0]*a_v,
|
||||
m_data[1]*a_v);
|
||||
}
|
||||
}
|
||||
vec2f operator+(const vec2f& a_v) const {
|
||||
return vec2f(m_data[0]+a_v.m_data[0],
|
||||
m_data[1]+a_v.m_data[1]);
|
||||
}
|
||||
}
|
||||
vec2f operator-(const vec2f& a_v) const {
|
||||
return vec2f(m_data[0]-a_v.m_data[0],
|
||||
m_data[1]-a_v.m_data[1]);
|
||||
}
|
||||
vec2f& operator+=(const vec2f& a_v) {
|
||||
}
|
||||
vec2f& operator+=(const vec2f& a_v) {
|
||||
m_data[0] += a_v.m_data[0];
|
||||
m_data[1] += a_v.m_data[1];
|
||||
return *this;
|
||||
}
|
||||
vec2f& operator*=(float a_v) {
|
||||
}
|
||||
vec2f& operator*=(float a_v) {
|
||||
m_data[0] *= a_v;
|
||||
m_data[1] *= a_v;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
vec2f operator-() const {
|
||||
return vec2f(-m_data[0],-m_data[1]);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public: //iv2sg
|
||||
void negate() {
|
||||
m_data[0] = -m_data[0];
|
||||
m_data[1] = -m_data[1];
|
||||
}
|
||||
}
|
||||
|
||||
private:static void check_instantiation() {vec2f v(0,0);v.set_value(1,1);}
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
vec3(const T& a0,const T& a1,const T& a2
|
||||
#ifdef TOOLS_MEM
|
||||
,bool a_inc = true
|
||||
#endif
|
||||
#endif
|
||||
) {
|
||||
#ifdef TOOLS_MEM
|
||||
if(a_inc) mem::increment(s_class().c_str());
|
||||
@@ -103,9 +103,9 @@ public:
|
||||
a0 = m_data[0];
|
||||
a1 = m_data[1];
|
||||
a2 = m_data[2];
|
||||
}
|
||||
}
|
||||
|
||||
//bool set_value(unsigned int a_index,const T& a_value) {
|
||||
//bool set_value(unsigned int a_index,const T& a_value) {
|
||||
// if(a_index>=3) return false;
|
||||
// m_[a_index] = a_value;
|
||||
// return true;
|
||||
@@ -123,16 +123,16 @@ public:
|
||||
}
|
||||
|
||||
T dot(const vec3& aV) const {
|
||||
return (m_data[0] * aV.m_data[0] +
|
||||
m_data[1] * aV.m_data[1] +
|
||||
return (m_data[0] * aV.m_data[0] +
|
||||
m_data[1] * aV.m_data[1] +
|
||||
m_data[2] * aV.m_data[2]);
|
||||
}
|
||||
}
|
||||
|
||||
void cross(const vec3<T>& aV,vec3<T>& a_value) const {
|
||||
a_value.set_value(m_data[1] * aV.m_data[2] - m_data[2] * aV.m_data[1],
|
||||
m_data[2] * aV.m_data[0] - m_data[0] * aV.m_data[2],
|
||||
m_data[0] * aV.m_data[1] - m_data[1] * aV.m_data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
bool equal(const vec3& aV) const {
|
||||
if(m_data[0]!=aV.m_data[0]) return false;
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
return vec3<T>(m_data[1] * aV.m_data[2] - m_data[2] * aV.m_data[1],
|
||||
m_data[2] * aV.m_data[0] - m_data[0] * aV.m_data[2],
|
||||
m_data[0] * aV.m_data[1] - m_data[1] * aV.m_data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
bool divide(const T& a_T) {
|
||||
if(a_T==T()) return false;
|
||||
@@ -176,25 +176,25 @@ public:
|
||||
m_data[0] += a_v.m_data[0];
|
||||
m_data[1] += a_v.m_data[1];
|
||||
m_data[2] += a_v.m_data[2];
|
||||
}
|
||||
}
|
||||
|
||||
void add(const T& a0,const T& a1,const T& a2) {
|
||||
m_data[0] += a0;
|
||||
m_data[1] += a1;
|
||||
m_data[2] += a2;
|
||||
}
|
||||
}
|
||||
|
||||
void subtract(const vec3& a_v) {
|
||||
m_data[0] -= a_v.m_data[0];
|
||||
m_data[1] -= a_v.m_data[1];
|
||||
m_data[2] -= a_v.m_data[2];
|
||||
}
|
||||
}
|
||||
|
||||
void subtract(const T& a0,const T& a1,const T& a2) {
|
||||
m_data[0] -= a0;
|
||||
m_data[1] -= a1;
|
||||
m_data[2] -= a2;
|
||||
}
|
||||
}
|
||||
|
||||
bool cos_angle(const vec3& a_v,T& a_cos,T(*a_sqrt)(T)) const {
|
||||
//WARNING : if ret false, a_cos is not set.
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool theta_phi(T& a_theta,T& a_phi,T(*a_sqrt)(T),T(*a_atan2)(T,T)) const {
|
||||
bool theta_phi(T& a_theta,T& a_phi,T(*a_sqrt)(T),T(*a_atan2)(T,T)) const {
|
||||
//WARNING : if ret false, a_theta, a_phi are not set.
|
||||
if(length(a_sqrt)==T()) return false;
|
||||
a_phi = a_atan2(m_data[1],m_data[0]);
|
||||
@@ -236,26 +236,26 @@ public: //operators
|
||||
return vec3(m_data[0]+a_v.m_data[0],
|
||||
m_data[1]+a_v.m_data[1],
|
||||
m_data[2]+a_v.m_data[2]);
|
||||
}
|
||||
}
|
||||
|
||||
vec3 operator-(const vec3& a_v) const {
|
||||
return vec3(m_data[0]-a_v.m_data[0],
|
||||
m_data[1]-a_v.m_data[1],
|
||||
m_data[2]-a_v.m_data[2]);
|
||||
}
|
||||
}
|
||||
|
||||
vec3 operator*(const T& a_v) const {
|
||||
return vec3(m_data[0]*a_v,
|
||||
m_data[1]*a_v,
|
||||
m_data[2]*a_v);
|
||||
}
|
||||
}
|
||||
|
||||
vec3 operator/(const T& a_v) const {
|
||||
if(a_v==T()) return vec3();
|
||||
return vec3(m_data[0]/a_v,
|
||||
m_data[1]/a_v,
|
||||
m_data[2]/a_v);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const vec3& a_v) const {return equal(a_v);}
|
||||
bool operator!=(const vec3& a_v) const {return !operator==(a_v);}
|
||||
@@ -276,7 +276,7 @@ public: //for iv2sg
|
||||
a0 = m_data[0];
|
||||
a1 = m_data[1];
|
||||
a2 = m_data[2];
|
||||
}
|
||||
}
|
||||
void setValue(const vec3& a_v) {
|
||||
m_data[0] = a_v.m_data[0];
|
||||
m_data[1] = a_v.m_data[1];
|
||||
|
||||
@@ -33,35 +33,35 @@ public: //operators
|
||||
return vec3d(m_data[0]*a_v,
|
||||
m_data[1]*a_v,
|
||||
m_data[2]*a_v);
|
||||
}
|
||||
}
|
||||
vec3d operator+(const vec3d& a_v) const {
|
||||
return vec3d(m_data[0]+a_v.m_data[0],
|
||||
m_data[1]+a_v.m_data[1],
|
||||
m_data[2]+a_v.m_data[2]);
|
||||
}
|
||||
}
|
||||
vec3d operator-(const vec3d& a_v) const {
|
||||
return vec3d(m_data[0]-a_v.m_data[0],
|
||||
m_data[1]-a_v.m_data[1],
|
||||
m_data[2]-a_v.m_data[2]);
|
||||
}
|
||||
vec3d& operator+=(const vec3d& a_v) {
|
||||
}
|
||||
vec3d& operator+=(const vec3d& a_v) {
|
||||
m_data[0] += a_v.m_data[0];
|
||||
m_data[1] += a_v.m_data[1];
|
||||
m_data[2] += a_v.m_data[2];
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
vec3d& operator-=(const vec3d& a_v) {
|
||||
m_data[0] -= a_v.m_data[0];
|
||||
m_data[1] -= a_v.m_data[1];
|
||||
m_data[2] -= a_v.m_data[2];
|
||||
return *this;
|
||||
}
|
||||
vec3d& operator*=(double a_v) {
|
||||
vec3d& operator*=(double a_v) {
|
||||
m_data[0] *= a_v;
|
||||
m_data[1] *= a_v;
|
||||
m_data[2] *= a_v;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
vec3d operator-() const {
|
||||
return vec3d(-m_data[0],-m_data[1],-m_data[2]);
|
||||
}
|
||||
|
||||
@@ -33,17 +33,17 @@ public: //operators
|
||||
return vec3f(m_data[0]*a_v,
|
||||
m_data[1]*a_v,
|
||||
m_data[2]*a_v);
|
||||
}
|
||||
}
|
||||
vec3f operator+(const vec3f& a_v) const {
|
||||
return vec3f(m_data[0]+a_v.m_data[0],
|
||||
m_data[1]+a_v.m_data[1],
|
||||
m_data[2]+a_v.m_data[2]);
|
||||
}
|
||||
}
|
||||
vec3f operator-(const vec3f& a_v) const {
|
||||
return vec3f(m_data[0]-a_v.m_data[0],
|
||||
m_data[1]-a_v.m_data[1],
|
||||
m_data[2]-a_v.m_data[2]);
|
||||
}
|
||||
}
|
||||
vec3f& operator+=(const vec3f& a_v) {
|
||||
m_data[0] += a_v.m_data[0];
|
||||
m_data[1] += a_v.m_data[1];
|
||||
@@ -56,12 +56,12 @@ public: //operators
|
||||
m_data[2] -= a_v.m_data[2];
|
||||
return *this;
|
||||
}
|
||||
vec3f& operator*=(float a_v) {
|
||||
vec3f& operator*=(float a_v) {
|
||||
m_data[0] *= a_v;
|
||||
m_data[1] *= a_v;
|
||||
m_data[2] *= a_v;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
vec3f operator-() const {
|
||||
return vec3f(-m_data[0],-m_data[1],-m_data[2]);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public: //iv2sg
|
||||
m_data[0] = -m_data[0];
|
||||
m_data[1] = -m_data[1];
|
||||
m_data[2] = -m_data[2];
|
||||
}
|
||||
}
|
||||
|
||||
private:static void check_instantiation() {vec3f v(0,0,0);v.set_value(1,1,1);}
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
vec4(const T& a0,const T& a1,const T& a2,const T& a3
|
||||
#ifdef TOOLS_MEM
|
||||
,bool a_inc = true
|
||||
#endif
|
||||
#endif
|
||||
) {
|
||||
#ifdef TOOLS_MEM
|
||||
if(a_inc) mem::increment(s_class().c_str());
|
||||
@@ -114,9 +114,9 @@ public:
|
||||
a1 = m_data[1];
|
||||
a2 = m_data[2];
|
||||
a3 = m_data[3];
|
||||
}
|
||||
}
|
||||
|
||||
bool set_value(unsigned int a_index,const T& a_value) {
|
||||
bool set_value(unsigned int a_index,const T& a_value) {
|
||||
if(a_index>=4) return false;
|
||||
m_data[a_index] = a_value;
|
||||
return true;
|
||||
@@ -197,28 +197,28 @@ public:
|
||||
m_data[1] += a_v.m_data[1];
|
||||
m_data[2] += a_v.m_data[2];
|
||||
m_data[3] += a_v.m_data[3];
|
||||
}
|
||||
}
|
||||
|
||||
void add(const T& a0,const T& a1,const T& a2,const T& a3) {
|
||||
m_data[0] += a0;
|
||||
m_data[1] += a1;
|
||||
m_data[2] += a2;
|
||||
m_data[3] += a3;
|
||||
}
|
||||
}
|
||||
|
||||
void subtract(const vec4& a_v) {
|
||||
m_data[0] -= a_v.m_data[0];
|
||||
m_data[1] -= a_v.m_data[1];
|
||||
m_data[2] -= a_v.m_data[2];
|
||||
m_data[3] -= a_v.m_data[3];
|
||||
}
|
||||
}
|
||||
|
||||
void subtract(const T& a0,const T& a1,const T& a2,const T& a3) {
|
||||
m_data[0] -= a0;
|
||||
m_data[1] -= a1;
|
||||
m_data[2] -= a2;
|
||||
m_data[3] -= a3;
|
||||
}
|
||||
}
|
||||
|
||||
public: //operators
|
||||
T& operator[](size_t a_index) {
|
||||
@@ -235,7 +235,7 @@ public: //operators
|
||||
m_data[1]+a_v.m_data[1],
|
||||
m_data[2]+a_v.m_data[2],
|
||||
m_data[3]+a_v.m_data[3]);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 operator-(const vec4& a_v) const {
|
||||
return vec4(m_data[0]-a_v.m_data[0],
|
||||
@@ -249,7 +249,7 @@ public: //operators
|
||||
m_data[1]*a_v,
|
||||
m_data[2]*a_v,
|
||||
m_data[3]*a_v);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const vec4& a_v) const {return equal(a_v);}
|
||||
bool operator!=(const vec4& a_v) const {return !operator==(a_v);}
|
||||
|
||||
@@ -35,33 +35,33 @@ public: //operators
|
||||
m_data[1]*a_v,
|
||||
m_data[2]*a_v,
|
||||
m_data[3]*a_v);
|
||||
}
|
||||
}
|
||||
vec4f operator+(const vec4f& a_v) const {
|
||||
return vec4f(m_data[0]+a_v.m_data[0],
|
||||
m_data[1]+a_v.m_data[1],
|
||||
m_data[2]+a_v.m_data[2],
|
||||
m_data[3]+a_v.m_data[3]);
|
||||
}
|
||||
}
|
||||
vec4f operator-(const vec4f& a_v) const {
|
||||
return vec4f(m_data[0]-a_v.m_data[0],
|
||||
m_data[1]-a_v.m_data[1],
|
||||
m_data[2]-a_v.m_data[2],
|
||||
m_data[3]-a_v.m_data[3]);
|
||||
}
|
||||
vec4f& operator+=(const vec4f& a_v) {
|
||||
}
|
||||
vec4f& operator+=(const vec4f& a_v) {
|
||||
m_data[0] += a_v.m_data[0];
|
||||
m_data[1] += a_v.m_data[1];
|
||||
m_data[2] += a_v.m_data[2];
|
||||
m_data[3] += a_v.m_data[3];
|
||||
return *this;
|
||||
}
|
||||
vec4f& operator*=(float a_v) {
|
||||
}
|
||||
vec4f& operator*=(float a_v) {
|
||||
m_data[0] *= a_v;
|
||||
m_data[1] *= a_v;
|
||||
m_data[2] *= a_v;
|
||||
m_data[3] *= a_v;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
vec4f operator-() const {
|
||||
return vec4f(-m_data[0],-m_data[1],-m_data[2],-m_data[3]);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ inline void safe_clear(std::map<K,V*>& a_m){
|
||||
it_t it = a_m.begin();
|
||||
V* entry = (*it).second;
|
||||
a_m.erase(it);
|
||||
delete entry;
|
||||
delete entry;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ inline bool in_domain_log(double a_x){return (a_x>0?true:false);}
|
||||
inline bool in_domain_tan(double a_x){
|
||||
int n = int(a_x/half_pi());
|
||||
if(a_x!=n*half_pi()) return true;
|
||||
return (2*int(n/2)==n?true:false);
|
||||
return (2*int(n/2)==n?true:false);
|
||||
}
|
||||
inline bool in_domain_acos(double a_x){
|
||||
if((a_x<-1)||(1<a_x)) return false;
|
||||
@@ -60,6 +60,8 @@ namespace tools {
|
||||
inline double dcos(const double& a_x) {return ::cos(a_x);}
|
||||
inline double dsin(const double& a_x) {return ::sin(a_x);}
|
||||
inline double dpow(const double& a_x,const double& a_y) {return ::pow(a_x,a_y);}
|
||||
inline double dcosh(const double& a_x) {return ::cosh(a_x);}
|
||||
inline double dsinh(const double& a_x) {return ::sinh(a_x);}
|
||||
|
||||
inline double dconj(const double& a_x) {return a_x;}
|
||||
inline double dfabs(const double& a_x) {return ::fabs(a_x);} //if passing a_fabs(const T&).
|
||||
|
||||
@@ -24,13 +24,13 @@ inline float frad2deg() {
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline int fround(float a_x) {
|
||||
inline int fround(const float& a_x) {
|
||||
// From CoinGL/src/base/SbViewportRegion.cpp.
|
||||
if (a_x == (float) (int(a_x))) return int(a_x);
|
||||
else return (a_x>0.0f) ? int(a_x+0.5f) : -int(0.5f-a_x);
|
||||
}
|
||||
|
||||
inline float fstep(float a_x) {return a_x<0.0f?0.0f:1.0f;}
|
||||
inline float fstep(const float& a_x) {return a_x<0.0f?0.0f:1.0f;}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,26 +39,23 @@ inline float fstep(float a_x) {return a_x<0.0f?0.0f:1.0f;}
|
||||
|
||||
namespace tools {
|
||||
|
||||
inline float fcos(float x) {return (float)::cos(double(x));}
|
||||
inline float fsin(float x) {return (float)::sin(double(x));}
|
||||
inline float facos(float x) {return (float)::acos(double(x));}
|
||||
inline float fasin(float x) {return (float)::asin(double(x));}
|
||||
inline float ftan(float x) {return (float)::tan(double(x));}
|
||||
inline float fatan(float x) {return (float)::atan(double(x));}
|
||||
inline float fatan2(float x,float y) {return (float)::atan2(double(x),double(y));}
|
||||
inline float fsqrt(float x) {return (float)::sqrt(double(x));}
|
||||
inline float fpow(float x,float y) {return (float)::pow(double(x),(double)(y));}
|
||||
inline float fexp(float x) {return (float)::exp(double(x));}
|
||||
inline float flog(float x) {return (float)::log(double(x));}
|
||||
inline float flog10(float x) {return (float)::log10(double(x));}
|
||||
inline float ffloor(float x) {return (float)::floor(double(x));}
|
||||
inline float fceil(float x) {return (float)::ceil(double(x));}
|
||||
inline float fcosh(float x) {return (float)::cosh(double(x));}
|
||||
inline float fsinh(float x) {return (float)::sinh(double(x));}
|
||||
|
||||
inline float ffabs(float x) {return (float)::fabs(double(x));}
|
||||
|
||||
inline float ffabsc(const float& x) {return (float)::fabs(double(x));}
|
||||
inline float fcos(const float& x) {return (float)::cos(double(x));}
|
||||
inline float fsin(const float& x) {return (float)::sin(double(x));}
|
||||
inline float facos(const float& x) {return (float)::acos(double(x));}
|
||||
inline float fasin(const float& x) {return (float)::asin(double(x));}
|
||||
inline float ftan(const float& x) {return (float)::tan(double(x));}
|
||||
inline float fatan(const float& x) {return (float)::atan(double(x));}
|
||||
inline float fatan2(const float& x,const float& y) {return (float)::atan2(double(x),double(y));}
|
||||
inline float fsqrt(const float& x) {return (float)::sqrt(double(x));}
|
||||
inline float fpow(const float& x,const float& y) {return (float)::pow(double(x),(double)(y));}
|
||||
inline float fexp(const float& x) {return (float)::exp(double(x));}
|
||||
inline float flog(const float& x) {return (float)::log(double(x));}
|
||||
inline float flog10(const float& x) {return (float)::log10(double(x));}
|
||||
inline float ffloor(const float& x) {return (float)::floor(double(x));}
|
||||
inline float fceil(const float& x) {return (float)::ceil(double(x));}
|
||||
inline float fcosh(const float& x) {return (float)::cosh(double(x));}
|
||||
inline float fsinh(const float& x) {return (float)::sinh(double(x));}
|
||||
inline float ffabs(const float& x) {return (float)::fabs(double(x));}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -69,15 +69,15 @@ public:
|
||||
static void balance(std::ostream& a_out){
|
||||
if(counter()) {
|
||||
a_out << "tools::mem::balance :"
|
||||
<< " bad global object balance : " << counter()
|
||||
<< " bad global object balance : " << counter()
|
||||
<< std::endl;
|
||||
if(check_by_class()) {
|
||||
a_out << "tools::mem::balance :"
|
||||
<< " check by class was enabled."
|
||||
<< " check by class was enabled."
|
||||
<< std::endl;
|
||||
} else {
|
||||
a_out << "tools::mem::balance :"
|
||||
<< " check by class was disabled."
|
||||
<< " check by class was disabled."
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
@@ -85,21 +85,21 @@ public:
|
||||
for(it=list().begin();it!=list().end();++it) {
|
||||
if((*it).second) {
|
||||
a_out << "tools::mem::balance :"
|
||||
<< " for class " << (*it).first
|
||||
<< " for class " << (*it).first
|
||||
<< ", bad object balance : " << (*it).second
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
list().clear();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
public: //for MT disconnection (see test/mt_root_ntuple.cpp).
|
||||
static int& counter() {
|
||||
static int s_count = 0;
|
||||
return s_count;
|
||||
}
|
||||
|
||||
|
||||
static bool& check_by_class() {
|
||||
static bool s_check_by_class = false;
|
||||
return s_check_by_class;
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
namespace tools {
|
||||
|
||||
template <class T>
|
||||
inline T mn(const T& a,const T& b) {return (a<b?a:b);}
|
||||
inline T mn(const T& a,const T& b) {return (a<b?a:b);}
|
||||
|
||||
template <class T>
|
||||
inline T mx(const T& a,const T& b) {return (a>b?a:b);}
|
||||
inline T mx(const T& a,const T& b) {return (a>b?a:b);}
|
||||
|
||||
// long name :
|
||||
template <class T>
|
||||
inline T min_of(const T& a,const T& b) {return (a<b?a:b);}
|
||||
inline T min_of(const T& a,const T& b) {return (a<b?a:b);}
|
||||
|
||||
template <class T>
|
||||
inline T max_of(const T& a,const T& b) {return (a>b?a:b);}
|
||||
inline T max_of(const T& a,const T& b) {return (a>b?a:b);}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
m_out << "tools::mpi::hmpi::wait_histos : rank " << m_rank << " : can't alloc buffer of size " << buffer_size << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(::MPI_Recv(buffer,buffer_size,MPI_CHAR,a_src,m_tag,m_comm,&status)!=MPI_SUCCESS) {
|
||||
m_out << "tools::mpi::hmpi::wait_histos : rank " << m_rank << " : MPI_Recv : failed." << std::endl;
|
||||
delete [] buffer;
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
num_t nhist;
|
||||
if(!_mpi.unpack(nhist)) return false;
|
||||
|
||||
if(m_verbose)
|
||||
if(m_verbose)
|
||||
m_out << "tools::mpi::hmpi::wait_histos : rank " << m_rank << " : number of histos to unpack " << nhist << std::endl;
|
||||
|
||||
{for(num_t ihist=0;ihist<nhist;ihist++) {
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
<< std::endl;
|
||||
}
|
||||
a_hists.push_back(class_pointer(h->s_cls(),h)); //give ownership of h.
|
||||
|
||||
|
||||
} else if(scls==tools::histo::p2d::s_class()) {
|
||||
tools::histo::profile_data<double,unsigned int,unsigned int,double,double> pdata;
|
||||
if(!profile_data_duiuidd_unpack(_mpi,pdata)) return false;
|
||||
@@ -206,11 +206,11 @@ public:
|
||||
|
||||
public:
|
||||
virtual int rank() const { return m_rank;}
|
||||
virtual bool comm_rank(int& a_rank) const {
|
||||
virtual bool comm_rank(int& a_rank) const {
|
||||
if(::MPI_Comm_rank(m_comm,&a_rank)!=MPI_SUCCESS) {a_rank=-1;return false;}
|
||||
return true;
|
||||
}
|
||||
virtual bool comm_size(int& a_size) const {
|
||||
virtual bool comm_size(int& a_size) const {
|
||||
if(::MPI_Comm_size(m_comm,&a_size)!=MPI_SUCCESS) {a_size=0;return false;}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ inline bool wait_buffer(std::ostream& a_out,int a_rank,int a_src,int a_tag,const
|
||||
a_probe_src = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(::MPI_Recv(a_buffer,a_buffer_size,MPI_CHAR,status.MPI_SOURCE,status.MPI_TAG,a_comm,&status)!=MPI_SUCCESS) {
|
||||
a_out << "tools::mpi::wait_buffer : rank " << a_rank << " : MPI_Recv : failed." << std::endl;
|
||||
a_buffer_size = 0;
|
||||
|
||||
@@ -31,15 +31,15 @@ protected:
|
||||
}
|
||||
#endif
|
||||
public:
|
||||
virtual bool init(int* a_argc,char*** a_argv) {
|
||||
virtual bool init(int* a_argc,char*** a_argv) {
|
||||
if(::MPI_Init(a_argc,a_argv)!=MPI_SUCCESS) return false;
|
||||
return true;
|
||||
}
|
||||
virtual bool rank(int& a_rank) const {
|
||||
virtual bool rank(int& a_rank) const {
|
||||
if(::MPI_Comm_rank(MPI_COMM_WORLD,&a_rank)!=MPI_SUCCESS) {a_rank=-1;return false;}
|
||||
return true;
|
||||
}
|
||||
virtual bool size(int& a_size) const {
|
||||
virtual bool size(int& a_size) const {
|
||||
if(::MPI_Comm_size(MPI_COMM_WORLD,&a_size)!=MPI_SUCCESS) {a_size=0;return false;}
|
||||
return true;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user