G3D::Vector3 gluUnProject ( GLdouble model[16], GLdouble proj[16], GLint view[4], G3D::Vector2 windowCoord, GluUnProjectZOperation::Enum zOperation) { GLfloat zWindowCoord = 0; if (zOperation == GluUnProjectZOperation::READ) glReadPixels (windowCoord.x, windowCoord.y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &zWindowCoord); else zWindowCoord = 0; double x = 0, y = 0, z = 0; GLint ret = gluUnProject (windowCoord.x, windowCoord.y, zWindowCoord, model, proj, view, &x, &y, &z); G3D::Vector3 v = G3D::Vector3 ( x, y, zOperation == GluUnProjectZOperation::READ ? z : 0); if (ret != GLU_TRUE) { cdbg << "model: "; for (size_t i = 0; i < 16; ++i) cdbg << model[i] << " "; cdbg << endl << "projection: "; for (size_t i = 0; i < 16; ++i) cdbg << proj[i] << " "; cdbg << endl << "viewport: "; for (size_t i = 0; i < 4; ++i) cdbg << view[i] << " "; cdbg << endl; WarnOnOpenGLError ("gluUnProject"); RuntimeAssert (false, "gluUnproject: ", v, " zOp:", zOperation); } __LOG__( cdbg << windowCoord << ", " << zWindowCoord << ", " << v << endl;) return v;
static void my_main (const char * theFileName){ LogicAssert (true == IsGoodPtr (theFileName)); LogicAssert (std::strlen (theFileName) > 0); ISI_DUMP (theFileName); #if 1 CellValue kCellValue [kDim * kDim]={ 0 }; LoadCellValuesFromFile (theFileName, kCellValue); #else const CellValue kCellValue [kDim * kDim]={ 0, 0, 6, 0, 5, 0, 8, 0, 2, 0, 0, 8, 0, 0, 4, 5, 0, 9, 0, 5, 7, 0, 8, 2, 3, 0, 0, 1, 0, 0, 0, 6, 0, 0, 5, 0, 0, 8, 5, 0, 0, 3, 0, 2, 6, 6, 4, 0, 0, 0, 0, 0, 0, 7, 0, 0, 9, 1, 0, 0, 6, 0, 0, 5, 0, 1, 8, 0, 0, 2, 0, 0, 0, 0, 4, 0, 3, 0, 7, 0, 0 }; #endif Cell aCell [kDim * kDim]; for (std::size_t aIter = 0; aIter < kDim * kDim; ++aIter){ if (0 != kCellValue [aIter]){ LogicAssert(IsInCRange <std::size_t>(0, aIter, IG_DIM_OF_ARRAY(kCellValue))); LogicAssert(IsInCRange <std::size_t>(0, aIter, IG_DIM_OF_ARRAY(aCell))); aCell [aIter].SetInitValue (kCellValue [aIter]); } } ISI_DUMP (std::count_if (aCell, aCell + kDim * kDim, IsInitValue)); // alias of rows MatrixOfCellPtr aRow (kDim); std::size_t i = 0; std::size_t j = 0; for (j = 0; j < kDim; ++j){ for (i = 0; i < kDim; ++i){ LogicAssert(IsInCRange <std::size_t>(0, i + j*kDim, IG_DIM_OF_ARRAY(aCell))); aRow [j].push_back(&aCell [i + j*kDim]); } } isi::DumpMatrix ("aRow", aRow); // alias of columns MatrixOfCellPtr aCol (kDim); for (j = 0; j < kDim; ++j){ for (i = 0; i < kDim; ++i){ LogicAssert(IsInCRange <std::size_t>(0, i + j*kDim, IG_DIM_OF_ARRAY(aCell))); aCol [i].push_back(&aCell [i + j*kDim]); } } // alias of square MatrixOfCellPtr aSqr (kDim); const std::size_t aTransform [kDim][3] = { // it would be interesting automagically create this matrix at compile time, using meta programming {0, 0, 0}, {1, 0, 3}, {2, 0, 6}, {3, 3, 0}, {4, 3, 3}, {5, 3, 6}, {6, 6, 0}, {7, 6, 3}, {8, 6, 6} }; for (j = 0; j < kDim; ++j){ std::size_t aIndex = 0; for (std::size_t a = aTransform [j][1]; a < aTransform [j][1] + 3; ++a){ for (std::size_t b = aTransform [j][2]; b < aTransform [j][2] + 3; ++b){ LogicAssert(IsInCRange <std::size_t>(0, a, kDim)); LogicAssert(IsInCRange <std::size_t>(0, b, kDim)); LogicAssert(IsInCRange <std::size_t>(0, j, kDim)); LogicAssert(IsInCRange <std::size_t>(0, aIndex, kDim)); aSqr [j].push_back (aRow [a] [b]); ++aIndex; } } } #ifdef _DEBUG isi::DumpMatrix ("aCol", aCol); isi::DumpMatrix ("aSqr", aSqr); #endif MatrixOfCellPtr aSchema []={ aRow, aCol, aSqr }; RuntimeAssert (true == IsGoodSchema (aSchema)); (void) isi::HandleNextRecursive (0, aCell, aSchema); isi::ISI_DUMP (isi::gNumOfCall); isi::ISI_DUMP (isi::gNumOfSolution); }
void DataProperties::SetDimension (size_t dimension) { RuntimeAssert (dimension == 2 || dimension == 3, "Invalid space dimension: ", dimension); m_dimension = Dimension::Enum (dimension); }