<commit_before>/***************************************************************************
 *   Copyright (c) 2012 <NAME> <<EMAIL>>                 *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/

#ifndef TECHDRAW_GEOMETRY_H
#define TECHDRAW_GEOMETRY_H

#include <Base/Tools2D.h>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>

class BRepAdaptor_Curve;

namespace TechDrawGeometry {

enum ExtractionType {               //obs sb vis/hid + hard/smooth/seam/out(edgeClass?)
      Plain = 0,
      WithHidden = 1,
      WithSmooth = 2
};

enum edgeClass {
    ecNONE,                                                            //not used, OCC index starts at 1
    ecUVISO,
    ecOUTLINE,
    ecSMOOTH,
    ecSEAM,
    ecHARD
};

enum GeomType {
    NOTDEF,
    CIRCLE,
    ARCOFCIRCLE,
    ELLIPSE,
    ARCOFELLIPSE,
    BSPLINE,
    GENERIC
};

class TechDrawExport BaseGeom
{
public:
   BaseGeom();
   virtual ~BaseGeom() {}
public:
    GeomType geomType;
    ExtractionType extractType;     //obs
    edgeClass classOfEdge;
    bool visible;
    bool reversed;
    int ref3D;
    TopoDS_Edge occEdge;            //projected Edge
    std::vector<Base::Vector2D> findEndPoints();
    Base::Vector2D getStartPoint();
    Base::Vector2D getEndPoint();
public:      //class wide methods
    static BaseGeom* baseFactory(TopoDS_Edge edge);
};

class TechDrawExport Circle: public BaseGeom
{
public:
  Circle(const TopoDS_Edge &e);
  ~Circle() {}
public:
  Base::Vector2D center;
  double radius;
};

class TechDrawExport Ellipse: public BaseGeom
{
public:
  Ellipse(const TopoDS_Edge &e);
  ~Ellipse() {}
public:
  Base::Vector2D center;
  double minor;
  double major;
  /// Angle between the major axis of the ellipse and the X axis, in radian
  double angle;
};

class TechDrawExport AOE: public Ellipse
{
public:
  AOE(const TopoDS_Edge &e);
  ~AOE() {}
public:
  Base::Vector2D startPnt;  //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
  Base::Vector2D endPnt;
  Base::Vector2D midPnt;
  /// Angle in radian
  double startAngle;
  /// Angle in radian
  double endAngle;
  /// Arc is drawn clockwise from startAngle to endAngle if true, counterclockwise if false
  bool cw;
  bool largeArc;
};

class TechDrawExport AOC: public Circle
{
public:
  AOC(const TopoDS_Edge &e);
  ~AOC() {}
public:
  Base::Vector2D startPnt;
  Base::Vector2D endPnt;
  Base::Vector2D midPnt;
  /// Angle in radian
  double startAngle;
  /// Angle in radian
  double endAngle;
  /// Arc is drawn clockwise from startAngle to endAngle if true, counterclockwise if false
  bool cw;  // TODO: Instead of this (and similar one in AOE), why not reorder startAngle and endAngle?
  bool largeArc;
};

/// Handles degree 1 to 3 Bezier segments
/*!
 * \todo extend this to higher orders if necessary
 */
struct BezierSegment
{
    /// Number of entries in pnts that are valid
    int poles;
    /// Control points for this segment
    /*!
     * Note that first and last used points define the endpoints for this
     * segment, so when we know that a sequence of BezierSegment objects are
     * going to be strung together, then we only need to know the start of
     * the first element (or the end of the last element).
     */
    Base::Vector2D pnts[4];
};

class TechDrawExport BSpline: public BaseGeom
{
public:
  BSpline(const TopoDS_Edge &e);
  ~BSpline(){}
public:
  bool isLine(void);
  std::vector<BezierSegment> segments;
};

class TechDrawExport Generic: public BaseGeom
{
public:
  Generic(const TopoDS_Edge &e);
  Generic();
  ~Generic() {}
  std::vector<Base::Vector2D> points;
};



/// Simple Collection of geometric features based on BaseGeom inherited classes in order
class TechDrawExport Wire
{
public:
  Wire();
  Wire(const TopoDS_Wire &w);
  ~Wire();
  std::vector<BaseGeom *> geoms;
};

/// Simple Collection of geometric features based on BaseGeom inherited classes in order
class TechDrawExport Face
{
public:
  Face();
  ~Face();
  std::vector<Wire *> wires;
};

//! 2D Vertex
class TechDrawExport Vertex
{
public:
  Vertex(double x, double y) { pnt = Base::Vector2D(x, y); }
  Vertex(Base::Vector2D v) { pnt = v; }
  ~Vertex() {}
  Base::Vector2D pnt;
  ExtractionType extractType;
  bool visible;
  int ref3D;
  TopoDS_Vertex occVertex;
  bool isEqual(Vertex* v, double tol);
};

//*** utility functions
extern "C" {

struct TechDrawExport getNextReturnVal {
    unsigned int index;
    bool reversed;<commit_msg>Whitespace cleanup.<commit_after>/***************************************************************************
 *   Copyright (c) 2012 <NAME> <<EMAIL>>                 *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/

#ifndef TECHDRAW_GEOMETRY_H
#define TECHDRAW_GEOMETRY_H

#include <Base/Tools2D.h>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>

class BRepAdaptor_Curve;

namespace TechDrawGeometry {

enum ExtractionType {               //obs sb vis/hid + hard/smooth/seam/out(edgeClass?)
    Plain,
    WithHidden,
    WithSmooth
};

enum edgeClass {
    ecNONE,                                                            //not used, OCC index starts at 1
    ecUVISO,
    ecOUTLINE,
    ecSMOOTH,
    ecSEAM,
    ecHARD
};

enum GeomType {
    NOTDEF,
    CIRCLE,
    ARCOFCIRCLE,
    ELLIPSE,
    ARCOFELLIPSE,
    BSPLINE,
    GENERIC
};

class TechDrawExport BaseGeom
{
    public:
        BaseGeom();
        virtual ~BaseGeom() = default;

    public:
        GeomType geomType;
        ExtractionType extractType;     //obs
        edgeClass classOfEdge;
        bool visible;
        bool reversed;
        int ref3D;
        TopoDS_Edge occEdge;            //projected Edge

        std::vector<Base::Vector2D> findEndPoints();
        Base::Vector2D getStartPoint();
        Base::Vector2D getEndPoint();
        static BaseGeom* baseFactory(TopoDS_Edge edge);
};

class TechDrawExport Circle: public BaseGeom
{
    public:
        Circle(const TopoDS_Edge &e);
        ~Circle() = default;

    public:
        Base::Vector2D center;
        double radius;
};

class TechDrawExport Ellipse: public BaseGeom
{
    public:
        Ellipse(const TopoDS_Edge &e);
        ~Ellipse() = default;

    public:
        Base::Vector2D center;
        double minor;
        double major;

        /// Angle between the major axis of the ellipse and the X axis, in radian
        double angle;
};

class TechDrawExport AOE: public Ellipse
{
    public:
        AOE(const TopoDS_Edge &e);
        ~AOE() = default;

    public:
        Base::Vector2D startPnt;  //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
        Base::Vector2D endPnt;
        Base::Vector2D midPnt;

        /// Angle in radian
        double startAngle;

        /// Angle in radian
        double endAngle;

        /// Arc is drawn clockwise from startAngle to endAngle if true, counterclockwise if false
        bool cw;
        bool largeArc;
};

class TechDrawExport AOC: public Circle
{
    public:
        AOC(const TopoDS_Edge &e);
        ~AOC() = default;

    public:
        Base::Vector2D startPnt;
        Base::Vector2D endPnt;
        Base::Vector2D midPnt;

        /// Angle in radian
        double startAngle;

        /// Angle in radian
        double endAngle;

        /// Arc is drawn clockwise from startAngle to endAngle if true, counterclockwise if false
        bool cw;  // TODO: Instead of this (and similar one in AOE), why not reorder startAngle and endAngle?
        bool largeArc;
};

/// Handles degree 1 to 3 Bezier segments
/*!
 * \todo extend this to higher orders if necessary
 */
struct BezierSegment
{
    /// Number of entries in pnts that are valid
    int poles;

    /// Control points for this segment
    /*!
     * Note that first and last used points define the endpoints for this
     * segment, so when we know that a sequence of BezierSegment objects are
     * going to be strung together, then we only need to know the start of
     * the first element (or the end of the last element).
     */
    Base::Vector2D pnts[4];
};

class TechDrawExport BSpline: public BaseGeom
{
    public:
        BSpline(const TopoDS_Edge &e);
        ~BSpline() = default;

    public:
        bool isLine(void);
        std::vector<BezierSegment> segments;
};

class TechDrawExport Generic: public BaseGeom
{
    public:
        Generic(const TopoDS_Edge &e);
        Generic();
        ~Generic() = default;

       std::vector<Base::Vector2D> points;
};


/// Simple Collection of geometric features based on BaseGeom inherited classes in order
class TechDrawExport Wire
{
    public:
        Wire();
        Wire(const TopoDS_Wire &w);
        ~Wire();

        std::vector<BaseGeom *> geoms;
};

/// Simple Collection of geometric features based on BaseGeom inherited classes in order
class TechDrawExport Face
{
    public:
        Face();
        ~Face();

        std::vector<Wire *> wires;
};

//! 2D Vertex
class TechDrawExport Vertex
{
    public:
        Vertex(double x, double y) { pnt = Base::Vector2D(x, y); }
        Vertex(Base::Vector2D v) { pnt = v; }
        ~Vertex() = default;

        Base::Vector2D pnt;
        ExtractionType extractType;
        bool visible;
        int ref3D;
        TopoDS_Vertex occVertex;
        bool isEqual(Vertex* v, double tol);
};


//*** utility functions
extern "C" {

struct TechDrawExport getNextReturnVal {
    unsigned int index;
    bool reversed;
{'fraction_non_alphanumeric': 0.10528438886647842, 'fraction_numerical': 0.007180314643001211, 'mean_word_length': 2.1106649937264743, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4915702', 'n_tokens_mistral': 3610, 'n_tokens_neox': 3468, 'n_words': 1187}