void OGRLineString::setPoints( int nPointsIn, OGRRawPoint * paoPointsIn, double * padfZ ) { setNumPoints( nPointsIn ); memcpy( paoPoints, paoPointsIn, sizeof(OGRRawPoint) * nPointsIn); /* -------------------------------------------------------------------- */ /* Check 2D/3D. */ /* -------------------------------------------------------------------- */ if( padfZ != NULL ) { int i, bIs3D = FALSE; for( i = 0; i < nPointsIn && !bIs3D; i++ ) { if( padfZ[i] != 0.0 ) bIs3D = TRUE; } if( !bIs3D ) padfZ = NULL; } if( padfZ == NULL ) { if( this->padfZ != NULL ) Make2D(); } else { Make3D(); memcpy( this->padfZ, padfZ, sizeof(double) * nPointsIn ); } }
void Reader::initialize() { pdal::Reader::initialize(); setNumPoints(m_numPoints); setPointCountType(PointCount_Fixed); setBounds(m_bounds); }
Sampler::Sampler( Sampler & input ) { setPortAddress( input.PortAddress() ); setNumPoints( input.NumPoints() ); setNumTriggerPoints( input.NumTriggerPoints() ); setTriggerLevel( input.TriggerLevel() ); setTimeOut( input.TimeOut() ); setSampleMethod( input.SampleMethod() ); setInterval( input.Interval() ); }
void APolygonalMesh::create(unsigned np, unsigned ni, unsigned nf) { createBuffer(np, ni); setNumPoints(np); setNumIndices(ni); m_numPolygons = nf; m_faceCounts->create(nf * 4); m_faceDrifts->create(nf * 4); }
Reader::Reader(const Options& options, const PointBuffer& buffer) : pdal::Reader(options) , m_buffer(buffer) { setNumPoints(buffer.getNumPoints()); setBounds(buffer.getSpatialBounds()); setSchema(buffer.getSchema()); setPointCountType(PointCount_Fixed); return; }
void Reader::initialize() { pdal::Reader::initialize(); Schema& schema = getSchemaRef(); schema = Schema(getDefaultDimensions()); setNumPoints(m_numPoints); setPointCountType(PointCount_Fixed); setBounds(m_bounds); }
Sampler & Sampler::operator = ( Sampler & input ) { if( this == &input ) { setPortAddress( input.PortAddress() ); setNumPoints( input.NumPoints() ); setNumTriggerPoints( input.NumTriggerPoints() ); setTriggerLevel( input.TriggerLevel() ); setTimeOut( input.TimeOut() ); setSampleMethod( input.SampleMethod() ); setInterval( input.Interval() ); } return *this; }
void OGRLineString::setPoints( int nPointsIn, double * padfX, double * padfY, double * padfZ ) { int i; /* -------------------------------------------------------------------- */ /* Check 2D/3D. */ /* -------------------------------------------------------------------- */ if( padfZ != NULL ) { int bIs3D = FALSE; for( i = 0; i < nPointsIn && !bIs3D; i++ ) { if( padfZ[i] != 0.0 ) bIs3D = TRUE; } if( !bIs3D ) padfZ = NULL; } #ifdef __WXOSX__ if( padfZ == NULL ) { Make2D(); return; } #else if( padfZ == NULL ) Make2D(); #endif else Make3D(); /* -------------------------------------------------------------------- */ /* Assign values. */ /* -------------------------------------------------------------------- */ setNumPoints( nPointsIn ); for( i = 0; i < nPointsIn; i++ ) { paoPoints[i].x = padfX[i]; paoPoints[i].y = padfY[i]; } if( this->padfZ != NULL ) memcpy( this->padfZ, padfZ, sizeof(double) * nPointsIn ); }
RandomMesh::RandomMesh(unsigned numFaces, const Vector3F & center, const float & size, int type) { createBuffer(numFaces * 4, numFaces * 4); Vector3F * p = points(); unsigned * idx = indices(); float rx, ry, rz, r, phi, theta; for(unsigned i = 0; i < numFaces; i++) { idx[i * 3] = i * 3; idx[i * 3 + 1] = i * 3 + 1; idx[i * 3 + 2] = i * 3 + 2; if(type == 0) { rx = (float(rand()%694) / 694.f - 0.5f) * 1.4f; ry = (float(rand()%594) / 594.f - 0.5f) * 1.4f; rz = (float(rand()%794) / 794.f - 0.5f) * 1.4f; } else { phi = ((float)(rand() % 25391)) / 25391.f * 2.f * 3.14f; theta = ((float)(rand() % 24331)) / 24331.f * 3.14f; r = ((float)(rand() % 24091)) / 24091.f * .1f + 0.9f; rx = sin(theta) * cos(phi); ry = sin(theta) * sin(phi); rz = cos(theta); } p[i * 3] = center + Vector3F(rx * size, ry * size, rz * size); rx = float(rand()%294) / 294.f - 0.5f; ry = float(rand()%594) / 594.f - 0.5f; rz = float(rand()%794) / 794.f - 0.5f; p[i * 3 + 1] = p[i * 3] + Vector3F(rx, ry, rz); rx = float(rand()%394) / 394.f - 0.5f; ry = float(rand()%594) / 594.f - 0.5f; rz = float(rand()%794) / 794.f - 0.5f; p[i * 3 + 2] = p[i * 3] + Vector3F(rx, ry, rz); } setNumPoints(numFaces * 3); setNumIndices(numFaces * 3); }
Reader::Reader(const Options& options) : pdal::Reader(options) , m_format(TERRASOLID_Format_Unknown) , m_haveColor(false) , m_haveTime(false) { std::string filename= getFileName(); std::istream* stream = FileUtils::openFile(filename); stream->seekg(0); TerraSolidHeaderPtr h(new TerraSolidHeader); m_header.swap(h); Utils::read_n(*m_header, *stream, sizeof(TerraSolidHeader)); if (m_header->RecogVal != 970401) throw terrasolid_error("Header identifier was not '970401', is this a TerraSolid .bin file?"); setNumPoints(m_header->PntCnt); m_haveColor = (m_header->Color != 0); m_haveTime = (m_header->Time != 0); m_format = static_cast<TERRASOLID_Format_Type>(m_header->HdrVersion); if (!((m_format==TERRASOLID_Format_1) || (m_format == TERRASOLID_Format_2))) { std::ostringstream oss; oss << "Version was '" << m_format << "', not '" << TERRASOLID_Format_1 << "' or '" << TERRASOLID_Format_2 << "'"; throw terrasolid_error(oss.str()); } registerFields(); m_offset = 56; const Schema& schema = getSchema(); m_size = schema.getByteSize(); delete stream; }
void OGRLineString::setPoint( int iPoint, double xIn, double yIn, double zIn ) { if( iPoint >= nPointCount ) setNumPoints( iPoint+1 ); paoPoints[iPoint].x = xIn; paoPoints[iPoint].y = yIn; if( zIn != 0.0 ) { Make3D(); padfZ[iPoint] = zIn; } else if( getCoordinateDimension() == 3 ) { padfZ[iPoint] = 0.0; } }
void MrsidReader::initialize() { const LizardTech::PointInfo& pointinfo = m_PS->getPointInfo(); Schema const& dimensions(getDefaultDimensions()); for (unsigned int i=0; i<pointinfo.getNumChannels(); i++) { const LizardTech::ChannelInfo &channel = pointinfo.getChannel(i); Dimension dim = LTChannelToPDalDimension(channel, dimensions); m_schema.appendDimension(dim); } setNumPoints(m_PS->getNumPoints()); pdal::Bounds<double> b(m_PS->getBounds().x.min, m_PS->getBounds().x.max, m_PS->getBounds().y.min, m_PS->getBounds().y.max, m_PS->getBounds().z.min,m_PS->getBounds().z.max); setBounds(b); m_iter = m_PS->createIterator(m_PS->getBounds(), 1.0, m_PS->getPointInfo(), NULL); }
OGRLinearRing::OGRLinearRing( OGRLinearRing * poSrcRing ) { if( poSrcRing == NULL ) { CPLDebug( "OGR", "OGRLinearRing::OGRLinearRing(OGRLinearRing*poSrcRing) - passed in ring is NULL!" ); return; } setNumPoints( poSrcRing->getNumPoints() ); memcpy( paoPoints, poSrcRing->paoPoints, sizeof(OGRRawPoint) * getNumPoints() ); if( poSrcRing->padfZ ) { Make3D(); memcpy( padfZ, poSrcRing->padfZ, sizeof(double) * getNumPoints() ); } }
void Reader::initialize() { pdal::Reader::initialize(); boost::scoped_ptr<PipelineManager> tmp(new PipelineManager()); m_manager.swap(tmp); PipelineReader xmlreader(*m_manager); bool isWriter = xmlreader.readPipeline(m_filename); if (isWriter) { throw pdal_error("pipeline file is not a Reader"); } m_stage = m_manager->getStage(); m_stage->initialize(); setNumPoints(m_stage->getNumPoints()); setPointCountType(m_stage->getPointCountType()); setBounds(m_stage->getBounds()); return; }
void Mosaic::initialize() { MultiFilter::initialize(); const std::vector<Stage*>& stages = getPrevStages(); const Stage& stage0 = *stages[0]; const SpatialReference& srs0 = stage0.getSpatialReference(); const Schema& schema0 = stage0.getSchema(); PointCountType pointCountType0 = stage0.getPointCountType(); boost::uint64_t totalPoints = stage0.getNumPoints(); Bounds<double> bigbox(stage0.getBounds()); // we will only mosaic if all the stages have the same core properties: SRS, schema, etc for (boost::uint32_t i=1; i<stages.size(); i++) { Stage& stage = *(stages[i]); if (stage.getSpatialReference() != srs0) throw impedance_invalid("mosaicked stages must have same srs"); if (stage.getSchema() != schema0) throw impedance_invalid("mosaicked stages must have same schema"); if (stage.getPointCountType() == PointCount_Unknown) pointCountType0 = PointCount_Unknown; totalPoints += stage.getNumPoints(); bigbox.grow(stage.getBounds()); } if (pointCountType0 == PointCount_Unknown) totalPoints = 0; setCoreProperties(stage0); setPointCountType(pointCountType0); setNumPoints(totalPoints); return; }
TriangleSystem::TriangleSystem(ATriangleMesh * md) { const unsigned np = md->numPoints(); create(md->numTriangles(), md->numTriangles(), np); Vector3F * p = md->points(); Vector3F * q = (Vector3F *)hostX(); unsigned i = 0; for(;i<np;i++) q[i] = p[i]; Vector3F * qi = (Vector3F *)hostXi(); for(i=0;i<np;i++) qi[i] = q[i]; Vector3F * vel = (Vector3F *)hostV(); for(i=0;i<np;i++) vel[i].setZero(); unsigned * ind = (unsigned *)md->indices(); unsigned * tris = hostTriangleIndices(); for(i=0; i< md->numIndices(); i++) tris[i] = ind[i]; unsigned * tetra = hostTetrahedronIndices(); for(i=0; i< md->numTriangles(); i++) { tetra[i*4] = ind[i*3]; tetra[i*4+1] = ind[i*3+1]; tetra[i*4+2] = ind[i*3+2]; tetra[i*4+3] = tetra[i*4+2]; } float * mass = hostMass(); for(i=0;i<np;i++) mass[i] = 1e20f; setNumPoints(np); setNumTetrahedrons(md->numTriangles()); setNumTriangles(md->numTriangles()); }
OGRErr OGRLinearRing::_importFromWkb( OGRwkbByteOrder eByteOrder, int b3D, unsigned char * pabyData, int nBytesAvailable ) { if( nBytesAvailable < 4 && nBytesAvailable != -1 ) return OGRERR_NOT_ENOUGH_DATA; /* -------------------------------------------------------------------- */ /* Get the vertex count. */ /* -------------------------------------------------------------------- */ int nNewNumPoints; memcpy( &nNewNumPoints, pabyData, 4 ); if( OGR_SWAP( eByteOrder ) ) nNewNumPoints = CPL_SWAP32(nNewNumPoints); setNumPoints( nNewNumPoints ); if( b3D ) Make3D(); else Make2D(); /* -------------------------------------------------------------------- */ /* Get the vertices */ /* -------------------------------------------------------------------- */ int i; if( !b3D ) memcpy( paoPoints, pabyData + 4, 16 * nPointCount ); else { for( int i = 0; i < nPointCount; i++ ) { memcpy( &(paoPoints[i].x), pabyData + 4 + 24 * i, 8 ); memcpy( &(paoPoints[i].y), pabyData + 4 + 24 * i + 8, 8 ); memcpy( padfZ + i, pabyData + 4 + 24 * i + 16, 8 ); } } /* -------------------------------------------------------------------- */ /* Byte swap if needed. */ /* -------------------------------------------------------------------- */ if( OGR_SWAP( eByteOrder ) ) { for( i = 0; i < nPointCount; i++ ) { CPL_SWAPDOUBLE( &(paoPoints[i].x) ); CPL_SWAPDOUBLE( &(paoPoints[i].y) ); if( b3D ) { CPL_SWAPDOUBLE( padfZ + i ); } } } return OGRERR_NONE; }
OGRErr OGRLinearRing::_importFromWkb( OGRwkbByteOrder eByteOrder, int b3D, unsigned char * pabyData, int nBytesAvailable ) { if( nBytesAvailable < 4 && nBytesAvailable != -1 ) return OGRERR_NOT_ENOUGH_DATA; /* -------------------------------------------------------------------- */ /* Get the vertex count. */ /* -------------------------------------------------------------------- */ int nNewNumPoints; memcpy( &nNewNumPoints, pabyData, 4 ); if( OGR_SWAP( eByteOrder ) ) nNewNumPoints = CPL_SWAP32(nNewNumPoints); /* Check if the wkb stream buffer is big enough to store * fetched number of points. * 16 or 24 - size of point structure */ int nPointSize = (b3D ? 24 : 16); if (nNewNumPoints < 0 || nNewNumPoints > INT_MAX / nPointSize) return OGRERR_CORRUPT_DATA; int nBufferMinSize = nPointSize * nNewNumPoints; if( nBytesAvailable != -1 && nBufferMinSize > nBytesAvailable - 4 ) { CPLError( CE_Failure, CPLE_AppDefined, "Length of input WKB is too small" ); return OGRERR_NOT_ENOUGH_DATA; } /* (Re)Allocation of paoPoints buffer. */ setNumPoints( nNewNumPoints ); if( b3D ) Make3D(); else Make2D(); /* -------------------------------------------------------------------- */ /* Get the vertices */ /* -------------------------------------------------------------------- */ int i = 0; if( !b3D ) { memcpy( paoPoints, pabyData + 4, 16 * nPointCount ); } else { for( int i = 0; i < nPointCount; i++ ) { memcpy( &(paoPoints[i].x), pabyData + 4 + 24 * i, 8 ); memcpy( &(paoPoints[i].y), pabyData + 4 + 24 * i + 8, 8 ); memcpy( padfZ + i, pabyData + 4 + 24 * i + 16, 8 ); } } /* -------------------------------------------------------------------- */ /* Byte swap if needed. */ /* -------------------------------------------------------------------- */ if( OGR_SWAP( eByteOrder ) ) { for( i = 0; i < nPointCount; i++ ) { CPL_SWAPDOUBLE( &(paoPoints[i].x) ); CPL_SWAPDOUBLE( &(paoPoints[i].y) ); if( b3D ) { CPL_SWAPDOUBLE( padfZ + i ); } } } return OGRERR_NONE; }
int main() { //Some Declarations (has to be here because this is C) RRHandle rrHandle; RRJobHandle jobHandle; char tempFolder[1024]; double val; char* modelFileName = "../models/test_1.xml"; char buf[2048]; char dataFile[1024]; char msg[1024]; // ------------------------------------------------------------- printf("Starting C program...\n"); rrHandle = createRRInstance(); if(!rrHandle) { printf("No handles...\n"); } else { printf("Handles allocated succesfully..\n"); } setLogLevel("Info"); strcpy(tempFolder, "../temp"); if(!setTempFolder(rrHandle, tempFolder)) { printf("The temp file folder \'%s\' do not exist. Exiting...\n", tempFolder); exit(0); } enableLoggingToConsole(); enableLoggingToFile(rrHandle); //loadSBML models in threads instead jobHandle = loadSBMLFromFileJob(rrHandle, modelFileName); //waitForJob will block until the thread haa finished //Instead, one can could check for activeJob, i.e. non blocking (see below) waitForJob(jobHandle); //Set parameters logMsg(clInfo, " ---------- SETTING PARAMETERS -------------"); //Setup instances with different variables val = 0; getValue(rrHandle, "k1", &val); setValue(rrHandle, "k1", val/(2.5)); setNumPoints(rrHandle, 500); setTimeEnd(rrHandle, 150); setTimeCourseSelectionList(rrHandle, "TIME S1"); //Simulate logMsg(clInfo, " ---------- SIMULATING ---------------------"); //Simulate them using a pool of threads.. jobHandle = simulateJob(rrHandle); waitForJob(jobHandle); //Write data to a file strcpy(dataFile, "oneJobData.dat"); strcat(msg,"Writing data to file: "); strcat(msg, dataFile); logMsg(clInfo, msg); writeRRData(rrHandle, dataFile); // Cleanup freeRRInstance(rrHandle); if(hasError()) { char* error = getLastError(); sprintf(buf, "Last error %s \n", error); } return 0; }
void ATetrahedronMesh::create(unsigned np, unsigned nt) { createBuffer(np, nt * 4); setNumPoints(np); setNumIndices(nt * 4); }
//! @cond Doxygen_Suppress OGRErr OGRLinearRing::_importFromWkb( OGRwkbByteOrder eByteOrder, int _flags, const unsigned char * pabyData, int nBytesAvailable, int& nBytesConsumedOut ) { nBytesConsumedOut = -1; if( nBytesAvailable < 4 && nBytesAvailable != -1 ) return OGRERR_NOT_ENOUGH_DATA; /* -------------------------------------------------------------------- */ /* Get the vertex count. */ /* -------------------------------------------------------------------- */ int nNewNumPoints = 0; memcpy( &nNewNumPoints, pabyData, 4 ); if( OGR_SWAP( eByteOrder ) ) nNewNumPoints = CPL_SWAP32(nNewNumPoints); // Check if the wkb stream buffer is big enough to store // fetched number of points. // 16, 24, or 32 - size of point structure. int nPointSize = 0; if( (_flags & OGR_G_3D) && (_flags & OGR_G_MEASURED) ) nPointSize = 32; else if( (_flags & OGR_G_3D) || (_flags & OGR_G_MEASURED) ) nPointSize = 24; else nPointSize = 16; if( nNewNumPoints < 0 || nNewNumPoints > INT_MAX / nPointSize ) return OGRERR_CORRUPT_DATA; int nBufferMinSize = nPointSize * nNewNumPoints; if( nBytesAvailable != -1 && nBufferMinSize > nBytesAvailable - 4 ) { CPLError( CE_Failure, CPLE_AppDefined, "Length of input WKB is too small" ); return OGRERR_NOT_ENOUGH_DATA; } // (Re)Allocation of paoPoints buffer. setNumPoints( nNewNumPoints, FALSE ); if( _flags & OGR_G_3D ) Make3D(); else Make2D(); if( _flags & OGR_G_MEASURED ) AddM(); else RemoveM(); nBytesConsumedOut = 4 + nPointCount * nPointSize; /* -------------------------------------------------------------------- */ /* Get the vertices */ /* -------------------------------------------------------------------- */ if( (flags & OGR_G_3D) && (flags & OGR_G_MEASURED) ) { for( int i = 0; i < nPointCount; i++ ) { memcpy( &(paoPoints[i].x), pabyData + 4 + 32 * i, 8 ); memcpy( &(paoPoints[i].y), pabyData + 4 + 32 * i + 8, 8 ); memcpy( padfZ + i, pabyData + 4 + 32 * i + 16, 8 ); memcpy( padfM + i, pabyData + 4 + 32 * i + 24, 8 ); } } else if( flags & OGR_G_MEASURED ) { for( int i = 0; i < nPointCount; i++ ) { memcpy( &(paoPoints[i].x), pabyData + 4 + 24 * i, 8 ); memcpy( &(paoPoints[i].y), pabyData + 4 + 24 * i + 8, 8 ); memcpy( padfM + i, pabyData + 4 + 24 * i + 16, 8 ); } } else if( flags & OGR_G_3D ) { for( int i = 0; i < nPointCount; i++ ) { memcpy( &(paoPoints[i].x), pabyData + 4 + 24 * i, 8 ); memcpy( &(paoPoints[i].y), pabyData + 4 + 24 * i + 8, 8 ); memcpy( padfZ + i, pabyData + 4 + 24 * i + 16, 8 ); } } else { memcpy( paoPoints, pabyData + 4, 16 * nPointCount ); } /* -------------------------------------------------------------------- */ /* Byte swap if needed. */ /* -------------------------------------------------------------------- */ if( OGR_SWAP( eByteOrder ) ) { for( int i = 0; i < nPointCount; i++ ) { CPL_SWAPDOUBLE( &(paoPoints[i].x) ); CPL_SWAPDOUBLE( &(paoPoints[i].y) ); if( flags & OGR_G_3D ) { CPL_SWAPDOUBLE( padfZ + i ); } if( flags & OGR_G_MEASURED ) { CPL_SWAPDOUBLE( padfM + i ); } } } return OGRERR_NONE; }
void ATriangleMesh::create(unsigned np, unsigned nt) { createBuffer(np, nt * 3); setNumPoints(np); setNumIndices(nt * 3); }
void OGRLineString::empty() { setNumPoints( 0 ); }
OGRErr OGRLineString::importFromWkb( unsigned char * pabyData, int nBytesAvailable ) { OGRwkbByteOrder eByteOrder; if( nBytesAvailable < 21 && nBytesAvailable != -1 ) return OGRERR_NOT_ENOUGH_DATA; /* -------------------------------------------------------------------- */ /* Get the byte order byte. */ /* -------------------------------------------------------------------- */ eByteOrder = (OGRwkbByteOrder) *pabyData; assert( eByteOrder == wkbXDR || eByteOrder == wkbNDR ); /* -------------------------------------------------------------------- */ /* Get the geometry feature type. For now we assume that */ /* geometry type is between 0 and 255 so we only have to fetch */ /* one byte. */ /* -------------------------------------------------------------------- */ OGRwkbGeometryType eGeometryType; int bIs3D; if( eByteOrder == wkbNDR ) { eGeometryType = (OGRwkbGeometryType) pabyData[1]; bIs3D = (pabyData[2] & 0x80); } else { eGeometryType = (OGRwkbGeometryType) pabyData[4]; bIs3D = (pabyData[3] & 0x80); } assert( eGeometryType == wkbLineString ); /* -------------------------------------------------------------------- */ /* Get the vertex count. */ /* -------------------------------------------------------------------- */ int nNewNumPoints; memcpy( &nNewNumPoints, pabyData + 5, 4 ); if( OGR_SWAP( eByteOrder ) ) nNewNumPoints = CPL_SWAP32(nNewNumPoints); setNumPoints( nNewNumPoints ); if( bIs3D ) Make3D(); else Make2D(); /* -------------------------------------------------------------------- */ /* Get the vertex. */ /* -------------------------------------------------------------------- */ int i; if( bIs3D ) { for( i = 0; i < nPointCount; i++ ) { memcpy( paoPoints + i, pabyData + 9 + i*24, 16 ); memcpy( padfZ + i, pabyData + 9 + 16 + i*24, 8 ); } } else { memcpy( paoPoints, pabyData + 9, 16 * nPointCount ); } /* -------------------------------------------------------------------- */ /* Byte swap if needed. */ /* -------------------------------------------------------------------- */ if( OGR_SWAP( eByteOrder ) ) { for( i = 0; i < nPointCount; i++ ) { CPL_SWAPDOUBLE( &(paoPoints[i].x) ); CPL_SWAPDOUBLE( &(paoPoints[i].y) ); } if( bIs3D ) { for( i = 0; i < nPointCount; i++ ) { CPL_SWAPDOUBLE( padfZ + i ); } } } return OGRERR_NONE; }