Commit a3e1505b authored by Kirill Terekhov's avatar Kirill Terekhov

Fix and updates

Remove warnings in visual studio in modify.cpp and SolverInner.cpp

Improve output in OldDrawGrid example.

Fix compilation problem reported by Vasily Kramarenko.
parent 5c461dc9
......@@ -662,9 +662,11 @@ void screenshot()
width *= tiles;
height *= tiles;
char * pixelbuffer = new char[width*height*3+oldwidth*oldheight*3];
char * tempbuffer = pixelbuffer + width*height*3;
char * vpixelbuffer = new char[width*height*3+oldwidth*oldheight*3];
assert(vpixelbuffer);
char * vtempbuffer = vpixelbuffer + width*height*3;
shell<char> pixelbuffer(vpixelbuffer, width*height * 3);
shell<char> tempbuffer(vtempbuffer, oldwidth*oldheight * 3);
......@@ -675,7 +677,7 @@ void screenshot()
glViewport(-oldwidth*i,-oldheight*j,width,height);
draw_screen();
glReadBuffer(GL_BACK);
glReadPixels(0,0,oldwidth,oldheight,GL_BGR_EXT,GL_UNSIGNED_BYTE,tempbuffer);
glReadPixels(0,0,oldwidth,oldheight,GL_BGR_EXT,GL_UNSIGNED_BYTE,vtempbuffer);
int koff = oldwidth*(i);
int loff = oldheight*(j);
......@@ -703,8 +705,8 @@ void screenshot()
write_tga("screenshot.tga",width,height,pixelbuffer);
delete [] pixelbuffer;
write_tga("screenshot.tga",width,height,vpixelbuffer);
delete [] vpixelbuffer;
width = oldwidth;
height = oldheight;
glViewport(0,0,width,height);
......@@ -3534,7 +3536,7 @@ public:
bool Canceled() {return canceled;}
void Draw()
{
float h = 24.0f/(float)height;
float h = 26.0f/(float)height;
glColor3f(1,1,1);
glBegin(GL_QUADS);
......@@ -3552,7 +3554,7 @@ public:
glEnd();
glColor4f(0,0,0,1);
glRasterPos2d(-0.985,-0.985);
glRasterPos2d(-0.985,-0.98);
//printtext(str.c_str());
char oldval[4096];
if( type == Double ) sprintf(oldval,"%g",*(double*)input_link);
......@@ -3941,7 +3943,7 @@ face2gl DrawFace(Element f)
return ret;
}
void DrawElement(Element e, color_t face, color_t edge, color_t node)
void DrawElement(Element e, color_t face, color_t edge, color_t node, double campos[3])
{
if( e.GetElementType() == NODE )
{
......@@ -3981,27 +3983,48 @@ void DrawElement(Element e, color_t face, color_t edge, color_t node)
glEnd();
node.set_color();
ElementArray<Node> nodes = e->getNodes();
ElementArray<Edge> edges = e->getEdges();
glBegin(GL_POINTS);
for(ElementArray<Node>::iterator it = nodes.begin(); it != nodes.end(); ++it)
glVertex3dv(it->Coords().data());
glEnd();
glColor3f(0, 0, 0);
//glDisable(GL_DEPTH_TEST);
for (ElementArray<Edge>::iterator it = edges.begin(); it != edges.end(); ++it)
{
double cnt[3];
it->Centroid(cnt);
//for (int k = 0; k < 3; ++k) cnt[k] = cnt[k] * 0.99 + campos[k] * 0.01;
glRasterPos3dv(cnt);
printtext("%d", it->LocalID());
}
//glEnable(GL_DEPTH_TEST);
}
else if( e.GetElementType() == CELL )
{
ElementArray<Face> dfaces = e.getFaces();
face.set_color();
glBegin(GL_TRIANGLES);
for(ElementArray<Face>::iterator it = dfaces.begin(); it != dfaces.end
(); ++it)
for(ElementArray<Face>::iterator it = dfaces.begin(); it != dfaces.end(); ++it)
{
face2gl f = DrawFace(it->self());
f.draw();
}
glEnd();
glColor3f(0, 0, 0);
//glDisable(GL_DEPTH_TEST);
for (ElementArray<Face>::iterator it = dfaces.begin(); it != dfaces.end(); ++it)
{
double cnt[3];
it->Centroid(cnt);
//for (int k = 0; k < 3; ++k) cnt[k] = cnt[k] * 0.99 + campos[k] * 0.01;
glRasterPos3dv(cnt);
printtext("%d", it->LocalID());
}
//glEnable(GL_DEPTH_TEST);
edge.set_color();
glBegin(GL_LINES);
for(ElementArray<Face>::iterator it = dfaces.begin(); it != dfaces.end
(); ++it)
for(ElementArray<Face>::iterator it = dfaces.begin(); it != dfaces.end(); ++it)
{
face2gl f = DrawFace(it->self());
f.drawedges();
......@@ -4084,13 +4107,15 @@ double display_elem_info(Element e, double top, double left, double interval)
set_matrix2d();
glColor3f(1,1,1);
glColor4f(1,1,1,0.45);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glVertex2f(left-0.01,bottom-0.01);
glVertex2f(left-0.01,top-0.01);
glVertex2f(0.99,top-0.01);
glVertex2f(0.99,bottom-0.01);
glEnd();
glDisable(GL_BLEND);
glColor3f(0,0,0);
glBegin(GL_LINE_LOOP);
glVertex2f(left-0.01,bottom-0.01);
......@@ -4203,7 +4228,7 @@ double display_elem_info(Element e, double top, double left, double interval)
}
}
glEnable(GL_DEPTH_TEST);
return top;
return top-2*interval;
}
void draw_screen()
......@@ -4267,7 +4292,7 @@ void draw_screen()
double campos[3] = {0.5,0.5,0}, pickp[3], pickd[3];
whereami(campos[0],campos[1],campos[2]);
whereami(campos[0], campos[1], campos[2]);
int picked = -1;
......@@ -4476,10 +4501,10 @@ void draw_screen()
if( draw_orphan )
for(int k = 0; k < (int)orphans.size(); ++k)
DrawElement(orphans[k],color_t(1,0,1),color_t(0,1,1),color_t(0,0,1));
DrawElement(orphans[k],color_t(1,0,1),color_t(0,1,1),color_t(0,0,1),campos);
if( disp_e.isValid() && disp_e.GetElementType() != ESET)
DrawElement(disp_e,color_t(1,1,0),color_t(1,0,0),color_t(0,0,1));
DrawElement(disp_e,color_t(1,1,0),color_t(1,0,0),color_t(0,0,1),campos);
double top = 0.96;
......
......@@ -813,6 +813,11 @@ namespace INMOST
/// @param pm Number of columns.
/// \warning The matrix does not necessery have zero entries.
Matrix(enumerator pn, enumerator pm) : space(pn*pm), n(pn), m(pm) {}
/// Construct a matrix with provided sizes and fills with value.
/// @param pn Number of rows.
/// @param pm Number of columns.
/// @param c Value to fill the matrix.
Matrix(enumerator pn, enumerator pm, const Var & c) : space(pn*pm,c), n(pn), m(pm) {}
/// Copy matrix.
/// @param other Another matrix of the same type.
Matrix(const Matrix & other) : space(other.space), n(other.n), m(other.m)
......@@ -1103,16 +1108,34 @@ namespace INMOST
return ret;
}
/// Unit matrix. Creates a square matrix of size pn by pn
/// and fills the diagonal with ones.
/// and fills the diagonal with c.
/// @param pn Number of rows and columns in the matrix.
/// @param c Value to put onto diagonal.
/// @return Returns a unit matrix.
static Matrix Unit(enumerator pn)
static Matrix Unit(enumerator pn, const Var & c = 1.0)
{
Matrix ret(pn,pn);
ret.Zero();
for(enumerator i = 0; i < pn; ++i) ret(i,i) = 1.0;
Matrix ret(pn,pn,0.0);
for(enumerator i = 0; i < pn; ++i) ret(i,i) = c;
return ret;
}
/// Matix with 1 row, Create a matrix of size 1 by pn and
/// fills it with c.
/// @param pn Number of columns.
/// @param c Value to fill the matrix.
/// @return Returns a matrix with 1 row.
static Matrix Row(enumerator pn, const Var & c = 1.0)
{
return Matrix(1,pn,c);
}
/// Matix with 1 column, Create a matrix of size pn by 1 and
/// fills it with c.
/// @param pn Number of rows.
/// @param c Value to fill the matrix.
/// @return Returns a matrix with 1 column.
static Matrix Col(enumerator pn, const Var & c = 1.0)
{
return Matrix(pn, 1, c);
}
/// Concatenate B matrix as columns of current matrix.
/// Assumes that number of rows of current matrix is
/// equal to number of rows of B matrix.
......@@ -1255,6 +1278,8 @@ namespace INMOST
/// @param last_col Last column (excluded) in the original matrix.
/// @return Submatrix of the original matrix.
::INMOST::SubMatrix<Var,storage_type> operator()(enumerator first_row, enumerator last_row, enumerator first_col, enumerator last_col);
const ::INMOST::SubMatrix<Var, storage_type> operator()(enumerator first_row, enumerator last_row, enumerator first_col, enumerator last_col) const;
};
/// This class allows for in-place operations on submatrix of the matrix elements.
template<typename Var, typename Storage>
......@@ -1338,7 +1363,7 @@ namespace INMOST
/// not affect elements of the submatrix or original matrix
/// used to create submatrix.
/// @return Matrix with same entries as submatrix.
Matrix<Var> Matrix()
::INMOST::Matrix<Var> MakeMatrix()
{
::INMOST::Matrix<Var> ret(Rows(),Cols());
for(enumerator i = 0; i < Rows(); ++i)
......@@ -1753,6 +1778,11 @@ namespace INMOST
{
return ::INMOST::SubMatrix<Var,storage_type>(*this,first_row,last_row,first_col,last_col);
}
template<typename Var, typename storage_type>
const SubMatrix<Var, storage_type> Matrix<Var, storage_type>::operator()(enumerator first_row, enumerator last_row, enumerator first_col, enumerator last_col) const
{
return ::INMOST::SubMatrix<Var, storage_type>(*this, first_row, last_row, first_col, last_col);
}
/// shortcut for matrix of real values.
typedef Matrix<INMOST_DATA_REAL_TYPE> rMatrix;
#if defined(USE_AUTODIFF)
......
......@@ -226,9 +226,9 @@ namespace INMOST
m->ReleaseMarker(visited);
if( doexit )
{
m->RemMarkerArray(inner_faces.data(),inner_faces.size(),rem);
m->RemMarkerArray(edges.data(),edges.size(),rem);
m->RemMarkerArray(nodes.data(),nodes.size(),rem);
m->RemMarkerArray(inner_faces.data(),(enumerator)inner_faces.size(),rem);
m->RemMarkerArray(edges.data(), (enumerator)edges.size(), rem);
m->RemMarkerArray(nodes.data(), (enumerator)nodes.size(), rem);
m->ReleaseMarker(rem);
return Cell(m,InvalidHandle());
}
......@@ -380,8 +380,8 @@ namespace INMOST
doexit = true;
}
for(tiny_map<HandleType,int,64>::iterator it = face_visit.begin(); it != face_visit.end(); it++) m->RemMarker(it->first,rem);
m->RemMarkerArray(edges.data(),edges.size(),rem);
m->RemMarkerArray(nodes.data(),nodes.size(),rem);
m->RemMarkerArray(edges.data(), (enumerator)edges.size(),rem);
m->RemMarkerArray(nodes.data(), (enumerator)nodes.size(), rem);
m->ReleaseMarker(rem);
if( doexit ) return false;
return true;
......@@ -415,7 +415,7 @@ namespace INMOST
}
}
}
m->RemMarkerArray(cells.data(),cells.size(),edge_set);
m->RemMarkerArray(cells.data(), (enumerator)cells.size(), edge_set);
assert(cells.size() <= 2);
//check is there a topological problem
//new face should be adjacent to no more then two cells
......@@ -497,7 +497,7 @@ namespace INMOST
m->RemMarker(it->first,rem);
m->RemMarker(it->first,edge_set);
}
m->RemMarkerArray(nodes.data(),nodes.size(),rem);
m->RemMarkerArray(nodes.data(), (enumerator)nodes.size(), rem);
m->ReleaseMarker(edge_set);
m->ReleaseMarker(rem);
assert( !dothrow ); //report the situation, because user need to debug the input
......@@ -696,7 +696,7 @@ namespace INMOST
m->SetMarker(hc[it],rem);
}
}
m->RemMarkerArray(cells.data(),cells.size(),rem);
m->RemMarkerArray(cells.data(), (enumerator)cells.size(), rem);
dynarray<HandleType,64> nodes;
tiny_map<HandleType, int,64> edge_visit;
for(ElementArray<Face>::size_type j = 0; j < unite.size(); j++)
......@@ -793,7 +793,7 @@ namespace INMOST
}
}
m->RemMarkerArray(cells.data(),cells.size(),rem);
m->RemMarkerArray(cells.data(), (enumerator)cells.size(), rem);
......@@ -872,7 +872,7 @@ namespace INMOST
if( doexit )
{
m->RemMarkerArray(edges.data(),edges.size(),rem);
m->RemMarkerArray(edges.data(), (enumerator)edges.size(), rem);
m->ReleaseMarker(rem);
assert(!dothrow);
//if( dothrow ) throw Impossible; // bad input
......
#define _CRT_SECURE_NO_WARNINGS
#include "SolverInner.h"
namespace INMOST {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment