diff --git a/Common/Options.cpp b/Common/Options.cpp index 90cec2af38a6e0f9833d8f4c19efa95d21e5e3c2..ef5328c640b6421d6cd8c0d99693100c7e09f989 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -500,7 +500,7 @@ GmshColorTable *GetColorTable(int num) #if defined(HAVE_POST) PViewOptions *opt; if(PView::list.empty() || num < 0 || num > (int)PView::list.size() - 1) - opt = &PViewOptions::reference; + opt = PViewOptions::reference(); else{ opt = PView::list[num]->getOptions(); // assume that if we access the colortable we will change it @@ -517,7 +517,7 @@ static void PrintColorTable(int num, int diff, const char *prefix, FILE *file) #if defined(HAVE_POST) PViewOptions *opt; if(PView::list.empty() || num < 0 || num > (int)PView::list.size() - 1) - opt = &PViewOptions::reference; + opt = PViewOptions::reference(); else opt = PView::list[num]->getOptions(); @@ -872,7 +872,7 @@ void PrintOptionsDoc() PViewData *data = 0; \ PViewOptions *opt; \ if(PView::list.empty()) \ - opt = &PViewOptions::reference; \ + opt = PViewOptions::reference(); \ else{ \ if(num < 0 || num >= (int)PView::list.size()){ \ Msg::Warning("View[%d] does not exist", num); \ diff --git a/Geo/CGNSOptions.h b/Geo/CGNSOptions.h index 931465d6c6e3f2d4ecec0682eda1d30d0d316043..242756fff4272d34d60332c4104f6da702af995d 100644 --- a/Geo/CGNSOptions.h +++ b/Geo/CGNSOptions.h @@ -8,6 +8,8 @@ #ifndef _CGNSOPTIONS_H_ #define _CGNSOPTIONS_H_ +#include <string> + class CGNSOptions { public: @@ -34,10 +36,8 @@ class CGNSOptions bool writeUserDef; // T - write user-defined elements for // element types unsupported by CGNS - CGNSOptions() - { - setDefaults(); - } + CGNSOptions(){ setDefaults(); } + ~CGNSOptions(){} void setDefaults() { baseName = "Base_1"; diff --git a/Mesh/meshPartitionOptions.h b/Mesh/meshPartitionOptions.h index da7925039df38519b66dcd485d99456e4577419d..5a9dac3d34bbe7bbccf692c39e5114898aa00662 100644 --- a/Mesh/meshPartitionOptions.h +++ b/Mesh/meshPartitionOptions.h @@ -48,13 +48,13 @@ class meshPartitionOptions // 3 - Octasection double eigtol; // Tolerance to the eigensolver long seed; // RNG seed - + // parameters int refine_partition; // Refine partitions at each level int internal_vertices; // Increase internal vertices int refine_map; // Refine processor mapping int terminal_propogation; // Run with terminal propogation - + // METIS int algorithm; // 1 - Recursive @@ -70,23 +70,24 @@ class meshPartitionOptions // 3 - Random boundary refinement (with // minimization of connectivity // along sub-domains) - - // element weights for load-balancing (currently used in METIS algorithm 3) - int triWeight; + + // element weights for load-balancing (currently used in METIS algorithm 3) + int triWeight; int quaWeight; int tetWeight; int priWeight; int pyrWeight; int hexWeight; - + // NODAL WEIGHT std::vector<int> nodalWeights; std::map<int, std::vector<int> > vWeightMap; std::map<int, int > eWeightMap; std::vector<int> tolerance; - + public: meshPartitionOptions(){ setDefaults(); } + ~meshPartitionOptions(){} void setAlgorithm(int algo){ algorithm = algo; } void setNumOfPartitions(int numPart){ num_partitions = numPart; } int getNumOfPartitions(){ return num_partitions; } @@ -127,7 +128,7 @@ class meshPartitionOptions tetWeight = 1; priWeight = 1; pyrWeight = 1; - hexWeight = 1; + hexWeight = 1; } }; diff --git a/Post/PView.cpp b/Post/PView.cpp index 2d27798da8d3238f8156c8dee5613cd01b473088..c894b76c67efec638d067de8e46da44c0bb4c91b 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -39,7 +39,7 @@ PView::PView(int num) { _init(num); _data = new PViewDataList(); - _options = new PViewOptions(PViewOptions::reference); + _options = new PViewOptions(*PViewOptions::reference()); if(_options->adaptVisualizationGrid) _data->initAdaptiveData(_options->timeStep, _options->maxRecursionLevel, _options->targetError); @@ -49,7 +49,7 @@ PView::PView(PViewData *data, int num) { _init(num); _data = data; - _options = new PViewOptions(PViewOptions::reference); + _options = new PViewOptions(*PViewOptions::reference()); if(_options->adaptVisualizationGrid) _data->initAdaptiveData(_options->timeStep, _options->maxRecursionLevel, _options->targetError); @@ -74,7 +74,7 @@ PView::PView(PView *ref, bool copyOptions) if(copyOptions) _options = new PViewOptions(*ref->getOptions()); else - _options = new PViewOptions(PViewOptions::reference); + _options = new PViewOptions(*PViewOptions::reference()); if(_options->adaptVisualizationGrid) _data->initAdaptiveData(_options->timeStep, _options->maxRecursionLevel, _options->targetError); @@ -88,7 +88,7 @@ PView::PView(const std::string &xname, const std::string &yname, _data->setXY(x, y); _data->setName(yname); _data->setFileName(yname + ".pos"); - _options = new PViewOptions(PViewOptions::reference); + _options = new PViewOptions(*PViewOptions::reference()); _options->type = PViewOptions::Plot2D; _options->axes = 3; _options->lineWidth = 2.; @@ -117,7 +117,7 @@ PView::PView(const std::string &name, const std::string &type, d->setName(name); d->setFileName(name + ".msh"); _data = d; - _options = new PViewOptions(PViewOptions::reference); + _options = new PViewOptions(*PViewOptions::reference()); if(_options->adaptVisualizationGrid) _data->initAdaptiveData(_options->timeStep, _options->maxRecursionLevel, _options->targetError); @@ -173,7 +173,7 @@ void PView::setOptions(PViewOptions *val) if(val) _options = val; else if(_options) // deep copy options from reference view - *_options = PViewOptions::reference; + *_options = *PViewOptions::reference(); } PViewData *PView::getData(bool useAdaptiveIfAvailable) diff --git a/Post/PViewOptions.cpp b/Post/PViewOptions.cpp index 8501b6338328b994b6f24440759793282a110a64..a7bfa5d5b9230946942be40d8b2d22d6ef3295bb 100644 --- a/Post/PViewOptions.cpp +++ b/Post/PViewOptions.cpp @@ -10,8 +10,6 @@ #include "PViewOptions.h" #include "mathEvaluator.h" -PViewOptions PViewOptions::reference; - PViewOptions::PViewOptions() : genRaiseEvaluator(0) { ColorTable_InitParam(2, &colorTable); @@ -23,10 +21,18 @@ PViewOptions::~PViewOptions() if(genRaiseEvaluator) delete genRaiseEvaluator; } +PViewOptions *PViewOptions::_reference = 0; + +PViewOptions *PViewOptions::reference() +{ + if(!_reference) _reference = new PViewOptions(); + return _reference; +} + double PViewOptions::getScaleValue(int iso, int numIso, double min, double max) { if(numIso == 1) return (min + max) / 2.; - + if(scaleType == Linear){ // treat min/max separately to avoid numerical errors (important // not to miss first/last discrete iso on piece-wise constant @@ -69,7 +75,7 @@ int PViewOptions::getScaleIndex(double val, int numIso, double min, double max, return 0; } -unsigned int PViewOptions::getColor(double val, double min, double max, +unsigned int PViewOptions::getColor(double val, double min, double max, bool forceLinear, int numColors) { if(colorTable.size == 1) return colorTable.table[0]; @@ -91,7 +97,7 @@ unsigned int PViewOptions::getColor(double val, double min, double max, unsigned int PViewOptions::getColor(int i, int nb) { - int index = (nb == 1) ? colorTable.size / 2 : + int index = (nb == 1) ? colorTable.size / 2 : (int)(i / (double)(nb - 1) * (colorTable.size - 1) + 0.5); if(index < 0) index = 0; else if(index > colorTable.size - 1) index = colorTable.size - 1; @@ -100,7 +106,7 @@ unsigned int PViewOptions::getColor(int i, int nb) void PViewOptions::createGeneralRaise() { - const char *names[] = + const char *names[] = { "x", "y", "z", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8"}; unsigned int numVariables = sizeof(names) / sizeof(names[0]); std::vector<std::string> expressions(3), variables(numVariables); diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index b1b684e74081f6f410c8aa5779e4e46194ef626c..d28c2c95e4536e8eea5212398269ac1be84c9a61 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -104,11 +104,13 @@ class PViewOptions { unsigned int tangents, normals; unsigned int text2d, text3d, axes, background2d; } color; + private: + // static reference that contains default values + static PViewOptions *_reference; public: - // static reference container that contains default values - static PViewOptions reference; PViewOptions(); ~PViewOptions(); + static PViewOptions *reference(); // return a floating point value in [min, max] corresponding to the // integer iso in [0, numIso - 1] double getScaleValue(int iso, int numIso, double min, double max);