diff --git a/qmake/c++/c++.pro b/qmake/c++/c++.pro deleted file mode 100644 index 2d988ec..0000000 --- a/qmake/c++/c++.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS += libstl diff --git a/qmake/c++/libstl/libstl.pro b/qmake/c++/libstl/libstl.pro deleted file mode 100644 index 1aa0b65..0000000 --- a/qmake/c++/libstl/libstl.pro +++ /dev/null @@ -1,56 +0,0 @@ -isEmpty(PREFIX_DIR) { - PREFIX_DIR = ../../.. -} - -include(../../config.pri) - -message($$PREFIX_DIR) - -TEMPLATE = lib -TARGET = fougstl-c++$$TARGET_SUFFIX -DESTDIR = $$PREFIX_DIR/lib - -DEFINES *= FOUG_USE_STDINT_H - -dll { - DEFINES *= FOUG_STL_DLL FOUG_STL_MAKE_DLL -} - -#*g++*:QMAKE_CXXFLAGS_RELEASE -= -O2 -#*g++*:QMAKE_CXXFLAGS_RELEASE += -O3 - -INCLUDEPATH += ../../../src - -HEADERS += \ - ../../../src/c++/io_base.h \ - ../../../src/c++/foug_global.h \ - ../../../src/c++/abstract_task_progress.h \ - ../../../src/c++/abstract_stream.h \ - ../../../src/c++/streams/std_io_stream.h \ - ../../../src/c++/streams/qt4_stream.h \ - ../../../src/c++/libstl/abstract_geometry.h \ - ../../../src/c++/libstl/stlb.h \ - ../../../src/c++/libstl/stla.h \ - ../../../src/c++/libstl/stl_global.h - -SOURCES += \ - ../../../src/c++/io_base.cpp \ - ../../../src/c++/abstract_task_progress.cpp \ -# ../../src/streams/std_io_stream.cpp \ - ../../../src/c++/streams/qt4_stream.cpp \ - ../../../src/c++/libstl/stlb.cpp \ - ../../../src/c++/libstl/stla.cpp - -global_inc.path = $$PREFIX_DIR/include/datax -global_inc.files = ../../../src/*.h -cpp_global_inc.path = $$PREFIX_DIR/include/datax/c++ -cpp_global_inc.files = ../../../src/c++/*.h -cpp_streams_inc.path = $$PREFIX_DIR/include/datax/c++/streams -cpp_streams_inc.files = ../../../src/c++/streams/*.h -cpp_libstl_inc.path = $$PREFIX_DIR/include/datax/c++/libstl -cpp_libstl_inc.files = ../../../src/c++/libstl/*.h -INSTALLS += global_inc cpp_global_inc cpp_streams_inc cpp_libstl_inc - -VER_MAJ = 0 -VER_MIN = 1 -VER_PAT = 0 diff --git a/src/c++/abstract_stream.h b/src/c++/abstract_stream.h deleted file mode 100644 index bcb3a0d..0000000 --- a/src/c++/abstract_stream.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef FOUG_CPP_ABSTRACT_STREAM_H -#define FOUG_CPP_ABSTRACT_STREAM_H - -#include "foug_global.h" - -namespace foug { - -class AbstractStream -{ -public: - virtual bool atEnd() const = 0; - - virtual bool isWritable() const = 0; - virtual bool isReadable() const = 0; - virtual bool isSequential() const = 0; - - virtual bool seek(int64_t pos) = 0; - virtual int64_t read(char* data, int64_t maxSize) = 0; - virtual int64_t write(const char* data, int64_t maxSize) = 0; -}; - -} // namespace foug - -#endif // FOUG_CPP_ABSTRACT_STREAM_H diff --git a/src/c++/abstract_task_progress.cpp b/src/c++/abstract_task_progress.cpp deleted file mode 100644 index c177eec..0000000 --- a/src/c++/abstract_task_progress.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include "abstract_task_progress.h" - -#include -#include - -namespace foug { - -namespace internal { - -class AbstractTaskProgressPrivate -{ -public: - AbstractTaskProgressPrivate() - : m_stepId(-1), - m_value(-1.), - m_rangeMin(-1.), - m_rangeMax(-2.), - m_rangeLength(0.), - m_progressThreshold(0.01), // Notifies each percent only - m_isTaskStopRequested(false) - { - } - - int m_stepId; - double m_value; - double m_rangeMin; - double m_rangeMax; - double m_rangeLength; - double m_progressThreshold; - bool m_isTaskStopRequested; -}; - -} // namespace internal - -AbstractTaskProgress::AbstractTaskProgress() - : d(new internal::AbstractTaskProgressPrivate) -{ -} - -AbstractTaskProgress::~AbstractTaskProgress() -{ - delete d; -} - -double AbstractTaskProgress::rangeMin() const -{ - return d->m_rangeMin; -} - -double AbstractTaskProgress::rangeMax() const -{ - return d->m_rangeMax; -} - -void AbstractTaskProgress::setRange(double min, double max) -{ - d->m_rangeMin = min; - d->m_rangeMax = max; - d->m_rangeLength = max - min; -} - -int AbstractTaskProgress::stepId() const -{ - return d->m_stepId; -} - -void AbstractTaskProgress::setStepId(int id) -{ - d->m_stepId = id; -} - -double AbstractTaskProgress::progress() const -{ - const double result = (d->m_value - d->m_rangeMin) / d->m_rangeLength; - return std::fabs(result); -} - -double AbstractTaskProgress::value() const -{ - return d->m_value; -} - -void AbstractTaskProgress::setValue(double v) -{ - if (std::fabs(v - d->m_value) > std::fabs(d->m_progressThreshold * d->m_rangeLength)) { - d->m_value = v; - this->progressUpdateEvent(); - } -} - -double AbstractTaskProgress::progressUpdateThreshold() const -{ - return d->m_progressThreshold; -} - -void AbstractTaskProgress::setProgressUpdateThreshold(double v) -{ - d->m_progressThreshold = v; -} - -void AbstractTaskProgress::asyncTaskStop() -{ - d->m_isTaskStopRequested = true; -} - -bool AbstractTaskProgress::isTaskStopRequested() const -{ - return d->m_isTaskStopRequested; -} - -void AbstractTaskProgress::taskStoppedEvent() -{ - d->m_isTaskStopRequested = false; -} - -void AbstractTaskProgress::reset() -{ - d->m_stepId = -1; - d->m_value = -1.; - d->m_rangeMin = -1.; - d->m_rangeMax = -2.; - d->m_isTaskStopRequested = false; -} - -} // namespace foug diff --git a/src/c++/abstract_task_progress.h b/src/c++/abstract_task_progress.h deleted file mode 100644 index 83e3ce8..0000000 --- a/src/c++/abstract_task_progress.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef FOUG_CPP_ABSTRACT_TASK_PROGRESS_H -#define FOUG_CPP_ABSTRACT_TASK_PROGRESS_H - -namespace foug { - -namespace internal { class AbstractTaskProgressPrivate; } - -class AbstractTaskProgress -{ -public: - AbstractTaskProgress(); - virtual ~AbstractTaskProgress(); - - double rangeMin() const; - double rangeMax() const; - void setRange(double min, double max); - - int stepId() const; - void setStepId(int id); - - double progress() const; - double value() const; - void setValue(double v); - - double progressUpdateThreshold() const; - void setProgressUpdateThreshold(double v); - - virtual void reset(); - - void asyncTaskStop(); - bool isTaskStopRequested() const; - virtual void taskStoppedEvent(); - - virtual void progressUpdateEvent() = 0; - -private: - internal::AbstractTaskProgressPrivate* const d; -}; - -} // namespace foug - -#endif // FOUG_CPP_ABSTRACT_TASK_PROGRESS_H diff --git a/src/c++/foug_global.h b/src/c++/foug_global.h deleted file mode 100644 index 6313580..0000000 --- a/src/c++/foug_global.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef FOUG_CPP_GLOBAL_H -#define FOUG_CPP_GLOBAL_H - -#include "../c/global.h" - -namespace foug { - -typedef foug_real32_t Real32; -typedef foug_real64_t Real64; - -} // namespace foug - -#endif // FOUG_CPP_GLOBAL_H diff --git a/src/c++/io_base.cpp b/src/c++/io_base.cpp deleted file mode 100644 index 31b33c9..0000000 --- a/src/c++/io_base.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "io_base.h" - -#include "abstract_stream.h" -#include "abstract_task_progress.h" - -namespace foug { - -namespace internal { - -class IoBasePrivate -{ -public: - IoBasePrivate() - : m_stream(0), - m_taskProgress(0), - m_autoDeleteStream(true), - m_autoDeleteTaskProgress(true) - { - } - - AbstractStream* m_stream; - AbstractTaskProgress* m_taskProgress; - bool m_autoDeleteStream; - bool m_autoDeleteTaskProgress; -}; - -} // namespace internal - -IoBase::IoBase(AbstractStream *stream) - : d(new internal::IoBasePrivate) -{ - d->m_stream = stream; -} - -IoBase::~IoBase() -{ - if (this->autoDeleteStream() && d->m_stream != 0) - delete d->m_stream; - - if (this->autoDeleteTaskProgress() && d->m_taskProgress != 0) - delete d->m_taskProgress; - - delete d; -} - -AbstractStream* IoBase::stream() const -{ - return d->m_stream; -} - -void IoBase::setStream(AbstractStream* stream) -{ - if (this->autoDeleteStream() && d->m_stream != 0 && d->m_stream != stream) - delete d->m_stream; - d->m_stream = stream; -} - -AbstractTaskProgress* IoBase::taskProgress() const -{ - return d->m_taskProgress; -} - -void IoBase::setTaskProgress(AbstractTaskProgress* progress) -{ - if (this->autoDeleteTaskProgress() && d->m_taskProgress != 0 && d->m_taskProgress != progress) - delete d->m_taskProgress; - d->m_taskProgress = progress; -} - -bool IoBase::autoDeleteStream() const -{ - return d->m_autoDeleteStream; -} - -void IoBase::setAutoDeleteStream(bool on) -{ - d->m_autoDeleteStream = on; -} - -bool IoBase::autoDeleteTaskProgress() const -{ - return d->m_autoDeleteTaskProgress; -} - -void IoBase::setAutoDeleteTaskProgress(bool on) const -{ - d->m_autoDeleteTaskProgress = on; -} - -} // namespace foug diff --git a/src/c++/io_base.h b/src/c++/io_base.h deleted file mode 100644 index 6fec4a0..0000000 --- a/src/c++/io_base.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef FOUG_CPP_IO_BASE_H -#define FOUG_CPP_IO_BASE_H - -namespace foug { - -class AbstractStream; -class AbstractTaskProgress; - -namespace internal { class IoBasePrivate; } - -class IoBase -{ -public: - IoBase(AbstractStream* stream = 0); - virtual ~IoBase(); - - AbstractStream* stream() const; - void setStream(AbstractStream* stream); - - AbstractTaskProgress* taskProgress() const; - void setTaskProgress(AbstractTaskProgress* progress); - - bool autoDeleteStream() const; - void setAutoDeleteStream(bool on); - - bool autoDeleteTaskProgress() const; - void setAutoDeleteTaskProgress(bool on) const; - -private: - internal::IoBasePrivate* const d; -}; - -} // namespace foug - -#endif // FOUG_CPP_IO_BASE_H diff --git a/src/c++/libstl/abstract_geometry.h b/src/c++/libstl/abstract_geometry.h deleted file mode 100644 index 1174353..0000000 --- a/src/c++/libstl/abstract_geometry.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef FOUG_CPP_LIBSTL_ABSTRACT_GEOMETRY_H -#define FOUG_CPP_LIBSTL_ABSTRACT_GEOMETRY_H - -#include "stl_global.h" - -namespace foug { - -template -struct Coords3d -{ - NUMERIC x; - NUMERIC y; - NUMERIC z; -}; - -template -struct Triangle -{ - COORDS normal; - COORDS v1; - COORDS v2; - COORDS v3; -}; - -namespace stl { - -typedef Coords3d Coords; -typedef Triangle Triangle; - -class FOUG_STL_EXPORT AbstractGeometry -{ -public: - virtual uint32_t triangleCount() const = 0; - virtual void getTriangle(uint32_t index, Triangle* triangle) const = 0; -}; - -} // namespace stl -} // namespace foug - -#endif // FOUG_CPP_LIBSTL_ABSTRACT_GEOMETRY_H diff --git a/src/c++/libstl/stl_global.h b/src/c++/libstl/stl_global.h deleted file mode 100644 index 34849eb..0000000 --- a/src/c++/libstl/stl_global.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef FOUG_CPP_LIBSTL_GLOBAL_H -#define FOUG_CPP_LIBSTL_GLOBAL_H - -#include "../foug_global.h" - -#ifdef FOUG_STL_DLL -# ifdef FOUG_STL_MAKE_DLL -# define FOUG_STL_EXPORT FOUG_DECL_EXPORT -# else -# define FOUG_STL_EXPORT FOUG_DECL_IMPORT -# endif // FOUG_STL_MAKE_DLL -#else -# define FOUG_STL_EXPORT -#endif // FOUG_STL_DLL - -#endif // FOUG_CPP_LIBSTL_GLOBAL_H diff --git a/src/c++/libstl/stla.cpp b/src/c++/libstl/stla.cpp deleted file mode 100644 index 3f687e9..0000000 --- a/src/c++/libstl/stla.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "stla.h" -#include "../abstract_stream.h" - -#include - -namespace foug { -namespace stla { - -bool Io::read(AbstractGeometryBuilder* builder, int64_t streamSize) -{ - return false; -} - -bool Io::write(const stl::AbstractGeometry& geom, const std::string& solidName) -{ - return false; -} - -void AbstractGeometryBuilder::beginSolid(const std::string& /*name*/) -{ -} - -void AbstractGeometryBuilder::endSolid(const std::string& /*name*/) -{ -} - -} // namespace stla -} // namespace foug diff --git a/src/c++/libstl/stla.h b/src/c++/libstl/stla.h deleted file mode 100644 index 081d882..0000000 --- a/src/c++/libstl/stla.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef FOUG_CPP_LIBSTL_STLA_H -#define FOUG_CPP_LIBSTL_STLA_H - -#include "stl_global.h" -#include "abstract_geometry.h" -#include "../io_base.h" -#include - -namespace foug { -namespace stla { - -class FOUG_STL_EXPORT AbstractGeometryBuilder -{ -public: - virtual void beginSolid(const std::string& name); - virtual void nextTriangle(const stl::Triangle& triangle) = 0; - virtual void endSolid(const std::string& name); -}; - -class FOUG_STL_EXPORT Io : public IoBase -{ -public: - Io(AbstractStream* stream = 0); - - bool read(AbstractGeometryBuilder* builder, int64_t streamSize = -1); - bool write(const stl::AbstractGeometry& geom, const std::string& solidName); -}; - -} // namespace stla -} // namespace foug - -#endif // FOUG_CPP_LIBSTL_STLA_H diff --git a/src/c++/libstl/stlb.cpp b/src/c++/libstl/stlb.cpp deleted file mode 100644 index 8e6bee9..0000000 --- a/src/c++/libstl/stlb.cpp +++ /dev/null @@ -1,264 +0,0 @@ -#include "stlb.h" -#include "../abstract_task_progress.h" - -#include -#include - -// Read tools - -template -NUMERIC fromLittleEndian(const uint8_t* bytes) -{ - return 0; -} - -template<> -uint16_t fromLittleEndian(const uint8_t* bytes) -{ - // |BB|AA| -> 0xAABB - return (bytes[1] << 8) | bytes[0]; -} - -template<> -uint32_t fromLittleEndian(const uint8_t* bytes) -{ - // |DD|CC|BB|AA| -> 0xAABBCCDD - return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); -} - -template<> -foug::Real32 fromLittleEndian(const uint8_t* bytes) -{ - union - { - uint32_t asInteger; - foug::Real32 asFloat; - } helper; - - helper.asInteger = fromLittleEndian(bytes); - return helper.asFloat; -} - -// Write tools - -template -void toLittleEndian(NUMERIC n, uint8_t* bytes) -{ - union { - NUMERIC asNumeric; - uint8_t asBytes[sizeof(NUMERIC)]; - } helper; - helper.asNumeric = n; - // std::copy(helper.asBytes, helper.asBytes + sizeof(NUMERIC), bytes); - for (unsigned i = 0; i < sizeof(NUMERIC); ++i) - bytes[i] = helper.asBytes[i]; -} - -namespace foug { -namespace stlb { - -static const int stlFacetSize = 50; -static const int stlMinFileSize = 284; -static const int stlTriangleDataSize = (4 * 3) * sizeof(foug::Real32) + sizeof(uint16_t); - -void AbstractGeometryBuilder::processHeader(const Header& /*data*/) -{ -} - -void AbstractGeometryBuilder::beginTriangles(uint32_t /*count*/) -{ -} - -void AbstractGeometryBuilder::endTriangles() -{ -} - -Io::Io(AbstractStream *stream) - : IoBase(stream) -{ -} - -bool Io::read(AbstractGeometryBuilder* builder) -{ - // // Check file size - // const qint64 fileSize = stream->size(); - // if (((fileSize - stlHeaderSize - stlFacetCountSize) % stlFacetSize != 0) - // || fileSize < stlMinFileSize) { - // cpp::checkedAssign(err, WrongFileSizeBinaryStlLoadError); - // return false; - // } - - // const int facetCount = (fileSize - stlHeaderSize - stlFacetCountSize) / stlFacetSize; - - if (this->stream() == 0) - return false; - - AbstractStream* istream = this->stream(); - AbstractTaskProgress* progress = this->taskProgress(); - const uint32_t chunkSize = stlTriangleDataSize * 163; - - uint8_t buffer[8192]; - char* charBuffer = reinterpret_cast(buffer); - - // Read header - Header headerData; - if (istream->read(reinterpret_cast(&headerData), HeaderSize) != HeaderSize) - return false; - builder->processHeader(headerData); - - // Read facet count - if (istream->read(charBuffer, sizeof(uint32_t)) != sizeof(uint32_t)) - return false; - const uint32_t facetCount = ::fromLittleEndian(buffer); - builder->beginTriangles(facetCount); - - if (progress != 0) { - progress->reset(); - progress->setRange(0., facetCount); - } - - // Read triangles - const uint64_t totalFacetSize = stlTriangleDataSize * facetCount; - uint64_t amountReadSize = 0; - stl::Triangle triangle; - bool streamError = false; - while (amountReadSize < totalFacetSize && !streamError) { - const int64_t iReadSize = istream->read(charBuffer, chunkSize); - if (iReadSize > 0 && (iReadSize % stlTriangleDataSize == 0)) { - const uint32_t iFacetCount = iReadSize / stlTriangleDataSize; - uint32_t bufferOffset = 0; - for (uint32_t i = 0; i < iFacetCount; ++i) { - // Read normal - triangle.normal.x = ::fromLittleEndian(buffer + bufferOffset); - triangle.normal.y = ::fromLittleEndian(buffer + 1*sizeof(Real32) + bufferOffset); - triangle.normal.z = ::fromLittleEndian(buffer + 2*sizeof(Real32) + bufferOffset); - - // Read vertex1 - triangle.v1.x = ::fromLittleEndian(buffer + 3*sizeof(Real32) + bufferOffset); - triangle.v1.y = ::fromLittleEndian(buffer + 4*sizeof(Real32) + bufferOffset); - triangle.v1.z = ::fromLittleEndian(buffer + 5*sizeof(Real32) + bufferOffset); - - // Read vertex2 - triangle.v2.x = ::fromLittleEndian(buffer + 6*sizeof(Real32) + bufferOffset); - triangle.v2.y = ::fromLittleEndian(buffer + 7*sizeof(Real32) + bufferOffset); - triangle.v2.z = ::fromLittleEndian(buffer + 8*sizeof(Real32) + bufferOffset); - - // Read vertex3 - triangle.v3.x = ::fromLittleEndian(buffer + 9*sizeof(Real32) + bufferOffset); - triangle.v3.y = ::fromLittleEndian(buffer + 10*sizeof(Real32) + bufferOffset); - triangle.v3.z = ::fromLittleEndian(buffer + 11*sizeof(Real32) + bufferOffset); - - // Attribute byte count - const uint16_t attributeByteCount = - ::fromLittleEndian(buffer + 12*sizeof(Real32) + bufferOffset); - - // Add triangle - builder->processNextTriangle(triangle, attributeByteCount); - - bufferOffset += stlTriangleDataSize; - } // end for - - if (progress != 0) { - if (progress->isTaskStopRequested()) { - streamError = true; - progress->taskStoppedEvent(); - } - else { - progress->setValue(amountReadSize / stlTriangleDataSize); - } - } - - amountReadSize += iReadSize; - } - else { - streamError = true; - } - } // end while - - if (!streamError) - builder->endTriangles(); - - return !streamError; -} - -bool Io::write(const stl::AbstractGeometry& geom, const AbstractGeometryExtraData* extraData) -{ - if (this->stream() == 0) - return false; - - AbstractStream* ostream = this->stream(); - AbstractTaskProgress* progress = this->taskProgress(); - - uint8_t buffer[128]; - - // Write header - Header headerData; - if (extraData != 0) - extraData->getHeader(headerData); - else - std::fill(headerData, headerData + HeaderSize, 0); - - if (ostream->write(reinterpret_cast(&headerData), HeaderSize) != HeaderSize) - return false; - - // Write facet count - const uint32_t facetCount = geom.triangleCount(); - ::toLittleEndian(facetCount, buffer); - if (ostream->write(reinterpret_cast(&buffer), sizeof(uint32_t)) != sizeof(uint32_t)) - return false; - - if (progress != 0) { - progress->reset(); - progress->setRange(0., facetCount); - } - - // Write triangles - stl::Triangle triangle; - for (uint32_t facet = 0; facet < facetCount; ++facet) { - geom.getTriangle(facet, &triangle); - - // Write normal - ::toLittleEndian(triangle.normal.x, buffer); - ::toLittleEndian(triangle.normal.y, buffer + 1*sizeof(Real32)); - ::toLittleEndian(triangle.normal.z, buffer + 2*sizeof(Real32)); - - // Write vertex1 - ::toLittleEndian(triangle.v1.x, buffer + 3*sizeof(Real32)); - ::toLittleEndian(triangle.v1.y, buffer + 4*sizeof(Real32)); - ::toLittleEndian(triangle.v1.z, buffer + 5*sizeof(Real32)); - - // Write vertex2 - ::toLittleEndian(triangle.v2.x, buffer + 6*sizeof(Real32)); - ::toLittleEndian(triangle.v2.y, buffer + 7*sizeof(Real32)); - ::toLittleEndian(triangle.v2.z, buffer + 8*sizeof(Real32)); - - // Write vertex3 - ::toLittleEndian(triangle.v3.x, buffer + 9*sizeof(Real32)); - ::toLittleEndian(triangle.v3.y, buffer + 10*sizeof(Real32)); - ::toLittleEndian(triangle.v3.z, buffer + 11*sizeof(Real32)); - - // Attribute byte count - const uint16_t attrByteCount = extraData != 0 ? extraData->attributeByteCount(facet) : 0; - ::toLittleEndian(attrByteCount, buffer + 12*sizeof(Real32)); - - // Write to stream - if (ostream->write(reinterpret_cast(buffer), stlTriangleDataSize) - != stlTriangleDataSize) - return false; - - if (progress != 0) { - if (progress->isTaskStopRequested()) { - progress->taskStoppedEvent(); - return false; - } - else { - progress->setValue(facet + 1); - } - } - } // end for - - return true; -} - -} // namespace stlb -} // namespace foug diff --git a/src/c++/libstl/stlb.h b/src/c++/libstl/stlb.h deleted file mode 100644 index a42c98e..0000000 --- a/src/c++/libstl/stlb.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef FOUG_CPP_LIBSTL_STLB_H -#define FOUG_CPP_LIBSTL_STLB_H - -#include "abstract_geometry.h" -#include "stl_global.h" -#include "../abstract_stream.h" -#include "../io_base.h" - -namespace foug { -namespace stlb { - -enum { HeaderSize = 80 }; -typedef uint8_t Header[HeaderSize]; - -class FOUG_STL_EXPORT AbstractGeometryBuilder -{ -public: - virtual void processHeader(const Header& data); - virtual void beginTriangles(uint32_t count); - virtual void processNextTriangle(const stl::Triangle& triangle, uint16_t attributeByteCount) = 0; - virtual void endTriangles(); -}; - -class FOUG_STL_EXPORT AbstractGeometryExtraData -{ -public: - virtual void getHeader(Header& data) const = 0; - virtual uint16_t attributeByteCount(uint32_t triangleIndex) const = 0; -}; - -class FOUG_STL_EXPORT Io : public IoBase -{ -public: - Io(AbstractStream* stream = 0); - - bool read(AbstractGeometryBuilder* builder); - bool write(const stl::AbstractGeometry& geom, const AbstractGeometryExtraData* extraData = 0); -}; - -} // namespace stlb -} // namespace foug - -#endif // FOUG_CPP_LIBSTL_STLB_H diff --git a/src/c++/streams/qt4_stream.cpp b/src/c++/streams/qt4_stream.cpp deleted file mode 100644 index ad40d81..0000000 --- a/src/c++/streams/qt4_stream.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "qt4_stream.h" - -#include -#include - -namespace foug { - -Qt4Stream::Qt4Stream(QIODevice *device) - : m_device(device) -{ -} - -bool Qt4Stream::atEnd() const -{ - return m_device->atEnd(); -} - -bool Qt4Stream::isWritable() const -{ - return m_device != 0 ? m_device->isWritable() : false; -} - -bool Qt4Stream::isReadable() const -{ - return m_device != 0 ? m_device->isReadable() : false; -} - -bool Qt4Stream::isSequential() const -{ - return m_device != 0 ? m_device->isSequential() : false; -} - -bool Qt4Stream::seek(int64_t pos) -{ - return m_device->seek(pos); -} - -int64_t Qt4Stream::read(char *data, int64_t maxSize) -{ - return m_device->read(data, maxSize); -} - -int64_t Qt4Stream::write(const char *data, int64_t maxSize) -{ - return m_device->write(data, maxSize); -} - -} // namespace foug diff --git a/src/c++/streams/qt4_stream.h b/src/c++/streams/qt4_stream.h deleted file mode 100644 index 2eb5257..0000000 --- a/src/c++/streams/qt4_stream.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef FOUG_CPP_STREAMS_QT4_STREAM_H -#define FOUG_CPP_STREAMS_QT4_STREAM_H - -#include "../abstract_stream.h" -class QIODevice; - -namespace foug { - -class Qt4Stream : public AbstractStream -{ -public: - Qt4Stream(QIODevice* device); - - bool atEnd() const; - - bool isWritable() const; - bool isReadable() const; - bool isSequential() const; - - bool seek(int64_t pos); - int64_t read(char* data, int64_t maxSize); - int64_t write(const char* data, int64_t maxSize); - -private: - QIODevice* m_device; -}; - -} // namespace foug - -#endif // FOUG_CPP_STREAMS_QT4_STREAM_H diff --git a/src/c++/streams/std_io_stream.cpp b/src/c++/streams/std_io_stream.cpp deleted file mode 100644 index 68601e1..0000000 --- a/src/c++/streams/std_io_stream.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "std_io_stream.h" - -namespace foug { - -StdIoStream::StdIoStream(std::iostream* iostr) - : m_iostr(iostr) -{ -} - -Int64 StdIoStream::read(char* data, Int64 maxSize) -{ - if (!m_iostr->eof()) - return 0; - - m_iostr->read(data, maxSize); - if (!m_iostr->good()) - return -1; - return maxSize; -} - -Int64 StdIoStream::write(const char* data, Int64 maxSize) -{ - m_iostr->write(data, maxSize); - if (!m_iostr->good()) - return -1; - return maxSize; -} - -} // namespace foug diff --git a/src/c++/streams/std_io_stream.h b/src/c++/streams/std_io_stream.h deleted file mode 100644 index 003383e..0000000 --- a/src/c++/streams/std_io_stream.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef FOUG_CPP_STREAMS_STD_IO_STREAM_H -#define FOUG_CPP_STREAMS_STD_IO_STREAM_H - -#include "../abstract_stream.h" - -namespace foug { - -template -class StdInputStream : public AbstractStream -{ -public: - StdInputStream(STD_STREAM* istr) - : m_istr(istr) - { - } - - bool atEnd() const - { - return m_istr->eof(); - } - - bool isWritable() const - { - return false; - } - - bool isReadable() const - { - return true; - } - - bool isSequential() const - { - return false; - } - - bool seek(foug::Int64 pos) - { - m_istr->seekg(pos); - return m_istr->good(); - } - - Int64 read(char* data, Int64 maxSize) - { - m_istr->read(data, maxSize); - if (!m_istr->eof() && m_istr->fail()) { - m_istr->clear(); - return -1; - } - const Int64 bytesCount = m_istr->gcount(); - if (m_istr->fail()) // TODO preserve eof() flag - m_istr->clear(); - return bytesCount; - } - - Int64 write(const char* /*data*/, Int64 /*maxSize*/) - { - return -1; - } - -private: - STD_STREAM* m_istr; -}; - -template -class StdOutputStream : public AbstractStream -{ -public: - StdOutputStream(STD_STREAM* ostr) - : m_ostr(ostr) - { - } - - bool atEnd() const - { - return m_ostr->eof(); - } - - bool isWritable() const - { - return true; - } - - bool isReadable() const - { - return false; - } - - bool isSequential() const - { - return false; - } - - bool seek(foug::Int64 pos) - { - m_ostr->seekp(pos); - return m_ostr->good(); - } - - Int64 read(char* /*data*/, Int64 /*maxSize*/) - { - return -1; - } - - Int64 write(const char* data, Int64 maxSize) - { - m_ostr->write(data, maxSize); - if (!m_ostr->good()) - return -1; - return maxSize; - } - -private: - STD_STREAM* m_ostr; -}; - -} // namespace foug - -#endif // FOUG_CPP_STREAMS_STD_IO_STREAM_H