Commit 89fa45b0 authored by Kirill Terekhov's avatar Kirill Terekhov

Rename OldDrawGrid -> DrawGrid

DrawGrid -> DrawGridTests
parent 56273402
if(USE_MESH)
add_subdirectory(AdaptiveMesh)
add_subdirectory(DrawGrid)
add_subdirectory(OldDrawGrid)
add_subdirectory(DrawGridTests)
add_subdirectory(GridGen)
add_subdirectory(GridTools)
endif(USE_MESH)
......
project(DrawGrid)
set(SOURCE main.cpp
rotate.cpp
rotate.h
my_glut.h)
rotate.cpp
clipboard.cpp
rotate.h
inc_glut.h
clipboard.h
color.h
coord.h
coord.cpp
octree.h
streamline.h
streamline.cpp
svg_line.h
svg_line.cpp
face2gl.h
face2gl.cpp
color_bar.h
color_bar.cpp
printtext.cpp
tga.h
tga.cpp
screenshot.h
screenshot.cpp
volumetric.h
volumetric.cpp
input.h
input.cpp
picker.h
picker.cpp
clipper.h
clipper.cpp
vector.h
vector.cpp)
find_package(OpenGL)
find_package(GLUT)
if(OPENGL_FOUND)
if(GLUT_FOUND)
message("linking DrawGrid with GLUT and OpenGL")
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLUT_INCLUDE_DIR})
add_executable(DrawGrid ${SOURCE})
target_link_libraries(DrawGrid inmost ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
if(USE_MPI)
target_link_libraries(DrawGrid ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(DrawGrid PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS DrawGrid EXPORT inmost-targets RUNTIME DESTINATION bin)
else(GLUT_FOUND)
message("GLUT not found, not building DrawGrid")
endif(GLUT_FOUND)
if(GLUT_FOUND)
message("linking DrawGrid with GLUT and OpenGL")
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLUT_INCLUDE_DIR})
add_executable(DrawGrid ${SOURCE})
target_link_libraries(DrawGrid inmost ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
if(USE_MPI)
target_link_libraries(DrawGrid ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(DrawGrid PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS DrawGrid EXPORT inmost-targets RUNTIME DESTINATION bin)
else(GLUT_FOUND)
message("GLUT not found, not building DrawGrid")
endif(GLUT_FOUND)
else(OPENGL_FOUND)
message("OpenGL not found, not building DrawGrid")
message("OpenGL not found, not building DrawGrid")
endif(OPENGL_FOUND)
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -14,9 +14,10 @@
Specific: glut.h
**********************************/
#include "my_glut.h"
#include "inc_glut.h"
#include "rotate.h"
#include "math.h"
#include <vector>
struct quaternion
{
......@@ -32,15 +33,16 @@ struct vector
struct quaternion q;
struct vector drag, onclick;
double mx,my;
extern int width, height;
extern int interactive;
//
std::vector<quaternion> storage;
void clickmotion(int nmx, int nmy) // Mouse
{
struct vector n;
double norm,length,t;
int width = glutGet(GLUT_WINDOW_WIDTH);
int height = glutGet(GLUT_WINDOW_HEIGHT);
mx = 2.*(nmx/(double)width - 0.5);
my = 2.*(0.5 - nmy/(double)height);
norm = mx*mx + my*my;
......@@ -75,12 +77,16 @@ void clickmotion(int nmx, int nmy) // Mouse
}
void motion(int nmx, int nmy) // Mouse
{
int width = glutGet(GLUT_WINDOW_WIDTH);
int height = glutGet(GLUT_WINDOW_HEIGHT);
mx = 2.*(nmx/(double)width - 0.5);
my = 2.*(0.5 - nmy/(double)height);
}
void click(int b, int s, int nmx, int nmy) // Mouse
{
double norm,length;
int width = glutGet(GLUT_WINDOW_WIDTH);
int height = glutGet(GLUT_WINDOW_HEIGHT);
switch(b)
{
case GLUT_LEFT_BUTTON:
......@@ -119,6 +125,20 @@ void quatinit()
q.w = 1.0;
}
void quatpush()
{
storage.push_back(q);
}
void quatpop()
{
if( !storage.empty() )
{
q = storage.back();
storage.pop_back();
}
}
void rotatevector(double * vec)
{
int i;
......@@ -153,6 +173,163 @@ void rotatevector(double * vec)
vec[2] = ret[2]/ret[3];
}
void reverse_rotatevector(double * vec)
{
int i;
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
}
void revrotatevector(double * vec)
{
int i;
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
q.w = -q.w;
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
q.w = -q.w;
}
void rotatevector_from_stack(double * vec)
{
int i;
struct quaternion q = storage.back();
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
}
void quatget(double *vec)
{
vec[0] = q.x / q.w;
vec[1] = q.y / q.w;
vec[2] = q.z / q.w;
}
void reverse_rotatevector_from_stack(double * vec)
{
int i;
struct quaternion q = storage.back();
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
}
void rotate()
{
double rot[16];
......@@ -175,3 +352,27 @@ void rotate()
glMultMatrixd(rot);
}
void rotate_from_stack()
{
double rot[16];
struct quaternion q = storage.back();
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
glMultMatrixd(rot);
}
......@@ -20,8 +20,16 @@
void clickmotion(int nmx, int nmy);
void motion(int nmx, int nmy);
void click(int b, int s, int nmx, int nmy);
void quatget(double * vec);
void quatinit();
void quatpush();
void quatpop();
void rotate();
void rotate_from_stack();
void rotatevector(double * vec);
void reverse_rotatevector(double * vec);
void revrotatevector(double * vec);
void rotatevector_from_stack(double * vec);
void reverse_rotatevector_from_stack(double * vec);
#endif
project(DrawGridTests)
set(SOURCE main.cpp
rotate.cpp
rotate.h
my_glut.h)
find_package(OpenGL)
find_package(GLUT)
if(OPENGL_FOUND)
if(GLUT_FOUND)
message("linking DrawGridTests with GLUT and OpenGL")
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLUT_INCLUDE_DIR})
add_executable(DrawGridTests ${SOURCE})
target_link_libraries(DrawGridTests inmost ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
if(USE_MPI)
target_link_libraries(DrawGridTests ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(DrawGridTests PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS DrawGridTests EXPORT inmost-targets RUNTIME DESTINATION bin)
else(GLUT_FOUND)
message("GLUT not found, not building DrawGridTests")
endif(GLUT_FOUND)
else(OPENGL_FOUND)
message("OpenGL not found, not building DrawGridTests")
endif(OPENGL_FOUND)
This diff is collapsed.
......@@ -14,10 +14,9 @@
Specific: glut.h
**********************************/
#include "inc_glut.h"
#include "my_glut.h"
#include "rotate.h"
#include "math.h"
#include <vector>
struct quaternion
{
......@@ -33,16 +32,15 @@ struct vector
struct quaternion q;
struct vector drag, onclick;
double mx,my;
extern int width, height;
extern int interactive;
//
std::vector<quaternion> storage;
void clickmotion(int nmx, int nmy) // Mouse
{
struct vector n;
double norm,length,t;
int width = glutGet(GLUT_WINDOW_WIDTH);
int height = glutGet(GLUT_WINDOW_HEIGHT);
mx = 2.*(nmx/(double)width - 0.5);
my = 2.*(0.5 - nmy/(double)height);
norm = mx*mx + my*my;
......@@ -77,16 +75,12 @@ void clickmotion(int nmx, int nmy) // Mouse
}
void motion(int nmx, int nmy) // Mouse
{
int width = glutGet(GLUT_WINDOW_WIDTH);
int height = glutGet(GLUT_WINDOW_HEIGHT);
mx = 2.*(nmx/(double)width - 0.5);
my = 2.*(0.5 - nmy/(double)height);
}
void click(int b, int s, int nmx, int nmy) // Mouse
{
double norm,length;
int width = glutGet(GLUT_WINDOW_WIDTH);
int height = glutGet(GLUT_WINDOW_HEIGHT);
switch(b)
{
case GLUT_LEFT_BUTTON:
......@@ -125,20 +119,6 @@ void quatinit()
q.w = 1.0;
}
void quatpush()
{
storage.push_back(q);
}
void quatpop()
{
if( !storage.empty() )
{
q = storage.back();
storage.pop_back();
}
}
void rotatevector(double * vec)
{
int i;
......@@ -173,163 +153,6 @@ void rotatevector(double * vec)
vec[2] = ret[2]/ret[3];
}
void reverse_rotatevector(double * vec)
{
int i;
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
}
void revrotatevector(double * vec)
{
int i;
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
q.w = -q.w;
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
q.w = -q.w;
}
void rotatevector_from_stack(double * vec)
{
int i;
struct quaternion q = storage.back();
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
}
void quatget(double *vec)
{
vec[0] = q.x / q.w;
vec[1] = q.y / q.w;
vec[2] = q.z / q.w;
}
void reverse_rotatevector_from_stack(double * vec)
{
int i;
struct quaternion q = storage.back();
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{