|
||||
File indexing completed on 2025-01-18 10:04:41
0001 // Copyright (c) 1999-2013 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _PrsDim_LengthDimension_HeaderFile 0015 #define _PrsDim_LengthDimension_HeaderFile 0016 0017 #include <PrsDim_Dimension.hxx> 0018 #include <Geom_Plane.hxx> 0019 #include <gp_Pnt.hxx> 0020 #include <gp_Dir.hxx> 0021 #include <Prs3d_DimensionAspect.hxx> 0022 #include <TopoDS.hxx> 0023 0024 DEFINE_STANDARD_HANDLE (PrsDim_LengthDimension, PrsDim_Dimension) 0025 0026 //! Length dimension. Can be constructed: 0027 //! - Between two generic points. 0028 //! - Between two vertices. 0029 //! - Between two faces. 0030 //! - Between two parallel edges. 0031 //! - Between face and edge. 0032 //! 0033 //! In case of two points (vertices) or one linear edge the user-defined plane 0034 //! that includes this geometry is necessary to be set. 0035 //! 0036 //! In case of face-edge, edge-vertex or face-face lengths the automatic plane 0037 //! computing is allowed. For this plane the third point is found on the 0038 //! edge or on the face. 0039 //! 0040 //! Please note that if the inappropriate geometry is defined 0041 //! or the distance between measured points is less than 0042 //! Precision::Confusion(), the dimension is invalid and its 0043 //! presentation can not be computed. 0044 class PrsDim_LengthDimension : public PrsDim_Dimension 0045 { 0046 DEFINE_STANDARD_RTTIEXT(PrsDim_LengthDimension, PrsDim_Dimension) 0047 public: 0048 0049 //! Construct an empty length dimension. 0050 //! @sa SetMeasuredGeometry(), SetMeasuredShapes() for initialization. 0051 Standard_EXPORT PrsDim_LengthDimension(); 0052 0053 //! Construct length dimension between face and edge. 0054 //! Here dimension can be built without user-defined plane. 0055 //! @param theFace [in] the face (first shape). 0056 //! @param theEdge [in] the edge (second shape). 0057 Standard_EXPORT PrsDim_LengthDimension (const TopoDS_Face& theFace, 0058 const TopoDS_Edge& theEdge); 0059 0060 //! Construct length dimension between two faces. 0061 //! @param theFirstFace [in] the first face (first shape). 0062 //! @param theSecondFace [in] the second face (second shape). 0063 Standard_EXPORT PrsDim_LengthDimension (const TopoDS_Face& theFirstFace, 0064 const TopoDS_Face& theSecondFace); 0065 0066 //! Construct length dimension between two points in 0067 //! the specified plane. 0068 //! @param theFirstPoint [in] the first point. 0069 //! @param theSecondPoint [in] the second point. 0070 //! @param thePlane [in] the plane to orient dimension. 0071 Standard_EXPORT PrsDim_LengthDimension (const gp_Pnt& theFirstPoint, 0072 const gp_Pnt& theSecondPoint, 0073 const gp_Pln& thePlane); 0074 0075 //! Construct length dimension between two arbitrary shapes in 0076 //! the specified plane. 0077 //! @param theFirstShape [in] the first shape. 0078 //! @param theSecondShape [in] the second shape. 0079 //! @param thePlane [in] the plane to orient dimension. 0080 Standard_EXPORT PrsDim_LengthDimension (const TopoDS_Shape& theFirstShape, 0081 const TopoDS_Shape& theSecondShape, 0082 const gp_Pln& thePlane); 0083 0084 //! Construct length dimension of linear edge. 0085 //! @param theEdge [in] the edge to measure. 0086 //! @param thePlane [in] the plane to orient dimension. 0087 Standard_EXPORT PrsDim_LengthDimension (const TopoDS_Edge& theEdge, 0088 const gp_Pln& thePlane); 0089 0090 public: 0091 0092 //! @return first attachment point. 0093 const gp_Pnt& FirstPoint() const { return myFirstPoint; } 0094 0095 //! @return second attachment point. 0096 const gp_Pnt& SecondPoint() const { return mySecondPoint; } 0097 0098 //! @return first attachment shape. 0099 const TopoDS_Shape& FirstShape() const { return myFirstShape; } 0100 0101 //! @return second attachment shape. 0102 const TopoDS_Shape& SecondShape() const { return mySecondShape; } 0103 0104 public: 0105 0106 //! Measure distance between two points. 0107 //! The dimension will become invalid if the new distance between 0108 //! attachment points is less than Precision::Confusion(). 0109 //! @param theFirstPoint [in] the first point. 0110 //! @param theSecondPoint [in] the second point. 0111 //! @param thePlane [in] the user-defined plane 0112 Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint, 0113 const gp_Pnt& theSecondPoint, 0114 const gp_Pln& thePlane); 0115 0116 //! Measure length of edge. 0117 //! The dimension will become invalid if the new length of edge 0118 //! is less than Precision::Confusion(). 0119 //! @param theEdge [in] the edge to measure. 0120 //! @param thePlane [in] the user-defined plane 0121 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theEdge, 0122 const gp_Pln& thePlane); 0123 0124 //! Measure distance between two faces. 0125 //! The dimension will become invalid if the distance can not 0126 //! be measured or it is less than Precision::Confusion(). 0127 //! @param theFirstFace [in] the first face (first shape). 0128 //! @param theSecondFace [in] the second face (second shape). 0129 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace, 0130 const TopoDS_Face& theSecondFace); 0131 0132 //! Measure distance between face and edge. 0133 //! The dimension will become invalid if the distance can not 0134 //! be measured or it is less than Precision::Confusion(). 0135 //! @param theFace [in] the face (first shape). 0136 //! @param theEdge [in] the edge (second shape). 0137 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFace, 0138 const TopoDS_Edge& theEdge); 0139 0140 //! Measure distance between generic pair of shapes (edges, vertices, length), 0141 //! where measuring is applicable. 0142 //! @param theFirstShape [in] the first shape. 0143 //! @param theSecondShape [in] the second shape. 0144 Standard_EXPORT void SetMeasuredShapes (const TopoDS_Shape& theFirstShape, 0145 const TopoDS_Shape& theSecondShape); 0146 0147 //! @return the display units string. 0148 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE; 0149 0150 //! @return the model units string. 0151 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE; 0152 0153 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE; 0154 0155 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE; 0156 0157 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE; 0158 0159 Standard_EXPORT virtual gp_Pnt GetTextPosition() const Standard_OVERRIDE; 0160 0161 //! Set custom direction for dimension. If it is not set, the direction is obtained 0162 //! from the measured geometry (e.g. line between points of dimension) 0163 //! The direction does not change flyout direction of dimension. 0164 //! @param theDirection [in] the dimension direction. 0165 //! @param theUseDirection [in] boolean value if custom direction should be used. 0166 Standard_EXPORT void SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection = Standard_True); 0167 0168 protected: 0169 0170 //! Checks if the plane includes first and second points to build dimension. 0171 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE; 0172 0173 Standard_EXPORT virtual gp_Pln ComputePlane(const gp_Dir& theAttachDir) const; 0174 0175 //! Computes distance between dimension points. If custom direction is defined, the distance 0176 //! is a projection value of the distance between points to this direction 0177 //! @return dimension value 0178 Standard_EXPORT Standard_Real ComputeValue() const Standard_OVERRIDE; 0179 0180 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePresentationManager, 0181 const Handle(Prs3d_Presentation)& thePresentation, 0182 const Standard_Integer theMode = 0) Standard_OVERRIDE; 0183 0184 //! Computes points bounded the flyout line for linear dimension. 0185 //! Direction of flyout line equal to the custom direction of dimension if defined or 0186 //! parallel to the main direction line 0187 //! @param theFirstPoint [in] the first attach point of linear dimension. 0188 //! @param theSecondPoint [in] the second attach point of linear dimension. 0189 //! @param theLineBegPoint [out] the first attach point of linear dimension. 0190 //! @param theLineEndPoint [out] the second attach point of linear dimension. 0191 Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint, 0192 gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint) Standard_OVERRIDE; 0193 0194 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection, 0195 const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE; 0196 0197 protected: 0198 0199 //! Checks that distance between two points is valid. 0200 //! @param theFirstPoint [in] the first point. 0201 //! @param theSecondPoint [in] the second point. 0202 Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint, 0203 const gp_Pnt& theSecondPoint) const; 0204 0205 Standard_EXPORT Standard_Boolean InitTwoEdgesLength (const TopoDS_Edge & theFirstEdge, 0206 const TopoDS_Edge& theSecondEdge, 0207 gp_Dir& theEdgeDir); 0208 0209 //! Auxiliary method for InitTwoShapesPoints() 0210 //! in case of the distance between edge and vertex. 0211 //! Finds the point on the edge that is the closest one to <theVertex>. 0212 //! @param theEdgeDir [out] is the direction on the edge to build automatic plane. 0213 Standard_EXPORT Standard_Boolean InitEdgeVertexLength (const TopoDS_Edge& theEdge, 0214 const TopoDS_Vertex& theVertex, 0215 gp_Dir& theEdgeDir, 0216 Standard_Boolean isInfinite); 0217 0218 //! Auxiliary method for InitTwoShapesPoints() 0219 //! in case of the distance between face and edge. 0220 //! The first attachment point is first parameter point from <theEdge>. 0221 //! Find the second attachment point which belongs to <theFace> 0222 //! Iterate over the edges of the face and find the closest point according 0223 //! to found point on edge. 0224 //! @param theEdgeDir [out] is the direction on the edge to build automatic plane. 0225 Standard_EXPORT Standard_Boolean InitEdgeFaceLength (const TopoDS_Edge& theEdge, 0226 const TopoDS_Face& theFace, 0227 gp_Dir& theEdgeDir); 0228 0229 //! Initialization of two attach points in case of two owner shapes. 0230 Standard_EXPORT Standard_Boolean InitTwoShapesPoints (const TopoDS_Shape& theFirstShape, 0231 const TopoDS_Shape& theSecondShape, 0232 gp_Pln& theComputedPlane, 0233 Standard_Boolean& theIsPlaneComputed); 0234 0235 //! Initialization of two attach points in case of one owner shape. 0236 Standard_EXPORT Standard_Boolean InitOneShapePoints (const TopoDS_Shape& theShape); 0237 0238 protected: 0239 0240 gp_Pnt myFirstPoint; 0241 gp_Pnt mySecondPoint; 0242 TopoDS_Shape myFirstShape; 0243 TopoDS_Shape mySecondShape; 0244 gp_Dir myDirection; 0245 Standard_Boolean myHasCustomDirection; 0246 }; 0247 0248 #endif // _PrsDim_LengthDimension_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |