Skip to content
Snippets Groups Projects
Commit 2862f8c8 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

pp

parent de99432e
No related branches found
No related tags found
No related merge requests found
// $Id: Post.cpp,v 1.130 2007-09-11 13:54:35 geuzaine Exp $ // $Id: Post.cpp,v 1.131 2007-09-13 06:57:21 geuzaine Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -1130,43 +1130,35 @@ void drawGlyphs(PView *p) ...@@ -1130,43 +1130,35 @@ void drawGlyphs(PView *p)
} }
} }
// We try to estimate how many primitives will end up in the vertex class initPView {
// arrays, since reallocating the arrays takes a HUGE amount of time private:
// on Windows/Cygwin. A better way would be to slightly redesign the // we try to estimate how many primitives will end up in the vertex
// drawing routines so we can have different pre-processing steps // arrays, since reallocating the arrays takes a huge amount of time
// (like the one we have for smooth normals right now), in order to // on Windows/Cygwin
// count how many primitives we will have. int _estimateNumPoints(PView *p)
static int estimateNumPoints(PView *p)
{ {
PViewData *data = p->getData(); PViewData *data = p->getData();
PViewOptions *opt = p->getOptions(); PViewOptions *opt = p->getOptions();
int heuristic = data->getNumElements(PViewData::Point); int heuristic = data->getNumElements(PViewData::Point);
return heuristic + 10000; return heuristic + 10000;
} }
int _estimateNumLines(PView *p)
static int estimateNumLines(PView *p)
{ {
PViewData *data = p->getData(); PViewData *data = p->getData();
PViewOptions *opt = p->getOptions(); PViewOptions *opt = p->getOptions();
int heuristic = data->getNumElements(PViewData::Line); int heuristic = data->getNumElements(PViewData::Line);
return heuristic + 10000; return heuristic + 10000;
} }
int _estimateNumTriangles(PView *p)
static int estimateNumTriangles(PView *p)
{ {
PViewData *data = p->getData(); PViewData *data = p->getData();
PViewOptions *opt = p->getOptions(); PViewOptions *opt = p->getOptions();
int tris = data->getNumElements(PViewData::Triangle); int tris = data->getNumElements(PViewData::Triangle);
int quads = data->getNumElements(PViewData::Quadrangle); int quads = data->getNumElements(PViewData::Quadrangle);
int tets = data->getNumElements(PViewData::Tetrahedron); int tets = data->getNumElements(PViewData::Tetrahedron);
int prisms = data->getNumElements(PViewData::Prism); int prisms = data->getNumElements(PViewData::Prism);
int pyrs = data->getNumElements(PViewData::Pyramid); int pyrs = data->getNumElements(PViewData::Pyramid);
int hexas = data->getNumElements(PViewData::Hexahedron); int hexas = data->getNumElements(PViewData::Hexahedron);
int heuristic = 0; int heuristic = 0;
if(opt->IntervalsType == PViewOptions::Iso) if(opt->IntervalsType == PViewOptions::Iso)
heuristic = (tets + prisms + pyrs + hexas) / 10; heuristic = (tets + prisms + pyrs + hexas) / 10;
...@@ -1176,21 +1168,15 @@ static int estimateNumTriangles(PView *p) ...@@ -1176,21 +1168,15 @@ static int estimateNumTriangles(PView *p)
else if(opt->IntervalsType == PViewOptions::Discrete) else if(opt->IntervalsType == PViewOptions::Discrete)
heuristic = (tris + 2 * quads + 6 * tets + heuristic = (tris + 2 * quads + 6 * tets +
8 * prisms + 6 * pyrs + 12 * hexas) * 2; 8 * prisms + 6 * pyrs + 12 * hexas) * 2;
return heuristic + 10000; return heuristic + 10000;
} }
int _estimateNumVectors(PView *p)
static int estimateNumVectors(PView *p)
{ {
PViewData *data = p->getData(); PViewData *data = p->getData();
PViewOptions *opt = p->getOptions(); PViewOptions *opt = p->getOptions();
int heuristic = data->getNumVectors(); int heuristic = data->getNumVectors();
return heuristic + 1000; return heuristic + 1000;
} }
class initPView {
public : public :
void operator () (PView *p) void operator () (PView *p)
{ {
...@@ -1202,13 +1188,13 @@ class initPView { ...@@ -1202,13 +1188,13 @@ class initPView {
if(!opt->Visible || opt->Type != PViewOptions::Plot3D) return; if(!opt->Visible || opt->Type != PViewOptions::Plot3D) return;
if(p->va_points) delete p->va_points; if(p->va_points) delete p->va_points;
p->va_points = new VertexArray(1, estimateNumPoints(p)); p->va_points = new VertexArray(1, _estimateNumPoints(p));
if(p->va_lines) delete p->va_lines; if(p->va_lines) delete p->va_lines;
p->va_lines = new VertexArray(2, estimateNumLines(p)); p->va_lines = new VertexArray(2, _estimateNumLines(p));
if(p->va_triangles) delete p->va_triangles; if(p->va_triangles) delete p->va_triangles;
p->va_triangles = new VertexArray(3, estimateNumTriangles(p)); p->va_triangles = new VertexArray(3, _estimateNumTriangles(p));
if(p->va_vectors) delete p->va_vectors; if(p->va_vectors) delete p->va_vectors;
p->va_vectors = new VertexArray(2, estimateNumVectors(p)); p->va_vectors = new VertexArray(2, _estimateNumVectors(p));
if(p->normals) delete p->normals; if(p->normals) delete p->normals;
p->normals = new smooth_normals(opt->AngleSmoothNormals); p->normals = new smooth_normals(opt->AngleSmoothNormals);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment