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