Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/PrsDim_RadiusDimension.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (c) 1995-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _PrsDim_RadiusDimension_HeaderFile
0016 #define _PrsDim_RadiusDimension_HeaderFile
0017 
0018 #include <PrsDim_Dimension.hxx>
0019 #include <gp_Pnt.hxx>
0020 #include <gp_Circ.hxx>
0021 #include <Standard.hxx>
0022 #include <Standard_Macro.hxx>
0023 
0024 //! Radius dimension. Can be constructed:
0025 //! - On generic circle.
0026 //! - On generic circle with user-defined anchor point on that circle.
0027 //! - On generic shape containing geometry that can be measured
0028 //!   by diameter dimension: circle wire, arc, circular face, etc.
0029 //! The anchor point is the location of left attachment point of
0030 //! dimension on the circle. It can be user-specified, or computed as
0031 //! middle point on the arc. The radius dimension always lies in the
0032 //! plane of the measured circle. The dimension is considered as
0033 //! invalid if the user-specified anchor point is not lying on the circle,
0034 //! if the radius of the circle is less than Precision::Confusion().
0035 //! In case if the dimension is built on the arbitrary shape,
0036 //! it can be considered as invalid if the shape does not contain
0037 //! circle geometry.
0038 class PrsDim_RadiusDimension : public PrsDim_Dimension
0039 {
0040   DEFINE_STANDARD_RTTIEXT(PrsDim_RadiusDimension, PrsDim_Dimension)
0041 public:
0042   //! Create radius dimension for the circle geometry.
0043   //! @param[in] theCircle  the circle to measure.
0044   Standard_EXPORT PrsDim_RadiusDimension(const gp_Circ& theCircle);
0045 
0046   //! Create radius dimension for the circle geometry and define its
0047   //! orientation by location of the first point on that circle.
0048   //! @param[in] theCircle  the circle to measure.
0049   //! @param[in] theAnchorPoint  the point to define the position
0050   //!        of the dimension attachment on the circle.
0051   Standard_EXPORT PrsDim_RadiusDimension(const gp_Circ& theCircle, const gp_Pnt& theAnchorPoint);
0052 
0053   //! Create radius dimension for the arbitrary shape (if possible).
0054   //! @param[in] theShape  the shape to measure.
0055   Standard_EXPORT PrsDim_RadiusDimension(const TopoDS_Shape& theShape);
0056 
0057 public:
0058   //! @return measured geometry circle.
0059   const gp_Circ& Circle() const { return myCircle; }
0060 
0061   //! @return anchor point on circle for radius dimension.
0062   const gp_Pnt& AnchorPoint() const { return myAnchorPoint; }
0063 
0064   //! @return the measured shape.
0065   const TopoDS_Shape& Shape() const { return myShape; }
0066 
0067 public:
0068   //! Measure radius of the circle.
0069   //! The dimension will become invalid if the radius of the circle
0070   //! is less than Precision::Confusion().
0071   //! @param[in] theCircle  the circle to measure.
0072   void SetMeasuredGeometry(const gp_Circ& theCircle)
0073   {
0074     SetMeasuredGeometry(theCircle, gp_Pnt(), false);
0075   }
0076 
0077   //! Measure radius of the circle and orient the dimension so
0078   //! the dimension lines attaches to anchor point on the circle.
0079   //! The dimension will become invalid if the radius of the circle
0080   //! is less than Precision::Confusion().
0081   //! @param[in] theCircle  the circle to measure.
0082   //! @param[in] theAnchorPoint  the point to attach the dimension lines, should be on the circle
0083   //! @param[in] theHasAnchor    should be set TRUE if theAnchorPoint should be used
0084   Standard_EXPORT void SetMeasuredGeometry(const gp_Circ& theCircle,
0085                                            const gp_Pnt&  theAnchorPoint,
0086                                            const bool     theHasAnchor = true);
0087 
0088   //! Measure radius on the passed shape, if applicable.
0089   //! The dimension will become invalid if the passed shape is not
0090   //! measurable or if measured diameter value is less than Precision::Confusion().
0091   //! @param[in] theShape  the shape to measure.
0092   void SetMeasuredGeometry(const TopoDS_Shape& theShape)
0093   {
0094     SetMeasuredGeometry(theShape, gp_Pnt(), false);
0095   }
0096 
0097   //! Measure radius on the passed shape, if applicable.
0098   //! The dimension will become invalid if the passed shape is not
0099   //! measurable or if measured diameter value is less than Precision::Confusion().
0100   //! @param[in] theShape  the shape to measure.
0101   //! @param[in] theAnchorPoint  the point to attach the dimension lines, should be on the circle
0102   //! @param[in] theHasAnchor    should be set TRUE if theAnchorPoint should be used
0103   Standard_EXPORT void SetMeasuredGeometry(const TopoDS_Shape& theShape,
0104                                            const gp_Pnt&       theAnchorPoint,
0105                                            const bool          theHasAnchor = true);
0106 
0107   //! @return the display units string.
0108   Standard_EXPORT const TCollection_AsciiString& GetDisplayUnits() const override;
0109 
0110   //! @return the model units string.
0111   Standard_EXPORT const TCollection_AsciiString& GetModelUnits() const override;
0112 
0113   Standard_EXPORT void SetDisplayUnits(const TCollection_AsciiString& theUnits) override;
0114 
0115   Standard_EXPORT void SetModelUnits(const TCollection_AsciiString& theUnits) override;
0116 
0117   Standard_EXPORT void SetTextPosition(const gp_Pnt& theTextPos) override;
0118 
0119   Standard_EXPORT gp_Pnt GetTextPosition() const override;
0120 
0121 protected:
0122   Standard_EXPORT virtual void ComputePlane();
0123 
0124   //! Checks if anchor point and the center of the circle are on the plane.
0125   Standard_EXPORT bool CheckPlane(const gp_Pln& thePlane) const override;
0126 
0127   Standard_EXPORT double ComputeValue() const override;
0128 
0129   Standard_EXPORT void Compute(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0130                                const occ::handle<Prs3d_Presentation>&         thePrs,
0131                                const int                                      theMode) override;
0132 
0133 protected:
0134   Standard_EXPORT bool IsValidCircle(const gp_Circ& theCircle) const;
0135 
0136   Standard_EXPORT bool IsValidAnchor(const gp_Circ& theCircle, const gp_Pnt& thePnt) const;
0137 
0138 private:
0139   gp_Circ      myCircle;
0140   gp_Pnt       myAnchorPoint;
0141   TopoDS_Shape myShape;
0142 };
0143 
0144 #endif // _PrsDim_RadiusDimension_HeaderFile