1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0024425: Improve usage ergonomics of new dimension presentations

- Added format for value string.
- Construction and validness.
- Revise modification of properties and update of presentations.
- Units moved to Drawer; code revisions.
- Length and angle initialization was changed. Type of geometry filed was added to AIS_Dimension.
- Method for test case bugs/vis/buc60915 was corrected. Description of the dimension classes was corrected.
- Fixed initialization of angle and length.
This commit is contained in:
aba
2013-12-11 19:16:07 +04:00
committed by abv
parent e04db19958
commit 60bf98ae02
44 changed files with 5023 additions and 3212 deletions

View File

@@ -464,29 +464,56 @@ is
---Purpose:
-- Returns the nearest point in a shape. This is used by
-- several classes in calculation of dimensions.
Nearest (theLine : Lin from gp;
thePoint : Pnt from gp)
returns Pnt from gp;
---Purpose:
-- @return the nearest point on the line.
Nearest (theCurve : Curve from Geom;
thePoint : Pnt from gp;
theFirstPoint : Pnt from gp;
theLastPoint : Pnt from gp;
theNearestPoint : out Pnt from gp)
returns Boolean from Standard;
---Purpose:
-- For the given point finds nearest point on the curve,
-- @return TRUE if found point is belongs to the curve
-- and FALSE otherwise.
Farest( aShape : Shape from TopoDS;
aPoint : Pnt from gp )
returns Pnt from gp;
ComputeGeometry(anEdge : Edge from TopoDS;
aCurve : out Curve from Geom;
FirstPnt : out Pnt from gp;
LastPnt : out Pnt from gp)
ComputeGeometry (theEdge : Edge from TopoDS;
theCurve : out Curve from Geom;
theFirstPnt : out Pnt from gp;
theLastPnt : out Pnt from gp)
---Purpose: Used by 2d Relation only
-- Computes the 3d geometry of <anEdge> in the current WorkingPlane
-- and the extremities if any
-- Return TRUE if ok
-- Return TRUE if ok.
returns Boolean from Standard;
ComputeGeometry(anEdge : Edge from TopoDS;
aCurve : out Curve from Geom;
FirstPnt : out Pnt from gp;
LastPnt : out Pnt from gp;
extCurve : out Curve from Geom;
isinfinite: out Boolean from Standard;
isOnPlane : out Boolean from Standard;
aPlane : Plane from Geom)
ComputeGeometry (theEdge : Edge from TopoDS;
theCurve : out Curve from Geom;
theFirstPnt : out Pnt from gp;
theLastPnt : out Pnt from gp;
theIsInfinite : out Boolean from Standard)
---Purpose: Used by dimensions only.
-- Computes the 3d geometry of <anEdge>.
-- Return TRUE if ok.
returns Boolean from Standard;
ComputeGeometry (theEdge : Edge from TopoDS;
theCurve : out Curve from Geom;
theFirstPnt : out Pnt from gp;
theLastPnt : out Pnt from gp;
theExtCurve : out Curve from Geom;
theIsInfinite : out Boolean from Standard;
theIsOnPlane : out Boolean from Standard;
thePlane : Plane from Geom)
---Purpose: Used by 2d Relation only
-- Computes the 3d geometry of <anEdge> in the current WorkingPlane
-- and the extremities if any.
@@ -494,39 +521,51 @@ is
-- the not projected curve associated to <anEdge>.
-- If <anEdge> is infinite, <isinfinite> = true and the 2
-- parameters <FirstPnt> and <LastPnt> have no signification.
-- Return TRUE if ok
-- Return TRUE if ok.
returns Boolean from Standard;
ComputeGeometry (anEdge1 : Edge from TopoDS;
anEdge2 : Edge from TopoDS;
aCurve1 : out Curve from Geom;
aCurve2 : out Curve from Geom;
FirstPnt1 : out Pnt from gp;
LastPnt1 : out Pnt from gp;
FirstPnt2 : out Pnt from gp;
LastPnt2 : out Pnt from gp;
aPlane : Plane from Geom)
ComputeGeometry (theFirstEdge : Edge from TopoDS;
theSecondEdge : Edge from TopoDS;
theFirstCurve : out Curve from Geom;
theSecondCurve : out Curve from Geom;
theFirstPnt1 : out Pnt from gp;
theLastPnt1 : out Pnt from gp;
theFirstPnt2 : out Pnt from gp;
theLastPnt2 : out Pnt from gp;
thePlane : Plane from Geom)
---Purpose: Used by 2d Relation only
-- Computes the 3d geometry of <anEdge> in the current WorkingPlane
-- and the extremities if any
-- Return TRUE if ok
-- Return TRUE if ok.
returns Boolean from Standard;
ComputeGeometry (theFirstEdge : Edge from TopoDS;
theSecondEdge : Edge from TopoDS;
theFirstCurve : out Curve from Geom;
theSecondCurve : out Curve from Geom;
theFirstPnt1 : out Pnt from gp;
theLastPnt1 : out Pnt from gp;
theFirstPnt2 : out Pnt from gp;
theLastPnt2 : out Pnt from gp;
theIsinfinite1 : out Boolean from Standard;
theIsinfinite2 : out Boolean from Standard)
---Purpose: Used by dimensions only.Computes the 3d geometry
-- of<anEdge1> and <anEdge2> and checks if they are infinite.
returns Boolean from Standard;
ComputeGeometry (anEdge1 : Edge from TopoDS;
anEdge2 : Edge from TopoDS;
indexExt : out Integer from Standard;
aCurve1 : out Curve from Geom;
aCurve2 : out Curve from Geom;
FirstPnt1 : out Pnt from gp;
LastPnt1 : out Pnt from gp;
FirstPnt2 : out Pnt from gp;
LastPnt2 : out Pnt from gp;
ExtCurve : out Curve from Geom;
isinfinite1 : out Boolean from Standard;
isinfinite2 : out Boolean from Standard;
aPlane : Plane from Geom)
ComputeGeometry (theFirstEdge : Edge from TopoDS;
theSecondEdge : Edge from TopoDS;
theExtIndex : out Integer from Standard;
theFirstCurve : out Curve from Geom;
theSecondCurve : out Curve from Geom;
theFirstPnt1 : out Pnt from gp;
theLastPnt1 : out Pnt from gp;
theFirstPnt2 : out Pnt from gp;
theLastPnt2 : out Pnt from gp;
theExtCurve : out Curve from Geom;
theIsinfinite1 : out Boolean from Standard;
theIsinfinite2 : out Boolean from Standard;
thePlane : Plane from Geom)
---Purpose: Used by 2d Relation only Computes the 3d geometry
-- of<anEdge1> and <anEdge2> in the current Plane and the
-- extremities if any. Return in ExtCurve the 3d curve
@@ -538,102 +577,78 @@ is
-- significant. Return TRUE if ok
returns Boolean from Standard;
ComputeGeomCurve (aCurve : in out Curve from Geom;
first1 : Real from Standard;
last1 : Real from Standard;
FirstPnt1 : out Pnt from gp;
LastPnt1 : out Pnt from gp;
aPlane : Plane from Geom;
isOnPlane: out Boolean from Standard)
ComputeGeomCurve (aCurve : in out Curve from Geom;
first1 : Real from Standard;
last1 : Real from Standard;
FirstPnt1 : out Pnt from gp;
LastPnt1 : out Pnt from gp;
aPlane : Plane from Geom;
isOnPlane: out Boolean from Standard)
---Purpose: Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
-- and returns aCurve;
-- Return TRUE if ok
returns Boolean from Standard;
ComputeGeometry(aVertex : Vertex from TopoDS;
point : out Pnt from gp;
aPlane : Plane from Geom;
isOnPlane: out Boolean from Standard)
ComputeGeometry (aVertex : Vertex from TopoDS;
point : out Pnt from gp;
aPlane : Plane from Geom;
isOnPlane: out Boolean from Standard)
returns Boolean from Standard;
GetPlaneFromFace( aFace : Face from TopoDS;
aPlane : out Pln from gp;
aSurf : out Surface from Geom;
aSurfType : out KindOfSurface from AIS;
Offset : out Real from Standard )
GetPlaneFromFace (aFace : Face from TopoDS;
aPlane : out Pln from gp;
aSurf : out Surface from Geom;
aSurfType : out KindOfSurface from AIS;
Offset : out Real from Standard)
returns Boolean from Standard;
---Purpose: Tryes to get Plane from Face. Returns Surface of Face
-- in aSurf. Returns Standard_True and Plane of Face in
-- aPlane in following cases:
-- Face is Plane, Offset of Plane,
-- Extrusion of Line and Offset of Extrusion of Line
-- Returns pure type of Surface which can be:
-- Plane, Cylinder, Cone, Sphere, Torus,
-- SurfaceOfRevolution, SurfaceOfExtrusion
-- Returns pure type of Surface which can be:
-- Plane, Cylinder, Cone, Sphere, Torus,
-- SurfaceOfRevolution, SurfaceOfExtrusion
InitFaceLength( aFace : Face from TopoDS;
aPlane : out Pln from gp;
aSurface : out Surface from Geom;
aSurfaceType : out KindOfSurface from AIS;
anOffset : out Real from Standard );
ComputeLengthBetweenPlanarFaces( FirstFace : Face from TopoDS;
SecondFace : Face from TopoDS;
Plane1 : Pln from gp;
Plane2 : Pln from gp;
Value : out Real from Standard;
FirstAttach : out Pnt from gp ;
SecondAttach : out Pnt from gp ;
DirAttach : out Dir from gp ;
AutomaticPos : Boolean from Standard;
Position : in out Pnt from gp);
ComputeLengthBetweenCurvilinearFaces( FirstFace : Face from TopoDS;
SecondFace : Face from TopoDS;
FirstSurf : in out Surface from Geom;
SecondSurf : in out Surface from Geom;
AutomaticPos : Boolean from Standard;
Value : out Real from Standard;
Position : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
DirAttach : out Dir from gp );
ComputeAngleBetweenPlanarFaces( FirstFace : Face from TopoDS;
SecondFace : Face from TopoDS;
Surf2 : Surface from Geom;
Axis : Ax1 from gp;
Value : Real from Standard;
AutomaticPos : Boolean from Standard;
Position : out Pnt from gp;
Center : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
FirstDir : out Dir from gp;
SecondDir : out Dir from gp);
---Purpose: Computes geometric parameters for planar faces for
-- Angular dimensions
ComputeAngleBetweenCurvilinearFaces( FirstFace : Face from TopoDS;
SecondFace : Face from TopoDS;
FirstSurf : Surface from Geom;
SecondSurf : Surface from Geom;
FirstSurfType : KindOfSurface from AIS;
SecondSurfType : KindOfSurface from AIS;
Axis : Ax1 from gp;
Value : Real from Standard;
AutomaticPos : Boolean from Standard;
Position : out Pnt from gp;
Center : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
FirstDir : out Dir from gp;
SecondDir : out Dir from gp;
Plane : out Plane from Geom );
---Purpose: Computes geometric parameters for curvilinear faces for
-- Angular dimensions
InitFaceLength (aFace : Face from TopoDS;
aPlane : out Pln from gp;
aSurface : out Surface from Geom;
aSurfaceType : out KindOfSurface from AIS;
anOffset : out Real from Standard );
InitLengthBetweenCurvilinearFaces (theFirstFace : Face from TopoDS;
theSecondFace : Face from TopoDS;
theFirstSurf : in out Surface from Geom;
theSecondSurf : in out Surface from Geom;
theFirstAttach : out Pnt from gp;
theSecondAttach : out Pnt from gp;
theDirOnPlane : out Dir from gp);
---Purpose: Finds attachment points on two curvilinear faces for length dimension.
-- @param thePlaneDir [in] the direction on the dimension plane to
-- compute the plane automatically. It will not be taken into account if
-- plane is defined by user.
InitAngleBetweenPlanarFaces (theFirstFace : Face from TopoDS;
theSecondFace : Face from TopoDS;
theCenter : out Pnt from gp;
theFirstAttach : out Pnt from gp;
theSecondAttach : out Pnt from gp;
theIsFirstPointSet : Boolean from Standard = Standard_False)
returns Boolean from Standard;
---Purpose: Finds three points for the angle dimension between
-- two planes.
InitAngleBetweenCurvilinearFaces (theFirstFace : Face from TopoDS;
theSecondFace : Face from TopoDS;
theFirstSurfType : KindOfSurface from AIS;
theSecondSurfType : KindOfSurface from AIS;
theCenter : out Pnt from gp;
theFirstAttach : out Pnt from gp;
theSecondAttach : out Pnt from gp;
theIsFirstPointSet : Boolean from Standard = Standard_False)
returns Boolean from Standard;
---Purpose: Finds three points for the angle dimension between
-- two curvilinear surfaces.
ProjectPointOnPlane( aPoint : Pnt from gp; aPlane : Pln from gp )
returns Pnt from gp;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -16,12 +16,6 @@
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//! A framework to define display of angles. <br>
//! These displays are particularly useful in viewing draft prisms. <br>
//! The angle displayed may define an intersection <br>
//! can be between two edges or two faces of a shape <br>
//! or a plane. The display consists of arrows and text. <br>
#ifndef _AIS_AngleDimension_HeaderFile
#define _AIS_AngleDimension_HeaderFile
@@ -42,45 +36,170 @@
#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 automatical plane by default is built on point of the
//! origin of parametrical 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 angle dimension between two edges
//! with automatic working plane computing
//! if it is possible. In case of PI angle please
//! set custom working plane or use constructor with 3 parameters.
Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
const TopoDS_Edge& theSecondEdge);
//! Constructs the angle display object defined by the <br>
//! two edges and custom working plane.
//! ATTENTION :In case if the working plane is custom and one edge is out of the
//! working plane it tries to project this edge line on the plane.
//! To avoid this case you can reset the working plane
//! using <ResetWorkingPlane ()> method.
Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
const TopoDS_Edge& theSecondEdge,
const gp_Pln& thePlane);
//! 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.
Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pnt& theThirdPoint);
//! @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);
//! Angle of cone
Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
//! 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);
//! TwoPlanarFaceAngle dimension
Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace,
const gp_Ax1& theAxis);
//! Constructs angle dimension for the cone face.
//! @param theCone [in] the conical face.
Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
//! Sets first shape
Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape,
const Standard_Boolean isSingleShape = Standard_False);
//! 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);
public:
@@ -88,63 +207,111 @@ public:
protected:
//! Computes dimension value in display units
Standard_EXPORT virtual void computeValue();
//! Initialization of fields that is common to all constructors.
Standard_EXPORT void Init();
Standard_EXPORT void init();
Standard_EXPORT gp_Pnt getCenterOnArc (const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach);
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);
Standard_EXPORT void drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theFirstAttach,
//! @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 TCollection_ExtendedString& theText,
const Standard_Real theTextWidth,
const Standard_Integer theMode,
const Standard_Integer theLabelPosition);
const gp_Pnt& theCenter);
//! 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);
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 Standard_Boolean initConeAngle (const TopoDS_Face& theCone);
Standard_EXPORT Standard_Boolean initTwoFacesAngle();
Standard_EXPORT Standard_Boolean initTwoEdgesAngle();
//! Auxiliary method to get position of the angle dimension
//! if the cone is trimmed
//! Returns 1 if <theC> center is above of <theCMin> center;
//! 0 if <theC> center is between <theCMin> and <theCMax> centers;
//! -1 if <theC> center is below <theCMax> center.
Standard_EXPORT Standard_Integer aboveInBelowCone (const gp_Circ &theCMax,
const gp_Circ &theCMin,
const gp_Circ &theC);
//! Fills default plane object if it is possible to count plane automatically.
Standard_EXPORT virtual void countDefaultPlane ();
//! Fills sensitive entity for flyouts and adds it to the selection
Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(SelectMgr_EntityOwner)& theOwner);
Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(SelectMgr_EntityOwner)& theOwner);
protected:
//! Shows if there is necessarily to draw extensions on angle dimension
//! It is set to the true value if the attachment point are out of the edges.
Standard_Boolean myIsFlyoutLines;
//! 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);
//! The center of dimension arc
gp_Pnt myCenter;
//! 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
#endif // _AIS_AngleDimension_HeaderFile

View File

@@ -19,17 +19,18 @@
// and conditions governing the rights and limitations under the License.
#include <AIS_DiameterDimension.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
#include <ElCLib.hxx>
#include <gce_MakeDir.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_Group.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Prs3d_Root.hxx>
IMPLEMENT_STANDARD_HANDLE(AIS_DiameterDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT(AIS_DiameterDimension, AIS_Dimension)
#include <AIS.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <ElCLib.hxx>
#include <GeomAPI_IntCS.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Plane.hxx>
#include <gce_MakeDir.hxx>
#include <Standard_ProgramError.hxx>
IMPLEMENT_STANDARD_HANDLE (AIS_DiameterDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT (AIS_DiameterDimension, AIS_Dimension)
namespace
{
@@ -40,69 +41,251 @@ namespace
//function : Constructor
//purpose :
//=======================================================================
AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle)
: AIS_Dimension(),
myCircle (theCircle)
AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle)
: AIS_Dimension (AIS_KOD_DIAMETER)
{
SetKindOfDimension(AIS_KOD_DIAMETER);
myIsInitialized = Standard_True;
SetMeasuredGeometry (theCircle);
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
SetFlyout (0.0);
// Count attach points
myFirstPoint = ElCLib::Value (0, myCircle);
mySecondPoint = myFirstPoint.Translated (gp_Vec(myFirstPoint, theCircle.Location())*2);
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle, const gp_Pnt& theAttachPoint)
: AIS_Dimension(),
myCircle (theCircle)
AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle,
const gp_Pln& thePlane)
: AIS_Dimension (AIS_KOD_DIAMETER)
{
SetKindOfDimension (AIS_KOD_DIAMETER);
SetCustomPlane (thePlane);
SetMeasuredGeometry (theCircle);
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
SetFlyout (0.0);
myFirstPoint = theAttachPoint;
// Count the second point
if (Abs(myFirstPoint.Distance (theCircle.Location()) - theCircle.Radius()) < Precision::Confusion())
{
mySecondPoint = myFirstPoint.Translated(gp_Vec(myFirstPoint, theCircle.Location())*2);
}
else
{
myFirstPoint = ElCLib::Value(0, myCircle);
mySecondPoint = myFirstPoint.Translated(gp_Vec(myFirstPoint, theCircle.Location())*2);
}
myIsInitialized = Standard_True;
}
//=======================================================================
//function : Constructor
//purpose : Universal constructor for diameter dimension of shape
//purpose :
//=======================================================================
AIS_DiameterDimension::AIS_DiameterDimension (const TopoDS_Shape& theShape)
: AIS_Dimension ()
: AIS_Dimension (AIS_KOD_DIAMETER)
{
SetKindOfDimension (AIS_KOD_DIAMETER);
SetMeasuredGeometry (theShape);
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
SetFlyout (0.0);
myFirstShape = theShape;
myIsInitialized = Standard_False;
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_DiameterDimension::AIS_DiameterDimension (const TopoDS_Shape& theShape,
const gp_Pln& thePlane)
: AIS_Dimension (AIS_KOD_DIAMETER)
{
SetCustomPlane (thePlane);
SetMeasuredGeometry (theShape);
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
SetFlyout (0.0);
}
//=======================================================================
//function : AnchorPoint
//purpose :
//=======================================================================
gp_Pnt AIS_DiameterDimension::AnchorPoint()
{
if (!IsValid())
{
return gp::Origin();
}
return myAnchorPoint;
}
//=======================================================================
//function : SetMeasuredGeometry
//purpose :
//=======================================================================
void AIS_DiameterDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
{
myCircle = theCircle;
myGeometryType = GeometryType_Edge;
myShape = BRepLib_MakeEdge (theCircle);
myAnchorPoint = gp::Origin();
myIsValid = IsValidCircle (myCircle);
if (myIsValid && myIsPlaneCustom)
{
ComputeAnchorPoint();
}
else if (!myIsPlaneCustom)
{
ComputePlane();
myAnchorPoint = ElCLib::Value (0.0, myCircle);
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
//=======================================================================
//function : SetMeasuredGeometry
//purpose :
//=======================================================================
void AIS_DiameterDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape)
{
gp_Pnt aDummyPnt (gp::Origin());
Standard_Boolean isClosed = Standard_False;
myGeometryType = GeometryType_UndefShapes;
myShape = theShape;
myAnchorPoint = gp::Origin();
myIsValid = InitCircularDimension (theShape, myCircle, aDummyPnt, isClosed)
&& IsValidCircle (myCircle)
&& isClosed;
if (myIsValid && myIsPlaneCustom)
{
ComputeAnchorPoint();
}
else if (!myIsPlaneCustom)
{
ComputePlane();
myAnchorPoint = ElCLib::Value (0.0, myCircle);
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
//=======================================================================
//function : CheckPlane
//purpose :
//=======================================================================
Standard_Boolean AIS_DiameterDimension::CheckPlane (const gp_Pln& thePlane) const
{
// Check if the circle center point belongs to plane.
if (!thePlane.Contains (myCircle.Location(), Precision::Confusion()))
{
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : ComputePlane
//purpose :
//=======================================================================
void AIS_DiameterDimension::ComputePlane()
{
if (!IsValid())
{
return;
}
myPlane = gp_Pln (gp_Ax3 (myCircle.Position()));
}
//=======================================================================
//function : ComputeAnchorPoint
//purpose :
//=======================================================================
void AIS_DiameterDimension::ComputeAnchorPoint()
{
// Anchor point is an intersection of dimension plane and circle.
Handle(Geom_Circle) aCircle = new Geom_Circle (myCircle);
Handle(Geom_Plane) aPlane = new Geom_Plane (myPlane);
GeomAPI_IntCS anIntersector (aCircle, aPlane);
if (!anIntersector.IsDone())
{
myIsValid = Standard_False;
return;
}
// The circle lays on the plane.
if (anIntersector.NbPoints() != 2)
{
myAnchorPoint = ElCLib::Value (0.0, myCircle);
myIsValid = Standard_True;
return;
}
gp_Pnt aFirstPoint = anIntersector.Point (1);
gp_Pnt aSecondPoint = anIntersector.Point (2);
// Choose one of two intersection points that stands with
// positive direction of flyout.
// An anchor point is supposed to be the left attachment point.
gp_Dir aFirstDir = gce_MakeDir (aFirstPoint, myCircle.Location());
gp_Dir aDir = myPlane.Axis().Direction() ^ aFirstDir;
myAnchorPoint = (gp_Vec (aDir) * gp_Vec(myCircle.Position().Direction()) > 0.0)
? aFirstPoint
: aSecondPoint;
}
//=======================================================================
//function : GetModelUnits
//purpose :
//=======================================================================
const TCollection_AsciiString& AIS_DiameterDimension::GetModelUnits() const
{
return myDrawer->DimLengthModelUnits();
}
//=======================================================================
//function : GetDisplayUnits
//purpose :
//=======================================================================
const TCollection_AsciiString& AIS_DiameterDimension::GetDisplayUnits() const
{
return myDrawer->DimLengthDisplayUnits();
}
//=======================================================================
//function : SetModelUnits
//purpose :
//=======================================================================
void AIS_DiameterDimension::SetModelUnits (const TCollection_AsciiString& theUnits)
{
myDrawer->SetDimLengthModelUnits (theUnits);
}
//=======================================================================
//function : SetDisplayUnits
//purpose :
//=======================================================================
void AIS_DiameterDimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
{
myDrawer->SetDimLengthDisplayUnits (theUnits);
}
//=======================================================================
//function : ComputeValue
//purpose :
//=======================================================================
Standard_Real AIS_DiameterDimension::ComputeValue() const
{
if (!IsValid())
{
return 0.0;
}
return myCircle.Radius() * 2.0;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
@@ -110,48 +293,72 @@ void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)&
thePresentation->Clear();
mySelectionGeom.Clear (theMode);
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
if (!myIsInitialized)
if (!IsValid())
{
if (!initCircularDimension (myFirstShape, myCircle,
myFirstPoint, mySecondPoint))
return;
else
myIsInitialized = Standard_True;
return;
}
if (!myIsWorkingPlaneCustom)
gp_Pnt aFirstPnt (gp::Origin());
gp_Pnt aSecondPnt (gp::Origin());
ComputeSidePoints (myCircle, GetPlane(), aFirstPnt, aSecondPnt);
DrawLinearDimension (thePresentation, theMode, aFirstPnt, aSecondPnt);
}
//=======================================================================
//function : ComputeFlyoutSelection
//purpose :
//=======================================================================
void AIS_DiameterDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(SelectMgr_EntityOwner)& theEntityOwner)
{
if (!IsValid())
{
countDefaultPlane();
return;
}
drawLinearDimension (thePresentation, theMode);
gp_Pnt aFirstPnt (gp::Origin());
gp_Pnt aSecondPnt (gp::Origin());
ComputeSidePoints (myCircle, GetPlane(), aFirstPnt, aSecondPnt);
ComputeLinearFlyouts (theSelection, theEntityOwner, aFirstPnt, aSecondPnt);
}
//=======================================================================
//function : computeValue
//function : ComputeSidePoints
//purpose :
//=======================================================================
void AIS_DiameterDimension::computeValue ()
void AIS_DiameterDimension::ComputeSidePoints (const gp_Circ& /*theCircle*/,
const gp_Pln& /*thePlane*/,
gp_Pnt& theFirstPnt,
gp_Pnt& theSecondPnt)
{
myValue = myFirstPoint.Distance (mySecondPoint);
AIS_Dimension::computeValue();
theFirstPnt = AnchorPoint();
gp_Vec aRadiusVector (myCircle.Location(), theFirstPnt);
theSecondPnt = myCircle.Location().Translated (-aRadiusVector);
}
//=======================================================================
//function : countDefaultPlane
//function : IsValidCircle
//purpose :
//=======================================================================
void AIS_DiameterDimension::countDefaultPlane ()
Standard_Boolean AIS_DiameterDimension::IsValidCircle (const gp_Circ& theCircle) const
{
// Compute normal of the default plane.
//gp_Vec aVec1(mySecondPoint, myFirstPoint),
// aVec2(mySecondPoint, ElCLib::Value(M_PI_2, myCircle));
myDefaultPlane = gp_Pln(gp_Ax3(myCircle.Position()));
// Set computed value to <myWorkingPlane>
ResetWorkingPlane ();
return (theCircle.Radius() * 2.0) > Precision::Confusion();
}
//=======================================================================
//function : IsValidAnchor
//purpose :
//=======================================================================
Standard_Boolean AIS_DiameterDimension::IsValidAnchor (const gp_Circ& theCircle,
const gp_Pnt& theAnchor) const
{
gp_Pln aCirclePlane (theCircle.Location(), theCircle.Axis().Direction());
Standard_Real anAnchorDist = theAnchor.Distance (theCircle.Location());
Standard_Real aRadius = myCircle.Radius();
return Abs (anAnchorDist - aRadius) > Precision::Confusion()
&& aCirclePlane.Contains (theAnchor, Precision::Confusion());
}

View File

@@ -15,6 +15,7 @@
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#ifndef _AIS_DiameterDimension_HeaderFile
#define _AIS_DiameterDimension_HeaderFile
@@ -26,48 +27,159 @@
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
DEFINE_STANDARD_HANDLE(AIS_DiameterDimension,AIS_Dimension)
DEFINE_STANDARD_HANDLE (AIS_DiameterDimension, AIS_Dimension)
//! A framework to display diameter dimensions. <br>
//! A diameter is displayed with arrows and text. The <br>
//! text gives the length of the diameter. <br>
//! The algorithm takes a length along a face and <br>
//! analyzes it as an arc. It then reconstructs the circle <br>
//! corresponding to the arc and calculates the <br>
//! diameter of this circle. This diameter serves as a <br>
//! relational reference in 3d presentations of the surface. <br>
//! Diameter dimension. Can be constructued:
//! - On generic circle.
//! - On generic circle with user-defined anchor point on that circle
//! (dimension plane is oriented to follow the anchor point).
//! - On generic circle in the specified plane.
//! - On generic shape containing geometry that can be measured
//! by diameter dimension: circle wire, circular face, etc.
//! The anchor point is the location of the left attachement point of
//! dimension on the circle.
//! The anchor point computation is processed after dimension plane setting
//! so that positive flyout direction stands with normal of the circle and
//! the normal of the plane.
//! If the plane is user-defined the anchor point was computed as intersection
//! of the plane and the basis circle. Among two intersection points
//! the one is selected so that positive flyout direction vector and
//! the circle normal on the one side form the circle plane.
//! (corner between positive flyout directio nand the circle normal is acute.)
//! If the plane is computed automatically (by default it is the circle plane),
//! the anchor point is the zero parameter point of the circle.
//!
//! The dimension is considered as invalid if the user-defined plane
//! does not include th enachor point and th ecircle center,
//! if the diameter of the circle is less than Precision::Confusion().
//! In case if the dimension is built on the arbitrary shape, it can be considered
//! as invalid if the shape does not contain circle geometry.
//!
class AIS_DiameterDimension : public AIS_Dimension
{
public:
//! Constructs a diameter display object defined by the <br>
//! circle <theCircle>
Standard_EXPORT AIS_DiameterDimension(const gp_Circ& theCircle);
//! Constructor that allows to set a attach point <br>
//! on the circle <theCircle> where to attach dimension
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
const gp_Pnt& theAttachPoint);
//! Construct diameter dimension for the circle.
//! @param theCircle [in] the circle to measure.
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle);
Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
//! Construct diameter dimension for the circle and orient it correspondingly
//! to the passed plane.
//! @param theCircle [in] the circle to measure.
//! @param thePlane [in] the plane defining preferred orientation
//! for dimension.
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
const gp_Pln& thePlane);
//! Construct diameter on the passed shape, if applicable.
//! @param theShape [in] the shape to measure.
Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
//! Construct diameter on the passed shape, if applicable - and
//! define the preferred plane to orient the dimension.
//! @param theShape [in] the shape to measure.
//! @param thePlane [in] the plane defining preferred orientation
//! for dimension.
Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape,
const gp_Pln& thePlane);
public:
//! @return measured geometry circle.
const gp_Circ& Circle() const
{
return myCircle;
}
//! @return anchor point on circle for diameter dimension.
Standard_EXPORT gp_Pnt AnchorPoint();
//! @return the measured shape.
const TopoDS_Shape& Shape() const
{
return myShape;
}
public:
//! Measure diameter of the circle.
//! The actual dimension plane is used for determining anchor points
//! on the circle to attach the dimension lines to.
//! The dimension will become invalid if the diameter of the circle
//! is less than Precision::Confusion().
//! @param theCircle [in] the circle to measure.
Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
//! Measure diameter on the passed shape, if applicable.
//! The dimension will become invalid if the passed shape is not
//! measurable or if measured diameter value is less than Precision::Confusion().
//! @param theShape [in] the shape to measure.
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape);
//! @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);
public:
DEFINE_STANDARD_RTTI(AIS_DiameterDimension)
protected:
Standard_EXPORT virtual void computeValue();
//! Override this method to change logic of anchor point computation.
//! Computes anchor point. Its computation is based on the current
//! dimension plane. Therfore, anchor point is an intersection of plane
//! and circle.
//! ATTENTION!
//! 1) The plane should be set or computed before.
//! 2) The plane should inclide th ecircle center to be valid.
Standard_EXPORT virtual void ComputeAnchorPoint();
//! Fills default plane object if it is possible to count plane automatically.
Standard_EXPORT virtual void countDefaultPlane();
Standard_EXPORT virtual void ComputePlane();
private:
//! Checks if the center of the circle is on the plane.
Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
Standard_EXPORT virtual Standard_Real ComputeValue() const;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(SelectMgr_EntityOwner)& theEntityOwner);
protected:
//! Compute points on the circle sides for the specified dimension plane.
//! Program error exception is raised if the dimension plane "x" direction
//! is orthogonal to plane (the "impossible" case). The passed dimension plane
//! is the one specially computed to locate dimension presentation in circle.
//! @param theCircle [in] the circle.
//! @param thePlane [in] the dimension presentation plane computed.
//! @param theFirstPnt [out] the first point.
//! @param theSecondPnt [out] the second point.
Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle,
const gp_Pln& thePlane,
gp_Pnt& theFirstPnt,
gp_Pnt& theSecondPnt);
Standard_EXPORT Standard_Boolean IsValidCircle (const gp_Circ& theCircle) const;
Standard_EXPORT Standard_Boolean IsValidAnchor (const gp_Circ& theCircle,
const gp_Pnt& thePnt) const;
// Fields
private:
gp_Circ myCircle;
gp_Circ myCircle;
gp_Pnt myAnchorPoint;
TopoDS_Shape myShape;
};
#endif
#endif // _AIS_DiameterDimension_HeaderFile

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2013 OPEN CASCADE SAS
// Created on: 2013-11-11
// Created by: Anastasia BORISOVA
// Copyright (c) 2013 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
@@ -16,8 +17,8 @@
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#ifndef _AIS_Dimension_Headerfile
#define _AIS_Dimension_Headerfile
#ifndef _AIS_Dimension_HeaderFile
#define _AIS_Dimension_HeaderFile
#include <AIS_DimensionSelectionMode.hxx>
#include <AIS_DimensionOwner.hxx>
@@ -26,11 +27,12 @@
#include <AIS_KindOfInteractive.hxx>
#include <AIS_KindOfDimension.hxx>
#include <AIS_KindOfSurface.hxx>
#include <Bnd_Box.hxx>
#include <AIS_Drawer.hxx>
#include <Geom_Curve.hxx>
#include <gp_Pln.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_DimensionUnits.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_TextAspect.hxx>
@@ -46,12 +48,121 @@
DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject)
//! AIS_Dimension is a base class for 2D presentations of linear (length, diameter, radius)
//! and angular dimensions.
//!
//! The dimensions provide measurement of quantities, such as lengths or plane angles.
//! The measurement of dimension "value" is done in model space "as is".
//! These "value" are said to be represented in "model units", which can be specified by user.
//! During the display the measured value converted from "model units" to "display units".
//! The display and model units are stored in common Prs3d_Drawer (drawer of the context)
//! to share it between all dimensions.
//! The specified by user units are stored in the dimension's drawer.
//!
//! As a drawing, the dimension is composed from the following components:
//! - Attachement (binding) points. The points where the dimension lines attaches to, for
//! length dimensions the distances are measured between these points.
//! - Main dimension line. The which extends from the attachement points in "up" direction,
//! and which contains text label on it with value string.
//! - Flyouts. The lines connecting the attachement points with main dimension line.
//! - Extension. The lines used to extend the main dimension line in the cases when text
//! or arrows do not fit into the main dimension line due to their size.
//! - Arrows.
//!
//! <pre>
//! Linear dimensions:
//!
//! extension
//! line arrow
//! -->|------- main dimension line -------|<--
//! | |
//! |flyout flyout|
//! | |
//! +-----------------------------------+
//! attachement attachement
//! point point
//!
//! Angular dimensions:
//!
//! extension
//! line
//! -->|+++++
//! arrow | +++
//! | 90(deg) - main dimension line
//! flyout | +++
//! | +
//! o---flyout---
//! center ^
//! point | extension
//! line
//! </pre>
//!
//! Being a 2D drawings, the dimensions are created on imaginary plane, called "dimension plane",
//! which can be thought of as reference system of axes (X,Y,N) for constructing the presentation.
//!
//! The role of axes of the dimension plane is to guide you through the encapsualted automations
//! of presentation building to help you understand how is the presentation will look and how it
//! will be oriented in model space during construction.
//!
//! Orientation of dimension line in model space relatively to the base shapes is defined
//! with the flyouts. Flyouts specify length of flyout lines and their orientation relatively
//! to the attachment points on the working plane.
//! For linear dimensions:
//! Direction of flyouts is specified with direction of main dimension line
//! (vector from the first attachment to the second attachment) and the normal of the dimension plane.
//! Positive direction of flyouts is defined by vector multiplication: AttachVector * PlaneNormal.
//! For angular dimensions:
//! Flyouts are defined by vectors from the center point to the attachment points.
//! These vectors directions are supposed to be the positive directions of flyouts.
//! Negative flyouts directions means that these vectors should be reversed
//! (and dimension will be built out of the angle constructed with center and two attach points).
//!
//! The dimension plane can be constructed automatically by application (where possible,
//! it depends on the measured geometry).
//! It can be also set by user. However, if the user-defined plane does not fit the
//! geometry of the dimension (attach points do not belong to it), the dimension could not
//! be built.
//! If it is not possible to compute automatic plane (for example, in case of length between
//! two points) the user is supposed to specify the custom plane.
//!
//! Since the dimensions feature automated construction procedures from an arbitrary shapes,
//! the interfaces to check the validness are also implemented. Once the measured geometry is
//! specified, the one can inquire the validness status by calling "IsValid()" method. If the result
//! is TRUE, then all of public parameters should be pre-computed and ready. The presentation
//! should be also computable. Otherwise, the parameters may return invalid values. In this case,
//! the presentation will not be computed and displayed.
//!
//! The dimension support two local selection modes: main dimension line selection and text label
//! selection. These modes can be used to develop interactive modification of dimension presentations.
//! The component hilighting in these selection modes is provided by AIS_DimensionOwner class.
//! Please note that selection is unavailable until the presentation is computed.
//!
//! The specific drawing attributes are controlled through Prs3d_DimensionAspect. The one can change
//! color, arrows, text and arrow style and specify positioning of value label by setting corresponding
//! values to the aspect.
//!
class AIS_Dimension : public AIS_InteractiveObject
{
protected:
// Specifies supported at base level horizontal and vertical
// label positions for drawing extension lines and centered text.
//! Geometry type defines type of shapes on which the dimension is to be built.
//! Some type of geometry allows automatical plane computing and
//! can be built without user-defined plane
//! Another types can't be built without user-defined plane.
enum GeometryType
{
GeometryType_UndefShapes,
GeometryType_Edge,
GeometryType_Face,
GeometryType_Points,
GeometryType_Edges,
GeometryType_Faces,
GeometryType_EdgeFace,
GeometryType_EdgeVertex
};
//! Specifies supported at base level horizontal and vertical
//! label positions for drawing extension lines and centered text.
enum LabelPosition
{
LabelPosition_None = 0x00,
@@ -59,12 +170,12 @@ protected:
LabelPosition_Left = 0x01,
LabelPosition_Right = 0x02,
LabelPosition_HCenter = 0x04,
LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter,
LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter,
LabelPosition_Above = 0x10,
LabelPosition_Below = 0x20,
LabelPosition_VCenter = 0x40,
LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter
LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter
};
public:
@@ -81,158 +192,174 @@ public:
public:
//! Constructor with default parameters values
Standard_EXPORT AIS_Dimension();
//! Constructor with default parameters values.
//! @param theType [in] the type of dimension.
Standard_EXPORT AIS_Dimension (const AIS_KindOfDimension theType);
//! Gets dimension value
Standard_EXPORT Standard_Real GetValue() const;
//! Gets dimension measurement value. If the value to display is not
//! specified by user, then the dimension object is responsible to
//! compute it on its own in model space coordinates.
//! @return the dimension value (in model units) which is used
//! during display of the presentation.
Standard_Real GetValue() const
{
return myIsValueCustom ? myCustomValue : ComputeValue();
}
//! Sets dimension value
//! Attention! This method is used ONLY to set custom value.
//! To set value internally, use <myValue>.
Standard_EXPORT void SetCustomValue (const Standard_Real theValue);
//! Sets user-defined dimension value.
//! The user-defined dimension value is specified in model space,
//! and affect by unit conversion during the display.
//! @param theValue [in] the user-defined value to display.
Standard_EXPORT void SetCustomValue (const Standard_Real theValue);
//! Gets working plane.
Standard_EXPORT const gp_Pln& GetWorkingPlane() const;
//! Get the dimension plane in which the 2D dimension presentation is computed.
//! By default, if plane is not defined by user, it is computed automatically
//! after dimension geometry is computed.
//! If computed dimension geometry (points) can't be placed on the user-defined
//! plane, dimension geometry was set as unvalid (validity flag is set to false)
//! and dimension presentation wil not be computed.
//! If user-defined plane allow geometry placement on it, it will be used for
//! computing of the dimension presentation.
//! @return dimension plane used for presentation computing.
Standard_EXPORT const gp_Pln& GetPlane() const;
//! Sets working plane.
Standard_EXPORT void SetWorkingPlane (const gp_Pln& thePlane);
//! Geometry type defines type of shapes on which the dimension is to be built.
//! @return type of geometry on which the dimension will be built.
Standard_EXPORT const Standard_Integer GetGeometryType () const;
Standard_EXPORT void SetFirstPoint (const gp_Pnt& thePoint);
//! Sets user-defined plane where the 2D dimension presentation will be placed.
//! Checks validity of this plane if geometry has been set already.
//! Validity of the plane is checked according to the geometry set
//! and has different criteria for different kinds of dimensions.
Standard_EXPORT virtual void SetCustomPlane (const gp_Pln& thePlane);
Standard_EXPORT void SetSecondPoint (const gp_Pnt& thePoint);
//! Unsets user-defined plane. Therefore the plane for dimension will be
//! computed automatically.
Standard_EXPORT void UnsetCustomPlane() { myIsPlaneCustom = Standard_False; }
Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theFirstShape);
Standard_EXPORT void SetSecondShape (const TopoDS_Shape& theSecondShape);
public:
//! Gets the dimension aspect from AIS object drawer.
//! Dimension aspect contains aspects of line, text and arrows for dimension presentation.
Standard_EXPORT Handle(Prs3d_DimensionAspect) DimensionAspect() const;
Handle(Prs3d_DimensionAspect) DimensionAspect() const
{
return myDrawer->DimensionAspect();
}
//! Sets new length aspect in the interactive object drawer.
Standard_EXPORT void SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect);
//! Sets new dimension aspect for the interactive object drawer.
//! The dimension aspect provides dynamic properties which are generally
//! used during computation of dimension presentations.
Standard_EXPORT void SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect);
//! Returns the kind of dimension
Standard_EXPORT AIS_KindOfDimension KindOfDimension() const;
//! @return the kind of dimension.
AIS_KindOfDimension KindOfDimension() const
{
return myKindOfDimension;
}
//! Returns the kind of interactive
Standard_EXPORT virtual AIS_KindOfInteractive Type() const;
//! Sets the kind of dimension
Standard_EXPORT virtual void SetKindOfDimension (const AIS_KindOfDimension theKindOfDimension);
//! @return the kind of interactive.
virtual AIS_KindOfInteractive Type() const
{
return AIS_KOI_Relation;
}
//! Returns true if the class of objects accepts the display mode theMode.
//! The interactive context can have a default mode of
//! representation for the set of Interactive Objects. This
//! mode may not be accepted by object
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const;
//! The interactive context can have a default mode of representation for
//! the set of Interactive Objects. This mode may not be accepted by object.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const
{
return theMode == ComputeMode_All;
}
// Selection computing if it is needed here
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode);
public:
//! Reset working plane to default.
Standard_EXPORT void ResetWorkingPlane();
//! @return dimension special symbol display options.
AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const
{
return myDisplaySpecialSymbol;
}
//! specifies dimension special symbol display options
Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol);
//! Specifies whether to display special symbol or not.
Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol);
//! shows dimension special symbol display options
Standard_EXPORT AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const;
//! @return special symbol.
Standard_ExtCharacter SpecialSymbol() const
{
return mySpecialSymbol;
}
//! specifies special symbol
Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
//! Specifies special symbol.
Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
//! returns special symbol
Standard_EXPORT Standard_ExtCharacter SpecialSymbol() const;
Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const;
//! shows if Units are to be displayed along with dimension value
Standard_EXPORT Standard_Boolean IsUnitsDisplayed() const;
Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const;
//! sets to display units along with the dimension value or no
Standard_EXPORT void MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits);
Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& /*theUnits*/) { }
//! returns the current type of units
Standard_EXPORT TCollection_AsciiString UnitsQuantity() const;
Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& /*theUnits*/) { }
//! sets the current type of units
Standard_EXPORT void SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity);
public:
//! returns the current model units
Standard_EXPORT TCollection_AsciiString ModelUnits() const;
//! sets the current model units
Standard_EXPORT void SetModelUnits (const TCollection_AsciiString& theUnits);
//! returns the current display units
Standard_EXPORT TCollection_AsciiString DisplayUnits() const;
//! sets the current display units
Standard_EXPORT void SetDisplayUnits (const TCollection_AsciiString& theUnits);
//! Important! Only for 3d text </br>
//! 3d text is oriented relative to the attachment points order </br>
//! By default, text direction vector is oriented from the first attachment point </br>
//! to the second one. This method checks if text direction is to be default or </br>
//! should be reversed.
Standard_EXPORT Standard_Boolean IsTextReversed() const;
//! Important! Only for 3d text
//! 3d text is oriented relative to the attachment points order </br>
//! By default, text direction vector is oriented from the first attachment point </br>
//! to the second one. This method sets value that shows if text direction </br>
//! should be reversed or not.
Standard_EXPORT void MakeTextReversed (const Standard_Boolean isTextReversed);
//! Returns selection tolerance for text2d:
//! For 2d text selection detection sensitive point with tolerance is used
//! Important! Only for 2d text.
Standard_Real SelToleranceForText2d() const
{
return mySelToleranceForText2d;
}
//! Sets selection tolerance for text2d:
//! For 2d text selection detection sensitive point with tolerance is used
//! to change this tolerance use this method
//! Important! Only for 2d text
Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol);
//! Important! Only for 2d text.
Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol);
//! Returns selection tolerance for text2d:
//! For 2d text selection detection sensitive point with tolerance is used
//! Important! Only for 2d text
Standard_EXPORT Standard_Real SelToleranceForText2d() const;
//! Sets flyout size for dimension.
Standard_EXPORT void SetFlyout (const Standard_Real theFlyout);
//! @return flyout size for dimension.
//! @return flyout value for dimension.
Standard_Real GetFlyout() const
{
return myFlyout;
}
//! Sets flyout value for dimension.
Standard_EXPORT void SetFlyout (const Standard_Real theFlyout);
//! Check that the input geometry for dimension is valid and the
//! presentation can be succesfully computed.
//! @return TRUE if dimension geometry is ok.
Standard_Boolean IsValid() const
{
return myIsValid;
}
public:
DEFINE_STANDARD_RTTI(AIS_Dimension)
protected:
Standard_EXPORT void getTextWidthAndString (Quantity_Length& theWidth,
TCollection_ExtendedString& theString) const;
Standard_EXPORT Standard_Real ValueToDisplayUnits() const;
Standard_EXPORT Standard_Real valueToDisplayUnits();
//! Reset working plane to default.
Standard_EXPORT void resetWorkingPlane (const gp_Pln& theNewDefaultPlane);
//! Count default plane
Standard_EXPORT virtual void countDefaultPlane();
//! Computes dimension value in display units
Standard_EXPORT virtual void computeValue();
//! Get formatted value string and its model space width.
//! @param theWidth [out] the model space with of the string.
//! @return formatted dimension value string.
Standard_EXPORT TCollection_ExtendedString GetValueString (Standard_Real& theWidth) const;
//! Performs drawing of 2d or 3d arrows on the working plane
Standard_EXPORT void drawArrow (const Handle(Prs3d_Presentation)& thePresentation,
//! @param theLocation [in] the location of the arrow tip.
//! @param theDirection [in] the direction from the tip to the bottom of the arrow.
Standard_EXPORT void DrawArrow (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theLocation,
const gp_Dir& theDirection);
//! Performs drawing of 2d or 3d text on the working plane
//! @param theTextPos [in] the position of the text label.
//! @param theTestDir [in] the direction of the text label.
//! @param theText [in] the text label string.
//! @param theLabelPosition [in] the text label vertical and horizontal positioning option
//! respectively to the main dimension line.
//! @return text width relative to the dimension working plane. For 2d text this value will be zero.
Standard_EXPORT void drawText (const Handle(Prs3d_Presentation)& thePresentation,
Standard_EXPORT void DrawText (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theTextPos,
const gp_Dir& theTextDir,
const TCollection_ExtendedString& theText,
@@ -247,7 +374,7 @@ protected:
//! @param theLabelWidth [in] the geometrical width computed for value string.
//! @param theMode [in] the display mode.
//! @param theLabelPosition [in] position flags for the text label.
Standard_EXPORT void drawExtension (const Handle(Prs3d_Presentation)& thePresentation,
Standard_EXPORT void DrawExtension (const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Real theExtensionSize,
const gp_Pnt& theExtensionStart,
const gp_Dir& theExtensionDir,
@@ -256,32 +383,81 @@ protected:
const Standard_Integer theMode,
const Standard_Integer theLabelPosition);
//! Performs computing of linear dimension (for length, diameter, radius and so on)
Standard_EXPORT void drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
//! Performs computing of linear dimension (for length, diameter, radius and so on).
//! Please note that this method uses base dimension properties, like working plane
//! flyout length, drawer attributes.
//! @param thePresentation [in] the presentation to fill with primitives.
//! @param theMode [in] the presentation compute mode.
//! @param theFirstPoint [in] the first attach point of linear dimension.
//! @param theSecondPoint [in] the second attach point of linear dimension.
//! @param theIsOneSide [in] specifies whether the dimension has only one flyout line.
Standard_EXPORT void DrawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode,
const Standard_Boolean isOneSideDimension = Standard_False);
const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const Standard_Boolean theIsOneSide = Standard_False);
//! If it's possible computes circle from planar face
Standard_EXPORT Standard_Boolean circleFromPlanarFace (const TopoDS_Face& theFace,
//! Compute selection sensitives for linear dimension flyout lines (length, diameter, radius).
//! Please note that this method uses base dimension properties: working plane and flyout length.
//! @param theSelection [in] the selection structure to fill with selection primitives.
//! @param theOwner [in] the selection entity owner.
//! @param theFirstPoint [in] the first attach point of linear dimension.
//! @param theSecondPoint [in] the second attach point of linear dimension.
Standard_EXPORT void ComputeLinearFlyouts (const Handle(SelectMgr_Selection)& theSelection,
const Handle(SelectMgr_EntityOwner)& theOwner,
const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint);
//! If it is possible extracts circle from planar face.
//! @param theFace [in] the planar face.
//! @param theCurve [out] the circular curve.
//! @param theFirstPoint [out] the point of the first parameter of the circlular curve.
//! @param theSecondPoint [out] the point of the last parameter of the circlular curve.
//! @return TRUE in case of successful circle extraction.
Standard_EXPORT Standard_Boolean CircleFromPlanarFace (const TopoDS_Face& theFace,
Handle(Geom_Curve)& theCurve,
gp_Pnt & theFirstPoint,
gp_Pnt & theLastPoint);
gp_Pnt& theFirstPoint,
gp_Pnt& theLastPoint);
//! Performs initialization of circle and points from given shape
//! (for radius, diameter and so on)
Standard_EXPORT Standard_Boolean initCircularDimension (const TopoDS_Shape& theShape,
gp_Circ& theCircle,
gp_Pnt& theMiddleArcPoint,
gp_Pnt& theOppositeDiameterPoint);
Standard_EXPORT Standard_Boolean isComputed() const;
//! Performs initialization of circle and middle arc point from the passed
//! shape which is assumed to contain circular geometry.
//! @param theShape [in] the shape to explore.
//! @param theCircle [out] the circle geometry.
//! @param theMiddleArcPoint [out] the middle point of the arc.
//! @param theIsClosed [out] returns TRUE if the geometry is closed circle.
//! @return TRUE if the the circle is successfully got from the input shape.
Standard_EXPORT Standard_Boolean InitCircularDimension (const TopoDS_Shape& theShape,
gp_Circ& theCircle,
gp_Pnt& theMiddleArcPoint,
Standard_Boolean& theIsClosed);
Standard_EXPORT void setComputed (Standard_Boolean isComputed);
protected: //! @name Behavior to implement
Standard_EXPORT void resetGeom();
//! Override this method to compute automatically dimension plane
//! in which the dimension presentation is built.
virtual void ComputePlane() { }
//! Fills sensitive entity for flyouts and adds it to the selection.
Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(SelectMgr_EntityOwner)& theOwner);
//! Override this method to check if user-defined plane
//! is valid for the dimension geometry.
//! @param thePlane [in] the working plane for positioning every
//! dimension in the application.
//! @return true is the plane is suitable for building dimension
//! with computed dimension geometry.
virtual Standard_Boolean CheckPlane (const gp_Pln& /*thePlane*/) const { return Standard_True; }
//! Override this method to computed value of dimension.
//! @return value from the measured geometry.
virtual Standard_Real ComputeValue() const
{
return 0.0;
}
//! Override this method to compute selection primitives for
//! flyout lines (if the dimension provides it).
//! This callback is a only a part of base selection
//! computation routine.
virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)&,
const Handle(SelectMgr_EntityOwner)&) {}
//! Produce points for triangular arrow face.
//! @param thePeakPnt [in] the arrow peak position.
@@ -300,41 +476,11 @@ protected:
gp_Pnt& theSidePnt1,
gp_Pnt& theSidePnt2);
protected: //! @name Working plane properties
//! Dimension default plane
gp_Pln myDefaultPlane;
//! Shows if working plane is set custom
Standard_Boolean myIsWorkingPlaneCustom;
protected: //! @name Value properties
//! Dimension value which is displayed with dimension lines
Standard_Real myValue;
//! Shows if the value is set by user and is no need to count it automatically
Standard_Boolean myIsValueCustom;
protected: // !@name Units properties
//! The quantity of units for the value computation
TCollection_AsciiString myUnitsQuantity;
//! Units of the model
TCollection_AsciiString myModelUnits;
//! Units in which the displayed value will be converted
TCollection_AsciiString myDisplayUnits;
//! Determines if units is to be displayed along with the value
Standard_Boolean myToDisplayUnits;
//! Special symbol for some kind of dimensions (for diameter, radius and so on)
Standard_ExtCharacter mySpecialSymbol;
//! Special symbol display options
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol;
//! Base procedure of computing selection (based on selection geometry data).
//! @param theSelection [in] the selection structure to will with primitives.
//! @param theMode [in] the selection mode.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode);
protected: //! @name Selection geometry
@@ -403,43 +549,28 @@ protected: //! @name Selection geometry
Standard_Real mySelToleranceForText2d; //!< Sensitive point tolerance for 2d text selection.
Standard_Boolean myIsComputed; //!< Shows if the presentation and selection was computed.
protected:
protected: //! @name Value properties
//! Shows if text is inverted
Standard_Boolean myIsTextReversed;
Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
Standard_Boolean myIsValueCustom; //!< Is user-defined value.
//! Points that are base for dimension.
//! My first point of dimension attach (belongs to shape for which dimension is computed)
gp_Pnt myFirstPoint;
protected: //! @name Units properties
//! My second point of dimension attach (belongs to shape for which dimension is computed)
gp_Pnt mySecondPoint;
Standard_ExtCharacter mySpecialSymbol; //!< Special symbol.
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options.
//! Shows if attach points are initialized correctly
Standard_Boolean myIsInitialized;
protected: //! @name Geometrical properties
//! First shape (can be vertex, edge or face)
TopoDS_Shape myFirstShape;
GeometryType myGeometryType; //!< defines type of shapes on which the dimension is to be built.
//! Second shape (can be vertex, edge or face)
TopoDS_Shape mySecondShape;
//! Number of shapes
Standard_Integer myShapesNumber;
//! Defines flyout lines and direction
//! Flyout direction in the working plane.
//! Can be negative, or positive and is defined by the sign of myFlyout value.
//! The direction vector is counting using the working plane.
//! myFlyout value defined the size of flyout.
Standard_Real myFlyout;
gp_Pln myPlane; //!< Plane where dimension will be built (computed or user defined).
Standard_Boolean myIsPlaneCustom; //!< Is plane defined by user (otherwise it will be computed automatically).
Standard_Real myFlyout; //!< Flyout distance.
Standard_Boolean myIsValid; //!< Is dimension geometry properly defined.
private:
//! Type of dimension
AIS_KindOfDimension myKindOfDimension;
//! Dimension working plane, is equal to <myDefaultPlane> if it can be computed automatically.
gp_Pln myWorkingPlane;
};
#endif
#endif // _AIS_Dimension_HeaderFile

View File

@@ -64,7 +64,10 @@ uses
NameOfColor from Quantity,
PlaneAngle from Quantity,
Length from Quantity,
TypeOfHLR from Prs3d
DimensionUnits from Prs3d,
AsciiString from TCollection,
TypeOfHLR from Prs3d,
Ax2 from gp
is
Create returns mutable Drawer from AIS;
@@ -542,16 +545,42 @@ is
-- Attributes for the presentation of a dimensions.
--
DimensionAspect(me:mutable) returns mutable DimensionAspect from Prs3d
DimensionAspect (me : mutable) returns mutable DimensionAspect from Prs3d is redefined static;
---Purpose: Returns a link with Prs3d_Drawer_DimensionAspect,
-- which provides settings for the appearance of dimensions.
is redefined static;
-- which provides settings for the appearance of dimensions.
HasDimensionAspect (me) returns Boolean from Standard is static;
---C++: inline
-- Purpose: Returns true if the Drawer has a dimension aspect setting active.
SetDimLengthModelUnits (me: mutable; theUnits : AsciiString from TCollection) is redefined static;
---Purpose: Sets dimension length model units for computing of dimension presentation.
SetDimAngleModelUnits (me: mutable; theUnits : AsciiString from TCollection) is redefined static;
---Purpose: Sets dimension angle model units for computing of dimension presentation.
DimAngleModelUnits (me) returns AsciiString from TCollection is redefined static;
---Purpose: Returns angle model units for the dimension presentation.
---C++: return const &
DimLengthModelUnits (me) returns AsciiString from TCollection is redefined static;
---Purpose: Returns length model units for the dimension presentation.
---C++: return const &
SetDimLengthDisplayUnits (me: mutable; theUnits : AsciiString from TCollection) is redefined static;
---Purpose: Sets length units in which value for dimension presentation is displayed.
SetDimAngleDisplayUnits (me: mutable; theUnits : AsciiString from TCollection) is redefined static;
---Purpose: Sets angle units in which value for dimension presentation is displayed.
DimLengthDisplayUnits (me) returns AsciiString from TCollection is redefined static;
---Purpose: Returns length units in which dimension presentation is displayed.
---C++: return const &
DimAngleDisplayUnits (me) returns AsciiString from TCollection is redefined static;
---Purpose: Returns angle units in which dimension presentation is displayed.
---C++: return const &
HasDimensionAspect (me) returns Boolean from Standard
---C++: inline
---Purpose: Returns true if the Drawer has a dimension aspect setting active.
is static;
-- Attributes for the sections
SectionAspect (me:mutable) returns mutable LineAspect from Prs3d
@@ -593,25 +622,32 @@ is
-- for Interactive Objects.
fields
myLink : Drawer from Prs3d;
hasLocalAttributes : Boolean from Standard;
myhasOwnDeviationCoefficient : Boolean from Standard;
myOwnDeviationCoefficient : Real from Standard;
myPreviousDeviationCoefficient : Real from Standard;
myhasOwnHLRDeviationCoefficient : Boolean from Standard;
myOwnHLRDeviationCoefficient : Real from Standard;
myPreviousHLRDeviationCoefficient: Real from Standard;
myhasOwnDeviationAngle : Boolean from Standard;
myOwnDeviationAngle : Real from Standard;
myPreviousDeviationAngle : Real from Standard;
myhasOwnHLRDeviationAngle : Boolean from Standard;
myOwnHLRDeviationAngle : Real from Standard;
myPreviousHLRDeviationAngle : Real from Standard;
myHasOwnFaceBoundaryDraw : Boolean from Standard;
myHasOwnDimLengthModelUnits : Boolean from Standard;
myHasOwnDimLengthDisplayUnits : Boolean from Standard;
myHasOwnDimAngleModelUnits : Boolean from Standard;
myHasOwnDimAngleDisplayUnits : Boolean from Standard;
end Drawer;

View File

@@ -19,21 +19,24 @@
#include <AIS_Drawer.ixx>
#include <Standard_ProgramError.hxx>
AIS_Drawer::AIS_Drawer():
myLink(new Prs3d_Drawer()),
hasLocalAttributes(Standard_False),
myhasOwnDeviationCoefficient(Standard_False),
myPreviousDeviationCoefficient(0.1),
myhasOwnHLRDeviationCoefficient (Standard_False),
myhasOwnDeviationAngle (Standard_False),
myhasOwnHLRDeviationAngle (Standard_False),
myHasOwnFaceBoundaryDraw (Standard_False)
// =======================================================================
// function : AIS_Drawer
// purpose :
// =======================================================================
AIS_Drawer::AIS_Drawer()
: myLink (new Prs3d_Drawer()),
hasLocalAttributes (Standard_False),
myhasOwnDeviationCoefficient (Standard_False),
myPreviousDeviationCoefficient (0.1),
myhasOwnHLRDeviationCoefficient (Standard_False),
myhasOwnDeviationAngle (Standard_False),
myhasOwnHLRDeviationAngle (Standard_False),
myHasOwnFaceBoundaryDraw (Standard_False)
{
SetMaximalParameterValue(500000.);
myLink->SetMaximalParameterValue(500000.);
SetMaximalParameterValue (500000.0);
myLink->SetMaximalParameterValue (500000.0);
SetTypeOfHLR (Prs3d_TOH_NotSet);
}
}
Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
{
@@ -216,8 +219,97 @@ Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
{return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect ()
{return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect ;}
// =======================================================================
// function : DimensionAspect
// purpose :
// =======================================================================
Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect()
{
return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect;
}
// =======================================================================
// function : DimAngleModelUnits
// purpose :
// =======================================================================
const TCollection_AsciiString& AIS_Drawer::DimAngleModelUnits() const
{
return myHasOwnDimAngleModelUnits
? Prs3d_Drawer::DimAngleModelUnits()
: myLink->DimAngleModelUnits();
}
// =======================================================================
// function : DimensionModelUnits
// purpose :
// =======================================================================
const TCollection_AsciiString& AIS_Drawer::DimLengthModelUnits() const
{
return myHasOwnDimLengthModelUnits
? Prs3d_Drawer::DimLengthModelUnits()
: myLink->DimLengthModelUnits();
}
// =======================================================================
// function : SetDimLengthModelUnits
// purpose :
// =======================================================================
void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
{
myHasOwnDimLengthModelUnits = Standard_True;
Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
}
// =======================================================================
// function : SetDimAngleModelUnits
// purpose :
// =======================================================================
void AIS_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
{
myHasOwnDimAngleModelUnits = Standard_True;
Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
}
// =======================================================================
// function : DimAngleDisplayUnits
// purpose :
// =======================================================================
const TCollection_AsciiString& AIS_Drawer::DimAngleDisplayUnits() const
{
return myHasOwnDimAngleDisplayUnits
? Prs3d_Drawer::DimAngleDisplayUnits()
: myLink->DimAngleDisplayUnits();
}
// =======================================================================
// function : DimLengthDisplayUnits
// purpose :
// =======================================================================
const TCollection_AsciiString& AIS_Drawer::DimLengthDisplayUnits() const
{
return myHasOwnDimLengthDisplayUnits
? Prs3d_Drawer::DimLengthDisplayUnits()
: myLink->DimLengthDisplayUnits();
}
// =======================================================================
// function : SetDimLengthDisplayUnits
// purpose :
// =======================================================================
void AIS_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
{
myHasOwnDimLengthDisplayUnits = Standard_True;
Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
}
// =======================================================================
// function : SetDimAngleDisplayUnits
// purpose :
// =======================================================================
void AIS_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
{
myHasOwnDimAngleDisplayUnits = Standard_True;
Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
}
Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
{return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
@@ -256,6 +348,10 @@ void AIS_Drawer::ClearLocalAttributes()
if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify();
myHasOwnFaceBoundaryDraw = Standard_False;
myHasOwnDimLengthModelUnits = Standard_False;
myHasOwnDimLengthDisplayUnits = Standard_False;
myHasOwnDimAngleModelUnits = Standard_False;
myHasOwnDimAngleDisplayUnits = Standard_False;
hasLocalAttributes = Standard_False;

View File

@@ -104,5 +104,7 @@ inline Prs3d_TypeOfHLR AIS_Drawer::TypeOfHLR ( ) const
return (myTypeOfHLR == Prs3d_TOH_NotSet) ? myLink->TypeOfHLR() : myTypeOfHLR;
}
inline Standard_Boolean AIS_Drawer::HasDimensionAspect () const
{ return !myDimensionAspect.IsNull();}
inline Standard_Boolean AIS_Drawer::HasDimensionAspect() const
{
return !myDimensionAspect.IsNull();
}

File diff suppressed because it is too large Load Diff

View File

@@ -58,69 +58,217 @@ class Handle(Standard_Type);
class Handle(AIS_Relation);
class AIS_LengthDimension;
DEFINE_STANDARD_HANDLE(AIS_LengthDimension,AIS_Dimension)
DEFINE_STANDARD_HANDLE (AIS_LengthDimension, AIS_Dimension)
//! A dimension to display lengths. <br>
//! These can be lengths along a face or edge, or <br>
//! between two faces or two edges.
//! Length dimension. Can be constructued:
//! - Between two generic points.
//! - Between two vertices.
//! - Between two faces.
//! - Between two parallel edges.
//! - Between face and edge.
//!
//! In case of two points (vertices) or one linear edge the user-defined plane
//! that includes this geometry is necessary to be set.
//!
//! In case of face-edge, edge-vertex or face-face lengthes the automatic plane
//! computing is allowed. For this plane the third point is found on the
//! edge or on the face.
//!
//! Please note that if the inappropriate geometry is defined
//! or the distance between measured points is less than
//! Precision::Confusion(), the dimension is invalid and its
//! presentation can not be computed.
class AIS_LengthDimension : public AIS_Dimension
{
public:
Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pln& theDimensionPlane);
//! Constructs a length dimension between two shapes(vertices, edges, shapes) with custom working plane
Standard_EXPORT AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
const TopoDS_Shape& theSecondShape,
const gp_Pln& theWorkingPlane);
Standard_EXPORT AIS_LengthDimension (const TopoDS_Edge& theEdge,
const gp_Pln& theWorkingPlane);
Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace);
//! Construct length dimension between face and edge.
//! Here dimension can be built without user-defined plane.
//! @param theFace [in] the face (first shape).
//! @param theEdge [in] the edge (second shape).
Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge);
public:
//! Construct length dimension between two faces.
//! @param theFirstFace [in] the first face (first shape).
//! @param theSecondFace [in] the second face (second shape).
Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace);
//! Construct length dimension between two points in
//! the specified plane.
//! @param theFirstPoint [in] the first point.
//! @param theSecondPoint [in] the second point.
//! @param thePlane [in] the plane to orient dimension.
Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pln& thePlane);
//! Construct length dimension between two arbitrary shapes in
//! the specified plane.
//! @param theFirstShape [in] the first shape.
//! @param theSecondShape [in] the second shape.
//! @param thePlane [in] the plane to orient dimension.
Standard_EXPORT AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
const TopoDS_Shape& theSecondShape,
const gp_Pln& thePlane);
//! Construct length dimension of linear edge.
//! @param theEdge [in] the edge to measure.
//! @param thePlane [in] the plane to orient dimension.
Standard_EXPORT AIS_LengthDimension (const TopoDS_Edge& theEdge,
const gp_Pln& thePlane);
public:
//! @return first attachement point.
const gp_Pnt& FirstPoint() const
{
return myFirstPoint;
}
//! @return second attachement point.
const gp_Pnt& SecondPoint() const
{
return mySecondPoint;
}
//! @return first attachement shape.
const TopoDS_Shape& FirstShape() const
{
return myFirstShape;
}
//! @return second attachement shape.
const TopoDS_Shape& SecondShape() const
{
return mySecondShape;
}
public:
//! Measure distance between two points.
//! The dimension will become invalid if the new distance between
//! attachement points is less than Precision::Confusion().
//! @param theFirstPoint [in] the first point.
//! @param theSecondPoint [in] the second point.
//! @param thePlane [in] the user-defined plane
Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pln& thePlane);
//! Measure length of edge.
//! The dimension will become invalid if the new length of edge
//! is less than Precision::Confusion().
//! @param theEdge [in] the edge to measure.
//! @param thePlane [in] the user-defined plane
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theEdge,
const gp_Pln& thePlane);
//! Measure distance between two faces.
//! The dimension will become invalid if the distance can not
//! be measured or it is less than Precision::Confusion().
//! @param theFirstFace [in] the first face (first shape).
//! @param theSecondFace [in] the second face (second shape).
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace);
//! Measure distance between face and edge.
//! The dimension will become invalid if the distance can not
//! be measured or it is less than Precision::Confusion().
//! @param theFace [in] the face (first shape).
//! @param theEdge [in] the edge (second shape).
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge);
//! Measure distance between generic pair of shapes (edges, vertices, length),
//! where measuring is applicable.
//! @param theFirstShape [in] the first shape.
//! @param theSecondShape [in] the second shape.
Standard_EXPORT void SetMeasuredShapes (const TopoDS_Shape& theFirstShape,
const TopoDS_Shape& theSecondShape);
//! @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);
public:
DEFINE_STANDARD_RTTI(AIS_LengthDimension)
protected:
//! Checks if the plane includes first and second points to build dimension.
Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
Standard_EXPORT virtual gp_Pln ComputePlane(const gp_Dir& theAttachDir) const;
Standard_EXPORT Standard_Real ComputeValue() const;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(SelectMgr_EntityOwner)& theEntityOwner);
protected:
//! Checks that distance between two points is valid.
//! @param theFirstPoint [in] the first point.
//! @param theSecondPoint [in] the second point.
Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint) const;
Standard_EXPORT Standard_Boolean InitTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
const TopoDS_Edge& theSecondEdge,
gp_Dir& theEdgeDir);
//! Auxiliary method for InitTwoShapesPoints()
//! in case of the distance between edge and vertex.
//! Finds the point on the edge that is the closest one to <theVertex>.
//! @param theEdgeDir [out] is the direction on the edge to build
//! automatical plane.
Standard_EXPORT Standard_Boolean InitEdgeVertexLength (const TopoDS_Edge& theEdge,
const TopoDS_Vertex& theVertex,
gp_Dir& theEdgeDir,
Standard_Boolean isInfinite);
//! Auxiliary method for InitTwoShapesPoints()
//! in case of the distance between face and edge.
//! The first attachment point is first parameter point from <theEdge>.
//! Find the second attachment point which belongs to <theFace>
//! Iterate over the edges of the face and find the closest point according
//! to finded point on edge.
//! @param theEdgeDir [out] is the direction on the edge to build
//! automatical plane.
Standard_EXPORT Standard_Boolean InitEdgeFaceLength (const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
gp_Dir& theEdgeDir);
//! Initialization of two attach points in case of two owner shapes.
Standard_EXPORT Standard_Boolean InitTwoShapesPoints (const TopoDS_Shape& theFirstShape,
const TopoDS_Shape& theSecondShape,
gp_Pln& theComputedPlane,
Standard_Boolean& theIsPlaneComputed);
//! Initialization of two attach points in case of one owner shape.
Standard_EXPORT Standard_Boolean InitOneShapePoints (const TopoDS_Shape& theShape);
private:
Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
const TopoDS_Edge& theSecondEdge,
gp_Dir& theDirAttach);
//! Auxiliary method for <InitTwoShapesPoints()>
//! in case of the distance between edge and vertex
Standard_Boolean initEdgeVertexLength (const TopoDS_Edge & theEdge,
const TopoDS_Vertex & theVertex,
gp_Dir & theDirAttach,
Standard_Boolean isInfinite);
//! Auxiliary method for <InitTwoShapesPoints()>
//! in case of the distance between face and edge
Standard_Boolean initEdgeFaceLength (const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
gp_Dir& theDirAttach);
//! Initialization of two attach points in case of two owner shapes
Standard_Boolean initTwoShapesPoints (const TopoDS_Shape& theFirstShape,
const TopoDS_Shape& theSecondShape);
//! Initialization of two attach points in case of one owner shape
Standard_Boolean initOneShapePoints (const TopoDS_Shape& theShape);
//! Compute length in display units.
virtual void computeValue();
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0) ;
gp_Pnt myFirstPoint;
gp_Pnt mySecondPoint;
TopoDS_Shape myFirstShape;
TopoDS_Shape mySecondShape;
};
#endif
#endif // _AIS_LengthDimension_HeaderFile

View File

@@ -21,32 +21,28 @@
#include <AIS_RadiusDimension.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <ElCLib.hxx>
#include <gce_MakeDir.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_Group.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Prs3d_Root.hxx>
IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension)
IMPLEMENT_STANDARD_HANDLE (AIS_RadiusDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT (AIS_RadiusDimension, AIS_Dimension)
namespace
{
static const Standard_ExtCharacter THE_RADIUS_SYMBOL ('R');
};
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle)
: AIS_Dimension(),
myCircle (theCircle)
: AIS_Dimension (AIS_KOD_RADIUS)
{
myFirstPoint = ElCLib::Value(0, myCircle);
mySecondPoint = theCircle.Location();
myIsInitialized = Standard_True;
SetSpecialSymbol ('R');
SetMeasuredGeometry (theCircle);
SetSpecialSymbol (THE_RADIUS_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
SetKindOfDimension (AIS_KOD_RADIUS);
SetFlyout (0.0);
}
@@ -54,18 +50,13 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle)
//function : Constructor
//purpose :
//=======================================================================
AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
const gp_Pnt& theAttachPoint)
: AIS_Dimension(),
myCircle (theCircle)
: AIS_Dimension (AIS_KOD_RADIUS)
{
myFirstPoint = theAttachPoint;
mySecondPoint = theCircle.Location();
myIsInitialized = Standard_True;
SetSpecialSymbol ('R');
SetMeasuredGeometry (theCircle, theAttachPoint);
SetSpecialSymbol (THE_RADIUS_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
SetKindOfDimension (AIS_KOD_RADIUS);
SetFlyout (0.0);
}
@@ -73,23 +64,170 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
//function : Constructor
//purpose :
//=======================================================================
AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
: AIS_Dimension ()
: AIS_Dimension (AIS_KOD_RADIUS)
{
myFirstShape = theShape;
myIsInitialized = Standard_False;
SetSpecialSymbol ('R');
SetMeasuredGeometry (theShape);
SetSpecialSymbol (THE_RADIUS_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
SetKindOfDimension (AIS_KOD_RADIUS);
SetFlyout (0.0);
}
//=======================================================================
//function : SetMeasuredGeometry
//purpose :
//=======================================================================
void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
{
myCircle = theCircle;
myGeometryType = GeometryType_Edge;
myShape = BRepLib_MakeEdge (theCircle);
myAnchorPoint = ElCLib::Value (0, myCircle);
myIsValid = IsValidCircle (myCircle);
if (myIsValid)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
//=======================================================================
//function : SetMeasuredGeometry
//purpose :
//=======================================================================
void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle,
const gp_Pnt& theAnchorPoint)
{
myCircle = theCircle;
myGeometryType = GeometryType_Edge;
myShape = BRepLib_MakeEdge (theCircle);
myAnchorPoint = theAnchorPoint;
myIsValid = IsValidCircle (myCircle) && IsValidAnchor (myCircle, theAnchorPoint);
if (myIsValid)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
//=======================================================================
//function : SetMeasuredGeometry
//purpose :
//=======================================================================
void AIS_RadiusDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape)
{
Standard_Boolean isClosed = Standard_False;
myShape = theShape;
myGeometryType = GeometryType_UndefShapes;
myIsValid = InitCircularDimension (theShape, myCircle, myAnchorPoint, isClosed)
&& IsValidCircle (myCircle);
if (myIsValid)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
//=======================================================================
//function : CheckPlane
//purpose :
//=======================================================================
Standard_Boolean AIS_RadiusDimension::CheckPlane (const gp_Pln& thePlane) const
{
// Check if anchor point and circle center point belong to plane.
if (!thePlane.Contains (myAnchorPoint, Precision::Confusion()) &&
!thePlane.Contains (myCircle.Location(), Precision::Confusion()))
{
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : ComputePlane
//purpose :
//=======================================================================
void AIS_RadiusDimension::ComputePlane()
{
if (!IsValid())
{
return;
}
gp_Dir aDimensionX = gce_MakeDir (myAnchorPoint, myCircle.Location());
myPlane = gp_Pln (gp_Ax3 (myCircle.Location(),
myCircle.Axis().Direction(),
aDimensionX));
}
//=======================================================================
//function : GetModelUnits
//purpose :
//=======================================================================
const TCollection_AsciiString& AIS_RadiusDimension::GetModelUnits() const
{
return myDrawer->DimLengthModelUnits();
}
//=======================================================================
//function : GetDisplayUnits
//purpose :
//=======================================================================
const TCollection_AsciiString& AIS_RadiusDimension::GetDisplayUnits() const
{
return myDrawer->DimLengthDisplayUnits();
}
//=======================================================================
//function : SetModelUnits
//purpose :
//=======================================================================
void AIS_RadiusDimension::SetModelUnits (const TCollection_AsciiString& theUnits)
{
myDrawer->SetDimLengthModelUnits (theUnits);
}
//=======================================================================
//function : SetDisplayUnits
//purpose :
//=======================================================================
void AIS_RadiusDimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
{
myDrawer->SetDimLengthDisplayUnits(theUnits);
}
//=======================================================================
//function : ComputeValue
//purpose :
//=======================================================================
Standard_Real AIS_RadiusDimension::ComputeValue() const
{
if (!IsValid())
{
return 0.0;
}
return myCircle.Radius();
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
@@ -97,52 +235,34 @@ void AIS_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
thePresentation->Clear();
mySelectionGeom.Clear (theMode);
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
if (!myIsInitialized)
if (!IsValid())
{
gp_Pnt aLastPoint;
if (!initCircularDimension (myFirstShape, myCircle,
myFirstPoint, aLastPoint))
return;
else
{
mySecondPoint = myCircle.Location();
myIsInitialized = Standard_True;
}
return;
}
if (!myIsWorkingPlaneCustom)
{
countDefaultPlane();
}
drawLinearDimension (thePresentation, theMode, Standard_True);
DrawLinearDimension (thePresentation, theMode, myAnchorPoint, myCircle.Location(), Standard_True);
}
//=======================================================================
//function : computeValue
//function : IsValidCircle
//purpose :
//=======================================================================
void AIS_RadiusDimension::computeValue ()
Standard_Boolean AIS_RadiusDimension::IsValidCircle (const gp_Circ& theCircle) const
{
myValue = myFirstPoint.Distance (mySecondPoint);
AIS_Dimension::computeValue ();
return theCircle.Radius() > Precision::Confusion();
}
//=======================================================================
//function : countDefaultPlane
//function : IsValidAnchor
//purpose :
//=======================================================================
void AIS_RadiusDimension::countDefaultPlane ()
Standard_Boolean AIS_RadiusDimension::IsValidAnchor (const gp_Circ& theCircle,
const gp_Pnt& theAnchor) const
{
// Compute normal of the default plane.
gp_Vec aVec1(mySecondPoint, myFirstPoint),
aVec2(mySecondPoint, ElCLib::Value(M_PI_2, myCircle));
myDefaultPlane = gp_Pln(myCircle.Location(), aVec1^aVec2);
// Set computed value to <myWorkingPlane>
ResetWorkingPlane ();
gp_Pln aCirclePlane (theCircle.Location(), theCircle.Axis().Direction());
Standard_Real anAnchorDist = theAnchor.Distance (theCircle.Location());
Standard_Real aRadius = myCircle.Radius();
return Abs (anAnchorDist - aRadius) > Precision::Confusion()
&& aCirclePlane.Contains (theAnchor, Precision::Confusion());
}

View File

@@ -16,63 +16,134 @@
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//! A framework to define display of radii. <br>
//! These displays serve as relational references in 3D <br>
//! presentations of surfaces, and are particularly useful <br>
//! in viewing fillets. The display consists of arrows and <br>
//! text giving the length of a radius. This display is <br>
//! recalculated if the applicative owner shape changes <br>
//! in dimension, and the text gives the modified length. <br>
//! The algorithm analyzes a length along a face as an <br>
//! arc. It then reconstructs the circle corresponding to <br>
//! the arc and calculates the radius of this circle. <br>
#ifndef _AIS_RadiusDimension_HeaderFile
#define _AIS_RadiusDimension_HeaderFile
#include <AIS.hxx>
#include <AIS_Dimension.hxx>
#include <gp_Circ.hxx>
#include <gp_Pnt.hxx>
#include <Prs3d_DimensionAspect.hxx>
#include <gp_Circ.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
#include <TopoDS_Shape.hxx>
DEFINE_STANDARD_HANDLE(AIS_RadiusDimension,AIS_Dimension)
DEFINE_STANDARD_HANDLE (AIS_RadiusDimension,AIS_Dimension)
//! Radius dimension. Can be constructued:
//! - On generic circle.
//! - On generic circle with user-defined anchor point on that circle.
//! - On generic shape containing geometry that can be measured
//! by diameter dimension: circle wire, arc, circular face, etc.
//! The anchor point is the location of left attachement point of
//! dimension on the circle. It can be user-specified, or computed as
//! middle point on the arc. The radius dimension always lies in the
//! plane of the measured circle. The dimension is considered as
//! invalid if the user-specified anchor point is not lying on the circle,
//! if the radius of the circle is less than Precision::Confusion().
//! In case if the dimension is built on the arbitrary shape,
//! it can be considered as invalid if the shape does not contain
//! circle geometry.
class AIS_RadiusDimension : public AIS_Dimension
{
public:
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle);
//! Create radius dimension for the circle geometry.
//! @param theCircle [in] the circle to measure.
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle);
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
const gp_Pnt& theAttachPoint);
//! Create radius dimension for the circle geometry and define its
//! orientation by location of the first point on that circle.
//! @param theCircle [in] the circle to measure.
//! @param theAnchorPoint [in] the point to define the position
//! of the dimension attachement on the circle.
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
const gp_Pnt& theAnchorPoint);
//! Constructs the radius display object defined by the <br>
//! shape aShape, the dimension aVal, and the text aText.
Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& aShape);
//! Create radius dimension for the arbitrary shape (if possible).
//! @param theShape [in] the shape to measure.
Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& theShape);
DEFINE_STANDARD_RTTI(AIS_RadiusDimension)
public:
//! @return measured geometry circle.
const gp_Circ& Circle() const
{
return myCircle;
}
//! @return anchor point on circle for radius dimension.
const gp_Pnt& AnchorPoint() const
{
return myAnchorPoint;
}
//! @return the measured shape.
const TopoDS_Shape& Shape() const
{
return myShape;
}
public:
//! Measure radius of the circle.
//! The dimension will become invalid if the radius of the circle
//! is less than Precision::Confusion().
//! @param theCircle [in] the circle to measure.
Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
//! Measure radius of the circle and orient the dimension so
//! the dimension lines attaches to anchor point on the circle.
//! The dimension will become invalid if the radiuss of the circle
//! is less than Precision::Confusion().
//! @param theCircle [in] the circle to measure.
//! @param theAnchorPoint [in] the point to attach the dimension lines.
Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle,
const gp_Pnt& theAnchorPoint);
//! Measure radius on the passed shape, if applicable.
//! The dimension will become invalid if the passed shape is not
//! measurable or if measured diameter value is less than Precision::Confusion().
//! @param theShape [in] the shape to measure.
Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape);
//! @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);
public:
DEFINE_STANDARD_RTTI (AIS_RadiusDimension)
protected:
//! Computes dimension value in display units
Standard_EXPORT virtual void computeValue ();
Standard_EXPORT virtual void ComputePlane();
//! Fills default plane object if it is possible to count plane automatically.
Standard_EXPORT virtual void countDefaultPlane ();
//! Checks if anchor point and the center of the circle are on the plane.
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)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
protected:
Standard_EXPORT Standard_Boolean IsValidCircle (const gp_Circ& theCircle) const;
Standard_EXPORT Standard_Boolean IsValidAnchor (const gp_Circ& theCircle,
const gp_Pnt& thePnt) const;
private:
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
// Fields
private:
gp_Circ myCircle;
gp_Circ myCircle;
gp_Pnt myAnchorPoint;
TopoDS_Shape myShape;
};
#endif
#endif // _AIS_RadiusDimension_HeaderFile