/usr/include/oce/AIS_AngleDimension.hxx is in liboce-visualization-dev 0.17.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | // Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_AngleDimension_HeaderFile
#define _AIS_AngleDimension_HeaderFile
#include <AIS_Dimension.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Line.hxx>
#include <Geom_Transformation.hxx>
#include <gp.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Projector.hxx>
#include <Prs3d_Presentation.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
//! Angle dimension. Can be constructed:
//! - on two intersected edges.
//! - on three points or vertices.
//! - on conical face.
//! - between two intersected faces.
//!
//! In case of three points or two intersected edges the dimension plane
//! (on which dimension presentation is built) can be computed uniquely
//! as through three defined points can be built only one plane.
//! Therefore, if user-defined plane differs from this one, the dimension can't be built.
//!
//! In cases of two planes automatic plane by default is built on point of the
//! origin of parametric space of the first face (the basis surface) so, that
//! the working plane and two faces intersection forms minimal angle between the faces.
//! User can define the other point which the dimension plane should pass through
//! using the appropriate constructor. This point can lay on the one of the faces or not.
//! Also user can define his own plane but it should pass through the three points
//! computed on the geometry initialization step (when the constructor or SetMeasuredGeometry() method
//! is called).
//!
//! In case of the conical face the center point of the angle is the apex of the conical surface.
//! The attachment points are points of the first and the last parameter of the basis circle of the cone.
//!
class AIS_AngleDimension : public AIS_Dimension
{
public:
//! Constructs minimum angle dimension between two linear edges (where possible).
//! These two edges should be intersected by each other. Otherwise the geometry is not valid.
//! @param theFirstEdge [in] the first edge.
//! @param theSecondEdge [in] the second edge.
Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
const TopoDS_Edge& theSecondEdge);
//! Constructs the angle display object defined by three points.
//! @param theFirstPoint [in] the first point (point on first angle flyout).
//! @param theSecondPoint [in] the center point of angle dimension.
//! @param theThirdPoint [in] the second point (point on second angle flyout).
Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pnt& theThirdPoint);
//! Constructs the angle display object defined by three vertices.
//! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
//! @param theSecondVertex [in] the center vertex of angle dimension.
//! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
Standard_EXPORT AIS_AngleDimension (const TopoDS_Vertex& theFirstVertex,
const TopoDS_Vertex& theSecondVertex,
const TopoDS_Vertex& theThirdVertex);
//! Constructs angle dimension for the cone face.
//! @param theCone [in] the conical face.
Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
//! Constructs angle dimension between two planar faces.
//! @param theFirstFace [in] the first face.
//! @param theSecondFace [in] the second face.
Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace);
//! Constructs angle dimension between two planar faces.
//! @param theFirstFace [in] the first face.
//! @param theSecondFace [in] the second face.
//! @param thePoint [in] the point which the dimension plane should pass through.
//! This point can lay on the one of the faces or not.
Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace,
const gp_Pnt& thePoint);
public:
//! @return first point forming the angle.
const gp_Pnt& FirstPoint() const
{
return myFirstPoint;
}
//! @return second point forming the angle.
const gp_Pnt& SecondPoint() const
{
return mySecondPoint;
}
//! @return center point forming the angle.
const gp_Pnt& CenterPoint() const
{
return myCenterPoint;
}
//! @return first argument shape.
const TopoDS_Shape& FirstShape() const
{
return myFirstShape;
}
//! @return second argument shape.
const TopoDS_Shape& SecondShape() const
{
return mySecondShape;
}
//! @return third argument shape.
const TopoDS_Shape& ThirdShape() const
{
return myThirdShape;
}
public:
//! Measures minimum angle dimension between two linear edges.
//! These two edges should be intersected by each other. Otherwise the geometry is not valid.
//! @param theFirstEdge [in] the first edge.
//! @param theSecondEdge [in] the second edge.
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge,
const TopoDS_Edge& theSecondEdge);
//! Measures angle defined by three points.
//! @param theFirstPoint [in] the first point (point on first angle flyout).
//! @param theSecondPoint [in] the center point of angle dimension.
//! @param theThirdPoint [in] the second point (point on second angle flyout).
Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pnt& theThridPoint);
//! Measures angle defined by three vertices.
//! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
//! @param theSecondVertex [in] the center vertex of angle dimension.
//! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Vertex& theFirstVertex,
const TopoDS_Vertex& theSecondVertex,
const TopoDS_Vertex& theThirdVertex);
//! Measures angle of conical face.
//! @param theCone [in] the shape to measure.
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theCone);
//! Measures angle between two planar faces.
//! @param theFirstFace [in] the first face.
//! @param theSecondFace [in] the second face..
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace);
//! Measures angle between two planar faces.
//! @param theFirstFace [in] the first face.
//! @param theSecondFace [in] the second face.
//! @param thePoint [in] the point which the dimension plane should pass through.
//! This point can lay on the one of the faces or not.
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace,
const gp_Pnt& thePoint);
//! @return the display units string.
Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const;
//! @return the model units string.
Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const;
Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
//! Principle of horizontal text alignment settings:
//! - divide circle into two halves according to attachment points
//! - if aTextPos is between attach points -> Center + positive flyout
//! - if aTextPos is not between attach points but in this half -> Left or Right + positive flyout
//! - if aTextPos is between reflections of attach points -> Center + negative flyout
//! - if aTextPos is not between reflections of attach points -> Left or Right + negative flyout
Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos);
Standard_EXPORT virtual const gp_Pnt GetTextPosition () const;
public:
DEFINE_STANDARD_RTTI (AIS_AngleDimension)
protected:
//! Initialization of fields that is common to all constructors.
Standard_EXPORT void Init();
//! @param theFirstAttach [in] the first attachment point.
//! @param theSecondAttach [in] the second attachment point.
//! @param theCenter [in] the center point (center point of the angle).
//! @return the center of the dimension arc (the main dimension line in case of angle).
Standard_EXPORT gp_Pnt GetCenterOnArc (const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach,
const gp_Pnt& theCenter) const;
//! Draws main dimension line (arc).
//! @param thePresentation [in] the dimension presentation.
//! @param theFirstAttach [in] the first attachment point.
//! @param theSecondAttach [in] the second attachment point.
//! @param theCenter [in] the center point (center point of the angle).
//! @param theRadius [in] the radius of the dimension arc.
//! @param theMode [in] the display mode.
Standard_EXPORT void DrawArc (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach,
const gp_Pnt& theCenter,
const Standard_Real theRadius,
const Standard_Integer theMode);
//! Draws main dimension line (arc) with text.
//! @param thePresentation [in] the dimension presentation.
//! @param theFirstAttach [in] the first attachment point.
//! @param theSecondAttach [in] the second attachment point.
//! @param theCenter [in] the center point (center point of the angle).
//! @param theText [in] the text label string.
//! @param theTextWidth [in] the text label width.
//! @param theMode [in] the display mode.
//! @param theLabelPosition [in] the text label vertical and horizontal positioning option
//! respectively to the main dimension line.
Standard_EXPORT void DrawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach,
const gp_Pnt& theCenter,
const TCollection_ExtendedString& theText,
const Standard_Real theTextWidth,
const Standard_Integer theMode,
const Standard_Integer theLabelPosition);
//! Fits text alignment relatively to the dimension line;
//! it computes the value of label position and arrow orientation
//! according set in the aspect and dimension properties.
//! @param theHorizontalTextPos [in] the horizontal alignment for text position.
//! @param theLabelPosition [out] the label position, contains bits that defines
//! vertical and horizontal alignment. (for internal usage in count text position).
//! @param theIsArrowExternal [out] is the arrows external,
//! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow
//! orientation automatically.
Standard_EXPORT void FitTextAlignment (const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
Standard_Integer& theLabelPosition,
Standard_Boolean& theIsArrowsExternal) const;
//! Adjusts aspect parameters according the text position:
//! extension size, vertical text alignment and flyout.
//! @param theTextPos [in] the user defined 3d point of text position.
//! @param theExtensionSize [out] the adjusted extension size.
//! @param theAlignment [out] the horizontal label alignment.
//! @param theFlyout [out] the adjusted value of flyout.
Standard_EXPORT void AdjustParameters (const gp_Pnt& theTextPos,
Standard_Real& theExtensionSize,
Prs3d_DimensionTextHorizontalPosition& theAlignment,
Standard_Real& theFlyout) const;
protected:
Standard_EXPORT virtual void ComputePlane();
//! Checks if the plane includes three angle points to build dimension.
Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
Standard_EXPORT virtual Standard_Real ComputeValue() const;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(SelectMgr_EntityOwner)& theOwner);
protected:
//! Init angular dimension to measure angle between two linear edges.
//! @return TRUE if the angular dimension can be constructured
//! for the passed edges.
Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane);
//! Init angular dimension to measure angle between two planar faces.
//! there is no user-defined poisitoning. So attach points are set
//! according to faces geometry (in origin of the first face basis surface).
//! @return TRUE if the angular dimension can be constructed
//! for the passed faces.
Standard_EXPORT Standard_Boolean InitTwoFacesAngle();
//! Init angular dimension to measure angle between two planar faces.
//! @param thePointOnFirstFace [in] the point which the dimension plane should pass through.
//! This point can lay on the one of the faces or not.
//! It will be projected on the first face and this point will be set
//! as the first point attach point.
//! It defines some kind of dimension positioning over the faces.
//! @return TRUE if the angular dimension can be constructed
//! for the passed faces.
Standard_EXPORT Standard_Boolean InitTwoFacesAngle (const gp_Pnt thePointOnFirstFace);
//! Init angular dimension to measure cone face.
//! @return TRUE if the angular dimension can be constructed
//! for the passed cone.
Standard_EXPORT Standard_Boolean InitConeAngle();
//! Check that the points forming angle are valid.
//! @return TRUE if the points met the following requirements:
//! The (P1, Center), (P2, Center) can be built.
//! The angle between the vectors > Precision::Angular().
Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
const gp_Pnt& theCenterPoint,
const gp_Pnt& theSecondPoint) const;
private:
gp_Pnt myFirstPoint;
gp_Pnt mySecondPoint;
gp_Pnt myCenterPoint;
TopoDS_Shape myFirstShape;
TopoDS_Shape mySecondShape;
TopoDS_Shape myThirdShape;
};
#endif // _AIS_AngleDimension_HeaderFile
|