Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision a2e6a2b1dd1da48e502fc25126aa9b8a139ed543 authored by GUANGMING ZANG on 13 August 2018, 08:44:48 UTC, committed by GitHub on 13 August 2018, 08:44:48 UTC
Update README.md
1 parent 80d039c
  • Files
  • Changes
  • 6fa5ac5
  • /
  • SpaceTimeTomography
  • /
  • ImageFormationModel
  • /
  • RayCaster.core.h
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:a2e6a2b1dd1da48e502fc25126aa9b8a139ed543
directory badge
swh:1:dir:314b434087cc08ec6b52c9a3e3f3261667e88ff4
content badge
swh:1:cnt:03fe3c3079bf596655431f3d5e99bef4063be54d

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
RayCaster.core.h
#include "RayCaster.h"
#include "Vector4.h"
#include "Vector3.h"
#include<iostream>
using namespace std;
// for data access module.
static inline float GetScalarValue(Vector4 pos);
static inline Vector4 GetNormal(Vector4 pos);

// glboal params, to store parames temporarily
static float sampleDistance;
static float isovalue;
static Vector4 baseColor;
static Vector3 ambient;
static Vector3 diffuse;
static Vector3 specular;
static float specular_power;
static Vector4 light_direction;
static float spec_threshold;
static int bsize[3];

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif

static inline void GetMinMax(int x,int y,int z,float &minV,float &maxV);
//
static inline int ConvertToVoxelIndex(int blockIndex, int dimId)
{
	return blockIndex*bsize[dimId];
}

static inline int ConvertToBlockIndex(int voxelIndex, int dimId)
{
	return voxelIndex / bsize[dimId];
}
//core functions, for generating  each ray  (from X-Ray source to measurement image) 
static inline double CastingRay(const Vector4& voxel_zero,const Vector4& voxel_unit,const Vector4& CameraDirection,float tnear,float tfar,float &SumWeight_Ray, int indexOfImage)
{

	
	
	int index=0;
	float density=0.0f;
	float t1=tnear;
	Vector4 pos1=voxel_zero+voxel_unit*t1;

	float tMaxX,tMaxY,tMaxZ;
	float tDeltaX,tDeltaY,tDeltaZ;

	//Vector4 acc(0.0f,0.0f,0.0f,0.0f);
	Vector4 voxel_step=voxel_unit*sampleDistance;



	float scalar1=GetScalarValue(pos1,SumWeight_Ray,indexOfImage);
	density+=scalar1*sampleDistance;
	int x,y,z;
	int stepX,stepY,stepZ;
	if (voxel_unit[0]==0)
	{
		x=ConvertToBlockIndex(((int)ceilf(pos1[0]-0.5f)-1),0);
		stepX=0;
		tMaxX=tfar;
	}
	else if (voxel_unit[0]<0)
	{
		x=ConvertToBlockIndex(((int)ceilf(pos1[0]-0.5f)-1),0);
		stepX=-1;
		tMaxX=(ConvertToVoxelIndex(x,0)+0.5f-voxel_zero[0])/voxel_unit[0];
		tDeltaX=-ConvertToVoxelIndex(1,0)/voxel_unit[0];
	}
	else
	{
		x=ConvertToBlockIndex((int)floorf(pos1[0]-0.5f),0);
		stepX=1;
		tMaxX=(ConvertToVoxelIndex(x+1,0)+0.5f-voxel_zero[0])/voxel_unit[0];
		tDeltaX=ConvertToVoxelIndex(1,0)/voxel_unit[0];
	}

	if (voxel_unit[1]==0)
	{
		y=ConvertToBlockIndex(((int)ceilf(pos1[1]-0.5f)-1),1);
		stepY=0;
		tMaxY=tfar;
	}
	else if (voxel_unit[1]<0)
	{
		y=ConvertToBlockIndex(((int)ceilf(pos1[1]-0.5f)-1),1);
		stepY=-1;
		tMaxY=(ConvertToVoxelIndex(y,1)+0.5f-voxel_zero[1])/voxel_unit[1];
		tDeltaY=-ConvertToVoxelIndex(1,1)/voxel_unit[1];
	}
	else
	{
		y=ConvertToBlockIndex((int)floorf(pos1[1]-0.5f),1);
		stepY=1;
		tMaxY=(ConvertToVoxelIndex(y+1,1)+0.5f-voxel_zero[1])/voxel_unit[1];
		tDeltaY=ConvertToVoxelIndex(1,1)/voxel_unit[1];
	}

	if (voxel_unit[2]==0)
	{
		z=ConvertToBlockIndex(((int)ceilf(pos1[2]-0.5f)-1),2);
		stepZ=0;
		tMaxZ=tfar;
	}
	else if (voxel_unit[2]<0)
	{
		z=ConvertToBlockIndex(((int)ceilf(pos1[2]-0.5f)-1),2);
		stepZ=-1;
		tMaxZ=(ConvertToVoxelIndex(z,2)+0.5f-voxel_zero[2])/voxel_unit[2];
		tDeltaZ=-ConvertToVoxelIndex(1,2)/voxel_unit[2];
	}
	else
	{
		z=ConvertToBlockIndex((int)floorf(pos1[2]-0.5f),2);
		stepZ=1;
		tMaxZ=(ConvertToVoxelIndex(z+1,2)+0.5f-voxel_zero[2])/voxel_unit[2];
		tDeltaZ=ConvertToVoxelIndex(1,2)/voxel_unit[2];
	}

	float t_b;

	
	while (t1<tfar)
	{
		t_b=min(min(tMaxX,tMaxY),tMaxZ);

	
		if (t_b>tfar) t_b=tfar;

		float t=ceilf((t1-tnear)/sampleDistance)*sampleDistance+tnear;
		Vector4 pos=voxel_zero + voxel_unit * t;		

		
		while(t<t_b)
		{
			//Vector4 color=GetShadedColor(pos,CameraDirection);
			density+=GetScalarValue(pos,SumWeight_Ray,indexOfImage)*sampleDistance;
			//float alpha=color[3];
			//color[3]=1.0f;
			//color*=alpha;		
			//acc+=(1.0f-acc[3])*color;				
			t += sampleDistance;
			pos += voxel_step;
			index++;
		}
		

		if (tMaxX<tMaxY)
		{
			if (tMaxX<tMaxZ) 
			{
				tMaxX+=tDeltaX;
				x+=stepX;
			}
			else 
			{
				tMaxZ+=tDeltaZ;
				z+=stepZ;
			}
		}
		else
		{
			if (tMaxY<tMaxZ) 
			{
				tMaxY+=tDeltaY;
				y+=stepY;
			}
			else 
			{
				tMaxZ+=tDeltaZ;
				z+=stepZ;
			}
		}
		t1=t_b;
	}


	
	return density;

}

// prepare for rendering, called by render_core
static bool RayCasterPrepare(RayCaster *RayCaster, int size[])
{
	if (!RayCaster) return false;

	
	sampleDistance=RayCaster->GetSampleDistance();
	
	baseColor[3]=1.0f;
	bsize[0] = size[0];
	bsize[1] = size[1];
	bsize[2] = size[2];
	float lightColor[3];

	light_direction[3]=0.0f;

	return true;
}



The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API