/*************************************************************************** * Copyright (c) 2013 Luke Parry * * * * 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_GEOMETRYOBJECT_H #define _TECHDRAW_GEOMETRYOBJECT_H #include #include #include #include #include #include #include "Geometry.h" class HLRBRep_Algo; class Handle_HLRBRep_Data; class HLRBRep_EdgeData; class TopoDS_Wire; class HLRBRep_HLRToShape; namespace TechDrawGeometry { class BaseGeom; class TechDrawExport GeometryObject { public: /// Constructor GeometryObject(); virtual ~GeometryObject(); void clear(); void setTolerance(double value); void setScale(double value); //! Returns 2D bounding box Base::BoundBox3d calcBoundingBox() const; const std::vector & getVertexGeometry() const { return vertexGeom; }; const std::vector & getEdgeGeometry() const { return edgeGeom; }; const std::vector & getFaceGeometry() const { return faceGeom; }; const std::vector & getVertexRefs() const { return vertexReferences; }; const std::vector & getEdgeRefs() const { return edgeReferences; }; const std::vector & getFaceRefs() const { return faceReferences; }; void projectSurfaces(const TopoDS_Shape &face, const TopoDS_Shape &support, const Base::Vector3d &direction, const Base::Vector3d &xaxis, std::vector &result) const; BaseGeom* projectEdge(const TopoDS_Shape &edge, const TopoDS_Shape &support, const Base::Vector3d &direction, const Base::Vector3d &projXAxis) const; Vertex* projectVertex(const TopoDS_Shape &vert, const TopoDS_Shape &support, const Base::Vector3d &direction, const Base::Vector3d &projXAxis) const; void initHLR(const TopoDS_Shape &input, const Base::Vector3d &direction, const Base::Vector3d &xAxis); void extractGeometry(edgeClass category, bool visible); BaseGeom* edgeToBase(TopoDS_Edge edge); void update3DRefs(); protected: void addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass category, bool visible); /// Helper for calcBoundingBox() /*! Note that the name of this function isn't totally accurate due to * TechDraw::Bsplines being composed of BezierSegments. */ Base::BoundBox3d boundingBoxOfBspline(const BSpline *spline) const; /// Helper for calcBoundingBox() /*! * AOE = arc of ellipse. Defaults allow this to be used for regular * ellipses as well as arcs. */ Base::BoundBox3d boundingBoxOfAoe(const Ellipse *aoe, double start = 0, double end = 2 * M_PI, bool cw = false) const; /// Helper for boundingBoxOf(Aoc|Aoe)() /*! * Returns true iff angle theta is in [first, last], where the arc goes * clockwise (cw=true) or counterclockwise (cw=false) from first to last. */ bool isWithinArc(double theta, double first, double last, bool cw) const; // Geometry std::vector edgeGeom; std::vector vertexGeom; std::vector faceGeom; bool findVertex(Base::Vector2D v); // indexes to geometry in Source object std::vector vertexReferences; std::vector edgeReferences; std::vector faceReferences; Handle_HLRBRep_Algo brep_hlr; double Tolerance; double Scale; /// Returns the centroid of shape, as viewed according to direction and xAxis gp_Pnt findCentroid(const TopoDS_Shape &shape, const Base::Vector3d &direction, const Base::Vector3d &xAxis) const; }; } //namespace TechDrawGeometry #endif