From dc2aa07dcad6f7b34ec432c0d164c569b8de1baa Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 25 Feb 2008 15:36:38 +0000 Subject: [PATCH] fix const in snprintf --- Geo/GeoStringInterface.cpp | 4 ++-- Post/PViewDataGModel.cpp | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Geo/GeoStringInterface.cpp b/Geo/GeoStringInterface.cpp index bd6b0653f6..734f11f354 100644 --- a/Geo/GeoStringInterface.cpp +++ b/Geo/GeoStringInterface.cpp @@ -1,4 +1,4 @@ -// $Id: GeoStringInterface.cpp,v 1.17 2008-02-23 15:30:07 geuzaine Exp $ +// $Id: GeoStringInterface.cpp,v 1.18 2008-02-25 15:36:38 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -37,7 +37,7 @@ extern Context_T CTX; // Some old systems don't have snprintf... Just call sprintf instead. #if defined(HAVE_NO_SNPRINTF) -int snprintf(const char *str, size_t size, const char* fmt, ...){ +int snprintf(char *str, size_t size, const char* fmt, ...){ va_list args; va_start(args, fmt); int ret = vsprintf(str, fmt, args); diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index 4bd3a39241..0210e27297 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataGModel.cpp,v 1.19 2008-02-24 21:05:04 geuzaine Exp $ +// $Id: PViewDataGModel.cpp,v 1.20 2008-02-25 15:36:38 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -24,9 +24,9 @@ #include "PViewDataGModel.h" #include "MElement.h" -#include "Message.h" PViewDataGModel::PViewDataGModel(GModel *model) : _model(model) + { // store vector of GEntities so we can index them efficiently for(GModel::eiter it = _model->firstEdge(); it != _model->lastEdge(); ++it) @@ -50,16 +50,19 @@ PViewDataGModel::PViewDataGModel(GModel *model) : _model(model) When reading a .msh file: - nodeData.resize(std::max(_model->getMaxNodeDataIndex(), numDataInFile)); + if(nodeData[step - 1].size()) + nodeData[step].values.resize(nodeData[step - 1].size()); + else + nodeData[step].values.resize(numDataInFile); loop over lines: * get node number in file * get vertex pointer from _model->getVertexByTag(num) * if MVertex has no dataIndex: increment it (need global value stored in GModel) - fill std::vector<double> tmp - nodeData[step].push_back(tmp) - else: - add data nodeData[step][dataIndex] + else + use the one that's stored + * if(dataIndex > nodeData[step].size()) nodeData[step].resize(dataIndex + 1) + * fill nodeData[step].value[dataIndex] .msh file format: -- GitLab