geos::geom::MultiPolygon *WKBParser::_readMultiPolygon() { int count = _is.readInt(); std::vector<geos::geom::Geometry *> *geoms = new std::vector<geos::geom::Geometry *>(count); try { for (int i=0; i<count; i++) { geos::geom::Geometry *g = _readGeometry(); if (!dynamic_cast<geos::geom::Polygon *>(g)) { AMIGO_LOG_E(TAG, "::_readMultiPolygon() Invalid geometry type\n"); _clean(geoms); return NULL; } (*geoms)[i] = g; } } catch (...) { AMIGO_LOG_E(TAG, "::_readMultiPolygon() Read failed.\n"); _clean(geoms); return NULL; } return _factory.createMultiPolygon(geoms); }
geos::geom::GeometryCollection *WKBParser::_readGeometryCollection() { int count = _is.readInt(); std::vector<geos::geom::Geometry *> *geoms = new std::vector<geos::geom::Geometry *>(count); try { for (int i=0; i<count; i++) { geos::geom::Geometry *g = _readGeometry(); if(g) { (*geoms)[i] = g; } else { AMIGO_LOG_E(TAG, "::_readGeometryCollection() Read failed.\n"); _clean(geoms); return NULL; } } } catch (...) { _clean(geoms); return NULL; } return _factory.createGeometryCollection(geoms); }
int code_2op_reg_mem(char *mnem,char * sreg1,char *ev) { int reg1 = getval(sreg1); int codesize = 0; if(!(reg1+1)){ return 0;if(VERBOSE) printf("\nInstruction Result:%d",codesize);} buffer.w=1; buffer.s = 0; buffer.mod = 0; buffer.rm = (*(ev+1)=='B'||*(ev+1)=='b')?6:7; buffer.reg =reg1; int xt = extr(ev); if (!xt){ int tmp[2]; encode(tmp,xt); buffer.dispa=tmp[0]; buffer.dispb=tmp[1]; } int t_opcode = _opcode(mnem); if (t_opcode==-1) return 0; //insert some error handling code here buffer.opcode = t_opcode; if(byte1(buffer)) { putc(byte1(buffer),fp); codesize++;} if(byte2(buffer)) { putc(byte2(buffer),fp);codesize++;} if(buffer.rm==7) { putc(buffer.dispa,fp); putc(buffer.dispb,fp); codesize+=2; } _clean(); }
int code_2op_reg_imm(char *mnem,char * sreg1,int imm){ int reg1 = getval(sreg1); int codesize = 0; //printf("\n%s:%d\n%s:%d",sreg1,reg1,reg2); if(!(reg1+1)){if(VERBOSE) printf("\nInstruction Result:%d",codesize); return 0;} buffer.s = 0; buffer.w = reg1>7?1:0; buffer.mod = 3; int t_rmcode = _rmcode(mnem); if(t_rmcode==-2) { if(reg1==0||reg1==4||reg1==8) { buffer.opcode = 011; if(buffer.w){ int mat[2]; encode(mat,imm); putc(mat[0],fp); putc(mat[1],fp); codesize += 2; } else { putc(imm,fp);codesize++;} if(byte1(buffer)) { putc(byte1(buffer),fp); codesize++;} } if(VERBOSE) printf("\nInstruction Result:%d",codesize); return codesize; } buffer.reg =reg1; int t_opcode = _opcode(mnem); if (t_opcode==-1||t_rmcode==-1) {if(VERBOSE) printf("\nInstruction Result:%d",codesize);return 0;} //insert some error handling code here buffer.opcode = t_opcode; buffer.rm = t_rmcode; if(byte1(buffer)) { putc(byte1(buffer),fp); codesize++; } if(byte2(buffer)) { putc(byte2(buffer),fp); codesize++;} if(buffer.w){ int mat[2]; encode(mat,imm); putc(mat[0],fp); putc(mat[1],fp);codesize+=2; } else{ putc(imm,fp);codesize++;} _clean(); if(VERBOSE) printf("\nInstruction Result:%d",codesize); return codesize; }
int code_2op(char *mnem,char * sreg1,char * sreg2){ int reg1 = getval(sreg1); int reg2 = getval(sreg2); int codesize = 0; if(!((reg1+1)&&(reg2+1))) {if(VERBOSE) printf("\nInstruction Result:%d",codesize); return 0;} buffer.s = 0; buffer.w = reg1>7?1:0; buffer.mod = 3; buffer.rm = reg2; buffer.reg =reg1; int t_opcode = _opcode(mnem); if (t_opcode==-1){ if(VERBOSE) printf("\nInstruction Result:%d",codesize); return 0; }//insert some error handling code here buffer.opcode = t_opcode; if(byte1(buffer)) { putc(byte1(buffer),fp);codesize++;} if(byte2(buffer)) { putc(byte2(buffer),fp);codesize++;} _clean(); if(VERBOSE) printf("\nInstruction Result:%d",codesize); return codesize; }
void exit(int status) { _calls(); if (_clean) _clean(); _exit(status) ; }
geos::geom::Polygon *WKBParser::_readPolygon() { int count = _is.readInt(); geos::geom::LinearRing *rind = NULL; std::vector<geos::geom::Geometry *> *holes=NULL; if ( count > 0 ) { try { if( count > 0 ) { rind = _readLinearRing(); } holes = new std::vector<geos::geom::Geometry *>(count-1); for (int i=0; i<count-1; i++) { geos::geom::Geometry *g = (geos::geom::Geometry *)_readLinearRing(); (*holes)[i] = g; } } catch (...) { if(holes) { _clean(holes); } if(rind) { delete rind; } AMIGO_LOG_E(TAG, "::_readPolygon() Read failed.\n"); return NULL; } } return _factory.createPolygon(rind, holes); }
bool IntegerRunLengthEncoder::initialise(size_t iRecordSize) { _clean(); m_iRecordSize = iRecordSize; // Buffer must hold at least 7 + 2 * 8 records, as the maximum object size // is 8 records, 2 of which are needed to detect a repeat, and 7 for the // offset at which the objects are found. m_iBufferSize = iRecordSize * 8 * 4; m_iBufferSizeUsed = 0; m_iBufferOffset = 0; m_pBuffer = new (std::nothrow) uint32_t[m_iBufferSize]; if(!m_pBuffer) return false; m_iOutputSize = iRecordSize * 32; m_iOutputSizeUsed = 0; m_pOutput = new (std::nothrow) uint32_t[m_iOutputSize]; if(!m_pOutput) return false; m_iObjectSize = 0; m_iObjectCount = 0; return true; }
void abort(void) { if (_clean) _clean(); /* flush all output files */ raise(SIGABRT); exit(-1); /* NORETURN */ }
Input::~Input() { if(_counter){ if(-- _counter == 0){ _clean(); } } }
Display::~Display() { if(_counter != 0){ if(--_counter == 0){ _clean(); } } }
bool IntegerRunLengthDecoder::initialise(size_t iRecordSize, LuaPersistReader *pReader) { _clean(); m_pBuffer = new (std::nothrow) uint32_t[9 * iRecordSize]; if(!m_pBuffer) return false; m_pReader = pReader; m_iRecordSize = iRecordSize; return pReader->readVUInt(m_iNumReadsRemaining); }
bool IntegerRunLengthDecoder::initialise(size_t iRecordSize, const uint32_t *pInput, size_t iCount) { _clean(); m_pBuffer = new (std::nothrow) uint32_t[9 * iRecordSize]; if(!m_pBuffer) return false; m_pInput = pInput; m_pInputEnd = pInput + iCount; m_iRecordSize = iRecordSize; return true; }
variant_int_string &operator=(variant_int_string const &x) { if (type == x.type) { if (type == String) as_string = x.as_string; else as_int = x.as_int; } else { _clean(); _copy_from(x); } return *this; }
void Tree<FeatType, FeatDim, nClasses>::load(const std::string &treePath, int idx) { boost::property_tree::ptree pt; boost::property_tree::read_xml(treePath, pt); if (idx!=-1) { m_id = idx; } unsigned int currDepth = pt.get<unsigned int>("Trees.MaxDepth"); if (!m_depth || m_depth!=currDepth) { _clean(); m_depth = currDepth; _init(); } for (unsigned int i=0; i<((2<<(m_depth-1))-1); i++) { std::stringstream nodeStream; const TreeNode<FeatType, FeatDim> &currNode = getNode(i); nodeStream << "Trees.Tree" << m_id << ".Node" << i << ".LeftChild"; *currNode.m_leftChild = pt.get<int>(nodeStream.str(), -2); if (*currNode.m_leftChild==-2) { // Node does not exists: fill with zeros std::fill_n(currNode.m_feature, FeatDim, 0); *currNode.m_threshold = 0; std::fill_n(currNode.m_posterior, nClasses, 0); } else if (*currNode.m_leftChild==-1) { // Leaf node std::stringstream histogramStream; nodeStream.str(""); nodeStream << "Trees.Tree" << m_id << ".Node" << i << ".Histogram"; histogramStream.str(pt.get<std::string>(nodeStream.str())); for (int l=0; l<nClasses; l++) { histogramStream >> currNode.m_posterior[l]; } std::fill_n(currNode.m_feature, FeatDim, 0); *currNode.m_threshold = 0; } else {
int code_1op_mem(char *mnem,char *ev) { int codesize=0; buffer.mod=00; buffer.rm = (*(ev+1)=='B'||*(ev+1)=='b')?6:7; if(!strcmp(mnem,"POP")||!(strcmp(mnem,"pop"))){ buffer.reg = 0; buffer.opc = 0xaf; int xt = extr(ev); if (!xt){ int tmp[2]; encode(tmp,xt); buffer.dispa=tmp[0]; buffer.dispb=tmp[1]; }} if(!strcmp(mnem,"PUSH")||!(strcmp(mnem,"push"))){ buffer.reg = 6; buffer.opc = 0xff; int xt = extr(ev); if (!xt){ int tmp[2]; encode(tmp,xt); buffer.dispa=tmp[0]; buffer.dispb=tmp[1]; } } if(buffer.opc){ putc(byte1(buffer),fp);codesize++;} if(byte2(buffer)) { putc(byte2(buffer),fp);codesize++;} if(buffer.rm==7) { putc(buffer.dispa,fp); putc(buffer.dispb,fp); codesize++; } _clean(); if(VERBOSE) printf("\nInstruction Result:%d",codesize); return codesize; }
void highOrderTools::computeStraightSidedPositions() { _clean(); // compute straigh sided positions that are actually X,Y,Z positions // that are NOT always on curves and surfaces // points classified on model vertices shall not move ! for(GModel::viter it = _gm->firstVertex(); it != _gm->lastVertex(); ++it){ if ((*it)->points.size()){ MPoint *p = (*it)->points[0]; MVertex *v = p->getVertex(0); _straightSidedLocation [v] = SVector3((*it)->x(),(*it)->y(),(*it)->z()); _targetLocation [v] = SVector3((*it)->x(),(*it)->y(),(*it)->z()); } } // printf("coucou2\n"); // compute stright sided positions of vertices that are classified on model edges for(GModel::eiter it = _gm->firstEdge(); it != _gm->lastEdge(); ++it){ for (unsigned int i=0;i<(*it)->lines.size();i++){ MLine *l = (*it)->lines[i]; int N = l->getNumVertices()-2; SVector3 p0((*it)->lines[i]->getVertex(0)->x(), (*it)->lines[i]->getVertex(0)->y(), (*it)->lines[i]->getVertex(0)->z()); SVector3 p1((*it)->lines[i]->getVertex(1)->x(), (*it)->lines[i]->getVertex(1)->y(), (*it)->lines[i]->getVertex(1)->z()); for (int j=1;j<=N;j++){ const double xi = (double)(j)/(N+1); // printf("xi = %g\n",xi); const SVector3 straightSidedPoint = p0 *(1.-xi) + p1*xi; MVertex *v = (*it)->lines[i]->getVertex(j+1); if (_straightSidedLocation.find(v) == _straightSidedLocation.end()){ _straightSidedLocation [v] = straightSidedPoint; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } } } } // printf("coucou3\n"); // compute stright sided positions of vertices that are classified on model faces for(GModel::fiter it = _gm->firstFace(); it != _gm->lastFace(); ++it){ for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++){ MVertex *v = (*it)->mesh_vertices[i]; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } for (unsigned int i=0;i<(*it)->triangles.size();i++){ MTriangle *t = (*it)->triangles[i]; MFace face = t->getFace(0); const nodalBasis* fs = t->getFunctionSpace(); for (int j=0;j<t->getNumVertices();j++){ if (t->getVertex(j)->onWhat() == *it){ const double t1 = fs->points(j, 0); const double t2 = fs->points(j, 1); SPoint3 pc = face.interpolate(t1, t2); _straightSidedLocation [t->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } for (unsigned int i=0;i<(*it)->quadrangles.size();i++){ // printf("coucou quad %d\n",i); MQuadrangle *q = (*it)->quadrangles[i]; MFace face = q->getFace(0); const nodalBasis* fs = q->getFunctionSpace(); for (int j=0;j<q->getNumVertices();j++){ if (q->getVertex(j)->onWhat() == *it){ const double t1 = fs->points(j, 0); const double t2 = fs->points(j, 1); SPoint3 pc = face.interpolate(t1, t2); _straightSidedLocation [q->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } } for(GModel::riter it = _gm->firstRegion(); it != _gm->lastRegion(); ++it){ for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++){ MVertex *v = (*it)->mesh_vertices[i]; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } for (unsigned int i=0;i<(*it)->tetrahedra.size();i++){ _dim = 3; MTetrahedron *t = (*it)->tetrahedra[i]; MTetrahedron t_1 ((*it)->tetrahedra[i]->getVertex(0), (*it)->tetrahedra[i]->getVertex(1), (*it)->tetrahedra[i]->getVertex(2), (*it)->tetrahedra[i]->getVertex(3)); const nodalBasis* fs = t->getFunctionSpace(); for (int j=0;j<t->getNumVertices();j++){ if (t->getVertex(j)->onWhat() == *it){ double t1 = fs->points(j, 0); double t2 = fs->points(j, 1); double t3 = fs->points(j, 2); SPoint3 pc; t_1.pnt(t1, t2, t3,pc); _straightSidedLocation [t->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } for (unsigned int i=0;i<(*it)->hexahedra.size();i++){ _dim = 3; MHexahedron *h = (*it)->hexahedra[i]; MHexahedron h_1 ((*it)->hexahedra[i]->getVertex(0), (*it)->hexahedra[i]->getVertex(1), (*it)->hexahedra[i]->getVertex(2), (*it)->hexahedra[i]->getVertex(3), (*it)->hexahedra[i]->getVertex(4), (*it)->hexahedra[i]->getVertex(5), (*it)->hexahedra[i]->getVertex(6), (*it)->hexahedra[i]->getVertex(7)); const nodalBasis* fs = h->getFunctionSpace(); for (int j=0;j<h->getNumVertices();j++){ if (h->getVertex(j)->onWhat() == *it){ double t1 = fs->points(j, 0); double t2 = fs->points(j, 1); double t3 = fs->points(j, 2); SPoint3 pc; h_1.pnt(t1, t2, t3,pc); _straightSidedLocation [h->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } } Msg::Info("highOrderTools has been set up : %d nodes are considered", _straightSidedLocation.size()); }
void abort(void) { if (_clean) _clean(); /* flush all output files */ raise(SIGABRT); }
Tree<FeatType, FeatDim, nClasses>::~Tree() { _clean(); }
IntegerRunLengthDecoder::IntegerRunLengthDecoder() { m_pBuffer = NULL; _clean(); }
IntegerRunLengthEncoder::~IntegerRunLengthEncoder() { _clean(); }
IntegerRunLengthEncoder::IntegerRunLengthEncoder() { m_pBuffer = NULL; m_pOutput = NULL; _clean(); }
GeomDepthCalculator::~GeomDepthCalculator() { _clean(); delete m_frame; delete m_frameWeights; }