DataModel.wiki - Vaa3D/Vaa3D_Wiki GitHub Wiki

Content

Overview

Vaa3D is built upon two types of data: (1) multidimensional images and (2) 3D surface objects. Each of these two basic types have many subtypes of data, as discussed below.

Multi-dimensional images

Vaa3D supports 2D-5D image stacks and time-series of image stacks. The core is a 4D image stack, which means "multi-color / multi-channel 3D image stack". The basic class for a 4D image defined in the file "basic_4dimage.h" under the basic_c_fun folder. It is also extended to describe a 5D image conveniently.

class Image4DSimple
{
protected:
	unsigned char * data1d;    //where the real data is stored
	V3DLONG sz0;               // dimension 1, corresponds to X 
	V3DLONG sz1;               // dimension 2, corresponds to Y
	V3DLONG sz2;               // dimension 3, corresponds to Z
	V3DLONG sz3;               // dimension 4, corresponds to C (color or channel)
	V3DLONG sz_time;           // dimension 5, corresponds to t (time point)
	TimePackType timepacktype; //the method to extend to 5D
	ImagePixelType datatype;   //pixel type, 8bit, 16bit, or 32bit. Can be extended
	char imgSrcFile[1024];     //the full file path
	int b_error;               //error flag
	double rez_x, rez_y, rez_z; //the resolution of a image pixel along the 3 axes
	double origin_x, origin_y, origin_z; //the "true" origin of an image, in term of the physical units (not pixels) using resolution information

	V3DLONG valid_zslicenum; //indicate how many zslices are usable. This can be used by a plugin program to stream read data
	V3DLONG prevalid_zslicenum; //indicate previous valid slices loaded before update GUI
	void * p_customStruct; //a convenient pointer to pass back and forth some useful parameter information for a plugin

	void setError( int v ) {b_error = v;}

private:

public:
	Image4DSimple();
	virtual ~Image4DSimple();
	virtual void cleanExistData();

	//main interface to the data
	unsigned char * getRawData() {return data1d;}
        const unsigned char * getRawData() const {return data1d;} // const version 25-Apr 2011 CMB
        V3DLONG getXDim() const {return sz0;}
        V3DLONG getYDim() const {return sz1;}
        V3DLONG getZDim() const {return sz2;}
        V3DLONG getCDim() const {return sz3;}
        V3DLONG getTDim() const {return sz_time;}
        V3DLONG getValidZSliceNum() const {return valid_zslicenum;}
        V3DLONG getPreValidZSliceNum() const {return prevalid_zslicenum;}
        int getError() const {return b_error;}
        ImagePixelType getDatatype() const {return datatype;}
        TimePackType getTimePackType() const {return timepacktype;}
        V3DLONG getTotalUnitNumber() const {return sz0*sz1*sz2*sz3;}
        V3DLONG getTotalUnitNumberPerPlane() const {return sz0*sz1;}
        V3DLONG getTotalUnitNumberPerChannel() const {return sz0*sz1*sz2;}
        V3DLONG getUnitBytes() const
	{
		switch (datatype)
		{
			case V3D_UINT8: return 1;
			case V3D_UINT16: return 2;
			case V3D_FLOAT32: return 4;
			default: return 1;
		}
	}
        V3DLONG getTotalBytes() const {return getUnitBytes()*sz0*sz1*sz2*sz3;}
	unsigned char * getRawDataAtChannel(V3DLONG cid); //return a pointer to a channel's data
	int isSuccess() {if (sz0<=0 || sz1<=0 || sz2<=0 || sz3<=0) b_error=1; return !b_error;}
	virtual bool valid(); // if data is valid, true/false
        double getRezX() const {return rez_x;}
        double getRezY() const {return rez_y;}
        double getRezZ() const {return rez_z;}
        double getOriginX() const {return origin_x;}
        double getOriginY() const {return origin_y;}
        double getOriginZ() const {return origin_z;}

	void setXDim(V3DLONG v) {sz0=v;}
	void setYDim(V3DLONG v) {sz1=v;}
	void setZDim(V3DLONG v) {sz2=v;}
	void setCDim(V3DLONG v) {sz3=v;}
	void setTDim(V3DLONG v) {sz_time=v;}
	bool setValidZSliceNum(V3DLONG v); //for a data-loading thread to use 
	bool setPreValidZSliceNum(V3DLONG v); // for a data-loading thread to use 
	void setDatatype(ImagePixelType v) {datatype=v;}
	void setTimePackType(TimePackType v) {timepacktype=v;}
	bool setNewRawDataPointer(unsigned char *p) {if (!p) return false; if (data1d) delete []data1d; data1d = p; return true;}
	void setRawDataPointerToNull() { this->data1d = 0; }
	void deleteRawDataAndSetPointerToNull() { if (data1d) {delete []data1d; data1d = 0;} }
	void setRawDataPointer(unsigned char *p) { this->data1d = p; }
	bool setRezX(double a) { if (a<=0) return false; rez_x = a; return true;}
	bool setRezY(double a) { if (a<=0) return false; rez_y = a; return true;}
	bool setRezZ(double a) { if (a<=0) return false; rez_z = a; return true;}
	void setOriginX(double a) { origin_x = a;}
	void setOriginY(double a) { origin_y = a;}
	void setOriginZ(double a) { origin_z = a;}
	

	void setCustomStructPointer(void *a) {p_customStruct = a;}
	void * getCustomStructPointer() {return p_customStruct;}
	bool isValidCustomStructPointer() {return (p_customStruct!=0)?true:false;}

	//these functions are the main place to call if you want to set your own 1d pointer data to this data structure
	bool setData(unsigned char *p, Image4DSimple * image );
	bool setData(unsigned char *p, V3DLONG s0, V3DLONG s1, V3DLONG s2, V3DLONG s3, ImagePixelType dt);

	bool setFileName(const char * myfile);
	const char * getFileName() const { return imgSrcFile; }

	//to call the following 4 functions you must link your project with basic_4dimage.cpp
	//Normally for the plugin interfaces you don't need to call the following functions
	void loadImage(char filename[]);
	void loadImage(char filename[], bool b_useMylib);
	bool saveImage(const char filename[]);
	bool createImage(V3DLONG mysz0, V3DLONG mysz1, V3DLONG mysz2, V3DLONG mysz3, ImagePixelType mytype);
	void createBlankImage(V3DLONG imgsz0, V3DLONG imgsz1, V3DLONG imgsz2, V3DLONG imgsz3, int imgdatatype);

	//a function to check if the data buffer is the same as another image
	bool isSameDataBuffer( Image4DSimple *p); //advanced use
};
  1. Large data access (to add)

3D surface objects

  1. Irregular surface meshes
  2. Point-cloud, where each point is modeled as a sphere, but can have a different size or color or name/comment and other properties
  3. 3D curved objects
  4. 3D tree-shaped objects
  5. 3D relationship / networked objects
  6. Abstracted 3D locations - 3D markers
⚠️ **GitHub.com Fallback** ⚠️