Extension Name E57_ZF_InfraredTemperatureC XML namespace IR xmlns:ir="http://www.libe57.org/E57_ZF_InfraredTemperatureC.txt" Contact Franz Haertl (fh @ zofre.de) Contributors none. Version Last Modified Date: Mai 1, 2015 Revision: 1 Dependencies none. Overview This extension adds a temperature value to each point IP Status No known IP claims. New Fields New Fields none. New Fields Element Name Type Description "ir:temperatureBounds" Structure Point data temperature bound structure "ir:DataMin" Float The minimum temperature in the dataset "ir:DataMax" Float The maximum temperature in the dataset "ir:CamMin" Float The minimum temperature of the camera setting "ir:CamMax" Float The maximum temperature of the camera setting New PointRecord Fields Element Name Type Description "ir:TemperatureC" Float The temperature of the point as celsius XML Example ... -4.5200000000000003e+001 1.0600000000000001e+001 -2e+001 1e+002 ... ... ... Errors none. Sample Code ////////////////////////////////// // Writing Extension declaration// ////////////////////////////////// // FoundationAPI _imf.extensionsAdd("ir","http://www.libe57.org/E57_ZF_InfraredTemperatureC.txt"); ... // Sample API e57::Writer pWriter(...); pWriter.GetRawIMF().extensionsAdd("ir","http://www.libe57.org/E57_ZF_InfraredTemperatureC.txt"); /////////////////////////////// // Write temperature bounds ////////////////////////////// //Given good temperature bounds data double DataMin = ..; //The minimum temperature in the dataset double DataMax = ..; //The maximum temperature in the dataset double CamMin = ..; //The minimum temperature of the camera setting double CamMax = ..; //The maximum temperature of the camera setting integer scanIndex = ..; //Get the scan index ... // Sample API ImageFile _imf = pWriter.GetRawIMF(); VectorNode _data3D = pWriter.GetRawData3D(); if( (scanIndex < 0) || (scanIndex >= _data3D.childCount())) return false; // Both API //access the data3D structure StructureNode scan(_data3D.get(scanIndex)); StructureNode tempBounds = StructureNode(_imf); timeBounds.set("ir:DataMin", FloatNode(_imf,DataMin)); timeBounds.set("ir:DataMax", FloatNode(_imf,DataMax)); timeBounds.set("ir:CamMin", FloatNode(_imf,CamMin)); timeBounds.set("ir:CamMax", FloatNode(_imf,CamMax)); scan.set("ir:temperatureBounds", tempBounds); /////////////////////////////// // Write temperatur on points ////////////////////////////// // Setup PointRecord prototype ////////////////////////////// // Sample API // call back function bool ProtoTemperature( ImageFile imf, StructureNode proto) { proto.set("ir:TemperatureC", FloatNode(imf, 0, E57_SINGLE, E57_FLOAT_MIN, E57_FLOAT_MAX)); ... return true; }; // Setup main header e57::Data3D header; header.name = (char*) scanName; // Set the name of the scan ... // when registering a scan use the function pointer to the above ProtoTemperature(). int scanIndex = pWriter.NewData3D(header, &ProtoTemperature); ... //////////////////////////////////// // Foundation API StructureNode proto = StructureNode(imf_); ... proto.set("ir:TemperatureC", FloatNode(imf, 0, E57_SINGLE, E57_FLOAT_MIN, E57_FLOAT_MAX)); ... VectorNode codecs = VectorNode(imf_, true); CompressedVectorNode points = CompressedVectorNode(imf_, proto, codecs); scan.set("points", points); ////////////////////////// // Setup buffers ////////////////////////// // Sample API #define DATA_SIZE 1024 //buffer size; extern double * temperatureData; //call back function bool PointDataTemperature( ImageFile imf, StructureNode proto, vector & sourceBuffers) { if(proto.isDefined("ir:TemperatureC")) sourceBuffers.push_back(SourceDestBuffer(imf, "ir:TemperatureC", temperatureData, (unsigned) DATA_SIZE, true)); return true; } ... // setup the temperature extension buffer temperatureData = new double[DATA_SIZE]; if(temperatureData == NULL) throw E57_EXCEPTION2(E57_ERROR_INTERNAL,"Error: allocation of memory failed (E57_ERROR_INTERNAL)"); //set up the compressedVectorWriter object e57::CompressedVectorWriter CVWriter = pWriter.SetUpData3DPointsData( scanIndex, //!< data block index given by the NewData3D DATA_SIZE, //!< size of each of the buffers given xData, //!< pointer to a buffer with the x data yData, //!< pointer to a buffer with the y data zData, //!< pointer to a buffer with the z data isInvalidData, //!< pointer to a buffer with the valid cartesian indication intData, //!< pointer to a buffer with the lidar return intesity isInvalidInt, //!< pointer to a buffer with the valid intensity indication redData, //!< pointer to a buffer with the color red data greenData, //!< pointer to a buffer with the color green data blueData, //!< pointer to a buffer with the color blue data isInvalidColor, //!< pointer to a buffer with the valid color indication rData, //!< pointer to a buffer with the range data aData, //!< pointer to a buffer with the azimuth data eData, //!< pointer to a buffer with the elevation data isInvalidSpherical, //!< pointer to a buffer with the valid spherical indication rowIndex, //!< pointer to a buffer with the rowIndex columnIndex, //!< pointer to a buffer with the columnIndex returnIndex, //!< pointer to a buffer with the returnIndex returnCount, //!< pointer to a buffer with the returnCount timeStamp, //!< pointer to a buffer with the timeStamp data isInvalidTime, //!< pointer to a buffer with the valid time indication &PointDataTemperature); //!< call back pointer to adding extension buffers //////////////////////////////////// // Foundation API double * temperatureData = new double[DATA_SIZE]; ... StructureNode scan(data3D_.get(dataIndex)); CompressedVectorNode points(scan.get("points")); StructureNode proto(points.prototype()); vector sourceBuffers; ... if(proto.isDefined("ir:TemperatureC")) sourceBuffers.push_back(SourceDestBuffer(imf,"ir:TemperatureC", temperatureData, (unsigned) DATA_SIZE, true)); ... CompressedVectorWriter CVWriter = points.writer(sourceBuffers); ///////////////////////////////// // Both APIs // Write data ////////////////////////////// ... unsigned size; while(size = getYourData(..)) { for(long i = 0; i < DATA_SIZE; i++) { ... //get temperature and load buffer temperatureData[i] = getYourPointTemperature(..); ... } CVWriter.write(size); } CVWriter.close(); /////////////////////////// //Read temperature bounds data ///////////////////////// // Sample API e57::Reader pReader(....); ... VectorNode _data3D = pReader.GetRawData3D(); if( (scanIndex < 0) || (scanIndex >= _data3D.childCount())) return false; // Both API //access the data3D structure StructureNode scan(_data3D.get(scanIndex)); ustring url; if (pReader.GetRawIMF().extensionsLookupPrefix("ir", url)) { if(scan.isDefined("ir:temperatureBounds")) { StructureNode tempBounds(scan.get("ir:temperatureBounds")); if(tempBounds.isDefined("ir:DataMin")) DataMin = FloatNode(tempBounds.get("ir:DataMin")).value(); if(tempBounds.isDefined("ir:DataMax")) DataMax = FloatNode(tempBounds.get("ir:DataMax")).value(); if(tempBounds.isDefined("ir:CamMin")) DataMin = FloatNode(tempBounds.get("ir:CamMin")).value(); if(tempBounds.isDefined("ir:CamMax")) DataMax = FloatNode(tempBounds.get("ir:CamMax")).value(); } } /////////////////////////// //Read temperature data ///////////////////////// // Sample API #define DATA_SIZE 1024 //buffer size; extern double * temperatureData; // call back function bool PointDataTemperature( ImageFile imf, StructureNode proto, int protoIndex, vector & destBuffers) { ustring url; ustring name = proto.get(protoIndex).elementName(); NodeType type = proto.get(protoIndex).type(); bool scaled = type == E57_SCALED_INTEGER ? true : false; if(imf.extensionsLookupPrefix("ir", url)) { if((name.compare("ir:TemperatureC") == 0) && proto.isDefined("ir:TemperatureC") && temperatureData != NULL) ) { destBuffers.push_back(SourceDestBuffer(imf, "ir:TemperatureC", temperatureData, (unsigned) DATA_SIZE, true)); } return true; } return false; } e57::Reader pReader(....); ... // setup the temperature extension buffer ustring url; if (imf.extensionsLookupPrefix("ir", url)) { temperatureData = new double[(unsigned int) nSize]; if(temperatureData == NULL) throw E57_EXCEPTION2(E57_ERROR_INTERNAL,"Error: allocation of memory failed (E57_ERROR_INTERNAL)"); memset(temperatureData,0,(size_t)nSize); //clear array } e57::CompressedVectorReader CVReader = pReader.SetUpData3DPointsData( scanIndex, //!< data block index given by the NewData3D nSize, //!< size of each of the buffers given xData, //!< pointer to a buffer with the x data yData, //!< pointer to a buffer with the y data zData, //!< pointer to a buffer with the z data isXYZInvalid, //!< pointer to a buffer with the valid indication intData, //!< pointer to a buffer with the lidar return intensity intInvalid, redData, //!< pointer to a buffer with the color red data greenData, //!< pointer to a buffer with the color green data blueData, //!< pointer to a buffer with the color blue data colorInvalid, rData, aData, eData, isRAEInvalid, rowIndex, columnIndex, returnIndex, returnCount, timeStamp, timeInvalid, &PointDataTemperature //////////////////////////////////// // Foundation API double *temperatureData = NULL; ustring url; if (imf.extensionsLookupPrefix("ir", url)) { temperatureData = new double[DATA_SIZE]; } StructureNode scan(data3D_.get(dataIndex)); CompressedVectorNode points(scan.get("points")); StructureNode prototype(points.prototype()); ... int64_t protoCount = prototype.childCount(); int64_t protoIndex; vector destBuffers; for( protoIndex = 0; protoIndex < protoCount; protoIndex++) { ustring name = prototype.get(protoIndex).elementName(); NodeType type = prototype.get(protoIndex).type(); bool scaled = type == E57_SCALED_INTEGER ? true : false; ... ustring url; if((name.compare("ir:TemperatureC") == 0) && imf.extensionsLookupPrefix("ir", url) && proto.isDefined("ir:TemperatureC") && (temperatureData != NULL) ) destBuffers.push_back(SourceDestBuffer(imf, "ir:TemperatureC", temperatureData, (unsigned) DATA_SIZE, true)); ... } CompressedVectorReader CVReader = points.reader(destBuffers); ... ///////////////////////// // Both APIs // Read point data ///////////////////////// unsigned size = 0; while(size = CVReader.read()) { for(long i = 0; i < size; i++) { Point P(pCartesianX[i],pCartesianY[i],pCartesianZ[i]); ... if(temperatureData) float temperature = temperatureData[i]; ... } } Issues none. ASTM E57 Listed Submitted Date: Mai 2015 Revision History Revision 1 - Initial implementation Copyright Copyright (c) 2015 Franz Haertl (fh @ zofre.de), All Rights Reserved. Permission is hereby granted, free of charge, to any person or organization obtaining a copy of this extension and accompanying documentation covered by this license (this "Extension") to use, reproduce, display, distribute, execute, and transmit this Extension, and to prepare derivative works of this Extension, and to permit third-parties to whom this Extension is furnished to do so, all subject to the following: The copyright notices in this Extension and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of this Extension, in whole or in part, and all derivative works of this Extension, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. Disclaimer THIS EXTENSION IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THIS EXTENSION BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS EXTENSION OR THE USE OR OTHER DEALINGS IN THIS EXTENSION.