本文整理汇总了C++中PView::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ PView::getData方法的具体用法?C++ PView::getData怎么用?C++ PView::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PView
的用法示例。
在下文中一共展示了PView::getData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readMED
bool PView::readMED(const std::string &fileName, int fileIndex)
{
std::vector<std::string> fieldNames = medGetFieldNames(fileName);
for(unsigned int index = 0; index < fieldNames.size(); index++){
if(fileIndex < 0 || (int)index == fileIndex){
PViewDataGModel *d = 0;
// we use the filename as a kind of "partition" indicator, allowing to
// complete datasets provided in separate files (e.g. coming from DDM)
PView *p = getViewByName(fieldNames[index], -1, -1, fileName);
if(p) d = dynamic_cast<PViewDataGModel*>(p->getData());
bool create = d ? false : true;
if(create) d = new PViewDataGModel();
if(!d->readMED(fileName, index)){
Msg::Error("Could not read data in MED file");
if(create) delete d;
return false;
}
else{
if(create) new PView(d);
}
}
}
return true;
}
示例2: computeAndSendVertexArrays
// This version sends VArrays using MPI
static void computeAndSendVertexArrays()
{
// compute...
for(unsigned int i = 0; i < PView::list.size(); i++)
PView::list[i]->fillVertexArrays();
// ...and send
int nbArrays = PView::list.size()* 4;
MPI_Send(&nbArrays, 1, MPI_INT, 0, MPI_GMSH_DATA_READY, MPI_COMM_WORLD);
for(unsigned int i = 0; i < PView::list.size(); i++){
PView *p = PView::list[i];
PViewData *data = p->getData();
PViewOptions *opt = p->getOptions();
double min = data->getMin(), max = data->getMax();
if(opt->rangeType == PViewOptions::PerTimeStep){
min = data->getMin(opt->timeStep);
max = data->getMax(opt->timeStep);
}
VertexArray *va[4] =
{p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
for(int type = 0; type < 4; type++){
if(va[type]){
int len;
char *str = va[type]->toChar
(p->getTag(), data->getName(), type + 1, min, max,
data->getNumTimeSteps(), data->getTime(opt->timeStep),
data->getBoundingBox(), len);
MPI_Send(&len, 1, MPI_INT, 0, MPI_GMSH_VARRAY_LEN, MPI_COMM_WORLD);
MPI_Send(str, len, MPI_CHAR, 0, MPI_GMSH_VARRAY, MPI_COMM_WORLD);
delete [] str;
}
}
}
}
示例3: addToVertexArrays
// Merge the vertex arrays
static void addToVertexArrays(int length, const char* bytes, int swap)
{
std::string name;
int num, type, numSteps;
double min, max, time, xmin, ymin, zmin, xmax, ymax, zmax;
VertexArray::decodeHeader(length, bytes, swap, name, num, type, min, max,
numSteps, time, xmin, ymin, zmin, xmax, ymax, zmax);
PView *p = PView::list[num - 1];
PViewData *data = p->getData();
VertexArray *varrays[4] =
{p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
VertexArray *va = varrays[type - 1];
if (data->getMin() > min) data->setMin(min);
if (data->getMax() < max) data->setMax(max);
SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax);
SBoundingBox3d bb = data->getBoundingBox();
bb += bbox;
data->setBoundingBox(bb);
if (type == 4) type = 2;
VertexArray* toAdd = new VertexArray(type, 100);
toAdd->fromChar(length, bytes, swap);
va->merge(toAdd);
delete toAdd;
}
示例4: number_of_animation
int number_of_animation()
{
int ret = 0;
for(unsigned int i = 0; i < PView::list.size(); i++){
PView * p = PView::list[i];
if(p->getOptions()->visible){
int numSteps = (int)p->getData()->getNumTimeSteps();
if(numSteps > ret) ret = numSteps;
}
}
return ret;
}
示例5: PView
void frameSolver2d::exportFrameData(const char *DISPL, const char *M)
{
#if defined(HAVE_POST)
{
std::map<int, std::vector<double> > data;
for(std::size_t i = 0; i < _beams.size(); i++) {
std::vector<double> tmp;
// tmp.push_back(_beams[i]._e);
// tmp.push_back(_beams[i]._i);
// tmp.push_back(_beams[i]._a);
tmp.reserve(6);
for(int j = 0; j < 6; j++) {
tmp.push_back(_beams[i]._displacement[j]);
}
data[_beams[i]._element->getNum()] = tmp;
}
PView *pv = new PView("displacements", "Beam", _myModel, data, 0.0, 6);
pv->getData()->writeMSH(DISPL);
delete pv;
}
{
std::map<int, std::vector<double> > data;
for(std::size_t i = 0; i < _beams.size(); i++) {
std::vector<double> tmp;
fullVector<double> d(_beams[i]._displacement, 6), F(6);
_beams[i]._stiffness.mult(d, F);
tmp.push_back(-F(2));
tmp.push_back(F(5));
data[_beams[i]._element->getNum()] = tmp;
}
PView *pv =
new PView("Momentum", "ElementNodeData", _myModel, data, 0.0, 1);
pv->getData()->writeMSH(M);
delete pv;
}
#endif
}
示例6: animation_next
int animation_next()
{
int ret = 0;
for(unsigned int i = 0; i < PView::list.size(); i++){
PView * p = PView::list[i];
if(p->getOptions()->visible){
int step = (int)p->getOptions()->timeStep + 1;
int numSteps = (int)p->getData()->getNumTimeSteps();
if(step < 0) step = numSteps - 1;
if(step > numSteps - 1) step = 0;
p->getOptions()->timeStep = step;
p->setChanged(true);
ret = step;
}
}
return ret;
}
示例7: readPLY
int GModel::readPLY(const std::string &name)
{
// this is crazy!?
replaceCommaByDot(name);
FILE *fp = Fopen(name.c_str(), "r");
if(!fp){
Msg::Error("Unable to open file '%s'", name.c_str());
return 0;
}
std::vector<MVertex*> vertexVector;
std::map<int, std::vector<MElement*> > elements[5];
std::map<int, std::vector<double> > properties;
char buffer[256], str[256], str2[256], str3[256];
std::string s1;
int elementary = getMaxElementaryNumber(-1) + 1;
int nbv = 0, nbf = 0;
int nbprop = 0;
int nbView = 0;
std::vector<std::string> propName;
while(!feof(fp)) {
if(!fgets(buffer, sizeof(buffer), fp)) break;
if(buffer[0] != '#'){ // skip comments
sscanf(buffer, "%s %s", str, str2);
if(!strcmp(str, "element") && !strcmp(str2, "vertex")){
sscanf(buffer, "%s %s %d", str, str2, &nbv);
}
if(!strcmp(str, "format") && strcmp(str2, "ascii")){
Msg::Error("Only reading of ascii PLY files implemented");
fclose(fp);
return 0;
}
if(!strcmp(str, "property") && strcmp(str2, "list")){
nbprop++;
sscanf(buffer, "%s %s %s", str, str2, str3);
if (nbprop > 3) propName.push_back(s1+str3);
}
if(!strcmp(str, "element") && !strcmp(str2, "face")){
sscanf(buffer, "%s %s %d", str, str2, &nbf);
}
if(!strcmp(str, "end_header")){
nbView = nbprop -3;
Msg::Info("%d elements", nbv);
Msg::Info("%d triangles", nbf);
Msg::Info("%d properties", nbView);
vertexVector.resize(nbv);
for(int i = 0; i < nbv; i++) {
double x,y,z;
char line[10000], *pEnd, *pEnd2, *pEnd3;
if(!fgets(line, sizeof(line), fp)){ fclose(fp); return 0; }
x = strtod(line, &pEnd);
y = strtod(pEnd, &pEnd2);
z = strtod(pEnd2, &pEnd3);
vertexVector[i] = new MVertex(x, y, z);
pEnd = pEnd3;
std::vector<double> prop(nbView);
for (int k = 0; k < nbView; k++){
prop[k]=strtod(pEnd, &pEnd2);
pEnd = pEnd2;
properties[k].push_back(prop[k]);
}
}
for(int i = 0; i < nbf; i++) {
if(!fgets(buffer, sizeof(buffer), fp)) break;
int n[3], nbe;
sscanf(buffer, "%d %d %d %d", &nbe, &n[0], &n[1], &n[2]);
std::vector<MVertex*> vertices;
if(!getVertices(3, n, vertexVector, vertices)){ fclose(fp); return 0; }
elements[0][elementary].push_back(new MTriangle(vertices));
}
}
}
}
for(int i = 0; i < (int)(sizeof(elements) / sizeof(elements[0])); i++)
_storeElementsInEntities(elements[i]);
_associateEntityWithMeshVertices();
_storeVerticesInEntities(vertexVector);
#if defined(HAVE_POST)
// create PViews here
std::vector<GEntity*> _entities;
getEntities(_entities);
for (int iV=0; iV< nbView; iV++){
PView *view = new PView();
PViewDataList *data = dynamic_cast<PViewDataList*>(view->getData());
for(unsigned int ii = 0; ii < _entities.size(); ii++){
for(unsigned int i = 0; i < _entities[ii]->getNumMeshElements(); i++){
MElement *e = _entities[ii]->getMeshElement(i);
int numNodes = e->getNumVertices();
std::vector<double> x(numNodes), y(numNodes), z(numNodes);
std::vector<double> *out = data->incrementList(1, e->getType());
for(int nod = 0; nod < numNodes; nod++) out->push_back((e->getVertex(nod))->x());
//.........这里部分代码省略.........
示例8: readMSH
//.........这里部分代码省略.........
if(fscanf(fp, "%d %d", &type, &numMatrices) != 2){ fclose(fp); return false; }
for(int j = 0; j < numMatrices; j++){
int m, n;
if(fscanf(fp, "%d %d", &m, &n) != 2){ fclose(fp); return false; }
fullMatrix<double> mat(m, n);
for(int k = 0; k < m; k++){
for(int l = 0; l < n; l++){
double d;
if(fscanf(fp, "%lf", &d) != 1){ fclose(fp); return false; }
mat.set(k, l, d);
}
}
PViewData::addMatrixToInterpolationScheme(name, type, mat);
}
}
}
else if(!strncmp(&str[1], "NodeData", 8) ||
!strncmp(&str[1], "ElementData", 11) ||
!strncmp(&str[1], "ElementNodeData", 15)) {
index++;
if(fileIndex < 0 || fileIndex == index){
PViewDataGModel::DataType type;
if(!strncmp(&str[1], "NodeData", 8))
type = PViewDataGModel::NodeData;
else if(!strncmp(&str[1], "ElementData", 11))
type = PViewDataGModel::ElementData;
else
type = PViewDataGModel::ElementNodeData;
int numTags;
// string tags
std::string viewName, interpolationScheme;
if(!fgets(str, sizeof(str), fp)){ fclose(fp); return false; }
if(sscanf(str, "%d", &numTags) != 1){ fclose(fp); return false; }
for(int i = 0; i < numTags; i++){
if(!fgets(str, sizeof(str), fp)){ fclose(fp); return false; }
if(i == 0)
viewName = ExtractDoubleQuotedString(str, sizeof(str));
else if(i == 1)
interpolationScheme = ExtractDoubleQuotedString(str, sizeof(str));
}
// double tags
double time = 0.;
if(!fgets(str, sizeof(str), fp)){ fclose(fp); return false; }
if(sscanf(str, "%d", &numTags) != 1){ fclose(fp); return false; }
for(int i = 0; i < numTags; i++){
if(!fgets(str, sizeof(str), fp)){ fclose(fp); return false; }
if(i == 0){
if(sscanf(str, "%lf", &time) != 1){ fclose(fp); return false; }
}
}
// integer tags
int timeStep = 0, numComp = 0, numEnt = 0, partition = 0;
if(!fgets(str, sizeof(str), fp)){ fclose(fp); return false; }
if(sscanf(str, "%d", &numTags) != 1){ fclose(fp); return false; }
for(int i = 0; i < numTags; i++){
if(!fgets(str, sizeof(str), fp)){ fclose(fp); return false; }
if(i == 0){
if(sscanf(str, "%d", &timeStep) != 1){ fclose(fp); return false; }
}
else if(i == 1){
if(sscanf(str, "%d", &numComp) != 1){ fclose(fp); return false; }
}
else if(i == 2){
if(sscanf(str, "%d", &numEnt) != 1){ fclose(fp); return false; }
}
else if(i == 3){
if(sscanf(str, "%d", &partition) != 1){ fclose(fp); return false; }
}
}
// either get existing viewData, or create new one
PView *p = getViewByName(viewName, timeStep, partition);
PViewDataGModel *d = 0;
if(p) d = dynamic_cast<PViewDataGModel*>(p->getData());
bool create = d ? false : true;
if(create) d = new PViewDataGModel(type);
if(!d->readMSH(viewName, fileName, fileIndex, fp, binary, swap, timeStep,
time, partition, numComp, numEnt, interpolationScheme)){
Msg::Error("Could not read data in msh file");
if(create) delete d;
fclose(fp);
return false;
}
else{
d->setName(viewName);
d->setFileName(fileName);
d->setFileIndex(index);
if(create) new PView(d);
}
}
}
do {
if(!fgets(str, sizeof(str), fp) || feof(fp))
break;
} while(str[0] != '$');
}
fclose(fp);
return true;
}
示例9: drawScale
void drawContext::drawScale()
{
glPushMatrix();
glLoadIdentity();
double size = std::max(_right -_left, _top - _bottom);
double width = size / 3.5;
double height = size / 10.;
double dh = height / 5;
// Draw the scale bar
int nPview = 0;
for(int i=0; i<PView::list.size();i++){
PView *p = PView::list[i];
PViewOptions *opt = p->getOptions();
if(!opt->visible) continue;
PViewData *data = p->getData();
double box = width / (opt->nbIso ? opt->nbIso : 1);
double xmin = _left + (_right - _left - width)/2.;
double ymin = _bottom + 0.7 * height + height * nPview;
std::vector<GLfloat> vertex(opt->nbIso*3*4);
std::vector<GLubyte> color(opt->nbIso*4*4);
for(int i = 0; i < opt->nbIso; i++){
if(opt->intervalsType == PViewOptions::Discrete ||
opt->intervalsType == PViewOptions::Numeric){
unsigned int col = opt->getColor(i, opt->nbIso);
color[i*4*4+0] = color[i*4*4+4] = color[i*4*4+8] = color[i*4*4+12] =
(GLubyte)CTX::instance()->unpackRed(col);
color[i*4*4+1] = color[i*4*4+5] = color[i*4*4+9] = color[i*4*4+13] =
(GLubyte)CTX::instance()->unpackGreen(col);
color[i*4*4+2] = color[i*4*4+6] = color[i*4*4+10] = color[i*4*4+14] =
(GLubyte)CTX::instance()->unpackBlue(col);
color[i*4*4+3] = color[i*4*4+7] = color[i*4*4+11] = color[i*4*4+15] =
(GLubyte)CTX::instance()->unpackAlpha(col);
vertex[i*3*4+0] = xmin + i * box;
vertex[i*3*4+1] = ymin;
vertex[i*3*4+2] = 0.;
vertex[i*3*4+3] = xmin + i * box;
vertex[i*3*4+4] = ymin + dh;
vertex[i*3*4+5] = 0.;
vertex[i*3*4+6] = xmin + (i + 1) * box;
vertex[i*3*4+7] = ymin;
vertex[i*3*4+8] = 0.;
vertex[i*3*4+9] = xmin + (i + 1) * box;
vertex[i*3*4+10] = ymin + dh;
vertex[i*3*4+11] = 0.;
}
else if(opt->intervalsType == PViewOptions::Continuous){
double dv = (opt->tmpMax - opt->tmpMin) / (opt->nbIso ? opt->nbIso : 1);
double v1 = opt->tmpMin + i * dv;
unsigned int col1 = opt->getColor(v1, opt->tmpMin, opt->tmpMax, true);
color[i*4*4+0] = color[i*4*4+4] = (GLubyte)CTX::instance()->unpackRed(col1);
color[i*4*4+1] = color[i*4*4+5] = (GLubyte)CTX::instance()->unpackGreen(col1);
color[i*4*4+2] = color[i*4*4+6] = (GLubyte)CTX::instance()->unpackBlue(col1);
color[i*4*4+3] = color[i*4*4+7] = (GLubyte)CTX::instance()->unpackAlpha(col1);
vertex[i*3*4+0] = xmin + i * box;
vertex[i*3*4+1] = ymin;
vertex[i*3*4+2] = 0.;
vertex[i*3*4+3] = xmin + i * box;
vertex[i*3*4+4] = ymin + dh;
vertex[i*3*4+5] = 0.;
double v2 = opt->tmpMin + (i + 1) * dv;
unsigned int col2 = opt->getColor(v2, opt->tmpMin, opt->tmpMax, true);
color[i*4*4+8] = color[i*4*4+12] = (GLubyte)CTX::instance()->unpackRed(col2);
color[i*4*4+9] = color[i*4*4+13] = (GLubyte)CTX::instance()->unpackGreen(col2);
color[i*4*4+10] = color[i*4*4+14] = (GLubyte)CTX::instance()->unpackBlue(col2);
color[i*4*4+11] = color[i*4*4+15] = (GLubyte)CTX::instance()->unpackAlpha(col2);
vertex[i*3*4+6] = xmin + (i + 1) * box;
vertex[i*3*4+7] = ymin;
vertex[i*3*4+8] = 0.;
vertex[i*3*4+9] = xmin + (i + 1) * box;
vertex[i*3*4+10] = ymin + dh;
vertex[i*3*4+11] = 0.;
}
else{
unsigned int col = opt->getColor(i, opt->nbIso);
color[i*4*4+0] = color[i*4*4+4] = color[i*4*4+8] = color[i*4*4+12] =
(GLubyte)CTX::instance()->unpackRed(col);
color[i*4*4+1] = color[i*4*4+5] = color[i*4*4+9] = color[i*4*4+13] =
(GLubyte)CTX::instance()->unpackGreen(col);
color[i*4*4+2] = color[i*4*4+6] = color[i*4*4+10] = color[i*4*4+14] =
(GLubyte)CTX::instance()->unpackBlue(col);
color[i*4*4+3] = color[i*4*4+7] = color[i*4*4+11] = color[i*4*4+15] =
(GLubyte)CTX::instance()->unpackAlpha(col);
vertex[i*3*4+0] = xmin + i * box;
vertex[i*3*4+1] = ymin;
vertex[i*3*4+2] = 0.;
vertex[i*3*4+3] = xmin + i * box;
vertex[i*3*4+4] = ymin + dh;
vertex[i*3*4+5] = 0.;
vertex[i*3*4+6] = xmin + (i + 1) * box;
vertex[i*3*4+7] = ymin;
vertex[i*3*4+8] = 0.;
vertex[i*3*4+9] = xmin + (i + 1) * box;
vertex[i*3*4+10] = ymin + dh;
vertex[i*3*4+11] = 0.;
}
}
//.........这里部分代码省略.........
示例10: drawScales
void drawContext::drawScales()
{
std::vector<PView*> scales;
for(unsigned int i = 0; i < PView::list.size(); i++){
PViewData *data = PView::list[i]->getData();
PViewOptions *opt = PView::list[i]->getOptions();
if(!data->getDirty() && opt->visible && opt->showScale &&
opt->type == PViewOptions::Plot3D && data->getNumElements() &&
isVisible(PView::list[i]))
scales.push_back(PView::list[i]);
}
if(scales.empty()) return;
drawContext::global()->setFont(CTX::instance()->glFontEnum,
CTX::instance()->glFontSize);
char label[1024];
double maxw = 0.;
for(unsigned int i = 0; i < scales.size(); i++) {
PViewOptions *opt = scales[i]->getOptions();
sprintf(label, opt->format.c_str(), -M_PI * 1.e-4);
maxw = std::max(maxw, drawContext::global()->getStringWidth(label));
}
const double tic = 10., bar_size = 16.;
double width = 0., width_prev = 0., width_total = 0.;
for(unsigned int i = 0; i < scales.size(); i++) {
PView *p = scales[i];
PViewData *data = p->getData();
PViewOptions *opt = p->getOptions();
if(!opt->autoPosition) {
double w = opt->size[0], h = opt->size[1];
double x = opt->position[0], y = opt->position[1] - h;
int c = fix2dCoordinates(&x, &y);
if(c & 1) x -= w / 2.;
if(c & 2) y += h / 2.;
drawScale(this, p, x, y, w, h, tic, CTX::instance()->post.horizontalScales);
}
else if(CTX::instance()->post.horizontalScales){
double ysep = 20.;
double xc = (viewport[2] - viewport[0]) / 2.;
if(scales.size() == 1){
double w = (viewport[2] - viewport[0]) / 2., h = bar_size;
double x = xc - w / 2., y = viewport[1] + ysep;
drawScale(this, p, x, y, w, h, tic, 1);
}
else{
double xsep = maxw / 4. + (viewport[2] - viewport[0]) / 10.;
double w = (viewport[2] - viewport[0] - 4 * xsep) / 2.;
if(w < 20.) w = 20.;
double h = bar_size;
double x = xc - (i % 2 ? -xsep / 1.5 : w + xsep / 1.5);
double y = viewport[1] + ysep +
(i / 2) * (bar_size + tic +
2 * drawContext::global()->getStringHeight() + ysep);
drawScale(this, p, x, y, w, h, tic, 1);
}
}
else{
double xsep = 20.;
double dy = 2. * drawContext::global()->getStringHeight();
if(scales.size() == 1){
double ysep = (viewport[3] - viewport[1]) / 6.;
double w = bar_size, h = viewport[3] - viewport[1] - 2 * ysep - dy;
double x = viewport[0] + xsep, y = viewport[1] + ysep + dy;
drawScale(this, p, x, y, w, h, tic, 0);
}
else{
double ysep = (viewport[3] - viewport[1]) / 15.;
double w = bar_size;
double h = (viewport[3] - viewport[1] - 3 * ysep - 2.5 * dy) / 2.;
double x = viewport[0] + xsep + width_total + (i / 2) * xsep;
double y = viewport[1] + ysep + dy + (1 - i % 2) * (h + 1.5 * dy + ysep);
drawScale(this, p, x, y, w, h, tic, 0);
}
// compute width
width_prev = width;
sprintf(label, opt->format.c_str(), -M_PI * 1.e-4);
width = bar_size + tic + drawContext::global()->getStringWidth(label);
if(opt->showTime){
char tmp[256];
sprintf(tmp, opt->format.c_str(), data->getTime(opt->timeStep));
sprintf(label, "%s (%s)", data->getName().c_str(), tmp);
}
else
sprintf(label, "%s", data->getName().c_str());
width = std::max(width, drawContext::global()->getStringWidth(label));
if(i % 2) width_total += std::max(bar_size + width, bar_size + width_prev);
}
}
}
示例11: combine
void PView::combine(bool time, int how, bool remove)
{
// time == true: combine the timesteps (oherwise combine the elements)
// how == 0: try to combine all visible views
// 1: try to combine all views
// 2: try to combine all views having identical names
std::vector<nameData> nds;
for(unsigned int i = 0; i < list.size(); i++) {
PView *p = list[i];
PViewData *data = p->getData();
if(how || p->getOptions()->visible) {
nameData nd;
// this will lead to weird results if there are views named
// "__all__" or "__vis__" :-)
if(how == 2)
nd.name = data->getName();
else if(how == 1)
nd.name = "__all__";
else
nd.name = "__vis__";
unsigned int j = 0;
while(j < nds.size()){
if(nds[j].name == nd.name){
nds[j].data.push_back(data);
nds[j].indices.push_back(i);
break;
}
j++;
}
if(j == nds.size()){
nd.data.push_back(data);
nd.indices.push_back(i);
nds.push_back(nd);
}
}
}
std::set<PView*> rm;
for(unsigned int i = 0; i < nds.size(); i++){
if(nds[i].data.size() > 1){ // there's potentially something to combine
// sanity checks:
bool allListBased = true, allModelBased = true;
for(unsigned int j = 0; j < nds[i].data.size(); j++){
PViewDataList *d1 = dynamic_cast<PViewDataList*>(nds[i].data[j]);
if(!d1) allListBased = false;
PViewDataGModel *d2 = dynamic_cast<PViewDataGModel*>(nds[i].data[j]);
if(!d2) allModelBased = false;
}
PViewData *data = 0;
if(allListBased){
data = new PViewDataList();
}
else if(allModelBased){
PViewDataGModel *d2 = dynamic_cast<PViewDataGModel*>(nds[i].data[0]);
data = new PViewDataGModel(d2->getType());
}
else{
Msg::Error("Cannot combine hybrid list/mesh-based datasets");
continue;
}
PView *p = new PView(data);
bool res = time ? data->combineTime(nds[i]) : data->combineSpace(nds[i]);
if(res){
for(unsigned int j = 0; j < nds[i].indices.size(); j++)
rm.insert(list[nds[i].indices[j]]);
PViewOptions *opt = p->getOptions();
if(opt->adaptVisualizationGrid){
// the (empty) adaptive data created in PView() must be
// recreated, since we added some data
data->destroyAdaptiveData();
data->initAdaptiveData
(opt->timeStep, opt->maxRecursionLevel, opt->targetError);
}
}
else
delete p;
}
}
if(remove)
for(std::set<PView*>::iterator it = rm.begin(); it != rm.end(); it++)
delete *it;
}
示例12: getView
PView *GMSH_Scal2VecPlugin::execute(PView *v)
{
// Load options
int iView[3];
for(int comp = 0; comp < 3; comp++)
iView[comp] = (int)Scal2VecOptions_Number[comp].def;
// Load data
PView *vRef = 0, *vComp[3];
for(int comp = 0; comp < 3; comp++) {
if(iView[comp] < 0)
vComp[comp] = 0;
else {
vComp[comp] = getView(iView[comp], v);
if(!vComp[comp]) {
Msg::Error("Scal2Vec plugin could not find View '%i'", iView[comp]);
return v;
}
if(!vRef) vRef = vComp[comp];
}
}
if(!vRef) {
Msg::Error("Scal2Vec plugin could not find any view.");
return v;
}
PViewData *dataRef = vRef->getData();
// Initialize the new view
PView *vNew = new PView();
PViewDataList *dataNew = getDataList(vNew);
int step0 = dataRef->getFirstNonEmptyTimeStep();
for(int ent = 0; ent < dataRef->getNumEntities(step0); ent++) {
for(int ele = 0; ele < dataRef->getNumElements(step0, ent); ele++) {
if(dataRef->skipElement(step0, ent, ele)) continue;
int type = dataRef->getType(step0, ent, ele);
int numNodes = dataRef->getNumNodes(step0, ent, ele);
std::vector<double> *out = dataNew->incrementList(
3, type, numNodes); // Pointer in data of the new view
if(!out) continue;
double x[8], y[8], z[8];
for(int nod = 0; nod < numNodes; nod++)
dataRef->getNode(step0, ent, ele, nod, x[nod], y[nod], z[nod]);
int dim = dataRef->getDimension(step0, ent, ele);
elementFactory factory;
element *element = factory.create(numNodes, dim, x, y, z);
if(!element) continue;
for(int nod = 0; nod < numNodes; nod++)
out->push_back(x[nod]); // Save coordinates (x,y,z)
for(int nod = 0; nod < numNodes; nod++) out->push_back(y[nod]);
for(int nod = 0; nod < numNodes; nod++) out->push_back(z[nod]);
for(int step = step0; step < dataRef->getNumTimeSteps(); step++) {
if(!dataRef->hasTimeStep(step)) continue;
for(int nod = 0; nod < numNodes; nod++) {
for(int comp = 0; comp < 3; comp++) {
double val = 0.;
if(vComp[comp])
vComp[comp]->getData()->getValue(step, ent, ele, nod, 0, val);
out->push_back(val); // Save value
}
}
}
delete element;
}
}
for(int step = step0; step < dataRef->getNumTimeSteps(); step++) {
if(!dataRef->hasTimeStep(step)) continue;
dataNew->Time.push_back(dataRef->getTime(step));
}
std::string nameNewView = Scal2VecOptions_String[0].def;
dataNew->setName(nameNewView);
dataNew->setFileName(nameNewView + ".pos");
dataNew->finalize();
return vNew;
}