int VisusConsumer::connect(int i, pVisusProducer producer, VisusData* sink) { if ((i < 0) || (i >= mNrOfInputs)) { vwarning("Cannot connect input. Index out of range."); return 0; } if (producer == NULL) { vwarning("Cannot connect NULL producer. Connection ignored."); return 0; } if (sink == NULL) { vwarning("Cannot connect NULL sink. Connection ignored."); return 0; } mInputNodes[i] = producer; mConnected[i] = true; mSinks[i] = sink; mSinks[i]->resetId(); return 1; }
int VisusConsumer::loadData(VisusData* data, int input) { if (input > mNrOfInputs || input < 0) { vwarning("Cannot load VisusData. Input index is out-of-range."); return 0; } if (mSinks[input] == NULL) { vwarning("Data at given index is NULL."); return 0; } mInputLock.writeLock(); if (!mSinks[input]->copyContent(data)) { mInputLock.unlock(); return 0; } mSinks[input]->resetId(); mInputLock.unlock(); updateInputDomain(); return 1; }
/* should we create the node here or let it be created by caller as now? */ void note_register_note(const unsigned char *tag, struct node *node) { struct note *np = NULL; if (tag) { np = note_find_in_line(tag); if (np) { if (np->status == NOTE_REGISTERED) { const char *nid = note_create_id(); setAttr(node, a_xml_id, (const unsigned char *)nid); setAttr(np->node, a_note_ref, (const unsigned char *)nid); setAttr(node, a_note_auto, (const unsigned char *)np->mark); np->status = NOTE_REFERENCED; } else { vwarning("note tag %s has multiple notes attached to it", tag); } } else { vwarning("note tag %s was not used in the preceding line", tag); } } else { warning("note_register_note passed NULL tag"); } }
int check_and_register(const char *id, int set_ok) { unsigned char *vec; unsigned int vmax; long idnum = strtoul(id+1,NULL,10); unsigned int v, b; int tab[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; /* The vector is created by Perl's vec() function; perldoc -f vec for more info */ v = idnum/8; b = tab[idnum%8]; if (*id == 'P') { vec = pvec; vmax = 1000000; } else if (*id == 'Q') { vec = qvec; vmax = QVEC_SIZ; } else return 0; if (idnum < vmax && set_ok) { if (BIT_ISSET(vec[v],b)) { vwarning("duplicate ID: %s", id); return 1; } else { BIT_SET(vec[v],b); } } #if 1 /* issue this as a notice so it doesn't affect error status */ if (*id == 'P' && (idnum > max_cat_id || !(BIT_ISSET(catvec[v],b)))) { if (strlen(id) > 7) { vwarning("%s: malformed ID; text will be ignored",id); return 1; } else vnotice("%s not in main catalog (new P-IDs may not register for 48 hours)",id); } #else else { vwarning("%s: ID too big (max %d)",id,vmax); return 1; } #endif return 0; }
//--------------------------------------------------------------------------- // Read from xml //--------------------------------------------------------------------------- bool VisusBorderAxis::fromXML(XMLNode& node) { if (strcmp(XML_TAG, node.getName())) { std::stringstream ss; ss << "VisusBorderAxis did not receive its top level node. received (" << node.getName() << ")\n"; vwarning(ss.str().c_str()); vverbose(ss.str().c_str(), VISUS_XML_VERBOSE); return false; } XMLNode child = node.getChildNode("label"); XMLNode text = child.getChildNode(0); if (! mLabel.fromXML(text)) { vwarning("Failed to retrieve label text for VisusBorderAxis"); return false; } mDrawLabels = xmltobool(node.getAttribute("drawLabel"), mDrawLabels); mLabelPosition = (AXISSide) xmltoi(node.getAttribute("labelPosition"), mLabelPosition); mLabelAlignment = (AXISAlignment) xmltoi(node.getAttribute("labelAlignment"), mLabelAlignment); mLabelOffset = xmltof(node.getAttribute("labelOffset"), mLabelOffset); child = node.getChildNode("legend"); text = child.getChildNode(0); if (! mLegend.fromXML(text)) { vwarning("Failed to retrieve label text for VisusBorderAxis"); return false; } mDrawLegend = xmltobool(node.getAttribute("drawLegend"), mDrawLegend); mLegendPosition = (AXISSide) xmltoi(node.getAttribute("legendPosition"), mLegendPosition); mLegendAlignment= (AXISAlignment) xmltoi(node.getAttribute("legendAlignment"), mLegendAlignment); mLegendOffset = xmltof(node.getAttribute("legendOffset"), mLegendOffset); mDrawTicks = xmltobool(node.getAttribute("drawTicks"), mDrawTicks); mMajorTickLength = xmltof(node.getAttribute("majorTickLength"), mMajorTickLength); mMajorTickThickness = xmltof(node.getAttribute("majorTickThickness"), mMajorTickThickness); mMinorTickLength = xmltof(node.getAttribute("minorTickLength"), mMinorTickLength); mMinorTickThickness = xmltof(node.getAttribute("minorTickThickness"), mMinorTickThickness); mTickPosition = (AXISSide) xmltoi(node.getAttribute("tickPosition"), mTickPosition); mMinValue = xmltof(node.getAttribute("min"), mMinValue); mMaxValue = xmltof(node.getAttribute("max"), mMaxValue); mMajorTicks = xmltoi(node.getAttribute("majorTicks"), mMajorTicks); mMinorTicks = xmltoi(node.getAttribute("minorTicks"), mMinorTicks); XMLNode tickColor = node.getChildNode("TickColor"); XMLNode color = tickColor.getChildNode(0); if (! mTickColor.fromXML(color)) { vwarning("Failed to retrieve tick color for VisusBorderAxis"); return false; } return true; }
void VisusMeshDisplay::renderColoredSmooth() { std::vector<VisusMeshData::IndexDataType>::iterator it; pVisusSharedColorMap colorMap = sharedValue<VisusSharedColorMap>(); if (colorMap->lockToRead() == 0) { vwarning("Could not lock color map for reading. Rendering aborted."); return; } glShadeModel(GL_SMOOTH); //fprintf(stderr,"VisusMeshDisplay::renderColoredSmooth()\n"); // Find Min / Max for color map if not hand-set if (mMinValue > mMaxValue) computeMinMax(); mValueRange = mMaxValue - mMinValue; // Get Local Colormap switch (mMesh.elementDim()) { case 3: glBegin(GL_TRIANGLES); break; case 4: glBegin(GL_QUADS); break; default: glBegin(GL_POLYGON); break; } // Loop and Draw for (uint32_t i=0;i<mMesh.nrOfElements();i++) { std::vector<VisusMeshData::IndexDataType>& element = mMesh.element(i); // Draw Values for (it=element.begin();it!=element.end();it++) { VisusMeshData::IndexDataType idx = *it; //glTexCoord1f(mMesh.vertex(idx)[mColorIndex]); setColor(*colorMap, mMesh.vertex(idx)[mColorIndex]); glNormal3fv(mMesh.componentAddress(idx,mNormalIndex)); glVertex3fv(mMesh.vertexAddress(idx)); } } glEnd(); if (colorMap->unlockAfterRead() == 0) { vwarning("Could not unlock color map after renderin. Aborting rendring."); return; } }
int VisusConsumer::synchronize(int n) { if (n < -1) { vwarning("Index out of range no such input. Synchronization aborted"); return 0; } else if (n == -1) n = mNrOfInputs; else if (n > mNrOfInputs) { vwarning("Cannot synchronize all requested inputs. Index out of range"); n = mNrOfInputs; } int flag = 1; mInputLock.writeLock(); for (int i=0;i<n;i++) { if ((mInputNodes[i] != NULL) && (mSinks[i] != NULL)) { if (mInputNodes[i]->readLockProduct() == 0) { vwarning("Could not read-lock input. Synchronization incomplete."); flag *= 0; continue; } if (mInputNodes[i]->product()->id() != mSinks[i]->id()) { mSinks[i]->copyContent(mInputNodes[i]->product()); mSinks[i]->id(mInputNodes[i]->product()->id()); flag *= 2; } if (mInputNodes[i]->unlockProduct() == 0) { vwarning("Could not unlock input."); flag *= 0; } } else if (mInputNodes[i] == NULL) { // Removed the warning since using a node without input is a // valid use case, for example, using loadData instead (ptb) //vwarning("Input node not valid. Synchronization incomplete."); } else if (mSinks[i] == NULL){ vwarning("Input buffer not valid. Synchronization incomplete.");} } mInputLock.unlock(); updateInputDomain(); return flag; }
bool VisusAxisAlignedExtractor::fromXMLLocalVariables(XMLNode& node) { if (strcmp(XML_TAG, node.getName())) { vwarning("VisusAxisAlignedExtractor did not receive top node"); return false; } // Connect us as producer if (! visusXML::connectProducer<VisusAxisAlignedExtractor>(node, self())) { vwarning("failed to connect as producer when loading xml"); return false; } return true; }
void warning(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vwarning(fmt, ap); }
int VisusIndexedData::constructElement(const std::vector<float>& vertices) { if ((vertices.size() / mVertexDim) != (vertices.size() / ((float)mVertexDim))) { vwarning("Number of input values does not match with the given vertex dimension."); return 0; } std::vector<float>::const_iterator cit; for (cit=vertices.begin();cit!=vertices.end();cit+=mVertexDim) { mVertices->push_back(std::vector<VertexDataType>(cit,cit+mVertexDim)); } std::vector<IndexDataType> element(vertices.size()/mVertexDim,0); std::vector<IndexDataType>::iterator it; for (it=element.begin();it!=element.end();it++) *it = mVertices->size() - (element.end() - it); mElements->push_back(element); return 1; }
int VisusIndexedData::swapContent(VisusData* data) { // If I can't read the input I cannot proceed if (!readCompatible(data)) { vwarning("Data types not compatible cannot swap."); return 0; } // If I can read the input but the input cannot read from me I // default to copying the dat if (!data->readCompatible(this)) return copyContent(data); VisusMetricData::swapContent(data); VisusIndexedData* mesh = (VisusIndexedData*)data; std::swap(mVertices,mesh->mVertices); std::swap(mElements,mesh->mElements); mVertexDim = mesh->mVertexDim; mSpatialDim = mesh->mSpatialDim; mBBox = mesh->mBBox; return 1; }
int VisusMetricData::swapContent(VisusData* data) { VisusData::swapContent(data); VisusMetricData* metric_data; #ifdef VISUS_NO_DYNAMIC_CAST metric_data = (VisusMetricData*)data; #else metric_data = dynamic_cast<VisusMetricData*>(data); if (metric_data == NULL) { vwarning("Dynamic cast failed invalid data types."); return 0; } #endif mMatrix = metric_data->mMatrix; this->mUnit = metric_data->mUnit; //std::swap(this->mLeftLower,metric_data->mLeftLower); //std::swap(this->mRightUpper,metric_data->mRightUpper); return 1; }
void load_labels(const char *PQ) { const char *fname[2]; static char *definedp = "1"; static char *undefinedp = "0"; if (!hash_lookup((unsigned char *)PQ,label_table)) { current_PQ = PQ; fname[0] = expand(project, PQ, "xtf"); fname[1] = NULL; if (!access(fname[0],R_OK)) { hash_insert((unsigned char*)PQ,definedp,label_table); runexpat(i_list, fname, sH, eH); } else { hash_insert((unsigned char*)PQ,undefinedp,label_table); #if 0 { const char *ename = strstr(fname[0], project); if (!ename) { ename = fname[0]; vwarning("%s: not readable/no label checking", ename); --status; /* don't count this as a real error */ } } #endif } } }
void warning(Loc loc, const char *format, ...) { va_list ap; va_start(ap, format); vwarning(loc, format, ap); va_end( ap ); }
void range_error (const char *string,...) { va_list args; va_start (args, string); switch (range_check) { case range_check_warn: vwarning (string, args); break; case range_check_on: verror (string, args); break; case range_check_off: /* FIXME: cagney/2002-01-30: Should this function print anything when range error is off? */ vfprintf_filtered (gdb_stderr, string, args); fprintf_filtered (gdb_stderr, "\n"); break; default: internal_error (__FILE__, __LINE__, "bad switch"); } va_end (args); }
void xcl_sentence_labels(struct xcl_context *xc, struct xcl_c *c) { const char *first = NULL, *last = NULL; int n_lems = 0; if (c->type != xcl_c_sentence || !c->nchildren) return; first = first_l(c); last = last_l(c); if (first) { if (last) { char *l = malloc(strlen(first)+strlen(last)+4); sprintf(l,"%s - %s",first,last); c->label = cc(pool_copy(ucc(l))); free(l); } else c->label = cc(pool_copy(ucc(first))); } else if (n_lems) /* sentences that don't have lemmata don't matter */ { vwarning("couldn't compute label for sentence with id=%s",c->ref); } }
void warning(const char *msg, ...) { va_list ap; va_start(ap, msg); vwarning(msg, ap); va_end(ap); }
void VisusDataProbe::translate(float x, float y) { VisusBoundingBox bbox; VisusTransformation3D acc; VisusTransformation3D matrix; VisusOpenGLState state; std::vector<float> trans; if (mDataLock.readLock() == 0) { vwarning("Could not lock data source for reading. Ignoring translation."); return; } if (mDataSource->isValid()) { mDataSource->domainBoundingBox(bbox); if (mDataLock.unlock() == 0) vwarning("Could not unlock data source."); accumulate3D(acc); getValue(matrix); getValue(state); trans = matrix.translation(acc,state,x,-y); trans[0] *= (bbox[3] - bbox[0]); trans[1] *= (bbox[4] - bbox[1]); trans[2] *= (bbox[5] - bbox[2]); matrix[12] += trans[0]; matrix[13] += trans[1]; matrix[14] += trans[2]; matrix[12] = MIN(bbox[3],MAX(bbox[0],matrix[12])); matrix[13] = MIN(bbox[4],MAX(bbox[1],matrix[13])); matrix[14] = MIN(bbox[5],MAX(bbox[2],matrix[14])); setValue(matrix); synchronize(true); } else { if (mDataLock.unlock() == 0) vwarning("Could not unlock data source."); } }
void compile_warning(const char *msg, ...) { va_list args; va_start(args, msg); vwarning(lexer_filename, lexer_nicename, yylineno, msg, args); va_end(args); }
void VisusDataProbe::display3D(VisusTransformation3D model_view_3D) { synchronize(); if (mDataLock.readLock() == 0) { vwarning("Could not lock data probe content for reading."); return; } glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadMatrixf(model_view_3D); // If we have a valid data source if (mDataSource->isValid()) { VisusBoundingBox bbox; mDataSource->domainBoundingBox(bbox); glColor3f(1,1,1); glDisable(GL_LIGHTING); glBegin(GL_LINES); glVertex3f(mPosition[0],mPosition[1],bbox[2]); glVertex3f(mPosition[0],mPosition[1],bbox[5]); glVertex3f(bbox[0],mPosition[1],mPosition[2]); glVertex3f(bbox[3],mPosition[1],mPosition[2]); glVertex3f(mPosition[0],bbox[1],mPosition[2]); glVertex3f(mPosition[0],bbox[4],mPosition[2]); glEnd(); } if (mDataLock.unlock() == 0) vwarning("Could not unlock data probe content."); for (CIterator it=mChildren.begin();it!=mChildren.end();it++) (*it)->display(model_view_3D); glPopMatrix(); }
/* Report warning msg at current filename, lineno */ void warning(const char *format, ...) { va_list args; va_start(args, format); vwarning(format, args); va_end(args); }
void fatal(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vwarning(fmt, ap); exit(1); }
const std::vector<VisusIndexedData::IndexDataType>& VisusIndexedData::element(IndexDataType i) const { if ((i < 0) || (i >= (int)nrOfElements())) { vwarning("Index out of range: no such element. Returning first element."); // This is a const function we cannot construct an // element. Therefore, if there is no element we can reference we // assert if (nrOfElements() == 0) { vwarning("Illegal access to element array. Cannot recover."); assert(false); } return (*mElements)[0]; } return (*mElements)[i]; }
const std::vector<VisusIndexedData::VertexDataType>& VisusIndexedData::vertex(IndexDataType i) const { if ((i < 0) || (i >= (int)nrOfVertices())) { vwarning("Index out of range: no such vertex. Return first vertex"); // This is a const function we cannot construct a // vertex. Therefore, if there is no vertex reference we could return we assert if (nrOfVertices() == 0) { vwarning("Illegal acces to vertex array. Cannot recover."); assert(false); } return (*mVertices)[0]; } return (*mVertices)[i]; }
int VisusMeshDisplay::connectInput(pVisusProducer producer) { if (connect(0,producer,&mMesh) == 0) { vwarning("Could not connect producer."); return 0; } return 1; }
void lem_save_lemma(struct node *wp, const char *lemma) { struct ilem_form *form = hash_find(word_form_index, getAttr(wp,"xml:id")); if (form) form->literal = (char*)npool_copy((unsigned char *)lemma,lemline_xcp->pool); else vwarning("internal error: word_form_index lookup failed"); }
void warning_line(const char *fname, const char *nname, int line, const char *msg, ...) { va_list args; va_start(args, msg); vwarning(fname, nname, line, msg, args); va_end(args); }
bool VisusConsumer::setNumberOfInputs(const int numberOfInputs) { if (mNrOfInputs != 0) { vwarning("Number of producer inputs for consumer has already been set. This attempt is ignored."); return false; } init(numberOfInputs); return true; }
void warning(int n, ...) { va_list ap; va_start(ap, n); vwarning(n, ap); va_end(ap); }
ssize_t dvmsg(int code, void *, const char *format, va_list va) { if (code == 0) return vmsg(format, va); if ( code > 0 ) vwarning(format, va); else verror(format, va); return 0; }