Continue cleaning.

This commit is contained in:
jmsgrogan 2023-01-13 14:29:12 +00:00
parent cd688f608f
commit cb4212d972
67 changed files with 367 additions and 282 deletions

View file

@ -9,7 +9,7 @@ int main(int argc, char *argv[])
args->recordLaunchPath(); args->recordLaunchPath();
WebsiteGenerator generator; WebsiteGenerator generator;
generator.findProject(args->getArg(1)); generator.findProject(args->getArgs()[1]);
generator.readConfig(); generator.readConfig();

View file

@ -41,7 +41,8 @@ void BlochSphereNode::update(SceneInfo* sceneInfo)
mOuterCircle = std::make_unique<CircleNode>(loc, mSize/2.0); mOuterCircle = std::make_unique<CircleNode>(loc, mSize/2.0);
const auto end_point_x = Point(loc.getX() + 1.2 * mSize / 2.0, loc.getY()); const auto end_point_x = Point(loc.getX() + 1.2 * mSize / 2.0, loc.getY());
mXAxis = std::make_unique<LineNode>(loc, { end_point_x }); const std::vector<Point> points{end_point_x };
mXAxis = std::make_unique<LineNode>(loc, points);
mCentreCircle = std::make_unique<CircleNode>(loc, mSize / 50.0); mCentreCircle = std::make_unique<CircleNode>(loc, mSize / 50.0);
mCentreCircle->setFillColor(Color(0, 0, 0)); mCentreCircle->setFillColor(Color(0, 0, 0));
@ -49,5 +50,6 @@ void BlochSphereNode::update(SceneInfo* sceneInfo)
addChild(mInnerCircle.get()); addChild(mInnerCircle.get());
addChild(mOuterCircle.get()); addChild(mOuterCircle.get());
addChild(mXAxis.get());
addChild(mCentreCircle.get()); addChild(mCentreCircle.get());
} }

View file

@ -73,7 +73,7 @@ void TemplateFile::onTextSpanFinished()
mWorkingLineContent.clear(); mWorkingLineContent.clear();
} }
unsigned TemplateFile::checkForStatement(const std::string& lineSection) std::size_t TemplateFile::checkForStatement(const std::string& lineSection)
{ {
if (lineSection.empty()) if (lineSection.empty())
{ {
@ -81,7 +81,7 @@ unsigned TemplateFile::checkForStatement(const std::string& lineSection)
} }
std::vector<std::string> hits; std::vector<std::string> hits;
unsigned hit_size{0}; std::size_t hit_size{0};
if (Lexer::matchPattern("{%@%}", lineSection, '@', hits)) if (Lexer::matchPattern("{%@%}", lineSection, '@', hits))
{ {
if (hits.size() == 1) if (hits.size() == 1)
@ -97,7 +97,7 @@ unsigned TemplateFile::checkForStatement(const std::string& lineSection)
return hit_size; return hit_size;
} }
unsigned TemplateFile::checkForExpression(const std::string& lineSection) std::size_t TemplateFile::checkForExpression(const std::string& lineSection)
{ {
if (lineSection.empty()) if (lineSection.empty())
{ {
@ -105,7 +105,7 @@ unsigned TemplateFile::checkForExpression(const std::string& lineSection)
} }
std::vector<std::string> hits; std::vector<std::string> hits;
unsigned hit_size{0}; std::size_t hit_size{0};
if (Lexer::matchPattern("{{@}}", lineSection, '@', hits)) if (Lexer::matchPattern("{{@}}", lineSection, '@', hits))
{ {
if (hits.size() == 1) if (hits.size() == 1)
@ -123,7 +123,7 @@ unsigned TemplateFile::checkForExpression(const std::string& lineSection)
void TemplateFile::processLine(const std::string& line) void TemplateFile::processLine(const std::string& line)
{ {
unsigned line_position = 0; std::size_t line_position = 0;
mWorkingLineContent.clear(); mWorkingLineContent.clear();
while(line_position < line.size()) while(line_position < line.size())
{ {

View file

@ -27,9 +27,9 @@ public:
void loadContent(); void loadContent();
private: private:
unsigned checkForStatement(const std::string& lineSection); std::size_t checkForStatement(const std::string& lineSection);
unsigned checkForExpression(const std::string& lineSection); std::size_t checkForExpression(const std::string& lineSection);
void onTextSpanFinished(); void onTextSpanFinished();

View file

@ -218,7 +218,7 @@ unsigned HuffmanCodeLengthTable::mapToDeflateIndex(unsigned index) const
} }
} }
unsigned HuffmanCodeLengthTable::getNumCodeLengths() const std::size_t HuffmanCodeLengthTable::getNumCodeLengths() const
{ {
return mTree.getNumCodeLengths(); return mTree.getNumCodeLengths();
} }

View file

@ -30,7 +30,7 @@ public:
const std::vector<unsigned> getCompressedLengthCounts() const; const std::vector<unsigned> getCompressedLengthCounts() const;
unsigned getNumCodeLengths() const; std::size_t getNumCodeLengths() const;
unsigned getCodeLength(std::size_t treeIndex) const; unsigned getCodeLength(std::size_t treeIndex) const;

View file

@ -1,6 +1,6 @@
set(MODULE_NAME core) set(MODULE_NAME core)
list(APPEND core_HEADERS list(APPEND HEADERS
AbstractApp.h AbstractApp.h
AbstractNamedItem.h AbstractNamedItem.h
AbstractWebApp.h AbstractWebApp.h
@ -8,20 +8,22 @@ list(APPEND core_HEADERS
Event.h Event.h
Color.h Color.h
CommandLineArgs.h CommandLineArgs.h
encoding/ByteUtils.h
encoding/StringUtils.h
encoding/UnicodeUtils.h
loggers/FileLogger.h loggers/FileLogger.h
file_utilities/Directory.h file_utilities/Directory.h
file_utilities/File.h file_utilities/File.h
file_utilities/FileFormats.h file_utilities/FileFormats.h
file_utilities/PathUtils.h file_utilities/PathUtils.h
StringUtils.h
http/HttpResponse.h http/HttpResponse.h
http/HttpHeader.h http/HttpHeader.h
http/HttpRequest.h http/HttpRequest.h
serializers/TomlReader.h serializers/TomlReader.h
Win32BaseIncludes.h
) )
list(APPEND core_LIB_INCLUDES list(APPEND LIB_INCLUDES
ByteUtils.cpp
Event.cpp Event.cpp
Dictionary.cpp Dictionary.cpp
Color.cpp Color.cpp
@ -35,7 +37,9 @@ list(APPEND core_LIB_INCLUDES
file_utilities/PathUtils.cpp file_utilities/PathUtils.cpp
memory/SharedMemory.cpp memory/SharedMemory.cpp
RandomUtils.cpp RandomUtils.cpp
StringUtils.cpp encoding/StringUtils.cpp
encoding/ByteUtils.cpp
encoding/UnicodeUtils.cpp
streams/BinaryStream.cpp streams/BinaryStream.cpp
streams/BitStream.cpp streams/BitStream.cpp
streams/InputBitStream.cpp streams/InputBitStream.cpp
@ -46,10 +50,11 @@ list(APPEND core_LIB_INCLUDES
http/HttpRequest.cpp http/HttpRequest.cpp
serializers/TomlReader.cpp) serializers/TomlReader.cpp)
add_library(${MODULE_NAME} SHARED ${core_LIB_INCLUDES} ${core_HEADERS}) add_library(${MODULE_NAME} SHARED ${LIB_INCLUDES} ${HEADERS})
target_include_directories(${MODULE_NAME} PUBLIC target_include_directories(${MODULE_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/encoding
${CMAKE_CURRENT_SOURCE_DIR}/file_utilities ${CMAKE_CURRENT_SOURCE_DIR}/file_utilities
${CMAKE_CURRENT_SOURCE_DIR}/loggers ${CMAKE_CURRENT_SOURCE_DIR}/loggers
${CMAKE_CURRENT_SOURCE_DIR}/memory ${CMAKE_CURRENT_SOURCE_DIR}/memory

View file

@ -1,9 +1,8 @@
#include "CommandLineArgs.h" #include "CommandLineArgs.h"
#include "StringUtils.h" #include "UnicodeUtils.h"
#ifdef _WIN32
#include "Windows.h" #include "Win32BaseIncludes.h"
#endif
CommandLineArgs::CommandLineArgs() CommandLineArgs::CommandLineArgs()
: mArugments(), : mArugments(),
@ -25,7 +24,7 @@ void CommandLineArgs::initialize(CommandLineArgs* args)
std::vector<std::string> windowsArgs(nArgs); std::vector<std::string> windowsArgs(nArgs);
for (int idx = 0; idx < nArgs; idx++) for (int idx = 0; idx < nArgs; idx++)
{ {
windowsArgs[idx] = StringUtils::convert(szArglist[idx]); windowsArgs[idx] = UnicodeUtils::utf16ToUtf8String(szArglist[idx]);
} }
::LocalFree(szArglist); ::LocalFree(szArglist);
@ -71,7 +70,7 @@ std::vector<std::string> CommandLineArgs::getUserArgs() const
return user_args; return user_args;
} }
const std::vector<std::string> CommandLineArgs::getArgs() const const std::vector<std::string> CommandLineArgs::getArgs() const
{ {
return mArugments; return mArugments;
} }

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <string> #include <string>
@ -15,15 +16,15 @@ public:
const std::vector<std::string> getArgs() const; const std::vector<std::string> getArgs() const;
std::vector<std::string> getUserArgs() const;
static void initialize(CommandLineArgs* args);
void process(int argc, char *argv[]); void process(int argc, char *argv[]);
void process(const std::vector<std::string>& args); void process(const std::vector<std::string>& args);
void recordLaunchPath(); void recordLaunchPath();
std::vector<std::string> getUserArgs() const;
static void initialize(CommandLineArgs* args);
private: private:
std::vector<std::string> mArugments; std::vector<std::string> mArugments;
std::filesystem::path mLaunchPath; std::filesystem::path mLaunchPath;

View file

@ -0,0 +1,13 @@
#pragma once
#ifndef UNICODE
#define UNICODE
#endif
//#ifndef WIN32_LEAN_AND_MEAN
//#define WIN32_LEAN_AND_MEAN
//#endif
#ifdef _WIN32
#include "Windows.h"
#endif

View file

@ -67,6 +67,6 @@ public:
static bool CompareWords(char* buffer, const char* tag); static bool CompareWords(char* buffer, const char* tag);
static const int BYTE_FIRST_BIT = 0x40; // 1000 0000 static const int BYTE_FIRST_BIT = 0x40; // 1000 0000
static const Word WORD_FIRST_BIT = 0x8000; // 1000 0000 - 0000 0000 static const Word WORD_FIRST_BIT = static_cast<Word>(0x8000); // 1000 0000 - 0000 0000
static const Word WORD_LAST_BYTE = 0x00FF; // 0000 0000 - 1111 1111 static const Word WORD_LAST_BYTE = 0x00FF; // 0000 0000 - 1111 1111
}; };

View file

@ -5,10 +5,6 @@
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#ifdef _WIN32
#include "Windows.h"
#endif
bool StringUtils::isAlphaNumeric(char c) bool StringUtils::isAlphaNumeric(char c)
{ {
return std::isalnum(c); return std::isalnum(c);
@ -57,7 +53,7 @@ bool StringUtils::isWhitespaceOnly(const std::string& input)
} }
} }
unsigned StringUtils::countFirstConsecutiveHits(const std::string& input, char c) std::size_t StringUtils::countFirstConsecutiveHits(const std::string& input, char c)
{ {
auto found_id = input.find(c); auto found_id = input.find(c);
if(found_id == std::string::npos) if(found_id == std::string::npos)
@ -66,8 +62,8 @@ unsigned StringUtils::countFirstConsecutiveHits(const std::string& input, char c
} }
else else
{ {
unsigned count = 1; std::size_t count = 1;
for(unsigned idx=found_id+1; idx<input.size(); idx++) for(std::size_t idx=found_id+1; idx<input.size(); idx++)
{ {
if(input[idx] == c) if(input[idx] == c)
{ {
@ -153,41 +149,6 @@ std::string StringUtils::toLower(const std::string& s)
return ret; return ret;
} }
std::string StringUtils::convert(const std::wstring& input)
{
if (input.empty())
{
return std::string();
}
#ifdef _WIN32
const auto size = ::WideCharToMultiByte(CP_UTF8, 0, &input[0], (int)input.size(), nullptr, 0, nullptr, nullptr);
std::string result(size, 0);
::WideCharToMultiByte(CP_UTF8, 0, &input[0], (int)input.size(), &result[0], size, nullptr, nullptr);
return result;
#else
throw std::logic_error("Not implemented");
#endif
}
std::wstring StringUtils::convert(const std::string& input)
{
if (input.empty())
{
return std::wstring();
}
#ifdef _WIN32
const auto charsNeeded = ::MultiByteToWideChar(CP_UTF8, 0, input.data(), (int)input.size(), NULL, 0);
std::vector<wchar_t> buffer(charsNeeded);
const auto charsConverted = ::MultiByteToWideChar(CP_UTF8, 0, input.data(), (int)input.size(), &buffer[0], buffer.size());
return std::wstring(&buffer[0], charsConverted);
#else
throw std::logic_error("Not implemented");
#endif
}
std::string StringUtils::toPaddedString(unsigned numBytes, unsigned entry) std::string StringUtils::toPaddedString(unsigned numBytes, unsigned entry)
{ {
std::stringstream sstr; std::stringstream sstr;

View file

@ -16,11 +16,7 @@ public:
static constexpr char SINGLE_QUOTE = '\''; static constexpr char SINGLE_QUOTE = '\'';
static constexpr char COLON = ':'; static constexpr char COLON = ':';
static unsigned countFirstConsecutiveHits(const std::string& input, char c); static std::size_t countFirstConsecutiveHits(const std::string& input, char c);
static std::string convert(const std::wstring& input);
static std::wstring convert(const std::string& input);
static bool isAlphaNumeric(char c); static bool isAlphaNumeric(char c);

View file

@ -0,0 +1,40 @@
#include "UnicodeUtils.h"
#include "Win32BaseIncludes.h"
#include <vector>
std::string UnicodeUtils::utf16ToUtf8String(const std::wstring& input)
{
if (input.empty())
{
return std::string();
}
#ifdef _WIN32
const auto size = ::WideCharToMultiByte(CP_UTF8, 0, &input[0], static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr);
std::string result(size, 0);
::WideCharToMultiByte(CP_UTF8, 0, &input[0], static_cast<int>(input.size()), &result[0], size, nullptr, nullptr);
return result;
#else
throw std::logic_error("Not implemented");
#endif
}
std::wstring UnicodeUtils::utf8ToUtf16WString(const std::string& input)
{
if (input.empty())
{
return std::wstring();
}
#ifdef _WIN32
const auto charsNeeded = ::MultiByteToWideChar(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0);
std::vector<wchar_t> buffer(charsNeeded);
const auto charsConverted = ::MultiByteToWideChar(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), &buffer[0], static_cast<int>(buffer.size()));
return std::wstring(&buffer[0], charsConverted);
#else
throw std::logic_error("Not implemented");
#endif
}

View file

@ -0,0 +1,11 @@
#pragma once
#include <string>
class UnicodeUtils
{
public:
static std::string utf16ToUtf8String(const std::wstring& input);
static std::wstring utf8ToUtf16WString(const std::string& input);
};

View file

@ -21,7 +21,7 @@ std::optional<unsigned char> InputBitStream::readNextByte()
{ {
if (mStream->good()) if (mStream->good())
{ {
return mStream->get(); return static_cast<unsigned char>(mStream->get());
} }
else else
{ {

View file

@ -9,7 +9,7 @@ class BasicFontEngine : public IFontEngine
{ {
virtual void initialize(){}; virtual void initialize(){};
virtual void loadFontFace(const std::filesystem::path& fontFile, int penSize = 16){}; virtual void loadFontFace(const std::filesystem::path& fontFile, float penSize = 16){};
virtual std::unique_ptr<FontGlyph> loadGlyph(unsigned charCode){return nullptr;}; virtual std::unique_ptr<FontGlyph> loadGlyph(unsigned charCode){return nullptr;};
}; };

View file

@ -14,6 +14,8 @@ list(APPEND fonts_LIB_INCLUDES
FontGlyph.h FontGlyph.h
IFont.h IFont.h
IFontEngine.h IFontEngine.h
BasicFontEngine.h
BasicFontEngine.cpp
) )
if(UNIX) if(UNIX)

View file

@ -34,7 +34,7 @@ IFontEngine* FontsManager::getFontEngine() const
return mFontEngine.get(); return mFontEngine.get();
} }
FontGlyph* FontsManager::getGlyph(const std::string& fontFace, int size, uint32_t c) FontGlyph* FontsManager::getGlyph(const std::string& fontFace, float size, uint32_t c)
{ {
auto path = std::filesystem::path("truetype/liberation/LiberationSans-Regular.ttf"); auto path = std::filesystem::path("truetype/liberation/LiberationSans-Regular.ttf");

View file

@ -17,7 +17,7 @@ public:
bool usesGlyphs() const; bool usesGlyphs() const;
FontGlyph* getGlyph(const std::string& fontFace, int size, uint32_t c); FontGlyph* getGlyph(const std::string& fontFace, float size, uint32_t c);
private: private:
bool mUsesGlyphs{ false }; bool mUsesGlyphs{ false };

View file

@ -13,7 +13,7 @@ public:
virtual void initialize(){}; virtual void initialize(){};
virtual void loadFontFace(const std::filesystem::path& fontFile, int penSize = 16) = 0; virtual void loadFontFace(const std::filesystem::path& fontFile, float penSize = 16) = 0;
virtual std::unique_ptr<FontGlyph> loadGlyph(uint32_t charCode) = 0; virtual std::unique_ptr<FontGlyph> loadGlyph(uint32_t charCode) = 0;
}; };

View file

@ -1,7 +1,7 @@
#include "DirectWriteFontEngine.h" #include "DirectWriteFontEngine.h"
#include "FontGlyph.h" #include "FontGlyph.h"
#include "StringUtils.h" #include "UnicodeUtils.h"
#include "DirectWriteHelpers.h" #include "DirectWriteHelpers.h"
@ -24,10 +24,10 @@ void DirectWriteFontEngine::initializeOffScreenRenderer()
pInterface->QueryInterface(IID_IOffScreenTextRenderer, &mOffScreenRenderer); pInterface->QueryInterface(IID_IOffScreenTextRenderer, &mOffScreenRenderer);
} }
void DirectWriteFontEngine::loadFontFaceFromName(const std::string& fontName, int penSize) void DirectWriteFontEngine::loadFontFaceFromName(const std::string& fontName, float penSize)
{ {
mDWriteFactory->CreateTextFormat(StringUtils::convert(fontName).c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, mDWriteFactory->CreateTextFormat(UnicodeUtils::utf8ToUtf16WString(fontName).c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL,
penSize, L"en-us", &mTextFormat); DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, penSize, L"en-us", &mTextFormat);
} }
std::unique_ptr<FontGlyph> DirectWriteFontEngine::loadGlyph(uint32_t charCode) std::unique_ptr<FontGlyph> DirectWriteFontEngine::loadGlyph(uint32_t charCode)
@ -45,7 +45,7 @@ std::unique_ptr<GlyphRunOutlines> DirectWriteFontEngine::getGlyphRunOutlines(con
text.push_back(code); text.push_back(code);
} }
auto hr = mDWriteFactory->CreateTextLayout(text.c_str(), text.size(), mTextFormat.Get(), 50.0, 50.0, &mTextLayout); auto hr = mDWriteFactory->CreateTextLayout(text.c_str(), static_cast<UINT32>(text.size()), mTextFormat.Get(), 50.0, 50.0, &mTextLayout);
mTextLayout->Draw(nullptr, mOffScreenRenderer.Get(), 0.0, 0.0); mTextLayout->Draw(nullptr, mOffScreenRenderer.Get(), 0.0, 0.0);

View file

@ -19,9 +19,9 @@ class DirectWriteFontEngine : public IFontEngine
public: public:
void initialize() override; void initialize() override;
void loadFontFace(const std::filesystem::path& fontFile, int penSize = 16) override {}; void loadFontFace(const std::filesystem::path& fontFile, float penSize = 16) override {};
void loadFontFaceFromName(const std::string& fontName, int penSize = 16); void loadFontFaceFromName(const std::string& fontName, float penSize = 16);
std::unique_ptr<FontGlyph> loadGlyph(uint32_t charCode) override; std::unique_ptr<FontGlyph> loadGlyph(uint32_t charCode) override;

View file

@ -1,46 +1,53 @@
set(MODULE_NAME geometry) set(MODULE_NAME geometry)
list(APPEND geometry_LIB_INCLUDES list(APPEND HEADERS
AbstractGeometricItem.h AbstractGeometricItem.h
Bounds.h Bounds.h
DiscretePoint.h
DiscretePoint.cpp
Grid.h Grid.h
Grid.cpp
Point.h
Point.cpp
Transform.cpp
math/Linalg.h math/Linalg.h
math/Linalg.cpp
math/Matrix.h math/Matrix.h
math/Matrix.cpp
math/Vector.h math/Vector.h
math/Vector.cpp
path/Curve.h path/Curve.h
path/Curve.cpp
path/Line.h path/Line.h
path/Line.cpp
path/LineSegment.h path/LineSegment.h
path/LineSegment.cpp
path/Path.h path/Path.h
path/Path.cpp
path/PathElement.h path/PathElement.h
points/Point.h
points/PointCollection.h
points/DiscretePoint.h
primitives/Circle.h primitives/Circle.h
primitives/Circle.cpp
primitives/Quad.h primitives/Quad.h
primitives/Quad.cpp
primitives/Rectangle.h primitives/Rectangle.h
primitives/Rectangle.cpp
primitives/Triangle.h primitives/Triangle.h
)
list(APPEND LIB_INCLUDES
Grid.cpp
Transform.cpp
math/Linalg.cpp
math/Matrix.cpp
math/Vector.cpp
path/Curve.cpp
path/Line.cpp
path/LineSegment.cpp
path/Path.cpp
path/PathElement.cpp
points/Point.cpp
points/PointCollection.cpp
points/DiscretePoint.cpp
primitives/Circle.cpp
primitives/Quad.cpp
primitives/Rectangle.cpp
primitives/Triangle.cpp primitives/Triangle.cpp
) )
add_library(${MODULE_NAME} SHARED ${geometry_LIB_INCLUDES}) add_library(${MODULE_NAME} SHARED ${LIB_INCLUDES} ${HEADERS})
target_include_directories(${MODULE_NAME} PUBLIC target_include_directories(${MODULE_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/math ${CMAKE_CURRENT_SOURCE_DIR}/math
${CMAKE_CURRENT_SOURCE_DIR}/path ${CMAKE_CURRENT_SOURCE_DIR}/path
${CMAKE_CURRENT_SOURCE_DIR}/points
${CMAKE_CURRENT_SOURCE_DIR}/primitives ${CMAKE_CURRENT_SOURCE_DIR}/primitives
) )

View file

@ -17,6 +17,8 @@ public:
Bounds getBounds() const override; Bounds getBounds() const override;
void sample(Grid* grid) const override {};
private: private:
Point mStartPoint; Point mStartPoint;
std::vector<Point> mPoints; std::vector<Point> mPoints;

View file

@ -1,6 +1,11 @@
#include "Path.h" #include "Path.h"
const std::vector<PathElementPtr> Path::getElements() const Path::~Path()
{
}
const std::vector<PathElementPtr>& Path::getElements() const
{ {
return mElements; return mElements;
} }

View file

@ -10,7 +10,8 @@ using PathElementPtr = std::unique_ptr<PathElement>;
class Path : public AbstractGeometricItem class Path : public AbstractGeometricItem
{ {
public: public:
const std::vector<PathElementPtr> getElements() const; ~Path();
const std::vector<PathElementPtr>& getElements() const;
private: private:
std::vector<PathElementPtr> mElements; std::vector<PathElementPtr> mElements;

View file

@ -0,0 +1,6 @@
#include "PathElement.h"
PathElement::~PathElement()
{
}

View file

@ -5,5 +5,5 @@
class PathElement : public AbstractGeometricItem class PathElement : public AbstractGeometricItem
{ {
public: public:
~PathElement() = default; ~PathElement();
}; };

View file

@ -1,5 +1,7 @@
#include "Point.h" #include "Point.h"
#include "Transform.h"
#include <cmath> #include <cmath>
Point::Point(double x, double y, double z) Point::Point(double x, double y, double z)
@ -77,16 +79,13 @@ double Point::getDeltaZ(const Point& point) const
return point.getZ() - mZ; return point.getZ() - mZ;
} }
void Point::scale(double x, double y, double z) void Point::apply(const Transform& transform)
{ {
mX = x * mX; mX -= transform.getLocation().getX();
mY = y * mY; mY -= transform.getLocation().getY();
mZ = z * mZ; mZ -= transform.getLocation().getZ();
}
void Point::translate(double x, double y, double z) mX *= transform.getScaleX();
{ mY *= transform.getScaleY();
mX += x; mZ *= transform.getScaleZ();
mY += y;
mZ += z;
} }

View file

@ -4,6 +4,9 @@
#include "Vector.h" #include "Vector.h"
#include <memory> #include <memory>
#include <vector>
class Transform;
class Point class Point
{ {
@ -18,6 +21,8 @@ public:
static std::shared_ptr<Point> Create(double x, double y, double z = 0); static std::shared_ptr<Point> Create(double x, double y, double z = 0);
void apply(const Transform& transform);
double getX() const; double getX() const;
double getY() const; double getY() const;
@ -34,10 +39,6 @@ public:
Vector getDelta(const Point& point) const; Vector getDelta(const Point& point) const;
void scale(double x, double y, double z = 1.0);
void translate(double x, double y, double z = 0.0);
bool operator==(const Point& rhs) const bool operator==(const Point& rhs) const
{ {
return (mX == rhs.mX) return (mX == rhs.mX)
@ -56,4 +57,4 @@ private:
double mZ{0}; double mZ{0};
}; };
using PointPtr = std::shared_ptr<Point>; using PointPtr = std::unique_ptr<Point>;

View file

@ -0,0 +1,15 @@
#include "PointCollection.h"
PointCollection::PointCollection(const std::vector<Point> points)
: mPoints(points)
{
}
void PointCollection::apply(const Transform& transform)
{
for (auto& point : mPoints)
{
point.apply(transform);
}
}

View file

@ -0,0 +1,15 @@
#pragma once
#include "Point.h"
#include "Transform.h"
class PointCollection
{
public:
PointCollection(const std::vector<Point> points = {});
void apply(const Transform& transform);
private:
std::vector<Point> mPoints;
};

View file

@ -6,7 +6,7 @@
RasterPainter::RasterPainter(DrawingContext* context) RasterPainter::RasterPainter(DrawingContext* context)
: AbstractPainter(context), : AbstractPainter(context),
mGrid(std::make_unique<Grid<unsigned char> >(ntk::Rectangle(Point(0, 0), Point(100, 100)))) mGrid(std::make_unique<Grid>(Bounds{0.0, 0.0, 100.0, 100.0}))
{ {
} }
@ -15,7 +15,7 @@ void RasterPainter::paint()
{ {
const auto width = mDrawingContext->getSurface()->getWidth(); const auto width = mDrawingContext->getSurface()->getWidth();
const auto height = mDrawingContext->getSurface()->getHeight(); const auto height = mDrawingContext->getSurface()->getHeight();
mGrid->resetBounds(ntk::Rectangle(Point(0, 0), Point(width, height))); mGrid->resetBounds(Bounds{ 0.0, 0.0, static_cast<double>(width), static_cast<double>(height) });
/* /*
for (unsigned idx=0; idx< context->getNumItems(); idx++) for (unsigned idx=0; idx< context->getNumItems(); idx++)

View file

@ -1,11 +1,10 @@
#pragma once #pragma once
#include "AbstractPainter.h" #include "AbstractPainter.h"
#include <memory> #include <memory>
class DrawingContext; class DrawingContext;
template<class T>
class Grid; class Grid;
class RasterPainter : public AbstractPainter class RasterPainter : public AbstractPainter
@ -16,5 +15,5 @@ public:
void paint() override; void paint() override;
private: private:
std::unique_ptr<Grid<unsigned char> > mGrid; std::unique_ptr<Grid> mGrid;
}; };

View file

@ -10,10 +10,10 @@
#include "SceneText.h" #include "SceneText.h"
#include "DirectX2dInterface.h" #include "DirectX2dInterface.h"
#include "StringUtils.h" #include "UnicodeUtils.h"
#include "File.h" #include "File.h"
#include <windows.h> #include "Win32BaseIncludes.h"
#include <d2d1_3.h> #include <d2d1_3.h>
#include <d2d1_1.h> #include <d2d1_1.h>
@ -33,7 +33,7 @@ void DirectXTextPainter::setD2dInterface(DirectX2dInterface* d2dIterface)
void DirectXTextPainter::updateTextFormat(const FontItem& font) void DirectXTextPainter::updateTextFormat(const FontItem& font)
{ {
mD2dInterface->getDirectWriteFactory()->CreateTextFormat( mD2dInterface->getDirectWriteFactory()->CreateTextFormat(
StringUtils::convert(font.getFaceName()).c_str(), UnicodeUtils::utf8ToUtf16WString(font.getFaceName()).c_str(),
nullptr, nullptr,
DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STYLE_NORMAL,
@ -53,7 +53,7 @@ void DirectXTextPainter::paint(SceneText* text, DrawingContext* context)
updateTextFormat(text->getTextData().mFont); updateTextFormat(text->getTextData().mFont);
auto content = StringUtils::convert(text->getTextData().mContent); auto content = UnicodeUtils::utf8ToUtf16WString(text->getTextData().mContent);
mD2dInterface->getRenderTarget()->DrawText(content.c_str(), static_cast<UINT32>(content.size()), mTextFormat.Get(), &textRect, mTextBrush.Get()); mD2dInterface->getRenderTarget()->DrawText(content.c_str(), static_cast<UINT32>(content.size()), mTextFormat.Get(), &textRect, mTextBrush.Get());
} }

View file

@ -126,7 +126,7 @@ void PngWriter::writeDataChunks(const BufferBitStream& buffer)
auto max_bytes{32000}; auto max_bytes{32000};
auto num_dat_chunks = num_bytes/max_bytes + 1; auto num_dat_chunks = num_bytes/max_bytes + 1;
unsigned offset = 0; std::size_t offset = 0;
for(std::size_t idx=0;idx<num_dat_chunks;idx++) for(std::size_t idx=0;idx<num_dat_chunks;idx++)
{ {
auto length = max_bytes; auto length = max_bytes;

View file

@ -2,7 +2,7 @@
#include "Edge.h" #include "Edge.h"
AbstractFace::AbstractFace(unsigned id) AbstractFace::AbstractFace(std::size_t id)
: mId(id) : mId(id)
{ {

View file

@ -19,29 +19,29 @@ public:
CCW CCW
}; };
AbstractFace(unsigned id=0); AbstractFace(std::size_t id=0);
virtual ~AbstractFace(); virtual ~AbstractFace();
virtual std::vector<unsigned> getNodeIds() const = 0; virtual std::vector<std::size_t> getNodeIds() const = 0;
void addVectorAttribute(const std::string& tag, const std::vector<double>& values); void addVectorAttribute(const std::string& tag, const std::vector<double>& values);
std::vector<double> getVectorAttribute(const std::string& tag) const; std::vector<double> getVectorAttribute(const std::string& tag) const;
void setIndex(std::size_t idx); virtual std::size_t getNumNodes() const = 0;
virtual unsigned getNumNodes() const = 0;
virtual void associateWidthEdges() = 0; virtual void associateWidthEdges() = 0;
virtual void replaceEdge(Edge* original, Edge* replacement) = 0; virtual std::vector<std::size_t> getEdgeIds() const = 0;
virtual std::vector<unsigned> getEdgeIds() const = 0;
virtual std::vector<Point> getNodeLocations(Orientation orientation = Orientation::CCW) const = 0; virtual std::vector<Point> getNodeLocations(Orientation orientation = Orientation::CCW) const = 0;
virtual void replaceEdge(Edge* original, Edge* replacement) = 0;
void setIndex(std::size_t idx);
protected: protected:
unsigned mId{0}; std::size_t mId{0};
std::unordered_map<std::string, std::vector<double> > mVectorAttributes; std::unordered_map<std::string, std::vector<double> > mVectorAttributes;
}; };

View file

@ -2,14 +2,14 @@
#include "Node.h" #include "Node.h"
Edge::Edge(Node* node0, Node* node1, unsigned id) Edge::Edge(Node* node0, Node* node1, std::size_t id)
: mNode0(node0), : mNode0(node0),
mNode1(node1), mNode1(node1),
mId(id) mId(id)
{ {
} }
std::unique_ptr<Edge> Edge::Create(Node* node0, Node* node1, unsigned id) std::unique_ptr<Edge> Edge::Create(Node* node0, Node* node1, std::size_t id)
{ {
return std::make_unique<Edge>(node0, node1, id); return std::make_unique<Edge>(node0, node1, id);
} }
@ -19,12 +19,12 @@ Edge::~Edge()
} }
unsigned Edge::getNode0Id() const std::size_t Edge::getNode0Id() const
{ {
return mNode0->getIndex(); return mNode0->getIndex();
} }
unsigned Edge::getNode1Id() const std::size_t Edge::getNode1Id() const
{ {
return mNode1->getIndex(); return mNode1->getIndex();
} }
@ -75,7 +75,7 @@ Node* Edge::getOtherNode(Node* node) const
} }
} }
unsigned Edge::getId() const std::size_t Edge::getId() const
{ {
return mId; return mId;
} }
@ -95,17 +95,17 @@ void Edge::clearConnectivity()
mAssociatedFaceIds.clear(); mAssociatedFaceIds.clear();
} }
unsigned Edge::getNumConnectedFaces() const std::size_t Edge::getNumConnectedFaces() const
{ {
return mAssociatedFaceIds.size(); return mAssociatedFaceIds.size();
} }
void Edge::associateFace(unsigned faceId) void Edge::associateFace(std::size_t faceId)
{ {
mAssociatedFaceIds.push_back(faceId); mAssociatedFaceIds.push_back(faceId);
} }
unsigned Edge::getConnectedFaceId(std::size_t idx) const std::size_t Edge::getConnectedFaceId(std::size_t idx) const
{ {
return mAssociatedFaceIds[idx]; return mAssociatedFaceIds[idx];
} }
@ -116,7 +116,7 @@ void Edge::associateWithNodes()
mNode1->associateEdge(mId); mNode1->associateEdge(mId);
} }
void Edge::setIndex(unsigned idx) void Edge::setIndex(std::size_t idx)
{ {
mId = idx; mId = idx;
} }

View file

@ -14,33 +14,33 @@ public:
DIRTY DIRTY
}; };
Edge(Node* node0, Node* node1, unsigned id = 0); Edge(Node* node0, Node* node1, std::size_t id = 0);
~Edge(); ~Edge();
static std::unique_ptr<Edge> Create(Node* node0, Node* node1, unsigned id = 0); static std::unique_ptr<Edge> Create(Node* node0, Node* node1, std::size_t id = 0);
void associateFace(unsigned faceId); void associateFace(std::size_t faceId);
void associateWithNodes(); void associateWithNodes();
void clearConnectivity(); void clearConnectivity();
unsigned getConnectedFaceId(std::size_t idx) const; std::size_t getConnectedFaceId(std::size_t idx) const;
State getState() const; State getState() const;
unsigned getId() const; std::size_t getId() const;
unsigned getNode0Id() const; std::size_t getNode0Id() const;
unsigned getNode1Id() const; std::size_t getNode1Id() const;
Node* getNode0() const; Node* getNode0() const;
Node* getNode1() const; Node* getNode1() const;
unsigned getNumConnectedFaces() const; std::size_t getNumConnectedFaces() const;
Node* getOtherNode(Node* node) const; Node* getOtherNode(Node* node) const;
@ -52,14 +52,14 @@ public:
void setState(State state); void setState(State state);
void setIndex(unsigned idx); void setIndex(std::size_t idx);
private: private:
unsigned mId{0}; std::size_t mId{0};
Node* mNode0{nullptr}; Node* mNode0{nullptr};
Node* mNode1{nullptr}; Node* mNode1{nullptr};
std::vector<unsigned> mAssociatedFaceIds; std::vector<std::size_t> mAssociatedFaceIds;
State mState{State::HEALTHY}; State mState{State::HEALTHY};
}; };

View file

@ -4,8 +4,6 @@
#include "Edge.h" #include "Edge.h"
#include "AbstractFace.h" #include "AbstractFace.h"
#include <iostream>
FaceMesh::~FaceMesh() FaceMesh::~FaceMesh()
{ {
@ -26,7 +24,7 @@ const VecFaces& FaceMesh::getFaces() const
return mFaces; return mFaces;
} }
std::vector<unsigned> FaceMesh::getFaceNodeIds() const std::vector<std::size_t> FaceMesh::getFaceNodeIds() const
{ {
if (mFaces.empty()) if (mFaces.empty())
{ {
@ -34,7 +32,7 @@ std::vector<unsigned> FaceMesh::getFaceNodeIds() const
} }
auto nodes_per_face = mFaces[0]->getNumNodes(); auto nodes_per_face = mFaces[0]->getNumNodes();
std::vector<unsigned> ids(nodes_per_face*mFaces.size()); std::vector<std::size_t> ids(nodes_per_face*mFaces.size());
for(std::size_t idx=0; idx<mFaces.size(); idx++) for(std::size_t idx=0; idx<mFaces.size(); idx++)
{ {
@ -67,7 +65,7 @@ void FaceMesh::addConstantFaceVectorAttribute(const std::string& tag, const std:
void FaceMesh::resetIds() void FaceMesh::resetIds()
{ {
unsigned count = 0; std::size_t count = 0;
for (auto& node : mNodes) for (auto& node : mNodes)
{ {
node->setIndex(count); node->setIndex(count);
@ -115,7 +113,7 @@ void FaceMesh::replaceIfOverlapping(FaceMesh* mesh, Node* target_node) const
if (node->getNumConnectedEdges() == 3 && node->isCoincident(target_node)) if (node->getNumConnectedEdges() == 3 && node->isCoincident(target_node))
{ {
target_node->setState(Node::State::DIRTY); target_node->setState(Node::State::DIRTY);
for (unsigned idx=0; idx<3; idx++) for (std::size_t idx=0; idx<3; idx++)
{ {
auto edge = mesh->mEdges[idx].get(); auto edge = mesh->mEdges[idx].get();
edge->replaceNodes(target_node, node.get()); edge->replaceNodes(target_node, node.get());
@ -132,7 +130,7 @@ void FaceMesh::replaceIfOverlapping(FaceMesh* mesh, Edge* target_edge) const
if (edge->getNumConnectedFaces() == 2 && target_edge->hasSameNodes(edge.get())) if (edge->getNumConnectedFaces() == 2 && target_edge->hasSameNodes(edge.get()))
{ {
target_edge->setState(Edge::State::DIRTY); target_edge->setState(Edge::State::DIRTY);
for (unsigned idx=0; idx<2; idx++) for (std::size_t idx=0; idx<2; idx++)
{ {
auto face = mesh->mFaces[idx].get(); auto face = mesh->mFaces[idx].get();
face->replaceEdge(target_edge, edge.get()); face->replaceEdge(target_edge, edge.get());
@ -142,9 +140,9 @@ void FaceMesh::replaceIfOverlapping(FaceMesh* mesh, Edge* target_edge) const
} }
} }
std::vector<unsigned> FaceMesh::getEdgeNodeIds() const std::vector<std::size_t> FaceMesh::getEdgeNodeIds() const
{ {
std::vector<unsigned> ids(2*mEdges.size()); std::vector<std::size_t> ids(2*mEdges.size());
for(std::size_t idx=0; idx<mEdges.size(); idx++) for(std::size_t idx=0; idx<mEdges.size(); idx++)
{ {
ids[2*idx] = mEdges[idx]->getNode0Id(); ids[2*idx] = mEdges[idx]->getNode0Id();

View file

@ -25,9 +25,9 @@ public:
void populate(VecNodes& nodes, VecEdges& edges, VecFaces& faces); void populate(VecNodes& nodes, VecEdges& edges, VecFaces& faces);
std::vector<unsigned> getFaceNodeIds() const; std::vector<std::size_t> getFaceNodeIds() const;
std::vector<unsigned> getEdgeNodeIds() const; std::vector<std::size_t> getEdgeNodeIds() const;
void addConstantFaceVectorAttribute(const std::string& tag, const std::vector<double>& values); void addConstantFaceVectorAttribute(const std::string& tag, const std::vector<double>& values);

View file

@ -23,9 +23,9 @@ LineMesh::MeshType LineMesh::getType() const
return LineMesh::MeshType::LINE; return LineMesh::MeshType::LINE;
} }
std::vector<unsigned> LineMesh::getEdgeNodeIds() const std::vector<std::size_t> LineMesh::getEdgeNodeIds() const
{ {
std::vector<unsigned> ids(2*mEdges.size()); std::vector<std::size_t> ids(2*mEdges.size());
for(std::size_t idx=0; idx<mEdges.size(); idx++) for(std::size_t idx=0; idx<mEdges.size(); idx++)
{ {
ids[2*idx] = mEdges[idx]->getNode0Id(); ids[2*idx] = mEdges[idx]->getNode0Id();

View file

@ -18,7 +18,7 @@ public:
void populate(VecNodes& nodes, VecEdges& edges); void populate(VecNodes& nodes, VecEdges& edges);
std::vector<unsigned> getEdgeNodeIds() const; std::vector<std::size_t> getEdgeNodeIds() const;
MeshType getType() const override; MeshType getType() const override;

View file

@ -1,6 +1,6 @@
#include "Node.h" #include "Node.h"
std::unique_ptr<Node> Node::Create(const Point& p, unsigned index) std::unique_ptr<Node> Node::Create(const Point& p, std::size_t index)
{ {
return std::make_unique<Node>(p, index); return std::make_unique<Node>(p, index);
} }
@ -10,19 +10,19 @@ Node::~Node()
} }
Node::Node(const Point& p, unsigned index) Node::Node(const Point& p, std::size_t index)
: mPoint(p), : mPoint(p),
mIndex(index) mIndex(index)
{ {
} }
unsigned Node::getIndex() const std::size_t Node::getIndex() const
{ {
return mIndex; return mIndex;
} }
void Node::updateIndex(unsigned index) void Node::updateIndex(std::size_t index)
{ {
mIndex = index; mIndex = index;
} }
@ -78,32 +78,32 @@ void Node::clearConnectivity()
mAssociatedFaceIds.clear(); mAssociatedFaceIds.clear();
} }
unsigned Node::getNumConnectedEdges() const std::size_t Node::getNumConnectedEdges() const
{ {
return mAssociatedEdgeIds.size(); return mAssociatedEdgeIds.size();
} }
unsigned Node::getNumConnectedFaces() const std::size_t Node::getNumConnectedFaces() const
{ {
return mAssociatedFaceIds.size(); return mAssociatedFaceIds.size();
} }
void Node::associateEdge(unsigned edgeId) void Node::associateEdge(std::size_t edgeId)
{ {
mAssociatedEdgeIds.push_back(edgeId); mAssociatedEdgeIds.push_back(edgeId);
} }
void Node::associateFace(unsigned faceId) void Node::associateFace(std::size_t faceId)
{ {
mAssociatedFaceIds.push_back(faceId); mAssociatedFaceIds.push_back(faceId);
} }
unsigned Node::getConnectedEdgeId(std::size_t idx) const std::size_t Node::getConnectedEdgeId(std::size_t idx) const
{ {
return mAssociatedEdgeIds[idx]; return mAssociatedEdgeIds[idx];
} }
unsigned Node::getConnectedFaceId(std::size_t idx) const std::size_t Node::getConnectedFaceId(std::size_t idx) const
{ {
return mAssociatedFaceIds[idx]; return mAssociatedFaceIds[idx];
} }

View file

@ -16,29 +16,29 @@ public:
DIRTY DIRTY
}; };
Node(const Point& p, unsigned index = 0); Node(const Point& p, std::size_t index = 0);
static std::unique_ptr<Node> Create(const Point& p, unsigned index = 0); static std::unique_ptr<Node> Create(const Point& p, std::size_t index = 0);
~Node(); ~Node();
void associateEdge(unsigned edgeId); void associateEdge(std::size_t edgeId);
void associateFace(unsigned faceId); void associateFace(std::size_t faceId);
void addVectorAttribute(const std::string& tag, const std::vector<double>& values); void addVectorAttribute(const std::string& tag, const std::vector<double>& values);
void clearConnectivity(); void clearConnectivity();
unsigned getIndex() const; std::size_t getIndex() const;
unsigned getNumConnectedEdges() const; std::size_t getNumConnectedEdges() const;
unsigned getNumConnectedFaces() const; std::size_t getNumConnectedFaces() const;
unsigned getConnectedEdgeId(std::size_t idx) const; std::size_t getConnectedEdgeId(std::size_t idx) const;
unsigned getConnectedFaceId(std::size_t idx) const; std::size_t getConnectedFaceId(std::size_t idx) const;
State getState() const; State getState() const;
@ -52,7 +52,7 @@ public:
void setIndex(std::size_t idx); void setIndex(std::size_t idx);
void updateIndex(unsigned index); void updateIndex(std::size_t index);
void scale(double x, double y); void scale(double x, double y);
@ -60,11 +60,11 @@ public:
private: private:
std::unordered_map<std::string, std::vector<double> > mVectorAttributes; std::unordered_map<std::string, std::vector<double> > mVectorAttributes;
unsigned mIndex{0}; std::size_t mIndex{0};
Point mPoint; Point mPoint;
std::vector<unsigned> mAssociatedEdgeIds; std::vector<std::size_t> mAssociatedEdgeIds;
std::vector<unsigned> mAssociatedFaceIds; std::vector<std::size_t> mAssociatedFaceIds;
State mState{State::HEALTHY}; State mState{State::HEALTHY};
}; };

View file

@ -3,7 +3,7 @@
#include "Edge.h" #include "Edge.h"
#include "Node.h" #include "Node.h"
TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id) TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, std::size_t id)
: AbstractFace(id), : AbstractFace(id),
mEdge0(edge0), mEdge0(edge0),
mEdge1(edge1), mEdge1(edge1),
@ -12,7 +12,7 @@ TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id)
} }
std::unique_ptr<TriFace> TriFace::Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id) std::unique_ptr<TriFace> TriFace::Create(Edge* edge0, Edge* edge1, Edge* edge2, std::size_t id)
{ {
return std::make_unique<TriFace>(edge0, edge1, edge2, id); return std::make_unique<TriFace>(edge0, edge1, edge2, id);
} }
@ -22,12 +22,12 @@ TriFace::~TriFace()
} }
std::vector<unsigned> TriFace::getNodeIds() const std::vector<std::size_t> TriFace::getNodeIds() const
{ {
return {mEdge0->getNode0Id(), mEdge0->getNode1Id(), mEdge1->getNode1Id()}; return {mEdge0->getNode0Id(), mEdge0->getNode1Id(), mEdge1->getNode1Id()};
} }
unsigned TriFace::getNumNodes() const std::size_t TriFace::getNumNodes() const
{ {
return 3; return 3;
} }
@ -48,22 +48,22 @@ void TriFace::replaceEdge(Edge* original, Edge* replacement)
} }
} }
unsigned TriFace::getEdge0Id () const std::size_t TriFace::getEdge0Id () const
{ {
return mEdge0->getId(); return mEdge0->getId();
} }
unsigned TriFace::getEdge1Id () const std::size_t TriFace::getEdge1Id () const
{ {
return mEdge1->getId(); return mEdge1->getId();
} }
unsigned TriFace::getEdge2Id () const std::size_t TriFace::getEdge2Id () const
{ {
return mEdge2->getId(); return mEdge2->getId();
} }
std::vector<unsigned> TriFace::getEdgeIds() const std::vector<std::size_t> TriFace::getEdgeIds() const
{ {
return {mEdge0->getId(), mEdge1->getId(), mEdge2->getId()}; return {mEdge0->getId(), mEdge1->getId(), mEdge2->getId()};
} }

View file

@ -8,24 +8,24 @@ class Edge;
class TriFace : public AbstractFace class TriFace : public AbstractFace
{ {
public: public:
TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id=0); TriFace(Edge* edge0, Edge* edge1, Edge* edge2, std::size_t id=0);
~TriFace(); ~TriFace();
static std::unique_ptr<TriFace> Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id=0); static std::unique_ptr<TriFace> Create(Edge* edge0, Edge* edge1, Edge* edge2, std::size_t id=0);
void associateWidthEdges() override; void associateWidthEdges() override;
std::vector<unsigned> getNodeIds() const override; std::vector<std::size_t> getNodeIds() const override;
unsigned getNumNodes() const override; std::size_t getNumNodes() const override;
void replaceEdge(Edge* original, Edge* replacement); void replaceEdge(Edge* original, Edge* replacement);
unsigned getEdge0Id () const; std::size_t getEdge0Id () const;
unsigned getEdge1Id () const; std::size_t getEdge1Id () const;
unsigned getEdge2Id () const; std::size_t getEdge2Id () const;
std::vector<unsigned> getEdgeIds() const override; std::vector<std::size_t> getEdgeIds() const override;
std::vector<Point> getNodeLocations(Orientation orientation = Orientation::CCW) const override; std::vector<Point> getNodeLocations(Orientation orientation = Orientation::CCW) const override;

View file

@ -5,6 +5,7 @@
#include "FileLogger.h" #include "FileLogger.h"
#include "Win32TempFile.h" #include "Win32TempFile.h"
#include "UnicodeUtils.h"
Win32WebRequest::Win32WebRequest() Win32WebRequest::Win32WebRequest()
: mBuffer(DEFAULT_BUFFER_SIZE) : mBuffer(DEFAULT_BUFFER_SIZE)
@ -47,8 +48,7 @@ void Win32WebRequest::resizeBuffer(unsigned size)
std::string Win32WebRequest::getUrlFromRequest() const std::string Win32WebRequest::getUrlFromRequest() const
{ {
const std::wstring wide_url = mHandle->CookedUrl.pFullUrl; return UnicodeUtils::utf16ToUtf8String(mHandle->CookedUrl.pFullUrl);
return StringUtils::convert(wide_url);
} }
HttpRequest Win32WebRequest::getRequest() const HttpRequest Win32WebRequest::getRequest() const

View file

@ -9,7 +9,7 @@
#include "HttpRequest.h" #include "HttpRequest.h"
#include "HttpResponse.h" #include "HttpResponse.h"
#include "FileLogger.h" #include "FileLogger.h"
#include "StringUtils.h" #include "UnicodeUtils.h"
Win32WebServer::Win32WebServer(AbstractWebApp* webApp) Win32WebServer::Win32WebServer(AbstractWebApp* webApp)
: mListenUrl("http://localhost:49153/"), : mListenUrl("http://localhost:49153/"),
@ -26,7 +26,7 @@ Win32WebServer::~Win32WebServer()
void Win32WebServer::clear() void Win32WebServer::clear()
{ {
// Remove url // Remove url
::HttpRemoveUrl(mWorkingQueue, StringUtils::convert(mListenUrl).c_str()); ::HttpRemoveUrl(mWorkingQueue, UnicodeUtils::utf8ToUtf16WString(mListenUrl).c_str());
// Close the Request Queue handle. // Close the Request Queue handle.
if (mWorkingQueue) if (mWorkingQueue)
@ -56,7 +56,7 @@ void Win32WebServer::initialize()
return; return;
} }
retCode = ::HttpAddUrl(mWorkingQueue, StringUtils::convert(mListenUrl).c_str(), nullptr); retCode = ::HttpAddUrl(mWorkingQueue, UnicodeUtils::utf8ToUtf16WString(mListenUrl).c_str(), nullptr);
if (FAILED(retCode)) if (FAILED(retCode))
{ {
MLOG_ERROR("Failed to register queue to url: " << mListenUrl); MLOG_ERROR("Failed to register queue to url: " << mListenUrl);

View file

@ -1,13 +1,10 @@
#pragma once #pragma once
#ifndef UNICODE
#define UNICODE
#endif
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif #endif
#include <windows.h>
#include "Win32BaseIncludes.h"
#ifndef _WIN32_WINNT #ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600 #define _WIN32_WINNT 0x0600

View file

@ -1,6 +1,6 @@
#include "LatexSymbols.h" #include "LatexSymbols.h"
#include "StringUtils.h" #include "UnicodeUtils.h"
std::unordered_map<std::string, std::wstring> LatexSymbolLookup::mSymbols = { std::unordered_map<std::string, std::wstring> LatexSymbolLookup::mSymbols = {
{"Psi", L"\u03A8"}, {"Psi", L"\u03A8"},
@ -14,7 +14,7 @@ std::optional<std::string> LatexSymbolLookup::getSymbolUtf8(const std::string& t
{ {
if (auto entry = getSymbolUtf16(tag); entry) if (auto entry = getSymbolUtf16(tag); entry)
{ {
return StringUtils::convert(*entry); return UnicodeUtils::utf16ToUtf8String(*entry);
} }
else else
{ {

View file

@ -73,7 +73,7 @@ void Button::doPaint(const PaintEvent* event)
void Button::updateLabel(const PaintEvent* event) void Button::updateLabel(const PaintEvent* event)
{ {
unsigned fontOffset = unsigned(mLabel.size()) * 4; unsigned fontOffset = unsigned(mLabel.size()) * 4;
auto middle = DiscretePoint(mLocation.GetX() + mSize.mWidth/2 - fontOffset, mLocation.GetY() + mSize.mHeight/2 + 4); auto middle = DiscretePoint(mLocation.getX() + mSize.mWidth/2 - fontOffset, mLocation.getY() + mSize.mHeight/2 + 4);
if (!mTextNode) if (!mTextNode)
{ {

View file

@ -48,7 +48,7 @@ void HorizontalSpacer::updateChildLocations()
delta = size.mMaxHeight; delta = size.mMaxHeight;
} }
child->setBounds(mSize.mWidth, unsigned(delta)); child->setBounds(mSize.mWidth, unsigned(delta));
child->setLocation(DiscretePoint(mLocation.GetX(), mLocation.GetY() + unsigned(offset))); child->setLocation(DiscretePoint(mLocation.getX(), mLocation.getY() + unsigned(offset)));
offset += delta; offset += delta;
} }
} }

View file

@ -39,7 +39,7 @@ void Label::doPaint(const PaintEvent* event)
void Label::updateLabel(const PaintEvent* event) void Label::updateLabel(const PaintEvent* event)
{ {
unsigned fontOffset = unsigned(mLabel.size()) * 4; unsigned fontOffset = unsigned(mLabel.size()) * 4;
auto middle = DiscretePoint(mLocation.GetX() + mSize.mWidth/2 - fontOffset, mLocation.GetY() + mSize.mHeight/2 + 4); auto middle = DiscretePoint(mLocation.getX() + mSize.mWidth/2 - fontOffset, mLocation.getY() + mSize.mHeight/2 + 4);
if (!mTextNode) if (!mTextNode)
{ {

View file

@ -83,7 +83,7 @@ void TextBox::doPaint(const PaintEvent* event)
void TextBox::updateLabel(const PaintEvent* event) void TextBox::updateLabel(const PaintEvent* event)
{ {
auto loc = DiscretePoint(mLocation.GetX() + mPadding.mLeft, mLocation.GetY() + mPadding.mTop + unsigned(0)); auto loc = DiscretePoint(mLocation.getX() + mPadding.mLeft, mLocation.getY() + mPadding.mTop + unsigned(0));
if (!mTextNode) if (!mTextNode)
{ {

View file

@ -37,7 +37,7 @@ void VerticalSpacer::updateChildLocations()
double scale = mScales[idx]; double scale = mScales[idx];
double delta = mSize.mWidth * (scale/scaleSum); double delta = mSize.mWidth * (scale/scaleSum);
child->setBounds(unsigned(delta), mSize.mHeight); child->setBounds(unsigned(delta), mSize.mHeight);
child->setLocation(DiscretePoint(mLocation.GetX() + unsigned(offset), mLocation.GetY())); child->setLocation(DiscretePoint(mLocation.getX() + unsigned(offset), mLocation.getY()));
offset += delta; offset += delta;
} }
} }

View file

@ -237,19 +237,19 @@ void Widget::updateChildLocations()
bool Widget::contains(const DiscretePoint& loc) const bool Widget::contains(const DiscretePoint& loc) const
{ {
if(loc.GetX() < mLocation.GetX()) if(loc.getX() < mLocation.getX())
{ {
return false; return false;
} }
if(loc.GetX() > mLocation.GetX() + mSize.mWidth) if(loc.getX() > mLocation.getX() + mSize.mWidth)
{ {
return false; return false;
} }
if(loc.GetY() > mLocation.GetY() + mSize.mHeight) if(loc.getY() > mLocation.getY() + mSize.mHeight)
{ {
return false; return false;
} }
if(loc.GetY() < mLocation.GetY()) if(loc.getY() < mLocation.getY())
{ {
return false; return false;
} }
@ -313,8 +313,8 @@ void Widget::onMyMouseEvent(const MouseEvent* event)
void Widget::updateBackground(const PaintEvent* event) void Widget::updateBackground(const PaintEvent* event)
{ {
unsigned locX = mLocation.GetX() + mMargin.mLeft; unsigned locX = mLocation.getX() + mMargin.mLeft;
unsigned locY = mLocation.GetY() + mMargin.mTop; unsigned locY = mLocation.getX() + mMargin.mTop;
unsigned deltaX = mSize.mWidth - mMargin.mLeft - mMargin.mRight; unsigned deltaX = mSize.mWidth - mMargin.mLeft - mMargin.mRight;
unsigned deltaY = mSize.mHeight - mMargin.mTop - mMargin.mBottom; unsigned deltaY = mSize.mHeight - mMargin.mTop - mMargin.mBottom;

View file

@ -0,0 +1,28 @@
#include "LineNode.h"
LineNode::LineNode(const Point& location, const std::vector<Point>& points)
: GeometryNode(location),
mPoints(points)
{
}
LineNode::Type LineNode::getType()
{
return Type::Line;
}
void LineNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
{
if (sceneInfo->mSupportsGeometryPrimitives)
{
auto line = std::make_unique<Line>(Point{ 0, 0 }, mPoints);
mBackgroundItem = std::make_unique<SceneModel>(std::move(line));
}
mBackgroundItem->setName(mName + "_Model");
}
void LineNode::updateTransform()
{
mBackgroundItem->updateTransform({ mLocation });
}

View file

@ -10,33 +10,14 @@
class LineNode : public GeometryNode class LineNode : public GeometryNode
{ {
public: public:
LineNode(const Point& location, const std::vector<Point>& points) LineNode(const Point& location, const std::vector<Point>& points);
: GeometryNode(location),
mPoints(points)
{
} Type getType();
Type getType()
{
return Type::Line;
}
void createOrUpdateGeometry(SceneInfo* sceneInfo)
{
if (sceneInfo->mSupportsGeometryPrimitives)
{
auto line = std::make_unique<Line>(Point{ 0, 0 }, 1, 1);
mBackgroundItem = std::make_unique<SceneModel>(std::move(line));
}
mBackgroundItem->setName(mName + "_Model");
}
void updateTransform()
{
mBackgroundItem->updateTransform({ mLocation });
}
private: private:
void createOrUpdateGeometry(SceneInfo* sceneInfo) override;
void updateTransform() override;
std::vector<Point> mPoints; std::vector<Point> mPoints;
}; };

View file

@ -32,7 +32,7 @@ bool MarkdownParser::isInMultilineBlock() const
return working_type == MarkdownElement::Type::MULTILINE_QUOTE || working_type == MarkdownElement::Type::CUSTOM_MULTILINE ; return working_type == MarkdownElement::Type::MULTILINE_QUOTE || working_type == MarkdownElement::Type::CUSTOM_MULTILINE ;
} }
unsigned MarkdownParser::checkForLink(const std::string& lineSection) std::size_t MarkdownParser::checkForLink(const std::string& lineSection)
{ {
if (lineSection.empty()) if (lineSection.empty())
{ {
@ -40,7 +40,7 @@ unsigned MarkdownParser::checkForLink(const std::string& lineSection)
} }
std::vector<std::string> hits; std::vector<std::string> hits;
unsigned hit_size{0}; std::size_t hit_size{0};
if (Lexer::matchPattern("[@](@)", lineSection, '@', hits)) if (Lexer::matchPattern("[@](@)", lineSection, '@', hits))
{ {
if (hits.size() == 2) if (hits.size() == 2)
@ -59,7 +59,7 @@ unsigned MarkdownParser::checkForLink(const std::string& lineSection)
return hit_size; return hit_size;
} }
unsigned MarkdownParser::checkForImage(const std::string& lineSection) std::size_t MarkdownParser::checkForImage(const std::string& lineSection)
{ {
if (lineSection.empty()) if (lineSection.empty())
{ {
@ -67,7 +67,7 @@ unsigned MarkdownParser::checkForImage(const std::string& lineSection)
} }
std::vector<std::string> hits; std::vector<std::string> hits;
unsigned hit_size{0}; std::size_t hit_size{0};
if (Lexer::matchPattern("![@](@)", lineSection, '@', hits)) if (Lexer::matchPattern("![@](@)", lineSection, '@', hits))
{ {
if (hits.size() == 2) if (hits.size() == 2)
@ -85,7 +85,7 @@ unsigned MarkdownParser::checkForImage(const std::string& lineSection)
return hit_size; return hit_size;
} }
unsigned MarkdownParser::checkForInlineQuote(const std::string& lineSection) std::size_t MarkdownParser::checkForInlineQuote(const std::string& lineSection)
{ {
if (lineSection.empty()) if (lineSection.empty())
{ {
@ -93,7 +93,7 @@ unsigned MarkdownParser::checkForInlineQuote(const std::string& lineSection)
} }
std::vector<std::string> hits; std::vector<std::string> hits;
unsigned hit_size{0}; std::size_t hit_size{0};
if (Lexer::matchPattern("`@`", lineSection, '@', hits)) if (Lexer::matchPattern("`@`", lineSection, '@', hits))
{ {
if (hits.size() == 1) if (hits.size() == 1)
@ -111,7 +111,8 @@ unsigned MarkdownParser::checkForInlineQuote(const std::string& lineSection)
} }
return hit_size; return hit_size;
} }
unsigned MarkdownParser::checkForCustomInline(const std::string& lineSection)
std::size_t MarkdownParser::checkForCustomInline(const std::string& lineSection)
{ {
if (lineSection.empty()) if (lineSection.empty())
{ {
@ -119,9 +120,9 @@ unsigned MarkdownParser::checkForCustomInline(const std::string& lineSection)
} }
std::vector<std::string> hits; std::vector<std::string> hits;
unsigned hit_size{0}; std::size_t hit_size{0};
for(unsigned idx=0; idx<mWorkingDocument->getNumInlineContexts(); idx++) for(std::size_t idx=0; idx<mWorkingDocument->getNumInlineContexts(); idx++)
{ {
const auto delimiter = mWorkingDocument->getInlineContext(idx)->getDelimiter(); const auto delimiter = mWorkingDocument->getInlineContext(idx)->getDelimiter();
if (Lexer::matchPattern(delimiter + "@" + delimiter, lineSection, '@', hits)) if (Lexer::matchPattern(delimiter + "@" + delimiter, lineSection, '@', hits))
@ -193,7 +194,7 @@ void MarkdownParser::processLine(const std::string& line)
} }
} }
unsigned line_position = 0; std::size_t line_position = 0;
mWorkingLine.clear(); mWorkingLine.clear();
while(line_position < line.size()) while(line_position < line.size())
{ {
@ -308,11 +309,11 @@ void MarkdownParser::onFoundHeading(const std::string& line)
{ {
onSectionFinished(); onSectionFinished();
unsigned level = StringUtils::countFirstConsecutiveHits(line, HEADING_DELIMITER); auto level = StringUtils::countFirstConsecutiveHits(line, HEADING_DELIMITER);
auto heading = std::make_unique<MarkdownHeading>(level); auto heading = std::make_unique<MarkdownHeading>(level);
std::string prefix; std::string prefix;
for(unsigned idx=0; idx<level; idx++) for(std::size_t idx=0; idx<level; idx++)
{ {
prefix += HEADING_DELIMITER; prefix += HEADING_DELIMITER;
} }

View file

@ -25,10 +25,10 @@ public:
private: private:
void addChildToWorkingElement(std::unique_ptr<MarkdownInlineElement> child); void addChildToWorkingElement(std::unique_ptr<MarkdownInlineElement> child);
unsigned checkForImage(const std::string& lineSection); std::size_t checkForImage(const std::string& lineSection);
unsigned checkForLink(const std::string& lineSection); std::size_t checkForLink(const std::string& lineSection);
unsigned checkForInlineQuote(const std::string& lineSection); std::size_t checkForInlineQuote(const std::string& lineSection);
unsigned checkForCustomInline(const std::string& lineSection); std::size_t checkForCustomInline(const std::string& lineSection);
bool isInMultilineBlock() const; bool isInMultilineBlock() const;

View file

@ -5,7 +5,7 @@
#include "Win32DxWindowInterface.h" #include "Win32DxWindowInterface.h"
#include "FileLogger.h" #include "FileLogger.h"
#include "StringUtils.h" #include "UnicodeUtils.h"
#include "Widget.h" #include "Widget.h"
#include "DrawingContext.h" #include "DrawingContext.h"
#include "DirectXPainter.h" #include "DirectXPainter.h"
@ -105,7 +105,7 @@ LRESULT CALLBACK Win32Window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa
key_event->setAction(KeyboardEvent::Action::Pressed); key_event->setAction(KeyboardEvent::Action::Pressed);
auto keyChar = (wchar_t)wParam; auto keyChar = (wchar_t)wParam;
key_event->setKeyString(StringUtils::convert(std::wstring(1, keyChar))); key_event->setKeyString(UnicodeUtils::utf16ToUtf8String(std::wstring(1, keyChar)));
mDesktopManager->onUiEvent(std::move(key_event)); mDesktopManager->onUiEvent(std::move(key_event));
return 0; return 0;
} }