|
||||
File indexing completed on 2025-01-18 10:04:40
0001 // Copyright (c) 1995-1999 Matra Datavision 0002 // Copyright (c) 1999-2013 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_AngleDimension_HeaderFile 0016 #define _PrsDim_AngleDimension_HeaderFile 0017 0018 #include <PrsDim_Dimension.hxx> 0019 #include <PrsDim_TypeOfAngle.hxx> 0020 #include <PrsDim_TypeOfAngleArrowVisibility.hxx> 0021 0022 #include <Geom_Plane.hxx> 0023 #include <Geom_Line.hxx> 0024 #include <gp_Dir.hxx> 0025 #include <gp_Pnt.hxx> 0026 #include <Prs3d_DimensionAspect.hxx> 0027 #include <Prs3d_Presentation.hxx> 0028 #include <Standard.hxx> 0029 #include <Standard_Macro.hxx> 0030 #include <Standard_Type.hxx> 0031 #include <TopoDS.hxx> 0032 #include <TopoDS_Edge.hxx> 0033 #include <TopoDS_Face.hxx> 0034 #include <TopoDS_Vertex.hxx> 0035 0036 DEFINE_STANDARD_HANDLE(PrsDim_AngleDimension, PrsDim_Dimension) 0037 0038 //! Angle dimension. Can be constructed: 0039 //! - on two intersected edges. 0040 //! - on three points or vertices. 0041 //! - on conical face. 0042 //! - between two intersected faces. 0043 //! 0044 //! In case of three points or two intersected edges the dimension plane 0045 //! (on which dimension presentation is built) can be computed uniquely 0046 //! as through three defined points can be built only one plane. 0047 //! Therefore, if user-defined plane differs from this one, the dimension can't be built. 0048 //! 0049 //! In cases of two planes automatic plane by default is built on point of the 0050 //! origin of parametric space of the first face (the basis surface) so, that 0051 //! the working plane and two faces intersection forms minimal angle between the faces. 0052 //! User can define the other point which the dimension plane should pass through 0053 //! using the appropriate constructor. This point can lay on the one of the faces or not. 0054 //! Also user can define his own plane but it should pass through the three points 0055 //! computed on the geometry initialization step (when the constructor or SetMeasuredGeometry() method 0056 //! is called). 0057 //! 0058 //! In case of the conical face the center point of the angle is the apex of the conical surface. 0059 //! The attachment points are points of the first and the last parameter of the basis circle of the cone. 0060 class PrsDim_AngleDimension : public PrsDim_Dimension 0061 { 0062 DEFINE_STANDARD_RTTIEXT(PrsDim_AngleDimension, PrsDim_Dimension) 0063 public: 0064 0065 //! Constructs minimum angle dimension between two linear edges (where possible). 0066 //! These two edges should be intersected by each other. Otherwise the geometry is not valid. 0067 //! @param theFirstEdge [in] the first edge. 0068 //! @param theSecondEdge [in] the second edge. 0069 Standard_EXPORT PrsDim_AngleDimension (const TopoDS_Edge& theFirstEdge, 0070 const TopoDS_Edge& theSecondEdge); 0071 0072 //! Constructs the angle display object defined by three points. 0073 //! @param theFirstPoint [in] the first point (point on first angle flyout). 0074 //! @param theSecondPoint [in] the center point of angle dimension. 0075 //! @param theThirdPoint [in] the second point (point on second angle flyout). 0076 Standard_EXPORT PrsDim_AngleDimension (const gp_Pnt& theFirstPoint, 0077 const gp_Pnt& theSecondPoint, 0078 const gp_Pnt& theThirdPoint); 0079 0080 //! Constructs the angle display object defined by three vertices. 0081 //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout). 0082 //! @param theSecondVertex [in] the center vertex of angle dimension. 0083 //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout). 0084 Standard_EXPORT PrsDim_AngleDimension (const TopoDS_Vertex& theFirstVertex, 0085 const TopoDS_Vertex& theSecondVertex, 0086 const TopoDS_Vertex& theThirdVertex); 0087 0088 //! Constructs angle dimension for the cone face. 0089 //! @param theCone [in] the conical face. 0090 Standard_EXPORT PrsDim_AngleDimension (const TopoDS_Face& theCone); 0091 0092 //! Constructs angle dimension between two planar faces. 0093 //! @param theFirstFace [in] the first face. 0094 //! @param theSecondFace [in] the second face. 0095 Standard_EXPORT PrsDim_AngleDimension (const TopoDS_Face& theFirstFace, 0096 const TopoDS_Face& theSecondFace); 0097 0098 //! Constructs angle dimension between two planar faces. 0099 //! @param theFirstFace [in] the first face. 0100 //! @param theSecondFace [in] the second face. 0101 //! @param thePoint [in] the point which the dimension plane should pass through. 0102 //! This point can lay on the one of the faces or not. 0103 Standard_EXPORT PrsDim_AngleDimension (const TopoDS_Face& theFirstFace, 0104 const TopoDS_Face& theSecondFace, 0105 const gp_Pnt& thePoint); 0106 0107 public: 0108 0109 //! @return first point forming the angle. 0110 const gp_Pnt& FirstPoint() const { return myFirstPoint; } 0111 0112 //! @return second point forming the angle. 0113 const gp_Pnt& SecondPoint() const { return mySecondPoint; } 0114 0115 //! @return center point forming the angle. 0116 const gp_Pnt& CenterPoint() const { return myCenterPoint; } 0117 0118 //! @return first argument shape. 0119 const TopoDS_Shape& FirstShape() const { return myFirstShape; } 0120 0121 //! @return second argument shape. 0122 const TopoDS_Shape& SecondShape() const { return mySecondShape; } 0123 0124 //! @return third argument shape. 0125 const TopoDS_Shape& ThirdShape() const { return myThirdShape; } 0126 0127 public: 0128 0129 //! Measures minimum angle dimension between two linear edges. 0130 //! These two edges should be intersected by each other. Otherwise the geometry is not valid. 0131 //! @param theFirstEdge [in] the first edge. 0132 //! @param theSecondEdge [in] the second edge. 0133 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge, 0134 const TopoDS_Edge& theSecondEdge); 0135 0136 //! Measures angle defined by three points. 0137 //! @param theFirstPoint [in] the first point (point on first angle flyout). 0138 //! @param theSecondPoint [in] the center point of angle dimension. 0139 //! @param theThirdPoint [in] the second point (point on second angle flyout). 0140 Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint, 0141 const gp_Pnt& theSecondPoint, 0142 const gp_Pnt& theThridPoint); 0143 0144 //! Measures angle defined by three vertices. 0145 //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout). 0146 //! @param theSecondVertex [in] the center vertex of angle dimension. 0147 //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout). 0148 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Vertex& theFirstVertex, 0149 const TopoDS_Vertex& theSecondVertex, 0150 const TopoDS_Vertex& theThirdVertex); 0151 0152 //! Measures angle of conical face. 0153 //! @param theCone [in] the shape to measure. 0154 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theCone); 0155 0156 //! Measures angle between two planar faces. 0157 //! @param theFirstFace [in] the first face. 0158 //! @param theSecondFace [in] the second face.. 0159 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace, 0160 const TopoDS_Face& theSecondFace); 0161 0162 //! Measures angle between two planar faces. 0163 //! @param theFirstFace [in] the first face. 0164 //! @param theSecondFace [in] the second face. 0165 //! @param thePoint [in] the point which the dimension plane should pass through. 0166 //! This point can lay on the one of the faces or not. 0167 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace, 0168 const TopoDS_Face& theSecondFace, 0169 const gp_Pnt& thePoint); 0170 0171 //! @return the display units string. 0172 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE; 0173 0174 //! @return the model units string. 0175 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE; 0176 0177 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE; 0178 0179 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE; 0180 0181 //! Principle of horizontal text alignment settings: 0182 //! - divide circle into two halves according to attachment points 0183 //! - if aTextPos is between attach points -> Center + positive flyout 0184 //! - if aTextPos is not between attach points but in this half -> Left or Right + positive flyout 0185 //! - if aTextPos is between reflections of attach points -> Center + negative flyout 0186 //! - if aTextPos is not between reflections of attach points -> Left or Right + negative flyout 0187 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE; 0188 0189 Standard_EXPORT virtual gp_Pnt GetTextPosition () const Standard_OVERRIDE; 0190 0191 //! Sets angle type. 0192 //! @param theType [in] the type value. 0193 void SetType (const PrsDim_TypeOfAngle theType) { myType = theType; } 0194 0195 //! @return the current angle type. 0196 PrsDim_TypeOfAngle GetType() const { return myType; } 0197 0198 //! Sets visible arrows type 0199 //! @param theType [in] the type of visibility of arrows. 0200 void SetArrowsVisibility (const PrsDim_TypeOfAngleArrowVisibility& theType) { myArrowsVisibility = theType; } 0201 0202 //! @return the type of visibility of arrows. 0203 PrsDim_TypeOfAngleArrowVisibility GetArrowsVisibility() const { return myArrowsVisibility; } 0204 0205 protected: 0206 0207 //! Initialization of fields that is common to all constructors. 0208 Standard_EXPORT void Init(); 0209 0210 //! Gets plane normal for minimal angle. 0211 //! Dimension computation is based on three attach points and plane normal. 0212 //! Based on this normal angle arc, arrows and extensions are constructed. 0213 gp_Dir GetNormalForMinAngle() const; 0214 0215 //! @param theFirstAttach [in] the first attachment point. 0216 //! @param theSecondAttach [in] the second attachment point. 0217 //! @param theCenter [in] the center point (center point of the angle). 0218 //! @return the center of the dimension arc (the main dimension line in case of angle). 0219 Standard_EXPORT gp_Pnt GetCenterOnArc (const gp_Pnt& theFirstAttach, 0220 const gp_Pnt& theSecondAttach, 0221 const gp_Pnt& theCenter) const; 0222 0223 //! Draws main dimension line (arc). 0224 //! @param thePresentation [in] the dimension presentation. 0225 //! @param theFirstAttach [in] the first attachment point. 0226 //! @param theSecondAttach [in] the second attachment point. 0227 //! @param theCenter [in] the center point (center point of the angle). 0228 //! @param theRadius [in] the radius of the dimension arc. 0229 //! @param theMode [in] the display mode. 0230 Standard_EXPORT void DrawArc (const Handle(Prs3d_Presentation)& thePresentation, 0231 const gp_Pnt& theFirstAttach, 0232 const gp_Pnt& theSecondAttach, 0233 const gp_Pnt& theCenter, 0234 const Standard_Real theRadius, 0235 const Standard_Integer theMode); 0236 0237 //! Draws main dimension line (arc) with text. 0238 //! @param thePresentation [in] the dimension presentation. 0239 //! @param theFirstAttach [in] the first attachment point. 0240 //! @param theSecondAttach [in] the second attachment point. 0241 //! @param theCenter [in] the center point (center point of the angle). 0242 //! @param theText [in] the text label string. 0243 //! @param theTextWidth [in] the text label width. 0244 //! @param theMode [in] the display mode. 0245 //! @param theLabelPosition [in] the text label vertical and horizontal positioning option 0246 //! respectively to the main dimension line. 0247 Standard_EXPORT void DrawArcWithText (const Handle(Prs3d_Presentation)& thePresentation, 0248 const gp_Pnt& theFirstAttach, 0249 const gp_Pnt& theSecondAttach, 0250 const gp_Pnt& theCenter, 0251 const TCollection_ExtendedString& theText, 0252 const Standard_Real theTextWidth, 0253 const Standard_Integer theMode, 0254 const Standard_Integer theLabelPosition); 0255 0256 //! Fits text alignment relatively to the dimension line; 0257 //! it computes the value of label position and arrow orientation 0258 //! according set in the aspect and dimension properties. 0259 //! @param theHorizontalTextPos [in] the horizontal alignment for text position. 0260 //! @param theLabelPosition [out] the label position, contains bits that defines 0261 //! vertical and horizontal alignment. (for internal usage in count text position). 0262 //! @param theIsArrowExternal [out] is the arrows external, 0263 //! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow 0264 //! orientation automatically. 0265 Standard_EXPORT void FitTextAlignment (const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos, 0266 Standard_Integer& theLabelPosition, 0267 Standard_Boolean& theIsArrowsExternal) const; 0268 0269 //! Adjusts aspect parameters according the text position: 0270 //! extension size, vertical text alignment and flyout. 0271 //! @param theTextPos [in] the user defined 3d point of text position. 0272 //! @param theExtensionSize [out] the adjusted extension size. 0273 //! @param theAlignment [out] the horizontal label alignment. 0274 //! @param theFlyout [out] the adjusted value of flyout. 0275 Standard_EXPORT void AdjustParameters (const gp_Pnt& theTextPos, 0276 Standard_Real& theExtensionSize, 0277 Prs3d_DimensionTextHorizontalPosition& theAlignment, 0278 Standard_Real& theFlyout) const; 0279 0280 protected: 0281 0282 Standard_EXPORT virtual void ComputePlane(); 0283 0284 //! Checks if the plane includes three angle points to build dimension. 0285 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE; 0286 0287 Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE; 0288 0289 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePM, 0290 const Handle(Prs3d_Presentation)& thePresentation, 0291 const Standard_Integer theMode = 0) Standard_OVERRIDE; 0292 0293 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection, 0294 const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; 0295 0296 protected: 0297 0298 //! Init angular dimension to measure angle between two linear edges. 0299 //! @return TRUE if the angular dimension can be constructured 0300 //! for the passed edges. 0301 Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane); 0302 0303 //! Init angular dimension to measure angle between two planar faces. 0304 //! there is no user-defined poisitoning. So attach points are set 0305 //! according to faces geometry (in origin of the first face basis surface). 0306 //! @return TRUE if the angular dimension can be constructed 0307 //! for the passed faces. 0308 Standard_EXPORT Standard_Boolean InitTwoFacesAngle(); 0309 0310 //! Init angular dimension to measure angle between two planar faces. 0311 //! @param thePointOnFirstFace [in] the point which the dimension plane should pass through. 0312 //! This point can lay on the one of the faces or not. 0313 //! It will be projected on the first face and this point will be set 0314 //! as the first point attach point. 0315 //! It defines some kind of dimension positioning over the faces. 0316 //! @return TRUE if the angular dimension can be constructed 0317 //! for the passed faces. 0318 Standard_EXPORT Standard_Boolean InitTwoFacesAngle (const gp_Pnt& thePointOnFirstFace); 0319 0320 //! Init angular dimension to measure cone face. 0321 //! @return TRUE if the angular dimension can be constructed 0322 //! for the passed cone. 0323 Standard_EXPORT Standard_Boolean InitConeAngle(); 0324 0325 //! Check that the points forming angle are valid. 0326 //! @return TRUE if the points met the following requirements: 0327 //! The (P1, Center), (P2, Center) can be built. 0328 //! The angle between the vectors > Precision::Angular(). 0329 Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint, 0330 const gp_Pnt& theCenterPoint, 0331 const gp_Pnt& theSecondPoint) const; 0332 0333 0334 //! Returns true if the arrow should be visible 0335 //! @param theArrowType an arrow type 0336 //! @return TRUE if the arrow should be visible 0337 Standard_EXPORT Standard_Boolean isArrowVisible (const PrsDim_TypeOfAngleArrowVisibility theArrowType) const; 0338 0339 private: 0340 PrsDim_TypeOfAngle myType; //!< type of angle 0341 PrsDim_TypeOfAngleArrowVisibility myArrowsVisibility; //!< type of arrows visibility 0342 0343 gp_Pnt myFirstPoint; 0344 gp_Pnt mySecondPoint; 0345 gp_Pnt myCenterPoint; 0346 TopoDS_Shape myFirstShape; 0347 TopoDS_Shape mySecondShape; 0348 TopoDS_Shape myThirdShape; 0349 }; 0350 0351 #endif // _PrsDim_AngleDimension_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |