Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r939 - in trunk: . Core Core/Geometry Core/Math Core/Util Engine/Shadows Interface Model/AmbientLights Model/Backgrounds Model/Cameras Model/Groups Model/Instances Model/Intersections Model/Lights Model/Materials Model/MiscObjects Model/Primitives Model/Readers Model/Readers/BART Model/TexCoordMappers Model/Textures StandAlone SwigInterface UserInterface fox/FManta fox/afr_demo/Engine/ImageTraversers fox/afr_demo/Model/Cameras fox/afr_demo/StandAlone fox/disco_demo/Engine/Renderers fox/disco_demo/Engine/Shaders fox/disco_demo/Interface fox/dm_demo fox/sc_demo scenes tests/perftest
- Date: Thu, 16 Feb 2006 17:08:34 -0700 (MST)
Author: bigler
Date: Thu Feb 16 17:08:22 2006
New Revision: 939
Added:
trunk/Core/Geometry/AffineTransformT.cc
- copied, changed from r885, trunk/Core/Geometry/AffineTransform.cc
trunk/Core/Geometry/AffineTransformT.h
- copied, changed from r885, trunk/Core/Geometry/AffineTransform.h
trunk/Core/Geometry/Vector.cc
- copied, changed from r885, trunk/Core/Geometry/PointVector.cc
trunk/Core/Geometry/Vector.h
- copied, changed from r885, trunk/Core/Geometry/PointVector.h
trunk/Core/Geometry/VectorT.cc
- copied, changed from r885, trunk/Core/Geometry/PointVector.cc
trunk/Core/Geometry/VectorT.h
- copied, changed from r885, trunk/Core/Geometry/PointVector.h
Removed:
trunk/Core/Geometry/PointVector.cc
trunk/Core/Geometry/PointVector.h
Modified:
trunk/Core/CMakeLists.txt
trunk/Core/Geometry/AffineTransform.cc
trunk/Core/Geometry/AffineTransform.h
trunk/Core/Geometry/BBox.h
trunk/Core/Geometry/Ray.h
trunk/Core/Math/HaltonSequence.h
trunk/Core/Math/Noise.cc
trunk/Core/Math/Noise.h
trunk/Core/Math/vector2d.h
trunk/Core/Util/Args.cc
trunk/Core/Util/Args.h
trunk/Engine/Shadows/BeamShadows.cc
trunk/Interface/Camera.h
trunk/Interface/Light.h
trunk/Interface/Material.h
trunk/Interface/RayPacket.h
trunk/MantaTypes.h.CMakeTemplate
trunk/Model/AmbientLights/ArcAmbient.h
trunk/Model/Backgrounds/LinearBackground.h
trunk/Model/Backgrounds/TextureBackground.cc
trunk/Model/Backgrounds/TextureBackground.h
trunk/Model/Cameras/EnvironmentCamera.cc
trunk/Model/Cameras/EnvironmentCamera.h
trunk/Model/Cameras/FisheyeCamera.cc
trunk/Model/Cameras/FisheyeCamera.h
trunk/Model/Cameras/OrthogonalCamera.cc
trunk/Model/Cameras/OrthogonalCamera.h
trunk/Model/Cameras/PinholeCamera.cc
trunk/Model/Cameras/PinholeCamera.h
trunk/Model/Groups/BVH.cc
trunk/Model/Groups/BVH.h
trunk/Model/Groups/FrustumKDTree.cc
trunk/Model/Groups/FrustumKDTree.h
trunk/Model/Groups/GriddedGroup.cc
trunk/Model/Groups/GriddedGroup.h
trunk/Model/Groups/KDTree.cc
trunk/Model/Groups/KDTree.h
trunk/Model/Groups/KDTreeLoader.cc
trunk/Model/Groups/RealisticBvh.cc
trunk/Model/Groups/SSEKDTree.cc
trunk/Model/Groups/SSEKDTree.h
trunk/Model/Groups/TransparentKDTree.cc
trunk/Model/Groups/TransparentKDTree.h
trunk/Model/Groups/VerticalKDTree.cc
trunk/Model/Groups/VerticalKDTree.h
trunk/Model/Groups/VolumeGrid.h
trunk/Model/Instances/Instance.cc
trunk/Model/Instances/InstanceRST.cc
trunk/Model/Instances/InstanceRT.cc
trunk/Model/Instances/InstanceST.cc
trunk/Model/Instances/InstanceST.h
trunk/Model/Instances/InstanceT.cc
trunk/Model/Instances/InstanceT.h
trunk/Model/Intersections/Plane.h
trunk/Model/Intersections/TriangleEdge.h
trunk/Model/Lights/HeadLight.cc
trunk/Model/Lights/HeadLight.h
trunk/Model/Lights/PointLight.cc
trunk/Model/Lights/PointLight.h
trunk/Model/Materials/AmbientOcclusion.h
trunk/Model/Materials/Checker.h
trunk/Model/Materials/Dielectric.cc
trunk/Model/MiscObjects/CuttingPlane.cc
trunk/Model/MiscObjects/CuttingPlane.h
trunk/Model/Primitives/BvhTriangleMesh.cc
trunk/Model/Primitives/BvhTriangleMesh.h
trunk/Model/Primitives/CMakeLists.txt
trunk/Model/Primitives/Cone.cc
trunk/Model/Primitives/Cone.h
trunk/Model/Primitives/Cube.cc
trunk/Model/Primitives/Cube.h
trunk/Model/Primitives/Cylinder.cc
trunk/Model/Primitives/Cylinder.h
trunk/Model/Primitives/Disk.cc
trunk/Model/Primitives/Disk.h
trunk/Model/Primitives/HeavyTriangle.cc
trunk/Model/Primitives/HeavyTriangle.h
trunk/Model/Primitives/Heightfield.cc
trunk/Model/Primitives/Heightfield.h
trunk/Model/Primitives/Hemisphere.cc
trunk/Model/Primitives/Hemisphere.h
trunk/Model/Primitives/Parallelogram.cc
trunk/Model/Primitives/Parallelogram.h
trunk/Model/Primitives/ParticleBVH.cc
trunk/Model/Primitives/ParticleBVH.h
trunk/Model/Primitives/Plane.cc
trunk/Model/Primitives/Plane.h
trunk/Model/Primitives/Ring.cc
trunk/Model/Primitives/Ring.h
trunk/Model/Primitives/Sphere.cc
trunk/Model/Primitives/Sphere.h
trunk/Model/Primitives/SuperEllipsoid.cc
trunk/Model/Primitives/SuperEllipsoid.h
trunk/Model/Primitives/TexTriangle.cc
trunk/Model/Primitives/TexTriangle.h
trunk/Model/Primitives/Triangle.cc
trunk/Model/Primitives/Triangle.h
trunk/Model/Primitives/VertexColoredTriangle.cc
trunk/Model/Primitives/VertexColoredTriangle.h
trunk/Model/Readers/BART/parse.cc
trunk/Model/Readers/ObjReader.cc
trunk/Model/Readers/ObjReader.h
trunk/Model/Readers/PlyReader.cc
trunk/Model/Readers/PlyReader.h
trunk/Model/TexCoordMappers/LinearMapper.cc
trunk/Model/TexCoordMappers/LinearMapper.h
trunk/Model/TexCoordMappers/SphericalMapper.cc
trunk/Model/TexCoordMappers/SphericalMapper.h
trunk/Model/Textures/CheckerTexture.h
trunk/Model/Textures/ImageTexture.cc
trunk/Model/Textures/ImageTexture.h
trunk/Model/Textures/MarbleTexture.h
trunk/Model/Textures/OakTexture.h
trunk/Model/Textures/TexCoordTexture.cc
trunk/Model/Textures/TexCoordTexture.h
trunk/Model/Textures/TriVerTexture.cc
trunk/Model/Textures/WoodTexture.h
trunk/StandAlone/frust-test.cc
trunk/StandAlone/manta.cc
trunk/StandAlone/v3c1_tools.cc
trunk/SwigInterface/manta.cc
trunk/SwigInterface/manta.i
trunk/UserInterface/CameraPathAutomator.cc
trunk/UserInterface/CameraPathAutomator.h
trunk/UserInterface/XWindowUI.cc
trunk/UserInterface/XWindowUI.h
trunk/fox/FManta/FMantaImageFrame.cc
trunk/fox/FManta/FMantaImageFrame.h
trunk/fox/FManta/FMantaKdExplorer.cc
trunk/fox/FManta/FMantaNavigator.h
trunk/fox/FManta/FMantaQuakeNav.cc
trunk/fox/FManta/FMantaQuakeNav.h
trunk/fox/FManta/FMantaRecorder.cc
trunk/fox/FManta/FMantaRecorder.h
trunk/fox/FManta/FMantaTrackballNav.cc
trunk/fox/FManta/FMantaTrackballNav.h
trunk/fox/FManta/FMantaUniformNav.h
trunk/fox/FManta/FMantaWindow.cc
trunk/fox/FManta/FMantaWindow.h
trunk/fox/afr_demo/Engine/ImageTraversers/AFImageTraverser.cc
trunk/fox/afr_demo/Engine/ImageTraversers/AFRImageTraverser.cc
trunk/fox/afr_demo/Engine/ImageTraversers/EGSRImageTraverser.cc
trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverser.cc
trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserNew.cc
trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserSTPlane.cc
trunk/fox/afr_demo/Engine/ImageTraversers/STAFRImageTraverser.cc
trunk/fox/afr_demo/Model/Cameras/AFRCamera.h
trunk/fox/afr_demo/Model/Cameras/AFRPinholeCamera.cc
trunk/fox/afr_demo/Model/Cameras/AFRPinholeCamera.h
trunk/fox/afr_demo/StandAlone/afr.cc
trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
trunk/fox/disco_demo/Engine/Shaders/AOShader.cc
trunk/fox/disco_demo/Interface/DiscoTile.h
trunk/fox/disco_demo/Interface/TilePacket.h
trunk/fox/dm_demo/dm_demo.cc
trunk/fox/sc_demo/sc_demo.cc
trunk/scenes/0.cc
trunk/scenes/ParticleBVHTest.cc
trunk/scenes/acceltest.cc
trunk/scenes/boeing777.cc
trunk/scenes/cube.cc
trunk/scenes/objviewer.cc
trunk/scenes/primtest.cc
trunk/scenes/volume.cc
trunk/tests/perftest/perftest1.cc
Log:
Hoo Doggie! Points are no more. Use Vector for any 3 component
vector. Vector is now no longer a typedef to a templated class, but
hard coded to 3 Real components. The templated version exists as
VectorT.
Core/CMakeLists.txt
Group all the Geometry files. Added AffineTransformT.
Core/Geometry/AffineTransform.cc
Core/Geometry/AffineTransform.h
Non templated version of type Real.
operator*(Vector) -> multiply_vector(Vector)
operator*(Point) -> multiply_point(Vector)
transpose_mult(Vector) -> transpose_mult_vector(Vector)
transpose_mult(Point) -> transpose_mult_point(Vector)
Core/Geometry/AffineTransformT.cc
Core/Geometry/AffineTransformT.h
Basically the old AffineTransform.
operator*(Vector) -> multiply_vector(Vector)
operator*(Point) -> multiply_point(Vector)
transpose_mult(Vector) -> transpose_mult_vector(Vector)
transpose_mult(Point) -> transpose_mult_point(Vector)
Core/Geometry/PointVector.cc
Core/Geometry/PointVector.h
Removed. Used either Vector or VectorT<Type, Dim>.
Core/Geometry/Vector.cc
Core/Geometry/Vector.h
No Point class. No longer templated. Replaced calls to member
functions with hand inlined code to help compliler.
Core/Geometry/VectorT.cc
Core/Geometry/VectorT.h
No Point class. Replaced calls to member functions with hand inlined
code to help compliler.
Core/Math/Noise.cc
Core/Math/Noise.h
Point -> Vector. double -> Real. float compatibility.
Core/Util/Args.cc
Core/Util/Args.h
Removed getPointArg().
Interface/Material.h
Removed include of PointVector.h
MantaTypes.h.CMakeTemplate
Removed typedefs for Point, Vector, and AffineTransform. Use the
classes directly.
Core/Geometry/BBox.h
Core/Geometry/Ray.h
Core/Math/HaltonSequence.h
Core/Math/vector2d.h
Engine/Shadows/BeamShadows.cc
Interface/Camera.h
Interface/Light.h
Interface/RayPacket.h
Model/AmbientLights/ArcAmbient.h
Model/Backgrounds/LinearBackground.h
Model/Backgrounds/TextureBackground.cc
Model/Backgrounds/TextureBackground.h
Point -> Vector.
PointVector.h -> Vector.h
Model/Cameras/EnvironmentCamera.cc
Model/Cameras/EnvironmentCamera.h
Model/Cameras/FisheyeCamera.cc
Model/Cameras/FisheyeCamera.h
Model/Cameras/OrthogonalCamera.cc
Model/Cameras/OrthogonalCamera.h
Model/Cameras/PinholeCamera.cc
Model/Cameras/PinholeCamera.h
Point -> Vector.
PointVector.h -> Vector.h
Moved constructors and reset() to .cc files.
Model/Groups/BVH.cc
Model/Groups/BVH.h
Model/Groups/FrustumKDTree.cc
Model/Groups/FrustumKDTree.h
Model/Groups/GriddedGroup.cc
Model/Groups/GriddedGroup.h
Model/Groups/KDTree.cc
Model/Groups/KDTree.h
Model/Groups/KDTreeLoader.cc
Model/Groups/RealisticBvh.cc
Model/Groups/SSEKDTree.cc
Model/Groups/SSEKDTree.h
Model/Groups/TransparentKDTree.cc
Model/Groups/TransparentKDTree.h
Model/Groups/VerticalKDTree.cc
Model/Groups/VerticalKDTree.h
Model/Groups/VolumeGrid.h
Model/Instances/Instance.cc
Model/Instances/InstanceRST.cc
Model/Instances/InstanceRT.cc
Model/Instances/InstanceST.cc
Model/Instances/InstanceST.h
Model/Instances/InstanceT.cc
Model/Instances/InstanceT.h
Model/Intersections/Plane.h
Model/Intersections/TriangleEdge.h
Model/Lights/HeadLight.cc
Model/Lights/HeadLight.h
Model/Lights/PointLight.cc
Model/Lights/PointLight.h
Model/Materials/AmbientOcclusion.h
Model/Materials/Checker.h
Model/Materials/Dielectric.cc
Model/MiscObjects/CuttingPlane.cc
Model/MiscObjects/CuttingPlane.h
Model/Primitives/BvhTriangleMesh.cc
Model/Primitives/BvhTriangleMesh.h
Point -> Vector.
PointVector.h -> Vector.h
Misc. float fixes.
Model/Primitives/CMakeLists.txt
Added Cylinder.{cc,h} commented out, so that you will know that
Cylinder isn't finished being implemented.
Model/Primitives/Cone.cc
Model/Primitives/Cone.h
Model/Primitives/Cube.cc
Model/Primitives/Cube.h
Model/Primitives/Cylinder.cc - throw exception in constructor
Model/Primitives/Cylinder.h
Model/Primitives/Disk.cc
Model/Primitives/Disk.h
Model/Primitives/HeavyTriangle.cc
Model/Primitives/HeavyTriangle.h - constructors -> .cc
Model/Primitives/Heightfield.cc
Model/Primitives/Heightfield.h
Model/Primitives/Hemisphere.cc
Model/Primitives/Hemisphere.h
Model/Primitives/Parallelogram.cc
Model/Primitives/Parallelogram.h
Model/Primitives/ParticleBVH.cc
Model/Primitives/ParticleBVH.h - double -> Real
Model/Primitives/Plane.cc
Model/Primitives/Plane.h
Model/Primitives/Ring.cc
Model/Primitives/Ring.h
Model/Primitives/Sphere.cc
Model/Primitives/Sphere.h
Model/Primitives/SuperEllipsoid.cc
Model/Primitives/SuperEllipsoid.h
Model/Primitives/TexTriangle.cc
Model/Primitives/TexTriangle.h - constructors -> .cc file
Model/Primitives/Triangle.cc
Model/Primitives/Triangle.h
Model/Primitives/VertexColoredTriangle.cc
Model/Primitives/VertexColoredTriangle.h
Model/Readers/BART/parse.cc
Model/Readers/ObjReader.cc
Model/Readers/ObjReader.h
Model/Readers/PlyReader.cc
Model/Readers/PlyReader.h
Model/TexCoordMappers/LinearMapper.cc
Model/TexCoordMappers/LinearMapper.h
Model/TexCoordMappers/SphericalMapper.cc
Model/TexCoordMappers/SphericalMapper.h
Model/Textures/CheckerTexture.h
Model/Textures/ImageTexture.cc
Model/Textures/ImageTexture.h
Model/Textures/MarbleTexture.h
Model/Textures/OakTexture.h double -> Real
Model/Textures/TexCoordTexture.cc
Model/Textures/TexCoordTexture.h
Model/Textures/TriVerTexture.cc
Model/Textures/WoodTexture.h double -> Real
StandAlone/frust-test.cc
StandAlone/manta.cc
StandAlone/v3c1_tools.cc
SwigInterface/manta.cc
Point -> Vector
PointVector.h -> Vector.h
SwigInterface/manta.i
PointVector.h -> Vector.h and VectorT.h
Removed Point and Vector templates. Added VectorT_Real3 template.
UserInterface/CameraPathAutomator.cc
UserInterface/CameraPathAutomator.h
UserInterface/XWindowUI.cc
UserInterface/XWindowUI.h
fox/FManta/FMantaImageFrame.cc
fox/FManta/FMantaImageFrame.h
fox/FManta/FMantaKdExplorer.cc
fox/FManta/FMantaNavigator.h
fox/FManta/FMantaQuakeNav.cc
fox/FManta/FMantaQuakeNav.h
fox/FManta/FMantaRecorder.cc
fox/FManta/FMantaRecorder.h
fox/FManta/FMantaTrackballNav.cc
fox/FManta/FMantaTrackballNav.h
fox/FManta/FMantaUniformNav.h
fox/FManta/FMantaWindow.cc
fox/FManta/FMantaWindow.h
fox/afr_demo/Engine/ImageTraversers/AFImageTraverser.cc
fox/afr_demo/Engine/ImageTraversers/AFRImageTraverser.cc
fox/afr_demo/Engine/ImageTraversers/EGSRImageTraverser.cc
fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverser.cc
fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserNew.cc
fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserSTPlane.cc
fox/afr_demo/Engine/ImageTraversers/STAFRImageTraverser.cc
fox/afr_demo/Model/Cameras/AFRCamera.h
fox/afr_demo/Model/Cameras/AFRPinholeCamera.cc - float friendlyness
fox/afr_demo/Model/Cameras/AFRPinholeCamera.h
fox/afr_demo/StandAlone/afr.cc
fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
fox/disco_demo/Engine/Shaders/AOShader.cc
fox/disco_demo/Interface/DiscoTile.h
fox/disco_demo/Interface/TilePacket.h
fox/dm_demo/dm_demo.cc
fox/sc_demo/sc_demo.cc
scenes/0.cc
scenes/ParticleBVHTest.cc
scenes/acceltest.cc
scenes/boeing777.cc
scenes/cube.cc
scenes/objviewer.cc
scenes/primtest.cc
scenes/volume.cc
tests/perftest/perftest1.cc
Point -> Vector
PointVector.h -> Vector.h
Modified: trunk/Core/CMakeLists.txt
==============================================================================
--- trunk/Core/CMakeLists.txt (original)
+++ trunk/Core/CMakeLists.txt Thu Feb 16 17:08:22 2006
@@ -8,12 +8,6 @@
Color/RGBColor.cc
Color/GrayColor.cc)
SET (CORE_SOURCES ${CORE_SOURCES}
- Geometry/Ray.h
- Geometry/PointVector.h
- Geometry/PointVector.cc
- Geometry/BBox.h
- )
-SET (CORE_SOURCES ${CORE_SOURCES}
Exceptions/BadPrimitive.h
Exceptions/BadPrimitive.cc
Exceptions/IllegalArgument.h
@@ -28,6 +22,18 @@
Exceptions/OutputError.cc
)
SET (CORE_SOURCES ${CORE_SOURCES}
+ Geometry/AffineTransform.h
+ Geometry/AffineTransform.cc
+ Geometry/AffineTransformT.h
+ Geometry/AffineTransformT.cc
+ Geometry/BBox.h
+ Geometry/Ray.h
+ Geometry/Vector.cc
+ Geometry/Vector.h
+ Geometry/VectorT.cc
+ Geometry/VectorT.h
+ )
+SET (CORE_SOURCES ${CORE_SOURCES}
Math/HaltonSequence.cc
Math/HaltonSequence.h
Math/MT_RNG.h
@@ -43,10 +49,6 @@
Util/Endian.h
Util/ThreadStorage.h
Util/ThreadStorage.cc)
-SET (CORE_SOURCES ${CORE_SOURCES}
- Geometry/AffineTransform.h
- Geometry/AffineTransform.cc
- )
ADD_LIBRARY (Manta_Core ${CORE_SOURCES})
Modified: trunk/Core/Geometry/AffineTransform.cc
==============================================================================
--- trunk/Core/Geometry/AffineTransform.cc (original)
+++ trunk/Core/Geometry/AffineTransform.cc Thu Feb 16 17:08:22 2006
@@ -1,3 +1,30 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005-2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
#include <MantaTypes.h>
#include <Core/Geometry/AffineTransform.h>
@@ -9,8 +36,7 @@
// TODO: several of these could be faster if they become bottlenecks
namespace Manta {
- template<typename T>
- void AffineTransformT<T>::initWithIdentity()
+ void AffineTransform::initWithIdentity()
{
for(int row = 0; row < 3; row++){
for(int col = 0; col < 4; col++)
@@ -19,45 +45,40 @@
}
}
- template<typename T>
- void AffineTransformT<T>::initWithScale(const VectorT<T, 3>& s)
+ void AffineTransform::initWithScale(const Vector& s)
{
initWithIdentity();
scale(s);
}
- template<typename T>
- void AffineTransformT<T>::initWithRotation(const VectorT<T, 3>& from,
- const VectorT<T, 3>& to)
+ void AffineTransform::initWithRotation(const Vector& from,
+ const Vector& to)
{
initWithIdentity();
rotate(from, to);
}
- template<typename T>
- void AffineTransformT<T>::initWithRotation(const VectorT<T, 3>& axis,
- T angleInRadians)
+ void AffineTransform::initWithRotation(const Vector& axis,
+ Real angleInRadians)
{
initWithIdentity();
rotate(axis, angleInRadians);
}
- template<typename T>
- void AffineTransformT<T>::initWithTranslation(const VectorT<T, 3>&
translation)
+ void AffineTransform::initWithTranslation(const Vector& translation)
{
initWithIdentity();
translate(translation);
}
/**
- * Each vector becomes a column in the resulting matrix, with the
+ * Each vector becomes a column in the resulting matrix, with the
* point in the last column
*/
- template<typename T>
- void AffineTransformT<T>::initWithBasis(const VectorT<T, 3>& v1,
- const VectorT<T, 3>& v2,
- const VectorT<T, 3>& v3,
- const PointT<T, 3>& p)
+ void AffineTransform::initWithBasis(const Vector& v1,
+ const Vector& v2,
+ const Vector& v3,
+ const Vector& p)
{
for(int i=0;i<3;i++)
mat[i][0] = v1[i];
@@ -69,45 +90,43 @@
mat[i][3] = p[i];
}
- template<typename T>
- void AffineTransformT<T>::scale(const VectorT<T, 3>& scale)
+ void AffineTransform::scale(const Vector& scale)
{
for(int row = 0; row < 3; row++){
- T s = scale[row];
+ Real s = scale[row];
for(int col = 0; col <= 3; col++)
mat[row][col] *= s;
}
}
- template<typename T>
- void AffineTransformT<T>::rotate(const VectorT<T, 3>& from_,
- const VectorT<T, 3>& to_)
+ void AffineTransform::rotate(const Vector& from_,
+ const Vector& to_)
{
// Modified from Moller/Hughes, Journal of Graphics Tools Vol. 4, No. 4
// "Efficiently Building a Matrix to Rotate One Vector to Another"
-
+
// Don't assume that to and from are normalized.
- VectorT<T,3> from = from_.normal();
- VectorT<T,3> to = to_.normal();
+ Vector from = from_.normal();
+ Vector to = to_.normal();
- VectorT<T, 3> v = Cross(from, to);
- T e = Dot(from, to);
- if(e > 1-(T)(1.e-9)){
+ Vector v = Cross(from, to);
+ Real e = Dot(from, to);
+ if(e > 1-(Real)(1.e-9)){
// No rotation
return;
- } else if (e < -1+(T)(1.e-9)){
+ } else if (e < -1+(Real)(1.e-9)){
// 180 degree rotation
- VectorT<T, 3> x = v.absoluteValue();
+ Vector x = v.absoluteValue();
int largest = x.indexOfMaxComponent();
- x = VectorT<T, 3>(0, 0, 0);
+ x = Vector(0, 0, 0);
x[largest] = 1;
- VectorT<T, 3> u = x-from;
- VectorT<T, 3> v = x-to;
- T c1 = 2/Dot(u, u);
- T c2 = 2/Dot(v, v);
- T c3 = c1 * c2 * Dot(u, v);
- T mtx[3][3];
+ Vector u = x-from;
+ Vector v = x-to;
+ Real c1 = 2/Dot(u, u);
+ Real c2 = 2/Dot(v, v);
+ Real c3 = c1 * c2 * Dot(u, v);
+ Real mtx[3][3];
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
mtx[i][j] = -c1 * u[i] * u[j] + c2 * v[i] * v[j] + c3 * v[i] *
u[j];
@@ -116,16 +135,16 @@
}
pre_multiply(mtx);
} else {
- T h = (T)1/(1 + e); /* optimization by Gottfried Chen */
- T mtx[3][3];
+ Real h = (Real)1/(1 + e); /* optimization by Gottfried Chen */
+ Real mtx[3][3];
mtx[0][0] = e + h * v[0] * v[0];
mtx[0][1] = h * v[0] * v[1] - v[2];
mtx[0][2] = h * v[0] * v[2] + v[1];
-
+
mtx[1][0] = h * v[0] * v[1] + v[2];
mtx[1][1] = e + h * v[1] * v[1];
mtx[1][2] = h * v[1] * v[2] - v[0];
-
+
mtx[2][0] = h * v[0] * v[2] - v[1];
mtx[2][1] = h * v[1] * v[2] + v[0];
mtx[2][2] = e + h * v[2] * v[2];
@@ -133,18 +152,17 @@
}
}
- template<typename T>
- void AffineTransformT<T>::rotate(const VectorT<T, 3>& axis,
- T angleInRadians)
+ void AffineTransform::rotate(const Vector& axis,
+ Real angleInRadians)
{
- T rot[3][3];
+ Real rot[3][3];
// From Foley and Van Dam, Pg 227
// NOTE: Element 0,1 is wrong in the text!
- T sintheta=Sin(angleInRadians);
- T costheta=Cos(angleInRadians);
- T ux=axis.x();
- T uy=axis.y();
- T uz=axis.z();
+ Real sintheta=Sin(angleInRadians);
+ Real costheta=Cos(angleInRadians);
+ Real ux=axis.x();
+ Real uy=axis.y();
+ Real uz=axis.z();
rot[0][0]=ux*ux+costheta*(1-ux*ux);
rot[0][1]=ux*uy*(1-costheta)-uz*sintheta;
rot[0][2]=uz*ux*(1-costheta)+uy*sintheta;
@@ -160,72 +178,65 @@
pre_multiply(rot);
}
- template<typename T>
- void AffineTransformT<T>::translate(const VectorT<T, 3>& translation)
+ void AffineTransform::translate(const Vector& translation)
{
for(int i=0;i<3;i++)
mat[i][3] += translation[i];
}
- template<typename T>
- static AffineTransformT<T> createScale(const VectorT<T, 3>& scale)
+ static AffineTransform createScale(const Vector& scale)
{
- AffineTransformT<T> result;
+ AffineTransform result;
result.initWithScale(scale);
return result;
}
- template<typename T>
- static AffineTransformT<T> createRotation(const VectorT<T, 3>& from,
- const VectorT<T, 3>& to)
+ static AffineTransform createRotation(const Vector& from,
+ const Vector& to)
{
- AffineTransformT<T> result;
+ AffineTransform result;
result.initWithRotation(from, to);
return result;
}
- template<typename T>
- static AffineTransformT<T> createRotation(const VectorT<T, 3>& axis,
- T angleInRadians)
+ static AffineTransform createRotation(const Vector& axis,
+ Real angleInRadians)
{
- AffineTransformT<T> result;
+ AffineTransform result;
result.initWithRotation(axis, angleInRadians);
return result;
}
- template<typename T>
- static AffineTransformT<T> createTranslation(const VectorT<T, 3>&
translation)
+ static AffineTransform createTranslation(const Vector& translation)
{
- AffineTransformT<T> result;
+ AffineTransform result;
result.initWithTranslation(translation);
return result;
}
- template<typename T>
- AffineTransformT<T> AffineTransformT<T>::inverse() const
+ AffineTransform AffineTransform::inverse() const
{
- AffineTransformT<T> result(*this);
+ AffineTransform result(*this);
result.invert();
return result;
}
- template<typename T>
- void AffineTransformT<T>::invert()
+ void AffineTransform::invert()
{
- T a = mat[0][0];
- T b = mat[0][1];
- T c = mat[0][2];
- T d = mat[1][0];
- T e = mat[1][1];
- T f = mat[1][2];
- T g = mat[2][0];
- T h = mat[2][1];
- T i = mat[2][2];
+ Real a = mat[0][0];
+ Real b = mat[0][1];
+ Real c = mat[0][2];
+ Real d = mat[1][0];
+ Real e = mat[1][1];
+ Real f = mat[1][2];
+ Real g = mat[2][0];
+ Real h = mat[2][1];
+ Real i = mat[2][2];
- T denom = c*d*h-c*e*g-b*d*i+b*f*g+a*e*i-a*f*h;
+ Real denom = c*d*h-c*e*g-b*d*i+b*f*g+a*e*i-a*f*h;
- T inv_denom = (T)(1)/denom;
+ Real inv_denom = (Real)(1)/denom;
mat[0][0] = (e*i-f*h)*inv_denom;
mat[0][1] = (c*h-b*i)*inv_denom;
mat[0][2] = (b*f-c*e)*inv_denom;
@@ -235,18 +246,17 @@
mat[2][0] = (d*h-e*g)*inv_denom;
mat[2][1] = (b*g-a*h)*inv_denom;
mat[2][2] = (a*e-b*d)*inv_denom;
- // These were double, but I changed them to type T. Do they need
+ // These were double, but I changed them to type Real. Do they need
// to be double for some reason?
- T x = mat[0][3];
- T y = mat[1][3];
- T z = mat[2][3];
+ Real x = mat[0][3];
+ Real y = mat[1][3];
+ Real z = mat[2][3];
mat[0][3] = -(mat[0][0]*x + mat[0][1]*y + mat[0][2]*z);
mat[1][3] = -(mat[1][0]*x + mat[1][1]*y + mat[1][2]*z);
mat[2][3] = -(mat[2][0]*x + mat[2][1]*y + mat[2][2]*z);
}
- template<typename T>
- AffineTransformT<T> AffineTransformT<T>::operator*(const
AffineTransformT<T>& m) const
+ AffineTransform AffineTransform::operator*(const AffineTransform& m) const
{
/*
* Multiplication of two matrices. They look like:
@@ -256,16 +266,16 @@
* [A20 A21 A22 A23] [B20 B21 B22 B23] [C20 C21 C22 C23]
* [ 0 0 0 1] [ 0 0 0 1] [ 0 0 0 1]
*/
- AffineTransformT<T> result;
+ AffineTransform result;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
- T sum = 0;
+ Real sum = 0;
for(int k=0;k<3;k++){
sum += mat[i][k] * m.mat[k][j];
}
result.mat[i][j] = sum;
}
- T sum = mat[i][3];
+ Real sum = mat[i][3];
for(int k=0;k<3;k++)
sum += mat[i][k] * m.mat[k][3];
result.mat[i][3] = sum;
@@ -273,11 +283,10 @@
return result;
}
- template<typename T>
- AffineTransformT<T>& AffineTransformT<T>::operator*=(const
AffineTransformT<T>& m)
+ AffineTransform& AffineTransform::operator*=(const AffineTransform& m)
{
- T tmp[3][4];
-
+ Real tmp[3][4];
+
for(int row = 0; row < 3; row++){
for(int col = 0; col < 4; col++){
tmp[row][col] = mat[row][col];
@@ -285,13 +294,13 @@
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
- T sum = 0;
+ Real sum = 0;
for(int k=0;k<3;k++){
sum += tmp[i][k] * m.mat[k][j];
}
mat[i][j] = sum;
}
- T sum = mat[i][3];
+ Real sum = mat[i][3];
for(int k=0;k<3;k++)
sum += tmp[i][k] * m.mat[k][3];
mat[i][3] = sum;
@@ -300,9 +309,8 @@
}
// Private helper function.
- template<typename T>
- void AffineTransformT<T>::pre_multiply( T pre[3][3] ) {
- T tmp[3][4];
+ void AffineTransform::pre_multiply( Real pre[3][3] ) {
+ Real tmp[3][4];
// Copy pre into tmp.
for(int row = 0; row < 3; row++){
@@ -313,71 +321,62 @@
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
- T sum = 0;
+ Real sum = 0;
for(int k=0;k<3;k++){
sum += pre[i][k] * tmp[k][j];
}
mat[i][j] = sum;
}
- T sum = 0;
+ Real sum = 0;
for(int k=0;k<3;k++)
sum += pre[i][k] * tmp[k][3];
mat[i][3] = sum;
}
}
- template<typename T>
- PointT<T, 3> operator*(const AffineTransformT<T>& trans, const PointT<T,
3>& point) {
- PointT<T,3> result;
+ Vector AffineTransform::multiply_point(const Vector& point) const {
+ Vector result;
for (int i=0;i<3;++i) {
- result[i] = trans(i,0) * point[0];
- result[i] += trans(i,1) * point[1];
- result[i] += trans(i,2) * point[2];
- result[i] += trans(i,3); // point[3] == 1
+ result[i] = mat[i][0] * point[0];
+ result[i] += mat[i][1] * point[1];
+ result[i] += mat[i][2] * point[2];
+ result[i] += mat[i][3]; // point[3] == 1
}
return result;
}
-
- template<typename T>
- VectorT<T, 3> operator*(const AffineTransformT<T>& trans, const VectorT<T,
3>& vec) {
- VectorT<T,3> result;
+ Vector AffineTransform::multiply_vector(const Vector& vec) const {
+ Vector result;
for (int i=0;i<3;++i) {
- result[i] = trans(i,0) * vec[0];
- result[i] += trans(i,1) * vec[1];
- result[i] += trans(i,2) * vec[2];
+ result[i] = mat[i][0] * vec[0];
+ result[i] += mat[i][1] * vec[1];
+ result[i] += mat[i][2] * vec[2];
// vec[3] == 0
}
return result;
}
- // Multiply by the transpose of the AffineTransformation, useful for
- // computations involving an inverse transpose.
- template<typename T>
- PointT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
PointT<T, 3>& point) {
- PointT<T,3> result;
+ Vector AffineTransform::transpose_mult_point(const Vector& point) const {
+ Vector result;
for (int i=0;i<3;++i) {
- result[i] = trans(0,i) * point[0];
- result[i] += trans(1,i) * point[1];
- result[i] += trans(2,i) * point[2];
- result[i] += trans(3,i); // point[3] == 1
+ result[i] = mat[0][i] * point[0];
+ result[i] += mat[1][i] * point[1];
+ result[i] += mat[2][i] * point[2];
+ result[i] += mat[3][i]; // point[3] == 1
}
return result;
}
-
- template<typename T>
- VectorT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
VectorT<T, 3>& vec) {
- VectorT<T,3> result;
+ Vector AffineTransform::transpose_mult_vector(const Vector& vec) const {
+ Vector result;
for (int i=0;i<3;++i) {
- result[i] = trans(0,i) * vec[0];
- result[i] += trans(1,i) * vec[1];
- result[i] += trans(2,i) * vec[2];
+ result[i] = mat[0][i] * vec[0];
+ result[i] += mat[1][i] * vec[1];
+ result[i] += mat[2][i] * vec[2];
// vec[3] == 0
}
- return result;
+ return result;
}
-
- template<typename T>
- std::ostream &operator << ( std::ostream &os, const AffineTransformT<T>
&trans ) {
+
+ std::ostream& operator<<( std::ostream& os, const AffineTransform& trans )
{
for (int i=0;i<3;++i) {
for (int j=0;j<4;++j) {
os << trans(i,j) << " ";
@@ -386,22 +385,5 @@
}
return os;
}
-
-
- // Static Instances.
- template PointT <double,3> operator*(const AffineTransformT<double>
&trans, const PointT <double,3> &point);
- template VectorT<double,3> operator*(const AffineTransformT<double>
&trans, const VectorT<double,3> &vec);
- template PointT <double,3> transpose_mult(const AffineTransformT<double>
&trans, const PointT <double,3> &point);
- template VectorT<double,3> transpose_mult(const AffineTransformT<double>
&trans, const VectorT<double,3> &vec);
- template class AffineTransformT<double>;
- template std::ostream& operator<<(std::ostream& os, const
AffineTransformT<double>& trans);
-
-
- template PointT <float,3> operator*(const AffineTransformT<float> &trans,
const PointT <float,3> &point);
- template VectorT<float,3> operator*(const AffineTransformT<float> &trans,
const VectorT<float,3> &vec);
- template PointT <float,3> transpose_mult(const AffineTransformT<float>
&trans, const PointT <float,3> &point);
- template VectorT<float,3> transpose_mult(const AffineTransformT<float>
&trans, const VectorT<float,3> &vec);
- template class AffineTransformT<float>;
- template std::ostream& operator<<(std::ostream& os, const
AffineTransformT<float>& trans);
}
Modified: trunk/Core/Geometry/AffineTransform.h
==============================================================================
--- trunk/Core/Geometry/AffineTransform.h (original)
+++ trunk/Core/Geometry/AffineTransform.h Thu Feb 16 17:08:22 2006
@@ -1,10 +1,40 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005-2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
#ifndef Manta_Core_AffineTransform_h
#define Manta_Core_AffineTransform_h
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
+
+#include <sgi_stl_warnings_off.h>
#include <iosfwd>
+#include <sgi_stl_warnings_on.h>
namespace Manta {
/**
@@ -17,20 +47,19 @@
* dimensional matrices, but a few things would need to be rethought,
* such as rotation and the load_basis constructor.
*/
- template<typename T>
- class AffineTransformT {
+ class AffineTransform {
public:
- AffineTransformT() {
+ AffineTransform() {
}
- ~AffineTransformT() {
+ ~AffineTransform() {
}
- AffineTransformT(const AffineTransformT<T> ©) {
+ AffineTransform(const AffineTransform ©) {
for(int i=0;i<3;i++)
for(int j=0;j<4;j++)
mat[i][j] = copy.mat[i][j];
}
- AffineTransformT<T>& operator=(const AffineTransformT<T> ©) {
+ AffineTransform& operator=(const AffineTransform ©) {
for(int i=0;i<3;i++)
for(int j=0;j<4;j++)
mat[i][j] = copy.mat[i][j];
@@ -39,62 +68,55 @@
// These methods set the current matrix
void initWithIdentity();
- void initWithScale(const VectorT<T, 3>& scale);
- void initWithRotation(const VectorT<T, 3>& from, const VectorT<T, 3>&
to);
- void initWithRotation(const VectorT<T, 3>& axis, T angleInRadians);
- void initWithTranslation(const VectorT<T, 3>& translation);
- void initWithBasis(const VectorT<T, 3>& v1, const VectorT<T, 3>& v2,
- const VectorT<T, 3>& v3, const PointT<T, 3>& p);
+ void initWithScale(const Vector& scale);
+ void initWithRotation(const Vector& from, const Vector& to);
+ void initWithRotation(const Vector& axis, Real angleInRadians);
+ void initWithTranslation(const Vector& translation);
+ void initWithBasis(const Vector& v1, const Vector& v2,
+ const Vector& v3, const Vector& p);
// These methods premultiply the current matrix by the indicated
transform
- void scale(const VectorT<T, 3>& scale);
- void rotate(const VectorT<T, 3>& from, const VectorT<T, 3>& to);
- void rotate(const VectorT<T, 3>& axis, T angleInRadians);
- void translate(const VectorT<T, 3>& translation);
+ void scale(const Vector& scale);
+ void rotate(const Vector& from, const Vector& to);
+ void rotate(const Vector& axis, Real angleInRadians);
+ void translate(const Vector& translation);
// These static methods return a new transform with the indicated
transform
- static AffineTransformT<T> createScale(const VectorT<T, 3>& scale);
- static AffineTransformT<T> createRotation(const VectorT<T, 3>& from,
- const VectorT<T, 3>& to);
- static AffineTransformT<T> createRotation(const VectorT<T, 3>& axis,
- T angleInRadians);
- static AffineTransformT<T> createTranslation(const VectorT<T, 3>&
translation);
+ static AffineTransform createScale(const Vector& scale);
+ static AffineTransform createRotation(const Vector& from,
+ const Vector& to);
+ static AffineTransform createRotation(const Vector& axis,
+ Real angleInRadians);
+ static AffineTransform createTranslation(const Vector& translation);
// Other methods
- AffineTransformT<T> inverse() const;
+ AffineTransform inverse() const;
void invert();
// Const Accessors used by global multiplication operators.
- const T &operator() (unsigned int r, unsigned int c) const {
+ const Real &operator() (unsigned int r, unsigned int c) const {
return mat[r][c];
}
// Post-multiplication
- AffineTransformT<T> operator*(const AffineTransformT<T>& m) const;
- AffineTransformT<T>& operator*=(const AffineTransformT<T>& m);
+ AffineTransform operator*(const AffineTransform& m) const;
+ AffineTransform& operator*=(const AffineTransform& m);
+
+ Vector multiply_point(const Vector& point) const;
+ Vector multiply_vector(const Vector& vec) const;
+
+ // Multiply by the transpose of the AffineTransformation, useful for
+ // computations involving an inverse transpose.
+ Vector transpose_mult_point(const Vector& point) const;
+ Vector transpose_mult_vector(const Vector& vec) const;
private:
- T mat[3][4];
+ Real mat[3][4];
// Pre-multiplication.
- void pre_multiply(T m[3][3]);
+ void pre_multiply(Real m[3][3]);
};
-
- template<typename T>
- PointT<T, 3> operator*(const AffineTransformT<T>& trans, const PointT<T,
3>& point);
-
- template<typename T>
- VectorT<T, 3> operator*(const AffineTransformT<T>& trans, const VectorT<T,
3>& vec);
-
- // Multiply by the transpose of the AffineTransformation, useful for
- // computations involving an inverse transpose.
- template<typename T>
- PointT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
PointT<T, 3>& point);
-
- template<typename T>
- VectorT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
VectorT<T, 3>& vec);
- template<typename T>
- std::ostream &operator << ( std::ostream &os, const AffineTransformT<T>
&trans );
+ std::ostream& operator<<( std::ostream& os, const AffineTransform& trans );
}
#endif
Copied: trunk/Core/Geometry/AffineTransformT.cc (from r885,
trunk/Core/Geometry/AffineTransform.cc)
==============================================================================
--- trunk/Core/Geometry/AffineTransform.cc (original)
+++ trunk/Core/Geometry/AffineTransformT.cc Thu Feb 16 17:08:22 2006
@@ -1,6 +1,33 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005-2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
#include <MantaTypes.h>
-#include <Core/Geometry/AffineTransform.h>
+#include <Core/Geometry/AffineTransformT.h>
#include <Core/Math/Trig.h>
#include <Core/Math/MinMax.h>
#include <Core/Math/MiscMath.h>
@@ -50,14 +77,14 @@
}
/**
- * Each vector becomes a column in the resulting matrix, with the
+ * Each vector becomes a column in the resulting matrix, with the
* point in the last column
*/
template<typename T>
void AffineTransformT<T>::initWithBasis(const VectorT<T, 3>& v1,
const VectorT<T, 3>& v2,
const VectorT<T, 3>& v3,
- const PointT<T, 3>& p)
+ const VectorT<T, 3>& p)
{
for(int i=0;i<3;i++)
mat[i][0] = v1[i];
@@ -85,7 +112,7 @@
{
// Modified from Moller/Hughes, Journal of Graphics Tools Vol. 4, No. 4
// "Efficiently Building a Matrix to Rotate One Vector to Another"
-
+
// Don't assume that to and from are normalized.
VectorT<T,3> from = from_.normal();
VectorT<T,3> to = to_.normal();
@@ -121,11 +148,11 @@
mtx[0][0] = e + h * v[0] * v[0];
mtx[0][1] = h * v[0] * v[1] - v[2];
mtx[0][2] = h * v[0] * v[2] + v[1];
-
+
mtx[1][0] = h * v[0] * v[1] + v[2];
mtx[1][1] = e + h * v[1] * v[1];
mtx[1][2] = h * v[1] * v[2] - v[0];
-
+
mtx[2][0] = h * v[0] * v[2] - v[1];
mtx[2][1] = h * v[1] * v[2] + v[0];
mtx[2][2] = e + h * v[2] * v[2];
@@ -277,7 +304,7 @@
AffineTransformT<T>& AffineTransformT<T>::operator*=(const
AffineTransformT<T>& m)
{
T tmp[3][4];
-
+
for(int row = 0; row < 3; row++){
for(int col = 0; col < 4; col++){
tmp[row][col] = mat[row][col];
@@ -327,57 +354,61 @@
}
template<typename T>
- PointT<T, 3> operator*(const AffineTransformT<T>& trans, const PointT<T,
3>& point) {
- PointT<T,3> result;
+ VectorT<T, 3>
+ AffineTransformT<T>::multiply_point(const VectorT<T, 3>& point) const {
+ VectorT<T, 3> result;
for (int i=0;i<3;++i) {
- result[i] = trans(i,0) * point[0];
- result[i] += trans(i,1) * point[1];
- result[i] += trans(i,2) * point[2];
- result[i] += trans(i,3); // point[3] == 1
+ result[i] = mat[i][0] * point[0];
+ result[i] += mat[i][1] * point[1];
+ result[i] += mat[i][2] * point[2];
+ result[i] += mat[i][3]; // point[3] == 1
}
return result;
}
-
+
template<typename T>
- VectorT<T, 3> operator*(const AffineTransformT<T>& trans, const VectorT<T,
3>& vec) {
- VectorT<T,3> result;
+ VectorT<T, 3>
+ AffineTransformT<T>::multiply_vector(const VectorT<T, 3>& vec) const {
+ VectorT<T, 3> result;
for (int i=0;i<3;++i) {
- result[i] = trans(i,0) * vec[0];
- result[i] += trans(i,1) * vec[1];
- result[i] += trans(i,2) * vec[2];
+ result[i] = mat[i][0] * vec[0];
+ result[i] += mat[i][1] * vec[1];
+ result[i] += mat[i][2] * vec[2];
// vec[3] == 0
}
return result;
}
- // Multiply by the transpose of the AffineTransformation, useful for
- // computations involving an inverse transpose.
template<typename T>
- PointT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
PointT<T, 3>& point) {
- PointT<T,3> result;
+ VectorT<T, 3>
+ AffineTransformT<T>::transpose_mult_point(const VectorT<T, 3>& point)
const {
+ VectorT<T, 3> result;
for (int i=0;i<3;++i) {
- result[i] = trans(0,i) * point[0];
- result[i] += trans(1,i) * point[1];
- result[i] += trans(2,i) * point[2];
- result[i] += trans(3,i); // point[3] == 1
+ result[i] = mat[0][i] * point[0];
+ result[i] += mat[1][i] * point[1];
+ result[i] += mat[2][i] * point[2];
+ result[i] += mat[3][i]; // point[3] == 1
}
return result;
}
-
+
template<typename T>
- VectorT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
VectorT<T, 3>& vec) {
- VectorT<T,3> result;
+ VectorT<T, 3>
+ AffineTransformT<T>::transpose_mult_vector(const VectorT<T, 3>& vec) const
{
+ VectorT<T, 3> result;
for (int i=0;i<3;++i) {
- result[i] = trans(0,i) * vec[0];
- result[i] += trans(1,i) * vec[1];
- result[i] += trans(2,i) * vec[2];
+ result[i] = mat[0][i] * vec[0];
+ result[i] += mat[1][i] * vec[1];
+ result[i] += mat[2][i] * vec[2];
// vec[3] == 0
}
- return result;
+ return result;
}
-
+
template<typename T>
- std::ostream &operator << ( std::ostream &os, const AffineTransformT<T>
&trans ) {
+ std::ostream& operator<<(std::ostream& os,
+ const AffineTransformT<T>& trans )
+ {
for (int i=0;i<3;++i) {
for (int j=0;j<4;++j) {
os << trans(i,j) << " ";
@@ -389,18 +420,9 @@
// Static Instances.
- template PointT <double,3> operator*(const AffineTransformT<double>
&trans, const PointT <double,3> &point);
- template VectorT<double,3> operator*(const AffineTransformT<double>
&trans, const VectorT<double,3> &vec);
- template PointT <double,3> transpose_mult(const AffineTransformT<double>
&trans, const PointT <double,3> &point);
- template VectorT<double,3> transpose_mult(const AffineTransformT<double>
&trans, const VectorT<double,3> &vec);
template class AffineTransformT<double>;
template std::ostream& operator<<(std::ostream& os, const
AffineTransformT<double>& trans);
-
- template PointT <float,3> operator*(const AffineTransformT<float> &trans,
const PointT <float,3> &point);
- template VectorT<float,3> operator*(const AffineTransformT<float> &trans,
const VectorT<float,3> &vec);
- template PointT <float,3> transpose_mult(const AffineTransformT<float>
&trans, const PointT <float,3> &point);
- template VectorT<float,3> transpose_mult(const AffineTransformT<float>
&trans, const VectorT<float,3> &vec);
template class AffineTransformT<float>;
template std::ostream& operator<<(std::ostream& os, const
AffineTransformT<float>& trans);
Copied: trunk/Core/Geometry/AffineTransformT.h (from r885,
trunk/Core/Geometry/AffineTransform.h)
==============================================================================
--- trunk/Core/Geometry/AffineTransform.h (original)
+++ trunk/Core/Geometry/AffineTransformT.h Thu Feb 16 17:08:22 2006
@@ -1,10 +1,39 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
-#ifndef Manta_Core_AffineTransform_h
-#define Manta_Core_AffineTransform_h
+ The MIT License
-#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+ Copyright (c) 2005-2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef Manta_Core_AffineTransformT_h
+#define Manta_Core_AffineTransformT_h
+
+#include <Core/Geometry/VectorT.h>
+
+#include <sgi_stl_warnings_off.h>
#include <iosfwd>
+#include <sgi_stl_warnings_on.h>
namespace Manta {
/**
@@ -44,7 +73,7 @@
void initWithRotation(const VectorT<T, 3>& axis, T angleInRadians);
void initWithTranslation(const VectorT<T, 3>& translation);
void initWithBasis(const VectorT<T, 3>& v1, const VectorT<T, 3>& v2,
- const VectorT<T, 3>& v3, const PointT<T, 3>& p);
+ const VectorT<T, 3>& v3, const VectorT<T, 3>& p);
// These methods premultiply the current matrix by the indicated
transform
void scale(const VectorT<T, 3>& scale);
@@ -65,36 +94,31 @@
void invert();
// Const Accessors used by global multiplication operators.
- const T &operator() (unsigned int r, unsigned int c) const {
+ const T &operator() (unsigned int r, unsigned int c) const {
return mat[r][c];
}
// Post-multiplication
AffineTransformT<T> operator*(const AffineTransformT<T>& m) const;
AffineTransformT<T>& operator*=(const AffineTransformT<T>& m);
+
+ VectorT<T, 3> multiply_point(const VectorT<T, 3>& point) const;
+ VectorT<T, 3> multiply_vector(const VectorT<T, 3>& vec) const;
+
+ // Multiply by the transpose of the AffineTransformation, useful for
+ // computations involving an inverse transpose.
+ VectorT<T, 3> transpose_mult_point(const VectorT<T, 3>& point) const;
+ VectorT<T, 3> transpose_mult_vector(const VectorT<T, 3>& vec) const;
private:
T mat[3][4];
// Pre-multiplication.
void pre_multiply(T m[3][3]);
};
-
- template<typename T>
- PointT<T, 3> operator*(const AffineTransformT<T>& trans, const PointT<T,
3>& point);
-
- template<typename T>
- VectorT<T, 3> operator*(const AffineTransformT<T>& trans, const VectorT<T,
3>& vec);
-
- // Multiply by the transpose of the AffineTransformation, useful for
- // computations involving an inverse transpose.
- template<typename T>
- PointT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
PointT<T, 3>& point);
-
- template<typename T>
- VectorT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
VectorT<T, 3>& vec);
template<typename T>
- std::ostream &operator << ( std::ostream &os, const AffineTransformT<T>
&trans );
+ std::ostream& operator<<(std::ostream& os,
+ const AffineTransformT<T>& trans );
}
#endif
Modified: trunk/Core/Geometry/BBox.h
==============================================================================
--- trunk/Core/Geometry/BBox.h (original)
+++ trunk/Core/Geometry/BBox.h Thu Feb 16 17:08:22 2006
@@ -2,7 +2,7 @@
#ifndef Manta_Core_BBox_h
#define Manta_Core_BBox_h
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <SCIRun/Core/Math/Expon.h>
#include <sgi_stl_warnings_off.h>
@@ -13,8 +13,7 @@
class BBox {
public:
- template< typename T >
- BBox(const PointT<T,3>& min_, const PointT<T,3>& max_ ) {
+ BBox(const Vector& min_, const Vector& max_ ) {
bounds[0] = min_;
bounds[1] = max_;
}
@@ -41,37 +40,36 @@
// accept new bounds [MAX, -MAX].
void reset() {
Real max_val = std::numeric_limits<Real>::max();
- bounds[0] = Point( max_val, max_val, max_val);
- bounds[1] = Point(-max_val, -max_val, -max_val);
+ bounds[0] = Vector( max_val, max_val, max_val);
+ bounds[1] = Vector(-max_val, -max_val, -max_val);
}
// Test whether the box is in the "uninitialized state"
bool isDefault() const {
Real max_val = std::numeric_limits<Real>::max();
- return ( bounds[0] == Point(max_val, max_val, max_val) &&
- bounds[1] == Point(-max_val, -max_val, -max_val) );
+ return ( bounds[0] == Vector( max_val, max_val, max_val) &&
+ bounds[1] == Vector(-max_val, -max_val, -max_val) );
}
Vector diagonal() const {
return bounds[1] - bounds[0];
}
- Point center() const {
+ Vector center() const {
return Interpolate(bounds[0], bounds[1], (Real)0.5);
}
- template< typename T >
- void extendByPoint(const PointT<T,3>& p) {
- bounds[0] = Min(bounds[0],
Point((Point::ScalarType)p[0],(Point::ScalarType)p[1],(Point::ScalarType)p[2]));
- bounds[1] = Max(bounds[1],
Point((Point::ScalarType)p[0],(Point::ScalarType)p[1],(Point::ScalarType)p[2]));
+ void extendByPoint(const Vector& p) {
+ bounds[0] = Min(bounds[0], p);
+ bounds[1] = Max(bounds[1], p);
}
- void extendBySphere(const Point& p, Real radius) {
+ void extendBySphere(const Vector& p, Real radius) {
bounds[0] = Min(bounds[0], p-Vector(radius, radius, radius));
bounds[1] = Max(bounds[1], p+Vector(radius, radius, radius));
}
// n really needs to be normalize, or you could get NaNs when
// taking the square root of a negative number.
- void extendByDisc(const Point& p, const Vector& n, Real radius) {
+ void extendByDisc(const Vector& p, const Vector& n, Real radius) {
Vector v(SCIRun::Sqrt(1-n.x()*n.x())*radius,
SCIRun::Sqrt(1-n.y()*n.y())*radius,
SCIRun::Sqrt(1-n.z()*n.z())*radius);
@@ -83,15 +81,15 @@
bounds[1] = Max(bounds[1], b.bounds[1]);
}
- const Point& getMin() const {
+ const Vector& getMin() const {
return bounds[0];
}
- const Point& getMax() const {
+ const Vector& getMax() const {
return bounds[1];
}
- Point getCorner(int i) const {
- return Point(bounds[i&4].x(), bounds[i&2].y(), bounds[i&1].z());
+ Vector getCorner(int i) const {
+ return Vector(bounds[i&4].x(), bounds[i&2].y(), bounds[i&1].z());
}
double computeVolume() const
@@ -103,7 +101,7 @@
double computeArea() const
{
Vector d = bounds[1] - bounds[0];
- return (2.0*(d.x()*d.y() + d.y()*d.z()) + d.x()*d.z() );
+ return (2*(d.x()*d.y() + d.y()*d.z()) + d.x()*d.z() );
}
int longestAxis() const
@@ -115,11 +113,11 @@
return d.y() > d.z() ? 1 : 2;
}
- inline Point &operator[] (int i) { return bounds[i]; }
- inline const Point &operator[] (int i) const { return bounds[i]; }
+ inline Vector &operator[] (int i) { return bounds[i]; }
+ inline const Vector &operator[] (int i) const { return bounds[i]; }
private:
- Point bounds[2];
+ Vector bounds[2];
};
}
Modified: trunk/Core/Geometry/Ray.h
==============================================================================
--- trunk/Core/Geometry/Ray.h (original)
+++ trunk/Core/Geometry/Ray.h Thu Feb 16 17:08:22 2006
@@ -2,7 +2,7 @@
#ifndef Manta_Interface_Ray_h
#define Manta_Interface_Ray_h
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class Ray {
@@ -10,7 +10,7 @@
Ray()
{
}
- Ray(const Point& origin, const Vector& direction)
+ Ray(const Vector& origin, const Vector& direction)
: orig(origin), dir(direction)
{
}
@@ -24,12 +24,12 @@
}
#endif
- void set(const Point& origin, const Vector& direction)
+ void set(const Vector& origin, const Vector& direction)
{
orig = origin;
dir = direction;
}
- void setOrigin(const Point& origin)
+ void setOrigin(const Vector& origin)
{
orig = origin;
}
@@ -38,7 +38,7 @@
dir = direction;
}
- const Point& origin() const {
+ const Vector& origin() const {
return orig;
}
const Vector& direction() const {
@@ -48,7 +48,7 @@
return dir.normalize();
}
private:
- Point orig;
+ Vector orig;
Vector dir;
};
}
Copied: trunk/Core/Geometry/Vector.cc (from r885,
trunk/Core/Geometry/PointVector.cc)
==============================================================================
--- trunk/Core/Geometry/PointVector.cc (original)
+++ trunk/Core/Geometry/Vector.cc Thu Feb 16 17:08:22 2006
@@ -1,81 +1,50 @@
-#include <Core/Geometry/PointVector.h>
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005-2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Core/Geometry/Vector.h>
#include <sgi_stl_warnings_off.h>
#include <iostream>
#include <sgi_stl_warnings_on.h>
namespace Manta {
- template<typename T, int Dim>
- std::ostream &operator<< (std::ostream &os, const VectorT<T,Dim> &v) {
- for (int i=0;i<Dim;++i)
- os << v[i] << " ";
+ std::ostream& operator<< (std::ostream& os, const Vector& v) {
+ os << v[0] << " ";
+ os << v[1] << " ";
+ os << v[2];
return os;
}
- template<typename T, int Dim>
- std::ostream &operator<< (std::ostream &os, const PointT<T,Dim> &v) {
- for (int i=0;i<Dim;++i)
- os << v[i] << " ";
- return os;
- }
-
- template<typename T, int Dim>
- std::istream &operator>> (std::istream &is, VectorT<T,Dim> &v) {
- for (int i=0;i<Dim;++i)
- is >> v[i];
- return is;
- }
-
- template<typename T, int Dim>
- std::istream &operator>> (std::istream &is, PointT<T,Dim> &v) {
- for (int i=0;i<Dim;++i)
- is >> v[i];
+ std::istream& operator>> (std::istream& is, Vector& v) {
+ is >> v[0];
+ is >> v[1];
+ is >> v[2];
return is;
}
-
- // Explicit instantiations for ostream operators
-
- // 3D Vectors
- template std::ostream& operator<<(std::ostream& os, const VectorT<double,
3>&);
- template std::ostream& operator<<(std::ostream& os, const VectorT<float,
3>&);
- template std::ostream& operator<<(std::ostream& os, const VectorT<int,
3>&);
-
- // 3D Points
- template std::ostream& operator<<(std::ostream& os, const PointT<double,
3>&);
- template std::ostream& operator<<(std::ostream& os, const PointT<float,
3>&);
- template std::ostream& operator<<(std::ostream& os, const PointT<int, 3>&);
-
- // 2D Vectors
- template std::ostream& operator<<(std::ostream& os, const VectorT<double,
2>&);
- template std::ostream& operator<<(std::ostream& os, const VectorT<float,
2>&);
- template std::ostream& operator<<(std::ostream& os, const VectorT<int,
2>&);
-
- // 2D Points
- template std::ostream& operator<<(std::ostream& os, const PointT<double,
2>&);
- template std::ostream& operator<<(std::ostream& os, const PointT<float,
2>&);
- template std::ostream& operator<<(std::ostream& os, const PointT<int, 2>&);
-
- // Explicit instantiations for istream operators
-
- // 3D Vectors
- template std::istream& operator>>(std::istream& is, VectorT<double, 3>&);
- template std::istream& operator>>(std::istream& is, VectorT<float, 3>&);
- template std::istream& operator>>(std::istream& is, VectorT<int, 3>&);
-
- // 3D Points
- template std::istream& operator>>(std::istream& is, PointT<double, 3>&);
- template std::istream& operator>>(std::istream& is, PointT<float, 3>&);
- template std::istream& operator>>(std::istream& is, PointT<int, 3>&);
-
- // 2D Vectors
- template std::istream& operator>>(std::istream& is, VectorT<double, 2>&);
- template std::istream& operator>>(std::istream& is, VectorT<float, 2>&);
- template std::istream& operator>>(std::istream& is, VectorT<int, 2>&);
-
- // 2D Points
- template std::istream& operator>>(std::istream& is, PointT<double, 2>&);
- template std::istream& operator>>(std::istream& is, PointT<float, 2>&);
- template std::istream& operator>>(std::istream& is, PointT<int, 2>&);
-
}
Copied: trunk/Core/Geometry/Vector.h (from r885,
trunk/Core/Geometry/PointVector.h)
==============================================================================
--- trunk/Core/Geometry/PointVector.h (original)
+++ trunk/Core/Geometry/Vector.h Thu Feb 16 17:08:22 2006
@@ -1,13 +1,42 @@
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005-2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
/*
- PointT and VectorT are made to be templated with floating point
- types. If you use an integral type, you could get into trouble with
- certain functions that compute division. Be warned!
+ Vector expects Real to be a floating point type. If you use an
+ integral type, you could get into trouble with certain functions
+ that compute division. Be warned!
*/
-#ifndef Manta_Core_PointVector_h
-#define Manta_Core_PointVector_h
+#ifndef Manta_Core_Vector_h
+#define Manta_Core_Vector_h
#include <MantaTypes.h>
#include <Core/Math/Expon.h>
@@ -18,72 +47,68 @@
#include <iosfwd>
#include <sgi_stl_warnings_on.h>
-#include <math.h>
-
namespace Manta {
- template<typename T, int Dim>
- class VectorT {
+ template<typename T, int Dim> class VectorT;
+
+ class Vector {
public:
- typedef T ComponentType;
-
- VectorT() {
+ typedef Real ComponentType;
+
+ Vector() {
}
-#ifndef SWIG
- VectorT(T x, T y) {
- typedef char unnamed[ Dim == 2 ? 1 : 0 ];
- data[0] = x; data[1] = y;
- }
-#endif
- VectorT(T x, T y, T z) {
- typedef char unnamed[ Dim == 3 ? 1 : 0 ];
+ Vector(Real data_in[3]) {
+ data[0] = data_in[0]; data[1] = data_in[1]; data[2] = data_in[2];
+ }
+ Vector(Real x, Real y, Real z) {
data[0] = x; data[1] = y; data[2] = z;
}
- explicit VectorT( const PointT<T,Dim> ©) {
- for (int i=0;i<Dim;i++)
- data[i] = copy[i];
+ Vector( const Vector& copy) {
+ data[0] = copy[0];
+ data[1] = copy[1];
+ data[2] = copy[2];
}
- // Copy from another vector of the same size.
- template< typename S >
- VectorT(const VectorT<S, Dim> ©) {
- for(int i=0;i<Dim;i++)
- data[i] = (T)copy[i];
+ // Copy from another vector of the same size, but of a templated type.
+ template< typename S >
+ Vector(const VectorT<S, 3>& copy) {
+ data[0] = static_cast<Real>(copy[0]);
+ data[1] = static_cast<Real>(copy[1]);
+ data[2] = static_cast<Real>(copy[2]);
}
#ifndef SWIG
- VectorT<T, Dim>& operator=(const VectorT<T, Dim>& copy) {
- for(int i=0;i<Dim;i++)
- data[i] = (T)copy[i];
+ Vector& operator=(const Vector& copy) {
+ data[0] = copy[0];
+ data[1] = copy[1];
+ data[2] = copy[2];
return *this;
}
#endif
- ~VectorT() {
+ ~Vector() {
}
- T x() const {
+ Real x() const {
return data[0];
}
- T y() const {
- typedef char unnamed[ Dim >=2 ? 1 : 0 ];
+ Real y() const {
return data[1];
}
- T z() const {
- typedef char unnamed[ Dim >= 3 ? 1 : 0 ];
+ Real z() const {
return data[2];
}
+
#ifndef SWIG
- const T &operator[](int i) const {
+ const Real& operator[] (int i) const {
return data[i];
}
- T &operator[] ( int i ) {
+ Real& operator[] ( int i ) {
return data[i];
}
-
#else
%extend {
- T& __getitem__( int i ) {
+ Real& __getitem__( int i ) {
return self->operator[](i);
}
}
@@ -91,437 +116,301 @@
// One might be tempted to add an "operator &" function, but
// that could lead to problems when you want an address to the
// object rather than a pointer to data.
- const T* getDataPtr() const { return data; }
+ const Real* getDataPtr() const { return data; }
- VectorT<T, Dim> operator+(const VectorT<T, Dim>& v) const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] + v.data[i];
+ // + operator
+ Vector operator+(const Vector& v) const {
+ Vector result;
+ result.data[0] = data[0] + v.data[0];
+ result.data[1] = data[1] + v.data[1];
+ result.data[2] = data[2] + v.data[2];
return result;
}
- VectorT<T, Dim>& operator+=(const VectorT<T, Dim>& v) {
- for(int i=0;i<Dim;i++)
- data[i] += v.data[i];
+ Vector& operator+=(const Vector& v) {
+ data[0] += v.data[0];
+ data[1] += v.data[1];
+ data[2] += v.data[2];
return *this;
}
- VectorT<T, Dim> operator-(const VectorT<T, Dim>& v) const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] - v.data[i];
+
+ // - operator
+ Vector operator-(const Vector& v) const {
+ Vector result;
+ result.data[0] = data[0] - v.data[0];
+ result.data[1] = data[1] - v.data[1];
+ result.data[2] = data[2] - v.data[2];
return result;
}
- VectorT<T, Dim>& operator-=(const VectorT<T, Dim>& v) {
- for(int i=0;i<Dim;i++)
- data[i] -= v.data[i];
+ Vector& operator-=(const Vector& v) {
+ data[0] -= v.data[0];
+ data[1] -= v.data[1];
+ data[2] -= v.data[2];
return *this;
}
- VectorT<T, Dim> operator-() const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = -data[i];
+ Vector operator-() const {
+ Vector result;
+ result.data[0] = -data[0];
+ result.data[1] = -data[1];
+ result.data[2] = -data[2];
return result;
}
- VectorT<T, Dim> operator*(const VectorT<T, Dim>& v) const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] * v.data[i];
- return result;
- }
- VectorT<T, Dim> operator*(T s) const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] * s;
- return result;
- }
- VectorT<T, Dim>& operator*=(const VectorT<T, Dim>& v) {
- for(int i=0;i<Dim;i++)
- data[i] *= v.data[i];
- return *this;
- }
- VectorT<T, Dim>& operator*=(T s) {
- for(int i=0;i<Dim;i++)
- data[i] *= s;
+ // * operator
+ Vector operator*(const Vector& v) const {
+ Vector result;
+ result.data[0] = data[0] * v.data[0];
+ result.data[1] = data[1] * v.data[1];
+ result.data[2] = data[2] * v.data[2];
+ return result;
+ }
+ Vector& operator*=(const Vector& v) {
+ data[0] *= v.data[0];
+ data[1] *= v.data[1];
+ data[2] *= v.data[2];
return *this;
}
- VectorT<T, Dim> operator/(T s) const {
- T inv_s = 1/s;
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] * inv_s;
+ Vector operator*(Real s) const {
+ Vector result;
+ result.data[0] = data[0] * s;
+ result.data[1] = data[1] * s;
+ result.data[2] = data[2] * s;
return result;
}
- VectorT<T, Dim>& operator/=(T s) {
- T inv_s = 1/s;
- for(int i=0;i<Dim;i++)
- data[i] *= inv_s;
+ Vector& operator*=(Real s) {
+ data[0] *= s;
+ data[1] *= s;
+ data[2] *= s;
return *this;
}
- VectorT<T, Dim> operator/(const VectorT<T, Dim>& v) const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] / v.data[i];
- return result;
+
+ // / operator
+ Vector operator/(const Vector& v) const {
+ Vector result;
+ result.data[0] = data[0] / v.data[0];
+ result.data[1] = data[1] / v.data[1];
+ result.data[2] = data[2] / v.data[2];
+ return result;
+ }
+ Vector operator/(Real s) const {
+ Real inv_s = 1/s;
+ Vector result;
+ result.data[0] = data[0] * inv_s;
+ result.data[1] = data[1] * inv_s;
+ result.data[2] = data[2] * inv_s;
+ return result;
+ }
+ Vector& operator/=(Real s) {
+ Real inv_s = 1/s;
+ data[0] *= inv_s;
+ data[1] *= inv_s;
+ data[2] *= inv_s;
+ return *this;
}
- bool operator==(const VectorT<T, Dim>& right) const {
- for (int i = 0; i < Dim; ++i)
- if(data[i] != right.data[i])
- return false;
- return true;
+ bool operator==(const Vector& right) const {
+ return (data[0] == right.data[0] &&
+ data[1] == right.data[1] &&
+ data[2] == right.data[2]);
}
- T length() const {
- T sum = 0;
- for(int i=0;i<Dim;i++)
- sum += data[i]*data[i];
+ Real length() const {
+ Real sum = data[0]*data[0];
+ sum += data[1]*data[1];
+ sum += data[2]*data[2];
return SCIRun::Sqrt(sum);
}
- T length2() const {
- T sum = 0;
- for(int i=0;i<Dim;i++)
- sum += data[i]*data[i];
+ Real length2() const {
+ Real sum = data[0]*data[0];
+ sum += data[1]*data[1];
+ sum += data[2]*data[2];
return sum;
}
- T normalize() {
- T l = length();
- T scale = 1/l;
- *this *= scale;
+ // GCC and perhaps other compilers have a hard time optimizing
+ // with additional levels of function calls (i.e. *this *= scale).
+ // Because of this, we try to minimize the number of function
+ // calls we make and do explicit inlining.
+ Real normalize() {
+ Real l = SCIRun::Sqrt(data[0]*data[0] +
+ data[1]*data[1] +
+ data[2]*data[2]);
+ Real scale = 1/l;
+ data[0] *= scale;
+ data[1] *= scale;
+ data[2] *= scale;
return l;
}
- VectorT<T, Dim> normal() const {
- T l = length();
- T scale = 1/l;
- return *this * scale;
- }
- T minComponent() const {
- T min = data[0];
- for(int i=1;i<Dim;i++)
- if(data[i] < min)
- min = data[i];
- return min;
- }
- T maxComponent() const {
- T max = data[0];
- for(int i=1;i<Dim;i++)
- if(data[i] > max)
- max = data[i];
- return max;
+ Vector normal() const {
+ Real l = SCIRun::Sqrt(data[0]*data[0] +
+ data[1]*data[1] +
+ data[2]*data[2]);
+ Real scale = 1/l;
+ Vector result;
+ result.data[0] = data[0] * scale;
+ result.data[1] = data[1] * scale;
+ result.data[2] = data[2] * scale;
+ return result;
+ }
+ Real minComponent() const {
+ if (data[0] < data[1]) {
+ if (data[0] < data[2])
+ return data[0];
+ else
+ return data[2];
+ } else {
+ if (data[1] < data[2])
+ return data[1];
+ else
+ return data[2];
+ }
+ }
+ Real maxComponent() const {
+ if (data[0] > data[1]) {
+ if (data[0] > data[2])
+ return data[0];
+ else
+ return data[2];
+ } else {
+ if (data[1] > data[2])
+ return data[1];
+ else
+ return data[2];
+ }
}
int indexOfMinComponent() const {
- int idx = 0;
- for(int i=1;i<Dim;i++)
- if(data[i] < data[idx])
- idx = i;
- return idx;
+ if (data[0] < data[1]) {
+ if (data[0] < data[2])
+ return 0;
+ else
+ return 2;
+ } else {
+ if (data[1] < data[2])
+ return 1;
+ else
+ return 2;
+ }
}
int indexOfMaxComponent() const {
- int idx = 0;
- for(int i=1;i<Dim;i++)
- if(data[i] > data[idx])
- idx = i;
- return idx;
- }
-
- VectorT<T, Dim> inverse() const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = 1/data[i];
- return result;
- }
- VectorT<T, Dim> absoluteValue() const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = SCIRun::Abs(data[i]);
- return result;
- }
-
- static VectorT<T, Dim> zero() {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = 0;
- return result;
- }
- static VectorT<T, Dim> one() {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = 1;
- return result;
- }
-
- private:
- T data[Dim];
-
- // Do not use this function!!!! Use getDataPtr() instead.
- // const T *operator &() const { return data; }
- };
-
-
- template<typename T, int Dim>
- class PointT {
- public:
- typedef T ScalarType;
-
- PointT() {
- }
-
-#ifndef SWIG
- PointT(T x, T y) {
- typedef char unnamed[ Dim == 2 ? 1 : 0 ];
- data[0] = x; data[1] = y;
- }
-#endif
- PointT(T x, T y, T z) {
- typedef char unnamed[ Dim == 3 ? 1 : 0 ];
- data[0] = x; data[1] = y; data[2] = z;
- }
-
- template< typename S >
- PointT(const PointT<S, Dim>& copy) {
- for(int i=0;i<Dim;i++)
- data[i] = (T)copy[i];
- }
-
- explicit PointT( const VectorT<T,Dim> © ) {
- for (int i=0;i<Dim;++i)
- data[i] = copy[i];
- }
-
- bool operator==(const PointT<T, Dim>& right) const {
- for (int i = 0; i < Dim; ++i)
- if(data[i] != right.data[i])
- return false;
- return true;
- }
-#ifndef SWIG
- template< typename S >
- PointT<T, Dim>& operator=(const PointT<S, Dim>& copy) {
- for(int i=0;i<Dim;i++)
- data[i] = (T)copy[i];
- return *this;
- }
-#endif
-
- ~PointT() {
- }
-
- T x() const {
- return data[0];
- }
- T y() const {
- return data[1];
- }
- T z() const {
- typedef char unnamed[ Dim == 3 ? 1 : 0 ];
- return data[2];
- }
-#ifndef SWIG
- T operator[](int i) const {
- return data[i];
- }
- T &operator[](int i) {
- return data[i];
- }
-
-#else
- %extend {
- T& __getitem__( int i ) {
- return self->operator[](i);
+ if (data[0] > data[1]) {
+ if (data[0] > data[2])
+ return 0;
+ else
+ return 2;
+ } else {
+ if (data[1] > data[2])
+ return 1;
+ else
+ return 2;
}
}
-#endif
- // One might be tempted to add an "operator &" function, but
- // that could lead to problems when you want an address to the
- // object rather than a pointer to data.
- const T* getDataPtr() const { return data; }
- VectorT<T, Dim> operator-(const PointT<T, Dim>& p) const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = data[i] - p[i];
+ Vector inverse() const {
+ Vector result;
+ result.data[0] = 1/data[0];
+ result.data[1] = 1/data[1];
+ result.data[2] = 1/data[2];
return result;
}
- PointT<T, Dim> operator-(const VectorT<T, Dim>& v) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] - v[i];
- return result;
- }
- PointT<T, Dim>& operator-=(const VectorT<T, Dim>& v) {
- for(int i=0;i<Dim;i++)
- data[i] -= v[i];
- return *this;
- }
- PointT<T, Dim> operator+(const VectorT<T, Dim>& v) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] + v[i];
+ Vector absoluteValue() const {
+ Vector result;
+ result.data[0] = SCIRun::Abs(data[0]);
+ result.data[1] = SCIRun::Abs(data[1]);
+ result.data[2] = SCIRun::Abs(data[2]);
return result;
}
- PointT<T, Dim>& operator+=(const VectorT<T, Dim>& v) {
- for(int i=0;i<Dim;i++)
- data[i] += v[i];
- return *this;
- }
- // These are non-natural points operations. They are sometimes needed,
so
- // we allow them but you need to explicitly type the method.
- PointT<T, Dim> multipliedBy(T s) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] * s;
- return result;
- }
- PointT<T, Dim> multipliedBy(const VectorT<T, Dim>& v) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] * v[i];
- return result;
- }
- PointT<T, Dim> addedTo(const PointT<T, Dim>& v) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] + v[i];
- return result;
+ static Vector zero() {
+ return Vector(0,0,0);
}
- // This one returns void instead of a reference to itself so that it is
harder
- // to use the wrong form and end up changing a variable without
realizing it
- void multiplyBy(T s) {
- for(int i=0;i<Dim;i++)
- data[i] *= s;
- }
- void multiplyBy(const VectorT<T, Dim>& v){
- for(int i=0;i<Dim;i++)
- data[i] *= v[i];
- }
- void addTo(const PointT<T, Dim>& v){
- for(int i=0;i<Dim;i++)
- data[i] += v[i];
+ static Vector one() {
+ return Vector(1,1,1);
}
+ // Friend functions. These will allow the functions to access
+ // data without having to use a function (hopefully).
+ template<typename S >
+ friend Vector operator*(S s, const Vector& v);
+ template<typename S >
+ friend Vector operator*(const Vector& v, S s);
+ friend Real Dot(const Vector& v1, const Vector& v2);
+ friend Vector Cross(const Vector& v1, const Vector& v2);
+ friend Vector Min(const Vector& v1, const Vector& v2);
+ friend Vector Max(const Vector& v1, const Vector& v2);
+ friend Vector Interpolate(const Vector& v1, const Vector& v2, Real
weight);
private:
- T data[Dim];
+ Real data[3];
- // Do not use this function!!!! Use getDataPtr() instead.
- // const T *operator &() const { return data; }
+ // Do not use this function!!!! Use getDataPtr() instead.
+ // const Real *operator &() const { return data; }
};
- // Two multiplication by a scalar operators.
- template<typename T, int Dim, typename S >
- inline VectorT<T, Dim> operator*(S s, const VectorT<T, Dim>& v)
- {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = s * (S)v[i];
- return result;
- }
- template<typename T, int Dim, typename S >
- inline VectorT<T, Dim> operator*(const VectorT<T, Dim>& v, S s)
- {
- return operator*((T)s,v);
- }
-
- template<typename T, int Dim>
- inline T Dot(const VectorT<T, Dim>& v1, const VectorT<T, Dim>& v2)
+ // Two multiplication by a scalar operators.
+ template<typename S >
+ inline Vector operator*(S s, const Vector& v)
{
- T result = 0;
- for(int i=0;i<Dim;i++)
- result += v1[i] * v2[i];
+ Real scalar = static_cast<Real>(s);
+ Vector result(scalar * v[0],
+ scalar * v[1],
+ scalar * v[2]);
return result;
}
- template<typename T, int Dim>
- inline T Dot(const VectorT<T, Dim>& v1, const PointT<T, Dim>& v2)
+ template<typename S >
+ inline Vector operator*(const Vector& v, S s)
{
- T result = 0;
- for(int i=0;i<Dim;i++)
- result += v1[i] * v2[i];
+ Real scalar = static_cast<Real>(s);
+ Vector result(v[0] * scalar,
+ v[1] * scalar,
+ v[2] * scalar);
return result;
}
- template<typename T, int Dim>
- inline T Dot(const PointT<T, Dim>& v1, const VectorT<T, Dim>& v2)
+ inline Real Dot(const Vector& v1, const Vector& v2)
{
- T result = 0;
- for(int i=0;i<Dim;i++)
- result += v1[i] * v2[i];
- return result;
+ return (v1[0] * v2[0] +
+ v1[1] * v2[1] +
+ v1[2] * v2[2]);
}
-
// Cross product is only defined for R3
- template<typename T>
- inline VectorT<T, 3> Cross(const VectorT<T, 3>& v1, const VectorT<T, 3>&
v2)
- {
- return VectorT<T, 3>(v1.y()*v2.z() - v1.z()*v2.y(),
- v1.z()*v2.x() - v1.x()*v2.z(),
- v1.x()*v2.y() - v1.y()*v2.x());
- }
-
- template<typename T, int Dim>
- inline VectorT<T, Dim> Min(const VectorT<T, Dim>& v1, const VectorT<T,
Dim>& v2)
- {
- using SCIRun::Min;
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Min(v1[i], v2[i]);
- return result;
- }
-
- template<typename T, int Dim>
- inline VectorT<T, Dim> Max(const VectorT<T, Dim>& v1, const VectorT<T,
Dim>& v2)
- {
- using SCIRun::Max;
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Max(v1[i], v2[i]);
- return result;
- }
-
- template<typename T, int Dim>
- inline PointT<T, Dim> Min(const PointT<T, Dim>& p1, const PointT<T,
Dim>& p2)
- {
- using SCIRun::Min;
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Min(p1[i], p2[i]);
- return result;
- }
-
- template<typename T, int Dim>
- inline PointT<T, Dim> Max(const PointT<T, Dim>& p1, const PointT<T,
Dim>& p2)
- {
- using SCIRun::Max;
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Max(p1[i], p2[i]);
- return result;
- }
+ inline Vector Cross(const Vector& v1, const Vector& v2)
+ {
+ return Vector(v1[1]*v2[2] - v1[2]*v2[1],
+ v1[2]*v2[0] - v1[0]*v2[2],
+ v1[0]*v2[1] - v1[1]*v2[0]);
+ }
- template<typename T, int Dim>
- inline PointT<T, Dim> Interpolate(const PointT<T, Dim>& p1, const
PointT<T, Dim>& p2, T weight)
- {
- using SCIRun::Interpolate;
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Interpolate(p1[i], p2[i], weight);
- return result;
- }
+ inline Vector Min(const Vector& v1, const Vector& v2)
+ {
+ using SCIRun::Min;
+ Vector result(Min(v1[0], v2[0]),
+ Min(v1[1], v2[1]),
+ Min(v1[2], v2[2]));
+ return result;
+ }
- template<typename T, int Dim>
- std::ostream &operator<< (std::ostream &os, const VectorT<T,Dim> &v);
+ inline Vector Max(const Vector& v1, const Vector& v2)
+ {
+ using SCIRun::Max;
+ Vector result(Max(v1[0], v2[0]),
+ Max(v1[1], v2[1]),
+ Max(v1[2], v2[2]));
+ return result;
+ }
- template<typename T, int Dim>
- std::ostream &operator<< (std::ostream &os, const PointT<T,Dim> &v);
+ inline Vector Interpolate(const Vector& v1, const Vector& v2, Real weight)
+ {
+ using SCIRun::Interpolate;
+ Vector result(Interpolate(v1[0], v2[0], weight),
+ Interpolate(v1[1], v2[1], weight),
+ Interpolate(v1[2], v2[2], weight));
+ return result;
+ }
- template<typename T, int Dim>
- std::istream &operator>> (std::istream &is, VectorT<T,Dim> &v);
-
- template<typename T, int Dim>
- std::istream &operator>> (std::istream &is, PointT<T,Dim> &v);
+ std::ostream& operator<< (std::ostream& os, const Vector& v);
+ std::istream& operator>> (std::istream& is, Vector& v);
}
#endif
Copied: trunk/Core/Geometry/VectorT.cc (from r885,
trunk/Core/Geometry/PointVector.cc)
==============================================================================
--- trunk/Core/Geometry/PointVector.cc (original)
+++ trunk/Core/Geometry/VectorT.cc Thu Feb 16 17:08:22 2006
@@ -1,5 +1,33 @@
-#include <Core/Geometry/PointVector.h>
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005-2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Core/Geometry/VectorT.h>
#include <sgi_stl_warnings_off.h>
#include <iostream>
@@ -14,68 +42,33 @@
}
template<typename T, int Dim>
- std::ostream &operator<< (std::ostream &os, const PointT<T,Dim> &v) {
- for (int i=0;i<Dim;++i)
- os << v[i] << " ";
- return os;
- }
-
- template<typename T, int Dim>
std::istream &operator>> (std::istream &is, VectorT<T,Dim> &v) {
for (int i=0;i<Dim;++i)
is >> v[i];
return is;
}
-
- template<typename T, int Dim>
- std::istream &operator>> (std::istream &is, PointT<T,Dim> &v) {
- for (int i=0;i<Dim;++i)
- is >> v[i];
- return is;
- }
-
+
// Explicit instantiations for ostream operators
// 3D Vectors
template std::ostream& operator<<(std::ostream& os, const VectorT<double,
3>&);
template std::ostream& operator<<(std::ostream& os, const VectorT<float,
3>&);
template std::ostream& operator<<(std::ostream& os, const VectorT<int,
3>&);
-
- // 3D Points
- template std::ostream& operator<<(std::ostream& os, const PointT<double,
3>&);
- template std::ostream& operator<<(std::ostream& os, const PointT<float,
3>&);
- template std::ostream& operator<<(std::ostream& os, const PointT<int, 3>&);
// 2D Vectors
template std::ostream& operator<<(std::ostream& os, const VectorT<double,
2>&);
template std::ostream& operator<<(std::ostream& os, const VectorT<float,
2>&);
template std::ostream& operator<<(std::ostream& os, const VectorT<int,
2>&);
- // 2D Points
- template std::ostream& operator<<(std::ostream& os, const PointT<double,
2>&);
- template std::ostream& operator<<(std::ostream& os, const PointT<float,
2>&);
- template std::ostream& operator<<(std::ostream& os, const PointT<int, 2>&);
-
// Explicit instantiations for istream operators
-
+
// 3D Vectors
template std::istream& operator>>(std::istream& is, VectorT<double, 3>&);
template std::istream& operator>>(std::istream& is, VectorT<float, 3>&);
template std::istream& operator>>(std::istream& is, VectorT<int, 3>&);
-
- // 3D Points
- template std::istream& operator>>(std::istream& is, PointT<double, 3>&);
- template std::istream& operator>>(std::istream& is, PointT<float, 3>&);
- template std::istream& operator>>(std::istream& is, PointT<int, 3>&);
-
+
// 2D Vectors
template std::istream& operator>>(std::istream& is, VectorT<double, 2>&);
template std::istream& operator>>(std::istream& is, VectorT<float, 2>&);
template std::istream& operator>>(std::istream& is, VectorT<int, 2>&);
-
- // 2D Points
- template std::istream& operator>>(std::istream& is, PointT<double, 2>&);
- template std::istream& operator>>(std::istream& is, PointT<float, 2>&);
- template std::istream& operator>>(std::istream& is, PointT<int, 2>&);
-
}
Copied: trunk/Core/Geometry/VectorT.h (from r885,
trunk/Core/Geometry/PointVector.h)
==============================================================================
--- trunk/Core/Geometry/PointVector.h (original)
+++ trunk/Core/Geometry/VectorT.h Thu Feb 16 17:08:22 2006
@@ -1,15 +1,44 @@
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005-2006
+ Scientific Computing and Imaging Institute, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
/*
- PointT and VectorT are made to be templated with floating point
- types. If you use an integral type, you could get into trouble with
- certain functions that compute division. Be warned!
+ VectorT is made to be templated with floating point types. If you
+ use an integral type, you could get into trouble with certain
+ functions that compute division. Be warned!
*/
-#ifndef Manta_Core_PointVector_h
-#define Manta_Core_PointVector_h
+#ifndef Manta_Core_VectorT_h
+#define Manta_Core_VectorT_h
-#include <MantaTypes.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Math/Expon.h>
#include <Core/Math/MinMax.h>
#include <Core/Math/MiscMath.h>
@@ -18,14 +47,12 @@
#include <iosfwd>
#include <sgi_stl_warnings_on.h>
-#include <math.h>
-
namespace Manta {
- template<typename T, int Dim>
- class VectorT {
+ template<typename T, int Dim>
+ class VectorT {
public:
typedef T ComponentType;
-
+
VectorT() {
}
#ifndef SWIG
@@ -33,22 +60,30 @@
typedef char unnamed[ Dim == 2 ? 1 : 0 ];
data[0] = x; data[1] = y;
}
-#endif
+#endif
VectorT(T x, T y, T z) {
typedef char unnamed[ Dim == 3 ? 1 : 0 ];
data[0] = x; data[1] = y; data[2] = z;
}
- explicit VectorT( const PointT<T,Dim> ©) {
- for (int i=0;i<Dim;i++)
- data[i] = copy[i];
+ VectorT(const Vector& copy) {
+ typedef char unnamed[ Dim == 3 ? 1 : 0 ];
+ data[0] = copy[0];
+ data[1] = copy[1];
+ data[2] = copy[2];
+ }
+
+ // Copy from another vector of the same size.
+ template< typename S >
+ VectorT(const VectorT<S, Dim>& copy) {
+ for(int i=0;i<Dim;i++)
+ data[i] = static_cast<T>(copy[i]);
}
- // Copy from another vector of the same size.
- template< typename S >
- VectorT(const VectorT<S, Dim> ©) {
+ // Copy from same type and size.
+ VectorT(const VectorT<T, Dim>& copy) {
for(int i=0;i<Dim;i++)
- data[i] = (T)copy[i];
+ data[i] = copy[i];
}
#ifndef SWIG
@@ -74,13 +109,13 @@
return data[2];
}
#ifndef SWIG
- const T &operator[](int i) const {
+ const T& operator[](int i) const {
return data[i];
}
- T &operator[] ( int i ) {
+ T& operator[] ( int i ) {
return data[i];
}
-
+
#else
%extend {
T& __getitem__( int i ) {
@@ -184,16 +219,30 @@
return sum;
}
+ // GCC and perhaps other compilers have a hard time optimizing
+ // with additional levels of function calls (i.e. *this *= scale).
+ // Because of this, we try to minimize the number of function
+ // calls we make and do explicit inlining.
T normalize() {
- T l = length();
+ T sum = 0;
+ for(int i=0;i<Dim;i++)
+ sum += data[i]*data[i];
+ T l = SCIRun::Sqrt(sum);
T scale = 1/l;
- *this *= scale;
+ for(int i=0;i<Dim;i++)
+ data[i] *= scale;
return l;
}
VectorT<T, Dim> normal() const {
- T l = length();
+ T sum = 0;
+ for(int i=0;i<Dim;i++)
+ sum += data[i]*data[i];
+ T l = SCIRun::Sqrt(sum);
T scale = 1/l;
- return *this * scale;
+ VectorT<T, Dim> result;
+ for(int i=0;i<Dim;i++)
+ result.data[i] = data[i] * scale;
+ return result;
}
T minComponent() const {
T min = data[0];
@@ -253,197 +302,34 @@
private:
T data[Dim];
- // Do not use this function!!!! Use getDataPtr() instead.
- // const T *operator &() const { return data; }
- };
-
-
- template<typename T, int Dim>
- class PointT {
- public:
- typedef T ScalarType;
-
- PointT() {
- }
-
-#ifndef SWIG
- PointT(T x, T y) {
- typedef char unnamed[ Dim == 2 ? 1 : 0 ];
- data[0] = x; data[1] = y;
- }
-#endif
- PointT(T x, T y, T z) {
- typedef char unnamed[ Dim == 3 ? 1 : 0 ];
- data[0] = x; data[1] = y; data[2] = z;
- }
-
- template< typename S >
- PointT(const PointT<S, Dim>& copy) {
- for(int i=0;i<Dim;i++)
- data[i] = (T)copy[i];
- }
-
- explicit PointT( const VectorT<T,Dim> © ) {
- for (int i=0;i<Dim;++i)
- data[i] = copy[i];
- }
-
- bool operator==(const PointT<T, Dim>& right) const {
- for (int i = 0; i < Dim; ++i)
- if(data[i] != right.data[i])
- return false;
- return true;
- }
-#ifndef SWIG
- template< typename S >
- PointT<T, Dim>& operator=(const PointT<S, Dim>& copy) {
- for(int i=0;i<Dim;i++)
- data[i] = (T)copy[i];
- return *this;
- }
-#endif
-
- ~PointT() {
- }
-
- T x() const {
- return data[0];
- }
- T y() const {
- return data[1];
- }
- T z() const {
- typedef char unnamed[ Dim == 3 ? 1 : 0 ];
- return data[2];
- }
-#ifndef SWIG
- T operator[](int i) const {
- return data[i];
- }
- T &operator[](int i) {
- return data[i];
- }
-
-#else
- %extend {
- T& __getitem__( int i ) {
- return self->operator[](i);
- }
- }
-#endif
- // One might be tempted to add an "operator &" function, but
- // that could lead to problems when you want an address to the
- // object rather than a pointer to data.
- const T* getDataPtr() const { return data; }
-
- VectorT<T, Dim> operator-(const PointT<T, Dim>& p) const {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = data[i] - p[i];
- return result;
- }
- PointT<T, Dim> operator-(const VectorT<T, Dim>& v) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] - v[i];
- return result;
- }
- PointT<T, Dim>& operator-=(const VectorT<T, Dim>& v) {
- for(int i=0;i<Dim;i++)
- data[i] -= v[i];
- return *this;
- }
-
- PointT<T, Dim> operator+(const VectorT<T, Dim>& v) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] + v[i];
- return result;
- }
- PointT<T, Dim>& operator+=(const VectorT<T, Dim>& v) {
- for(int i=0;i<Dim;i++)
- data[i] += v[i];
- return *this;
- }
-
- // These are non-natural points operations. They are sometimes needed,
so
- // we allow them but you need to explicitly type the method.
- PointT<T, Dim> multipliedBy(T s) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] * s;
- return result;
- }
- PointT<T, Dim> multipliedBy(const VectorT<T, Dim>& v) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] * v[i];
- return result;
- }
- PointT<T, Dim> addedTo(const PointT<T, Dim>& v) const {
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result.data[i] = data[i] + v[i];
- return result;
- }
- // This one returns void instead of a reference to itself so that it is
harder
- // to use the wrong form and end up changing a variable without
realizing it
- void multiplyBy(T s) {
- for(int i=0;i<Dim;i++)
- data[i] *= s;
- }
- void multiplyBy(const VectorT<T, Dim>& v){
- for(int i=0;i<Dim;i++)
- data[i] *= v[i];
- }
- void addTo(const PointT<T, Dim>& v){
- for(int i=0;i<Dim;i++)
- data[i] += v[i];
- }
-
- private:
- T data[Dim];
-
- // Do not use this function!!!! Use getDataPtr() instead.
- // const T *operator &() const { return data; }
+ // Do not use this function!!!! Use getDataPtr() instead.
+ // const T *operator &() const { return data; }
};
- // Two multiplication by a scalar operators.
- template<typename T, int Dim, typename S >
- inline VectorT<T, Dim> operator*(S s, const VectorT<T, Dim>& v)
- {
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = s * (S)v[i];
- return result;
- }
- template<typename T, int Dim, typename S >
- inline VectorT<T, Dim> operator*(const VectorT<T, Dim>& v, S s)
- {
- return operator*((T)s,v);
- }
-
- template<typename T, int Dim>
- inline T Dot(const VectorT<T, Dim>& v1, const VectorT<T, Dim>& v2)
+ // Two multiplication by a scalar operators.
+ template<typename T, int Dim, typename S >
+ inline VectorT<T, Dim> operator*(S s, const VectorT<T, Dim>& v)
{
- T result = 0;
+ T scalar = static_cast<T>(s);
+ VectorT<T, Dim> result;
for(int i=0;i<Dim;i++)
- result += v1[i] * v2[i];
+ result[i] = scalar * v[i];
return result;
}
- template<typename T, int Dim>
- inline T Dot(const VectorT<T, Dim>& v1, const PointT<T, Dim>& v2)
+ template<typename T, int Dim, typename S >
+ inline VectorT<T, Dim> operator*(const VectorT<T, Dim>& v, S s)
{
- T result = 0;
+ T scalar = static_cast<T>(s);
+ VectorT<T, Dim> result;
for(int i=0;i<Dim;i++)
- result += v1[i] * v2[i];
+ result[i] = v[i] * scalar;
return result;
}
- template<typename T, int Dim>
- inline T Dot(const PointT<T, Dim>& v1, const VectorT<T, Dim>& v2)
+ template<typename T, int Dim>
+ inline T Dot(const VectorT<T, Dim>& v1, const VectorT<T, Dim>& v2)
{
T result = 0;
for(int i=0;i<Dim;i++)
@@ -451,77 +337,54 @@
return result;
}
-
// Cross product is only defined for R3
- template<typename T>
- inline VectorT<T, 3> Cross(const VectorT<T, 3>& v1, const VectorT<T, 3>&
v2)
- {
- return VectorT<T, 3>(v1.y()*v2.z() - v1.z()*v2.y(),
- v1.z()*v2.x() - v1.x()*v2.z(),
- v1.x()*v2.y() - v1.y()*v2.x());
- }
-
- template<typename T, int Dim>
- inline VectorT<T, Dim> Min(const VectorT<T, Dim>& v1, const VectorT<T,
Dim>& v2)
- {
- using SCIRun::Min;
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Min(v1[i], v2[i]);
- return result;
- }
-
- template<typename T, int Dim>
- inline VectorT<T, Dim> Max(const VectorT<T, Dim>& v1, const VectorT<T,
Dim>& v2)
- {
- using SCIRun::Max;
- VectorT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Max(v1[i], v2[i]);
- return result;
- }
-
- template<typename T, int Dim>
- inline PointT<T, Dim> Min(const PointT<T, Dim>& p1, const PointT<T,
Dim>& p2)
- {
- using SCIRun::Min;
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Min(p1[i], p2[i]);
- return result;
- }
-
- template<typename T, int Dim>
- inline PointT<T, Dim> Max(const PointT<T, Dim>& p1, const PointT<T,
Dim>& p2)
- {
- using SCIRun::Max;
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Max(p1[i], p2[i]);
- return result;
- }
+ template<typename T>
+ inline VectorT<T, 3> Cross(const VectorT<T, 3>& v1, const VectorT<T, 3>&
v2)
+ {
+ return VectorT<T, 3>(v1[1]*v2[2] - v1[2]*v2[1],
+ v1[2]*v2[0] - v1[0]*v2[2],
+ v1[0]*v2[1] - v1[1]*v2[0]);
+ }
- template<typename T, int Dim>
- inline PointT<T, Dim> Interpolate(const PointT<T, Dim>& p1, const
PointT<T, Dim>& p2, T weight)
- {
- using SCIRun::Interpolate;
- PointT<T, Dim> result;
- for(int i=0;i<Dim;i++)
- result[i] = Interpolate(p1[i], p2[i], weight);
- return result;
- }
+ template<typename T, int Dim>
+ inline VectorT<T, Dim> Min(const VectorT<T, Dim>& v1,
+ const VectorT<T, Dim>& v2)
+ {
+ using SCIRun::Min;
+ VectorT<T, Dim> result;
+ for(int i=0;i<Dim;i++)
+ result[i] = Min(v1[i], v2[i]);
+ return result;
+ }
template<typename T, int Dim>
- std::ostream &operator<< (std::ostream &os, const VectorT<T,Dim> &v);
+ inline VectorT<T, Dim> Max(const VectorT<T, Dim>& v1,
+ const VectorT<T, Dim>& v2)
+ {
+ using SCIRun::Max;
+ VectorT<T, Dim> result;
+ for(int i=0;i<Dim;i++)
+ result[i] = Max(v1[i], v2[i]);
+ return result;
+ }
template<typename T, int Dim>
- std::ostream &operator<< (std::ostream &os, const PointT<T,Dim> &v);
+ inline VectorT<T, Dim> Interpolate(const VectorT<T, Dim>& p1,
+ const VectorT<T, Dim>& p2,
+ T weight)
+ {
+ using SCIRun::Interpolate;
+ VectorT<T, Dim> result;
+ for(int i=0;i<Dim;i++)
+ result[i] = Interpolate(p1[i], p2[i], weight);
+ return result;
+ }
template<typename T, int Dim>
- std::istream &operator>> (std::istream &is, VectorT<T,Dim> &v);
-
+ std::ostream& operator<< (std::ostream& os, const VectorT<T,Dim>& v);
+
template<typename T, int Dim>
- std::istream &operator>> (std::istream &is, PointT<T,Dim> &v);
+ std::istream& operator>> (std::istream& is, VectorT<T,Dim>& v);
}
#endif
Modified: trunk/Core/Math/HaltonSequence.h
==============================================================================
--- trunk/Core/Math/HaltonSequence.h (original)
+++ trunk/Core/Math/HaltonSequence.h Thu Feb 16 17:08:22 2006
@@ -30,7 +30,7 @@
*/
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/VectorT.h>
namespace Manta {
@@ -40,7 +40,7 @@
HaltonSequence( int n_ = 1 ) : n( n ) { };
// Generate the next number in the sequence.
- void next( PointT<T,S> &p ) {
+ void next( VectorT<T,S>& p ) {
static const int halton_sequence_primes[] = { 2, 3, 5, 7 };
for (int i=0;i<S;++i) {
p[i] = folded_radical_inverse( n, halton_sequence_primes[i] );
Modified: trunk/Core/Math/Noise.cc
==============================================================================
--- trunk/Core/Math/Noise.cc (original)
+++ trunk/Core/Math/Noise.cc Thu Feb 16 17:08:22 2006
@@ -1,5 +1,5 @@
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Noise.h>
@@ -31,7 +31,7 @@
118, 240, 128, 11, 211, 153, 42, 149, 216, 93, 69, 61, 220, 47, 199,
219, 124, 80, 26, 58, 162, 39, 246, 192
};
-
+
/**
* This is the table of permutations required by the noise functions to
* hash their input to generate the Y coordinates.
@@ -55,7 +55,7 @@
132, 51, 131, 255, 144, 8, 224, 173, 153, 242, 160, 29, 43, 149, 6,
155, 148, 175, 53, 151, 250, 174, 59, 187, 119
};
-
+
/**
* This is the table of permutations required by the noise functions to
* hash their input to generate the Z coordinates.
@@ -79,13 +79,13 @@
93, 246, 179, 148, 230, 234, 233, 193, 103, 189, 14, 190, 92, 149, 184,
202, 205, 111, 98, 218, 145, 48, 136, 113, 150, 6
};
-
+
/**
* A table of 256 random values, evenly distributed between -1.0 and 1.0.
* The values in the noise permutation tables can be used to index into
* this table to get the gradients for the noise.
*/
- static double Noise1DValueTable[] = {
+ static Real Noise1DValueTable[] = {
0.47451, 0.482353, 0.670588, 0.545098, 0.803922, -0.443137, -0.678431,
0.32549, 0.45098, 0.396078, 0.905882, -0.0666667, -0.466667, 0.733333,
0.87451, 0.568627, 0.921569, -0.584314, 0.262745, -0.670588, 0.254902,
@@ -128,14 +128,14 @@
-0.207843, -0.733333, -0.913725, -0.498039, 0.105882, -0.0352941,
-0.529412
};
-
+
/**
* A table of 256 random vectors, evenly distributed over the unit sphere
* (precalculated using point repulsion). The values in the noise
* permutation tables can be used to index into this table to get the
* gradients for the noise.
*/
- static double Noise3DValueTable[][ 3 ] = {
+ static Real Noise3DValueTable[][ 3 ] = {
{ -0.439336, 0.540416, 0.71759 }, { 0.183348, 0.923971, 0.33565 },
{ -0.15203, -0.392751, -0.906991 }, { 0.707649, 0.112768, 0.697507 },
{ 0.136611, -0.456018, 0.879423 }, { -0.414372, -0.868792, -0.271103 },
@@ -266,124 +266,122 @@
{ 0.238053, -0.36183, -0.901338 }, { 0.5581, -0.681458, -0.473433 }
};
- double ScalarNoise(
- Point const &location )
+ Real ScalarNoise( Vector const& location )
{
int integer_of_x = Floor( location.x() );
int integer_of_y = Floor( location.y() );
int integer_of_z = Floor( location.z() );
- double offset_of_x = location.x() - integer_of_x;
- double offset_of_y = location.y() - integer_of_y;
- double offset_of_z = location.z() - integer_of_z;
- double fade_x = offset_of_x * offset_of_x * offset_of_x * ( offset_of_x
* ( offset_of_x * 6.0 - 15.0 ) + 10.0 );
- double fade_y = offset_of_y * offset_of_y * offset_of_y * ( offset_of_y
* ( offset_of_y * 6.0 - 15.0 ) + 10.0 );
- double fade_z = offset_of_z * offset_of_z * offset_of_z * ( offset_of_z
* ( offset_of_z * 6.0 - 15.0 ) + 10.0 );
+ Real offset_of_x = location.x() - integer_of_x;
+ Real offset_of_y = location.y() - integer_of_y;
+ Real offset_of_z = location.z() - integer_of_z;
+ Real fade_x = offset_of_x * offset_of_x * offset_of_x * ( offset_of_x *
( offset_of_x * 6 - 15 ) + 10 );
+ Real fade_y = offset_of_y * offset_of_y * offset_of_y * ( offset_of_y *
( offset_of_y * 6 - 15 ) + 10 );
+ Real fade_z = offset_of_z * offset_of_z * offset_of_z * ( offset_of_z *
( offset_of_z * 6 - 15 ) + 10 );
int hash_0 = NoiseXPermutationTable[ integer_of_x & 0xFF ];
int hash_00 = NoiseXPermutationTable[ ( hash_0 + integer_of_y ) & 0xFF ];
int hash_000 = NoiseXPermutationTable[ ( hash_00 + integer_of_z ) & 0xFF
];
int hash_001 = NoiseXPermutationTable[ ( hash_00 + integer_of_z + 1 ) &
0xFF ];
using SCIRun::Interpolate;
- double value_00 = Interpolate( ( Noise3DValueTable[ hash_000 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_000 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_000 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_001 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_001 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_001 ][ 2 ] * (
offset_of_z - 1.0 ) ),
- fade_z );
+ Real value_00 = Interpolate( ( Noise3DValueTable[ hash_000 ][ 0 ] *
offset_of_x +
+ Noise3DValueTable[ hash_000 ][ 1 ] *
offset_of_y +
+ Noise3DValueTable[ hash_000 ][ 2 ] *
offset_of_z ),
+ ( Noise3DValueTable[ hash_001 ][ 0 ] *
offset_of_x +
+ Noise3DValueTable[ hash_001 ][ 1 ] *
offset_of_y +
+ Noise3DValueTable[ hash_001 ][ 2 ] * (
offset_of_z - 1 ) ),
+ fade_z );
int hash_01 = NoiseXPermutationTable[ ( hash_0 + integer_of_y + 1 ) &
0xFF ];
int hash_010 = NoiseXPermutationTable[ ( hash_01 + integer_of_z ) & 0xFF
];
int hash_011 = NoiseXPermutationTable[ ( hash_01 + integer_of_z + 1 ) &
0xFF ];
- double value_01 = Interpolate( ( Noise3DValueTable[ hash_010 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_010 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_010 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_011 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_011 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_011 ][ 2 ] * (
offset_of_z - 1.0 ) ),
- fade_z );
- double value_0 = Interpolate( value_00, value_01, fade_y );
+ Real value_01 = Interpolate( ( Noise3DValueTable[ hash_010 ][ 0 ] *
offset_of_x +
+ Noise3DValueTable[ hash_010 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_010 ][ 2 ] *
offset_of_z ),
+ ( Noise3DValueTable[ hash_011 ][ 0 ] *
offset_of_x +
+ Noise3DValueTable[ hash_011 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_011 ][ 2 ] * (
offset_of_z - 1 ) ),
+ fade_z );
+ Real value_0 = Interpolate( value_00, value_01, fade_y );
int hash_1 = NoiseXPermutationTable[ ( integer_of_x + 1 ) & 0xFF ];
int hash_10 = NoiseXPermutationTable[ ( hash_1 + integer_of_y ) & 0xFF ];
int hash_100 = NoiseXPermutationTable[ ( hash_10 + integer_of_z ) & 0xFF
];
int hash_101 = NoiseXPermutationTable[ ( hash_10 + integer_of_z + 1 ) &
0xFF ];
- double value_10 = Interpolate( ( Noise3DValueTable[ hash_100 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_100 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_100 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_101 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_101 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_101 ][ 2 ] * (
offset_of_z - 1.0 ) ),
- fade_z );
+ Real value_10 = Interpolate( ( Noise3DValueTable[ hash_100 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_100 ][ 1 ] *
offset_of_y +
+ Noise3DValueTable[ hash_100 ][ 2 ] *
offset_of_z ),
+ ( Noise3DValueTable[ hash_101 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_101 ][ 1 ] *
offset_of_y +
+ Noise3DValueTable[ hash_101 ][ 2 ] * (
offset_of_z - 1 ) ),
+ fade_z );
int hash_11 = NoiseXPermutationTable[ ( hash_1 + integer_of_y + 1 ) &
0xFF ];
int hash_110 = NoiseXPermutationTable[ ( hash_11 + integer_of_z ) & 0xFF
];
int hash_111 = NoiseXPermutationTable[ ( hash_11 + integer_of_z + 1 ) &
0xFF ];
- double value_11 = Interpolate( ( Noise3DValueTable[ hash_110 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_110 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_110 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_111 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_111 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_111 ][ 2 ] * (
offset_of_z - 1.0 ) ),
- fade_z );
- double value_1 = Interpolate( value_10, value_11, fade_y );
+ Real value_11 = Interpolate( ( Noise3DValueTable[ hash_110 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_110 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_110 ][ 2 ] *
offset_of_z ),
+ ( Noise3DValueTable[ hash_111 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_111 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_111 ][ 2 ] * (
offset_of_z - 1 ) ),
+ fade_z );
+ Real value_1 = Interpolate( value_10, value_11, fade_y );
return Interpolate( value_0, value_1, fade_x );
}
-
- Vector const VectorNoise(
- Point const &location )
+
+ Vector const VectorNoise( Vector const& location )
{
int integer_of_x = Floor( location.x() );
int integer_of_y = Floor( location.y() );
int integer_of_z = Floor( location.z() );
- double offset_of_x = location.x() - integer_of_x;
- double offset_of_y = location.y() - integer_of_y;
- double offset_of_z = location.z() - integer_of_z;
- double fade_x = offset_of_x * offset_of_x * offset_of_x * ( offset_of_x
* ( offset_of_x * 6.0 - 15.0 ) + 10.0 );
- double fade_y = offset_of_y * offset_of_y * offset_of_y * ( offset_of_y
* ( offset_of_y * 6.0 - 15.0 ) + 10.0 );
- double fade_z = offset_of_z * offset_of_z * offset_of_z * ( offset_of_z
* ( offset_of_z * 6.0 - 15.0 ) + 10.0 );
+ Real offset_of_x = location.x() - integer_of_x;
+ Real offset_of_y = location.y() - integer_of_y;
+ Real offset_of_z = location.z() - integer_of_z;
+ Real fade_x = offset_of_x * offset_of_x * offset_of_x * ( offset_of_x *
( offset_of_x * 6 - 15 ) + 10 );
+ Real fade_y = offset_of_y * offset_of_y * offset_of_y * ( offset_of_y *
( offset_of_y * 6 - 15 ) + 10 );
+ Real fade_z = offset_of_z * offset_of_z * offset_of_z * ( offset_of_z *
( offset_of_z * 6 - 15 ) + 10 );
int hash_0 = NoiseXPermutationTable[ integer_of_x & 0xFF ];
int hash_00 = NoiseXPermutationTable[ ( hash_0 + integer_of_y ) & 0xFF ];
int hash_000 = NoiseXPermutationTable[ ( hash_00 + integer_of_z ) & 0xFF
];
int hash_001 = NoiseXPermutationTable[ ( hash_00 + integer_of_z + 1 ) &
0xFF ];
using SCIRun::Interpolate;
- double value_00 = Interpolate( ( Noise3DValueTable[ hash_000 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_000 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_000 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_001 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_001 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_001 ][ 2 ] * (
offset_of_z - 1.0 ) ),
- fade_z );
+ Real value_00 = Interpolate( ( Noise3DValueTable[ hash_000 ][ 0 ] *
offset_of_x +
+ Noise3DValueTable[ hash_000 ][ 1 ] *
offset_of_y +
+ Noise3DValueTable[ hash_000 ][ 2 ] *
offset_of_z ),
+ ( Noise3DValueTable[ hash_001 ][ 0 ] *
offset_of_x +
+ Noise3DValueTable[ hash_001 ][ 1 ] *
offset_of_y +
+ Noise3DValueTable[ hash_001 ][ 2 ] * (
offset_of_z - 1 ) ),
+ fade_z );
int hash_01 = NoiseXPermutationTable[ ( hash_0 + integer_of_y + 1 ) &
0xFF ];
int hash_010 = NoiseXPermutationTable[ ( hash_01 + integer_of_z ) & 0xFF
];
int hash_011 = NoiseXPermutationTable[ ( hash_01 + integer_of_z + 1 ) &
0xFF ];
- double value_01 = Interpolate( ( Noise3DValueTable[ hash_010 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_010 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_010 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_011 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_011 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_011 ][ 2 ] * (
offset_of_z - 1.0 ) ),
- fade_z );
- double value_0 = Interpolate( value_00, value_01, fade_y );
+ Real value_01 = Interpolate( ( Noise3DValueTable[ hash_010 ][ 0 ] *
offset_of_x +
+ Noise3DValueTable[ hash_010 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_010 ][ 2 ] *
offset_of_z ),
+ ( Noise3DValueTable[ hash_011 ][ 0 ] *
offset_of_x +
+ Noise3DValueTable[ hash_011 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_011 ][ 2 ] * (
offset_of_z - 1 ) ),
+ fade_z );
+ Real value_0 = Interpolate( value_00, value_01, fade_y );
int hash_1 = NoiseXPermutationTable[ ( integer_of_x + 1 ) & 0xFF ];
int hash_10 = NoiseXPermutationTable[ ( hash_1 + integer_of_y ) & 0xFF ];
int hash_100 = NoiseXPermutationTable[ ( hash_10 + integer_of_z ) & 0xFF
];
int hash_101 = NoiseXPermutationTable[ ( hash_10 + integer_of_z + 1 ) &
0xFF ];
- double value_10 = Interpolate( ( Noise3DValueTable[ hash_100 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_100 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_100 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_101 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_101 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_101 ][ 2 ] * (
offset_of_z - 1.0 ) ),
- fade_z );
+ Real value_10 = Interpolate( ( Noise3DValueTable[ hash_100 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_100 ][ 1 ] *
offset_of_y +
+ Noise3DValueTable[ hash_100 ][ 2 ] *
offset_of_z ),
+ ( Noise3DValueTable[ hash_101 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_101 ][ 1 ] *
offset_of_y +
+ Noise3DValueTable[ hash_101 ][ 2 ] * (
offset_of_z - 1 ) ),
+ fade_z );
int hash_11 = NoiseXPermutationTable[ ( hash_1 + integer_of_y + 1 ) &
0xFF ];
int hash_110 = NoiseXPermutationTable[ ( hash_11 + integer_of_z ) & 0xFF
];
int hash_111 = NoiseXPermutationTable[ ( hash_11 + integer_of_z + 1 ) &
0xFF ];
- double value_11 = Interpolate( ( Noise3DValueTable[ hash_110 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_110 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_110 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_111 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_111 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_111 ][ 2 ] * (
offset_of_z - 1.0 ) ),
- fade_z );
- double value_1 = Interpolate( value_10, value_11, fade_y );
- double x_result = Interpolate( value_0, value_1, fade_x );
+ Real value_11 = Interpolate( ( Noise3DValueTable[ hash_110 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_110 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_110 ][ 2 ] *
offset_of_z ),
+ ( Noise3DValueTable[ hash_111 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_111 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_111 ][ 2 ] * (
offset_of_z - 1 ) ),
+ fade_z );
+ Real value_1 = Interpolate( value_10, value_11, fade_y );
+ Real x_result = Interpolate( value_0, value_1, fade_x );
hash_0 = NoiseYPermutationTable[ integer_of_x & 0xFF ];
hash_00 = NoiseYPermutationTable[ ( hash_0 + integer_of_y ) & 0xFF ];
hash_000 = NoiseYPermutationTable[ ( hash_00 + integer_of_z ) & 0xFF ];
@@ -393,42 +391,42 @@
Noise3DValueTable[ hash_000 ][ 2 ] *
offset_of_z ),
( Noise3DValueTable[ hash_001 ][ 0 ] *
offset_of_x +
Noise3DValueTable[ hash_001 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_001 ][ 2 ] * (
offset_of_z - 1.0 ) ),
+ Noise3DValueTable[ hash_001 ][ 2 ] * (
offset_of_z - 1 ) ),
fade_z );
hash_01 = NoiseYPermutationTable[ ( hash_0 + integer_of_y + 1 ) & 0xFF ];
hash_010 = NoiseYPermutationTable[ ( hash_01 + integer_of_z ) & 0xFF ];
hash_011 = NoiseYPermutationTable[ ( hash_01 + integer_of_z + 1 ) & 0xFF
];
value_01 = Interpolate( ( Noise3DValueTable[ hash_010 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_010 ][ 1 ] * (
offset_of_y - 1.0 ) +
+ Noise3DValueTable[ hash_010 ][ 1 ] * (
offset_of_y - 1 ) +
Noise3DValueTable[ hash_010 ][ 2 ] *
offset_of_z ),
( Noise3DValueTable[ hash_011 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_011 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_011 ][ 2 ] * (
offset_of_z - 1.0 ) ),
+ Noise3DValueTable[ hash_011 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_011 ][ 2 ] * (
offset_of_z - 1 ) ),
fade_z );
value_0 = Interpolate( value_00, value_01, fade_y );
hash_1 = NoiseYPermutationTable[ ( integer_of_x + 1 ) & 0xFF ];
hash_10 = NoiseYPermutationTable[ ( hash_1 + integer_of_y ) & 0xFF ];
hash_100 = NoiseYPermutationTable[ ( hash_10 + integer_of_z ) & 0xFF ];
hash_101 = NoiseYPermutationTable[ ( hash_10 + integer_of_z + 1 ) & 0xFF
];
- value_10 = Interpolate( ( Noise3DValueTable[ hash_100 ][ 0 ] * (
offset_of_x - 1.0 ) +
+ value_10 = Interpolate( ( Noise3DValueTable[ hash_100 ][ 0 ] * (
offset_of_x - 1 ) +
Noise3DValueTable[ hash_100 ][ 1 ] *
offset_of_y +
Noise3DValueTable[ hash_100 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_101 ][ 0 ] * (
offset_of_x - 1.0 ) +
+ ( Noise3DValueTable[ hash_101 ][ 0 ] * (
offset_of_x - 1 ) +
Noise3DValueTable[ hash_101 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_101 ][ 2 ] * (
offset_of_z - 1.0 ) ),
+ Noise3DValueTable[ hash_101 ][ 2 ] * (
offset_of_z - 1 ) ),
fade_z );
hash_11 = NoiseYPermutationTable[ ( hash_1 + integer_of_y + 1 ) & 0xFF ];
hash_110 = NoiseYPermutationTable[ ( hash_11 + integer_of_z ) & 0xFF ];
hash_111 = NoiseYPermutationTable[ ( hash_11 + integer_of_z + 1 ) & 0xFF
];
- value_11 = Interpolate( ( Noise3DValueTable[ hash_110 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_110 ][ 1 ] * (
offset_of_y - 1.0 ) +
+ value_11 = Interpolate( ( Noise3DValueTable[ hash_110 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_110 ][ 1 ] * (
offset_of_y - 1 ) +
Noise3DValueTable[ hash_110 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_111 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_111 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_111 ][ 2 ] * (
offset_of_z - 1.0 ) ),
+ ( Noise3DValueTable[ hash_111 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_111 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_111 ][ 2 ] * (
offset_of_z - 1 ) ),
fade_z );
value_1 = Interpolate( value_10, value_11, fade_y );
- double y_result = Interpolate( value_0, value_1, fade_x );
+ Real y_result = Interpolate( value_0, value_1, fade_x );
hash_0 = NoiseZPermutationTable[ integer_of_x & 0xFF ];
hash_00 = NoiseZPermutationTable[ ( hash_0 + integer_of_y ) & 0xFF ];
hash_000 = NoiseZPermutationTable[ ( hash_00 + integer_of_z ) & 0xFF ];
@@ -438,47 +436,46 @@
Noise3DValueTable[ hash_000 ][ 2 ] *
offset_of_z ),
( Noise3DValueTable[ hash_001 ][ 0 ] *
offset_of_x +
Noise3DValueTable[ hash_001 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_001 ][ 2 ] * (
offset_of_z - 1.0 ) ),
+ Noise3DValueTable[ hash_001 ][ 2 ] * (
offset_of_z - 1 ) ),
fade_z );
hash_01 = NoiseZPermutationTable[ ( hash_0 + integer_of_y + 1 ) & 0xFF ];
hash_010 = NoiseZPermutationTable[ ( hash_01 + integer_of_z ) & 0xFF ];
hash_011 = NoiseZPermutationTable[ ( hash_01 + integer_of_z + 1 ) & 0xFF
];
value_01 = Interpolate( ( Noise3DValueTable[ hash_010 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_010 ][ 1 ] * (
offset_of_y - 1.0 ) +
+ Noise3DValueTable[ hash_010 ][ 1 ] * (
offset_of_y - 1 ) +
Noise3DValueTable[ hash_010 ][ 2 ] *
offset_of_z ),
( Noise3DValueTable[ hash_011 ][ 0 ] *
offset_of_x +
- Noise3DValueTable[ hash_011 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_011 ][ 2 ] * (
offset_of_z - 1.0 ) ),
+ Noise3DValueTable[ hash_011 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_011 ][ 2 ] * (
offset_of_z - 1 ) ),
fade_z );
value_0 = Interpolate( value_00, value_01, fade_y );
hash_1 = NoiseZPermutationTable[ ( integer_of_x + 1 ) & 0xFF ];
hash_10 = NoiseZPermutationTable[ ( hash_1 + integer_of_y ) & 0xFF ];
hash_100 = NoiseZPermutationTable[ ( hash_10 + integer_of_z ) & 0xFF ];
hash_101 = NoiseZPermutationTable[ ( hash_10 + integer_of_z + 1 ) & 0xFF
];
- value_10 = Interpolate( ( Noise3DValueTable[ hash_100 ][ 0 ] * (
offset_of_x - 1.0 ) +
+ value_10 = Interpolate( ( Noise3DValueTable[ hash_100 ][ 0 ] * (
offset_of_x - 1 ) +
Noise3DValueTable[ hash_100 ][ 1 ] *
offset_of_y +
Noise3DValueTable[ hash_100 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_101 ][ 0 ] * (
offset_of_x - 1.0 ) +
+ ( Noise3DValueTable[ hash_101 ][ 0 ] * (
offset_of_x - 1 ) +
Noise3DValueTable[ hash_101 ][ 1 ] *
offset_of_y +
- Noise3DValueTable[ hash_101 ][ 2 ] * (
offset_of_z - 1.0 ) ),
+ Noise3DValueTable[ hash_101 ][ 2 ] * (
offset_of_z - 1 ) ),
fade_z );
hash_11 = NoiseZPermutationTable[ ( hash_1 + integer_of_y + 1 ) & 0xFF ];
hash_110 = NoiseZPermutationTable[ ( hash_11 + integer_of_z ) & 0xFF ];
hash_111 = NoiseZPermutationTable[ ( hash_11 + integer_of_z + 1 ) & 0xFF
];
- value_11 = Interpolate( ( Noise3DValueTable[ hash_110 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_110 ][ 1 ] * (
offset_of_y - 1.0 ) +
+ value_11 = Interpolate( ( Noise3DValueTable[ hash_110 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_110 ][ 1 ] * (
offset_of_y - 1 ) +
Noise3DValueTable[ hash_110 ][ 2 ] *
offset_of_z ),
- ( Noise3DValueTable[ hash_111 ][ 0 ] * (
offset_of_x - 1.0 ) +
- Noise3DValueTable[ hash_111 ][ 1 ] * (
offset_of_y - 1.0 ) +
- Noise3DValueTable[ hash_111 ][ 2 ] * (
offset_of_z - 1.0 ) ),
+ ( Noise3DValueTable[ hash_111 ][ 0 ] * (
offset_of_x - 1 ) +
+ Noise3DValueTable[ hash_111 ][ 1 ] * (
offset_of_y - 1 ) +
+ Noise3DValueTable[ hash_111 ][ 2 ] * (
offset_of_z - 1 ) ),
fade_z );
value_1 = Interpolate( value_10, value_11, fade_y );
- double z_result = Interpolate( value_0, value_1, fade_x );
+ Real z_result = Interpolate( value_0, value_1, fade_x );
return Vector( x_result, y_result, z_result );
}
-
- double ScalarCellNoise(
- Point const &location )
+
+ Real ScalarCellNoise( Vector const& location )
{
int integer_of_x = Floor( location.x() );
int integer_of_y = Floor( location.y() );
@@ -488,9 +485,8 @@
hash = NoiseXPermutationTable[ ( hash + integer_of_z ) & 0xFF ];
return Noise1DValueTable[ hash ];
}
-
- Vector const VectorCellNoise(
- Point const &location )
+
+ Vector const VectorCellNoise( Vector const& location )
{
int integer_of_x = Floor( location.x() );
int integer_of_y = Floor( location.y() );
@@ -498,68 +494,65 @@
int hash = NoiseXPermutationTable[ integer_of_x & 0xFF ];
hash = NoiseXPermutationTable[ ( hash + integer_of_y ) & 0xFF ];
hash = NoiseXPermutationTable[ ( hash + integer_of_z ) & 0xFF ];
- double x_result = Noise1DValueTable[ hash ];
+ Real x_result = Noise1DValueTable[ hash ];
hash = NoiseYPermutationTable[ integer_of_x & 0xFF ];
hash = NoiseYPermutationTable[ ( hash + integer_of_y ) & 0xFF ];
hash = NoiseYPermutationTable[ ( hash + integer_of_z ) & 0xFF ];
- double y_result = Noise1DValueTable[ hash ];
+ Real y_result = Noise1DValueTable[ hash ];
hash = NoiseZPermutationTable[ integer_of_x & 0xFF ];
hash = NoiseZPermutationTable[ ( hash + integer_of_y ) & 0xFF ];
hash = NoiseZPermutationTable[ ( hash + integer_of_z ) & 0xFF ];
- double z_result = Noise1DValueTable[ hash ];
+ Real z_result = Noise1DValueTable[ hash ];
return Vector( x_result, y_result, z_result );
}
-
- double ScalarFBM(
- Point const &location,
- int const octaves,
- double const lacunarity,
- double const gain )
+
+ Real ScalarFBM( Vector const& location,
+ int octaves,
+ Real lacunarity,
+ Real gain )
{
- double sum = 0.0;
- double scale = 1.0;
- double amplitude = 1.0;
+ Real sum = 0;
+ Real scale = 1;
+ Real amplitude = 1;
for( int octave = 0; octave < octaves; ++octave ) {
- sum += amplitude * ScalarNoise( location.multipliedBy(scale) );
+ sum += amplitude * ScalarNoise( location * scale );
scale *= lacunarity;
amplitude *= gain;
}
return sum;
}
-
- Vector const VectorFBM(
- Point const &location,
- int const octaves,
- double const lacunarity,
- double const gain )
+
+ Vector const VectorFBM( Vector const& location,
+ int octaves,
+ Real lacunarity,
+ Real gain )
{
- Vector sum( 0.0, 0.0, 0.0 );
- double scale = 1.0;
- double amplitude = 1.0;
+ Vector sum( 0, 0, 0 );
+ Real scale = 1;
+ Real amplitude = 1;
for( int octave = 0; octave < octaves; ++octave ) {
- sum += amplitude * VectorNoise( location.multipliedBy(scale) );
+ sum += amplitude * VectorNoise( location * scale );
scale *= lacunarity;
amplitude *= gain;
}
return sum;
}
-
- double Turbulence(
- Point const &location,
- int const octaves,
- double const lacunarity,
- double const gain )
+
+ Real Turbulence( Vector const& location,
+ int octaves,
+ Real lacunarity,
+ Real gain )
{
- double sum = 0.0;
- double scale = 1.0;
- double amplitude = 1.0;
+ Real sum = 0;
+ Real scale = 1;
+ Real amplitude = 1;
for( int octave = 0; octave < octaves; ++octave ) {
- sum += amplitude * fabs( ScalarNoise( location.multipliedBy(scale) ) );
+ sum += amplitude * Abs( ScalarNoise( location * scale ) );
scale *= lacunarity;
amplitude *= gain;
}
return sum;
}
-
+
}
Modified: trunk/Core/Math/Noise.h
==============================================================================
--- trunk/Core/Math/Noise.h (original)
+++ trunk/Core/Math/Noise.h Thu Feb 16 17:08:22 2006
@@ -1,7 +1,8 @@
#ifndef MANTA_CORE_MATH_NOISE_H
#define MANTA_CORE_MATH_NOISE_H
-#include <Core/Geometry/PointVector.h>
+#include <MantaTypes.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
@@ -15,8 +16,7 @@
* @param location the point to evaluate the noise at
* @return a signed scalar noise value
*/
- double ScalarNoise(
- Point const &location );
+ Real ScalarNoise( Vector const& location );
/**
* Computes the vector-valued Perlin noise for a given point. The
@@ -27,8 +27,7 @@
* @param location the point to evaluate the noise at
* @return a signed vector
*/
- Vector const VectorNoise(
- Point const &location );
+ Vector const VectorNoise( Vector const& location );
/**
* Computes a pseudo-random number that is constant between the integer
@@ -38,8 +37,7 @@
* @param location the point to evaluate the noise at
* @return a scalar value between -1 and 1
*/
- double ScalarCellNoise(
- Point const &location );
+ Real ScalarCellNoise( Vector const& location );
/**
* Computes a pseudo-random vecotr that is constant between the integer
@@ -50,9 +48,8 @@
* @param location the point to evaluate the noise at
* @return a vector with component values between -1 and 1
*/
- Vector const VectorCellNoise(
- Point const &location );
-
+ Vector const VectorCellNoise( Vector const& location );
+
/**
* Scalar-valued fractional brownian motion noise, a.k.a. fBm noise.
* This is just the sum of several Perlin noise computations with
@@ -68,11 +65,10 @@
* @param gain how the range is scaled at each octave.
* @return the scalar-value at that point
*/
- double ScalarFBM(
- Point const &location,
- int const octaves,
- double const lacunarity,
- double const gain );
+ Real ScalarFBM( Vector const& location,
+ int octaves,
+ Real lacunarity,
+ Real gain );
/**
* Vector-valued fractional brownian motion noise, a.k.a. fBm noise.
@@ -89,11 +85,10 @@
* @param gain how the range is scaled at each octave.
* @return the vector-value at that Point
*/
- Vector const VectorFBM(
- Point const &location,
- int const octaves,
- double const lacunarity,
- double const gain );
+ Vector const VectorFBM( Vector const& location,
+ int octaves,
+ Real lacunarity,
+ Real gain );
/**
* Perlin's turbulence function. This is very similiar to the fractional
@@ -107,11 +102,10 @@
* @param gain how the range is scaled at each octave.
* @return the scalar-value at that point
*/
- double Turbulence(
- Point const &location,
- int const octaves,
- double const lacunarity,
- double const gain );
+ Real Turbulence( Vector const& location,
+ int octaves,
+ Real lacunarity,
+ Real gain );
}
Modified: trunk/Core/Math/vector2d.h
==============================================================================
--- trunk/Core/Math/vector2d.h (original)
+++ trunk/Core/Math/vector2d.h Thu Feb 16 17:08:22 2006
@@ -1,14 +1,14 @@
//vector2d .... for sampling
-#ifndef Manta_Core_vector2d_h
-#define Manta_Core_vector2d_h
+#ifndef Manta_Core_Vector2D_h
+#define Manta_Core_Vector2D_h
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/VectorT.h>
namespace Manta {
- typedef VectorT<Real, 2> vector2d;
+ typedef VectorT<Real, 2> Vector2D;
} // end namespace Manta
Modified: trunk/Core/Util/Args.cc
==============================================================================
--- trunk/Core/Util/Args.cc (original)
+++ trunk/Core/Util/Args.cc Thu Feb 16 17:08:22 2006
@@ -1,7 +1,7 @@
#include <Core/Util/Args.h>
#include <Core/Exceptions/IllegalValue.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
using namespace std;
using SCIRun::IllegalValue;
@@ -111,23 +111,6 @@
yres = tmpyres;
return true;
}
-
- bool getPointArg(int& i, const vector<string>& args, Point& p)
- {
- double x,y,z;
- if(!getDoubleArg(i, args, x))
- return false;
- if(!getDoubleArg(i, args, y)){
- i--;
- return false;
- }
- if(!getDoubleArg(i, args, z)){
- i-=2;
- return false;
- }
- p = Point(x,y,z);
- return true;
- }
bool getVectorArg(int& i, const vector<string>& args, Vector& v)
{
Modified: trunk/Core/Util/Args.h
==============================================================================
--- trunk/Core/Util/Args.h (original)
+++ trunk/Core/Util/Args.h Thu Feb 16 17:08:22 2006
@@ -10,13 +10,14 @@
#include <sgi_stl_warnings_on.h>
namespace Manta {
+ class Vector;
+
using namespace std;
bool getStringArg(int& i, const vector<string>&, string& result);
bool getDoubleArg(int& i, const vector<string>&, double& result);
bool getIntArg(int& i, const vector<string>&, int& result);
bool getLongArg(int& i, const vector<string>&, long& result);
bool getResolutionArg(int& i, const vector<string>&, int& xres, int& yres);
- bool getPointArg(int& i, const vector<string>&, Point& p);
bool getVectorArg(int& i, const vector<string>&, Vector& p);
void parseSpec(const string& spec, string& name, vector<string>& args);
Modified: trunk/Engine/Shadows/BeamShadows.cc
==============================================================================
--- trunk/Engine/Shadows/BeamShadows.cc (original)
+++ trunk/Engine/Shadows/BeamShadows.cc Thu Feb 16 17:08:22 2006
@@ -177,7 +177,7 @@
e.shadowBegin = sidx;
for(int l = 0;l<nlights;l++){
Vector dir( lights->centers[l]+Vector(0,0,radius)-e.hitPosition );
- dir+=VectorNoise(Point(dir*noisefreq))*noiseamp;
+ dir+=VectorNoise(Vector(dir*noisefreq))*noiseamp;
if(Dot(dir, e.normal) > 0){
RayPacket::Element& s = shadowRays.get(sidx++);
double length = dir.normalize();
@@ -186,7 +186,7 @@
s.hitInfo.reset(length);
}
dir =
lights->centers[l]+Vector(-2.0/3.0*M_SQRT1_2*radius,-6.0*M_SQRT1_2*radius,-1.0/3.0*radius)-e.hitPosition;
-
dir+=VectorNoise(Point((dir+Vector(0,0,31.4159))*noisefreq))*noiseamp;
+
dir+=VectorNoise(Vector((dir+Vector(0,0,31.4159))*noisefreq))*noiseamp;
if(Dot(dir, e.normal) > 0){
RayPacket::Element& s = shadowRays.get(sidx++);
double length = dir.normalize();
@@ -195,7 +195,7 @@
s.hitInfo.reset(length);
}
dir =
lights->centers[l]+Vector(-2.0/3.0*M_SQRT1_2*radius,6.0*M_SQRT1_2*radius,-1.0/3.0*radius)-e.hitPosition;
-
dir+=VectorNoise(Point((dir+Vector(0,31.4159,0))*noisefreq))*noiseamp;
+
dir+=VectorNoise(Vector((dir+Vector(0,31.4159,0))*noisefreq))*noiseamp;
if(Dot(dir, e.normal) > 0){
RayPacket::Element& s = shadowRays.get(sidx++);
double length = dir.normalize();
@@ -204,7 +204,7 @@
s.hitInfo.reset(length);
}
dir =
lights->centers[l]+Vector(4.0/3.0*M_SQRT1_2*radius,0,-1.0/3.0*radius)-e.hitPosition;
-
dir+=VectorNoise(Point((dir+Vector(31.4159,0,0))*noisefreq))*noiseamp;
+
dir+=VectorNoise(Vector((dir+Vector(31.4159,0,0))*noisefreq))*noiseamp;
if(Dot(dir, e.normal) > 0){
RayPacket::Element& s = shadowRays.get(sidx++);
double length = dir.normalize();
Modified: trunk/Interface/Camera.h
==============================================================================
--- trunk/Interface/Camera.h (original)
+++ trunk/Interface/Camera.h Thu Feb 16 17:08:22 2006
@@ -4,9 +4,10 @@
#include <MantaTypes.h>
#include <Core/Geometry/BBox.h>
+#include <Core/Geometry/AffineTransform.h>
#include <sgi_stl_warnings_off.h>
-#include <ostream>
+#include <iosfwd>
#include <sgi_stl_warnings_on.h>
namespace Manta {
@@ -24,21 +25,38 @@
virtual void dolly(Real) = 0;
// Accessors
- virtual Point getPosition() const = 0; // This method is called to get
the eye point by HeadLight etc.
- virtual Vector getUp() const = 0; // This method returns the
"horizontal center of rotation" about the camera.
- virtual Point getLookAt() const = 0; // This method returns the
"center of rotation point" about the look at point.
-
+
+
+ virtual Vector getPosition() const = 0; // This method is called
+ // to get the eye point by
+ // HeadLight etc.
+
+ virtual Vector getUp() const = 0; // This method returns the
+ // "horizontal center of
+ // rotation" about the camera.
+
+ virtual Vector getLookAt() const = 0; // This method returns the
+ // "center of rotation
+ // point" about the look at
+ // point.
+
// Reset the camera.
- virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ ) = 0;
+ virtual void reset( const Vector& eye_,
+ const Vector& up_,
+ const Vector& lookat_ ) = 0;
enum TransformCenter {
LookAt,
Eye,
Origin
};
+ // AffineTransform needs to not be a reference in order to get the
+ // transactions to work properly. A copy is needed.
virtual void transform(AffineTransform t, TransformCenter) = 0;
virtual void autoview(const BBox bbox) = 0;
- virtual void output( std::ostream &os ) = 0; // Output a text
description of the camera's state.
+ virtual void output( std::ostream& os ) = 0; // Output a text
+ // description of the
+ // camera's state.
private:
Camera(const Camera&);
Camera& operator=(const Camera&);
Modified: trunk/Interface/Light.h
==============================================================================
--- trunk/Interface/Light.h (original)
+++ trunk/Interface/Light.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Interface_Light_h
#include <Core/Color/Color.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Interface/RayPacket.h>
namespace Manta {
Modified: trunk/Interface/Material.h
==============================================================================
--- trunk/Interface/Material.h (original)
+++ trunk/Interface/Material.h Thu Feb 16 17:08:22 2006
@@ -30,8 +30,6 @@
DEALINGS IN THE SOFTWARE.
*/
-#include <Core/Geometry/PointVector.h>
-
namespace Manta {
class PreprocessContext;
class RayPacket;
Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Thu Feb 16 17:08:22 2006
@@ -4,13 +4,17 @@
#include <Core/Color/Color.h>
#include <Core/Geometry/Ray.h>
+#include <Core/Geometry/VectorT.h>
#include <Core/Math/Expon.h>
#include <Core/Util/Assert.h>
#include <Core/Util/Align.h>
#include <Interface/Parameters.h>
#include <Interface/Primitive.h>
#include <Interface/TexCoordMapper.h>
-#include <algorithm>
+
+// #include <sgi_stl_warnings_off.h>
+// #include <algorithm>
+// #include <sgi_stl_warnings_on.h>
namespace Manta {
class Material;
@@ -171,7 +175,7 @@
}
// Rays
- void setRay(int which, const Point& origin, const Vector& direction)
+ void setRay(int which, const Vector& origin, const Vector& direction)
{
for(int i=0;i<3;i++)
data->origin[i][which] = origin[i];
@@ -187,11 +191,11 @@
}
Ray getRay(int which) const
{
- return Ray(Point(data->origin[0][which], data->origin[1][which],
data->origin[2][which]),
+ return Ray(Vector(data->origin[0][which], data->origin[1][which],
data->origin[2][which]),
Vector(data->direction[0][which],
data->direction[1][which], data->direction[2][which]));
}
- void setOrigin(int which, const Point& origin)
+ void setOrigin(int which, const Vector& origin)
{
for(int i=0;i<3;i++)
data->origin[i][which] = origin[i];
@@ -204,9 +208,9 @@
///////////////////////////////////////////////////////////////////////////
// GET ORIGIN
- Point getOrigin(int which) const
+ Vector getOrigin(int which) const
{
- return Point(data->origin[0][which], data->origin[1][which],
data->origin[2][which]);
+ return Vector(data->origin[0][which], data->origin[1][which],
data->origin[2][which]);
}
Real &getOrigin(int which, int i)
@@ -429,23 +433,23 @@
}
// Texture Coordinates
- void setTexCoords(int which, const Point& tc)
+ void setTexCoords(int which, const Vector& tc)
{
for(int i=0;i<3;i++)
data->texCoords[i][which] = tc[i];
}
- void setTexCoords(int which, const PointT<Real, 2>& tc)
+ void setTexCoords(int which, const VectorT<Real, 2>& tc)
{
for(int i=0;i<2;i++)
data->texCoords[i][which] = tc[i];
}
- Point getTexCoords(int which) const
+ Vector getTexCoords(int which) const
{
- return Point(data->texCoords[0][which], data->texCoords[1][which],
data->texCoords[2][which]);
+ return Vector(data->texCoords[0][which], data->texCoords[1][which],
data->texCoords[2][which]);
}
- PointT<Real, 2> getTexCoords2(int which) const
+ VectorT<Real, 2> getTexCoords2(int which) const
{
- return PointT<Real, 2>(data->texCoords[0][which],
data->texCoords[1][which]);
+ return VectorT<Real, 2>(data->texCoords[0][which],
data->texCoords[1][which]);
}
// These aren't right - the texture object may not be consecutive
@@ -509,11 +513,11 @@
}
// Hit positions
- Point getHitPosition(int which) const
+ Vector getHitPosition(int which) const
{
- return Point(data->hitPosition[0][which], data->hitPosition[1][which],
data->hitPosition[2][which]);
+ return Vector(data->hitPosition[0][which],
data->hitPosition[1][which], data->hitPosition[2][which]);
}
- Point setHitPosition(int which, const Point& hit) const
+ Vector setHitPosition(int which, const Vector& hit) const
{
for(int i=0;i<3;i++)
data->hitPosition[i][which] = hit[which];
Modified: trunk/MantaTypes.h.CMakeTemplate
==============================================================================
--- trunk/MantaTypes.h.CMakeTemplate (original)
+++ trunk/MantaTypes.h.CMakeTemplate Thu Feb 16 17:08:22 2006
@@ -45,18 +45,6 @@
class RGBTraits;
template<typename T> class ColorSpace;
typedef ColorSpace<RGBTraits> Color;
-
- // Points/Vectors - forward declarations
- template<typename T, int Dim> class PointT;
- // Point and Vector must always use Dim = 3
- typedef PointT<Real, 3> Point;
- template<typename T, int Dim> class VectorT;
- typedef VectorT<Real, 3> Vector;
-
- // Transforms - forward declarations
- template<typename T> class AffineTransformT;
- typedef AffineTransformT<Real> AffineTransform;
-
}
#endif
Modified: trunk/Model/AmbientLights/ArcAmbient.h
==============================================================================
--- trunk/Model/AmbientLights/ArcAmbient.h (original)
+++ trunk/Model/AmbientLights/ArcAmbient.h Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#include <Interface/AmbientLight.h>
#include <Core/Color/Color.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <sgi_stl_warnings_off.h>
#include <string>
Modified: trunk/Model/Backgrounds/LinearBackground.h
==============================================================================
--- trunk/Model/Backgrounds/LinearBackground.h (original)
+++ trunk/Model/Backgrounds/LinearBackground.h Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#include <Interface/Background.h>
#include <Core/Color/Color.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
Modified: trunk/Model/Backgrounds/TextureBackground.cc
==============================================================================
--- trunk/Model/Backgrounds/TextureBackground.cc (original)
+++ trunk/Model/Backgrounds/TextureBackground.cc Thu Feb 16 17:08:22
2006
@@ -31,6 +31,7 @@
#include <MantaTypes.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
+#include <Core/Geometry/Vector.h>
using namespace Manta;
using namespace SCIRun;
@@ -59,13 +60,13 @@
{
rays.computeHitPositions();
for(int i = rays.begin();i<rays.end();i++){
- Point n = rays.getHitPosition(i);
+ Vector n = rays.getHitPosition(i);
Real angle = Clamp(n.z(), (Real)-1, (Real)1);
Real theta = Acos(angle);
Real phi = Atan2(n.x(), n.y());
Real x = (phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI);
Real y = theta*(Real)M_1_PI;
- rays.setTexCoords(i, PointT<Real, 2>(x, y));
+ rays.setTexCoords(i, VectorT<Real, 2>(x, y));
}
}
@@ -80,7 +81,7 @@
// Set the TexCoordMapper pointer.
rays.setHitTexCoordMapper(i, mapper);
// Copy the direction from old ray to the new one.
- rays.setHitPosition(i, Point(rays.getDirection(i)));
+ rays.setHitPosition(i, rays.getDirection(i));
}
// Tell the RayPacket that we have the hit positions since we just
// fed them in there.
Modified: trunk/Model/Backgrounds/TextureBackground.h
==============================================================================
--- trunk/Model/Backgrounds/TextureBackground.h (original)
+++ trunk/Model/Backgrounds/TextureBackground.h Thu Feb 16 17:08:22 2006
@@ -37,7 +37,6 @@
#include <Model/TexCoordMappers/UniformMapper.h>
#include <Interface/Texture.h>
#include <Core/Color/Color.h>
-#include <Core/Geometry/PointVector.h>
namespace Manta {
Modified: trunk/Model/Cameras/EnvironmentCamera.cc
==============================================================================
--- trunk/Model/Cameras/EnvironmentCamera.cc (original)
+++ trunk/Model/Cameras/EnvironmentCamera.cc Thu Feb 16 17:08:22 2006
@@ -16,6 +16,14 @@
using namespace std;
using SCIRun::Clamp;
+EnvironmentCamera::EnvironmentCamera(const Vector& eye_,
+ const Vector& lookat_,
+ const Vector& up_ )
+ : eye( eye_ ), lookat( lookat_ ), up( up_ )
+{
+ setup();
+}
+
EnvironmentCamera::EnvironmentCamera(const vector<string>& args)
{
bool gotEye=false;
@@ -26,11 +34,11 @@
for (int i=0; i<argc; i++) {
string arg=args[i];
if (arg=="-eye") {
- if (!getPointArg(i, args, eye))
+ if (!getVectorArg(i, args, eye))
throw IllegalArgument("EnvironmentCamera -eye", i, args);
gotEye=true;
} else if (arg=="-lookat") {
- if (!getPointArg(i, args, lookat))
+ if (!getVectorArg(i, args, lookat))
throw IllegalArgument("EnvironmentCamera -lookat", i, args);
gotLookat=true;
} else if (arg=="-up") {
@@ -57,8 +65,8 @@
return new EnvironmentCamera(args);
}
-void EnvironmentCamera::reset( const Point &eye_, const Vector &up_,
- const Point &lookat_ )
+void EnvironmentCamera::reset( const Vector &eye_, const Vector &up_,
+ const Vector &lookat_ )
{
eye = eye_;
up = up_;
@@ -138,7 +146,7 @@
void EnvironmentCamera::transform(AffineTransform t, TransformCenter center)
{
- Point cen;
+ Vector cen;
switch(center) {
case Eye:
cen=eye;
@@ -147,7 +155,7 @@
cen=lookat;
break;
case Origin:
- cen=Point(0., 0., 0.);
+ cen=Vector(0, 0, 0);
break;
}
@@ -160,9 +168,9 @@
frame_inv.invert();
AffineTransform t2=frame*t*frame_inv;
- up=t2*up;
- eye=t2*eye;
- lookat=t2*lookat;
+ up = t2.multiply_vector(up);
+ eye = t2.multiply_point(eye);
+ lookat = t2.multiply_point(lookat);
setup();
}
Modified: trunk/Model/Cameras/EnvironmentCamera.h
==============================================================================
--- trunk/Model/Cameras/EnvironmentCamera.h (original)
+++ trunk/Model/Cameras/EnvironmentCamera.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_EnvironmentCamera_h
#include <Interface/Camera.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <sgi_stl_warnings_off.h>
#include <string>
#include <vector>
@@ -14,10 +14,10 @@
class EnvironmentCamera : public Camera {
public:
+ EnvironmentCamera(const Vector& eye_, const Vector& lookat_,
+ const Vector& up_ );
EnvironmentCamera(const vector<string>& args);
- EnvironmentCamera(const Point &eye_, const Point &lookat_,
- const Vector &up_ ) :
- eye( eye_ ), lookat( lookat_ ), up( up_ ) { setup(); }
+
virtual ~EnvironmentCamera();
virtual void makeRays(RayPacket&) const;
@@ -30,18 +30,19 @@
static Camera* create(const vector<string>& args);
- virtual Point getPosition() const { return eye; }
- virtual Point getLookAt() const { return lookat; };
+ virtual Vector getPosition() const { return eye; }
+ virtual Vector getLookAt() const { return lookat; };
virtual Vector getUp() const { return up; };
- virtual void reset( const Point &eye_, const Vector &up_,
- const Point &lookat_ );
+ virtual void reset( const Vector& eye_, const Vector& up_,
+ const Vector& lookat_ );
- virtual void output( std::ostream &os );
+ virtual void output( std::ostream& os );
private:
void setup();
- Point eye;
- Point lookat;
+
+ Vector eye;
+ Vector lookat;
Vector up;
bool normalizeRays;
Modified: trunk/Model/Cameras/FisheyeCamera.cc
==============================================================================
--- trunk/Model/Cameras/FisheyeCamera.cc (original)
+++ trunk/Model/Cameras/FisheyeCamera.cc Thu Feb 16 17:08:22 2006
@@ -19,6 +19,14 @@
using namespace SCIRun;
using namespace std;
+FisheyeCamera::FisheyeCamera(const Vector& eye_, const Vector& lookat_,
+ const Vector& up_, Real hfov_)
+ : eye( eye_ ), up( up_ ), lookat( lookat_ ), hfov( hfov_ )
+{
+ setup();
+ hfov = hfov / 90;
+}
+
FisheyeCamera::FisheyeCamera(const vector<string>& args)
{
bool gotEye = false;
@@ -29,11 +37,11 @@
for(int i=0; i< argc; i++){
string arg = args[i];
if(arg == "-eye"){
- if(!getPointArg(i, args, eye))
+ if(!getVectorArg(i, args, eye))
throw IllegalArgument("FisheyeCamera -eye", i, args);
gotEye = true;
} else if(arg == "-lookat"){
- if(!getPointArg(i, args, lookat))
+ if(!getVectorArg(i, args, lookat))
throw IllegalArgument("FisheyeCamera -lookat", i, args);
gotLookat = true;
} else if(arg == "-up"){
@@ -127,7 +135,7 @@
void FisheyeCamera::transform(AffineTransform t, TransformCenter center)
{
- Point cen;
+ Vector cen;
switch(center){
case Eye:
cen = eye;
@@ -136,7 +144,7 @@
cen = lookat;
break;
case Origin:
- cen = Point(0,0,0);
+ cen = Vector(0,0,0);
break;
}
@@ -149,9 +157,9 @@
frame_inv.invert();
AffineTransform t2 = frame * t * frame_inv;
- up = t2 * up;
- eye = t2 * eye;
- lookat = t2 * lookat;
+ up = t2.multiply_vector(up);
+ eye = t2.multiply_point(eye);
+ lookat = t2.multiply_point(lookat);
setup();
}
@@ -177,5 +185,14 @@
<< std::endl;
}
+void FisheyeCamera::reset(const Vector& eye_, const Vector& up_,
+ const Vector& lookat_ )
+{
+ eye = eye_;
+ up = up_;
+ lookat = lookat_;
+
+ setup();
+}
Modified: trunk/Model/Cameras/FisheyeCamera.h
==============================================================================
--- trunk/Model/Cameras/FisheyeCamera.h (original)
+++ trunk/Model/Cameras/FisheyeCamera.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_FisheyeCamera_h
#include <Interface/Camera.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <sgi_stl_warnings_off.h>
#include <string>
#include <vector>
@@ -17,13 +17,8 @@
void setup();
public:
FisheyeCamera(const vector<string>& args);
- FisheyeCamera( const Point &eye_, const Point &lookat_, const Vector
&up_,
- Real hfov_ = 60 ) :
- eye( eye_ ), up( up_ ), lookat( lookat_ ), hfov( hfov_ )
- {
- setup();
- hfov = hfov / 90;
- };
+ FisheyeCamera(const Vector& eye_, const Vector& lookat_, const Vector&
up_,
+ Real hfov_ = 60 );
virtual ~FisheyeCamera();
virtual void makeRays(RayPacket&) const;
@@ -37,16 +32,16 @@
virtual void output( std::ostream &os );
static Camera* create(const vector<string>& args);
- virtual Point getPosition() const { return eye; }
- virtual Point getLookAt() const { return lookat; };
+ virtual Vector getPosition() const { return eye; }
+ virtual Vector getLookAt() const { return lookat; };
virtual Vector getUp() const { return up; };
- virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ ) {
- eye = eye_; up = up_; lookat = lookat_; setup(); };
+ virtual void reset(const Vector& eye_, const Vector& up_,
+ const Vector& lookat_ );
private:
- Point eye;
- Point lookat;
+ Vector eye;
+ Vector lookat;
Vector up;
Real hfov, vfov, width, height, nearZ; // x and y field of view,
// width and height of
Modified: trunk/Model/Cameras/OrthogonalCamera.cc
==============================================================================
--- trunk/Model/Cameras/OrthogonalCamera.cc (original)
+++ trunk/Model/Cameras/OrthogonalCamera.cc Thu Feb 16 17:08:22 2006
@@ -13,6 +13,13 @@
using namespace std;
using namespace SCIRun;
+OrthogonalCamera::OrthogonalCamera(const Vector& eye_, const Vector& lookat_,
+ const Vector& up_, Real hscale_ )
+ : eye( eye_ ), lookat( lookat_ ), up( up_ ), hscale( hscale_ )
+{
+ setup();
+}
+
OrthogonalCamera::OrthogonalCamera(const vector<string>& args)
{
bool gotEye = false;
@@ -23,11 +30,11 @@
for(int i=0; i< argc; i++){
string arg = args[i];
if(arg == "-eye"){
- if(!getPointArg(i, args, eye))
+ if(!getVectorArg(i, args, eye))
throw IllegalArgument("OrthogonalCamera -eye", i, args);
gotEye = true;
} else if(arg == "-lookat"){
- if(!getPointArg(i, args, lookat))
+ if(!getVectorArg(i, args, lookat))
throw IllegalArgument("OrthogonalCamera -lookat", i, args);
gotLookat = true;
} else if(arg == "-up"){
@@ -79,7 +86,9 @@
ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates));
for(int i=rays.begin();i<rays.end();i++){
- Point rayposition(eye+v*rays.getImageCoordinates(i,
0)+u*rays.getImageCoordinates(i, 1));
+ Vector rayposition(eye +
+ v*rays.getImageCoordinates(i, 0) +
+ u*rays.getImageCoordinates(i, 1));
rays.setRay(i, rayposition, direction);
}
rays.setFlag(RayPacket::NormalizedDirections);
@@ -113,7 +122,7 @@
void OrthogonalCamera::transform(AffineTransform t, TransformCenter center)
{
- Point cen;
+ Vector cen;
switch(center){
case Eye:
cen = eye;
@@ -122,7 +131,7 @@
cen = lookat;
break;
case Origin:
- cen = Point(0,0,0);
+ cen = Vector(0,0,0);
break;
}
@@ -137,9 +146,9 @@
AffineTransform t2 = frame * t * frame_inv;
- up = t2 * up;
- eye = t2 * eye;
- lookat = t2 * lookat;
+ up = t2.multiply_vector(up);
+ eye = t2.multiply_point(eye);
+ lookat = t2.multiply_point(lookat);
setup();
}
@@ -163,3 +172,12 @@
<< std::endl;
}
+void OrthogonalCamera::reset(const Vector& eye_, const Vector& up_,
+ const Vector& lookat_ )
+{
+ eye = eye_;
+ up = up_;
+ lookat = lookat_;
+
+ setup();
+}
Modified: trunk/Model/Cameras/OrthogonalCamera.h
==============================================================================
--- trunk/Model/Cameras/OrthogonalCamera.h (original)
+++ trunk/Model/Cameras/OrthogonalCamera.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_OrthogonalCamera_h
#include <Interface/Camera.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <sgi_stl_warnings_off.h>
#include <string>
#include <vector>
@@ -13,9 +13,9 @@
using namespace std;
class OrthogonalCamera : public Camera {
public:
+ OrthogonalCamera(const Vector& eye_, const Vector& lookat_,
+ const Vector& up_, Real hscale_ );
OrthogonalCamera(const vector<string>& args);
- OrthogonalCamera( const Point &eye_, const Point &lookat_,
const Vector &up_, Real hscale_ ) :
- eye( eye_ ), lookat( lookat_ ), up( up_ ), hscale(
hscale_ ) { setup(); }
virtual ~OrthogonalCamera();
virtual void makeRays(RayPacket&) const;
@@ -28,17 +28,17 @@
virtual void output( std::ostream &os );
static Camera* create(const vector<string>& args);
- virtual Point getPosition() const { return eye; }
- virtual Point getLookAt() const { return lookat; }
+ virtual Vector getPosition() const { return eye; }
+ virtual Vector getLookAt() const { return lookat; }
virtual Vector getUp() const { return up; }
- virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ ) {
- eye = eye_; up = up_; lookat = lookat_; setup(); }
+ virtual void reset(const Vector& eye_, const Vector& up_,
+ const Vector& lookat_ );
private:
void setup();
- Point eye;
- Point lookat;
+ Vector eye;
+ Vector lookat;
Vector up;
Real hscale, vscale;
Modified: trunk/Model/Cameras/PinholeCamera.cc
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.cc (original)
+++ trunk/Model/Cameras/PinholeCamera.cc Thu Feb 16 17:08:22 2006
@@ -16,6 +16,14 @@
using SCIRun::Clamp;
using SCIRun::Abs;
+PinholeCamera::PinholeCamera( const Vector& eye_, const Vector& lookat_,
+ const Vector &up_, Real fov_ )
+ : eye( eye_ ), lookat( lookat_ ), up( up_ ),
+ stereo_offset( 0.0 ), hfov( fov_ )
+{
+ setup();
+}
+
PinholeCamera::PinholeCamera(const vector<string>& args)
{
normalizeRays = false;
@@ -23,8 +31,8 @@
stereo_offset = 0;
// pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 0 0 1 -fov 60
- eye = Point ( 3, 3, 2 );
- lookat = Point ( 0, 0, (Real)0.3 );
+ eye = Vector ( 3, 3, 2 );
+ lookat = Vector ( 0, 0, (Real)0.3 );
up = Vector( 0, 0, 1 );
hfov = 60;
@@ -35,10 +43,10 @@
if(!getArg(i, args, stereo_offset))
throw IllegalArgument("PinholeCamera -offset", i, args);
} else if(arg == "-eye"){
- if(!getPointArg(i, args, eye))
+ if(!getVectorArg(i, args, eye))
throw IllegalArgument("PinholeCamera -eye", i, args);
} else if(arg == "-lookat"){
- if(!getPointArg(i, args, lookat))
+ if(!getVectorArg(i, args, lookat))
throw IllegalArgument("PinholeCamera -lookat", i, args);
} else if(arg == "-up"){
if(!getVectorArg(i, args, up))
@@ -119,7 +127,7 @@
ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates));
rays.setFlag(RayPacket::ConstantOrigin);
- Point stereo_eye[2];
+ Vector stereo_eye[2];
stereo_eye[0] = (eye - (v*stereo_offset));
stereo_eye[1] = (eye + (v*stereo_offset));
@@ -170,7 +178,7 @@
void PinholeCamera::transform(AffineTransform t, TransformCenter center)
{
- Point cen;
+ Vector cen;
switch(center){
case Eye:
cen = eye;
@@ -179,7 +187,7 @@
cen = lookat;
break;
case Origin:
- cen = Point(0,0,0);
+ cen = Vector(0,0,0);
break;
}
@@ -192,9 +200,9 @@
frame_inv.invert();
AffineTransform t2 = frame * t * frame_inv;
- up = t2 * up;
- eye = t2 * eye;
- lookat = t2 * lookat;
+ up = t2.multiply_vector(up);
+ eye = t2.multiply_point(eye);
+ lookat = t2.multiply_point(lookat);
setup();
}
@@ -211,3 +219,12 @@
setup();
}
+void PinholeCamera::reset( const Vector& eye_, const Vector& up_,
+ const Vector& lookat_ )
+{
+ eye = eye_;
+ up = up_;
+ lookat = lookat_;
+
+ setup();
+}
Modified: trunk/Model/Cameras/PinholeCamera.h
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.h (original)
+++ trunk/Model/Cameras/PinholeCamera.h Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#define Manta_Model_PinholeCamera_h
#include <Interface/Camera.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <sgi_stl_warnings_off.h>
#include <string>
#include <vector>
@@ -15,8 +15,8 @@
class PinholeCamera : public Camera {
public:
- PinholeCamera( const Point &eye_, const Point &lookat_, const Vector
&up_, Real fov_ ) :
- eye( eye_ ), lookat( lookat_ ), up( up_ ), stereo_offset( 0.0 ), hfov(
fov_ ) { setup(); }
+ PinholeCamera( const Vector& eye_, const Vector& lookat_,
+ const Vector &up_, Real fov_ );
PinholeCamera(const vector<string>& args);
virtual ~PinholeCamera();
virtual void makeRays(RayPacket&) const;
@@ -27,27 +27,27 @@
virtual void dolly(Real);
virtual void transform(AffineTransform t, TransformCenter);
virtual void autoview(const BBox bbox);
- virtual void output( std::ostream &os );
+ virtual void output( std::ostream& os );
static Camera* create(const vector<string>& args);
- virtual Point getPosition() const { return eye; }
- virtual Point getLookAt() const { return lookat; };
+ virtual Vector getPosition() const { return eye; }
+ virtual Vector getLookAt() const { return lookat; };
virtual Vector getUp() const { return up; };
- virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ ) {
- eye = eye_; up = up_; lookat = lookat_; setup(); };
+ virtual void reset( const Vector& eye_, const Vector& up_,
+ const Vector& lookat_ );
void setStereoOffset( Real stereo_offset_ ) { stereo_offset =
stereo_offset_; }
Real getStereoOffset() const { return stereo_offset; }
virtual void setup();
protected:
- Point eye;
- Point lookat;
+ Vector eye;
+ Vector lookat;
Vector up;
Real stereo_offset;
- Real hfov, vfov, width, height, nearZ; // x and y field of view,
+ Real hfov, vfov, width, height, nearZ; // x and y field of view,
// width and height of image
plane
// distance from eye to image
plane
bool normalizeRays;
Modified: trunk/Model/Groups/BVH.cc
==============================================================================
--- trunk/Model/Groups/BVH.cc (original)
+++ trunk/Model/Groups/BVH.cc Thu Feb 16 17:08:22 2006
@@ -131,8 +131,8 @@
for(int j=i-1; j>=0; j--)
{
- Point min = Min(objValues[i].min,objValues[j].min);
- Point max = Max(objValues[i].max,objValues[j].max);
+ Vector min = Min(objValues[i].min,objValues[j].min);
+ Vector max = Max(objValues[i].max,objValues[j].max);
//compute area as a cost function
float area = computeArea(max,min);
//store cost in table
@@ -174,7 +174,7 @@
--i; // bring it back to last index.
// find out if primitive or not use appropriate array
- Point markiMin, markiMax;
+ Vector markiMin, markiMax;
if(indexTable[marki] <= 0)
{
markiMin = objValues[-indexTable[marki]].min;
@@ -185,7 +185,7 @@
markiMin = nodes[indexTable[marki]].min;
markiMax = nodes[indexTable[marki]].max;
}
- Point markjMin, markjMax;
+ Vector markjMin, markjMax;
if(indexTable[markj] <= 0)
{
markjMin = objValues[-indexTable[markj]].min;
@@ -214,8 +214,8 @@
costTable[m][markj] = costTable[i][m];
// replace new column with new values
- Point bmin, bmax;
- Point mmin, mmax;
+ Vector bmin, bmax;
+ Vector mmin, mmax;
for(int m=0; m<marki; m++)
{
if(indexTable[m]<=0)
Modified: trunk/Model/Groups/BVH.h
==============================================================================
--- trunk/Model/Groups/BVH.h (original)
+++ trunk/Model/Groups/BVH.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_BVH_h
#include <Model/Groups/Group.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Interface/RayPacket.h>
namespace Manta {
@@ -22,8 +22,8 @@
static Group* create(const vector<string>& args);
private:
struct Node {
- Point min;
- Point max;
+ Vector min;
+ Vector max;
int left, right;
};
Node* nodes;
@@ -35,7 +35,7 @@
bool bv_hit[RayPacket::MaxSize];
};
inline int intersect_box(RayPacket& rays, StackEntry& cur) const;
- inline float computeArea(const Point &max, const Point &min) const
+ inline float computeArea(const Vector& max, const Vector& min) const
{
return 2*(max-min).length2();
}
Modified: trunk/Model/Groups/FrustumKDTree.cc
==============================================================================
--- trunk/Model/Groups/FrustumKDTree.cc (original)
+++ trunk/Model/Groups/FrustumKDTree.cc Thu Feb 16 17:08:22 2006
@@ -46,7 +46,7 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-PacketFrustum::PacketFrustum( const Point &origin_,
+PacketFrustum::PacketFrustum( const Vector &origin_,
const Vector &bound0_, const Vector &bound1_,
const Vector &bound2_, const Vector &bound3_,
int debug_level) :
@@ -247,10 +247,10 @@
PacketFrustum &frustum,
const BBox &node_bounds )
{
- typedef PointT<float,2> Point2f;
- typedef PointT<float,3> Point3f;
+ typedef VectorT<float,2> Vector2f;
+ typedef VectorT<float,3> Vector3f;
- typedef PointT<Real,2> Point2;
+ typedef VectorT<Real,2> Vector2;
// Determine the split plane direction.
unsigned int axis = node->axis();
@@ -285,12 +285,12 @@
// Find the n and f, the max and min 2D intersection points on the split
// plane.
- Point2 n(-FLT_MAX,-FLT_MAX);
- Point2 f( FLT_MAX, FLT_MAX);
+ Vector2 n(-FLT_MAX,-FLT_MAX);
+ Vector2 f( FLT_MAX, FLT_MAX);
for (int i=0;i<4;++i) {
// Intersection pt = origin + (t)(direction)
- Point pt = frustum.origin();
+ Vector pt = frustum.origin();
// t = dot((point-origin),normal) / dot(direction,normal)
// Determine dn (1/ray direction)
@@ -416,12 +416,12 @@
Vector entry[4];
Vector exit[4];
// frustum.direction() is 0 for negative directions, 1 for zero/positive.
- Point bb_min(leaf_bounds[1-frustum.direction(0)].x(),
- leaf_bounds[1-frustum.direction(1)].y(),
- leaf_bounds[1-frustum.direction(2)].z());
- Point bb_max(leaf_bounds[ frustum.direction(0)].x(),
- leaf_bounds[ frustum.direction(1)].y(),
- leaf_bounds[ frustum.direction(2)].z());
+ Vector bb_min(leaf_bounds[1-frustum.direction(0)].x(),
+ leaf_bounds[1-frustum.direction(1)].y(),
+ leaf_bounds[1-frustum.direction(2)].z());
+ Vector bb_max(leaf_bounds[ frustum.direction(0)].x(),
+ leaf_bounds[ frustum.direction(1)].y(),
+ leaf_bounds[ frustum.direction(2)].z());
for(unsigned int i = 0; i < 4; ++i) {
entry[i] = ((bb_min - frustum.origin()) / frustum.bound(i));
exit[i] = ((bb_max - frustum.origin()) / frustum.bound(i));
Modified: trunk/Model/Groups/FrustumKDTree.h
==============================================================================
--- trunk/Model/Groups/FrustumKDTree.h (original)
+++ trunk/Model/Groups/FrustumKDTree.h Thu Feb 16 17:08:22 2006
@@ -46,7 +46,7 @@
// Container for a bounding frustum about a ray packet.
class PacketFrustum {
private:
- Point frustum_origin; // Common origin.
+ Vector frustum_origin; // Common origin.
Vector frustum_bound[4]; // Four vectors which bound
// the frustum.
unsigned int frustum_direction[3]; // All rays in frustum must
@@ -54,13 +54,13 @@
public:
// Create a frustum given a common origin and four bounding vectors.
- PacketFrustum( const Point &origin_,
+ PacketFrustum( const Vector &origin_,
const Vector &bound0_, const Vector &bound1_,
const Vector &bound2_, const Vector &bound3_,
int debug_level = 0);
// Accessors.
- const Point &origin() const { return frustum_origin; };
+ const Vector &origin() const { return frustum_origin; };
const Vector &bound( int i ) const { return frustum_bound[i]; };
// Direction, sign mask of all bounding rays assumed to be the same.
Modified: trunk/Model/Groups/GriddedGroup.cc
==============================================================================
--- trunk/Model/Groups/GriddedGroup.cc (original)
+++ trunk/Model/Groups/GriddedGroup.cc Thu Feb 16 17:08:22 2006
@@ -165,7 +165,7 @@
rays.computeInverseDirections();
for(int i=rays.begin(); i<rays.end(); i++) {
- Point origin(rays.getOrigin(i));
+ Vector origin(rays.getOrigin(i));
Vector direction(rays.getOrigin(i));
Vector inv_direction(rays.getInverseDirection(i));
// Step 2
@@ -183,7 +183,7 @@
tnear = 0;
// Step 3
- Point p = origin + tnear * direction;
+ Vector p = origin + tnear * direction;
Vector L = (p-min)*inv_cellsize;
int Lx = Clamp(static_cast<int>(L.x()), 0, cells.getNx()-1);
int Ly = Clamp(static_cast<int>(L.y()), 0, cells.getNy()-1);
Modified: trunk/Model/Groups/GriddedGroup.h
==============================================================================
--- trunk/Model/Groups/GriddedGroup.h (original)
+++ trunk/Model/Groups/GriddedGroup.h Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#include <vector>
#include <Model/Groups/Group.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Interface/RayPacket.h>
namespace Manta {
@@ -135,7 +135,7 @@
GriddedGroup& operator=(const GriddedGroup&);
Real cellfactor;
- Point min, max;
+ Vector min, max;
Vector diag;
Vector cellsize;
Vector inv_cellsize;
Modified: trunk/Model/Groups/KDTree.cc
==============================================================================
--- trunk/Model/Groups/KDTree.cc (original)
+++ trunk/Model/Groups/KDTree.cc Thu Feb 16 17:08:22 2006
@@ -78,9 +78,9 @@
// This is a C++ version of the above routine.
static int
-intersectTriangle3Edge(const Vectorf &direction, const Pointf &origin,
- const Vectorf &edge1, Vectorf &edge2, Pointf &p0,
- float &t, float &u, float &v );
+intersectTriangle3Edge(const Vectorf& direction, const Vectorf& origin,
+ const Vectorf& edge1, Vectorf& edge2, Vectorf& p0,
+ float& t, float& u, float& v );
///////////////////////////////////////////////////////////////////////////////
@@ -88,7 +88,7 @@
// INTERSECT TRIANGLES INTERSECT TRIANGLES INTERSECT TRIANGLES INTERSECT
TRI
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-int KDTree::intersectTriangles(const Pointf& origin, const Vectorf&
direction,
+int KDTree::intersectTriangles(const Vectorf& origin, const Vectorf&
direction,
unsigned int listBegin, unsigned int listSize,
float maxDist,
RayTriIntersectUserData& isectData) const
@@ -225,7 +225,7 @@
travStack[exitPos].t = maxDist;
travStack[exitPos].prev = 0;
- Pointf origin = rays.getOrigin(which);
+ Vectorf origin = rays.getOrigin(which);
Vectorf direction = rays.getDirection(which);
Vectorf invDirection = rays.getInverseDirection(which);
@@ -542,8 +542,8 @@
return 1;
}
-inline int intersectTriangle3Edge(const Vectorf &direction, const Pointf
&origin,
- const Vectorf &edge1, Vectorf &edge2,
Pointf &p0,
+inline int intersectTriangle3Edge(const Vectorf &direction, const Vectorf
&origin,
+ const Vectorf &edge1, Vectorf &edge2,
Vectorf &p0,
float &t, float &u, float &v )
{
@@ -643,7 +643,7 @@
VectorT<float,2> texcoord = (t[1] * u) + (t[2] * v) + (t[0] * (1 - u -
v));
- rays.setTexCoords(i, Point( texcoord[0], texcoord[1], 0 ) );
+ rays.setTexCoords(i, Vector( texcoord[0], texcoord[1], 0 ) );
}
rays.setFlag(RayPacket::HaveTexture2);
Modified: trunk/Model/Groups/KDTree.h
==============================================================================
--- trunk/Model/Groups/KDTree.h (original)
+++ trunk/Model/Groups/KDTree.h Thu Feb 16 17:08:22 2006
@@ -31,7 +31,7 @@
#include <Model/Groups/Group.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/VectorT.h>
#include <Core/Geometry/BBox.h>
#include <Core/Util/Endian.h>
@@ -61,23 +61,22 @@
// Data is stored in 32 bit floats.
typedef VectorT<float,3> Vectorf;
- typedef PointT <float,3> Pointf;
///////////////////////////////////////////////////////////////////////////
// TRIANGLE TRIANGLE TRIANGLE TRIANGLE TRIANGLE TRIANGLE TRIANGLE
TR
///////////////////////////////////////////////////////////////////////////
class Triangle {
public:
- Pointf v[3]; // 3*3 floats = 9*4 bytes = 36 bytes
- Color payload;
+ Vectorf v[3]; // 3*3 floats = 9*4 bytes = 36 bytes
+ Color payload;
Vectorf edge1, edge2; // 2*3 floats = 6*4 bytes = 24 bytes
// the above are exactly 64 bytes
Triangle() { }
// Access vertices.
- Pointf &operator[] (int i) { return v[i]; }
- const Pointf &operator[] (int i) const { return v[i]; }
+ Vectorf& operator[] (int i) { return v[i]; }
+ const Vectorf& operator[] (int i) const { return v[i]; }
// Compute bounds.
void getBound(BBox &bounds_) {
@@ -94,8 +93,8 @@
private:
Vectorf normal[3];
public:
- Vectorf &operator[] ( int i ) { return normal[i]; };
- const Vectorf &operator[] ( int i ) const { return normal[i]; };
+ Vectorf& operator[] ( int i ) { return normal[i]; };
+ const Vectorf& operator[] ( int i ) const { return normal[i]; };
};
///////////////////////////////////////////////////////////////////////////
@@ -194,28 +193,26 @@
RayHit_Triangle(Real tt, Real uu, Real vv) {
t = tt; u = uu; v = vv;
}
- void computeHitPoint(Point &hitP,
- const Point &v0, const Point &v1, const Point &v2)
+ void computeHitPoint(Vector& hitP, const Vector& v0,
+ const Vector& v1, const Vector& v2)
{
- hitP = Point( Vector(v0)*((Real)1.0 - u - v) +
- Vector(v1)*u +
- Vector(v2)*v );
+ hitP = v0*(1 - u - v) + v1*u + v2*v;
}
- Real computeDistance2(const Ray &ray,
- const Point &v0, const Point &v1, const Point
&v2)
+ Real computeDistance2(const Ray& ray, const Vector& v0,
+ const Vector& v1, const Vector& v2)
{
- Point hitP;
+ Vector hitP;
computeHitPoint( hitP, v0, v1, v2 );
Vector distance = (hitP - ray.origin());
return Dot(distance,distance);
}
- Real computeDistance2(const Point &point,
- Point &v0, const Point &v1, const Point &v2)
+ Real computeDistance2(const Vector& point, const Vector& v0,
+ const Vector& v1, const Vector& v2)
{
- Point hitP;
+ Vector hitP;
computeHitPoint(hitP, v0, v1, v2);
Vector distance = (hitP - point);
@@ -366,7 +363,7 @@
class KDTree : public PrimitiveCommon, public KDTreeData {
protected:
// This method intersects a list of triangles with the ray.
- int intersectTriangles(const Pointf& origin, const Vectorf& direction,
+ int intersectTriangles(const Vectorf& origin, const Vectorf& direction,
unsigned int listBegin, unsigned int listSize,
float maxDist,
RayTriIntersectUserData &isectData) const;
Modified: trunk/Model/Groups/KDTreeLoader.cc
==============================================================================
--- trunk/Model/Groups/KDTreeLoader.cc (original)
+++ trunk/Model/Groups/KDTreeLoader.cc Thu Feb 16 17:08:22 2006
@@ -163,15 +163,15 @@
// Data was generate on Altix (little endian)
if (is_big_endian()) {
for (int j=0; j<3; ++j) {
- (**tris)[i][j] = Pointf( endian_swap(
_rawVertColData[0] ),
-
endian_swap(
_rawVertColData[1] ),
-
endian_swap(
_rawVertColData[2] ));
+ (**tris)[i][j] = Vectorf(
endian_swap( _rawVertColData[0] ),
+ endian_swap( _rawVertColData[1] ),
+ endian_swap( _rawVertColData[2] ));
_rawVertColData += 3;
if(rawNormData) {
(*perVertNormals)[i][j] =
Vectorf( endian_swap( _rawNormData[0] ),
- endian_swap( _rawNormData[1] ),
- endian_swap( _rawNormData[2] ));
+ endian_swap( _rawNormData[1]
),
+ endian_swap( _rawNormData[2]
));
_rawNormData += 3;
}
}
@@ -180,7 +180,9 @@
// Otherwise don't swap.
else {
for (int j=0; j<3; ++j) {
- (**tris)[i][j] = Pointf(
_rawVertColData[0], _rawVertColData[1], _rawVertColData[2] );
+ (**tris)[i][j] = Vectorf(
_rawVertColData[0],
+ _rawVertColData[1],
+ _rawVertColData[2] );
_rawVertColData += 3;
if(rawNormData) {
@@ -508,7 +510,7 @@
// This structure is only used to read from the kd tree file.
struct AABox3f {
- Pointf min, max;
+ Vectorf min, max;
};
static float endianness_swap( float in ) {
Modified: trunk/Model/Groups/RealisticBvh.cc
==============================================================================
--- trunk/Model/Groups/RealisticBvh.cc (original)
+++ trunk/Model/Groups/RealisticBvh.cc Thu Feb 16 17:08:22 2006
@@ -34,7 +34,10 @@
#include <Model/Groups/RealisticBvh.h>
#include <Model/Intersections/AxisAlignedBox.h>
+#include <sgi_stl_warnings_off.h>
#include <iostream>
+#include <sgi_stl_warnings_on.h>
+
using namespace std;
using namespace Manta;
@@ -82,7 +85,7 @@
}
// Find a pivot point.
- Point pivot((Vector(bounds[0]) + Vector(bounds[1])) * 0.5);
+ Vector pivot((Vector(bounds[0]) + Vector(bounds[1])) * 0.5);
// Split along the axis.
int mid_point = qsplit( array, size, pivot[0], 0 );
@@ -141,7 +144,7 @@
}
// Find a pivot point.
- Point pivot((Vector(new_node->bounds[0]) +
Vector(new_node->bounds[1])) * (Real)0.5);
+ Vector pivot((new_node->bounds[0] + new_node->bounds[1]) * (Real)0.5);
// Split along the axis.
int mid_point = qsplit( array, size, pivot[axis], axis );
Modified: trunk/Model/Groups/SSEKDTree.cc
==============================================================================
--- trunk/Model/Groups/SSEKDTree.cc (original)
+++ trunk/Model/Groups/SSEKDTree.cc Thu Feb 16 17:08:22 2006
@@ -64,13 +64,13 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-inline void intersectTriangleEdgeSSE( IntersectPacket *result,
- const RayPacket &rays,
+inline void intersectTriangleEdgeSSE( IntersectPacket* result,
+ const RayPacket& rays,
const int which,
const int tri_index,
- const Vector &edge1,
- const Vector &edge2,
- const Point &p0 );
+ const Vector& edge1,
+ const Vector& edge2,
+ const Vector& p0 );
///////////////////////////////////////////////////////////////////////////////
@@ -557,14 +557,13 @@
return _mm_sub_ps(_mm_add_ps(rcp, rcp),_mm_mul_ps(_mm_mul_ps(rcp,rcp),v));
}
-void intersectTriangleEdgeSSE( IntersectPacket *result,
-
- const RayPacket &rays,
+void intersectTriangleEdgeSSE( IntersectPacket* result,
+ const RayPacket& rays,
const int which,
const int tri_index,
- const Vector &edge0,
- const Vector &edge1,
- const Point &p0 )
+ const Vector& edge0,
+ const Vector& edge1,
+ const Vector& p0 )
{
__m128 xdir, ydir, zdir;
__m128 xnorm, ynorm, znorm;
Modified: trunk/Model/Groups/SSEKDTree.h
==============================================================================
--- trunk/Model/Groups/SSEKDTree.h (original)
+++ trunk/Model/Groups/SSEKDTree.h Thu Feb 16 17:08:22 2006
@@ -38,7 +38,6 @@
#define __SSE_KD_TREE_H__
-#include <Core/Geometry/PointVector.h>
#include <Core/Geometry/BBox.h>
#include <Interface/RayPacket.h>
Modified: trunk/Model/Groups/TransparentKDTree.cc
==============================================================================
--- trunk/Model/Groups/TransparentKDTree.cc (original)
+++ trunk/Model/Groups/TransparentKDTree.cc Thu Feb 16 17:08:22 2006
@@ -82,9 +82,10 @@
const float *edge1, const float *edge2);
static int
-intersectTriangle3Edge(const Vectorf &direction, const Pointf &origin,
- const Vectorf &edge1, Vectorf &edge2, Pointf &p0,
- float &t, float &u, float &v );
+intersectTriangle3Edge(const Vectorf& direction, const Vectorf& origin,
+ const Vectorf& edge1, const Vectorf& edge2,
+ const Vectorf& p0,
+ float& t, float& u, float& v );
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -106,12 +107,12 @@
VArray<VArray<TransparentKDTree::Isect> *>
TransparentKDTree::isectBuffers(1024, 0);
int TransparentKDTree::intersectTrianglesTransparent
- (const Pointf& origin, const Vectorf& direction,
+ (const Vectorf& origin, const Vectorf& direction,
ScratchPadInfo& scratch_pad,
unsigned int listBegin, unsigned int listSize,
float maxDist,
RayTriIntersectUserData& userData,
- const RenderContext &context) const
+ const RenderContext& context) const
{
////////////////////////////////////////////////////////////////////////////
// Check to see if the thread buffers array is allocated.
@@ -342,7 +343,7 @@
travStack[exitPos].t = maxDist;
travStack[exitPos].prev = 0;
- Pointf origin = rays.getOrigin(which);
+ Vectorf origin = rays.getOrigin(which);
Vectorf direction = rays.getDirection(which);
Vectorf invDirection = rays.getInverseDirection(which);
@@ -617,9 +618,12 @@
return 1;
}
-inline int intersectTriangle3Edge(const Vectorf &direction, const Pointf
&origin,
- const Vectorf &edge1, Vectorf &edge2, Pointf &p0,
-
float &t, float &u, float &v )
+inline int intersectTriangle3Edge(const Vectorf& direction,
+ const Vectorf& origin,
+ const Vectorf& edge1,
+ const Vectorf& edge2,
+ const Vectorf& p0,
+ float& t, float& u, float& v )
{
Vectorf tvec, pvec, qvec;
@@ -651,23 +655,23 @@
float vv;
if (det > 1e-5f) {
- if (uu < 0.0 || uu > det)
+ if (uu < 0 || uu > det)
return 0;
/* calculate V parameter and test bounds */
vv = Dot( direction, qvec );
- if (vv < 0.0 || uu + vv > det)
+ if (vv < 0 || uu + vv > det)
return 0;
}
else if(det < -1e-5f) {
- if (uu > 0.0 || uu < det)
+ if (uu > 0 || uu < det)
return 0;
/* calculate V parameter and test bounds */
vv = Dot(direction, qvec) ;
- if (vv > 0.0 || uu + vv < det)
+ if (vv > 0 || uu + vv < det)
return 0;
}
else {
Modified: trunk/Model/Groups/TransparentKDTree.h
==============================================================================
--- trunk/Model/Groups/TransparentKDTree.h (original)
+++ trunk/Model/Groups/TransparentKDTree.h Thu Feb 16 17:08:22 2006
@@ -30,7 +30,7 @@
#define __TRANSPARENT_KD_TREE_H__
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/VectorT.h>
#include <Core/Geometry/BBox.h>
#include <Interface/RayPacket.h>
@@ -70,14 +70,14 @@
Real sample_alpha;
// This method intersects a list of triangles with the ray.
- int intersectTrianglesTransparent(const Pointf& origin,
+ int intersectTrianglesTransparent(const Vectorf& origin,
const Vectorf& direction,
ScratchPadInfo& scratch_pad,
unsigned int listBegin,
unsigned int listSize,
float maxDist,
RayTriIntersectUserData& userData,
- const RenderContext &context) const;
+ const RenderContext& context) const;
// This method is called by the above method with a hansong ray.
void intersect_node(KDTreeNode *startNode,
Modified: trunk/Model/Groups/VerticalKDTree.cc
==============================================================================
--- trunk/Model/Groups/VerticalKDTree.cc (original)
+++ trunk/Model/Groups/VerticalKDTree.cc Thu Feb 16 17:08:22 2006
@@ -699,9 +699,12 @@
return 1;
}
-inline int intersectTriangle3Edge(const Vectorf &direction, const Pointf
&origin,
- const Vectorf &edge1, Vectorf &edge2,
Pointf &p0,
- float &t, float &u, float &v )
+inline int intersectTriangle3Edge(const Vectorf& direction,
+ const Vectorf& origin,
+ const Vectorf& edge1,
+ const Vectorf& edge2,
+ const Vectorf& p0,
+ float& t, float& u, float& v )
{
Vectorf tvec, pvec, qvec;
@@ -733,23 +736,23 @@
float vv;
if (det > 1e-5f) {
- if (uu < 0.0 || uu > det)
+ if (uu < 0 || uu > det)
return 0;
/* calculate V parameter and test bounds */
vv = Dot( direction, qvec );
- if (vv < 0.0 || uu + vv > det)
+ if (vv < 0 || uu + vv > det)
return 0;
}
else if(det < -1e-5f) {
- if (uu > 0.0 || uu < det)
+ if (uu > 0 || uu < det)
return 0;
/* calculate V parameter and test bounds */
vv = Dot(direction, qvec) ;
- if (vv > 0.0 || uu + vv < det)
+ if (vv > 0 || uu + vv < det)
return 0;
}
else {
Modified: trunk/Model/Groups/VerticalKDTree.h
==============================================================================
--- trunk/Model/Groups/VerticalKDTree.h (original)
+++ trunk/Model/Groups/VerticalKDTree.h Thu Feb 16 17:08:22 2006
@@ -38,7 +38,6 @@
#define __VERTICAL_KD_TREE_H__
-#include <Core/Geometry/PointVector.h>
#include <Core/Geometry/BBox.h>
#include <Interface/RayPacket.h>
Modified: trunk/Model/Groups/VolumeGrid.h
==============================================================================
--- trunk/Model/Groups/VolumeGrid.h (original)
+++ trunk/Model/Groups/VolumeGrid.h Thu Feb 16 17:08:22 2006
@@ -2,7 +2,7 @@
#define __SPATIAL_H__
#include <Model/Groups/Group.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/BBox.h>
#include <Model/Intersections/AxisAlignedBox.h>
@@ -22,7 +22,6 @@
namespace Manta {
#define Vec3f VectorT<float,3>
-#define Point3f PointT<float,3>
#define Vec4f VectorT<float,4>
struct AABox3f {
Vec3f min, max;
@@ -646,7 +645,7 @@
float initialOffset=mindist, tMaxX, tMaxY, tMaxZ;
float tDeltaX, tDeltaY, tDeltaZ;
int stepX, stepY, stepZ, outX, outY, outZ, x, y, z;
- Point3f curpos;
+ Vec3f curpos;
hit = false;
@@ -727,8 +726,8 @@
}
float stepT = 1.0f;
- Point3f curSamplePoint;
- Point3f curSamplePoint_vol;
+ Vec3f curSamplePoint;
+ Vec3f curSamplePoint_vol;
float curT = (curpos - ray->origin()).length();
float attenBase =
(curT-mindist)/_boundSize[0]*attenFactor;
Modified: trunk/Model/Instances/Instance.cc
==============================================================================
--- trunk/Model/Instances/Instance.cc (original)
+++ trunk/Model/Instances/Instance.cc Thu Feb 16 17:08:22 2006
@@ -70,7 +70,7 @@
// Transform the eight corners of the child bounding box
for(int i=0;i<8;i++)
- bbox.extendByPoint(transform * ibox.getCorner(i));
+ bbox.extendByPoint(transform.multiply_point(ibox.getCorner(i)));
}
void Instance::intersect(const RenderContext& context, RayPacket& rays) const
@@ -82,10 +82,10 @@
Real inv_scales[RayPacket::MaxSize];
if(rays.getFlag(RayPacket::ConstantOrigin)){
- Point o = transform_inv * rays.getOrigin(rays.begin());
+ Vector o = transform_inv.multiply_point(rays.getOrigin(rays.begin()));
for(int i = rays.begin();i<rays.end();i++){
- Vector dir = transform_inv * rays.getDirection(i);
+ Vector dir = transform_inv.multiply_vector(rays.getDirection(i));
Real length = dir.length();
inv_scales[i] = length;
@@ -96,8 +96,8 @@
}
} else {
for(int i = rays.begin();i<rays.end();i++){
- Point o = transform_inv * rays.getOrigin(i);
- Vector dir = transform_inv * rays.getDirection(i);
+ Vector o = transform_inv.multiply_point(rays.getOrigin(i));
+ Vector dir = transform_inv.multiply_vector(rays.getDirection(i));
Real length = dir.length();
inv_scales[i] = length;
@@ -132,8 +132,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
Real scale = rays.scratchpad<MPTscale>(i).scale;
rays.setRay(i, o, dir*scale);
@@ -160,7 +160,7 @@
rays.setRay(i, old_rays[i]);
rays.overrideMinT(i, old_minT[i]);
- rays.setNormal(i, transpose_mult(transform_inv,rays.getNormal(i)));
+ rays.setNormal(i,
transform_inv.transpose_mult_vector(rays.getNormal(i)));
}
rays.resetFlag(RayPacket::HaveHitPositions);
}
@@ -195,8 +195,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
Real scale = rays.scratchpad<MPTscale>(i).scale;
rays.setRay(i, o, dir*scale);
@@ -234,8 +234,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
Real scale = rays.scratchpad<MPTscale>(i).scale;
rays.setRay(i, o, dir*scale);
Modified: trunk/Model/Instances/InstanceRST.cc
==============================================================================
--- trunk/Model/Instances/InstanceRST.cc (original)
+++ trunk/Model/Instances/InstanceRST.cc Thu Feb 16 17:08:22 2006
@@ -50,12 +50,12 @@
// Determine the scale of the matrix. We could use eigenvalue analysis,
// but this seems easier: pass in the three axes and make sure that the
// transformed lengths are all the same
- Vector v1 = transform * Vector(1,0,0);
- Real l1 = v1.normalize();
- Vector v2 = transform * Vector(0,1,0);
- Real l2 = v2.normalize();
- Vector v3 = transform * Vector(0,0,1);
- Real l3 = v3.normalize();
+ Vector v1 = transform.multiply_vector(Vector(1,0,0));
+ Real l1 = v1.normalize();
+ Vector v2 = transform.multiply_vector(Vector(0,1,0));
+ Real l2 = v2.normalize();
+ Vector v3 = transform.multiply_vector(Vector(0,0,1));
+ Real l3 = v3.normalize();
scale = l1;
inv_scale = 1/l1;
@@ -84,7 +84,7 @@
// Transform the eight corners of the child bounding box
for(int i=0;i<8;i++)
- bbox.extendByPoint(transform * ibox.getCorner(i));
+ bbox.extendByPoint(transform.multiply_point(ibox.getCorner(i)));
}
void InstanceRST::intersect(const RenderContext& context, RayPacket& rays)
const
@@ -94,18 +94,18 @@
rays.getAllFlags());
if(rays.getFlag(RayPacket::ConstantOrigin)){
- Point o = transform_inv * rays.getOrigin(rays.begin());
+ Vector o = transform_inv.multiply_point(rays.getOrigin(rays.begin()));
for(int i = rays.begin();i<rays.end();i++){
- Vector dir = transform_inv * rays.getDirection(i);
+ Vector dir = transform_inv.multiply_vector(rays.getDirection(i));
instance_rays.setRay(i, o, dir*scale);
instance_rays.resetHit(i, rays.getMinT(i)*inv_scale);
}
} else {
for(int i = rays.begin();i<rays.end();i++){
- Point o = transform_inv * rays.getOrigin(i);
- Vector dir = transform_inv * rays.getDirection(i);
+ Vector o = transform_inv.multiply_point(rays.getOrigin(i));
+ Vector dir = transform_inv.multiply_vector(rays.getDirection(i));
instance_rays.setRay(i, o, dir*scale);
instance_rays.resetHit(i, rays.getMinT(i)*inv_scale);
@@ -134,8 +134,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
rays.setRay(i, o, dir*scale);
old_minT[i] = rays.getMinT(i);
@@ -166,7 +166,7 @@
rays.setRay(i, old_rays[i]);
rays.overrideMinT(i, old_minT[i]);
- rays.setNormal(i, transpose_mult(transform_inv,rays.getNormal(i)) *
scale);
+ rays.setNormal(i, transform_inv.transpose_mult_vector(rays.getNormal(i))
* scale);
}
rays.resetFlag(RayPacket::HaveHitPositions);
}
@@ -201,8 +201,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
rays.setRay(i, o, dir*scale);
old_minT[i] = rays.getMinT(i);
@@ -238,8 +238,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
rays.setRay(i, o, dir*scale);
old_minT[i] = rays.getMinT(i);
Modified: trunk/Model/Instances/InstanceRT.cc
==============================================================================
--- trunk/Model/Instances/InstanceRT.cc (original)
+++ trunk/Model/Instances/InstanceRT.cc Thu Feb 16 17:08:22 2006
@@ -50,18 +50,21 @@
// Determine the scale of the matrix. We could use eigenvalue analysis,
// but this seems easier: pass in the three axes and make sure that the
// transformed lengths are all the same
- Vector v1 = transform * Vector(1,0,0);
- double l1 = v1.normalize();
- Vector v2 = transform * Vector(0,1,0);
- double l2 = v2.normalize();
- Vector v3 = transform * Vector(0,0,1);
- double l3 = v3.normalize();
-
- if(SCIRun::Abs(l1-1) > 1.e-10 || SCIRun::Abs(l2-1) > 1.e-10 ||
SCIRun::Abs(l3-1) > 1.e-10){
- ostringstream msg;
- msg << "Nonuniform scale for InstanceRT, scalefactor=[" << l1 << ' '
- << l2 << ' ' << l3 << ']';
- throw BadPrimitive(msg.str());
+ Vector v1 = transform.multiply_vector(Vector(1,0,0));
+ Real l1 = v1.normalize();
+ Vector v2 = transform.multiply_vector(Vector(0,1,0));
+ Real l2 = v2.normalize();
+ Vector v3 = transform.multiply_vector(Vector(0,0,1));
+ Real l3 = v3.normalize();
+
+ if(SCIRun::Abs(l1-1) > (Real)1.e-7 ||
+ SCIRun::Abs(l2-1) > (Real)1.e-7 ||
+ SCIRun::Abs(l3-1) > (Real)1.e-7)
+ {
+ ostringstream msg;
+ msg << "Nonuniform scale for InstanceRT, scalefactor=[" << l1 << ' '
+ << l2 << ' ' << l3 << ']';
+ throw BadPrimitive(msg.str());
}
}
@@ -82,7 +85,7 @@
// Transform the eight corners of the child bounding box
for(int i=0;i<8;i++)
- bbox.extendByPoint(transform * ibox.getCorner(i));
+ bbox.extendByPoint(transform.multiply_point(ibox.getCorner(i)));
}
void InstanceRT::intersect(const RenderContext& context, RayPacket& rays)
const
@@ -92,18 +95,18 @@
rays.getAllFlags());
if(rays.getFlag(RayPacket::ConstantOrigin)){
- Point o = transform_inv * rays.getOrigin(rays.begin());
+ Vector o = transform_inv.multiply_point(rays.getOrigin(rays.begin()));
for(int i = rays.begin();i<rays.end();i++){
- Vector dir = transform_inv * rays.getDirection(i);
+ Vector dir = transform_inv.multiply_vector(rays.getDirection(i));
instance_rays.setRay(i, o, dir);
instance_rays.resetHit(i, rays.getMinT(i));
}
} else {
for(int i = rays.begin();i<rays.end();i++){
- Point o = transform_inv * rays.getOrigin(i);
- Vector dir = transform_inv * rays.getDirection(i);
+ Vector o = transform_inv.multiply_point(rays.getOrigin(i));
+ Vector dir = transform_inv.multiply_vector(rays.getDirection(i));
instance_rays.setRay(i, o, dir);
instance_rays.resetHit(i, rays.getMinT(i));
@@ -131,8 +134,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
rays.setRay(i, o, dir);
}
@@ -157,7 +160,7 @@
// Put the rays back and fix the normals
for(int i=rays.begin();i<rays.end();i++){
rays.setRay(i, old_rays[i]);
- rays.setNormal(i, transpose_mult(transform_inv,rays.getNormal(i)));
+ rays.setNormal(i,
transform_inv.transpose_mult_vector(rays.getNormal(i)));
}
rays.resetFlag(RayPacket::HaveHitPositions);
}
@@ -190,8 +193,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
rays.setRay(i, o, dir);
}
@@ -223,8 +226,8 @@
for(int i=rays.begin();i<rays.end();i++){
old_rays[i] = rays.getRay(i);
- Point o = transform_inv * old_rays[i].origin();
- Vector dir = transform_inv * old_rays[i].direction();
+ Vector o = transform_inv.multiply_point(old_rays[i].origin());
+ Vector dir = transform_inv.multiply_vector(old_rays[i].direction());
rays.setRay(i, o, dir);
}
Modified: trunk/Model/Instances/InstanceST.cc
==============================================================================
--- trunk/Model/Instances/InstanceST.cc (original)
+++ trunk/Model/Instances/InstanceST.cc Thu Feb 16 17:08:22 2006
@@ -60,8 +60,8 @@
{
BBox ibox;
instance->computeBounds(context, ibox);
- bbox.extendByPoint(Point(Vector(ibox.getMin())*scale)+translation);
- bbox.extendByPoint(Point(Vector(ibox.getMax())*scale)+translation);
+ bbox.extendByPoint(ibox.getMin()*scale + translation);
+ bbox.extendByPoint(ibox.getMax()*scale + translation);
}
void InstanceST::intersect(const RenderContext& context, RayPacket& rays)
const
@@ -74,7 +74,7 @@
if(uniform_scale){
Real iscale = inv_scale.x();
if(rays.getFlag(RayPacket::ConstantOrigin)){
- Point o( Vector(rays.getOrigin(rays.begin())-translation)*iscale );
+ Vector o( (rays.getOrigin(rays.begin())-translation) * iscale );
for(int i = rays.begin();i<rays.end();i++){
instance_rays.setRay(i, o, rays.getDirection(i));
@@ -82,14 +82,14 @@
}
} else {
for(int i = rays.begin();i<rays.end();i++){
- Point o( Vector(rays.getOrigin(i)-translation)*iscale );
+ Vector o( (rays.getOrigin(i)-translation) * iscale );
instance_rays.setRay(i, o, rays.getDirection(i));
instance_rays.resetHit(i, rays.getMinT(i)*iscale);
}
}
} else {
if(rays.getFlag(RayPacket::ConstantOrigin)){
- Point o( Vector(rays.getOrigin(rays.begin())-translation)*inv_scale );
+ Vector o( (rays.getOrigin(rays.begin())-translation) * inv_scale );
for(int i = rays.begin();i<rays.end();i++){
Vector dir(rays.getDirection(i)*inv_scale);
Real length = dir.length();
@@ -101,7 +101,7 @@
}
} else {
for(int i = rays.begin();i<rays.end();i++){
- Point o( Vector(rays.getOrigin(i)-translation)*inv_scale );
+ Vector o( (rays.getOrigin(i)-translation) * inv_scale );
Vector dir(rays.getDirection(i)*inv_scale);
Real length = dir.length();
scales[i] = length;
@@ -148,7 +148,7 @@
InstanceST::computeNormal(const RenderContext& context, RayPacket& rays)
const
{
Real old_minT[RayPacket::MaxSize];
- Point old_origins[RayPacket::MaxSize];
+ Vector old_origins[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
if(uniform_scale){
@@ -156,7 +156,7 @@
Real is = inv_scale.x();
for(int i=rays.begin();i<rays.end();i++){
old_origins[i] = rays.getOrigin(i);
- rays.setOrigin(i, Point(Vector(old_origins[i]-translation)*is));
+ rays.setOrigin(i, (old_origins[i]-translation) * is);
old_minT[i] = rays.getMinT(i);
rays.scaleMinT(i, is);
}
@@ -166,7 +166,7 @@
old_rays[i] = rays.getRay(i);
Vector dir(old_rays[i].direction()*inv_scale);
Real ilength = rays.scratchpad<MPTscale>(i).scale;
- Point o( (old_rays[i].origin()-translation).multipliedBy(inv_scale) );
+ Vector o( (old_rays[i].origin()-translation) * inv_scale );
rays.setRay(i, o, dir*ilength);
old_minT[i] = rays.getMinT(i);
Real length = rays.scratchpad<MPTscale>(i).inv_scale;
@@ -229,7 +229,7 @@
RayPacket& rays) const
{
Real old_minT[RayPacket::MaxSize];
- Point old_origins[RayPacket::MaxSize];
+ Vector old_origins[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
if(uniform_scale){
@@ -237,7 +237,7 @@
Real is = inv_scale.x();
for(int i=rays.begin();i<rays.end();i++){
old_origins[i] = rays.getOrigin(i);
- rays.setOrigin(i, Point(Vector(old_origins[i]-translation)*is));
+ rays.setOrigin(i, (old_origins[i]-translation) * is);
old_minT[i] = rays.getMinT(i);
rays.scaleMinT(i, is);
}
@@ -247,7 +247,7 @@
old_rays[i] = rays.getRay(i);
Vector dir(old_rays[i].direction()*inv_scale);
Real ilength = rays.scratchpad<MPTscale>(i).scale;
- Point o( (old_rays[i].origin()-translation).multipliedBy(inv_scale) );
+ Vector o( (old_rays[i].origin()-translation) * inv_scale );
rays.setRay(i, o, dir*ilength);
old_minT[i] = rays.getMinT(i);
Real length = rays.scratchpad<MPTscale>(i).inv_scale;
@@ -286,7 +286,7 @@
RayPacket& rays) const
{
Real old_minT[RayPacket::MaxSize];
- Point old_origins[RayPacket::MaxSize];
+ Vector old_origins[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
if(uniform_scale){
@@ -294,7 +294,7 @@
Real is = inv_scale.x();
for(int i=rays.begin();i<rays.end();i++){
old_origins[i] = rays.getOrigin(i);
- rays.setOrigin(i, Point(Vector(old_origins[i]-translation)*is));
+ rays.setOrigin(i, (old_origins[i]-translation) * is);
old_minT[i] = rays.getMinT(i);
rays.scaleMinT(i, is);
}
@@ -304,7 +304,7 @@
old_rays[i] = rays.getRay(i);
Vector dir(old_rays[i].direction()*inv_scale);
Real ilength = rays.scratchpad<MPTscale>(i).scale;
- Point o( (old_rays[i].origin()-translation).multipliedBy(inv_scale) );
+ Vector o( (old_rays[i].origin()-translation) * inv_scale );
rays.setRay(i, o, dir*ilength);
old_minT[i] = rays.getMinT(i);
Real length = rays.scratchpad<MPTscale>(i).inv_scale;
Modified: trunk/Model/Instances/InstanceST.h
==============================================================================
--- trunk/Model/Instances/InstanceST.h (original)
+++ trunk/Model/Instances/InstanceST.h Thu Feb 16 17:08:22 2006
@@ -32,14 +32,14 @@
#include <Interface/Material.h>
#include <Interface/Primitive.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class InstanceST : public Primitive, public Material, public
TexCoordMapper {
public:
InstanceST(Object* instance, const Vector& scale,
- const Vector& translation);
+ const Vector& translation);
virtual ~InstanceST();
// Generic
Modified: trunk/Model/Instances/InstanceT.cc
==============================================================================
--- trunk/Model/Instances/InstanceT.cc (original)
+++ trunk/Model/Instances/InstanceT.cc Thu Feb 16 17:08:22 2006
@@ -65,14 +65,14 @@
rays.getAllFlags());
if(rays.getFlag(RayPacket::ConstantOrigin)){
- Point o(rays.getOrigin(rays.begin())-translation);
+ Vector o(rays.getOrigin(rays.begin())-translation);
for(int i = rays.begin();i<rays.end();i++){
instance_rays.setRay(i, o, rays.getDirection(i));
instance_rays.resetHit(i, rays.getMinT(i));
}
} else {
for(int i = rays.begin();i<rays.end();i++){
- Point o(rays.getOrigin(i)-translation);
+ Vector o(rays.getOrigin(i)-translation);
instance_rays.setRay(i, o, rays.getDirection(i));
instance_rays.resetHit(i, rays.getMinT(i));
}
@@ -93,7 +93,7 @@
void InstanceT::computeNormal(const RenderContext& context, RayPacket& rays)
const
{
- Point old_origins[RayPacket::MaxSize];
+ Vector old_origins[RayPacket::MaxSize];
// Save the original origins
for(int i=rays.begin();i<rays.end();i++){
@@ -147,7 +147,7 @@
void InstanceT::computeTexCoords2(const RenderContext& context,
RayPacket& rays) const
{
- Point old_origins[RayPacket::MaxSize];
+ Vector old_origins[RayPacket::MaxSize];
// Save the original origins
for(int i=rays.begin();i<rays.end();i++){
@@ -175,7 +175,7 @@
void InstanceT::computeTexCoords3(const RenderContext& context,
RayPacket& rays) const
{
- Point old_origins[RayPacket::MaxSize];
+ Vector old_origins[RayPacket::MaxSize];
// Save the original origins
for(int i=rays.begin();i<rays.end();i++){
Modified: trunk/Model/Instances/InstanceT.h
==============================================================================
--- trunk/Model/Instances/InstanceT.h (original)
+++ trunk/Model/Instances/InstanceT.h Thu Feb 16 17:08:22 2006
@@ -32,7 +32,7 @@
#include <Interface/Material.h>
#include <Interface/Primitive.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
Modified: trunk/Model/Intersections/Plane.h
==============================================================================
--- trunk/Model/Intersections/Plane.h (original)
+++ trunk/Model/Intersections/Plane.h Thu Feb 16 17:08:22 2006
@@ -7,10 +7,10 @@
namespace Intersection {
template< typename Scalar >
- inline bool intersectPlane( const Point &point,
- const Vector &normal,
- Scalar &t,
- const Ray &ray ) {
+ inline bool intersectPlane( const Vector& point,
+ const Vector& normal,
+ Scalar& t,
+ const Ray& ray ) {
Scalar dn = Dot( ray.direction(), normal );
if (dn != 0) {
Modified: trunk/Model/Intersections/TriangleEdge.h
==============================================================================
--- trunk/Model/Intersections/TriangleEdge.h (original)
+++ trunk/Model/Intersections/TriangleEdge.h Thu Feb 16 17:08:22 2006
@@ -32,16 +32,18 @@
#include <MantaTypes.h>
#include <Core/Geometry/Ray.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Interface/RayPacket.h>
namespace Manta {
namespace Intersection {
- inline bool intersectTriangleEdge(Real &t, Real &u, Real &v,
-
const Ray &ray,
-
const Vector &edge1, const Vector
&edge2, const Point &p0 )
+ inline bool intersectTriangleEdge(Real& t, Real& u, Real& v,
+ const Ray& ray,
+ const Vector& edge1,
+ const Vector& edge2,
+ const Vector& p0 )
{
Vector tvec, pvec, qvec;
@@ -68,7 +70,7 @@
Real uu = Dot( tvec, pvec );
Real vv;
- if (det > 1e-5) {
+ if (det > (Real)1e-5) {
if (uu < 0 || uu > det)
return false;
@@ -79,13 +81,13 @@
return false;
}
- else if(det < -1e-5f) {
+ else if(det < (Real)-1e-5) {
if (uu > 0 || uu < det)
return false;
/* calculate V parameter and test bounds */
vv = Dot(ray.direction(), qvec) ;
- if (vv > 0.0 || uu + vv < det)
+ if (vv > 0 || uu + vv < det)
return false;
}
else {
Modified: trunk/Model/Lights/HeadLight.cc
==============================================================================
--- trunk/Model/Lights/HeadLight.cc (original)
+++ trunk/Model/Lights/HeadLight.cc Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#include <Interface/Context.h>
#include <Interface/Camera.h>
#include <Interface/RayPacket.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
using namespace Manta;
@@ -14,11 +14,11 @@
RayPacket &rays) const
{
// Determine the camera position.
- Point camera = context.camera->getPosition();
- Vector up = context.camera->getUp();
+ Vector camera = context.camera->getPosition();
+ Vector up = context.camera->getUp();
// Determine light position.
- Point position = camera + (up * offset);
+ Vector position = camera + (up * offset);
rays.computeHitPositions();
for(int i = rays.begin(); i < rays.end(); i++){
Modified: trunk/Model/Lights/HeadLight.h
==============================================================================
--- trunk/Model/Lights/HeadLight.h (original)
+++ trunk/Model/Lights/HeadLight.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_HeadLight_h
#include <Interface/Light.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Color/Color.h>
namespace Manta {
Modified: trunk/Model/Lights/PointLight.cc
==============================================================================
--- trunk/Model/Lights/PointLight.cc (original)
+++ trunk/Model/Lights/PointLight.cc Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
using namespace Manta;
-PointLight::PointLight(const Point& position, const Color& color)
+PointLight::PointLight(const Vector& position, const Color& color)
: position(position), color(color)
{
}
Modified: trunk/Model/Lights/PointLight.h
==============================================================================
--- trunk/Model/Lights/PointLight.h (original)
+++ trunk/Model/Lights/PointLight.h Thu Feb 16 17:08:22 2006
@@ -3,13 +3,13 @@
#define Manta_Model_PointLight_h
#include <Interface/Light.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Color/Color.h>
namespace Manta {
class PointLight : public Light {
public:
- PointLight(const Point& position, const Color& color);
+ PointLight(const Vector& position, const Color& color);
virtual ~PointLight();
virtual void preprocess(const PreprocessContext&);
@@ -19,7 +19,7 @@
const RenderContext &context,
RayPacket &rays) const;
private:
- Point position;
+ Vector position;
Color color;
};
}
Modified: trunk/Model/Materials/AmbientOcclusion.h
==============================================================================
--- trunk/Model/Materials/AmbientOcclusion.h (original)
+++ trunk/Model/Materials/AmbientOcclusion.h Thu Feb 16 17:08:22 2006
@@ -4,6 +4,7 @@
#include <Model/Materials/LitMaterial.h>
#include <Core/Color/Color.h>
#include <Interface/Texture.h>
+#include <Core/Geometry/Vector.h>
#include <sgi_stl_warnings_off.h>
#include <vector>
Modified: trunk/Model/Materials/Checker.h
==============================================================================
--- trunk/Model/Materials/Checker.h (original)
+++ trunk/Model/Materials/Checker.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_Checker_h
#include <Interface/Material.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta{
class LightSet;
Modified: trunk/Model/Materials/Dielectric.cc
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/Dielectric.cc Thu Feb 16 17:08:22 2006
@@ -113,7 +113,7 @@
Real cosine_sq = 1 + (n_dot_v*n_dot_v - 1) * (eta_tmp_inv*eta_tmp_inv);
Color in_importance = rays.getImportance(i);
- Point hitpos = rays.getHitPosition(i);
+ Vector hitpos = rays.getHitPosition(i);
if ( cosine_sq <= 0 ) {
// total internal reflection - no attenuation
Color refl_importance = in_importance * beers_color;
Modified: trunk/Model/MiscObjects/CuttingPlane.cc
==============================================================================
--- trunk/Model/MiscObjects/CuttingPlane.cc (original)
+++ trunk/Model/MiscObjects/CuttingPlane.cc Thu Feb 16 17:08:22 2006
@@ -3,9 +3,21 @@
#include <Model/Intersections/AxisAlignedBox.h>
#include <Model/Intersections/Plane.h>
+#include <sgi_stl_warnings_off.h>
#include <iostream>
+#include <sgi_stl_warnings_on.h>
using namespace Manta;
+
+CuttingPlane::CuttingPlane( const Vector &point_, const Vector &normal_,
+ Object *internal_object_ )
+ : internal_object( internal_object_ ),
+ movement_scale( 1 ),
+ initial_point( point_ ),
+ plane_point( point_ ),
+ plane_normal( normal_ )
+{
+}
void CuttingPlane::movePlaneAlongNormal( Real distance )
{
Modified: trunk/Model/MiscObjects/CuttingPlane.h
==============================================================================
--- trunk/Model/MiscObjects/CuttingPlane.h (original)
+++ trunk/Model/MiscObjects/CuttingPlane.h Thu Feb 16 17:08:22 2006
@@ -2,7 +2,7 @@
#ifndef Manta_Model_CuttingPlane_h
#define Manta_Model_CuttinPlane_h
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/BBox.h>
#include <Interface/Object.h>
#include <Interface/RayPacket.h>
@@ -19,18 +19,14 @@
Object *internal_object; // Object to be cut.
Real movement_scale;
- Point initial_point;
+ Vector initial_point;
- Point plane_point;
+ Vector plane_point;
Vector plane_normal;
public:
- CuttingPlane( const Point &point_, const Vector &normal_, Object
*internal_object_ ) :
- internal_object( internal_object_ ),
- movement_scale( 1.0 ),
- initial_point( point_ ),
- plane_point( point_ ),
- plane_normal( normal_ ) { }
+ CuttingPlane( const Vector &point_, const Vector &normal_,
+ Object *internal_object_ );
// Preprocess the internal object and compute its bounds.
void preprocess( const PreprocessContext &context );
@@ -49,10 +45,10 @@
Object *getObject() { return internal_object; };
void setObject( Object *object_ ) { internal_object = object_; };
- void getPlanePoint ( Point &result ) { result = plane_point; };
- void getPlaneNormal( Vector &result ) { result = plane_normal; };
+ void getPlanePoint ( Vector& result ) { result = plane_point; };
+ void getPlaneNormal( Vector& result ) { result = plane_normal; };
- void setPlanePoint ( const Point &plane_point_ )
+ void setPlanePoint ( const Vector &plane_point_ )
{
plane_point = plane_point_;
}
Modified: trunk/Model/Primitives/BvhTriangleMesh.cc
==============================================================================
--- trunk/Model/Primitives/BvhTriangleMesh.cc (original)
+++ trunk/Model/Primitives/BvhTriangleMesh.cc Thu Feb 16 17:08:22 2006
@@ -202,7 +202,7 @@
}
// Find a pivot point.
- Point pivot((Vector(new_node->bounds[0]) + Vector(new_node->bounds[1])) *
0.5);
+ Vector pivot((new_node->bounds[0] + new_node->bounds[1]) * (Real)0.5);
// Split along the axis.
int mid_point = qsplit( array, size, pivot[axis], axis );
@@ -227,7 +227,7 @@
///////////////////////////////////////////////////////////////////////////////
// Construct a BVH from an array of objects.
-BvhTriangleMesh::BvhTriangleMesh( Point *vertex_array_,
+BvhTriangleMesh::BvhTriangleMesh( Vector *vertex_array_,
Vector *edge_array_,
Vector *normal_array_,
IndexedTriangle *triangle_array_,
@@ -249,7 +249,7 @@
}
// Find a pivot point.
- Point pivot((Vector(root->bounds[0]) + Vector(root->bounds[1])) * 0.5);
+ Vector pivot((root->bounds[0] + root->bounds[1]) * (Real)0.5);
// Split along the axis.
int mid_point = qsplit( array, size, pivot[0], 0 );
Modified: trunk/Model/Primitives/BvhTriangleMesh.h
==============================================================================
--- trunk/Model/Primitives/BvhTriangleMesh.h (original)
+++ trunk/Model/Primitives/BvhTriangleMesh.h Thu Feb 16 17:08:22 2006
@@ -32,7 +32,7 @@
#include <Model/Primitives/PrimitiveCommon.h>
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/BBox.h>
namespace Manta {
@@ -82,7 +82,7 @@
///////////////////////////////////////////////////////////////////////////
// Data members indexed to.
- Point *vertex_array;
+ Vector *vertex_array;
Vector *edge_array;
Vector *normal_array;
@@ -107,9 +107,9 @@
inline void compute_bounds( BBox &bounds, int triangle )
const {
- Point &v0 = vertex_array[ triangle_array[ triangle
].v0 ];
- Vector &e0 = edge_array [ triangle_array[ triangle
].e0 ];
- Vector &e1 = edge_array [ triangle_array[ triangle
].e1 ];
+ Vector& v0 = vertex_array[ triangle_array[ triangle
].v0 ];
+ Vector& e0 = edge_array [ triangle_array[ triangle
].e0 ];
+ Vector& e1 = edge_array [ triangle_array[ triangle
].e1 ];
bounds.extendByPoint( v0 );
bounds.extendByPoint( v0 + e0 );
@@ -125,7 +125,7 @@
// int array of triangle indices.
BvhTriangleMesh( // Mesh data (possibly shared) to index into.
- Point *vertex_array_,
+ Vector *vertex_array_,
Vector *edge_array_,
Vector *normal_array_,
IndexedTriangle *triangle_array_,
Modified: trunk/Model/Primitives/CMakeLists.txt
==============================================================================
--- trunk/Model/Primitives/CMakeLists.txt (original)
+++ trunk/Model/Primitives/CMakeLists.txt Thu Feb 16 17:08:22 2006
@@ -6,6 +6,9 @@
Primitives/Cone.h
Primitives/Cube.cc
Primitives/Cube.h
+ # Cylinder needs to be fixed before using.
+# Primitives/Cylinder.cc
+# Primitives/Cylinder.h
Primitives/Disk.cc
Primitives/Disk.h
Primitives/HeavyTriangle.cc
Modified: trunk/Model/Primitives/Cone.cc
==============================================================================
--- trunk/Model/Primitives/Cone.cc (original)
+++ trunk/Model/Primitives/Cone.cc Thu Feb 16 17:08:22 2006
@@ -9,7 +9,8 @@
using namespace SCIRun;
using namespace std;
-Cone::Cone(Material* mat, const Point& bottom, const Point& top, Real Rb,
Real Rt)
+Cone::Cone(Material* mat, const Vector& bottom, const Vector& top,
+ Real Rb, Real Rt)
: PrimitiveCommon(mat, this), bottom(bottom), top(top), Rb(Rb), Rt(Rt)
{
}
@@ -29,7 +30,7 @@
void Cone::intersect(const RenderContext&, RayPacket& rays) const
{
if(rays.getFlag(RayPacket::ConstantOrigin)) {
- Point Pa = bottom + Rb * (top - bottom) / (Rb-Rt);
+ Vector Pa = bottom + Rb * (top - bottom) / (Rb-Rt);
Real btx = (top.x()-bottom.x())*(top.x()-bottom.x());
Real bty = (top.y()-bottom.y())*(top.y()-bottom.y());
Real btz = (top.z()-bottom.z())*(top.z()-bottom.z());
@@ -43,10 +44,10 @@
Real sinA = lbt/hyp;
Real cosA2 = cosA*cosA;
Real sinA2 = sinA*sinA;
- Point P(xform * rays.getOrigin(rays.begin()));
+ Vector P(xform.multiply_point(rays.getOrigin(rays.begin())));
Vector dP(P - Pa);
for(int i=rays.begin(); i<rays.end(); i++) {
- Vector V(xform * rays.getDirection(i));
+ Vector V(xform.multiply_vector(rays.getDirection(i)));
Vector tv = V;
Real dist_scale = tv.normalize();
Real a = ((cosA2*Dot(V-Dot(V,Va)*Va, V-Dot(V,Va)*Va))-
@@ -81,7 +82,7 @@
}
}
else {
- Point Pa = bottom + Rb * (top - bottom) / (Rb-Rt);
+ Vector Pa = bottom + Rb * (top - bottom) / (Rb-Rt);
Real btx = (top.x()-bottom.x())*(top.x()-bottom.x());
Real bty = (top.y()-bottom.y())*(top.y()-bottom.y());
Real btz = (top.z()-bottom.z())*(top.z()-bottom.z());
@@ -96,9 +97,9 @@
Real cosA2 = cosA*cosA;
Real sinA2 = sinA*sinA;
for(int i=rays.begin(); i<rays.end(); i++) {
- Point P(xform * rays.getOrigin(i));
+ Vector P(xform.multiply_point(rays.getOrigin(i)));
Vector dP(P - Pa);
- Vector V(xform * rays.getDirection(i));
+ Vector V(xform.multiply_vector(rays.getDirection(i)));
Vector tv = V;
Real dist_scale = tv.normalize();
Real a = ((cosA2*Dot(V-Dot(V,Va)*Va, V-Dot(V,Va)*Va))-
@@ -154,7 +155,7 @@
RayPacket& rays) const
{
for(int i=rays.begin();i<rays.end();i++)
- rays.setTexCoords(i, rays.scratchpad<Point>(i));
+ rays.setTexCoords(i, rays.scratchpad<Vector>(i));
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
@@ -162,6 +163,6 @@
RayPacket& rays) const
{
for(int i=rays.begin();i<rays.end();i++)
- rays.setTexCoords(i, rays.scratchpad<Point>(i));
+ rays.setTexCoords(i, rays.scratchpad<Vector>(i));
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
Modified: trunk/Model/Primitives/Cone.h
==============================================================================
--- trunk/Model/Primitives/Cone.h (original)
+++ trunk/Model/Primitives/Cone.h Thu Feb 16 17:08:22 2006
@@ -4,14 +4,15 @@
#include <Model/Primitives/PrimitiveCommon.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/AffineTransform.h>
namespace Manta
{
class Cone : public PrimitiveCommon, public TexCoordMapper {
public:
- Cone(Material* mat, const Point& bottom, const Point& top, Real Rb, Real
Rt);
+ Cone(Material* mat, const Vector& bottom, const Vector& top,
+ Real Rb, Real Rt);
virtual ~Cone();
virtual void computeBounds(const PreprocessContext& context,
@@ -24,7 +25,7 @@
RayPacket& rays) const;
private:
- Point bottom, top;
+ Vector bottom, top;
Real Rb, Rt;
AffineTransform xform, ixform;
};
Modified: trunk/Model/Primitives/Cube.cc
==============================================================================
--- trunk/Model/Primitives/Cube.cc (original)
+++ trunk/Model/Primitives/Cube.cc Thu Feb 16 17:08:22 2006
@@ -10,7 +10,7 @@
using namespace std;
using SCIRun::Abs;
-Cube::Cube(Material* mat, const Point& p0, const Point& p1)
+Cube::Cube(Material* mat, const Vector& p0, const Vector& p1)
: PrimitiveCommon(mat)
{
bbox[0] = Min(p0, p1);
@@ -62,7 +62,7 @@
{
rays.computeHitPositions();
for(int i=rays.begin(); i<rays.end(); i++) {
- Point hp = rays.getHitPosition(i);
+ Vector hp = rays.getHitPosition(i);
if (Abs(hp.x() - bbox[0][0]) < 0.0001)
rays.setNormal(i, Vector(-1, 0, 0 ));
Modified: trunk/Model/Primitives/Cube.h
==============================================================================
--- trunk/Model/Primitives/Cube.h (original)
+++ trunk/Model/Primitives/Cube.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_Cube_h
#include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/BBox.h>
namespace Manta
@@ -11,7 +11,7 @@
class Cube : public PrimitiveCommon {
public:
- Cube(Material *mat, const Point &min_, const Point &max_ );
+ Cube(Material* mat, const Vector& min_, const Vector& max_ );
~Cube();
virtual void computeBounds(const PreprocessContext& context,
Modified: trunk/Model/Primitives/Cylinder.cc
==============================================================================
--- trunk/Model/Primitives/Cylinder.cc (original)
+++ trunk/Model/Primitives/Cylinder.cc Thu Feb 16 17:08:22 2006
@@ -1,14 +1,16 @@
#include <Packages/manta/Model/Primitives/Cylinder.h>
#include <Packages/manta/Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
+#include <Core/Exceptions/BadPrimitive.h>
using namespace Manta;
using namespace std;
-Cylinder::Cylinder(Material* mat, const Point& bottom, const Point& top,
- double radius)
+Cylinder::Cylinder(Material* mat, const Vector& bottom, const Vector& top,
+ Real radius)
: PrimitiveCommon(mat, this), bottom(bottom), top(top), radius(radius)
{
+ throw BadPrimitive("Cylinder class's implementation is not finished");
}
Cylinder::~Cylinder()
Modified: trunk/Model/Primitives/Cylinder.h
==============================================================================
--- trunk/Model/Primitives/Cylinder.h (original)
+++ trunk/Model/Primitives/Cylinder.h Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#include <Model/Primitives/PrimitiveCommon.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/AffineTransform.h>
namespace Manta
@@ -12,7 +12,7 @@
class Cylinder : public PrimitiveCommon, public TexCoordMapper {
public:
- Cylinder(Material* mat, const Point& bottom, const Point& top,
+ Cylinder(Material* mat, const Vector& bottom, const Vector& top,
double radius);
virtual ~Cylinder();
@@ -22,8 +22,8 @@
virtual void computeNormal(const RenderContext& context, RayPacket
&rays) const;
private:
- Point bottom, top;
- double radius;
+ Vector bottom, top;
+ Real radius;
AffineTransform xform;
AffineTransform ixform;
};
Modified: trunk/Model/Primitives/Disk.cc
==============================================================================
--- trunk/Model/Primitives/Disk.cc (original)
+++ trunk/Model/Primitives/Disk.cc Thu Feb 16 17:08:22 2006
@@ -7,7 +7,7 @@
using namespace Manta;
using namespace std;
-Disk::Disk(Material* mat, const Point& center, const Vector& n,
+Disk::Disk(Material* mat, const Vector& center, const Vector& n,
Real radius, const Vector& axis)
: PrimitiveCommon(mat, this), _c(center), _n(n), _r(radius),
_partial(false), _minTheta(0.0), _maxTheta(2.0 * M_PI)
@@ -17,7 +17,7 @@
setupAxes(axis);
}
-Disk::Disk(Material* mat, const Point& center, const Vector& n,
+Disk::Disk(Material* mat, const Vector& center, const Vector& n,
Real radius, const Vector& axis, Real minTheta, Real maxTheta)
: PrimitiveCommon(mat, this), _c(center), _n(n), _r(radius),
_partial(true), _minTheta(minTheta), _maxTheta(maxTheta)
@@ -40,7 +40,7 @@
void Disk::intersect(const RenderContext& /*context*/, RayPacket& rays) const
{
if (rays.getFlag(RayPacket::ConstantOrigin)) {
- Point rayO = rays.getOrigin(rays.begin());
+ Vector rayO = rays.getOrigin(rays.begin());
Real nDotO(Dot(_n, rayO));
for (int i = rays.begin(); i < rays.end(); i++) {
@@ -56,7 +56,7 @@
}
} else {
for (int i = rays.begin(); i < rays.end(); i++) {
- Point rayO = rays.getOrigin(i);
+ Vector rayO = rays.getOrigin(i);
Vector rayD = rays.getDirection(i);
Real denom = Dot(_n, rayD);
@@ -89,13 +89,13 @@
// set 2-d texture coordinates as returned by getTexCoords()
for (int i = rays.begin(); i < rays.end(); i++) {
- Point p = rays.getHitPosition(i);
+ Vector p = rays.getHitPosition(i);
Vector dir = p - _c;
Real dist = dir.normalize();
Real theta = Atan2(Dot(_v, dir), Dot(_u, dir));
if(theta < 0)
theta += (Real)M_PI;
- rays.setTexCoords(i, Point(dist/_r, (theta - _minTheta) / (_maxTheta -
_minTheta), 0));
+ rays.setTexCoords(i, Vector(dist/_r, (theta - _minTheta) / (_maxTheta -
_minTheta), 0));
}
// set flag to show texcoords have been computed
@@ -111,13 +111,13 @@
// set 3-d texture coordinates to be the hit locations
for (int i = rays.begin(); i < rays.end(); i++) {
- Point p = rays.getHitPosition(i);
+ Vector p = rays.getHitPosition(i);
Vector dir = p - _c;
Real dist = dir.normalize();
Real theta = Atan2(Dot(_v, dir), Dot(_u, dir));
if(theta < 0)
theta += (Real)M_PI;
- rays.setTexCoords(i, Point(dist/_r, (theta - _minTheta) / (_maxTheta -
_minTheta), 0));
+ rays.setTexCoords(i, Vector(dist/_r, (theta - _minTheta) / (_maxTheta -
_minTheta), 0));
}
// set flag to show texcoords have been computed
@@ -131,7 +131,7 @@
* lies within the region of the plane encompassed by the (possibly partial)
* disk, false otherwise.
**/
-bool Disk::checkBounds(const Point& p) const {
+bool Disk::checkBounds(const Vector& p) const {
Vector dir(p - _c);
Real dist(dir.normalize());
@@ -139,7 +139,7 @@
return false;
if (_partial) {
- Real theta(atan2(Dot(_v, dir), Dot(_u, dir)));
+ Real theta(Atan2(Dot(_v, dir), Dot(_u, dir)));
if (theta < 0)
theta = 2 * (Real)M_PI + theta;
Modified: trunk/Model/Primitives/Disk.h
==============================================================================
--- trunk/Model/Primitives/Disk.h (original)
+++ trunk/Model/Primitives/Disk.h Thu Feb 16 17:08:22 2006
@@ -4,14 +4,14 @@
#include <Model/Primitives/PrimitiveCommon.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class Disk : public PrimitiveCommon, public TexCoordMapper {
public:
- Disk(Material* mat, const Point& center, const Vector& n,
+ Disk(Material* mat, const Vector& center, const Vector& n,
Real radius, const Vector& axis);
- Disk(Material* mat, const Point& center, const Vector& n,
+ Disk(Material* mat, const Vector& center, const Vector& n,
Real radius, const Vector& axis, Real minTheta, Real maxTheta);
virtual ~Disk();
@@ -24,13 +24,13 @@
private:
bool _partial;
- Point _c;
+ Vector _c;
Vector _n, _u, _v;
Real _d, _r, _minTheta, _maxTheta;
- bool checkBounds(const Point& p) const;
+ bool checkBounds(const Vector& p) const;
void setupAxes(const Vector& axis);
- void getTexCoords(Point& p) const;
+ void getTexCoords(Vector& p) const;
};
}
Modified: trunk/Model/Primitives/HeavyTriangle.cc
==============================================================================
--- trunk/Model/Primitives/HeavyTriangle.cc (original)
+++ trunk/Model/Primitives/HeavyTriangle.cc Thu Feb 16 17:08:22 2006
@@ -38,6 +38,33 @@
using namespace Manta;
using namespace std;
+HeavyTriangle::HeavyTriangle(Material* material_, const Vector& p0_,
+ const Vector& p1_, const Vector& p2_ )
+ : PrimitiveCommon( material_ )
+{
+ point = p0_;
+
+ edge[0] = (p1_-p0_);
+ edge[1] = (p2_-p0_);
+
+ n[0] = Cross( edge[0], edge[1] );
+ n[0].normalize();
+ n[1] = n[2] = n[0];
+}
+
+HeavyTriangle::HeavyTriangle(Material* material_, const Vector& point_,
+ const Vector& edge0_, const Vector& edge1_,
+ const Vector& n0_, const Vector& n1_,
+ const Vector& n2_ )
+ : PrimitiveCommon( material_ )
+{
+ point = point_;
+ edge[0] = edge0_;
+ edge[1] = edge1_;
+ n[0] = n0_;
+ n[1] = n1_;
+ n[2] = n2_;
+}
HeavyTriangle::~HeavyTriangle()
{
Modified: trunk/Model/Primitives/HeavyTriangle.h
==============================================================================
--- trunk/Model/Primitives/HeavyTriangle.h (original)
+++ trunk/Model/Primitives/HeavyTriangle.h Thu Feb 16 17:08:22 2006
@@ -33,7 +33,7 @@
#include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/Ray.h>
// Major revision: Abe Stephens, December 2005
@@ -45,7 +45,7 @@
// normal for each vertex.
class HeavyTriangle : public PrimitiveCommon {
protected:
- Point point;
+ Vector point;
Vector edge[2];
Vector n[3];
@@ -56,30 +56,14 @@
};
HeavyTriangle() : PrimitiveCommon( 0 ) { };
- HeavyTriangle(Material *material_, const Point &p0_, const Point &p1_,
const Point &p2_ ) :
- PrimitiveCommon( material_ )
- {
- point = p0_;
- edge[0] = (p1_-p0_);
- edge[1] = (p2_-p0_);
+ HeavyTriangle(Material* material_, const Vector& p0_,
+ const Vector& p1_, const Vector& p2_ );
- n[0] = Cross( edge[0], edge[1] );
- n[0].normalize();
- n[1] = n[2] = n[0];
- }
+ HeavyTriangle(Material* material_, const Vector& point_,
+ const Vector& edge0_, const Vector& edge1_,
+ const Vector& n0_, const Vector& n1_, const Vector& n2_ );
- HeavyTriangle(Material *material_, const Point &point_, const Vector
&edge0_, const Vector &edge1_,
- const Vector &n0_, const Vector &n1_, const Vector &n2_ ) :
- PrimitiveCommon( material_ )
- {
- point = point_;
- edge[0] = edge0_;
- edge[1] = edge1_;
- n[0] = n0_;
- n[1] = n1_;
- n[2] = n2_;
- }
virtual ~HeavyTriangle();
virtual void intersect (const RenderContext& context, RayPacket&
rays) const;
Modified: trunk/Model/Primitives/Heightfield.cc
==============================================================================
--- trunk/Model/Primitives/Heightfield.cc (original)
+++ trunk/Model/Primitives/Heightfield.cc Thu Feb 16 17:08:22 2006
@@ -5,9 +5,12 @@
#include <Core/Math/Expon.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/MinMax.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
+
+#include <sgi_stl_warnings_off.h>
#include <fstream>
#include <iostream>
+#include <sgi_stl_warnings_on.h>
using namespace Manta;
using namespace std;
@@ -42,7 +45,7 @@
//
--------------------------------------------------------------------------------------
// --- Constructor
//
--------------------------------------------------------------------------------------
-Heightfield::Heightfield(Material * material, char * fileName, const Point &
minBound, const Point & maxBound, Real scale)
+Heightfield::Heightfield(Material * material, char * fileName, const Vector
& minBound, const Vector & maxBound, Real scale)
: PrimitiveCommon(material), m_Box(minBound, maxBound)
{
readHeightfieldFile(fileName, &m_Nx, &m_Ny, &m_Data);
@@ -77,7 +80,7 @@
RayPacket& rays) const
{
Vector diagonal;
- Point hitPoint;
+ Vector hitPoint;
int hitLattice[2], stop[2], di[2], ind;
Real tnext[2], dtd[2], far[2], zm[2], datam[2], cellSize[2];
Real tnear, tfar, zenter, texit, zexit;
@@ -159,7 +162,7 @@
{
Real a, b, c;
Real sx, dx, sy, dy;
- Point pe;
+ Vector pe;
Real ce[2], z[4];
pe = ray.origin() + ray.direction() * tnear;
@@ -188,7 +191,10 @@
u = sx + tcell * dx;
v = sy + tcell * dy;
- if (tcell > T_EPSILON && tcell < texit && u > 0.0 && u < 1.0 && v
>
0.0 && v < 1.0)
+ if (tcell > T_EPSILON &&
+ tcell < texit &&
+ u > 0 && u < 1 &&
+ v > 0 && v < 1)
{
if (rays.hit(i, tnear + tcell, getMaterial(), this,
getTexCoordMapper()))
rays.scratchpad<Vector>(i) = Vector(- (z[1] + v*z[3]) /
cellSize[0], - (z[2] + u*z[3]) / cellSize[1], 1.0);
Modified: trunk/Model/Primitives/Heightfield.h
==============================================================================
--- trunk/Model/Primitives/Heightfield.h (original)
+++ trunk/Model/Primitives/Heightfield.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_Heightfield_h
#include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/BBox.h>
namespace Manta {
@@ -13,7 +13,7 @@
public:
- Heightfield(Material * material, char * fileName, const
Point & minBound, const Point & maxBound, Real scale = 0.95);
+ Heightfield(Material * material, char * fileName, const
Vector & minBound, const Vector & maxBound, Real scale = 0.95);
virtual ~Heightfield();
virtual void computeBounds(const PreprocessContext & context, BBox &
bbox) const;
Modified: trunk/Model/Primitives/Hemisphere.cc
==============================================================================
--- trunk/Model/Primitives/Hemisphere.cc (original)
+++ trunk/Model/Primitives/Hemisphere.cc Thu Feb 16 17:08:22 2006
@@ -12,7 +12,8 @@
using namespace SCIRun;
using namespace std;
-Hemisphere::Hemisphere(Material* material, const Point& center, Real radius,
const Vector& normal)
+Hemisphere::Hemisphere(Material* material, const Vector& center,
+ Real radius, const Vector& normal)
: PrimitiveCommon(material, this), _c(center), _r(radius), _n(normal)
{
setupAxes();
@@ -29,11 +30,12 @@
void Hemisphere::intersect(const RenderContext&, RayPacket& rays) const
{
- switch(rays.getFlag(RayPacket::ConstantOrigin |
RayPacket::NormalizedDirections)){
+ switch(rays.getFlag(RayPacket::ConstantOrigin |
+ RayPacket::NormalizedDirections)) {
case RayPacket::ConstantOrigin | RayPacket::NormalizedDirections:
{
// Rays all have the same origin and unit-length directions
- Point rayO = rays.getOrigin(rays.begin());
+ Vector rayO = rays.getOrigin(rays.begin());
Vector tRayO = rayO - _c;
Real c = Dot(tRayO, tRayO) - _r * _r;
@@ -43,7 +45,7 @@
Real b = Dot(tRayO, rayD);
Real disc = b * b - c;
- if (disc >= 0.0) {
+ if (disc >= 0) {
Real r = Sqrt(disc);
Real t = -(b + r);
if (t > 0 && checkBounds(rayO + t * rayD)) {
@@ -61,7 +63,7 @@
case RayPacket::ConstantOrigin:
{
// Rays all have the same origin
- Point rayO = rays.getOrigin(rays.begin());
+ Vector rayO = rays.getOrigin(rays.begin());
Vector tRayO = rayO - _c;
Real c = Dot(tRayO, tRayO) - _r * _r;
@@ -72,14 +74,14 @@
Real b = Dot(tRayO, rayD);
Real disc = b * b - a * c;
- if (disc >= 0.0) {
+ if (disc >= 0) {
Real r = Sqrt(disc);
Real t = -(b + r) / a;
- if (t > 0.0 && checkBounds(rayO + t * rayD)) {
+ if (t > 0 && checkBounds(rayO + t * rayD)) {
rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
} else {
t = (r - b) / a;
- if (t > 0.0 && checkBounds(rayO + t * rayD)) {
+ if (t > 0 && checkBounds(rayO + t * rayD)) {
rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
}
}
@@ -91,7 +93,7 @@
{
// Rays all have unit-length direction
for (int i = rays.begin(); i < rays.end(); i++) {
- Point rayO = rays.getOrigin(i);
+ Vector rayO = rays.getOrigin(i);
Vector rayD = rays.getDirection(i);
Vector tRayO = rayO - _c;
@@ -99,14 +101,14 @@
Real c = Dot(tRayO, tRayO) - _r * _r;
Real disc = b * b - c;
- if (disc >= 0.0) {
+ if (disc >= 0) {
Real r = Sqrt(disc);
Real t = -(b + r);
if (t > 0.0 && checkBounds(rayO + t * rayD)) {
rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
} else {
t = r - b;
- if (t > 0.0 && checkBounds(rayO + t * rayD)) {
+ if (t > 0 && checkBounds(rayO + t * rayD)) {
rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
}
}
@@ -118,7 +120,7 @@
{
// General rays
for (int i = rays.begin(); i < rays.end(); i++) {
- Point rayO = rays.getOrigin(i);
+ Vector rayO = rays.getOrigin(i);
Vector rayD = rays.getDirection(i);
Vector tRayO = rayO - _c;
@@ -127,18 +129,18 @@
Real c = Dot(tRayO, tRayO) - _r * _r;
Real disc = b * b - a * c;
- if (disc >= 0.0) {
+ if (disc >= 0) {
Real r = Sqrt(disc);
Real t = -(b + r) / a;
- if ((t > 0.0) && checkBounds(rayO + t * rayD)) {
+ if ((t > 0) && checkBounds(rayO + t * rayD)) {
rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
} else {
t = (r - b) / a;
- if (t > 0.0 && checkBounds(rayO + t * rayD)) {
+ if (t > 0 && checkBounds(rayO + t * rayD)) {
rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
}
}
- }
+ }
}
}
}
@@ -163,7 +165,9 @@
Vector n = rays.getNormal(i);
Real theta = Acos(Dot(_n, n));
Real phi = Atan2(Dot(_u, n), Dot(_v, n));
- rays.setTexCoords(i, Point(0.5 * phi / M_PI, 2.0 * theta / M_PI, 0.0));
+ Real x = phi * (Real)(M_1_PI*0.5);
+ Real y = theta * (Real)M_2_PI;
+ rays.setTexCoords(i, Vector(x, y, 0));
}
rays.setFlag(RayPacket::HaveTexture2 | RayPacket::HaveTexture3);
@@ -178,7 +182,9 @@
Vector n = rays.getNormal(i);
Real theta = Acos(Dot(_n, n));
Real phi = Atan2(Dot(_u, n), Dot(_v, n));
- rays.setTexCoords(i, Point(0.5 * phi / M_PI, 2.0 * theta / M_PI, 0.0));
+ Real x = phi * (Real)(M_1_PI*0.5);
+ Real y = theta * (Real)M_2_PI;
+ rays.setTexCoords(i, Vector(x, y, 0));
}
rays.setFlag(RayPacket::HaveTexture2 | RayPacket::HaveTexture3);
@@ -190,9 +196,9 @@
* Given a point p assumed to lie on the sphere, checks to make sure it lies
* within the correct hemisphere.
**/
-bool Hemisphere::checkBounds(const Point& p) const
+bool Hemisphere::checkBounds(const Vector& p) const
{
- return (Dot(_n, p - _c) >= 0.0);
+ return (Dot(_n, p - _c) >= 0);
}
void Hemisphere::setupAxes()
Modified: trunk/Model/Primitives/Hemisphere.h
==============================================================================
--- trunk/Model/Primitives/Hemisphere.h (original)
+++ trunk/Model/Primitives/Hemisphere.h Thu Feb 16 17:08:22 2006
@@ -1,6 +1,3 @@
-#ifndef Manta_Model_Hemisphere_h
-#define Manta_Model_Hemisphere_h
-
/*
For more information, please see:
http://software.sci.utah.edu
@@ -29,14 +26,18 @@
DEALINGS IN THE SOFTWARE.
*/
+#ifndef Manta_Model_Hemisphere_h
+#define Manta_Model_Hemisphere_h
+
+#include <MantaTypes.h>
#include <Model/Primitives/PrimitiveCommon.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class Hemisphere : public PrimitiveCommon, public TexCoordMapper {
public:
- Hemisphere(Material* material, const Point& center, Real radius, const
Vector& normal);
+ Hemisphere(Material* material, const Vector& center, Real radius, const
Vector& normal);
virtual ~Hemisphere();
virtual void computeBounds(const PreprocessContext& context, BBox& bbox)
const;
@@ -47,12 +48,12 @@
virtual void computeTexCoords3(const RenderContext& context, RayPacket&
rays) const;
private:
- Point _c;
+ Vector _c;
Real _r;
Real _inv_r;
Vector _n, _u, _v;
- bool checkBounds(const Point& p) const;
+ bool checkBounds(const Vector& p) const;
void setupAxes();
};
}
Modified: trunk/Model/Primitives/Parallelogram.cc
==============================================================================
--- trunk/Model/Primitives/Parallelogram.cc (original)
+++ trunk/Model/Primitives/Parallelogram.cc Thu Feb 16 17:08:22 2006
@@ -7,8 +7,8 @@
using namespace Manta;
using SCIRun::Abs;
-Parallelogram::Parallelogram(Material* material, const Point& anchor,
- const Vector& in_v1, const Vector& in_v2)
+Parallelogram::Parallelogram(Material* material, const Vector& anchor,
+ const Vector& in_v1, const Vector& in_v2)
: PrimitiveCommon(material, this), anchor(anchor), v1(in_v1), v2(in_v2)
{
normal = Cross(v1, v2);
@@ -51,7 +51,7 @@
rays.normalizeDirections();
if(rays.getFlag(RayPacket::ConstantOrigin) && rays.end()-rays.begin() > 1){
Real num = d-Dot(normal, rays.getOrigin(0));
- Point a(rays.getOrigin(0)-anchor);
+ Vector a(rays.getOrigin(0)-anchor);
Real o1 = Dot(a, v1);
Real o2 = Dot(a, v2);
int i = rays.begin();
@@ -71,7 +71,7 @@
continue;
if(rays.hit(i, t, getMaterial(), this, getTexCoordMapper()))
- rays.scratchpad<Point>(i) = Point(a1, a2, 0);
+ rays.scratchpad<Vector>(i) = Vector(a1, a2, 0);
} while(++i < rays.end());
} else {
int i = rays.begin();
@@ -80,11 +80,11 @@
Real dt=Dot(dir, normal);
if(Abs(dt) < (Real)1.e-6)
continue;
- Point origin = rays.getOrigin(i);
+ Vector origin = rays.getOrigin(i);
Real t=(d-Dot(normal, origin))/dt;
if(t>rays.getMinT(i))
continue;
- Point p(origin+dir*t);
+ Vector p(origin+dir*t);
Vector vi(p-anchor);
Real a1 = Dot(v1, vi);
if (a1 < 0 || a1 > 1)
@@ -94,7 +94,7 @@
continue;
if(rays.hit(i, t, getMaterial(), this, getTexCoordMapper()))
- rays.scratchpad<Point>(i) = Point(a1, a2, 0);
+ rays.scratchpad<Vector>(i) = Vector(a1, a2, 0);
} while(++i < rays.end());
}
}
@@ -103,7 +103,7 @@
RayPacket& rays) const
{
for(int i=rays.begin();i<rays.end();i++){
- rays.setTexCoords(i, rays.scratchpad<Point>(i));
+ rays.setTexCoords(i, rays.scratchpad<Vector>(i));
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
@@ -112,7 +112,7 @@
RayPacket& rays) const
{
for(int i=rays.begin();i<rays.end();i++){
- rays.setTexCoords(i, rays.scratchpad<Point>(i));
+ rays.setTexCoords(i, rays.scratchpad<Vector>(i));
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
Modified: trunk/Model/Primitives/Parallelogram.h
==============================================================================
--- trunk/Model/Primitives/Parallelogram.h (original)
+++ trunk/Model/Primitives/Parallelogram.h Thu Feb 16 17:08:22 2006
@@ -4,13 +4,13 @@
#include <Model/Primitives/PrimitiveCommon.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class Parallelogram : public PrimitiveCommon, public TexCoordMapper {
public:
- Parallelogram(Material* material, const Point& anchor,
- const Vector& v1, const Vector& v2);
+ Parallelogram(Material* material, const Vector& anchor,
+ const Vector& v1, const Vector& v2);
virtual ~Parallelogram();
virtual void computeBounds(const PreprocessContext& context,
@@ -22,7 +22,7 @@
virtual void computeTexCoords3(const RenderContext& context,
RayPacket& rays) const;
private:
- Point anchor;
+ Vector anchor;
Vector v1, v2;
Vector normal;
Real d;
Modified: trunk/Model/Primitives/ParticleBVH.cc
==============================================================================
--- trunk/Model/Primitives/ParticleBVH.cc (original)
+++ trunk/Model/Primitives/ParticleBVH.cc Thu Feb 16 17:08:22 2006
@@ -25,20 +25,20 @@
void ParticleBVH::setParticle(
int const which_one,
Color const &color,
- Point const ¢er,
- double const radius )
+ Vector const ¢er,
+ Real const radius )
{
particles[ which_one ].color = color;
particles[ which_one ].center = center;
particles[ which_one ].radius = radius;
- particles[ which_one ].inverse_radius = 1.0 / radius;
+ particles[ which_one ].inverse_radius = 1 / radius;
}
inline int ParticleBVH::partition(
int first,
int last,
int const axis,
- double const position )
+ Real const position )
{
--first;
for ( ; ; ) {
@@ -64,7 +64,8 @@
Node &node( nodes[ index ] );
node.bound.reset();
for ( int current = first; current < last; ++current )
- node.bound.extendBySphere( particles[ current ].center, particles[
current ].radius );
+ node.bound.extendBySphere( particles[ current ].center,
+ particles[ current ].radius );
if ( last - first <= maximum_objects_per_leaf ) {
node.index = first;
node.length = last - first;
@@ -73,7 +74,7 @@
return size;
}
int axis = node.bound.longestAxis();
- double position = ( node.bound.getMin()[ axis ] + node.bound.getMax()[
axis ] ) * 0.5;
+ Real position = ( node.bound.getMin()[ axis ] + node.bound.getMax()[ axis
] ) * (Real)0.5;
int split = partition( first, last, axis, position );
if ( split == first || split == last ) {
node.index = first;
@@ -103,29 +104,30 @@
BBox &box ) const
{
for ( int current = 0; current < number_of_particles; ++current )
- box.extendBySphere( particles[ current ].center, particles[ current
].radius );
+ box.extendBySphere( particles[ current ].center,
+ particles[ current ].radius );
}
inline bool ParticleBVH::testBox(
RayPacket &rays,
BBox const &box ) const
{
- double bound[ 6 ];
+ Real bound[ 6 ];
bound[ 0 ] = box.getMin().x(); bound[ 1 ] = box.getMax().x();
bound[ 2 ] = box.getMin().y(); bound[ 3 ] = box.getMax().y();
bound[ 4 ] = box.getMin().z(); bound[ 5 ] = box.getMax().z();
for ( int ray = rays.begin(); ray < rays.end(); ++ray ) {
- double maximum_minimum = T_EPSILON;
- double minimum_maximum = rays.getMinT(ray);
- Point O = rays.getOrigin(ray);
+ Real maximum_minimum = T_EPSILON;
+ Real minimum_maximum = rays.getMinT(ray);
+ Vector O = rays.getOrigin(ray);
Vector inverseDirection = rays.getInverseDirection(ray);
VectorT<int, 3> signs = rays.getSigns(ray);
- double x_minimum = ( bound[ signs[ 0 ] ] - O.x() ) *
inverseDirection.x();
- double x_maximum = ( bound[ 1 - signs[ 0 ] ] - O.x() ) *
inverseDirection.x();
- double y_minimum = ( bound[ 2 + signs[ 1 ] ] - O.y() ) *
inverseDirection.y();
- double y_maximum = ( bound[ 3 - signs[ 1 ] ] - O.y() ) *
inverseDirection.y();
- double z_minimum = ( bound[ 4 + signs[ 2 ] ] - O.z() ) *
inverseDirection.z();
- double z_maximum = ( bound[ 5 - signs[ 2 ] ] - O.z() ) *
inverseDirection.z();
+ Real x_minimum =( bound[ signs[ 0 ] ] - O.x() ) *
inverseDirection.x();
+ Real x_maximum =( bound[ 1 - signs[ 0 ] ] - O.x() ) *
inverseDirection.x();
+ Real y_minimum =( bound[ 2 + signs[ 1 ] ] - O.y() ) *
inverseDirection.y();
+ Real y_maximum =( bound[ 3 - signs[ 1 ] ] - O.y() ) *
inverseDirection.y();
+ Real z_minimum =( bound[ 4 + signs[ 2 ] ] - O.z() ) *
inverseDirection.z();
+ Real z_maximum =( bound[ 5 - signs[ 2 ] ] - O.z() ) *
inverseDirection.z();
if ( minimum_maximum < x_minimum ||
maximum_minimum > x_maximum )
continue;
@@ -154,20 +156,20 @@
{
for ( int current = first; current < last; ++current ) {
Particle &particle( particles[ current ] );
- double radius_squared = particle.radius * particle.radius;
+ Real radius_squared = particle.radius * particle.radius;
for ( int ray = rays.begin(); ray < rays.end(); ray++ ) {
Vector offset( rays.getOrigin(ray) - particle.center );
- double B = Dot( offset, rays.getDirection(ray) );
- double C = Dot( offset, offset ) - radius_squared;
- double discriminant = B * B - C;
- if ( discriminant >= 0.0 ) {
- double r = sqrt( discriminant );
- double t0 = -r - B;
- if( t0 > 0.0 )
+ Real B = Dot( offset, rays.getDirection(ray) );
+ Real C = Dot( offset, offset ) - radius_squared;
+ Real discriminant = B * B - C;
+ if ( discriminant >= 0 ) {
+ Real r = Sqrt( discriminant );
+ Real t0 = -r - B;
+ if( t0 > 0 )
if ( rays.hit( ray, t0, getMaterial(), this, getTexCoordMapper() )
)
rays.scratchpad< int >(ray) = current;
else {
- double t1 = r - B;
+ Real t1 = r - B;
if ( rays.hit( ray, t1, getMaterial(), this, getTexCoordMapper() )
)
rays.scratchpad< int >(ray) = current;
}
Modified: trunk/Model/Primitives/ParticleBVH.h
==============================================================================
--- trunk/Model/Primitives/ParticleBVH.h (original)
+++ trunk/Model/Primitives/ParticleBVH.h Thu Feb 16 17:08:22 2006
@@ -2,7 +2,7 @@
#define Manta_Particle_BVH_h
#include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/BBox.h>
#include <Core/Color/Color.h>
#include <Interface/Texture.h>
@@ -14,7 +14,8 @@
ParticleBVH( Material *material, int const number_of_particles );
virtual ~ParticleBVH();
- virtual void setParticle( int const which_one, Color const &color, Point
const ¢er, double const radius );
+ virtual void setParticle( int const which_one, Color const& color,
+ Vector const& center, Real const radius );
virtual void preprocess( PreprocessContext const &context );
virtual void computeBounds( PreprocessContext const &context, BBox &box
) const;
virtual void intersect( RenderContext const &context, RayPacket &rays )
const;
@@ -26,10 +27,10 @@
int number_of_particles;
struct Particle {
- Color color;
- Point center;
- double radius;
- double inverse_radius;
+ Color color;
+ Vector center;
+ Real radius;
+ Real inverse_radius;
} *particles;
struct Node {
BBox bound;
@@ -39,7 +40,7 @@
bool leaf : 1;
} *nodes;
- int partition( int first, int last, int const axis, double const
position );
+ int partition( int first, int last, int const axis, Real const position
);
int build( int const index, int const first, int const last, int const
size );
bool testBox( RayPacket &rays, BBox const &box ) const;
void intersectParticles( RayPacket &rays, int const first, int const
last ) const;
Modified: trunk/Model/Primitives/Plane.cc
==============================================================================
--- trunk/Model/Primitives/Plane.cc (original)
+++ trunk/Model/Primitives/Plane.cc Thu Feb 16 17:08:22 2006
@@ -36,7 +36,7 @@
using namespace std;
//using SCIRun::Clamp;
-Plane::Plane(Material* material, const Vector& normal, const Point& center):
+Plane::Plane(Material* material, const Vector& normal, const Vector& center):
PrimitiveCommon(material), normal(normal), center(center)
{
this->normal.normalize();
Modified: trunk/Model/Primitives/Plane.h
==============================================================================
--- trunk/Model/Primitives/Plane.h (original)
+++ trunk/Model/Primitives/Plane.h Thu Feb 16 17:08:22 2006
@@ -30,12 +30,12 @@
#define Manta_Model_Plane_h
#include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class Plane : public PrimitiveCommon {
public:
- Plane(Material* material, const Vector& normal, const Point& center);
+ Plane(Material* material, const Vector& normal, const Vector& center);
virtual ~Plane();
virtual void computeBounds(const PreprocessContext& context,
@@ -44,7 +44,7 @@
virtual void computeNormal(const RenderContext& context, RayPacket&
rays) const;
private:
Vector normal;
- Point center;
+ Vector center;
};
}
Modified: trunk/Model/Primitives/Ring.cc
==============================================================================
--- trunk/Model/Primitives/Ring.cc (original)
+++ trunk/Model/Primitives/Ring.cc Thu Feb 16 17:08:22 2006
@@ -34,7 +34,7 @@
using namespace Manta;
using namespace std;
-Ring::Ring(Material* material, const Point& center, const Vector& normal,
+Ring::Ring(Material* material, const Vector& center, const Vector& normal,
Real radius, Real thickness)
: PrimitiveCommon(material), center(center), normal(normal),
radius2(radius*radius)
@@ -60,7 +60,7 @@
for(int i=rays.begin(); i<rays.end(); i++)
{
Vector dir(rays.getDirection(i));
- Point orig(rays.getOrigin(i));
+ Vector orig(rays.getOrigin(i));
Real dt = Dot(dir, normal);
// // Check for when the ray is parallel to the plane of the ring.
// if(dt < 1.e-6 && dt > -1.e-6)
@@ -72,7 +72,7 @@
// return;
// Compute the location of the hit point and then see if the point
// is inside the ring extents.
- Point hitPosition(orig+dir*t);
+ Vector hitPosition(orig+dir*t);
Real l = (hitPosition-center).length2();
if(l > radius2 && l < outer_radius2)
rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
Modified: trunk/Model/Primitives/Ring.h
==============================================================================
--- trunk/Model/Primitives/Ring.h (original)
+++ trunk/Model/Primitives/Ring.h Thu Feb 16 17:08:22 2006
@@ -30,14 +30,14 @@
#define Manta_Model_Ring_h
#include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta
{
class Ring : public PrimitiveCommon {
public:
- Ring(Material* material, const Point& center, const Vector& normal,
+ Ring(Material* material, const Vector& center, const Vector& normal,
Real radius, Real thicknes);
virtual ~Ring();
@@ -49,7 +49,7 @@
RayPacket &rays) const;
private:
- Point center;
+ Vector center;
Vector normal;
Real normal_dot_center, radius2, outer_radius2;
};
Modified: trunk/Model/Primitives/Sphere.cc
==============================================================================
--- trunk/Model/Primitives/Sphere.cc (original)
+++ trunk/Model/Primitives/Sphere.cc Thu Feb 16 17:08:22 2006
@@ -10,7 +10,7 @@
using namespace SCIRun;
using namespace std;
-Sphere::Sphere(Material* material, const Point& center, Real radius)
+Sphere::Sphere(Material* material, const Vector& center, Real radius)
: PrimitiveCommon(material, this), center(center), radius(radius)
{
inv_radius = 1/radius;
@@ -172,9 +172,9 @@
Real angle = Clamp(n.z(), (Real)-1, (Real)1);
Real theta = Acos(angle);
Real phi = Atan2(n.x(), n.y());
- Real x = (phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI);
+ Real x = (phi+(Real)M_PI)*((Real)0.5*M_1_PI);
Real y = theta*(Real)M_1_PI;
- rays.setTexCoords(i, Point(x, y, 0));
+ rays.setTexCoords(i, Vector(x, y, 0));
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
@@ -188,9 +188,9 @@
Real angle = Clamp(n.z(), (Real)-1, (Real)1);
Real theta = Acos(angle);
Real phi = Atan2(n.x(), n.y());
- rays.setTexCoords(i, Point((phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI),
- theta*(Real)M_1_PI,
- 0));
+ Real x = (phi+(Real)M_PI)*((Real)0.5*M_1_PI);
+ Real y = theta*(Real)M_1_PI;
+ rays.setTexCoords(i, Vector(x, y, 0));
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
Modified: trunk/Model/Primitives/Sphere.h
==============================================================================
--- trunk/Model/Primitives/Sphere.h (original)
+++ trunk/Model/Primitives/Sphere.h Thu Feb 16 17:08:22 2006
@@ -4,12 +4,12 @@
#include <Model/Primitives/PrimitiveCommon.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class Sphere : public PrimitiveCommon, public TexCoordMapper {
public:
- Sphere(Material* material, const Point& center, Real radius);
+ Sphere(Material* material, const Vector& center, Real radius);
virtual ~Sphere();
virtual void computeBounds(const PreprocessContext& context,
@@ -21,7 +21,7 @@
virtual void computeTexCoords3(const RenderContext& context,
RayPacket& rays) const;
private:
- Point center;
+ Vector center;
Real radius;
Real inv_radius;
};
Modified: trunk/Model/Primitives/SuperEllipsoid.cc
==============================================================================
--- trunk/Model/Primitives/SuperEllipsoid.cc (original)
+++ trunk/Model/Primitives/SuperEllipsoid.cc Thu Feb 16 17:08:22 2006
@@ -1,5 +1,3 @@
-#include <iostream>
-
#include <Model/Primitives/SuperEllipsoid.h>
#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
@@ -7,17 +5,21 @@
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
+#include <sgi_stl_warnings_off.h>
+#include <iostream>
+#include <sgi_stl_warnings_on.h>
+
using namespace std;
using namespace SCIRun;
using namespace Manta;
-static const float golden_mean = static_cast< Real >( 0.61803398874989484820
);
-static const float bracket_width = static_cast< Real >( 1.e-3 );
+static const Real golden_mean = static_cast< Real >( 0.61803398874989484820
);
+static const Real bracket_width = static_cast< Real >( 1.e-3 );
static const int max_newton_iter = 10;
SuperEllipsoid::SuperEllipsoid(
Material *material,
- Point const ¢er,
+ Vector const ¢er,
Real radius,
Real alpha,
Real beta )
@@ -76,8 +78,8 @@
PreprocessContext const &,
BBox &bbox ) const
{
- bbox.extendByPoint( Point( -1., -1., -1. ) );
- bbox.extendByPoint( Point( 1., 1., 1. ) );
+ bbox.extendByPoint( Vector( -1, -1, -1 ) );
+ bbox.extendByPoint( Vector( 1, 1, 1 ) );
}
void SuperEllipsoid::intersect(const RenderContext&, RayPacket& rays) const
@@ -244,9 +246,9 @@
Real angle = Clamp( n.z(), (Real)-1, (Real)1 );
Real theta = Acos( angle );
Real phi = Atan2( n.x(), n.y() );
- rays.setTexCoords(i, Point( ( phi + (Real)M_PI ) * (Real)( 0.5 * M_1_PI
),
- theta * (Real)M_1_PI,
- 0. ));
+ Real x = ( phi + (Real)M_PI ) * (Real)( 0.5 * M_1_PI );
+ Real y = theta * (Real)M_1_PI;
+ rays.setTexCoords(i, Vector( x, y, 0));
}
rays.setFlag( RayPacket::HaveTexture2 | RayPacket::HaveTexture3 );
}
@@ -261,9 +263,9 @@
Real angle = Clamp( n.z(), (Real)-1, (Real)1 );
Real theta = Acos( angle );
Real phi = Atan2( n.x(), n.y() );
- rays.setTexCoords(i, Point( ( phi + (Real)M_PI ) * (Real)( 0.5 * M_1_PI
),
- theta * (Real)M_1_PI,
- 0. ));
+ Real x = ( phi + (Real)M_PI ) * (Real)( 0.5 * M_1_PI );
+ Real y = theta * (Real)M_1_PI;
+ rays.setTexCoords(i, Vector( x, y, 0));
}
rays.setFlag( RayPacket::HaveTexture2 | RayPacket::HaveTexture3 );
}
Modified: trunk/Model/Primitives/SuperEllipsoid.h
==============================================================================
--- trunk/Model/Primitives/SuperEllipsoid.h (original)
+++ trunk/Model/Primitives/SuperEllipsoid.h Thu Feb 16 17:08:22 2006
@@ -4,12 +4,12 @@
#include <Model/Primitives/PrimitiveCommon.h>
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class SuperEllipsoid : public PrimitiveCommon, public TexCoordMapper {
public:
- SuperEllipsoid(Material* material, const Point& center, Real radius,
+ SuperEllipsoid(Material* material, const Vector& center, Real radius,
Real alpha, Real beta);
virtual ~SuperEllipsoid();
@@ -25,7 +25,7 @@
Real functionValue(const Vector& location) const;
inline Vector functionGradient(const Vector& location, Real& value )
const;
inline Vector logarithmFunctionGradient(const Vector& location, Real&
value ) const;
- Point center;
+ Vector center;
Real radius;
Real inv_radius;
Real two_over_alpha;
Modified: trunk/Model/Primitives/TexTriangle.cc
==============================================================================
--- trunk/Model/Primitives/TexTriangle.cc (original)
+++ trunk/Model/Primitives/TexTriangle.cc Thu Feb 16 17:08:22 2006
@@ -8,6 +8,31 @@
using namespace Manta;
using namespace std;
+TexTriangle::TexTriangle( Material *material_,
+ const Vector& p0_, const Vector& p1_, const Vector& p2_,
+ const Vector& tex0_, const Vector& tex1_, const Vector& tex2_ )
+ : HeavyTriangle( material_, p0_, p1_, p2_ )
+{
+ tex[0] = tex0_;
+ tex[1] = tex1_;
+ tex[2] = tex2_;
+
+ setTexCoordMapper( this );
+}
+
+TexTriangle::TexTriangle( Material *material_,
+ const Vector &point_, const Vector &edge0_, const Vector
&edge1_,
+ const Vector &n0_, const Vector &n1_, const Vector &n2_,
+ const Vector &tex0_, const Vector &tex1_, const Vector
&tex2_ )
+ : HeavyTriangle( material_, point_, edge0_, edge1_, n0_, n1_, n2_ )
+{
+ tex[0] = tex0_;
+ tex[1] = tex1_;
+ tex[2] = tex2_;
+
+ setTexCoordMapper( this );
+}
+
//Performs the exact same operation as computeTexCoords3
void TexTriangle::computeTexCoords2(const RenderContext& /*context*/,
RayPacket& rays) const {
@@ -19,7 +44,7 @@
TexTriangle *t = (TexTriangle *)th.ptr;
- rays.setTexCoords(i, Point((t->tex[1] * a) + (t->tex[2] * b) +(t->tex[0]
* c)));
+ rays.setTexCoords(i, (t->tex[1] * a) + (t->tex[2] * b) + (t->tex[0] *
c));
}
rays.setFlag( RayPacket::HaveTexture2|RayPacket::HaveTexture3 );
}
Modified: trunk/Model/Primitives/TexTriangle.h
==============================================================================
--- trunk/Model/Primitives/TexTriangle.h (original)
+++ trunk/Model/Primitives/TexTriangle.h Thu Feb 16 17:08:22 2006
@@ -41,31 +41,13 @@
public:
TexTriangle() { setTexCoordMapper( this ); };
TexTriangle( Material *material_,
- const Point &p0_, const Point &p1_, const Point &p2_,
- const Vector &tex0_, const Vector &tex1_, const Vector
&tex2_ ) :
-
- HeavyTriangle( material_, p0_, p1_, p2_ )
- {
- tex[0] = tex0_;
- tex[1] = tex1_;
- tex[2] = tex2_;
-
- setTexCoordMapper( this );
- }
+ const Vector& p0_, const Vector& p1_, const Vector& p2_,
+ const Vector& tex0_, const Vector& tex1_, const Vector&
tex2_ );
TexTriangle( Material *material_,
- const Point &point_, const Vector &edge0_, const Vector
&edge1_,
- const Vector &n0_, const Vector &n1_, const Vector
&n2_,
- const Vector &tex0_, const Vector &tex1_, const Vector
&tex2_ ) :
-
- HeavyTriangle( material_, point_, edge0_, edge1_, n0_, n1_, n2_ )
- {
- tex[0] = tex0_;
- tex[1] = tex1_;
- tex[2] = tex2_;
-
- setTexCoordMapper( this );
- }
+ const Vector &point_, const Vector &edge0_, const Vector
&edge1_,
+ const Vector &n0_, const Vector &n1_, const Vector
&n2_,
+ const Vector &tex0_, const Vector &tex1_, const Vector
&tex2_ );
virtual ~TexTriangle() { };
virtual void computeTexCoords2(const RenderContext& context, RayPacket&
rays) const;
Modified: trunk/Model/Primitives/Triangle.cc
==============================================================================
--- trunk/Model/Primitives/Triangle.cc (original)
+++ trunk/Model/Primitives/Triangle.cc Thu Feb 16 17:08:22 2006
@@ -10,7 +10,8 @@
using namespace Manta;
using namespace std;
-Triangle::Triangle(Material* mat, const Point& _p1, const Point& _p2, const
Point& _p3)
+Triangle::Triangle(Material* mat,
+ const Vector& _p1, const Vector& _p2, const Vector& _p3)
: PrimitiveCommon(mat)
{
p1 = _p1;
Modified: trunk/Model/Primitives/Triangle.h
==============================================================================
--- trunk/Model/Primitives/Triangle.h (original)
+++ trunk/Model/Primitives/Triangle.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_Triangle_h
#include <Model/Primitives/PrimitiveCommon.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/Ray.h>
namespace Manta
@@ -15,7 +15,8 @@
};
Triangle() { };
- Triangle(Material* mat, const Point& _p1, const Point& _p2, const Point&
_p3);
+ Triangle(Material* mat,
+ const Vector& _p1, const Vector& _p2, const Vector& _p3);
virtual ~Triangle();
virtual void computeBounds(const PreprocessContext& context,
@@ -24,7 +25,7 @@
virtual void computeNormal(const RenderContext& context, RayPacket
&rays) const;
protected:
- Point p1,p2,p3;
+ Vector p1, p2, p3;
};
}
Modified: trunk/Model/Primitives/VertexColoredTriangle.cc
==============================================================================
--- trunk/Model/Primitives/VertexColoredTriangle.cc (original)
+++ trunk/Model/Primitives/VertexColoredTriangle.cc Thu Feb 16 17:08:22
2006
@@ -1,31 +1,29 @@
#include <Model/Primitives/VertexColoredTriangle.h>
-namespace Manta {
+using namespace Manta;
- VertexColoredTriangle::VertexColoredTriangle(
- Material* mat,
- const Point& _p1,
- const Point& _p2,
- const Point& _p3,
- const Color& _color1,
- const Color& _color2,
- const Color& _color3)
- : Triangle(mat, _p1,_p2,_p3)
- {
- colors[0] = _color1;
- colors[1] = _color2;
- colors[2] = _color3;
- }
+VertexColoredTriangle::VertexColoredTriangle(Material* mat,
+ const Vector& _p1,
+ const Vector& _p2,
+ const Vector& _p3,
+ const Color& _color1,
+ const Color& _color2,
+ const Color& _color3)
+ : Triangle(mat, _p1,_p2,_p3)
+{
+ colors[0] = _color1;
+ colors[1] = _color2;
+ colors[2] = _color3;
+}
- VertexColoredTriangle::~VertexColoredTriangle()
- {
- }
+VertexColoredTriangle::~VertexColoredTriangle()
+{
+}
- Color& VertexColoredTriangle::getVertexColor(int which) {
- return colors[which];
- }
+Color& VertexColoredTriangle::getVertexColor(int which) {
+ return colors[which];
+}
- const Color& VertexColoredTriangle::getVertexColor(int which) const {
- return colors[which];
- }
+const Color& VertexColoredTriangle::getVertexColor(int which) const {
+ return colors[which];
}
Modified: trunk/Model/Primitives/VertexColoredTriangle.h
==============================================================================
--- trunk/Model/Primitives/VertexColoredTriangle.h (original)
+++ trunk/Model/Primitives/VertexColoredTriangle.h Thu Feb 16 17:08:22
2006
@@ -10,12 +10,12 @@
class VertexColoredTriangle : public Triangle {
public:
VertexColoredTriangle(Material* mat,
- const Point& _p1,
- const Point& _p2,
- const Point& _p3,
- const Color& _color1,
- const Color& _color2,
- const Color& _color3);
+ const Vector& _p1,
+ const Vector& _p2,
+ const Vector& _p3,
+ const Color& _color1,
+ const Color& _color2,
+ const Color& _color3);
virtual ~VertexColoredTriangle();
Color& getVertexColor(int which);
Modified: trunk/Model/Readers/BART/parse.cc
==============================================================================
--- trunk/Model/Readers/BART/parse.cc (original)
+++ trunk/Model/Readers/BART/parse.cc Thu Feb 16 17:08:22 2006
@@ -157,8 +157,8 @@
NOT_FINISHED("WARNING: Ignoring resolution");
/*
- Camera cam = new Camera(Point(from[X],from[Y],from[Z]),
- Point(at[X],at[Y],at[Z]),
+ Camera cam = new Camera(Vector(from[X],from[Y],from[Z]),
+ Vector(at[X],at[Y],at[Z]),
Vector(up[X],up[Y],up[Z]),
fov_angle);
*/
@@ -234,8 +234,8 @@
}
col[A]=1.0f;
- PointLight *pl = new PointLight(Point(pos[X],pos[Y],pos[Z]),
- Color(RGB(col[X],col[Y],col[Z])));
+ PointLight *pl = new PointLight(Vector(pos[X],pos[Y],pos[Z]),
+ Color(RGB(col[X],col[Y],col[Z])));
myLights->add(pl);
}
@@ -403,10 +403,9 @@
}
Cone *nextObj = new Cone(currentMaterial,
- Point(base_pt[X],base_pt[Y],base_pt[Z]),
- Point(apex_pt[X],apex_pt[Y],apex_pt[Z]),
- (double)r0,
- (double)r1);
+ Vector(base_pt[X],base_pt[Y],base_pt[Z]),
+ Vector(apex_pt[X],apex_pt[Y],apex_pt[Z]),
+ r0, r1);
myGroup->add(nextObj);
}
@@ -435,8 +434,8 @@
}
Sphere *nextObj = new Sphere(currentMaterial,
- Point(center[X],center[Y],center[Z]),
- (double)radius);
+ Vector(center[X],center[Y],center[Z]),
+ radius);
myGroup->add(nextObj);
}
@@ -1356,9 +1355,9 @@
}
/* indices appear in this order: [texture] [normals] vertices.
[]=optional */
- Point p1((double)verts[v[0]][0], (double)verts[v[0]][1],
(double)verts[v[0]][2]);
- Point p2((double)verts[v[1]][0], (double)verts[v[1]][1],
(double)verts[v[1]][2]);
- Point p3((double)verts[v[2]][0], (double)verts[v[2]][1],
(double)verts[v[2]][2]);
+ Vector p1(verts[v[0]][0], verts[v[0]][1], verts[v[0]][2]);
+ Vector p2(verts[v[1]][0], verts[v[1]][1], verts[v[1]][2]);
+ Vector p3(verts[v[2]][0], verts[v[2]][1], verts[v[2]][2]);
myGroup->add(new Triangle(currentMaterial, p1, p2, p3));
Modified: trunk/Model/Readers/ObjReader.cc
==============================================================================
--- trunk/Model/Readers/ObjReader.cc (original)
+++ trunk/Model/Readers/ObjReader.cc Thu Feb 16 17:08:22 2006
@@ -1,4 +1,4 @@
-#include <Core/Geometry/Point.h>
+#include <Core/Geometry/Vector.h>
#include <Packages/manta/Interface/Object.h>
#include <Packages/manta/Model/Groups/Group.h>
#include <Packages/manta/Model/Primitives/Triangle.h>
@@ -76,8 +76,8 @@
return &str[index];
}
-void GetFace(char *buf, vector<Point> &pts, vector<Vector> &nml,
- vector<Point> &tex, Group *g, Material *mat, Transform &t) {
+void GetFace(char *buf, vector<Vector> &pts, vector<Vector> &nml,
+ vector<Vector> &tex, Group *g, Material *mat, Transform &t) {
static vector<int> fis;
static vector<int> uvis;
static vector<int> nrmis;
@@ -124,9 +124,9 @@
int s1=k+1;
int s2=k+2;
- Point p1 = pts[fis[s0]];
- Point p2 = pts[fis[s1]];
- Point p3 = pts[fis[s2]];
+ Vector p1 = pts[fis[s0]];
+ Vector p2 = pts[fis[s1]];
+ Vector p3 = pts[fis[s2]];
// TODO uv coordinate storage.
//if (uvis.size())
@@ -362,9 +362,9 @@
matl.resize(0);
matl.push_back(m);
}
- vector<Point> pts;
+ vector<Vector> pts;
vector<Vector> nml;
- vector<Point> tex;
+ vector<Vector> tex;
Group *g1 = new Group;
int num_faces = 0;
@@ -376,7 +376,7 @@
switch(buf[1]) {
case 't': // texture coordinate...
Get2d(&buf[2],scratch);
- tex.push_back(Point(scratch[0], scratch[1], scratch[2]));
+ tex.push_back(Vector(scratch[0], scratch[1], scratch[2]));
break;
case 'n': // normal
Get3d(&buf[2],scratch);
@@ -386,7 +386,7 @@
default:
Get3d(&buf[2],scratch);
// add to points list!
- Point p(scratch[0], scratch[1], scratch[2]);
+ Vector p(scratch[0], scratch[1], scratch[2]);
// TODO acceleration structures.
//bbox.extend(p);
//tbbox.extend(t.project(p));
Modified: trunk/Model/Readers/ObjReader.h
==============================================================================
--- trunk/Model/Readers/ObjReader.h (original)
+++ trunk/Model/Readers/ObjReader.h Thu Feb 16 17:08:22 2006
@@ -2,7 +2,7 @@
#ifndef Manta_Model_ObjReader_h
#define Manta_Model_ObjReader_h
-#include <Core/Geometry/Point.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/Transform.h>
#include <Packages/manta/Model/Groups/Group.h>
#include <vector>
Modified: trunk/Model/Readers/PlyReader.cc
==============================================================================
--- trunk/Model/Readers/PlyReader.cc (original)
+++ trunk/Model/Readers/PlyReader.cc Thu Feb 16 17:08:22 2006
@@ -5,12 +5,17 @@
#include <Model/Primitives/VertexColoredTriangle.h>
#include <Model/Textures/TriVerTexture.h>
#include <Model/Materials/Lambertian.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Color/Color.h>
#include <Core/Color/RGBColor.h>
#include <SCIRun/Core/Exceptions/FileNotFound.h>
+#include <Model/Readers/rply/rply.h>
+
+#include <sgi_stl_warnings_off.h>
#include <sstream>
+#include <sgi_stl_warnings_on.h>
+
#include <stdlib.h>
-#include "rply/rply.h"
//TODO: normals?, acceleration structure.
@@ -23,8 +28,8 @@
bool coloredTriangleMode = false;
struct VertexData {
- Point point;
- RGBColor color;
+ Vector point;
+ RGBColor color;
};
std::vector<VertexData> vertices;
@@ -32,8 +37,8 @@
AffineTransform *t;
static void addVertex() {
- vertexData.point = *t * vertexData.point;
- vertices.push_back(vertexData);
+ vertexData.point = t->multiply_point(vertexData.point);
+ vertices.push_back(vertexData);
}
static int vertex_cb(p_ply_argument argument) {
Modified: trunk/Model/Readers/PlyReader.h
==============================================================================
--- trunk/Model/Readers/PlyReader.h (original)
+++ trunk/Model/Readers/PlyReader.h Thu Feb 16 17:08:22 2006
@@ -2,11 +2,12 @@
#ifndef Manta_Model_PlyReader_h
#define Manta_Model_PlyReader_h
-#include <Core/Geometry/PointVector.h>
#include <Core/Geometry/AffineTransform.h>
#include <Model/Groups/Group.h>
+#include <sgi_stl_warnings_off.h>
#include <string>
+#include <sgi_stl_warnings_on.h>
namespace Manta {
@@ -16,7 +17,7 @@
class Group;
extern "C" bool readPlyFile(const string fileName, AffineTransform &t,
- Group *g, int gridsize=0, Material *m=0);
+ Group *g, int gridsize=0, Material *m=0);
}
#endif
Modified: trunk/Model/TexCoordMappers/LinearMapper.cc
==============================================================================
--- trunk/Model/TexCoordMappers/LinearMapper.cc (original)
+++ trunk/Model/TexCoordMappers/LinearMapper.cc Thu Feb 16 17:08:22 2006
@@ -5,8 +5,8 @@
using namespace Manta;
-LinearMapper::LinearMapper(const Point& origin, const Vector& v1,
- const Vector& v2, const Vector& v3)
+LinearMapper::LinearMapper(const Vector& origin, const Vector& v1,
+ const Vector& v2, const Vector& v3)
{
transform.initWithBasis(v1, v2, v3, origin);
transform.invert();
@@ -28,7 +28,7 @@
rays.computeHitPositions();
for(int i = rays.begin();i<rays.end();i++)
// Unproject a hit point by multiplying by inverse.
- rays.setTexCoords(i, transform * rays.getHitPosition(i));
+ rays.setTexCoords(i, transform.multiply_point(rays.getHitPosition(i)));
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
@@ -38,6 +38,6 @@
rays.computeHitPositions();
for(int i = rays.begin();i<rays.end();i++)
// Unproject a hit point by multiplying by inverse.
- rays.setTexCoords(i, transform * rays.getHitPosition(i));
+ rays.setTexCoords(i, transform.multiply_point(rays.getHitPosition(i)));
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
Modified: trunk/Model/TexCoordMappers/LinearMapper.h
==============================================================================
--- trunk/Model/TexCoordMappers/LinearMapper.h (original)
+++ trunk/Model/TexCoordMappers/LinearMapper.h Thu Feb 16 17:08:22 2006
@@ -3,15 +3,15 @@
#define Manta_Model_LinearMapper_h
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/AffineTransform.h>
namespace Manta {
class LinearMapper : public TexCoordMapper {
public:
- LinearMapper(const Point& origin, const Vector& v1,
- const Vector& v2, const Vector& v3);
+ LinearMapper(const Vector& origin, const Vector& v1,
+ const Vector& v2, const Vector& v3);
LinearMapper(const AffineTransform& transform);
virtual ~LinearMapper();
Modified: trunk/Model/TexCoordMappers/SphericalMapper.cc
==============================================================================
--- trunk/Model/TexCoordMappers/SphericalMapper.cc (original)
+++ trunk/Model/TexCoordMappers/SphericalMapper.cc Thu Feb 16 17:08:22
2006
@@ -7,7 +7,7 @@
using namespace Manta;
using SCIRun::Clamp;
-SphericalMapper::SphericalMapper(const Point& center, Real radius)
+SphericalMapper::SphericalMapper(const Vector& center, Real radius)
: center(center), radius(radius)
{
inv_radius = 1/radius;
@@ -27,15 +27,15 @@
Real angle = Clamp(n.z(), (Real)-1, (Real)1);
Real theta = Acos(angle);
Real phi = Atan2(n.x(), n.y());
- rays.setTexCoords(i, Point((phi+(Real)M_PI)*(Real)(0.5*M_1_PI),
- theta*(Real)M_1_PI,
- w));
+ rays.setTexCoords(i, Vector((phi+(Real)M_PI)*(Real)(0.5*M_1_PI),
+ theta*(Real)M_1_PI,
+ w));
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
void SphericalMapper::computeTexCoords3(const RenderContext&,
- RayPacket& rays) const
+ RayPacket& rays) const
{
rays.computeHitPositions();
for(int i = rays.begin();i<rays.end();i++){
@@ -44,9 +44,9 @@
Real angle = Clamp(n.z(), (Real)-1, (Real)1);
Real theta = Acos(angle);
Real phi = Atan2(n.x(), n.y());
- rays.setTexCoords(i, Point((phi+(Real)M_PI)*(Real)(0.5*M_1_PI),
- theta*(Real)M_1_PI,
- w));
+ rays.setTexCoords(i, Vector((phi+(Real)M_PI)*(Real)(0.5*M_1_PI),
+ theta*(Real)M_1_PI,
+ w));
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
Modified: trunk/Model/TexCoordMappers/SphericalMapper.h
==============================================================================
--- trunk/Model/TexCoordMappers/SphericalMapper.h (original)
+++ trunk/Model/TexCoordMappers/SphericalMapper.h Thu Feb 16 17:08:22
2006
@@ -3,13 +3,13 @@
#define Manta_Model_SphericalMapper_h
#include <Interface/TexCoordMapper.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
namespace Manta {
class SphericalMapper : public TexCoordMapper {
public:
- SphericalMapper(const Point& center, Real radius);
+ SphericalMapper(const Vector& center, Real radius);
virtual ~SphericalMapper();
virtual void computeTexCoords2(const RenderContext& context,
@@ -20,7 +20,7 @@
SphericalMapper(const SphericalMapper&);
SphericalMapper& operator=(const SphericalMapper&);
- Point center;
+ Vector center;
Real radius;
Real inv_radius;
};
Modified: trunk/Model/Textures/CheckerTexture.h
==============================================================================
--- trunk/Model/Textures/CheckerTexture.h (original)
+++ trunk/Model/Textures/CheckerTexture.h Thu Feb 16 17:08:22 2006
@@ -3,7 +3,7 @@
#define Manta_Model_CheckerTexture_h
#include <Interface/Texture.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Interface/RayPacket.h>
namespace Manta {
Modified: trunk/Model/Textures/ImageTexture.cc
==============================================================================
--- trunk/Model/Textures/ImageTexture.cc (original)
+++ trunk/Model/Textures/ImageTexture.cc Thu Feb 16 17:08:22 2006
@@ -32,7 +32,6 @@
#include <Core/Color/Color.h>
#include <Core/Exceptions/InternalError.h>
-#include <Core/Geometry/PointVector.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
Modified: trunk/Model/Textures/ImageTexture.h
==============================================================================
--- trunk/Model/Textures/ImageTexture.h (original)
+++ trunk/Model/Textures/ImageTexture.h Thu Feb 16 17:08:22 2006
@@ -54,12 +54,11 @@
#include <Core/Exceptions/InternalError.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
#include <Interface/Texture.h>
-#include <Core/Geometry/PointVector.h>
#include <Core/Containers/Array2.h>
#include <Core/Math/MiscMath.h>
@@ -231,12 +230,12 @@
ValueType results[] ) const
{
rays.computeTextureCoordinates2( context );
- PointT<ScalarType, 2> tex_coords[RayPacket::MaxSize];
+ VectorT<ScalarType, 2> tex_coords[RayPacket::MaxSize];
// Grab the texture coordinates
for( int i = rays.begin(); i < rays.end(); ++i ) {
tex_coords[i] = rays.getTexCoords2(i);
- tex_coords[i].multiplyBy(scale);
+ tex_coords[i] *= scale;
}
int xres = texture.dim1();
Modified: trunk/Model/Textures/MarbleTexture.h
==============================================================================
--- trunk/Model/Textures/MarbleTexture.h (original)
+++ trunk/Model/Textures/MarbleTexture.h Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#include <Interface/Texture.h>
#include <Interface/RayPacket.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Math/Noise.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
@@ -80,7 +80,7 @@
{
rays.computeTextureCoordinates3( context );
for( int i = rays.begin(); i < rays.end(); i++ ) {
- Point T = rays.getTexCoords(i).multipliedBy(scale * fscale);
+ Vector T = rays.getTexCoords(i) * (scale * fscale);
ColorComponent value = (Real)0.25 *
Cos( rays.getTexCoords(i).x() * scale + tscale *
(Real)Turbulence( T, octaves, lacunarity, gain ) );
Modified: trunk/Model/Textures/OakTexture.h
==============================================================================
--- trunk/Model/Textures/OakTexture.h (original)
+++ trunk/Model/Textures/OakTexture.h Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#include <Interface/Texture.h>
#include <Interface/RayPacket.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Math/Noise.h>
#include <Core/Math/MiscMath.h>
@@ -14,20 +14,19 @@
template< typename ValueType >
class OakTexture : public Texture< ValueType > {
public:
- OakTexture(
- ValueType const &value1,
- ValueType const &value2,
- double const ringfreq,
- double const ringunevenness,
- double const grainfreq,
- double const ringnoise,
- double const ringnoisefreq,
- double const trunkwobble,
- double const trunkwobblefreq,
- double const angularwobble,
- double const angularwobblefreq,
- double const ringy,
- double const grainy );
+ OakTexture(ValueType const &value1,
+ ValueType const &value2,
+ Real const ringfreq,
+ Real const ringunevenness,
+ Real const grainfreq,
+ Real const ringnoise,
+ Real const ringnoisefreq,
+ Real const trunkwobble,
+ Real const trunkwobblefreq,
+ Real const angularwobble,
+ Real const angularwobblefreq,
+ Real const ringy,
+ Real const grainy );
virtual ~OakTexture();
virtual void mapValues(
RenderContext const &context,
@@ -41,35 +40,34 @@
ValueType value1;
ValueType value2;
- double const ringfreq;
- double const ringunevenness;
- double const grainfreq;
- double const ringnoise;
- double const ringnoisefreq;
- double const trunkwobble;
- double const trunkwobblefreq;
- double const angularwobble;
- double const angularwobblefreq;
- double const ringy;
- double const grainy;
+ Real const ringfreq;
+ Real const ringunevenness;
+ Real const grainfreq;
+ Real const ringnoise;
+ Real const ringnoisefreq;
+ Real const trunkwobble;
+ Real const trunkwobblefreq;
+ Real const angularwobble;
+ Real const angularwobblefreq;
+ Real const ringy;
+ Real const grainy;
};
template< class ValueType >
- OakTexture< ValueType >::OakTexture(
- ValueType const &value1,
- ValueType const &value2,
- double const ringfreq,
- double const ringunevenness,
- double const grainfreq,
- double const ringnoise,
- double const ringnoisefreq,
- double const trunkwobble,
- double const trunkwobblefreq,
- double const angularwobble,
- double const angularwobblefreq,
- double const ringy,
- double const grainy )
+ OakTexture< ValueType >::OakTexture(ValueType const &value1,
+ ValueType const &value2,
+ Real const ringfreq,
+ Real const ringunevenness,
+ Real const grainfreq,
+ Real const ringnoise,
+ Real const ringnoisefreq,
+ Real const trunkwobble,
+ Real const trunkwobblefreq,
+ Real const angularwobble,
+ Real const angularwobblefreq,
+ Real const ringy,
+ Real const grainy )
: value1( value1 ),
value2( value2 ),
ringfreq( ringfreq ),
@@ -100,34 +98,39 @@
using SCIRun::SmoothStep;
rays.computeTextureCoordinates3( context );
for( int i = rays.begin(); i < rays.end(); i++ ) {
- Point tc = rays.getTexCoords(i);
- Vector offset = VectorFBM( tc.multipliedBy(ringnoisefreq), 2, 4.0, 0.5
);
- Point Pring = tc + ringnoise * offset;
- Vector vsnoise = VectorNoise( Point( 0.5, 0.5, tc.z() *
trunkwobblefreq ) );
- Pring += Vector( trunkwobble * vsnoise.x(), trunkwobble * vsnoise.y(),
0.0 );
- double r = SCIRun::Sqrt( Pring.x() * Pring.x() + Pring.y() * Pring.y()
) * ringfreq;
- r += angularwobble * SmoothStep( r, 0, 5 ) * ScalarNoise( Point(
angularwobble * Pring.x(),
-
angularwobble * Pring.y(),
-
angularwobble * Pring.z() * 0.1 ) );
- r += 0.5 * ScalarNoise( Point( 0.5, 0.5, r ) );
- double rfrac = r - floor( r );
- double inring = SmoothStep( rfrac, 0.1, 0.55 ) - SmoothStep( rfrac,
0.7, 0.95 );
- Point Pgrain( tc.multipliedBy(Vector(grainfreq, grainfreq,
grainfreq*0.05)));
- double grain = 0.0;
- double amp = 1.0;
+ Vector tc = rays.getTexCoords(i);
+ Vector offset = VectorFBM( tc * ringnoisefreq, 2, 4, (Real)0.5 );
+ Vector Pring = tc + ringnoise * offset;
+ Vector vsnoise = VectorNoise( Vector( (Real)0.5,
+ (Real)0.5,
+ tc.z()*trunkwobblefreq) );
+ Pring += Vector( trunkwobble * vsnoise.x(),
+ trunkwobble * vsnoise.y(),
+ 0 );
+ Real r = SCIRun::Sqrt( Pring.x() * Pring.x() + Pring.y() * Pring.y() )
* ringfreq;
+ r += angularwobble * SmoothStep( r, 0, 5 ) * ScalarNoise( Vector(
angularwobble * Pring.x(),
+
angularwobble * Pring.y(),
+
angularwobble * Pring.z() * 0.1 ) );
+ r += (Real)0.5 * ScalarNoise( Vector( (Real)0.5, (Real)0.5, r ) );
+ Real rfrac = r - SCIRun::Floor( r );
+ Real inring = (SmoothStep( rfrac, (Real)0.1, (Real)0.55 ) -
+ SmoothStep( rfrac, (Real)0.7, (Real)0.95 ));
+ Vector Pgrain( tc * Vector(grainfreq, grainfreq,
grainfreq*(Real)0.05));
+ Real grain = 0;
+ Real amp = 1;
for ( int it = 0; it < 2; ++it )
{
- double g = 0.8 * ScalarNoise( Pgrain );
- g *= ( 0.3 + 0.7 * inring );
- g = SCIRun::Clamp( 0.8 - g, 0.0, 1.0 );
- g = grainy * SmoothStep( g * g, 0.5, 1.0 );
+ Real g = (Real)0.8 * ScalarNoise( Pgrain );
+ g *= ( (Real)0.3 + (Real)0.7 * inring );
+ g = SCIRun::Clamp( (Real)0.8 - g, (Real)0, (Real)1 );
+ g = grainy * SmoothStep( g * g, (Real)0.5, 1 );
if ( it == 0 )
- inring *= 0.7;
+ inring *= (Real)0.7;
grain = SCIRun::Max( grain, g );
- Pgrain.multiplyBy(2.0);
- amp *= 0.5;
+ Pgrain *= 2;
+ amp *= (Real)0.5;
}
- double value = SCIRun::Interpolate( 1.0, grain, inring * ringy );
+ Real value = SCIRun::Interpolate( (Real)1, grain, inring * ringy );
results[ i ] = SCIRun::Interpolate( value2, value1, value );
}
}
Modified: trunk/Model/Textures/TexCoordTexture.cc
==============================================================================
--- trunk/Model/Textures/TexCoordTexture.cc (original)
+++ trunk/Model/Textures/TexCoordTexture.cc Thu Feb 16 17:08:22 2006
@@ -32,7 +32,7 @@
#include <Interface/Image.h>
#include <Core/Exceptions/InternalError.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
@@ -47,7 +47,7 @@
rays.computeTextureCoordinates3( context );
for( int i = rays.begin(); i < rays.end(); ++i ) {
- Point texCoords = rays.getTexCoords(i);
+ Vector texCoords = rays.getTexCoords(i);
// Convert the coordinates to a color.
results[i] = Color( RGB( (ColorComponent)texCoords[0],
(ColorComponent)texCoords[1],
Modified: trunk/Model/Textures/TexCoordTexture.h
==============================================================================
--- trunk/Model/Textures/TexCoordTexture.h (original)
+++ trunk/Model/Textures/TexCoordTexture.h Thu Feb 16 17:08:22 2006
@@ -36,7 +36,6 @@
#include <Interface/Texture.h>
-#include <Core/Geometry/PointVector.h>
#include <Core/Containers/Array2.h>
#include <Core/Math/MiscMath.h>
Modified: trunk/Model/Textures/TriVerTexture.cc
==============================================================================
--- trunk/Model/Textures/TriVerTexture.cc (original)
+++ trunk/Model/Textures/TriVerTexture.cc Thu Feb 16 17:08:22 2006
@@ -18,7 +18,7 @@
rays.computeTextureCoordinates3( context );
for( int i = rays.begin(); i < rays.end(); i++ ) {
- Point T = rays.getTexCoords(i);
+ Vector T = rays.getTexCoords(i);
Triangle::TriangleHit& th = rays.scratchpad<Triangle::TriangleHit>(i);
const VertexColoredTriangle* vct =
static_cast<const VertexColoredTriangle*>(rays.getHitPrimitive(i));
Modified: trunk/Model/Textures/WoodTexture.h
==============================================================================
--- trunk/Model/Textures/WoodTexture.h (original)
+++ trunk/Model/Textures/WoodTexture.h Thu Feb 16 17:08:22 2006
@@ -4,9 +4,10 @@
#include <Interface/Texture.h>
#include <Interface/RayPacket.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Math/Noise.h>
#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
namespace Manta {
@@ -15,49 +16,44 @@
template< typename ValueType >
class WoodTexture : public Texture< ValueType > {
public:
- WoodTexture(
- ValueType const &value1,
- ValueType const &value2,
- double const scale,
- double const rscale,
- double const tscale,
- double const sharpness,
- int const octaves,
- double const lacunarity,
- double const gain );
+ WoodTexture(ValueType const &value1,
+ ValueType const &value2,
+ Real const scale,
+ Real const rscale,
+ Real const tscale,
+ Real const sharpness,
+ int const octaves,
+ Real const lacunarity,
+ Real const gain );
virtual ~WoodTexture();
- virtual void mapValues(
- RenderContext const &context,
- RayPacket &rays,
- ValueType results[] ) const;
+ virtual void mapValues(RenderContext const &context,
+ RayPacket &rays,
+ ValueType results[] ) const;
private:
- WoodTexture(
- WoodTexture const & );
- WoodTexture& operator=(
- WoodTexture const & );
+ WoodTexture( WoodTexture const & );
+ WoodTexture& operator=( WoodTexture const & );
ValueType value1;
ValueType value2;
- double scale;
- double rscale;
- double tscale;
- double sharpness;
+ Real scale;
+ Real rscale;
+ Real tscale;
+ Real sharpness;
int octaves;
- double lacunarity;
- double gain;
+ Real lacunarity;
+ Real gain;
};
template< class ValueType >
- WoodTexture< ValueType >::WoodTexture(
- ValueType const &value1,
- ValueType const &value2,
- double const scale,
- double const rscale,
- double const tscale,
- double const sharpness,
- int const octaves,
- double const lacunarity,
- double const gain )
+ WoodTexture< ValueType >::WoodTexture(ValueType const &value1,
+ ValueType const &value2,
+ Real const scale,
+ Real const rscale,
+ Real const tscale,
+ Real const sharpness,
+ int const octaves,
+ Real const lacunarity,
+ Real const gain )
: value1( value1 ),
value2( value2 ),
scale ( scale ),
@@ -83,11 +79,12 @@
{
rays.computeTextureCoordinates3( context );
for( int i = rays.begin(); i < rays.end(); i++ ) {
- Point T = rays.getTexCoords(i).multipliedBy(scale);
- double distance = sqrt( T.x() * T.x() + T.y() * T.y() ) * rscale;
- double fbm = tscale * ScalarFBM( T, octaves, lacunarity, gain );
- double value = 0.5 * cos( distance + fbm ) + 0.5;
- results[ i ] = SCIRun::Interpolate( value2, value1, pow( value,
sharpness ) );
+ Vector T = rays.getTexCoords(i) * scale;
+ Real distance = SCIRun::Sqrt( T.x() * T.x() + T.y() * T.y() ) * rscale;
+ Real fbm = tscale * ScalarFBM( T, octaves, lacunarity, gain );
+ Real value = (Real)0.5 * Cos( distance + fbm ) + (Real)0.5;
+ results[ i ] = SCIRun::Interpolate( value2, value1,
+ SCIRun::Pow( value, sharpness ) );
}
}
Modified: trunk/StandAlone/frust-test.cc
==============================================================================
--- trunk/StandAlone/frust-test.cc (original)
+++ trunk/StandAlone/frust-test.cc Thu Feb 16 17:08:22 2006
@@ -41,7 +41,7 @@
}
// Here's the bounding box for the node
- Point bbox_min(-10,-5,-4), bbox_max(-2,7,12);
+ Vector bbox_min(-10,-5,-4), bbox_max(-2,7,12);
BBox bbox(bbox_min, bbox_max);
// OK, create my first KDTreeNode
KDTreeNode node;
@@ -57,8 +57,8 @@
NULL, NULL,
NULL,NULL,NULL );
// Ah, the ray packet
- Point ray_origin(20, 0, 20);
- Point Pn(19,1,2), Pf(2,1,2);
+ Vector ray_origin(20, 0, 20);
+ Vector Pn(19,1,2), Pf(2,1,2);
cout << "Pn-ray_origin = "<<Pn-ray_origin<<"\n";
cout << "Pf-ray_origin = "<<Pf-ray_origin<<"\n";
Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc (original)
+++ trunk/StandAlone/manta.cc Thu Feb 16 17:08:22 2006
@@ -507,19 +507,19 @@
Group* world = new Group();
- Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
+ Primitive* floor = new Parallelogram(plane_matl, Vector(-20,-20,0),
Vector(40,0,0), Vector(0,40,0));
// Setup world-space texture coordinates for the checkerboard floor
UniformMapper* uniformmap = new UniformMapper();
floor->setTexCoordMapper(uniformmap);
world->add(floor);
- world->add(new Sphere(red, Point(0,0,1.2), 1.0));
+ world->add(new Sphere(red, Vector(0,0,1.2), 1.0));
scene->setObject(world);
LightSet* lights = new LightSet();
- lights->add(new PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1))));
- lights->add(new PointLight(Point(5,0,8), Color(RGBColor(.1,.6,.1))));
- lights->add(new PointLight(Point(5,5,2), Color(RGBColor(.2,.2,.2))));
+ lights->add(new PointLight(Vector(0,5,8), Color(RGBColor(.6,.1,.1))));
+ lights->add(new PointLight(Vector(5,0,8), Color(RGBColor(.1,.6,.1))));
+ lights->add(new PointLight(Vector(5,5,2), Color(RGBColor(.2,.2,.2))));
lights->setAmbientLight(new ConstantAmbient(Color::black()));
scene->setLights(lights);
scene->getRenderParameters().maxDepth = 5;
Modified: trunk/StandAlone/v3c1_tools.cc
==============================================================================
--- trunk/StandAlone/v3c1_tools.cc (original)
+++ trunk/StandAlone/v3c1_tools.cc Thu Feb 16 17:08:22 2006
@@ -11,7 +11,7 @@
#include <MantaTypes.h>
#include <Core/Color/ColorDB.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/BBox.h>
#include <Model/Readers/glm/glm.h>
@@ -40,7 +40,7 @@
// v3c1 format.
void v3c1_info( const char *file_name );
-void v3c1_clip( const char *file_name, const Point &plane_point, const
Vector &plane_normal );
+void v3c1_clip( const char *file_name, const Vector &plane_point, const
Vector &plane_normal );
void v3c1_scale( const char *file_name );
FILE *out_file = 0;
@@ -174,7 +174,7 @@
int file_list_end = 0;
// Cutting plane.
- Point plane_point;
+ Vector plane_point;
Vector plane_normal;
CommandType command = NONE;
@@ -540,9 +540,9 @@
}
// Compute the bounds of the face.
- bounds.extendByPoint( Point( out_buffer[i].vertex0[0],
out_buffer[i].vertex0[1], out_buffer[i].vertex0[2] ) );
- bounds.extendByPoint( Point( out_buffer[i].vertex1[0],
out_buffer[i].vertex1[1], out_buffer[i].vertex1[2] ) );
- bounds.extendByPoint( Point( out_buffer[i].vertex2[0],
out_buffer[i].vertex2[1], out_buffer[i].vertex2[2] ) );
+ bounds.extendByPoint( Vector( out_buffer[i].vertex0[0],
out_buffer[i].vertex0[1], out_buffer[i].vertex0[2] ) );
+ bounds.extendByPoint( Vector( out_buffer[i].vertex1[0],
out_buffer[i].vertex1[1], out_buffer[i].vertex1[2] ) );
+ bounds.extendByPoint( Vector( out_buffer[i].vertex2[0],
out_buffer[i].vertex2[1], out_buffer[i].vertex2[2] ) );
}
// Write to the output file.
@@ -656,9 +656,9 @@
out_face.vertex(v)[2] =
model->vertices[(3*vertex_index)+2] * input_scale[2];
// Bound the vertex.
- bounds.extendByPoint( Point( out_face.vertex(v)[0],
- out_face.vertex(v)[1],
- out_face.vertex(v)[2] ) );
+ bounds.extendByPoint( Vector( out_face.vertex(v)[0],
+ out_face.vertex(v)[1],
+ out_face.vertex(v)[2] ) );
///////////////////////////////////////////////////////////////////////
// Do we need to copy out normals?
@@ -815,7 +815,7 @@
vertex_list[index-1].v[1] = v[1] * input_scale[1];
vertex_list[index-1].v[2] = v[2] * input_scale[2];
- bounds.extendByPoint( Point( v[0], v[1], v[2] ) );
+ bounds.extendByPoint( Vector( v[0], v[1], v[2] ) );
}
else if (strstr(line,"Face")) {
@@ -891,9 +891,9 @@
file_color_map[ out_buffer[i].color ]++;
// Compute the bounds of the face.
- file_bounds.extendByPoint( Point( out_buffer[i].vertex0[0],
out_buffer[i].vertex0[1], out_buffer[i].vertex0[2] ) );
- file_bounds.extendByPoint( Point( out_buffer[i].vertex1[0],
out_buffer[i].vertex1[1], out_buffer[i].vertex1[2] ) );
- file_bounds.extendByPoint( Point( out_buffer[i].vertex2[0],
out_buffer[i].vertex2[1], out_buffer[i].vertex2[2] ) );
+ file_bounds.extendByPoint( Vector( out_buffer[i].vertex0[0],
out_buffer[i].vertex0[1], out_buffer[i].vertex0[2] ) );
+ file_bounds.extendByPoint( Vector( out_buffer[i].vertex1[0],
out_buffer[i].vertex1[1], out_buffer[i].vertex1[2] ) );
+ file_bounds.extendByPoint( Vector( out_buffer[i].vertex2[0],
out_buffer[i].vertex2[1], out_buffer[i].vertex2[2] ) );
}
// Output the bounds.
@@ -916,7 +916,7 @@
total_faces += file_faces;
};
-void v3c1_clip( const char *file_name, const Point &plane_point, const
Vector &plane_normal ) {
+void v3c1_clip( const char *file_name, const Vector &plane_point, const
Vector &plane_normal ) {
// Open the data file.
FILE *in_file = fopen( file_name, "r" );
@@ -1061,9 +1061,9 @@
for (int f=0;f<3;++f) {
// Check to see if this vertex is on the back side of the plane.
- Point vertex( out_buffer[i].vertex(f)[0],
- out_buffer[i].vertex(f)[1],
- out_buffer[i].vertex(f)[2] );
+ Vector vertex( out_buffer[i].vertex(f)[0],
+ out_buffer[i].vertex(f)[1],
+ out_buffer[i].vertex(f)[2] );
// Determine if the triangle should be added.
not_clipped = not_clipped && (Dot((vertex-plane_point),plane_normal) <
0.0);
@@ -1076,12 +1076,12 @@
// Compare the face to the cutting plane.
for (int f=0;f<3;++f) {
- // Check to see if this vertex is on the back side of the plane.
- Point vertex( out_buffer[i].vertex(f)[0],
- out_buffer[i].vertex(f)[1],
- out_buffer[i].vertex(f)[2] );
-
- bounds.extendByPoint( vertex );
+ // Check to see if this vertex is on the back side of the plane.
+ Vector vertex( out_buffer[i].vertex(f)[0],
+ out_buffer[i].vertex(f)[1],
+ out_buffer[i].vertex(f)[2] );
+
+ bounds.extendByPoint( vertex );
}
// Output the face.
@@ -1202,9 +1202,9 @@
for (int f=0;f<3;++f) {
// Check to see if this vertex is on the back side of the plane.
- Point vertex( out_buffer[i].vertex(f)[0] *= input_scale[0],
- out_buffer[i].vertex(f)[1] *= input_scale[1],
- out_buffer[i].vertex(f)[2] *= input_scale[2] );
+ Vector vertex( out_buffer[i].vertex(f)[0] *= input_scale[0],
+ out_buffer[i].vertex(f)[1] *= input_scale[1],
+ out_buffer[i].vertex(f)[2] *= input_scale[2] );
bounds.extendByPoint( vertex );
}
Modified: trunk/SwigInterface/manta.cc
==============================================================================
--- trunk/SwigInterface/manta.cc (original)
+++ trunk/SwigInterface/manta.cc Thu Feb 16 17:08:22 2006
@@ -41,19 +41,19 @@
Vector(0,1,0)));
Group* world = new Group();
- Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
- Vector(40,0,0), Vector(0,40,0));
+ Primitive* floor = new Parallelogram(plane_matl, Vector(-20,-20,0),
+ Vector(40,0,0), Vector(0,40,0));
// Setup world-space texture coordinates for the checkerboard floor
UniformMapper* uniformmap = new UniformMapper();
floor->setTexCoordMapper(uniformmap);
world->add(floor);
- world->add(new Sphere(red, Point(0,0,1.2), 1.0));
+ world->add(new Sphere(red, Vector(0,0,1.2), 1.0));
scene->setObject(world);
LightSet* lights = new LightSet();
- lights->add(new PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1))));
- lights->add(new PointLight(Point(5,0,8), Color(RGBColor(.1,.6,.1))));
- lights->add(new PointLight(Point(5,5,2), Color(RGBColor(.2,.2,.2))));
+ lights->add(new PointLight(Vector(0,5,8), Color(RGBColor(.6,.1,.1))));
+ lights->add(new PointLight(Vector(5,0,8), Color(RGBColor(.1,.6,.1))));
+ lights->add(new PointLight(Vector(5,5,2), Color(RGBColor(.2,.2,.2))));
lights->setAmbientLight(new ConstantAmbient(Color::black()));
scene->setLights(lights);
scene->getRenderParameters().maxDepth = 5;
Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Thu Feb 16 17:08:22 2006
@@ -6,15 +6,16 @@
%{
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
+#include <Core/Geometry/VectorT.h>
%}
%include <MantaTypes.h>
-%include <Core/Geometry/PointVector.h>
+%include <Core/Geometry/Vector.h>
+%include <Core/Geometry/VectorT.h>
namespace Manta {
- %template(Point) PointT<Manta::Real, 3>;
- %template(Vector) VectorT<Manta::Real, 3>;
+ %template(VectorT_Real3) VectorT<Manta::Real, 3>;
}
%{
Modified: trunk/UserInterface/CameraPathAutomator.cc
==============================================================================
--- trunk/UserInterface/CameraPathAutomator.cc (original)
+++ trunk/UserInterface/CameraPathAutomator.cc Thu Feb 16 17:08:22 2006
@@ -52,8 +52,10 @@
// SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP
SETU
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-CameraPathAutomator::CameraPathAutomator( MantaInterface *manta_interface_,
int channel_, int warmup_frames,
- Point *eye_, Point *lookat_,
Vector *up_, int total_points_,
+CameraPathAutomator::CameraPathAutomator( MantaInterface *manta_interface_,
+ int channel_, int warmup_frames,
+ Vector *eye_, Vector *lookat_,
+ Vector *up_, int total_points_,
Real delta_t_, Real delta_time_ )
:
AutomatorUI( manta_interface_, warmup_frames ),
@@ -375,8 +377,7 @@
getMantaInterface()->addTransaction
("CameraPathAutomator",
Callback::create(this, &CameraPathAutomator::mantaSetCamera,
- Point(current_eye), Point(current_lookat),
- current_up ) );
+ current_eye, current_lookat, current_up ) );
// Check to see if this is a synchronization point.
@@ -423,8 +424,8 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-void CameraPathAutomator::mantaSetCamera( const Point eye_,
- const Point lookat_,
+void CameraPathAutomator::mantaSetCamera( const Vector eye_,
+ const Vector lookat_,
const Vector up_ ) {
// Reset the current camera.
Modified: trunk/UserInterface/CameraPathAutomator.h
==============================================================================
--- trunk/UserInterface/CameraPathAutomator.h (original)
+++ trunk/UserInterface/CameraPathAutomator.h Thu Feb 16 17:08:22 2006
@@ -32,7 +32,7 @@
#include <UserInterface/AutomatorUI.h>
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <SCIRun/Core/Thread/Barrier.h>
@@ -50,10 +50,6 @@
///////////////////////////////////////////////////////////////////////////
// Control points.
- //
- // These are all vectors, because we have to do operators with
- // them that don't exist for Points. Points passed in are
- // converted to Vectors, so the API remains the same.
Vector *eye;
Vector *lookat;
Vector *up;
@@ -103,7 +99,7 @@
Real delta_t_ = 0.2, Real delta_time_ = 0.2 );
CameraPathAutomator( MantaInterface *manta_interface_, int channel_,
- int warmup_, Point *eye_, Point *lookat_,
+ int warmup_, Vector *eye_, Vector *lookat_,
Vector *up_, int total_points_,
Real delta_t_ = 0.2, Real delta_time_ = 0.2 );
~CameraPathAutomator();
@@ -117,7 +113,7 @@
// This method is called by the manta rendering thread to update
// the camera.
- void mantaSetCamera( const Point eye_, const Point lookat_,
+ void mantaSetCamera( const Vector eye_, const Vector lookat_,
const Vector up_ );
// This method is called by the manta rendering thread to synchronize.
Modified: trunk/UserInterface/XWindowUI.cc
==============================================================================
--- trunk/UserInterface/XWindowUI.cc (original)
+++ trunk/UserInterface/XWindowUI.cc Thu Feb 16 17:08:22 2006
@@ -52,7 +52,7 @@
}
static void connection_watch(Display*, XPointer data, int fd,
- Bool opening, XPointer*)
+ Bool opening, XPointer*)
{
XWindowUI* ui = reinterpret_cast<XWindowUI*>(data);
if(opening)
Modified: trunk/UserInterface/XWindowUI.h
==============================================================================
--- trunk/UserInterface/XWindowUI.h (original)
+++ trunk/UserInterface/XWindowUI.h Thu Feb 16 17:08:22 2006
@@ -5,7 +5,7 @@
#include <Interface/UserInterface.h>
#include <Interface/Callback.h>
#include <Interface/SetupCallback.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Thread/Runnable.h>
#include <Core/Thread/Mutex.h>
#include <Core/Thread/Semaphore.h>
Modified: trunk/fox/FManta/FMantaImageFrame.cc
==============================================================================
--- trunk/fox/FManta/FMantaImageFrame.cc (original)
+++ trunk/fox/FManta/FMantaImageFrame.cc Thu Feb 16 17:08:22 2006
@@ -118,7 +118,11 @@
return navigator->onKeyPress( sender, sel, data );
}
-bool FMantaImageFrame::shootOneRay( int pixel_x, int pixel_y, Point
&result_position, Vector &result_normal, bool debug_packet ) {
+bool FMantaImageFrame::shootOneRay( int pixel_x, int pixel_y,
+ Vector& result_position,
+ Vector& result_normal,
+ bool debug_packet )
+{
// Make sure we have an instance of RTRT.
RTRT *rtrt = dynamic_cast< RTRT * >( manta_interface );
Modified: trunk/fox/FManta/FMantaImageFrame.h
==============================================================================
--- trunk/fox/FManta/FMantaImageFrame.h (original)
+++ trunk/fox/FManta/FMantaImageFrame.h Thu Feb 16 17:08:22 2006
@@ -63,7 +63,9 @@
int getMantaChannel () { return manta_channel;
};
// Debugging.
- bool shootOneRay( int pixel_x, int pixel_y, Point
&result_position, Vector &result_normal, bool debug_packet );
+ bool shootOneRay( int pixel_x, int pixel_y,
+ Vector& result_position, Vector& result_normal,
+ bool debug_packet );
};
};
Modified: trunk/fox/FManta/FMantaKdExplorer.cc
==============================================================================
--- trunk/fox/FManta/FMantaKdExplorer.cc (original)
+++ trunk/fox/FManta/FMantaKdExplorer.cc Thu Feb 16 17:08:22 2006
@@ -223,7 +223,7 @@
// Update bbox and plane.
BBox bbox = bbox_stack.back();
- Point max = bbox[1];
+ Vector max = bbox[1];
max[root->axis()] = root->split();
BBox new_bbox( bbox[0], max );
@@ -256,7 +256,7 @@
// Update bbox and plane.
BBox bbox = bbox_stack.back();
- Point min = bbox[0];
+ Vector min = bbox[0];
min[root->axis()] = root->split();
BBox new_bbox( min, bbox[1] );
@@ -287,10 +287,10 @@
// Create a parallelogram and add it to the plane group.
KDTreeNode *node = kdtree->getRootNode();
- Point anchor = bbox[0];
+ Vector anchor = bbox[0];
anchor[node->axis()] = node->split();
- Point amax = bbox[1];
+ Vector amax = bbox[1];
amax[node->axis()] = node->split();
Vector diag = amax - anchor;
@@ -305,7 +305,7 @@
v2[v2i] = 0;
Object *parallelogram = new Parallelogram( material[node->axis()],
- anchor, v1, v2 );
+ anchor, v1, v2 );
Object *bounds = new Cube( material[3], bbox[0], bbox[1] );
Modified: trunk/fox/FManta/FMantaNavigator.h
==============================================================================
--- trunk/fox/FManta/FMantaNavigator.h (original)
+++ trunk/fox/FManta/FMantaNavigator.h Thu Feb 16 17:08:22 2006
@@ -46,8 +46,10 @@
virtual long onMouseChange ( FXObject *sender, FXSelector
sel, void *data ) = 0;
virtual void setControlSpeed( Real new_speed ) = 0;
- virtual void resetToCamera( const Point &eye, const Point
&lookat, const Vector &up ) { };
- virtual void getCamera ( Point &eye, Point &lookat, Vector &up )
const { };
+ virtual void resetToCamera( const Vector& eye, const Vector&
lookat,
+ const Vector& up ) { };
+ virtual void getCamera ( Vector& eye, Vector& lookat,
+ Vector& up ) const { };
};
};
Modified: trunk/fox/FManta/FMantaQuakeNav.cc
==============================================================================
--- trunk/fox/FManta/FMantaQuakeNav.cc (original)
+++ trunk/fox/FManta/FMantaQuakeNav.cc Thu Feb 16 17:08:22 2006
@@ -4,7 +4,7 @@
#include <MantaTypes.h>
#include <Interface/Camera.h>
#include <Interface/Callback.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/AffineTransform.h>
using namespace fox_manta;
@@ -129,7 +129,8 @@
return 1;
}
-void FMantaQuakeNav::resetToCamera( const Point &eye, const Point &lookat,
const Vector &up )
+void FMantaQuakeNav::resetToCamera( const Vector& eye, const Vector& lookat,
+ const Vector& up )
{
// Extract the camera position.
@@ -153,7 +154,9 @@
}
-void FMantaQuakeNav::getCamera ( Point &eye, Point &lookat, Vector &up )
const {
+void FMantaQuakeNav::getCamera( Vector& eye, Vector& lookat,
+ Vector& up ) const
+{
// Transform a default eye, up, and lookat.
double Azi=viewDirAngle*TORADS , Elev=viewElevAngle*TORADS;
@@ -161,19 +164,9 @@
dY=(float)(sin(Azi)*cos(Elev)),
dZ=(float)sin(Elev);
- eye = Point(
- (forward_dir*posX) +
- (right_dir*posY) +
- (up_dir*height));
-
- lookat = eye +
- (forward_dir*dX) +
- (right_dir*dY) +
- (up_dir*dZ);
-
- up = up_dir;
-
-
+ eye = (forward_dir*posX) + (right_dir*posY) + (up_dir*height);
+ lookat = eye + (forward_dir*dX) + (right_dir*dY) + (up_dir*dZ);
+ up = up_dir;
}
void FMantaQuakeNav::setCoordSystemUp( int up ) {
@@ -202,8 +195,7 @@
// Get a pointer to the camera.
Camera *manta_camera = manta_interface->getCamera( manta_channel );
- Point eye_, lookat_;
- Vector up_;
+ Vector eye_, lookat_, up_;
getCamera( eye_, lookat_, up_ );
Modified: trunk/fox/FManta/FMantaQuakeNav.h
==============================================================================
--- trunk/fox/FManta/FMantaQuakeNav.h (original)
+++ trunk/fox/FManta/FMantaQuakeNav.h Thu Feb 16 17:08:22 2006
@@ -139,8 +139,9 @@
long onMouseChange( FXObject *sender, FXSelector sel, void
*data );
void setControlSpeed( Real new_speed ) { translateStepSize =
new_speed; };
- void resetToCamera( const Point &eye, const Point &lookat, const Vector
&up );
- void getCamera ( Point &eye, Point &lookat, Vector &up ) const ;
+ void resetToCamera( const Vector& eye, const Vector& lookat,
+ const Vector& up );
+ void getCamera ( Vector& eye, Vector& lookat, Vector& up ) const ;
// Transaction callback for manta thread.
Modified: trunk/fox/FManta/FMantaRecorder.cc
==============================================================================
--- trunk/fox/FManta/FMantaRecorder.cc (original)
+++ trunk/fox/FManta/FMantaRecorder.cc Thu Feb 16 17:08:22 2006
@@ -298,8 +298,8 @@
record_time_interval = record_interval->getValue();
record_iter = 0;
- record_eye = new Point [total_record_points];
- record_lookat = new Point [total_record_points];
+ record_eye = new Vector[total_record_points];
+ record_lookat = new Vector[total_record_points];
record_up = new Vector[total_record_points];
stop_button->enable();
Modified: trunk/fox/FManta/FMantaRecorder.h
==============================================================================
--- trunk/fox/FManta/FMantaRecorder.h (original)
+++ trunk/fox/FManta/FMantaRecorder.h Thu Feb 16 17:08:22 2006
@@ -68,8 +68,8 @@
Real record_time_interval;
// Storage during recording.
- Point *record_eye;
- Point *record_lookat;
+ Vector *record_eye;
+ Vector *record_lookat;
Vector *record_up;
// Elasp time for recording.
Modified: trunk/fox/FManta/FMantaTrackballNav.cc
==============================================================================
--- trunk/fox/FManta/FMantaTrackballNav.cc (original)
+++ trunk/fox/FManta/FMantaTrackballNav.cc Thu Feb 16 17:08:22 2006
@@ -64,7 +64,7 @@
// Two clicks of the right button changes the lookat point.
if ((event->state & SHIFTMASK) == SHIFTMASK) {
// New center of rotation.
- Point lookat;
+ Vector lookat;
Vector normal;
// std::cerr << "Setting center of rotation. " << event->win_x << " "
<< event->win_y << std::endl;
@@ -143,7 +143,7 @@
}
// These functions are called by the manta thread.
-void FMantaTrackballNav::mantaLookat( Point lookat ) {
+void FMantaTrackballNav::mantaLookat( Vector lookat ) {
Camera *camera = manta_interface->getCamera( manta_channel );
Modified: trunk/fox/FManta/FMantaTrackballNav.h
==============================================================================
--- trunk/fox/FManta/FMantaTrackballNav.h (original)
+++ trunk/fox/FManta/FMantaTrackballNav.h Thu Feb 16 17:08:22 2006
@@ -2,7 +2,7 @@
#define fox_FMantaTrackballNav__H
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/AffineTransform.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
@@ -50,11 +50,12 @@
void setMantaFrame( FMantaImageFrame *frame ) {
manta_frame = frame; };
void setTrackballRadius( Real trackball_radius_ ) {
trackball_radius = trackball_radius_; };
void setControlSpeed( Real new_speed ) {
control_speed = new_speed; };
- void resetToCamera( const Point &eye, const Point &lookat,
const Vector &up ) {
- /* Trackball nav contains no camera state. */ };
+ void resetToCamera( const Vector& eye, const Vector& lookat,
+ const Vector& up )
+ { /* Trackball nav contains no camera state. */ };
// Methods called by the manta thread.
- void mantaLookat( Point lookat );
+ void mantaLookat( Vector lookat );
void mantaTrackball( AffineTransform rotation );
void mantaDolly( Real distance );
void mantaPan( Vector pan );
Modified: trunk/fox/FManta/FMantaUniformNav.h
==============================================================================
--- trunk/fox/FManta/FMantaUniformNav.h (original)
+++ trunk/fox/FManta/FMantaUniformNav.h Thu Feb 16 17:08:22 2006
@@ -2,7 +2,7 @@
#define fox_FMantaUniformNav__H
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/AffineTransform.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
@@ -76,8 +76,9 @@
void setTrackballRadius( Real trackball_radius_ ) {
trackball_radius = trackball_radius_; };
void setControlSpeed( Real new_speed ) { amount =
new_speed; };
- void resetToCamera( const Point &eye, const Point &lookat,
const Vector &up ) {
- /* Uniform nav contains no camera state. */ };
+ void resetToCamera( const Vector& eye, const Vector& lookat,
+ const Vector& up )
+ { /* Uniform nav contains no camera state. */ };
};
};
Modified: trunk/fox/FManta/FMantaWindow.cc
==============================================================================
--- trunk/fox/FManta/FMantaWindow.cc (original)
+++ trunk/fox/FManta/FMantaWindow.cc Thu Feb 16 17:08:22 2006
@@ -559,7 +559,7 @@
std::cerr << "Image location: " << event->win_x << " " << event->win_y
<< std::endl;
- Point point;
+ Vector point;
Vector normal;
// Save the location.
@@ -588,7 +588,7 @@
// Input the image coords.
str >> debug_ray_x >> debug_ray_y;
- Point point;
+ Vector point;
Vector normal;
// Send the debug ray.
@@ -613,7 +613,7 @@
return 1;
}
- Point point;
+ Vector point;
Vector normal;
// Shoot a ray into the scene.
@@ -766,7 +766,7 @@
root_object = cutting_plane->getObject();
}
- Point point;
+ Vector point;
Vector normal;
// Check to see if this object is either a transparent or normal kdtree.
@@ -834,15 +834,15 @@
root_object = cutting_plane->getObject();
}
- Point point;
+ Vector point;
Vector normal;
// Check to see if this object is either a transparent or normal kdtree.
int result = manta_frame->shootOneRay( x, y, point, normal, false );
if (result) {
- Point eye[4];
- Point lookat[4];
+ Vector eye[4];
+ Vector lookat[4];
Vector up[4];
// Get the current manta camera.
int channel = manta_frame->getNavigator()->getMantaChannel();
@@ -1019,12 +1019,12 @@
//////////////////////////////////////////////////////////////////////
// Create a camera path.
- Point eye[4];
- Point lookat[4];
+ Vector eye[4];
+ Vector lookat[4];
Vector up[4];
// Determine destination.
- Point point = new_camera->getPosition();
+ Vector point = new_camera->getPosition();
Vector normal = (new_camera->getPosition() - new_camera->getLookAt());
normal.normalize();
@@ -1189,7 +1189,7 @@
}
// This method is called by the manta thread to add a cutting plane.
-void FMantaWindow::mantaAddCuttingPlane( Point point, Vector normal ) const {
+void FMantaWindow::mantaAddCuttingPlane( Vector point, Vector normal ) const
{
// Add a cutting plane on top of the root object.
Scene *scene = manta_interface->getScene();
Modified: trunk/fox/FManta/FMantaWindow.h
==============================================================================
--- trunk/fox/FManta/FMantaWindow.h (original)
+++ trunk/fox/FManta/FMantaWindow.h Thu Feb 16 17:08:22 2006
@@ -230,7 +230,7 @@
void mantaTraverser( const string shadow_text ) const;
// This method is called by the manta thread to add a cutting plane.
- void mantaAddCuttingPlane( Point point, Vector normal ) const;
+ void mantaAddCuttingPlane( Vector point, Vector normal ) const;
void mantaRemoveCuttingPlane() const;
void mantaMoveCuttingPlane( Real amount ) const;
void mantaFlipCuttingPlane() const;
@@ -239,7 +239,7 @@
void mantaPOIManeuverComplete();
mutable CameraPathAutomator *automator;
- mutable Point dstPosition, dstLookAt;
+ mutable Vector dstPosition, dstLookAt;
mutable Vector dstUp;
// This method is called by the manta thread to change the rendering
mode.
Modified: trunk/fox/afr_demo/Engine/ImageTraversers/AFImageTraverser.cc
==============================================================================
--- trunk/fox/afr_demo/Engine/ImageTraversers/AFImageTraverser.cc
(original)
+++ trunk/fox/afr_demo/Engine/ImageTraversers/AFImageTraverser.cc Thu
Feb 16 17:08:22 2006
@@ -354,7 +354,7 @@
for(i=0; i<5; i++) {
int rayindex = (j-start)*5+i;
Color clr = rays.getColor(rayindex);
- Point p = rays.getHitPosition(rayindex);
+ Vector p = rays.getHitPosition(rayindex);
RGBColor tempcol = clr.convertRGB();
float nsx, nsy;
nsx = newSampleSet[myID][j].sample[TEMPORAL_SAMPLE].viewCoord[0] +
offset[i][0];
@@ -517,7 +517,7 @@
int fi = (f+i);
Color clr = rays.getColor(i);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(i);
+ Vector p = rays.getHitPosition(i);
newSample[myID][fi].c[0] = tempcol.r();
newSample[myID][fi].c[1] = tempcol.g();
newSample[myID][fi].c[2] = tempcol.b();
@@ -643,8 +643,8 @@
if(!isinf(px) && !isinf(py) && !isinf(pz))
#endif
{
- const Point p(px, py, pz);
- Point rp;
+ const Vector p(px, py, pz);
+ Vector rp;
rp = ((AFRCamera*)context.camera)->project(p);
sp->viewCoord[0] = rp.x()*xres;
sp->viewCoord[1] = rp.y()*yres;
Modified: trunk/fox/afr_demo/Engine/ImageTraversers/AFRImageTraverser.cc
==============================================================================
--- trunk/fox/afr_demo/Engine/ImageTraversers/AFRImageTraverser.cc
(original)
+++ trunk/fox/afr_demo/Engine/ImageTraversers/AFRImageTraverser.cc Thu
Feb 16 17:08:22 2006
@@ -167,10 +167,10 @@
const Kdtree::Triangle &triangle =
kdtree->getFace( face_index );
// now project the triangle into imagespace
- const Point p1(triangle.v[0].x(), triangle.v[0].y(),
triangle.v[0].z());
- const Point p2(triangle.v[1].x(), triangle.v[1].y(),
triangle.v[1].z());
- const Point p3(triangle.v[2].x(), triangle.v[2].y(),
triangle.v[2].z());
- Point rp;
+ const Vector p1(triangle.v[0].x(), triangle.v[0].y(),
triangle.v[0].z());
+ const Vector p2(triangle.v[1].x(), triangle.v[1].y(),
triangle.v[1].z());
+ const Vector p3(triangle.v[2].x(), triangle.v[2].y(),
triangle.v[2].z());
+ Vector rp;
const AFRCamera *camera = dynamic_cast<const AFRCamera *>(
context.camera );
// rp = ((AFRCamera*)context.camera)->project(p1);
rp = camera->project(p1);
Modified: trunk/fox/afr_demo/Engine/ImageTraversers/EGSRImageTraverser.cc
==============================================================================
--- trunk/fox/afr_demo/Engine/ImageTraversers/EGSRImageTraverser.cc
(original)
+++ trunk/fox/afr_demo/Engine/ImageTraversers/EGSRImageTraverser.cc Thu
Feb 16 17:08:22 2006
@@ -377,7 +377,7 @@
int rayindex = (j-start)*5+i;
Color clr = rays.getColor(rayindex);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(rayindex);
+ Vector p = rays.getHitPosition(rayindex);
float nsx, nsy;
nsx = newSampleSet[myID][j].sample[TEMPORAL_SAMPLE].viewCoord[0] +
offset[i][0];
nsy = newSampleSet[myID][j].sample[TEMPORAL_SAMPLE].viewCoord[1] +
offset[i][1];
@@ -418,8 +418,8 @@
if(!isinf(px) && !isinf(py) && !isinf(pz))
#endif
{
- const Point p(px, py, pz);
- Point rp;
+ const Vector p(px, py, pz);
+ Vector rp;
rp = ((AFRCamera*)context.camera)->project(p);
if(fabsf(rp.x()*xres- sp->sample[j].viewCoord[0])>0.001)
sameloc=false;
if(fabsf(rp.y()*yres- sp->sample[j].viewCoord[1])>0.001)
sameloc=false;
@@ -534,7 +534,7 @@
occlusionSample[myID][fi].c[0] = tempcol.r();
occlusionSample[myID][fi].c[1] = tempcol.g();
occlusionSample[myID][fi].c[2] = tempcol.b();
- Point p = rays.getHitPosition(i);
+ Vector p = rays.getHitPosition(i);
occlusionSample[myID][fi].worldCoord[0] = p.x();
occlusionSample[myID][fi].worldCoord[1] = p.y();
occlusionSample[myID][fi].worldCoord[2] = p.z();
Modified: trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverser.cc
==============================================================================
--- trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverser.cc
(original)
+++ trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverser.cc Thu
Feb 16 17:08:22 2006
@@ -429,7 +429,7 @@
int rayindex = (j-start)*5+i;
Color clr = rays.getColor(rayindex);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(rayindex);
+ Vector p = rays.getHitPosition(rayindex);
float nsx, nsy;
nsx = newSampleSet[myID][j].sample[TEMPORAL_SAMPLE].viewCoord[0] +
offset[i][0];
nsy = newSampleSet[myID][j].sample[TEMPORAL_SAMPLE].viewCoord[1] +
offset[i][1];
@@ -595,7 +595,7 @@
newSample[myID][fi].c[0] = tempcol.r();
newSample[myID][fi].c[1] = tempcol.g();
newSample[myID][fi].c[2] = tempcol.b();
- Point hitpos = rays.getHitPosition(i);
+ Vector hitpos = rays.getHitPosition(i);
newSample[myID][fi].worldCoord[0] = hitpos.x();
newSample[myID][fi].worldCoord[1] = hitpos.y();
newSample[myID][fi].worldCoord[2] = hitpos.z();
@@ -689,8 +689,8 @@
if(!isinf(px) && !isinf(py) && !isinf(pz))
#endif
{
- const Point p(px, py, pz);
- Point rp;
+ const Vector p(px, py, pz);
+ Vector rp;
rp = ((AFRCamera*)context.camera)->project(p);
sp->viewCoord[0] = rp.x()*xres;
sp->viewCoord[1] = rp.y()*yres;
Modified: trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserNew.cc
==============================================================================
--- trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserNew.cc
(original)
+++ trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserNew.cc
Thu Feb 16 17:08:22 2006
@@ -415,7 +415,7 @@
for(i=start; i<=sscount; i++) {
Color clr = rays.getColor(j);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(j);
+ Vector p = rays.getHitPosition(j);
//cout << "processing sampleset " << i << endl;
newPartialSampleSet[myID][i].set( numFrontXhairSamples,
newPartialSampleSet[myID][i].sample[0].viewCoord[0],
@@ -648,7 +648,7 @@
int rayindex = i*numFrontXhairSamples+j;
Color clr = rays.getColor(rayindex);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(rayindex);
+ Vector p = rays.getHitPosition(rayindex);
newTempPartialSampleSet[myID][pssindex].set(j,
newTempPartialSampleSet[myID][pssindex].sample[j].viewCoord[0],
newTempPartialSampleSet[myID][pssindex].sample[j].viewCoord[1],
@@ -817,7 +817,7 @@
int rayindex = i*numFrontXhairSamples+j;
Color clr = rays.getColor(rayindex);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(rayindex);
+ Vector p = rays.getHitPosition(rayindex);
newTempPartialSampleSet[myID][pssindex].set(j,
newTempPartialSampleSet[myID][pssindex].sample[j].viewCoord[0],
newTempPartialSampleSet[myID][pssindex].sample[j].viewCoord[1],
@@ -987,8 +987,8 @@
if(!isinf(px) && !isinf(py) && !isinf(pz))
#endif
{
- const Point p(px, py, pz);
- Point rp;
+ const Vector p(px, py, pz);
+ Vector rp;
rp = ((AFRCamera*)context.camera)->project(p);
sp->sample[j].viewCoord[0] = rp.x()*xres;
sp->sample[j].viewCoord[1] = rp.y()*yres;
Modified:
trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserSTPlane.cc
==============================================================================
--- trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserSTPlane.cc
(original)
+++ trunk/fox/afr_demo/Engine/ImageTraversers/GSTAFRImageTraverserSTPlane.cc
Thu Feb 16 17:08:22 2006
@@ -413,7 +413,7 @@
for(i=start; i<=sscount; i++) {
Color clr = rays.getColor(j);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(j);
+ Vector p = rays.getHitPosition(j);
//cout << "processing sampleset " << i << endl;
newSampleSet[myID][i].set( numFrontXhairSamples,
newSampleSet[myID][i].sample[0].viewCoord[0],
@@ -446,8 +446,8 @@
ey =v1[1]+(v2[1]-v1[1])*ival;
//ez =v1[2]+(v2[2]-v1[2])*ival;
// project into screenspace
- /*const Point p(ex, ey, ez);
- Point rp;
+ /*const Vector p(ex, ey, ez);
+ Vector rp;
rp = context.camera->project(p);
ex = rp.x()*xres;
ey = rp.y()*yres;
@@ -517,7 +517,7 @@
int rayindex = i*numFrontXhairSamples+j;
Color clr = rays.getColor(rayindex);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(rayindex);
+ Vector p = rays.getHitPosition(rayindex);
edgesampleset[i].set(j,
edgesampleset[i].sample[j].viewCoord[0],
edgesampleset[i].sample[j].viewCoord[1],
@@ -552,13 +552,13 @@
}
else
{
- Point rp2;
+ Vector rp2;
ex[2] = edgesampleset[i].sample[CENTER_SAMPLE].worldCoord[0];
ey[2] = edgesampleset[i].sample[CENTER_SAMPLE].worldCoord[1];
ez[2] = edgesampleset[i].sample[CENTER_SAMPLE].worldCoord[2];
- const Point p2(ex[2], ey[2], ez[2]);
- const Point p3(ex[2], ey[2], ez[2]);
- Point rp3 = ((AFRCamera*)context.camera)->project(p3, 0);
+ const Vector p2(ex[2], ey[2], ez[2]);
+ const Vector p3(ex[2], ey[2], ez[2]);
+ Vector rp3 = ((AFRCamera*)context.camera)->project(p3, 0);
rp2 = ((AFRCamera*)context.camera)->project(p2, 1);
printf("point moved from %f,%f to %f,%f, recentcam says %f, %f\n",
edgesampleset[i].sample[CENTER_SAMPLE].viewCoord[0],
edgesampleset[i].sample[CENTER_SAMPLE].viewCoord[1], rp2.x()*xres,
rp2.y()*yres, rp3.x()*xres, rp3.y()*yres);
ex[2] = rp2.x()*xres;
@@ -700,7 +700,7 @@
int rayindex = i*numFrontXhairSamples+j;
Color clr = rays.getColor(rayindex);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(rayindex);
+ Vector p = rays.getHitPosition(rayindex);
mainSampleSet[i].set(j,
mainSampleSet[i].sample[j].viewCoord[0],
mainSampleSet[i].sample[j].viewCoord[1],
@@ -909,8 +909,8 @@
if(!isinf(px) && !isinf(py) && !isinf(pz))
#endif
{
- const Point p(px, py, pz);
- Point rp;
+ const Vector p(px, py, pz);
+ Vector rp;
rp = ((AFRCamera*)context.camera)->project(p);
/*printf("in clienttask: reprojected %f,%f to %f,%f\n",
sp->sample[j].viewCoord[0],
Modified: trunk/fox/afr_demo/Engine/ImageTraversers/STAFRImageTraverser.cc
==============================================================================
--- trunk/fox/afr_demo/Engine/ImageTraversers/STAFRImageTraverser.cc
(original)
+++ trunk/fox/afr_demo/Engine/ImageTraversers/STAFRImageTraverser.cc Thu
Feb 16 17:08:22 2006
@@ -398,7 +398,7 @@
j = 0;
for(i=start; i<=sscount; i++) {
Color clr = rays.getColor(j);
- Point p = rays.getHitPosition(j);
+ Vector p = rays.getHitPosition(j);
RGBColor tempcol = clr.convertRGB();
//cout << "processing sampleset " << i << endl;
newPartialSampleSet[myID][i].set( numFrontXhairSamples,
@@ -541,7 +541,7 @@
int rayindex = i*numFrontXhairSamples+j;
Color clr = rays.getColor(rayindex);
RGBColor tempcol = clr.convertRGB();
- Point p = rays.getHitPosition(rayindex);
+ Vector p = rays.getHitPosition(rayindex);
newTempPartialSampleSet[myID][pssindex].set(j,
newTempPartialSampleSet[myID][pssindex].sample[j].viewCoord[0],
newTempPartialSampleSet[myID][pssindex].sample[j].viewCoord[1],
@@ -676,8 +676,8 @@
if(!isinf(px) && !isinf(py) && !isinf(pz))
#endif
{
- const Point p(px, py, pz);
- Point rp;
+ const Vector p(px, py, pz);
+ Vector rp;
rp = ((AFRCamera*)context.camera)->project(p);
sp->sample[j].viewCoord[0] = rp.x()*xres;
sp->sample[j].viewCoord[1] = rp.y()*yres;
Modified: trunk/fox/afr_demo/Model/Cameras/AFRCamera.h
==============================================================================
--- trunk/fox/afr_demo/Model/Cameras/AFRCamera.h (original)
+++ trunk/fox/afr_demo/Model/Cameras/AFRCamera.h Thu Feb 16 17:08:22
2006
@@ -38,7 +38,7 @@
#include <Model/Cameras/AFRPinholeCamera.h>
#include <Interface/Camera.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Geometry/AffineTransform.h>
#include <Engine/Control/AFRPipeline.h>
@@ -68,7 +68,7 @@
public:
///////////////////////////////////////////////////////////////////////////
// Constructors.
- AFRCamera( const Point &eye_, const Point &lookat_, const Vector &up_,
Real fov_ ) :
+ AFRCamera( const Vector &eye_, const Vector &lookat_, const Vector &up_,
Real fov_ ) :
current( 0 ) { for(int i=0; i<Size; i++) cam[i] = new
AFRPinholeCamera( eye_, lookat_, up_, fov_ ); };
AFRCamera(const vector<string>& args) :
current( 0 ) { for(int i=0; i<Size; i++) cam[i] = new
AFRPinholeCamera( args ); };
@@ -100,7 +100,7 @@
{ update(); getCurrent()->autoview( bbox ); }
virtual void output ( std::ostream &os )
{ getCurrent()->output( os ); }
- virtual Point project (const Point &point, int steps=0) const
+ virtual Vector project (const Vector &point, int steps=0) const
{ if (steps >= Size)
throw InternalError( "getHistory steps >= History size.", __FILE__,
__LINE__ );
@@ -108,14 +108,14 @@
prev = (prev < 0) ? (prev+Size) : prev;
return cam[prev]->project( point );
}
- virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ )
+ virtual void reset( const Vector &eye_, const Vector &up_, const Vector
&lookat_ )
{ for(int i=0; i<Size; i++) cam[i]->reset( eye_, up_, lookat_ );}
virtual void writeToFile(FILE *fp) const {getCurrent()->writeToFile(fp);
};
///////////////////////////////////////////////////////////////////////////
// Accessors
- virtual Point getPosition() const { return
getCurrent()->getPosition(); }
- virtual Point getLookAt() const { return getCurrent()->getLookAt();
};
- virtual Vector getUp() const { return getCurrent()->getUp(); };
+ virtual Vector getPosition() const { return
getCurrent()->getPosition(); }
+ virtual Vector getLookAt() const { return getCurrent()->getLookAt();
};
+ virtual Vector getUp() const { return getCurrent()->getUp(); };
///////////////////////////////////////////////////////////////////////////
// History Accessors
Modified: trunk/fox/afr_demo/Model/Cameras/AFRPinholeCamera.cc
==============================================================================
--- trunk/fox/afr_demo/Model/Cameras/AFRPinholeCamera.cc (original)
+++ trunk/fox/afr_demo/Model/Cameras/AFRPinholeCamera.cc Thu Feb 16
17:08:22 2006
@@ -19,7 +19,9 @@
{
}
-AFRPinholeCamera::AFRPinholeCamera( const Point &eye_, const Point &lookat_,
const Vector &up_, Real fov_ ):PinholeCamera(eye_, lookat_, up_, fov_)
+AFRPinholeCamera::AFRPinholeCamera( const Vector& eye_, const Vector&
lookat_,
+ const Vector& up_, Real fov_ )
+ : PinholeCamera(eye_, lookat_, up_, fov_)
{
}
@@ -47,7 +49,7 @@
up.normalize();
v=Cross(direction, up);
- if(v.length2() == 0.0){
+ if(v.length2() == 0){
std::cerr << __FILE__ << " line: " << __LINE__ << " Ambiguous up
direciton...\n";
}
v.normalize();
@@ -57,39 +59,39 @@
for(i=0; i<4; i++)
for(j=0; j<4; j++)
- proj[i][j] = mv[i][j] = 0.0;
+ proj[i][j] = mv[i][j] = 0;
// form modelview matrix
mv[0][0] = v.x(); mv[0][1] = v.y(); mv[0][2] = v.z();
mv[0][3] = (-eye.x()*v.x()) + (-eye.y()*v.y()) + (-eye.z()*v.z());
mv[1][0] = u.x(); mv[1][1] = u.y(); mv[1][2] = u.z();
mv[1][3] = (-eye.x()*u.x()) + (-eye.y()*u.y()) + (-eye.z()*u.z());
- mv[2][0] = -1.0*n.x(); mv[2][1] = -1.0*n.y(); mv[2][2] = -1.0*n.z();
+ mv[2][0] = -1*n.x(); mv[2][1] = -1*n.y(); mv[2][2] = -1*n.z();
mv[2][3] = (eye.x()*n.x()) + (eye.y()*n.y()) + (eye.z()*n.z());
- mv[3][3]= 1.0;
+ mv[3][3]= 1;
- height=nearZ*tan(vfov*0.5*M_PI/180.0);
+ height=nearZ*Tan(vfov*(Real)(0.5*M_PI/180));
u*=height;
- width=nearZ*tan(hfov*0.5*M_PI/180.0);
+ width=nearZ*Tan(hfov*(Real)(0.5*M_PI/180));
v*=width;
// form projection matrix
- Real f = 1.0/tan((vfov*M_PI/180.0)/2.0);
+ Real f = 1/Tan(vfov*(Real)(0.5*M_PI/180));
Real aspect = width/height;
- Real farZ = nearZ*1000.0;
+ Real farZ = nearZ*1000;
proj[0][0] = f/aspect;
proj[1][1] = f;
proj[2][2] = (farZ+nearZ)/(nearZ-farZ);
- proj[2][3] = (2.0*farZ*nearZ)/(nearZ-farZ);
- proj[3][2] = -1.0;
+ proj[2][3] = (2*farZ*nearZ)/(nearZ-farZ);
+ proj[3][2] = -1;
// product of two
for(i=0; i<4; i++)
{
for(j=0; j<4; j++)
{
- prodMat[i][j] = 0.0;
+ prodMat[i][j] = 0;
for(k=0; k<4; k++)
{
prodMat[i][j] += proj[i][k]*mv[k][j];
@@ -98,31 +100,31 @@
}
}
-Point AFRPinholeCamera::project(const Point &point) const
+Vector AFRPinholeCamera::project(const Vector& point) const
{
- Point p2(prodMat[0][0]*point.x() + prodMat[0][1]*point.y() +
prodMat[0][2]*point.z() + prodMat[0][3],
- prodMat[1][0]*point.x() + prodMat[1][1]*point.y() +
prodMat[1][2]*point.z() + prodMat[1][3],
- prodMat[2][0]*point.x() + prodMat[2][1]*point.y() +
prodMat[2][2]*point.z() + prodMat[2][3]);
+ Vector p2(prodMat[0][0]*point.x() + prodMat[0][1]*point.y() +
prodMat[0][2]*point.z() + prodMat[0][3],
+ prodMat[1][0]*point.x() + prodMat[1][1]*point.y() +
prodMat[1][2]*point.z() + prodMat[1][3],
+ prodMat[2][0]*point.x() + prodMat[2][1]*point.y() +
prodMat[2][2]*point.z() + prodMat[2][3]);
Real zval = prodMat[3][0]*point.x() + prodMat[3][1]*point.y() +
prodMat[3][2]*point.z() + prodMat[3][3];
- return Point(((p2.x()/zval)+1.0)/2.0,
- ((p2.y()/zval)+1.0)/2.0,
- ((p2.z()/zval)+1.0)/2.0);
+ return Vector(((p2.x()/zval)+1)*(Real)0.5,
+ ((p2.y()/zval)+1)*(Real)0.5,
+ ((p2.z()/zval)+1)*(Real)0.5);
}
void AFRPinholeCamera::writeToFile(FILE *fp) const
{
float wR, wT;
- wR = nearZ*tan(hfov*0.5*M_PI/180.0);
- wT = nearZ*tan(vfov*0.5*M_PI/180.0);
+ wR = nearZ*Tan(hfov*(Real)(0.5*M_PI/180));
+ wT = nearZ*Tan(vfov*(Real)(0.5*M_PI/180));
fprintf(fp,"origin %f %f %f\nU %f %f %f\nV %f %f %f\nN %f %f %f\nextents
%f %f %f %f\nnear %f\nfar %f\n",
eye.x(), eye.y(), eye.z(),
mv[0][0], mv[0][1], mv[0][2],
mv[1][0], mv[1][1], mv[1][2],
-mv[2][0], -mv[2][1], -mv[2][2],
-wR, wR, -wT, wT,
- nearZ, nearZ*1000.0);
+ nearZ, nearZ*1000);
}
Modified: trunk/fox/afr_demo/Model/Cameras/AFRPinholeCamera.h
==============================================================================
--- trunk/fox/afr_demo/Model/Cameras/AFRPinholeCamera.h (original)
+++ trunk/fox/afr_demo/Model/Cameras/AFRPinholeCamera.h Thu Feb 16 17:08:22
2006
@@ -3,7 +3,7 @@
#define Manta_Model_AFRPinholeCamera_h
#include <Model/Cameras/PinholeCamera.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <sgi_stl_warnings_off.h>
#include <string>
#include <vector>
@@ -15,12 +15,13 @@
class AFRPinholeCamera : public PinholeCamera {
public:
AFRPinholeCamera(const vector<string>& args);
- AFRPinholeCamera( const Point &eye_, const Point &lookat_, const Vector
&up_, Real fov_ );
+ AFRPinholeCamera( const Vector& eye_, const Vector& lookat_,
+ const Vector& up_, Real fov_ );
static Camera* create(const vector<string>& args);
virtual ~AFRPinholeCamera();
- virtual Point project(const Point &point) const; // project a 3D point
to the camera image plane
+ virtual Vector project(const Vector& point) const; // project a 3D
point to the camera image plane
virtual void writeToFile(FILE *fp) const;
virtual void setup();
void copyProjectionMatrices(AFRPinholeCamera *cam)
Modified: trunk/fox/afr_demo/StandAlone/afr.cc
==============================================================================
--- trunk/fox/afr_demo/StandAlone/afr.cc (original)
+++ trunk/fox/afr_demo/StandAlone/afr.cc Thu Feb 16 17:08:22 2006
@@ -208,9 +208,9 @@
throw InternalError("default shadow algorithm not found", __FILE__,
__LINE__ );
// Set camera for the default scene.
- Camera* currentCamera = new AFRCamera( Point( 3, 3, 2 ),
- Point( 0, 0, 0.3 ),
- Vector( 0, 0, 1 ), 60 );
+ Camera* currentCamera = new AFRCamera( Vector( 3, 3, 2 ),
+ Vector( 0, 0, 0.3 ),
+ Vector( 0, 0, 1 ), 60 );
AFRGlobals::globalAFRPipeline = (AFRPipeline*)rtrt;
// Defaults for command line args.
int xres = 512, yres = 512;
@@ -552,19 +552,19 @@
Group* world = new Group();
- Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
+ Primitive* floor = new Parallelogram(plane_matl, Vector(-20,-20,0),
Vector(40,0,0), Vector(0,40,0));
// Setup world-space texture coordinates for the checkerboard floor
UniformMapper* uniformmap = new UniformMapper();
floor->setTexCoordMapper(uniformmap);
world->add(floor);
- world->add(new Sphere(red, Point(0,0,1.2), 1.0));
+ world->add(new Sphere(red, Vector(0,0,1.2), 1.0));
scene->setObject(world);
LightSet* lights = new LightSet();
- lights->add(new PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1))));
- lights->add(new PointLight(Point(5,0,8), Color(RGBColor(.1,.6,.1))));
- lights->add(new PointLight(Point(5,5,2), Color(RGBColor(.2,.2,.2))));
+ lights->add(new PointLight(Vector(0,5,8), Color(RGBColor(.6,.1,.1))));
+ lights->add(new PointLight(Vector(5,0,8), Color(RGBColor(.1,.6,.1))));
+ lights->add(new PointLight(Vector(5,5,2), Color(RGBColor(.2,.2,.2))));
lights->setAmbientLight(new ConstantAmbient(Color::black()));
scene->setLights(lights);
scene->getRenderParameters().maxDepth = 5;
Modified: trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
==============================================================================
--- trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc (original)
+++ trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc Thu Feb 16
17:08:22 2006
@@ -126,10 +126,10 @@
int end = i+1;
// Set the tile packet hit flag.
- tile_packet.get(i).flags |= TilePacket::WAS_HIT;
+ tile_packet.setFlag(i, TilePacket::WAS_HIT);
while(end < ray_packet.end() && ray_packet.wasHit(end)) {
- tile_packet.get(end++).flags |= TilePacket::WAS_HIT;
+ tile_packet.setFlag(end++, TilePacket::WAS_HIT);
}
RayPacket sub_ray_packet (ray_packet, i, end);
@@ -152,8 +152,8 @@
// Copy the background color over to the tile packet.
for (int j=subPacket.begin();j<subPacket.end();++j) {
- tile_packet.get(j).flags &= (~TilePacket::WAS_HIT);
- tile_packet.get(j).color = ray_packet.getColor(j);
+ tile_packet.resetFlag(j, TilePacket::WAS_HIT);
+ tile_packet.setColor(j, ray_packet.getColor(j));
}
i=end;
Modified: trunk/fox/disco_demo/Engine/Shaders/AOShader.cc
==============================================================================
--- trunk/fox/disco_demo/Engine/Shaders/AOShader.cc (original)
+++ trunk/fox/disco_demo/Engine/Shaders/AOShader.cc Thu Feb 16 17:08:22
2006
@@ -35,7 +35,8 @@
#include <Interface/Context.h>
#include <Interface/Primitive.h>
#include <Interface/Scene.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
+#include <Core/Geometry/VectorT.h>
#include <Core/Math/HaltonSequence.h>
#include <SCIRun/Core/Math/Trig.h>
@@ -84,7 +85,7 @@
/////////////////////////////////////////////////////////////////////////
// Generate cosine weighted directions
HaltonSequence<Real,2> sequence( context.proc*100 );
- PointT<Real,2> p;
+ VectorT<Real,2> p;
// #define STRATIFY
#ifdef STRATIFY
Modified: trunk/fox/disco_demo/Interface/DiscoTile.h
==============================================================================
--- trunk/fox/disco_demo/Interface/DiscoTile.h (original)
+++ trunk/fox/disco_demo/Interface/DiscoTile.h Thu Feb 16 17:08:22 2006
@@ -29,13 +29,10 @@
DEALINGS IN THE SOFTWARE.
*/
+#include <Interface/RayPacket.h>
#include <Core/Util/ThreadStorage.h>
#include <disco_demo/Interface/TilePacket.h>
-namespace Manta {
- class RayPacket;
-};
-
namespace disco {
using namespace Manta;
@@ -75,10 +72,15 @@
/////////////////////////////////////////////////////////////////////////..
// TilePacket Accessors, caller is responsible for determining size.
TilePacketData &getTilePacketData( int i ) {
- size_t index = i*RayPacket::MaxSize;
+ // For whatever reason, GCC 4.0 didn't like it when I had
+ // i*RayPacket::MaxSize instead of assigning it to a temporary
+ // variable. It was some kind of lexical parsing error as far
+ // as I could tell. Don't change it back.
+ int size = RayPacket::MaxSize;
+ size_t index = i*size;
ASSERT(index < total);
return *((TilePacketData *)&tilepacket_data[index]);
- };
+ }
int getPacketSize( int i ) {
int rounded = (total/RayPacket::MaxSize);
Modified: trunk/fox/disco_demo/Interface/TilePacket.h
==============================================================================
--- trunk/fox/disco_demo/Interface/TilePacket.h (original)
+++ trunk/fox/disco_demo/Interface/TilePacket.h Thu Feb 16 17:08:22 2006
@@ -53,7 +53,7 @@
Real illuminance;
Real t;
Vector normal;
- Point point;
+ Vector point;
// Result
Color color;
Modified: trunk/fox/dm_demo/dm_demo.cc
==============================================================================
--- trunk/fox/dm_demo/dm_demo.cc (original)
+++ trunk/fox/dm_demo/dm_demo.cc Thu Feb 16 17:08:22 2006
@@ -158,7 +158,7 @@
manta_interface->selectRenderer ( "raytracer" );
manta_interface->selectShadowAlgorithm( "hard" );
- // Camera *camera = new PinholeCamera( Point ( 0.0, 0.0, 0.0 ), Point (
0.0, -1.0, 0.0 ), Vector( 0.0, 0.0, 1.0 ), 60 );
+ // Camera *camera = new PinholeCamera( Vector ( 0, 0, 0 ), Vector ( 0,
-1, 0 ), Vector( 0, 0, 1 ), 60 );
// Create the manta image frame.
FMantaImageFrame *manta_frame = manta_window.getMantaFrame();
@@ -188,8 +188,8 @@
PreprocessContext context;
root_object->computeBounds( context, bounds );
- Point lookat = bounds[0] + (bounds[1] - bounds[0]) * 0.5;
- Point eye = lookat + Vector( 0, bounds.diagonal().length(), 0 );
+ Vector lookat = bounds[0] + (bounds[1] - bounds[0]) * (Real)0.5;
+ Vector eye = lookat + Vector( 0, bounds.diagonal().length(), 0 );
Vector up( 0, 0, 1 );
ostringstream oss;
@@ -502,20 +502,20 @@
Vector(0,1,0)));
Group* world = new Group();
- Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
+ Primitive* floor = new Parallelogram(plane_matl, Vector(-20,-20,0),
Vector(40,0,0), Vector(0,40,0));
// Setup world-space texture coordinates for the checkerboard floor
UniformMapper* uniformmap = new UniformMapper();
floor->setTexCoordMapper(uniformmap);
world->add(floor);
- world->add(new Sphere(red, Point(0,0,1.2), 1.0));
+ world->add(new Sphere(red, Vector(0,0,1.2), 1.0));
scene->setObject(world);
LightSet* lights = new LightSet();
- lights->add(new PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1))));
- lights->add(new PointLight(Point(5,0,8), Color(RGBColor(.1,.6,.1))));
- lights->add(new PointLight(Point(5,5,2), Color(RGBColor(.2,.2,.2))));
+ lights->add(new PointLight(Vector(0,5,8), Color(RGBColor(.6,.1,.1))));
+ lights->add(new PointLight(Vector(5,0,8), Color(RGBColor(.1,.6,.1))));
+ lights->add(new PointLight(Vector(5,5,2), Color(RGBColor(.2,.2,.2))));
lights->setAmbientLight(new ConstantAmbient(Color::black()));
scene->setLights(lights);
scene->getRenderParameters().maxDepth = 5;
Modified: trunk/fox/sc_demo/sc_demo.cc
==============================================================================
--- trunk/fox/sc_demo/sc_demo.cc (original)
+++ trunk/fox/sc_demo/sc_demo.cc Thu Feb 16 17:08:22 2006
@@ -219,8 +219,8 @@
PreprocessContext context;
root_object->computeBounds( context, bounds );
- Point lookat = bounds[0] + (bounds[1] - bounds[0]) * 0.5;
- Point eye = lookat + Vector( 0, bounds.diagonal().length(), 0 );
+ Vector lookat = bounds[0] + (bounds[1] - bounds[0]) * (Real)0.5;
+ Vector eye = lookat + Vector( 0, bounds.diagonal().length(), 0 );
Vector up( 0, 0, 1 );
ostringstream oss;
@@ -365,19 +365,19 @@
Vector(0,1,0)));
Group* world = new Group();
- Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
- Vector(40,0,0), Vector(0,40,0));
+ Primitive* floor = new Parallelogram(plane_matl, Vector(-20,-20,0),
+ Vector(40,0,0), Vector(0,40,0));
// Setup world-space texture coordinates for the checkerboard floor
UniformMapper* uniformmap = new UniformMapper();
floor->setTexCoordMapper(uniformmap);
world->add(floor);
- world->add(new Sphere(red, Point(0,0,1.2), 1.0));
+ world->add(new Sphere(red, Vector(0,0,1.2), 1.0));
scene->setObject(world);
LightSet* lights = new LightSet();
- lights->add(new PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1))));
- lights->add(new PointLight(Point(5,0,8), Color(RGBColor(.1,.6,.1))));
- lights->add(new PointLight(Point(5,5,2), Color(RGBColor(.2,.2,.2))));
+ lights->add(new PointLight(Vector(0,5,8), Color(RGBColor(.6,.1,.1))));
+ lights->add(new PointLight(Vector(5,0,8), Color(RGBColor(.1,.6,.1))));
+ lights->add(new PointLight(Vector(5,5,2), Color(RGBColor(.2,.2,.2))));
lights->setAmbientLight(new ConstantAmbient(Color::black()));
scene->setLights(lights);
scene->getRenderParameters().maxDepth = 5;
Modified: trunk/scenes/0.cc
==============================================================================
--- trunk/scenes/0.cc (original)
+++ trunk/scenes/0.cc Thu Feb 16 17:08:22 2006
@@ -1,5 +1,5 @@
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Util/Args.h>
#include <Interface/Context.h>
@@ -48,19 +48,19 @@
t.initWithRotation(axis, rot);
for(int n=0;n<3;n++){
- dir[n] = t * dir[n];
+ dir[n] = t.multiply_vector(dir[n]);
}
for(int ns=0;ns<3;ns++){
AffineTransform t;
t.initWithRotation(Vector(0,0,1), ns*2.*M_PI/3.);
for(int nv=0;nv<3;nv++){
- objset[ns*3+nv] = t * dir[nv];
+ objset[ns*3+nv] = t.multiply_vector(dir[nv]);
}
}
}
-static void create_objs(Group* group, const Point& center,
+static void create_objs(Group* group, const Vector& center,
double radius, const Vector& dir, int depth,
Vector* objset, Material* matl)
{
@@ -78,8 +78,8 @@
double scale = radius * (1+SCALE);
for(int n=0;n<9;n++){
- Vector child_vec(mx * objset[n]);
- Point child_pt(center+child_vec*scale);
+ Vector child_vec(mx.multiply_vector(objset[n]));
+ Vector child_pt(center+child_vec*scale);
double child_rad=radius*SCALE; Vector child_dir = child_pt-center;
child_dir *= 1./scale;
create_objs(group, child_pt, child_rad, child_dir, depth, objset,
matl);
@@ -88,7 +88,7 @@
}
static void make_box(Group* group, Material* matl,
- const Point& corner, const Vector& x, const Vector& y,
const Vector& z)
+ const Vector& corner, const Vector& x, const Vector& y,
const Vector& z)
{
group->add(new Parallelogram(matl, corner, x*2, z*2));
group->add(new Parallelogram(matl, corner+y*2, z*2, x*2));
@@ -102,7 +102,7 @@
Vector objset[9];
create_dirs(objset);
Material* matl0=new Lambertian(Color(RGBColor(.4,.4,.4)));
- create_objs(group, Point(0,0,.5), BV_RADIUS/2.0, Vector(0,0,1),
+ create_objs(group, Vector(0,0,.5), BV_RADIUS/2.0, Vector(0,0,1),
size, objset, matl0);
world->add(group);
@@ -114,7 +114,7 @@
diag1*=1.5;
diag2*=1.5;
Vector z(0,0,.4);
- Point corner(-1.8,-.3,0);
+ Vector corner(-1.8,-.3,0);
make_box(world, matl1, corner, diag1, diag2, z);
Material* matl3=new MetalMaterial( Color(RGBColor(.7,.7,.7)));
@@ -127,7 +127,7 @@
Vector(-1.1,1,0)*scale));
Vector edge1(planesize, planesize*1.1, 0);
Vector edge2(-planesize*1.1, planesize, 0);
- Object* obj1=new Parallelogram(matl2, Point(0,0,0)-edge1-edge2, edge1*2,
edge2*2);
+ Object* obj1=new Parallelogram(matl2, Vector(0,0,0)-edge1-edge2, edge1*2,
edge2*2);
world->add(obj1);
}
@@ -169,7 +169,7 @@
NOT_FINISHED("scene 0");
make_obj(world, group, scenesize);
#if 0
- Camera cam(Point(1.8,-5.53,1.25), Point(0.0,-.13,1.22),
+ Camera cam(Vector(1.8,-5.53,1.25), Vector(0.0,-.13,1.22),
Vector(0,0,1), 28.2);
double ambient_scale=1.0;
@@ -178,7 +178,7 @@
Color cup(RGB(0.1, 0.3, 0.8));
- rtrt::Plane groundplane ( Point(0, 0, 0), Vector(0, 0, 3) );
+ rtrt::Plane groundplane ( Vector(0, 0, 0), Vector(0, 0, 3) );
Scene* scene=new Scene(obj, cam,
bgcolor, cdown, cup, groundplane,
ambient_scale, Arc_Ambient);
@@ -193,7 +193,7 @@
NOT_FINISHED("soft shadows/area lights for scene 0");
LightSet* lights = new LightSet();
- lights->add(new PointLight(Point(5,-3,3), Color(RGB(1,1,.8))*2));
+ lights->add(new PointLight(Vector(5,-3,3), Color(RGB(1,1,.8))*2));
Color cup(RGB(0.1, 0.3, 0.8));
Color cdown(RGB(0.82, 0.62, 0.62));
Vector up(0,0,1);
Modified: trunk/scenes/ParticleBVHTest.cc
==============================================================================
--- trunk/scenes/ParticleBVHTest.cc (original)
+++ trunk/scenes/ParticleBVHTest.cc Thu Feb 16 17:08:22 2006
@@ -48,7 +48,7 @@
int maximum_particles = 0;
int map_channel = 0;
double default_radius = 0.0005;
- Point light_position( 5.0, 5.0, 8.0 );
+ Vector light_position( 5, 5, 8 );
int occlusion_rays = 0;
double minimum_value = numeric_limits< double >::max();
double maximum_value = -numeric_limits< double >::max();
@@ -74,7 +74,7 @@
if ( !getDoubleArg( i, args, default_radius ) )
throw IllegalArgument( "scene particlebvhtest -radius", i, args );
} else if ( arg == "-lightpos" ) {
- if ( !getPointArg( i, args, light_position ) )
+ if ( !getVectorArg( i, args, light_position ) )
throw IllegalArgument( "scene particlebvhtest -lightpos", i, args );
} else if ( arg == "-occlusionrays" ) {
if ( !getIntArg( i, args, occlusion_rays ) )
@@ -142,7 +142,7 @@
Interpolate( color_map[ Floor( map_value ) ],
color_map[ Ceil( map_value ) ],
Fraction( map_value ) ),
- Point( data[ 0 ], data[ 1 ], data[ 2 ] ),
+ Vector( data[ 0 ], data[ 1 ], data[ 2 ] ),
radius_index > 0 ? data[ radius_index ] :
default_radius );
}
Scene *scene = new Scene();
Modified: trunk/scenes/acceltest.cc
==============================================================================
--- trunk/scenes/acceltest.cc (original)
+++ trunk/scenes/acceltest.cc Thu Feb 16 17:08:22 2006
@@ -69,7 +69,7 @@
for ( int variable = 0; variable < number_of_variables; ++variable )
in >> data[ variable ];
world->add( new Sphere( material,
- Point( data[ 0 ], data[ 1 ], data[ 2 ] ),
+ Vector( data[ 0 ], data[ 1 ], data[ 2 ] ),
radius_index > 0 ? data[ radius_index ] : 1.0 )
);
}
@@ -79,10 +79,10 @@
Vector( 0.0, 1.0, 0.0 ) ) );
scene->setObject( world );
LightSet *lights = new LightSet();
- lights->add( new PointLight( Point( 5.0, 5.0, 8.0), Color( RGB( 2.0, 2.0 ,
2.0 ) ) ) );
+ lights->add( new PointLight( Vector( 5, 5, 8), Color( RGB( 2, 2, 2 ) ) ) );
lights->setAmbientLight( new ArcAmbient( Color( RGB( 0.1, 0.3, 0.8 ) ),
Color( RGB( 0.8, 0.6, 0.6 ) ),
- Vector( 0.0, 1.0, 0.0 ) ) );
+ Vector( 0, 1, 0 ) ) );
scene->setLights( lights );
return scene;
}
Modified: trunk/scenes/boeing777.cc
==============================================================================
--- trunk/scenes/boeing777.cc (original)
+++ trunk/scenes/boeing777.cc Thu Feb 16 17:08:22 2006
@@ -32,7 +32,7 @@
// May 2005.
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Util/Args.h>
#include <Interface/Context.h>
@@ -96,7 +96,7 @@
string file_name;
- Point plane_point;
+ Vector plane_point;
Vector plane_normal;
CuttingPlaneType cutting_type = CUTTING_NONE;
@@ -170,7 +170,7 @@
}
else if (args[i] == "-cutting") {
string cutting_string;
- if (getPointArg(i, args, plane_point ) &&
getVectorArg(i, args, plane_normal)) {
+ if (getVectorArg(i, args, plane_point ) &&
getVectorArg(i, args, plane_normal)) {
cutting_type = CUTTING_SPECIFIED;
}
else if (getStringArg(i, args, cutting_string) &&
cutting_string == "default") {
Modified: trunk/scenes/cube.cc
==============================================================================
--- trunk/scenes/cube.cc (original)
+++ trunk/scenes/cube.cc Thu Feb 16 17:08:22 2006
@@ -27,7 +27,7 @@
*/
#include <Core/Color/ColorDB.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Util/Args.h>
#include <Interface/Context.h>
@@ -91,14 +91,14 @@
Material* matl1=new Lambertian(ColorDB::getNamedColor("sky blue"));
// Add a simple sphere to the scene
- world->add(new Sphere( matl1, Point(0.0,0.0,0.00), 1.0 ) );
+ world->add(new Sphere( matl1, Vector(0, 0, 0), 1.0 ) );
Scene* scene = new Scene();
scene->setBackground(new ConstantBackground(ColorDB::getNamedColor("light
slate gray")));
scene->setObject(world);
LightSet* lights = new LightSet();
- lights->add(new PointLight(Point(5,-3,3), Color(RGB(1,1,.8))*2));
+ lights->add(new PointLight(Vector(5,-3,3), Color(RGB(1,1,.8))*2));
Color cup(RGB(0.1, 0.3, 0.8));
Color cdown(RGB(0.82, 0.62, 0.62));
Vector up(0,0,1);
Modified: trunk/scenes/objviewer.cc
==============================================================================
--- trunk/scenes/objviewer.cc (original)
+++ trunk/scenes/objviewer.cc Thu Feb 16 17:08:22 2006
@@ -29,7 +29,7 @@
#include <MantaTypes.h>
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Util/Args.h>
@@ -88,7 +88,7 @@
static BBox bounds;
-typedef PointT<float,3> Pointf;
+typedef VectorT<float,3> Vectorf;
static Material **material_array = 0;
@@ -177,7 +177,7 @@
}
// Compute model bounds
- Pointf bmax, bmin;
+ Vectorf bmax, bmin;
glmBoundingBox( model, (float *)&bmin, (float *)&bmax );
/////////////////////////////////////////////////////////////////////////////
@@ -187,9 +187,9 @@
std::cerr << "Min: " << bmin << " Max: " << bmax << " translate: " <<
translate << std::endl;
- Pointf *vertex;
+ Vectorf *vertex;
for (int i=0;i<model->numvertices;++i) {
- vertex = (Pointf *)&model->vertices[i*3];
+ vertex = (Vectorf *)&model->vertices[i*3];
(*vertex) = (*vertex) - translate;
}
@@ -214,7 +214,7 @@
Material* yellow=new Lambertian(Color(RGBColor(.6,.6,0)));
// Add a floor.
- Parallelogram* floor = new Parallelogram(yellow,
Point(-20,-20,bounds[0][2]),
+ Parallelogram* floor = new Parallelogram(yellow,
Vector(-20,-20,bounds[0][2]),
Vector(40,0,0), Vector(0,40,0));
Group *manta_group = new Group();
// manta_group->add( floor );
@@ -451,7 +451,7 @@
int total_faces = group->numtriangles;
for (int i=0;i<total_faces;++i) {
- Point vertex[3];
+ Vector vertex[3];
Vector normal[3];
Vector texcoord[3];
Modified: trunk/scenes/primtest.cc
==============================================================================
--- trunk/scenes/primtest.cc (original)
+++ trunk/scenes/primtest.cc Thu Feb 16 17:08:22 2006
@@ -182,9 +182,9 @@
for(int j=0;j<numy;j++){
int idx = j*numx+i;
Real radius = (idx+1)/((numx*numy)*scale/max);
- Point p((numx>1 ? i/static_cast<Real>(numx-1) - (Real)0.5 :
0)*scale*2,
- (numy>1 ? j/static_cast<Real>(numy-1) - (Real)0.5 :
0)*scale*2,
- 0);
+ Vector p((numx>1 ? i/static_cast<Real>(numx-1)-(Real)0.5 :
0)*scale*2,
+ (numy>1 ? j/static_cast<Real>(numy-1)-(Real)0.5 :
0)*scale*2,
+ 0);
Primitive* prim = new Sphere( matl, p, radius );
if ( mapr )
prim->setTexCoordMapper( mapr );
@@ -198,9 +198,9 @@
Real radius = (idx+1)/((numx*numy)*scale/max);
Real alpha = (i+1)/static_cast<Real>(numx)*2;
Real beta = (j+1)/static_cast<Real>(numy)*2;
- Point p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
- (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
- 0);
+ Vector p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+ 0);
Primitive* prim = new SuperEllipsoid( matl, p, radius, alpha, beta );
if ( mapr )
prim->setTexCoordMapper( mapr );
@@ -211,9 +211,9 @@
Vector p2(scale/max, scale/max, scale/max);
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Point p((numx>1 ? i/static_cast<Real>(numx-1) - (Real)0.5 :
0)*scale*2,
- (numy>1 ? j/static_cast<Real>(numy-1) - (Real)0.5 :
0)*scale*2,
- 0);
+ Vector p((numx>1 ? i/static_cast<Real>(numx-1)-(Real)0.5 :
0)*scale*2,
+ (numy>1 ? j/static_cast<Real>(numy-1)-(Real)0.5 :
0)*scale*2,
+ 0);
Primitive* prim = new Cube( matl, p-p2, p+p2);
if ( mapr )
prim->setTexCoordMapper( mapr );
@@ -221,30 +221,30 @@
}
}
} else if(primtype == "sphere"){
- Primitive* prim = new Sphere(matl, Point(0,0,0), scale/max);
+ Primitive* prim = new Sphere(matl, Vector(0,0,0), scale/max);
if ( mapr )
prim->setTexCoordMapper( mapr );
spinprim = prim;
} else if(primtype == "box"){
- Point p2(scale/max/1.732, scale/max/1.732, scale/max/1.732);
- Primitive* prim = new Cube(matl, Point(-Vector(p2)), p2);
+ Vector p2(scale/max/1.732, scale/max/1.732, scale/max/1.732);
+ Primitive* prim = new Cube(matl, -p2, p2);
if ( mapr )
prim->setTexCoordMapper( mapr );
spinprim = prim;
} else if(primtype == "intersection"){
- Point p2(scale/max/1.414, scale/max/1.414, scale/max/1.414);
- Primitive* o1 = new Cube(matl, Point(-Vector(p2)), p2);
- Primitive* o2 = new Sphere(matl, Point(0,0,0), scale/max);
- SphericalMapper* map = new SphericalMapper(Point(0,0,0), scale/max);
+ Vector p2(scale/max/1.414, scale/max/1.414, scale/max/1.414);
+ Primitive* o1 = new Cube(matl, -p2, p2);
+ Primitive* o2 = new Sphere(matl, Vector(0,0,0), scale/max);
+ SphericalMapper* map = new SphericalMapper(Vector(0,0,0), scale/max);
o1->setTexCoordMapper( mapr ? mapr : map );
o2->setTexCoordMapper( mapr ? mapr : map );
spinprim = new Intersection(o1, o2);
} else if(primtype == "difference"){
- Point p2(scale/max/1.414, scale/max/1.414, scale/max/1.414);
- Primitive* o1 = new Cube(matl, Point(-Vector(p2)), p2);
- Primitive* o2 = new Sphere(matl, Point(0,0,0), scale/max);
+ Vector p2(scale/max/1.414, scale/max/1.414, scale/max/1.414);
+ Primitive* o1 = new Cube(matl, -p2, p2);
+ Primitive* o2 = new Sphere(matl, Vector(0,0,0), scale/max);
Real s = scale/max/(Real)1.414*2*(Real)(1+1.e-10);
- LinearMapper* map = new LinearMapper(Point(0,0,0),
+ LinearMapper* map = new LinearMapper(Vector(0,0,0),
Vector(s,0,0),
Vector(0,s,0),
Vector(0,0,s));
@@ -252,17 +252,20 @@
o2->setTexCoordMapper( mapr ? mapr : map );
spinprim = new Difference(o1, o2);
} else if (primtype == "disk") {
- Primitive* prim = new Disk(matl, Point(0.0, 0.0, 0.0), Vector(0.0, 0.0,
1.0), scale / max, Vector(1.0, 0.0, 0.0), 0.25 * M_PI, 1.75 * M_PI);
+ Primitive* prim = new Disk(matl, Vector(0, 0, 0), Vector(0, 0, 1),
+ scale / max, Vector(1, 0, 0),
+ 0.25 * M_PI, 1.75 * M_PI);
if ( mapr )
prim->setTexCoordMapper( mapr );
spinprim = prim;
} else if (primtype == "hemisphere") {
- Primitive* prim = new Hemisphere(matl, Point(0.0, 0.0, 0.0), scale /
max, Vector(0.0, 0.0, 1.0));
+ Primitive* prim = new Hemisphere(matl, Vector(0, 0, 0), scale / max,
+ Vector(0, 0, 1));
if ( mapr )
prim->setTexCoordMapper( mapr );
spinprim = prim;
} else if (primtype == "superellipsoid"){
- Primitive* prim = new SuperEllipsoid(matl, Point(0, 0, 0), scale / max,
0.5, 1.5);
+ Primitive* prim = new SuperEllipsoid(matl, Vector(0, 0, 0), scale / max,
0.5, 1.5);
if ( mapr )
prim->setTexCoordMapper( mapr );
spinprim = prim;
@@ -274,7 +277,7 @@
printf("error loading or reading ply file: %s\n",
modelName.c_str()); //would be better to throw an error.
group->add(model);
} else if (primtype == "heightfield") {
- Primitive* prim = new Heightfield(matl, "../sinc200x200.hf", Point(-0.2,
-0.2, 0.2), Point(0.2, 0.2, 0.4));
+ Primitive* prim = new Heightfield(matl, "../sinc200x200.hf",
Vector(-0.2, -0.2, 0.2), Vector(0.2, 0.2, 0.4));
if ( mapr )
prim->setTexCoordMapper( mapr );
group->add(prim);
@@ -286,8 +289,8 @@
if(arraytype == "spin"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((numx>1 ? i/static_cast<Real>(numx-1) - (Real)0.5 :
0)*scale*2,
- (numy>1 ? j/static_cast<Real>(numy-1) - (Real)0.5 :
0)*scale*2,
+ Vector p((numx>1 ? i/static_cast<Real>(numx-1)-(Real)0.5 :
0)*scale*2,
+ (numy>1 ? j/static_cast<Real>(numy-1)-(Real)0.5 :
0)*scale*2,
0);
Real a1 = i/static_cast<Real>(numx)*(Real)M_PI*2;
Real a2 = j/static_cast<Real>(numy)*(Real)M_PI*2;
@@ -302,8 +305,8 @@
} else if(arraytype == "shift"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((numx>1 ? i/static_cast<Real>(numx-1) - (Real)0.5 :
0)*scale*2,
- (numy>1 ? j/static_cast<Real>(numy-1) - (Real)0.5 :
0)*scale*2,
+ Vector p((numx>1 ? i/static_cast<Real>(numx-1)-(Real)0.5 :
0)*scale*2,
+ (numy>1 ? j/static_cast<Real>(numy-1)-(Real)0.5 :
0)*scale*2,
0);
group->add(new InstanceT(spinprim, p));
}
@@ -311,8 +314,8 @@
} else if(arraytype == "scale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((numx>1 ? i/static_cast<Real>(numx-1) - (Real)0.5 :
0)*scale*2,
- (numy>1 ? j/static_cast<Real>(numy-1) - (Real)0.5 :
0)*scale*2,
+ Vector p((numx>1 ? i/static_cast<Real>(numx-1)-(Real)0.5 :
0)*scale*2,
+ (numy>1 ? j/static_cast<Real>(numy-1)-(Real)0.5 :
0)*scale*2,
0);
int idx = j*numx+i;
Real scale = (idx+1)/static_cast<Real>(numx*numy);
@@ -322,8 +325,8 @@
} else if(arraytype == "nuscale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((numx>1 ? i/static_cast<Real>(numx-1) - (Real)0.5 :
0)*scale*2,
- (numy>1 ? j/static_cast<Real>(numy-1) - (Real)0.5 :
0)*scale*2,
+ Vector p((numx>1 ? i/static_cast<Real>(numx-1)-(Real)0.5 :
0)*scale*2,
+ (numy>1 ? j/static_cast<Real>(numy-1)-(Real)0.5 :
0)*scale*2,
0);
Real xscale = (i+1)/static_cast<Real>(numx);
Real yscale = (j+1)/static_cast<Real>(numy);
@@ -333,8 +336,8 @@
} else if(arraytype == "spinscale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((numx>1 ? i/static_cast<Real>(numx-1) - (Real)0.5 :
0)*scale*2,
- (numy>1 ? j/static_cast<Real>(numy-1) - (Real)0.5 :
0)*scale*2,
+ Vector p((numx>1 ? i/static_cast<Real>(numx-1)-(Real)0.5 :
0)*scale*2,
+ (numy>1 ? j/static_cast<Real>(numy-1)-(Real)0.5 :
0)*scale*2,
0);
Real a1 = i/static_cast<Real>(numx)*(Real)M_PI*2;
Real a2 = j/static_cast<Real>(numy)*(Real)M_PI*2;
@@ -352,8 +355,8 @@
} else if(arraytype == "spinscale2"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
- Vector p((numx>1 ? i/static_cast<Real>(numx-1) - (Real)0.5 :
0)*scale*2,
- (numy>1 ? j/static_cast<Real>(numy-1) - (Real)0.5 :
0)*scale*2,
+ Vector p((numx>1 ? i/static_cast<Real>(numx-1)-(Real)0.5 :
0)*scale*2,
+ (numy>1 ? j/static_cast<Real>(numy-1)-(Real)0.5 :
0)*scale*2,
0);
Real a1 = i/static_cast<Real>(numx)*(Real)M_PI*2;
Real a2 = j/static_cast<Real>(numy)*(Real)M_PI*2;
@@ -378,7 +381,7 @@
Vector(1,0,0)*numx*2,
Vector(0,1,0)*numy*2));
- group->add(new Parallelogram(bgmatl, Point(-scale-1./max, -scale-1./max,
-1.5/max),
+ group->add(new Parallelogram(bgmatl, Vector(-scale-1./max,
-scale-1./max, -1.5/max),
Vector(scale*2+2./max, 0, 0), Vector(0,
scale*2+2./max, 0)));
}
Scene* scene = new Scene();
@@ -388,7 +391,7 @@
scene->setObject(group);
LightSet* lights = new LightSet();
- lights->add(new PointLight(Point(5,5,8), Color(RGB(1,1,1))*2));
+ lights->add(new PointLight(Vector(5,5,8), Color(RGB(1,1,1))*2));
Color cup(RGB(0.1, 0.3, 0.8));
Color cdown(RGB(0.82, 0.62, 0.62));
Vector up(0,1,0);
Modified: trunk/scenes/volume.cc
==============================================================================
--- trunk/scenes/volume.cc (original)
+++ trunk/scenes/volume.cc Thu Feb 16 17:08:22 2006
@@ -5,7 +5,7 @@
// June 2005.
-#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/Vector.h>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Util/Args.h>
#include <Interface/Context.h>
@@ -46,7 +46,7 @@
string file_name;
string tf_name;
- Point plane_point;
+ Vector plane_point;
Vector plane_normal;
CuttingPlaneType cutting_type = CUTTING_NONE;
@@ -70,7 +70,7 @@
}
else if (args[i] == "-cutting") {
string cutting_string;
- if (getPointArg(i, args, plane_point ) &&
getVectorArg(i, args, plane_normal)) {
+ if (getVectorArg(i, args, plane_point ) &&
getVectorArg(i, args, plane_normal)) {
cutting_type = CUTTING_SPECIFIED;
}
else if (getStringArg(i, args, cutting_string) &&
cutting_string == "default") {
@@ -132,8 +132,8 @@
// Set other important scene properties.
PinholeCamera *camera = new PinholeCamera(
- PointT<Real,3>(bounds.max[0]/2, bounds.max[1]/2,
bounds.max[2]*2),
- PointT<Real,3>(bounds.max[0]/2, bounds.max[1]/2, 0),
+ Vector(bounds.max[0]/2, bounds.max[1]/2,
bounds.max[2]*2),
+ Vector(bounds.max[0]/2, bounds.max[1]/2, 0),
Vector(0,1,0), 50.0 );
// Background.
Modified: trunk/tests/perftest/perftest1.cc
==============================================================================
--- trunk/tests/perftest/perftest1.cc (original)
+++ trunk/tests/perftest/perftest1.cc Thu Feb 16 17:08:22 2006
@@ -24,7 +24,7 @@
main()
{
LightSet lights;
- lights.add(new PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1))));
+ lights.add(new PointLight(Vector(0,5,8), Color(RGBColor(.6,.1,.1))));
lights.setAmbientLight(new ConstantAmbient(Color::black()));
Color x = Color(RGBColor(1,1,1));
@@ -37,7 +37,7 @@
NoShadows shadows(noargs);
//HardShadows shadows(noargs);
- Sphere s(&p, Point(0, 0, 0), 1);
+ Sphere s(&p, Vector(0, 0, 0), 1);
Scene scene;
scene.setObject(&s);
@@ -49,7 +49,7 @@
rays.resetHit();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- e.ray = Ray(Point(0, 0, 10), Vector(0, 0, 1));
+ e.ray = Ray(Vector(0, 0, 10), Vector(0, 0, 1));
e.hitInfo.hit(9, &p, &s, 0);
}
- [MANTA] r939 - in trunk: . Core Core/Geometry Core/Math Core/Util Engine/Shadows Interface Model/AmbientLights Model/Backgrounds Model/Cameras Model/Groups Model/Instances Model/Intersections Model/Lights Model/Materials Model/MiscObjects Model/Primitives Model/Readers Model/Readers/BART Model/TexCoordMappers Model/Textures StandAlone SwigInterface UserInterface fox/FManta fox/afr_demo/Engine/ImageTraversers fox/afr_demo/Model/Cameras fox/afr_demo/StandAlone fox/disco_demo/Engine/Renderers fox/disco_demo/Engine/Shaders fox/disco_demo/Interface fox/dm_demo fox/sc_demo scenes tests/perftest, bigler, 02/16/2006
Archive powered by MHonArc 2.6.16.