Remove Point2f, replace with Vector2f

This commit is contained in:
Bram Verhulst
2024-04-17 13:54:48 +02:00
parent 64e96ab209
commit db83ae5e13
42 changed files with 494 additions and 634 deletions

View File

@@ -7,13 +7,13 @@ class SVGParser final
{
public:
// The only function to be called
static bool GetVerticesFromSvgFile(const std::string& filePath, std::vector<std::vector<Point2f>> &vertices);
static bool GetVerticesFromSvgFile(const std::string& filePath, std::vector<std::vector<Vector2f>> &vertices);
private:
//static bool LoadGeometryFromSvgStream(unsigned char* pBlob, int blobSize, std::vector<Point2f> &vertices);
//static bool LoadGeometryFromSvgStream(unsigned char* pBlob, int blobSize, std::vector<Vector2f> &vertices);
static void RemoveSpaces( std::string& svgString );
static bool GetVerticesFromSvgString(std::string& svgText, std::vector<std::vector<Point2f>> &vertices);
static bool GetVerticesFromPathData( const std::string& pathData, std::vector<Point2f> &vertices );
static bool GetVerticesFromSvgString(std::string& svgText, std::vector<std::vector<Vector2f>> &vertices);
static bool GetVerticesFromPathData( const std::string& pathData, std::vector<Vector2f> &vertices );
static bool GetElementContent( const std::string& svgText, const std::string& elementName, std::string& elementValue, size_t& startContentPos, size_t& endContentPos);
static bool GetAttributeValue( const std::string& svgText, const std::string& attributeName, std::string& attributeValue );
@@ -27,23 +27,23 @@ private:
static float ReadSvgValue(std::stringstream& stream, bool separatorRequired);
// Reads a single point
static Point2f ReadSvgPoint( std::stringstream& stream );
static Vector2f ReadSvgPoint( std::stringstream& stream );
// Read the first point,
// taking into account relative and absolute positioning.
// Stores this point, needed when path is closed
// Advances the cursor if requested.
static Point2f FirstSvgPoint(std::stringstream& stream, Point2f& cursor, char cmd, bool isOpen, bool advance);
static Vector2f FirstSvgPoint(std::stringstream& stream, Vector2f& cursor, char cmd, bool isOpen, bool advance);
// Read the next point,
// taking into account relative and absolute positioning.
// Advances the cursor if requested.
// Throws an exception if the figure is not open
static Point2f NextSvgPoint(std::stringstream& stream, Point2f& cursor, char cmd, bool isOpen, bool advance);
static Vector2f NextSvgPoint(std::stringstream& stream, Vector2f& cursor, char cmd, bool isOpen, bool advance);
// Reads next point, given only the new x coordinate
static Point2f NextSvgCoordX(std::stringstream& stream, Point2f& cursor, char cmd, bool isOpen);
static Vector2f NextSvgCoordX(std::stringstream& stream, Vector2f& cursor, char cmd, bool isOpen);
// Reads next point, given only the new y coordinate
static Point2f NextSvgCoordY(std::stringstream& ssRef, Point2f& cursor, char cmd, bool isOpen);
static Vector2f NextSvgCoordY(std::stringstream& ssRef, Vector2f& cursor, char cmd, bool isOpen);
};