1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0024668: Null flyout value case in AIS_Dimension::SetTextPosition() method is not considered.

Corrected checks of working plane and dimension geometry.

Corrected remarks: IsComputed flag was added to the SelectionGeometry to check if it is filled; AdjustParameters() methods became const ones.

minor remark
This commit is contained in:
aba 2014-03-20 13:44:02 +04:00 committed by abv
parent c69d58d816
commit b0e6ae72af
7 changed files with 173 additions and 172 deletions

View File

@ -145,19 +145,17 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge,
{
gp_Pln aComputedPlane;
myFirstShape = theFirstEdge;
mySecondShape = theSecondEdge;
myThirdShape = TopoDS_Shape();
myGeometryType = GeometryType_Edges;
myIsValid = InitTwoEdgesAngle (aComputedPlane);
myFirstShape = theFirstEdge;
mySecondShape = theSecondEdge;
myThirdShape = TopoDS_Shape();
myGeometryType = GeometryType_Edges;
myIsGeometryValid = InitTwoEdgesAngle (aComputedPlane);
if (myIsValid && !myIsPlaneCustom)
if (myIsGeometryValid && !myIsPlaneCustom)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -176,15 +174,13 @@ void AIS_AngleDimension::SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
mySecondShape = BRepLib_MakeVertex (myCenterPoint);
myThirdShape = BRepLib_MakeVertex (mySecondPoint);
myGeometryType = GeometryType_Points;
myIsValid = IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
myIsGeometryValid = IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
if (myIsValid && !myIsPlaneCustom)
if (myIsGeometryValid && !myIsPlaneCustom)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -196,22 +192,20 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Vertex& theFirstVerte
const TopoDS_Vertex& theSecondVertex,
const TopoDS_Vertex& theThirdVertex)
{
myFirstShape = theFirstVertex;
mySecondShape = theSecondVertex;
myThirdShape = theThirdVertex;
myFirstPoint = BRep_Tool::Pnt (theFirstVertex);
myCenterPoint = BRep_Tool::Pnt (theSecondVertex);
mySecondPoint = BRep_Tool::Pnt (theThirdVertex);
myGeometryType = GeometryType_Points;
myIsValid = IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
myFirstShape = theFirstVertex;
mySecondShape = theSecondVertex;
myThirdShape = theThirdVertex;
myFirstPoint = BRep_Tool::Pnt (theFirstVertex);
myCenterPoint = BRep_Tool::Pnt (theSecondVertex);
mySecondPoint = BRep_Tool::Pnt (theThirdVertex);
myGeometryType = GeometryType_Points;
myIsGeometryValid = IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
if (myIsValid && !myIsPlaneCustom)
if (myIsGeometryValid && !myIsPlaneCustom)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -221,19 +215,17 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Vertex& theFirstVerte
//=======================================================================
void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theCone)
{
myFirstShape = theCone;
mySecondShape = TopoDS_Shape();
myThirdShape = TopoDS_Shape();
myGeometryType = GeometryType_Face;
myIsValid = InitConeAngle();
myFirstShape = theCone;
mySecondShape = TopoDS_Shape();
myThirdShape = TopoDS_Shape();
myGeometryType = GeometryType_Face;
myIsGeometryValid = InitConeAngle();
if (myIsValid && !myIsPlaneCustom)
if (myIsGeometryValid && !myIsPlaneCustom)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -244,19 +236,17 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theCone)
void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace)
{
myFirstShape = theFirstFace;
mySecondShape = theSecondFace;
myThirdShape = TopoDS_Shape();
myGeometryType = GeometryType_Faces;
myIsValid = InitTwoFacesAngle();
myFirstShape = theFirstFace;
mySecondShape = theSecondFace;
myThirdShape = TopoDS_Shape();
myGeometryType = GeometryType_Faces;
myIsGeometryValid = InitTwoFacesAngle();
if (myIsValid && !myIsPlaneCustom)
if (myIsGeometryValid && !myIsPlaneCustom)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -268,19 +258,17 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace,
const gp_Pnt& thePoint)
{
myFirstShape = theFirstFace;
mySecondShape = theSecondFace;
myThirdShape = TopoDS_Shape();
myGeometryType = GeometryType_Faces;
myIsValid = InitTwoFacesAngle (thePoint);
myFirstShape = theFirstFace;
mySecondShape = theSecondFace;
myThirdShape = TopoDS_Shape();
myGeometryType = GeometryType_Faces;
myIsGeometryValid = InitTwoFacesAngle (thePoint);
if (myIsValid && !myIsPlaneCustom)
if (myIsGeometryValid && !myIsPlaneCustom)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -518,7 +506,7 @@ Standard_Boolean AIS_AngleDimension::CheckPlane (const gp_Pln& thePlane)const
//=======================================================================
void AIS_AngleDimension::ComputePlane()
{
if (!IsValid())
if (!myIsGeometryValid)
{
return;
}
@ -626,7 +614,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
if (IsTextPositionCustom())
{
AdjustParameters (myFixedTextPosition,anExtensionSize, aHorisontalTextPos);
AdjustParameters (myFixedTextPosition,anExtensionSize, aHorisontalTextPos, myFlyout);
}
// Handle user-defined and automatic arrow placement
@ -810,7 +798,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
}
myIsComputed = Standard_True;
mySelectionGeom.IsComputed = Standard_True;
}
//=======================================================================
@ -1243,12 +1231,13 @@ void AIS_AngleDimension::SetTextPosition (const gp_Pnt& theTextPos)
}
//=======================================================================
//function : AdjustAspectParameters
//function : AdjustParameters
//purpose :
//=======================================================================
void AIS_AngleDimension::AdjustParameters (const gp_Pnt& theTextPos,
Standard_Real& theExtensionSize,
Prs3d_DimensionTextHorizontalPosition& theAlignment)
Prs3d_DimensionTextHorizontalPosition& theAlignment,
Standard_Real& theFlyout) const
{
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
@ -1290,9 +1279,7 @@ void AIS_AngleDimension::AdjustParameters (const gp_Pnt& theTextPos,
// Horizontal center
if (aTextPar > aParamBeg && aTextPar < aParamEnd)
{
myFlyout = aRadius;
SetToUpdate();
theFlyout = aRadius;
return;
}
@ -1302,9 +1289,7 @@ void AIS_AngleDimension::AdjustParameters (const gp_Pnt& theTextPos,
if (aTextPar > aParamBeg && aTextPar < aParamEnd)
{
myFlyout = -aRadius;
SetToUpdate();
theFlyout = -aRadius;
return;
}
@ -1326,7 +1311,7 @@ void AIS_AngleDimension::AdjustParameters (const gp_Pnt& theTextPos,
gp_Vec aPosFlyoutDir = gp_Vec (myCenterPoint, myFirstPoint).Normalized().Scaled (aRadius);
myFlyout = aFirstTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()
theFlyout = aFirstTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()
? -aRadius : aRadius;
}
else
@ -1341,7 +1326,7 @@ void AIS_AngleDimension::AdjustParameters (const gp_Pnt& theTextPos,
gp_Vec aPosFlyoutDir = gp_Vec (myCenterPoint, mySecondPoint).Normalized().Scaled (aRadius);
myFlyout = aSecondTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()
theFlyout = aSecondTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()
? -aRadius : aRadius;
}
}

View File

@ -272,13 +272,14 @@ protected:
//! Adjusts aspect parameters according the text position:
//! extension size, vertical text alignment and flyout.
//! It changes flyout of the dimension.
//! @param theTextPos [in] the user defined 3d point of text position.
//! @param theExtensionSize [out] the adjusted extension size.
//! @param theAlignment [out] the horizontal label alignment.
//! @param theFlyout [out] the adjusted value of flyout.
Standard_EXPORT void AdjustParameters (const gp_Pnt& theTextPos,
Standard_Real& theExtensionSize,
Prs3d_DimensionTextHorizontalPosition& theAlignment);
Prs3d_DimensionTextHorizontalPosition& theAlignment,
Standard_Real& theFlyout) const;
protected:

View File

@ -109,13 +109,13 @@ gp_Pnt AIS_DiameterDimension::AnchorPoint()
//=======================================================================
void AIS_DiameterDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
{
myCircle = theCircle;
myGeometryType = GeometryType_Edge;
myShape = BRepLib_MakeEdge (theCircle);
myAnchorPoint = gp::Origin();
myIsValid = IsValidCircle (myCircle);
myCircle = theCircle;
myGeometryType = GeometryType_Edge;
myShape = BRepLib_MakeEdge (theCircle);
myAnchorPoint = gp::Origin();
myIsGeometryValid = IsValidCircle (myCircle);
if (myIsValid && myIsPlaneCustom)
if (myIsGeometryValid && myIsPlaneCustom)
{
ComputeAnchorPoint();
}
@ -125,8 +125,6 @@ void AIS_DiameterDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
myAnchorPoint = ElCLib::Value (0.0, myCircle);
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -139,14 +137,14 @@ 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;
myGeometryType = GeometryType_UndefShapes;
myShape = theShape;
myAnchorPoint = gp::Origin();
myIsGeometryValid = InitCircularDimension (theShape, myCircle, aDummyPnt, isClosed)
&& IsValidCircle (myCircle)
&& isClosed;
if (myIsValid && myIsPlaneCustom)
if (myIsGeometryValid && myIsPlaneCustom)
{
ComputeAnchorPoint();
}
@ -156,8 +154,6 @@ void AIS_DiameterDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape)
myAnchorPoint = ElCLib::Value (0.0, myCircle);
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -182,7 +178,7 @@ Standard_Boolean AIS_DiameterDimension::CheckPlane (const gp_Pln& thePlane) cons
//=======================================================================
void AIS_DiameterDimension::ComputePlane()
{
if (!IsValid())
if (!myIsGeometryValid)
{
return;
}
@ -202,7 +198,7 @@ void AIS_DiameterDimension::ComputeAnchorPoint()
GeomAPI_IntCS anIntersector (aCircle, aPlane);
if (!anIntersector.IsDone())
{
myIsValid = Standard_False;
myIsGeometryValid = Standard_False;
return;
}
@ -210,7 +206,7 @@ void AIS_DiameterDimension::ComputeAnchorPoint()
if (anIntersector.NbPoints() != 2)
{
myAnchorPoint = ElCLib::Value (0.0, myCircle);
myIsValid = Standard_True;
myIsGeometryValid = Standard_True;
return;
}
@ -379,7 +375,7 @@ const gp_Pnt AIS_DiameterDimension::GetTextPosition() const
//=======================================================================
void AIS_DiameterDimension::SetTextPosition (const gp_Pnt& theTextPos)
{
if (!myIsValid)
if (!IsValid())
{
return;
}

View File

@ -106,7 +106,7 @@ AIS_Dimension::AIS_Dimension (const AIS_KindOfDimension theType)
myGeometryType (GeometryType_UndefShapes),
myIsPlaneCustom (Standard_False),
myFlyout (0.0),
myIsValid (Standard_False),
myIsGeometryValid (Standard_False),
myKindOfDimension (theType)
{
}
@ -156,13 +156,12 @@ void AIS_Dimension::SetCustomPlane (const gp_Pln& thePlane)
myPlane = thePlane;
myIsPlaneCustom = Standard_True;
// Disable fixed text position
// Disable fixed (custom) text position
UnsetFixedTextPosition();
// Check validity if geometry has been set already.
if (myIsValid)
if (IsValid())
{
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
}
@ -650,9 +649,11 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
Prs3d_DimensionTextHorizontalPosition aHorisontalTextPos = aDimensionAspect->TextHorizontalPosition();
if (IsTextPositionCustom())
{
AdjustParametersForLinear (myFixedTextPosition, theFirstPoint, theSecondPoint,
anExtensionSize, aHorisontalTextPos);
if (!AdjustParametersForLinear (myFixedTextPosition, theFirstPoint, theSecondPoint,
anExtensionSize, aHorisontalTextPos, myFlyout, myPlane, myIsPlaneCustom))
{
Standard_ProgramError::Raise ("Can not adjust plane to the custom label position.");
}
}
FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, aHorisontalTextPos,
@ -961,7 +962,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
}
myIsComputed = Standard_True;
mySelectionGeom.IsComputed = Standard_True;
}
//=======================================================================
@ -1187,7 +1188,7 @@ Standard_Boolean AIS_Dimension::InitCircularDimension (const TopoDS_Shape& theSh
void AIS_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
if (!myIsComputed)
if (!mySelectionGeom.IsComputed)
{
return;
}
@ -1350,7 +1351,7 @@ gp_Pnt AIS_Dimension::GetTextPositionForLinear (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const Standard_Boolean theIsOneSide) const
{
if (!myIsValid)
if (!IsValid())
{
return gp::Origin();
}
@ -1418,30 +1419,43 @@ gp_Pnt AIS_Dimension::GetTextPositionForLinear (const gp_Pnt& theFirstPoint,
}
//=======================================================================
//function : AdjustAspectParameters
//function : AdjustParametersForLinear
//purpose :
//=======================================================================
void AIS_Dimension::AdjustParametersForLinear (const gp_Pnt& theTextPos,
const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
Standard_Real& theExtensionSize,
Prs3d_DimensionTextHorizontalPosition& theAlignment)
Standard_Boolean AIS_Dimension::AdjustParametersForLinear (const gp_Pnt& theTextPos,
const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
Standard_Real& theExtensionSize,
Prs3d_DimensionTextHorizontalPosition& theAlignment,
Standard_Real& theFlyout,
gp_Pln& thePlane,
Standard_Boolean& theIsPlaneOld) const
{
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
//Set new automatic plane.
myPlane = gce_MakePln (theTextPos, theFirstPoint, theSecondPoint);
myIsPlaneCustom = Standard_False;
// Compute dimension line points.
gp_Dir aPlaneNormal = GetPlane().Axis().Direction();
gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint);
gp_Vec aTargetPointsVec (theFirstPoint, theSecondPoint);
// Don't set new plane if the text position lies on the attachment points line.
gp_Lin aTargetPointsLin (theFirstPoint, aTargetPointsDir);
if (!aTargetPointsLin.Contains (theTextPos, Precision::Confusion()))
{
//Set new automatic plane.
thePlane = gce_MakePln (theTextPos, theFirstPoint, theSecondPoint);
theIsPlaneOld = Standard_False;
}
// Compute flyout direction vector.
gp_Dir aPlaneNormal = GetPlane().Axis().Direction();
gp_Dir aPositiveFlyout = aPlaneNormal ^ aTargetPointsDir;
// Additional check of collinearity of the plane normal and attachment points vector.
if (aPlaneNormal.IsParallel (aTargetPointsDir, Precision::Angular()))
{
return Standard_False;
}
// Set flyout.
gp_Vec aFirstToTextVec (theFirstPoint, theTextPos);
@ -1453,15 +1467,19 @@ void AIS_Dimension::AdjustParametersForLinear (const gp_Pnt& theTextPos,
// Compute flyout value and direction.
gp_Vec aFlyoutVector = gp_Vec (aTextPosProj, theTextPos);
myFlyout = gp_Dir (aFlyoutVector).IsOpposite (aPositiveFlyout, Precision::Angular())
? -aFlyoutVector.Magnitude()
: aFlyoutVector.Magnitude();
theFlyout = 0.0;
if (aFlyoutVector.Magnitude() > Precision::Confusion())
{
theFlyout = gp_Dir (aFlyoutVector).IsOpposite (aPositiveFlyout, Precision::Angular())
? -aFlyoutVector.Magnitude()
: aFlyoutVector.Magnitude();
}
// Compute attach points (through which main dimension line passes).
gp_Pnt aFirstAttach = theFirstPoint.Translated (aFlyoutVector);
gp_Pnt aSecondAttach = theSecondPoint.Translated (aFlyoutVector);
// Set horisontal text alignment.
// Set horizontal text alignment.
if (aCos < 0.0)
{
theAlignment = Prs3d_DTHP_Left;
@ -1480,6 +1498,7 @@ void AIS_Dimension::AdjustParametersForLinear (const gp_Pnt& theTextPos,
{
theAlignment = Prs3d_DTHP_Center;
}
return Standard_True;
}
//=======================================================================

View File

@ -370,9 +370,9 @@ public:
//! Check that the input geometry for dimension is valid and the
//! presentation can be successfully computed.
//! @return TRUE if dimension geometry is ok.
Standard_Boolean IsValid() const
virtual Standard_Boolean IsValid() const
{
return myIsValid;
return myIsGeometryValid && CheckPlane (GetPlane());
}
public:
@ -506,26 +506,31 @@ protected:
//! @param theIsArrowExternal [out] is the arrows external,
//! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow
//! orientation automatically.
void FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const Standard_Boolean theIsOneSide,
const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
Standard_Integer& theLabelPosition,
Standard_Boolean& theIsArrowsExternal) const;
Standard_EXPORT void FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const Standard_Boolean theIsOneSide,
const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
Standard_Integer& theLabelPosition,
Standard_Boolean& theIsArrowsExternal) const;
//! Adjusts aspect parameters according the text position:
//! extension size, vertical text alignment and flyout.
//! It changes working plane and flyout of linear dimension.
//! @param theTextPos [in] the user defined 3d point of text position
//! @param theFirstPoint [in] the first point of linear measurement.
//! @param theSecondPoint [in] the second point of linear measurement.
//! @param theExtensionSize [out] the adjusted extension size
//! @param theAlignment [out] the horizontal label alignment.
void AdjustParametersForLinear (const gp_Pnt& theTextPos,
const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
Standard_Real& theExtensionSize,
Prs3d_DimensionTextHorizontalPosition& theAlignment);
//! @param theFlyout [out] the adjusted value of flyout.
//! @param thePlane [out] the new plane that contains theTextPos and attachment points.
//! @param theIsPlaneOld [out] shows if new plane is computed.
Standard_EXPORT Standard_Boolean AdjustParametersForLinear (const gp_Pnt& theTextPos,
const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
Standard_Real& theExtensionSize,
Prs3d_DimensionTextHorizontalPosition& theAlignment,
Standard_Real& theFlyout,
gp_Pln& thePlane,
Standard_Boolean& theIsPlaneOld) const;
protected: //! @name Behavior to implement
@ -587,6 +592,7 @@ protected: //! @name Selection geometry
Standard_Real TextHeight; //!< Height of text label.
SeqOfCurves DimensionLine; //!< Sequence of points for composing the segments of dimension line.
SeqOfArrows Arrows; //!< Sequence of arrow geometries.
Standard_Boolean IsComputed; //!< Shows if the selection geometry was filled.
public:
@ -607,6 +613,8 @@ protected: //! @name Selection geometry
TextWidth = 0.0;
TextHeight = 0.0;
}
IsComputed = Standard_False;
}
//! Add new curve entry and return the reference to populate it.
@ -627,7 +635,6 @@ protected: //! @name Selection geometry
} mySelectionGeom;
Standard_Real mySelToleranceForText2d; //!< Sensitive point tolerance for 2d text selection.
Standard_Boolean myIsComputed; //!< Shows if the presentation and selection was computed.
protected: //! @name Value properties
@ -648,10 +655,10 @@ protected: //! @name Geometrical properties
GeometryType myGeometryType; //!< defines type of shapes on which the dimension is to be built.
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.
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 myIsGeometryValid; //!< Is dimension geometry properly defined.
private:

View File

@ -108,13 +108,13 @@ void AIS_LengthDimension::SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pln& thePlane)
{
myFirstPoint = theFirstPoint;
mySecondPoint = theSecondPoint;
myFirstShape = BRepLib_MakeVertex (myFirstPoint);
mySecondShape = BRepLib_MakeVertex (mySecondPoint);
myGeometryType = GeometryType_Points;
myFirstPoint = theFirstPoint;
mySecondPoint = theSecondPoint;
myFirstShape = BRepLib_MakeVertex (myFirstPoint);
mySecondShape = BRepLib_MakeVertex (mySecondPoint);
myGeometryType = GeometryType_Points;
SetCustomPlane (thePlane);
myIsValid = IsValidPoints (theFirstPoint, theSecondPoint) && CheckPlane (myPlane);
myIsGeometryValid = IsValidPoints (theFirstPoint, theSecondPoint);
SetToUpdate();
}
@ -126,11 +126,11 @@ void AIS_LengthDimension::SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
void AIS_LengthDimension::SetMeasuredGeometry (const TopoDS_Edge& theEdge,
const gp_Pln& thePlane)
{
myFirstShape = theEdge;
mySecondShape = TopoDS_Shape();
myGeometryType = GeometryType_Edge;
myFirstShape = theEdge;
mySecondShape = TopoDS_Shape();
myGeometryType = GeometryType_Edge;
SetCustomPlane (thePlane);
myIsValid = InitOneShapePoints (myFirstShape) && CheckPlane (myPlane);
myIsGeometryValid = InitOneShapePoints (myFirstShape);
SetToUpdate();
}
@ -164,11 +164,12 @@ void AIS_LengthDimension::SetMeasuredShapes (const TopoDS_Shape& theFirstShape,
{
gp_Pln aComputedPlane;
Standard_Boolean isPlaneReturned = Standard_False;
myFirstShape = theFirstShape;
mySecondShape = theSecondShape;
myIsValid = InitTwoShapesPoints (myFirstShape, mySecondShape, aComputedPlane, isPlaneReturned);
if (myIsValid && !myIsPlaneCustom)
myFirstShape = theFirstShape;
mySecondShape = theSecondShape;
myIsGeometryValid = InitTwoShapesPoints (myFirstShape, mySecondShape, aComputedPlane, isPlaneReturned);
if (myIsGeometryValid && !myIsPlaneCustom)
{
if (isPlaneReturned)
{
@ -176,12 +177,10 @@ void AIS_LengthDimension::SetMeasuredShapes (const TopoDS_Shape& theFirstShape,
}
else
{
myIsValid = Standard_False;
myIsGeometryValid = Standard_False;
}
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -730,7 +729,7 @@ const gp_Pnt AIS_LengthDimension::GetTextPosition() const
//=======================================================================
void AIS_LengthDimension::SetTextPosition (const gp_Pnt& theTextPos)
{
if (!myIsValid)
if (!IsValid())
{
return;
}

View File

@ -75,19 +75,17 @@ AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
//=======================================================================
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);
myCircle = theCircle;
myGeometryType = GeometryType_Edge;
myShape = BRepLib_MakeEdge (theCircle);
myAnchorPoint = ElCLib::Value (0, myCircle);
myIsGeometryValid = IsValidCircle (myCircle);
if (myIsValid)
if (myIsGeometryValid)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -98,19 +96,17 @@ void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
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);
myCircle = theCircle;
myGeometryType = GeometryType_Edge;
myShape = BRepLib_MakeEdge (theCircle);
myAnchorPoint = theAnchorPoint;
myIsGeometryValid = IsValidCircle (myCircle) && IsValidAnchor (myCircle, theAnchorPoint);
if (myIsValid)
if (myIsGeometryValid)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -121,18 +117,16 @@ void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle,
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);
myShape = theShape;
myGeometryType = GeometryType_UndefShapes;
myIsGeometryValid = InitCircularDimension (theShape, myCircle, myAnchorPoint, isClosed)
&& IsValidCircle (myCircle);
if (myIsValid)
if (myIsGeometryValid)
{
ComputePlane();
}
myIsValid &= CheckPlane (myPlane);
SetToUpdate();
}
@ -158,7 +152,7 @@ Standard_Boolean AIS_RadiusDimension::CheckPlane (const gp_Pln& thePlane) const
//=======================================================================
void AIS_RadiusDimension::ComputePlane()
{
if (!IsValid())
if (!myIsGeometryValid)
{
return;
}
@ -284,7 +278,7 @@ const gp_Pnt AIS_RadiusDimension::GetTextPosition() const
//=======================================================================
void AIS_RadiusDimension::SetTextPosition (const gp_Pnt& theTextPos)
{
if (!myIsValid)
if (!myIsGeometryValid)
{
return;
}