Skip to content

Commit

Permalink
make SchemaLayout go away; update swig
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgerlek committed Sep 29, 2011
1 parent 7044413 commit e693cc0
Show file tree
Hide file tree
Showing 31 changed files with 107 additions and 113 deletions.
1 change: 0 additions & 1 deletion apps/pcinfo.cpp
Expand Up @@ -39,7 +39,6 @@

#include <pdal/Stage.hpp>
#include <pdal/StageIterator.hpp>
#include <pdal/SchemaLayout.hpp>
#include <pdal/FileUtils.hpp>
#include <pdal/PointBuffer.hpp>
#include <pdal/filters/StatsFilter.hpp>
Expand Down
1 change: 0 additions & 1 deletion apps/pcview/main.cpp
Expand Up @@ -47,7 +47,6 @@
#include <pdal/drivers/las/Reader.hpp>
#include <pdal/PointBuffer.hpp>
#include <pdal/Schema.hpp>
#include <pdal/SchemaLayout.hpp>
#include <pdal/Bounds.hpp>
#include <pdal/Dimension.hpp>
#include <pdal/StageIterator.hpp>
Expand Down
167 changes: 98 additions & 69 deletions csharp/pdal_swig_cpp/pdal.i
Expand Up @@ -37,15 +37,17 @@
%{
#include <iostream>

#include "pdal/external/boost/uuid/uuid.hpp"

#include "pdal/pdal_config.hpp"

#include "pdal/Bounds.hpp"
#include "pdal/Range.hpp"

#include "pdal/DimensionId.hpp"
#include "pdal/Dimension.hpp"
#include "pdal/DimensionLayout.hpp"
#include "pdal/Schema.hpp"
#include "pdal/SchemaLayout.hpp"
#include "pdal/PointBuffer.hpp"
#include "pdal/SpatialReference.hpp"

Expand Down Expand Up @@ -231,60 +233,97 @@ public:
};



class Dimension
class DimensionId
{
public:
enum Field

enum Id
{
Field_INVALID = 0,
Field_X,
Field_Y,
Field_Z,
Field_Intensity,
Field_ReturnNumber,
Field_NumberOfReturns,
Field_ScanDirectionFlag,
Field_EdgeOfFlightLine,
Field_Classification,
Field_ScanAngleRank,
Field_UserData,
Field_PointSourceId,
Field_Time,
Field_Red,
Field_Green,
Field_Blue,
Field_WavePacketDescriptorIndex,
Field_WaveformDataOffset,
Field_ReturnPointWaveformLocation,
Field_WaveformXt,
Field_WaveformYt,
Field_WaveformZt,
Field_Alpha,
// ...

// add more here
Field_User1 = 512,
Field_User2,
Field_User3,
Field_User4,
Field_User5,
Field_User6,
Field_User7,
Field_User8,
Field_User9,
Field_User10,
Field_User11,
Field_User12,
Field_User13,
Field_User14,
Field_User15,
// ...
// feel free to use your own int here

Field_LAST = 1023
//
// common field types: 0..999
//
X_i32 = 0,
Y_i32,
Z_i32,
X_f64,
Y_f64,
Z_f64,

Red_u8,
Green_u8,
Blue_u8,
Red_u16,
Green_u16,
Blue_u16,

Time_u64,

//
// LAS: 1000..1999
//
Las_Intensity = 1000,
Las_ReturnNumber,
Las_NumberOfReturns,
Las_ScanDirectionFlag,
Las_EdgeOfFlightLine,
Las_Classification,
Las_ScanAngleRank,
Las_UserData,
Las_PointSourceId,
Las_WavePacketDescriptorIndex,
Las_WaveformDataOffset,
Las_ReturnPointWaveformLocation,
Las_WaveformXt,
Las_WaveformYt,
Las_WaveformZt,
Las_Time,

//
// terrasolid: 2000..2999
//
TerraSolid_Alpha = 2000,
TerraSolid_Classification,
TerraSolid_PointSourceId_u8,
TerraSolid_PointSourceId_u16,
TerraSolid_ReturnNumber_u8,
TerraSolid_ReturnNumber_u16,
TerraSolid_Flag,
TerraSolid_Mark,
TerraSolid_Intensity,
TerraSolid_Time,

//
// chipper stuff: 3000..3999
//
Chipper_1 = 3000,
Chipper_2,

//
// qfit: 4000..4999
//
Qfit_StartPulse = 4000,
Qfit_ReflectedPulse,
Qfit_ScanAngleRank,
Qfit_Pitch,
Qfit_Roll,
Qfit_Time,
Qfit_PassiveSignal,
Qfit_PassiveX,
Qfit_PassiveY,
Qfit_PassiveZ,
Qfit_GpsTime,
Qfit_PDOP,
Qfit_PulseWidth,

// user fields are 100,000..199,999

Undefined = 200000
};
};

class Dimension
{
public:
enum DataType
{
Int8,
Expand All @@ -295,24 +334,25 @@ public:
Uint32,
Int64,
Uint64,
Pointer, // stored as 64 bits, even on a 32-bit box
Float, // 32 bits
Double, // 64 bits
Undefined
};

public:
Dimension(Field field, DataType type);
Dimension(DimensionId::Id id);

std::string const& getFieldName() const;
Field getField() const;
DimensionId::Id getId() const;

DataType getDataType() const;
static std::string getDataTypeName(DataType);
static DataType getDataTypeFromString(const std::string&);
static std::size_t getDataTypeSize(DataType);
static bool getDataTypeIsNumeric(DataType);
static bool getDataTypeIsSigned(DataType);
static bool getDataTypeIsInteger(DataType);
static std::string const& getFieldName(Field);
std::string const& getName();
std::size_t getByteSize() const;
inline std::string getDescription() const;
inline void setDescription(std::string const& v);
Expand Down Expand Up @@ -358,17 +398,10 @@ public:
Schema();
const Dimension& getDimension(std::size_t index) const;
const std::vector<Dimension>& getDimensions() const;
int getDimensionIndex(Dimension::Field field, Dimension::DataType datatype) const;
int getDimensionIndex(DimensionId::Id) const;
int getDimensionIndex(const Dimension& dim) const;
bool hasDimension(Dimension::Field field, Dimension::DataType datatype) const;
bool hasDimension(const Dimension& dim) const;
};
bool hasDimension(const DimensionId::Id&) const;

class SchemaLayout
{
public:
SchemaLayout(const Schema&);
const Schema& getSchema() const;
std::size_t getByteSize() const;
const DimensionLayout& getDimensionLayout(std::size_t index) const;
};
Expand All @@ -377,17 +410,13 @@ public:
class PointBuffer
{
public:
PointBuffer(const SchemaLayout&, boost::uint32_t capacity);
PointBuffer(const Schema&, boost::uint32_t capacity);
const Bounds<double>& getSpatialBounds() const;
void setSpatialBounds(const Bounds<double>& bounds);
boost::uint32_t getNumPoints() const;
void setNumPoints(boost::uint32_t v);
boost::uint32_t& getNumPointsRef();
boost::uint32_t getCapacity() const;
const SchemaLayout& getSchemaLayout() const;
const Schema& getSchema() const;
//SchemaLayout& getSchemaLayout();
//Schema& getSchema();
template<class T> T getField(std::size_t pointIndex, boost::int32_t fieldIndex) const;
template<class T> void setField(std::size_t pointIndex, boost::int32_t fieldIndex, T value);
void setFieldData(std::size_t pointIndex, boost::int32_t fieldIndex, const boost::uint8_t* data);
Expand Down Expand Up @@ -652,7 +681,7 @@ public:
void setPointFormat(PointFormat);
void setDate(boost::uint16_t dayOfYear, boost::uint16_t year);

void setProjectId(const boost::uuids::uuid&);
void setProjectId(const pdal::external::boost::uuids::uuid&);

// up to 32 chars (default is "PDAL")
void setSystemIdentifier(const std::string& systemId);
Expand Down
4 changes: 2 additions & 2 deletions csharp/pdal_swig_cs/pdal_swig_cs.csproj
Expand Up @@ -89,6 +89,7 @@
<ItemGroup>
<Compile Include="Bounds_double.cs" />
<Compile Include="Dimension.cs" />
<Compile Include="DimensionId.cs" />
<Compile Include="DimensionLayout.cs" />
<Compile Include="EndianType.cs" />
<Compile Include="Filter.cs" />
Expand All @@ -112,7 +113,6 @@
<Compile Include="Reader.cs" />
<Compile Include="ReaderBase.cs" />
<Compile Include="Schema.cs" />
<Compile Include="SchemaLayout.cs" />
<Compile Include="SpatialReference.cs" />
<Compile Include="Stage.cs" />
<Compile Include="StageBase.cs" />
Expand All @@ -126,10 +126,10 @@
<Compile Include="std_vector_Range_double.cs" />
<Compile Include="std_vector_u8.cs" />
<Compile Include="SWIGTYPE_p_boost__property_tree__ptree.cs" />
<Compile Include="SWIGTYPE_p_boost__uuids__uuid.cs" />
<Compile Include="SWIGTYPE_p_char.cs" />
<Compile Include="SWIGTYPE_p_f_enum_std__ios_base__event_r_std__ios_base_int__void.cs" />
<Compile Include="SWIGTYPE_p_long.cs" />
<Compile Include="SWIGTYPE_p_pdal__external__boost__uuids__uuid.cs" />
<Compile Include="SWIGTYPE_p_p_unsigned_char.cs" />
<Compile Include="SWIGTYPE_p_p_void.cs" />
<Compile Include="SWIGTYPE_p_std__basic_streambufT_char_std__char_traitsT_char_t_t.cs" />
Expand Down
2 changes: 1 addition & 1 deletion csharp/pdal_swig_test/TestDimension.cs
Expand Up @@ -20,7 +20,7 @@ private void Test1()
string s = Dimension.getDataTypeName(Dimension.DataType.Double);
Assert(s == "Double");

Dimension d = new Dimension(Dimension.Field.Field_Blue, Dimension.DataType.Float);
Dimension d = new Dimension(DimensionId.Id.Blue_u16);

return;
}
Expand Down
9 changes: 4 additions & 5 deletions csharp/pdal_swig_test/TestLasReader.cs
Expand Up @@ -30,13 +30,12 @@ private void Test1()
// create the point buffer we'll read into
// make it only hold 128 points a time, so we can show iterating
Schema schema = reader.getSchema();
SchemaLayout layout = new SchemaLayout(schema);
PointBuffer data = new PointBuffer(layout, 128);
PointBuffer data = new PointBuffer(schema, 128);

// get the dimensions (fields) of the point record for the X, Y, and Z values
int offsetX = schema.getDimensionIndex(Dimension.Field.Field_X, Dimension.DataType.Int32);
int offsetY = schema.getDimensionIndex(Dimension.Field.Field_Y, Dimension.DataType.Int32);
int offsetZ = schema.getDimensionIndex(Dimension.Field.Field_Z, Dimension.DataType.Int32);
int offsetX = schema.getDimensionIndex(DimensionId.Id.X_i32);
int offsetY = schema.getDimensionIndex(DimensionId.Id.Y_i32);
int offsetZ = schema.getDimensionIndex(DimensionId.Id.Z_i32);
Dimension dimensionX = schema.getDimension((uint)offsetX);
Dimension dimensionY = schema.getDimension((uint)offsetY);
Dimension dimensionZ = schema.getDimension((uint)offsetZ);
Expand Down
4 changes: 0 additions & 4 deletions include/pdal/PointBuffer.hpp
Expand Up @@ -106,8 +106,6 @@ class PDAL_DLL PointBuffer
// (later, this will be implemented properly, to handle the general cases slowly and the best case quickly)
inline void copyPointFast(std::size_t destPointIndex, std::size_t srcPointIndex, const PointBuffer& srcPointBuffer)
{
// assert(getSchemaLayout() == srcPointBuffer.getSchemaLayout());

const boost::uint8_t* src = srcPointBuffer.getData(srcPointIndex);
boost::uint8_t* dest = getData(destPointIndex);
const std::size_t len = getSchema().getByteSize();
Expand All @@ -122,8 +120,6 @@ class PDAL_DLL PointBuffer
// same as above, but copies N points
inline void copyPointsFast(std::size_t destPointIndex, std::size_t srcPointIndex, const PointBuffer& srcPointBuffer, std::size_t numPoints)
{
// assert(getSchemaLayout() == srcPointBuffer.getSchemaLayout());

const boost::uint8_t* src = srcPointBuffer.getData(srcPointIndex);
boost::uint8_t* dest = getData(destPointIndex);
const std::size_t len = getSchema().getByteSize();
Expand Down
Empty file removed include/pdal/SchemaLayout.hpp
Empty file.
1 change: 0 additions & 1 deletion include/pdal/XMLSchema.hpp
Expand Up @@ -37,7 +37,6 @@

#include <pdal/pdal.hpp>
#include <pdal/Schema.hpp>
#include <pdal/SchemaLayout.hpp>
#include <pdal/Dimension.hpp>
#include <pdal/DimensionLayout.hpp>

Expand Down
2 changes: 0 additions & 2 deletions include/pdal/drivers/qfit/Reader.hpp
Expand Up @@ -40,8 +40,6 @@
#include <pdal/Reader.hpp>
#include <pdal/Options.hpp>

#include <pdal/SchemaLayout.hpp>

#include <pdal/StageIterator.hpp>


Expand Down
3 changes: 0 additions & 3 deletions include/pdal/drivers/terrasolid/Reader.hpp
Expand Up @@ -40,11 +40,8 @@
#include <pdal/Reader.hpp>
#include <pdal/Options.hpp>

#include <pdal/SchemaLayout.hpp>

#include <pdal/StageIterator.hpp>


#include <vector>

#include <boost/detail/endian.hpp>
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -44,7 +44,6 @@ set(PDAL_BASE_HPP
${PDAL_HEADERS_DIR}/Reader.hpp
${PDAL_HEADERS_DIR}/ReaderIterator.hpp
${PDAL_HEADERS_DIR}/Schema.hpp
${PDAL_HEADERS_DIR}/SchemaLayout.hpp
${PDAL_HEADERS_DIR}/SpatialReference.hpp
${PDAL_HEADERS_DIR}/Stage.hpp
${PDAL_HEADERS_DIR}/StageBase.hpp
Expand Down Expand Up @@ -82,7 +81,6 @@ set(PDAL_BASE_CPP
Reader.cpp
ReaderIterator.cpp
Schema.cpp
SchemaLayout.cpp
SpatialReference.cpp
Stage.cpp
StageBase.cpp
Expand Down
Empty file removed src/SchemaLayout.cpp
Empty file.
1 change: 0 additions & 1 deletion src/drivers/faux/Reader.cpp
Expand Up @@ -35,7 +35,6 @@
#include <pdal/drivers/faux/Reader.hpp>

#include <pdal/drivers/faux/Iterator.hpp>
#include <pdal/SchemaLayout.hpp>
#include <pdal/PointBuffer.hpp>


Expand Down
1 change: 0 additions & 1 deletion src/drivers/las/Writer.cpp
Expand Up @@ -45,7 +45,6 @@
#endif

#include <pdal/Stage.hpp>
#include <pdal/SchemaLayout.hpp>
#include <pdal/PointBuffer.hpp>

#include <iostream>
Expand Down

0 comments on commit e693cc0

Please sign in to comment.