Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r434 - in branches/newpipeline: Engine/Display Engine/IdleModes Engine/ImageTraversers Image Interface Model/Groups Model/MiscObjects Model/Primitives Model/Readers Model/Readers/rply Model/Textures StandAlone SwigInterface UserInterface scenes
- Date: Wed, 20 Jul 2005 13:21:54 -0600 (MDT)
Author: bigler
Date: Wed Jul 20 13:21:52 2005
New Revision: 434
Added:
branches/newpipeline/Engine/ImageTraversers/DissolveImageTraverser.cc
- copied unchanged from r433,
trunk/Engine/ImageTraversers/DissolveImageTraverser.cc
branches/newpipeline/Engine/ImageTraversers/DissolveImageTraverser.h
- copied unchanged from r433,
trunk/Engine/ImageTraversers/DissolveImageTraverser.h
branches/newpipeline/SwigInterface/manta.h
- copied unchanged from r433, trunk/SwigInterface/manta.h
Modified:
branches/newpipeline/Engine/Display/OpenGLDisplay.cc
branches/newpipeline/Engine/IdleModes/ZoomIdleMode.cc
branches/newpipeline/Engine/ImageTraversers/FramelessImageTraverser.cc
branches/newpipeline/Engine/ImageTraversers/FramelessImageTraverser.h
branches/newpipeline/Image/TGAFile.cc
branches/newpipeline/Interface/Callback.h
branches/newpipeline/Interface/CallbackHelpers.h
branches/newpipeline/Model/Groups/BVH.cc
branches/newpipeline/Model/MiscObjects/Difference.cc
branches/newpipeline/Model/Primitives/SuperEllipsoid.cc
branches/newpipeline/Model/Primitives/SuperEllipsoid.h
branches/newpipeline/Model/Readers/PlyReader.cc
branches/newpipeline/Model/Readers/rply/rply.c
branches/newpipeline/Model/Textures/ImageTexture.cc
branches/newpipeline/StandAlone/manta.cc
branches/newpipeline/SwigInterface/CMakeLists.txt
branches/newpipeline/SwigInterface/manta.i
branches/newpipeline/UserInterface/XWindowUI.cc
branches/newpipeline/scenes/primtest.cc
Log:
Merged the changes in the trunk into this branch. It still doesn't
compile, but I'm working on that.
I used this command to merge in the changes (I actually used HEAD
instead of 433, but that's what HEAD translated in to).
svn merge -r 415:433
https://code.sci.utah.edu/svn/Manta/trunk
Modified: branches/newpipeline/Engine/Display/OpenGLDisplay.cc
==============================================================================
--- branches/newpipeline/Engine/Display/OpenGLDisplay.cc (original)
+++ branches/newpipeline/Engine/Display/OpenGLDisplay.cc Wed Jul 20
13:21:52 2005
@@ -92,12 +92,12 @@
// Open the display and make sure it has opengl
dpy = XOpenDisplay(NULL);
if(!dpy)
- throw InternalError("Error opening display");
+ throw InternalError("Error opening display", __FILE__, __LINE__);
int error, event;
if ( !glXQueryExtension( dpy, &error, &event) ) {
XCloseDisplay(dpy);
dpy=0;
- throw InternalError("GL extension NOT available!\n");
+ throw InternalError("GL extension NOT available!\n", __FILE__, __LINE__);
}
int screen=DefaultScreen(dpy);
@@ -121,7 +121,7 @@
vi = glXChooseVisual(dpy, screen, &attribList[0]);
if(!vi){
// Cannot find anything suitable
- throw InternalError("Error selecting OpenGL visual");
+ throw InternalError("Error selecting OpenGL visual", __FILE__,
__LINE__);
}
}
@@ -175,7 +175,7 @@
XFree(vi);
if(!glXMakeCurrent(dpy, win, cx))
- throw InternalError("glXMakeCurrent failed!\n");
+ throw InternalError("glXMakeCurrent failed!\n", __FILE__, __LINE__);
glClearColor(.05, .1, .2, 0);
glClear(GL_COLOR_BUFFER_BIT);
@@ -185,13 +185,13 @@
// Get the fonts. You need to call this with a current GL context.
fontInfo = XHelper::getX11Font(dpy);
if (!fontInfo)
- throw InternalError("getX11Font failed!\n");
+ throw InternalError("getX11Font failed!\n", __FILE__, __LINE__);
fontbase = XHelper::getGLFont(fontInfo);
if (fontbase == 0)
- throw InternalError("getGLFont failed!\n");
+ throw InternalError("getGLFont failed!\n", __FILE__, __LINE__);
if(!glXMakeCurrent(dpy, None, NULL))
- throw InternalError("glXMakeCurrent failed!\n");
+ throw InternalError("glXMakeCurrent failed!\n", __FILE__, __LINE__);
}
void OpenGLDisplay::displayImage(const DisplayContext& context,
@@ -213,7 +213,7 @@
if(!madeCurrent){
if(!glXMakeCurrent(dpy, win, cx))
- throw InternalError("glXMakeCurrent failed!\n");
+ throw InternalError("glXMakeCurrent failed!\n", __FILE__, __LINE__);
madeCurrent=true;
}
bool stereo;
@@ -284,7 +284,8 @@
glDrawPixels(xres, yres, GL_RGB, GL_FLOAT, si->getRaw(0));
}
} else {
- throw InternalError("Unknown image type in OpenGLDisplay");
+ throw InternalError("Unknown image type in OpenGLDisplay",
+ __FILE__, __LINE__);
}
display_frame_rate(1.0/(currentTime-last_frame_time));
Modified: branches/newpipeline/Engine/IdleModes/ZoomIdleMode.cc
==============================================================================
--- branches/newpipeline/Engine/IdleModes/ZoomIdleMode.cc (original)
+++ branches/newpipeline/Engine/IdleModes/ZoomIdleMode.cc Wed Jul 20
13:21:52 2005
@@ -1,7 +1,7 @@
#include <Engine/IdleModes/ZoomIdleMode.h>
#include <Interface/Context.h>
-#include <Interface/RTRTInterface.h>
+#include <Interface/MantaInterface.h>
#include <Core/Math/MinMax.h>
using namespace Manta;
Modified:
branches/newpipeline/Engine/ImageTraversers/FramelessImageTraverser.cc
==============================================================================
--- branches/newpipeline/Engine/ImageTraversers/FramelessImageTraverser.cc
(original)
+++ branches/newpipeline/Engine/ImageTraversers/FramelessImageTraverser.cc
Wed Jul 20 13:21:52 2005
@@ -85,18 +85,18 @@
nx = 1;
int tres = xres;
while(tres>1)
- {
- nx++;
- tres /= 2;
- }
+ {
+ nx++;
+ tres /= 2;
+ }
ny = 1;
tres = yres;
while(tres>1)
- {
- ny++;
- tres /= 2;
- }
+ {
+ ny++;
+ tres /= 2;
+ }
nx/=2;
ny/=2;
@@ -120,32 +120,32 @@
shuffledTiles = new UniformTiles[xtiles*ytiles];
for(i=0; i<xtiles*ytiles; i++) {
if(xtiles<ytiles)
- {
- j = i%xtiles;
- k = i/xtiles;
- shuffledTiles[i].xstart = j*xtilesize;
- shuffledTiles[i].xend = (j+1)*xtilesize;
- shuffledTiles[i].ystart = k*ytilesize;
- shuffledTiles[i].yend = (k+1)*ytilesize;
- }
+ {
+ j = i%xtiles;
+ k = i/xtiles;
+ shuffledTiles[i].xstart = j*xtilesize;
+ shuffledTiles[i].xend = (j+1)*xtilesize;
+ shuffledTiles[i].ystart = k*ytilesize;
+ shuffledTiles[i].yend = (k+1)*ytilesize;
+ }
else
- {
- j = i%ytiles;
- k = i/ytiles;
- shuffledTiles[i].xstart = k*xtilesize;
- shuffledTiles[i].xend = (k+1)*xtilesize;
- shuffledTiles[i].ystart = j*ytilesize;
- shuffledTiles[i].yend = (j+1)*ytilesize;
- }
+ {
+ j = i%ytiles;
+ k = i/ytiles;
+ shuffledTiles[i].xstart = k*xtilesize;
+ shuffledTiles[i].xend = (k+1)*xtilesize;
+ shuffledTiles[i].ystart = j*ytilesize;
+ shuffledTiles[i].yend = (j+1)*ytilesize;
+ }
if(shuffledTiles[i].xend>xres)
shuffledTiles[i].xend = xres;
if(shuffledTiles[i].yend>yres)
shuffledTiles[i].yend = yres;
if(shuffledTiles[i].xstart == shuffledTiles[i].xend)
- { printf("error\n"); }
+ { printf("error\n"); }
if( shuffledTiles[i].ystart == shuffledTiles[i].yend)
- { printf("error\n"); }
+ { printf("error\n"); }
}
shuffleMyTiles(); // shuffle them up
@@ -185,15 +185,15 @@
// normalized
double px, py;
if(xres>yres) // let the smaller dimension be mapped to [-1,1]
- {
- px = (double)(-1.0 + 2.0*(double)(fe.x+0.5)/(double)yres);
- py = (double)(-1.0 + 2.0*(double)(fe.y+0.5)/(double)yres);
- }
+ {
+ px = (double)(-1.0 + 2.0*(double)(fe.x+0.5)/(double)yres);
+ py = (double)(-1.0 + 2.0*(double)(fe.y+0.5)/(double)yres);
+ }
else
- {
- px = (double)(-1.0 + 2.0*(double)(fe.x+0.5)/(double)xres);
- py = (double)(-1.0 + 2.0*(double)(fe.y+0.5)/(double)xres);
- }
+ {
+ px = (double)(-1.0 + 2.0*(double)(fe.x+0.5)/(double)xres);
+ py = (double)(-1.0 + 2.0*(double)(fe.y+0.5)/(double)xres);
+ }
//printf("%f, %f\n", (float)px, (float)py);
rays.setPixel(i, 0, px, py, &fe.color);
}
Modified:
branches/newpipeline/Engine/ImageTraversers/FramelessImageTraverser.h
==============================================================================
--- branches/newpipeline/Engine/ImageTraversers/FramelessImageTraverser.h
(original)
+++ branches/newpipeline/Engine/ImageTraversers/FramelessImageTraverser.h
Wed Jul 20 13:21:52 2005
@@ -13,7 +13,7 @@
using namespace std;
struct UniformTiles
{
- int xstart, ystart, xend, yend;
+ int xstart, ystart, xend, yend;
};
class FramelessImageTraverser : public ImageTraverser {
public:
@@ -23,16 +23,16 @@
virtual void setupDisplayChannel(SetupContext&);
virtual void setupFrame(const RenderContext& context);
virtual void renderImage(const RenderContext& context, Image* image);
- void shuffleMyTiles();
+ void shuffleMyTiles();
void renderFragment(const RenderContext& context, Fragment& fragment,
int xres, int yres);
static ImageTraverser* create(const vector<string>& args);
private:
FramelessImageTraverser(const FramelessImageTraverser&);
FramelessImageTraverser& operator=(const FramelessImageTraverser&);
- int xtilesize, ytilesize;
- UniformTiles *shuffledTiles;
+ int xtilesize, ytilesize;
+ UniformTiles *shuffledTiles;
int xtiles,ytiles;
- MT_RNG *myRandomNumber;
+ MT_RNG *myRandomNumber;
};
}
Modified: branches/newpipeline/Image/TGAFile.cc
==============================================================================
--- branches/newpipeline/Image/TGAFile.cc (original)
+++ branches/newpipeline/Image/TGAFile.cc Wed Jul 20 13:21:52 2005
@@ -39,7 +39,8 @@
{
ofstream out( filename.c_str(), ios::out | ios::binary );
if ( !out )
- throw InternalError( "Couldn't open TGA file for writing: " + filename
);
+ throw InternalError("Couldn't open TGA file for writing: " + filename,
+ __FILE__, __LINE__);
out.put( 0 ); // ID length: 0
out.put( 0 ); // Color map type: None
out.put( 2 ); // Image type: uncompressed, true-color
image
@@ -125,7 +126,8 @@
++buffer;
}
} else {
- throw InternalError( "Unknown image type in writeTGA()" );
+ throw InternalError("Unknown image type in writeTGA()",
+ __FILE__, __LINE__);
}
}
@@ -152,14 +154,16 @@
{
ifstream in( filename.c_str(), ios::in | ios::binary );
if ( !in )
- throw InternalError( "Couldn't open TGA file for reading: " + filename
);
+ throw InternalError("Couldn't open TGA file for reading: " + filename,
+ __FILE__, __LINE__);
int id_length = in.get();
int color_map_type = in.get();
if ( color_map_type != 0 )
- throw InternalError( "Color map TGA files currently unsupported" );
+ throw InternalError("Color map TGA files currently unsupported",
+ __FILE__, __LINE__);
int image_type = in.get();
if ( image_type != 2 )
- throw InternalError( "Only uncompressed true-color TGA files currently
supported" );
+ throw InternalError("Only uncompressed true-color TGA files currently
supported", __FILE__, __LINE__);
int color_map_first_entry_index = readShort( in );
int color_map_length = readShort( in );
int color_map_entry_size = in.get();
@@ -198,7 +202,8 @@
}
return si;
}
- throw InternalError( "Unhandled pixel depth and alpha for TGA files" );
+ throw InternalError("Unhandled pixel depth and alpha for TGA files",
+ __FILE__, __LINE__);
}
}
Modified: branches/newpipeline/Interface/Callback.h
==============================================================================
--- branches/newpipeline/Interface/Callback.h (original)
+++ branches/newpipeline/Interface/Callback.h Wed Jul 20 13:21:52 2005
@@ -51,6 +51,14 @@
}
template<class T, typename Data1, typename Data2,
+ typename Arg1, typename Arg2> static
+ CallbackBase_2Data<Data1, Data2>*
+ create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2),
+ Arg1 arg1, Arg2 arg2) {
+ return new Callback_2Data_2Arg<T, Data1, Data2, Arg1, Arg2>(ptr, pmf,
arg1, arg2);
+ }
+
+ template<class T, typename Data1, typename Data2,
typename Arg1, typename Arg2, typename Arg3> static
CallbackBase_2Data<Data1, Data2>*
create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2, Arg3),
Modified: branches/newpipeline/Interface/CallbackHelpers.h
==============================================================================
--- branches/newpipeline/Interface/CallbackHelpers.h (original)
+++ branches/newpipeline/Interface/CallbackHelpers.h Wed Jul 20 13:21:52
2005
@@ -262,6 +262,29 @@
};
template<class T, typename Data1, typename Data2,
+ typename Arg1, typename Arg2>
+ class Callback_2Data_2Arg : public CallbackBase_2Data<Data1, Data2> {
+ public:
+ Callback_2Data_2Arg(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2),
+ Arg1 arg1, Arg2 arg2)
+ : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2)
+ {
+ }
+ virtual ~Callback_2Data_2Arg()
+ {
+ }
+ virtual void call(Data1 data1, Data2 data2)
+ {
+ (ptr->*pmf)(data1, data2, arg1, arg2);
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)(Data1, Data2, Arg1, Arg2);
+ Arg1 arg1;
+ Arg2 arg2;
+ };
+
+ template<class T, typename Data1, typename Data2,
typename Arg1, typename Arg2, typename Arg3>
class Callback_2Data_3Arg : public CallbackBase_2Data<Data1, Data2> {
public:
Modified: branches/newpipeline/Model/Groups/BVH.cc
==============================================================================
--- branches/newpipeline/Model/Groups/BVH.cc (original)
+++ branches/newpipeline/Model/Groups/BVH.cc Wed Jul 20 13:21:52 2005
@@ -263,7 +263,7 @@
delete [] objValues;
}
else {
- throw InternalError("Unknown build mode: "+buildMode);
+ throw InternalError("Unknown build mode: "+buildMode, __FILE__,
__LINE__);
}
@@ -281,12 +281,12 @@
if(node->left > 0){
stack[nstack++] = node->left;
if(nstack >= MAXDEPTH)
- throw InternalError("Depth of BVH exceeds maximum depth:
"+to_string(MAXDEPTH)+", must change MAXDEPTH in "+__FILE__);
+ throw InternalError("Depth of BVH exceeds maximum depth:
"+to_string(MAXDEPTH)+", must change MAXDEPTH in "+__FILE__, __FILE__,
__LINE__);
}
if(node->right > 0){
stack[nstack++] = node->right;
if(nstack >= MAXDEPTH)
- throw InternalError("Depth of BVH exceeds maximum depth:
"+to_string(MAXDEPTH)+", must change MAXDEPTH in "+__FILE__);
+ throw InternalError("Depth of BVH exceeds maximum depth:
"+to_string(MAXDEPTH)+", must change MAXDEPTH in "+__FILE__, __FILE__,
__LINE__);
}
}
Modified: branches/newpipeline/Model/MiscObjects/Difference.cc
==============================================================================
--- branches/newpipeline/Model/MiscObjects/Difference.cc (original)
+++ branches/newpipeline/Model/MiscObjects/Difference.cc Wed Jul 20
13:21:52 2005
@@ -9,7 +9,7 @@
Difference::Difference(Object* object1, Object* object2)
: object1(object1), object2(object2)
{
- throw InternalError("Difference not yet implemented");
+ throw InternalError("Difference not yet implemented", __FILE__, __LINE__);
}
Difference::~Difference()
Modified: branches/newpipeline/Model/Primitives/SuperEllipsoid.cc
==============================================================================
--- branches/newpipeline/Model/Primitives/SuperEllipsoid.cc (original)
+++ branches/newpipeline/Model/Primitives/SuperEllipsoid.cc Wed Jul 20
13:21:52 2005
@@ -1,31 +1,28 @@
+#include <iostream>
+
#include <Model/Primitives/SuperEllipsoid.h>
#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
#include <Core/Math/MinMax.h>
#include <Core/Math/MiscMath.h>
-using namespace Manta;
using namespace std;
-using SCIRun::Clamp;
+using namespace SCIRun;
+using namespace Manta;
#define GOLDENMEAN 0.61803398874989484820
-#define BRACKETWIDTH 1.e-6
-#define MAXNEWTONITER 25
+#define BRACKETWIDTH 1.e-3
+#define MAXNEWTONITER 10
SuperEllipsoid::SuperEllipsoid(
Material *material,
- Point const ¢er,
- double radius,
double alpha,
double beta )
: PrimitiveCommon( material, this ),
- center( center ),
- radius( radius )
+ two_over_alpha( 2. / alpha ),
+ two_over_beta( 2. / beta ),
+ alpha_over_beta( alpha / beta )
{
- inv_radius = 1. / radius;
- two_over_alpha = 2. / alpha;
- two_over_beta = 2. / beta;
- alpha_over_beta = alpha / beta;
}
SuperEllipsoid::~SuperEllipsoid()
@@ -33,7 +30,7 @@
}
inline double SuperEllipsoid::functionValue(
- Vector const &location ) const
+ Point const &location ) const
{
double x_power = pow( fabs( location.x() ), two_over_alpha );
double y_power = pow( fabs( location.y() ), two_over_alpha );
@@ -42,7 +39,7 @@
}
inline Vector const SuperEllipsoid::functionGradient(
- Vector const &location,
+ Point const &location,
double &value ) const
{
double x_power = pow( fabs(location.x() ), two_over_alpha );
@@ -56,7 +53,7 @@
}
inline Vector const SuperEllipsoid::logarithmFunctionGradient(
- Vector const &location,
+ Point const &location,
double &value ) const
{
double x_power = pow( fabs(location.x() ), two_over_alpha );
@@ -73,64 +70,49 @@
PreprocessContext const &,
BBox &bbox ) const
{
- bbox.extendBySphere( center, radius );
+ bbox.extendByPoint( Point( -1., -1., -1. ) );
+ bbox.extendByPoint( Point( 1., 1., 1. ) );
}
void SuperEllipsoid::intersect(const RenderContext&, RayPacket& rays) const
{
- rays.normalizeDirections();
rays.computeInverseDirections();
- for ( int i = 0; i < rays.getSize(); ++i )
- {
- RayPacket::Element &e( rays.get( i ) );
- Vector offset_center = e.ray.origin() - center;
+ for( int i = 0; i < rays.getSize(); ++i ) {
+ RayPacket::Element& e( rays.get(i) );
// First check if the ray hits the bounding box and whether it could
// remotely produce a hit of interest.
// TODO: Maybe factor this out into a common routine?
- double tnear, tfar, t1, t2;
- t1 = ( -radius - offset_center.x() ) * e.inverseDirection.x();
- t2 = ( radius - offset_center.x() ) * e.inverseDirection.x();
- if( t1 > t2 ) {
- double temp = t1;
- t1 = t2;
- t2 = temp;
- }
- tnear = t1;
- tfar = t2;
- t1 = ( -radius - offset_center.y() ) * e.inverseDirection.y();
- t2 = ( radius - offset_center.y() ) * e.inverseDirection.y();
- if( t1 > t2 ) {
- double temp = t1;
- t1 = t2;
- t2 = temp;
- }
- using SCIRun::Max;
- using SCIRun::Min;
- tnear = Max( t1, tnear );
- tfar = Min( t2, tfar );
- t1 = ( -radius - offset_center.z() ) * e.inverseDirection.z();
- t2 = ( radius - offset_center.z() ) * e.inverseDirection.z();
- if( t1 > t2 ) {
- double temp = t1;
- t1 = t2;
- t2 = temp;
- }
- tnear = Max( Max( t1, tnear ), T_EPSILON );
- tfar = Min( Min( t2, tfar ), e.hitInfo.minT() );
-
- if ( tfar < T_EPSILON || tnear >= e.hitInfo.minT() )
+ double t1 = ( -1.01 - e.ray.origin().x() ) * e.inverseDirection.x();
+ double t2 = ( 1.01 - e.ray.origin().x() ) * e.inverseDirection.x();
+ if ( t1 > t2 )
+ SWAP( t1, t2 );
+ double tnear = t1;
+ double tfar = t2;
+ t1 = ( -1.01 - e.ray.origin().y() ) * e.inverseDirection.y();
+ t2 = ( 1.01 - e.ray.origin().y() ) * e.inverseDirection.y();
+ if ( t1 > t2 )
+ SWAP( t1, t2 );
+ tnear = SCIRun::Max( t1, tnear );
+ tfar = SCIRun::Min( t2, tfar );
+ t1 = ( -1.01 - e.ray.origin().z() ) * e.inverseDirection.z();
+ t2 = ( 1.01 - e.ray.origin().z() ) * e.inverseDirection.z();
+ if ( t1 > t2 )
+ SWAP( t1, t2 );
+ tnear = SCIRun::Max( SCIRun::Max( t1, tnear ), T_EPSILON );
+ tfar = SCIRun::Min( SCIRun::Min( t2, tfar ), e.hitInfo.minT() );
+ if ( tnear > tfar || tfar <= T_EPSILON || tnear >= e.hitInfo.minT() )
continue;
// A few preliminary early exit tests...
double near_value, far_value;
double near_deriv = Dot( functionGradient(
- ( offset_center + tnear * e.ray.direction()
) * inv_radius,
+ ( e.ray.origin() + tnear *
e.ray.direction() ),
near_value ),
e.ray.direction() );
double far_deriv = Dot( functionGradient(
- ( offset_center + tfar * e.ray.direction() )
* inv_radius,
+ ( e.ray.origin() + tfar * e.ray.direction()
),
far_value ),
e.ray.direction() );
if ( ( near_value < T_EPSILON && far_value < T_EPSILON ) ||
@@ -143,32 +125,28 @@
double a_bracket = tnear;
double b_bracket = tfar;
double left = GOLDENMEAN * a_bracket + ( 1. - GOLDENMEAN ) * b_bracket;
- double left_value = functionValue(
- ( offset_center + left * e.ray.direction() ) * inv_radius );
+ double left_value = functionValue( e.ray.origin() + left *
e.ray.direction() );
double right = ( 1. - GOLDENMEAN ) * a_bracket + GOLDENMEAN *
b_bracket;
- double right_value = functionValue(
- ( offset_center + right * e.ray.direction() ) * inv_radius );
+ double right_value = functionValue( e.ray.origin() + right *
e.ray.direction() );
while( fabs( b_bracket - a_bracket ) > BRACKETWIDTH ) {
if ( left_value < right_value ) {
b_bracket = right;
right = left;
right_value = left_value;
left = GOLDENMEAN * a_bracket + ( 1. - GOLDENMEAN ) * b_bracket;
- left_value = functionValue(
- ( offset_center + left * e.ray.direction() ) * inv_radius );
+ left_value = functionValue( e.ray.origin() + left *
e.ray.direction() );
} else {
a_bracket = left;
left = right;
left_value = right_value;
right = ( 1. - GOLDENMEAN ) * a_bracket + GOLDENMEAN * b_bracket;
- right_value = functionValue(
- ( offset_center + right * e.ray.direction() ) * inv_radius );
+ right_value = functionValue( e.ray.origin() + right *
e.ray.direction() );
}
}
// If our minimum is positive, we missed the superquadric - it
// couldn't have crossed zero.
- if ( right_value >= T_EPSILON )
+ if ( right_value >= -T_EPSILON )
continue;
// Narrow the range with the location of the minimum found
@@ -191,7 +169,7 @@
double troot = ( tnear + tfar ) * 0.5;
double root_value;
double root_deriv = Dot( logarithmFunctionGradient(
- ( offset_center + troot * e.ray.direction()
) * inv_radius,
+ e.ray.origin() + troot * e.ray.direction(),
root_value ),
e.ray.direction() );
int iterations = 0;
@@ -205,11 +183,11 @@
tnear = troot;
near_value = root_value;
}
- troot = troot - root_value / root_deriv;
+ troot -= root_value / root_deriv;
if ( troot <= tnear || troot >= tfar )
troot = ( tnear + tfar ) * 0.5;
root_deriv = Dot( logarithmFunctionGradient(
- ( offset_center + troot * e.ray.direction() ) *
inv_radius,
+ e.ray.origin() + troot * e.ray.direction(),
root_value ),
e.ray.direction() );
}
@@ -225,14 +203,14 @@
RenderContext const &,
RayPacket &rays ) const
{
- // FIXME: Calculate proper normal once intersection code works - sphere
- // normal close enough for now...
double ignored;
rays.computeHitPositions();
for( int i = 0; i < rays.getSize(); i++ ) {
RayPacket::Element &e( rays.get( i ) );
- e.normal = functionGradient( ( e.hitPosition - center ) * inv_radius,
ignored );
+ e.normal = functionGradient( e.hitPosition, ignored );
+ e.normal.normalize();
}
+ rays.setFlag(RayPacket::HaveNormals | RayPacket::HaveUnitNormals);
}
void SuperEllipsoid::computeTexCoords2(
@@ -242,13 +220,12 @@
rays.computeHitPositions();
for( int i = 0; i < rays.getSize(); i++ ) {
RayPacket::Element &e( rays.get( i ) );
- Vector n = ( e.hitPosition - center ) * inv_radius;
- double angle = Clamp( n.z(), -1.0, 1.0 );
+ double angle = Clamp( e.hitPosition.z(), -1.0, 1.0 );
double theta = acos( angle );
- double phi = atan2( n.x(), n.y() );
+ double phi = atan2( e.hitPosition.x(), e.hitPosition.y() );
e.texCoords = Point( ( phi + M_PI ) * ( 1. / ( 2 * M_PI ) ),
theta * ( 1. / M_PI ),
- 0 );
+ 0. );
}
rays.setFlag( RayPacket::HaveTexture2 | RayPacket::HaveTexture3 );
}
@@ -260,13 +237,12 @@
rays.computeHitPositions();
for( int i = 0; i < rays.getSize(); i++ ) {
RayPacket::Element &e = rays.get( i );
- Vector n = ( e.hitPosition - center ) * inv_radius;
- double angle = Clamp( n.z(), -1.0, 1.0 );
+ double angle = Clamp( e.hitPosition.z(), -1.0, 1.0 );
double theta = acos( angle );
- double phi = atan2( n.x(), n.y() );
+ double phi = atan2( e.hitPosition.x(), e.hitPosition.y() );
e.texCoords = Point( ( phi + M_PI ) * ( 1. / ( 2 * M_PI ) ),
theta * ( 1. / M_PI ),
- 0 );
+ 0. );
}
rays.setFlag( RayPacket::HaveTexture2 | RayPacket::HaveTexture3 );
}
Modified: branches/newpipeline/Model/Primitives/SuperEllipsoid.h
==============================================================================
--- branches/newpipeline/Model/Primitives/SuperEllipsoid.h (original)
+++ branches/newpipeline/Model/Primitives/SuperEllipsoid.h Wed Jul 20
13:21:52 2005
@@ -9,7 +9,7 @@
namespace Manta {
class SuperEllipsoid : public PrimitiveCommon, public TexCoordMapper {
public:
- SuperEllipsoid(Material* material, const Point& center, double radius,
double alpha, double beta);
+ SuperEllipsoid(Material* material, double alpha, double beta);
virtual ~SuperEllipsoid();
virtual void computeBounds(const PreprocessContext& context,
@@ -21,12 +21,9 @@
virtual void computeTexCoords3(const RenderContext& context,
RayPacket& rays) const;
private:
- double functionValue(const Vector& location) const;
- Vector const functionGradient(const Vector& location, double& value )
const;
- Vector const logarithmFunctionGradient(const Vector& location, double&
value ) const;
- Point center;
- double radius;
- double inv_radius;
+ double functionValue(const Point& location) const;
+ Vector const functionGradient(const Point& location, double& value )
const;
+ Vector const logarithmFunctionGradient(const Point& location, double&
value ) const;
double two_over_alpha;
double two_over_beta;
double alpha_over_beta;
Modified: branches/newpipeline/Model/Readers/PlyReader.cc
==============================================================================
--- branches/newpipeline/Model/Readers/PlyReader.cc (original)
+++ branches/newpipeline/Model/Readers/PlyReader.cc Wed Jul 20 13:21:52
2005
@@ -130,7 +130,7 @@
{
ostringstream msg;
msg << "An error occured while trying to load the following ply
file: " << fileName;
- throw SCIRun::FileNotFound(msg.str());
+ throw SCIRun::FileNotFound(msg.str(), __FILE__, __LINE__);
}
Modified: branches/newpipeline/Model/Readers/rply/rply.c
==============================================================================
--- branches/newpipeline/Model/Readers/rply/rply.c (original)
+++ branches/newpipeline/Model/Readers/rply/rply.c Wed Jul 20 13:21:52
2005
@@ -1055,14 +1055,14 @@
}
static int ibinary_int32(p_ply ply, double *value) {
- long int32;
+ int int32;
if (!ply->idriver->ichunk(ply, &int32, sizeof(int32))) return 0;
*value = int32;
return 1;
}
static int ibinary_uint32(p_ply ply, double *value) {
- unsigned long uint32;
+ unsigned int uint32;
if (!ply->idriver->ichunk(ply, &uint32, sizeof(uint32))) return 0;
*value = uint32;
return 1;
Modified: branches/newpipeline/Model/Textures/ImageTexture.cc
==============================================================================
--- branches/newpipeline/Model/Textures/ImageTexture.cc (original)
+++ branches/newpipeline/Model/Textures/ImageTexture.cc Wed Jul 20 13:21:52
2005
@@ -82,7 +82,8 @@
y - bottom );
}
} else {
- throw SCIRun::InternalError( "Unknown image type in ImageTexture" );
+ throw SCIRun::InternalError("Unknown image type in ImageTexture",
+ __FILE__, __LINE__);
}
}
Modified: branches/newpipeline/StandAlone/manta.cc
==============================================================================
--- branches/newpipeline/StandAlone/manta.cc (original)
+++ branches/newpipeline/StandAlone/manta.cc Wed Jul 20 13:21:52 2005
@@ -124,7 +124,7 @@
Pipeline* pipeline = createDefaultPipeline();
if(!rtrt->selectImageType("rgba8"))
- throw InternalError("default image not found");
+ throw InternalError("default image not found", __FILE__, __LINE__);
int xres = 512, yres = 512;
bool channelCreated=false;
bool haveUI = false;
@@ -384,19 +384,21 @@
{
PipelineComponent* it = factory->createPipelineComponent("tiled");
if(!it)
- throw InternalError("default image traverser not found");
+ throw InternalError("default image traverser not found",
+ __FILE__, __LINE__);
RenderParameters* rp = new RenderParameters;
if(!(rp->loadBalancer = factory->createLoadBalancer("workqueue")))
- throw InternalError("default load balancer not found");
+ throw InternalError("default load balancer not found", __FILE__,
__LINE__);
if(!(rp->pixelSampler = factory->createPixelSampler("singlesample")))
- throw InternalError("default pixel sampler not found");
+ throw InternalError("default pixel sampler not found", __FILE__,
__LINE__);
if(!(rp->renderer = factory->createRenderer("raytracer")))
- throw InternalError("default renderer not found");
+ throw InternalError("default renderer not found", __FILE__, __LINE__);
if(!(rp->shadowAlgorithm = factory->createShadowAlgorithm("hard")))
- throw InternalError("default shadow algorithm not found");
+ throw InternalError("default shadow algorithm not found",
+ __FILE__, __LINE__);
if(!(rp->camera = factory->createCamera("pinhole(-eye 3 3 2 -lookat 0 0
0.3 -up 0 0 1 -fov 60)")))
- throw InternalError("default camera not found");
+ throw InternalError("default camera not found", __FILE__, __LINE__);
PipelineParameters* pp = new PipelineParameters();
Modified: branches/newpipeline/SwigInterface/CMakeLists.txt
==============================================================================
--- branches/newpipeline/SwigInterface/CMakeLists.txt (original)
+++ branches/newpipeline/SwigInterface/CMakeLists.txt Wed Jul 20 13:21:52
2005
@@ -20,7 +20,7 @@
SET_SOURCE_FILES_PROPERTIES(manta.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(manta.i PROPERTIES SWIG_FLAGS "`echo \"\"`")
-SWIG_ADD_MODULE(manta python manta.i manta.cc)
+SWIG_ADD_MODULE(manta python manta.i manta.cc manta.h)
SWIG_LINK_LIBRARIES(manta
${PYTHON_LIBRARIES}
Modified: branches/newpipeline/SwigInterface/manta.i
==============================================================================
--- branches/newpipeline/SwigInterface/manta.i (original)
+++ branches/newpipeline/SwigInterface/manta.i Wed Jul 20 13:21:52 2005
@@ -56,6 +56,9 @@
#include <Interface/UserInterface.h>
#include <Interface/RenderParameters.h>
#include <Interface/Scene.h>
+#include <Interface/Callback.h>
+#include <Interface/CallbackHelpers.h>
+#include <SwigInterface/manta.h>
%}
namespace std {
@@ -72,6 +75,9 @@
%include <Interface/Transaction.h>
%include <Interface/TValue.h>
+%include <Interface/RTRTInterface.h>
+%include <SwigInterface/manta.h>
+
namespace Manta {
using namespace std;
@@ -81,8 +87,6 @@
}
extern Manta::Scene* createDefaultScene();
-
-%include <Interface/RTRTInterface.h>
%exception;
Modified: branches/newpipeline/UserInterface/XWindowUI.cc
==============================================================================
--- branches/newpipeline/UserInterface/XWindowUI.cc (original)
+++ branches/newpipeline/UserInterface/XWindowUI.cc Wed Jul 20 13:21:52
2005
@@ -80,13 +80,13 @@
// Open the display and setup file descriptors for threads
if(pipe(xpipe) == -1){
- throw ErrnoException("XWindowUI pipe", errno);
+ throw ErrnoException("XWindowUI pipe", errno, __FILE__, __LINE__);
}
dpy = XOpenDisplay(NULL);
if(!dpy)
- throw InternalError("XOpenDisplay failed");
+ throw InternalError("XOpenDisplay failed", __FILE__, __LINE__);
if(XAddConnectionWatch(dpy, connection_watch,
reinterpret_cast<XPointer>(this)) == 0)
- throw InternalError("XAddConnectionWatch failed");
+ throw InternalError("XAddConnectionWatch failed", __FILE__, __LINE__);
if(xfds.size() == 0){
// XAddConnectionWatch must be broken. To fix it, we look at the
@@ -94,7 +94,7 @@
// file descriptors are between the two.
int tmp_pipe[2];
if(pipe(tmp_pipe) == -1)
- throw ErrnoException("XWindowUI pipe2", errno);
+ throw ErrnoException("XWindowUI pipe2", errno, __FILE__, __LINE__);
for(int i=xpipe[1]+1; i<tmp_pipe[0];i++)
addConnection(i);
}
@@ -174,14 +174,14 @@
}
int s = select(max+1, &readfds, 0, 0, 0);
if(s == -1)
- throw ErrnoException("XWindowUI select", errno);
+ throw ErrnoException("XWindowUI select", errno, __FILE__, __LINE__);
if(FD_ISSET(xpipe[0], &readfds)){
// Process the pipe...
int token;
ssize_t s = read(xpipe[0], &token, sizeof(token));
if(s != sizeof(token))
- throw ErrnoException("XWindowUI read pipe", errno);
+ throw ErrnoException("XWindowUI read pipe", errno, __FILE__,
__LINE__);
switch(token){
case TOKEN_NOOP:
break;
@@ -191,7 +191,8 @@
xlock.lock();
break;
default:
- throw InternalError("XWindowUI::Unknown token in pipe");
+ throw InternalError("XWindowUI::Unknown token in pipe",
+ __FILE__, __LINE__);
}
}
bool have_some = false;
@@ -226,7 +227,7 @@
int token = TOKEN_LOCK;
ssize_t s = write(xpipe[1], &token, sizeof(int));
if(s != sizeof(int)){
- throw ErrnoException("XWindowUI write 3", errno);
+ throw ErrnoException("XWindowUI write 3", errno, __FILE__, __LINE__);
}
xlock.lock();
}
@@ -253,8 +254,12 @@
XTextProperty tp;
ostringstream title;
title << "Manta ray tracer (channel " << channel << ")";
- char* name = const_cast<char*>(title.str().c_str());
+ // This used to be a const_cast<char*>(title...), but it somehow
+ // data in name pointed to was corrupted.
+ char* name = strdup(title.str().c_str());
XStringListToTextProperty(&name, 1, &tp);
+ free(name);
+
XSizeHints sh;
sh.flags = USPosition|USSize;
@@ -277,12 +282,13 @@
{
cerr << description << ": " << (void*)key << '\n';
if(key == 0)
- throw InternalError("tried to register invalid key: "+description);
+ throw InternalError("tried to register invalid key: "+description,
+ __FILE__, __LINE__);
for(vector<KeyTab>::iterator iter = keys.begin();
iter != keys.end(); iter++){
if(key == iter->key && state == iter->state)
- throw InternalError("Two functions mapped to the same key:
"+description+" and "+iter->description);
+ throw InternalError("Two functions mapped to the same key:
"+description+" and "+iter->description, __FILE__, __LINE__);
}
KeyTab entry;
entry.key = key;
@@ -301,7 +307,7 @@
for(vector<MouseTab>::iterator iter = mouse.begin();
iter != mouse.end(); iter++){
if(button == iter->button && state == iter->state)
- throw InternalError("Two functions mapped to the same mouse button:
"+description+" and "+iter->description);
+ throw InternalError("Two functions mapped to the same mouse button:
"+description+" and "+iter->description, __FILE__, __LINE__);
}
MouseTab entry;
entry.state = state;
Modified: branches/newpipeline/scenes/primtest.cc
==============================================================================
--- branches/newpipeline/scenes/primtest.cc (original)
+++ branches/newpipeline/scenes/primtest.cc Wed Jul 20 13:21:52 2005
@@ -174,8 +174,8 @@
for(int j=0;j<numy;j++){
int idx = j*numx+i;
double radius = (idx+1)/static_cast<double>(numx*numy)*scale/max;
- Point p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ Point p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 : 0.)*scale*2,
+ (numy>1 ? j/static_cast<double>(numy-1) - 0.5 : 0.)*scale*2,
0);
Primitive* prim = new Sphere( matl, p, radius );
if ( mapr )
@@ -183,28 +183,12 @@
group->add( prim );
}
}
- } else if (primtype == "simplesuperellipsoid"){
- for(int i=0;i<numx;i++){
- for(int j=0;j<numy;j++){
- int idx = j*numx+i;
- double radius = (idx+1)/static_cast<double>(numx*numy)*scale/max;
- double alpha = (i+1)/static_cast<double>(numx)*2.;
- double beta = (j+1)/static_cast<double>(numy)*2.;
- Point p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
- 0);
- Primitive* prim = new SuperEllipsoid( matl, p, radius, alpha, beta );
- if ( mapr )
- prim->setTexCoordMapper( mapr );
- group->add( prim );
- }
- }
} else if(primtype == "simplebox"){
Vector p2(scale/max, scale/max, scale/max);
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Point p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ Point p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 : 0.)*scale*2,
+ (numy>1 ? j/static_cast<double>(numy-1) - 0.5 : 0.)*scale*2,
0);
Primitive* prim = new Cube( matl, p-p2, p2.x()*1.156, p2.y()*1.156,
p2.z()*1.156 );
if ( mapr )
@@ -253,6 +237,11 @@
if ( mapr )
prim->setTexCoordMapper( mapr );
spinprim = prim;
+ } else if (primtype == "superellipsoid"){
+ Primitive* prim = new SuperEllipsoid(matl, 0.5, 1.5);
+ if ( mapr )
+ prim->setTexCoordMapper( mapr );
+ spinprim = prim;
} else if(primtype == "ply"){
AffineTransform t;
t.initWithScale(Vector(scale/max*30, scale/max*30, scale/max*30));
@@ -273,11 +262,11 @@
if(arraytype == "spin"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
+ (numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
0);
- double a1 = i/static_cast<double>(numx-1)*M_PI*2;
- double a2 = j/static_cast<double>(numy-1)*M_PI*2;
+ double a1 = i/static_cast<double>(numx)*M_PI*2;
+ double a2 = j/static_cast<double>(numy)*M_PI*2;
AffineTransform t;
t.initWithIdentity();
t.rotate(Vector(0,1,0), a1);
@@ -289,8 +278,8 @@
} else if(arraytype == "shift"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
+ (numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
0);
group->add(new InstanceT(spinprim, p));
}
@@ -298,8 +287,8 @@
} else if(arraytype == "scale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
+ (numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
0);
int idx = j*numx+i;
double scale = (idx+1)/static_cast<double>(numx*numy);
@@ -309,8 +298,8 @@
} else if(arraytype == "nuscale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
+ (numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
0);
double xscale = (i+1)/static_cast<double>(numx);
double yscale = (j+1)/static_cast<double>(numy);
@@ -320,11 +309,11 @@
} else if(arraytype == "spinscale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
+ (numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
0);
- double a1 = i/static_cast<double>(numx-1)*M_PI*2;
- double a2 = j/static_cast<double>(numy-1)*M_PI*2;
+ double a1 = i/static_cast<double>(numx)*M_PI*2;
+ double a2 = j/static_cast<double>(numy)*M_PI*2;
int idx = j*numx+i;
double scale = (idx+1)/static_cast<double>(numx*numy);
AffineTransform t;
@@ -339,11 +328,11 @@
} else if(arraytype == "spinscale2"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
- (j/static_cast<double>(numy-1) - 0.5)*scale*2,
+ Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
+ (numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
0);
- double a1 = i/static_cast<double>(numx-1)*M_PI*2;
- double a2 = j/static_cast<double>(numy-1)*M_PI*2;
+ double a1 = i/static_cast<double>(numx)*M_PI*2;
+ double a2 = j/static_cast<double>(numy)*M_PI*2;
int idx = j*numx+i;
double scale = (idx+1)/static_cast<double>(numx*numy);
AffineTransform t;
- [MANTA] r434 - in branches/newpipeline: Engine/Display Engine/IdleModes Engine/ImageTraversers Image Interface Model/Groups Model/MiscObjects Model/Primitives Model/Readers Model/Readers/rply Model/Textures StandAlone SwigInterface UserInterface scenes, bigler, 07/20/2005
Archive powered by MHonArc 2.6.16.