n AIS
n Aspect
n DsgPrs
+n PrsDim
n Graphic3d
n Image
n Media
Methods computing HLR presentation within *PrsMgr_PresentableObject::Compute()* have been renamed to *PrsMgr_PresentableObject::computeHLR()*
and now accept *Graphic3d_Camera* object instead of removed *Prs3d_Projector*.
+@subsection upgrade_750_dimensions Dimension and Relation presentations moved from AIS to PrsDim
+
+Presentation classes displaying Dimensions and Relations have been moved from *AIS* package to *PrsDim*.
+Corresponding classes should be renamed in application code (like *AIS_LengthDimension* -> *PrsDim_LengthDimension*).
+
@subsection upgrade_750_sensitiveEntity Select3D_SensitiveEntity interface change
The method Select3D_SensitiveEntity::NbSubElements() has been changed to be constant. Select3D_SensitiveEntity subclasses at application level should be updated accordingly.
The **Relation** is made up of constraints on one or more interactive shapes and the corresponding reference geometry. For example, you might want to constrain two edges in a parallel relation. This constraint is considered as an object in its own right, and is shown as a sensitive primitive. This takes the graphic form of a perpendicular arrow marked with the || symbol and lying between the two edges.
-The following relations are provided by *AIS*:
- * *AIS_ConcentricRelation*
- * *AIS_FixRelation*
- * *AIS_IdenticRelation*
- * *AIS_ParallelRelation*
- * *AIS_PerpendicularRelation*
- * *AIS_Relation*
- * *AIS_SymmetricRelation*
- * *AIS_TangentRelation*
+The following relations are provided by *PrsDim*:
+ * *PrsDim_ConcentricRelation*
+ * *PrsDim_FixRelation*
+ * *PrsDim_IdenticRelation*
+ * *PrsDim_ParallelRelation*
+ * *PrsDim_PerpendicularRelation*
+ * *PrsDim_Relation*
+ * *PrsDim_SymmetricRelation*
+ * *PrsDim_TangentRelation*
The list of relations is not exhaustive.
@subsubsection occt_visu_3_5_4 Dimensions
- * *AIS_AngleDimension*
- * *AIS_Chamf3dDimension*
- * *AIS_DiameterDimension*
- * *AIS_DimensionOwner*
- * *AIS_LengthDimension*
- * *AIS_OffsetDimension*
- * *AIS_RadiusDimension*
+ * *PrsDim_AngleDimension*
+ * *PrsDim_Chamf3dDimension*
+ * *PrsDim_DiameterDimension*
+ * *PrsDim_DimensionOwner*
+ * *PrsDim_LengthDimension*
+ * *PrsDim_OffsetDimension*
+ * *PrsDim_RadiusDimension*
@subsubsection occt_visu_3_5_5 MeshVS_Mesh
#include "DimensionDlg.h"
#include <AIS_InteractiveContext.hxx>
-#include <AIS_LengthDimension.hxx>
-#include <AIS_AngleDimension.hxx>
+#include <PrsDim_AngleDimension.hxx>
#include <BRep_Tool.hxx>
#include <GC_MakePlane.hxx>
#include <Prs3d_DimensionAspect.hxx>
GC_MakePlane aPlaneBuilder (aP1,aP2,aP3);
Handle(Geom_Plane) aPlane = aPlaneBuilder.Value();
- Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (aP1,aP2,aP3);
+ Handle(PrsDim_AngleDimension) anAngleDim = new PrsDim_AngleDimension (aP1,aP2,aP3);
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
anAspect->MakeArrows3d (Standard_False);
anAspect->MakeText3d (aDimDlg->GetTextType());
}
else // radians - no special symbol
{
- anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No);
+ anAngleDim->SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_No);
}
}
anAngleDim->SetDimensionAspect (anAspect);
#include <Standard_Macro.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <AIS_LengthDimension.hxx>
+#include <PrsDim_LengthDimension.hxx>
#include <GC_MakePlane.hxx>
#include <TopExp.hxx>
CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner());
- Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (TopoDS::Edge (anEdge), aPlane->Pln());
+ Handle(PrsDim_LengthDimension) aLenDim = new PrsDim_LengthDimension (TopoDS::Edge (anEdge), aPlane->Pln());
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
anAspect->MakeArrows3d (Standard_False);
anAspect->MakeText3d (aDimDlg->GetTextType());
#include "LengthParamsEdgesPage.h"
#include "DimensionDlg.h"
#include <AIS_InteractiveContext.hxx>
-#include <AIS_LengthDimension.hxx>
-#include <AIS_AngleDimension.hxx>
+#include <PrsDim_LengthDimension.hxx>
+#include <PrsDim_AngleDimension.hxx>
#include <GC_MakePlane.hxx>
// CLengthParamsEdgesPage dialog
if (myIsAngleDimension)
{
// Build an angle dimension between two non-parallel edges
- Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (myFirstEdge, mySecondEdge);
+ Handle(PrsDim_AngleDimension) anAngleDim = new PrsDim_AngleDimension (myFirstEdge, mySecondEdge);
anAngleDim->SetDimensionAspect (anAspect);
anAngleDim->DimensionAspect()->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed());
if (aDimDlg->IsUnitsDisplayed())
}
else
{
- anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No);
+ anAngleDim->SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_No);
}
}
}
else
{
- Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (myFirstEdge, mySecondEdge, aPlane->Pln());
+ Handle(PrsDim_LengthDimension) aLenDim = new PrsDim_LengthDimension (myFirstEdge, mySecondEdge, aPlane->Pln());
aLenDim->SetDimensionAspect (anAspect);
aLenDim->SetFlyout (aDimDlg->GetFlyout());
if (aDimDlg->IsUnitsDisplayed())
#include "DimensionDlg.h"
#include <Standard_Macro.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <AIS_LengthDimension.hxx>
+#include <PrsDim_LengthDimension.hxx>
#include <GC_MakePlane.hxx>
CDimensionDlg *aDimDlg = (CDimensionDlg*)(this->GetParentOwner());
- Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (aP1, aP2, aPlane->Pln());
+ Handle(PrsDim_LengthDimension) aLenDim = new PrsDim_LengthDimension (aP1, aP2, aPlane->Pln());
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
anAspect->MakeArrows3d (Standard_False);
#include "ParamsFacesPage.h"
#include "DimensionDlg.h"
#include <AIS_InteractiveContext.hxx>
-#include <AIS_LengthDimension.hxx>
-#include <AIS_AngleDimension.hxx>
+#include <PrsDim_LengthDimension.hxx>
+#include <PrsDim_AngleDimension.hxx>
// CParamsFacesPage dialog
if (myIsAngleDimension)
{
// Build an angle dimension between two non-parallel edges
- Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (myFirstFace, mySecondFace);
+ Handle(PrsDim_AngleDimension) anAngleDim = new PrsDim_AngleDimension (myFirstFace, mySecondFace);
anAngleDim->SetDimensionAspect (anAspect);
if (aDimDlg->IsUnitsDisplayed())
}
else
{
- anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No);
+ anAngleDim->SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_No);
}
}
}
else
{
- Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (myFirstFace, mySecondFace);
+ Handle(PrsDim_LengthDimension) aLenDim = new PrsDim_LengthDimension (myFirstFace, mySecondFace);
aLenDim->SetDimensionAspect (anAspect);
if (aLenDim->DimensionAspect()->IsUnitsDisplayed())
#include "DimensionDlg.h"
#include <AIS_InteractiveContext.hxx>
-#include <AIS_RadiusDimension.hxx>
-#include <AIS_DiameterDimension.hxx>
+#include <PrsDim_RadiusDimension.hxx>
+#include <PrsDim_DiameterDimension.hxx>
#include <ElCLib.hxx>
#include <TopoDS_Shape.hxx>
myAISContext->ClearSelected (Standard_False);
CDimensionDlg *aDimDlg = (CDimensionDlg*)(this->GetParentOwner());
// Try to create dimension if it is possible
- Handle(AIS_Dimension) aDim;
+ Handle(PrsDim_Dimension) aDim;
if (myIsDiameterDimension)
{
- aDim = new AIS_DiameterDimension (aCircle);
- Handle(AIS_DiameterDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout());
+ aDim = new PrsDim_DiameterDimension (aCircle);
+ Handle(PrsDim_DiameterDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout());
}
else
{
- aDim = new AIS_RadiusDimension (aCircle);
- Handle(AIS_RadiusDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout());
+ aDim = new PrsDim_RadiusDimension (aCircle);
+ Handle(PrsDim_RadiusDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout());
}
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AIS.hxx>
-
-#include <Adaptor3d_HCurve.hxx>
-#include <Adaptor3d_HSurface.hxx>
-#include <Bnd_Box.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_HSurface.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <BRepTools.hxx>
-#include <BRepTopAdaptor_FClass2d.hxx>
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <GccEnt_QualifiedLin.hxx>
-#include <gce_MakeDir.hxx>
-#include <gce_MakeLin.hxx>
-#include <Geom2d_Circle.hxx>
-#include <Geom_CartesianPoint.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_ConicalSurface.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_OffsetSurface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_SphericalSurface.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
-#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_ToroidalSurface.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <GeomAPI_ExtremaCurveCurve.hxx>
-#include <GeomAPI_IntSS.hxx>
-#include <GeomAPI_ProjectPointOnCurve.hxx>
-#include <GeomAPI_ProjectPointOnSurf.hxx>
-#include <GeomLib.hxx>
-#include <GeomProjLib.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Elips.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <gp_XYZ.hxx>
-#include <Precision.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_PointAspect.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <StdPrs_Point.hxx>
-#include <StdPrs_WFShape.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <TColStd_Array2OfReal.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-
-const Standard_Real SquareTolerance = Precision::SquareConfusion();
-
-//=======================================================================
-//function : Nearest
-//purpose :
-//=======================================================================
-gp_Pnt AIS::Nearest(const TopoDS_Shape& ashape, const gp_Pnt& apoint)
-{
- Standard_Real dist2 = RealLast();
- Standard_Real curdist2;
- gp_Pnt result(0.0,0.0,0.0);
- gp_Pnt curpnt(0.0,0.0,0.0);
- TopExp_Explorer explo(ashape,TopAbs_VERTEX);
- while (explo.More())
- {
- curpnt = BRep_Tool::Pnt(TopoDS::Vertex(explo.Current()));
- curdist2 = apoint.SquareDistance(curpnt);
- if (curdist2 < dist2)
- {
- result = curpnt;
- dist2 = curdist2;
- }
- explo.Next();
- }
- return result;
-}
-
-//=======================================================================
-//function : Nearest
-//purpose : For <thePoint> finds the nearest point on <theLine>.
-//=======================================================================
-gp_Pnt AIS::Nearest (const gp_Lin& theLine, const gp_Pnt& thePoint)
-{
- Handle(Geom_Line) aLine = new Geom_Line (theLine);
-
- GeomAPI_ProjectPointOnCurve aPointProj (thePoint, aLine);
- return aPointProj.Point (1);
-}
-
-//=======================================================================
-//function : Nearest
-//purpose : For the given point finds nearest point on the curve,
-// return TRUE if found point is belongs to curve
-// and FALSE otherwise.
-//=======================================================================
-Standard_Boolean AIS::Nearest (const Handle(Geom_Curve)& theCurve,
- const gp_Pnt& thePoint,
- const gp_Pnt& theFirstPoint,
- const gp_Pnt& theLastPoint,
- gp_Pnt& theNearestPoint)
-{
- GeomAPI_ProjectPointOnCurve aPointProj (thePoint, theCurve);
- theNearestPoint = theCurve->Value (aPointProj.LowerDistanceParameter());
-
- Standard_Real aLength = theFirstPoint.Distance (theLastPoint);
-
- if (theNearestPoint.Distance (theFirstPoint) > aLength
- || theNearestPoint.Distance (theLastPoint) >aLength)
- {
- return Standard_False;
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : Farest
-//purpose :
-//=======================================================================
-gp_Pnt AIS::Farest( const TopoDS_Shape& aShape, const gp_Pnt& aPoint )
-{
- Standard_Real MaxDist2 = 0.0e0, curdist2;
- gp_Pnt Result(0.0,0.0,0.0);
- gp_Pnt curpnt(0.0,0.0,0.0);
- TopExp_Explorer Explo( aShape, TopAbs_VERTEX );
- for (; Explo.More(); Explo.Next())
- {
- curpnt = BRep_Tool::Pnt( TopoDS::Vertex( Explo.Current() ) );
- curdist2 = aPoint.SquareDistance( curpnt );
- if (curdist2 > MaxDist2)
- {
- MaxDist2 = curdist2;
- Result = curpnt;
- }
- }
- return Result;
-}
-
-
-//=======================================================================
-//function : ComputeGeometry
-//purpose : for line, circle, ellipse.
-//=======================================================================
-Standard_Boolean AIS::ComputeGeometry (const TopoDS_Edge& theEdge,
- Handle(Geom_Curve)& theCurve,
- gp_Pnt& theFirstPnt,
- gp_Pnt& theLastPnt)
-{
- TopLoc_Location anEdgeLoc;
- Standard_Real aFirst, aLast;
- theCurve = BRep_Tool::Curve (theEdge, anEdgeLoc, aFirst, aLast);
- if (theCurve.IsNull())
- {
- return Standard_False;
- }
-
- if (!anEdgeLoc.IsIdentity())
- {
- Handle(Geom_Geometry) aGeometry = theCurve->Transformed (anEdgeLoc.Transformation());
- theCurve = Handle(Geom_Curve)::DownCast (aGeometry);
- }
-
- if (theCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
- {
- theCurve = Handle(Geom_TrimmedCurve)::DownCast (theCurve)->BasisCurve();
- }
-
- if (theCurve->IsInstance (STANDARD_TYPE (Geom_Line)))
- {
- Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theCurve);
- theFirstPnt = ElCLib::Value (aFirst, aLine->Lin());
- theLastPnt = ElCLib::Value (aLast, aLine->Lin());
- }
- else if (theCurve->IsInstance (STANDARD_TYPE (Geom_Circle)))
- {
- Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast (theCurve);
-
- theFirstPnt = ElCLib::Value (aFirst, aCirc->Circ());
- theLastPnt = ElCLib::Value (aLast, aCirc->Circ());
- }
- else if (theCurve->IsInstance (STANDARD_TYPE (Geom_Ellipse)))
- {
- Handle(Geom_Ellipse) anEllipse = Handle(Geom_Ellipse)::DownCast (theCurve);
- theFirstPnt = ElCLib::Value (aFirst, anEllipse->Elips());
- theLastPnt = ElCLib::Value (aLast, anEllipse->Elips());
- }
- else
- {
- return Standard_False;
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeGeometry
-//purpose : for line, circle, ellipse.
-//=======================================================================
-Standard_Boolean AIS::ComputeGeometry (const TopoDS_Edge& theEdge,
- Handle(Geom_Curve)& theCurve,
- gp_Pnt& theFirstPnt,
- gp_Pnt& theLastPnt,
- Standard_Boolean& theIsInfinite)
-{
- Standard_Real aFirst, aLast;
-
- BRepAdaptor_Curve anAdaptor (theEdge);
-
- theCurve = Handle(Geom_Curve)::DownCast
- (anAdaptor.Curve().Curve()->Transformed (anAdaptor.Trsf()));
-
- if (theCurve.IsNull())
- {
- return Standard_False;
- }
-
- aFirst = anAdaptor.FirstParameter();
- aLast = anAdaptor.LastParameter();
-
- theIsInfinite = (Precision::IsInfinite (aFirst) || Precision::IsInfinite (aLast));
-
- if (theCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
- {
- theCurve = Handle(Geom_TrimmedCurve)::DownCast (theCurve)->BasisCurve();
- }
-
- if (!theIsInfinite)
- {
- theFirstPnt = theCurve->Value (aFirst);
- theLastPnt = theCurve->Value (aLast);
- }
- else
- {
- theFirstPnt = gp::Origin();
- theLastPnt = gp::Origin();
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeGeometry
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS::ComputeGeometry (const TopoDS_Edge& theEdge,
- Handle(Geom_Curve)& theCurve,
- gp_Pnt& theFirstPnt,
- gp_Pnt& theLastPnt,
- Handle(Geom_Curve)& theExtCurve,
- Standard_Boolean& theIsInfinite,
- Standard_Boolean& theIsOnPlane,
- const Handle(Geom_Plane)& thePlane)
-{
- if (thePlane.IsNull())
- {
- return Standard_False;
- }
-
- Standard_Real aFirst, aLast;
- BRepAdaptor_Curve aCurveAdaptor (theEdge);
- theCurve = Handle(Geom_Curve)::DownCast (aCurveAdaptor.Curve().Curve()->Transformed (aCurveAdaptor.Trsf()));
- aFirst = aCurveAdaptor.FirstParameter();
- aLast = aCurveAdaptor.LastParameter();
-
- if (theCurve.IsNull())
- {
- return Standard_False;
- }
-
- theExtCurve = theCurve;
- theIsInfinite = (Precision::IsInfinite (aFirst) || Precision::IsInfinite (aLast));
-
- // Checks that the projected curve is not in the plane.
- theIsOnPlane = Standard_True;
- if (theExtCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
- {
- theExtCurve = Handle(Geom_TrimmedCurve)::DownCast (theExtCurve)->BasisCurve();
- }
-
- if (theExtCurve->IsInstance (STANDARD_TYPE (Geom_Line)))
- {
- Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theExtCurve);
- theIsOnPlane = thePlane->Pln().Contains (aLine->Lin(),
- Precision::Confusion(),
- Precision::Angular());
- }
- else if (theExtCurve->IsInstance (STANDARD_TYPE (Geom_Circle)))
- {
- Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast (theExtCurve);
-
- gp_Ax3 aCircPos (aCircle->Position());
- theIsOnPlane = aCircPos.IsCoplanar (thePlane->Pln().Position(),
- Precision::Confusion(),
- Precision::Angular());
- }
-
- if (theIsOnPlane)
- {
- theExtCurve.Nullify();
- }
-
- theCurve = GeomProjLib::ProjectOnPlane (theCurve, thePlane,
- thePlane->Pln().Axis().Direction(),
- Standard_False);
-
- if (theCurve->IsInstance (STANDARD_TYPE (Geom_Line)))
- {
- Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theCurve);
- if (!theIsInfinite)
- {
- theFirstPnt = ElCLib::Value (aFirst, aLine->Lin());
- theLastPnt = ElCLib::Value (aLast, aLine->Lin());
- }
- }
- else if (theCurve->IsInstance (STANDARD_TYPE (Geom_Circle)))
- {
- Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast (theCurve);
-
- theFirstPnt = ElCLib::Value (aFirst, aCirc->Circ());
- theLastPnt = ElCLib::Value (aLast, aCirc->Circ());
- }
- else if (theCurve->IsInstance (STANDARD_TYPE (Geom_Ellipse)))
- {
- Handle(Geom_Ellipse) anEllipse = Handle(Geom_Ellipse)::DownCast (theCurve);
-
- theFirstPnt = ElCLib::Value (aFirst, anEllipse->Elips());
- theLastPnt = ElCLib::Value (aLast, anEllipse->Elips());
- }
- else
- {
- return Standard_False;
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeGeometry
-//purpose :
-//=======================================================================
-Standard_Boolean AIS::ComputeGeometry (const TopoDS_Edge& theFirstEdge,
- const TopoDS_Edge& theSecondEdge,
- Handle(Geom_Curve)& theFirstCurve,
- Handle(Geom_Curve)& theSecondCurve,
- gp_Pnt& theFirstPnt1,
- gp_Pnt& theLastPnt1,
- gp_Pnt& theFirstPnt2,
- gp_Pnt& theLastPnt2,
- const Handle(Geom_Plane)& thePlane)
-{
- if (thePlane.IsNull())
- {
- return Standard_False;
- }
-
- TopLoc_Location aFirstEdgeLoc, aSecondEdgeLoc;
- Standard_Real aFirst1, aLast1, aFirst2, aLast2;
-
- theFirstCurve = BRep_Tool::Curve (theFirstEdge, aFirstEdgeLoc, aFirst1, aLast1);
- theSecondCurve = BRep_Tool::Curve (theSecondEdge, aSecondEdgeLoc, aFirst2, aLast2);
-
- if (theFirstCurve.IsNull())
- {
- return Standard_False;
- }
-
- if (theSecondCurve.IsNull())
- {
- return Standard_False;
- }
-
- if (!aFirstEdgeLoc.IsIdentity())
- {
- Handle(Geom_Geometry) aGeomGeometry = theFirstCurve->Transformed (aFirstEdgeLoc.Transformation());
- theFirstCurve = Handle(Geom_Curve)::DownCast (aGeomGeometry);
- }
-
- if (!aSecondEdgeLoc.IsIdentity())
- {
- Handle(Geom_Geometry) aGeomGeometry = theSecondCurve->Transformed (aSecondEdgeLoc.Transformation());
- theSecondCurve = Handle(Geom_Curve)::DownCast (aGeomGeometry);
- }
-
- theFirstCurve = GeomProjLib::ProjectOnPlane (theFirstCurve, thePlane,
- thePlane->Pln().Axis().Direction(),
- Standard_False);
-
-
- theSecondCurve = GeomProjLib::ProjectOnPlane (theSecondCurve, thePlane,
- thePlane->Pln().Axis().Direction(),
- Standard_False);
-
-
- if (theFirstCurve->IsInstance (STANDARD_TYPE(Geom_TrimmedCurve)))
- {
- theFirstCurve = Handle(Geom_TrimmedCurve)::DownCast (theFirstCurve)->BasisCurve();
- }
-
- if (theSecondCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
- {
- theSecondCurve = Handle(Geom_TrimmedCurve)::DownCast (theSecondCurve)->BasisCurve();
- }
-
- if (theFirstCurve->IsInstance(STANDARD_TYPE(Geom_Line)))
- {
- Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theFirstCurve);
-
- theFirstPnt1 = ElCLib::Value (aFirst1, aLine->Lin());
- theLastPnt1 = ElCLib::Value (aLast1, aLine->Lin());
- }
- else if (theFirstCurve->IsInstance(STANDARD_TYPE(Geom_Circle)))
- {
- Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast (theFirstCurve);
-
- theFirstPnt1 = ElCLib::Value (aFirst1, aCirc->Circ());
- theLastPnt1 = ElCLib::Value (aLast1, aCirc->Circ());
- }
- else
- {
- return Standard_False;
- }
-
- if (theSecondCurve->IsInstance (STANDARD_TYPE (Geom_Line)))
-{
- Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theSecondCurve);
-
- theFirstPnt2 = ElCLib::Value (aFirst2, aLine->Lin());
- theLastPnt2 = ElCLib::Value (aLast2, aLine->Lin());
- }
- else if (theSecondCurve->IsInstance (STANDARD_TYPE (Geom_Circle)))
- {
- Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast (theSecondCurve);
-
- theFirstPnt2 = ElCLib::Value (aFirst2, aCirc->Circ());
- theLastPnt2 = ElCLib::Value (aLast2, aCirc->Circ());
- }
- else
- {
- return Standard_False;
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeGeometry
-//purpose : Computes the geometry of the 2 edges.
-//=======================================================================
-Standard_Boolean AIS::ComputeGeometry (const TopoDS_Edge& theFirstEdge,
- const TopoDS_Edge& theSecondEdge,
- Handle(Geom_Curve)& theFirstCurve,
- Handle(Geom_Curve)& theSecondCurve,
- gp_Pnt& theFirstPnt1,
- gp_Pnt& theLastPnt1,
- gp_Pnt& theFirstPnt2,
- gp_Pnt& theLastPnt2,
- Standard_Boolean& theIsInfinite1,
- Standard_Boolean& theIsInfinite2)
-{
- theIsInfinite1 = theIsInfinite2 = Standard_False;
-
- if (!AIS::ComputeGeometry (theFirstEdge, theFirstCurve,theFirstPnt1, theLastPnt1, theIsInfinite1))
- {
- return Standard_False;
- }
-
- if (!AIS::ComputeGeometry (theSecondEdge, theSecondCurve,theFirstPnt2, theLastPnt2, theIsInfinite2))
- {
- return Standard_False;
- }
-
- if (theIsInfinite1 || theIsInfinite2)
- {
- if (theFirstCurve->DynamicType() == theSecondCurve->DynamicType())
- {
- gp_Lin aLin1 = Handle(Geom_Line)::DownCast (theFirstCurve)->Lin();
- gp_Lin aLin2 = Handle(Geom_Line)::DownCast (theSecondCurve)->Lin();
-
- if (theIsInfinite1)
- {
- theFirstPnt1 = ElCLib::Value (ElCLib::Parameter (aLin2, theFirstPnt2), aLin1);
- theLastPnt1 = ElCLib::Value (ElCLib::Parameter (aLin2, theLastPnt2), aLin1);
- }
- else if (theIsInfinite2)
- {
- theFirstPnt2 = ElCLib::Value (ElCLib::Parameter (aLin1, theFirstPnt1), aLin2);
- theLastPnt2 = ElCLib::Value (ElCLib::Parameter (aLin1, theLastPnt1), aLin2);
- }
- }
- else
- {
- if (theIsInfinite1 && !theIsInfinite2)
- {
- GeomAPI_ProjectPointOnCurve aProjector (theFirstPnt2, theFirstCurve);
- theFirstPnt1 = theFirstCurve->Value (aProjector.LowerDistanceParameter ());
-
- aProjector.Init (theLastPnt2, theFirstCurve);
- theLastPnt1 = theFirstCurve->Value (aProjector.LowerDistanceParameter ());
- }
- else if (!theIsInfinite1 && theIsInfinite2)
- {
- GeomAPI_ProjectPointOnCurve aProjector (theFirstPnt1, theSecondCurve);
- theFirstPnt2 = theSecondCurve->Value (aProjector.LowerDistanceParameter ());
-
- aProjector.Init (theLastPnt1, theSecondCurve);
- theLastPnt2 = theSecondCurve->Value (aProjector.LowerDistanceParameter ());
- }
- else
- {
- return Standard_False;
- }
- }
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeGeometry
-//purpose : Computes the geometry of the 2 edges in the current wp
-// and the 'right' geometry of the edges if one doesn't
-// belong to the current working plane.
-// There may be only one curve that can't belong to the
-// current working plane ( attachement constraint)
-// if the 2 edges belong to the current WP, <WhatProj> = 0
-//
-// indexExt = 0 2 edges are in the current wp
-// indexExt = 1 first edge is not in the current wp
-// indexExt = 2 second edge is not in the current wp
-// if none of the two edges is in the current wp ,
-// it returns Standard_False
-//=======================================================================
-Standard_Boolean AIS::ComputeGeometry (const TopoDS_Edge& theFirstEdge,
- const TopoDS_Edge& theSecondEdge,
- Standard_Integer& theExtIndex,
- Handle(Geom_Curve)& theFirstCurve,
- Handle(Geom_Curve)& theSecondCurve,
- gp_Pnt& theFirstPnt1,
- gp_Pnt& theLastPnt1,
- gp_Pnt& theFirstPnt2,
- gp_Pnt& theLastPnt2,
- Handle(Geom_Curve)& theExtCurve,
- Standard_Boolean& theIsInfinite1,
- Standard_Boolean& theIsInfinite2,
- const Handle(Geom_Plane)& thePlane)
-{
- if (thePlane.IsNull())
- {
- return Standard_False;
- }
-
- theExtCurve.Nullify();
- theExtIndex = 0;
-
- Standard_Real aFirst1, aLast1, aFirst2, aLast2;
- theIsInfinite1 = theIsInfinite2 = Standard_False;
-
- BRepAdaptor_Curve aFirstAdaptor (theFirstEdge);
- BRepAdaptor_Curve aSecondAdaptor (theSecondEdge);
-
- theFirstCurve = Handle(Geom_Curve)::DownCast
- (aFirstAdaptor.Curve().Curve()->Transformed (aFirstAdaptor.Trsf()));
- theSecondCurve = Handle(Geom_Curve)::DownCast
- (aSecondAdaptor.Curve().Curve()->Transformed (aSecondAdaptor.Trsf()));
-
- if (theFirstCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
- {
- theFirstCurve = Handle(Geom_TrimmedCurve)::DownCast (theFirstCurve)->BasisCurve();
- }
- if (theSecondCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
- {
- theSecondCurve = Handle(Geom_TrimmedCurve)::DownCast (theSecondCurve)->BasisCurve();
- }
-
- aFirst1 = aFirstAdaptor.FirstParameter();
- aLast1 = aFirstAdaptor.LastParameter();
-
- aFirst2 = aSecondAdaptor.FirstParameter();
- aLast2 = aSecondAdaptor.LastParameter();
-
- if (theFirstCurve.IsNull() || theSecondCurve.IsNull())
- {
- return Standard_False;
- }
-
- Handle(Geom_Curve) aFirstSaved = theFirstCurve;
- Handle(Geom_Curve) aSecondSaved = theSecondCurve;
-
- // Checks that the projected curve is not in the plane
- Standard_Boolean isFirstOnPlane,isSecondOnPlane;
-
- if ((!ComputeGeomCurve (theFirstCurve, aFirst1, aLast1, theFirstPnt1, theLastPnt1, thePlane, isFirstOnPlane))
- || (!ComputeGeomCurve( theSecondCurve, aFirst2, aLast2, theFirstPnt2, theLastPnt2, thePlane,isSecondOnPlane)))
- {
- return Standard_False;
- }
-
- if (Precision::IsInfinite (aFirst1) || Precision::IsInfinite (aLast1))
- {
- theIsInfinite1 = Standard_True;
- theExtIndex = 1;
- }
- if (Precision::IsInfinite (aFirst2) || Precision::IsInfinite (aLast2))
- {
- theIsInfinite2 = Standard_True;
- theExtIndex = 2;
- }
- if (theIsInfinite1 && theIsInfinite2)
- {
- theExtIndex = 0;
- }
-
- if (theIsInfinite1 || theIsInfinite2)
- {
- if (theFirstCurve->DynamicType() == theSecondCurve->DynamicType())
- {
- gp_Lin aLin1 = Handle(Geom_Line)::DownCast (theFirstCurve)->Lin();
- gp_Lin aLin2 = Handle(Geom_Line)::DownCast (theSecondCurve)->Lin();
-
- if (theExtIndex == 1)
- {
- theFirstPnt1 = ElCLib::Value (ElCLib::Parameter (aLin2, theFirstPnt2), aLin1);
- theLastPnt1 = ElCLib::Value (ElCLib::Parameter (aLin2, theLastPnt2), aLin1);
- }
- else if (theExtIndex == 2)
- {
- theFirstPnt2 = ElCLib::Value (ElCLib::Parameter (aLin1, theFirstPnt1), aLin2);
- theLastPnt2 = ElCLib::Value (ElCLib::Parameter (aLin1, theLastPnt1), aLin2);
- }
- }
- }
-
- if (isFirstOnPlane && isSecondOnPlane)
- {
- return Standard_True;
- }
-
- if (!isFirstOnPlane && isSecondOnPlane)
- {// curve 2 only in the plane
- theExtIndex = 1;
- theExtCurve = aFirstSaved;
- }
- else if (isFirstOnPlane && !isSecondOnPlane)
- {// curve 1 only in the plane
- theExtIndex = 2;
- theExtCurve = aSecondSaved;
- }
- else
- {
- return Standard_False;
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeGeomCurve
-//purpose : Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
-// and returns aCurveproj;
-// Return TRUE if ok
-//=======================================================================
-Standard_Boolean AIS::ComputeGeomCurve (Handle(Geom_Curve)& aCurve,
- const Standard_Real first1,
- const Standard_Real last1,
- gp_Pnt& FirstPnt1,
- gp_Pnt& LastPnt1,
- const Handle(Geom_Plane)& aPlane,
- Standard_Boolean& isOnPlane)
-{
- isOnPlane = Standard_True;
- const Standard_Integer NodeNumber = 20;
- Standard_Real Delta = (last1 - first1) / (NodeNumber - 1);
- if (Delta <= Precision::PConfusion())
- {
- Delta = last1 - first1;
- }
-
- gp_Pnt CurPnt(0.0, 0.0, 0.0);
- Standard_Real CurPar = first1;
- for (Standard_Integer i = 1; i <= NodeNumber; i++)
- {
- CurPnt = aCurve->Value( CurPar );
- if (aPlane->Pln().SquareDistance( CurPnt ) > SquareTolerance)
- {
- isOnPlane = Standard_False;
- break;
- }
- CurPar += Delta;
- }
-
- if (!Precision::IsInfinite(first1) && !Precision::IsInfinite(last1))
- {
- FirstPnt1 = aCurve->Value (first1);
- LastPnt1 = aCurve->Value (last1);
- }
-
- if (!isOnPlane)
- {
- Handle(Geom_Curve) aGeomCurve = GeomProjLib::ProjectOnPlane (aCurve,
- aPlane,
- aPlane->Pln().Axis().Direction(),
- Standard_False);
- aCurve = aGeomCurve;
- if (aCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
- {
- aCurve = Handle(Geom_TrimmedCurve)::DownCast (aCurve)->BasisCurve();
- }
- if (! Precision::IsInfinite(first1) && ! Precision::IsInfinite(last1))
- {
- FirstPnt1 = AIS::ProjectPointOnPlane( FirstPnt1, aPlane->Pln() );
- LastPnt1 = AIS::ProjectPointOnPlane( LastPnt1, aPlane->Pln() );
- }
- }
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeGeometry
-//purpose : computes the point corresponding to the vertex <aVertex>
-// in the plane <aPlane>. If the vertex is already in the plane
-// <isOnPlane>, <isOnPlane> = true.
-// <point> is the projected vertex in the plane.
-//=======================================================================
-Standard_Boolean AIS::ComputeGeometry(const TopoDS_Vertex& aVertex,
- gp_Pnt& point,
- const Handle(Geom_Plane)& aPlane,
- Standard_Boolean& isOnPlane)
-{
- point = BRep_Tool::Pnt(aVertex);
- isOnPlane = aPlane->Pln().Contains(point, Precision::Confusion());
- if ( !isOnPlane) {
- point = AIS::ProjectPointOnPlane( point, aPlane->Pln() );
- }
- return Standard_True;
-}
-
-//=======================================================================
-//function : GetPlaneFromFace
-//purpose :
-// Returns type of surface which can be Plane or OtherSurface
-//=======================================================================
-Standard_Boolean AIS::GetPlaneFromFace(const TopoDS_Face& aFace,
- gp_Pln & aPlane,
- Handle( Geom_Surface )& aSurf,
- AIS_KindOfSurface & aSurfType,
- Standard_Real & Offset)
-
-{
- Standard_Boolean Result = Standard_False;
- BRepAdaptor_Surface surf1( aFace );
- Handle( Adaptor3d_HSurface ) surf2;
- Standard_Boolean isOffset = Standard_False;
- Offset = 0.0;
-
- if (surf1.GetType() == GeomAbs_OffsetSurface)
- {
- // Extracting Basis Surface
- surf2 = surf1.BasisSurface();
- isOffset = Standard_True;
- }
- else
- surf2 = new BRepAdaptor_HSurface( surf1 );
-
- aSurf = surf1.Surface().Surface();
- // aSurf->Transform(surf1.Trsf()) ;
- aSurf = Handle( Geom_Surface )::DownCast( aSurf->Transformed( surf1.Trsf() ) );
-
- if (surf2->GetType() == GeomAbs_Plane)
- {
- aPlane = surf2->Plane();
- aSurfType = AIS_KOS_Plane;
- Result = Standard_True;
- }
-
- else if (surf2->GetType() == GeomAbs_SurfaceOfExtrusion)
- {
- Handle( Adaptor3d_HCurve ) BasisCurve = surf2->BasisCurve();
- gp_Dir ExtrusionDir = surf2->Direction();
- if (BasisCurve->GetType() == GeomAbs_Line)
- {
- gp_Lin BasisLine = BasisCurve->Line();
- gp_Dir LineDir = BasisLine.Direction();
- gp_Pnt LinePos = BasisLine.Location();
- gp_Pln thePlane( LinePos, LineDir ^ ExtrusionDir);
- aPlane = thePlane;
- aSurfType = AIS_KOS_Plane;
- Result = Standard_True;
- }
- }
-
- if (Result == Standard_True && isOffset)
- {
- aSurf = (Handle( Geom_OffsetSurface )::DownCast( aSurf ))->Surface();
- aPlane = (Handle( Geom_Plane )::DownCast( aSurf ))->Pln();
- }
- if (Result == Standard_False)
- {
- if (isOffset)
- {
- Handle( Standard_Type ) TheType = aSurf->DynamicType();
- if (TheType == STANDARD_TYPE(Geom_CylindricalSurface) ||
- TheType == STANDARD_TYPE(Geom_ConicalSurface) ||
- TheType == STANDARD_TYPE(Geom_SphericalSurface) ||
- TheType == STANDARD_TYPE(Geom_ToroidalSurface))
- {
- aSurf = (Handle( Geom_OffsetSurface )::DownCast( aSurf ))->Surface();
- }
- else
- {
- Offset = (Handle( Geom_OffsetSurface )::DownCast( aSurf ))->Offset();
- aSurf = (Handle( Geom_OffsetSurface )::DownCast( aSurf ))->BasisSurface();
- }
- }
- Handle( Standard_Type ) TheType = aSurf->DynamicType();
- if (TheType == STANDARD_TYPE(Geom_CylindricalSurface))
- aSurfType = AIS_KOS_Cylinder;
- else if (TheType == STANDARD_TYPE(Geom_ConicalSurface))
- aSurfType = AIS_KOS_Cone;
- else if (TheType == STANDARD_TYPE(Geom_SphericalSurface))
- aSurfType = AIS_KOS_Sphere;
- else if (TheType == STANDARD_TYPE(Geom_ToroidalSurface))
- aSurfType = AIS_KOS_Torus;
- else if (TheType == STANDARD_TYPE(Geom_SurfaceOfRevolution))
- aSurfType = AIS_KOS_Revolution;
- else if (TheType == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))
- aSurfType = AIS_KOS_Extrusion;
- else
- aSurfType = AIS_KOS_OtherSurface;
- }
- return Result;
-}
-
-
-//=======================================================================
-//function : ProjectPointOnPlane
-//purpose :
-//=======================================================================
-
-gp_Pnt AIS::ProjectPointOnPlane( const gp_Pnt & aPoint, const gp_Pln & aPlane )
-{
- gp_Vec aVec( aPlane.Location(), aPoint );
- gp_Vec Normal = aPlane.Axis().Direction();
- Normal = (aVec * Normal) * Normal;
-
- return ( aPoint.Translated( -Normal ) );
-}
-
-//=======================================================================
-//function : ProjectPointOnLine
-//purpose :
-//=======================================================================
-
-gp_Pnt AIS::ProjectPointOnLine( const gp_Pnt & aPoint, const gp_Lin & aLine )
-{
- gp_XYZ LinLoc = aLine.Location().XYZ();
- gp_XYZ LinDir = aLine.Direction().XYZ();
- Standard_Real Parameter = (aPoint.XYZ() - LinLoc) * LinDir;
- gp_Pnt Result( LinLoc + Parameter * LinDir );
- return Result;
-}
-
-//=======================================================================
-//function : InitFaceLength
-//purpose :
-//=======================================================================
-void AIS::InitFaceLength (const TopoDS_Face& theFace,
- gp_Pln& thePlane,
- Handle(Geom_Surface)& theSurface,
- AIS_KindOfSurface& theSurfaceType,
- Standard_Real& theOffset)
-{
- if (AIS::GetPlaneFromFace (theFace, thePlane, theSurface, theSurfaceType, theOffset)
- && Abs (theOffset) > Precision::Confusion())
- {
- theSurface = new Geom_OffsetSurface (theSurface, theOffset);
- theOffset = 0.0e0;
- }
-}
-
-//=======================================================================
-//function : InitAngleBetweenPlanarFaces
-//purpose :
-//=======================================================================
-Standard_Boolean AIS::InitAngleBetweenPlanarFaces (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace,
- gp_Pnt & theCenter,
- gp_Pnt & theFirstAttach,
- gp_Pnt & theSecondAttach,
- const Standard_Boolean theIsFirstPointSet)
-{
- Handle(Geom_Plane) aFirstPlane = Handle(Geom_Plane)::DownCast (BRep_Tool::Surface (theFirstFace));
- Handle(Geom_Plane) aSecondPlane = Handle(Geom_Plane)::DownCast (BRep_Tool::Surface (theSecondFace));
-
- GeomAPI_IntSS aPlaneIntersector (aFirstPlane, aSecondPlane, Precision::Confusion());
-
- // Fails if two planes haven't only one intersection line.
- if (!aPlaneIntersector.IsDone())
- {
- return Standard_False;
- }
-
- if (aPlaneIntersector.NbLines() != 1)
- {
- return Standard_False;
- }
-
- // Get intersect line.
- Handle(Geom_Curve) anIntersectCurve = aPlaneIntersector.Line (1);
-
- Handle(Geom_Line) anIntersectLine = Handle(Geom_Line)::DownCast (anIntersectCurve);
-
- if (anIntersectLine.IsNull())
- {
- return Standard_False;
- }
-
- gp_Lin anIntersectLin = anIntersectLine->Lin();
-
- gp_Pnt aFirstCenter, aSecondCenter;
- Standard_Real anU1Min, anU1Max, aV1Min, aV1Max;
- Standard_Real anU2Min, anU2Max, aV2Min, aV2Max;
-
- BRepTools::UVBounds (theFirstFace, anU1Min, anU1Max, aV1Min, aV1Max);
- BRepTools::UVBounds (theSecondFace, anU2Min, anU2Max, aV2Min, aV2Max);
-
- // Get first and second attach.
- if (theIsFirstPointSet)
- {
- GeomAPI_ProjectPointOnSurf aProjector (theFirstAttach, aFirstPlane);
- if (!aProjector.IsDone())
- {
- return Standard_False;
- }
-
- aFirstCenter = aProjector.Point (1);
- }
- else
- {
- aFirstCenter = aFirstPlane->Value ((anU1Min + anU1Max) * 0.5, (aV1Min + aV1Max) * 0.5);
- }
-
- aSecondCenter = aSecondPlane->Value ((anU2Min + anU2Max) * 0.5, (aV2Min + aV2Max) * 0.5);
-
- GeomAPI_ProjectPointOnCurve aProj (aFirstCenter, anIntersectCurve);
- theCenter = aProj.NearestPoint();
-
- gp_Vec aFirstNormal = anIntersectLin.Direction() ^ aFirstPlane->Pln().Axis().Direction();
- if (aFirstNormal * gp_Vec (theCenter, aFirstCenter) < 0.0)
- {
- aFirstNormal.Reverse();
- }
- theFirstAttach = theCenter.Translated (aFirstNormal);
-
- gp_Vec aSecondNormal = anIntersectLin.Direction() ^ aSecondPlane->Pln().Axis().Direction();
- if (aSecondNormal * gp_Vec (theCenter, aSecondCenter) < 0.0)
- {
- aSecondNormal.Reverse();
- }
- theSecondAttach = theCenter.Translated (aSecondNormal);
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : InitAngleBetweenCurvilinearFaces
-//purpose :
-//=======================================================================
-Standard_Boolean AIS::InitAngleBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace,
- const AIS_KindOfSurface theFirstSurfType,
- const AIS_KindOfSurface theSecondSurfType,
- gp_Pnt& theCenter,
- gp_Pnt& theFirstAttach,
- gp_Pnt& theSecondAttach,
- const Standard_Boolean theIsFirstPointSet)
-{
- Handle(Geom_Surface) aFirstSurf = BRep_Tool::Surface (theFirstFace);
- Handle(Geom_Surface) aSecondSurf = BRep_Tool::Surface (theSecondFace);
-
- // Find intersection curve between two surfaces.
- GeomAPI_IntSS aSurfaceIntersector (aFirstSurf, aSecondSurf, Precision::Confusion());
-
- // Fails if two planes haven't only one intersection line.
- if (!aSurfaceIntersector.IsDone())
- {
- return Standard_False;
- }
-
- if (aSurfaceIntersector.NbLines() != 1)
- {
- return Standard_False;
- }
-
- // Get intersect line.
- Handle(Geom_Curve) anIntersectCurve = aSurfaceIntersector.Line (1);
-
- Handle(Geom_Line) aFirstLine, aSecondLine;
- Standard_Real aFirstU = 0.0;
- Standard_Real aFirstV = 0.0;
-
- if (theIsFirstPointSet)
- {
- GeomAPI_ProjectPointOnSurf aProjector (theFirstAttach, aFirstSurf);
- if (!aProjector.IsDone())
- {
- return Standard_False;
- }
-
- theFirstAttach = aProjector.Point (1);
- }
- else
- {
- theFirstAttach = aFirstSurf->Value (aFirstU, aFirstV);
- }
-
- aFirstLine = Handle(Geom_Line)::DownCast (aFirstSurf->UIso (aFirstU));
-
- if (theSecondSurfType == AIS_KOS_Cylinder)
- {
- Handle(Geom_CylindricalSurface) aCylinder = Handle(Geom_CylindricalSurface)::DownCast (aSecondSurf);
-
- Standard_Real aSecondU = aCylinder->Cylinder().XAxis().Direction().Angle(
- gce_MakeDir (ProjectPointOnLine (theFirstAttach,
- gp_Lin (aCylinder->Cylinder().Axis())),
- theFirstAttach));
-
- aSecondLine = Handle(Geom_Line)::DownCast (aCylinder->UIso (aSecondU));
- }
- else if (theSecondSurfType == AIS_KOS_Cone)
- {
- Handle(Geom_ConicalSurface) aCone = Handle(Geom_ConicalSurface)::DownCast (aSecondSurf);
-
- gp_Dir anXdirection = aCone->Cone().XAxis().Direction();
-
- gp_Dir aToFirstAttach = gce_MakeDir (ProjectPointOnLine (theFirstAttach,
- gp_Lin (aCone->Cone().Axis())),
- theFirstAttach);
-
- Standard_Real aSecondU = anXdirection.Angle (aToFirstAttach);
-
- // Check sign
- if (!anXdirection.IsEqual (aToFirstAttach, Precision::Angular()) &&
- !anXdirection.IsOpposite (aToFirstAttach, Precision::Angular()) &&
- (anXdirection ^ aToFirstAttach) * aCone->Cone().Axis().Direction() < 0.0)
- {
- aSecondU = 2*M_PI - aSecondU;
- }
- aSecondLine = Handle( Geom_Line )::DownCast (aCone->UIso(aSecondU));
- }
- else
- {
- return Standard_False;
- }
-
- // If angle can be computed between two lines.
- if (!(aFirstLine->Lin().Direction().IsEqual (aSecondLine->Lin().Direction(), Precision::Angular() )) &&
- !(aFirstLine->Lin().Direction().IsOpposite (aSecondLine->Lin().Direction(), Precision::Angular())))
- {
- GeomAPI_ExtremaCurveCurve anIntersector (aFirstLine, aSecondLine);
- anIntersector.Points (1, theCenter, theCenter);
-
- // Move theFirstAttach on aFirstLine if it is on theCenter.
- if (theCenter.SquareDistance(theFirstAttach ) <= SquareTolerance)
- {
- gp_Vec aDir (aFirstLine->Lin().Direction());
- theFirstAttach = theCenter.Translated (aDir);
-
- // theFirstAttach should be on theFirstSurf.
- Standard_Real anU, aV;
- if (theFirstSurfType == AIS_KOS_Cylinder)
- {
- ElSLib::Parameters ((Handle(Geom_CylindricalSurface)::DownCast (aFirstSurf))->Cylinder(),
- theFirstAttach, anU, aV);
-
- theFirstAttach = ElSLib::Value (aFirstU, aV,
- (Handle( Geom_CylindricalSurface )::DownCast (aFirstSurf))->Cylinder() );
- }
- else if (theFirstSurfType == AIS_KOS_Cone)
- {
- ElSLib::Parameters ((Handle(Geom_ConicalSurface)::DownCast (aFirstSurf))->Cone(),
- theFirstAttach, anU, aV);
- theFirstAttach = ElSLib::Value (aFirstU, aV,
- (Handle(Geom_ConicalSurface)::DownCast (aFirstSurf))->Cone());
- }
- else
- {
- return Standard_False;
- }
- }
-
- // Find theSecondAttach
- GeomAPI_ProjectPointOnSurf aProjector (theFirstAttach, aSecondSurf);
- if (!aProjector.IsDone())
- {
- return Standard_False;
- }
- Standard_Real anU, aV;
- aProjector.LowerDistanceParameters (anU, aV);
- theSecondAttach = aSecondSurf->Value (anU, aV);
- }
- else // aFirstLine and aSecondLine are coincident
- {
- gp_Vec aDir (aFirstLine->Lin().Direction());
- theFirstAttach = theCenter.Translated (aDir);
- theSecondAttach = theCenter.Translated (-aDir);
- }
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeLengthBetweenCurvilinearFaces
-//purpose :
-//=======================================================================
-void AIS::InitLengthBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace,
- Handle(Geom_Surface)& theFirstSurf,
- Handle(Geom_Surface)& theSecondSurf,
- gp_Pnt& theFirstAttach,
- gp_Pnt& theSecondAttach,
- gp_Dir& theDirOnPlane)
-{
- GeomAPI_ProjectPointOnSurf aProjector;
- Standard_Real aPU, aPV;
-
- TopExp_Explorer anExplorer (theFirstFace, TopAbs_VERTEX);
-
- theFirstAttach = BRep_Tool::Pnt (TopoDS::Vertex (anExplorer.Current()));
- aProjector.Init (theFirstAttach, theFirstSurf);
-
- theFirstAttach = aProjector.NearestPoint();
- aProjector.LowerDistanceParameters (aPU, aPV);
-
- gp_Vec aD1U, aD1V;
- theFirstSurf->D1 (aPU, aPV, theFirstAttach, aD1U, aD1V);
-
- if (aD1U.SquareMagnitude() <= SquareTolerance || aD1V.SquareMagnitude() <= SquareTolerance)
- {
- theFirstAttach = AIS::Farest (theFirstFace, theFirstAttach);
- aProjector.Init (theFirstAttach, theFirstSurf);
- aProjector.LowerDistanceParameters (aPU, aPV);
- theFirstSurf->D1 (aPU, aPV, theFirstAttach, aD1U, aD1V);
- }
-
- aD1U.Normalize();
- aD1V.Normalize();
-
- theDirOnPlane = gp_Dir (aD1U);
-
- gp_Dir aFirstSurfN = gp_Dir (aD1U ^ aD1V);
-
- aProjector.Init (theFirstAttach, theSecondSurf);
-
- Standard_Integer aBestPointIndex = 0;
- Standard_Real aMinDist = RealLast();
- gp_Dir aLocalDir;
-
- for (Standard_Integer aPointIt = 1; aPointIt <= aProjector.NbPoints(); aPointIt++)
- {
- aProjector.Parameters (aPointIt, aPU, aPV);
-
- theSecondSurf->D1 (aPU, aPV, theSecondAttach, aD1U, aD1V);
-
- aLocalDir = aD1U.SquareMagnitude() <= SquareTolerance || aD1V.SquareMagnitude() <= SquareTolerance
- ? gp_Dir (gp_Vec (theFirstAttach, aProjector.Point (aPointIt)))
- : gp_Dir (aD1U ^ aD1V);
-
- if (aFirstSurfN.IsParallel (aLocalDir, Precision::Angular()) && aProjector.Distance (aPointIt) < aMinDist)
- {
- aBestPointIndex = aPointIt;
- aMinDist = aProjector.Distance (aPointIt);
- }
- }
-
- if (aBestPointIndex == 0)
- {
- theSecondAttach = theFirstAttach;
- }
- else
- {
- theSecondAttach = aProjector.Point (aBestPointIndex);
- aProjector.Parameters (aBestPointIndex, aPU, aPV);
-
- // Now there is projection of FirstAttach onto SecondSurf in aProjector
- BRepTopAdaptor_FClass2d aClassifier (theSecondFace, Precision::Confusion());
-
- TopAbs_State aState =
- aClassifier.Perform (gp_Pnt2d (aPU, aPV), theSecondSurf->IsUPeriodic() || theSecondSurf->IsVPeriodic());
-
- if (aState == TopAbs_OUT || aState == TopAbs_UNKNOWN)
- {
- theSecondAttach = AIS::Nearest (theSecondFace, theSecondAttach);
- }
- }
-}
-
-gp_Pnt AIS::TranslatePointToBound( const gp_Pnt & aPoint, const gp_Dir & aDir, const Bnd_Box & aBndBox )
-{
- if (aBndBox.IsOut( aPoint ))
- return aPoint;
- else
- {
- gp_Pnt Result(0.0,0.0,0.0);
- TColStd_Array2OfReal Bound( 1, 3, 1, 2 );
- TColStd_Array1OfReal Origin( 1, 3 );
- TColStd_Array1OfReal Dir( 1, 3 );
- Standard_Real t;
-
- aBndBox.Get( Bound(1,1), Bound(2,1), Bound(3,1), Bound(1,2), Bound(2,2), Bound(3,2) );
- aPoint.Coord( Origin(1), Origin(2), Origin(3) );
- aDir.Coord( Dir(1), Dir(2), Dir(3) );
-
- Bnd_Box EnlargedBox = aBndBox;
- EnlargedBox.Enlarge( aBndBox.GetGap() + Precision::Confusion() );
-
- Standard_Boolean IsFound = Standard_False;
- for (Standard_Integer i = 1; i <= 3; i++)
- {
- if (Abs( Dir( i ) ) <= gp::Resolution())
- continue;
- for (Standard_Integer j = 1; j <= 2; j++)
- {
- t = (Bound( i, j ) - Origin( i )) / Dir( i );
- if (t < 0.0e0)
- continue;
- Result = aPoint.Translated( gp_Vec( aDir ) * t );
- if (! EnlargedBox.IsOut( Result ))
- {
- IsFound = Standard_True;
- break;
- }
- }
- if (IsFound) break;
- }
- return Result;
- }
-}
-
-
-//=======================================================================
-//function : InDomain
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS::InDomain(const Standard_Real fpar,
- const Standard_Real lpar,
- const Standard_Real para)
-{
- if (fpar >= 0.) {
- if(lpar > fpar)
- return ((para >= fpar) && (para <= lpar));
- else { // fpar > lpar
- Standard_Real delta = 2*M_PI-fpar;
- Standard_Real lp, par, fp;
- lp = lpar + delta;
- par = para + delta;
- while(lp > 2*M_PI) lp-=2*M_PI;
- while(par > 2*M_PI) par-=2*M_PI;
- fp = 0.;
- return ((par >= fp) && (par <= lp));
- }
-
- }
- if (para >= (fpar+2*M_PI)) return Standard_True;
- if (para <= lpar) return Standard_True;
- return Standard_False;
-}
-
-//=======================================================================
-//function : DistanceFromApex
-//purpose : calculates parametric length arc of ellipse
-//=======================================================================
-
-Standard_Real AIS::DistanceFromApex(const gp_Elips & elips,
- const gp_Pnt & Apex,
- const Standard_Real par)
-{
- Standard_Real dist;
- Standard_Real parApex = ElCLib::Parameter ( elips, Apex );
- if(parApex == 0.0 || parApex == M_PI)
- {//Major case
- if(parApex == 0.0) //pos Apex
- dist = (par < M_PI) ? par : (2*M_PI - par);
- else //neg Apex
- dist = (par < M_PI) ? ( M_PI - par) : ( par - M_PI );
- }
- else
- {// Minor case
- if(parApex == M_PI / 2) //pos Apex
- {
- if(par <= parApex + M_PI && par > parApex) // 3/2*M_PI < par < M_PI/2
- dist = par - parApex;
- else
- {
- if(par > parApex + M_PI) // 3/2*M_PI < par < 2*M_PI
- dist = 2*M_PI - par + parApex;
- else
- dist = parApex - par;
- }
- }
- else //neg Apex == 3/2*M_PI
- {
- if(par <= parApex && par >= M_PI/2) // M_PI/2 < par < 3/2*M_PI
- dist = parApex - par;
- else
- {
- if(par > parApex) // 3/2*M_PI < par < 2*M_PI
- dist = par - parApex;
- else
- dist = par + M_PI/2; // 0 < par < M_PI/2
- }
- }
- }
- return dist;
-}
-
-//=======================================================================
-//function : NearestApex
-//purpose :
-//=======================================================================
-
-gp_Pnt AIS::NearestApex(const gp_Elips & elips,
- const gp_Pnt & pApex,
- const gp_Pnt & nApex,
- const Standard_Real fpara,
- const Standard_Real lpara,
- Standard_Boolean & IsInDomain)
-{
- Standard_Real parP, parN;
- gp_Pnt EndOfArrow(0.0,0.0,0.0);
- IsInDomain = Standard_True;
- parP = ElCLib::Parameter ( elips, pApex );
- if(InDomain(fpara, lpara, parP)) EndOfArrow = pApex;
- else
- {
- parN = ElCLib::Parameter ( elips, nApex );
- if(InDomain(fpara, lpara, parN)) EndOfArrow = nApex;
- else {
- IsInDomain = Standard_False;
- Standard_Real posd = Min(DistanceFromApex (elips,pApex, fpara),
- DistanceFromApex (elips,pApex, lpara));
- Standard_Real negd = Min(DistanceFromApex (elips,nApex, fpara),
- DistanceFromApex (elips,nApex, lpara));
- if( posd < negd )
- EndOfArrow = pApex;
- else
- EndOfArrow = nApex;
- }
- }
- return EndOfArrow;
-}
-
-//=======================================================================
-//function : ComputeProjEdgePresentation
-//purpose :
-//=======================================================================
-
-void AIS::ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPresentation,
- const Handle(Prs3d_Drawer)& aDrawer,
- const TopoDS_Edge& anEdge,
- const Handle(Geom_Curve)& ProjCurve,
- const gp_Pnt& FirstP,
- const gp_Pnt& LastP,
- const Quantity_NameOfColor aColor,
- const Standard_Real aWidth,
- const Aspect_TypeOfLine aProjTOL,
- const Aspect_TypeOfLine aCallTOL)
-{
- if (!aDrawer->HasOwnWireAspect()){
- aDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aProjTOL,2.));}
- else {
- // CLE
- // const Handle(Prs3d_LineAspect)& li = aDrawer->WireAspect();
- Handle(Prs3d_LineAspect) li = aDrawer->WireAspect();
- // ENDCLE
- li->SetColor(aColor);
- li->SetTypeOfLine(aProjTOL);
- li->SetWidth(aWidth);
- }
-
- Standard_Real pf, pl;
- TopLoc_Location loc;
- Handle(Geom_Curve) curve;
- Standard_Boolean isInfinite;
- curve = BRep_Tool::Curve(anEdge,loc,pf,pl);
- isInfinite = (Precision::IsInfinite(pf) || Precision::IsInfinite(pl));
-
- TopoDS_Edge E;
-
- // Calculate presentation of the edge
- if (ProjCurve->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
- // CLE
- // Handle(Geom_Line) gl (Handle(Geom_Line)::DownCast (ProjCurve));
- Handle(Geom_Line) gl = Handle(Geom_Line)::DownCast (ProjCurve);
- // ENDCLE
- if ( !isInfinite) {
- pf = ElCLib::Parameter(gl->Lin(),FirstP);
- pl = ElCLib::Parameter(gl->Lin(),LastP);
- BRepBuilderAPI_MakeEdge MakEd(gl->Lin(), pf, pl);
- E = MakEd.Edge();
- }
- else {
- BRepBuilderAPI_MakeEdge MakEd(gl->Lin());
- E = MakEd.Edge();
- }
- }
- else if (ProjCurve->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
- // CLE
- // Handle(Geom_Circle) gc (Handle(Geom_Circle)::DownCast (ProjCurve));
- Handle(Geom_Circle) gc = Handle(Geom_Circle)::DownCast (ProjCurve);
- // ENDCLE
- pf = ElCLib::Parameter(gc->Circ(),FirstP);
- pl = ElCLib::Parameter(gc->Circ(),LastP);
- BRepBuilderAPI_MakeEdge MakEd(gc->Circ(),pf, pl);
- E = MakEd.Edge();
- }
- StdPrs_WFShape::Add (aPresentation, E, aDrawer);
-
- //Calculate the presentation of line connections
- aDrawer->WireAspect()->SetTypeOfLine(aCallTOL);
- if (!isInfinite) {
- gp_Pnt ppf(0.0,0.0,0.0), ppl(0.0,0.0,0.0);
- ppf = BRep_Tool::Pnt( TopExp::FirstVertex(TopoDS::Edge(anEdge)));
- ppl = BRep_Tool::Pnt( TopExp::LastVertex(TopoDS::Edge(anEdge)));
-
- // it is patch!
- if (FirstP.SquareDistance (ppf) > SquareTolerance)
- {
- BRepBuilderAPI_MakeEdge MakEd1 (FirstP, ppf);
- StdPrs_WFShape::Add (aPresentation, MakEd1.Edge(), aDrawer);
- }
- else
- {
- BRepBuilderAPI_MakeVertex MakVert1 (FirstP);
- StdPrs_WFShape::Add (aPresentation, MakVert1.Vertex(), aDrawer);
- }
- if (LastP.SquareDistance (ppl) > SquareTolerance)
- {
- BRepBuilderAPI_MakeEdge MakEd2 (LastP, ppl);
- StdPrs_WFShape::Add (aPresentation, MakEd2.Edge(), aDrawer);
- }
- else
- {
- BRepBuilderAPI_MakeVertex MakVert2 (LastP);
- StdPrs_WFShape::Add (aPresentation, MakVert2.Vertex(), aDrawer);
- }
-/*
- BRepBuilderAPI_MakeEdge MakEd1 (FirstP, ppf);
- StdPrs_WFShape::Add (aPresentation, MakEd1.Edge(), aDrawer);
- BRepBuilderAPI_MakeEdge MakEd2 (LastP, ppl);
- StdPrs_WFShape::Add (aPresentation, MakEd2.Edge(), aDrawer);
-*/
- }
-}
-
-//=======================================================================
-//function : ComputeProjVertexPresentation
-//purpose :
-//=======================================================================
-
-void AIS::ComputeProjVertexPresentation (const Handle( Prs3d_Presentation )& aPresentation,
- const Handle( Prs3d_Drawer )& aDrawer,
- const TopoDS_Vertex& aVertex,
- const gp_Pnt& ProjPoint,
- const Quantity_NameOfColor aColor,
- const Standard_Real aWidth,
- const Aspect_TypeOfMarker aProjTOM,
- const Aspect_TypeOfLine aCallTOL)
-{
- if (!aDrawer->HasOwnPointAspect()){
- aDrawer->SetPointAspect(new Prs3d_PointAspect(aProjTOM, aColor,1));}
- else {
- // CLE
- // const Handle(Prs3d_PointAspect)& pa = aDrawer->PointAspect();
- Handle(Prs3d_PointAspect) pa = aDrawer->PointAspect();
- // ENDCLE
- pa->SetColor(aColor);
- pa->SetTypeOfMarker(aProjTOM);
- }
-
- // calculate the projection
- StdPrs_Point::Add(aPresentation, new Geom_CartesianPoint(ProjPoint), aDrawer);
-
- if (!aDrawer->HasOwnWireAspect()){
- aDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aCallTOL,2.));}
- else {
- // CLE
- // const Handle(Prs3d_LineAspect)& li = aDrawer->WireAspect();
- Handle(Prs3d_LineAspect) li = aDrawer->WireAspect();
- // ENDCLE
- li->SetColor(aColor);
- li->SetTypeOfLine(aCallTOL);
- li->SetWidth(aWidth);
- }
-
- // If the points are not mixed...
- if (!ProjPoint.IsEqual (BRep_Tool::Pnt (aVertex), Precision::Confusion()))
- {
- // calculate the lines of recall
- BRepBuilderAPI_MakeEdge MakEd (ProjPoint, BRep_Tool::Pnt (aVertex));
- StdPrs_WFShape::Add (aPresentation, MakEd.Edge(), aDrawer);
- }
-}
#ifndef _AIS_HeaderFile
#define _AIS_HeaderFile
-#include <AIS_KindOfSurface.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <Aspect_TypeOfMarker.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <Quantity_NameOfColor.hxx>
-#include <Prs3d_Drawer.hxx>
#include <Prs3d_Presentation.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-class Bnd_Box;
-class Geom_Curve;
-class Geom_Plane;
-class Geom_Surface;
-class TopoDS_Edge;
-class TopoDS_Face;
-class TopoDS_Shape;
-class TopoDS_Vertex;
//! Application Interactive Services provide the means to create links between an application GUI viewer and
//! the packages which are used to manage selection and presentation.
DEFINE_STANDARD_ALLOC
-
-
- //! Returns the nearest point in a shape. This is used by
- //! several classes in calculation of dimensions.
- Standard_EXPORT static gp_Pnt Nearest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
-
-
- //! @return the nearest point on the line.
- Standard_EXPORT static gp_Pnt Nearest (const gp_Lin& theLine, const gp_Pnt& thePoint);
-
-
- //! For the given point finds nearest point on the curve,
- //! @return TRUE if found point is belongs to the curve
- //! and FALSE otherwise.
- Standard_EXPORT static Standard_Boolean Nearest (const Handle(Geom_Curve)& theCurve, const gp_Pnt& thePoint, const gp_Pnt& theFirstPoint, const gp_Pnt& theLastPoint, gp_Pnt& theNearestPoint);
-
- Standard_EXPORT static gp_Pnt Farest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
-
- //! Used by 2d Relation only
- //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
- //! and the extremities if any
- //! Return TRUE if ok.
- Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt);
-
- //! Used by dimensions only.
- //! Computes the 3d geometry of <anEdge>.
- //! Return TRUE if ok.
- Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Standard_Boolean& theIsInfinite);
-
- //! Used by 2d Relation only
- //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
- //! and the extremities if any.
- //! If <aCurve> is not in the current plane, <extCurve> contains
- //! 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.
- Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsInfinite, Standard_Boolean& theIsOnPlane, const Handle(Geom_Plane)& thePlane);
-
- //! Used by 2d Relation only
- //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
- //! and the extremities if any
- //! Return TRUE if ok.
- Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, const Handle(Geom_Plane)& thePlane);
-
- //! Used by dimensions only.Computes the 3d geometry
- //! of<anEdge1> and <anEdge2> and checks if they are infinite.
- Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2);
-
- //! 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
- //! (not projected in the plane) of the first edge if
- //! <indexExt> =1 or of the 2nd edge if <indexExt> = 2. If
- //! <indexExt> = 0, ExtCurve is Null. if there is an edge
- //! external to the plane, <isinfinite> is true if this
- //! edge is infinite. So, the extremities of it are not
- //! significant. Return TRUE if ok
- Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Standard_Integer& theExtIndex, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2, const Handle(Geom_Plane)& thePlane);
-
- //! Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
- //! and returns aCurve;
- //! Return TRUE if ok
- Standard_EXPORT static Standard_Boolean ComputeGeomCurve (Handle(Geom_Curve)& aCurve, const Standard_Real first1, const Standard_Real last1, gp_Pnt& FirstPnt1, gp_Pnt& LastPnt1, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane);
-
- Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Vertex& aVertex, gp_Pnt& point, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane);
-
- //! 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
- Standard_EXPORT static Standard_Boolean GetPlaneFromFace (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurf, AIS_KindOfSurface& aSurfType, Standard_Real& Offset);
-
- Standard_EXPORT static void InitFaceLength (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurface, AIS_KindOfSurface& aSurfaceType, Standard_Real& anOffset);
-
- //! 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.
- Standard_EXPORT static void InitLengthBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, Handle(Geom_Surface)& theFirstSurf, Handle(Geom_Surface)& theSecondSurf, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, gp_Dir& theDirOnPlane);
-
- //! Finds three points for the angle dimension between
- //! two planes.
- Standard_EXPORT static Standard_Boolean InitAngleBetweenPlanarFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False);
-
- //! Finds three points for the angle dimension between
- //! two curvilinear surfaces.
- Standard_EXPORT static Standard_Boolean InitAngleBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, const AIS_KindOfSurface theFirstSurfType, const AIS_KindOfSurface theSecondSurfType, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False);
-
- Standard_EXPORT static gp_Pnt ProjectPointOnPlane (const gp_Pnt& aPoint, const gp_Pln& aPlane);
-
- Standard_EXPORT static gp_Pnt ProjectPointOnLine (const gp_Pnt& aPoint, const gp_Lin& aLine);
-
- Standard_EXPORT static gp_Pnt TranslatePointToBound (const gp_Pnt& aPoint, const gp_Dir& aDir, const Bnd_Box& aBndBox);
-
- //! returns True if point with anAttachPar is
- //! in domain of arc
- Standard_EXPORT static Standard_Boolean InDomain (const Standard_Real aFirstPar, const Standard_Real aLastPar, const Standard_Real anAttachPar);
-
- //! computes nearest to ellipse arc apex
- Standard_EXPORT static gp_Pnt NearestApex (const gp_Elips& elips, const gp_Pnt& pApex, const gp_Pnt& nApex, const Standard_Real fpara, const Standard_Real lpara, Standard_Boolean& IsInDomain);
-
- //! computes length of ellipse arc in parametric units
- Standard_EXPORT static Standard_Real DistanceFromApex (const gp_Elips& elips, const gp_Pnt& Apex, const Standard_Real par);
-
- Standard_EXPORT static void ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Edge& anEdge, const Handle(Geom_Curve)& ProjCurve, const gp_Pnt& FirstP, const gp_Pnt& LastP, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfLine aProjTOL = Aspect_TOL_DASH, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
-
- Standard_EXPORT static void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
-
};
#endif // _AIS_HeaderFile
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Arnaud BOUZY/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AIS_AngleDimension.hxx>
-
-#include <AIS.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepLib_MakeVertex.hxx>
-#include <BRep_Tool.hxx>
-#include <ElCLib.hxx>
-#include <GCPnts_UniformAbscissa.hxx>
-#include <GC_MakeArcOfCircle.hxx>
-#include <gce_MakeLin2d.hxx>
-#include <gce_MakeLin.hxx>
-#include <gce_MakeCirc.hxx>
-#include <gce_MakeCone.hxx>
-#include <gce_MakePln.hxx>
-#include <gce_MakeDir.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <Geom_ConicalSurface.hxx>
-#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_OffsetSurface.hxx>
-#include <Graphic3d_ArrayOfSegments.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <IntAna2d_AnaIntersection.hxx>
-#include <ProjLib.hxx>
-#include <Prs3d_Root.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
-#include <Select3D_SensitiveGroup.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_ProgramError.hxx>
-#include <UnitsAPI.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_AngleDimension,AIS_Dimension)
-
-namespace
-{
- static const TCollection_ExtendedString THE_EMPTY_LABEL_STRING;
- static const Standard_Real THE_EMPTY_LABEL_WIDTH = 0.0;
- static const Standard_ExtCharacter THE_DEGREE_SYMBOL (0x00B0);
- static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
-
- //! Returns true if the given points lie on a same line.
- static Standard_Boolean isSameLine (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theCenterPoint,
- const gp_Pnt& theSecondPoint)
- {
- gp_Vec aVec1 (theFirstPoint, theCenterPoint);
- gp_Vec aVec2 (theCenterPoint, theSecondPoint);
-
- return aVec1.IsParallel (aVec2, Precision::Angular());
- }
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
- const TopoDS_Edge& theSecondEdge)
-: AIS_Dimension (AIS_KOD_PLANEANGLE)
-{
- Init();
- SetMeasuredGeometry (theFirstEdge, theSecondEdge);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const gp_Pnt& theThirdPoint)
-: AIS_Dimension (AIS_KOD_PLANEANGLE)
-{
- Init();
- SetMeasuredGeometry (theFirstPoint, theSecondPoint, theThirdPoint);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Vertex& theFirstVertex,
- const TopoDS_Vertex& theSecondVertex,
- const TopoDS_Vertex& theThirdVertex)
-: AIS_Dimension (AIS_KOD_PLANEANGLE)
-{
- Init();
- SetMeasuredGeometry (theFirstVertex, theSecondVertex, theThirdVertex);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone)
-: AIS_Dimension (AIS_KOD_PLANEANGLE)
-{
- Init();
- SetMeasuredGeometry (theCone);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace)
-: AIS_Dimension (AIS_KOD_PLANEANGLE)
-{
- Init();
- SetMeasuredGeometry (theFirstFace, theSecondFace);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace,
- const gp_Pnt& thePoint)
-: AIS_Dimension (AIS_KOD_PLANEANGLE)
-{
- Init();
- SetMeasuredGeometry (theFirstFace, theSecondFace, thePoint);
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge,
- const TopoDS_Edge& theSecondEdge)
-{
- gp_Pln aComputedPlane;
-
- myFirstShape = theFirstEdge;
- mySecondShape = theSecondEdge;
- myThirdShape = TopoDS_Shape();
- myGeometryType = GeometryType_Edges;
- myIsGeometryValid = InitTwoEdgesAngle (aComputedPlane);
-
- if (myIsGeometryValid && !myIsPlaneCustom)
- {
- myPlane = aComputedPlane;
- }
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const gp_Pnt& theThirdPoint)
-{
- myFirstPoint = theFirstPoint;
- myCenterPoint = theSecondPoint;
- mySecondPoint = theThirdPoint;
- myFirstShape = BRepLib_MakeVertex (myFirstPoint);
- mySecondShape = BRepLib_MakeVertex (myCenterPoint);
- myThirdShape = BRepLib_MakeVertex (mySecondPoint);
- myGeometryType = GeometryType_Points;
- myIsGeometryValid = IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
-
- Standard_Boolean anIsSameLine = isSameLine (myFirstPoint, myCenterPoint, mySecondPoint);
- if (myIsGeometryValid && !myIsPlaneCustom && !anIsSameLine)
- {
- ComputePlane();
- }
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Vertex& theFirstVertex,
- 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;
- myIsGeometryValid = IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
-
- Standard_Boolean anIsSameLine = isSameLine (myFirstPoint, myCenterPoint, mySecondPoint);
- if (myIsGeometryValid && !myIsPlaneCustom && !anIsSameLine)
- {
- ComputePlane();
- }
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theCone)
-{
- myFirstShape = theCone;
- mySecondShape = TopoDS_Shape();
- myThirdShape = TopoDS_Shape();
- myGeometryType = GeometryType_Face;
- myIsGeometryValid = InitConeAngle();
-
- if (myIsGeometryValid && !myIsPlaneCustom)
- {
- ComputePlane();
- }
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace)
-{
- myFirstShape = theFirstFace;
- mySecondShape = theSecondFace;
- myThirdShape = TopoDS_Shape();
- myGeometryType = GeometryType_Faces;
- myIsGeometryValid = InitTwoFacesAngle();
-
- if (myIsGeometryValid && !myIsPlaneCustom)
- {
- ComputePlane();
- }
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-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;
- myIsGeometryValid = InitTwoFacesAngle (thePoint);
-
- if (myIsGeometryValid && !myIsPlaneCustom)
- {
- ComputePlane();
- }
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : Init
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::Init()
-{
- SetType (AIS_TOA_Interior);
- SetArrowsVisibility (AIS_TOAV_Both);
- SetSpecialSymbol (THE_DEGREE_SYMBOL);
- SetDisplaySpecialSymbol (AIS_DSS_After);
- SetFlyout (15.0);
-}
-
-//=======================================================================
-//function: GetCenterOnArc
-//purpose :
-//=======================================================================
-gp_Pnt AIS_AngleDimension::GetCenterOnArc (const gp_Pnt& theFirstAttach,
- const gp_Pnt& theSecondAttach,
- const gp_Pnt& theCenter) const
-{
- // construct plane where the circle and the arc are located
- gce_MakePln aConstructPlane (theFirstAttach, theSecondAttach, theCenter);
- if (!aConstructPlane.IsDone())
- {
- return gp::Origin();
- }
-
- gp_Pln aPlane = aConstructPlane.Value();
- // to have an exterior angle presentation, a plane for further constructed circle should be reversed
- if (myType == AIS_TOA_Exterior)
- {
- gp_Ax1 anAxis = aPlane.Axis();
- gp_Dir aDir = anAxis.Direction();
- aDir.Reverse();
- aPlane.SetAxis(gp_Ax1(anAxis.Location(), aDir));
- }
-
- Standard_Real aRadius = theFirstAttach.Distance (theCenter);
-
- // construct circle forming the arc
- gce_MakeCirc aConstructCircle (theCenter, aPlane, aRadius);
- if (!aConstructCircle.IsDone())
- {
- return gp::Origin();
- }
-
- gp_Circ aCircle = aConstructCircle.Value();
-
- // compute angle parameters of arc end-points on circle
- Standard_Real aParamBeg = ElCLib::Parameter (aCircle, theFirstAttach);
- Standard_Real aParamEnd = ElCLib::Parameter (aCircle, theSecondAttach);
- ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd);
-
- return ElCLib::Value ((aParamBeg + aParamEnd) * 0.5, aCircle);
-}
-
-//=======================================================================
-//function : GetNormalForMinAngle
-//purpose :
-//=======================================================================
-gp_Dir AIS_AngleDimension::GetNormalForMinAngle() const
-{
- const gp_Dir& aNormal = myPlane.Axis().Direction();
- gp_Dir aFirst (gp_Vec (myCenterPoint, myFirstPoint) );
- gp_Dir aSecond (gp_Vec (myCenterPoint, mySecondPoint) );
-
- return aFirst.AngleWithRef (aSecond, aNormal) < 0.0
- ? aNormal.Reversed()
- : aNormal;
-}
-
-//=======================================================================
-//function : DrawArc
-//purpose : draws the arc between two attach points
-//=======================================================================
-void AIS_AngleDimension::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)
-{
- gp_Pln aPlane (myCenterPoint, GetNormalForMinAngle());
-
- // to have an exterior angle presentation, a plane for further constructed circle should be reversed
- if (myType == AIS_TOA_Exterior)
- {
- gp_Ax1 anAxis = aPlane.Axis();
- gp_Dir aDir = anAxis.Direction();
- aDir.Reverse();
- aPlane.SetAxis(gp_Ax1(anAxis.Location(), aDir));
- }
-
- // construct circle forming the arc
- gce_MakeCirc aConstructCircle (theCenter, aPlane, theRadius);
- if (!aConstructCircle.IsDone())
- {
- return;
- }
-
- gp_Circ aCircle = aConstructCircle.Value();
-
- // construct the arc
- GC_MakeArcOfCircle aConstructArc (aCircle, theFirstAttach, theSecondAttach, Standard_True);
- if (!aConstructArc.IsDone())
- {
- return;
- }
-
- // generate points with specified deflection
- const Handle(Geom_TrimmedCurve)& anArcCurve = aConstructArc.Value();
-
- GeomAdaptor_Curve anArcAdaptor (anArcCurve, anArcCurve->FirstParameter(), anArcCurve->LastParameter());
-
- // compute number of discretization elements in old-fanshioned way
- gp_Vec aCenterToFirstVec (theCenter, theFirstAttach);
- gp_Vec aCenterToSecondVec (theCenter, theSecondAttach);
- Standard_Real anAngle = aCenterToFirstVec.Angle (aCenterToSecondVec);
- if (myType == AIS_TOA_Exterior)
- anAngle = 2.0 * M_PI - anAngle;
- // it sets 50 points on PI, and a part of points if angle is less
- const Standard_Integer aNbPoints = Max (4, Standard_Integer (50.0 * anAngle / M_PI));
-
- GCPnts_UniformAbscissa aMakePnts (anArcAdaptor, aNbPoints);
- if (!aMakePnts.IsDone())
- {
- return;
- }
-
- // init data arrays for graphical and selection primitives
- Handle(Graphic3d_ArrayOfPolylines) aPrimSegments = new Graphic3d_ArrayOfPolylines (aNbPoints);
-
- SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
-
- // load data into arrays
- for (Standard_Integer aPntIt = 1; aPntIt <= aMakePnts.NbPoints(); ++aPntIt)
- {
- gp_Pnt aPnt = anArcAdaptor.Value (aMakePnts.Parameter (aPntIt));
-
- aPrimSegments->AddVertex (aPnt);
-
- aSensitiveCurve.Append (aPnt);
- }
-
- // add display presentation
- if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
- {
- Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True);
- }
- Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
- Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionLineStyle);
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
- if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
- {
- Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False);
- }
-}
-
-//=======================================================================
-//function: DrawArcWithText
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::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)
-{
- gp_Pln aPlane (myCenterPoint, GetNormalForMinAngle());
-
- Standard_Real aRadius = theFirstAttach.Distance (myCenterPoint);
-
- // construct circle forming the arc
- gce_MakeCirc aConstructCircle (theCenter, aPlane, aRadius);
- if (!aConstructCircle.IsDone())
- {
- return;
- }
-
- gp_Circ aCircle = aConstructCircle.Value();
-
- // compute angle parameters of arc end-points on circle
- Standard_Real aParamBeg = ElCLib::Parameter (aCircle, theFirstAttach);
- Standard_Real aParamEnd = ElCLib::Parameter (aCircle, theSecondAttach);
- ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd);
-
- // middle point of arc parameter on circle
- Standard_Real aParamMid = (aParamBeg + aParamEnd) * 0.5;
-
- // add text graphical primitives
- if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
- {
- gp_Pnt aTextPos = ElCLib::Value (aParamMid, aCircle);
- gp_Dir aTextDir = gce_MakeDir (theFirstAttach, theSecondAttach);
-
- // Drawing text
- drawText (thePresentation,
- aTextPos,
- aTextDir,
- theText,
- theLabelPosition);
- }
-
- if (theMode != ComputeMode_All && theMode != ComputeMode_Line)
- {
- return;
- }
-
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
-
- Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
- && aDimensionAspect->IsText3d();
-
- if (isLineBreak)
- {
- // compute gap for label as parameteric size of sector on circle segment
- Standard_Real aSectorOfText = theTextWidth / aRadius;
- Standard_Real aTextBegin = aParamMid - aSectorOfText * 0.5;
- Standard_Real aTextEnd = aParamMid + aSectorOfText * 0.5;
- gp_Pnt aTextPntBeg = ElCLib::Value (aTextBegin, aCircle);
- gp_Pnt aTextPntEnd = ElCLib::Value (aTextEnd, aCircle);
-
- // Drawing arcs
- if (aTextBegin > aParamBeg)
- {
- DrawArc (thePresentation, theFirstAttach, aTextPntBeg, theCenter, aRadius, theMode);
- }
- if (aTextEnd < aParamEnd)
- {
- DrawArc (thePresentation, aTextPntEnd, theSecondAttach, theCenter, aRadius, theMode);
- }
- }
- else
- {
- DrawArc (thePresentation, theFirstAttach, theSecondAttach, theCenter, aRadius, theMode);
- }
-}
-
-//=======================================================================
-//function : CheckPlane
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_AngleDimension::CheckPlane (const gp_Pln& thePlane)const
-{
- if (!thePlane.Contains (myFirstPoint, Precision::Confusion()) &&
- !thePlane.Contains (mySecondPoint, Precision::Confusion()) &&
- !thePlane.Contains (myCenterPoint, Precision::Confusion()))
- {
- return Standard_False;
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputePlane
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::ComputePlane()
-{
- if (!myIsGeometryValid)
- {
- return;
- }
-
- // Compute working plane so that Y axis is codirectional
- // with Y axis of text coordinate system (necessary for text alignment)
- gp_Vec aFirstVec = gp_Vec (myCenterPoint, myFirstPoint);
- gp_Vec aSecondVec = gp_Vec (myCenterPoint, mySecondPoint);
- gp_Vec aDirectionN = aSecondVec ^ aFirstVec;
- gp_Vec aDirectionY = aFirstVec + aSecondVec;
- gp_Vec aDirectionX = aDirectionY ^ aDirectionN;
-
- myPlane = gp_Pln (gp_Ax3 (myCenterPoint, gp_Dir (aDirectionN), gp_Dir (aDirectionX)));
-}
-
-//=======================================================================
-//function : GetModelUnits
-//purpose :
-//=======================================================================
-const TCollection_AsciiString& AIS_AngleDimension::GetModelUnits() const
-{
- return myDrawer->DimAngleModelUnits();
-}
-
-//=======================================================================
-//function : GetDisplayUnits
-//purpose :
-//=======================================================================
-const TCollection_AsciiString& AIS_AngleDimension::GetDisplayUnits() const
-{
- return myDrawer->DimAngleDisplayUnits();
-}
-
-//=======================================================================
-//function : SetModelUnits
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::SetModelUnits (const TCollection_AsciiString& theUnits)
-{
- myDrawer->SetDimAngleModelUnits (theUnits);
-}
-
-//=======================================================================
-//function : SetDisplayUnits
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
-{
- myDrawer->SetDimAngleDisplayUnits (theUnits);
-}
-
-//=======================================================================
-//function : ComputeValue
-//purpose :
-//=======================================================================
-Standard_Real AIS_AngleDimension::ComputeValue() const
-{
- if (!IsValid())
- {
- return 0.0;
- }
-
- gp_Vec aVec1 (myCenterPoint, myFirstPoint);
- gp_Vec aVec2 (myCenterPoint, mySecondPoint);
-
- Standard_Real anAngle = aVec1.AngleWithRef (aVec2, GetNormalForMinAngle());
-
- return anAngle > 0.0 ? anAngle : (2.0 * M_PI + anAngle);
-}
-
-//=======================================================================
-//function : Compute
-//purpose : Having three gp_Pnt points compute presentation
-//=======================================================================
-void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode)
-{
- mySelectionGeom.Clear (theMode);
-
- if (!IsValid())
- {
- return;
- }
-
- // Parameters for presentation
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
-
- Prs3d_Root::CurrentGroup(thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
-
- Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
-
- // prepare label string and compute its geometrical width
- Standard_Real aLabelWidth;
- TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
-
- // add margins to label width
- if (aDimensionAspect->IsText3d())
- {
- aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0;
- }
-
- // Get parameters from aspect or adjust it according with custom text position
- Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
- Prs3d_DimensionTextHorizontalPosition aHorisontalTextPos = aDimensionAspect->TextHorizontalPosition();
-
- if (IsTextPositionCustom())
- {
- AdjustParameters (myFixedTextPosition,anExtensionSize, aHorisontalTextPos, myFlyout);
- }
-
- // Handle user-defined and automatic arrow placement
- Standard_Boolean isArrowsExternal = Standard_False;
- Standard_Integer aLabelPosition = LabelPosition_None;
-
- FitTextAlignment (aHorisontalTextPos, aLabelPosition, isArrowsExternal);
-
- gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
- gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
-
- //Arrows positions and directions
- gp_Vec aWorkingPlaneDir (GetNormalForMinAngle());
-
- gp_Dir aFirstExtensionDir = aWorkingPlaneDir.Reversed() ^ gp_Vec (myCenterPoint, aFirstAttach);
- gp_Dir aSecondExtensionDir = aWorkingPlaneDir ^ gp_Vec (myCenterPoint, aSecondAttach);
-
- gp_Vec aFirstArrowVec = gp_Vec (aFirstExtensionDir) * anArrowLength;
- gp_Vec aSecondArrowVec = gp_Vec (aSecondExtensionDir) * anArrowLength;
-
- if (isArrowsExternal)
- {
- aFirstArrowVec.Reverse();
- aSecondArrowVec.Reverse();
- }
-
- gp_Pnt aFirstArrowBegin (0.0, 0.0, 0.0);
- gp_Pnt aFirstArrowEnd (0.0, 0.0, 0.0);
- gp_Pnt aSecondArrowBegin (0.0, 0.0, 0.0);
- gp_Pnt aSecondArrowEnd (0.0, 0.0, 0.0);
-
- aFirstArrowBegin = aFirstAttach;
- aSecondArrowBegin = aSecondAttach;
- aFirstArrowEnd = aFirstAttach.Translated (-aFirstArrowVec);
- aSecondArrowEnd = aSecondAttach.Translated (-aSecondArrowVec);
-
- // Group1: stenciling text and the angle dimension arc
- Prs3d_Root::NewGroup (thePresentation);
-
- Standard_Integer aHPosition = aLabelPosition & LabelPosition_HMask;
-
- // draw text label
- switch (aHPosition)
- {
- case LabelPosition_HCenter :
- {
- Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
- && aDimensionAspect->IsText3d();
-
- if (isLineBreak)
- {
- DrawArcWithText (thePresentation,
- aFirstAttach,
- aSecondAttach,
- myCenterPoint,
- aLabelString,
- aLabelWidth,
- theMode,
- aLabelPosition);
- break;
- }
-
- // compute text primitives
- if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
- {
- gp_Vec aDimensionDir (aFirstAttach, aSecondAttach);
- gp_Pnt aTextPos = IsTextPositionCustom() ? myFixedTextPosition
- : GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint);
- gp_Dir aTextDir = aDimensionDir;
-
- drawText (thePresentation,
- aTextPos,
- aTextDir,
- aLabelString,
- aLabelPosition);
- }
-
- if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
- {
- DrawArc (thePresentation,
- (isArrowsExternal || !isArrowVisible(AIS_TOAV_First)) ? aFirstAttach : aFirstArrowEnd,
- (isArrowsExternal || !isArrowVisible(AIS_TOAV_Second)) ? aSecondAttach : aSecondArrowEnd,
- myCenterPoint,
- Abs (GetFlyout()),
- theMode);
- }
- }
- break;
-
- case LabelPosition_Left :
- {
- DrawExtension (thePresentation,
- anExtensionSize,
- (isArrowsExternal && isArrowVisible(AIS_TOAV_First)) ? aFirstArrowEnd : aFirstAttach,
- aFirstExtensionDir,
- aLabelString,
- aLabelWidth,
- theMode,
- aLabelPosition);
- }
- break;
-
- case LabelPosition_Right :
- {
- DrawExtension (thePresentation,
- anExtensionSize,
- (isArrowsExternal && isArrowVisible(AIS_TOAV_Second)) ? aSecondArrowEnd : aSecondAttach,
- aSecondExtensionDir,
- aLabelString,
- aLabelWidth,
- theMode,
- aLabelPosition);
- }
- break;
- }
-
- // dimension arc without text
- if ((theMode == ComputeMode_All || theMode == ComputeMode_Line) && aHPosition != LabelPosition_HCenter)
- {
- Prs3d_Root::NewGroup (thePresentation);
-
- DrawArc (thePresentation,
- (isArrowsExternal || !isArrowVisible(AIS_TOAV_First)) ? aFirstAttach : aFirstArrowEnd,
- (isArrowsExternal || !isArrowVisible(AIS_TOAV_Second)) ? aSecondAttach : aSecondArrowEnd,
- myCenterPoint,
- Abs(GetFlyout ()),
- theMode);
- }
-
- // arrows and arrow extensions
- if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
- {
- Prs3d_Root::NewGroup (thePresentation);
-
- if (isArrowVisible(AIS_TOAV_First))
- DrawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec));
- if (isArrowVisible(AIS_TOAV_Second))
- DrawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec));
- }
-
- if ((theMode == ComputeMode_All || theMode == ComputeMode_Line) && isArrowsExternal)
- {
- Prs3d_Root::NewGroup (thePresentation);
-
- if (aHPosition != LabelPosition_Left && isArrowVisible(AIS_TOAV_First))
- {
- DrawExtension (thePresentation,
- aDimensionAspect->ArrowTailSize(),
- aFirstArrowEnd,
- aFirstExtensionDir,
- THE_EMPTY_LABEL_STRING,
- THE_EMPTY_LABEL_WIDTH,
- theMode,
- LabelPosition_None);
- }
-
- if (aHPosition != LabelPosition_Right && isArrowVisible(AIS_TOAV_Second))
- {
- DrawExtension (thePresentation,
- aDimensionAspect->ArrowTailSize(),
- aSecondArrowEnd,
- aSecondExtensionDir,
- THE_EMPTY_LABEL_STRING,
- THE_EMPTY_LABEL_WIDTH,
- theMode,
- LabelPosition_None);
- }
- }
-
- // flyouts
- if (theMode == ComputeMode_All)
- {
- Prs3d_Root::NewGroup (thePresentation);
-
- Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (4);
- aPrimSegments->AddVertex (myCenterPoint);
- aPrimSegments->AddVertex (aFirstAttach);
- aPrimSegments->AddVertex (myCenterPoint);
- aPrimSegments->AddVertex (aSecondAttach);
-
- Handle(Graphic3d_AspectLine3d) aFlyoutStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
- Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aFlyoutStyle);
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
- }
-
- mySelectionGeom.IsComputed = Standard_True;
-}
-
-//=======================================================================
-//function : ComputeFlyoutSelection
-//purpose : computes selection for flyouts
-//=======================================================================
-void AIS_AngleDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Handle(SelectMgr_EntityOwner)& theOwner)
-{
- gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
- gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
-
- Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (theOwner);
- aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myCenterPoint, aFirstAttach));
- aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myCenterPoint, aSecondAttach));
-
- theSelection->Add (aSensitiveEntity);
-}
-
-//=======================================================================
-//function : InitTwoEdgesAngle
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane)
-{
- TopoDS_Edge aFirstEdge = TopoDS::Edge (myFirstShape);
- TopoDS_Edge aSecondEdge = TopoDS::Edge (mySecondShape);
-
- BRepAdaptor_Curve aMakeFirstLine (aFirstEdge);
- BRepAdaptor_Curve aMakeSecondLine (aSecondEdge);
-
- if (aMakeFirstLine.GetType() != GeomAbs_Line || aMakeSecondLine.GetType() != GeomAbs_Line)
- {
- return Standard_False;
- }
-
- Handle(Geom_Line) aFirstLine = new Geom_Line (aMakeFirstLine.Line());
- Handle(Geom_Line) aSecondLine = new Geom_Line (aMakeSecondLine.Line());
-
- gp_Lin aFirstLin = aFirstLine->Lin();
- gp_Lin aSecondLin = aSecondLine->Lin();
-
- Standard_Boolean isParallelLines = aFirstLin.Direction().IsParallel (aSecondLin.Direction(), Precision::Angular());
-
- theComputedPlane = isParallelLines ? gp_Pln(gp::XOY())
- : gp_Pln (aSecondLin.Location(), gp_Vec (aFirstLin.Direction()) ^ gp_Vec (aSecondLin.Direction()));
-
- // Compute geometry for this plane and edges
- Standard_Boolean isInfinite1,isInfinite2;
- gp_Pnt aFirstPoint1, aLastPoint1, aFirstPoint2, aLastPoint2;
- Handle(Geom_Curve) aFirstCurve = aFirstLine, aSecondCurve = aSecondLine;
- if (!AIS::ComputeGeometry (aFirstEdge, aSecondEdge,
- aFirstCurve, aSecondCurve,
- aFirstPoint1, aLastPoint1,
- aFirstPoint2, aLastPoint2,
- isInfinite1, isInfinite2))
- {
- return Standard_False;
- }
-
- Standard_Boolean isSameLines = aFirstLin.Direction().IsEqual (aSecondLin.Direction(), Precision::Angular())
- && aFirstLin.Location().IsEqual (aSecondLin.Location(),Precision::Confusion());
-
- // It can be the same gp_Lin geometry but the different begin and end parameters
- Standard_Boolean isSameEdges =
- (aFirstPoint1.IsEqual (aFirstPoint2, Precision::Confusion()) && aLastPoint1.IsEqual (aLastPoint2, Precision::Confusion()))
- || (aFirstPoint1.IsEqual (aLastPoint2, Precision::Confusion()) && aLastPoint1.IsEqual (aFirstPoint2, Precision::Confusion()));
-
- if (isParallelLines)
- {
- // Zero angle, it could not handle this geometry
- if (isSameLines && isSameEdges)
- {
- return Standard_False;
- }
-
- // Handle the case of Pi angle
- const Standard_Real aParam11 = ElCLib::Parameter (aFirstLin, aFirstPoint1);
- const Standard_Real aParam12 = ElCLib::Parameter (aFirstLin, aLastPoint1);
- const Standard_Real aParam21 = ElCLib::Parameter (aFirstLin, aFirstPoint2);
- const Standard_Real aParam22 = ElCLib::Parameter (aFirstLin, aLastPoint2);
- myCenterPoint = ElCLib::Value ( (Min (aParam11, aParam12) + Max (aParam21, aParam22)) * 0.5, aFirstLin);
- myFirstPoint = myCenterPoint.Translated (gp_Vec (aFirstLin.Direction()) * Abs (GetFlyout()));
- mySecondPoint = myCenterPoint.XYZ() + (aFirstLin.Direction().IsEqual (aSecondLin.Direction(), Precision::Angular())
- ? aFirstLin.Direction().Reversed().XYZ() * Abs (GetFlyout())
- : aSecondLin.Direction().XYZ() * Abs (GetFlyout()));
- }
- else
- {
- // Find intersection
- gp_Lin2d aFirstLin2d = ProjLib::Project (theComputedPlane, aFirstLin);
- gp_Lin2d aSecondLin2d = ProjLib::Project (theComputedPlane, aSecondLin);
-
- IntAna2d_AnaIntersection anInt2d (aFirstLin2d, aSecondLin2d);
- gp_Pnt2d anIntersectPoint;
- if (!anInt2d.IsDone() || anInt2d.IsEmpty())
- {
- return Standard_False;
- }
-
- anIntersectPoint = gp_Pnt2d (anInt2d.Point(1).Value());
- myCenterPoint = ElCLib::To3d (theComputedPlane.Position().Ax2(), anIntersectPoint);
-
- if (isInfinite1 || isInfinite2)
- {
- myFirstPoint = myCenterPoint.Translated (gp_Vec (aFirstLin.Direction()) * Abs (GetFlyout()));
- mySecondPoint = myCenterPoint.Translated (gp_Vec (aSecondLin.Direction()) * Abs (GetFlyout()));
-
- return IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
- }
-
- // |
- // | <- dimension should be here
- // *----
- myFirstPoint = myCenterPoint.Distance (aFirstPoint1) > myCenterPoint.Distance (aLastPoint1)
- ? aFirstPoint1
- : aLastPoint1;
-
- mySecondPoint = myCenterPoint.Distance (aFirstPoint2) > myCenterPoint.Distance (aLastPoint2)
- ? aFirstPoint2
- : aLastPoint2;
- }
-
- return IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
-}
-
-//=======================================================================
-//function : InitTwoFacesAngle
-//purpose : initialization of angle dimension between two faces
-//=======================================================================
-Standard_Boolean AIS_AngleDimension::InitTwoFacesAngle()
-{
- TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
- TopoDS_Face aSecondFace = TopoDS::Face (mySecondShape);
-
- gp_Dir aFirstDir, aSecondDir;
- gp_Pln aFirstPln, aSecondPln;
- Handle(Geom_Surface) aFirstBasisSurf, aSecondBasisSurf;
- AIS_KindOfSurface aFirstSurfType, aSecondSurfType;
- Standard_Real aFirstOffset, aSecondOffset;
-
- AIS::GetPlaneFromFace (aFirstFace, aFirstPln,
- aFirstBasisSurf,aFirstSurfType,aFirstOffset);
-
- AIS::GetPlaneFromFace (aSecondFace, aSecondPln,
- aSecondBasisSurf, aSecondSurfType, aSecondOffset);
-
- if (aFirstSurfType == AIS_KOS_Plane && aSecondSurfType == AIS_KOS_Plane)
- {
- //Planar faces angle
- Handle(Geom_Plane) aFirstPlane = Handle(Geom_Plane)::DownCast (aFirstBasisSurf);
- Handle(Geom_Plane) aSecondPlane = Handle(Geom_Plane)::DownCast (aSecondBasisSurf);
- return AIS::InitAngleBetweenPlanarFaces (aFirstFace,
- aSecondFace,
- myCenterPoint,
- myFirstPoint,
- mySecondPoint)
- && IsValidPoints (myFirstPoint,
- myCenterPoint,
- mySecondPoint);
- }
- else
- {
- // Curvilinear faces angle
- return AIS::InitAngleBetweenCurvilinearFaces (aFirstFace,
- aSecondFace,
- aFirstSurfType,
- aSecondSurfType,
- myCenterPoint,
- myFirstPoint,
- mySecondPoint)
- && IsValidPoints (myFirstPoint,
- myCenterPoint,
- mySecondPoint);
- }
-}
-
-//=======================================================================
-//function : InitTwoFacesAngle
-//purpose : initialization of angle dimension between two faces
-//=======================================================================
-Standard_Boolean AIS_AngleDimension::InitTwoFacesAngle (const gp_Pnt thePointOnFirstFace)
-{
- TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
- TopoDS_Face aSecondFace = TopoDS::Face (mySecondShape);
-
- gp_Dir aFirstDir, aSecondDir;
- gp_Pln aFirstPln, aSecondPln;
- Handle(Geom_Surface) aFirstBasisSurf, aSecondBasisSurf;
- AIS_KindOfSurface aFirstSurfType, aSecondSurfType;
- Standard_Real aFirstOffset, aSecondOffset;
-
- AIS::GetPlaneFromFace (aFirstFace, aFirstPln,
- aFirstBasisSurf,aFirstSurfType,aFirstOffset);
-
- AIS::GetPlaneFromFace (aSecondFace, aSecondPln,
- aSecondBasisSurf, aSecondSurfType, aSecondOffset);
-
- myFirstPoint = thePointOnFirstFace;
- if (aFirstSurfType == AIS_KOS_Plane && aSecondSurfType == AIS_KOS_Plane)
- {
- //Planar faces angle
- Handle(Geom_Plane) aFirstPlane = Handle(Geom_Plane)::DownCast (aFirstBasisSurf);
- Handle(Geom_Plane) aSecondPlane = Handle(Geom_Plane)::DownCast (aSecondBasisSurf);
- return AIS::InitAngleBetweenPlanarFaces (aFirstFace,
- aSecondFace,
- myCenterPoint,
- myFirstPoint,
- mySecondPoint,
- Standard_True)
- && IsValidPoints (myFirstPoint,
- myCenterPoint,
- mySecondPoint);
- }
- else
- {
- // Curvilinear faces angle
- return AIS::InitAngleBetweenCurvilinearFaces (aFirstFace,
- aSecondFace,
- aFirstSurfType,
- aSecondSurfType,
- myCenterPoint,
- myFirstPoint,
- mySecondPoint,
- Standard_True)
- && IsValidPoints (myFirstPoint,
- myCenterPoint,
- mySecondPoint);
- }
-}
-
-//=======================================================================
-//function : InitConeAngle
-//purpose : initialization of the cone angle
-//=======================================================================
-Standard_Boolean AIS_AngleDimension::InitConeAngle()
-{
- if (myFirstShape.IsNull())
- {
- return Standard_False;
- }
-
- TopoDS_Face aConeShape = TopoDS::Face (myFirstShape);
- gp_Pln aPln;
- gp_Cone aCone;
- gp_Circ aCircle;
- // A surface from the Face
- Handle(Geom_Surface) aSurf;
- Handle(Geom_OffsetSurface) aOffsetSurf;
- Handle(Geom_ConicalSurface) aConicalSurf;
- Handle(Geom_SurfaceOfRevolution) aRevSurf;
- Handle(Geom_Line) aLine;
- BRepAdaptor_Surface aConeAdaptor (aConeShape);
- TopoDS_Face aFace;
- AIS_KindOfSurface aSurfType;
- Standard_Real anOffset = 0.;
- Handle(Standard_Type) aType;
-
- Standard_Real aMaxV = aConeAdaptor.FirstVParameter();
- Standard_Real aMinV = aConeAdaptor.LastVParameter();
-
- AIS::GetPlaneFromFace (aConeShape, aPln, aSurf, aSurfType, anOffset);
-
- if (aSurfType == AIS_KOS_Revolution)
- {
- // Surface of revolution
- aRevSurf = Handle(Geom_SurfaceOfRevolution)::DownCast(aSurf);
- gp_Lin aLin (aRevSurf->Axis());
- Handle(Geom_Curve) aBasisCurve = aRevSurf->BasisCurve();
- //Must be a part of line (basis curve should be linear)
- if (aBasisCurve ->DynamicType() != STANDARD_TYPE(Geom_Line))
- return Standard_False;
-
- gp_Pnt aFirst1 = aConeAdaptor.Value (0., aMinV);
- gp_Pnt aLast1 = aConeAdaptor.Value (0., aMaxV);
- gp_Vec aVec1 (aFirst1, aLast1);
-
- //Projection <aFirst> on <aLin>
- gp_Pnt aFirst2 = ElCLib::Value (ElCLib::Parameter (aLin, aFirst1), aLin);
- // Projection <aLast> on <aLin>
- gp_Pnt aLast2 = ElCLib::Value (ElCLib::Parameter (aLin, aLast1), aLin);
-
- gp_Vec aVec2 (aFirst2, aLast2);
-
- // Check if two parts of revolution are parallel (it's a cylinder) or normal (it's a circle).
- if (aVec1.IsParallel (aVec2, Precision::Angular())
- || aVec1.IsNormal (aVec2,Precision::Angular()))
- return Standard_False;
-
- gce_MakeCone aMkCone (aRevSurf->Axis(), aFirst1, aLast1);
- aCone = aMkCone.Value();
- myCenterPoint = aCone.Apex();
- }
- else
- {
- aType = aSurf->DynamicType();
- if (aType == STANDARD_TYPE(Geom_OffsetSurface) || anOffset > 0.01)
- {
- // Offset surface
- aOffsetSurf = new Geom_OffsetSurface (aSurf, anOffset);
- aSurf = aOffsetSurf->Surface();
- BRepBuilderAPI_MakeFace aMkFace(aSurf, Precision::Confusion());
- aMkFace.Build();
- if (!aMkFace.IsDone())
- return Standard_False;
- aConeAdaptor.Initialize (aMkFace.Face());
- }
- aCone = aConeAdaptor.Cone();
- aConicalSurf = Handle(Geom_ConicalSurface)::DownCast (aSurf);
- myCenterPoint = aConicalSurf->Apex();
- }
-
- // A circle where the angle is drawn
- Handle(Geom_Curve) aCurve;
- Standard_Real aMidV = ( aMinV + aMaxV ) / 2.5;
- aCurve = aSurf->VIso (aMidV);
- aCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ();
-
- aCurve = aSurf->VIso(aMaxV);
- gp_Circ aCircVmax = Handle(Geom_Circle)::DownCast(aCurve)->Circ();
- aCurve = aSurf->VIso(aMinV);
- gp_Circ aCircVmin = Handle(Geom_Circle)::DownCast(aCurve)->Circ();
-
- if (aCircVmax.Radius() < aCircVmin.Radius())
- {
- gp_Circ aTmpCirc = aCircVmax;
- aCircVmax = aCircVmin;
- aCircVmin = aTmpCirc;
- }
-
- myFirstPoint = ElCLib::Value (0, aCircle);
- mySecondPoint = ElCLib::Value (M_PI, aCircle);
- return Standard_True;
-}
-
-//=======================================================================
-//function : IsValidPoints
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_AngleDimension::IsValidPoints (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theCenterPoint,
- const gp_Pnt& theSecondPoint) const
-{
- return theFirstPoint.Distance (theCenterPoint) > Precision::Confusion()
- && theSecondPoint.Distance (theCenterPoint) > Precision::Confusion()
- && gp_Vec (theCenterPoint, theFirstPoint).Angle (
- gp_Vec (theCenterPoint, theSecondPoint)) > Precision::Angular();
-}
-
-//=======================================================================
-//function : isArrowVisible
-//purpose : compares given and internal arrows types, returns true if the the type should be shown
-//=======================================================================
-Standard_Boolean AIS_AngleDimension::isArrowVisible(const AIS_TypeOfAngleArrowVisibility& theArrowType) const
-{
- switch (theArrowType)
- {
- case AIS_TOAV_Both:
- return myArrowsVisibility == AIS_TOAV_Both;
- case AIS_TOAV_First:
- return myArrowsVisibility == AIS_TOAV_Both || myArrowsVisibility == AIS_TOAV_First;
- case AIS_TOAV_Second:
- return myArrowsVisibility == AIS_TOAV_Both || myArrowsVisibility == AIS_TOAV_Second;
- case AIS_TOAV_None:
- return false;
- }
- return false;
-}
-
-//=======================================================================
-//function : GetTextPosition
-//purpose :
-//=======================================================================
-const gp_Pnt AIS_AngleDimension::GetTextPosition() const
-{
- if (!IsValid())
- {
- return gp::Origin();
- }
-
- if (IsTextPositionCustom())
- {
- return myFixedTextPosition;
- }
-
- // Counts text position according to the dimension parameters
- gp_Pnt aTextPosition (gp::Origin());
-
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
-
- // Prepare label string and compute its geometrical width
- Standard_Real aLabelWidth;
- TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
-
- gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
- gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
-
- // Handle user-defined and automatic arrow placement
- Standard_Boolean isArrowsExternal = Standard_False;
- Standard_Integer aLabelPosition = LabelPosition_None;
- FitTextAlignment (aDimensionAspect->TextHorizontalPosition(),
- aLabelPosition, isArrowsExternal);
-
- // Get text position
- switch (aLabelPosition & LabelPosition_HMask)
- {
- case LabelPosition_HCenter:
- {
- aTextPosition = GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint);
- }
- break;
- case LabelPosition_Left:
- {
- gp_Dir aPlaneNormal = gp_Vec (aFirstAttach, aSecondAttach) ^ gp_Vec (myCenterPoint, aFirstAttach);
- gp_Dir anExtensionDir = aPlaneNormal ^ gp_Vec (myCenterPoint, aFirstAttach);
- Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
- Standard_Real anOffset = isArrowsExternal
- ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length()
- : anExtensionSize;
- gp_Vec anExtensionVec = gp_Vec (anExtensionDir) * -anOffset;
- aTextPosition = aFirstAttach.Translated (anExtensionVec);
- }
- break;
- case LabelPosition_Right:
- {
- gp_Dir aPlaneNormal = gp_Vec (aFirstAttach, aSecondAttach) ^ gp_Vec (myCenterPoint, aFirstAttach);
- gp_Dir anExtensionDir = aPlaneNormal ^ gp_Vec (myCenterPoint, aSecondAttach);
- Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
- Standard_Real anOffset = isArrowsExternal
- ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length()
- : anExtensionSize;
- gp_Vec anExtensionVec = gp_Vec (anExtensionDir) * anOffset;
- aTextPosition = aSecondAttach.Translated (anExtensionVec);
- }
- break;
- }
-
- return aTextPosition;
-}
-
-//=======================================================================
-//function : SetTextPosition
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::SetTextPosition (const gp_Pnt& theTextPos)
-{
- if (!IsValid())
- {
- return;
- }
-
- // The text position point for angle dimension should belong to the working plane.
- if (!GetPlane().Contains (theTextPos, Precision::Confusion()))
- {
- throw Standard_ProgramError("The text position point for angle dimension doesn't belong to the working plane.");
- }
-
- myIsTextPositionFixed = Standard_True;
- myFixedTextPosition = theTextPos;
-}
-
-//=======================================================================
-//function : AdjustParameters
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::AdjustParameters (const gp_Pnt& theTextPos,
- Standard_Real& theExtensionSize,
- Prs3d_DimensionTextHorizontalPosition& theAlignment,
- Standard_Real& theFlyout) const
-{
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
- Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
-
- // Build circle with radius that is equal to distance from text position to the center point.
- Standard_Real aRadius = gp_Vec (myCenterPoint, theTextPos).Magnitude();
-
- // Set attach points in positive direction of the flyout.
- gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, myFirstPoint).Normalized() * aRadius);
- gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, mySecondPoint).Normalized() * aRadius);
-
- gce_MakeCirc aConstructCircle (myCenterPoint, GetPlane(), aRadius);
- if (!aConstructCircle.IsDone())
- {
- return;
- }
- gp_Circ aCircle = aConstructCircle.Value();
-
- // Default values
- theExtensionSize = aDimensionAspect->ArrowAspect()->Length();
- theAlignment = Prs3d_DTHP_Center;
-
- Standard_Real aParamBeg = ElCLib::Parameter (aCircle, aFirstAttach);
- Standard_Real aParamEnd = ElCLib::Parameter (aCircle, aSecondAttach);
- if (aParamEnd < aParamBeg)
- {
- Standard_Real aParam = aParamEnd;
- aParamEnd = aParamBeg;
- aParamBeg = aParam;
- }
-
- ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd);
- Standard_Real aTextPar = ElCLib::Parameter (aCircle , theTextPos);
-
- // Horizontal center
- if (aTextPar > aParamBeg && aTextPar < aParamEnd)
- {
- theFlyout = aRadius;
- return;
- }
-
- aParamBeg += M_PI;
- aParamEnd += M_PI;
- ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd);
-
- if (aTextPar > aParamBeg && aTextPar < aParamEnd)
- {
- theFlyout = -aRadius;
- return;
- }
-
- // Text on the extensions
- gp_Lin aFirstLine = gce_MakeLin (myCenterPoint, myFirstPoint);
- gp_Lin aSecondLine = gce_MakeLin (myCenterPoint, mySecondPoint);
- gp_Pnt aFirstTextProj = AIS::Nearest (aFirstLine, theTextPos);
- gp_Pnt aSecondTextProj = AIS::Nearest (aSecondLine, theTextPos);
- Standard_Real aFirstDist = aFirstTextProj.Distance (theTextPos);
- Standard_Real aSecondDist = aSecondTextProj.Distance (theTextPos);
-
- if (aFirstDist <= aSecondDist)
- {
- aRadius = myCenterPoint.Distance (aFirstTextProj);
- Standard_Real aNewExtensionSize = aFirstDist - anArrowLength;
- theExtensionSize = aNewExtensionSize < 0.0 ? 0.0 : aNewExtensionSize;
-
- theAlignment = Prs3d_DTHP_Left;
-
- gp_Vec aPosFlyoutDir = gp_Vec (myCenterPoint, myFirstPoint).Normalized().Scaled (aRadius);
-
- theFlyout = aFirstTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()
- ? -aRadius : aRadius;
- }
- else
- {
- aRadius = myCenterPoint.Distance (aSecondTextProj);
-
- Standard_Real aNewExtensionSize = aSecondDist - anArrowLength;
-
- theExtensionSize = aNewExtensionSize < 0.0 ? 0.0 : aNewExtensionSize;
-
- theAlignment = Prs3d_DTHP_Right;
-
- gp_Vec aPosFlyoutDir = gp_Vec (myCenterPoint, mySecondPoint).Normalized().Scaled (aRadius);
-
- theFlyout = aSecondTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()
- ? -aRadius : aRadius;
- }
-}
-
-//=======================================================================
-//function : FitTextAlignment
-//purpose :
-//=======================================================================
-void AIS_AngleDimension::FitTextAlignment (const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
- Standard_Integer& theLabelPosition,
- Standard_Boolean& theIsArrowsExternal) const
-{
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
-
- Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
-
- // Prepare label string and compute its geometrical width
- Standard_Real aLabelWidth;
- TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
-
- // add margins to label width
- if (aDimensionAspect->IsText3d())
- {
- aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0;
- }
-
- gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
- gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
-
- // Handle user-defined and automatic arrow placement
- switch (aDimensionAspect->ArrowOrientation())
- {
- case Prs3d_DAO_External: theIsArrowsExternal = true; break;
- case Prs3d_DAO_Internal: theIsArrowsExternal = false; break;
- case Prs3d_DAO_Fit:
- {
- gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
- Standard_Real aDimensionWidth = anAttachVector.Magnitude();
-
- // Add margin to ensure a small tail between text and arrow
- Standard_Real anArrowMargin = aDimensionAspect->IsText3d()
- ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN
- : 0.0;
-
- Standard_Real anArrowsWidth = (anArrowLength + anArrowMargin) * 2.0;
-
- theIsArrowsExternal = aDimensionWidth < aLabelWidth + anArrowsWidth;
- break;
- }
- }
-
- // Handle user-defined and automatic text placement
- switch (theHorizontalTextPos)
- {
- case Prs3d_DTHP_Left : theLabelPosition |= LabelPosition_Left; break;
- case Prs3d_DTHP_Right : theLabelPosition |= LabelPosition_Right; break;
- case Prs3d_DTHP_Center: theLabelPosition |= LabelPosition_HCenter; break;
- case Prs3d_DTHP_Fit:
- {
- gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
- Standard_Real aDimensionWidth = anAttachVector.Magnitude();
- Standard_Real anArrowsWidth = anArrowLength * 2.0;
- Standard_Real aContentWidth = theIsArrowsExternal ? aLabelWidth : aLabelWidth + anArrowsWidth;
-
- theLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter;
- break;
- }
- }
-
- switch (aDimensionAspect->TextVerticalPosition())
- {
- case Prs3d_DTVP_Above : theLabelPosition |= LabelPosition_Above; break;
- case Prs3d_DTVP_Below : theLabelPosition |= LabelPosition_Below; break;
- case Prs3d_DTVP_Center : theLabelPosition |= LabelPosition_VCenter; break;
- }
-}
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2013 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_AngleDimension_HeaderFile
-#define _AIS_AngleDimension_HeaderFile
-
-#include <AIS_Dimension.hxx>
-#include <AIS_TypeOfAngle.hxx>
-#include <AIS_TypeOfAngleArrowVisibility.hxx>
-
-#include <Geom_Plane.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Vertex.hxx>
-
-class AIS_AngleDimension;
-DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
-
-//! Angle dimension. Can be constructed:
-//! - on two intersected edges.
-//! - on three points or vertices.
-//! - on conical face.
-//! - between two intersected faces.
-//!
-//! In case of three points or two intersected edges the dimension plane
-//! (on which dimension presentation is built) can be computed uniquely
-//! as through three defined points can be built only one plane.
-//! Therefore, if user-defined plane differs from this one, the dimension can't be built.
-//!
-//! In cases of two planes automatic plane by default is built on point of the
-//! origin of parametric space of the first face (the basis surface) so, that
-//! the working plane and two faces intersection forms minimal angle between the faces.
-//! User can define the other point which the dimension plane should pass through
-//! using the appropriate constructor. This point can lay on the one of the faces or not.
-//! Also user can define his own plane but it should pass through the three points
-//! computed on the geometry initialization step (when the constructor or SetMeasuredGeometry() method
-//! is called).
-//!
-//! In case of the conical face the center point of the angle is the apex of the conical surface.
-//! The attachment points are points of the first and the last parameter of the basis circle of the cone.
-//!
-class AIS_AngleDimension : public AIS_Dimension
-{
-public:
-
- //! Constructs minimum angle dimension between two linear edges (where possible).
- //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
- //! @param theFirstEdge [in] the first edge.
- //! @param theSecondEdge [in] the second edge.
- Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
- const TopoDS_Edge& theSecondEdge);
-
- //! Constructs the angle display object defined by three points.
- //! @param theFirstPoint [in] the first point (point on first angle flyout).
- //! @param theSecondPoint [in] the center point of angle dimension.
- //! @param theThirdPoint [in] the second point (point on second angle flyout).
- Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const gp_Pnt& theThirdPoint);
-
- //! Constructs the angle display object defined by three vertices.
- //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
- //! @param theSecondVertex [in] the center vertex of angle dimension.
- //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
- Standard_EXPORT AIS_AngleDimension (const TopoDS_Vertex& theFirstVertex,
- const TopoDS_Vertex& theSecondVertex,
- const TopoDS_Vertex& theThirdVertex);
-
- //! Constructs angle dimension for the cone face.
- //! @param theCone [in] the conical face.
- Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
-
- //! Constructs angle dimension between two planar faces.
- //! @param theFirstFace [in] the first face.
- //! @param theSecondFace [in] the second face.
- Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace);
-
- //! Constructs angle dimension between two planar faces.
- //! @param theFirstFace [in] the first face.
- //! @param theSecondFace [in] the second face.
- //! @param thePoint [in] the point which the dimension plane should pass through.
- //! This point can lay on the one of the faces or not.
- Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace,
- const gp_Pnt& thePoint);
-
-public:
-
- //! @return first point forming the angle.
- const gp_Pnt& FirstPoint() const
- {
- return myFirstPoint;
- }
-
- //! @return second point forming the angle.
- const gp_Pnt& SecondPoint() const
- {
- return mySecondPoint;
- }
-
- //! @return center point forming the angle.
- const gp_Pnt& CenterPoint() const
- {
- return myCenterPoint;
- }
-
- //! @return first argument shape.
- const TopoDS_Shape& FirstShape() const
- {
- return myFirstShape;
- }
-
- //! @return second argument shape.
- const TopoDS_Shape& SecondShape() const
- {
- return mySecondShape;
- }
-
- //! @return third argument shape.
- const TopoDS_Shape& ThirdShape() const
- {
- return myThirdShape;
- }
-
-public:
-
- //! Measures minimum angle dimension between two linear edges.
- //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
- //! @param theFirstEdge [in] the first edge.
- //! @param theSecondEdge [in] the second edge.
- Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge,
- const TopoDS_Edge& theSecondEdge);
-
- //! Measures angle defined by three points.
- //! @param theFirstPoint [in] the first point (point on first angle flyout).
- //! @param theSecondPoint [in] the center point of angle dimension.
- //! @param theThirdPoint [in] the second point (point on second angle flyout).
- Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const gp_Pnt& theThridPoint);
-
- //! Measures angle defined by three vertices.
- //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
- //! @param theSecondVertex [in] the center vertex of angle dimension.
- //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
- Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Vertex& theFirstVertex,
- const TopoDS_Vertex& theSecondVertex,
- const TopoDS_Vertex& theThirdVertex);
-
- //! Measures angle of conical face.
- //! @param theCone [in] the shape to measure.
- Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theCone);
-
- //! Measures angle between two planar faces.
- //! @param theFirstFace [in] the first face.
- //! @param theSecondFace [in] the second face..
- Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace);
-
- //! Measures angle between two planar faces.
- //! @param theFirstFace [in] the first face.
- //! @param theSecondFace [in] the second face.
- //! @param thePoint [in] the point which the dimension plane should pass through.
- //! This point can lay on the one of the faces or not.
- Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace,
- const gp_Pnt& thePoint);
-
- //! @return the display units string.
- Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE;
-
- //! @return the model units string.
- Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
-
- //! Principle of horizontal text alignment settings:
- //! - divide circle into two halves according to attachment points
- //! - if aTextPos is between attach points -> Center + positive flyout
- //! - if aTextPos is not between attach points but in this half -> Left or Right + positive flyout
- //! - if aTextPos is between reflections of attach points -> Center + negative flyout
- //! - if aTextPos is not between reflections of attach points -> Left or Right + negative flyout
- Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
-
- Standard_EXPORT virtual const gp_Pnt GetTextPosition () const Standard_OVERRIDE;
-
- //! Sets angle type.
- //! @param theType [in] the type value.
- void SetType(const AIS_TypeOfAngle theType)
- {
- myType = theType;
- }
-
- //! @return the current angle type.
- AIS_TypeOfAngle GetType() const
- {
- return myType;
- }
-
- //! Sets visible arrows type
- //! @param theType [in] the type of visibility of arrows.
- void SetArrowsVisibility(const AIS_TypeOfAngleArrowVisibility& theType)
- {
- myArrowsVisibility = theType;
- }
-
- //! @return the type of visibility of arrows.
- AIS_TypeOfAngleArrowVisibility GetArrowsVisibility() const
- {
- return myArrowsVisibility;
- }
-
-public:
-
- DEFINE_STANDARD_RTTIEXT(AIS_AngleDimension,AIS_Dimension)
-
-protected:
-
- //! Initialization of fields that is common to all constructors.
- Standard_EXPORT void Init();
-
- //! Gets plane normal for minimal angle.
- //! Dimension computation is based on three attach points and plane normal.
- //! Based on this normal angle arc, arrows and extensions are constructed.
- gp_Dir GetNormalForMinAngle() const;
-
- //! @param theFirstAttach [in] the first attachment point.
- //! @param theSecondAttach [in] the second attachment point.
- //! @param theCenter [in] the center point (center point of the angle).
- //! @return the center of the dimension arc (the main dimension line in case of angle).
- Standard_EXPORT gp_Pnt GetCenterOnArc (const gp_Pnt& theFirstAttach,
- const gp_Pnt& theSecondAttach,
- const gp_Pnt& theCenter) const;
-
- //! Draws main dimension line (arc).
- //! @param thePresentation [in] the dimension presentation.
- //! @param theFirstAttach [in] the first attachment point.
- //! @param theSecondAttach [in] the second attachment point.
- //! @param theCenter [in] the center point (center point of the angle).
- //! @param theRadius [in] the radius of the dimension arc.
- //! @param theMode [in] the display mode.
- Standard_EXPORT void DrawArc (const Handle(Prs3d_Presentation)& thePresentation,
- const gp_Pnt& theFirstAttach,
- const gp_Pnt& theSecondAttach,
- const gp_Pnt& theCenter,
- const Standard_Real theRadius,
- const Standard_Integer theMode);
-
- //! Draws main dimension line (arc) with text.
- //! @param thePresentation [in] the dimension presentation.
- //! @param theFirstAttach [in] the first attachment point.
- //! @param theSecondAttach [in] the second attachment point.
- //! @param theCenter [in] the center point (center point of the angle).
- //! @param theText [in] the text label string.
- //! @param theTextWidth [in] the text label width.
- //! @param theMode [in] the display mode.
- //! @param theLabelPosition [in] the text label vertical and horizontal positioning option
- //! respectively to the main dimension line.
- Standard_EXPORT void DrawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
- const gp_Pnt& theFirstAttach,
- const gp_Pnt& theSecondAttach,
- const gp_Pnt& theCenter,
- const TCollection_ExtendedString& theText,
- const Standard_Real theTextWidth,
- const Standard_Integer theMode,
- const Standard_Integer theLabelPosition);
-
- //! Fits text alignment relatively to the dimension line;
- //! it computes the value of label position and arrow orientation
- //! according set in the aspect and dimension properties.
- //! @param theHorizontalTextPos [in] the horizontal alignment for text position.
- //! @param theLabelPosition [out] the label position, contains bits that defines
- //! vertical and horizontal alignment. (for internal usage in count text position).
- //! @param theIsArrowExternal [out] is the arrows external,
- //! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow
- //! orientation automatically.
- Standard_EXPORT void FitTextAlignment (const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
- Standard_Integer& theLabelPosition,
- Standard_Boolean& theIsArrowsExternal) const;
-
- //! Adjusts aspect parameters according the text position:
- //! extension size, vertical text alignment and flyout.
- //! @param theTextPos [in] the user defined 3d point of text position.
- //! @param theExtensionSize [out] the adjusted extension size.
- //! @param theAlignment [out] the horizontal label alignment.
- //! @param theFlyout [out] the adjusted value of flyout.
- Standard_EXPORT void AdjustParameters (const gp_Pnt& theTextPos,
- Standard_Real& theExtensionSize,
- Prs3d_DimensionTextHorizontalPosition& theAlignment,
- Standard_Real& theFlyout) const;
-
-protected:
-
- Standard_EXPORT virtual void ComputePlane();
-
- //! Checks if the plane includes three angle points to build dimension.
- Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE;
-
- Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
-
-protected:
-
- //! Init angular dimension to measure angle between two linear edges.
- //! @return TRUE if the angular dimension can be constructured
- //! for the passed edges.
- Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane);
-
- //! Init angular dimension to measure angle between two planar faces.
- //! there is no user-defined poisitoning. So attach points are set
- //! according to faces geometry (in origin of the first face basis surface).
- //! @return TRUE if the angular dimension can be constructed
- //! for the passed faces.
- Standard_EXPORT Standard_Boolean InitTwoFacesAngle();
-
- //! Init angular dimension to measure angle between two planar faces.
- //! @param thePointOnFirstFace [in] the point which the dimension plane should pass through.
- //! This point can lay on the one of the faces or not.
- //! It will be projected on the first face and this point will be set
- //! as the first point attach point.
- //! It defines some kind of dimension positioning over the faces.
- //! @return TRUE if the angular dimension can be constructed
- //! for the passed faces.
- Standard_EXPORT Standard_Boolean InitTwoFacesAngle (const gp_Pnt thePointOnFirstFace);
-
- //! Init angular dimension to measure cone face.
- //! @return TRUE if the angular dimension can be constructed
- //! for the passed cone.
- Standard_EXPORT Standard_Boolean InitConeAngle();
-
- //! Check that the points forming angle are valid.
- //! @return TRUE if the points met the following requirements:
- //! The (P1, Center), (P2, Center) can be built.
- //! The angle between the vectors > Precision::Angular().
- Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theCenterPoint,
- const gp_Pnt& theSecondPoint) const;
-
-
- //! Returns true if the arrow should be visible
- //! @param theArrowType an arrow type
- //! @return TRUE if the arrow should be visible
- Standard_EXPORT Standard_Boolean isArrowVisible(const AIS_TypeOfAngleArrowVisibility& theArrowType) const;
-
-private:
- AIS_TypeOfAngle myType; //!< type of angle
- AIS_TypeOfAngleArrowVisibility myArrowsVisibility; //!< type of arrows visibility
-
- gp_Pnt myFirstPoint;
- gp_Pnt mySecondPoint;
- gp_Pnt myCenterPoint;
- TopoDS_Shape myFirstShape;
- TopoDS_Shape mySecondShape;
- TopoDS_Shape myThirdShape;
-};
-
-#endif // _AIS_AngleDimension_HeaderFile
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Flore Lantheaume/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_Chamf2dDimension.hxx>
-#include <Bnd_Box.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepBndLib.hxx>
-#include <BRepTools_WireExplorer.hxx>
-#include <DsgPrs_Chamf2dPresentation.hxx>
-#include <ElCLib.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <Precision.hxx>
-#include <ProjLib.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopAbs_Orientation.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Shape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_Chamf2dDimension,AIS_Relation)
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_Chamf2dDimension::AIS_Chamf2dDimension(const TopoDS_Shape& aFShape,
- const Handle(Geom_Plane)& aPlane,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText)
-:AIS_Relation()
-{
- myFShape = aFShape;
- myPlane = aPlane;
- myVal = aVal;
- myText = aText;
- mySymbolPrs = DsgPrs_AS_LASTAR;
- myAutomaticPosition = Standard_True;
-
- myArrowSize = myVal / 100.;
-}
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_Chamf2dDimension::AIS_Chamf2dDimension(const TopoDS_Shape& aFShape,
- const Handle(Geom_Plane)& aPlane,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText,
- const gp_Pnt& aPosition,
- const DsgPrs_ArrowSide aSymbolPrs ,
- const Standard_Real anArrowSize)
-:AIS_Relation()
-{
- myFShape = aFShape;
- myPlane = aPlane;
- myVal = aVal;
- myText = aText;
- myPosition = aPosition;
- mySymbolPrs = aSymbolPrs;
- SetArrowSize( anArrowSize );
- myAutomaticPosition = Standard_False;
-}
-
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-
-void AIS_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer)
-{
- Handle(Geom_Curve) gcurv;
- gp_Pnt pfirst,plast;
- const TopoDS_Edge& thechamfedge = TopoDS::Edge(myFShape);
- if (!AIS::ComputeGeometry (thechamfedge, gcurv, pfirst, plast))
- return;
-
- Handle(Geom_Line) glin = Handle(Geom_Line)::DownCast (gcurv);
- gp_Dir dir1 (glin->Position().Direction());
- gp_Dir norm1 = myPlane->Pln().Axis().Direction();
- myDir = norm1.Crossed(dir1);
-
-
- //-------------------------------------------------
- // calcul d'une direction orthogonale a l'edge du
- // chanfrein et dirigee vers l'ext. du contour
- //-------------------------------------------------
-
-
- // recup. d'une edge adjacente a l'edge du chanfrein
- /*TopoDS_Edge nextedge = TopoDS::Edge(mySShape);
-
- gp_Pnt pfirstnext,plastnext;
- Handle(Geom_Line) glinnext;
- if (!AIS::ComputeGeometry(nextedge,glinnext,pfirstnext,plastnext) )
- return;
-
- gp_Vec v1(pfirst,plast);
- gp_Vec v2;
- if (pfirst.IsEqual(plastnext, Precision::Confusion()))
- v2.SetXYZ(pfirstnext.XYZ() - pfirst.XYZ());
- else
- v2.SetXYZ(plastnext.XYZ() - pfirst.XYZ());
- gp_Vec crossvec = v1.Crossed(v2);
-
- myDir = dimserv.GetDirection().Crossed(glin->Position().Direction());
- if (crossvec.Dot(dimserv.GetDirection()) > 0 )
- myDir.Reverse();*/ // myDir => donne a la creation
-
- //--------------------------------------------
- //Calcul du point de positionnement du texte
- //--------------------------------------------
- gp_Pnt curpos;
- if (myAutomaticPosition) {
- myPntAttach.SetXYZ((pfirst.XYZ()+plast.XYZ())/2);
- gp_Vec transVec(myDir);
- transVec*=myVal;
- curpos = myPntAttach.Translated(transVec);
-
- if (myIsSetBndBox)
- curpos = AIS::TranslatePointToBound( curpos, myDir, myBndBox );
-
- myPosition = curpos;
- }
- else {
-
- myPntAttach.SetXYZ((pfirst.XYZ()+plast.XYZ())/2);
- Handle(Geom_Line) dimLin = new Geom_Line(myPntAttach, myDir);
- Standard_Real parcurpos = ElCLib::Parameter(dimLin->Lin(),myPosition);
- curpos = ElCLib::Value(parcurpos,dimLin->Lin());
- //static Standard_Real minlength = 0.005;
- //taille minimale de la dimension
-
- if ( curpos.Distance(myPntAttach) < 5. ) {
- gp_Vec transVec(myDir);
- transVec*=5.;
- curpos = myPntAttach.Translated(transVec);
- }
- myPosition = curpos;
- }
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
-
- //-------------------------------------------------
- //Calcul de la boite englobante du component pour
- //determiner la taille de la fleche
- //-------------------------------------------------
-
- if( !myArrowSizeIsDefined ) {
- Standard_Real arrsize = myArrowSize;
- if ( (myVal/4) < arrsize)
- arrsize = myVal/4;
- if (arrsize > 30.)
- arrsize = 30.;
- else if (arrsize < 8.)
- arrsize = 8.;
- myArrowSize = arrsize;
- }
- arr->SetLength(myArrowSize);
-
- //Calcul de la presentation
- DsgPrs_Chamf2dPresentation::Add(aPresentation,
- myDrawer,
- myPntAttach,
- curpos,
- myText,
- mySymbolPrs);
-
- }
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-
-void AIS_Chamf2dDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer)
-{
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
- Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,myPntAttach,myPosition);
- aSelection->Add(seg);
-
- // Text
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
- myPosition.X(),
- myPosition.Y(),
- myPosition.Z(),
- myPosition.X() + size,
- myPosition.Y() + size,
- myPosition.Z() + size);
- aSelection->Add(box);
-}
-
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Flore Lantheaume/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_Chamf2dDimension_HeaderFile
-#define _AIS_Chamf2dDimension_HeaderFile
-
-#include <AIS_KindOfDimension.hxx>
-#include <AIS_Relation.hxx>
-#include <DsgPrs_ArrowSide.hxx>
-#include <gp_Dir.hxx>
-
-class Geom_Plane;
-
-DEFINE_STANDARD_HANDLE(AIS_Chamf2dDimension, AIS_Relation)
-
-//! A framework to define display of 2D chamfers.
-//! A chamfer is displayed with arrows and text. The text
-//! gives the length of the chamfer if it is a symmetrical
-//! chamfer, or the angle if it is not.
-class AIS_Chamf2dDimension : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_Chamf2dDimension, AIS_Relation)
-public:
-
- //! Constructs the display object for 2D chamfers.
- //! This object is defined by the face aFShape, the
- //! dimension aVal, the plane aPlane and the text aText.
- Standard_EXPORT AIS_Chamf2dDimension(const TopoDS_Shape& aFShape, const Handle(Geom_Plane)& aPlane, const Standard_Real aVal, const TCollection_ExtendedString& aText);
-
- //! Constructs the display object for 2D chamfers.
- //! This object is defined by the face aFShape, the plane
- //! aPlane, the dimension aVal, the position aPosition,
- //! the type of arrow aSymbolPrs with the size
- //! anArrowSize, and the text aText.
- Standard_EXPORT AIS_Chamf2dDimension(const TopoDS_Shape& aFShape, const Handle(Geom_Plane)& aPlane, const Standard_Real aVal, const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.0);
-
- //! Indicates that we are concerned with a 2d length.
- virtual AIS_KindOfDimension KindOfDimension() const Standard_OVERRIDE;
-
- //! Returns true if the 2d chamfer dimension is movable.
- virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- gp_Pnt myPntAttach;
- gp_Dir myDir;
-
-};
-
-#include <AIS_Chamf2dDimension.lxx>
-
-#endif // _AIS_Chamf2dDimension_HeaderFile
+++ /dev/null
-// Created on: 1997-02-28
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : KindOfDimension
-//purpose :
-//=======================================================================
-inline AIS_KindOfDimension AIS_Chamf2dDimension::KindOfDimension() const
-{
- return AIS_KOD_LENGTH;
-}
-
-//=======================================================================
-//function : IsMovable
-//purpose :
-//=======================================================================
-inline Standard_Boolean AIS_Chamf2dDimension::IsMovable() const
-{
- return Standard_True;
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_Chamf3dDimension.hxx>
-#include <Bnd_Box.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepBndLib.hxx>
-#include <BRepTools_WireExplorer.hxx>
-#include <DsgPrs_Chamf2dPresentation.hxx>
-#include <ElCLib.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <Precision.hxx>
-#include <ProjLib.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopAbs_Orientation.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Shape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_Chamf3dDimension,AIS_Relation)
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_Chamf3dDimension::AIS_Chamf3dDimension(const TopoDS_Shape& aFShape,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText)
-:AIS_Relation()
-{
- myFShape = aFShape;
- myVal = aVal;
- myText = aText;
- mySymbolPrs = DsgPrs_AS_LASTAR;
- myAutomaticPosition = Standard_True;
-
- myArrowSize = myVal / 100.;
-}
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_Chamf3dDimension::AIS_Chamf3dDimension(const TopoDS_Shape& aFShape,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText,
- const gp_Pnt& aPosition,
- const DsgPrs_ArrowSide aSymbolPrs ,
- const Standard_Real anArrowSize)
-:AIS_Relation()
-{
- myFShape = aFShape;
- myVal = aVal;
- myText = aText;
- myPosition = aPosition;
- mySymbolPrs = aSymbolPrs;
- SetArrowSize( anArrowSize );
- myAutomaticPosition = Standard_False;
-}
-
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-
-void AIS_Chamf3dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer)
-{
- //----------------------------
- // Calcul du centre de la face
- //----------------------------
- BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
- Standard_Real uFirst, uLast, vFirst, vLast;
- uFirst = surfAlgo.FirstUParameter();
- uLast = surfAlgo.LastUParameter();
- vFirst = surfAlgo.FirstVParameter();
- vLast = surfAlgo.LastVParameter();
- Standard_Real uMoy = (uFirst + uLast)/2;
- Standard_Real vMoy = (vFirst + vLast)/2;
- gp_Pnt apos ;
- gp_Vec d1u, d1v;
- surfAlgo.D1(uMoy, vMoy, apos, d1u, d1v);
- myPntAttach = apos;
-
- myDir = d1u ^ d1v;
-// myDir = surfAlgo.Plane().Axis().Direction();
-
-
-
-
- //--------------------------------------------
- //Calcul du point de positionnement du texte
- //--------------------------------------------
- gp_Pnt curpos;
- if (myAutomaticPosition) {
- gp_Vec transVec(myDir);
- transVec*=myVal;
- curpos = myPntAttach.Translated(transVec);
-
- if (myIsSetBndBox)
- curpos = AIS::TranslatePointToBound( curpos, myDir, myBndBox );
-
- myPosition = curpos;
- }
- else {
-
- Handle(Geom_Line) dimLin = new Geom_Line(myPntAttach, myDir);
- Standard_Real parcurpos = ElCLib::Parameter(dimLin->Lin(),myPosition);
- curpos = ElCLib::Value(parcurpos,dimLin->Lin());
-
- if ( curpos.Distance(myPntAttach) < 5. ) {
- gp_Vec transVec(myDir);
- transVec*=5.;
- curpos = myPntAttach.Translated(transVec);
- }
- myPosition = curpos;
- }
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
-
- //-------------------------------------------------
- //Calcul de la boite englobante du component pour
- //determiner la taille de la fleche
- //-------------------------------------------------
- if( !myArrowSizeIsDefined ) {
- Standard_Real arrsize = myArrowSize;
- if ( (myVal/4) < arrsize)
- arrsize = myVal/4;
- if (arrsize > 30.)
- arrsize = 30.;
- else if (arrsize < 8.)
- arrsize = 8.;
- myArrowSize = arrsize;
- }
- arr->SetLength(myArrowSize);
-
- //Calcul de la presentation
- DsgPrs_Chamf2dPresentation::Add(aPresentation,
- myDrawer,
- myPntAttach,
- curpos,
- myText,
- mySymbolPrs);
-
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-
-void AIS_Chamf3dDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer)
-{
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
- Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,myPntAttach,myPosition);
- aSelection->Add(seg);
-
- // Text
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
- myPosition.X(),
- myPosition.Y(),
- myPosition.Z(),
- myPosition.X() + size,
- myPosition.Y() + size,
- myPosition.Z() + size);
- aSelection->Add(box);
-}
-
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_Chamf3dDimension_HeaderFile
-#define _AIS_Chamf3dDimension_HeaderFile
-
-#include <AIS_KindOfDimension.hxx>
-#include <AIS_Relation.hxx>
-#include <DsgPrs_ArrowSide.hxx>
-#include <gp_Dir.hxx>
-
-DEFINE_STANDARD_HANDLE(AIS_Chamf3dDimension, AIS_Relation)
-
-//! A framework to define display of 3D chamfers.
-//! A chamfer is displayed with arrows and text. The text
-//! gives the length of the chamfer if it is a symmetrical
-//! chamfer, or the angle if it is not.
-class AIS_Chamf3dDimension : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_Chamf3dDimension, AIS_Relation)
-public:
-
- //! Constructs a display object for 3D chamfers.
- //! This object is defined by the shape aFShape, the
- //! dimension aVal and the text aText.
- Standard_EXPORT AIS_Chamf3dDimension(const TopoDS_Shape& aFShape, const Standard_Real aVal, const TCollection_ExtendedString& aText);
-
- //! Constructs a display object for 3D chamfers.
- //! This object is defined by the shape aFShape, the
- //! dimension aVal, the text aText, the point of origin of
- //! the chamfer aPosition, the type of arrow aSymbolPrs
- //! with the size anArrowSize.
- Standard_EXPORT AIS_Chamf3dDimension(const TopoDS_Shape& aFShape, const Standard_Real aVal, const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.0);
-
- //! Indicates that we are concerned with a 3d length.
- virtual AIS_KindOfDimension KindOfDimension() const Standard_OVERRIDE;
-
- //! Returns true if the 3d chamfer dimension is movable.
- virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- gp_Pnt myPntAttach;
- gp_Dir myDir;
-
-};
-
-#include <AIS_Chamf3dDimension.lxx>
-
-#endif // _AIS_Chamf3dDimension_HeaderFile
+++ /dev/null
-// Created on: 1997-02-28
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : KindOfDimension
-//purpose :
-//=======================================================================
-inline AIS_KindOfDimension AIS_Chamf3dDimension::KindOfDimension() const
-{
- return AIS_KOD_LENGTH;
-}
-
-//=======================================================================
-//function : IsMovable
-//purpose :
-//=======================================================================
-inline Standard_Boolean AIS_Chamf3dDimension::IsMovable() const
-{
- return Standard_True;
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Flore Lantheaume/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_ConcentricRelation.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <DsgPrs_ConcentricPresentation.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <GeomAbs_CurveType.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveCircle.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_ConcentricRelation,AIS_Relation)
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_ConcentricRelation::AIS_ConcentricRelation(
- const TopoDS_Shape& aFShape,
- const TopoDS_Shape& aSShape,
- const Handle(Geom_Plane)& aPlane)
-{
- myFShape = aFShape;
- mySShape = aSShape;
- myPlane = aPlane;
- myDir = aPlane->Pln().Axis().Direction();
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_ConcentricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer)
-{
- TopAbs_ShapeEnum type2(mySShape.ShapeType());
- aPresentation->SetInfiniteState(Standard_True);
- switch (myFShape.ShapeType()) {
- case TopAbs_EDGE:
- {
- if (type2 == TopAbs_EDGE) ComputeTwoEdgesConcentric(aPresentation);
- else if (type2 == TopAbs_VERTEX) ComputeEdgeVertexConcentric(aPresentation);
- }
- break;
-
- case TopAbs_VERTEX:
- {
- if (type2 == TopAbs_VERTEX) ComputeTwoVerticesConcentric(aPresentation);
- else if (type2 == TopAbs_EDGE) ComputeEdgeVertexConcentric(aPresentation);
- }
- break;
- default: {return;}
- }
-}
-
-//=======================================================================
-//function : ComputeTwoEdgesConcentric
-//purpose :
-//=======================================================================
-void AIS_ConcentricRelation::ComputeEdgeVertexConcentric(const Handle(Prs3d_Presentation)& aPresentation)
-{
- TopoDS_Edge E;
- TopoDS_Vertex V;
- if (myFShape.ShapeType() == TopAbs_EDGE) {
- E = TopoDS::Edge(myFShape);
- V = TopoDS::Vertex(mySShape);
- }
- else {
- E = TopoDS::Edge(mySShape);
- V = TopoDS::Vertex(myFShape);
- }
- gp_Pnt p1,p2;
- Handle(Geom_Curve) C;
- Handle(Geom_Curve) extCurv;
- Standard_Boolean isInfinite;
- Standard_Boolean isOnPlanEdge, isOnPlanVertex;
- if (!AIS::ComputeGeometry(E,C,p1,p2,extCurv,isInfinite,isOnPlanEdge,myPlane)) return;
- gp_Pnt P;
- AIS::ComputeGeometry(V,P, myPlane, isOnPlanVertex);
-
- Handle(Geom_Circle) CIRCLE (Handle(Geom_Circle)::DownCast (C));
- myCenter = CIRCLE->Location();
- myRad = Min(CIRCLE->Radius()/5.,15.);
- gp_Dir vec(p1.XYZ() - myCenter.XYZ() );
- gp_Vec vectrans(vec);
- myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
- DsgPrs_ConcentricPresentation::Add(aPresentation,myDrawer,myCenter,myRad,myDir,myPnt);
- if (!isOnPlanEdge) AIS::ComputeProjEdgePresentation(aPresentation,myDrawer,E,CIRCLE,p1,p2);
- if (!isOnPlanVertex) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V,P);
-}
-
-//=======================================================================
-//function : ComputeTwoEdgesConcentric
-//purpose :
-//=======================================================================
-void AIS_ConcentricRelation::ComputeTwoVerticesConcentric(const Handle(Prs3d_Presentation)& aPresentation)
-{
- TopoDS_Vertex V1,V2;
- V1 = TopoDS::Vertex(myFShape);
- V2 = TopoDS::Vertex(myFShape);
- Standard_Boolean isOnPlanVertex1(Standard_True),isOnPlanVertex2(Standard_True);
- gp_Pnt P1,P2;
- AIS::ComputeGeometry(V1,P1, myPlane,isOnPlanVertex1);
- AIS::ComputeGeometry(V2,P2, myPlane,isOnPlanVertex2);
- myCenter = P1;
- myRad = 15.;
- gp_Dir vec(myPlane->Pln().Position().XDirection());
- gp_Vec vectrans(vec);
- myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
- DsgPrs_ConcentricPresentation::Add(aPresentation,myDrawer,myCenter,myRad,myDir,myPnt);
- if (!isOnPlanVertex1) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V1,P1);
- if (!isOnPlanVertex2) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V2,P2);
-}
-
-//=======================================================================
-//function : ComputeTwoEdgesConcentric
-//purpose :
-//=======================================================================
-void AIS_ConcentricRelation::ComputeTwoEdgesConcentric(const Handle(Prs3d_Presentation)& aPresentation)
-{
- BRepAdaptor_Curve curv1(TopoDS::Edge(myFShape));
- BRepAdaptor_Curve curv2(TopoDS::Edge(mySShape));
-
- gp_Pnt ptat11,ptat12,ptat21,ptat22;
- Handle(Geom_Curve) geom1,geom2;
- Standard_Boolean isInfinite1,isInfinite2;
- Handle(Geom_Curve) extCurv;
- if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),
- TopoDS::Edge(mySShape),
- myExtShape,
- geom1,
- geom2,
- ptat11,
- ptat12,
- ptat21,
- ptat22,
- extCurv,
- isInfinite1,isInfinite2,
- myPlane)) {
- return;
- }
-
- Handle(Geom_Circle) gcirc1 (Handle(Geom_Circle)::DownCast (geom1));
- Handle(Geom_Circle) gcirc2 (Handle(Geom_Circle)::DownCast (geom2));
-
- myCenter = gcirc1->Location();
-
- // choose the radius equal to 1/5 of the smallest radius of
- // 2 circles. Limit is imposed ( 0.02 by chance)
- Standard_Real aRad1 = gcirc1->Radius();
- Standard_Real aRad2 = gcirc2->Radius();
- myRad = (aRad1 > aRad2 ) ? aRad2 : aRad1;
- myRad /= 5;
- if (myRad > 15.) myRad =15.;
-
-
- //Calculate a point of circle of radius myRad
- gp_Dir vec(ptat11.XYZ() - myCenter.XYZ() );
- gp_Vec vectrans(vec);
- myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
-
- DsgPrs_ConcentricPresentation::Add(aPresentation,
- myDrawer,
- myCenter,
- myRad,
- myDir,
- myPnt);
- if ( (myExtShape != 0) && !extCurv.IsNull()) {
- gp_Pnt pf, pl;
- if ( myExtShape == 1 ) {
- if (!isInfinite1) {
- pf = ptat11;
- pl = ptat12;
- }
- ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(myFShape),gcirc1,pf,pl);
- }
- else {
- if (!isInfinite2) {
- pf = ptat21;
- pl = ptat22;
- }
- ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(mySShape),gcirc2,pf,pl);
- }
- }
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-
-void AIS_ConcentricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer)
-{
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
-
- //Creation of 2 sensitive circles
- // the greater
- gp_Ax2 ax(myCenter, myDir);
- Handle(Geom_Circle) Circ = new Geom_Circle(ax, myRad) ;
- Handle(Select3D_SensitiveCircle)
- sensit = new Select3D_SensitiveCircle (own,
- Circ);
- aSelection->Add(sensit);
- // the smaller
- Circ->SetRadius(myRad/2);
- sensit = new Select3D_SensitiveCircle (own,
- Circ);
- aSelection->Add(sensit);
-
- //Creation of 2 segments sensitive for the cross
- Handle(Select3D_SensitiveSegment) seg;
- gp_Pnt otherPnt = myPnt.Mirrored(myCenter);
- seg = new Select3D_SensitiveSegment(own,
- otherPnt,
- myPnt);
- aSelection->Add(seg);
-
- gp_Ax1 RotateAxis(myCenter, myDir);
- gp_Pnt FPnt = myCenter.Rotated(RotateAxis, M_PI/2);
- gp_Pnt SPnt = myCenter.Rotated(RotateAxis, -M_PI/2);
- seg = new Select3D_SensitiveSegment(own,
- FPnt,
- SPnt);
- aSelection->Add(seg);
-
-}
-
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Flore Lantheaume/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_ConcentricRelation_HeaderFile
-#define _AIS_ConcentricRelation_HeaderFile
-
-#include <AIS_Relation.hxx>
-#include <gp_Dir.hxx>
-
-class Geom_Plane;
-
-DEFINE_STANDARD_HANDLE(AIS_ConcentricRelation, AIS_Relation)
-
-//! A framework to define a constraint by a relation of
-//! concentricity between two or more interactive datums.
-//! The display of this constraint is also defined.
-//! A plane is used to create an axis along which the
-//! relation of concentricity can be extended.
-class AIS_ConcentricRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_ConcentricRelation, AIS_Relation)
-public:
-
- //! Constructs the display object for concentric relations
- //! between shapes.
- //! This object is defined by the two shapes, aFShape
- //! and aSShape and the plane aPlane.
- //! aPlane is provided to create an axis along which the
- //! relation of concentricity can be extended.
- Standard_EXPORT AIS_ConcentricRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane);
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeTwoEdgesConcentric (const Handle(Prs3d_Presentation)& aPresentationManager);
-
- Standard_EXPORT void ComputeEdgeVertexConcentric (const Handle(Prs3d_Presentation)& aPresentationManager);
-
- Standard_EXPORT void ComputeTwoVerticesConcentric (const Handle(Prs3d_Presentation)& aPresentationManager);
-
- Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- gp_Pnt myCenter;
- Standard_Real myRad;
- gp_Dir myDir;
- gp_Pnt myPnt;
-
-};
-
-#endif // _AIS_ConcentricRelation_HeaderFile
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Jacques MINOT/Odile Olivier/Sergey ZARITCHNY
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AIS_DiameterDimension.hxx>
-
-#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_RTTIEXT(AIS_DiameterDimension,AIS_Dimension)
-
-namespace
-{
- static const Standard_ExtCharacter THE_DIAMETER_SYMBOL (0x00D8);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle)
-: AIS_Dimension (AIS_KOD_DIAMETER)
-{
- SetMeasuredGeometry (theCircle);
- SetSpecialSymbol (THE_DIAMETER_SYMBOL);
- SetDisplaySpecialSymbol (AIS_DSS_Before);
- SetFlyout (0.0);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle,
- const gp_Pln& thePlane)
-: AIS_Dimension (AIS_KOD_DIAMETER)
-{
- SetCustomPlane (thePlane);
- SetMeasuredGeometry (theCircle);
- SetSpecialSymbol (THE_DIAMETER_SYMBOL);
- SetDisplaySpecialSymbol (AIS_DSS_Before);
- SetFlyout (0.0);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_DiameterDimension::AIS_DiameterDimension (const TopoDS_Shape& theShape)
-: AIS_Dimension (AIS_KOD_DIAMETER)
-{
- SetMeasuredGeometry (theShape);
- SetSpecialSymbol (THE_DIAMETER_SYMBOL);
- SetDisplaySpecialSymbol (AIS_DSS_Before);
- SetFlyout (0.0);
-}
-
-//=======================================================================
-//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();
- myIsGeometryValid = IsValidCircle (myCircle);
-
- if (myIsGeometryValid && myIsPlaneCustom)
- {
- ComputeAnchorPoint();
- }
- else if (!myIsPlaneCustom)
- {
- ComputePlane();
- myAnchorPoint = ElCLib::Value (0.0, myCircle);
- }
-
- 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();
- myIsGeometryValid = InitCircularDimension (theShape, myCircle, aDummyPnt, isClosed)
- && IsValidCircle (myCircle)
- && isClosed;
-
- if (myIsGeometryValid && myIsPlaneCustom)
- {
- ComputeAnchorPoint();
- }
- else if (!myIsPlaneCustom)
- {
- ComputePlane();
- myAnchorPoint = ElCLib::Value (0.0, myCircle);
- }
-
- 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 (!myIsGeometryValid)
- {
- 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())
- {
- myIsGeometryValid = Standard_False;
- return;
- }
-
- // The circle lays on the plane.
- if (anIntersector.NbPoints() != 2)
- {
- myAnchorPoint = ElCLib::Value (0.0, myCircle);
- myIsGeometryValid = 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)
-{
- mySelectionGeom.Clear (theMode);
-
- if (!IsValid())
- {
- return;
- }
-
- gp_Pnt aFirstPnt (gp::Origin());
- gp_Pnt aSecondPnt (gp::Origin());
- ComputeSidePoints (myCircle, 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())
- {
- return;
- }
-
- gp_Pnt aFirstPnt (gp::Origin());
- gp_Pnt aSecondPnt (gp::Origin());
- ComputeSidePoints (myCircle, aFirstPnt, aSecondPnt);
-
- ComputeLinearFlyouts (theSelection, theEntityOwner, aFirstPnt, aSecondPnt);
-}
-
-//=======================================================================
-//function : ComputeSidePoints
-//purpose :
-//=======================================================================
-void AIS_DiameterDimension::ComputeSidePoints (const gp_Circ& theCircle,
- gp_Pnt& theFirstPnt,
- gp_Pnt& theSecondPnt)
-{
- theFirstPnt = AnchorPoint();
-
- gp_Vec aRadiusVector (theCircle.Location(), theFirstPnt);
- theSecondPnt = theCircle.Location().Translated (-aRadiusVector);
-}
-
-//=======================================================================
-//function : IsValidCircle
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_DiameterDimension::IsValidCircle (const gp_Circ& theCircle) const
-{
- 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());
-}
-
-//=======================================================================
-//function : GetTextPosition
-//purpose :
-//=======================================================================
-const gp_Pnt AIS_DiameterDimension::GetTextPosition() const
-{
- if (IsTextPositionCustom())
- {
- return myFixedTextPosition;
- }
-
- // Counts text position according to the dimension parameters
- return GetTextPositionForLinear (myAnchorPoint, myCircle.Location());
-}
-
-//=======================================================================
-//function : GetTextPosition
-//purpose :
-//=======================================================================
-void AIS_DiameterDimension::SetTextPosition (const gp_Pnt& theTextPos)
-{
- if (!IsValid())
- {
- return;
- }
-
- myIsTextPositionFixed = Standard_True;
- myFixedTextPosition = theTextPos;
-
- SetToUpdate();
-}
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#ifndef _AIS_DiameterDimension_HeaderFile
-#define _AIS_DiameterDimension_HeaderFile
-
-#include <AIS.hxx>
-#include <AIS_Dimension.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Circ.hxx>
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-
-class AIS_DiameterDimension;
-DEFINE_STANDARD_HANDLE (AIS_DiameterDimension, AIS_Dimension)
-
-//! 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:
-
- //! Construct diameter dimension for the circle.
- //! @param theCircle [in] the circle to measure.
- Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle);
-
- //! 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 Standard_OVERRIDE;
-
- //! @return the model units string.
- Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
-
- Standard_EXPORT virtual const gp_Pnt GetTextPosition() const Standard_OVERRIDE;
-
-public:
-
- DEFINE_STANDARD_RTTIEXT(AIS_DiameterDimension,AIS_Dimension)
-
-protected:
-
- //! 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();
-
- Standard_EXPORT virtual void ComputePlane();
-
- //! Checks if the center of the circle is on the plane.
- Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE;
-
- Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
-
-protected:
-
- //! Compute points on the circle sides for the 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 theFirstPnt [out] the first point.
- //! @param theSecondPnt [out] the second point.
- Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle,
- 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;
-
-private:
-
- gp_Circ myCircle;
- gp_Pnt myAnchorPoint;
- TopoDS_Shape myShape;
-};
-
-#endif // _AIS_DiameterDimension_HeaderFile
+++ /dev/null
-// Created on: 2013-11-11
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2013-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AIS_Dimension.hxx>
-
-#include <AIS.hxx>
-#include <AIS_DimensionOwner.hxx>
-#include <Adaptor3d_HCurve.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepBndLib.hxx>
-#include <Bnd_Box.hxx>
-#include <ElCLib.hxx>
-#include <Font_BRepFont.hxx>
-#include <Font_BRepTextBuilder.hxx>
-#include <GC_MakeCircle.hxx>
-#include <Geom_Line.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <gce_MakeDir.hxx>
-#include <gce_MakeLin.hxx>
-#include <gce_MakePln.hxx>
-#include <Graphic3d_ArrayOfSegments.hxx>
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
-#include <Graphic3d_Group.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
-#include <Prs3d_Arrow.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Prs3d_Root.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <Prs3d_Text.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SequenceOfOwner.hxx>
-#include <Select3D_SensitiveCircle.hxx>
-#include <Select3D_SensitiveGroup.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <Select3D_SensitiveTriangle.hxx>
-#include <Select3D_SensitiveTriangulation.hxx>
-#include <Poly_Array1OfTriangle.hxx>
-#include <Poly_Triangulation.hxx>
-#include <Standard_CString.hxx>
-#include <Standard_ProgramError.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_WFShape.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <Units.hxx>
-#include <Units_UnitsDictionary.hxx>
-#include <UnitsAPI.hxx>
-#include <UnitsAPI_SystemUnits.hxx>
-
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_Dimension,AIS_InteractiveObject)
-
-namespace
-{
- // default text strings
- static const TCollection_ExtendedString THE_EMPTY_LABEL;
- static const TCollection_AsciiString THE_UNDEFINED_UNITS;
-
- // default text margin and resolution
- static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
- static const unsigned int THE_2D_TEXT_RESOLUTION = 72;
-
- // default selection priorities
- static const Standard_Integer THE_NEUTRAL_SEL_PRIORITY = 5;
- static const Standard_Integer THE_LOCAL_SEL_PRIORITY = 6;
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_Dimension::AIS_Dimension (const AIS_KindOfDimension theType)
-: AIS_InteractiveObject (),
- mySelToleranceForText2d(0.0),
- myValueType (ValueType_Computed),
- myCustomValue (0.0),
- myCustomStringValue (),
- myIsTextPositionFixed (Standard_False),
- mySpecialSymbol (' '),
- myDisplaySpecialSymbol (AIS_DSS_No),
- myGeometryType (GeometryType_UndefShapes),
- myIsPlaneCustom (Standard_False),
- myFlyout (0.0),
- myIsGeometryValid (Standard_False),
- myKindOfDimension (theType)
-{
-}
-
-//=======================================================================
-//function : SetCustomValue
-//purpose :
-//=======================================================================
-void AIS_Dimension::SetCustomValue (const Standard_Real theValue)
-{
- if (myValueType == ValueType_CustomReal && myCustomValue == theValue)
- {
- return;
- }
-
- myValueType = ValueType_CustomReal;
- myCustomValue = theValue;
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetCustomValue
-//purpose :
-//=======================================================================
-void AIS_Dimension::SetCustomValue (const TCollection_ExtendedString& theValue)
-{
- if (myValueType == ValueType_CustomText && myCustomStringValue == theValue)
- {
- return;
- }
-
- myValueType = ValueType_CustomText;
- myCustomStringValue = theValue;
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : GetCustomValue
-//purpose :
-//=======================================================================
-const TCollection_ExtendedString& AIS_Dimension::GetCustomValue () const
-{
- return myCustomStringValue;
-}
-
-//=======================================================================
-//function : GetPlane
-//purpose :
-//=======================================================================
-const gp_Pln& AIS_Dimension::GetPlane() const
-{
- return myPlane;
-}
-
-//=======================================================================
-//function : SetUserPlane
-//purpose :
-//=======================================================================
-void AIS_Dimension::SetCustomPlane (const gp_Pln& thePlane)
-{
- myPlane = thePlane;
- myIsPlaneCustom = Standard_True;
-
- // Disable fixed (custom) text position
- UnsetFixedTextPosition();
-
- // Check validity if geometry has been set already.
- if (IsValid())
- {
- SetToUpdate();
- }
-}
-
-//=======================================================================
-//function : SetDimensionAspect
-//purpose :
-//=======================================================================
-void AIS_Dimension::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect)
-{
- myDrawer->SetDimensionAspect (theDimensionAspect);
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetDisplaySpecialSymbol
-//purpose :
-//=======================================================================
-void AIS_Dimension::SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol)
-{
- if (myDisplaySpecialSymbol == theDisplaySpecSymbol)
- {
- return;
- }
-
- myDisplaySpecialSymbol = theDisplaySpecSymbol;
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetSpecialSymbol
-//purpose :
-//=======================================================================
-void AIS_Dimension::SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol)
-{
- if (mySpecialSymbol == theSpecialSymbol)
- {
- return;
- }
-
- mySpecialSymbol = theSpecialSymbol;
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetSelToleranceForText2d
-//purpose :
-//=======================================================================
-void AIS_Dimension::SetSelToleranceForText2d (const Standard_Real theTol)
-{
- if (mySelToleranceForText2d == theTol)
- {
- return;
- }
-
- mySelToleranceForText2d = theTol;
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetFlyout
-//purpose :
-//=======================================================================
-void AIS_Dimension::SetFlyout (const Standard_Real theFlyout)
-{
- if (myFlyout == theFlyout)
- {
- return;
- }
-
- myFlyout = theFlyout;
-
- // Disable fixed text position
- UnsetFixedTextPosition();
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : GetDisplayUnits
-//purpose :
-//=======================================================================
-const TCollection_AsciiString& AIS_Dimension::GetDisplayUnits() const
-{
- return THE_UNDEFINED_UNITS;
-}
-
-//=======================================================================
-//function : GetModelUnits
-//purpose :
-//=======================================================================
-const TCollection_AsciiString& AIS_Dimension::GetModelUnits() const
-{
- return THE_UNDEFINED_UNITS;
-}
-
-//=======================================================================
-//function : ValueToDisplayUnits
-//purpose :
-//=======================================================================
-Standard_Real AIS_Dimension::ValueToDisplayUnits() const
-{
- return UnitsAPI::AnyToAny (GetValue(),
- GetModelUnits().ToCString(),
- GetDisplayUnits().ToCString());
-}
-
-//=======================================================================
-//function : GetValueString
-//purpose :
-//=======================================================================
-TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidth) const
-{
- TCollection_ExtendedString aValueStr;
- if (myValueType == ValueType_CustomText)
- {
- aValueStr = myCustomStringValue;
- }
- else
- {
- // format value string using "sprintf"
- TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
-
- char aFmtBuffer[256];
- sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
- aValueStr = TCollection_ExtendedString (aFmtBuffer);
- }
-
- // add units to values string
- if (myDrawer->DimensionAspect()->IsUnitsDisplayed())
- {
- aValueStr += " ";
- aValueStr += TCollection_ExtendedString (GetDisplayUnits());
- }
-
- switch (myDisplaySpecialSymbol)
- {
- case AIS_DSS_Before : aValueStr.Insert (1, mySpecialSymbol); break;
- case AIS_DSS_After : aValueStr.Insert (aValueStr.Length() + 1, mySpecialSymbol); break;
- case AIS_DSS_No : break;
- }
-
- // Get text style parameters
- Handle(Prs3d_TextAspect) aTextAspect = myDrawer->DimensionAspect()->TextAspect();
- NCollection_Utf8String anUTFString (aValueStr.ToExtString());
-
- theWidth = 0.0;
-
- if (myDrawer->DimensionAspect()->IsText3d())
- {
- // text width produced by BRepFont
- Font_BRepFont aFont;
- if (aFont.FindAndInit (aTextAspect->Aspect()->Font(), aTextAspect->Aspect()->GetTextFontAspect(), aTextAspect->Height(), Font_StrictLevel_Any))
- {
- for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
- {
- Standard_Utf32Char aCurrChar = *anIter;
- Standard_Utf32Char aNextChar = *(++anIter);
- theWidth += aFont.AdvanceX (aCurrChar, aNextChar);
- }
- }
- }
- else
- {
- // Text width for 1:1 scale 2D case
- Font_FTFontParams aFontParams;
- aFontParams.PointSize = (unsigned int )aTextAspect->Height();
- aFontParams.Resolution = THE_2D_TEXT_RESOLUTION;
- if (Handle(Font_FTFont) aFont = Font_FTFont::FindAndCreate (aTextAspect->Aspect()->Font(), aTextAspect->Aspect()->GetTextFontAspect(), aFontParams, Font_StrictLevel_Any))
- {
- for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
- {
- Standard_Utf32Char aCurrChar = *anIter;
- Standard_Utf32Char aNextChar = *(++anIter);
- theWidth += (Standard_Real) aFont->AdvanceX (aCurrChar, aNextChar);
- }
- }
- }
-
- return aValueStr;
-}
-
-//=======================================================================
-//function : DrawArrow
-//purpose :
-//=======================================================================
-void AIS_Dimension::DrawArrow (const Handle(Prs3d_Presentation)& thePresentation,
- const gp_Pnt& theLocation,
- const gp_Dir& theDirection)
-{
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
-
- Standard_Real aLength = myDrawer->DimensionAspect()->ArrowAspect()->Length();
- Standard_Real anAngle = myDrawer->DimensionAspect()->ArrowAspect()->Angle();
-
- if (myDrawer->DimensionAspect()->IsArrows3d())
- {
- Prs3d_Arrow::Draw (aGroup,
- theLocation,
- theDirection,
- anAngle,
- aLength);
- aGroup->SetGroupPrimitivesAspect (myDrawer->DimensionAspect()->ArrowAspect()->Aspect());
- }
- else
- {
- gp_Pnt aLeftPoint (gp::Origin());
- gp_Pnt aRightPoint (gp::Origin());
- const gp_Dir& aPlane = GetPlane().Axis().Direction();
-
- PointsForArrow (theLocation, theDirection, aPlane, aLength, anAngle, aLeftPoint, aRightPoint);
-
- Handle(Graphic3d_ArrayOfTriangles) anArrow = new Graphic3d_ArrayOfTriangles(3);
-
- anArrow->AddVertex (aLeftPoint);
- anArrow->AddVertex (theLocation);
- anArrow->AddVertex (aRightPoint);
-
- // Set aspect for arrow triangles
- Graphic3d_PolygonOffset aPolOffset;
- aPolOffset.Mode = Aspect_POM_Off;
- aPolOffset.Factor = 0.0f;
- aPolOffset.Units = 0.0f;
- Handle(Graphic3d_AspectFillArea3d) aShadingStyle = new Graphic3d_AspectFillArea3d();
- aShadingStyle->SetInteriorStyle (Aspect_IS_SOLID);
- aShadingStyle->SetColor (myDrawer->DimensionAspect()->ArrowAspect()->Aspect()->Color());
- aShadingStyle->SetShadingModel (Graphic3d_TOSM_UNLIT);
- aShadingStyle->SetPolygonOffset (aPolOffset);
-
- aGroup->SetPrimitivesAspect (aShadingStyle);
- aGroup->AddPrimitiveArray (anArrow);
- }
-
- SelectionGeometry::Arrow& aSensitiveArrow = mySelectionGeom.NewArrow();
- aSensitiveArrow.Position = theLocation;
- aSensitiveArrow.Direction = theDirection;
-}
-
-//=======================================================================
-//function : drawText
-//purpose :
-//=======================================================================
-void AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation,
- const gp_Pnt& theTextPos,
- const gp_Dir& theTextDir,
- const TCollection_ExtendedString& theText,
- const Standard_Integer theLabelPosition)
-{
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
- if (myDrawer->DimensionAspect()->IsText3d())
- {
- // getting font parameters
- Handle(Prs3d_TextAspect) aTextAspect = myDrawer->DimensionAspect()->TextAspect();
- Quantity_Color aColor = aTextAspect->Aspect()->Color();
- Font_FontAspect aFontAspect = aTextAspect->Aspect()->GetTextFontAspect();
- Standard_Real aFontHeight = aTextAspect->Height();
-
- // creating TopoDS_Shape for text
- Font_BRepFont aFont (aTextAspect->Aspect()->Font().ToCString(),
- aFontAspect, aFontHeight);
- NCollection_Utf8String anUTFString (theText.ToExtString());
-
- Font_BRepTextBuilder aBuilder;
- TopoDS_Shape aTextShape = aBuilder.Perform (aFont, anUTFString);
-
- // compute text width with kerning
- Standard_Real aTextWidth = 0.0;
- Standard_Real aTextHeight = aFont.Ascender() + aFont.Descender();
-
- for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
- {
- Standard_Utf32Char aCurrChar = *anIter;
- Standard_Utf32Char aNextChar = *(++anIter);
- aTextWidth += aFont.AdvanceX (aCurrChar, aNextChar);
- }
-
- // formating text position in XOY plane
- Standard_Integer aHLabelPos = theLabelPosition & LabelPosition_HMask;
- Standard_Integer aVLabelPos = theLabelPosition & LabelPosition_VMask;
-
- gp_Dir aTextDir (aHLabelPos == LabelPosition_Left ? -theTextDir : theTextDir);
-
- // compute label offsets
- Standard_Real aMarginSize = aFontHeight * THE_3D_TEXT_MARGIN;
- Standard_Real aCenterHOffset = 0.0;
- Standard_Real aCenterVOffset = 0.0;
- switch (aHLabelPos)
- {
- case LabelPosition_HCenter : aCenterHOffset = 0.0; break;
- case LabelPosition_Right : aCenterHOffset = aTextWidth / 2.0 + aMarginSize; break;
- case LabelPosition_Left : aCenterHOffset = -aTextWidth / 2.0 - aMarginSize; break;
- }
- switch (aVLabelPos)
- {
- case LabelPosition_VCenter : aCenterVOffset = 0.0; break;
- case LabelPosition_Above : aCenterVOffset = aTextHeight / 2.0 + aMarginSize; break;
- case LabelPosition_Below : aCenterVOffset = -aTextHeight / 2.0 - aMarginSize; break;
- }
-
- // compute shape offset transformation
- Standard_Real aShapeHOffset = aCenterHOffset - aTextWidth / 2.0;
- Standard_Real aShapeVOffset = aCenterVOffset - aTextHeight / 2.0;
-
- // center shape in its bounding box (suppress border spacing added by FT_Font)
- Bnd_Box aShapeBnd;
- BRepBndLib::AddClose (aTextShape, aShapeBnd);
-
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- aShapeBnd.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-
- Standard_Real aXalign = aTextWidth * 0.5 - (aXmax + aXmin) * 0.5;
- Standard_Real aYalign = aTextHeight * 0.5 - (aYmax + aYmin) * 0.5;
- aShapeHOffset += aXalign;
- aShapeVOffset += aYalign;
-
- gp_Trsf anOffsetTrsf;
- anOffsetTrsf.SetTranslation (gp::Origin(), gp_Pnt (aShapeHOffset, aShapeVOffset, 0.0));
- aTextShape.Move (anOffsetTrsf);
-
- // transform text to myWorkingPlane coordinate system
- gp_Ax3 aTextCoordSystem (theTextPos, GetPlane().Axis().Direction(), aTextDir);
- gp_Trsf aTextPlaneTrsf;
- aTextPlaneTrsf.SetTransformation (aTextCoordSystem, gp_Ax3 (gp::XOY()));
- aTextShape.Move (aTextPlaneTrsf);
-
- // set text flipping anchors
- gp_Trsf aCenterOffsetTrsf;
- gp_Pnt aCenterOffset (aCenterHOffset, aCenterVOffset, 0.0);
- aCenterOffsetTrsf.SetTranslation (gp::Origin(), aCenterOffset);
-
- gp_Pnt aCenterOfLabel (gp::Origin());
- aCenterOfLabel.Transform (aCenterOffsetTrsf);
- aCenterOfLabel.Transform (aTextPlaneTrsf);
-
- gp_Ax2 aFlippingAxes (aCenterOfLabel, GetPlane().Axis().Direction(), aTextDir);
- aGroup->SetFlippingOptions (Standard_True, aFlippingAxes);
-
- // draw text
- if (myDrawer->DimensionAspect()->IsTextShaded())
- {
- // Setting text shading and color parameters
- if (!myDrawer->HasOwnShadingAspect())
- {
- myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- }
-
- Graphic3d_MaterialAspect aShadeMat (Graphic3d_NOM_DEFAULT);
- aShadeMat.SetAmbientColor (Quantity_NOC_BLACK);
- aShadeMat.SetDiffuseColor (Quantity_NOC_BLACK);
- aShadeMat.SetSpecularColor(Quantity_NOC_BLACK);
- myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor);
- myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor (aColor);
- myDrawer->ShadingAspect()->SetMaterial (aShadeMat);
-
- // drawing text
- StdPrs_ShadedShape::Add (thePresentation, aTextShape, myDrawer);
- }
- else
- {
- // Setting color for text
- if (!myDrawer->HasOwnFreeBoundaryAspect())
- {
- myDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (aColor, Aspect_TOL_SOLID, 1.0));
- }
- myDrawer->FreeBoundaryAspect()->Aspect()->SetColor (aColor);
-
- // drawing text
- if (Handle(Graphic3d_ArrayOfPrimitives) anEdges = StdPrs_WFShape::AddAllEdges (aTextShape, myDrawer))
- {
- aGroup->SetGroupPrimitivesAspect (myDrawer->FreeBoundaryAspect()->Aspect());
- aGroup->AddPrimitiveArray (anEdges);
- }
- }
- Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, gp_Ax2());
-
- mySelectionGeom.TextPos = aCenterOfLabel;
- mySelectionGeom.TextDir = aTextDir;
- mySelectionGeom.TextWidth = aTextWidth + aMarginSize * 2.0;
- mySelectionGeom.TextHeight = aTextHeight;
-
- return;
- }
-
- // generate primitives for 2D text
- myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION);
-
- Prs3d_Text::Draw (aGroup,
- myDrawer->DimensionAspect()->TextAspect(),
- theText,
- theTextPos);
-
- mySelectionGeom.TextPos = theTextPos;
- mySelectionGeom.TextDir = theTextDir;
- mySelectionGeom.TextWidth = 0.0;
- mySelectionGeom.TextHeight = 0.0;
-}
-
-//=======================================================================
-//function : DrawExtension
-//purpose :
-//=======================================================================
-void AIS_Dimension::DrawExtension (const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Real theExtensionSize,
- const gp_Pnt& theExtensionStart,
- const gp_Dir& theExtensionDir,
- const TCollection_ExtendedString& theLabelString,
- const Standard_Real theLabelWidth,
- const Standard_Integer theMode,
- const Standard_Integer theLabelPosition)
-{
- // reference line for extension starting at its connection point
- gp_Lin anExtensionLine (theExtensionStart, theExtensionDir);
-
- Standard_Boolean hasLabel = theLabelString.Length() > 0;
- if (hasLabel && (theMode == ComputeMode_All || theMode == ComputeMode_Text))
- {
- // compute text primitives; get its model width
- gp_Pnt aTextPos = ElCLib::Value (theExtensionSize, anExtensionLine);
- gp_Dir aTextDir = theExtensionDir;
-
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
- drawText (thePresentation,
- aTextPos,
- aTextDir,
- theLabelString,
- theLabelPosition);
- }
-
- if (theMode != ComputeMode_All && theMode != ComputeMode_Line)
- {
- return;
- }
-
- Standard_Boolean isShortLine = !myDrawer->DimensionAspect()->IsText3d()
- || theLabelPosition & LabelPosition_VCenter;
-
- // compute graphical primitives and sensitives for extension line
- gp_Pnt anExtStart = theExtensionStart;
- gp_Pnt anExtEnd = !hasLabel || isShortLine
- ? ElCLib::Value (theExtensionSize, anExtensionLine)
- : ElCLib::Value (theExtensionSize + theLabelWidth, anExtensionLine);
-
- // add graphical primitives
- Handle(Graphic3d_ArrayOfSegments) anExtPrimitive = new Graphic3d_ArrayOfSegments (2);
- anExtPrimitive->AddVertex (anExtStart);
- anExtPrimitive->AddVertex (anExtEnd);
-
- // add selection primitives
- SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
- aSensitiveCurve.Append (anExtStart);
- aSensitiveCurve.Append (anExtEnd);
-
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
- if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
- {
- aGroup->SetStencilTestOptions (Standard_True);
- }
- Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
- aGroup->SetPrimitivesAspect (aDimensionLineStyle);
- aGroup->AddPrimitiveArray (anExtPrimitive);
- if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
- {
- aGroup->SetStencilTestOptions (Standard_False);
- }
-}
-
-//=======================================================================
-//function : DrawLinearDimension
-//purpose :
-//=======================================================================
-void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode,
- const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const Standard_Boolean theIsOneSide)
-{
- // do not build any dimension for equal points
- if (theFirstPoint.IsEqual (theSecondPoint, Precision::Confusion()))
- {
- throw Standard_ProgramError("Can not build presentation for equal points.");
- }
-
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
-
- // For extensions we need to know arrow size, text size and extension size: get it from aspect
- Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
- Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
- // prepare label string and compute its geometrical width
- Standard_Real aLabelWidth;
- TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
-
- // add margins to cut dimension lines for 3d text
- if (aDimensionAspect->IsText3d())
- {
- aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0;
- }
-
- // handle user-defined and automatic arrow placement
- Standard_Boolean isArrowsExternal = Standard_False;
- Standard_Integer aLabelPosition = LabelPosition_None;
-
- Prs3d_DimensionTextHorizontalPosition aHorisontalTextPos = aDimensionAspect->TextHorizontalPosition();
- if (IsTextPositionCustom())
- {
- if (!AdjustParametersForLinear (myFixedTextPosition, theFirstPoint, theSecondPoint,
- anExtensionSize, aHorisontalTextPos, myFlyout, myPlane, myIsPlaneCustom))
- {
- throw Standard_ProgramError("Can not adjust plane to the custom label position.");
- }
- }
-
- FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, aHorisontalTextPos,
- aLabelPosition, isArrowsExternal);
-
- // compute dimension line points
- gp_Pnt aLineBegPoint, aLineEndPoint;
- ComputeFlyoutLinePoints (theFirstPoint, theSecondPoint, aLineBegPoint, aLineEndPoint);
- gp_Lin aDimensionLine = gce_MakeLin (aLineBegPoint, aLineEndPoint);
-
- // compute arrows positions and directions
- gp_Dir aFirstArrowDir = aDimensionLine.Direction().Reversed();
- gp_Dir aSecondArrowDir = aDimensionLine.Direction();
- gp_Dir aFirstExtensionDir = aDimensionLine.Direction().Reversed();
- gp_Dir aSecondExtensionDir = aDimensionLine.Direction();
-
- gp_Pnt aFirstArrowBegin (0.0, 0.0, 0.0);
- gp_Pnt aFirstArrowEnd (0.0, 0.0, 0.0);
- gp_Pnt aSecondArrowBegin (0.0, 0.0, 0.0);
- gp_Pnt aSecondArrowEnd (0.0, 0.0, 0.0);
-
- if (isArrowsExternal)
- {
- aFirstArrowDir.Reverse();
- aSecondArrowDir.Reverse();
- }
-
- aFirstArrowBegin = aLineBegPoint;
- aSecondArrowBegin = aLineEndPoint;
- aFirstArrowEnd = aLineBegPoint.Translated (-gp_Vec (aFirstArrowDir).Scaled (anArrowLength));
- aSecondArrowEnd = aLineEndPoint.Translated (-gp_Vec (aSecondArrowDir).Scaled (anArrowLength));
-
- gp_Pnt aCenterLineBegin = isArrowsExternal
- ? aLineBegPoint : aFirstArrowEnd;
-
- gp_Pnt aCenterLineEnd = isArrowsExternal || theIsOneSide
- ? aLineEndPoint : aSecondArrowEnd;
-
-
- switch (aLabelPosition & LabelPosition_HMask)
- {
- // ------------------------------------------------------------------------ //
- // CENTER //
- // -------------------------------------------------------------------------//
- case LabelPosition_HCenter:
- {
- // add label on dimension or extension line to presentation
- gp_Pnt aTextPos = IsTextPositionCustom() ? myFixedTextPosition
- : (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5;
- gp_Dir aTextDir = aDimensionLine.Direction();
-
- // add text primitives
- if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
- {
- thePresentation->NewGroup();
- drawText (thePresentation,
- aTextPos,
- aTextDir,
- aLabelString,
- aLabelPosition);
- }
-
- // add dimension line primitives
- if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
- {
- Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
- && aDimensionAspect->IsText3d();
-
- Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (isLineBreak ? 4 : 2);
-
- // compute continuous or sectioned main line segments
- if (isLineBreak)
- {
- Standard_Real aPTextPosition = ElCLib::Parameter (aDimensionLine, aTextPos);
- gp_Pnt aSection1Beg = aCenterLineBegin;
- gp_Pnt aSection1End = ElCLib::Value (aPTextPosition - (aLabelWidth * 0.5), aDimensionLine);
- gp_Pnt aSection2Beg = ElCLib::Value (aPTextPosition + (aLabelWidth * 0.5), aDimensionLine);
- gp_Pnt aSection2End = aCenterLineEnd;
-
- aPrimSegments->AddVertex (aSection1Beg);
- aPrimSegments->AddVertex (aSection1End);
- aPrimSegments->AddVertex (aSection2Beg);
- aPrimSegments->AddVertex (aSection2End);
-
- SelectionGeometry::Curve& aLeftSensitiveCurve = mySelectionGeom.NewCurve();
- SelectionGeometry::Curve& aRightSensitiveCurve = mySelectionGeom.NewCurve();
- aLeftSensitiveCurve.Append (aSection1Beg);
- aLeftSensitiveCurve.Append (aSection1End);
- aRightSensitiveCurve.Append (aSection2Beg);
- aRightSensitiveCurve.Append (aSection2End);
- }
- else
- {
- aPrimSegments->AddVertex (aCenterLineBegin);
- aPrimSegments->AddVertex (aCenterLineEnd);
-
- SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
- aSensitiveCurve.Append (aCenterLineBegin);
- aSensitiveCurve.Append (aCenterLineEnd);
- }
-
- // set text label justification
- Graphic3d_VerticalTextAlignment aTextJustificaton = Graphic3d_VTA_BOTTOM;
- switch (aLabelPosition & LabelPosition_VMask)
- {
- case LabelPosition_Above :
- case LabelPosition_VCenter : aTextJustificaton = Graphic3d_VTA_BOTTOM; break;
- case LabelPosition_Below : aTextJustificaton = Graphic3d_VTA_TOP; break;
- }
- aDimensionAspect->TextAspect()->SetVerticalJustification (aTextJustificaton);
-
- // main dimension line, short extension
- {
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
- if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
- {
- aGroup->SetStencilTestOptions (Standard_True);
- }
- aGroup->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- aGroup->AddPrimitiveArray (aPrimSegments);
- if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
- {
- aGroup->SetStencilTestOptions (Standard_False);
- }
- }
-
- // add arrows to presentation
- {
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
- DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
- if (!theIsOneSide)
- {
- DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
- }
- }
-
- if (!isArrowsExternal)
- {
- break;
- }
-
- // add arrow extension lines to presentation
- {
- DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
- aFirstArrowEnd, aFirstExtensionDir,
- THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
- if (!theIsOneSide)
- {
- DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
- aSecondArrowEnd, aSecondExtensionDir,
- THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
- }
- }
- }
- break;
- }
- // ------------------------------------------------------------------------ //
- // LEFT //
- // -------------------------------------------------------------------------//
-
- case LabelPosition_Left:
- {
- // add label on dimension or extension line to presentation
- {
- // Left extension with the text
- DrawExtension (thePresentation, anExtensionSize,
- isArrowsExternal
- ? aFirstArrowEnd
- : aFirstArrowBegin,
- aFirstExtensionDir,
- aLabelString,
- aLabelWidth,
- theMode,
- aLabelPosition);
- }
-
- // add dimension line primitives
- if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
- {
- // add central dimension line
- {
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
-
- // add graphical primitives
- Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
- aPrimSegments->AddVertex (aCenterLineBegin);
- aPrimSegments->AddVertex (aCenterLineEnd);
-
- aGroup->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- aGroup->AddPrimitiveArray (aPrimSegments);
-
- // add selection primitives
- SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
- aSensitiveCurve.Append (aCenterLineBegin);
- aSensitiveCurve.Append (aCenterLineEnd);
- }
-
- // add arrows to presentation
- {
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
- DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
- if (!theIsOneSide)
- {
- DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
- }
- }
-
- if (!isArrowsExternal || theIsOneSide)
- {
- break;
- }
-
- // add extension lines for external arrows
- {
- DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
- aSecondArrowEnd, aSecondExtensionDir,
- THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
- }
- }
-
- break;
- }
- // ------------------------------------------------------------------------ //
- // RIGHT //
- // -------------------------------------------------------------------------//
-
- case LabelPosition_Right:
- {
- // add label on dimension or extension line to presentation
-
- // Right extension with text
- DrawExtension (thePresentation, anExtensionSize,
- isArrowsExternal
- ? aSecondArrowEnd
- : aSecondArrowBegin,
- aSecondExtensionDir,
- aLabelString, aLabelWidth,
- theMode,
- aLabelPosition);
-
- if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
- {
- // add central dimension line
- {
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
-
- // add graphical primitives
- Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
- aPrimSegments->AddVertex (aCenterLineBegin);
- aPrimSegments->AddVertex (aCenterLineEnd);
- aGroup->SetGroupPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- aGroup->AddPrimitiveArray (aPrimSegments);
-
- // add selection primitives
- SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
- aSensitiveCurve.Append (aCenterLineBegin);
- aSensitiveCurve.Append (aCenterLineEnd);
- }
-
- // add arrows to presentation
- {
- thePresentation->NewGroup();
- DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
- if (!theIsOneSide)
- {
- DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
- }
- }
-
- if (!isArrowsExternal || theIsOneSide)
- {
- break;
- }
-
- // add extension lines for external arrows
- {
- DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
- aFirstArrowEnd, aFirstExtensionDir,
- THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
- }
- }
-
- break;
- }
- }
-
- // add flyout lines to presentation
- if (theMode == ComputeMode_All)
- {
- Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
-
- Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4);
- aPrimSegments->AddVertex (theFirstPoint);
- aPrimSegments->AddVertex (aLineBegPoint);
-
- aPrimSegments->AddVertex (theSecondPoint);
- aPrimSegments->AddVertex (aLineEndPoint);
-
- aGroup->SetGroupPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- aGroup->AddPrimitiveArray (aPrimSegments);
- }
-
- mySelectionGeom.IsComputed = Standard_True;
-}
-
-//=======================================================================
-//function : ComputeFlyoutLinePoints
-//purpose :
-//=======================================================================
-void AIS_Dimension::ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
- gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint)
-{
- // compute dimension line points
- gp_Ax1 aPlaneNormal = GetPlane().Axis();
- // compute flyout direction vector
- gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
- gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector;
- // create lines for layouts
- gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
- gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
-
- // Get flyout end points
- theLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
- theLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
-}
-
-//=======================================================================
-//function : ComputeLinearFlyouts
-//purpose :
-//=======================================================================
-void AIS_Dimension::ComputeLinearFlyouts (const Handle(SelectMgr_Selection)& theSelection,
- const Handle(SelectMgr_EntityOwner)& theOwner,
- const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint)
-{
- // count flyout direction
- gp_Ax1 aPlaneNormal = GetPlane().Axis();
- gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
-
- // count a flyout direction vector.
- gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector;
-
- // create lines for layouts
- gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
- gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
-
- // get flyout end points
- gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
- gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
-
- // fill sensitive entity for flyouts
- Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (theOwner);
- aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, theFirstPoint, aFlyoutEnd1));
- aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, theSecondPoint, aFlyoutEnd2));
- theSelection->Add (aSensitiveEntity);
-}
-
-//=======================================================================
-//function : CircleFromPlanarFace
-//purpose : if possible computes circle from planar face
-//=======================================================================
-Standard_Boolean AIS_Dimension::CircleFromPlanarFace (const TopoDS_Face& theFace,
- Handle(Geom_Curve)& theCurve,
- gp_Pnt& theFirstPoint,
- gp_Pnt& theLastPoint)
-{
- TopExp_Explorer anIt (theFace, TopAbs_EDGE);
- for ( ; anIt.More(); anIt.Next())
- {
- TopoDS_Edge aCurEdge = TopoDS::Edge (anIt.Current());
- if (AIS::ComputeGeometry (aCurEdge, theCurve, theFirstPoint, theLastPoint))
- {
- if (theCurve->IsInstance (STANDARD_TYPE(Geom_Circle)))
- {
- return Standard_True;
- }
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : CircleFromEdge
-//purpose : if possible computes circle from edge
-//=======================================================================
-Standard_Boolean AIS_Dimension::CircleFromEdge (const TopoDS_Edge& theEdge,
- gp_Circ& theCircle,
- gp_Pnt& theFirstPoint,
- gp_Pnt& theLastPoint)
-{
- BRepAdaptor_Curve anAdaptedCurve (theEdge);
- switch (anAdaptedCurve.GetType())
- {
- case GeomAbs_Circle:
- {
- theCircle = anAdaptedCurve.Circle();
- break;
- }
- case GeomAbs_Ellipse:
- {
- gp_Elips anEll = anAdaptedCurve.Ellipse();
- if ((anEll.MinorRadius() - anEll.MajorRadius()) >= Precision::Confusion())
- {
- return Standard_False;
- }
- theCircle = gp_Circ(anEll.Position(),anEll.MinorRadius());
- break;
- }
- case GeomAbs_Line:
- case GeomAbs_Hyperbola:
- case GeomAbs_Parabola:
- case GeomAbs_BezierCurve:
- case GeomAbs_BSplineCurve:
- case GeomAbs_OtherCurve:
- default:
- return Standard_False;
- }
-
- theFirstPoint = anAdaptedCurve.Value (anAdaptedCurve.FirstParameter());
- theLastPoint = anAdaptedCurve.Value (anAdaptedCurve.LastParameter());
- return Standard_True;
-}
-
-//=======================================================================
-//function : InitCircularDimension
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_Dimension::InitCircularDimension (const TopoDS_Shape& theShape,
- gp_Circ& theCircle,
- gp_Pnt& theMiddleArcPoint,
- Standard_Boolean& theIsClosed)
-{
- gp_Pln aPln;
- Handle(Geom_Surface) aBasisSurf;
- AIS_KindOfSurface aSurfType = AIS_KOS_OtherSurface;
- gp_Pnt aFirstPoint, aLastPoint;
- Standard_Real anOffset = 0.0;
- Standard_Real aFirstParam = 0.0;
- Standard_Real aLastParam = 0.0;
-
- // Discover circular geometry
- switch (theShape.ShapeType())
- {
- case TopAbs_FACE:
- {
- AIS::GetPlaneFromFace (TopoDS::Face (theShape), aPln, aBasisSurf, aSurfType, anOffset);
-
- if (aSurfType == AIS_KOS_Plane)
- {
- Handle(Geom_Curve) aCurve;
- if (!CircleFromPlanarFace (TopoDS::Face (theShape), aCurve, aFirstPoint, aLastPoint))
- {
- return Standard_False;
- }
-
- theCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ();
- }
- else
- {
- gp_Pnt aCurPos;
- BRepAdaptor_Surface aSurf1 (TopoDS::Face (theShape));
- Standard_Real aFirstU = aSurf1.FirstUParameter();
- Standard_Real aLastU = aSurf1.LastUParameter();
- Standard_Real aFirstV = aSurf1.FirstVParameter();
- Standard_Real aLastV = aSurf1.LastVParameter();
- Standard_Real aMidU = (aFirstU + aLastU) * 0.5;
- Standard_Real aMidV = (aFirstV + aLastV) * 0.5;
- aSurf1.D0 (aMidU, aMidV, aCurPos);
- Handle (Adaptor3d_HCurve) aBasisCurve;
- Standard_Boolean isExpectedType = Standard_False;
- if (aSurfType == AIS_KOS_Cylinder)
- {
- isExpectedType = Standard_True;
- }
- else
- {
- if (aSurfType == AIS_KOS_Revolution)
- {
- aBasisCurve = aSurf1.BasisCurve();
- if (aBasisCurve->GetType() == GeomAbs_Line)
- {
- isExpectedType = Standard_True;
- }
- }
- else if (aSurfType == AIS_KOS_Extrusion)
- {
- aBasisCurve = aSurf1.BasisCurve();
- if (aBasisCurve->GetType() == GeomAbs_Circle)
- {
- isExpectedType = Standard_True;
- }
- }
- }
-
- if (!isExpectedType)
- {
- return Standard_False;
- }
-
- Handle(Geom_Curve) aCurve = aBasisSurf->VIso(aMidV);
- if (aCurve->DynamicType() == STANDARD_TYPE (Geom_Circle))
- {
- theCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ();
- }
- else if (aCurve->DynamicType() == STANDARD_TYPE (Geom_TrimmedCurve))
- {
- Handle(Geom_TrimmedCurve) aTrimmedCurve = Handle(Geom_TrimmedCurve)::DownCast (aCurve);
- aFirstU = aTrimmedCurve->FirstParameter();
- aLastU = aTrimmedCurve->LastParameter();
- if (aTrimmedCurve->BasisCurve()->DynamicType() == STANDARD_TYPE (Geom_Circle))
- {
- theCircle = Handle(Geom_Circle)::DownCast(aTrimmedCurve->BasisCurve())->Circ();
- }
- }
- else
- {
- // Compute a circle from 3 points on "aCurve"
- gp_Pnt aP1, aP2;
- aSurf1.D0 (aFirstU, aMidV, aP1);
- aSurf1.D0 (aLastU, aMidV, aP2);
- GC_MakeCircle aMkCirc (aP1, aCurPos, aP2);
- theCircle = aMkCirc.Value()->Circ();
- }
-
- aFirstPoint = ElCLib::Value (aFirstU, theCircle);
- aLastPoint = ElCLib::Value (aLastU, theCircle);
- }
- break;
- }
- case TopAbs_WIRE:
- {
- TopoDS_Edge anEdge;
- TopExp_Explorer anIt (theShape, TopAbs_EDGE);
- if (anIt.More())
- {
- anEdge = TopoDS::Edge (anIt.Current());
- }
- if (!AIS_Dimension::CircleFromEdge (anEdge, theCircle, aFirstPoint, aLastPoint))
- {
- return Standard_False;
- }
- break;
- }
- case TopAbs_EDGE:
- {
- TopoDS_Edge anEdge = TopoDS::Edge (theShape);
- if (!AIS_Dimension::CircleFromEdge (anEdge, theCircle, aFirstPoint, aLastPoint))
- {
- return Standard_False;
- }
- break;
- }
- case TopAbs_COMPOUND:
- case TopAbs_COMPSOLID:
- case TopAbs_SOLID:
- case TopAbs_SHELL:
- case TopAbs_VERTEX:
- case TopAbs_SHAPE:
- default:
- return Standard_False;
- }
-
- theIsClosed = aFirstPoint.IsEqual (aLastPoint, Precision::Confusion());
-
- gp_Pnt aCenter = theCircle.Location();
-
- if (theIsClosed) // Circle
- {
- gp_Dir anXDir = theCircle.XAxis().Direction();
- theMiddleArcPoint = aCenter.Translated (gp_Vec (anXDir) * theCircle.Radius());
- }
- else // Arc
- {
- aFirstParam = ElCLib::Parameter (theCircle, aFirstPoint);
- aLastParam = ElCLib::Parameter (theCircle, aLastPoint);
- if (aFirstParam > aLastParam)
- {
- aFirstParam -= 2.0 * M_PI;
- }
-
- Standard_Real aParCurPos = (aFirstParam + aLastParam) * 0.5;
- gp_Vec aVec = gp_Vec (aCenter, ElCLib::Value (aParCurPos, theCircle)).Normalized () * theCircle.Radius ();
- theMiddleArcPoint = aCenter.Translated (aVec);
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-void AIS_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode)
-{
- if (!mySelectionGeom.IsComputed)
- {
- return;
- }
-
- AIS_DimensionSelectionMode aSelectionMode = (AIS_DimensionSelectionMode)theMode;
-
- // init appropriate entity owner
- Handle(SelectMgr_EntityOwner) aSensitiveOwner;
-
- switch (aSelectionMode)
- {
- // neutral selection owner
- case AIS_DSM_All :
- aSensitiveOwner = new SelectMgr_EntityOwner (this, THE_NEUTRAL_SEL_PRIORITY);
- break;
-
- // local selection owners
- case AIS_DSM_Line :
- case AIS_DSM_Text :
- aSensitiveOwner = new AIS_DimensionOwner (this, aSelectionMode, THE_LOCAL_SEL_PRIORITY);
- break;
- }
-
- if (aSelectionMode == AIS_DSM_All || aSelectionMode == AIS_DSM_Line)
- {
- // sensitives for dimension line segments
- Handle(Select3D_SensitiveGroup) aGroupOfSensitives = new Select3D_SensitiveGroup (aSensitiveOwner);
-
- SelectionGeometry::SeqOfCurves::Iterator aCurveIt (mySelectionGeom.DimensionLine);
- for (; aCurveIt.More(); aCurveIt.Next())
- {
- const SelectionGeometry::HCurve& aCurveData = aCurveIt.Value();
-
- TColgp_Array1OfPnt aSensitivePnts (1, aCurveData->Length());
- for (Standard_Integer aPntIt = 1; aPntIt <= aCurveData->Length(); ++aPntIt)
- {
- aSensitivePnts.ChangeValue (aPntIt) = aCurveData->Value (aPntIt);
- }
-
- aGroupOfSensitives->Add (new Select3D_SensitiveCurve (aSensitiveOwner, aSensitivePnts));
- }
-
- Standard_Real anArrowLength = myDrawer->DimensionAspect()->ArrowAspect()->Length();
- Standard_Real anArrowAngle = myDrawer->DimensionAspect()->ArrowAspect()->Angle();
-
- // sensitives for arrows
- SelectionGeometry::SeqOfArrows::Iterator anArrowIt (mySelectionGeom.Arrows);
- for (; anArrowIt.More(); anArrowIt.Next())
- {
- const SelectionGeometry::HArrow& anArrow = anArrowIt.Value();
-
- gp_Pnt aSidePnt1 (gp::Origin());
- gp_Pnt aSidePnt2 (gp::Origin());
- const gp_Dir& aPlane = GetPlane().Axis().Direction();
- const gp_Pnt& aPeak = anArrow->Position;
- const gp_Dir& aDir = anArrow->Direction;
-
- // compute points for arrow in plane
- PointsForArrow (aPeak, aDir, aPlane, anArrowLength, anArrowAngle, aSidePnt1, aSidePnt2);
-
- aGroupOfSensitives->Add (new Select3D_SensitiveTriangle (aSensitiveOwner, aPeak, aSidePnt1, aSidePnt2));
-
- if (!myDrawer->DimensionAspect()->IsArrows3d())
- {
- continue;
- }
-
- // compute points for orthogonal sensitive plane
- gp_Dir anOrthoPlane = anArrow->Direction.Crossed (aPlane);
-
- PointsForArrow (aPeak, aDir, anOrthoPlane, anArrowLength, anArrowAngle, aSidePnt1, aSidePnt2);
-
- aGroupOfSensitives->Add (new Select3D_SensitiveTriangle (aSensitiveOwner, aPeak, aSidePnt1, aSidePnt2));
- }
-
- theSelection->Add (aGroupOfSensitives);
- }
-
- // sensitives for text element
- if (aSelectionMode == AIS_DSM_All || aSelectionMode == AIS_DSM_Text)
- {
- Handle(Select3D_SensitiveEntity) aTextSensitive;
-
- gp_Ax2 aTextAxes (mySelectionGeom.TextPos,
- GetPlane().Axis().Direction(),
- mySelectionGeom.TextDir);
-
- if (myDrawer->DimensionAspect()->IsText3d())
- {
- // sensitive planar rectangle for text
- Standard_Real aDx = mySelectionGeom.TextWidth * 0.5;
- Standard_Real aDy = mySelectionGeom.TextHeight * 0.5;
-
- gp_Trsf aLabelPlane;
- aLabelPlane.SetTransformation (aTextAxes, gp::XOY());
-
- TColgp_Array1OfPnt aRectanglePoints(1, 4);
- aRectanglePoints.ChangeValue(1) = gp_Pnt (-aDx, -aDy, 0.0).Transformed (aLabelPlane);
- aRectanglePoints.ChangeValue(2) = gp_Pnt (-aDx, aDy, 0.0).Transformed (aLabelPlane);
- aRectanglePoints.ChangeValue(3) = gp_Pnt ( aDx, aDy, 0.0).Transformed (aLabelPlane);
- aRectanglePoints.ChangeValue(4) = gp_Pnt ( aDx, -aDy, 0.0).Transformed (aLabelPlane);
-
- Poly_Array1OfTriangle aTriangles(1, 2);
- aTriangles.ChangeValue(1) = Poly_Triangle(1, 2, 3);
- aTriangles.ChangeValue(2) = Poly_Triangle(1, 3, 4);
-
- Handle(Poly_Triangulation) aRectanglePoly =
- new Poly_Triangulation(aRectanglePoints, aTriangles);
-
- aTextSensitive =
- new Select3D_SensitiveTriangulation (aSensitiveOwner, aRectanglePoly, TopLoc_Location(), Standard_True);
- }
- else
- {
- gp_Circ aTextGeom (aTextAxes, mySelToleranceForText2d != 0.0
- ? mySelToleranceForText2d : 1.0);
-
- Handle(Geom_Circle) aSensGeom = new Geom_Circle (aTextGeom);
-
- aTextSensitive = new Select3D_SensitiveCircle (aSensitiveOwner, aSensGeom, Standard_True);
- }
-
- theSelection->Add (aTextSensitive);
- }
-
- // callback for flyout sensitive calculation
- if (aSelectionMode == AIS_DSM_All)
- {
- ComputeFlyoutSelection (theSelection, aSensitiveOwner);
- }
-}
-
-//=======================================================================
-//function : PointsForArrow
-//purpose :
-//=======================================================================
-void AIS_Dimension::PointsForArrow (const gp_Pnt& thePeakPnt,
- const gp_Dir& theDirection,
- const gp_Dir& thePlane,
- const Standard_Real theArrowLength,
- const Standard_Real theArrowAngle,
- gp_Pnt& theSidePnt1,
- gp_Pnt& theSidePnt2)
-{
- gp_Lin anArrowLin (thePeakPnt, theDirection.Reversed());
- gp_Pnt anArrowEnd = ElCLib::Value (theArrowLength, anArrowLin);
- gp_Lin anEdgeLin (anArrowEnd, theDirection.Crossed (thePlane));
-
- Standard_Real anEdgeLength = Tan (theArrowAngle) * theArrowLength;
-
- theSidePnt1 = ElCLib::Value ( anEdgeLength, anEdgeLin);
- theSidePnt2 = ElCLib::Value (-anEdgeLength, anEdgeLin);
-}
-
-//=======================================================================
-//function : GetTextPositionForLinear
-//purpose :
-//=======================================================================
-gp_Pnt AIS_Dimension::GetTextPositionForLinear (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const Standard_Boolean theIsOneSide) const
-{
- if (!IsValid())
- {
- return gp::Origin();
- }
-
- gp_Pnt aTextPosition (gp::Origin());
-
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
-
- // Get label alignment and arrow orientation.
- Standard_Integer aLabelPosition = 0;
- Standard_Boolean isArrowsExternal = Standard_False;
- FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide,
- aDimensionAspect->TextHorizontalPosition(),
- aLabelPosition, isArrowsExternal);
-
- // Compute dimension line points.
- gp_Dir aPlaneNormal = GetPlane().Axis().Direction();
- gp_Vec aTargetPointsVec (theFirstPoint, theSecondPoint);
-
- // Compute flyout direction vector
- gp_Dir aFlyoutVector = aPlaneNormal ^ gp_Dir (aTargetPointsVec);
-
- // create lines for layouts
- gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
- gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
- // Get flyout end points
- gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
- gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
-
- // Get text position.
- switch (aLabelPosition & LabelPosition_HMask)
- {
- case LabelPosition_Left:
- {
- gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint);
- Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
-
- Standard_Real anOffset = isArrowsExternal
- ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length()
- : anExtensionSize;
- gp_Vec anExtensionVec = gp_Vec (aTargetPointsDir) * -anOffset;
- aTextPosition = aLineEndPoint.Translated (anExtensionVec);
- }
- break;
- case LabelPosition_Right:
- {
- gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint);
- Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
-
- Standard_Real anOffset = isArrowsExternal
- ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length()
- : anExtensionSize;
- gp_Vec anExtensionVec = gp_Vec (aTargetPointsDir) * anOffset;
- aTextPosition = aLineBegPoint.Translated (anExtensionVec);
- }
- break;
- case LabelPosition_HCenter:
- {
- aTextPosition = (aLineBegPoint.XYZ() + aLineEndPoint.XYZ()) * 0.5;
- }
- break;
- }
-
- return aTextPosition;
-}
-
-//=======================================================================
-//function : AdjustParametersForLinear
-//purpose :
-//=======================================================================
-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();
-
- 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);
-
- Standard_Real aCos = aFirstToTextVec.Normalized() * gp_Vec (aTargetPointsDir);
-
- gp_Pnt aTextPosProj = theFirstPoint.Translated
- (gp_Vec (aTargetPointsDir) * aFirstToTextVec.Magnitude() * aCos);
-
- // Compute flyout value and direction.
- gp_Vec aFlyoutVector = gp_Vec (aTextPosProj, theTextPos);
-
- 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 horizontal text alignment.
- if (aCos < 0.0)
- {
- theAlignment = Prs3d_DTHP_Left;
-
- Standard_Real aNewExtSize = theTextPos.Distance (aFirstAttach) - anArrowLength;
- theExtensionSize = aNewExtSize < 0.0 ? 0.0 : aNewExtSize;
- }
- else if (aTextPosProj.Distance (theFirstPoint) > theFirstPoint.Distance (theSecondPoint))
- {
- theAlignment = Prs3d_DTHP_Right;
-
- Standard_Real aNewExtSize = theTextPos.Distance (aSecondAttach) - anArrowLength;
- theExtensionSize = aNewExtSize < 0.0 ? 0.0 : aNewExtSize;
- }
- else
- {
- theAlignment = Prs3d_DTHP_Center;
- }
- return Standard_True;
-}
-
-//=======================================================================
-//function : FitTextAlignmentForLinear
-//purpose :
-//=======================================================================
-void AIS_Dimension::FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const Standard_Boolean theIsOneSide,
- const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
- Standard_Integer& theLabelPosition,
- Standard_Boolean& theIsArrowsExternal) const
-{
- theLabelPosition = LabelPosition_None;
- theIsArrowsExternal = Standard_False;
-
- // Compute dimension line points
- gp_Ax1 aPlaneNormal = GetPlane().Axis();
- gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
-
- // compute flyout direction vector
- gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector;
-
- // create lines for layouts
- gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
- gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
-
- // Get flyout end points
- gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
- gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
-
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
-
- // For extensions we need to know arrow size, text size and extension size: get it from aspect
- Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
-
- // prepare label string and compute its geometrical width
- Standard_Real aLabelWidth;
- TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
-
- // Add margins to cut dimension lines for 3d text
- if (aDimensionAspect->IsText3d())
- {
- aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0;
- }
-
- // Handle user-defined and automatic arrow placement
- switch (aDimensionAspect->ArrowOrientation())
- {
- case Prs3d_DAO_External: theIsArrowsExternal = true; break;
- case Prs3d_DAO_Internal: theIsArrowsExternal = false; break;
- case Prs3d_DAO_Fit:
- {
- // Add margin to ensure a small tail between text and arrow
- Standard_Real anArrowMargin = aDimensionAspect->IsText3d()
- ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN
- : 0.0;
-
- Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint);
- Standard_Real anArrowsWidth = theIsOneSide
- ? anArrowLength + anArrowMargin
- : (anArrowLength + anArrowMargin) * 2.0;
-
- theIsArrowsExternal = aDimensionWidth < aLabelWidth + anArrowsWidth;
- break;
- }
- }
-
- // Handle user-defined and automatic text placement
- switch (theHorizontalTextPos)
- {
- case Prs3d_DTHP_Left : theLabelPosition |= LabelPosition_Left; break;
- case Prs3d_DTHP_Right : theLabelPosition |= LabelPosition_Right; break;
- case Prs3d_DTHP_Center: theLabelPosition |= LabelPosition_HCenter; break;
- case Prs3d_DTHP_Fit:
- {
- Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint);
- Standard_Real anArrowsWidth = theIsOneSide ? anArrowLength : 2.0 * anArrowLength;
- Standard_Real aContentWidth = theIsArrowsExternal ? aLabelWidth : aLabelWidth + anArrowsWidth;
-
- theLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter;
- break;
- }
- }
-
- // Handle vertical text placement options
- switch (aDimensionAspect->TextVerticalPosition())
- {
- case Prs3d_DTVP_Above : theLabelPosition |= LabelPosition_Above; break;
- case Prs3d_DTVP_Below : theLabelPosition |= LabelPosition_Below; break;
- case Prs3d_DTVP_Center : theLabelPosition |= LabelPosition_VCenter; break;
- }
-}
-
-//=======================================================================
-//function : UnsetFixedTextPosition
-//purpose :
-//=======================================================================
-void AIS_Dimension::UnsetFixedTextPosition()
-{
- myIsTextPositionFixed = Standard_False;
- myFixedTextPosition = gp::Origin();
-}
+++ /dev/null
-// Created on: 2013-11-11
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2013-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_Dimension_HeaderFile
-#define _AIS_Dimension_HeaderFile
-
-#include <AIS_DimensionSelectionMode.hxx>
-#include <AIS_DimensionOwner.hxx>
-#include <AIS_DisplaySpecialSymbol.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_KindOfInteractive.hxx>
-#include <AIS_KindOfDimension.hxx>
-#include <AIS_KindOfSurface.hxx>
-#include <Geom_Curve.hxx>
-#include <gp_Pln.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_DimensionUnits.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <Standard.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TColgp_HSequenceOfPnt.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shape.hxx>
-#include <NCollection_Sequence.hxx>
-#include <NCollection_Handle.hxx>
-
-class AIS_Dimension;
-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:
-//! - Attachment (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 attachment points in "up" direction,
-//! and which contains text label on it with value string.
-//! - Flyouts. The lines connecting the attachment 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|
-//! | |
-//! +-----------------------------------+
-//! attachment attachment
-//! 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 highlighting 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.
-//!
-//! Such set of parameters that consists of:
-//! - flyout size and direction,
-//! - user-defined dimension plane,
-//! - horizontal and vertical text alignment
-//! can be uniquely replaced with text position in 3d space. Therefore, there are methods to convert
-//! this set of parameters to the text position and vice versa:
-//!
-//! - If the fixed text position is defined by user, called SetTextPosition (theTextPos) method converts
-//! this 3d point to the set of parameters including adjusting of the dimension plane (this plane will be
-//! automatic plane, NOT user-defined one).
-//! If the fixed text position is set, the flag myIsFixedTextPosition is set to TRUE.
-//! ATTENSION! myIsFixedTextPosition fixes all parameters of the set from recomputing inside
-//! SetMeasureGeometry() methods. Parameters in dimension aspect (they are horizontal text position
-//! and extension size) are adjusted on presentation computing step, user-defined values in
-//! dimension aspect are not changed.
-//! But plane and flyout as dimension position parameters are changed by SetTextPosition() method
-//! according with user-defined text position.
-//! If parameters from the set are changed by user with calls of setters, it leads to disabling of
-//! fixed text position (myIsFixedTextPosition is set to FALSE).
-//! If the fixed text position is set and geometry is changed by user (SetMeasureGeometry() method
-//! is called) and the geometry doesn't satisfy computed dimension plane, the dimension is not valid.
-//!
-//! - If the set of parameters was set by user (may be without the user-defined plane or with it),
-//! it can be converted to the text position by calling the method GetTextPosition(). In this case
-//! the text position is NOT fixed, and SetMeasureGeometry() without user-defined plane adjusts
-//! the automatic plane according input geometry (if it is possible).
-//!
-class AIS_Dimension : public AIS_InteractiveObject
-{
-protected:
-
- //! Geometry type defines type of shapes on which the dimension is to be built.
- //! Some type of geometry allows automatic 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,
-
- LabelPosition_Left = 0x01,
- LabelPosition_Right = 0x02,
- LabelPosition_HCenter = 0x04,
- 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
- };
-
- enum ValueType
- {
- ValueType_Computed,
- ValueType_CustomReal,
- ValueType_CustomText
- };
-
-public:
-
- //! Specifies supported presentation compute modes.
- //! Used to compute only parts of presentation for
- //! advanced highlighting.
- enum ComputeMode
- {
- ComputeMode_All = 0, //!< "0" is reserved as neutral mode
- ComputeMode_Line = 1, //!< corresponds to selection mode
- ComputeMode_Text = 2 //!< corresponds to selection mode
- };
-
-public:
-
- //! Constructor with default parameters values.
- //! @param theType [in] the type of dimension.
- Standard_EXPORT AIS_Dimension (const AIS_KindOfDimension theType);
-
- //! 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 myValueType == ValueType_CustomReal ? myCustomValue : ComputeValue();
- }
-
- //! Sets computed dimension value. Resets custom value mode if it was set.
- void SetComputedValue ()
- {
- myValueType = ValueType_Computed;
- }
-
- //! 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);
-
- //! Sets user-defined dimension value.
- //! Unit conversion during the display is not applyed.
- //! @param theValue [in] the user-defined value to display.
- Standard_EXPORT void SetCustomValue (const TCollection_ExtendedString& theValue);
-
- //! Gets user-defined dimension value.
- //! @return dimension value string.
- Standard_EXPORT const TCollection_ExtendedString& GetCustomValue () 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 invalid (validity flag is set to false)
- //! and dimension presentation will 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;
-
- //! 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_Integer GetGeometryType () const { return myGeometryType; }
-
- //! 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);
-
- //! Unsets user-defined plane. Therefore the plane for dimension will be
- //! computed automatically.
- void UnsetCustomPlane() { myIsPlaneCustom = Standard_False; }
-
- //! @return TRUE if text position is set by user with method SetTextPosition().
- Standard_Boolean IsTextPositionCustom() const
- {
- return myIsTextPositionFixed;
- }
-
- //! Fixes the absolute text position and adjusts flyout, plane and text alignment
- //! according to it. Updates presentation if the text position is valid.
- //! ATTENTION! It does not change vertical text alignment.
- //! @param theTextPos [in] the point of text position.
- virtual void SetTextPosition (const gp_Pnt& /*theTextPos*/) { }
-
- //! Computes absolute text position from dimension parameters
- //! (flyout, plane and text alignment).
- virtual const gp_Pnt GetTextPosition () const { return gp_Pnt(); }
-
-public:
-
- //! Gets the dimension aspect from AIS object drawer.
- //! Dimension aspect contains aspects of line, text and arrows for dimension presentation.
- Handle(Prs3d_DimensionAspect) DimensionAspect() const
- {
- return myDrawer->DimensionAspect();
- }
-
- //! 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);
-
- //! @return the kind of dimension.
- AIS_KindOfDimension KindOfDimension() const
- {
- return myKindOfDimension;
- }
-
- //! @return the kind of interactive.
- virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
- {
- return AIS_KOI_Dimension;
- }
-
- //! 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.
- virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
- {
- return theMode == ComputeMode_All;
- }
-
-public:
-
- //! @return dimension special symbol display options.
- AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const
- {
- return myDisplaySpecialSymbol;
- }
-
- //! Specifies whether to display special symbol or not.
- Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol);
-
- //! @return special symbol.
- Standard_ExtCharacter SpecialSymbol() const
- {
- return mySpecialSymbol;
- }
-
- //! Specifies special symbol.
- Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
-
- Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const;
-
- Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const;
-
- virtual void SetDisplayUnits (const TCollection_AsciiString& /*theUnits*/) { }
-
- virtual void SetModelUnits (const TCollection_AsciiString& /*theUnits*/) { }
-
- //! Unsets user defined text positioning and enables text positioning
- //! by other parameters: text alignment, extension size, flyout and custom plane.
- Standard_EXPORT void UnsetFixedTextPosition();
-
-public:
-
- //! 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);
-
- //! @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 successfully computed.
- //! @return TRUE if dimension geometry is ok.
- virtual Standard_Boolean IsValid() const
- {
- return myIsGeometryValid && CheckPlane (GetPlane());
- }
-
-public:
-
- DEFINE_STANDARD_RTTIEXT(AIS_Dimension,AIS_InteractiveObject)
-
-protected:
-
- Standard_EXPORT Standard_Real ValueToDisplayUnits() const;
-
- //! 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
- //! @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,
- const gp_Pnt& theTextPos,
- const gp_Dir& theTextDir,
- const TCollection_ExtendedString& theText,
- const Standard_Integer theLabelPosition);
-
- //! Performs computing of dimension linear extension with text
- //! @param thePresentation [in] the presentation to fill with graphical primitives.
- //! @param theExtensionSize [in] the size of extension line.
- //! @param theExtensionStart [in] the point where extension line connects to dimension.
- //! @param theExtensionDir [in] the direction of extension line.
- //! @param theLabelString [in] the string with value.
- //! @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,
- const Standard_Real theExtensionSize,
- const gp_Pnt& theExtensionStart,
- const gp_Dir& theExtensionDir,
- const TCollection_ExtendedString& theLabelString,
- const Standard_Real theLabelWidth,
- const Standard_Integer theMode,
- const Standard_Integer theLabelPosition);
-
- //! 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 gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const Standard_Boolean theIsOneSide = Standard_False);
-
- //! Computes points bounded the flyout line for linear dimension.
- //! @param theFirstPoint [in] the first attach point of linear dimension.
- //! @param theSecondPoint [in] the second attach point of linear dimension.
- //! @param theLineBegPoint [out] the first attach point of linear dimension.
- //! @param theLineEndPoint [out] the second attach point of linear dimension.
- Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
- gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint);
-
- //! 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);
-
-
- //! 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);
-
- //! Produce points for triangular arrow face.
- //! @param thePeakPnt [in] the arrow peak position.
- //! @param theDirection [in] the arrow direction.
- //! @param thePlane [in] the face plane.
- //! @param theArrowLength [in] the length of arrow.
- //! @param theArrowAngle [in] the angle of arrow.
- //! @param theSidePnt1 [out] the first side point.
- //! @param theSidePnt2 [out] the second side point.
- Standard_EXPORT void PointsForArrow (const gp_Pnt& thePeakPnt,
- const gp_Dir& theDirection,
- const gp_Dir& thePlane,
- const Standard_Real theArrowLength,
- const Standard_Real theArrowAngle,
- gp_Pnt& theSidePnt1,
- gp_Pnt& theSidePnt2);
-
- //! Compute point of text position for dimension parameters
- //! for linear kinds of dimensions (length, radius, diameter).
- Standard_EXPORT gp_Pnt GetTextPositionForLinear (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const Standard_Boolean theIsOneSide = Standard_False) const;
-
- //! Fits text alignment relatively to the dimension line.
- //! @param theFirstPoint [in] the first attachment point.
- //! @param theSecondPoint [in] the second attachment point.
- //! @param theIsOneSide [in] is the arrow displayed only on the one side of the dimension.
- //! @param theHorizontalTextPos [in] the text horizontal position (alignment).
- //! @param theLabelPosition [out] the label position, contains bits that defines
- //! vertical and horizontal alignment. (for internal usage in count text position)
- //! @param theIsArrowExternal [out] is the arrows external,
- //! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow
- //! orientation automatically.
- Standard_EXPORT void 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.
- //! @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.
- //! @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 Static auxilliary methods for geometry extraction
-
- //! 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
- static Standard_Boolean CircleFromPlanarFace (const TopoDS_Face& theFace,
- Handle(Geom_Curve)& theCurve,
- gp_Pnt& theFirstPoint,
- gp_Pnt& theLastPoint);
-
- //! If it is possible extracts circle from the edge.
- //! @param theEdge [in] input edge to extract circle from
- //! @param theCircle [out] circle
- //! @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.
- static Standard_Boolean CircleFromEdge (const TopoDS_Edge& theEdge,
- gp_Circ& theCircle,
- gp_Pnt& theFirstPoint,
- gp_Pnt& theLastPoint);
-
-protected: //! @name Behavior to implement
-
- //! 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)&) {}
-
-
- //! 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) Standard_OVERRIDE;
-
-protected: //! @name Selection geometry
-
- //! Selection geometry of dimension presentation. The structure is filled with data
- //! during compute of presentation, then this data is used to generate selection
- //! sensitives when computing selection.
- struct SelectionGeometry
- {
- //! Arrows are represented by directed triangles.
- struct Arrow
- {
- gp_Pnt Position;
- gp_Dir Direction;
- };
- typedef NCollection_Sequence<gp_Pnt> Curve;
- typedef NCollection_Handle<Curve> HCurve;
- typedef NCollection_Handle<Arrow> HArrow;
- typedef NCollection_Sequence<HCurve> SeqOfCurves;
- typedef NCollection_Sequence<HArrow> SeqOfArrows;
-
- gp_Pnt TextPos; //!< Center of text label.
- gp_Dir TextDir; //!< Direction of text label.
- Standard_Real TextWidth; //!< Width of text label.
- 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:
-
- //! Clear geometry of sensitives for the specified compute mode.
- //! @param theMode [in] the compute mode to clear.
- void Clear (const Standard_Integer theMode)
- {
- if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
- {
- DimensionLine.Clear();
- Arrows.Clear();
- }
-
- if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
- {
- TextPos = gp::Origin();
- TextDir = gp::DX();
- TextWidth = 0.0;
- TextHeight = 0.0;
- }
-
- IsComputed = Standard_False;
- }
-
- //! Add new curve entry and return the reference to populate it.
- Curve& NewCurve()
- {
- DimensionLine.Append( new Curve );
- HCurve& aLastCurve = DimensionLine.ChangeLast();
- return *aLastCurve;
- }
-
- //! Add new arrow entry and return the reference to populate it.
- Arrow& NewArrow()
- {
- Arrows.Append( new Arrow );
- HArrow& aLastArrow = Arrows.ChangeLast();
- return *aLastArrow;
- }
- } mySelectionGeom;
-
- Standard_Real mySelToleranceForText2d; //!< Sensitive point tolerance for 2d text selection.
-
-protected: //! @name Value properties
-
- ValueType myValueType; //! type of value (computed or user-defined)
- Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
-
- TCollection_ExtendedString myCustomStringValue; //!< Value of the dimension (computed or user-defined).
-
-protected: //! @name Fixed text position properties
-
- gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user.
- Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user.
-
-protected: //! @name Units properties
-
- Standard_ExtCharacter mySpecialSymbol; //!< Special symbol.
- AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options.
-
-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 myIsGeometryValid; //!< Is dimension geometry properly defined.
-
-private:
-
- AIS_KindOfDimension myKindOfDimension;
-};
-
-#endif // _AIS_Dimension_HeaderFile
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AIS_DimensionOwner.hxx>
-
-#include <AIS_Dimension.hxx>
-#include <PrsMgr_PresentationManager.hxx>
-#include <SelectMgr_SelectableObject.hxx>
-#include <Standard_Type.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_DimensionOwner,SelectMgr_EntityOwner)
-
-namespace
-{
- //=======================================================================
- //function : HighlightMode
- //purpose : Return corresponding compute mode for selection type.
- //=======================================================================
- static AIS_Dimension::ComputeMode HighlightMode (const Standard_Integer theSelMode)
- {
- switch (theSelMode)
- {
- case AIS_DSM_Line : return AIS_Dimension::ComputeMode_Line;
- case AIS_DSM_Text : return AIS_Dimension::ComputeMode_Text;
- default:
- return AIS_Dimension::ComputeMode_All;
- }
- }
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_DimensionOwner::AIS_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
- const AIS_DimensionSelectionMode theMode,
- const Standard_Integer thePriority)
-: SelectMgr_EntityOwner(theSelObject, thePriority),
- mySelectionMode (theMode)
-{
-}
-
-//=======================================================================
-//function : AIS_DimensionSelectionMode
-//purpose :
-//=======================================================================
-AIS_DimensionSelectionMode AIS_DimensionOwner::SelectionMode () const
-{
- return mySelectionMode;
-}
-
-//=======================================================================
-//function : IsHilighted
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
- const Standard_Integer /*theMode*/) const
-{
- if (!HasSelectable())
- {
- return Standard_False;
- }
-
- return thePM->IsHighlighted (Selectable(), HighlightMode (mySelectionMode));
-}
-
-//=======================================================================
-//function : Unhilight
-//purpose :
-//=======================================================================
-void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
- const Standard_Integer /*theMode*/)
-{
- if (!HasSelectable())
- {
- return;
- }
-
- thePM->Unhighlight (Selectable());
-}
-
-//=======================================================================
-//function : HilightWithColor
-//purpose :
-//=======================================================================
-void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
- const Handle(Prs3d_Drawer)& theStyle,
- const Standard_Integer /*theMode*/)
-{
- thePM->Color (Selectable(), theStyle, HighlightMode (mySelectionMode));
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_DimensionOwner_HeaderFile
-#define _AIS_DimensionOwner_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <AIS_DimensionSelectionMode.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <Standard_Integer.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
-#include <Quantity_NameOfColor.hxx>
-#include <Standard_Boolean.hxx>
-
-class SelectMgr_SelectableObject;
-class PrsMgr_PresentationManager;
-
-DEFINE_STANDARD_HANDLE(AIS_DimensionOwner, SelectMgr_EntityOwner)
-
-//! The owner is the entity which makes it possible to link
-//! the sensitive primitives and the reference shapes that
-//! you want to detect. It stocks the various pieces of
-//! information which make it possible to find objects. An
-//! owner has a priority which you can modulate, so as to
-//! make one entity more selectable than another. You
-//! might want to make edges more selectable than
-//! faces, for example. In that case, you could attribute sa
-//! higher priority to the one compared to the other. An
-//! edge, could have priority 5, for example, and a face,
-//! priority 4. The default priority is 5.
-class AIS_DimensionOwner : public SelectMgr_EntityOwner
-{
- DEFINE_STANDARD_RTTIEXT(AIS_DimensionOwner, SelectMgr_EntityOwner)
-public:
-
- //! Initializes the dimension owner, theSO, and attributes it
- //! the priority, thePriority.
- Standard_EXPORT AIS_DimensionOwner(const Handle(SelectMgr_SelectableObject)& theSelObject, const AIS_DimensionSelectionMode theSelMode, const Standard_Integer thePriority = 0);
-
- Standard_EXPORT AIS_DimensionSelectionMode SelectionMode() const;
-
- Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
- const Handle(Prs3d_Drawer)& theStyle,
- const Standard_Integer theMode = 0) Standard_OVERRIDE;
-
- //! Returns true if an object with the selection mode
- //! aMode is highlighted in the presentation manager aPM.
- Standard_EXPORT virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode = 0) const Standard_OVERRIDE;
-
- //! Removes highlighting from the selected part of dimension.
- Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode = 0) Standard_OVERRIDE;
-
-private:
-
- AIS_DimensionSelectionMode mySelectionMode;
-
-};
-
-#endif // _AIS_DimensionOwner_HeaderFile
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_DimensionSelectionMode_HeaderFile
-#define _AIS_DimensionSelectionMode_HeaderFile
-
-//! Specifies dimension selection modes.
-enum AIS_DimensionSelectionMode
-{
-AIS_DSM_All,
-AIS_DSM_Line,
-AIS_DSM_Text
-};
-
-#endif // _AIS_DimensionSelectionMode_HeaderFile
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_DisplaySpecialSymbol_HeaderFile
-#define _AIS_DisplaySpecialSymbol_HeaderFile
-
-//! Specifies dimension special symbol display options
-enum AIS_DisplaySpecialSymbol
-{
-AIS_DSS_No,
-AIS_DSS_Before,
-AIS_DSS_After
-};
-
-#endif // _AIS_DisplaySpecialSymbol_HeaderFile
+++ /dev/null
-// Created on: 1998-01-22
-// Created by: Sergey ZARITCHNY
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_EllipseRadiusDimension.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_OffsetCurve.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
-#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <GeomAPI.hxx>
-#include <GeomAPI_ExtremaCurveCurve.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Elips.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <Precision.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_EllipseRadiusDimension,AIS_Relation)
-
-//=======================================================================
-//function : AIS_EllipseRadiusDimension
-//purpose :
-//=======================================================================
-AIS_EllipseRadiusDimension::AIS_EllipseRadiusDimension(const TopoDS_Shape& aShape,
- const TCollection_ExtendedString& aText)
-:AIS_Relation()
-{
- myFShape = aShape;
- myText = aText;
-// ComputeGeometry( );
-}
-
-//=======================================================================
-//function : ComputeGeometry
-//purpose :
-//=======================================================================
-
-void AIS_EllipseRadiusDimension::ComputeGeometry()
-{
-
- switch (myFShape.ShapeType()) {
- case TopAbs_FACE :
- {
- // compute one face case
- ComputeFaceGeometry ();
- break;
- }
- case TopAbs_EDGE:
- {
- ComputeEdgeGeometry ();
- break;
- }
- default:
- break;
- }
- while (myFirstPar > 2*M_PI) myFirstPar -= 2*M_PI;
- while (myLastPar > 2*M_PI) myLastPar -= 2*M_PI;
- while (myFirstPar < 0.0) myFirstPar += 2*M_PI;
- while (myLastPar < 0.0) myLastPar += 2*M_PI;
-}
-
-//=======================================================================
-//function : ComputeFaceGeometry
-//purpose :
-//=======================================================================
-
-void AIS_EllipseRadiusDimension::ComputeFaceGeometry()
-{
-
- gp_Pln aPln;
- Handle( Geom_Surface ) aBasisSurf;
- AIS_KindOfSurface aSurfType;
- Standard_Real Offset;
- AIS::GetPlaneFromFace( TopoDS::Face( myFShape),
- aPln,
- aBasisSurf,
- aSurfType,
- Offset ) ;
-
- if ( aSurfType == AIS_KOS_Plane )
- ComputePlanarFaceGeometry( );
- else
- ComputeCylFaceGeometry( aSurfType, aBasisSurf, Offset );
-
-}
-
-//=======================================================================
-//function : ComputeCylFaceGeometry
-//purpose : defines Ellipse and plane of dimension
-//=======================================================================
-
-void AIS_EllipseRadiusDimension::ComputeCylFaceGeometry(const AIS_KindOfSurface aSurfType,
- const Handle( Geom_Surface )& aBasisSurf,
- const Standard_Real Offset)
-{
-
- BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
- Standard_Real vFirst, vLast;
- vFirst = surf1.FirstVParameter();
- vLast = surf1.LastVParameter();
- Standard_Real vMid = (vFirst + vLast)*0.5;
- gp_Pln aPlane;
- gp_Ax1 Axis;
-// Standard_Real Param;
- if (aSurfType == AIS_KOS_Extrusion)
- {
- Axis.SetDirection((Handle( Geom_SurfaceOfLinearExtrusion )::DownCast( aBasisSurf ))
- ->Direction() );
- Axis.SetLocation( gp_Pnt((Handle( Geom_SurfaceOfLinearExtrusion )::DownCast( aBasisSurf ))
- ->Direction().XYZ() ) );
-
- aPlane.SetAxis(Axis);
- aPlane.SetLocation(myEllipse.Location());
- myPlane = new Geom_Plane(aPlane);
-
- Handle(Geom_Curve) aCurve;
- aCurve = aBasisSurf->VIso(vMid);
- if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
- {
- myEllipse = Handle(Geom_Ellipse)::DownCast(aCurve)-> Elips();//gp_Elips
- myIsAnArc = Standard_False;
- }
- else if (aCurve->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) {
- Handle(Geom_TrimmedCurve) tCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve);
- aCurve = tCurve->BasisCurve();
- myFirstPar = tCurve->FirstParameter();
- myLastPar = tCurve->LastParameter();
- myIsAnArc = Standard_True;
- if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
- {
- myEllipse = Handle(Geom_Ellipse)::DownCast(aCurve)->Elips();//gp_Elips
- }
- }
- else
- {
- throw Standard_ConstructionError("AIS:: Not expected type of surface") ;
- return;
- }
-
-// Offset
-
- if(surf1.GetType() == GeomAbs_OffsetSurface)
- {
- if(Offset <0.0 && Abs(Offset) > myEllipse.MinorRadius ())
- {
- throw Standard_ConstructionError("AIS:: Absolute value of negative offset is larger than MinorRadius");
- return;
- }
-
- myOffsetCurve = new Geom_OffsetCurve(new Geom_Ellipse(myEllipse), Offset,
- myPlane->Pln().Axis().Direction());
- myOffset = Offset;
- myIsOffset = Standard_True;
- gp_Elips elips = myEllipse;
- Standard_Real Val = Offset + elips.MajorRadius ();//simulation
- myEllipse.SetMajorRadius (Val);
- Val = Offset + elips.MinorRadius ();
- myEllipse.SetMinorRadius (Val);
- }
- else
- myIsOffset = Standard_False;
- }
-}
-
-
-//=======================================================================
-//function : ComputePlanarFaceGeometry
-//purpose :
-//=======================================================================
-
-void AIS_EllipseRadiusDimension::ComputePlanarFaceGeometry()
-{
-
- Standard_Boolean find = Standard_False;
- gp_Pnt ptfirst,ptend;
- TopExp_Explorer ExploEd( TopoDS::Face(myFShape), TopAbs_EDGE );
- for ( ; ExploEd.More(); ExploEd.Next())
- {
- TopoDS_Edge curedge = TopoDS::Edge( ExploEd.Current() );
- Handle(Geom_Curve) curv;
- Handle(Geom_Ellipse) ellips;
- if (AIS::ComputeGeometry(curedge,curv,ptfirst,ptend))
- {
- if (curv->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
- {
- ellips = Handle(Geom_Ellipse)::DownCast(curv);
- if ( !ellips.IsNull() ) {
- myEllipse = ellips->Elips();
- find = Standard_True;
- break;
- }
- }
- }
- }
- if( !find )
- {
- throw Standard_ConstructionError("AIS:: Curve is not an ellipsee or is Null") ;
- return;
- }
-
- if ( !ptfirst.IsEqual(ptend, Precision::Confusion()) )
- {
- myIsAnArc = Standard_True;
- myFirstPar = ElCLib::Parameter(myEllipse, ptfirst);
- myLastPar = ElCLib::Parameter(myEllipse, ptend);
- }
- else
- myIsAnArc = Standard_False;
-
- BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
- myPlane = new Geom_Plane( surfAlgo.Plane() );
-
-}
-
-
-
-//=======================================================================
-//function : ComputeEdgeGeometry
-//purpose :
-//=======================================================================
-
-void AIS_EllipseRadiusDimension::ComputeEdgeGeometry()
-{
- gp_Pnt ptfirst,ptend;
- Handle(Geom_Curve) curv;
- if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),curv,ptfirst,ptend)) return;
-
- Handle(Geom_Ellipse) elips = Handle(Geom_Ellipse)::DownCast(curv);
- if ( elips.IsNull()) return;
-
- myEllipse = elips->Elips();
- gp_Pln aPlane;
- aPlane.SetPosition(gp_Ax3(myEllipse.Position()));
- myPlane = new Geom_Plane(aPlane);
-
-
- if ( ptfirst.IsEqual(ptend, Precision::Confusion()) ) {
- myIsAnArc = Standard_False;
- }
- else {
- myIsAnArc = Standard_True;
- myFirstPar = ElCLib::Parameter(myEllipse, ptfirst);
- myLastPar = ElCLib::Parameter(myEllipse, ptend);
- }
-}
-//=======================================================================
-//function : KindOfDimension
-//purpose :
-//=======================================================================
- AIS_KindOfDimension AIS_EllipseRadiusDimension::KindOfDimension() const
-{
- return AIS_KOD_ELLIPSERADIUS;
-}
-
-//=======================================================================
-//function : IsMovable
-//purpose :
-//=======================================================================
- Standard_Boolean AIS_EllipseRadiusDimension::IsMovable() const
-{
- return Standard_True;
-}
+++ /dev/null
-// Created on: 1998-01-22
-// Created by: Sergey ZARITCHNY
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_EllipseRadiusDimension_HeaderFile
-#define _AIS_EllipseRadiusDimension_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <gp_Elips.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Boolean.hxx>
-#include <AIS_Relation.hxx>
-#include <AIS_KindOfDimension.hxx>
-#include <AIS_KindOfSurface.hxx>
-class Geom_OffsetCurve;
-class TopoDS_Shape;
-class TCollection_ExtendedString;
-class Geom_Surface;
-
-
-class AIS_EllipseRadiusDimension;
-DEFINE_STANDARD_HANDLE(AIS_EllipseRadiusDimension, AIS_Relation)
-
-
-//! Computes geometry ( basis curve and plane of dimension)
-//! for input shape aShape from TopoDS
-//! Root class for MinRadiusDimension and MaxRadiusDimension
-class AIS_EllipseRadiusDimension : public AIS_Relation
-{
-
-public:
-
-
- Standard_EXPORT virtual AIS_KindOfDimension KindOfDimension() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeGeometry();
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(AIS_EllipseRadiusDimension,AIS_Relation)
-
-protected:
-
-
- Standard_EXPORT AIS_EllipseRadiusDimension(const TopoDS_Shape& aShape, const TCollection_ExtendedString& aText);
-
- gp_Elips myEllipse;
- Standard_Real myFirstPar;
- Standard_Real myLastPar;
- Standard_Boolean myIsAnArc;
- Handle(Geom_OffsetCurve) myOffsetCurve;
- Standard_Real myOffset;
- Standard_Boolean myIsOffset;
-
-
-private:
-
-
- Standard_EXPORT void ComputeFaceGeometry();
-
- Standard_EXPORT void ComputeCylFaceGeometry (const AIS_KindOfSurface aSurfType, const Handle(Geom_Surface)& aSurf, const Standard_Real Offset);
-
- Standard_EXPORT void ComputePlanarFaceGeometry();
-
- Standard_EXPORT void ComputeEdgeGeometry();
-
-
-
-};
-
-
-
-
-
-
-
-#endif // _AIS_EllipseRadiusDimension_HeaderFile
+++ /dev/null
-// Created on: 1998-01-24
-// Created by: Julia GERASIMOVA
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS_EqualDistanceRelation.hxx>
-#include <AIS_LengthDimension.hxx>
-#include <Bnd_Box.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <DsgPrs_EqualDistancePresentation.hxx>
-#include <ElCLib.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <GeomAPI_ProjectPointOnCurve.hxx>
-#include <GeomAPI_ProjectPointOnSurf.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pnt.hxx>
-#include <Precision.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveCircle.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_EqualDistanceRelation,AIS_Relation)
-
-//=======================================================================
-//function : AIS_EqualDistanceRelation
-//purpose :
-//=======================================================================
-AIS_EqualDistanceRelation::AIS_EqualDistanceRelation( const TopoDS_Shape& aShape1,
- const TopoDS_Shape& aShape2,
- const TopoDS_Shape& aShape3,
- const TopoDS_Shape& aShape4,
- const Handle( Geom_Plane )& aPlane )
- :AIS_Relation()
-{
- myFShape = aShape1;
- mySShape = aShape2;
- myShape3 = aShape3;
- myShape4 = aShape4;
- myPlane = aPlane;
-
- //Temporary
- myArrowSize = 3.0; //set the concrete value
- mySymbolPrs = DsgPrs_AS_BOTHAR;
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-
-void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager3d )&,
- const Handle( Prs3d_Presentation )& aPresentation,
- const Standard_Integer )
-{
- gp_Pnt Position12 = myPosition, Position34 = myPosition;
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
-// -- ota -- begin
- if (!myAutomaticPosition ){
- gp_Pnt aMiddle12 ((myPoint1.XYZ() + myPoint2.XYZ())*0.5);
- gp_Pnt aMiddle34 ((myPoint3.XYZ() + myPoint4.XYZ())*0.5);
-
- if (myPosition.Distance(aMiddle12) > myPosition.Distance(aMiddle34))
- Position12.SetXYZ((myPoint1.XYZ() + myPoint2.XYZ())*0.5);
- else
- Position34.SetXYZ((myPoint3.XYZ() + myPoint4.XYZ())*0.5);
-
- }
-
- if (myFShape.ShapeType() == TopAbs_EDGE && mySShape.ShapeType() == TopAbs_EDGE)
- AIS_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
- myDrawer,
- myArrowSize,
- TopoDS::Edge(myFShape),
- TopoDS::Edge(mySShape),
- myPlane,
- myAutomaticPosition,
- myIsSetBndBox,
- myBndBox,
- Position12,
- myAttachPoint1,
- myAttachPoint2,
- myPoint1,
- myPoint2,
- mySymbolPrs );
-
-
- else if (myFShape.ShapeType() == TopAbs_VERTEX && mySShape.ShapeType() == TopAbs_VERTEX)
- AIS_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
- myDrawer,
- myArrowSize,
- TopoDS::Vertex(myFShape),
- TopoDS::Vertex(mySShape),
- myPlane,
- myAutomaticPosition,
- myIsSetBndBox,
- myBndBox,
- AIS_TOD_Unknown,
- Position12,
- myAttachPoint1,
- myAttachPoint2,
- myPoint1,
- myPoint2,
- mySymbolPrs );
- else
- AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
- myDrawer,
- myArrowSize,
- myFShape,
- mySShape,
- myPlane,
- myAutomaticPosition,
- myIsSetBndBox,
- myBndBox,
- Position12,
- myAttachPoint1,
- myAttachPoint2,
- myPoint1,
- myPoint2,
- mySymbolPrs );
-
- if (myShape3.ShapeType() == TopAbs_EDGE && myShape4.ShapeType() == TopAbs_EDGE)
- AIS_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
- myDrawer,
- myArrowSize,
- TopoDS::Edge(myShape3),
- TopoDS::Edge(myShape4),
- myPlane,
- myAutomaticPosition,
- myIsSetBndBox,
- myBndBox,
- Position34,
- myAttachPoint3,
- myAttachPoint4,
- myPoint3,
- myPoint4,
- mySymbolPrs );
-
- else if (myShape3.ShapeType() == TopAbs_VERTEX && myShape4.ShapeType() == TopAbs_VERTEX)
- AIS_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
- myDrawer,
- myArrowSize,
- TopoDS::Vertex(myShape3),
- TopoDS::Vertex(myShape4),
- myPlane,
- myAutomaticPosition,
- myIsSetBndBox,
- myBndBox,
- AIS_TOD_Unknown,
- Position34,
- myAttachPoint3,
- myAttachPoint4,
- myPoint3,
- myPoint4,
- mySymbolPrs );
-
- else
- AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
- myDrawer,
- myArrowSize,
- myShape3,
- myShape4,
- myPlane,
- myAutomaticPosition,
- myIsSetBndBox,
- myBndBox,
- Position34,
- myAttachPoint3,
- myAttachPoint4,
- myPoint3,
- myPoint4,
- mySymbolPrs );
-
- DsgPrs_EqualDistancePresentation::Add( aPresentation, myDrawer,
- myPoint1, myPoint2, myPoint3, myPoint4, myPlane );
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-
-void AIS_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
- const Standard_Integer )
-{
- Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 );
- Handle( Select3D_SensitiveSegment ) seg;
-
- seg = new Select3D_SensitiveSegment( own, myPoint1, myPoint2 );
- aSelection->Add( seg );
-
- seg = new Select3D_SensitiveSegment( own, myPoint3, myPoint4 );
- aSelection->Add( seg );
-
- // Line between two middles
- gp_Pnt Middle12( (myPoint1.XYZ() + myPoint2.XYZ()) * 0.5 ),
- Middle34( (myPoint3.XYZ() + myPoint4.XYZ()) *0.5 );
- seg = new Select3D_SensitiveSegment( own, Middle12, Middle34 );
- aSelection->Add( seg );
-
- gp_Pnt Middle((Middle12.XYZ() + Middle34.XYZ())*0.5);
- Standard_Real SmallDist = .001;
- Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
- Middle.X() - SmallDist,
- Middle.Y() - SmallDist,
- Middle.Z() - SmallDist,
- Middle.X() + SmallDist,
- Middle.Y() + SmallDist,
- Middle.Z() + SmallDist );
- aSelection->Add(box);
-
- if (myFShape.ShapeType() == TopAbs_EDGE){
- BRepAdaptor_Curve aCurve(TopoDS::Edge(myFShape));
- if (aCurve.GetType() == GeomAbs_Line){
- //add sensetive element - line
- seg = new Select3D_SensitiveSegment( own, myAttachPoint1, myPoint1);
- aSelection->Add( seg );
- }
- else if (aCurve.GetType() == GeomAbs_Circle){
- Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
- Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint1),
- LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint1);
- if (LastPar < FirstPar ) LastPar+=M_PI*2;
- //add sensetive arc
- Handle(Select3D_SensitiveCircle) circ =
- new Select3D_SensitiveCircle( own, aCircle, FirstPar, LastPar);
- aSelection->Add( circ );
- }
- }
- else {
- seg = new Select3D_SensitiveSegment( own, myAttachPoint1, myPoint1);
- aSelection->Add( seg );
- }
-
- if (mySShape.ShapeType() == TopAbs_EDGE){
- BRepAdaptor_Curve aCurve(TopoDS::Edge(mySShape));
- if (aCurve.GetType() == GeomAbs_Line) {
- //add sensetive element - line
- seg = new Select3D_SensitiveSegment( own, myAttachPoint2, myPoint2);
- aSelection->Add( seg );
- }
- else if (aCurve.GetType() == GeomAbs_Circle){
- Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
- Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint2),
- LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint2);
- if (LastPar < FirstPar ) LastPar+=M_PI*2;
- //add sensetive arc
- Handle(Select3D_SensitiveCircle) circ =
- new Select3D_SensitiveCircle( own,aCircle, FirstPar, LastPar);
- aSelection->Add( circ );
- }
- }
- else {
- seg = new Select3D_SensitiveSegment( own, myAttachPoint2, myPoint2);
- aSelection->Add( seg );
- }
-
- if (myShape3.ShapeType() == TopAbs_EDGE){
- BRepAdaptor_Curve aCurve(TopoDS::Edge(myShape3));
- if (aCurve.GetType() == GeomAbs_Line) {
- //add sensetive element - line
- seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
- aSelection->Add( seg );
- }
- else if (aCurve.GetType() == GeomAbs_Circle){
- Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
- Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint3),
- LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint3);
- if (LastPar < FirstPar ) LastPar+=M_PI*2;
- Handle(Select3D_SensitiveCircle) circ =
- new Select3D_SensitiveCircle( own, aCircle, FirstPar, LastPar);
- aSelection->Add( circ );
- }
- else {
- seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
- aSelection->Add( seg );
- }
- }
- else {
- seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
- aSelection->Add( seg );
- }
-
- if (myShape4.ShapeType() == TopAbs_EDGE){
- BRepAdaptor_Curve aCurve(TopoDS::Edge(myShape4));
- if (aCurve.GetType() == GeomAbs_Line) {
- //add sensetive element - line
- seg = new Select3D_SensitiveSegment( own, myAttachPoint4, myPoint4);
- aSelection->Add( seg );
- }
- else if (aCurve.GetType() == GeomAbs_Circle){
- Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
- Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint4),
- LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint4);
- if (LastPar < FirstPar ) LastPar+=M_PI*2;
- //add sensetive arc
- Handle(Select3D_SensitiveCircle) circ =
- new Select3D_SensitiveCircle( own,aCircle, FirstPar, LastPar);
- aSelection->Add( circ );
- }
- }
- else {
- seg = new Select3D_SensitiveSegment( own, myAttachPoint4, myPoint4);
- aSelection->Add( seg );
- }
-}
-
-//=======================================================================
-//function : ComputeTwoEdgesLength
-//purpose :
-//=======================================================================
-void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Presentation )& aPresentation,
- const Handle( Prs3d_Drawer )& aDrawer,
- const Standard_Real ArrowSize,
- const TopoDS_Edge & FirstEdge,
- const TopoDS_Edge & SecondEdge,
- const Handle( Geom_Plane )& Plane,
- const Standard_Boolean AutomaticPos,
- const Standard_Boolean IsSetBndBox,
- const Bnd_Box & BndBox,
- gp_Pnt& Position,
- gp_Pnt& FirstAttach,
- gp_Pnt& SecondAttach,
- gp_Pnt& FirstExtreme,
- gp_Pnt& SecondExtreme,
- DsgPrs_ArrowSide & SymbolPrs )
-{
- gp_Dir DirAttach;
- BRepAdaptor_Curve cu1( FirstEdge );
- BRepAdaptor_Curve cu2( SecondEdge );
-
- // 3d lines
- Handle(Geom_Curve) geom1,geom2;
- gp_Pnt ptat11,ptat12,ptat21,ptat22;
-
- Standard_Boolean isInfinite1(Standard_False),isInfinite2(Standard_False);
- Handle(Geom_Curve) extCurv;
- Standard_Real arrsize = ArrowSize;// size
- Standard_Real Val=0.;
- Standard_Boolean isInPlane1, isInPlane2;
-
- if(!AIS::ComputeGeometry(FirstEdge,geom1, ptat11, ptat12,extCurv,isInfinite1,isInPlane1, Plane ))
- return;
- if(!AIS::ComputeGeometry(SecondEdge, geom2, ptat21, ptat22, extCurv, isInfinite2,isInPlane2, Plane))
- return;
-
- aPresentation->SetInfiniteState(isInfinite1 || isInfinite2);
-
- if (cu1.GetType() == GeomAbs_Line && cu2.GetType() == GeomAbs_Line)
- {
- Handle(Geom_Line) geom_lin1 (Handle(Geom_Line)::DownCast (geom1));
- Handle(Geom_Line) geom_lin2 (Handle(Geom_Line)::DownCast (geom2));
- const gp_Lin& l1 = geom_lin1->Lin();
- const gp_Lin& l2 = geom_lin2->Lin();
-
- //Get Val value
- Val = l1.Distance( l2 );
-
- DirAttach = l1.Direction();
-
- if (AutomaticPos) {
- // compute position of offset point
- gp_Pnt curpos;
- Standard_Real par1=0., par2=0.;
- if(!(isInfinite1 || isInfinite2))
- {
- par1 = ElCLib::Parameter(l1,ptat11);
- par2 = ElCLib::Parameter(l1,ptat21);
- if (par1 <par2){//project ptat11 on l2
- gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2);
- curpos.SetXYZ((ptat11.XYZ()+p2.XYZ())*0.5);
- }
- else {//project ptat21 on l1
- gp_Pnt p2 = ElCLib::Value(par2, l1);
- curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())*0.5);
- }
- }
- else if (!isInfinite1){
- par2 = ElCLib::Parameter(l1,ptat21);
- gp_Pnt p2 = ElCLib::Value(par2,l1);
- curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())/2.);
- }
- else if (!isInfinite2) {
- gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2);
- curpos.SetXYZ((ptat11.XYZ()+p2.XYZ())*0.5);
- }
- else
- curpos.SetXYZ((l1.Location().XYZ()+l2.Location().XYZ())*0.5);
-
- // compute offset
- gp_Vec offset(DirAttach);
- offset = offset*ArrowSize*(-10.);
- curpos.Translate(offset);
- Position = curpos;
- }
- else { // project point on the plane
- Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
- }
-
- // find attach points
- if (!isInfinite1) {
- if (Position.Distance(ptat11) > Position.Distance(ptat12)) FirstAttach = ptat12;
- else FirstAttach = ptat11;
- }
- else {
- FirstAttach = ElCLib::Value(ElCLib::Parameter(l1,Position),l1);
- }
-
- if (!isInfinite2) {
- if (Position.Distance(ptat21) > Position.Distance(ptat22)) SecondAttach = ptat22;
- else SecondAttach = ptat21;
- }
- else {
- SecondAttach = ElCLib::Value(ElCLib::Parameter(l2,Position),l2);
- }
-
- Standard_Real confusion(Precision::Confusion());
- if (arrsize < confusion) arrsize = Val*0.1;
- if (Abs(Val) <= confusion) {arrsize = 0.;}
-
- Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- arr->SetLength(arrsize);
- arr = la->ArrowAspect();
- arr->SetLength(arrsize);
-
- if (AutomaticPos && IsSetBndBox)
- Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
-
- DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
- aDrawer,
- FirstAttach,
- SecondAttach,
- DirAttach,
- Position,
- SymbolPrs,
- FirstExtreme,
- SecondExtreme);
-
-
-}
- if (cu1.GetType() == GeomAbs_Circle && cu2.GetType() == GeomAbs_Circle){
- //Get first and last points of circles
- Handle(Geom_Circle) aCir1 (Handle(Geom_Circle)::DownCast(geom1));
- Handle(Geom_Circle) aCir2 (Handle(Geom_Circle)::DownCast(geom2));
- gp_Circ aCirc1 = aCir1->Circ();
- gp_Circ aCirc2 = aCir2->Circ();
-
- //To avoid circles with different orientaion
- Standard_Real aTol = Precision::Confusion();
- if(aCirc2.Axis().IsOpposite(aCirc1.Axis(), aTol) ||
- aCirc2.XAxis().IsOpposite(aCirc1.XAxis(), aTol) ||
- aCirc2.YAxis().IsOpposite(aCirc1.YAxis(), aTol) )
- {
- aCirc2.SetPosition(aCirc1.Position());
- aCirc2.SetAxis(aCirc1.Axis());
- }
-
- if (AutomaticPos){
- Standard_Real par1 = 0, par2 = 0;
- gp_Pln aPln = Plane->Pln();
- //Project ptat12 and ptat22 on constraint plane
- gp_Pnt PrPnt12 = AIS::ProjectPointOnPlane(ptat12, aPln);
- gp_Pnt PrPnt22 = AIS::ProjectPointOnPlane(ptat22, aPln);
- //Project circles center on constraint plane
- gp_Pnt PrCenter = AIS::ProjectPointOnPlane(aCirc1.Location(), aPln);
-
- gp_Dir XDir = aPln.XAxis().Direction();
- gp_Dir YDir = aPln.YAxis().Direction();
-
-
- if (PrPnt12.Distance(PrCenter) >Precision::Confusion())
- {
- gp_Dir aDir1(PrPnt12.XYZ() - PrCenter.XYZ());
- Standard_Real anAngle = aDir1.Angle(XDir); //Get the angle in range [0, M_PI]
- if (aDir1.Dot(YDir) < 0)
- anAngle = 2 * M_PI - anAngle;
- par1 = anAngle;
- }
-
- if (PrPnt22.Distance(PrCenter) >Precision::Confusion())
- {
- gp_Dir aDir2(PrPnt22.XYZ() - PrCenter.XYZ());
- Standard_Real anAngle = aDir2.Angle(XDir); //Get the angle in range [0, M_PI]
- if (aDir2.Dot(YDir) < 0)
- anAngle = 2 * M_PI - anAngle;
- par2 = anAngle;
- }
-
-
- if(par1 > par2 ){
- FirstExtreme = ptat12;
- Standard_Real aPar1 = ElCLib::Parameter(aCirc2, ptat12);
- SecondExtreme = ElCLib::Value(aPar1, aCirc2);
- }
- else {
- Standard_Real aPar2 = ElCLib::Parameter(aCirc1, ptat22);
- FirstExtreme = ElCLib::Value(aPar2, aCirc1);
- SecondExtreme = ptat22;
- }
- }
- else {
- Standard_Real pospar = ElCLib::Parameter(aCirc1, Position);
- FirstExtreme = ElCLib::Value(pospar, aCirc1);
- pospar = ElCLib::Parameter(aCirc2, Position);
- SecondExtreme = ElCLib::Value(pospar, aCirc2);
- }
-
- DsgPrs_EqualDistancePresentation::AddIntervalBetweenTwoArcs(aPresentation,
- aDrawer,
- aCirc1,
- aCirc2,
- ptat12,
- FirstExtreme,
- ptat22,
- SecondExtreme,
- SymbolPrs);
-
- FirstAttach = ptat12; SecondAttach = ptat22; //assign attach points
- Position.SetXYZ( (FirstAttach.XYZ() + SecondAttach.XYZ())*0.5);
- }
-
- if (arrsize < Precision::Confusion()) arrsize = Val*0.1;
- if (Abs(Val) <= Precision::Confusion()) {arrsize = 0.;}
-
-// gp_Pnt pf, pl;
- if (!isInPlane1) {
- AIS::ComputeProjEdgePresentation( aPresentation, aDrawer, FirstEdge, geom1, ptat11, ptat12);
- }
- if(!isInPlane2) {
- AIS::ComputeProjEdgePresentation( aPresentation, aDrawer, SecondEdge, geom2, ptat21, ptat22);
- }
-}
-
-//=======================================================================
-//function : ComputeTwoVerticesLength
-//purpose :
-//=======================================================================
-
-void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Presentation )& aPresentation,
- const Handle( Prs3d_Drawer )& aDrawer,
- const Standard_Real ArrowSize,
- const TopoDS_Vertex& FirstVertex,
- const TopoDS_Vertex& SecondVertex,
- const Handle( Geom_Plane )& Plane,
- const Standard_Boolean AutomaticPos,
- const Standard_Boolean IsSetBndBox,
- const Bnd_Box& BndBox,
- const AIS_TypeOfDist TypeDist,
- gp_Pnt& Position,
- gp_Pnt& FirstAttach,
- gp_Pnt& SecondAttach,
- gp_Pnt& FirstExtreme,
- gp_Pnt& SecondExtreme,
- DsgPrs_ArrowSide& SymbolPrs )
-{
- Standard_Boolean isOnPlane1, isOnPlane2;
- gp_Dir DirAttach;
- AIS::ComputeGeometry( FirstVertex, FirstAttach, Plane, isOnPlane1);
- AIS::ComputeGeometry( SecondVertex, SecondAttach, Plane, isOnPlane2);
-
- Standard_Real confusion(Precision::Confusion());
- Standard_Boolean samePoint(FirstAttach.IsEqual(SecondAttach,confusion));
-
- if (TypeDist == AIS_TOD_Vertical) DirAttach = Plane->Pln().XAxis().Direction();
- else if (TypeDist == AIS_TOD_Horizontal) DirAttach = Plane->Pln().YAxis().Direction();
- else {
- if (!samePoint) {
- DirAttach.SetXYZ(SecondAttach.XYZ() - FirstAttach.XYZ());
- DirAttach.Rotate(Plane->Pln().Axis(),M_PI/2.);
- }
- }
-
- // size
- if (AutomaticPos) {
- if (!samePoint) {
- gp_Pnt curpos((FirstAttach.XYZ()+SecondAttach.XYZ())*0.5);
- // make offset of curpos
- gp_Vec offset(DirAttach);
- offset = offset*ArrowSize*(-10.);
- curpos.Translate(offset);
- Position = curpos;
- }
- else {
- gp_Dir aDir = Plane->Pln().Axis().Direction();
- gp_Vec aVec (aDir.XYZ()*10*ArrowSize);
- //Position = gp_Pnt(FirstAttach.XYZ()+gp_XYZ(1.,1.,1.)); // not correct
- Position = FirstAttach.Translated(aVec);
- Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );//not needed really
- DirAttach.SetXYZ(Position.XYZ() - FirstAttach.XYZ());
- }
- }
- else {
- Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
- }
-
-
- Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- arr->SetLength(ArrowSize);
- arr = la->ArrowAspect();
- arr->SetLength(ArrowSize);
-
- if (AutomaticPos && IsSetBndBox)
- Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
-
- DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
- aDrawer,
- FirstAttach,
- SecondAttach,
- DirAttach,
- Position,
- SymbolPrs,
- FirstExtreme, //returned
- SecondExtreme); //returned
-
- // Compute projection
- if ( !isOnPlane1)
- AIS::ComputeProjVertexPresentation(aPresentation, aDrawer, FirstVertex, FirstAttach);
- if ( !isOnPlane2)
- AIS::ComputeProjVertexPresentation(aPresentation, aDrawer, SecondVertex, SecondAttach);
-
-}
-
-
-//=======================================================================
-//function : ComputeOneEdgeOneVertexLength
-//purpose :
-//=======================================================================
-
-void AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs3d_Presentation )& aPresentation,
- const Handle( Prs3d_Drawer )& aDrawer,
- const Standard_Real ArrowSize,
- const TopoDS_Shape & FirstShape,
- const TopoDS_Shape & SecondShape,
- const Handle( Geom_Plane )& Plane,
- const Standard_Boolean AutomaticPos,
- const Standard_Boolean IsSetBndBox,
- const Bnd_Box & BndBox,
- gp_Pnt & Position,
- gp_Pnt & FirstAttach,
- gp_Pnt & SecondAttach,
- gp_Pnt& FirstExtreme,
- gp_Pnt& SecondExtreme,
- DsgPrs_ArrowSide & SymbolPrs )
-{
- TopoDS_Vertex thevertex;
- TopoDS_Edge theedge;
-
- gp_Pnt ptonedge1,ptonedge2;
- Handle(Geom_Curve) aCurve;
- Handle(Geom_Curve) extCurv;
- Standard_Boolean isInfinite;
- Standard_Real Val;
- Standard_Boolean isOnPlanEdge, isOnPlanVertex;
- Standard_Integer edgenum ;
-
- if (FirstShape.ShapeType() == TopAbs_VERTEX) {
- thevertex = TopoDS::Vertex(FirstShape);
- theedge = TopoDS::Edge(SecondShape);
- edgenum = 2; //edge is the second shape
- }
- else {
- thevertex = TopoDS::Vertex(SecondShape);
- theedge = TopoDS::Edge(FirstShape);
- edgenum = 1;//edge is the first shape
- }
- if (!AIS::ComputeGeometry(theedge,aCurve,ptonedge1,ptonedge2,extCurv,isInfinite,isOnPlanEdge,Plane))
- return;
- aPresentation->SetInfiniteState(isInfinite);
- AIS::ComputeGeometry(thevertex, FirstAttach, Plane, isOnPlanVertex);
-
- if ( aCurve->IsInstance(STANDARD_TYPE(Geom_Line)) )
- {
- Handle(Geom_Line) geom_lin (Handle(Geom_Line)::DownCast (aCurve));
- const gp_Lin& l = geom_lin->Lin();
-
- // computation of Val
- Val = l.Distance( FirstAttach );
-
- gp_Dir DirAttach = l.Direction();
- // size
- Standard_Real arrsize = ArrowSize;
- if (Abs(Val) <= Precision::Confusion()) {arrsize = 0.;}
-
- if (AutomaticPos) {
- gp_Pnt p = ElCLib::Value(ElCLib::Parameter(l,FirstAttach),l);
- gp_Pnt curpos((FirstAttach.XYZ()+p.XYZ())*0.5);
- // make offset
- gp_Vec offset(DirAttach);
- offset = offset*ArrowSize*(-10.);
- curpos.Translate(offset);
- Position = curpos;
- }
- else { // project point on the plane
- Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
- }
-
- if (!isInfinite) {
- if (Position.Distance(ptonedge1) > Position.Distance(ptonedge2)) SecondAttach = ptonedge2;
- else SecondAttach = ptonedge1;
- }
- else {
- SecondAttach = ElCLib::Value(ElCLib::Parameter(l,Position),l);
- }
-
- Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- arr->SetLength(arrsize);
- arr = la->ArrowAspect();
- arr->SetLength(arrsize);
-
- if (AutomaticPos && IsSetBndBox)
- Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
- DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
- aDrawer,
- FirstAttach,
- SecondAttach,
- DirAttach,
- Position,
- SymbolPrs,
- FirstExtreme,
- SecondExtreme);
-
-}
- if (aCurve->IsInstance(STANDARD_TYPE(Geom_Circle))){
- gp_Circ aCirc1 = (Handle(Geom_Circle)::DownCast(aCurve))->Circ();
- gp_Circ aCirc2(aCirc1); aCirc2.SetRadius(0); //create the second formal circle
- if(AutomaticPos)
- {
- SecondAttach = ptonedge2; //a vertex
- Position.SetXYZ((SecondAttach.XYZ() + aCirc1.Location().XYZ())*0.5);
- }
- else {
- Standard_Real aPar = ElCLib::Parameter(aCirc1, Position);
- SecondAttach = ElCLib::Value(aPar, aCirc1);
- }
-
- Handle(Geom_Circle) aCurve2 = new Geom_Circle(aCirc2);
- DsgPrs_EqualDistancePresentation::AddIntervalBetweenTwoArcs(aPresentation,
- aDrawer,
- aCirc1, //circle or arc
- aCirc2, //really vertex
- ptonedge2, //last point of aCirc1
- SecondAttach,
- FirstAttach, //vertex really
- FirstAttach,
- SymbolPrs);
-
- //Assign arc points
- if (edgenum == 1){
- FirstExtreme = SecondAttach; SecondExtreme = FirstAttach;
- SecondAttach = FirstAttach; FirstAttach = ptonedge2;
- } else { //vertex is the first shape, circle is sthe last.
- FirstExtreme = FirstAttach; SecondExtreme = SecondAttach;
- SecondAttach = ptonedge2;
- }
- }
-
- // computation of Val
- Val = FirstAttach.Distance(SecondAttach);
-
- //Display the pieces of attached to the curve if it is not
- // in the WP
- if (!isOnPlanEdge) { // add presentation of projection of the edge in WP
- AIS::ComputeProjEdgePresentation(aPresentation,aDrawer,theedge,aCurve,ptonedge1,ptonedge2);
- }
- if (!isOnPlanVertex) { // add presentation of projection of the vertex in WP
- AIS::ComputeProjVertexPresentation(aPresentation,aDrawer,thevertex,FirstAttach);
- }
-
-}
-// -- ota -- end
+++ /dev/null
-// Created on: 1998-01-24
-// Created by: Julia GERASIMOVA
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_EqualDistanceRelation_HeaderFile
-#define _AIS_EqualDistanceRelation_HeaderFile
-
-#include <AIS_Relation.hxx>
-#include <AIS_TypeOfDist.hxx>
-#include <DsgPrs_ArrowSide.hxx>
-
-class Geom_Plane;
-
-DEFINE_STANDARD_HANDLE(AIS_EqualDistanceRelation, AIS_Relation)
-
-//! A framework to display equivalent distances between
-//! shapes and a given plane.
-//! The distance is the length of a projection from the
-//! shape to the plane.
-//! These distances are used to compare shapes by this vector alone.
-class AIS_EqualDistanceRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_EqualDistanceRelation,AIS_Relation)
-public:
-
- //! Constructs a framework to display equivalent
- //! distances between the shapes aShape1, aShape2,
- //! aShape3, aShape4 and the plane aPlane.
- //! The distance is the length of a projection from the
- //! shape to the plane.
- Standard_EXPORT AIS_EqualDistanceRelation(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const TopoDS_Shape& aShape3, const TopoDS_Shape& aShape4, const Handle(Geom_Plane)& aPlane);
-
-
- //! Sets the shape aShape to be used as the shape
- //! aShape3 in the framework created at construction time.
- void SetShape3 (const TopoDS_Shape& aShape);
-
-
- //! Returns the shape aShape3 from the framework
- //! created at construction time.
- const TopoDS_Shape& Shape3() const;
-
-
- //! Sets the shape aShape to be used as the shape
- //! aShape4 in the framework created at construction time.
- void SetShape4 (const TopoDS_Shape& aShape);
-
-
- //! Returns the shape aShape4 from the framework
- //! created at construction time.
- const TopoDS_Shape& Shape4() const;
-
- //! Computes the location of an intreval between
- //! between two edges. FirstAttach , SecondAttach
- //! are the returned extreme points of the interval.
- Standard_EXPORT static void ComputeTwoEdgesLength (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Drawer)& aDrawer, const Standard_Real ArrowSize, const TopoDS_Edge& FirstEdge, const TopoDS_Edge& SecondEdge, const Handle(Geom_Plane)& Plane, const Standard_Boolean AutomaticPos, const Standard_Boolean IsSetBndBox, const Bnd_Box& BndBox, gp_Pnt& Position, gp_Pnt& FirstAttach, gp_Pnt& SecondAttach, gp_Pnt& FirstExtreme, gp_Pnt& SecondExtreme, DsgPrs_ArrowSide& SymbolPrs);
-
- //! Computes the interval position between two vertexs. FirstAttach,
- //! SecondAttach are the returned extreme points of the interval.
- Standard_EXPORT static void ComputeTwoVerticesLength (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Drawer)& aDrawer, const Standard_Real ArrowSize, const TopoDS_Vertex& FirstVertex, const TopoDS_Vertex& SecondVertex, const Handle(Geom_Plane)& Plane, const Standard_Boolean AutomaticPos, const Standard_Boolean IsSetBndBox, const Bnd_Box& BndBox, const AIS_TypeOfDist TypeDist, gp_Pnt& Position, gp_Pnt& FirstAttach, gp_Pnt& SecondAttach, gp_Pnt& FirstExtreme, gp_Pnt& SecondExtreme, DsgPrs_ArrowSide& SymbolPrs);
-
- //! Compute the interval location between a vertex and an edge. Edge may be
- //! a line or a circle.
- Standard_EXPORT static void ComputeOneEdgeOneVertexLength (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Drawer)& aDrawer, const Standard_Real ArrowSize, const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& Plane, const Standard_Boolean AutomaticPos, const Standard_Boolean IsSetBndBox, const Bnd_Box& BndBox, gp_Pnt& Position, gp_Pnt& FirstAttach, gp_Pnt& SecondAttach, gp_Pnt& FirstExtreme, gp_Pnt& SecondExtreme, DsgPrs_ArrowSide& SymbolPrs);
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- TopoDS_Shape myShape3;
- TopoDS_Shape myShape4;
- gp_Pnt myAttachPoint1;
- gp_Pnt myAttachPoint2;
- gp_Pnt myAttachPoint3;
- gp_Pnt myAttachPoint4;
- gp_Pnt myPoint1;
- gp_Pnt myPoint2;
- gp_Pnt myPoint3;
- gp_Pnt myPoint4;
-
-};
-
-#include <AIS_EqualDistanceRelation.lxx>
-
-#endif // _AIS_EqualDistanceRelation_HeaderFile
+++ /dev/null
-// Created on: 1998-01-24
-// Created by: Julia GERASIMOVA
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : SetShape3
-//purpose :
-//=======================================================================
-
-inline void AIS_EqualDistanceRelation::SetShape3( const TopoDS_Shape& aShape )
-{
- myShape3 = aShape;
-}
-
-//=======================================================================
-//function : Shape3
-//purpose :
-//=======================================================================
-
-inline const TopoDS_Shape& AIS_EqualDistanceRelation::Shape3() const
-{
- return myShape3;
-}
-
-
-//=======================================================================
-//function : SetShape4
-//purpose :
-//=======================================================================
-
-inline void AIS_EqualDistanceRelation::SetShape4( const TopoDS_Shape& aShape )
-{
- myShape4 = aShape;
-}
-
-//=======================================================================
-//function : Shape4
-//purpose :
-//=======================================================================
-
-inline const TopoDS_Shape& AIS_EqualDistanceRelation::Shape4() const
-{
- return myShape4;
-}
-
+++ /dev/null
-// Created on: 1998-01-20
-// Created by: Julia GERASIMOVA
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_EqualRadiusRelation.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <DsgPrs_EqualRadiusPresentation.hxx>
-#include <ElCLib.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <GeomAPI_ProjectPointOnSurf.hxx>
-#include <gp_Circ.hxx>
-#include <Precision.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_EqualRadiusRelation,AIS_Relation)
-
-//=======================================================================
-//function : AIS_EqualRadiusRelation
-//purpose :
-//=======================================================================
-AIS_EqualRadiusRelation::AIS_EqualRadiusRelation( const TopoDS_Edge& aFirstEdge,
- const TopoDS_Edge& aSecondEdge,
- const Handle( Geom_Plane )& aPlane )
- :AIS_Relation()
-{
- myFShape = aFirstEdge;
- mySShape = aSecondEdge;
- myPlane = aPlane;
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-
-void AIS_EqualRadiusRelation::Compute( const Handle( PrsMgr_PresentationManager3d )&,
- const Handle( Prs3d_Presentation )& aPresentation,
- const Standard_Integer )
-{
- BRepAdaptor_Curve FirstCurve( TopoDS::Edge( myFShape ) ), SecondCurve( TopoDS::Edge( mySShape ) );
-
- Standard_Real FirstPar1 = FirstCurve.FirstParameter(), LastPar1 = FirstCurve.LastParameter(),
- FirstPar2 = SecondCurve.FirstParameter(), LastPar2 = SecondCurve.LastParameter();
-
- Handle( Geom_Curve ) FirstProjCurve = FirstCurve.Curve().Curve(),
- SecondProjCurve = SecondCurve.Curve().Curve();
- gp_Pnt FirstPoint1, LastPoint1, FirstPoint2, LastPoint2;
- Standard_Boolean isFirstOnPlane, isSecondOnPlane;
-
- AIS::ComputeGeomCurve( FirstProjCurve, FirstPar1, LastPar1, FirstPoint1, LastPoint1, myPlane, isFirstOnPlane );
- AIS::ComputeGeomCurve( SecondProjCurve, FirstPar2, LastPar2, FirstPoint2, LastPoint2, myPlane, isSecondOnPlane );
-
- if (!isFirstOnPlane)
- ComputeProjEdgePresentation( aPresentation, TopoDS::Edge( myFShape ), FirstProjCurve, FirstPoint1, LastPoint1 );
- if (! isSecondOnPlane)
- ComputeProjEdgePresentation( aPresentation, TopoDS::Edge( mySShape ), SecondProjCurve, FirstPoint2, LastPoint2 );
-
- gp_Circ FirstCirc = (Handle( Geom_Circle )::DownCast( FirstProjCurve ))->Circ();
- gp_Circ SecondCirc = (Handle( Geom_Circle )::DownCast( SecondProjCurve ))->Circ();
-
- myFirstCenter = FirstCirc.Location();
- mySecondCenter = SecondCirc.Location();
-
- //ota -- begin --
- if (myAutomaticPosition)
- {
- myFirstPoint = ElCLib::Value( (FirstPar1 + LastPar1)*0.5, FirstCirc );
- mySecondPoint = ElCLib::Value( (FirstPar2 + LastPar2)*0.5, SecondCirc );
- }
- else {
- Standard_Real aPar = ElCLib::Parameter(FirstCirc, myFirstPoint);
- if (IntegerPart(0.5*LastPar1/M_PI) != 0 && aPar < FirstPar1 )
- aPar +=2*M_PI*IntegerPart(0.5*LastPar1/M_PI);
- Standard_Real aRadius = FirstCirc.Radius();
-
- if (Abs(myFirstPoint.Distance(myFirstCenter) - aRadius) >= Precision::Confusion())
- myFirstPoint = ElCLib::Value(aPar, FirstCirc);
- if ( FirstPoint1.Distance(LastPoint1) > Precision::Confusion()){
- //check where is myFirstPoint
- if (aPar > LastPar1 || aPar < FirstPar1)
- {
- //myFirstPoint is out of Arc of FirstCircle
- if (FirstPoint1.Distance(myFirstPoint)< LastPoint1.Distance(myFirstPoint))
- myFirstPoint = FirstPoint1;
- else
- myFirstPoint = LastPoint1;
- }
- }
-
-
- aPar = ElCLib::Parameter(SecondCirc, mySecondPoint);
- if (IntegerPart(0.5*LastPar2/M_PI) != 0 && aPar < FirstPar2 )
- aPar +=2*M_PI*IntegerPart(0.5*LastPar2/M_PI);
-
- aRadius = SecondCirc.Radius();
- if (Abs(mySecondPoint.Distance(mySecondCenter) - aRadius) >= Precision::Confusion())
- mySecondPoint = ElCLib::Value(aPar, SecondCirc);
- if (FirstPoint2.Distance(LastPoint2) > Precision::Confusion()){
- if (aPar > LastPar2 || aPar < FirstPar2)
- { //mySecondPoint is out of Arc of mySecondCircle
- if (FirstPoint2.Distance(mySecondPoint)< LastPoint2.Distance(mySecondPoint))
- mySecondPoint = FirstPoint2;
- else
- mySecondPoint = LastPoint2;
- }
- }
- }
- if( !myArrowSizeIsDefined )
- myArrowSize = (Min(myFirstCenter.Distance(myFirstPoint),
- mySecondCenter.Distance(mySecondPoint)))*0.05;
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
-
- //ota -- end --
-
- DsgPrs_EqualRadiusPresentation::Add(aPresentation, myDrawer,
- myFirstCenter, mySecondCenter, myFirstPoint, mySecondPoint, myPlane );
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-
-void AIS_EqualRadiusRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
- const Standard_Integer )
-{
- Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 );
- Handle( Select3D_SensitiveSegment ) seg;
-
- seg = new Select3D_SensitiveSegment( own, myFirstCenter, myFirstPoint );
- aSelection->Add( seg );
-
- if(!myAutomaticPosition)
- ComputeRadiusPosition();
-
- seg = new Select3D_SensitiveSegment( own, mySecondCenter, mySecondPoint );
- aSelection->Add( seg );
-
- seg = new Select3D_SensitiveSegment( own, myFirstCenter, mySecondCenter );
- aSelection->Add( seg );
-
-
- // Two small lines
- gp_Pnt Middle( (myFirstCenter.XYZ() + mySecondCenter.XYZ())*0.5 );
-
- Standard_Real SmallDist = .001;
- //Should be changed as the domain of small lines could be changed.
- Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox(own,
- Middle.X() - SmallDist,
- Middle.Y() - SmallDist,
- Middle.Z() - SmallDist,
- Middle.X() + SmallDist,
- Middle.Y() + SmallDist,
- Middle.Z() + SmallDist );
- aSelection->Add(box);
-}
-
-//=================================================================
-//function : ComputeRadiusPosition
-//purpose :
-//=================================================================
-void AIS_EqualRadiusRelation::ComputeRadiusPosition()
-{
- if (myAutomaticPosition ||
- myFirstCenter.Distance(myPosition) < Precision::Confusion() ||
- mySecondCenter.Distance(myPosition) < Precision::Confusion())
- return;
-
- gp_Pnt aPosition;
-
- //project myPosition to the plane of constraint
- GeomAPI_ProjectPointOnSurf aProj(myPosition, myPlane);
- aPosition = aProj.NearestPoint();
-
- Standard_Real aDist1 = myFirstPoint.Distance(aPosition);
- Standard_Real aDist2 = mySecondPoint.Distance(aPosition);
-
- if(aDist1<aDist2)
- {
- Standard_Real Rad1 = myFirstPoint.Distance(myFirstCenter);
- const gp_Dir aNewDir1(aPosition.XYZ() - myFirstCenter.XYZ());
- const gp_Vec aTVec (aNewDir1.XYZ()*Rad1);
- myFirstPoint = myFirstCenter.Translated(aTVec);
- }
- else {
- Standard_Real Rad2 = mySecondPoint.Distance(mySecondCenter);
- const gp_Dir aNewDir2(aPosition.XYZ() - mySecondCenter.XYZ());
- gp_Vec aTVec (aNewDir2.XYZ()*Rad2);
- mySecondPoint = mySecondCenter.Translated(aTVec);
- }
-
-}
-
+++ /dev/null
-// Created on: 1998-01-17
-// Created by: Julia GERASIMOVA
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_EqualRadiusRelation_HeaderFile
-#define _AIS_EqualRadiusRelation_HeaderFile
-
-#include <AIS_Relation.hxx>
-
-class Geom_Plane;
-
-DEFINE_STANDARD_HANDLE(AIS_EqualRadiusRelation, AIS_Relation)
-
-class AIS_EqualRadiusRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_EqualRadiusRelation, AIS_Relation)
-public:
-
- //! Creates equal relation of two arc's radiuses.
- //! If one of edges is not in the given plane,
- //! the presentation method projects it onto the plane.
- Standard_EXPORT AIS_EqualRadiusRelation(const TopoDS_Edge& aFirstEdge, const TopoDS_Edge& aSecondEdge, const Handle(Geom_Plane)& aPlane);
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeRadiusPosition();
-
- gp_Pnt myFirstCenter;
- gp_Pnt mySecondCenter;
- gp_Pnt myFirstPoint;
- gp_Pnt mySecondPoint;
-
-};
-
-#endif // _AIS_EqualRadiusRelation_HeaderFile
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Flore Lantheaume/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_FixRelation.hxx>
-#include <AIS_Shape.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <DsgPrs_FixPresentation.hxx>
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Circ.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <gp_XYZ.hxx>
-#include <Precision.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_DomainError.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TColStd_ListIteratorOfListOfTransient.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <TopExp.hxx>
-#include <TopLoc_Location.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_FixRelation,AIS_Relation)
-
-static Standard_Boolean InDomain(const Standard_Real fpar,
- const Standard_Real lpar,
- const Standard_Real para)
-{
- if (fpar >= 0.) {
- return ((para >= fpar) && (para <= lpar));
- }
- if (para >= (fpar+2*M_PI)) return Standard_True;
- if (para <= lpar) return Standard_True;
- return Standard_False;
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : vertex Fix Relation
-//=======================================================================
-
-AIS_FixRelation::AIS_FixRelation(const TopoDS_Shape& aShape,
- const Handle(Geom_Plane)& aPlane,
- const TopoDS_Wire& aWire)
-:AIS_Relation(),
- myWire(aWire)
-{
- myFShape = aShape;
- myPlane = aPlane;
- myAutomaticPosition = Standard_True;
- myArrowSize = 5.;
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : vertex Fix Relation
-//=======================================================================
-
-AIS_FixRelation::AIS_FixRelation(const TopoDS_Shape& aShape,
- const Handle(Geom_Plane)& aPlane,
- const TopoDS_Wire& aWire,
- const gp_Pnt& aPosition,
- const Standard_Real anArrowSize)
-:AIS_Relation(),
- myWire(aWire)
-{
- myFShape = aShape;
- myPlane = aPlane;
- myPosition = aPosition;
- SetArrowSize( anArrowSize );
- myAutomaticPosition = Standard_False;
-}
-
-
-//=======================================================================
-//function : Constructor
-//purpose : edge (line or circle) Fix Relation
-//=======================================================================
-
-AIS_FixRelation::AIS_FixRelation(const TopoDS_Shape& aShape,
- const Handle(Geom_Plane)& aPlane)
-{
- myFShape = aShape;
- myPlane = aPlane;
- myAutomaticPosition = Standard_True;
- myArrowSize = 5.;
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : edge (line or circle) Fix Relation
-//=======================================================================
-
-AIS_FixRelation::AIS_FixRelation(
- const TopoDS_Shape& aShape,
- const Handle(Geom_Plane)& aPlane,
- const gp_Pnt& aPosition,
- const Standard_Real anArrowSize)
-{
- myFShape = aShape;
- myPlane = aPlane;
- myPosition = aPosition;
- SetArrowSize( anArrowSize );
- myAutomaticPosition = Standard_False;
-}
-
-//=======================================================================
-//function : Wire
-//purpose :
-//=======================================================================
-
-TopoDS_Wire AIS_FixRelation::Wire()
-{
- return myWire;
-}
-
-//=======================================================================
-//function : SetWire
-//purpose :
-//=======================================================================
-
-void AIS_FixRelation::SetWire(const TopoDS_Wire& aWire)
-{
- myWire = aWire;
-}
-
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-
-void AIS_FixRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer)
-{
- // Calculate position of the symbol and
- // point of attach of the segment on the shape
- gp_Pnt curpos;
- if (myFShape.ShapeType() == TopAbs_VERTEX)
- ComputeVertex(TopoDS::Vertex(myFShape), curpos);
- else if (myFShape.ShapeType() == TopAbs_EDGE)
- ComputeEdge(TopoDS::Edge(myFShape), curpos);
-
- const gp_Dir& nor = myPlane->Axis().Direction();
-
-
- // calculate presentation
- // definition of the symbol size
- if( !myArrowSizeIsDefined )
- myArrowSize = 5.;
-
- //creation of the presentation
- DsgPrs_FixPresentation::Add(aPresentation,
- myDrawer,
- myPntAttach,
- curpos,
- nor,
- myArrowSize);
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-
-void AIS_FixRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer)
-{
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
-
- // creation of segment sensible for the linked segment
- // of the shape fixed to symbol 'Fix'
- Handle(Select3D_SensitiveSegment) seg;
- seg = new Select3D_SensitiveSegment(own,
- myPntAttach,
- myPosition);
- aSelection->Add(seg);
-
- // Creation of the sensible zone of symbol 'Fix'
- gp_Dir norm = myPlane->Axis().Direction();
-
- gp_Vec dirac(myPntAttach,myPosition);
- dirac.Normalize();
- gp_Vec norac = dirac.Crossed(gp_Vec(norm));
- gp_Ax1 ax(myPosition, norm);
- norac.Rotate(ax, M_PI/8);
-
- norac*=(myArrowSize/2);
- gp_Pnt P1 = myPosition.Translated(norac);
- gp_Pnt P2 = myPosition.Translated(-norac);
- seg = new Select3D_SensitiveSegment(own,
- P1,
- P2);
- aSelection->Add(seg);
-
- norac*=0.8;
- P1 = myPosition.Translated(norac);
- P2 = myPosition.Translated(-norac);
- dirac*=(myArrowSize/2);
- gp_Pnt PF(P1.XYZ());
- gp_Pnt PL = PF.Translated(dirac);
- PL.Translate(norac);
- seg = new Select3D_SensitiveSegment(own,
- PF,
- PL);
- aSelection->Add(seg);
-
-
- PF.SetXYZ(P2.XYZ());
- PL = PF.Translated(dirac);
- PL.Translate(norac);
- seg = new Select3D_SensitiveSegment(own,
- PF,
- PL);
- aSelection->Add(seg);
-
- PF.SetXYZ( (P1.XYZ() + P2.XYZ()) /2 );
- PL = PF.Translated(dirac);
- PL.Translate(norac);
- seg = new Select3D_SensitiveSegment(own,
- PF,
- PL);
-}
-
-//=======================================================================
-//function : ComputeVertex
-//purpose : computes myPntAttach and the position of the presentation
-// when you fix a vertex
-//=======================================================================
-
-void AIS_FixRelation::ComputeVertex(const TopoDS_Vertex& /*FixVertex*/,
- gp_Pnt& curpos)
-{
- myPntAttach = BRep_Tool::Pnt(TopoDS::Vertex(myFShape));
- curpos = myPosition;
- if (myAutomaticPosition) {
- gp_Pln pln(myPlane->Pln());
- gp_Dir dir(pln.XAxis().Direction());
- gp_Vec transvec = gp_Vec(dir)*myArrowSize;
- curpos = myPntAttach.Translated(transvec);
- myPosition = curpos;
- myAutomaticPosition = Standard_True;
- }
-}
-
-//=======================================================================
-//function : ComputePosition
-//purpose :
-//=======================================================================
-
-gp_Pnt AIS_FixRelation::ComputePosition(const Handle(Geom_Curve)& curv1,
- const Handle(Geom_Curve)& curv2,
- const gp_Pnt& firstp1,
- const gp_Pnt& lastp1,
- const gp_Pnt& firstp2,
- const gp_Pnt& lastp2) const
-{
- //---------------------------------------------------------
- // calculate the point of attach
- //---------------------------------------------------------
- gp_Pnt curpos;
-
- if (curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) || curv2->IsInstance(STANDARD_TYPE(Geom_Circle))) {
- Handle(Geom_Circle) gcirc = Handle(Geom_Circle)::DownCast(curv1);
- if (gcirc.IsNull()) gcirc = Handle(Geom_Circle)::DownCast(curv2);
- gp_Dir dir( gcirc->Location().XYZ() + myPntAttach.XYZ() );
- gp_Vec transvec = gp_Vec(dir)*myArrowSize;
- curpos = myPntAttach.Translated(transvec);
- }
-
- else {
- gp_Vec vec1(firstp1,lastp1);
- gp_Vec vec2(firstp2,lastp2);
-
- if (!vec1.IsParallel(vec2, Precision::Angular()) ) {
- gp_Dir dir;
- Standard_Real conf =Precision::Confusion();
- if (lastp1.IsEqual(firstp2,conf) || firstp1.IsEqual(lastp2,conf)) dir.SetXYZ(vec1.XYZ() - vec2.XYZ());
- else dir.SetXYZ(vec1.XYZ() + vec2.XYZ());
- gp_Vec transvec = gp_Vec(dir)*myArrowSize;
- curpos = myPntAttach.Translated(transvec);
- }
- else {
- gp_Vec crossvec = vec1.Crossed(vec2);
- vec1.Cross(crossvec);
- gp_Dir dir(vec1);
- curpos = myPntAttach.Translated(gp_Vec(dir)*myArrowSize);
- }
- }
-
- return curpos;
-}
-
-//=======================================================================
-//function : ComputePosition
-//purpose : Computes the position of the "fix dimension" when the
-// fixed object is a vertex which is set at the intersection
-// of two curves.
-// The "dimension" is in the "middle" of the two edges.
-//=======================================================================
-
-gp_Pnt AIS_FixRelation::ComputePosition(const Handle(Geom_Curve)& curv,
- const gp_Pnt& firstp,
- const gp_Pnt& lastp) const
-{
- //---------------------------------------------------------
- // calculate the point of attach
- //---------------------------------------------------------
- gp_Pnt curpos;
-
- if (curv->IsKind(STANDARD_TYPE(Geom_Circle))) {
-
- Handle(Geom_Circle) gcirc = Handle(Geom_Circle)::DownCast(curv);
- gp_Dir dir( gcirc->Location().XYZ() + myPntAttach.XYZ() );
- gp_Vec transvec = gp_Vec(dir)*myArrowSize;
- curpos = myPntAttach.Translated(transvec);
-
- } //if (curv->IsKind(STANDARD_TYPE(Geom_Circle))
-
- else {
-// gp_Pln pln(Component()->WorkingPlane()->Plane()->GetValue()->Pln());
- gp_Pln pln(myPlane->Pln());
- gp_Dir NormPln = pln.Axis().Direction();
- gp_Vec vec(firstp,lastp);
- vec.Cross( gp_Vec(NormPln));
- vec.Normalize();
- gp_Vec transvec = vec*myArrowSize;
- curpos = myPntAttach.Translated(transvec);
- gp_Ax1 RotAx( myPntAttach, NormPln);
- curpos.Rotate(RotAx, M_PI/10);
- }
-
- return curpos;
- }
-
-//=======================================================================
-//function : ComputeEdge
-//purpose : computes myPntAttach and the position of the presentation
-// when you fix an edge
-//=======================================================================
-
-void AIS_FixRelation::ComputeEdge(const TopoDS_Edge& FixEdge, gp_Pnt& curpos)
-{
- Handle(Geom_Curve) curEdge;
- gp_Pnt ptbeg,ptend;
- if (!AIS::ComputeGeometry(FixEdge,curEdge,ptbeg,ptend)) return;
-
- //---------------------------------------------------------
- // calcul du point de positionnement du symbole 'fix'
- //---------------------------------------------------------
- //--> In case of a straight line
- if (curEdge->IsKind(STANDARD_TYPE(Geom_Line))){
- gp_Lin glin = Handle(Geom_Line)::DownCast(curEdge)->Lin();
- Standard_Real pfirst(ElCLib::Parameter(glin,ptbeg));
- Standard_Real plast(ElCLib::Parameter(glin,ptend));
- ComputeLinePosition(glin, curpos, pfirst, plast);
- }
-
- //--> In case of a circle
- else if (curEdge->IsKind(STANDARD_TYPE(Geom_Circle))) {
- gp_Circ gcirc = Handle(Geom_Circle)::DownCast(curEdge)->Circ();
- Standard_Real pfirst, plast;
- BRepAdaptor_Curve cu(FixEdge);
- pfirst = cu.FirstParameter();
- plast = cu.LastParameter();
- ComputeCirclePosition(gcirc, curpos, pfirst, plast);
- }
-
- else
- return;
-
-}
-
-//=======================================================================
-//function : ComputeLinePosition
-//purpose : compute the values of myPntAttach and the position <pos> of
-// the symbol when the fixed edge has a geometric support equal
-// to a line.
-//=======================================================================
-
-void AIS_FixRelation::ComputeLinePosition(const gp_Lin& glin,
- gp_Pnt& pos,
- Standard_Real& pfirst,
- Standard_Real& plast)
-{
- if (myAutomaticPosition) {
- // point of attach is chosen as middle of the segment
- myPntAttach = ElCLib::Value((pfirst+ plast)/2, glin);
-
- gp_Dir norm = myPlane ->Axis().Direction();
-
- norm.Cross(glin.Position().Direction());
- pos = myPntAttach.Translated(gp_Vec(norm)*myArrowSize);
- myAutomaticPosition = Standard_True;
- } // if (myAutomaticPosition)
-
- else {
- pos = myPosition;
- Standard_Real linparam = ElCLib::Parameter(glin, pos);
-
- // case if the projection of position is located between 2 vertices
- // de l'edge
- if ( (linparam >= pfirst) && (linparam <= plast) )
- myPntAttach = ElCLib::Value(linparam,glin);
-
- // case if the projection of Position is outside of the limits
- // of the edge : the point closest to the projection is chosen
- // as the attach point
- else {
- Standard_Real pOnLin;
- if (linparam > plast)
- pOnLin = plast;
- else
- pOnLin = pfirst;
- myPntAttach = ElCLib::Value(pOnLin,glin);
- gp_Dir norm = myPlane->Axis().Direction();
-
- norm.Cross(glin.Position().Direction());
- gp_Lin lsup(myPntAttach, norm);
- Standard_Real parpos = ElCLib::Parameter(lsup,myPosition);
- pos = ElCLib::Value(parpos,lsup);
- }
-
- }
- myPosition = pos;
-}
-
-//=======================================================================
-//function : ComputeCirclePosition
-//purpose : compute the values of myPntAttach and the position <pos> of
-// the symbol when the fixed edge has a geometric support equal
-// to a circle.
-//=======================================================================
-
-void AIS_FixRelation::ComputeCirclePosition(
- const gp_Circ& gcirc,
- gp_Pnt& pos,
- Standard_Real& pfirst,
- Standard_Real& plast)
-{
- // readjust parametres on the circle
- if (plast > 2*M_PI ) {
- Standard_Real nbtours = Floor(plast / (2*M_PI));
- plast -= nbtours*2*M_PI;
- pfirst -= nbtours*2*M_PI;
- }
-
- if (myAutomaticPosition) {
- // the point attach is the "middle" of the segment (relatively
- // to the parametres of start and end vertices of the edge
-
- Standard_Real circparam = (pfirst + plast)/2.;
-
- if ( !InDomain(pfirst,plast,circparam)) {
- Standard_Real otherpar = circparam + M_PI;
- if (otherpar > 2*M_PI) otherpar -= 2*M_PI;
- circparam = otherpar;
- }
-
- myPntAttach = ElCLib::Value(circparam, gcirc );
-
- gp_Vec dir( gcirc.Location().XYZ(), myPntAttach.XYZ() );
- dir.Normalize();
- gp_Vec transvec = dir*myArrowSize;
- pos = myPntAttach.Translated(transvec);
- myPosition = pos;
- myAutomaticPosition = Standard_True;
- } // if (myAutomaticPosition)
-
- else {
- // case if the projection of myPosition is outside of 2
- // vertices of the edge. In this case the parameter is readjusted
- // in the valid part of the circle
- pos = myPosition;
-
- Standard_Real circparam = ElCLib::Parameter(gcirc, pos);
-
- if ( !InDomain(pfirst,plast,circparam)) {
- Standard_Real otherpar = circparam + M_PI;
- if (otherpar > 2*M_PI) otherpar -= 2*M_PI;
- circparam = otherpar;
- }
-
- myPntAttach = ElCLib::Value(circparam,gcirc);
- }
-}
-
-//=======================================================================
-//function : ConnectedEdges
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_FixRelation::ConnectedEdges(const TopoDS_Wire& WIRE,
- const TopoDS_Vertex& V,
- TopoDS_Edge& E1,
- TopoDS_Edge& E2)
-{
- TopTools_IndexedDataMapOfShapeListOfShape vertexMap;
- TopExp::MapShapesAndAncestors (WIRE,TopAbs_VERTEX,TopAbs_EDGE,vertexMap);
-
- Standard_Boolean found(Standard_False);
- TopoDS_Vertex theVertex;
- for (Standard_Integer i=1; i<=vertexMap.Extent() && !found; i++) {
- if (vertexMap.FindKey(i).IsSame(V)) {
- theVertex = TopoDS::Vertex(vertexMap.FindKey(i));
- found = Standard_True;
- }
- }
- if (!found) {
- E1.Nullify();
- E2.Nullify();
- return Standard_False;
- }
-
- TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(theVertex));
- if (iterator.More()) {
- E1 = TopoDS::Edge(iterator.Value());
- BRepAdaptor_Curve curv(E1);
- iterator.Next();
- }
- else {
- E1.Nullify();
- return Standard_False;
- }
-
- if (iterator.More()) {
- E2 = TopoDS::Edge(iterator.Value());
- BRepAdaptor_Curve curv(E2);
- iterator.Next();
- }
- else {
- E2.Nullify();
- return Standard_False;
- }
-
- if (iterator.More()) {
- E1.Nullify();
- E2.Nullify();
- return Standard_False;
- }
- return Standard_True;
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Flore Lantheaume/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_FixRelation_HeaderFile
-#define _AIS_FixRelation_HeaderFile
-
-#include <TopoDS_Wire.hxx>
-#include <AIS_Relation.hxx>
-
-class Geom_Plane;
-
-DEFINE_STANDARD_HANDLE(AIS_FixRelation, AIS_Relation)
-
-//! Constructs and manages a constraint by a fixed
-//! relation between two or more interactive datums. This
-//! constraint is represented by a wire from a shape -
-//! point, vertex, or edge - in the first datum and a
-//! corresponding shape in the second.
-//! Warning: This relation is not bound with any kind of parametric
-//! constraint : it represents the "status" of an parametric
-//! object.
-class AIS_FixRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_FixRelation, AIS_Relation)
-public:
-
- //! initializes the vertex aShape, the
- //! plane aPlane and the wire aWire, which connects
- //! the two vertices in a fixed relation.
- Standard_EXPORT AIS_FixRelation(const TopoDS_Shape& aShape, const Handle(Geom_Plane)& aPlane, const TopoDS_Wire& aWire);
-
- //! initializes the vertex aShape, the
- //! plane aPlane and the wire aWire, the position
- //! aPosition, the arrow size anArrowSize and the
- //! wire aWire, which connects the two vertices in a fixed relation.
- Standard_EXPORT AIS_FixRelation(const TopoDS_Shape& aShape, const Handle(Geom_Plane)& aPlane, const TopoDS_Wire& aWire, const gp_Pnt& aPosition, const Standard_Real anArrowSize = 0.01);
-
- //! initializes the edge aShape and the plane aPlane.
- Standard_EXPORT AIS_FixRelation(const TopoDS_Shape& aShape, const Handle(Geom_Plane)& aPlane);
-
- //! initializes the edge aShape, the
- //! plane aPlane, the position aPosition and the arrow
- //! size anArrowSize.
- Standard_EXPORT AIS_FixRelation(const TopoDS_Shape& aShape, const Handle(Geom_Plane)& aPlane, const gp_Pnt& aPosition, const Standard_Real anArrowSize = 0.01);
-
- //! Returns the wire which connects vertices in a fixed relation.
- Standard_EXPORT TopoDS_Wire Wire();
-
- //! Constructs the wire aWire. This connects vertices
- //! which are in a fixed relation.
- Standard_EXPORT void SetWire (const TopoDS_Wire& aWire);
-
- //! Returns true if the Interactive Objects in the relation
- //! are movable.
- virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
-
-private:
-
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- //! computes the presentation for <myFixShape> if it's a
- //! vertex.
- Standard_EXPORT void ComputeVertex (const TopoDS_Vertex& FixVertex, gp_Pnt& curpos);
-
- Standard_EXPORT gp_Pnt ComputePosition (const Handle(Geom_Curve)& curv1, const Handle(Geom_Curve)& curv2, const gp_Pnt& firstp1, const gp_Pnt& lastp1, const gp_Pnt& firstp2, const gp_Pnt& lastp2) const;
-
- Standard_EXPORT gp_Pnt ComputePosition (const Handle(Geom_Curve)& curv, const gp_Pnt& firstp, const gp_Pnt& lastp) const;
-
- //! computes the presentation for <myFixShape> if it's a
- //! edge.
- Standard_EXPORT void ComputeEdge (const TopoDS_Edge& FixEdge, gp_Pnt& curpos);
-
- Standard_EXPORT void ComputeLinePosition (const gp_Lin& glin, gp_Pnt& pos, Standard_Real& pfirst, Standard_Real& plast);
-
- Standard_EXPORT void ComputeCirclePosition (const gp_Circ& gcirc, gp_Pnt& pos, Standard_Real& pfirst, Standard_Real& plast);
-
- Standard_EXPORT static Standard_Boolean ConnectedEdges (const TopoDS_Wire& aWire, const TopoDS_Vertex& aVertex, TopoDS_Edge& Edge1, TopoDS_Edge& Edge2);
-
- TopoDS_Wire myWire;
- gp_Pnt myPntAttach;
-
-
-};
-
-#endif // _AIS_FixRelation_HeaderFile
+++ /dev/null
-// Created on: 1997-03-03
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_IdenticRelation.hxx>
-#include <AIS_Shape.hxx>
-#include <BRep_Tool.hxx>
-#include <DsgPrs_IdenticPresentation.hxx>
-#include <ElCLib.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <GeomAPI_ProjectPointOnCurve.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <Precision.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TColStd_ListIteratorOfListOfTransient.hxx>
-#include <TopAbs.hxx>
-#include <TopExp.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_IdenticRelation,AIS_Relation)
-
-// jfa 15/10/2000
-static Standard_Real Modulo2PI(const Standard_Real ANGLE)
-{
- if ( ANGLE < 0 ) return Modulo2PI(ANGLE + 2*M_PI);
- else if ( ANGLE >= 2*M_PI ) return Modulo2PI(ANGLE - 2*M_PI);
- return ANGLE;
-}
-
-static Standard_Boolean IsEqual2PI(const Standard_Real angle1,
- const Standard_Real angle2, const Standard_Real precision)
-{
- Standard_Real diff = Abs(angle1-angle2);
- if ( diff < precision ) return Standard_True;
- else if ( Abs(diff-2*M_PI) < precision ) return Standard_True;
- return Standard_False;
-}
-// jfa 15/10/2000 end
-
-//=======================================================================
-//function : AIS_Sort
-//purpose : sort an array of parameters <tab1> in increasing order
-// updates <tab2> and <tab3> according to <tab1>
-//=======================================================================
-static void AIS_Sort(Standard_Real tab1[4],
- gp_Pnt tab2[4],
- Standard_Integer tab3[4])
-{
- Standard_Boolean found = Standard_True;
- Standard_Real cur; gp_Pnt cur1; Standard_Integer cur2;
-
- while (found) {
- found = Standard_False;
- for (Standard_Integer i=0; i< 3; i++) {
- if (tab1[i+1] < tab1[i]) {
- found = Standard_True;
- cur = tab1[i]; cur1 = tab2[i]; cur2 = tab3[i];
- tab1[i] = tab1[i+1]; tab2[i] = tab2[i+1]; tab3[i] = tab3[i+1];
- tab1[i+1] = cur; tab2[i+1] = cur1; tab3[i+1] = cur2;
- }
- }
- }
-}
-
-//=======================================================================
-//function : ConnectedEdges
-//purpose :
-//=======================================================================
-static Standard_Boolean ConnectedEdges(const TopoDS_Wire& WIRE,
- const TopoDS_Vertex& V,
- TopoDS_Edge& E1,
- TopoDS_Edge& E2)
-{
- TopTools_IndexedDataMapOfShapeListOfShape vertexMap;
- TopExp::MapShapesAndAncestors (WIRE,TopAbs_VERTEX,TopAbs_EDGE,vertexMap);
-
- Standard_Boolean found(Standard_False);
- TopoDS_Vertex theVertex;
- for (Standard_Integer i=1; i<=vertexMap.Extent() && !found; i++) {
- if (vertexMap.FindKey(i).IsSame(V)) {
- theVertex = TopoDS::Vertex(vertexMap.FindKey(i));
- found = Standard_True;
- }
- }
- if (!found) {
- E1.Nullify();
- E2.Nullify();
- return Standard_False;
- }
-
- TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(theVertex));
- if (iterator.More()) {
- E1 = TopoDS::Edge(iterator.Value());
- iterator.Next();
- }
- else {
- E1.Nullify();
- return Standard_False;
- }
-
- if (iterator.More()) {
- E2 = TopoDS::Edge(iterator.Value());
- iterator.Next();
- }
- else {
- E2.Nullify();
- return Standard_False;
- }
-
- if (iterator.More()) {
- E1.Nullify();
- E2.Nullify();
- return Standard_False;
- }
- return Standard_True;
-}
-
-// jfa 16/10/2000
-//=======================================================================
-//function : ComputeAttach
-//purpose : Compute a point on the arc of <thecirc>
-// between <aFAttach> and <aSAttach>
-// corresponding to <aPosition>
-// Returns result into <aPosition>
-// Note : This function is to be used only in the case of circles.
-// The <aPosition> parameter is in/out.
-//=======================================================================
-static Standard_Boolean ComputeAttach(const gp_Circ& thecirc,
- const gp_Pnt& aFAttach,
- const gp_Pnt& aSAttach,
- gp_Pnt& aPosition)
-{
- gp_Pnt curpos = aPosition;
-
- // Case of confusion between the current position and the center
- // of the circle -> we move the current position
- Standard_Real confusion (Precision::Confusion());
- gp_Pnt aCenter = thecirc.Location();
- if ( aCenter.Distance(curpos) <= confusion )
- {
- gp_Vec vprec(aCenter, aFAttach);
- vprec.Normalize();
- curpos.Translate(vprec*1e-5);
- }
-
- Standard_Real pcurpos = ElCLib::Parameter(thecirc,curpos);
- Standard_Real pFAttach = ElCLib::Parameter(thecirc,aFAttach);
- Standard_Real pSAttach = ElCLib::Parameter(thecirc,aSAttach);
-
- Standard_Real pSAttachM = pSAttach;
- Standard_Real deltap = pSAttachM - pFAttach;
- if ( deltap < 0 )
- {
- deltap += 2 * M_PI;
- pSAttachM += 2 * M_PI;
- }
- pSAttachM -= pFAttach;
-
- Standard_Real pmiddleout = pSAttachM/2.0 + M_PI;
-
- Standard_Real pcurpos1 = pcurpos;
- // define where curpos lays
- if ( pcurpos1 < pFAttach )
- {
- pcurpos1 = pcurpos1 + 2 * M_PI - pFAttach;
- if ( pcurpos1 > pSAttachM ) // out
- {
- if ( pcurpos1 > pmiddleout ) pcurpos = pFAttach;
- else pcurpos = pSAttach;
- }
- }
- else if ( pcurpos1 > (pFAttach + deltap) ) // out
- {
- pcurpos1 -= pFAttach;
- if ( pcurpos1 > pmiddleout ) pcurpos = pFAttach;
- else pcurpos = pSAttach;
- }
-
- aPosition = ElCLib::Value(pcurpos,thecirc);
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeAttach
-//purpose : Compute a point on the arc of ellipse <theEll>
-// between <aFAttach> and <aSAttach>
-// corresponding to <aPosition>
-// Returns result into <aPosition>
-// Note : This function is to be used only in the case of ellipses.
-// The <aPosition> parameter is in/out.
-//=======================================================================
-static Standard_Boolean ComputeAttach(const gp_Elips& theEll,
- const gp_Pnt& aFAttach,
- const gp_Pnt& aSAttach,
- gp_Pnt& aPosition)
-{
- gp_Pnt curpos = aPosition;
-
- // Case of confusion between the current position and the center
- // of the circle -> we move the current position
- Standard_Real confusion (Precision::Confusion());
- gp_Pnt aCenter = theEll.Location();
- if ( aCenter.Distance(curpos) <= confusion )
- {
- gp_Vec vprec(aCenter, aFAttach);
- vprec.Normalize();
- curpos.Translate(vprec*1e-5);
- }
-
-// for ellipses it's not good Standard_Real pcurpos = ElCLib::Parameter(theEll,curpos);
- Handle(Geom_Ellipse) theEllg = new Geom_Ellipse(theEll);
- GeomAPI_ProjectPointOnCurve aProj (curpos, theEllg);
- Standard_Real pcurpos = aProj.LowerDistanceParameter();
-
- Standard_Real pFAttach = ElCLib::Parameter(theEll,aFAttach);
- Standard_Real pSAttach = ElCLib::Parameter(theEll,aSAttach);
-
- Standard_Real pSAttachM = pSAttach;
- Standard_Real deltap = pSAttachM - pFAttach;
- if ( deltap < 0 )
- {
- deltap += 2 * M_PI;
- pSAttachM += 2 * M_PI;
- }
- pSAttachM -= pFAttach;
-
- Standard_Real pmiddleout = pSAttachM/2.0 + M_PI;
-
- Standard_Real pcurpos1 = pcurpos;
- // define where curpos lays
- if ( pcurpos1 < pFAttach )
- {
- pcurpos1 = pcurpos1 + 2 * M_PI - pFAttach;
- if ( pcurpos1 > pSAttachM ) // out
- {
- if ( pcurpos1 > pmiddleout ) pcurpos = pFAttach;
- else pcurpos = pSAttach;
- }
- }
- else if ( pcurpos1 > (pFAttach + deltap) ) // out
- {
- pcurpos1 -= pFAttach;
- if ( pcurpos1 > pmiddleout ) pcurpos = pFAttach;
- else pcurpos = pSAttach;
- }
-
- aPosition = ElCLib::Value(pcurpos,theEll);
- return Standard_True;
-}
-// jfa 16/10/2000 end
-
-//=======================================================================
-//function : AIS_IdenticRelation
-//purpose :
-//=======================================================================
-AIS_IdenticRelation::AIS_IdenticRelation(const TopoDS_Shape& FirstShape,
- const TopoDS_Shape& SecondShape,
- const Handle(Geom_Plane)& aPlane)
- :isCircle(Standard_False)
-{
- myFShape = FirstShape;
- mySShape = SecondShape;
- myPlane = aPlane;
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_IdenticRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aprs,
- const Standard_Integer)
-{
- switch ( myFShape.ShapeType() ) {
-
- case TopAbs_VERTEX:
- {
- switch ( mySShape.ShapeType() ) {
- case TopAbs_VERTEX:
- {
- ComputeTwoVerticesPresentation(aprs);
- }
- break;
- case TopAbs_EDGE:
- {
- ComputeOneEdgeOVertexPresentation(aprs);
- }
- break;
- default:
- break;
- }
- }
- break;
-
- case TopAbs_EDGE:
- {
- switch ( mySShape.ShapeType() ) {
- case TopAbs_VERTEX:
- {
- ComputeOneEdgeOVertexPresentation(aprs);
- }
- break;
- case TopAbs_EDGE:
- {
- ComputeTwoEdgesPresentation(aprs);
- }
- break;
- default:
- break;
- }
- }
- break;
- default: break;
- }
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose : function used to compute the selection associated to the
-// "identic" presentation
-// note : if we are in the case of lines, we create a segment between
-// myFAttach and mySAttach. In the case of Circles, we create
-// an arc of circle between the sames points. We Add a segment
-// to link Position to its projection on the curve described
-// before.
-//=======================================================================
-
-void AIS_IdenticRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer)
-{
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
-
- Handle(Select3D_SensitiveSegment) seg;
- // attachement point of the segment linking position to the curve
- gp_Pnt attach;
- Standard_Real confusion (Precision::Confusion());
-
- if ( myFAttach.IsEqual(mySAttach, confusion) )
- {
- attach = myFAttach;
- }
- else
- {
-// jfa 24/10/2000
- if ( myFShape.ShapeType() == TopAbs_EDGE )
- {
- Handle(Geom_Curve) curv1,curv2;
- gp_Pnt firstp1,lastp1,firstp2,lastp2;
- Standard_Boolean isInfinite1,isInfinite2;
- Handle(Geom_Curve) extCurv;
- if ( !AIS::ComputeGeometry(TopoDS::Edge(myFShape),TopoDS::Edge(mySShape),
- myExtShape,curv1,curv2,
- firstp1,lastp1,firstp2,lastp2,
- extCurv,isInfinite1,isInfinite2,myPlane) ) return;
-
- if ( isCircle ) // case of Circles
- {
- Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv1);
- Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),myFAttach);
- Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),mySAttach);
- Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
-
- Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecu);
- aSelection->Add(scurv);
-
- attach = myPosition;
- ComputeAttach(thecirc->Circ(),myFAttach,mySAttach,attach);
- }
- else if ( curv1->IsInstance(STANDARD_TYPE(Geom_Ellipse)) ) // case of ellipses
- {
- Handle(Geom_Ellipse) theEll = Handle(Geom_Ellipse)::DownCast (curv1);
-
- Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),myFAttach);
- Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),mySAttach);
- Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
-
- Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecu);
- aSelection->Add(scurv);
-
- attach = myPosition;
- ComputeAttach(theEll->Elips(),myFAttach,mySAttach,attach);
- }
- else if ( curv1->IsInstance(STANDARD_TYPE(Geom_Line)) ) // case of Lines
- {
- seg = new Select3D_SensitiveSegment(own, myFAttach, mySAttach);
- aSelection->Add(seg);
-
- //attach = projection of Position() on the curve;
- gp_Vec v1 (myFAttach, mySAttach);
- gp_Vec v2 (myFAttach, myPosition);
- if ( v1.IsParallel(v2, Precision::Angular()) )
- {
- attach = mySAttach;
- }
- else
- {
- gp_Lin ll (myFAttach, gp_Dir(v1));
- attach = ElCLib::Value(ElCLib::Parameter(ll,myPosition), ll);
- }
- }
- else return;
- }
-// else if ( myFShape.ShapeType() == TopAbs_VERTEX )
-// {
-// }
-// jfa 24/10/2000 end
- }
-
- // Creation of the segment linking the attachement point with the
- // position
- if ( !attach.IsEqual(myPosition, confusion) )
- {
- seg = new Select3D_SensitiveSegment(own, attach, myPosition);
- aSelection->Add(seg);
- }
-}
-
-//=======================================================================
-//function : ComputeTwoEdgesPresentation
-//purpose :
-//=======================================================================
-void AIS_IdenticRelation::ComputeTwoEdgesPresentation(const Handle(Prs3d_Presentation)& aPrs)
-{
- Handle(Geom_Curve) curv1,curv2;
- gp_Pnt firstp1,lastp1,firstp2,lastp2;
- Standard_Boolean isInfinite1,isInfinite2;
-
- Handle(Geom_Curve) extCurv;
- if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),
- TopoDS::Edge(mySShape),
- myExtShape,
- curv1,
- curv2,
- firstp1,
- lastp1,
- firstp2,
- lastp2,
- extCurv,
- isInfinite1,isInfinite2,
- myPlane))
- return;
- aPrs->SetInfiniteState((isInfinite1 || isInfinite2) && myExtShape != 0);
-
- // Treatement of the case of lines
- if ( curv1->IsInstance(STANDARD_TYPE(Geom_Line)) && curv2->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
- // we take the line curv1 like support
- Handle(Geom_Line) thelin;
- if (isInfinite1 && !isInfinite2) thelin = Handle(Geom_Line)::DownCast (curv2);
- else if (!isInfinite1 && isInfinite2) thelin = Handle(Geom_Line)::DownCast (curv1);
- else thelin = Handle(Geom_Line)::DownCast (curv1);
- ComputeTwoLinesPresentation(aPrs, thelin, firstp1, lastp1, firstp2, lastp2, isInfinite1, isInfinite2);
- }
-
- // Treatement of the case of circles
- else if ( curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) && curv2->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
- //gp_Pnt curpos;
- isCircle = Standard_True; // useful for ComputeSelection
- Handle(Geom_Circle) thecirc (Handle(Geom_Circle)::DownCast (curv1));
- ComputeTwoCirclesPresentation(aPrs, thecirc, firstp1, lastp1, firstp2, lastp2);
- }
-
- // jfa 10/10/2000
- // Treatement of the case of ellipses
- else if ( curv1->IsInstance(STANDARD_TYPE(Geom_Ellipse)) && curv2->IsInstance(STANDARD_TYPE(Geom_Ellipse)) )
- {
- Handle(Geom_Ellipse) theEll (Handle(Geom_Ellipse)::DownCast (curv1));
- ComputeTwoEllipsesPresentation(aPrs, theEll, firstp1, lastp1, firstp2, lastp2);
- }
- // jfa 10/10/2000 end
- else
- return;
-
- // Calculate presentation of projected edges
- if ( (myExtShape != 0) && !extCurv.IsNull()) {
- if (myExtShape == 1 )
- ComputeProjEdgePresentation(aPrs, TopoDS::Edge(myFShape), curv1, firstp1, lastp1);
- else
- ComputeProjEdgePresentation(aPrs, TopoDS::Edge(mySShape), curv2, firstp2, lastp2);
- }
-}
-
-//=======================================================================
-//function : ComputeTwoLinesPresentation
-//purpose : Compute the presentation of the 'identic' constraint
-// between two lines ( which are equal)
-//input : <thelin> : the
-// <firstp1>: first extremity of the 1st curve of the constraint
-// <lastp1> : last extremity of the 1st curve of the constraint
-// <firstp2>: first extremity of the 2nd curve of the constraint
-// <lastp2> :last extremity of the 2nd curve of the constraint
-//=======================================================================
-void AIS_IdenticRelation::ComputeTwoLinesPresentation(const Handle(Prs3d_Presentation)& aPrs,
- const Handle(Geom_Line)& thelin,
- gp_Pnt& firstp1,
- gp_Pnt& lastp1,
- gp_Pnt& firstp2,
- gp_Pnt& lastp2,
- const Standard_Boolean isInfinite1,
- const Standard_Boolean isInfinite2)
-{
- if (isInfinite1 && isInfinite2) {
- if ( myAutomaticPosition ) {
- myFAttach = mySAttach = thelin->Lin().Location();
- gp_Pnt curpos;
- gp_Pln pln(myPlane->Pln());
- gp_Dir dir(pln.XAxis().Direction());
- gp_Vec transvec = gp_Vec(dir)*myArrowSize;
- curpos = myFAttach.Translated(transvec);
- myPosition = curpos;
- myAutomaticPosition = Standard_True;
- }
- else {
- myFAttach = mySAttach = ElCLib::Value(ElCLib::Parameter(thelin->Lin(),myPosition),thelin->Lin());
- }
- TCollection_ExtendedString vals(" ==");
- DsgPrs_IdenticPresentation::Add(aPrs,
- myDrawer,
- vals,
- myFAttach,
- myPosition);
- }
- else {
- // Computation of the parameters of the 4 points on the line <thelin>
- Standard_Real pf1, pf2, pl1, pl2;
-
- pf1 = ElCLib::Parameter(thelin->Lin(), firstp1);
- pl1 = ElCLib::Parameter(thelin->Lin(), lastp1);
-
- pf2 = ElCLib::Parameter(thelin->Lin(), firstp2);
- pl2 = ElCLib::Parameter(thelin->Lin(), lastp2);
-
- if (isInfinite1) {
- pf1 = pf2;
- pl1 = pl2;
- firstp1 = firstp2;
- lastp1 = lastp2;
- }
- else if (isInfinite2) {
- pf2 = pf1;
- pl2 = pl1;
- firstp2 = firstp1;
- lastp2 = lastp1;
- }
-
- Standard_Real tabRang1[4]; // array taht contains the parameters of the 4 points
- // ordered by increasing abscisses.
-
- gp_Pnt tabRang2[4]; // array containing the points corresponding to the
- // parameters in tabRang1
-
- Standard_Integer tabRang3[4]; // array containing the number of the curve( 1 or 2)
- // of which belongs each point of tabRang2
-
- // Filling of the arrays
- tabRang1[0] = pf1; tabRang2[0] = firstp1; tabRang3[0] = 1;
- tabRang1[1] = pf2; tabRang2[1] = firstp2; tabRang3[1] = 2;
- tabRang1[2] = pl1; tabRang2[2] = lastp1; tabRang3[2] = 1;
- tabRang1[3] = pl2; tabRang2[3] = lastp2; tabRang3[3] = 2;
-
- // Sort of the array of parameters (tabRang1)
- AIS_Sort(tabRang1, tabRang2, tabRang3);
-
- // Computation of myFAttach and mySAttach according to the
- // position of the 2 linear edges
- gp_Pnt curpos;
- gp_Pnt middle;
-
- if ( (tabRang1[0] == tabRang1[1]) && (tabRang1[2] == tabRang1[3]) ) {
- middle.SetXYZ((tabRang2[1].XYZ() + tabRang2[2].XYZ())/2. );
- Standard_Real pmiddle = (tabRang1[1] + tabRang1[2]) / 2.;
- Standard_Real delta = (tabRang1[3] - tabRang1[0])/ 5.;
- myFAttach = ElCLib::Value(pmiddle-delta, thelin->Lin());
- mySAttach = ElCLib::Value(pmiddle+delta, thelin->Lin());
- }
-
- else if ( tabRang1[1] == tabRang1[2] ) {
- middle = tabRang2[1];
- Standard_Real delta1 = tabRang1[1] - tabRang1[0];
- Standard_Real delta2 = tabRang1[3] - tabRang1[2];
- if ( delta1 > delta2 ) delta1 = delta2;
- myFAttach = ElCLib::Value(tabRang1[1]-delta1/2., thelin->Lin());
- mySAttach = ElCLib::Value(tabRang1[1]+delta1/2., thelin->Lin());
- }
-
- // Case of 2 disconnected segments -> the symbol completes the gap
- // between the 2 edges
- //--------------------------------
- else if ( (tabRang3[0] == tabRang3[1]) && (tabRang1[1] != tabRang1[2])) {
- middle.SetXYZ((tabRang2[1].XYZ() + tabRang2[2].XYZ())/2. );
- myFAttach = tabRang2[1];
- mySAttach = tabRang2[2];
- }
- else if ( (tabRang3[0] != tabRang3[1])
- && (tabRang3[1] != tabRang3[2]) // Intersection
- && (tabRang1[1] != tabRang1[2]) ) {
- middle.SetXYZ((tabRang2[1].XYZ() + tabRang2[2].XYZ())/2. );
- myFAttach = tabRang2[1];
- mySAttach = tabRang2[2];
- }
- else { // Inclusion
- myFAttach.SetXYZ((tabRang2[0].XYZ() + tabRang2[1].XYZ())/2. );
- mySAttach.SetXYZ((tabRang2[1].XYZ() + tabRang2[2].XYZ())/2. );
- middle.SetXYZ( (myFAttach.XYZ() + mySAttach.XYZ() )/2.);
- }
-
-
- if ( myAutomaticPosition ) {
-
- gp_Vec vtrans(myFAttach, mySAttach);
- vtrans.Normalize();
- vtrans.Cross(gp_Vec(myPlane->Pln().Axis().Direction()));
- vtrans *= ComputeSegSize();
- curpos = middle.Translated(vtrans);
- myPosition = curpos;
- myAutomaticPosition = Standard_True;
- }
-
- else {
-
- curpos = myPosition;
- Standard_Real pcurpos = ElCLib::Parameter(thelin->Lin() ,curpos);
- Standard_Real dist = thelin->Lin().Distance(curpos);
- gp_Pnt proj = ElCLib::Value( pcurpos, thelin->Lin());
- gp_Vec trans;
- Standard_Real confusion(Precision::Confusion());
- if ( dist >= confusion ) {
- trans = gp_Vec(proj, curpos);
- trans.Normalize();
- }
- Standard_Real pf = ElCLib::Parameter(thelin->Lin() ,myFAttach);
- Standard_Real pl = ElCLib::Parameter(thelin->Lin() ,mySAttach);
- if ( pcurpos <= pf ) {
- pcurpos = pf + 1e-5;
- curpos = ElCLib::Value( pcurpos, thelin->Lin());
- if ( dist >= confusion ) curpos.Translate(trans*dist);
- }
- else if ( pcurpos >= pl ) {
- pcurpos = pl - 1e-5;
- curpos = ElCLib::Value( pcurpos, thelin->Lin());
- if ( dist >= confusion ) curpos.Translate(trans*dist);
- }
- SetPosition(curpos);
- }
-
- // Display of the presentation
- TCollection_ExtendedString vals(" ==");
- DsgPrs_IdenticPresentation::Add(aPrs,
- myDrawer,
- vals,
- myFAttach,
- mySAttach,
- curpos);
- }
-}
-
-// jfa 17/10/2000
-//=======================================================================
-//function : ComputeTwoCirclesPresentation
-//purpose : Compute the presentation of the 'identic' constraint
-// between two circles ( which are equal)
-//input : <thecirc>: the circle
-// <firstp1>: first extremity of the 1st curve of the constraint
-// <lastp1> : last extremity of the 1st curve of the constraint
-// <firstp2>: first extremity of the 2nd curve of the constraint
-// <lastp2> :last extremity of the 2nd curve of the constraint
-//=======================================================================
-void AIS_IdenticRelation::ComputeTwoCirclesPresentation(const Handle(Prs3d_Presentation)& aPrs,
- const Handle(Geom_Circle)& thecirc,
- const gp_Pnt& firstp1,
- const gp_Pnt& lastp1,
- const gp_Pnt& firstp2,
- const gp_Pnt& lastp2)
-{
- Standard_Real confusion (Precision::Confusion());
-
- // Searching of complete circles
- Standard_Boolean circ1complete = (firstp1.IsEqual(lastp1, confusion));
- Standard_Boolean circ2complete = (firstp2.IsEqual(lastp2, confusion));
-
- myCenter = thecirc->Location();
- Standard_Real aSegSize = thecirc->Radius()/5.0;
- Standard_Real rad = M_PI / 5.0;
-
- // I. Case of 2 complete circles
- if ( circ1complete && circ2complete )
- {
- if (myAutomaticPosition)
- {
- Standard_Real pfirst1 = ElCLib::Parameter(thecirc->Circ(), firstp1);
- myFAttach = ElCLib::Value(Modulo2PI(pfirst1-rad), thecirc->Circ());
- mySAttach = ElCLib::Value(Modulo2PI(pfirst1+rad), thecirc->Circ());
-
- gp_Pnt curpos = ElCLib::Value(pfirst1,thecirc->Circ());
- gp_Vec vtrans(myCenter, curpos);
- vtrans.Normalize();
- vtrans *= aSegSize;
- curpos.Translate(vtrans);
- myPosition = curpos;
- }
- else ComputeNotAutoCircPresentation(thecirc);
- }
-
- // II. Case of one complete circle and one arc
- else if ( (circ1complete && !circ2complete) || (!circ1complete && circ2complete) )
- {
- gp_Pnt firstp, lastp;
- if ( circ1complete && !circ2complete)
- {
- firstp = firstp2;
- lastp = lastp2;
- }
- else
- {
- firstp = firstp1;
- lastp = lastp1;
- }
-
- if (myAutomaticPosition)
- {
- ComputeAutoArcPresentation(thecirc, firstp, lastp);
- }
- else
- {
- ComputeNotAutoArcPresentation(thecirc, firstp, lastp);
- }
- }
-
- // III and IV. Case of two arcs
- else if ( !circ1complete && !circ2complete )
- {
- // We project all the points on the circle
- Standard_Real pf1, pf2, pl1, pl2;
- pf1 = ElCLib::Parameter(thecirc->Circ(), firstp1);
- pf2 = ElCLib::Parameter(thecirc->Circ(), firstp2);
- pl1 = ElCLib::Parameter(thecirc->Circ(), lastp1);
- pl2 = ElCLib::Parameter(thecirc->Circ(), lastp2);
-
- // III. Arcs with common ends
- // III.1. First of one and last of another
- if ( IsEqual2PI(pl1,pf2,confusion) || IsEqual2PI(pf1,pl2,confusion) )
- {
- gp_Pnt curpos(0.,0.,0.);
- Standard_Real att=0.;
- if ( IsEqual2PI(pl1,pf2,confusion) )
- {
- att = pl1;
- curpos = lastp1;
- }
- else if ( IsEqual2PI(pf1,pl2,confusion) )
- {
- att = pf1;
- curpos = firstp1;
- }
- Standard_Real maxrad = Min(Modulo2PI(pl1 - pf1),Modulo2PI(pl2 - pf2))*3/4;
- if ( rad > maxrad ) rad = maxrad;
- Standard_Real pFAttach = Modulo2PI(att - rad);
- Standard_Real pSAttach = Modulo2PI(att + rad);
- myFAttach = ElCLib::Value(pFAttach, thecirc->Circ());
- mySAttach = ElCLib::Value(pSAttach, thecirc->Circ());
- if ( myAutomaticPosition )
- {
- gp_Vec vtrans(myCenter,curpos);
- vtrans.Normalize();
- vtrans *= aSegSize;
- curpos.Translate(vtrans);
- myPosition = curpos;
- }
- }
- // III.2. Two first or two last
- else if ( IsEqual2PI(pf1,pf2,confusion) || IsEqual2PI(pl1,pl2,confusion) )
- {
- Standard_Real l1 = Modulo2PI(pl1 - pf1);
- Standard_Real l2 = Modulo2PI(pl2 - pf2);
- gp_Pnt firstp,lastp;
- if ( l1 < l2 )
- {
- firstp = firstp1;
- lastp = lastp1;
- }
- else
- {
- firstp = firstp2;
- lastp = lastp2;
- }
-
- if ( myAutomaticPosition )
- {
- ComputeAutoArcPresentation(thecirc, firstp, lastp);
- }
- else
- {
- ComputeNotAutoArcPresentation(thecirc, firstp, lastp);
- }
- }
- // IV. All others arcs (without common ends)
- else
- {
- // order the parameters; first will be pf1
- Standard_Real pl1m = Modulo2PI(pl1 - pf1);
- Standard_Real pf2m = Modulo2PI(pf2 - pf1);
- Standard_Real pl2m = Modulo2PI(pl2 - pf1);
-
- Standard_Boolean case1 = Standard_False;
- // 1 - not intersecting arcs
- // 2 - intersecting arcs, but one doesn't contain another
- // 3a - first arc contains the second one
- // 3b - second arc contains the first one
- // 4 - two intersections
-
- gp_Pnt firstp, lastp;
-
- if ( pl1m < pf2m ) // 1 or 2b or 3b
- {
- if ( pl1m < pl2m ) // 1 or 3b
- {
- if ( pl2m < pf2m ) // 3b
- {
- firstp = firstp1;
- lastp = lastp1;
- }
- else // 1
- {
- case1 = Standard_True;
- Standard_Real deltap1 = Modulo2PI(pf1 - pl2);
- Standard_Real deltap2 = Modulo2PI(pf2 - pl1);
- if ( ((deltap1 < deltap2) && (deltap1 < 2*rad)) ||
- ((deltap2 < deltap1) && (deltap2 > 2*rad)) ) // deltap2
- {
- firstp = lastp1;
- lastp = firstp2;
- }
- else // deltap1
- {
- firstp = lastp2;
- lastp = firstp1;
- }
- }
- }
- else // 2b
- {
- firstp = firstp1;
- lastp = lastp2;
- }
- }
- else // 2a or 3a or 4
- {
- if ( pl1m < pl2m ) // 2a
- {
- firstp = firstp2;
- lastp = lastp1;
- }
- else // 3a or 4
- {
- if ( pl2m > pf2m ) // 3a
- {
- firstp = firstp2;
- lastp = lastp2;
- }
- else // 4
- {
- Standard_Real deltap1 = Modulo2PI(pl1 - pf2);
- Standard_Real deltap2 = Modulo2PI(pl2 - pf1);
- if ( ((deltap1 < deltap2) && (deltap1 < 2*rad)) ||
- ((deltap2 < deltap1) && (deltap2 > 2*rad)) ) // deltap2
- {
- firstp = firstp1;
- lastp = lastp2;
- }
- else // deltap1
- {
- firstp = firstp2;
- lastp = lastp1;
- }
- }
- }
- }
-
- if ( myAutomaticPosition )
- {
- ComputeAutoArcPresentation(thecirc,firstp,lastp,case1);
- }
- else
- {
- if ( case1 )
- {
- myFAttach = firstp;
- mySAttach = lastp;
- }
- else ComputeNotAutoArcPresentation(thecirc, firstp, lastp);
- }
- }
- }
-
- // Display of the presentation
- TCollection_ExtendedString vals(" ==");
- gp_Pnt attach = myPosition;
- ComputeAttach(thecirc->Circ(),myFAttach,mySAttach,attach);
- DsgPrs_IdenticPresentation::Add(aPrs,
- myDrawer,
- vals,
- myPlane->Pln().Position().Ax2(),
- myCenter,
- myFAttach,
- mySAttach,
- myPosition,
- attach);
-}
-
-//=======================================================================
-//function : ComputeAutoArcPresentation
-//purpose : Compute the presentation of the constraint where we are
-// not in the case of dragging.
-//=======================================================================
-void AIS_IdenticRelation::ComputeAutoArcPresentation(const Handle(Geom_Circle)& thecirc,
- const gp_Pnt& firstp,
- const gp_Pnt& lastp,
- const Standard_Boolean isstatic)
-{
- Standard_Real aSegSize = thecirc->Radius()/5.0;
- Standard_Real rad = M_PI / 5.0;
-
- Standard_Real pFA = ElCLib::Parameter(thecirc->Circ(),firstp);
- Standard_Real pSA = ElCLib::Parameter(thecirc->Circ(),lastp);
- Standard_Real maxrad = Modulo2PI(pSA - pFA)/2.0;
-
- if ( (rad > maxrad) || isstatic ) rad = maxrad;
- Standard_Real pmiddle = Modulo2PI(pFA + Modulo2PI(pSA - pFA)/2.0);
-
- myFAttach = ElCLib::Value(Modulo2PI(pmiddle - rad),thecirc->Circ());
- mySAttach = ElCLib::Value(Modulo2PI(pmiddle + rad),thecirc->Circ());
-
- gp_Pnt curpos = ElCLib::Value(pmiddle,thecirc->Circ());
- gp_Vec vtrans(myCenter, curpos);
- vtrans.Normalize();
- vtrans *= aSegSize;
- myPosition = curpos.Translated(vtrans);
-}
-
-//=======================================================================
-//function : ComputeNotAutoCircPresentation
-//purpose : Compute the presentation of the constraint where we are
-// in the case of dragging.
-// Note : This function is to be used only in the case of full circles.
-// The symbol of the constraint moves together with arc
-// representing the constraint around all the circle.
-//=======================================================================
-void AIS_IdenticRelation::ComputeNotAutoCircPresentation(const Handle(Geom_Circle)& thecirc)
-{
- gp_Pnt curpos = myPosition;
-
- Handle(Geom_Circle) cirNotAuto = new Geom_Circle(thecirc->Circ());
-
- // Case of confusion between the current position and the center
- // of the circle -> we move the current position
- Standard_Real confusion (Precision::Confusion());
- if ( myCenter.Distance(curpos) <= confusion )
- {
- gp_Vec vprec(myCenter, myFAttach);
- vprec.Normalize();
- curpos.Translate(vprec*1e-5);
- }
-
- Standard_Real rad = M_PI / 5.0;
- Standard_Real pcurpos = ElCLib::Parameter(cirNotAuto->Circ(),curpos);
- Standard_Real pFAttach = pcurpos - rad;
- Standard_Real pSAttach = pcurpos + rad;
- myFAttach = ElCLib::Value(pFAttach,cirNotAuto->Circ());
- mySAttach = ElCLib::Value(pSAttach,cirNotAuto->Circ());
-}
-
-//=======================================================================
-//function : ComputeNotAutoArcPresentation
-//purpose : Compute the presentation of the constraint where we are
-// in the case of dragging.
-// Note : This function is to be used only in the case of circles.
-// The symbol of the constraint moves only between myFAttach
-// and mySAttach.
-//=======================================================================
-void AIS_IdenticRelation::ComputeNotAutoArcPresentation(const Handle(Geom_Circle)& thecirc,
- const gp_Pnt& pntfirst,
- const gp_Pnt& pntlast)
-{
- gp_Pnt curpos = myPosition;
-
- gp_Circ cirNotAuto = thecirc->Circ();
-
- Standard_Real pFPnt = ElCLib::Parameter(cirNotAuto, pntfirst);
- Standard_Real pSPnt = ElCLib::Parameter(cirNotAuto, pntlast);
- Standard_Real deltap = Modulo2PI(pSPnt - pFPnt)/2.0;
-
- Standard_Real rad = M_PI / 5;
- if ( deltap < rad )
- {
- myFAttach = pntfirst;
- mySAttach = pntlast;
- }
- else
- {
- gp_Pnt aFPnt = ElCLib::Value(Modulo2PI(pFPnt + rad), cirNotAuto);
- gp_Pnt aSPnt = ElCLib::Value(Modulo2PI(pSPnt - rad), cirNotAuto);
-
- ComputeAttach(cirNotAuto,aFPnt,aSPnt,curpos);
-
- Standard_Real pcurpos = ElCLib::Parameter(cirNotAuto,curpos);
- myFAttach = ElCLib::Value(pcurpos - rad, cirNotAuto);
- mySAttach = ElCLib::Value(pcurpos + rad, cirNotAuto);
- }
-}
-// jfa 17/10/2000 end
-
-// jfa 18/10/2000
-//=======================================================================
-//function : ComputeTwoEllipsesPresentation
-//purpose : Compute the presentation of the 'identic' constraint
-// between two ellipses (which are equal)
-//input : <theEll>: the ellipse
-// <firstp1>: first extremity of the 1st curve of the constraint
-// <lastp1> : last extremity of the 1st curve of the constraint
-// <firstp2>: first extremity of the 2nd curve of the constraint
-// <lastp2> :last extremity of the 2nd curve of the constraint
-//=======================================================================
-void AIS_IdenticRelation::ComputeTwoEllipsesPresentation(const Handle(Prs3d_Presentation)& aPrs,
- const Handle(Geom_Ellipse)& theEll,
- const gp_Pnt& firstp1,
- const gp_Pnt& lastp1,
- const gp_Pnt& firstp2,
- const gp_Pnt& lastp2)
-{
- Standard_Real confusion (Precision::Confusion());
-
- // Searching of complete ellipses
- Standard_Boolean circ1complete = (firstp1.IsEqual(lastp1, confusion));
- Standard_Boolean circ2complete = (firstp2.IsEqual(lastp2, confusion));
-
- myCenter = theEll->Location();
- Standard_Real aSegSize = theEll->MajorRadius()/5.0;
- Standard_Real rad = M_PI / 5.0;
-
- // I. Case of 2 complete ellipses
- if ( circ1complete && circ2complete )
- {
- if (myAutomaticPosition)
- {
- Standard_Real pfirst1 = ElCLib::Parameter(theEll->Elips(), firstp1);
- myFAttach = ElCLib::Value(Modulo2PI(pfirst1-rad), theEll->Elips());
- mySAttach = ElCLib::Value(Modulo2PI(pfirst1+rad), theEll->Elips());
-
- gp_Pnt curpos = ElCLib::Value(pfirst1,theEll->Elips());
- gp_Vec vtrans(myCenter, curpos);
- vtrans.Normalize();
- vtrans *= aSegSize;
- curpos.Translate(vtrans);
- myPosition = curpos;
- }
- else ComputeNotAutoElipsPresentation(theEll);
- }
-
- // II. Case of one complete circle and one arc
- else if ( (circ1complete && !circ2complete) || (!circ1complete && circ2complete) )
- {
- gp_Pnt firstp, lastp;
- if ( circ1complete && !circ2complete)
- {
- firstp = firstp2;
- lastp = lastp2;
- }
- else
- {
- firstp = firstp1;
- lastp = lastp1;
- }
-
- if (myAutomaticPosition)
- {
- ComputeAutoArcPresentation(theEll, firstp, lastp);
- }
- else
- {
- ComputeNotAutoArcPresentation(theEll, firstp, lastp);
- }
- }
-
- // III and IV. Case of two arcs
- else if ( !circ1complete && !circ2complete )
- {
- // We project all the points on the circle
- Standard_Real pf1, pf2, pl1, pl2;
- pf1 = ElCLib::Parameter(theEll->Elips(), firstp1);
- pf2 = ElCLib::Parameter(theEll->Elips(), firstp2);
- pl1 = ElCLib::Parameter(theEll->Elips(), lastp1);
- pl2 = ElCLib::Parameter(theEll->Elips(), lastp2);
-
- // III. Arcs with common ends
- // III.1. First of one and last of another
- if ( IsEqual2PI(pl1,pf2,confusion) || IsEqual2PI(pf1,pl2,confusion) )
- {
- gp_Pnt curpos;
- Standard_Real att=0.;
- if ( IsEqual2PI(pl1,pf2,confusion) )
- {
- att = pl1;
- curpos = lastp1;
- }
- else if ( IsEqual2PI(pf1,pl2,confusion) )
- {
- att = pf1;
- curpos = firstp1;
- }
- Standard_Real maxrad = Min(Modulo2PI(pl1 - pf1),Modulo2PI(pl2 - pf2))*3/4;
- if ( rad > maxrad ) rad = maxrad;
- Standard_Real pFAttach = Modulo2PI(att - rad);
- Standard_Real pSAttach = Modulo2PI(att + rad);
- myFAttach = ElCLib::Value(pFAttach, theEll->Elips());
- mySAttach = ElCLib::Value(pSAttach, theEll->Elips());
- if ( myAutomaticPosition )
- {
- gp_Vec vtrans(myCenter,curpos);
- vtrans.Normalize();
- vtrans *= aSegSize;
- curpos.Translate(vtrans);
- myPosition = curpos;
- }
- }
- // III.2. Two first or two last
- else if ( IsEqual2PI(pf1,pf2,confusion) || IsEqual2PI(pl1,pl2,confusion) )
- {
- Standard_Real l1 = Modulo2PI(pl1 - pf1);
- Standard_Real l2 = Modulo2PI(pl2 - pf2);
- gp_Pnt firstp,lastp;
- if ( l1 < l2 )
- {
- firstp = firstp1;
- lastp = lastp1;
- }
- else
- {
- firstp = firstp2;
- lastp = lastp2;
- }
-
- if ( myAutomaticPosition )
- {
- ComputeAutoArcPresentation(theEll, firstp, lastp);
- }
- else
- {
- ComputeNotAutoArcPresentation(theEll, firstp, lastp);
- }
- }
- // IV. All others arcs (without common ends)
- else
- {
- // order the parameters; first will be pf1
- Standard_Real pl1m = Modulo2PI(pl1 - pf1);
- Standard_Real pf2m = Modulo2PI(pf2 - pf1);
- Standard_Real pl2m = Modulo2PI(pl2 - pf1);
-
- Standard_Boolean case1 = Standard_False;
- // 1 - not intersecting arcs
- // 2 - intersecting arcs, but one doesn't contain another
- // 3a - first arc contains the second one
- // 3b - second arc contains the first one
- // 4 - two intersections
-
- gp_Pnt firstp, lastp;
-
- if ( pl1m < pf2m ) // 1 or 2b or 3b
- {
- if ( pl1m < pl2m ) // 1 or 3b
- {
- if ( pl2m < pf2m ) // 3b
- {
- firstp = firstp1;
- lastp = lastp1;
- }
- else // 1
- {
- case1 = Standard_True;
- Standard_Real deltap1 = Modulo2PI(pf1 - pl2);
- Standard_Real deltap2 = Modulo2PI(pf2 - pl1);
- if ( ((deltap1 < deltap2) && (deltap1 < 2*rad)) ||
- ((deltap2 < deltap1) && (deltap2 > 2*rad)) ) // deltap2
- {
- firstp = lastp1;
- lastp = firstp2;
- }
- else // deltap1
- {
- firstp = lastp2;
- lastp = firstp1;
- }
- }
- }
- else // 2b
- {
- firstp = firstp1;
- lastp = lastp2;
- }
- }
- else // 2a or 3a or 4
- {
- if ( pl1m < pl2m ) // 2a
- {
- firstp = firstp2;
- lastp = lastp1;
- }
- else // 3a or 4
- {
- if ( pl2m > pf2m ) // 3a
- {
- firstp = firstp2;
- lastp = lastp2;
- }
- else // 4
- {
- Standard_Real deltap1 = Modulo2PI(pl1 - pf2);
- Standard_Real deltap2 = Modulo2PI(pl2 - pf1);
- if ( ((deltap1 < deltap2) && (deltap1 < 2*rad)) ||
- ((deltap2 < deltap1) && (deltap2 > 2*rad)) ) // deltap2
- {
- firstp = firstp1;
- lastp = lastp2;
- }
- else // deltap1
- {
- firstp = firstp2;
- lastp = lastp1;
- }
- }
- }
- }
-
- if ( myAutomaticPosition )
- {
- ComputeAutoArcPresentation(theEll,firstp,lastp,case1);
- }
- else
- {
- if ( case1 )
- {
- myFAttach = firstp;
- mySAttach = lastp;
- }
- else ComputeNotAutoArcPresentation(theEll, firstp, lastp);
- }
- }
- }
-
- // Display of the presentation
- TCollection_ExtendedString vals(" ==");
- gp_Pnt attach = myPosition;
- ComputeAttach(theEll->Elips(),myFAttach,mySAttach,attach);
- DsgPrs_IdenticPresentation::Add(aPrs,
- myDrawer,
- vals,
- theEll->Elips(),
- myFAttach,
- mySAttach,
- myPosition,
- attach);
-}
-
-//=======================================================================
-//function : ComputeAutoArcPresentation
-//purpose : Compute the presentation of the constraint where we are
-// not in the case of dragging.
-//=======================================================================
-void AIS_IdenticRelation::ComputeAutoArcPresentation(const Handle(Geom_Ellipse)& theEll,
- const gp_Pnt& firstp,
- const gp_Pnt& lastp,
- const Standard_Boolean isstatic)
-{
- Standard_Real aSegSize = theEll->MajorRadius()/5.0;
- Standard_Real rad = M_PI / 5.0;
-
- gp_Elips anEll = theEll->Elips();
-
- Standard_Real pFA = ElCLib::Parameter(anEll,firstp);
- Standard_Real pSA = ElCLib::Parameter(anEll,lastp);
- Standard_Real maxrad = Modulo2PI(pSA - pFA)/2.0;
-
- if ( (rad > maxrad) || isstatic ) rad = maxrad;
- Standard_Real pmiddle = Modulo2PI(pFA + Modulo2PI(pSA - pFA)/2.0);
-
- myFAttach = ElCLib::Value(Modulo2PI(pmiddle - rad),anEll);
- mySAttach = ElCLib::Value(Modulo2PI(pmiddle + rad),anEll);
-
- gp_Pnt curpos = ElCLib::Value(pmiddle,anEll);
- gp_Vec vtrans(myCenter, curpos);
- vtrans.Normalize();
- vtrans *= aSegSize;
- myPosition = curpos.Translated(vtrans);
-}
-
-//=======================================================================
-//function : ComputeNotAutoElipsPresentation
-//purpose : Compute the presentation of the constraint where we are
-// in the case of dragging.
-// Note : This function is to be used only in the case of ellipses.
-// The symbol of the constraint moves only between myFAttach
-// and mySAttach.
-//=======================================================================
-void AIS_IdenticRelation::ComputeNotAutoElipsPresentation(const Handle(Geom_Ellipse)& theEll)
-{
- gp_Pnt curpos = myPosition;
-
- gp_Elips anEll = theEll->Elips();
-
- // Case of confusion between the current position and the center
- // of the ellipse -> we move the current position
- Standard_Real confusion (Precision::Confusion());
- if ( myCenter.Distance(curpos) <= confusion )
- {
- gp_Vec vprec(myCenter, myFAttach);
- vprec.Normalize();
- curpos.Translate(vprec*1e-5);
- }
-
- Standard_Real rad = M_PI / 5.0;
-// Standard_Real pcurpos = ElCLib::Parameter(anEll,curpos);
- GeomAPI_ProjectPointOnCurve aProj (curpos, theEll);
- Standard_Real pcurpos = aProj.LowerDistanceParameter();
-
- Standard_Real pFAttach = pcurpos - rad;
- Standard_Real pSAttach = pcurpos + rad;
- myFAttach = ElCLib::Value(pFAttach,anEll);
- mySAttach = ElCLib::Value(pSAttach,anEll);
-}
-
-//=======================================================================
-//function : ComputeNotAutoArcPresentation
-//purpose : Compute the presentation of the constraint where we are
-// in the case of dragging.
-// Note : This function is to be used only in the case of ellipses.
-// The symbol of the constraint moves only between myFAttach
-// and mySAttach.
-//=======================================================================
-void AIS_IdenticRelation::ComputeNotAutoArcPresentation(const Handle(Geom_Ellipse)& theEll,
- const gp_Pnt& pntfirst,
- const gp_Pnt& pntlast)
-{
- gp_Pnt curpos = myPosition;
-
- gp_Elips anEll = theEll->Elips();
-
- Standard_Real pFPnt = ElCLib::Parameter(anEll, pntfirst);
- Standard_Real pSPnt = ElCLib::Parameter(anEll, pntlast);
- Standard_Real deltap = Modulo2PI(pSPnt - pFPnt)/2.0;
-
- Standard_Real rad = M_PI / 5;
- if ( deltap < rad )
- {
- myFAttach = pntfirst;
- mySAttach = pntlast;
- }
- else
- {
- gp_Pnt aFPnt = ElCLib::Value(Modulo2PI(pFPnt + rad), anEll);
- gp_Pnt aSPnt = ElCLib::Value(Modulo2PI(pSPnt - rad), anEll);
-
- ComputeAttach(anEll,aFPnt,aSPnt,curpos);
-
-// Standard_Real pcurpos = ElCLib::Parameter(anEll,curpos);
- GeomAPI_ProjectPointOnCurve aProj (curpos, theEll);
- Standard_Real pcurpos = aProj.LowerDistanceParameter();
-
- myFAttach = ElCLib::Value(pcurpos - rad, anEll);
- mySAttach = ElCLib::Value(pcurpos + rad, anEll);
- }
-}
-// jfa 18/10/2000 end
-
-//=======================================================================
-//function : ComputeTwoVerticesPresentation
-//purpose :
-//=======================================================================
-void AIS_IdenticRelation::ComputeTwoVerticesPresentation(const Handle(Prs3d_Presentation)& aPrs)
-{
- Standard_Boolean isOnPlane1, isOnPlane2;
- const TopoDS_Vertex& FVertex = TopoDS::Vertex(myFShape);
- const TopoDS_Vertex& SVertex = TopoDS::Vertex(mySShape);
-
- AIS::ComputeGeometry(FVertex, myFAttach, myPlane, isOnPlane1);
- AIS::ComputeGeometry(SVertex, mySAttach, myPlane, isOnPlane2);
-
- if (isOnPlane1 && isOnPlane2)
- myExtShape = 0;
- else if ( isOnPlane1 && !isOnPlane2)
- myExtShape = 2;
- else if (!isOnPlane1 && isOnPlane2)
- myExtShape = 1;
- else
- return ;
-
-
- // The attachement points are the points themselves that must be
- //identical
- myFAttach = BRep_Tool::Pnt(FVertex);
- mySAttach = myFAttach;
-
- gp_Pnt curpos;
- if (myAutomaticPosition)
- {
- //Computation of the size of the symbol
- Standard_Real symbsize = ComputeSegSize();
- if (symbsize <= Precision::Confusion()) symbsize = 1.;
- symbsize*=5;
- // Computation of the direction of the segment of the presentation
- // we take the median of the edges connected to vertices
- gp_Dir dF, dS;
- gp_Dir myDir;
- TColStd_ListIteratorOfListOfTransient it(Users());
- if (it.More())
- {
- Handle(AIS_Shape) USER (Handle(AIS_Shape)::DownCast(it.Value()));
- if (!USER.IsNull())
- {
- const TopoDS_Shape& SH =USER->Shape();
- if ( (!SH.IsNull()) && (SH.ShapeType() == TopAbs_WIRE) )
- {
- const TopoDS_Wire& WIRE = TopoDS::Wire(USER->Shape());
- Standard_Boolean done = ComputeDirection(WIRE,FVertex,dF);
- if (!done) return;
- done = ComputeDirection(WIRE,SVertex,dS);
- if (!done) return;
- }
- else return;
- }
- else return;
-
- // computation of the segment direction like average
- // of the 2 computed directions.
- if ( dF.IsParallel(dS, Precision::Angular()) )
- {
- myDir = dF.Crossed(myPlane->Pln().Axis().Direction());
- }
- else
- {
- myDir.SetXYZ(dF.XYZ() + dS.XYZ());
- }
- curpos = myFAttach.Translated(gp_Vec(myDir)*symbsize) ;
- }
-// jfa 11/10/2000
- else
- {
- curpos = myFAttach;
- }
-// jfa 11/10/2000 end
-
- myPosition = curpos;
- myAutomaticPosition = Standard_False;
- }
- else
- {
- curpos = myPosition;
- }
-
- // Presentation computation
- TCollection_ExtendedString vals(" ++");
- DsgPrs_IdenticPresentation::Add(aPrs,
- myDrawer,
- vals,
- myFAttach,
- curpos);
- // Calculate the projection of vertex
- if ( myExtShape == 1)
- ComputeProjVertexPresentation(aPrs,FVertex,myFAttach);
- else if ( myExtShape == 2)
- ComputeProjVertexPresentation(aPrs,SVertex,mySAttach);
-}
-
-
-
-//=======================================================================
-//function : ComputeSegSize
-//purpose :
-//=======================================================================
-Standard_Real AIS_IdenticRelation::ComputeSegSize() const
-{
- return 1.;
-}
-
-//=======================================================================
-//function : ComputeDirection
-//purpose : Compute a direction according to the different geometric
-// elements connected to the vertex <VERT>, in way to not have
-// overlap between the symbol and them.
-//=======================================================================
-Standard_Boolean AIS_IdenticRelation::ComputeDirection(const TopoDS_Wire& aWire,
- const TopoDS_Vertex& VERT,
- gp_Dir& dF) const
-{
- // we take the median of the edges connected to vertices
- TopoDS_Edge edg1,edg2;
- ConnectedEdges(aWire,VERT,edg1,edg2);
-
- if ( edg1.IsNull() && edg2.IsNull() ) {
- return Standard_False;
- }
-
- Handle(Geom_Curve) curv1,curv2;
- gp_Pnt firstp1,lastp1,firstp2,lastp2;
-
- // Case with 2 edges connected to the vertex <VERT>
- if ( !edg1.IsNull() && !edg2.IsNull() ) {
- if ( !AIS::ComputeGeometry(edg1,edg2,
- curv1,curv2,
- firstp1, lastp1,
- firstp2, lastp2,myPlane))
- return Standard_False;
-
- gp_Dir d1, d2;
- if ( curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
- d1 = ComputeCircleDirection(Handle(Geom_Circle)::DownCast (curv1), VERT);
- }
- else if (curv1->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
- d1 = ComputeLineDirection(Handle(Geom_Line)::DownCast (curv1), firstp1);
- }
- else
- return Standard_False;
-
- if ( curv2->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
- d2 = ComputeCircleDirection( Handle(Geom_Circle)::DownCast (curv2), VERT);
- }
- else if (curv2->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
- d2 =ComputeLineDirection( Handle(Geom_Line)::DownCast (curv2), firstp2);
- }
- else
- return Standard_False;
-
- if ( !d1.IsParallel(d2, Precision::Angular() ))
- dF.SetXYZ( (d1.XYZ() + d2.XYZ())/2 );
- else {
- dF= d1.Crossed(myPlane->Pln().Axis().Direction());
- }
- }
-
- // Case where <VERT> is at an extremity of a wire.
- else {
- TopoDS_Edge VEdge;
- if ( !edg1.IsNull() )
- VEdge = edg1;
- else if (!edg2.IsNull() )
- VEdge = edg2;
- else
- return Standard_False;
-
- if ( !AIS::ComputeGeometry(VEdge, curv1, firstp1, lastp1) )
- return Standard_False;
- if ( curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
- dF = ComputeCircleDirection( Handle(Geom_Circle)::DownCast (curv1), VERT);
- }
- else if (curv1->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
- dF = ComputeLineDirection( Handle(Geom_Line)::DownCast (curv1), firstp1);
- }
- else
- return Standard_False;
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputeLineDirection
-//purpose :
-//=======================================================================
-gp_Dir AIS_IdenticRelation::ComputeLineDirection(const Handle(Geom_Line)& lin,
- const gp_Pnt& firstP) const
-{
- gp_Dir dir;
- dir = lin->Lin().Direction();
- if ( !myFAttach.IsEqual(firstP, Precision::Confusion()) )
- dir.Reverse();
- return dir;
-}
-
-//=======================================================================
-//function : ComputeCircleDirection
-//purpose :
-//=======================================================================
-gp_Dir AIS_IdenticRelation::ComputeCircleDirection(const Handle(Geom_Circle)& circ,
- const TopoDS_Vertex& VERT) const
-{
- gp_Vec V(circ->Location(),BRep_Tool::Pnt(VERT));
- return gp_Dir(V);
-}
-
-//=======================================================================
-//function : ComputeOneEdgeOVertexPresentation
-//purpose :
-//=======================================================================
-void AIS_IdenticRelation::ComputeOneEdgeOVertexPresentation(const Handle(Prs3d_Presentation)& aPrs)
-{
- TopoDS_Vertex V;
- TopoDS_Edge E;
- Standard_Integer numedge;
-
- if (myFShape.ShapeType() == TopAbs_VERTEX) {
- V = TopoDS::Vertex(myFShape);
- E = TopoDS::Edge(mySShape);
- numedge = 2;// edge = 2nd shape
- }
- else {
- V = TopoDS::Vertex(mySShape);
- E = TopoDS::Edge(myFShape);
- numedge = 1; // edge = 1st shape
- }
- gp_Pnt ptonedge1,ptonedge2;
- Handle(Geom_Curve) aCurve;
- Handle(Geom_Curve) extCurv;
- Standard_Boolean isInfinite;
- Standard_Boolean isOnPlanEdge, isOnPlanVertex;
- if (!AIS::ComputeGeometry(E,aCurve,ptonedge1,ptonedge2,extCurv,isInfinite,isOnPlanEdge,myPlane))
- return;
- aPrs->SetInfiniteState(isInfinite);
- AIS::ComputeGeometry(V, myFAttach, myPlane, isOnPlanVertex);
-
- // only the curve can be projected
- if (!isOnPlanEdge && !isOnPlanVertex) return;
-
- if (!isOnPlanEdge) {
- if (numedge == 1) myExtShape = 1;
- else myExtShape = 2;
- }
- else if (!isOnPlanVertex) {
- if (numedge == 1) myExtShape = 2;
- else myExtShape = 1;
- }
- // The attachement points are the point
- myFAttach = BRep_Tool::Pnt(V);
- mySAttach = myFAttach;
-
- gp_Pnt curpos;
- if (myAutomaticPosition) {
- //Computation of the size of the symbol
- Standard_Real symbsize = ComputeSegSize();
- symbsize*=5;
- // Computation of the direction of the segment of the presentation
- // we take the median of the edges connected to vertices
- gp_Dir myDir;
- if ( aCurve->IsKind(STANDARD_TYPE(Geom_Line))) {
- myDir = Handle(Geom_Line)::DownCast (aCurve)->Lin().Direction();
- myDir.Cross(myPlane->Pln().Axis().Direction());
- }
- else if (aCurve->IsKind(STANDARD_TYPE(Geom_Circle))) {
- Handle(Geom_Circle) CIR = Handle(Geom_Circle)::DownCast (aCurve);
- myDir.SetXYZ(myFAttach.XYZ() - CIR->Location().XYZ());
- }
- // jfa 10/10/2000
- else if (aCurve->IsKind(STANDARD_TYPE(Geom_Ellipse))) {
- Handle(Geom_Ellipse) CIR = Handle(Geom_Ellipse)::DownCast (aCurve);
- myDir.SetXYZ(myFAttach.XYZ() - CIR->Location().XYZ());
- }
- // jfa 10/10/2000 end
-
- curpos = myFAttach.Translated(gp_Vec(myDir)*symbsize) ;
- myPosition = curpos;
- myAutomaticPosition = Standard_True;
- }
- else {
- curpos = myPosition;
- }
-
- // Presentation computation
- TCollection_ExtendedString vals(" -+-");
- DsgPrs_IdenticPresentation::Add(aPrs,
- myDrawer,
- vals,
- myFAttach,
- curpos);
- if (myExtShape != 0) {
- if (!extCurv.IsNull()) { // the edge is not in the WP
- ComputeProjEdgePresentation(aPrs,E,Handle(Geom_Line)::DownCast (aCurve),ptonedge1,ptonedge2);
- }
- }
-}
+++ /dev/null
-// Created on: 1997-03-03
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_IdenticRelation_HeaderFile
-#define _AIS_IdenticRelation_HeaderFile
-
-#include <AIS_Relation.hxx>
-#include <gp_Pnt.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <TColStd_ListOfTransient.hxx>
-
-class TopoDS_Shape;
-class Geom_Plane;
-class Geom_Line;
-class gp_Pnt;
-class Geom_Circle;
-class Geom_Ellipse;
-class TopoDS_Wire;
-class TopoDS_Vertex;
-class gp_Dir;
-
-DEFINE_STANDARD_HANDLE(AIS_IdenticRelation, AIS_Relation)
-
-//! Constructs a constraint by a relation of identity
-//! between two or more datums figuring in shape
-//! Interactive Objects.
-class AIS_IdenticRelation : public AIS_Relation
-{
-
-public:
-
- //! Initializes the relation of identity between the two
- //! entities, FirstShape and SecondShape. The plane
- //! aPlane is initialized in case a visual reference is
- //! needed to show identity.
- Standard_EXPORT AIS_IdenticRelation(const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& aPlane);
-
- Standard_Boolean HasUsers() const { return !myUsers.IsEmpty(); }
-
- const TColStd_ListOfTransient& Users() const { return myUsers; }
-
- void AddUser (const Handle(Standard_Transient)& theUser) { myUsers.Append (theUser); }
-
- void ClearUsers() { myUsers.Clear(); }
-
- //! Returns true if the interactive object is movable.
- virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
-
- DEFINE_STANDARD_RTTIEXT(AIS_IdenticRelation,AIS_Relation)
-
-private:
-
-
- Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeOneEdgeOVertexPresentation (const Handle(Prs3d_Presentation)& aPresentation);
-
- Standard_EXPORT void ComputeTwoEdgesPresentation (const Handle(Prs3d_Presentation)& aPresentation);
-
- Standard_EXPORT void ComputeTwoLinesPresentation (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Geom_Line)& aLin, gp_Pnt& Pnt1On1, gp_Pnt& Pnt2On1, gp_Pnt& Pnt1On2, gp_Pnt& Pnt2On2, const Standard_Boolean isInf1, const Standard_Boolean isInf2);
-
- Standard_EXPORT void ComputeTwoCirclesPresentation (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Geom_Circle)& aCircle, const gp_Pnt& Pnt1On1, const gp_Pnt& Pnt2On1, const gp_Pnt& Pnt1On2, const gp_Pnt& Pnt2On2);
-
- //! Computes the presentation of the identic constraint
- //! between 2 arcs in the case of automatic presentation
- Standard_EXPORT void ComputeAutoArcPresentation (const Handle(Geom_Circle)& aCircle, const gp_Pnt& firstp, const gp_Pnt& lastp, const Standard_Boolean isstatic = Standard_False);
-
- //! Computes the presentation of the identic constraint
- //! between 2 circles in the case of non automatic presentation
- Standard_EXPORT void ComputeNotAutoCircPresentation (const Handle(Geom_Circle)& aCircle);
-
- //! Computes the presentation of the identic constraint
- //! between 2 arcs in the case of non automatic presentation
- Standard_EXPORT void ComputeNotAutoArcPresentation (const Handle(Geom_Circle)& aCircle, const gp_Pnt& pntfirst, const gp_Pnt& pntlast);
-
- Standard_EXPORT void ComputeTwoEllipsesPresentation (const Handle(Prs3d_Presentation)& aPrs, const Handle(Geom_Ellipse)& anEll, const gp_Pnt& Pnt1On1, const gp_Pnt& Pnt2On1, const gp_Pnt& Pnt1On2, const gp_Pnt& Pnt2On2);
-
- //! Computes the presentation of the identic constraint
- //! between 2 arcs in the case of automatic presentation
- Standard_EXPORT void ComputeAutoArcPresentation (const Handle(Geom_Ellipse)& theEll, const gp_Pnt& firstp, const gp_Pnt& lastp, const Standard_Boolean isstatic = Standard_False);
-
- //! Computes the presentation of the identic constraint
- //! between 2 ellipses in the case of non automatic presentation
- Standard_EXPORT void ComputeNotAutoElipsPresentation (const Handle(Geom_Ellipse)& theEll);
-
- //! Computes the presentation of the identic constraint
- //! between 2 arcs in the case of non automatic presentation
- Standard_EXPORT void ComputeNotAutoArcPresentation (const Handle(Geom_Ellipse)& theEll, const gp_Pnt& pntfirst, const gp_Pnt& pntlast);
-
- Standard_EXPORT void ComputeTwoVerticesPresentation (const Handle(Prs3d_Presentation)& aPresentation);
-
- Standard_EXPORT Standard_Real ComputeSegSize() const;
-
- Standard_EXPORT Standard_Boolean ComputeDirection (const TopoDS_Wire& aWire, const TopoDS_Vertex& aVertex, gp_Dir& aDir) const;
-
- Standard_EXPORT gp_Dir ComputeLineDirection (const Handle(Geom_Line)& aLin, const gp_Pnt& anExtremity) const;
-
- Standard_EXPORT gp_Dir ComputeCircleDirection (const Handle(Geom_Circle)& aCirc, const TopoDS_Vertex& ConnectedVertex) const;
-
-private:
-
- TColStd_ListOfTransient myUsers;
- Standard_Boolean isCircle;
- gp_Pnt myFAttach;
- gp_Pnt mySAttach;
- gp_Pnt myCenter;
-
-};
-
-#endif // _AIS_IdenticRelation_HeaderFile
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_KindOfDimension_HeaderFile
-#define _AIS_KindOfDimension_HeaderFile
-
-//! Declares the kinds of dimensions needed in the
-//! display of Interactive Objects.
-enum AIS_KindOfDimension
-{
-AIS_KOD_NONE,
-AIS_KOD_LENGTH,
-AIS_KOD_PLANEANGLE,
-AIS_KOD_SOLIDANGLE,
-AIS_KOD_AREA,
-AIS_KOD_VOLUME,
-AIS_KOD_MASS,
-AIS_KOD_TIME,
-AIS_KOD_RADIUS,
-AIS_KOD_DIAMETER,
-AIS_KOD_CHAMF2D,
-AIS_KOD_CHAMF3D,
-AIS_KOD_OFFSET,
-AIS_KOD_ELLIPSERADIUS
-};
-
-#endif // _AIS_KindOfDimension_HeaderFile
+++ /dev/null
-// Created on: 2016-11-25
-// Copyright (c) 2016 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_KindOfRelation_HeaderFile
-#define _AIS_KindOfRelation_HeaderFile
-
-enum AIS_KindOfRelation
-{
- AIS_KOR_NONE = 0,
- AIS_KOR_CONCENTRIC,
- AIS_KOR_EQUALDISTANCE,
- AIS_KOR_EQUALRADIUS,
- AIS_KOR_FIX,
- AIS_KOR_IDENTIC,
- AIS_KOR_OFFSET,
- AIS_KOR_PARALLEL,
- AIS_KOR_PERPENDICULAR,
- AIS_KOR_TANGENT,
- AIS_KOR_SYMMETRIC
-};
-
-#endif
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_KindOfSurface_HeaderFile
-#define _AIS_KindOfSurface_HeaderFile
-
-
-enum AIS_KindOfSurface
-{
-AIS_KOS_Plane,
-AIS_KOS_Cylinder,
-AIS_KOS_Cone,
-AIS_KOS_Sphere,
-AIS_KOS_Torus,
-AIS_KOS_Revolution,
-AIS_KOS_Extrusion,
-AIS_KOS_OtherSurface
-};
-
-#endif // _AIS_KindOfSurface_HeaderFile
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_KindOfUnit_HeaderFile
-#define _AIS_KindOfUnit_HeaderFile
-
-//! Declares the type of Interactive Object unit.
-enum AIS_KindOfUnit
-{
-AIS_TOU_LENGTH,
-AIS_TOU_SURFACE,
-AIS_TOU_VOLUME,
-AIS_TOU_PLANE_ANGLE,
-AIS_TOU_SOLID_ANGLE,
-AIS_TOU_MASS,
-AIS_TOU_FORCE,
-AIS_TOU_TIME
-};
-
-#endif // _AIS_KindOfUnit_HeaderFile
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Arnaud BOUZY/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2013 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AIS_LengthDimension.hxx>
-
-#include <AIS.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepExtrema_DistShapeShape.hxx>
-#include <BRepLib_MakeVertex.hxx>
-#include <BRepTopAdaptor_FClass2d.hxx>
-#include <BRepTools.hxx>
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <gce_MakeDir.hxx>
-#include <gce_MakePln.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <GeomAPI_ExtremaCurveCurve.hxx>
-#include <GeomAPI_ExtremaSurfaceSurface.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_Line.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension,AIS_Dimension)
-
-//=======================================================================
-//function : Constructor
-//purpose : Dimension between two faces
-//=======================================================================
-AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace)
-: AIS_Dimension (AIS_KOD_LENGTH),
- myHasCustomDirection (Standard_False)
-{
- SetMeasuredGeometry (theFirstFace, theSecondFace);
- SetFlyout (15.0);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : Dimension between two shape
-//=======================================================================
-AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
- const TopoDS_Edge& theEdge)
-: AIS_Dimension (AIS_KOD_LENGTH),
- myHasCustomDirection (Standard_False)
-{
- SetMeasuredGeometry (theFace, theEdge);
- SetFlyout (15.0);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : Dimension between two points
-//=======================================================================
-AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const gp_Pln& thePlane)
-: AIS_Dimension (AIS_KOD_LENGTH),
- myHasCustomDirection (Standard_False)
-{
- SetMeasuredGeometry (theFirstPoint, theSecondPoint, thePlane);
- SetFlyout (15.0);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : Dimension between two shape
-//=======================================================================
-AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
- const TopoDS_Shape& theSecondShape,
- const gp_Pln& thePlane)
-: AIS_Dimension (AIS_KOD_LENGTH),
- myHasCustomDirection (Standard_False)
-{
- SetCustomPlane (thePlane);
- SetMeasuredShapes (theFirstShape, theSecondShape);
- SetFlyout (15.0);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : Dimension of one edge
-//=======================================================================
-AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
- const gp_Pln& thePlane)
-: AIS_Dimension (AIS_KOD_LENGTH),
- myHasCustomDirection (Standard_False)
-{
- SetMeasuredGeometry (theEdge, thePlane);
- SetFlyout (15.0);
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-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;
- SetCustomPlane (thePlane);
- myIsGeometryValid = IsValidPoints (theFirstPoint, theSecondPoint);
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::SetMeasuredGeometry (const TopoDS_Edge& theEdge,
- const gp_Pln& thePlane)
-{
- myFirstShape = theEdge;
- mySecondShape = TopoDS_Shape();
- myGeometryType = GeometryType_Edge;
- SetCustomPlane (thePlane);
- myIsGeometryValid = InitOneShapePoints (myFirstShape);
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
- const TopoDS_Face& theSecondFace)
-{
- SetMeasuredShapes (theFirstFace, theSecondFace);
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::SetMeasuredGeometry (const TopoDS_Face& theFace,
- const TopoDS_Edge& theEdge)
-{
- SetMeasuredShapes (theFace, theEdge);
-}
-
-//=======================================================================
-//function : SetMeasuredShapes
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::SetMeasuredShapes (const TopoDS_Shape& theFirstShape,
- const TopoDS_Shape& theSecondShape)
-{
- gp_Pln aComputedPlane;
- Standard_Boolean isPlaneReturned = Standard_False;
-
- myFirstShape = theFirstShape;
- mySecondShape = theSecondShape;
- myIsGeometryValid = InitTwoShapesPoints (myFirstShape, mySecondShape, aComputedPlane, isPlaneReturned);
-
- if (myIsGeometryValid && !myIsPlaneCustom)
- {
- if (isPlaneReturned)
- {
- myPlane = aComputedPlane;
- }
- else
- {
- myIsGeometryValid = Standard_False;
- }
- }
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : CheckPlane
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_LengthDimension::CheckPlane (const gp_Pln& thePlane) const
-{
- Standard_Boolean anIsFaultyNormal =
- thePlane.Axis().Direction().IsParallel(gce_MakeDir (myFirstPoint, mySecondPoint), Precision::Angular());
-
- if ((!thePlane.Contains (myFirstPoint, Precision::Confusion()) && !thePlane.Contains (mySecondPoint, Precision::Confusion()))
- || anIsFaultyNormal)
- {
- return Standard_False;
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : ComputePlane
-//purpose :
-//=======================================================================
-gp_Pln AIS_LengthDimension::ComputePlane (const gp_Dir& theAttachDir) const
-{
- if (!IsValidPoints (myFirstPoint, mySecondPoint))
- {
- return gp_Pln();
- }
-
- gp_Pnt aThirdPoint (myFirstPoint.Translated (gp_Vec(theAttachDir)));
- gce_MakePln aPlaneConstrustor (myFirstPoint, mySecondPoint, aThirdPoint);
- return aPlaneConstrustor.Value();
-}
-
-//=======================================================================
-//function : GetModelUnits
-//purpose :
-//=======================================================================
-const TCollection_AsciiString& AIS_LengthDimension::GetModelUnits() const
-{
- return myDrawer->DimLengthModelUnits();
-}
-
-//=======================================================================
-//function : GetDisplayUnits
-//purpose :
-//=======================================================================
-const TCollection_AsciiString& AIS_LengthDimension::GetDisplayUnits() const
-{
- return myDrawer->DimLengthDisplayUnits();
-}
-
-//=======================================================================
-//function : SetModelUnits
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::SetModelUnits (const TCollection_AsciiString& theUnits)
-{
- myDrawer->SetDimLengthModelUnits (theUnits);
-}
-
-//=======================================================================
-//function : SetDisplayUnits
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
-{
- myDrawer->SetDimLengthDisplayUnits (theUnits);
-}
-
-//=======================================================================
-//function : ComputeValue
-//purpose :
-//=======================================================================
-Standard_Real AIS_LengthDimension::ComputeValue() const
-{
- if (!IsValid())
- return 0.0;
-
- if (!myHasCustomDirection)
- return myFirstPoint.Distance (mySecondPoint);
-
- return fabs (gp_Vec(myFirstPoint, mySecondPoint).Dot (myDirection));
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode)
-{
- mySelectionGeom.Clear (theMode);
-
- if (!IsValid())
- {
- return;
- }
-
- DrawLinearDimension (thePresentation, theMode, myFirstPoint, mySecondPoint);
-}
-
- //=======================================================================
-//function : ComputeFlyoutLinePoints
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
- gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint)
-{
- if (!myHasCustomDirection)
- {
- AIS_Dimension::ComputeFlyoutLinePoints (theFirstPoint, theSecondPoint, theLineBegPoint, theLineEndPoint);
- return;
- }
-
- // find scalar of projection target vector (from start to second point) to flyout vector
- gp_Ax1 aPlaneNormal = GetPlane().Axis();
- gp_Vec aFlyoutNormalizedDir(aPlaneNormal.Direction() ^ myDirection);
- aFlyoutNormalizedDir.Normalize();
- Standard_Real aTargetProjectedToFlyout = gp_Vec(theFirstPoint, theSecondPoint).Dot (aFlyoutNormalizedDir);
-
- gp_Dir aFlyoutVector = aFlyoutNormalizedDir;
- // create lines for layouts
- gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
- gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
-
- // Get flyout end points
- theLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout() + aTargetProjectedToFlyout, aLine1);
- theLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
-}
-
-//=======================================================================
-//function : ComputeFlyoutSelection
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Handle(SelectMgr_EntityOwner)& theEntityOwner)
-{
- if (!IsValid())
- {
- return;
- }
-
- ComputeLinearFlyouts (theSelection, theEntityOwner, myFirstPoint, mySecondPoint);
-}
-
-//=======================================================================
-//function : IsValidPoints
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_LengthDimension::IsValidPoints (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint) const
-{
- return theFirstPoint.Distance (theSecondPoint) > Precision::Confusion();
-}
-
-//=======================================================================
-//function : InitTwoEdgesLength
-//purpose : Initialization of dimension between two linear edges
-//=======================================================================
-Standard_Boolean AIS_LengthDimension::InitTwoEdgesLength (const TopoDS_Edge& theFirstEdge,
- const TopoDS_Edge& theSecondEdge,
- gp_Dir& theDirAttach)
-{
- BRepAdaptor_Curve aFirstCurveAdapt (theFirstEdge);
- if (aFirstCurveAdapt.GetType() != GeomAbs_Line)
- {
- return Standard_False;
- }
-
- BRepAdaptor_Curve aSecondCurveAdapt (theSecondEdge);
- if (aSecondCurveAdapt.GetType() != GeomAbs_Line)
- {
- return Standard_False;
- }
-
- Handle(Geom_Curve) aFirstCurve;
- Handle(Geom_Curve) aSecondCurve;
-
- gp_Pnt aPoint11 (gp::Origin());
- gp_Pnt aPoint12 (gp::Origin());
- gp_Pnt aPoint21 (gp::Origin());
- gp_Pnt aPoint22 (gp::Origin());
- Standard_Boolean isFirstInfinite = Standard_False;
- Standard_Boolean isSecondInfinite = Standard_False;
-
- if (!AIS::ComputeGeometry (theFirstEdge, theSecondEdge,
- aFirstCurve, aSecondCurve,
- aPoint11, aPoint12,
- aPoint21, aPoint22,
- isFirstInfinite,
- isSecondInfinite))
- {
- return Standard_False;
- }
-
- const Handle(Geom_Line) aFirstLine = Handle(Geom_Line)::DownCast (aFirstCurve);
- const Handle(Geom_Line) aSecondLine = Handle(Geom_Line)::DownCast (aSecondCurve);
-
- if (!aFirstLine->Lin().Direction().IsParallel (aSecondLine->Lin().Direction(),Precision::Angular()))
- {
- return Standard_False;
- }
-
- theDirAttach = aFirstLine->Lin().Direction();
-
- gp_Pnt aPoint;
-
- if (!isFirstInfinite)
- {
- if (AIS::Nearest (aSecondCurve, aPoint11, aPoint21, aPoint22, aPoint))
- {
- myFirstPoint = aPoint11;
- mySecondPoint = aPoint;
- return IsValidPoints (myFirstPoint, mySecondPoint);
- }
- else if (AIS::Nearest (aSecondCurve, aPoint12, aPoint21, aPoint22, aPoint))
- {
- myFirstPoint = aPoint12;
- mySecondPoint = aPoint;
- return IsValidPoints (myFirstPoint, mySecondPoint);
- }
- }
-
- if (!isSecondInfinite)
- {
- if (AIS::Nearest (aFirstCurve, aPoint21, aPoint11, aPoint12, aPoint))
- {
- myFirstPoint = aPoint;
- mySecondPoint = aPoint21;
- return IsValidPoints (myFirstPoint, mySecondPoint);
- }
- if (AIS::Nearest (aFirstCurve, aPoint22, aPoint11, aPoint12, aPoint))
- {
- myFirstPoint = aPoint;
- mySecondPoint = aPoint22;
- return IsValidPoints (myFirstPoint, mySecondPoint);
- }
- }
-
- GeomAPI_ExtremaCurveCurve anExtrema (aFirstCurve, aSecondCurve);
- anExtrema.NearestPoints (myFirstPoint, mySecondPoint);
- return IsValidPoints (myFirstPoint, mySecondPoint);
-}
-
-//=======================================================================
-//function : InitEdgeVertexLength
-//purpose : for first edge and second vertex shapes
-//=======================================================================
-Standard_Boolean AIS_LengthDimension::InitEdgeVertexLength (const TopoDS_Edge& theEdge,
- const TopoDS_Vertex& theVertex,
- gp_Dir& theEdgeDir,
- Standard_Boolean isInfinite)
-{
- gp_Pnt anEdgePoint1 (gp::Origin());
- gp_Pnt anEdgePoint2 (gp::Origin());
- Handle(Geom_Curve) aCurve;
-
- if (!AIS::ComputeGeometry (theEdge, aCurve, anEdgePoint1, anEdgePoint2, isInfinite))
- {
- return Standard_False;
- }
-
- myFirstPoint = BRep_Tool::Pnt (theVertex);
-
- Handle(Geom_Line) aGeomLine (Handle(Geom_Line)::DownCast (aCurve));
- const gp_Lin& aLin = aGeomLine->Lin();
-
- // Get direction of edge to build plane automatically.
- theEdgeDir = aLin.Direction();
-
- mySecondPoint = AIS::Nearest (aLin, myFirstPoint);
-
- return IsValidPoints (myFirstPoint, mySecondPoint);
-}
-
-//=======================================================================
-//function : InitEdgeFaceLength
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_LengthDimension::InitEdgeFaceLength (const TopoDS_Edge& theEdge,
- const TopoDS_Face& theFace,
- gp_Dir& theEdgeDir)
-{
- theEdgeDir = gp::DX();
-
- // Find attachment points (closest distance between the edge and the face)
- BRepExtrema_DistShapeShape aDistAdaptor (theEdge, theFace, Extrema_ExtFlag_MIN);
- if (!aDistAdaptor.IsDone() || aDistAdaptor.NbSolution() <1)
- {
- return Standard_False;
- }
- myFirstPoint = aDistAdaptor.PointOnShape1 (1);
- mySecondPoint = aDistAdaptor.PointOnShape2 (1);
-
- // Take direction for dimension line (will be orthogonalized later) parallel to edge
- BRepAdaptor_Curve aCurveAdaptor (theEdge);
- Standard_Real aParam;
- if (aDistAdaptor.SupportOnShape1 (1).ShapeType() == TopAbs_EDGE)
- {
- aDistAdaptor.ParOnEdgeS1 (1, aParam);
- }
- else
- {
- Standard_Real aD1 = aCurveAdaptor.Value(aCurveAdaptor.FirstParameter()).SquareDistance (myFirstPoint);
- Standard_Real aD2 = aCurveAdaptor.Value(aCurveAdaptor.LastParameter()).SquareDistance (myFirstPoint);
- aParam = (aD1 < aD2 ? aCurveAdaptor.FirstParameter() : aCurveAdaptor.LastParameter());
- }
- gp_Pnt aP;
- gp_Vec aV;
- aCurveAdaptor.D1 (aParam, aP, aV);
- if (aV.SquareMagnitude() > gp::Resolution())
- {
- theEdgeDir = aV;
- }
-
- // reverse direction if parameter is close to the end of the curve,
- // to reduce chances to have overlapping between dimension line and edge
- if (Abs (aParam - aCurveAdaptor.FirstParameter()) < Abs (aParam - aCurveAdaptor.LastParameter()))
- {
- theEdgeDir.Reverse();
- }
-
- return IsValidPoints (myFirstPoint, mySecondPoint);
-}
-
-//=======================================================================
-//function : InitTwoShapesPoints
-//purpose : Initialization of two points where dimension layouts
-// will be attached
-//=======================================================================
-Standard_Boolean AIS_LengthDimension::InitTwoShapesPoints (const TopoDS_Shape& theFirstShape,
- const TopoDS_Shape& theSecondShape,
- gp_Pln& theComputedPlane,
- Standard_Boolean& theIsPlaneComputed)
-{
- theIsPlaneComputed = Standard_False;
- gp_Dir aDirAttach;
- Standard_Boolean isInfinite = Standard_False;
- Standard_Boolean isSuccess = Standard_False;
- switch (theFirstShape.ShapeType())
- {
- case TopAbs_FACE:
- {
- // Initialization for face
- gp_Pln aFirstPlane;
- Handle(Geom_Surface) aFirstSurface;
- AIS_KindOfSurface aFirstSurfKind;
- Standard_Real aFirstOffset;
-
- TopoDS_Face aFirstFace = TopoDS::Face (theFirstShape);
-
- AIS::InitFaceLength (TopoDS::Face (theFirstShape),
- aFirstPlane,
- aFirstSurface,
- aFirstSurfKind,
- aFirstOffset);
-
- if (theSecondShape.ShapeType() == TopAbs_FACE)
- {
- // Initialization for face
- myGeometryType = GeometryType_Faces;
- gp_Pln aSecondPlane;
- Handle(Geom_Surface) aSecondSurface;
- AIS_KindOfSurface aSecondSurfKind;
- Standard_Real aSecondOffset;
-
- TopoDS_Face aSecondFace = TopoDS::Face (theSecondShape);
-
- AIS::InitFaceLength (aSecondFace,
- aSecondPlane,
- aSecondSurface,
- aSecondSurfKind,
- aSecondOffset);
-
- if (aFirstSurfKind == AIS_KOS_Plane)
- {
- if (!aFirstPlane.Axis().Direction().IsParallel (aSecondPlane.Axis().Direction(), Precision::Angular()))
- {
- return Standard_False;
- }
-
- TopExp_Explorer anExplorer (theFirstShape, TopAbs_VERTEX);
-
- // In case of infinite planes
- if (!anExplorer.More())
- {
- myFirstPoint = aFirstPlane.Location();
- }
- else
- {
- myFirstPoint = BRep_Tool::Pnt (TopoDS::Vertex (anExplorer.Current()));
- }
-
- mySecondPoint = AIS::ProjectPointOnPlane (myFirstPoint, aSecondPlane);
-
- Standard_Real anU, aV;
- ElSLib::Parameters (aSecondPlane, mySecondPoint, anU, aV);
-
- BRepTopAdaptor_FClass2d aClassifier (aSecondFace, Precision::Confusion());
- TopAbs_State aState = aClassifier.Perform (gp_Pnt2d (anU, aV), Standard_False);
-
- if (aState == TopAbs_OUT || aState == TopAbs_UNKNOWN)
- {
- mySecondPoint = AIS::Nearest (aSecondFace, myFirstPoint);
- }
-
- isSuccess = IsValidPoints (myFirstPoint, mySecondPoint);
- if (isSuccess)
- {
- theComputedPlane = ComputePlane (aFirstPlane.Position().XDirection());
- theIsPlaneComputed = Standard_True;
- }
- }
- else // curvilinear faces
- {
- Standard_Real aU1Min, aV1Min, aU1Max, aV1Max;
- Standard_Real aU2Min, aV2Min, aU2Max, aV2Max;
- BRepTools::UVBounds (aFirstFace, aU1Min, aU1Max, aV1Min, aV1Max);
- BRepTools::UVBounds (aSecondFace, aU2Min, aU2Max, aV2Min, aV2Max);
-
- GeomAPI_ExtremaSurfaceSurface anExtrema (aFirstSurface, aSecondSurface,
- aU1Min, aU1Max, aV1Min, aV1Max,
- aU2Min, aU2Max, aV2Min, aV2Max);
-
- Standard_Real aU1, aV1, aU2, aV2;
- anExtrema.LowerDistanceParameters (aU1, aV1, aU2, aV2);
- myFirstPoint = BRep_Tool::Surface (aFirstFace)->Value (aU1, aV1);
- mySecondPoint = BRep_Tool::Surface (aSecondFace)->Value (aU2, aV2);
-
- // Adjust automatic plane
- gp_Ax2 aLocalAxes (myFirstPoint, gce_MakeDir (myFirstPoint, mySecondPoint));
- aDirAttach = gce_MakeDir (aLocalAxes.XDirection ());
-
- // Check points
- isSuccess = IsValidPoints (myFirstPoint, mySecondPoint);
- if (isSuccess)
- {
- theComputedPlane = ComputePlane (aDirAttach);
- theIsPlaneComputed = Standard_True;
- }
- }
-
- return isSuccess && IsValidPoints (myFirstPoint, mySecondPoint);
- }
- else if (theSecondShape.ShapeType() == TopAbs_EDGE)
- {
- myGeometryType = GeometryType_EdgeFace;
- isSuccess = InitEdgeFaceLength (TopoDS::Edge (theSecondShape),
- TopoDS::Face (theFirstShape),
- aDirAttach);
-
- if (isSuccess)
- {
- theComputedPlane = ComputePlane (aDirAttach);
- theIsPlaneComputed = Standard_True;
- }
-
- return isSuccess;
- }
- }
- break;
-
- case TopAbs_EDGE:
- {
- if (theSecondShape.ShapeType() == TopAbs_VERTEX)
- {
- myGeometryType = GeometryType_EdgeVertex;
- isSuccess = InitEdgeVertexLength (TopoDS::Edge (theFirstShape),
- TopoDS::Vertex (theSecondShape),
- aDirAttach,
- isInfinite);
-
- if (isSuccess)
- {
- theComputedPlane = ComputePlane (aDirAttach);
- theIsPlaneComputed = Standard_True;
- }
-
- return isSuccess;
- }
- else if (theSecondShape.ShapeType() == TopAbs_EDGE)
- {
- myGeometryType = GeometryType_Edges;
- isSuccess = InitTwoEdgesLength (TopoDS::Edge (theFirstShape),
- TopoDS::Edge (theSecondShape),
- aDirAttach);
-
- if (isSuccess)
- {
- theComputedPlane = ComputePlane (aDirAttach);
- theIsPlaneComputed = Standard_True;
- }
-
- return isSuccess;
- }
- else if (theSecondShape.ShapeType() == TopAbs_FACE)
- {
- myGeometryType = GeometryType_EdgeFace;
- isSuccess = InitEdgeFaceLength (TopoDS::Edge (theFirstShape),
- TopoDS::Face (theSecondShape),
- aDirAttach);
-
- if (isSuccess)
- {
- theComputedPlane = ComputePlane (aDirAttach);
- theIsPlaneComputed = Standard_True;
- }
-
- return isSuccess;
- }
- }
- break;
-
- case TopAbs_VERTEX:
- {
- if (theSecondShape.ShapeType() == TopAbs_VERTEX)
- {
- myGeometryType = GeometryType_Points;
- myFirstPoint = BRep_Tool::Pnt (TopoDS::Vertex (theFirstShape));
- mySecondPoint = BRep_Tool::Pnt (TopoDS::Vertex (theSecondShape));
-
- return IsValidPoints (myFirstPoint, mySecondPoint);
- }
- else if (theSecondShape.ShapeType() == TopAbs_EDGE)
- {
- myGeometryType = GeometryType_EdgeVertex;
- isSuccess = InitEdgeVertexLength (TopoDS::Edge(theSecondShape),
- TopoDS::Vertex(theFirstShape),
- aDirAttach,
- isInfinite);
- if (isSuccess)
- {
- theComputedPlane = ComputePlane (aDirAttach);
- theIsPlaneComputed = Standard_True;
- }
-
- return isSuccess;
- }
- }
- break;
-
- case TopAbs_COMPOUND:
- case TopAbs_COMPSOLID:
- case TopAbs_SOLID:
- case TopAbs_SHELL:
- case TopAbs_WIRE:
- case TopAbs_SHAPE:
- break;
- }
-
- return Standard_False;
-}
-
-//=======================================================================
-//function : InitOneShapePoints
-//purpose : Initialization of two points where dimension layouts
-// will be attached
-// Attention: 1) <theShape> can be only the edge in currect implementation
-// 2) No length for infinite edge
-//=======================================================================
-Standard_Boolean AIS_LengthDimension::InitOneShapePoints (const TopoDS_Shape& theShape)
-{
- if (theShape.ShapeType() != TopAbs_EDGE)
- {
- return Standard_False;
- }
-
- TopoDS_Edge anEdge = TopoDS::Edge (theShape);
-
- BRepAdaptor_Curve aBrepCurve(anEdge);
- Standard_Real aFirst = aBrepCurve.FirstParameter();
- Standard_Real aLast = aBrepCurve.LastParameter();
-
- if (aBrepCurve.GetType() != GeomAbs_Line)
- {
- return Standard_False;
- }
-
- Standard_Boolean isInfinite = (Precision::IsInfinite (aFirst) || Precision::IsInfinite (aLast));
- if (isInfinite)
- {
- return Standard_False;
- }
-
- myFirstPoint = aBrepCurve.Value (aBrepCurve.FirstParameter());
- mySecondPoint = aBrepCurve.Value (aBrepCurve.LastParameter());
-
- return IsValidPoints (myFirstPoint, mySecondPoint);
-}
-
-//=======================================================================
-//function : GetTextPosition
-//purpose :
-//=======================================================================
-const gp_Pnt AIS_LengthDimension::GetTextPosition() const
-{
- if (IsTextPositionCustom())
- {
- return myFixedTextPosition;
- }
-
- // Counts text position according to the dimension parameters
- return GetTextPositionForLinear (myFirstPoint, mySecondPoint);
-}
-
-//=======================================================================
-//function : SetTextPosition
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::SetTextPosition (const gp_Pnt& theTextPos)
-{
- if (!IsValid())
- {
- return;
- }
-
- myIsTextPositionFixed = Standard_True;
- myFixedTextPosition = theTextPos;
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetDirection
-//purpose :
-//=======================================================================
-void AIS_LengthDimension::SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection)
-{
- myHasCustomDirection = theUseDirection;
- if (myHasCustomDirection)
- myDirection = theDirection;
-}
+++ /dev/null
-// Copyright (c) 1999-2013 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_LengthDimension_HeaderFile
-#define _AIS_LengthDimension_HeaderFile
-
-#include <AIS.hxx>
-#include <AIS_Dimension.hxx>
-#include <AIS_KindOfDimension.hxx>
-#include <Geom_Plane.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
-
-DEFINE_STANDARD_HANDLE (AIS_LengthDimension, AIS_Dimension)
-
-//! 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:
-
- //! 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);
-
- //! 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 Standard_OVERRIDE;
-
- //! @return the model units string.
- Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
-
- Standard_EXPORT virtual const gp_Pnt GetTextPosition() const Standard_OVERRIDE;
-
- //! Set custom direction for dimension. If it is not set, the direction is obtained
- //! from the measured geometry (e.g. line between points of dimension)
- //! The direction does not change flyout direction of dimension.
- //! @param theDirection [in] the dimension direction.
- //! @param theUseDirection [in] boolean value if custom direction should be used.
- Standard_EXPORT void SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection = Standard_True);
-
-public:
-
- DEFINE_STANDARD_RTTIEXT(AIS_LengthDimension,AIS_Dimension)
-
-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_OVERRIDE;
-
- Standard_EXPORT virtual gp_Pln ComputePlane(const gp_Dir& theAttachDir) const;
-
- //! Computes distance between dimension points. If custom direction is defined, the distance
- //! is a projection value of the distance between points to this direction
- //! @return dimension value
- Standard_EXPORT Standard_Real ComputeValue() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode = 0) Standard_OVERRIDE;
-
- //! Computes points bounded the flyout line for linear dimension.
- //! Direction of flyout line equal to the custom direction of dimension if defined or
- //! parallel to the main direction line
- //! @param theFirstPoint [in] the first attach point of linear dimension.
- //! @param theSecondPoint [in] the second attach point of linear dimension.
- //! @param theLineBegPoint [out] the first attach point of linear dimension.
- //! @param theLineEndPoint [out] the second attach point of linear dimension.
- Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
- gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
-
-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:
-
- gp_Pnt myFirstPoint;
- gp_Pnt mySecondPoint;
- TopoDS_Shape myFirstShape;
- TopoDS_Shape mySecondShape;
- gp_Dir myDirection;
- Standard_Boolean myHasCustomDirection;
-};
-
-#endif // _AIS_LengthDimension_HeaderFile
+++ /dev/null
-// Created on: 1998-01-23
-// Created by: Sergey ZARITCHNY
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_EllipseRadiusDimension.hxx>
-#include <AIS_MaxRadiusDimension.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <DsgPrs_EllipseRadiusPresentation.hxx>
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_OffsetCurve.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
-#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_Transformation.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <Precision.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Prs3d_Text.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_ConstructionError.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_MaxRadiusDimension,AIS_EllipseRadiusDimension)
-
-//=======================================================================
-//function : AIS_MaxRadiusDimension
-//purpose :
-//=======================================================================
-AIS_MaxRadiusDimension::AIS_MaxRadiusDimension(const TopoDS_Shape& aShape,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText)
-:AIS_EllipseRadiusDimension(aShape, aText)
-{
- myVal = aVal;
- mySymbolPrs = DsgPrs_AS_LASTAR;
- myAutomaticPosition = Standard_True;
- myArrowSize = myVal / 100.;
-}
-
-//=======================================================================
-//function : AIS_MaxRadiusDimension
-//purpose :
-//=======================================================================
-
-AIS_MaxRadiusDimension::AIS_MaxRadiusDimension(const TopoDS_Shape& aShape,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText,
- const gp_Pnt& aPosition,
- const DsgPrs_ArrowSide aSymbolPrs,
- const Standard_Real anArrowSize)
-:AIS_EllipseRadiusDimension(aShape, aText)
-{
- myVal = aVal;
- mySymbolPrs = aSymbolPrs;
- myPosition = aPosition;
- myAutomaticPosition = Standard_False;
- SetArrowSize( anArrowSize );
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-
-void AIS_MaxRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer /*aMode*/)
-{
-// if( myAutomaticPosition )
- {//ota : recompute in any case
- ComputeGeometry();
- myEllipse.SetMajorRadius(myVal);
- gp_Vec v1(myEllipse.XAxis().Direction());
- v1 *=myVal;
- myApexP = myEllipse.Location().Translated(v1);
- myApexN = myEllipse.Location().Translated(-v1);
- }
- if(myIsAnArc) ComputeArcOfEllipse(aPresentation);
- else
- ComputeEllipse(aPresentation);
-}
-
-//=======================================================================
-//function : ComputeEllipse
-//purpose :
-//=======================================================================
-
-void AIS_MaxRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aPresentation)
-{
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
-
- // size
- if( !myArrowSizeIsDefined ) {
- myArrowSize = Min(myArrowSize,myVal / 5.);
- }
- arr->SetLength(myArrowSize);
-
- Standard_Real U;//,V;
- gp_Pnt curPos, Center;
- Center = myEllipse.Location();
- if( myAutomaticPosition )
- {
- myPosition = Center;
- myEndOfArrow = myApexP;
- myAutomaticPosition = Standard_True;
-
- if ( myIsSetBndBox )
- myPosition = AIS::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
- myBndBox );
- curPos = myPosition;
- }
- else //!AutomaticPosition
- {
- curPos = myPosition;
- gp_Lin L1(myEllipse.XAxis());
- U = ElCLib::Parameter ( L1, curPos );
- curPos = ElCLib::Value (U, L1);
- if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
- myEndOfArrow = myApexP ;
- else
- myEndOfArrow = myApexN ;
- }
-
- // Presenatation
- DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, curPos,
- myEndOfArrow, Center, Standard_True, mySymbolPrs);
-
-}
-
-//=======================================================================
-//function : ComputeArcOfEllipse
-//purpose :
-//=======================================================================
-
-void AIS_MaxRadiusDimension::ComputeArcOfEllipse(const Handle(Prs3d_Presentation)& aPresentation)
-{
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
-
- // size
- if( !myArrowSizeIsDefined ) {
- myArrowSize = Min(myArrowSize,myVal / 5.);
- }
- arr->SetLength(myArrowSize);
-
- Standard_Real par;
- gp_Pnt curPos, Center;
- Center = myEllipse.Location();
- Standard_Boolean IsInDomain = Standard_True;
- if( myAutomaticPosition )
- {
- myEndOfArrow = AIS::NearestApex(myEllipse, myApexP, myApexN,
- myFirstPar, myLastPar, IsInDomain);
- myPosition = Center;
- myAutomaticPosition = Standard_True;
- if ( myIsSetBndBox )
- myPosition = AIS::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
- myBndBox );
- curPos = myPosition;
- }
- else //!AutomaticPosition
- {
- curPos = myPosition;
-// ElSLib::Parameters ( myPlane->Pln(), curPos, U, V );
-// curPos = ElSLib::Value (U, V, myPlane->Pln());
- gp_Lin L1(myEllipse.XAxis());
- par = ElCLib::Parameter ( L1, curPos );
- curPos = ElCLib::Value (par, L1);
- if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
- myEndOfArrow = myApexP ;
- else
- myEndOfArrow = myApexN ;
- par = ElCLib::Parameter ( myEllipse, myEndOfArrow );
- IsInDomain = AIS::InDomain( myFirstPar, myLastPar, par );
- myPosition = curPos;
- }
-
-// Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
- Standard_Real parStart = 0.;
- if( !IsInDomain )
- {
- if(AIS::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
- AIS::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
- parStart = myFirstPar;
- else
- parStart = myLastPar;
- }
- if(!myIsOffset)
- DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myEllipse,
- curPos, myEndOfArrow, Center, parStart, IsInDomain,
- Standard_True, mySymbolPrs);
- else
- DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myOffsetCurve,
- curPos, myEndOfArrow, Center, parStart, IsInDomain,
- Standard_True, mySymbolPrs);
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-
-void AIS_MaxRadiusDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer /*aMode*/)
-{
-
- gp_Pnt center = myEllipse.Location();
- gp_Pnt AttachmentPoint = myPosition;
- Standard_Real dist = center.Distance(AttachmentPoint);
- Standard_Real aRadius = myVal;
- //Standard_Real inside = Standard_False;
- gp_Pnt pt1;
- if (dist > aRadius) pt1 = AttachmentPoint;
- else
- pt1 = myEndOfArrow;
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
- Handle(Select3D_SensitiveSegment)
- seg = new Select3D_SensitiveSegment(own, center , pt1);
- aSelection->Add(seg);
-
- // Text
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
- AttachmentPoint.X(),
- AttachmentPoint.Y(),
- AttachmentPoint.Z(),
- AttachmentPoint.X()+size,
- AttachmentPoint.Y()+size,
- AttachmentPoint.Z()+size);
- aSelection->Add(box);
-
- // Arc of Ellipse
- if(myIsAnArc)
- {
-
- Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
- if(!AIS::InDomain(myFirstPar, myLastPar, parEnd))
- {
- Standard_Real parStart, par;
- if(AIS::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
- AIS::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
- par = myFirstPar;
- else
- par = myLastPar;
- gp_Vec Vapex(center, ElCLib::Value( parEnd, myEllipse )) ;
- gp_Vec Vpnt (center, ElCLib::Value( par, myEllipse )) ;
- gp_Dir dir(Vpnt ^ Vapex);
- if(myEllipse.Position().Direction().IsOpposite( dir, Precision::Angular())) {
- parStart = parEnd;
- parEnd = par;
- }
- else
- parStart = par;
-
- Handle(Geom_Curve)TrimCurve;
- if(myIsOffset)
- {
- Handle(Geom_Curve) aCurve = myOffsetCurve;
- TrimCurve = new Geom_TrimmedCurve( aCurve, parStart, parEnd );
- }
- else
- {
- Handle(Geom_Ellipse) Ellipse = new Geom_Ellipse( myEllipse );
- TrimCurve = new Geom_TrimmedCurve( Ellipse, parStart, parEnd );
- }
- Handle( Select3D_SensitiveCurve ) SensArc;
- SensArc = new Select3D_SensitiveCurve( own, TrimCurve );
- aSelection->Add( SensArc );
- }
- }
-
-}
+++ /dev/null
-// Created on: 1998-01-22
-// Created by: Sergey ZARITCHNY
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_MaxRadiusDimension_HeaderFile
-#define _AIS_MaxRadiusDimension_HeaderFile
-
-#include <AIS_EllipseRadiusDimension.hxx>
-#include <DsgPrs_ArrowSide.hxx>
-
-DEFINE_STANDARD_HANDLE(AIS_MaxRadiusDimension, AIS_EllipseRadiusDimension)
-
-//! Ellipse Max radius dimension of a Shape which can be Edge
-//! or Face (planar or cylindrical(surface of extrusion or
-//! surface of offset))
-class AIS_MaxRadiusDimension : public AIS_EllipseRadiusDimension
-{
- DEFINE_STANDARD_RTTIEXT(AIS_MaxRadiusDimension, AIS_EllipseRadiusDimension)
-public:
-
- //! Max Ellipse radius dimension
- //! Shape can be edge , planar face or cylindrical face
- Standard_EXPORT AIS_MaxRadiusDimension(const TopoDS_Shape& aShape, const Standard_Real aVal, const TCollection_ExtendedString& aText);
-
- //! Max Ellipse radius dimension with position
- //! Shape can be edge , planar face or cylindrical face
- Standard_EXPORT AIS_MaxRadiusDimension(const TopoDS_Shape& aShape, const Standard_Real aVal, const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.0);
-
-private:
-
- Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeEllipse (const Handle(Prs3d_Presentation)& aPresentation);
-
- Standard_EXPORT void ComputeArcOfEllipse (const Handle(Prs3d_Presentation)& aPresentation);
-
- gp_Pnt myApexP;
- gp_Pnt myApexN;
- gp_Pnt myEndOfArrow;
-
-};
-
-#endif // _AIS_MaxRadiusDimension_HeaderFile
+++ /dev/null
-// Created on: 2000-10-20
-// Created by: Julia DOROVSKIKH
-// Copyright (c) 2000-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_MidPointRelation.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <DsgPrs_MidPointPresentation.hxx>
-#include <ElCLib.hxx>
-#include <gce_MakeLin.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Circ.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Elips.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <Precision.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_MidPointRelation,AIS_Relation)
-
-//=======================================================================
-//function : AIS_MidPointRelation
-//purpose :
-//=======================================================================
-AIS_MidPointRelation::AIS_MidPointRelation(const TopoDS_Shape& aMidPointTool,
- const TopoDS_Shape& FirstShape,
- const TopoDS_Shape& SecondShape,
- const Handle(Geom_Plane)& aPlane)
-:AIS_Relation(),
- myTool(aMidPointTool)
-{
- SetFirstShape(FirstShape);
- SetSecondShape(SecondShape);
- SetPlane(aPlane);
- myPosition = aPlane->Pln().Location();
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aprs,
- const Standard_Integer)
-{
- if (myTool.ShapeType() == TopAbs_VERTEX)
- {
- gp_Pnt pp;
- Standard_Boolean isonplane;
- if ( AIS::ComputeGeometry(TopoDS::Vertex(myTool),pp,myPlane,isonplane) )
- {
- if ( !isonplane ) ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myTool),pp);
- }
- myMidPoint = pp;
- }
- else return;
-
- if ( myAutomaticPosition ) myPosition = myMidPoint;
-
- switch (myFShape.ShapeType())
- {
- case TopAbs_FACE :
- {
- ComputeFaceFromPnt(aprs, Standard_True);
- }
- break;
- case TopAbs_EDGE :
- {
- ComputeEdgeFromPnt(aprs, Standard_True);
- }
- break;
- case TopAbs_VERTEX :
- {
- ComputeVertexFromPnt(aprs, Standard_True);
- }
- break;
- default:
- break;
- }
-
- switch (mySShape.ShapeType())
- {
- case TopAbs_FACE :
- {
- ComputeFaceFromPnt(aprs, Standard_False);
- }
- break;
- case TopAbs_EDGE :
- {
- ComputeEdgeFromPnt(aprs, Standard_False);
- }
- break;
- case TopAbs_VERTEX :
- {
- ComputeVertexFromPnt(aprs, Standard_False);
- }
- break;
- default:
- break;
- }
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
- const Standard_Integer)
-{
- Handle(Select3D_SensitiveSegment) seg;
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
-
- if ( !myMidPoint.IsEqual(myFAttach,Precision::Confusion()) )
- {
- // segment from mid point to the first geometry
- seg = new Select3D_SensitiveSegment(own,myFAttach,myMidPoint);
- aSel->Add(seg);
- // segment from mid point to the second geometry
- seg = new Select3D_SensitiveSegment(own,mySAttach,myMidPoint);
- aSel->Add(seg);
- }
- if ( !myMidPoint.IsEqual(myPosition,Precision::Confusion()) )
- {
- // segment from mid point to the text position
- seg = new Select3D_SensitiveSegment(own,myMidPoint,myPosition);
- aSel->Add(seg);
- }
-
- // center of the symmetry - circle around the MidPoint
- gp_Ax2 ax = myPlane->Pln().Position().Ax2();
- ax.SetLocation(myMidPoint);
- Standard_Real rad = myFAttach.Distance(myMidPoint)/20.0;
- gp_Circ aCircleM (ax,rad);
- Handle(Geom_Curve) thecir = new Geom_Circle(aCircleM);
- Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecir);
- aSel->Add(scurv);
-
- Handle(Geom_Curve) curv;
- gp_Pnt firstp,lastp;
- Standard_Boolean isInfinite,isOnPlane;
- Handle(Geom_Curve) extCurv;
-
- // segment on first curve
- if ( myFShape.ShapeType() == TopAbs_EDGE )
- {
- TopoDS_Edge E = TopoDS::Edge(myFShape);
- if ( !AIS::ComputeGeometry(E,curv,firstp,lastp,extCurv,isInfinite,isOnPlane,myPlane) ) return;
- if ( curv->IsInstance(STANDARD_TYPE(Geom_Line)) ) // case of line
- {
- // segment on line
- seg = new Select3D_SensitiveSegment(own,myFirstPnt1,myFirstPnt2);
- aSel->Add(seg);
- }
- else if ( curv->IsInstance(STANDARD_TYPE(Geom_Circle)) ) // case of circle
- {
- // segment on circle
- Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv);
- Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),myFirstPnt1);
- Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),myFirstPnt2);
- Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
-
- scurv = new Select3D_SensitiveCurve(own, thecu);
- aSel->Add(scurv);
- }
- else if ( curv->IsInstance(STANDARD_TYPE(Geom_Ellipse)) ) // case of ellipse
- {
- // segment on ellipse
- Handle(Geom_Ellipse) theEll = Handle(Geom_Ellipse)::DownCast (curv);
- Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),myFirstPnt1);
- Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),myFirstPnt2);
- Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
-
- scurv = new Select3D_SensitiveCurve(own, thecu);
- aSel->Add(scurv);
- }
- }
-
- // segment on second curve
- if ( mySShape.ShapeType() == TopAbs_EDGE )
- {
- TopoDS_Edge E = TopoDS::Edge(mySShape);
- if ( !AIS::ComputeGeometry(E,curv,firstp,lastp,extCurv,isInfinite,isOnPlane,myPlane) ) return;
- if ( curv->IsInstance(STANDARD_TYPE(Geom_Line)) ) // case of line
- {
- // segment on line
- seg = new Select3D_SensitiveSegment(own,mySecondPnt1,mySecondPnt2);
- aSel->Add(seg);
- }
- else if ( curv->IsInstance(STANDARD_TYPE(Geom_Circle)) ) // case of circle
- {
- // segment on circle
- Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv);
- Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),mySecondPnt1);
- Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),mySecondPnt2);
- Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
-
- scurv = new Select3D_SensitiveCurve(own, thecu);
- aSel->Add(scurv);
- }
- else if ( curv->IsInstance(STANDARD_TYPE(Geom_Ellipse)) ) // case of ellipse
- {
- // segment on ellipse
- Handle(Geom_Ellipse) theEll = Handle(Geom_Ellipse)::DownCast (curv);
- Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),mySecondPnt1);
- Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),mySecondPnt2);
- Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
-
- scurv = new Select3D_SensitiveCurve(own, thecu);
- aSel->Add(scurv);
- }
- }
-}
-
-//=======================================================================
-//function : ComputeFaceFromPnt
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::ComputeFaceFromPnt(const Handle(Prs3d_Presentation)&,
- const Standard_Boolean /*first*/)
-{
-}
-
-//=======================================================================
-//function : ComputeEdgeFromPnt
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::ComputeEdgeFromPnt(const Handle(Prs3d_Presentation)& aprs,
- const Standard_Boolean first)
-{
- TopoDS_Edge E;
- if ( first ) E = TopoDS::Edge(myFShape);
- else E = TopoDS::Edge(mySShape);
-
- Handle(Geom_Curve) geom;
- gp_Pnt ptat1,ptat2;
- Handle(Geom_Curve) extCurv;
- Standard_Boolean isInfinite,isOnPlane;
- if ( !AIS::ComputeGeometry(E, geom, ptat1, ptat2, extCurv, isInfinite, isOnPlane, myPlane) ) return;
-
- gp_Ax2 ax = myPlane->Pln().Position().Ax2();
-
- if ( geom->IsInstance(STANDARD_TYPE(Geom_Line)) )
- {
- if ( !isInfinite ) ComputePointsOnLine(ptat1,ptat2,first);
- else
- {
- const gp_Lin& line = Handle(Geom_Line)::DownCast (geom)->Lin();
- ComputePointsOnLine(line,first);
- }
- if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,
- myFAttach,myFirstPnt1,myFirstPnt2,first);
- else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,
- mySAttach,mySecondPnt1,mySecondPnt2,first);
- }
- else if ( geom->IsInstance(STANDARD_TYPE(Geom_Circle)) )
- {
- Handle(Geom_Circle) geom_cir (Handle(Geom_Circle)::DownCast (geom));
- gp_Circ circ (geom_cir->Circ());
- ComputePointsOnCirc(circ,ptat1,ptat2,first);
- if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,circ,myMidPoint,myPosition,
- myFAttach,myFirstPnt1,myFirstPnt2,first);
- else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,circ,myMidPoint,myPosition,
- mySAttach,mySecondPnt1,mySecondPnt2,first);
- }
- else if ( geom->IsInstance(STANDARD_TYPE(Geom_Ellipse)) )
- {
- Handle(Geom_Ellipse) geom_ell (Handle(Geom_Ellipse)::DownCast (geom));
- gp_Elips elips (geom_ell->Elips());
- ComputePointsOnElips(elips,ptat1,ptat2,first);
- if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,elips,myMidPoint,myPosition,
- myFAttach,myFirstPnt1,myFirstPnt2,first);
- else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,elips,myMidPoint,myPosition,
- mySAttach,mySecondPnt1,mySecondPnt2,first);
- }
- else return;
-
- // projection on myPlane
- if ( !isOnPlane ) ComputeProjEdgePresentation(aprs,E,geom,ptat1,ptat2);
-}
-
-//=======================================================================
-//function : ComputeVertexFromPnt
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::ComputeVertexFromPnt(const Handle(Prs3d_Presentation)& aprs,
- const Standard_Boolean first)
-{
- gp_Ax2 ax = myPlane->Pln().Position().Ax2();
- if ( first )
- {
- Standard_Boolean isOnPlane;
- TopoDS_Vertex V = TopoDS::Vertex(myFShape);
- AIS::ComputeGeometry(V, myFAttach, myPlane, isOnPlane);
- DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,myFAttach,first);
- if ( !isOnPlane ) ComputeProjVertexPresentation(aprs,V,myFAttach);
- }
- else
- {
- Standard_Boolean isOnPlane;
- TopoDS_Vertex V = TopoDS::Vertex(mySShape);
- AIS::ComputeGeometry(V, mySAttach, myPlane, isOnPlane);
- DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,mySAttach,first);
- if ( !isOnPlane ) ComputeProjVertexPresentation(aprs,V,mySAttach);
- }
-}
-
-//=======================================================================
-//function : ComputePointsOnLine
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::ComputePointsOnLine(const gp_Lin& aLin,
- const Standard_Boolean first)
-{
- Standard_Real ppar = ElCLib::Parameter(aLin,myMidPoint);
- gp_Pnt anAttach = ElCLib::Value(ppar,aLin);
-
- Standard_Real dist = anAttach.Distance(myMidPoint)/10.0;
- if ( dist < Precision::Confusion() ) dist = 10.0;
-
- Standard_Real fpar = ppar + dist;
- Standard_Real spar = ppar - dist;
-
- gp_Pnt aPnt1 = ElCLib::Value(fpar,aLin);
- gp_Pnt aPnt2 = ElCLib::Value(spar,aLin);
-
- if ( first )
- {
- myFAttach = anAttach;
- myFirstPnt1 = aPnt1;
- myFirstPnt2 = aPnt2;
- }
- else
- {
- mySAttach = anAttach;
- mySecondPnt1 = aPnt1;
- mySecondPnt2 = aPnt2;
- }
-}
-
-//=======================================================================
-//function : ComputePointsOnLine
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::ComputePointsOnLine(const gp_Pnt& pnt1, const gp_Pnt& pnt2,
- const Standard_Boolean first)
-{
- gp_Vec aVec (pnt1,pnt2);
- gp_Lin aLin (pnt1,gp_Dir(aVec));
-
- Standard_Real fpar = ElCLib::Parameter(aLin,pnt1);
- Standard_Real spar = ElCLib::Parameter(aLin,pnt2);
- Standard_Real ppar = ElCLib::Parameter(aLin,myMidPoint);
-
- gp_Pnt aProjPnt = ElCLib::Value(ppar,aLin);
- Standard_Real dist = myMidPoint.Distance(aProjPnt);
- Standard_Real ll = pnt1.Distance(pnt2);
- Standard_Real segm = Min(dist,ll)*0.75;
- if ( dist < Precision::Confusion() ) segm = ll*0.75;
-
- gp_Pnt anAttach,aPnt1,aPnt2;
- anAttach = aProjPnt;
- gp_Vec aVecTr;
- if ( ppar <= fpar )
- {
- aPnt2 = pnt1;
- aVecTr = gp_Vec(pnt2,pnt1);
- aVecTr.Normalize();
- aPnt1 = aProjPnt.Translated(aVecTr*segm);
- }
- else if ( ppar >= spar )
- {
- aPnt1 = pnt2;
- aVecTr = gp_Vec(pnt1,pnt2);
- aVecTr.Normalize();
- aPnt2 = aProjPnt.Translated(aVecTr*segm);
- }
- else
- {
- Standard_Real dp1 = aProjPnt.Distance(pnt1);
- Standard_Real dp2 = aProjPnt.Distance(pnt2);
-
- segm = Min(dist,dp1)*0.75;
- aVecTr = gp_Vec(aProjPnt,pnt1);
- aVecTr.Normalize();
- aPnt1 = aProjPnt.Translated(aVecTr*segm);
-
- segm = Min(dist,dp2)*0.75;
- aVecTr = gp_Vec(aProjPnt,pnt2);
- aVecTr.Normalize();
- aPnt2 = aProjPnt.Translated(aVecTr*segm);
- }
-
- if ( first )
- {
- myFAttach = anAttach;
- myFirstPnt1 = aPnt1;
- myFirstPnt2 = aPnt2;
- }
- else
- {
- mySAttach = anAttach;
- mySecondPnt1 = aPnt1;
- mySecondPnt2 = aPnt2;
- }
-}
-
-//=======================================================================
-//function : ComputePointsOnCirc
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::ComputePointsOnCirc(const gp_Circ& aCirc,
- const gp_Pnt& pnt1, const gp_Pnt& pnt2,
- const Standard_Boolean first)
-{
- gp_Pnt curpos = myMidPoint;
-
- // Case of confusion between the current position and the center
- // of the circle -> we move the current position
- Standard_Real confusion (Precision::Confusion());
- gp_Pnt aCenter = aCirc.Location();
- if ( aCenter.Distance(curpos) <= confusion )
- {
- gp_Vec vprec(aCenter, pnt1);
- vprec.Normalize();
- curpos.Translate(vprec*1e-5);
- }
-
- Standard_Real pcurpos = ElCLib::Parameter(aCirc,curpos);
-
- Standard_Real rad = M_PI / 5.0;
- Standard_Real segm;
-
- Standard_Real pFPnt;
- Standard_Real pSPnt;
-
- if ( pnt1.IsEqual(pnt2,confusion) ) // full circle
- {
- pFPnt = pcurpos - rad;
- pSPnt = pcurpos + rad;
- }
- else
- {
- Standard_Real pFAttach = ElCLib::Parameter(aCirc,pnt1);
- Standard_Real pSAttach = ElCLib::Parameter(aCirc,pnt2);
-
- Standard_Real pSAttachM = pSAttach;
- Standard_Real deltap = pSAttachM - pFAttach;
- if ( deltap < 0 )
- {
- deltap += 2 * M_PI;
- pSAttachM += 2 * M_PI;
- }
- pSAttachM -= pFAttach;
-
- Standard_Real pmiddleout = pSAttachM/2.0 + M_PI;
-
- Standard_Real pcurpos1 = pcurpos;
- // define where curpos lays
- if ( pcurpos1 < pFAttach )
- {
- pcurpos1 = pcurpos1 + 2 * M_PI - pFAttach;
- if ( pcurpos1 > pSAttachM ) // out
- {
- segm = Min(rad,deltap*0.75);
- if ( pcurpos1 > pmiddleout )
- {
- pcurpos = pFAttach;
- pFPnt = pFAttach;
- pSPnt = pFAttach + segm;
- }
- else
- {
- pcurpos = pSAttach;
- pFPnt = pSAttach - segm;
- pSPnt = pSAttach;
- }
- }
- else // on arc
- {
- Standard_Real dp1 = pcurpos1 - pFAttach;
- Standard_Real dp2 = pSAttachM - pcurpos1;
-
- segm = Min(rad,dp1*0.75);
- pFPnt = pcurpos - segm;
-
- segm = Min(rad,dp2*0.75);
- pSPnt = pcurpos + segm;
- }
- }
- else if ( pcurpos1 > (pFAttach + deltap) ) // out
- {
- pcurpos1 -= pFAttach;
- segm = Min(rad,deltap*0.75);
- if ( pcurpos1 > pmiddleout )
- {
- pcurpos = pFAttach;
- pFPnt = pFAttach;
- pSPnt = pFAttach + segm;
- }
- else
- {
- pcurpos = pSAttach;
- pFPnt = pSAttach - segm;
- pSPnt = pSAttach;
- }
- }
- else // on arc
- {
- Standard_Real dp1 = pcurpos1 - pFAttach;
- Standard_Real dp2 = pSAttach - pcurpos1;
-
- segm = Min(rad,dp1*0.75);
- pFPnt = pcurpos - segm;
-
- segm = Min(rad,dp2*0.75);
- pSPnt = pcurpos + segm;
- }
- }
-
- if ( first )
- {
- myFAttach = ElCLib::Value(pcurpos,aCirc);
- myFirstPnt1 = ElCLib::Value(pFPnt,aCirc);
- myFirstPnt2 = ElCLib::Value(pSPnt,aCirc);
- }
- else
- {
- mySAttach = ElCLib::Value(pcurpos,aCirc);
- mySecondPnt1 = ElCLib::Value(pFPnt,aCirc);
- mySecondPnt2 = ElCLib::Value(pSPnt,aCirc);
- }
-}
-
-//=======================================================================
-//function : ComputePointsOnElips
-//purpose :
-//=======================================================================
-void AIS_MidPointRelation::ComputePointsOnElips(const gp_Elips& anEll,
- const gp_Pnt& pnt1, const gp_Pnt& pnt2,
- const Standard_Boolean first)
-{
- gp_Pnt curpos = myMidPoint;
-
- // Case of confusion between the current position and the center
- // of the circle -> we move the current position
- Standard_Real confusion (Precision::Confusion());
- gp_Pnt aCenter = anEll.Location();
- if ( aCenter.Distance(curpos) <= confusion )
- {
- gp_Vec vprec(aCenter, pnt1);
- vprec.Normalize();
- curpos.Translate(vprec*1e-5);
- }
-
- Standard_Real pcurpos = ElCLib::Parameter(anEll,curpos);
-
- Standard_Real rad = M_PI / 5.0;
- Standard_Real segm;
-
- Standard_Real pFPnt;
- Standard_Real pSPnt;
-
- if ( pnt1.IsEqual(pnt2,confusion) ) // full circle
- {
- pFPnt = pcurpos - rad;
- pSPnt = pcurpos + rad;
- }
- else
- {
- Standard_Real pFAttach = ElCLib::Parameter(anEll,pnt1);
- Standard_Real pSAttach = ElCLib::Parameter(anEll,pnt2);
-
- Standard_Real pSAttachM = pSAttach;
- Standard_Real deltap = pSAttachM - pFAttach;
- if ( deltap < 0 )
- {
- deltap += 2 * M_PI;
- pSAttachM += 2 * M_PI;
- }
- pSAttachM -= pFAttach;
-
- Standard_Real pmiddleout = pSAttachM / 2.0 + M_PI;
-
- Standard_Real pcurpos1 = pcurpos;
- // define where curpos lays
- if ( pcurpos1 < pFAttach )
- {
- pcurpos1 = pcurpos1 + 2 * M_PI - pFAttach;
- if ( pcurpos1 > pSAttachM ) // out
- {
- segm = Min(rad,deltap*0.75);
- if ( pcurpos1 > pmiddleout )
- {
- pcurpos = pFAttach;
- pFPnt = pFAttach;
- pSPnt = pFAttach + segm;
- }
- else
- {
- pcurpos = pSAttach;
- pFPnt = pSAttach - segm;
- pSPnt = pSAttach;
- }
- }
- else // on arc
- {
- Standard_Real dp1 = pcurpos1 - pFAttach;
- Standard_Real dp2 = pSAttachM - pcurpos1;
-
- segm = Min(rad,dp1*0.75);
- pFPnt = pcurpos - segm;
-
- segm = Min(rad,dp2*0.75);
- pSPnt = pcurpos + segm;
- }
- }
- else if ( pcurpos1 > (pFAttach + deltap) ) // out
- {
- pcurpos1 -= pFAttach;
- segm = Min(rad,deltap*0.75);
- if ( pcurpos1 > pmiddleout )
- {
- pcurpos = pFAttach;
- pFPnt = pFAttach;
- pSPnt = pFAttach + segm;
- }
- else
- {
- pcurpos = pSAttach;
- pFPnt = pSAttach - segm;
- pSPnt = pSAttach;
- }
- }
- else // on arc
- {
- Standard_Real dp1 = pcurpos1 - pFAttach;
- Standard_Real dp2 = pSAttach - pcurpos1;
-
- segm = Min(rad,dp1*0.75);
- pFPnt = pcurpos - segm;
-
- segm = Min(rad,dp2*0.75);
- pSPnt = pcurpos + segm;
- }
- }
-
- if ( first )
- {
- myFAttach = ElCLib::Value(pcurpos,anEll);
- myFirstPnt1 = ElCLib::Value(pFPnt,anEll);
- myFirstPnt2 = ElCLib::Value(pSPnt,anEll);
- }
- else
- {
- mySAttach = ElCLib::Value(pcurpos,anEll);
- mySecondPnt1 = ElCLib::Value(pFPnt,anEll);
- mySecondPnt2 = ElCLib::Value(pSPnt,anEll);
- }
-}
+++ /dev/null
-// Created on: 2000-10-20
-// Created by: Julia DOROVSKIKH
-// Copyright (c) 2000-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_MidPointRelation_HeaderFile
-#define _AIS_MidPointRelation_HeaderFile
-
-#include <AIS_Relation.hxx>
-
-class Geom_Plane;
-class gp_Lin;
-class gp_Pnt;
-class gp_Circ;
-class gp_Elips;
-
-DEFINE_STANDARD_HANDLE(AIS_MidPointRelation, AIS_Relation)
-
-//! presentation of equal distance to point myMidPoint
-class AIS_MidPointRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_MidPointRelation, AIS_Relation)
-public:
-
- Standard_EXPORT AIS_MidPointRelation(const TopoDS_Shape& aSymmTool, const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& aPlane);
-
- virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
-
- void SetTool (const TopoDS_Shape& aMidPointTool);
-
- const TopoDS_Shape& GetTool() const;
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeFaceFromPnt (const Handle(Prs3d_Presentation)& aprs, const Standard_Boolean first);
-
- Standard_EXPORT void ComputeEdgeFromPnt (const Handle(Prs3d_Presentation)& aprs, const Standard_Boolean first);
-
- Standard_EXPORT void ComputeVertexFromPnt (const Handle(Prs3d_Presentation)& aprs, const Standard_Boolean first);
-
- Standard_EXPORT void ComputePointsOnLine (const gp_Lin& aLin, const Standard_Boolean first);
-
- Standard_EXPORT void ComputePointsOnLine (const gp_Pnt& pnt1, const gp_Pnt& pnt2, const Standard_Boolean first);
-
- Standard_EXPORT void ComputePointsOnCirc (const gp_Circ& aCirc, const gp_Pnt& pnt1, const gp_Pnt& pnt2, const Standard_Boolean first);
-
- //! ComputePointsOn... methods set myFAttach, myFirstPnt and myLastPnt
- //! from the following initial data: curve, end points, myMidPoint.
- //! End points (pnt1 & pnt2) and curve define the trimmed curve.
- //! If end points are equal, curve is not trimmed (line - special case).
- //!
- //! .------. pnt2
- //! /
- //! . circle . myLastPnt
- //! | |
- //! . pnt1 . myFAttach
- //! \ arc / . myMidPoint
- //! .______. myFirstPnt
- Standard_EXPORT void ComputePointsOnElips (const gp_Elips& anEll, const gp_Pnt& pnt1, const gp_Pnt& pnt2, const Standard_Boolean first);
-
- TopoDS_Shape myTool;
- gp_Pnt myMidPoint;
- gp_Pnt myFAttach;
- gp_Pnt myFirstPnt1;
- gp_Pnt myFirstPnt2;
- gp_Pnt mySAttach;
- gp_Pnt mySecondPnt1;
- gp_Pnt mySecondPnt2;
-
-};
-
-#include <AIS_MidPointRelation.lxx>
-
-#endif // _AIS_MidPointRelation_HeaderFile
+++ /dev/null
-// Created on: 2000-10-20
-// Created by: Julia DOROVSKIKH
-// Copyright (c) 2000-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : SetTool
-//purpose :
-//=======================================================================
-inline void AIS_MidPointRelation::SetTool(const TopoDS_Shape& aMidPointTool)
-{
- myTool = aMidPointTool;
-}
-
-//=======================================================================
-//function : GetTool
-//purpose :
-//=======================================================================
-inline const TopoDS_Shape& AIS_MidPointRelation::GetTool() const
-{
- return myTool;
-}
-
-
-//=======================================================================
-//function : IsMovable
-//purpose :
-//=======================================================================
-inline Standard_Boolean AIS_MidPointRelation::IsMovable() const
-{
- return Standard_True;
-}
+++ /dev/null
-// Created on: 1998-01-27
-// Created by: Sergey ZARITCHNY
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_EllipseRadiusDimension.hxx>
-#include <AIS_MinRadiusDimension.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <DsgPrs_EllipseRadiusPresentation.hxx>
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_OffsetCurve.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
-#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_Transformation.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <Precision.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Prs3d_Text.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_ConstructionError.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_MinRadiusDimension,AIS_EllipseRadiusDimension)
-
-//=======================================================================
-//function : AIS_MinRadiusDimension
-//purpose :
-//=======================================================================
-AIS_MinRadiusDimension::AIS_MinRadiusDimension(const TopoDS_Shape& aShape,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText)
-:AIS_EllipseRadiusDimension(aShape, aText)
-{
- myVal = aVal;
- mySymbolPrs = DsgPrs_AS_LASTAR;
- myAutomaticPosition = Standard_True;
- myArrowSize = myVal / 100.;
-}
-
-//=======================================================================
-//function : AIS_MinRadiusDimension
-//purpose :
-//=======================================================================
-
-AIS_MinRadiusDimension::AIS_MinRadiusDimension(const TopoDS_Shape& aShape,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText,
- const gp_Pnt& aPosition,
- const DsgPrs_ArrowSide aSymbolPrs,
- const Standard_Real anArrowSize)
-:AIS_EllipseRadiusDimension(aShape, aText)
-{
- myVal = aVal;
- mySymbolPrs = aSymbolPrs;
- myPosition = aPosition;
- myAutomaticPosition = Standard_False;
- SetArrowSize( anArrowSize );
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-
-void AIS_MinRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer /*aMode*/)
-{
-// if( myAutomaticPosition )
- //{ //ota : recompute ellipse always
- ComputeGeometry();
- myEllipse.SetMinorRadius(myVal);
- gp_Vec v1(myEllipse.YAxis().Direction());
- v1 *=myVal;
- myApexP = myEllipse.Location().Translated(v1);
- myApexN = myEllipse.Location().Translated(-v1);
-// }
- if(myIsAnArc) ComputeArcOfEllipse(aPresentation);
- else
- ComputeEllipse(aPresentation);
-}
-
-//=======================================================================
-//function : ComputeEllipse
-//purpose :
-//=======================================================================
-
-void AIS_MinRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aPresentation)
-{
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
-
- // size
- if( !myArrowSizeIsDefined ) {
- myArrowSize = Min(myArrowSize,myVal/5.);
- }
- arr->SetLength(myArrowSize);
-
- Standard_Real U;//,V;
- gp_Pnt curPos, Center;
- Center = myEllipse.Location();
- if( myAutomaticPosition )
- {
- myPosition = Center;
- myEndOfArrow = myApexP;
- myAutomaticPosition = Standard_True;
-
- if ( myIsSetBndBox )
- myPosition = AIS::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
- myBndBox );
- curPos = myPosition;
- }
- else //!AutomaticPosition
- {
- curPos = myPosition;
- gp_Lin L1(myEllipse.YAxis());
- U = ElCLib::Parameter ( L1, curPos );
- curPos = ElCLib::Value (U, L1);
- if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
- myEndOfArrow = myApexP ;
- else
- myEndOfArrow = myApexN ;
- myPosition = curPos;
- }
-
- // Presenatation
- DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, curPos,
- myEndOfArrow, Center, Standard_False, mySymbolPrs);
-
-}
-
-//=======================================================================
-//function : ComputeArcOfEllipse
-//purpose :
-//=======================================================================
-
-void AIS_MinRadiusDimension::ComputeArcOfEllipse(const Handle(Prs3d_Presentation)& aPresentation)
-{
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
-
- // size
- if( !myArrowSizeIsDefined ) {
- myArrowSize = Min(myArrowSize,myVal/5.);
- }
- arr->SetLength(myArrowSize);
-
- Standard_Real par;
- gp_Pnt curPos, Center;
- Center = myEllipse.Location();
- Standard_Boolean IsInDomain = Standard_True;
- if( myAutomaticPosition )
- {
- myEndOfArrow = AIS::NearestApex(myEllipse, myApexP, myApexN,
- myFirstPar, myLastPar, IsInDomain);
- myPosition = Center;
- myAutomaticPosition = Standard_True;
- if ( myIsSetBndBox )
- myPosition = AIS::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
- myBndBox );
- curPos = myPosition;
-
- }
- else //!AutomaticPosition
- {
- curPos = myPosition;
- gp_Lin L1(myEllipse.YAxis());
- par = ElCLib::Parameter ( L1, curPos );
- curPos = ElCLib::Value (par, L1);
- if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
- myEndOfArrow = myApexP ;
- else
- myEndOfArrow = myApexN ;
- par = ElCLib::Parameter ( myEllipse, myEndOfArrow );
- IsInDomain = AIS::InDomain(myFirstPar, myLastPar, par);
- myPosition = curPos;
- }
-
- Standard_Real parStart =0.;
- if( !IsInDomain )
- {
- if(AIS::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
- AIS::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
- parStart = myFirstPar;
- else
- parStart = myLastPar;
-
- }
-
- if(!myIsOffset)
- DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myEllipse,
- curPos, myEndOfArrow, Center, parStart, IsInDomain,
- Standard_True, mySymbolPrs);
- else
- DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myOffsetCurve,
- curPos, myEndOfArrow, Center, parStart, IsInDomain,
- Standard_True, mySymbolPrs);
-}
-
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-
-void AIS_MinRadiusDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer /*aMode*/)
-{
-
- gp_Pnt center = myEllipse.Location();
- gp_Pnt AttachmentPoint = myPosition;
- Standard_Real dist = center.Distance(AttachmentPoint);
- Standard_Real aRadius = myVal;
- //Standard_Real inside = Standard_False;
- gp_Pnt pt1;
- if (dist > aRadius) pt1 = AttachmentPoint;
- else
- pt1 = myEndOfArrow;
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
- Handle(Select3D_SensitiveSegment)
- seg = new Select3D_SensitiveSegment(own, center , pt1);
- aSelection->Add(seg);
-
- // Text
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
- AttachmentPoint.X(),
- AttachmentPoint.Y(),
- AttachmentPoint.Z(),
- AttachmentPoint.X()+size,
- AttachmentPoint.Y()+size,
- AttachmentPoint.Z()+size);
- aSelection->Add(box);
-
- // Arc of Ellipse
- if(myIsAnArc)
- {
-
- Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
- if(!AIS::InDomain(myFirstPar, myLastPar, parEnd))
- {
- Standard_Real parStart, par;
- if(AIS::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
- AIS::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
- par = myFirstPar;
- else
- par = myLastPar;
- gp_Vec Vapex(center, ElCLib::Value( parEnd, myEllipse )) ;
- gp_Vec Vpnt (center, ElCLib::Value( par, myEllipse )) ;
- gp_Dir dir(Vpnt ^ Vapex);
- if(myEllipse.Position().Direction().IsOpposite( dir, Precision::Angular())) {
- parStart = parEnd;
- parEnd = par;
- }
- else
- parStart = par;
- Handle(Geom_Curve)TrimCurve;
- if(myIsOffset)
- {
- Handle(Geom_Curve) aCurve = myOffsetCurve;
- TrimCurve = new Geom_TrimmedCurve( aCurve, parStart, parEnd );
- }
- else
- {
- Handle(Geom_Ellipse) Ellipse = new Geom_Ellipse( myEllipse );
- TrimCurve = new Geom_TrimmedCurve( Ellipse, parStart, parEnd );
- }
- Handle( Select3D_SensitiveCurve ) SensArc;
- SensArc = new Select3D_SensitiveCurve( own, TrimCurve );
- aSelection->Add( SensArc );
- }
- }
-
-}
+++ /dev/null
-// Created on: 1998-01-22
-// Created by: Sergey ZARITCHNY
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_MinRadiusDimension_HeaderFile
-#define _AIS_MinRadiusDimension_HeaderFile
-
-#include <AIS_EllipseRadiusDimension.hxx>
-#include <DsgPrs_ArrowSide.hxx>
-
-DEFINE_STANDARD_HANDLE(AIS_MinRadiusDimension, AIS_EllipseRadiusDimension)
-
-//! -- Ellipse Min radius dimension of a Shape which
-//! can be Edge or Face (planar or cylindrical(surface of
-//! extrusion or surface of offset))
-class AIS_MinRadiusDimension : public AIS_EllipseRadiusDimension
-{
- DEFINE_STANDARD_RTTIEXT(AIS_MinRadiusDimension, AIS_EllipseRadiusDimension)
-public:
-
- //! Max Ellipse radius dimension
- //! Shape can be edge , planar face or cylindrical face
- Standard_EXPORT AIS_MinRadiusDimension(const TopoDS_Shape& aShape, const Standard_Real aVal, const TCollection_ExtendedString& aText);
-
- //! Max Ellipse radius dimension with position
- //! Shape can be edge , planar face or cylindrical face
- Standard_EXPORT AIS_MinRadiusDimension(const TopoDS_Shape& aShape, const Standard_Real aVal, const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.0);
-
-private:
-
- Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeEllipse (const Handle(Prs3d_Presentation)& aPresentation);
-
- Standard_EXPORT void ComputeArcOfEllipse (const Handle(Prs3d_Presentation)& aPresentation);
-
- gp_Pnt myApexP;
- gp_Pnt myApexN;
- gp_Pnt myEndOfArrow;
-
-};
-
-#endif // _AIS_MinRadiusDimension_HeaderFile
+++ /dev/null
-// Created on: 1997-03-04
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_OffsetDimension.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepBuilderAPI_Transform.hxx>
-#include <DsgPrs_OffsetPresentation.hxx>
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <gce_MakeLin.hxx>
-#include <Geom_Transformation.hxx>
-#include <GeomAbs_SurfaceType.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_Vec.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Precision.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <StdPrs_WFShape.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TColStd_Array2OfReal.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_OffsetDimension,AIS_Relation)
-
-//=======================================================================
-//function : AIS_OffsetDimension
-//purpose :
-//=======================================================================
-AIS_OffsetDimension::AIS_OffsetDimension(const TopoDS_Shape& FistShape,
- const TopoDS_Shape& SecondShape,
- const Standard_Real aVal,
- const TCollection_ExtendedString& aText)
-:AIS_Relation(),
-myFAttach(0.,0.,0.),
-mySAttach(0.,0.,0.)
-{
- myFShape = FistShape;
- mySShape = SecondShape;
- mySymbolPrs = DsgPrs_AS_BOTHAR;
- myVal = aVal;
- myText = aText;
- //myArrowSize = fabs (myVal/5.);
- myArrowSize = fabs (myVal/10.0);
- if (myArrowSize > 30.) myArrowSize = 30.;
- if (myArrowSize < 15.) myArrowSize = 15.;
- //std::cout<<"AIS_OffsetDimension::AIS_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_OffsetDimension::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aprs,
- const Standard_Integer)
-{
- gp_Trsf aInvertTrsf = myRelativePos;
- //myArrowSize = fabs (myVal/5.);
- myArrowSize = fabs (myVal/10.0);
- if (myArrowSize > 30.) myArrowSize = 30.;
- if (myArrowSize < 15.) myArrowSize = 15.;
- //std::cout<<"AIS_OffsetDimension::AIS_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
-
- BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
- BRepAdaptor_Surface surf2(TopoDS::Face(mySShape));
-
- if (surf1.GetType() == GeomAbs_Cylinder ||
- surf1.GetType() == GeomAbs_Cone ||
- surf1.GetType() == GeomAbs_Torus) {
- if (surf2.GetType() == GeomAbs_Cylinder ||
- surf2.GetType() == GeomAbs_Cone ||
- surf2.GetType() == GeomAbs_Torus) {
- ComputeTwoAxesOffset(aprs, aInvertTrsf);
- } else {
- ComputeAxeFaceOffset(aprs, aInvertTrsf);
- }
- }
- else {
- //myDirAttach : oriente de myFShape vers mySShape
- gp_Pln aPln = surf1.Plane();
- gp_Pnt aPnt = aPln.Location();
-
- gp_Pln bPln = surf2.Plane();
-
- Standard_Real uPnt, vPnt;
- ElSLib::Parameters (bPln , aPnt , uPnt, vPnt);
- gp_Pnt bPnt = ElSLib::Value (uPnt, vPnt, bPln);
- if (aPnt.IsEqual(bPnt,Precision::Confusion())) {
- gp_Ax1 aAx1 = aPln.Axis();
- myDirAttach = aAx1.Direction();
- } else {
- gp_Vec aVec (aPnt,bPnt);
- myDirAttach.SetCoord(aVec.X(),aVec.Y(),aVec.Z());
- }
- ComputeTwoFacesOffset(aprs, aInvertTrsf);
- }
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-void AIS_OffsetDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
- const Standard_Integer)
-{
- //myArrowSize = fabs (myVal/5.);
- myArrowSize = fabs (myVal/10.0);
- if (myArrowSize > 30.) myArrowSize = 30.;
- if (myArrowSize < 15.) myArrowSize = 15.;
- //std::cout<<"AIS_OffsetDimension::AIS_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
- gp_Pnt myTFAttach = myFAttach.Transformed (myRelativePos);
- gp_Pnt myTSAttach = mySAttach.Transformed (myRelativePos);
- gp_Dir myTDirAttach = myDirAttach.Transformed (myRelativePos);
- gp_Dir myTDirAttach2 = myDirAttach2.Transformed (myRelativePos);
- gp_Pnt Tcurpos = myPosition.Transformed (myRelativePos);
-
- gp_Lin L1 (myTFAttach,myTDirAttach);
- gp_Lin L2 (myTSAttach,myTDirAttach2);
- gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,Tcurpos),L1);
- gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,Tcurpos),L2);
- gp_Lin L3;
-
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
-
- if (!Proj1.IsEqual(Proj2,Precision::Confusion())) {
- L3 = gce_MakeLin(Proj1,Proj2);
- }
- else { // cas ou la dimension est nulle
- if (!Proj1.IsEqual(Tcurpos,Precision::Confusion())) {
- gp_Vec v3 (Proj1,Tcurpos);
- gp_Dir d3 (v3);
- L3 = gce_MakeLin(Proj1,d3);
- } else {
- L3 = gce_MakeLin(Proj1,myTDirAttach);
- }
-
- // Text
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
- Tcurpos.X(),
- Tcurpos.Y(),
- Tcurpos.Z(),
- Tcurpos.X() + size,
- Tcurpos.Y() + size,
- Tcurpos.Z() + size);
- aSel->Add(box);
- }
-
- Standard_Real parmin,parmax,parcur;
- parmin = ElCLib::Parameter(L3,Proj1);
- parmax = parmin;
-
- parcur = ElCLib::Parameter(L3,Proj2);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- parcur = ElCLib::Parameter(L3,Tcurpos);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- gp_Pnt PointMin = ElCLib::Value(parmin,L3);
- gp_Pnt PointMax = ElCLib::Value(parmax,L3);
-
- Handle(Select3D_SensitiveSegment) seg;
- if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- PointMin,
- PointMax);
- aSel->Add(seg);
- }
-
- if (!myTFAttach.IsEqual(Proj1,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- myTFAttach,
- Proj1);
- aSel->Add(seg);
- }
- if (!myTSAttach.IsEqual(Proj2,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- myTSAttach,
- Proj2);
- aSel->Add(seg);
- }
-}
-
-//=======================================================================
-//function : ComputeTwoAxesOffset
-//purpose :
-//=======================================================================
-void AIS_OffsetDimension::ComputeTwoAxesOffset(const Handle(Prs3d_Presentation)& aprs,
- const gp_Trsf& aTrsf)
-{
- BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
- BRepAdaptor_Surface surf2(TopoDS::Face(mySShape));
-
- gp_Ax1 Ax1Surf1, Ax1Surf2;
-
- if (surf1.GetType() == GeomAbs_Cylinder) {
- gp_Cylinder aCyl= surf1.Cylinder();
- Ax1Surf1 = aCyl.Axis();
- } else if (surf1.GetType() == GeomAbs_Cone) {
- gp_Cone aCone= surf1.Cone();
- Ax1Surf1 = aCone.Axis();
- } else if (surf1.GetType() == GeomAbs_Torus) {
- gp_Torus aTore= surf1.Torus();
- Ax1Surf1 = aTore.Axis();
- }
- Standard_Real FirstUParam = surf1.FirstUParameter();
- Standard_Real FirstVParam = surf1.FirstVParameter();
- Standard_Real LastVParam = surf1.LastVParameter();
- gp_Pnt P1First = surf1.Value(FirstUParam,FirstVParam);
- gp_Pnt P1Last = surf1.Value(FirstUParam,LastVParam);
-
-
- if (surf2.GetType() == GeomAbs_Cylinder) {
- gp_Cylinder aCyl= surf2.Cylinder();
- Ax1Surf2 = aCyl.Axis();
- } else if (surf2.GetType() == GeomAbs_Cone) {
- gp_Cone aCone= surf2.Cone();
- Ax1Surf2 = aCone.Axis();
- } else if (surf2.GetType() == GeomAbs_Torus) {
- gp_Torus aTore= surf2.Torus();
- Ax1Surf2 = aTore.Axis();
- }
- FirstUParam = surf2.FirstUParameter();
- FirstVParam = surf2.FirstVParameter();
- LastVParam = surf2.LastVParameter();
- gp_Pnt P2First = surf2.Value(FirstUParam,FirstVParam);
- gp_Pnt P2Last = surf2.Value(FirstUParam,LastVParam);
-
-
-
- myFAttach = Ax1Surf1.Location();
- mySAttach = Ax1Surf2.Location();
- myDirAttach = Ax1Surf1.Direction();
- myDirAttach2 = myDirAttach;
- gp_Pnt curpos;
- gp_Lin aProjLine = gce_MakeLin(myFAttach,myDirAttach);
-
- if (myAutomaticPosition) {
- curpos.SetX ( (myFAttach.X() + mySAttach.X()) /2. + 0.01);
- curpos.SetY ( (myFAttach.Y() + mySAttach.Y()) /2. + 0.01);
- curpos.SetZ ( (myFAttach.Z() + mySAttach.Z()) /2. + 0.01);
- // + 0.01 pour eviter un raise de ComputeSelection...
-
- myPosition = curpos;
- }
- else {
- curpos = myPosition;
- }
-
- curpos = ElCLib::Value(ElCLib::Parameter(aProjLine,curpos),aProjLine);
- // on projette pour la presentation
-
- gp_Pnt P1FirstProj = ElCLib::Value(ElCLib::Parameter(aProjLine,P1First),aProjLine);
- gp_Pnt P1LastProj = ElCLib::Value(ElCLib::Parameter(aProjLine,P1Last),aProjLine);
- if (P1FirstProj.Distance(curpos) > P1LastProj.Distance(curpos))
- myFAttach = P1FirstProj;
- else
- myFAttach = P1LastProj;
-
- gp_Pnt P2FirstProj = ElCLib::Value(ElCLib::Parameter(aProjLine,P2First),aProjLine);
- gp_Pnt P2LastProj = ElCLib::Value(ElCLib::Parameter(aProjLine,P2Last),aProjLine);
- if (P2FirstProj.Distance(curpos) > P2LastProj.Distance(curpos))
- mySAttach = P2FirstProj;
- else
- mySAttach = P2LastProj;
-
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- //std::cout<<"AIS_OffsetDimension::AIS_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
- arr->SetLength(myArrowSize);
- arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
-
- gp_Pnt myTFAttach = myFAttach.Transformed (aTrsf);
- gp_Pnt myTSAttach = mySAttach.Transformed (aTrsf);
- gp_Dir myTDirAttach = myDirAttach.Transformed (aTrsf);
- gp_Dir myTDirAttach2 = myTDirAttach;
- gp_Pnt Tcurpos = curpos.Transformed (aTrsf);
-
- if (myIsSetBndBox)
- Tcurpos = AIS::TranslatePointToBound( Tcurpos, myDirAttach, myBndBox );
-
- DsgPrs_OffsetPresentation::AddAxes(aprs,
- myDrawer,
- myText,
- myTFAttach,
- myTSAttach,
- myTDirAttach,
- myTDirAttach2,
- Tcurpos);
-
- BRepBuilderAPI_Transform transform1 (myFShape, aTrsf, Standard_True);
- TopoDS_Shape myTFShape = transform1.Shape();
- BRepBuilderAPI_Transform transform2 (mySShape, aTrsf, Standard_True);
- TopoDS_Shape myTSShape = transform2.Shape();
-
- StdPrs_WFShape::Add (aprs, myTFShape, myDrawer);
- StdPrs_WFShape::Add (aprs, myTSShape, myDrawer);
-}
-
-//=======================================================================
-//function : ComputeTwoFacesOffset
-//purpose :
-//=======================================================================
-void AIS_OffsetDimension::ComputeTwoFacesOffset(const Handle(Prs3d_Presentation)& aprs,
- const gp_Trsf& aTrsf)
-{
- gp_Dir norm1 = myDirAttach;
- gp_Pnt curpos;
- gp_Ax2 myax2;
- if (myAutomaticPosition && ! myIsSetBndBox) {
- TopExp_Explorer explo(myFShape,TopAbs_VERTEX);
- if (explo.More()) {
- TopoDS_Vertex vertref = TopoDS::Vertex(explo.Current());
- myFAttach = BRep_Tool::Pnt(vertref);
- gp_Vec trans = norm1.XYZ()*fabs(myVal/2);
- gp_Ax2 ax2(myFAttach,norm1);
- myDirAttach = ax2.XDirection();
- curpos = myFAttach.Translated(trans);
- if (myVal <= Precision::Confusion()) {
- gp_Vec vecnorm1 = norm1.XYZ()*.001;
- curpos.Translate(vecnorm1);
- }
- myPosition = curpos;
- myax2 = ax2;
- }
- }
- else {
- if (myAutomaticPosition && myIsSetBndBox)
- {
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- myBndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
- myPosition.SetCoord( aXmax, aYmax, aZmax );
- }
-
- curpos = myPosition;
- myFAttach = AIS::Nearest(myFShape,curpos);
- if (myFAttach.Distance(curpos) <= Precision::Confusion()) {
- gp_Ax2 ax2(myFAttach,norm1);
- myDirAttach = ax2.XDirection();
- myax2 = ax2;
- }
- else {
- gp_Dir orient(myFAttach.XYZ()-curpos.XYZ());
- gp_Ax2 ax2(myFAttach,norm1);
- if (orient.Angle(norm1) <= Precision::Angular()) {
- myDirAttach = ax2.XDirection();
- }
- else {
- gp_Dir adir = norm1 ^ orient;
- myDirAttach = adir ^ norm1;
- }
- myax2 = ax2;
- }
- }
- // en attendant mieux
- mySAttach = AIS::Nearest(mySShape,curpos);
- gp_Ax3 anax3 (myax2);
- gp_Pln apln (anax3);
-
- //gp_Pnt proj2;
- Standard_Real u2,v2, uatt, vatt;
- ElSLib::Parameters (apln , mySAttach, uatt,vatt);
- ElSLib::Parameters (apln , curpos , u2,v2);
-
- if (uatt== u2 && vatt == v2) {
- myDirAttach2 = myDirAttach;
- } else {
- gp_Vec avec (ElSLib::Value (uatt,vatt, apln) , ElSLib::Value (u2,v2, apln));
- myDirAttach2.SetCoord (avec.X(),avec.Y(),avec.Z());
- }
-
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- //std::cout<<"AIS_OffsetDimension::AIS_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
- arr->SetLength(myArrowSize);
- arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
-
- gp_Pnt myTFAttach = myFAttach.Transformed (aTrsf);
- gp_Pnt myTSAttach = mySAttach.Transformed (aTrsf);
- gp_Dir myTDirAttach = myDirAttach.Transformed (aTrsf);
- gp_Dir myTDirAttach2 = myDirAttach2.Transformed (aTrsf);
- gp_Pnt Tcurpos = curpos.Transformed (aTrsf);
-
-/*
- if (myIsSetBndBox)
- {
- BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
- Tcurpos = AIS::TranslatePointToBound( Tcurpos, surf1.Plane().XAxis().Direction(), myBndBox );
- }
-*/
- DsgPrs_OffsetPresentation::Add(aprs,
- myDrawer,
- myText,
- myTFAttach,
- myTSAttach,
- myTDirAttach,
- myTDirAttach2,
- Tcurpos);
-
-
- BRepBuilderAPI_Transform transform1 (myFShape, aTrsf, Standard_True);
- TopoDS_Shape myTFShape = transform1.Shape();
- BRepBuilderAPI_Transform transform2 (mySShape, aTrsf, Standard_True);
- TopoDS_Shape myTSShape = transform2.Shape();
-
- StdPrs_WFShape::Add (aprs, myTFShape, myDrawer);
- StdPrs_WFShape::Add (aprs, myTSShape, myDrawer);
-}
-
-//=======================================================================
-//function : ComputeAxeFaceOffset
-//purpose :
-//=======================================================================
-void AIS_OffsetDimension::ComputeAxeFaceOffset(const Handle(Prs3d_Presentation)& aprs,
- const gp_Trsf& aTrsf)
-{
- BRepBuilderAPI_Transform transform1 (myFShape, aTrsf, Standard_True);
- TopoDS_Shape myTFShape = transform1.Shape();
- BRepBuilderAPI_Transform transform2 (mySShape, aTrsf, Standard_True);
- TopoDS_Shape myTSShape = transform2.Shape();
-
- StdPrs_WFShape::Add (aprs, myTFShape, myDrawer);
- StdPrs_WFShape::Add (aprs, myTSShape, myDrawer);
-}
-
+++ /dev/null
-// Created on: 1997-03-04
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_OffsetDimension_HeaderFile
-#define _AIS_OffsetDimension_HeaderFile
-
-#include <AIS_Relation.hxx>
-#include <AIS_KindOfDimension.hxx>
-
-DEFINE_STANDARD_HANDLE(AIS_OffsetDimension, AIS_Relation)
-
-//! A framework to display dimensions of offsets.
-//! The relation between the offset and the basis shape
-//! is indicated. This relation is displayed with arrows and
-//! text. The text gives the dsitance between the offset
-//! and the basis shape.
-class AIS_OffsetDimension : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_OffsetDimension, AIS_Relation)
-public:
-
- //! Constructs the offset display object defined by the
- //! first shape aFShape, the second shape aSShape, the
- //! dimension aVal, and the text aText.
- Standard_EXPORT AIS_OffsetDimension(const TopoDS_Shape& FistShape, const TopoDS_Shape& SecondShape, const Standard_Real aVal, const TCollection_ExtendedString& aText);
-
- //! Indicates that the dimension we are concerned with is an offset.
- virtual AIS_KindOfDimension KindOfDimension() const Standard_OVERRIDE;
-
- //! Returns true if the offset datum is movable.
- virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
-
- //! Sets a transformation aTrsf for presentation and
- //! selection to a relative position.
- void SetRelativePos (const gp_Trsf& aTrsf);
-
-private:
-
- Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeTwoFacesOffset (const Handle(Prs3d_Presentation)& aPresentation, const gp_Trsf& aTrsf);
-
- Standard_EXPORT void ComputeTwoAxesOffset (const Handle(Prs3d_Presentation)& aPresentation, const gp_Trsf& aTrsf);
-
- Standard_EXPORT void ComputeAxeFaceOffset (const Handle(Prs3d_Presentation)& aPresentation, const gp_Trsf& aTrsf);
-
- gp_Pnt myFAttach;
- gp_Pnt mySAttach;
- gp_Dir myDirAttach;
- gp_Dir myDirAttach2;
- gp_Trsf myRelativePos;
-
-};
-
-#include <AIS_OffsetDimension.lxx>
-
-#endif // _AIS_OffsetDimension_HeaderFile
+++ /dev/null
-// Created on: 1997-03-04
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : KindOfDimension
-//purpose :
-//=======================================================================
-inline AIS_KindOfDimension AIS_OffsetDimension::KindOfDimension() const
-{
- return AIS_KOD_OFFSET;
-}
-
-//=======================================================================
-//function : IsMovable
-//purpose :
-//=======================================================================
-inline Standard_Boolean AIS_OffsetDimension::IsMovable() const
-{
- return Standard_True;
-}
-
-//=======================================================================
-//function : SetRelativePos
-//purpose :
-//=======================================================================
-inline void AIS_OffsetDimension::SetRelativePos(const gp_Trsf& aTrsf)
-{
- myRelativePos = aTrsf;
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Jean-Pierre COMBE/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_ParallelRelation.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <DsgPrs_LengthPresentation.hxx>
-#include <ElCLib.hxx>
-#include <gce_MakeLin.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <Precision.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_DomainError.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_ParallelRelation,AIS_Relation)
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_ParallelRelation::AIS_ParallelRelation(const TopoDS_Shape& aFShape,
- const TopoDS_Shape& aSShape,
- const Handle(Geom_Plane)& aPlane)
-{
- myFShape = aFShape;
- mySShape = aSShape;
- myPlane = aPlane;
- myAutomaticPosition = Standard_True;
- myArrowSize = 0.01;
- mySymbolPrs = DsgPrs_AS_BOTHAR;
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_ParallelRelation::AIS_ParallelRelation(const TopoDS_Shape& aFShape,
- const TopoDS_Shape& aSShape,
- const Handle(Geom_Plane)& aPlane,
- const gp_Pnt& aPosition,
- const DsgPrs_ArrowSide aSymbolPrs,
- const Standard_Real anArrowSize)
-{
- myFShape = aFShape;
- mySShape = aSShape;
- myPlane = aPlane;
- myAutomaticPosition = Standard_False;
- SetArrowSize( anArrowSize );
- myPosition = aPosition;
- mySymbolPrs = aSymbolPrs;
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_ParallelRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer)
-{
- switch (myFShape.ShapeType())
- {
- case TopAbs_FACE :
- {
- // cas longueur entre deux faces
- ComputeTwoFacesParallel(aPresentation);
- }
- break;
- case TopAbs_EDGE :
- {
- // cas longueur entre deux edges
- ComputeTwoEdgesParallel(aPresentation);
- }
- break;
- default:
- break;
- }
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-void AIS_ParallelRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer)
-{
- gp_Lin L1 (myFAttach,myDirAttach);
- gp_Lin L2 (mySAttach,myDirAttach);
- gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,myPosition),L1);
- gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,myPosition),L2);
-
- gp_Lin L3;
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
-
- if (!Proj1.IsEqual(Proj2,Precision::Confusion()))
- {
- L3 = gce_MakeLin(Proj1,Proj2);
- }
- else
- {
- L3 = gce_MakeLin(Proj1,myDirAttach);
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle(Select3D_SensitiveBox) box =
- new Select3D_SensitiveBox(own,
- myPosition.X(),
- myPosition.Y(),
- myPosition.Z(),
- myPosition.X()+size,
- myPosition.Y()+size,
- myPosition.Z()+size);
- aSelection->Add(box);
- }
- Standard_Real parmin,parmax,parcur;
- parmin = ElCLib::Parameter(L3,Proj1);
- parmax = parmin;
-
- parcur = ElCLib::Parameter(L3,Proj2);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- parcur = ElCLib::Parameter(L3,myPosition);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- gp_Pnt PointMin = ElCLib::Value(parmin,L3);
- gp_Pnt PointMax = ElCLib::Value(parmax,L3);
-
- Handle(Select3D_SensitiveSegment) seg;
-
- if (!PointMin.IsEqual(PointMax,Precision::Confusion()))
- {
- seg = new Select3D_SensitiveSegment(own,
- PointMin,
- PointMax);
- aSelection->Add(seg);
- }
- if (!myFAttach.IsEqual(Proj1,Precision::Confusion()))
- {
- seg = new Select3D_SensitiveSegment(own, myFAttach, Proj1);
- aSelection->Add(seg);
- }
- if (!mySAttach.IsEqual(Proj2,Precision::Confusion()))
- {
- seg = new Select3D_SensitiveSegment(own, mySAttach, Proj2);
- aSelection->Add(seg);
- }
-}
-
-//=======================================================================
-//function : ComputeTwoFacesParallel
-//purpose :
-//=======================================================================
-void AIS_ParallelRelation::ComputeTwoFacesParallel(const Handle(Prs3d_Presentation)&)
-{
- throw Standard_NotImplemented("AIS_ParallelRelation::ComputeTwoFacesParallel not implemented");
-}
-
-//=======================================================================
-//function : ComputeTwoEdgesParallel
-//purpose :
-//=======================================================================
-void AIS_ParallelRelation::ComputeTwoEdgesParallel(const Handle(Prs3d_Presentation)& aPresentation)
-{
- TopoDS_Edge E1 = TopoDS::Edge(myFShape);
- TopoDS_Edge E2 = TopoDS::Edge(mySShape);
-
- gp_Pnt ptat11,ptat12,ptat21,ptat22;//,pint3d;
- Handle(Geom_Curve) geom1,geom2;
- Standard_Boolean isInfinite1,isInfinite2;
- Handle(Geom_Curve) extCurv;
- if (!AIS::ComputeGeometry(E1,E2,myExtShape,
- geom1,geom2,
- ptat11,ptat12,ptat21,ptat22,
- extCurv,
- isInfinite1,isInfinite2,
- myPlane))
- {
- return;
- }
-
- aPresentation->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape != 0));
-
- gp_Lin l1;
- gp_Lin l2;
- Standard_Boolean isEl1 = Standard_False, isEl2 = Standard_False;
-
- if (geom1->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
- {
- Handle(Geom_Ellipse) geom_el1 (Handle(Geom_Ellipse)::DownCast (geom1));
- // construct lines through focuses
- gp_Ax1 elAx = geom_el1->XAxis();
- l1 = gp_Lin(elAx);
- Standard_Real focex = geom_el1->MajorRadius() - geom_el1->Focal()/2.0;
- gp_Vec transvec = gp_Vec(elAx.Direction())*focex;
- ptat11 = geom_el1->Focus1().Translated(transvec);
- ptat12 = geom_el1->Focus2().Translated(-transvec);
- isEl1 = Standard_True;
- }
- else if (geom1->IsInstance(STANDARD_TYPE(Geom_Line)))
- {
- Handle(Geom_Line) geom_lin1 (Handle(Geom_Line)::DownCast (geom1));
- l1 = geom_lin1->Lin();
- }
- else return;
-
- if (geom2->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
- {
- Handle(Geom_Ellipse) geom_el2 (Handle(Geom_Ellipse)::DownCast (geom2));
- // construct lines through focuses
- gp_Ax1 elAx = geom_el2->XAxis();
- l2 = gp_Lin(elAx);
- Standard_Real focex = geom_el2->MajorRadius() - geom_el2->Focal()/2.0;
- gp_Vec transvec = gp_Vec(elAx.Direction())*focex;
- ptat21 = geom_el2->Focus1().Translated(transvec);
- ptat22 = geom_el2->Focus2().Translated(-transvec);
- isEl2 = Standard_True;
- }
- else if (geom2->IsInstance(STANDARD_TYPE(Geom_Line)))
- {
- Handle(Geom_Line) geom_lin2 (Handle(Geom_Line)::DownCast (geom2));
- l2 = geom_lin2->Lin();
- }
- else return;
-
- const Handle(Geom_Line)& geom_lin1 = new Geom_Line(l1);
- const Handle(Geom_Line)& geom_lin2 = new Geom_Line(l2);
-
- myDirAttach = l1.Direction();
- // size
- if( !myArrowSizeIsDefined ) {
- Standard_Real arrSize1 (myArrowSize), arrSize2 (myArrowSize);
- if (!isInfinite1) arrSize1 = ptat11.Distance(ptat12)/50.;
- if (!isInfinite2) arrSize2 = ptat21.Distance(ptat22)/50.;
- myArrowSize = Max(myArrowSize,Max(arrSize1,arrSize2));
-// myArrowSize = Min(myArrowSize,Min(arrSize1,arrSize2));
- }
-
- if ( myAutomaticPosition )
- {
- gp_Pnt curpos;
- if ( !isInfinite1 )
- {
- gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2);
- curpos.SetXYZ((ptat11.XYZ() + p2.XYZ())/2.);
- }
- else if ( !isInfinite2 )
- {
- gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l1,ptat21),l1);
- curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())/2.);
- }
- else
- {
- curpos.SetXYZ((l1.Location().XYZ()+l2.Location().XYZ())/2.);
- }
- // offset pour eviter confusion Edge et Dimension
- gp_Vec offset (myDirAttach);
- offset = offset*myArrowSize*(-10.);
- curpos.Translate(offset);
- myPosition = curpos;
- }
-
- // recherche points attache
- if (!isInfinite1)
- {
- if ( isEl1 )
- {
- if (myPosition.Distance(ptat11) < myPosition.Distance(ptat12)) myFAttach = ptat12;
- else myFAttach = ptat11;
- }
- else
- {
- if (myPosition.Distance(ptat11) > myPosition.Distance(ptat12)) myFAttach = ptat12;
- else myFAttach = ptat11;
- }
- }
- else
- {
- myFAttach = ElCLib::Value(ElCLib::Parameter(l1,myPosition),l1);
- }
-
- if (!isInfinite2)
- {
- if ( isEl2 )
- {
- if (myPosition.Distance(ptat21) < myPosition.Distance(ptat22)) mySAttach = ptat22;
- else mySAttach = ptat21;
- }
- else
- {
- if (myPosition.Distance(ptat21) > myPosition.Distance(ptat22)) mySAttach = ptat22;
- else mySAttach = ptat21;
- }
- }
- else
- {
- mySAttach = ElCLib::Value(ElCLib::Parameter(l2,myPosition),l2);
- }
- TCollection_ExtendedString aText (" //");
-
- if (l1.Distance(l2) <= Precision::Confusion())
- {
- myArrowSize = 0.;
- }
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
- arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
- if ( myExtShape == 1)
- mySymbolPrs = DsgPrs_AS_FIRSTPT_LASTAR;
- else if ( myExtShape == 2)
- mySymbolPrs = DsgPrs_AS_FIRSTAR_LASTPT;
-
- DsgPrs_LengthPresentation::Add(aPresentation,
- myDrawer,
- aText,
- myFAttach,
- mySAttach,
- myDirAttach,
- myPosition,
- mySymbolPrs);
- if ( (myExtShape != 0) && !extCurv.IsNull())
- {
- gp_Pnt pf, pl;
- if ( myExtShape == 1 )
- {
- if (!isInfinite1)
- {
- pf = ptat11;
- pl = ptat12;
- }
- ComputeProjEdgePresentation(aPresentation,E1,geom_lin1,pf,pl);
- }
- else
- {
- if (!isInfinite2)
- {
- pf = ptat21;
- pl = ptat22;
- }
- ComputeProjEdgePresentation(aPresentation,E2,geom_lin2,pf,pl);
- }
- }
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Jean-Pierre COMBE/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_ParallelRelation_HeaderFile
-#define _AIS_ParallelRelation_HeaderFile
-
-#include <AIS_Relation.hxx>
-#include <DsgPrs_ArrowSide.hxx>
-
-DEFINE_STANDARD_HANDLE(AIS_ParallelRelation, AIS_Relation)
-
-//! A framework to display constraints of parallelism
-//! between two or more Interactive Objects. These
-//! entities can be faces or edges.
-class AIS_ParallelRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_ParallelRelation, AIS_Relation)
-public:
-
-
- //! Constructs an object to display parallel constraints.
- //! This object is defined by the first shape aFShape and
- //! the second shape aSShape and the plane aPlane.
- Standard_EXPORT AIS_ParallelRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane);
-
- //! Constructs an object to display parallel constraints.
- //! This object is defined by the first shape aFShape and
- //! the second shape aSShape the plane aPlane, the
- //! position aPosition, the type of arrow, aSymbolPrs and
- //! its size anArrowSize.
- Standard_EXPORT AIS_ParallelRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.01);
-
- //! Returns true if the parallelism is movable.
- virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeTwoFacesParallel (const Handle(Prs3d_Presentation)& aPresentation);
-
- Standard_EXPORT void ComputeTwoEdgesParallel (const Handle(Prs3d_Presentation)& aPresentation);
-
- gp_Pnt myFAttach;
- gp_Pnt mySAttach;
- gp_Dir myDirAttach;
-
-};
-
-#include <AIS_ParallelRelation.lxx>
-
-#endif // _AIS_ParallelRelation_HeaderFile
+++ /dev/null
-// Created on: 1997-02-28
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : IsMovable
-//purpose :
-//=======================================================================
-inline Standard_Boolean AIS_ParallelRelation::IsMovable() const
-{
- return Standard_True;
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Jean-Pierre COMBE/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_PerpendicularRelation.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <DsgPrs_PerpenPresentation.hxx>
-#include <ElCLib.hxx>
-#include <gce_MakeDir.hxx>
-#include <Geom2d_Line.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <GeomAPI.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pnt2d.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_Vec.hxx>
-#include <IntAna2d_AnaIntersection.hxx>
-#include <IntAna2d_IntPoint.hxx>
-#include <Precision.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_PerpendicularRelation,AIS_Relation)
-
-//=======================================================================
-//function : Constructor
-//purpose : TwoEdgesPerpendicular
-//=======================================================================
-AIS_PerpendicularRelation::AIS_PerpendicularRelation(const TopoDS_Shape& aFShape,
- const TopoDS_Shape& aSShape,
- const Handle(Geom_Plane)& aPlane)
-:AIS_Relation()
-{
- myFShape = aFShape;
- mySShape = aSShape;
- myPlane = aPlane;
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : TwoFacesPerpendicular
-//=======================================================================
-AIS_PerpendicularRelation::AIS_PerpendicularRelation(const TopoDS_Shape& aFShape,
- const TopoDS_Shape& aSShape)
-:AIS_Relation()
-{
- myFShape = aFShape;
- mySShape = aSShape;
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_PerpendicularRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer)
-{
- if (myFShape.ShapeType() == mySShape.ShapeType()) {
- switch (myFShape.ShapeType()) {
- case TopAbs_FACE :
- {
- // cas perpendiculaire entre deux faces
- ComputeTwoFacesPerpendicular(aPresentation);
- }
- break;
- case TopAbs_EDGE :
- {
- // cas perpendiculaire entre deux edges
- ComputeTwoEdgesPerpendicular(aPresentation);
- }
- break;
- default:
- break;
- }
- }
- // Cas pas traite - Edge/Face
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-void AIS_PerpendicularRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer)
-{
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
- const gp_Pnt& pos = myPosition;
- Handle(Select3D_SensitiveSegment) seg;
- Standard_Boolean ok1(Standard_False),ok2(Standard_False);
-
- if (!myFAttach.IsEqual(pos,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- myFAttach,
- pos);
- aSelection->Add(seg);
- ok1 = Standard_True;
- }
- if (!mySAttach.IsEqual(myPosition,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- mySAttach,
- pos);
- aSelection->Add(seg);
- ok2 = Standard_True;
- }
-
- if (ok1 && ok2) {
- gp_Vec vec1(gce_MakeDir(pos,myFAttach));
- gp_Vec vec2(gce_MakeDir(pos,mySAttach));
- Standard_Real dist1(pos.Distance(myFAttach));
- Standard_Real dist2(pos.Distance(mySAttach));
- vec1 *= dist1;
- vec1 *= .2;
- vec2 *= dist2;
- vec2 *= .2;
-
- gp_Pnt pAx11 = pos.Translated(vec1);
- gp_Pnt pAx22 = pos.Translated(vec2);
- gp_Pnt p_symb = pAx22.Translated(vec1);
- seg = new Select3D_SensitiveSegment(own,pAx11,p_symb);
- aSelection->Add(seg);
- seg = new Select3D_SensitiveSegment(own,p_symb,pAx22);
- aSelection->Add(seg);
- }
-}
-
-//=======================================================================
-//function : ComputeTwoFacesPerpendicular
-//purpose :
-//=======================================================================
-void AIS_PerpendicularRelation::ComputeTwoFacesPerpendicular
- (const Handle(Prs3d_Presentation)& /*aPresentation*/)
-{
-}
-
-//=======================================================================
-//function : ComputeTwoEdgesPerpendicular
-//purpose :
-//=======================================================================
-void AIS_PerpendicularRelation::ComputeTwoEdgesPerpendicular(const Handle(Prs3d_Presentation)& aPresentation)
-{
- // 3d lines
- Handle(Geom_Curve) geom1,geom2;
- gp_Pnt pint3d,p1,p2,pAx1,pAx2,ptat11,ptat12,ptat21,ptat22;
- Standard_Boolean isInfinite1,isInfinite2;
- Handle(Geom_Curve) extCurv;
- if ( !AIS::ComputeGeometry(TopoDS::Edge(myFShape),TopoDS::Edge(mySShape),
- myExtShape,
- geom1,geom2,
- ptat11,ptat12,ptat21,ptat22,
- extCurv,
- isInfinite1,isInfinite2,
- myPlane) ) return;
-
- Standard_Boolean interOut1(Standard_False),interOut2(Standard_False);
-
- Handle(Geom_Line) geom_lin1;
- Handle(Geom_Line) geom_lin2;
- if ( geom1->IsInstance(STANDARD_TYPE(Geom_Ellipse)) )
- {
- Handle(Geom_Ellipse) geom_el (Handle(Geom_Ellipse)::DownCast (geom1));
- // construct lines through focuses
- gp_Ax1 elAx = geom_el->XAxis();
- gp_Lin ll (elAx);
- geom_lin1 = new Geom_Line(ll);
- Standard_Real focex = geom_el->MajorRadius() - geom_el->Focal()/2.0;
- gp_Vec transvec = gp_Vec(elAx.Direction())*focex;
- ptat11 = geom_el->Focus1().Translated(transvec);
- ptat12 = geom_el->Focus2().Translated(-transvec);
- interOut1 = Standard_True;
- }
- else if ( geom1->IsInstance(STANDARD_TYPE(Geom_Line)) )
- {
- geom_lin1 = Handle(Geom_Line)::DownCast (geom1);
- }
- else return;
-
- if (geom2->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
- {
- Handle(Geom_Ellipse) geom_el (Handle(Geom_Ellipse)::DownCast (geom2));
- // construct lines through focuses
- gp_Ax1 elAx = geom_el->XAxis();
- gp_Lin ll (elAx);
- geom_lin2 = new Geom_Line(ll);
- Standard_Real focex = geom_el->MajorRadius() - geom_el->Focal()/2.0;
- gp_Vec transvec = gp_Vec(elAx.Direction())*focex;
- ptat21 = geom_el->Focus1().Translated(transvec);
- ptat22 = geom_el->Focus2().Translated(-transvec);
- interOut2 = Standard_True;
- }
- else if ( geom2->IsInstance(STANDARD_TYPE(Geom_Line)) )
- {
- geom_lin2 = Handle(Geom_Line)::DownCast (geom2);
- }
- else return;
-
- // current face
- BRepBuilderAPI_MakeFace makeface (myPlane->Pln());
- TopoDS_Face face (makeface.Face());
- BRepAdaptor_Surface adp (makeface.Face());
-
- // 2d lines => projection of 3d on current plane
- Handle(Geom2d_Curve) aGeom2dCurve = GeomAPI::To2d(geom_lin1,myPlane->Pln());
- Handle(Geom2d_Line) lin1_2d = Handle(Geom2d_Line)::DownCast (aGeom2dCurve) ;
- aGeom2dCurve = GeomAPI::To2d(geom_lin2,myPlane->Pln());
- Handle(Geom2d_Line) lin2_2d = Handle(Geom2d_Line)::DownCast (aGeom2dCurve) ;
- IntAna2d_AnaIntersection inter(lin1_2d->Lin2d(),lin2_2d->Lin2d());
- if (!inter.IsDone()) return;
- if (!inter.NbPoints()) return;
-
- gp_Pnt2d pint(inter.Point(1).Value());
- pint3d = adp.Value(pint.X(),pint.Y());
-
- myPosition = pint3d;
- // recherche points attache
- Standard_Real par1,par2,curpar,pmin,pmax;//,dist,sign;
- Standard_Real length(0.);
-
- if ( isInfinite1 && isInfinite2 )
- {
- Standard_Real curpar1 = ElCLib::Parameter(geom_lin1->Lin(),pint3d);
- Standard_Real curpar2 = ElCLib::Parameter(geom_lin2->Lin(),pint3d);
- par1 = par2 = 50.;
- p1 = p2 = pint3d;
- myFAttach = ElCLib::Value(curpar1+par1,geom_lin1->Lin());
- mySAttach = ElCLib::Value(curpar2+par2,geom_lin2->Lin());
- }
- else
- {
- Standard_Boolean lengthComputed (Standard_False);
- if ( !isInfinite1 )
- {
- curpar = ElCLib::Parameter(geom_lin1->Lin(),pint3d);
- par1 = ElCLib::Parameter(geom_lin1->Lin(),ptat11);
- par2 = ElCLib::Parameter(geom_lin1->Lin(),ptat12);
- pmin = Min(par1,par2);
- pmax = Max(par1,par2);
-
- if ( myPosition.SquareDistance(ptat11) > myPosition.SquareDistance(ptat12) )
- p1 = ptat11;
- else
- p1 = ptat12;
- if ( (curpar < pmin) || (curpar > pmax) )
- {
- interOut1 = Standard_True;
- }
- if ( !isInfinite2 ) length = 2.*Min(ptat11.Distance(ptat12),ptat21.Distance(ptat22))/5.;
- else length = 2.*ptat11.Distance(ptat12)/5.;
- lengthComputed = Standard_True;
- gp_Vec vec1 (gce_MakeDir(myPosition,p1));
- vec1.Multiply(length);
- pAx1 = myPosition.Translated(vec1);
- myFAttach = pAx1;
- }
- if ( !isInfinite2 )
- {
- curpar = ElCLib::Parameter(geom_lin2->Lin(),pint3d);
- par1 = ElCLib::Parameter(geom_lin2->Lin(),ptat21);
- par2 = ElCLib::Parameter(geom_lin2->Lin(),ptat22);
- pmin = Min(par1,par2);
- pmax = Max(par1,par2);
-
- if ( myPosition.SquareDistance(ptat21) > myPosition.SquareDistance(ptat22) ) p2 = ptat21;
- else p2 = ptat22;
- if ( (curpar < pmin) || (curpar > pmax) )
- {
- interOut2 = Standard_True;
- }
- gp_Vec vec2 (gce_MakeDir(myPosition,p2));
- if ( !lengthComputed )
- {
- if ( !isInfinite1 ) length = 2.*Min(ptat11.Distance(ptat12),ptat21.Distance(ptat22))/5.;
- else length = 2.*ptat21.Distance(ptat22)/5.;
- }
- vec2.Multiply(length);
- pAx2 = myPosition.Translated(vec2);
- mySAttach = pAx2;
- }
- if ( isInfinite1 )
- {
- p1 = myPosition;
- gp_Vec vec1(geom_lin1->Lin().Direction());
- vec1.Multiply(length);
- myFAttach = myPosition.Translated(vec1);
- }
- if ( isInfinite2 )
- {
- p2 = myPosition;
- gp_Vec vec2(geom_lin2->Lin().Direction());
- vec2.Multiply(length);
- mySAttach = myPosition.Translated(vec2);
- }
- }
- DsgPrs_PerpenPresentation::Add(aPresentation,myDrawer,
- myFAttach,mySAttach,
- p1,p2,
- myPosition,
- interOut1,interOut2);
-
- if ( (myExtShape != 0) && !extCurv.IsNull()) {
- gp_Pnt pf,pl;
- if ( myExtShape == 1 ) {
- if (!isInfinite1) {
- pf = ptat11;
- pl = ptat12;
- }
- aPresentation->SetInfiniteState(isInfinite1);
- ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(myFShape),geom_lin1,pf,pl);
- }
- else {
- if (!isInfinite2) {
- pf = ptat21;
- pl = ptat22;
- }
- aPresentation->SetInfiniteState(isInfinite2);
- ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(mySShape),geom_lin2,pf,pl);
- }
- }
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Jean-Pierre COMBE/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_PerpendicularRelation_HeaderFile
-#define _AIS_PerpendicularRelation_HeaderFile
-
-#include <AIS_Relation.hxx>
-
-DEFINE_STANDARD_HANDLE(AIS_PerpendicularRelation, AIS_Relation)
-
-//! A framework to display constraints of perpendicularity
-//! between two or more interactive datums. These
-//! datums can be edges or faces.
-class AIS_PerpendicularRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_PerpendicularRelation, AIS_Relation)
-public:
-
- //! Constructs an object to display constraints of
- //! perpendicularity on shapes.
- //! This object is defined by a first shape aFShape, a
- //! second shape aSShape, and a plane aPlane.
- //! aPlane is the plane of reference to show and test the
- //! perpendicular relation between two shapes, at least
- //! one of which has a revolved surface.
- Standard_EXPORT AIS_PerpendicularRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane);
-
- //! Constructs an object to display constraints of
- //! perpendicularity on shapes.
- //! This object is defined by a first shape aFShape and a
- //! second shape aSShape.
- Standard_EXPORT AIS_PerpendicularRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape);
-
-private:
-
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeTwoFacesPerpendicular (const Handle(Prs3d_Presentation)& aPresentation);
-
- Standard_EXPORT void ComputeTwoEdgesPerpendicular (const Handle(Prs3d_Presentation)& aPresentation);
-
- gp_Pnt myFAttach;
- gp_Pnt mySAttach;
-
-};
-
-#endif // _AIS_PerpendicularRelation_HeaderFile
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Jean-Pierre COMBE/Odile Olivier/Serguei Zaritchny
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AIS_RadiusDimension.hxx>
-
-#include <AIS.hxx>
-#include <BRepLib_MakeEdge.hxx>
-#include <ElCLib.hxx>
-#include <gce_MakeDir.hxx>
-
-
-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 (AIS_KOD_RADIUS)
-{
- SetMeasuredGeometry (theCircle);
- SetSpecialSymbol (THE_RADIUS_SYMBOL);
- SetDisplaySpecialSymbol (AIS_DSS_Before);
- SetFlyout (0.0);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
- const gp_Pnt& theAttachPoint)
-: AIS_Dimension (AIS_KOD_RADIUS)
-{
- SetMeasuredGeometry (theCircle, theAttachPoint);
- SetSpecialSymbol (THE_RADIUS_SYMBOL);
- SetDisplaySpecialSymbol (AIS_DSS_Before);
- SetFlyout (0.0);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
-: AIS_Dimension (AIS_KOD_RADIUS)
-{
- SetMeasuredGeometry (theShape);
- SetSpecialSymbol (THE_RADIUS_SYMBOL);
- SetDisplaySpecialSymbol (AIS_DSS_Before);
- SetFlyout (0.0);
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle,
- const gp_Pnt& theAnchorPoint,
- const Standard_Boolean theHasAnchor)
-{
- myCircle = theCircle;
- myGeometryType = GeometryType_Edge;
- myShape = BRepLib_MakeEdge (theCircle);
- myAnchorPoint = theHasAnchor ? theAnchorPoint : ElCLib::Value (0, myCircle);
- myIsGeometryValid = IsValidCircle (myCircle) && IsValidAnchor (myCircle, myAnchorPoint);
-
- if (myIsGeometryValid)
- {
- ComputePlane();
- }
-
- SetToUpdate();
-}
-
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_RadiusDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape,
- const gp_Pnt& theAnchorPoint,
- const Standard_Boolean theHasAnchor)
-{
- Standard_Boolean isClosed = Standard_False;
- myShape = theShape;
- myGeometryType = GeometryType_UndefShapes;
- myIsGeometryValid = InitCircularDimension (theShape, myCircle, myAnchorPoint, isClosed)
- && IsValidCircle (myCircle);
- if (theHasAnchor)
- {
- myAnchorPoint = theAnchorPoint;
- myIsGeometryValid = myIsGeometryValid && IsValidAnchor (myCircle, myAnchorPoint);
- }
-
- if (myIsGeometryValid)
- {
- ComputePlane();
- }
-
- 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 (!myIsGeometryValid)
- {
- 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)
-{
- mySelectionGeom.Clear (theMode);
-
- if (!IsValid())
- {
- return;
- }
-
- DrawLinearDimension (thePresentation, theMode, myAnchorPoint, myCircle.Location(), Standard_True);
-}
-
-//=======================================================================
-//function : IsValidCircle
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_RadiusDimension::IsValidCircle (const gp_Circ& theCircle) const
-{
- return theCircle.Radius() > Precision::Confusion();
-}
-
-//=======================================================================
-//function : IsValidAnchor
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_RadiusDimension::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());
-
- return anAnchorDist > Precision::Confusion()
- && aCirclePlane.Contains (theAnchor, Precision::Confusion());
-}
-
-//=======================================================================
-//function : GetTextPosition
-//purpose :
-//=======================================================================
-const gp_Pnt AIS_RadiusDimension::GetTextPosition() const
-{
- if (IsTextPositionCustom())
- {
- return myFixedTextPosition;
- }
-
- // Counts text position according to the dimension parameters
- return GetTextPositionForLinear (myAnchorPoint, myCircle.Location(), Standard_True);
-}
-
-//=======================================================================
-//function : GetTextPosition
-//purpose :
-//=======================================================================
-void AIS_RadiusDimension::SetTextPosition (const gp_Pnt& theTextPos)
-{
- if (!myIsGeometryValid)
- {
- return;
- }
-
- myIsTextPositionFixed = Standard_True;
- myFixedTextPosition = theTextPos;
-
- SetToUpdate();
-}
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_RadiusDimension_HeaderFile
-#define _AIS_RadiusDimension_HeaderFile
-
-#include <AIS.hxx>
-#include <AIS_Dimension.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Circ.hxx>
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-
-class AIS_RadiusDimension;
-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:
-
- //! Create radius dimension for the circle geometry.
- //! @param theCircle [in] the circle to measure.
- Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle);
-
- //! 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 attachment on the circle.
- Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
- const gp_Pnt& theAnchorPoint);
-
- //! Create radius dimension for the arbitrary shape (if possible).
- //! @param theShape [in] the shape to measure.
- Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& theShape);
-
-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.
- void SetMeasuredGeometry (const gp_Circ& theCircle) { SetMeasuredGeometry (theCircle, gp_Pnt(), Standard_False); }
-
- //! 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 radius 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, should be on the circle
- //! @param theHasAnchor [in] should be set TRUE if theAnchorPoint should be used
- Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle,
- const gp_Pnt& theAnchorPoint,
- const Standard_Boolean theHasAnchor = Standard_True);
-
- //! 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.
- void SetMeasuredGeometry (const TopoDS_Shape& theShape) { SetMeasuredGeometry (theShape, gp_Pnt(), Standard_False); }
-
- //! 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.
- //! @param theAnchorPoint [in] the point to attach the dimension lines, should be on the circle
- //! @param theHasAnchor [in] should be set TRUE if theAnchorPoint should be used
- Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape,
- const gp_Pnt& theAnchorPoint,
- const Standard_Boolean theHasAnchor = Standard_True);
-
- //! @return the display units string.
- Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE;
-
- //! @return the model units string.
- Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
-
- Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
-
- Standard_EXPORT virtual const gp_Pnt GetTextPosition() const Standard_OVERRIDE;
-
-public:
-
- DEFINE_STANDARD_RTTIEXT(AIS_RadiusDimension,AIS_Dimension)
-
-protected:
-
- Standard_EXPORT virtual void ComputePlane();
-
- //! 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_OVERRIDE;
-
- Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE;
-
- Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode = 0) Standard_OVERRIDE;
-
-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:
-
- gp_Circ myCircle;
- gp_Pnt myAnchorPoint;
- TopoDS_Shape myShape;
-};
-
-#endif // _AIS_RadiusDimension_HeaderFile
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_GraphicTool.hxx>
-#include <AIS_Relation.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <ElCLib.hxx>
-#include <Geom_CartesianPoint.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Surface.hxx>
-#include <Graphic3d_ArrayOfSegments.hxx>
-#include <gp_Circ.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pnt.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Precision.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_PointAspect.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Quantity_Color.hxx>
-#include <Standard_Type.hxx>
-#include <StdPrs_Point.hxx>
-#include <StdPrs_WFShape.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopExp.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_Relation,AIS_InteractiveObject)
-
-//=======================================================================
-//function : AIS_Relation
-//purpose :
-//=======================================================================
-AIS_Relation::AIS_Relation(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
-:AIS_InteractiveObject(aTypeOfPresentation3d),
- myVal(1.),
- myPosition(0.,0.,0.),
- myArrowSize( myVal / 10. ),
- myAutomaticPosition(Standard_True),
- myExtShape(0),
- myFirstOffset(0.),mySecondOffset(0.),
- myIsSetBndBox( Standard_False ),
- myArrowSizeIsDefined( Standard_False)
-{
-}
-
-
-
-//=======================================================================
-//function : ComputeProjEdgePresentation
-//purpose :
-//=======================================================================
-
-void AIS_Relation::ComputeProjEdgePresentation(const Handle(Prs3d_Presentation)& aPrs,
- const TopoDS_Edge& anEdge,
- const Handle(Geom_Curve)& ProjCurv,
- const gp_Pnt& FirstP,
- const gp_Pnt& LastP,
- const Quantity_NameOfColor aColor,
- const Standard_Real width,
- const Aspect_TypeOfLine aProjTOL,
- const Aspect_TypeOfLine aCallTOL) const
-{
- if (!myDrawer->HasOwnWireAspect()){
- myDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aProjTOL,2.));}
- else {
- const Handle(Prs3d_LineAspect)& li = myDrawer->WireAspect();
- li->SetColor(aColor);
- li->SetTypeOfLine(aProjTOL);
- li->SetWidth(width);
- }
-
- Standard_Real pf, pl;
- TopLoc_Location loc;
- Handle(Geom_Curve) curve;
- Standard_Boolean isInfinite;
- curve = BRep_Tool::Curve(anEdge,loc,pf,pl);
- isInfinite = (Precision::IsInfinite(pf) || Precision::IsInfinite(pl));
-
- TopoDS_Edge E;
-
- // Calcul de la presentation de l'edge
- if (ProjCurv->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
- Handle(Geom_Line) gl (Handle(Geom_Line)::DownCast (ProjCurv));
- if ( !isInfinite) {
- pf = ElCLib::Parameter(gl->Lin(),FirstP);
- pl = ElCLib::Parameter(gl->Lin(),LastP);
- BRepBuilderAPI_MakeEdge MakEd(gl->Lin(), pf, pl);
- E = MakEd.Edge();
- }
- else {
- BRepBuilderAPI_MakeEdge MakEd(gl->Lin());
- E = MakEd.Edge();
- }
- }
- else if (ProjCurv->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
- Handle(Geom_Circle) gc (Handle(Geom_Circle)::DownCast (ProjCurv));
- pf = ElCLib::Parameter(gc->Circ(),FirstP);
- pl = ElCLib::Parameter(gc->Circ(),LastP);
- BRepBuilderAPI_MakeEdge MakEd(gc->Circ(),pf, pl);
- E = MakEd.Edge();
- }
- StdPrs_WFShape::Add (aPrs, E, myDrawer);
-
- //Calcul de la presentation des lignes de raccord
- myDrawer->WireAspect()->SetTypeOfLine(aCallTOL);
- if (!isInfinite) {
- gp_Pnt ppf, ppl;
- ppf = BRep_Tool::Pnt( TopExp::FirstVertex(TopoDS::Edge(anEdge)));
- ppl = BRep_Tool::Pnt( TopExp::LastVertex(TopoDS::Edge(anEdge)));
- if (FirstP.Distance (ppf) > gp::Resolution())
- {
- BRepBuilderAPI_MakeEdge MakEd1 (FirstP, ppf);
- StdPrs_WFShape::Add (aPrs, MakEd1.Edge(), myDrawer);
- }
- else
- {
- BRepBuilderAPI_MakeVertex MakVert1 (FirstP);
- StdPrs_WFShape::Add (aPrs, MakVert1.Vertex(), myDrawer);
- }
- if (LastP.Distance (ppl) > gp::Resolution())
- {
- BRepBuilderAPI_MakeEdge MakEd2 (LastP, ppl);
- StdPrs_WFShape::Add (aPrs, MakEd2.Edge(), myDrawer);
- }
- else
- {
- BRepBuilderAPI_MakeVertex MakVert2 (LastP);
- StdPrs_WFShape::Add (aPrs, MakVert2.Vertex(), myDrawer);
- }
-/*
- BRepBuilderAPI_MakeEdge MakEd1 (FirstP, ppf);
- StdPrs_WFShape::Add (aPrs, MakEd1.Edge(), myDrawer);
- BRepBuilderAPI_MakeEdge MakEd2 (LastP, ppl);
- StdPrs_WFShape::Add (aPrs, MakEd2.Edge(), myDrawer);
-*/
- }
-}
-
-
-//=======================================================================
-//function : ComputeProjVertexPresentation
-//purpose :
-//=======================================================================
-
-void AIS_Relation::ComputeProjVertexPresentation(const Handle(Prs3d_Presentation)& aPrs,
- const TopoDS_Vertex& aVertex,
- const gp_Pnt& ProjPoint,
- const Quantity_NameOfColor aColor,
- const Standard_Real width,
- const Aspect_TypeOfMarker aProjTOM,
- const Aspect_TypeOfLine aCallTOL) const
-{
- if (!myDrawer->HasOwnPointAspect()){
- myDrawer->SetPointAspect(new Prs3d_PointAspect(aProjTOM, aColor,1));}
- else {
- const Handle(Prs3d_PointAspect)& pa = myDrawer->PointAspect();
- pa->SetColor(aColor);
- pa->SetTypeOfMarker(aProjTOM);
- }
-
- {
- Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
- Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
- anArrayOfPoints->AddVertex (ProjPoint);
- aGroup->SetGroupPrimitivesAspect (myDrawer->PointAspect()->Aspect());
- aGroup->AddPrimitiveArray (anArrayOfPoints);
- }
-
- if (!myDrawer->HasOwnWireAspect()){
- myDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aCallTOL,2.));}
- else {
- const Handle(Prs3d_LineAspect)& li = myDrawer->WireAspect();
- li->SetColor(aColor);
- li->SetTypeOfLine(aCallTOL);
- li->SetWidth(width);
- }
-
- // Si les points ne sont pas confondus...
- if (!ProjPoint.IsEqual (BRep_Tool::Pnt(aVertex),Precision::Confusion()))
- {
- Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
- Handle(Graphic3d_ArrayOfSegments) anArrayOfLines = new Graphic3d_ArrayOfSegments (2);
- anArrayOfLines->AddVertex (ProjPoint);
- anArrayOfLines->AddVertex (BRep_Tool::Pnt(aVertex));
- aGroup->SetGroupPrimitivesAspect (myDrawer->WireAspect()->Aspect());
- aGroup->AddPrimitiveArray (anArrayOfLines);
- }
-}
-
-//=======================================================================
-//function : SetColor
-//purpose :
-//=======================================================================
-void AIS_Relation::SetColor(const Quantity_Color &aCol)
-{
- if(hasOwnColor && myDrawer->Color() == aCol) return;
-
- if (!myDrawer->HasOwnTextAspect()) myDrawer->SetTextAspect(new Prs3d_TextAspect());
- hasOwnColor=Standard_True;
- myDrawer->SetColor (aCol);
- myDrawer->TextAspect()->SetColor(aCol);
-
- Standard_Real WW = HasWidth()? Width(): myDrawer->HasLink() ?
- AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.;
- if (!myDrawer->HasOwnLineAspect()) {
- myDrawer->SetLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
- }
- if (!myDrawer->HasOwnDimensionAspect()) {
- myDrawer->SetDimensionAspect(new Prs3d_DimensionAspect);
- }
-
- myDrawer->LineAspect()->SetColor(aCol);
- const Handle(Prs3d_DimensionAspect)& DIMENSION = myDrawer->DimensionAspect();
- const Handle(Prs3d_LineAspect)& LINE = myDrawer->LineAspect();
- const Handle(Prs3d_TextAspect)& TEXT = myDrawer->TextAspect();
-
- DIMENSION->SetLineAspect(LINE);
- DIMENSION->SetTextAspect(TEXT);
-}
-
-//=======================================================================
-//function : UnsetColor
-//purpose :
-//=======================================================================
-void AIS_Relation::UnsetColor()
-{
- if (!hasOwnColor) return;
- hasOwnColor = Standard_False;
- const Handle(Prs3d_LineAspect)& LA = myDrawer->LineAspect();
- Quantity_Color CC = Quantity_NOC_YELLOW;
- if (myDrawer->HasLink())
- {
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
- myDrawer->SetTextAspect(myDrawer->Link()->TextAspect());
- }
- LA->SetColor(CC);
- myDrawer->DimensionAspect()->SetLineAspect(LA);
-}
-
-//=======================================================================
-//function : AcceptDisplayMode
-//purpose :
-//=======================================================================
-
- Standard_Boolean AIS_Relation::
-AcceptDisplayMode(const Standard_Integer aMode) const
-{return aMode == 0;}
-
-
-//=======================================================================
-//function : SetFirstShape
-//purpose :
-//=======================================================================
-
-void AIS_Relation::SetFirstShape(const TopoDS_Shape& aFShape)
-{
- myFShape = aFShape;
-}
-
-
-//=======================================================================
-//function : SetSecondShape
-//purpose :
-//=======================================================================
-
-void AIS_Relation::SetSecondShape(const TopoDS_Shape& aSShape)
-{
- mySShape = aSShape;
-}
-
-//=======================================================================
-//function : KindOfDimension
-//purpose :
-//=======================================================================
-AIS_KindOfDimension AIS_Relation::KindOfDimension() const
-{return AIS_KOD_NONE;}
-
-//=======================================================================
-//function : IsMovable
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_Relation::IsMovable() const
-{return Standard_False;}
-
-
+++ /dev/null
-// Created on: 1997-02-27
-// Created by: Odile Olivier
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_Relation_HeaderFile
-#define _AIS_Relation_HeaderFile
-
-#include <AIS_KindOfDimension.hxx>
-#include <AIS_KindOfInteractive.hxx>
-#include <AIS_KindOfSurface.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <Aspect_TypeOfMarker.hxx>
-#include <Bnd_Box.hxx>
-#include <DsgPrs_ArrowSide.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopoDS_Shape.hxx>
-
-class Geom_Curve;
-class Geom_Plane;
-class Geom_Surface;
-class TopoDS_Edge;
-class TopoDS_Vertex;
-
-//! One of the four types of interactive object in
-//! AIS,comprising dimensions and constraints. Serves
-//! as the abstract class for the seven relation classes as
-//! well as the seven dimension classes.
-//! The statuses available for relations between shapes are as follows:
-//! - 0 - there is no connection to a shape;
-//! - 1 - there is a connection to the first shape;
-//! - 2 - there is a connection to the second shape.
-//! The connection takes the form of an edge between the two shapes.
-class AIS_Relation : public AIS_InteractiveObject
-{
- DEFINE_STANDARD_RTTIEXT(AIS_Relation, AIS_InteractiveObject)
-public:
-
- //! Allows you to provide settings for the color theColor
- //! of the lines representing the relation between the two shapes.
- Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
-
- //! Allows you to remove settings for the color of the
- //! lines representing the relation between the two shapes.
- Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
-
- virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Relation; }
-
- //! Indicates that the type of dimension is unknown.
- Standard_EXPORT virtual AIS_KindOfDimension KindOfDimension() const;
-
- //! Returns true if the interactive object is movable.
- Standard_EXPORT virtual Standard_Boolean IsMovable() const;
-
- const TopoDS_Shape& FirstShape() const { return myFShape; }
-
- Standard_EXPORT virtual void SetFirstShape (const TopoDS_Shape& aFShape);
-
- //! Returns the second shape.
- const TopoDS_Shape& SecondShape() const { return mySShape; }
-
- //! Allows you to identify the second shape aSShape
- //! relative to the first.
- Standard_EXPORT virtual void SetSecondShape (const TopoDS_Shape& aSShape);
-
- void SetBndBox (const Standard_Real theXmin, const Standard_Real theYmin, const Standard_Real theZmin,
- const Standard_Real theXmax, const Standard_Real theYmax, const Standard_Real theZmax)
- {
- myBndBox.Update (theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
- myIsSetBndBox = Standard_True;
- }
-
- void UnsetBndBox() { myIsSetBndBox = Standard_False; }
-
- //! Returns the plane.
- const Handle(Geom_Plane)& Plane() const { return myPlane; }
-
- //! Allows you to set the plane thePlane. This is used to
- //! define relations and dimensions in several daughter classes.
- void SetPlane (const Handle(Geom_Plane)& thePlane) { myPlane = thePlane; }
-
- //! Returns the value of each object in the relation.
- Standard_Real Value() const { return myVal; }
-
- //! Allows you to provide settings for the value theVal for each object in the relation.
- void SetValue (const Standard_Real theVal) { myVal = theVal; }
-
- //! Returns the position set using SetPosition.
- const gp_Pnt& Position() const { return myPosition; }
-
- //! Allows you to provide the objects in the relation with
- //! settings for a non-default position.
- void SetPosition (const gp_Pnt& thePosition)
- {
- myPosition = thePosition;
- myAutomaticPosition = Standard_False;
- }
-
- //! Returns settings for text aspect.
- const TCollection_ExtendedString& Text() const { return myText; }
-
- //! Allows you to provide the settings theText for text aspect.
- void SetText (const TCollection_ExtendedString& theText) { myText = theText; }
-
- //! Returns the value for the size of the arrow identifying
- //! the relation between the two shapes.
- Standard_Real ArrowSize() const { return myArrowSize; }
-
- //! Allows you to provide settings for the size of the
- //! arrow theArrowSize identifying the relation between the two shapes.
- void SetArrowSize (const Standard_Real theArrowSize)
- {
- myArrowSize = theArrowSize;
- myArrowSizeIsDefined = Standard_True;
- }
-
- //! Returns the value of the symbol presentation. This will be one of:
- //! - AS_NONE - none
- //! - AS_FIRSTAR - first arrow
- //! - AS_LASTAR - last arrow
- //! - AS_BOTHAR - both arrows
- //! - AS_FIRSTPT - first point
- //! - AS_LASTPT - last point
- //! - AS_BOTHPT - both points
- //! - AS_FIRSTAR_LASTPT - first arrow, last point
- //! - AS_FIRSTPT_LASTAR - first point, last arrow
- DsgPrs_ArrowSide SymbolPrs() const { return mySymbolPrs; }
-
- //! Allows you to provide settings for the symbol presentation.
- void SetSymbolPrs (const DsgPrs_ArrowSide theSymbolPrs) { mySymbolPrs = theSymbolPrs; }
-
- //! Allows you to set the status of the extension shape by
- //! the index aIndex.
- //! The status will be one of the following:
- //! - 0 - there is no connection to a shape;
- //! - 1 - there is a connection to the first shape;
- //! - 2 - there is a connection to the second shape.
- void SetExtShape (const Standard_Integer theIndex) { myExtShape = theIndex; }
-
- //! Returns the status index of the extension shape.
- Standard_Integer ExtShape() const { return myExtShape; }
-
- //! Returns true if the display mode aMode is accepted
- //! for the Interactive Objects in the relation.
- //! ComputeProjPresentation(me;
- //! aPres : Presentation from Prs3d;
- //! Curve1 : Curve from Geom;
- //! Curve2 : Curve from Geom;
- //! FirstP1 : Pnt from gp;
- //! LastP1 : Pnt from gp;
- //! FirstP2 : Pnt from gp;
- //! LastP2 : Pnt from gp;
- //! aColor : NameOfColor from Quantity = Quantity_NOC_PURPLE;
- //! aWidth : Real from Standard = 2;
- //! aProjTOL : TypeOfLine from Aspect = Aspect_TOL_DASH;
- //! aCallTOL : TypeOfLine from Aspect = Aspect_TOL_DOT)
- Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
-
- void SetAutomaticPosition (const Standard_Boolean theStatus) { myAutomaticPosition = theStatus; }
-
- Standard_Boolean AutomaticPosition() const { return myAutomaticPosition; }
-
-protected:
-
- Standard_EXPORT AIS_Relation(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
-
- //! Calculates the presentation aPres of the the edge
- //! anEdge and the curve it defines, ProjCurve. The later
- //! is also specified by the first point FirstP and the last point LastP.
- //! The presentation includes settings for color aColor,
- //! type - aProjTOL and aCallTOL - and width of line, aWidth.
- Standard_EXPORT void ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPres, const TopoDS_Edge& anEdge, const Handle(Geom_Curve)& ProjCurve, const gp_Pnt& FirstP, const gp_Pnt& LastP, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfLine aProjTOL = Aspect_TOL_DASH, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT) const;
-
- //! Calculates the presentation aPres of the the vertex
- //! aVertex and the point it defines, ProjPoint.
- //! The presentation includes settings for color aColor,
- //! type - aProjTOM and aCallTOL - and width of line, aWidth.
- Standard_EXPORT void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT) const;
-
-protected:
-
- TopoDS_Shape myFShape;
- TopoDS_Shape mySShape;
- Handle(Geom_Plane) myPlane;
- Standard_Real myVal;
- gp_Pnt myPosition;
- TCollection_ExtendedString myText;
- Standard_Real myArrowSize;
- Standard_Boolean myAutomaticPosition;
- DsgPrs_ArrowSide mySymbolPrs;
- Standard_Integer myExtShape;
- gp_Pln myFirstPlane;
- gp_Pln mySecondPlane;
- Handle(Geom_Surface) myFirstBasisSurf;
- Handle(Geom_Surface) mySecondBasisSurf;
- AIS_KindOfSurface myFirstSurfType;
- AIS_KindOfSurface mySecondSurfType;
- Standard_Real myFirstOffset;
- Standard_Real mySecondOffset;
- Bnd_Box myBndBox;
- Standard_Boolean myIsSetBndBox;
- Standard_Boolean myArrowSizeIsDefined;
-
-};
-
-DEFINE_STANDARD_HANDLE(AIS_Relation, AIS_InteractiveObject)
-
-#endif // _AIS_Relation_HeaderFile
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef AIS_SequenceOfDimension_HeaderFile
-#define AIS_SequenceOfDimension_HeaderFile
-
-#include <AIS_Relation.hxx>
-#include <NCollection_Sequence.hxx>
-
-typedef NCollection_Sequence<Handle(AIS_Relation)> AIS_SequenceOfDimension;
-
-
-#endif
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_StandardDatum_HeaderFile
-#define _AIS_StandardDatum_HeaderFile
-
-//! Declares the type of standard datum of an Interactive Object.
-enum AIS_StandardDatum
-{
-AIS_SD_None,
-AIS_SD_Point,
-AIS_SD_Axis,
-AIS_SD_Trihedron,
-AIS_SD_PlaneTrihedron,
-AIS_SD_Line,
-AIS_SD_Circle,
-AIS_SD_Plane
-};
-
-#endif // _AIS_StandardDatum_HeaderFile
+++ /dev/null
-// Created on: 1997-03-03
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_SymmetricRelation.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <DsgPrs_SymmetricPresentation.hxx>
-#include <ElCLib.hxx>
-#include <gce_MakeLin.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Circ.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <Precision.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_SymmetricRelation,AIS_Relation)
-
-//=======================================================================
-//function : AIS_SymmetricRelation
-//purpose :
-//=======================================================================
-AIS_SymmetricRelation::AIS_SymmetricRelation(const TopoDS_Shape& aSymmTool,
- const TopoDS_Shape& FirstShape,
- const TopoDS_Shape& SecondShape,
- const Handle(Geom_Plane)& aPlane)
-:AIS_Relation(),
- myTool(aSymmTool)
-{
- SetFirstShape(FirstShape);
- SetSecondShape(SecondShape);
- SetPlane(aPlane);
- myPosition = aPlane->Pln().Location();
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_SymmetricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aprs,
- const Standard_Integer)
-{
- switch (myFShape.ShapeType()) {
- case TopAbs_FACE :
- {
- // cas symetrie entre deux faces
- ComputeTwoFacesSymmetric(aprs);
- }
- break;
- case TopAbs_EDGE :
- {
- // cas symetrie entre deux edges
- ComputeTwoEdgesSymmetric(aprs);
- }
- break;
- case TopAbs_VERTEX :
- {
- // cas symetrie entre deux vertexs
- ComputeTwoVerticesSymmetric(aprs);
- }
- break;
- default:
- break;
- }
- if (myTool.ShapeType() == TopAbs_EDGE) {
- Handle(Geom_Curve) aCurve,extcurve;
- gp_Pnt p1,p2;
- Standard_Boolean isinfinite,isonplane;
- if (AIS::ComputeGeometry(TopoDS::Edge(myTool),
- aCurve,p1,p2,
- extcurve,
- isinfinite,
- isonplane,
- myPlane)) {
- if (!extcurve.IsNull()) {
- gp_Pnt pf, pl;
- if (!isinfinite) {
- pf = p1;
- pl = p2;
- }
- if (isinfinite) aprs->SetInfiniteState(Standard_True);
- ComputeProjEdgePresentation(aprs,TopoDS::Edge(myTool),aCurve,pf,pl);
- }
- }
- }
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-void AIS_SymmetricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
- const Standard_Integer)
-{
- Handle(Select3D_SensitiveSegment) seg;
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
- Standard_Real F,L;
-
- Handle(Geom_Curve) geom_axis, extcurve;
- gp_Pnt p1,p2;
- Standard_Boolean isinfinite,isonplane;
- if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
- geom_axis,p1,p2,
- extcurve,
- isinfinite,
- isonplane,
- myPlane)) return;
-
- Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
- gp_Lin laxis (geom_line->Lin());
-
- if(myFShape.ShapeType() != TopAbs_VERTEX){
- BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
-
- if(cu1.GetType() == GeomAbs_Line) {
-// gp_Lin L1 (myFAttach,myFDirAttach);
- gp_Pnt PjAttachPnt1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
- gp_Pnt PjOffSetPnt = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
- Standard_Real h = fabs(PjOffSetPnt.Distance(PjAttachPnt1)/cos(myAxisDirAttach.Angle(myFDirAttach)));
- gp_Vec VL1(myFDirAttach);
- gp_Vec VLa(PjAttachPnt1,PjOffSetPnt);
- Standard_Real scal = VL1.Dot(VLa);
- if(scal < 0) VL1.Reverse();
- VL1.Multiply(h);
- gp_Pnt P1 = myFAttach.Translated(VL1);
- gp_Pnt ProjAxis = ElCLib::Value(ElCLib::Parameter(laxis,P1),laxis);
- gp_Vec v(P1,ProjAxis);
- gp_Pnt P2 = ProjAxis.Translated(v);
-
- gp_Lin L3;
-
- if (!P1.IsEqual(P2,Precision::Confusion())) {
- L3 = gce_MakeLin(P1,P2);
- }
- else {
- L3 = gce_MakeLin(P1,myFDirAttach);
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle(Select3D_SensitiveBox) box =
- new Select3D_SensitiveBox(own,
- myPosition.X(),
- myPosition.Y(),
- myPosition.Z(),
- myPosition.X()+size,
- myPosition.Y()+size,
- myPosition.Z()+size);
- aSel->Add(box);
- }
- Standard_Real parmin,parmax,parcur;
- parmin = ElCLib::Parameter(L3,P1);
- parmax = parmin;
-
- parcur = ElCLib::Parameter(L3,P2);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- parcur = ElCLib::Parameter(L3,myPosition);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- gp_Pnt PointMin = ElCLib::Value(parmin,L3);
- gp_Pnt PointMax = ElCLib::Value(parmax,L3);
-
- if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- PointMin,
- PointMax);
- aSel->Add(seg);
- }
- if (!myFAttach.IsEqual(P1,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- myFAttach,
- P1);
- aSel->Add(seg);
- }
- if (!mySAttach.IsEqual(P2,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- mySAttach,
- P2);
- aSel->Add(seg);
- }
- }
-
- //=======================Pour les arcs======================
- if(cu1.GetType() == GeomAbs_Circle) {
- Handle(Geom_Curve) aGeomCurve = BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
- Handle(Geom_Circle) geom_circ1 = Handle(Geom_Circle)::DownCast (aGeomCurve) ;
-// Handle(Geom_Circle) geom_circ1 = (const Handle(Geom_Circle)&) BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
- gp_Circ circ1(geom_circ1->Circ());
- gp_Pnt OffsetPnt(myPosition.X(),myPosition.Y(),myPosition.Z());
- gp_Pnt Center1 = circ1.Location();
- gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,OffsetPnt),laxis);
- gp_Pnt ProjCenter1 = ElCLib::Value(ElCLib::Parameter(laxis,Center1),laxis);
- gp_Vec Vp(ProjCenter1,Center1);
- if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(laxis.Direction())^myPlane->Pln().Position().Direction();
- Standard_Real Dt,R,h;
- Dt = ProjCenter1.Distance(ProjOffsetPoint);
- R = circ1.Radius();
- if (Dt > .999*R) {
- Dt = .999*R;
- gp_Vec Vout(ProjCenter1,ProjOffsetPoint);
- ProjOffsetPoint = ProjCenter1.Translated(Vout.Divided(Vout.Magnitude()).Multiplied(Dt));
- OffsetPnt = ProjOffsetPoint;
- }
- h = Sqrt(R*R - Dt*Dt);
- gp_Pnt P1 = ProjOffsetPoint.Translated(Vp.Added(Vp.Divided(Vp.Magnitude()).Multiplied(h)));
- gp_Vec v(P1,ProjOffsetPoint);
- gp_Pnt P2 = ProjOffsetPoint.Translated(v);
-
- gp_Lin L3;
- if (!P1.IsEqual(P2,Precision::Confusion())) {
- L3 = gce_MakeLin(P1,P2);
- }
- else {
- L3 = gce_MakeLin(P1,laxis.Direction());
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle(Select3D_SensitiveBox) box =
- new Select3D_SensitiveBox(own,
- myPosition.X(),
- myPosition.Y(),
- myPosition.Z(),
- myPosition.X()+size,
- myPosition.Y()+size,
- myPosition.Z()+size);
- aSel->Add(box);
- }
- Standard_Real parmin,parmax,parcur;
- parmin = ElCLib::Parameter(L3,P1);
- parmax = parmin;
-
- parcur = ElCLib::Parameter(L3,P2);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- parcur = ElCLib::Parameter(L3,myPosition);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- gp_Pnt PointMin = ElCLib::Value(parmin,L3);
- gp_Pnt PointMax = ElCLib::Value(parmax,L3);
-
- if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,
- PointMin,
- PointMax);
- aSel->Add(seg);
- }
- }
- }
- //=======================Pour les points======================
- else {
- if (myFAttach.IsEqual(mySAttach,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,myPosition,myFAttach);
- aSel->Add(seg);
- }
- else{
- gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
- gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
- gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,myFAttach);
- gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1);
- gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed());
- gp_Lin L3;
-
- if (!P1.IsEqual(P2,Precision::Confusion())) {
- L3 = gce_MakeLin(P1,P2);
- }
- else {
- L3 = gce_MakeLin(P1,myFDirAttach);
- Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
- Handle(Select3D_SensitiveBox) box =
- new Select3D_SensitiveBox(own,
- myPosition.X(),
- myPosition.Y(),
- myPosition.Z(),
- myPosition.X()+size,
- myPosition.Y()+size,
- myPosition.Z()+size);
- aSel->Add(box);
- }
- Standard_Real parmin,parmax,parcur;
- parmin = ElCLib::Parameter(L3,P1);
- parmax = parmin;
-
- parcur = ElCLib::Parameter(L3,P2);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- parcur = ElCLib::Parameter(L3,myPosition);
- parmin = Min(parmin,parcur);
- parmax = Max(parmax,parcur);
-
- gp_Pnt PointMin = ElCLib::Value(parmin,L3);
- gp_Pnt PointMax = ElCLib::Value(parmax,L3);
-
- if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,PointMin,PointMax);
- aSel->Add(seg);
- }
- if (!myFAttach.IsEqual(P1,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,myFAttach,P1);
- aSel->Add(seg);
- }
- if (!mySAttach.IsEqual(P2,Precision::Confusion())) {
- seg = new Select3D_SensitiveSegment(own,mySAttach,P2);
- aSel->Add(seg);
- }
- }
- }
-}
-
-//=======================================================================
-//function : ComputeTwoFacesSymmetric
-//purpose :
-//=======================================================================
-void AIS_SymmetricRelation::ComputeTwoFacesSymmetric(const Handle(Prs3d_Presentation)&)
-{
-}
-
-//=======================================================================
-//function : ComputeTwoEdgesSymmetric
-//purpose :
-//=======================================================================
-void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presentation)& aprs)
-{
- BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
- if (cu1.GetType() != GeomAbs_Line && cu1.GetType() != GeomAbs_Circle) return;
- BRepAdaptor_Curve cu2(TopoDS::Edge(mySShape));
- if (cu2.GetType() != GeomAbs_Line && cu2.GetType() != GeomAbs_Circle) return;
-// gp_Pnt pint3d,ptat11,ptat12,ptat21,ptat22;
- gp_Pnt ptat11,ptat12,ptat21,ptat22;
- Handle(Geom_Curve) geom1,geom2;
- Standard_Boolean isInfinite1,isInfinite2;
- Handle(Geom_Curve) extCurv;
- if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),
- TopoDS::Edge(mySShape),
- myExtShape,
- geom1,
- geom2,
- ptat11,
- ptat12,
- ptat21,
- ptat22,
- extCurv,
- isInfinite1,isInfinite2,
- myPlane)) {
- return;
- }
- aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0));
- Handle(Geom_Curve) geom_axis,extcurve;
- gp_Pnt p1,p2;
- Standard_Boolean isinfinite,isonplane;
- if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
- geom_axis,p1,p2,
- extcurve,
- isinfinite,
- isonplane,
- myPlane)) return;
-
- Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
- gp_Lin laxis (geom_line->Lin());
- myAxisDirAttach = laxis.Direction();
-
- if(cu1.GetType() == GeomAbs_Line){
- Handle(Geom_Line) geom_lin1 (Handle(Geom_Line)::DownCast (geom1));
- gp_Lin l1(geom_lin1->Lin());
- myFDirAttach = l1.Direction();
- }
- gp_Circ circ;
- if(cu1.GetType() == GeomAbs_Circle){
- Handle(Geom_Circle) geom_cir1 (Handle(Geom_Circle)::DownCast (geom1));
- gp_Circ c(geom_cir1->Circ());
- circ = c;
- }
-
- // recherche points attache
- gp_Pnt ProjOffset = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
-
-/*//----------------------------------------------------
- //Quand on fait la symetrie de 2 edges consecutifs:
- //
- // :<-- Axe
- // :
- // /:\
- // Edge n --->/ : \
- // / : \<-- Edge n+1
- // :
- //----------------------------------------------------
-*/
- Standard_Boolean idem = Standard_False;
- if (isInfinite1 && isInfinite2) { // geom1 et geom2 sont des lignes
- const gp_Lin& line2 = Handle(Geom_Line)::DownCast (geom2)->Lin();
- if (myAutomaticPosition) {
- myFAttach = Handle(Geom_Line)::DownCast (geom1)->Lin().Location();
- mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
- }
- else {
- const gp_Lin& line1 = Handle(Geom_Line)::DownCast (geom1)->Lin();
- myFAttach = ElCLib::Value(ElCLib::Parameter(line1,myPosition),line1);
- mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
- }
- }
- else if (!isInfinite1 && !isInfinite2) {
- if (ptat11.IsEqual(ptat21,Precision::Confusion())) {
- myFAttach = ptat12;
- mySAttach = ptat22;
- idem = Standard_True;
- }
- if (ptat11.IsEqual(ptat22,Precision::Confusion())) {
- myFAttach = ptat12;
- mySAttach = ptat21;
- idem = Standard_True;
- }
- if (ptat12.IsEqual(ptat21,Precision::Confusion())) {
- myFAttach = ptat11;
- mySAttach = ptat22;
- idem = Standard_True;
- }
- if (ptat12.IsEqual(ptat22,Precision::Confusion())) {
- myFAttach = ptat11;
- mySAttach = ptat21;
- idem = Standard_True;
- }
- if(!idem){
- if( ProjOffset.SquareDistance(ptat11) > ProjOffset.SquareDistance(ptat12)) myFAttach = ptat12;
- else myFAttach = ptat11;
-
- if (ProjOffset.SquareDistance(ptat21) > ProjOffset.SquareDistance(ptat22)) mySAttach = ptat22;
- else mySAttach = ptat21;
- }
- }
- else if (isInfinite1) {// geom1 et geom2 sont des lignes
- mySAttach = ptat21;
- const gp_Lin& line1 = Handle(Geom_Line)::DownCast (geom1)->Lin();
- myFAttach = ElCLib::Value(ElCLib::Parameter(line1,mySAttach),line1);
- }
- else if (isInfinite2) {// geom1 et geom2 sont des lignes
- myFAttach = ptat11;
- const gp_Lin& line2 = Handle(Geom_Line)::DownCast (geom2)->Lin();
- mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
- }
-
- if( !myArrowSizeIsDefined )
- myArrowSize = myFAttach.Distance(mySAttach)/50.;
- //----------------------------------------------------
-
- //----------------------------------------------------
- // Si myFAttach <> mySAttach et PjFAttach = myFAttach
- //----------------------------------------------------
- gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
-
- if (PjFAttach.IsEqual(myFAttach,Precision::Confusion())){
- Handle(Geom_Line) geom_lin2 (Handle(Geom_Line)::DownCast (geom2));
- gp_Lin l2(geom_lin2->Lin());
- myFDirAttach = l2.Direction();
- gp_Pnt PntTempo;
- PntTempo = myFAttach;
- myFAttach = mySAttach;
- mySAttach = PntTempo;
- PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
- }
-
- //----------------------------------------------------
-// gp_Pnt curpos;
-
- if (myAutomaticPosition) {
- //gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
- // offset pour eviter confusion Edge et Dimension
- gp_Vec offset(myAxisDirAttach);
- offset = offset * myArrowSize * (-5);
- gp_Vec Vt(myFAttach, PjFAttach);
- gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15)));
- myPosition = curpos;
- }
-
- gp_Pnt Pj1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
- gp_Pnt Pj2 = ElCLib::Value(ElCLib::Parameter(laxis,mySAttach),laxis);
- if ((myFAttach.SquareDistance(Pj1)+mySAttach.SquareDistance(Pj2)) <= Precision::Confusion()) myArrowSize = 0.;
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
- arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
- if(cu1.GetType() == GeomAbs_Line)
- DsgPrs_SymmetricPresentation::Add(aprs,
- myDrawer,
- myFAttach,
- mySAttach,
- myFDirAttach,
- laxis,
- myPosition);
-
- if(cu1.GetType() == GeomAbs_Circle)
- DsgPrs_SymmetricPresentation::Add(aprs,
- myDrawer,
- myFAttach,
- mySAttach,
- circ,
- laxis,
- myPosition);
- if ( (myExtShape != 0) && !extCurv.IsNull()) {
- gp_Pnt pf, pl;
- if ( myExtShape == 1 ) {
- if (!isInfinite1) {
- pf = ptat11;
- pl = ptat12;
- }
- ComputeProjEdgePresentation(aprs,TopoDS::Edge(myFShape),geom1,pf,pl);
- }
- else {
- if (!isInfinite2) {
- pf = ptat21;
- pl = ptat22;
- }
- ComputeProjEdgePresentation(aprs,TopoDS::Edge(mySShape),geom2,pf,pl);
- }
- }
-}
-
-//=======================================================================
-//function : ComputeTwoVertexsSymmetric
-//purpose :
-//=======================================================================
-void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs)
-{
- if(myFShape.ShapeType() != TopAbs_VERTEX || mySShape.ShapeType() != TopAbs_VERTEX) return;
- Handle(Geom_Curve) geom_axis,extcurve;
- gp_Pnt p1,p2;
- Standard_Boolean isinfinite,isonplane;
- if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
- geom_axis,p1,p2,
- extcurve,
- isinfinite,
- isonplane,
- myPlane)) return;
-
- Standard_Boolean isOnPlane1, isOnPlane2;
-
- AIS::ComputeGeometry(TopoDS::Vertex(myFShape), myFAttach, myPlane, isOnPlane1);
- AIS::ComputeGeometry(TopoDS::Vertex(mySShape), mySAttach, myPlane, isOnPlane2);
-
- if( !myArrowSizeIsDefined )
- myArrowSize = myFAttach.Distance(mySAttach)/50.;
-
- if (isOnPlane1 && isOnPlane2)
- myExtShape = 0;
- else if ( isOnPlane1 && !isOnPlane2)
- myExtShape = 2;
- else if (!isOnPlane1 && isOnPlane2)
- myExtShape = 1;
- else
- return ;
-
- Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
- gp_Lin laxis (geom_line->Lin());
- myAxisDirAttach = laxis.Direction();
-
- // recherche points attache
-// gp_Pnt curpos;
- if (myAutomaticPosition) {
- gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
- // offset pour eviter confusion Edge et Dimension
- gp_Vec offset(myAxisDirAttach);
- offset = offset * myArrowSize * (-5);
- gp_Vec Vt(myFAttach, PjFAttach);
- gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15)));
- myPosition = curpos;
- }
- if (2*(myFAttach.Distance(mySAttach)) <= Precision::Confusion()) myArrowSize = 0.;
- Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
- Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
- arr = la->ArrowAspect();
- arr->SetLength(myArrowSize);
- DsgPrs_SymmetricPresentation::Add(aprs,
- myDrawer,
- myFAttach,
- mySAttach,
- laxis,
- myPosition);
- if ( myExtShape == 1)
- ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myFShape),myFAttach);
- else if ( myExtShape == 2)
- ComputeProjVertexPresentation(aprs,TopoDS::Vertex(mySShape),mySAttach);
-}
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1997-03-03
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_SymmetricRelation_HeaderFile
-#define _AIS_SymmetricRelation_HeaderFile
-
-#include <TopoDS_Shape.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
-#include <AIS_Relation.hxx>
-
-DEFINE_STANDARD_HANDLE(AIS_SymmetricRelation, AIS_Relation)
-
-//! A framework to display constraints of symmetricity
-//! between two or more datum Interactive Objects.
-//! A plane serves as the axis of symmetry between the
-//! shapes of which the datums are parts.
-class AIS_SymmetricRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_SymmetricRelation, AIS_Relation)
-public:
-
- //! Constructs an object to display constraints of symmetricity.
- //! This object is defined by a tool aSymmTool, a first
- //! shape FirstShape, a second shape SecondShape, and a plane aPlane.
- //! aPlane serves as the axis of symmetry.
- //! aSymmTool is the shape composed of FirstShape
- //! SecondShape and aPlane. It may be queried and
- //! edited using the functions GetTool and SetTool.
- //! The two shapes are typically two edges, two vertices or two points.
- Standard_EXPORT AIS_SymmetricRelation(const TopoDS_Shape& aSymmTool, const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& aPlane);
-
- //! Returns true if the symmetric constraint display is movable.
- virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
-
- //! Sets the tool aSymmetricTool composed of a first
- //! shape, a second shape, and a plane.
- //! This tool is initially created at construction time.
- void SetTool (const TopoDS_Shape& aSymmetricTool);
-
- //! Returns the tool composed of a first shape, a second
- //! shape, and a plane. This tool is created at construction time.
- const TopoDS_Shape& GetTool() const;
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeTwoFacesSymmetric (const Handle(Prs3d_Presentation)& aprs);
-
- Standard_EXPORT void ComputeTwoEdgesSymmetric (const Handle(Prs3d_Presentation)& aprs);
-
- Standard_EXPORT void ComputeTwoVerticesSymmetric (const Handle(Prs3d_Presentation)& aprs);
-
- TopoDS_Shape myTool;
- gp_Pnt myFAttach;
- gp_Pnt mySAttach;
- gp_Dir myFDirAttach;
- gp_Dir myAxisDirAttach;
-
-};
-
-#include <AIS_SymmetricRelation.lxx>
-
-#endif // _AIS_SymmetricRelation_HeaderFile
+++ /dev/null
-// Created on: 1997-03-03
-// Created by: Jean-Pierre COMBE
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : SetTool
-//purpose :
-//=======================================================================
-inline void AIS_SymmetricRelation::SetTool(const TopoDS_Shape& aSymmetricTool)
-{
- myTool = aSymmetricTool;
-}
-
-//=======================================================================
-//function : GetTool
-//purpose :
-//=======================================================================
-inline const TopoDS_Shape& AIS_SymmetricRelation::GetTool() const
-{
- return myTool;
-}
-
-
-//=======================================================================
-//function : IsMovable
-//purpose :
-//=======================================================================
-inline Standard_Boolean AIS_SymmetricRelation::IsMovable() const
-{
- return Standard_True;
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Jean-Pierre COMBE/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS.hxx>
-#include <AIS_Shape.hxx>
-#include <AIS_TangentRelation.hxx>
-#include <Bnd_Box.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <DsgPrs_TangentPresentation.hxx>
-#include <ElCLib.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
-#include <GeomAPI_ExtremaCurveCurve.hxx>
-#include <gp_Circ.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Vec.hxx>
-#include <Precision.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <TColStd_ListIteratorOfListOfTransient.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(AIS_TangentRelation,AIS_Relation)
-
-//=======================================================================
-//function : Constructor
-//purpose :
-//=======================================================================
-AIS_TangentRelation::AIS_TangentRelation(const TopoDS_Shape& aFShape,
- const TopoDS_Shape& aSShape,
- const Handle(Geom_Plane)& aPlane,
- const Standard_Integer anExternRef)
- :myExternRef(anExternRef)
-{
- myFShape = aFShape;
- mySShape = aSShape;
- myPlane = aPlane;
- myAutomaticPosition = Standard_False;
-}
-
-//=======================================================================
-//function : ExternRef
-//purpose :
-//=======================================================================
-Standard_Integer AIS_TangentRelation::ExternRef()
-{
- return myExternRef;
-}
-
-//=======================================================================
-//function : SetExternRef
-//purpose :
-//=======================================================================
-void AIS_TangentRelation::SetExternRef(const Standard_Integer aRef)
-{
- myExternRef = aRef;
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-void AIS_TangentRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer)
-{
- switch (myFShape.ShapeType())
- {
- case TopAbs_FACE :
- {
- ComputeTwoFacesTangent(aPresentation);
- }
- break;
- case TopAbs_EDGE :
- {
- ComputeTwoEdgesTangent(aPresentation);
- }
- break;
- default:
- break;
- }
-}
-
-//=======================================================================
-//function : ComputeSelection
-//purpose :
-//=======================================================================
-void AIS_TangentRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
- const Standard_Integer)
-{
- gp_Vec vec(myDir);
- gp_Vec vec1 = vec.Multiplied(myLength);
- gp_Vec vec2 = vec.Multiplied(-myLength);
- gp_Pnt p1 = myPosition.Translated(vec1);
- gp_Pnt p2 = myPosition.Translated(vec2);
-
- Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
- Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,p1,p2);
- aSelection->Add(seg);
-}
-
-//=======================================================================
-//function : ComputeTwoFacesTangent
-//purpose :
-//=======================================================================
-void AIS_TangentRelation::ComputeTwoFacesTangent
- (const Handle(Prs3d_Presentation)& /*aPresentation*/)
-{
-}
-
-// jfa 19/10/2000 begin
-//=======================================================================
-//function : ComputeTangencyPoint
-//purpose :
-//=======================================================================
-static Standard_Boolean ComputeTangencyPoint(const Handle(Geom_Curve)& GC1,
- const Handle(Geom_Curve)& GC2,
- gp_Pnt& aPoint)
-{
- Standard_Real U1f = GC1->FirstParameter();
- Standard_Real U1l = GC1->LastParameter();
- Standard_Real U2f = GC2->FirstParameter();
- Standard_Real U2l = GC2->LastParameter();
-
- gp_Pnt PC1;
- Standard_Real mindist=0;
- GeomAPI_ExtremaCurveCurve Ex(GC1,GC2,U1f,U1l,U2f,U2l);
- for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++)
- {
- gp_Pnt P1,P2;
- Ex.Points(i,P1,P2);
- Standard_Real dist = P1.Distance(P2);
- if ( i == 1 )
- {
- mindist = dist;
- PC1 = P1;
- }
- else
- {
- if ( (dist < mindist) || (dist < Precision::Confusion()) )
- {
- mindist = dist;
- PC1 = P1;
- }
- }
- if ( dist < Precision::Confusion() )
- {
- if (GC1->IsInstance(STANDARD_TYPE(Geom_Line)))
- {
- continue; // tangent line and conic can have only one point with zero distance
- }
- gp_Vec aVector1,aVector2;
- if (GC1->IsInstance(STANDARD_TYPE(Geom_Circle)))
- {
- Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (GC1));
- Standard_Real par_inter = ElCLib::Parameter(circle->Circ(), P1);
- ElCLib::D1(par_inter,circle->Circ(),P1,aVector1);
- }
- else if (GC1->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
- {
- Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (GC1));
- Standard_Real par_inter = ElCLib::Parameter(ellipse->Elips(), P1);
- ElCLib::D1(par_inter,ellipse->Elips(),P1,aVector1);
- }
- if (GC2->IsInstance(STANDARD_TYPE(Geom_Circle)))
- {
- Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (GC2));
- Standard_Real par_inter = ElCLib::Parameter(circle->Circ(), P2);
- ElCLib::D1(par_inter,circle->Circ(),P2,aVector2);
- }
- else if (GC2->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
- {
- Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (GC2));
- Standard_Real par_inter = ElCLib::Parameter(ellipse->Elips(), P2);
- ElCLib::D1(par_inter,ellipse->Elips(),P2,aVector2);
- }
-// if ( aVector1.IsParallel(aVector2, 100*Precision::Angular()) ) break;
- if ( aVector1.IsParallel(aVector2, M_PI / 360.0) ) break; // 0.5 graduce
- }
- }
- aPoint = PC1;
- return Standard_True;
-}
-// jfa 19/10/2000 end
-
-//=======================================================================
-//function : ComputeTwoEdgesTangent
-//purpose :
-//=======================================================================
-void AIS_TangentRelation::ComputeTwoEdgesTangent(const Handle(Prs3d_Presentation)& aPresentation)
-{
- Handle(Geom_Curve) copy1,copy2;
- gp_Pnt ptat11,ptat12,ptat21,ptat22;
- Standard_Boolean isInfinite1,isInfinite2;
- Handle(Geom_Curve) extCurv;
- if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),
- TopoDS::Edge(mySShape),
- myExtShape,
- copy1,
- copy2,
- ptat11,
- ptat12,
- ptat21,
- ptat22,
- extCurv,
- isInfinite1,isInfinite2,
- myPlane))
- {
- return;
- }
-
- aPresentation->SetInfiniteState(isInfinite1 || isInfinite2);
- // current face
- BRepBuilderAPI_MakeFace makeface(myPlane->Pln());
- TopoDS_Face face(makeface.Face());
- BRepAdaptor_Surface adp(makeface.Face());
-
- Standard_Integer typArg(0);
-
- if (copy1->IsInstance(STANDARD_TYPE(Geom_Line)))
- {
- typArg = 10;
- }
- else if (copy1->IsInstance(STANDARD_TYPE(Geom_Circle)))
- {
- typArg = 20;
- }
- else if (copy1->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
- {
- typArg = 30;
- }
- else return;
-
- if (copy2->IsInstance(STANDARD_TYPE(Geom_Line)))
- {
- typArg += 1;
- }
- else if (copy2->IsInstance(STANDARD_TYPE(Geom_Circle)))
- {
- typArg += 2;
- }
- else if (copy2->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
- {
- typArg += 3;
- }
- else return;
-
- //First find the tangengy vector if exists
- TopoDS_Vertex VCom;
- TopExp_Explorer expF(TopoDS::Edge(myFShape),TopAbs_VERTEX);
- TopExp_Explorer expS(TopoDS::Edge(mySShape),TopAbs_VERTEX);
- TopoDS_Shape tab[2];
- Standard_Integer p ;
- for (p = 0; expF.More(); expF.Next(),p++)
- {
- tab[p] = TopoDS::Vertex(expF.Current());
- }
- Standard_Boolean found(Standard_False);
- for ( ; expS.More() && !found; expS.Next())
- {
- for ( Standard_Integer l = 0; l<=p && !found; l++)
- {
- found = ( expS.Current().IsSame(tab[l]));
- if (found) VCom = TopoDS::Vertex(expS.Current());
- }
- }
-
- gp_Vec theVector;
- gp_Pnt pint3d; // tangency point
- gp_Dir theDir; // tangency direction
- Standard_Real par_inter = 0.0; // parameter of tangency point
-
- if (found)
- {
- pint3d = BRep_Tool::Pnt(VCom);
- }
-
- // Otherwise it is found as if it was known that 2 curves
- // are tangents (which must be the cases)
- switch (typArg)
- {
- case 12: // circle line
- {
- Handle(Geom_Line) line (Handle(Geom_Line)::DownCast (copy1));
- Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (copy2));
-
- if ( !found )
- {
- // it is enough to project the circus center on the straight line
- par_inter = ElCLib::Parameter(line->Lin(), circle->Location());
- pint3d = ElCLib::Value(par_inter, line->Lin());
- }
-
- theDir = line->Lin().Direction();
- myLength = circle->Radius()/5.;
- if ( !isInfinite1 )
- {
- Standard_Real copy1Length = ptat12.Distance(ptat11);
- if ( copy1Length < myLength )
- myLength = copy1Length/3.;
- }
- }
- break;
- case 21: // circle line
- {
- Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (copy1));
- Handle(Geom_Line) line (Handle(Geom_Line)::DownCast (copy2));
-
- if (!found)
- {
- // it is enough to project the circus center on the straight line
- par_inter = ElCLib::Parameter(line->Lin(), circle->Location());
- pint3d = ElCLib::Value(par_inter, line->Lin());
- }
-
- theDir = line->Lin().Direction();
- myLength = circle->Radius()/5.;
- if (!isInfinite2)
- {
- Standard_Real copy2Length = ptat21.Distance(ptat22);
- if ( copy2Length < myLength )
- myLength = copy2Length/3.;
- }
- }
- break;
- // jfa 19/10/2000 begin
- case 13: // line ellipse
- {
- Handle(Geom_Line) line (Handle(Geom_Line)::DownCast (copy1));
- Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (copy2));
-
- if (!found)
- {
- ComputeTangencyPoint(line,ellipse,pint3d);
- }
-
- theDir = line->Lin().Direction();
- myLength = ellipse->MajorRadius()/5.;
-
- if (!isInfinite1)
- {
- Standard_Real copy1Length = ptat12.Distance(ptat11);
- if ( copy1Length < myLength )
- myLength = copy1Length/3.;
- }
- }
- break;
- case 31: // ellipse line
- {
- Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (copy1));
- Handle(Geom_Line) line (Handle(Geom_Line)::DownCast (copy2));
-
- if (!found)
- {
- ComputeTangencyPoint(line,ellipse,pint3d);
- }
-
- theDir = line->Lin().Direction();
- myLength = ellipse->MajorRadius()/5.;
-
- if (!isInfinite2)
- {
- Standard_Real copy2Length = ptat21.Distance(ptat22);
- if ( copy2Length < myLength )
- myLength = copy2Length/3.;
- }
- }
- break;
- case 22: // circle circle
- {
- Handle(Geom_Circle) circle1 (Handle(Geom_Circle)::DownCast (copy1));
- Handle(Geom_Circle) circle2 (Handle(Geom_Circle)::DownCast (copy2));
- Standard_Real R1 = circle1->Radius();
- Standard_Real R2 = circle2->Radius();
- myLength = Max(R1,R2)/5.0;
- if ( !found )
- {
- if ( (circle1->Location()).IsEqual(circle2->Location(),Precision::Confusion()) )
- {
- if ( R1 >= R2 )
- {
- ElCLib::D1(par_inter,circle1->Circ(),pint3d,theVector);
- }
- else
- {
- ElCLib::D1(par_inter,circle2->Circ(),pint3d,theVector);
- }
- }
- else
- {
- if ( R1 >= R2 )
- {
- par_inter = ElCLib::Parameter(circle1->Circ(), circle2->Location());
- ElCLib::D1(par_inter,circle1->Circ(),pint3d,theVector);
- }
- else
- {
- par_inter = ElCLib::Parameter(circle2->Circ(), circle1->Location());
- ElCLib::D1(par_inter,circle2->Circ(),pint3d,theVector);
- }
- }
- }
- else
- {
- par_inter = ElCLib::Parameter(circle1->Circ(), pint3d);
- ElCLib::D1(par_inter,circle1->Circ(),pint3d,theVector);
- }
- theDir = gp_Dir(theVector);
- }
- break;
- case 23: // circle ellipse
- {
- Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (copy1));
- Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (copy2));
- Standard_Real R1 = circle->Radius();
- Standard_Real R2 = ellipse->MajorRadius();
- myLength = Max(R1,R2)/5.0;
- if (!found)
- {
- if ( R1 >= R2 )
- {
- ComputeTangencyPoint(circle,ellipse,pint3d);
- par_inter = ElCLib::Parameter(circle->Circ(), pint3d);
- ElCLib::D1(par_inter,circle->Circ(),pint3d,theVector);
- }
- else
- {
- ComputeTangencyPoint(ellipse,circle,pint3d);
- par_inter = ElCLib::Parameter(ellipse->Elips(), pint3d);
- ElCLib::D1(par_inter,ellipse->Elips(),pint3d,theVector);
- }
- }
- else
- {
- par_inter = ElCLib::Parameter(circle->Circ(), pint3d);
- ElCLib::D1(par_inter,circle->Circ(),pint3d,theVector);
- }
- theDir = gp_Dir(theVector);
- }
- break;
- case 32: // ellipse circle
- {
- Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (copy1));
- Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (copy2));
- Standard_Real R1 = ellipse->MajorRadius();
- Standard_Real R2 = circle->Radius();
- myLength = Max(R1,R2)/5.0;
- if (!found)
- {
- if ( R1 >= R2 )
- {
- ComputeTangencyPoint(ellipse,circle,pint3d);
- par_inter = ElCLib::Parameter( ellipse->Elips(), pint3d);
- ElCLib::D1(par_inter,ellipse->Elips(),pint3d,theVector);
- }
- else
- {
- ComputeTangencyPoint(circle,ellipse,pint3d);
- par_inter = ElCLib::Parameter( circle->Circ(), pint3d);
- ElCLib::D1(par_inter,circle->Circ(),pint3d,theVector);
- }
- }
- else
- {
- par_inter = ElCLib::Parameter(circle->Circ(), pint3d);
- ElCLib::D1(par_inter,circle->Circ(),pint3d,theVector);
- }
- theDir = gp_Dir(theVector);
- }
- break;
- case 33: // ellipse ellipse
- {
- Handle(Geom_Ellipse) ellipse1 (Handle(Geom_Ellipse)::DownCast (copy1));
- Handle(Geom_Ellipse) ellipse2 (Handle(Geom_Ellipse)::DownCast (copy2));
- Standard_Real R1 = ellipse1->MajorRadius();
- Standard_Real R2 = ellipse2->MajorRadius();
- myLength = Max(R1,R2)/5.0;
- if (!found)
- {
- if ( R1 > R2 )
- {
- ComputeTangencyPoint(ellipse1,ellipse2,pint3d);
- par_inter = ElCLib::Parameter( ellipse1->Elips(), pint3d);
- ElCLib::D1(par_inter,ellipse1->Elips(),pint3d,theVector);
- }
- else
- {
- ComputeTangencyPoint(ellipse2,ellipse1,pint3d);
- par_inter = ElCLib::Parameter( ellipse2->Elips(), pint3d);
- ElCLib::D1(par_inter,ellipse2->Elips(),pint3d,theVector);
- }
- }
- else
- {
- par_inter = ElCLib::Parameter(ellipse1->Elips(), pint3d);
- ElCLib::D1(par_inter,ellipse1->Elips(),pint3d,theVector);
- }
- theDir = gp_Dir(theVector);
- }
- break;
- // jfa 19/10/2000 end
- default:
- return;
- }
-
- myAttach = pint3d;
- myDir = theDir;
- myPosition = pint3d;
- myLength = Min(myLength,myArrowSize);
-
- DsgPrs_TangentPresentation::Add(aPresentation,myDrawer,myAttach,myDir,myLength);
- if ( (myExtShape != 0) && !extCurv.IsNull())
- {
- gp_Pnt pf, pl;
- if ( myExtShape == 1 )
- {
- if (!isInfinite1)
- {
- pf = ptat11;
- pl = ptat12;
- }
- ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(myFShape),copy1,pf,pl);
- }
- else
- {
- if (!isInfinite2)
- {
- pf = ptat21;
- pl = ptat22;
- }
- ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(mySShape),copy2,pf,pl);
- }
- }
-}
+++ /dev/null
-// Created on: 1996-12-05
-// Created by: Jean-Pierre COMBE/Odile Olivier
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_TangentRelation_HeaderFile
-#define _AIS_TangentRelation_HeaderFile
-
-#include <AIS_Relation.hxx>
-
-DEFINE_STANDARD_HANDLE(AIS_TangentRelation, AIS_Relation)
-
-//! A framework to display tangency constraints between
-//! two or more Interactive Objects of the datum type.
-//! The datums are normally faces or edges.
-class AIS_TangentRelation : public AIS_Relation
-{
- DEFINE_STANDARD_RTTIEXT(AIS_TangentRelation, AIS_Relation)
-public:
-
- //! TwoFacesTangent or TwoEdgesTangent relation
- //! Constructs an object to display tangency constraints.
- //! This object is defined by the first shape aFShape, the
- //! second shape aSShape, the plane aPlane and the index anExternRef.
- //! aPlane serves as an optional axis.
- //! anExternRef set to 0 indicates that there is no relation.
- Standard_EXPORT AIS_TangentRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane, const Standard_Integer anExternRef = 0);
-
- //! Returns the external reference for tangency.
- //! The values are as follows:
- //! - 0 - there is no connection;
- //! - 1 - there is a connection to the first shape;
- //! - 2 - there is a connection to the second shape.
- //! This reference is defined at construction time.
- Standard_EXPORT Standard_Integer ExternRef();
-
- //! Sets the external reference for tangency, aRef.
- //! The values are as follows:
- //! - 0 - there is no connection;
- //! - 1 - there is a connection to the first shape;
- //! - 2 - there is a connection to the second shape.
- //! This reference is initially defined at construction time.
- Standard_EXPORT void SetExternRef (const Standard_Integer aRef);
-
-private:
-
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeTwoFacesTangent (const Handle(Prs3d_Presentation)& aPresentation);
-
- Standard_EXPORT void ComputeTwoEdgesTangent (const Handle(Prs3d_Presentation)& aPresentation);
-
- gp_Pnt myAttach;
- gp_Dir myDir;
- Standard_Real myLength;
- Standard_Integer myExternRef;
-
-};
-
-#endif // _AIS_TangentRelation_HeaderFile
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_TypeOfAngle_HeaderFile
-#define _AIS_TypeOfAngle_HeaderFile
-
-//! Declares the type of angle.
-enum AIS_TypeOfAngle
-{
-AIS_TOA_Interior, //!< the angle between two lines built on geometry parameters
-AIS_TOA_Exterior //!< the angle equal 2 PI minus the interior angle
-};
-
-#endif // _AIS_TypeOfAngle_HeaderFile
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_TypeOfAngleArrowVisibility_HeaderFile
-#define _AIS_TypeOfAngleArrowVisibility_HeaderFile
-
-//! Declares what arrows are visible on angle presentation
-enum AIS_TypeOfAngleArrowVisibility
-{
-AIS_TOAV_Both, //!< both arrows of the first and the second angle tips
-AIS_TOAV_First, //!< only first point arrow
-AIS_TOAV_Second, //!< only second point arrow
-AIS_TOAV_None //!< arrows are not visible
-};
-
-#endif // _AIS_TypeOfAngleArrowVisibility_HeaderFile
+++ /dev/null
-// Created on: 1996-12-11
-// Created by: Robert COUBLANC
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _AIS_TypeOfDist_HeaderFile
-#define _AIS_TypeOfDist_HeaderFile
-
-//! To declare the type of distance.
-enum AIS_TypeOfDist
-{
-AIS_TOD_Unknown,
-AIS_TOD_Horizontal,
-AIS_TOD_Vertical
-};
-
-#endif // _AIS_TypeOfDist_HeaderFile
-AIS.cxx
AIS.hxx
AIS_Animation.cxx
AIS_Animation.hxx
AIS_AnimationCamera.hxx
AIS_AnimationObject.cxx
AIS_AnimationObject.hxx
-AIS_AngleDimension.cxx
-AIS_AngleDimension.hxx
AIS_AttributeFilter.cxx
AIS_AttributeFilter.hxx
AIS_AttributeFilter.lxx
AIS_C0RegularityFilter.hxx
AIS_CameraFrustum.cxx
AIS_CameraFrustum.hxx
-AIS_Chamf2dDimension.cxx
-AIS_Chamf2dDimension.hxx
-AIS_Chamf2dDimension.lxx
-AIS_Chamf3dDimension.cxx
-AIS_Chamf3dDimension.hxx
-AIS_Chamf3dDimension.lxx
AIS_Circle.cxx
AIS_Circle.hxx
AIS_ClearMode.hxx
AIS_DataMapOfShapeDrawer.hxx
AIS_ColorScale.cxx
AIS_ColorScale.hxx
-AIS_ConcentricRelation.cxx
-AIS_ConcentricRelation.hxx
AIS_ConnectedInteractive.cxx
AIS_ConnectedInteractive.hxx
AIS_ConnectStatus.hxx
AIS_DataMapofIntegerListOfinteractive.hxx
AIS_DataMapOfIOStatus.hxx
AIS_DataMapOfSelStat.hxx
-AIS_DiameterDimension.cxx
-AIS_DiameterDimension.hxx
-AIS_Dimension.cxx
-AIS_Dimension.hxx
-AIS_DimensionOwner.cxx
-AIS_DimensionOwner.hxx
-AIS_DimensionSelectionMode.hxx
AIS_DisplayMode.hxx
-AIS_DisplaySpecialSymbol.hxx
AIS_DisplayStatus.hxx
AIS_DragAction.hxx
-AIS_EllipseRadiusDimension.cxx
-AIS_EllipseRadiusDimension.hxx
-AIS_EqualDistanceRelation.cxx
-AIS_EqualDistanceRelation.hxx
-AIS_EqualDistanceRelation.lxx
-AIS_EqualRadiusRelation.cxx
-AIS_EqualRadiusRelation.hxx
AIS_ExclusionFilter.cxx
AIS_ExclusionFilter.hxx
AIS_ExclusionFilter.lxx
-AIS_FixRelation.cxx
-AIS_FixRelation.hxx
AIS_GlobalStatus.cxx
AIS_GlobalStatus.hxx
AIS_GraphicTool.cxx
AIS_GraphicTool.hxx
-AIS_IdenticRelation.cxx
-AIS_IdenticRelation.hxx
AIS_IndexedDataMapOfOwnerPrs.hxx
AIS_InteractiveContext.cxx
AIS_InteractiveContext.hxx
AIS_InteractiveContext_3.cxx
AIS_InteractiveObject.cxx
AIS_InteractiveObject.hxx
-AIS_KindOfDimension.hxx
AIS_KindOfInteractive.hxx
-AIS_KindOfRelation.hxx
-AIS_KindOfSurface.hxx
-AIS_KindOfUnit.hxx
-AIS_LengthDimension.cxx
-AIS_LengthDimension.hxx
AIS_Line.cxx
AIS_Line.hxx
AIS_ListIteratorOfListOfInteractive.hxx
AIS_ManipulatorOwner.cxx
AIS_MapIteratorOfMapOfInteractive.hxx
AIS_MapOfInteractive.hxx
-AIS_MaxRadiusDimension.cxx
-AIS_MaxRadiusDimension.hxx
AIS_MediaPlayer.cxx
AIS_MediaPlayer.hxx
AIS_MouseGesture.hxx
-AIS_MidPointRelation.cxx
-AIS_MidPointRelation.hxx
-AIS_MidPointRelation.lxx
-AIS_MinRadiusDimension.cxx
-AIS_MinRadiusDimension.hxx
AIS_MultipleConnectedInteractive.cxx
AIS_MultipleConnectedInteractive.hxx
AIS_MultipleConnectedInteractive.lxx
AIS_NavigationMode.hxx
AIS_NListOfEntityOwner.hxx
-AIS_OffsetDimension.cxx
-AIS_OffsetDimension.hxx
-AIS_OffsetDimension.lxx
-AIS_ParallelRelation.cxx
-AIS_ParallelRelation.hxx
-AIS_ParallelRelation.lxx
-AIS_PerpendicularRelation.cxx
-AIS_PerpendicularRelation.hxx
AIS_Plane.cxx
AIS_Plane.hxx
AIS_PlaneTrihedron.cxx
AIS_Point.hxx
AIS_PointCloud.cxx
AIS_PointCloud.hxx
-AIS_RadiusDimension.cxx
-AIS_RadiusDimension.hxx
-AIS_Relation.cxx
-AIS_Relation.hxx
AIS_RotationMode.hxx
AIS_RubberBand.hxx
AIS_RubberBand.cxx
AIS_Selection.hxx
AIS_SelectStatus.hxx
AIS_SelectionModesConcurrency.hxx
-AIS_SequenceOfDimension.hxx
AIS_SequenceOfInteractive.hxx
AIS_Shape.cxx
AIS_Shape.hxx
AIS_SignatureFilter.cxx
AIS_SignatureFilter.hxx
-AIS_StandardDatum.hxx
AIS_StatusOfDetection.hxx
AIS_StatusOfPick.hxx
-AIS_SymmetricRelation.cxx
-AIS_SymmetricRelation.hxx
-AIS_SymmetricRelation.lxx
-AIS_TangentRelation.cxx
-AIS_TangentRelation.hxx
AIS_TextLabel.cxx
AIS_TextLabel.hxx
AIS_TexturedShape.cxx
AIS_TrihedronSelectionMode.hxx
AIS_TypeFilter.cxx
AIS_TypeFilter.hxx
-AIS_TypeOfAngle.hxx
-AIS_TypeOfAngleArrowVisibility.hxx
AIS_TypeOfAttribute.hxx
AIS_TypeOfAxis.hxx
-AIS_TypeOfDist.hxx
AIS_TypeOfIso.hxx
AIS_TypeOfPlane.hxx
AIS_ViewController.cxx
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_AngleDimension_HeaderFile
+#define _AIS_AngleDimension_HeaderFile
+
+#include <PrsDim_AngleDimension.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_AngleDimension AIS_AngleDimension;
+
+#endif // _AIS_AngleDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_Chamf2dDimension_HeaderFile
+#define _AIS_Chamf2dDimension_HeaderFile
+
+#include <PrsDim_Chamf2dDimension.hxx>
+
+Standard_DEPRECATED("Alias to moved class")
+typedef PrsDim_Chamf2dDimension AIS_Chamf2dDimension;
+
+#endif // _AIS_Chamf2dDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_Chamf3dDimension_HeaderFile
+#define _AIS_Chamf3dDimension_HeaderFile
+
+#include <PrsDim_Chamf3dDimension.hxx>
+
+Standard_DEPRECATED("Alias to moved class")
+typedef PrsDim_Chamf3dDimension AIS_Chamf3dDimension;
+
+#endif // _AIS_Chamf3dDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_ConcentricRelation_HeaderFile
+#define _AIS_ConcentricRelation_HeaderFile
+
+#include <PrsDim_ConcentricRelation.hxx>
+
+Standard_DEPRECATED("Alias to moved class")
+typedef PrsDim_ConcentricRelation AIS_ConcentricRelation;
+
+#endif // _AIS_ConcentricRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_DiameterDimension_HeaderFile
+#define _AIS_DiameterDimension_HeaderFile
+
+#include <PrsDim_DiameterDimension.hxx>
+
+Standard_DEPRECATED("Alias to moved class")
+typedef PrsDim_DiameterDimension AIS_DiameterDimension;
+
+#endif // _AIS_DiameterDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_Dimension_HeaderFile
+#define _AIS_Dimension_HeaderFile
+
+#include <PrsDim_Dimension.hxx>
+
+Standard_DEPRECATED("Alias to moved class")
+typedef PrsDim_Dimension AIS_Dimension;
+
+#endif // _AIS_Dimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_DimensionOwner_HeaderFile
+#define _AIS_DimensionOwner_HeaderFile
+
+#include <PrsDim_DimensionOwner.hxx>
+
+Standard_DEPRECATED("Alias to moved class")
+typedef PrsDim_DimensionOwner AIS_DimensionOwner;
+
+#endif // _AIS_DimensionOwner_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_EllipseRadiusDimension_HeaderFile
+#define _AIS_EllipseRadiusDimension_HeaderFile
+
+#include <PrsDim_EllipseRadiusDimension.hxx>
+
+Standard_DEPRECATED("Alias to moved class")
+typedef PrsDim_EllipseRadiusDimension AIS_EllipseRadiusDimension;
+
+#endif // _AIS_EllipseRadiusDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_EqualDistanceRelation_HeaderFile
+#define _AIS_EqualDistanceRelation_HeaderFile
+
+#include <PrsDim_EqualDistanceRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_EqualDistanceRelation AIS_EqualDistanceRelation;
+
+#endif // _AIS_EqualDistanceRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_EqualRadiusRelation_HeaderFile
+#define _AIS_EqualRadiusRelation_HeaderFile
+
+#include <PrsDim_EqualRadiusRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_EqualRadiusRelation AIS_EqualRadiusRelation;
+
+#endif // _AIS_EqualRadiusRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_FixRelation_HeaderFile
+#define _AIS_FixRelation_HeaderFile
+
+#include <PrsDim_FixRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_FixRelation AIS_FixRelation;
+
+#endif // _AIS_FixRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_IdenticRelation_HeaderFile
+#define _AIS_IdenticRelation_HeaderFile
+
+#include <PrsDim_IdenticRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_IdenticRelation AIS_IdenticRelation;
+
+#endif // _AIS_IdenticRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_LengthDimension_HeaderFile
+#define _AIS_LengthDimension_HeaderFile
+
+#include <PrsDim_LengthDimension.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_LengthDimension AIS_LengthDimension;
+
+#endif // _AIS_LengthDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_MaxRadiusDimension_HeaderFile
+#define _AIS_MaxRadiusDimension_HeaderFile
+
+#include <PrsDim_MaxRadiusDimension.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_MaxRadiusDimension AIS_MaxRadiusDimension;
+
+#endif // _AIS_MaxRadiusDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_MidPointRelation_HeaderFile
+#define _AIS_MidPointRelation_HeaderFile
+
+#include <PrsDim_MidPointRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_MidPointRelation AIS_MidPointRelation;
+
+#endif // _AIS_MidPointRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_MinRadiusDimension_HeaderFile
+#define _AIS_MinRadiusDimension_HeaderFile
+
+#include <PrsDim_MinRadiusDimension.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_MinRadiusDimension AIS_MinRadiusDimension;
+
+#endif // _AIS_MinRadiusDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_OffsetDimension_HeaderFile
+#define _AIS_OffsetDimension_HeaderFile
+
+#include <PrsDim_OffsetDimension.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_OffsetDimension AIS_OffsetDimension;
+
+#endif // _AIS_OffsetDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_ParallelRelation_HeaderFile
+#define _AIS_ParallelRelation_HeaderFile
+
+#include <PrsDim_ParallelRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_ParallelRelation AIS_ParallelRelation;
+
+#endif // _AIS_ParallelRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_PerpendicularRelation_HeaderFile
+#define _AIS_PerpendicularRelation_HeaderFile
+
+#include <PrsDim_PerpendicularRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_PerpendicularRelation AIS_PerpendicularRelation;
+
+#endif // _AIS_PerpendicularRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_RadiusDimension_HeaderFile
+#define _AIS_RadiusDimension_HeaderFile
+
+#include <PrsDim_RadiusDimension.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_RadiusDimension AIS_RadiusDimension;
+
+#endif // _AIS_RadiusDimension_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_Relation_HeaderFile
+#define _AIS_Relation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_Relation AIS_Relation;
+
+#endif // _AIS_Relation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_SymmetricRelation_HeaderFile
+#define _AIS_SymmetricRelation_HeaderFile
+
+#include <PrsDim_SymmetricRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_SymmetricRelation AIS_SymmetricRelation;
+
+#endif // _AIS_SymmetricRelation_HeaderFile
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_TangentRelation_HeaderFile
+#define _AIS_TangentRelation_HeaderFile
+
+#include <PrsDim_TangentRelation.hxx>
+
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef PrsDim_TangentRelation AIS_TangentRelation;
+
+#endif // _AIS_TangentRelation_HeaderFile
--- /dev/null
+PrsDim.cxx
+PrsDim.hxx
+PrsDim_AngleDimension.cxx
+PrsDim_AngleDimension.hxx
+PrsDim_Chamf2dDimension.cxx
+PrsDim_Chamf2dDimension.hxx
+PrsDim_Chamf3dDimension.cxx
+PrsDim_Chamf3dDimension.hxx
+PrsDim_ConcentricRelation.cxx
+PrsDim_ConcentricRelation.hxx
+PrsDim_DiameterDimension.cxx
+PrsDim_DiameterDimension.hxx
+PrsDim_Dimension.cxx
+PrsDim_Dimension.hxx
+PrsDim_DimensionOwner.cxx
+PrsDim_DimensionOwner.hxx
+PrsDim_EllipseRadiusDimension.cxx
+PrsDim_EllipseRadiusDimension.hxx
+PrsDim_EqualDistanceRelation.cxx
+PrsDim_EqualDistanceRelation.hxx
+PrsDim_EqualRadiusRelation.cxx
+PrsDim_EqualRadiusRelation.hxx
+PrsDim_FixRelation.cxx
+PrsDim_FixRelation.hxx
+PrsDim_IdenticRelation.cxx
+PrsDim_IdenticRelation.hxx
+PrsDim_LengthDimension.cxx
+PrsDim_LengthDimension.hxx
+PrsDim_MaxRadiusDimension.cxx
+PrsDim_MaxRadiusDimension.hxx
+PrsDim_MidPointRelation.cxx
+PrsDim_MidPointRelation.hxx
+PrsDim_MinRadiusDimension.cxx
+PrsDim_MinRadiusDimension.hxx
+PrsDim_OffsetDimension.cxx
+PrsDim_OffsetDimension.hxx
+PrsDim_ParallelRelation.cxx
+PrsDim_ParallelRelation.hxx
+PrsDim_PerpendicularRelation.cxx
+PrsDim_PerpendicularRelation.hxx
+PrsDim_RadiusDimension.cxx
+PrsDim_RadiusDimension.hxx
+PrsDim_Relation.cxx
+PrsDim_Relation.hxx
+PrsDim_SymmetricRelation.cxx
+PrsDim_SymmetricRelation.hxx
+PrsDim_TangentRelation.cxx
+PrsDim_TangentRelation.hxx
+PrsDim_DimensionSelectionMode.hxx
+PrsDim_DisplaySpecialSymbol.hxx
+PrsDim_KindOfDimension.hxx
+PrsDim_KindOfRelation.hxx
+PrsDim_KindOfSurface.hxx
+PrsDim_TypeOfAngle.hxx
+PrsDim_TypeOfAngleArrowVisibility.hxx
+PrsDim_TypeOfDist.hxx
+AIS_AngleDimension.hxx
+AIS_Chamf2dDimension.hxx
+AIS_Chamf3dDimension.hxx
+AIS_ConcentricRelation.hxx
+AIS_DiameterDimension.hxx
+AIS_Dimension.hxx
+AIS_DimensionOwner.hxx
+AIS_EllipseRadiusDimension.hxx
+AIS_EqualDistanceRelation.hxx
+AIS_EqualRadiusRelation.hxx
+AIS_FixRelation.hxx
+AIS_IdenticRelation.hxx
+AIS_LengthDimension.hxx
+AIS_MaxRadiusDimension.hxx
+AIS_MidPointRelation.hxx
+AIS_MinRadiusDimension.hxx
+AIS_OffsetDimension.hxx
+AIS_ParallelRelation.hxx
+AIS_PerpendicularRelation.hxx
+AIS_RadiusDimension.hxx
+AIS_Relation.hxx
+AIS_SymmetricRelation.hxx
+AIS_TangentRelation.hxx
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim.hxx>
+
+#include <Adaptor3d_HCurve.hxx>
+#include <Adaptor3d_HSurface.hxx>
+#include <Bnd_Box.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_HSurface.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepTools.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+#include <GccEnt_QualifiedLin.hxx>
+#include <gce_MakeDir.hxx>
+#include <gce_MakeLin.hxx>
+#include <Geom2d_Circle.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_OffsetSurface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_SurfaceOfLinearExtrusion.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
+#include <Geom_ToroidalSurface.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAPI_ExtremaCurveCurve.hxx>
+#include <GeomAPI_IntSS.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+#include <GeomLib.hxx>
+#include <GeomProjLib.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax3.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Elips.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <gp_XYZ.hxx>
+#include <Precision.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <StdPrs_Point.hxx>
+#include <StdPrs_WFShape.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_Array2OfReal.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+
+const Standard_Real SquareTolerance = Precision::SquareConfusion();
+
+//=======================================================================
+//function : Nearest
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim::Nearest(const TopoDS_Shape& ashape, const gp_Pnt& apoint)
+{
+ Standard_Real dist2 = RealLast();
+ Standard_Real curdist2;
+ gp_Pnt result(0.0,0.0,0.0);
+ gp_Pnt curpnt(0.0,0.0,0.0);
+ TopExp_Explorer explo(ashape,TopAbs_VERTEX);
+ while (explo.More())
+ {
+ curpnt = BRep_Tool::Pnt(TopoDS::Vertex(explo.Current()));
+ curdist2 = apoint.SquareDistance(curpnt);
+ if (curdist2 < dist2)
+ {
+ result = curpnt;
+ dist2 = curdist2;
+ }
+ explo.Next();
+ }
+ return result;
+}
+
+//=======================================================================
+//function : Nearest
+//purpose : For <thePoint> finds the nearest point on <theLine>.
+//=======================================================================
+gp_Pnt PrsDim::Nearest (const gp_Lin& theLine, const gp_Pnt& thePoint)
+{
+ Handle(Geom_Line) aLine = new Geom_Line (theLine);
+
+ GeomAPI_ProjectPointOnCurve aPointProj (thePoint, aLine);
+ return aPointProj.Point (1);
+}
+
+//=======================================================================
+//function : Nearest
+//purpose : For the given point finds nearest point on the curve,
+// return TRUE if found point is belongs to curve
+// and FALSE otherwise.
+//=======================================================================
+Standard_Boolean PrsDim::Nearest (const Handle(Geom_Curve)& theCurve,
+ const gp_Pnt& thePoint,
+ const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theLastPoint,
+ gp_Pnt& theNearestPoint)
+{
+ GeomAPI_ProjectPointOnCurve aPointProj (thePoint, theCurve);
+ theNearestPoint = theCurve->Value (aPointProj.LowerDistanceParameter());
+
+ Standard_Real aLength = theFirstPoint.Distance (theLastPoint);
+ if (theNearestPoint.Distance (theFirstPoint) > aLength
+ || theNearestPoint.Distance (theLastPoint) > aLength)
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Farest
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim::Farest( const TopoDS_Shape& aShape, const gp_Pnt& aPoint )
+{
+ Standard_Real MaxDist2 = 0.0e0, curdist2;
+ gp_Pnt Result(0.0,0.0,0.0);
+ gp_Pnt curpnt(0.0,0.0,0.0);
+ TopExp_Explorer Explo( aShape, TopAbs_VERTEX );
+ for (; Explo.More(); Explo.Next())
+ {
+ curpnt = BRep_Tool::Pnt( TopoDS::Vertex( Explo.Current() ) );
+ curdist2 = aPoint.SquareDistance( curpnt );
+ if (curdist2 > MaxDist2)
+ {
+ MaxDist2 = curdist2;
+ Result = curpnt;
+ }
+ }
+ return Result;
+}
+
+
+//=======================================================================
+//function : ComputeGeometry
+//purpose : for line, circle, ellipse.
+//=======================================================================
+Standard_Boolean PrsDim::ComputeGeometry (const TopoDS_Edge& theEdge,
+ Handle(Geom_Curve)& theCurve,
+ gp_Pnt& theFirstPnt,
+ gp_Pnt& theLastPnt)
+{
+ TopLoc_Location anEdgeLoc;
+ Standard_Real aFirst, aLast;
+ theCurve = BRep_Tool::Curve (theEdge, anEdgeLoc, aFirst, aLast);
+ if (theCurve.IsNull())
+ {
+ return Standard_False;
+ }
+
+ if (!anEdgeLoc.IsIdentity())
+ {
+ Handle(Geom_Geometry) aGeometry = theCurve->Transformed (anEdgeLoc.Transformation());
+ theCurve = Handle(Geom_Curve)::DownCast (aGeometry);
+ }
+
+ if (theCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
+ {
+ theCurve = Handle(Geom_TrimmedCurve)::DownCast (theCurve)->BasisCurve();
+ }
+
+ if (theCurve->IsInstance (STANDARD_TYPE (Geom_Line)))
+ {
+ Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theCurve);
+ theFirstPnt = ElCLib::Value (aFirst, aLine->Lin());
+ theLastPnt = ElCLib::Value (aLast, aLine->Lin());
+ }
+ else if (theCurve->IsInstance (STANDARD_TYPE (Geom_Circle)))
+ {
+ Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast (theCurve);
+
+ theFirstPnt = ElCLib::Value (aFirst, aCirc->Circ());
+ theLastPnt = ElCLib::Value (aLast, aCirc->Circ());
+ }
+ else if (theCurve->IsInstance (STANDARD_TYPE (Geom_Ellipse)))
+ {
+ Handle(Geom_Ellipse) anEllipse = Handle(Geom_Ellipse)::DownCast (theCurve);
+ theFirstPnt = ElCLib::Value (aFirst, anEllipse->Elips());
+ theLastPnt = ElCLib::Value (aLast, anEllipse->Elips());
+ }
+ else
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeGeometry
+//purpose : for line, circle, ellipse.
+//=======================================================================
+Standard_Boolean PrsDim::ComputeGeometry (const TopoDS_Edge& theEdge,
+ Handle(Geom_Curve)& theCurve,
+ gp_Pnt& theFirstPnt,
+ gp_Pnt& theLastPnt,
+ Standard_Boolean& theIsInfinite)
+{
+ Standard_Real aFirst, aLast;
+
+ BRepAdaptor_Curve anAdaptor (theEdge);
+
+ theCurve = Handle(Geom_Curve)::DownCast
+ (anAdaptor.Curve().Curve()->Transformed (anAdaptor.Trsf()));
+
+ if (theCurve.IsNull())
+ {
+ return Standard_False;
+ }
+
+ aFirst = anAdaptor.FirstParameter();
+ aLast = anAdaptor.LastParameter();
+
+ theIsInfinite = (Precision::IsInfinite (aFirst) || Precision::IsInfinite (aLast));
+
+ if (theCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
+ {
+ theCurve = Handle(Geom_TrimmedCurve)::DownCast (theCurve)->BasisCurve();
+ }
+
+ if (!theIsInfinite)
+ {
+ theFirstPnt = theCurve->Value (aFirst);
+ theLastPnt = theCurve->Value (aLast);
+ }
+ else
+ {
+ theFirstPnt = gp::Origin();
+ theLastPnt = gp::Origin();
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeGeometry
+//purpose :
+//=======================================================================
+
+Standard_Boolean PrsDim::ComputeGeometry (const TopoDS_Edge& theEdge,
+ Handle(Geom_Curve)& theCurve,
+ gp_Pnt& theFirstPnt,
+ gp_Pnt& theLastPnt,
+ Handle(Geom_Curve)& theExtCurve,
+ Standard_Boolean& theIsInfinite,
+ Standard_Boolean& theIsOnPlane,
+ const Handle(Geom_Plane)& thePlane)
+{
+ if (thePlane.IsNull())
+ {
+ return Standard_False;
+ }
+
+ Standard_Real aFirst, aLast;
+ BRepAdaptor_Curve aCurveAdaptor (theEdge);
+ theCurve = Handle(Geom_Curve)::DownCast (aCurveAdaptor.Curve().Curve()->Transformed (aCurveAdaptor.Trsf()));
+ aFirst = aCurveAdaptor.FirstParameter();
+ aLast = aCurveAdaptor.LastParameter();
+
+ if (theCurve.IsNull())
+ {
+ return Standard_False;
+ }
+
+ theExtCurve = theCurve;
+ theIsInfinite = (Precision::IsInfinite (aFirst) || Precision::IsInfinite (aLast));
+
+ // Checks that the projected curve is not in the plane.
+ theIsOnPlane = Standard_True;
+ if (theExtCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
+ {
+ theExtCurve = Handle(Geom_TrimmedCurve)::DownCast (theExtCurve)->BasisCurve();
+ }
+
+ if (theExtCurve->IsInstance (STANDARD_TYPE (Geom_Line)))
+ {
+ Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theExtCurve);
+ theIsOnPlane = thePlane->Pln().Contains (aLine->Lin(),
+ Precision::Confusion(),
+ Precision::Angular());
+ }
+ else if (theExtCurve->IsInstance (STANDARD_TYPE (Geom_Circle)))
+ {
+ Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast (theExtCurve);
+
+ gp_Ax3 aCircPos (aCircle->Position());
+ theIsOnPlane = aCircPos.IsCoplanar (thePlane->Pln().Position(),
+ Precision::Confusion(),
+ Precision::Angular());
+ }
+
+ if (theIsOnPlane)
+ {
+ theExtCurve.Nullify();
+ }
+
+ theCurve = GeomProjLib::ProjectOnPlane (theCurve, thePlane,
+ thePlane->Pln().Axis().Direction(),
+ Standard_False);
+
+ if (theCurve->IsInstance (STANDARD_TYPE (Geom_Line)))
+ {
+ Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theCurve);
+ if (!theIsInfinite)
+ {
+ theFirstPnt = ElCLib::Value (aFirst, aLine->Lin());
+ theLastPnt = ElCLib::Value (aLast, aLine->Lin());
+ }
+ }
+ else if (theCurve->IsInstance (STANDARD_TYPE (Geom_Circle)))
+ {
+ Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast (theCurve);
+
+ theFirstPnt = ElCLib::Value (aFirst, aCirc->Circ());
+ theLastPnt = ElCLib::Value (aLast, aCirc->Circ());
+ }
+ else if (theCurve->IsInstance (STANDARD_TYPE (Geom_Ellipse)))
+ {
+ Handle(Geom_Ellipse) anEllipse = Handle(Geom_Ellipse)::DownCast (theCurve);
+
+ theFirstPnt = ElCLib::Value (aFirst, anEllipse->Elips());
+ theLastPnt = ElCLib::Value (aLast, anEllipse->Elips());
+ }
+ else
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeGeometry
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim::ComputeGeometry (const TopoDS_Edge& theFirstEdge,
+ const TopoDS_Edge& theSecondEdge,
+ Handle(Geom_Curve)& theFirstCurve,
+ Handle(Geom_Curve)& theSecondCurve,
+ gp_Pnt& theFirstPnt1,
+ gp_Pnt& theLastPnt1,
+ gp_Pnt& theFirstPnt2,
+ gp_Pnt& theLastPnt2,
+ const Handle(Geom_Plane)& thePlane)
+{
+ if (thePlane.IsNull())
+ {
+ return Standard_False;
+ }
+
+ TopLoc_Location aFirstEdgeLoc, aSecondEdgeLoc;
+ Standard_Real aFirst1, aLast1, aFirst2, aLast2;
+
+ theFirstCurve = BRep_Tool::Curve (theFirstEdge, aFirstEdgeLoc, aFirst1, aLast1);
+ theSecondCurve = BRep_Tool::Curve (theSecondEdge, aSecondEdgeLoc, aFirst2, aLast2);
+
+ if (theFirstCurve.IsNull())
+ {
+ return Standard_False;
+ }
+
+ if (theSecondCurve.IsNull())
+ {
+ return Standard_False;
+ }
+
+ if (!aFirstEdgeLoc.IsIdentity())
+ {
+ Handle(Geom_Geometry) aGeomGeometry = theFirstCurve->Transformed (aFirstEdgeLoc.Transformation());
+ theFirstCurve = Handle(Geom_Curve)::DownCast (aGeomGeometry);
+ }
+
+ if (!aSecondEdgeLoc.IsIdentity())
+ {
+ Handle(Geom_Geometry) aGeomGeometry = theSecondCurve->Transformed (aSecondEdgeLoc.Transformation());
+ theSecondCurve = Handle(Geom_Curve)::DownCast (aGeomGeometry);
+ }
+
+ theFirstCurve = GeomProjLib::ProjectOnPlane (theFirstCurve, thePlane,
+ thePlane->Pln().Axis().Direction(),
+ Standard_False);
+
+
+ theSecondCurve = GeomProjLib::ProjectOnPlane (theSecondCurve, thePlane,
+ thePlane->Pln().Axis().Direction(),
+ Standard_False);
+
+
+ if (theFirstCurve->IsInstance (STANDARD_TYPE(Geom_TrimmedCurve)))
+ {
+ theFirstCurve = Handle(Geom_TrimmedCurve)::DownCast (theFirstCurve)->BasisCurve();
+ }
+
+ if (theSecondCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
+ {
+ theSecondCurve = Handle(Geom_TrimmedCurve)::DownCast (theSecondCurve)->BasisCurve();
+ }
+
+ if (theFirstCurve->IsInstance(STANDARD_TYPE(Geom_Line)))
+ {
+ Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theFirstCurve);
+
+ theFirstPnt1 = ElCLib::Value (aFirst1, aLine->Lin());
+ theLastPnt1 = ElCLib::Value (aLast1, aLine->Lin());
+ }
+ else if (theFirstCurve->IsInstance(STANDARD_TYPE(Geom_Circle)))
+ {
+ Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast (theFirstCurve);
+
+ theFirstPnt1 = ElCLib::Value (aFirst1, aCirc->Circ());
+ theLastPnt1 = ElCLib::Value (aLast1, aCirc->Circ());
+ }
+ else
+ {
+ return Standard_False;
+ }
+
+ if (theSecondCurve->IsInstance (STANDARD_TYPE (Geom_Line)))
+{
+ Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (theSecondCurve);
+
+ theFirstPnt2 = ElCLib::Value (aFirst2, aLine->Lin());
+ theLastPnt2 = ElCLib::Value (aLast2, aLine->Lin());
+ }
+ else if (theSecondCurve->IsInstance (STANDARD_TYPE (Geom_Circle)))
+ {
+ Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast (theSecondCurve);
+
+ theFirstPnt2 = ElCLib::Value (aFirst2, aCirc->Circ());
+ theLastPnt2 = ElCLib::Value (aLast2, aCirc->Circ());
+ }
+ else
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeGeometry
+//purpose : Computes the geometry of the 2 edges.
+//=======================================================================
+Standard_Boolean PrsDim::ComputeGeometry (const TopoDS_Edge& theFirstEdge,
+ const TopoDS_Edge& theSecondEdge,
+ Handle(Geom_Curve)& theFirstCurve,
+ Handle(Geom_Curve)& theSecondCurve,
+ gp_Pnt& theFirstPnt1,
+ gp_Pnt& theLastPnt1,
+ gp_Pnt& theFirstPnt2,
+ gp_Pnt& theLastPnt2,
+ Standard_Boolean& theIsInfinite1,
+ Standard_Boolean& theIsInfinite2)
+{
+ theIsInfinite1 = theIsInfinite2 = Standard_False;
+
+ if (!PrsDim::ComputeGeometry (theFirstEdge, theFirstCurve,theFirstPnt1, theLastPnt1, theIsInfinite1))
+ {
+ return Standard_False;
+ }
+
+ if (!PrsDim::ComputeGeometry (theSecondEdge, theSecondCurve,theFirstPnt2, theLastPnt2, theIsInfinite2))
+ {
+ return Standard_False;
+ }
+
+ if (theIsInfinite1 || theIsInfinite2)
+ {
+ if (theFirstCurve->DynamicType() == theSecondCurve->DynamicType())
+ {
+ gp_Lin aLin1 = Handle(Geom_Line)::DownCast (theFirstCurve)->Lin();
+ gp_Lin aLin2 = Handle(Geom_Line)::DownCast (theSecondCurve)->Lin();
+
+ if (theIsInfinite1)
+ {
+ theFirstPnt1 = ElCLib::Value (ElCLib::Parameter (aLin2, theFirstPnt2), aLin1);
+ theLastPnt1 = ElCLib::Value (ElCLib::Parameter (aLin2, theLastPnt2), aLin1);
+ }
+ else if (theIsInfinite2)
+ {
+ theFirstPnt2 = ElCLib::Value (ElCLib::Parameter (aLin1, theFirstPnt1), aLin2);
+ theLastPnt2 = ElCLib::Value (ElCLib::Parameter (aLin1, theLastPnt1), aLin2);
+ }
+ }
+ else
+ {
+ if (theIsInfinite1 && !theIsInfinite2)
+ {
+ GeomAPI_ProjectPointOnCurve aProjector (theFirstPnt2, theFirstCurve);
+ theFirstPnt1 = theFirstCurve->Value (aProjector.LowerDistanceParameter ());
+
+ aProjector.Init (theLastPnt2, theFirstCurve);
+ theLastPnt1 = theFirstCurve->Value (aProjector.LowerDistanceParameter ());
+ }
+ else if (!theIsInfinite1 && theIsInfinite2)
+ {
+ GeomAPI_ProjectPointOnCurve aProjector (theFirstPnt1, theSecondCurve);
+ theFirstPnt2 = theSecondCurve->Value (aProjector.LowerDistanceParameter ());
+
+ aProjector.Init (theLastPnt1, theSecondCurve);
+ theLastPnt2 = theSecondCurve->Value (aProjector.LowerDistanceParameter ());
+ }
+ else
+ {
+ return Standard_False;
+ }
+ }
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeGeometry
+//purpose : Computes the geometry of the 2 edges in the current wp
+// and the 'right' geometry of the edges if one doesn't
+// belong to the current working plane.
+// There may be only one curve that can't belong to the
+// current working plane ( attachement constraint)
+// if the 2 edges belong to the current WP, <WhatProj> = 0
+//
+// indexExt = 0 2 edges are in the current wp
+// indexExt = 1 first edge is not in the current wp
+// indexExt = 2 second edge is not in the current wp
+// if none of the two edges is in the current wp ,
+// it returns Standard_False
+//=======================================================================
+Standard_Boolean PrsDim::ComputeGeometry (const TopoDS_Edge& theFirstEdge,
+ const TopoDS_Edge& theSecondEdge,
+ Standard_Integer& theExtIndex,
+ Handle(Geom_Curve)& theFirstCurve,
+ Handle(Geom_Curve)& theSecondCurve,
+ gp_Pnt& theFirstPnt1,
+ gp_Pnt& theLastPnt1,
+ gp_Pnt& theFirstPnt2,
+ gp_Pnt& theLastPnt2,
+ Handle(Geom_Curve)& theExtCurve,
+ Standard_Boolean& theIsInfinite1,
+ Standard_Boolean& theIsInfinite2,
+ const Handle(Geom_Plane)& thePlane)
+{
+ if (thePlane.IsNull())
+ {
+ return Standard_False;
+ }
+
+ theExtCurve.Nullify();
+ theExtIndex = 0;
+
+ Standard_Real aFirst1, aLast1, aFirst2, aLast2;
+ theIsInfinite1 = theIsInfinite2 = Standard_False;
+
+ BRepAdaptor_Curve aFirstAdaptor (theFirstEdge);
+ BRepAdaptor_Curve aSecondAdaptor (theSecondEdge);
+
+ theFirstCurve = Handle(Geom_Curve)::DownCast
+ (aFirstAdaptor.Curve().Curve()->Transformed (aFirstAdaptor.Trsf()));
+ theSecondCurve = Handle(Geom_Curve)::DownCast
+ (aSecondAdaptor.Curve().Curve()->Transformed (aSecondAdaptor.Trsf()));
+
+ if (theFirstCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
+ {
+ theFirstCurve = Handle(Geom_TrimmedCurve)::DownCast (theFirstCurve)->BasisCurve();
+ }
+ if (theSecondCurve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
+ {
+ theSecondCurve = Handle(Geom_TrimmedCurve)::DownCast (theSecondCurve)->BasisCurve();
+ }
+
+ aFirst1 = aFirstAdaptor.FirstParameter();
+ aLast1 = aFirstAdaptor.LastParameter();
+
+ aFirst2 = aSecondAdaptor.FirstParameter();
+ aLast2 = aSecondAdaptor.LastParameter();
+
+ if (theFirstCurve.IsNull() || theSecondCurve.IsNull())
+ {
+ return Standard_False;
+ }
+
+ Handle(Geom_Curve) aFirstSaved = theFirstCurve;
+ Handle(Geom_Curve) aSecondSaved = theSecondCurve;
+
+ // Checks that the projected curve is not in the plane
+ Standard_Boolean isFirstOnPlane,isSecondOnPlane;
+
+ if ((!ComputeGeomCurve (theFirstCurve, aFirst1, aLast1, theFirstPnt1, theLastPnt1, thePlane, isFirstOnPlane))
+ || (!ComputeGeomCurve( theSecondCurve, aFirst2, aLast2, theFirstPnt2, theLastPnt2, thePlane,isSecondOnPlane)))
+ {
+ return Standard_False;
+ }
+
+ if (Precision::IsInfinite (aFirst1) || Precision::IsInfinite (aLast1))
+ {
+ theIsInfinite1 = Standard_True;
+ theExtIndex = 1;
+ }
+ if (Precision::IsInfinite (aFirst2) || Precision::IsInfinite (aLast2))
+ {
+ theIsInfinite2 = Standard_True;
+ theExtIndex = 2;
+ }
+ if (theIsInfinite1 && theIsInfinite2)
+ {
+ theExtIndex = 0;
+ }
+
+ if (theIsInfinite1 || theIsInfinite2)
+ {
+ if (theFirstCurve->DynamicType() == theSecondCurve->DynamicType())
+ {
+ gp_Lin aLin1 = Handle(Geom_Line)::DownCast (theFirstCurve)->Lin();
+ gp_Lin aLin2 = Handle(Geom_Line)::DownCast (theSecondCurve)->Lin();
+
+ if (theExtIndex == 1)
+ {
+ theFirstPnt1 = ElCLib::Value (ElCLib::Parameter (aLin2, theFirstPnt2), aLin1);
+ theLastPnt1 = ElCLib::Value (ElCLib::Parameter (aLin2, theLastPnt2), aLin1);
+ }
+ else if (theExtIndex == 2)
+ {
+ theFirstPnt2 = ElCLib::Value (ElCLib::Parameter (aLin1, theFirstPnt1), aLin2);
+ theLastPnt2 = ElCLib::Value (ElCLib::Parameter (aLin1, theLastPnt1), aLin2);
+ }
+ }
+ }
+
+ if (isFirstOnPlane && isSecondOnPlane)
+ {
+ return Standard_True;
+ }
+
+ if (!isFirstOnPlane && isSecondOnPlane)
+ {// curve 2 only in the plane
+ theExtIndex = 1;
+ theExtCurve = aFirstSaved;
+ }
+ else if (isFirstOnPlane && !isSecondOnPlane)
+ {// curve 1 only in the plane
+ theExtIndex = 2;
+ theExtCurve = aSecondSaved;
+ }
+ else
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeGeomCurve
+//purpose : Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
+// and returns aCurveproj;
+// Return TRUE if ok
+//=======================================================================
+Standard_Boolean PrsDim::ComputeGeomCurve (Handle(Geom_Curve)& aCurve,
+ const Standard_Real first1,
+ const Standard_Real last1,
+ gp_Pnt& FirstPnt1,
+ gp_Pnt& LastPnt1,
+ const Handle(Geom_Plane)& aPlane,
+ Standard_Boolean& isOnPlane)
+{
+ isOnPlane = Standard_True;
+ const Standard_Integer NodeNumber = 20;
+ Standard_Real Delta = (last1 - first1) / (NodeNumber - 1);
+ if (Delta <= Precision::PConfusion())
+ {
+ Delta = last1 - first1;
+ }
+
+ gp_Pnt CurPnt(0.0, 0.0, 0.0);
+ Standard_Real CurPar = first1;
+ for (Standard_Integer i = 1; i <= NodeNumber; i++)
+ {
+ CurPnt = aCurve->Value( CurPar );
+ if (aPlane->Pln().SquareDistance( CurPnt ) > SquareTolerance)
+ {
+ isOnPlane = Standard_False;
+ break;
+ }
+ CurPar += Delta;
+ }
+
+ if (!Precision::IsInfinite(first1) && !Precision::IsInfinite(last1))
+ {
+ FirstPnt1 = aCurve->Value (first1);
+ LastPnt1 = aCurve->Value (last1);
+ }
+
+ if (!isOnPlane)
+ {
+ Handle(Geom_Curve) aGeomCurve = GeomProjLib::ProjectOnPlane (aCurve,
+ aPlane,
+ aPlane->Pln().Axis().Direction(),
+ Standard_False);
+ aCurve = aGeomCurve;
+ if (aCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
+ {
+ aCurve = Handle(Geom_TrimmedCurve)::DownCast (aCurve)->BasisCurve();
+ }
+ if (! Precision::IsInfinite(first1) && ! Precision::IsInfinite(last1))
+ {
+ FirstPnt1 = PrsDim::ProjectPointOnPlane( FirstPnt1, aPlane->Pln() );
+ LastPnt1 = PrsDim::ProjectPointOnPlane( LastPnt1, aPlane->Pln() );
+ }
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeGeometry
+//purpose : computes the point corresponding to the vertex <aVertex>
+// in the plane <aPlane>. If the vertex is already in the plane
+// <isOnPlane>, <isOnPlane> = true.
+// <point> is the projected vertex in the plane.
+//=======================================================================
+Standard_Boolean PrsDim::ComputeGeometry (const TopoDS_Vertex& aVertex,
+ gp_Pnt& point,
+ const Handle(Geom_Plane)& aPlane,
+ Standard_Boolean& isOnPlane)
+{
+ point = BRep_Tool::Pnt(aVertex);
+ isOnPlane = aPlane->Pln().Contains(point, Precision::Confusion());
+ if ( !isOnPlane) {
+ point = PrsDim::ProjectPointOnPlane( point, aPlane->Pln() );
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : GetPlaneFromFace
+//purpose :
+// Returns type of surface which can be Plane or OtherSurface
+//=======================================================================
+Standard_Boolean PrsDim::GetPlaneFromFace (const TopoDS_Face& aFace,
+ gp_Pln& aPlane,
+ Handle(Geom_Surface)& aSurf,
+ PrsDim_KindOfSurface& aSurfType,
+ Standard_Real& Offset)
+
+{
+ Standard_Boolean Result = Standard_False;
+ BRepAdaptor_Surface surf1( aFace );
+ Handle( Adaptor3d_HSurface ) surf2;
+ Standard_Boolean isOffset = Standard_False;
+ Offset = 0.0;
+
+ if (surf1.GetType() == GeomAbs_OffsetSurface)
+ {
+ // Extracting Basis Surface
+ surf2 = surf1.BasisSurface();
+ isOffset = Standard_True;
+ }
+ else
+ surf2 = new BRepAdaptor_HSurface( surf1 );
+
+ aSurf = surf1.Surface().Surface();
+ // aSurf->Transform(surf1.Trsf()) ;
+ aSurf = Handle( Geom_Surface )::DownCast( aSurf->Transformed( surf1.Trsf() ) );
+
+ if (surf2->GetType() == GeomAbs_Plane)
+ {
+ aPlane = surf2->Plane();
+ aSurfType = PrsDim_KOS_Plane;
+ Result = Standard_True;
+ }
+ else if (surf2->GetType() == GeomAbs_SurfaceOfExtrusion)
+ {
+ Handle( Adaptor3d_HCurve ) BasisCurve = surf2->BasisCurve();
+ gp_Dir ExtrusionDir = surf2->Direction();
+ if (BasisCurve->GetType() == GeomAbs_Line)
+ {
+ gp_Lin BasisLine = BasisCurve->Line();
+ gp_Dir LineDir = BasisLine.Direction();
+ gp_Pnt LinePos = BasisLine.Location();
+ gp_Pln thePlane( LinePos, LineDir ^ ExtrusionDir);
+ aPlane = thePlane;
+ aSurfType = PrsDim_KOS_Plane;
+ Result = Standard_True;
+ }
+ }
+
+ if (Result == Standard_True && isOffset)
+ {
+ aSurf = (Handle( Geom_OffsetSurface )::DownCast( aSurf ))->Surface();
+ aPlane = (Handle( Geom_Plane )::DownCast( aSurf ))->Pln();
+ }
+ if (Result == Standard_False)
+ {
+ if (isOffset)
+ {
+ Handle( Standard_Type ) TheType = aSurf->DynamicType();
+ if (TheType == STANDARD_TYPE(Geom_CylindricalSurface) ||
+ TheType == STANDARD_TYPE(Geom_ConicalSurface) ||
+ TheType == STANDARD_TYPE(Geom_SphericalSurface) ||
+ TheType == STANDARD_TYPE(Geom_ToroidalSurface))
+ {
+ aSurf = Handle(Geom_OffsetSurface)::DownCast(aSurf)->Surface();
+ }
+ else
+ {
+ Offset = Handle(Geom_OffsetSurface)::DownCast(aSurf)->Offset();
+ aSurf = Handle(Geom_OffsetSurface)::DownCast(aSurf)->BasisSurface();
+ }
+ }
+ Handle( Standard_Type ) TheType = aSurf->DynamicType();
+ if (TheType == STANDARD_TYPE(Geom_CylindricalSurface))
+ aSurfType = PrsDim_KOS_Cylinder;
+ else if (TheType == STANDARD_TYPE(Geom_ConicalSurface))
+ aSurfType = PrsDim_KOS_Cone;
+ else if (TheType == STANDARD_TYPE(Geom_SphericalSurface))
+ aSurfType = PrsDim_KOS_Sphere;
+ else if (TheType == STANDARD_TYPE(Geom_ToroidalSurface))
+ aSurfType = PrsDim_KOS_Torus;
+ else if (TheType == STANDARD_TYPE(Geom_SurfaceOfRevolution))
+ aSurfType = PrsDim_KOS_Revolution;
+ else if (TheType == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))
+ aSurfType = PrsDim_KOS_Extrusion;
+ else
+ aSurfType = PrsDim_KOS_OtherSurface;
+ }
+ return Result;
+}
+
+
+//=======================================================================
+//function : ProjectPointOnPlane
+//purpose :
+//=======================================================================
+
+gp_Pnt PrsDim::ProjectPointOnPlane( const gp_Pnt & aPoint, const gp_Pln & aPlane )
+{
+ gp_Vec aVec( aPlane.Location(), aPoint );
+ gp_Vec Normal = aPlane.Axis().Direction();
+ Normal = (aVec * Normal) * Normal;
+
+ return ( aPoint.Translated( -Normal ) );
+}
+
+//=======================================================================
+//function : ProjectPointOnLine
+//purpose :
+//=======================================================================
+
+gp_Pnt PrsDim::ProjectPointOnLine( const gp_Pnt & aPoint, const gp_Lin & aLine )
+{
+ gp_XYZ LinLoc = aLine.Location().XYZ();
+ gp_XYZ LinDir = aLine.Direction().XYZ();
+ Standard_Real Parameter = (aPoint.XYZ() - LinLoc) * LinDir;
+ gp_Pnt Result( LinLoc + Parameter * LinDir );
+ return Result;
+}
+
+//=======================================================================
+//function : InitFaceLength
+//purpose :
+//=======================================================================
+void PrsDim::InitFaceLength (const TopoDS_Face& theFace,
+ gp_Pln& thePlane,
+ Handle(Geom_Surface)& theSurface,
+ PrsDim_KindOfSurface& theSurfaceType,
+ Standard_Real& theOffset)
+{
+ if (PrsDim::GetPlaneFromFace (theFace, thePlane, theSurface, theSurfaceType, theOffset)
+ && Abs (theOffset) > Precision::Confusion())
+ {
+ theSurface = new Geom_OffsetSurface (theSurface, theOffset);
+ theOffset = 0.0e0;
+ }
+}
+
+//=======================================================================
+//function : InitAngleBetweenPlanarFaces
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim::InitAngleBetweenPlanarFaces (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace,
+ gp_Pnt& theCenter,
+ gp_Pnt& theFirstAttach,
+ gp_Pnt& theSecondAttach,
+ const Standard_Boolean theIsFirstPointSet)
+{
+ Handle(Geom_Plane) aFirstPlane = Handle(Geom_Plane)::DownCast (BRep_Tool::Surface (theFirstFace));
+ Handle(Geom_Plane) aSecondPlane = Handle(Geom_Plane)::DownCast (BRep_Tool::Surface (theSecondFace));
+
+ GeomAPI_IntSS aPlaneIntersector (aFirstPlane, aSecondPlane, Precision::Confusion());
+
+ // Fails if two planes haven't only one intersection line.
+ if (!aPlaneIntersector.IsDone())
+ {
+ return Standard_False;
+ }
+
+ if (aPlaneIntersector.NbLines() != 1)
+ {
+ return Standard_False;
+ }
+
+ // Get intersect line.
+ Handle(Geom_Curve) anIntersectCurve = aPlaneIntersector.Line (1);
+
+ Handle(Geom_Line) anIntersectLine = Handle(Geom_Line)::DownCast (anIntersectCurve);
+
+ if (anIntersectLine.IsNull())
+ {
+ return Standard_False;
+ }
+
+ gp_Lin anIntersectLin = anIntersectLine->Lin();
+
+ gp_Pnt aFirstCenter, aSecondCenter;
+ Standard_Real anU1Min, anU1Max, aV1Min, aV1Max;
+ Standard_Real anU2Min, anU2Max, aV2Min, aV2Max;
+
+ BRepTools::UVBounds (theFirstFace, anU1Min, anU1Max, aV1Min, aV1Max);
+ BRepTools::UVBounds (theSecondFace, anU2Min, anU2Max, aV2Min, aV2Max);
+
+ // Get first and second attach.
+ if (theIsFirstPointSet)
+ {
+ GeomAPI_ProjectPointOnSurf aProjector (theFirstAttach, aFirstPlane);
+ if (!aProjector.IsDone())
+ {
+ return Standard_False;
+ }
+
+ aFirstCenter = aProjector.Point (1);
+ }
+ else
+ {
+ aFirstCenter = aFirstPlane->Value ((anU1Min + anU1Max) * 0.5, (aV1Min + aV1Max) * 0.5);
+ }
+
+ aSecondCenter = aSecondPlane->Value ((anU2Min + anU2Max) * 0.5, (aV2Min + aV2Max) * 0.5);
+
+ GeomAPI_ProjectPointOnCurve aProj (aFirstCenter, anIntersectCurve);
+ theCenter = aProj.NearestPoint();
+
+ gp_Vec aFirstNormal = anIntersectLin.Direction() ^ aFirstPlane->Pln().Axis().Direction();
+ if (aFirstNormal * gp_Vec (theCenter, aFirstCenter) < 0.0)
+ {
+ aFirstNormal.Reverse();
+ }
+ theFirstAttach = theCenter.Translated (aFirstNormal);
+
+ gp_Vec aSecondNormal = anIntersectLin.Direction() ^ aSecondPlane->Pln().Axis().Direction();
+ if (aSecondNormal * gp_Vec (theCenter, aSecondCenter) < 0.0)
+ {
+ aSecondNormal.Reverse();
+ }
+ theSecondAttach = theCenter.Translated (aSecondNormal);
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : InitAngleBetweenCurvilinearFaces
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim::InitAngleBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace,
+ const PrsDim_KindOfSurface theFirstSurfType,
+ const PrsDim_KindOfSurface theSecondSurfType,
+ gp_Pnt& theCenter,
+ gp_Pnt& theFirstAttach,
+ gp_Pnt& theSecondAttach,
+ const Standard_Boolean theIsFirstPointSet)
+{
+ Handle(Geom_Surface) aFirstSurf = BRep_Tool::Surface (theFirstFace);
+ Handle(Geom_Surface) aSecondSurf = BRep_Tool::Surface (theSecondFace);
+
+ // Find intersection curve between two surfaces.
+ GeomAPI_IntSS aSurfaceIntersector (aFirstSurf, aSecondSurf, Precision::Confusion());
+
+ // Fails if two planes haven't only one intersection line.
+ if (!aSurfaceIntersector.IsDone())
+ {
+ return Standard_False;
+ }
+
+ if (aSurfaceIntersector.NbLines() != 1)
+ {
+ return Standard_False;
+ }
+
+ // Get intersect line.
+ Handle(Geom_Curve) anIntersectCurve = aSurfaceIntersector.Line (1);
+
+ Handle(Geom_Line) aFirstLine, aSecondLine;
+ Standard_Real aFirstU = 0.0;
+ Standard_Real aFirstV = 0.0;
+
+ if (theIsFirstPointSet)
+ {
+ GeomAPI_ProjectPointOnSurf aProjector (theFirstAttach, aFirstSurf);
+ if (!aProjector.IsDone())
+ {
+ return Standard_False;
+ }
+
+ theFirstAttach = aProjector.Point (1);
+ }
+ else
+ {
+ theFirstAttach = aFirstSurf->Value (aFirstU, aFirstV);
+ }
+
+ aFirstLine = Handle(Geom_Line)::DownCast (aFirstSurf->UIso (aFirstU));
+
+ if (theSecondSurfType == PrsDim_KOS_Cylinder)
+ {
+ Handle(Geom_CylindricalSurface) aCylinder = Handle(Geom_CylindricalSurface)::DownCast (aSecondSurf);
+
+ Standard_Real aSecondU = aCylinder->Cylinder().XAxis().Direction().Angle(
+ gce_MakeDir (ProjectPointOnLine (theFirstAttach,
+ gp_Lin (aCylinder->Cylinder().Axis())),
+ theFirstAttach));
+
+ aSecondLine = Handle(Geom_Line)::DownCast (aCylinder->UIso (aSecondU));
+ }
+ else if (theSecondSurfType == PrsDim_KOS_Cone)
+ {
+ Handle(Geom_ConicalSurface) aCone = Handle(Geom_ConicalSurface)::DownCast (aSecondSurf);
+
+ gp_Dir anXdirection = aCone->Cone().XAxis().Direction();
+
+ gp_Dir aToFirstAttach = gce_MakeDir (ProjectPointOnLine (theFirstAttach,
+ gp_Lin (aCone->Cone().Axis())),
+ theFirstAttach);
+
+ Standard_Real aSecondU = anXdirection.Angle (aToFirstAttach);
+
+ // Check sign
+ if (!anXdirection.IsEqual (aToFirstAttach, Precision::Angular()) &&
+ !anXdirection.IsOpposite (aToFirstAttach, Precision::Angular()) &&
+ (anXdirection ^ aToFirstAttach) * aCone->Cone().Axis().Direction() < 0.0)
+ {
+ aSecondU = 2*M_PI - aSecondU;
+ }
+ aSecondLine = Handle( Geom_Line )::DownCast (aCone->UIso(aSecondU));
+ }
+ else
+ {
+ return Standard_False;
+ }
+
+ // If angle can be computed between two lines.
+ if (!(aFirstLine->Lin().Direction().IsEqual (aSecondLine->Lin().Direction(), Precision::Angular() )) &&
+ !(aFirstLine->Lin().Direction().IsOpposite (aSecondLine->Lin().Direction(), Precision::Angular())))
+ {
+ GeomAPI_ExtremaCurveCurve anIntersector (aFirstLine, aSecondLine);
+ anIntersector.Points (1, theCenter, theCenter);
+
+ // Move theFirstAttach on aFirstLine if it is on theCenter.
+ if (theCenter.SquareDistance(theFirstAttach ) <= SquareTolerance)
+ {
+ gp_Vec aDir (aFirstLine->Lin().Direction());
+ theFirstAttach = theCenter.Translated (aDir);
+
+ // theFirstAttach should be on theFirstSurf.
+ Standard_Real anU, aV;
+ if (theFirstSurfType == PrsDim_KOS_Cylinder)
+ {
+ ElSLib::Parameters ((Handle(Geom_CylindricalSurface)::DownCast (aFirstSurf))->Cylinder(),
+ theFirstAttach, anU, aV);
+
+ theFirstAttach = ElSLib::Value (aFirstU, aV,
+ (Handle( Geom_CylindricalSurface )::DownCast (aFirstSurf))->Cylinder() );
+ }
+ else if (theFirstSurfType == PrsDim_KOS_Cone)
+ {
+ ElSLib::Parameters ((Handle(Geom_ConicalSurface)::DownCast (aFirstSurf))->Cone(),
+ theFirstAttach, anU, aV);
+ theFirstAttach = ElSLib::Value (aFirstU, aV,
+ (Handle(Geom_ConicalSurface)::DownCast (aFirstSurf))->Cone());
+ }
+ else
+ {
+ return Standard_False;
+ }
+ }
+
+ // Find theSecondAttach
+ GeomAPI_ProjectPointOnSurf aProjector (theFirstAttach, aSecondSurf);
+ if (!aProjector.IsDone())
+ {
+ return Standard_False;
+ }
+ Standard_Real anU, aV;
+ aProjector.LowerDistanceParameters (anU, aV);
+ theSecondAttach = aSecondSurf->Value (anU, aV);
+ }
+ else // aFirstLine and aSecondLine are coincident
+ {
+ gp_Vec aDir (aFirstLine->Lin().Direction());
+ theFirstAttach = theCenter.Translated (aDir);
+ theSecondAttach = theCenter.Translated (-aDir);
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeLengthBetweenCurvilinearFaces
+//purpose :
+//=======================================================================
+void PrsDim::InitLengthBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace,
+ Handle(Geom_Surface)& theFirstSurf,
+ Handle(Geom_Surface)& theSecondSurf,
+ gp_Pnt& theFirstAttach,
+ gp_Pnt& theSecondAttach,
+ gp_Dir& theDirOnPlane)
+{
+ GeomAPI_ProjectPointOnSurf aProjector;
+ Standard_Real aPU, aPV;
+
+ TopExp_Explorer anExplorer (theFirstFace, TopAbs_VERTEX);
+
+ theFirstAttach = BRep_Tool::Pnt (TopoDS::Vertex (anExplorer.Current()));
+ aProjector.Init (theFirstAttach, theFirstSurf);
+
+ theFirstAttach = aProjector.NearestPoint();
+ aProjector.LowerDistanceParameters (aPU, aPV);
+
+ gp_Vec aD1U, aD1V;
+ theFirstSurf->D1 (aPU, aPV, theFirstAttach, aD1U, aD1V);
+
+ if (aD1U.SquareMagnitude() <= SquareTolerance || aD1V.SquareMagnitude() <= SquareTolerance)
+ {
+ theFirstAttach = PrsDim::Farest (theFirstFace, theFirstAttach);
+ aProjector.Init (theFirstAttach, theFirstSurf);
+ aProjector.LowerDistanceParameters (aPU, aPV);
+ theFirstSurf->D1 (aPU, aPV, theFirstAttach, aD1U, aD1V);
+ }
+
+ aD1U.Normalize();
+ aD1V.Normalize();
+
+ theDirOnPlane = gp_Dir (aD1U);
+
+ gp_Dir aFirstSurfN = gp_Dir (aD1U ^ aD1V);
+
+ aProjector.Init (theFirstAttach, theSecondSurf);
+
+ Standard_Integer aBestPointIndex = 0;
+ Standard_Real aMinDist = RealLast();
+ gp_Dir aLocalDir;
+
+ for (Standard_Integer aPointIt = 1; aPointIt <= aProjector.NbPoints(); aPointIt++)
+ {
+ aProjector.Parameters (aPointIt, aPU, aPV);
+
+ theSecondSurf->D1 (aPU, aPV, theSecondAttach, aD1U, aD1V);
+
+ aLocalDir = aD1U.SquareMagnitude() <= SquareTolerance || aD1V.SquareMagnitude() <= SquareTolerance
+ ? gp_Dir (gp_Vec (theFirstAttach, aProjector.Point (aPointIt)))
+ : gp_Dir (aD1U ^ aD1V);
+
+ if (aFirstSurfN.IsParallel (aLocalDir, Precision::Angular()) && aProjector.Distance (aPointIt) < aMinDist)
+ {
+ aBestPointIndex = aPointIt;
+ aMinDist = aProjector.Distance (aPointIt);
+ }
+ }
+
+ if (aBestPointIndex == 0)
+ {
+ theSecondAttach = theFirstAttach;
+ }
+ else
+ {
+ theSecondAttach = aProjector.Point (aBestPointIndex);
+ aProjector.Parameters (aBestPointIndex, aPU, aPV);
+
+ // Now there is projection of FirstAttach onto SecondSurf in aProjector
+ BRepTopAdaptor_FClass2d aClassifier (theSecondFace, Precision::Confusion());
+
+ TopAbs_State aState =
+ aClassifier.Perform (gp_Pnt2d (aPU, aPV), theSecondSurf->IsUPeriodic() || theSecondSurf->IsVPeriodic());
+
+ if (aState == TopAbs_OUT || aState == TopAbs_UNKNOWN)
+ {
+ theSecondAttach = PrsDim::Nearest (theSecondFace, theSecondAttach);
+ }
+ }
+}
+
+gp_Pnt PrsDim::TranslatePointToBound( const gp_Pnt & aPoint, const gp_Dir & aDir, const Bnd_Box & aBndBox )
+{
+ if (aBndBox.IsOut( aPoint ))
+ return aPoint;
+ else
+ {
+ gp_Pnt Result(0.0,0.0,0.0);
+ TColStd_Array2OfReal Bound( 1, 3, 1, 2 );
+ TColStd_Array1OfReal Origin( 1, 3 );
+ TColStd_Array1OfReal Dir( 1, 3 );
+ Standard_Real t;
+
+ aBndBox.Get( Bound(1,1), Bound(2,1), Bound(3,1), Bound(1,2), Bound(2,2), Bound(3,2) );
+ aPoint.Coord( Origin(1), Origin(2), Origin(3) );
+ aDir.Coord( Dir(1), Dir(2), Dir(3) );
+
+ Bnd_Box EnlargedBox = aBndBox;
+ EnlargedBox.Enlarge( aBndBox.GetGap() + Precision::Confusion() );
+
+ Standard_Boolean IsFound = Standard_False;
+ for (Standard_Integer i = 1; i <= 3; i++)
+ {
+ if (Abs( Dir( i ) ) <= gp::Resolution())
+ continue;
+ for (Standard_Integer j = 1; j <= 2; j++)
+ {
+ t = (Bound( i, j ) - Origin( i )) / Dir( i );
+ if (t < 0.0e0)
+ continue;
+ Result = aPoint.Translated( gp_Vec( aDir ) * t );
+ if (! EnlargedBox.IsOut( Result ))
+ {
+ IsFound = Standard_True;
+ break;
+ }
+ }
+ if (IsFound) break;
+ }
+ return Result;
+ }
+}
+
+
+//=======================================================================
+//function : InDomain
+//purpose :
+//=======================================================================
+
+Standard_Boolean PrsDim::InDomain(const Standard_Real fpar,
+ const Standard_Real lpar,
+ const Standard_Real para)
+{
+ if (fpar >= 0.) {
+ if(lpar > fpar)
+ return ((para >= fpar) && (para <= lpar));
+ else { // fpar > lpar
+ Standard_Real delta = 2*M_PI-fpar;
+ Standard_Real lp, par, fp;
+ lp = lpar + delta;
+ par = para + delta;
+ while(lp > 2*M_PI) lp-=2*M_PI;
+ while(par > 2*M_PI) par-=2*M_PI;
+ fp = 0.;
+ return ((par >= fp) && (par <= lp));
+ }
+
+ }
+ if (para >= (fpar+2*M_PI)) return Standard_True;
+ if (para <= lpar) return Standard_True;
+ return Standard_False;
+}
+
+//=======================================================================
+//function : DistanceFromApex
+//purpose : calculates parametric length arc of ellipse
+//=======================================================================
+
+Standard_Real PrsDim::DistanceFromApex(const gp_Elips & elips,
+ const gp_Pnt & Apex,
+ const Standard_Real par)
+{
+ Standard_Real dist;
+ Standard_Real parApex = ElCLib::Parameter ( elips, Apex );
+ if(parApex == 0.0 || parApex == M_PI)
+ {//Major case
+ if(parApex == 0.0) //pos Apex
+ dist = (par < M_PI) ? par : (2*M_PI - par);
+ else //neg Apex
+ dist = (par < M_PI) ? ( M_PI - par) : ( par - M_PI );
+ }
+ else
+ {// Minor case
+ if(parApex == M_PI / 2) //pos Apex
+ {
+ if(par <= parApex + M_PI && par > parApex) // 3/2*M_PI < par < M_PI/2
+ dist = par - parApex;
+ else
+ {
+ if(par > parApex + M_PI) // 3/2*M_PI < par < 2*M_PI
+ dist = 2*M_PI - par + parApex;
+ else
+ dist = parApex - par;
+ }
+ }
+ else //neg Apex == 3/2*M_PI
+ {
+ if(par <= parApex && par >= M_PI/2) // M_PI/2 < par < 3/2*M_PI
+ dist = parApex - par;
+ else
+ {
+ if(par > parApex) // 3/2*M_PI < par < 2*M_PI
+ dist = par - parApex;
+ else
+ dist = par + M_PI/2; // 0 < par < M_PI/2
+ }
+ }
+ }
+ return dist;
+}
+
+//=======================================================================
+//function : NearestApex
+//purpose :
+//=======================================================================
+
+gp_Pnt PrsDim::NearestApex(const gp_Elips & elips,
+ const gp_Pnt & pApex,
+ const gp_Pnt & nApex,
+ const Standard_Real fpara,
+ const Standard_Real lpara,
+ Standard_Boolean & IsInDomain)
+{
+ Standard_Real parP, parN;
+ gp_Pnt EndOfArrow(0.0,0.0,0.0);
+ IsInDomain = Standard_True;
+ parP = ElCLib::Parameter ( elips, pApex );
+ if(InDomain(fpara, lpara, parP)) EndOfArrow = pApex;
+ else
+ {
+ parN = ElCLib::Parameter ( elips, nApex );
+ if(InDomain(fpara, lpara, parN)) EndOfArrow = nApex;
+ else {
+ IsInDomain = Standard_False;
+ Standard_Real posd = Min(DistanceFromApex (elips,pApex, fpara),
+ DistanceFromApex (elips,pApex, lpara));
+ Standard_Real negd = Min(DistanceFromApex (elips,nApex, fpara),
+ DistanceFromApex (elips,nApex, lpara));
+ if( posd < negd )
+ EndOfArrow = pApex;
+ else
+ EndOfArrow = nApex;
+ }
+ }
+ return EndOfArrow;
+}
+
+//=======================================================================
+//function : ComputeProjEdgePresentation
+//purpose :
+//=======================================================================
+
+void PrsDim::ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPresentation,
+ const Handle(Prs3d_Drawer)& aDrawer,
+ const TopoDS_Edge& anEdge,
+ const Handle(Geom_Curve)& ProjCurve,
+ const gp_Pnt& FirstP,
+ const gp_Pnt& LastP,
+ const Quantity_NameOfColor aColor,
+ const Standard_Real aWidth,
+ const Aspect_TypeOfLine aProjTOL,
+ const Aspect_TypeOfLine aCallTOL)
+{
+ if (!aDrawer->HasOwnWireAspect()){
+ aDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aProjTOL,2.));}
+ else {
+ // CLE
+ // const Handle(Prs3d_LineAspect)& li = aDrawer->WireAspect();
+ Handle(Prs3d_LineAspect) li = aDrawer->WireAspect();
+ // ENDCLE
+ li->SetColor(aColor);
+ li->SetTypeOfLine(aProjTOL);
+ li->SetWidth(aWidth);
+ }
+
+ Standard_Real pf, pl;
+ TopLoc_Location loc;
+ Handle(Geom_Curve) curve;
+ Standard_Boolean isInfinite;
+ curve = BRep_Tool::Curve(anEdge,loc,pf,pl);
+ isInfinite = (Precision::IsInfinite(pf) || Precision::IsInfinite(pl));
+
+ TopoDS_Edge E;
+
+ // Calculate presentation of the edge
+ if (ProjCurve->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
+ // CLE
+ // Handle(Geom_Line) gl (Handle(Geom_Line)::DownCast (ProjCurve));
+ Handle(Geom_Line) gl = Handle(Geom_Line)::DownCast (ProjCurve);
+ // ENDCLE
+ if ( !isInfinite) {
+ pf = ElCLib::Parameter(gl->Lin(),FirstP);
+ pl = ElCLib::Parameter(gl->Lin(),LastP);
+ BRepBuilderAPI_MakeEdge MakEd(gl->Lin(), pf, pl);
+ E = MakEd.Edge();
+ }
+ else {
+ BRepBuilderAPI_MakeEdge MakEd(gl->Lin());
+ E = MakEd.Edge();
+ }
+ }
+ else if (ProjCurve->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
+ // CLE
+ // Handle(Geom_Circle) gc (Handle(Geom_Circle)::DownCast (ProjCurve));
+ Handle(Geom_Circle) gc = Handle(Geom_Circle)::DownCast (ProjCurve);
+ // ENDCLE
+ pf = ElCLib::Parameter(gc->Circ(),FirstP);
+ pl = ElCLib::Parameter(gc->Circ(),LastP);
+ BRepBuilderAPI_MakeEdge MakEd(gc->Circ(),pf, pl);
+ E = MakEd.Edge();
+ }
+ StdPrs_WFShape::Add (aPresentation, E, aDrawer);
+
+ //Calculate the presentation of line connections
+ aDrawer->WireAspect()->SetTypeOfLine(aCallTOL);
+ if (!isInfinite) {
+ gp_Pnt ppf(0.0,0.0,0.0), ppl(0.0,0.0,0.0);
+ ppf = BRep_Tool::Pnt( TopExp::FirstVertex(TopoDS::Edge(anEdge)));
+ ppl = BRep_Tool::Pnt( TopExp::LastVertex(TopoDS::Edge(anEdge)));
+
+ // it is patch!
+ if (FirstP.SquareDistance (ppf) > SquareTolerance)
+ {
+ BRepBuilderAPI_MakeEdge MakEd1 (FirstP, ppf);
+ StdPrs_WFShape::Add (aPresentation, MakEd1.Edge(), aDrawer);
+ }
+ else
+ {
+ BRepBuilderAPI_MakeVertex MakVert1 (FirstP);
+ StdPrs_WFShape::Add (aPresentation, MakVert1.Vertex(), aDrawer);
+ }
+ if (LastP.SquareDistance (ppl) > SquareTolerance)
+ {
+ BRepBuilderAPI_MakeEdge MakEd2 (LastP, ppl);
+ StdPrs_WFShape::Add (aPresentation, MakEd2.Edge(), aDrawer);
+ }
+ else
+ {
+ BRepBuilderAPI_MakeVertex MakVert2 (LastP);
+ StdPrs_WFShape::Add (aPresentation, MakVert2.Vertex(), aDrawer);
+ }
+/*
+ BRepBuilderAPI_MakeEdge MakEd1 (FirstP, ppf);
+ StdPrs_WFShape::Add (aPresentation, MakEd1.Edge(), aDrawer);
+ BRepBuilderAPI_MakeEdge MakEd2 (LastP, ppl);
+ StdPrs_WFShape::Add (aPresentation, MakEd2.Edge(), aDrawer);
+*/
+ }
+}
+
+//=======================================================================
+//function : ComputeProjVertexPresentation
+//purpose :
+//=======================================================================
+
+void PrsDim::ComputeProjVertexPresentation (const Handle( Prs3d_Presentation )& aPresentation,
+ const Handle( Prs3d_Drawer )& aDrawer,
+ const TopoDS_Vertex& aVertex,
+ const gp_Pnt& ProjPoint,
+ const Quantity_NameOfColor aColor,
+ const Standard_Real aWidth,
+ const Aspect_TypeOfMarker aProjTOM,
+ const Aspect_TypeOfLine aCallTOL)
+{
+ if (!aDrawer->HasOwnPointAspect()){
+ aDrawer->SetPointAspect(new Prs3d_PointAspect(aProjTOM, aColor,1));}
+ else {
+ // CLE
+ // const Handle(Prs3d_PointAspect)& pa = aDrawer->PointAspect();
+ Handle(Prs3d_PointAspect) pa = aDrawer->PointAspect();
+ // ENDCLE
+ pa->SetColor(aColor);
+ pa->SetTypeOfMarker(aProjTOM);
+ }
+
+ // calculate the projection
+ StdPrs_Point::Add(aPresentation, new Geom_CartesianPoint(ProjPoint), aDrawer);
+
+ if (!aDrawer->HasOwnWireAspect()){
+ aDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aCallTOL,2.));}
+ else {
+ // CLE
+ // const Handle(Prs3d_LineAspect)& li = aDrawer->WireAspect();
+ Handle(Prs3d_LineAspect) li = aDrawer->WireAspect();
+ // ENDCLE
+ li->SetColor(aColor);
+ li->SetTypeOfLine(aCallTOL);
+ li->SetWidth(aWidth);
+ }
+
+ // If the points are not mixed...
+ if (!ProjPoint.IsEqual (BRep_Tool::Pnt (aVertex), Precision::Confusion()))
+ {
+ // calculate the lines of recall
+ BRepBuilderAPI_MakeEdge MakEd (ProjPoint, BRep_Tool::Pnt (aVertex));
+ StdPrs_WFShape::Add (aPresentation, MakEd.Edge(), aDrawer);
+ }
+}
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_HeaderFile
+#define _PrsDim_HeaderFile
+
+#include <PrsDim_KindOfSurface.hxx>
+#include <Aspect_TypeOfLine.hxx>
+#include <Aspect_TypeOfMarker.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+#include <Quantity_NameOfColor.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+class Bnd_Box;
+class Geom_Curve;
+class Geom_Plane;
+class Geom_Surface;
+class TopoDS_Edge;
+class TopoDS_Face;
+class TopoDS_Shape;
+class TopoDS_Vertex;
+
+//! Auxiliary methods for computing dimensions.
+class PrsDim
+{
+public:
+
+ DEFINE_STANDARD_ALLOC
+
+ //! Returns the nearest point in a shape. This is used by
+ //! several classes in calculation of dimensions.
+ Standard_EXPORT static gp_Pnt Nearest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
+
+ //! @return the nearest point on the line.
+ Standard_EXPORT static gp_Pnt Nearest (const gp_Lin& theLine, const gp_Pnt& thePoint);
+
+ //! For the given point finds nearest point on the curve,
+ //! @return TRUE if found point is belongs to the curve
+ //! and FALSE otherwise.
+ Standard_EXPORT static Standard_Boolean Nearest (const Handle(Geom_Curve)& theCurve, const gp_Pnt& thePoint, const gp_Pnt& theFirstPoint, const gp_Pnt& theLastPoint, gp_Pnt& theNearestPoint);
+
+ Standard_EXPORT static gp_Pnt Farest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
+
+ //! Used by 2d Relation only
+ //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
+ //! and the extremities if any
+ //! Return TRUE if ok.
+ Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt);
+
+ //! Used by dimensions only.
+ //! Computes the 3d geometry of <anEdge>.
+ //! Return TRUE if ok.
+ Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Standard_Boolean& theIsInfinite);
+
+ //! Used by 2d Relation only
+ //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
+ //! and the extremities if any.
+ //! If <aCurve> is not in the current plane, <extCurve> contains
+ //! 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.
+ Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsInfinite, Standard_Boolean& theIsOnPlane, const Handle(Geom_Plane)& thePlane);
+
+ //! Used by 2d Relation only
+ //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
+ //! and the extremities if any
+ //! Return TRUE if ok.
+ Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, const Handle(Geom_Plane)& thePlane);
+
+ //! Used by dimensions only.Computes the 3d geometry
+ //! of<anEdge1> and <anEdge2> and checks if they are infinite.
+ Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2);
+
+ //! 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
+ //! (not projected in the plane) of the first edge if
+ //! <indexExt> =1 or of the 2nd edge if <indexExt> = 2. If
+ //! <indexExt> = 0, ExtCurve is Null. if there is an edge
+ //! external to the plane, <isinfinite> is true if this
+ //! edge is infinite. So, the extremities of it are not
+ //! significant. Return TRUE if ok
+ Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Standard_Integer& theExtIndex, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2, const Handle(Geom_Plane)& thePlane);
+
+ //! Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
+ //! and returns aCurve;
+ //! Return TRUE if ok
+ Standard_EXPORT static Standard_Boolean ComputeGeomCurve (Handle(Geom_Curve)& aCurve, const Standard_Real first1, const Standard_Real last1, gp_Pnt& FirstPnt1, gp_Pnt& LastPnt1, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane);
+
+ Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Vertex& aVertex, gp_Pnt& point, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane);
+
+ //! 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
+ Standard_EXPORT static Standard_Boolean GetPlaneFromFace (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurf, PrsDim_KindOfSurface& aSurfType, Standard_Real& Offset);
+
+ Standard_EXPORT static void InitFaceLength (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurface, PrsDim_KindOfSurface& aSurfaceType, Standard_Real& anOffset);
+
+ //! 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.
+ Standard_EXPORT static void InitLengthBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, Handle(Geom_Surface)& theFirstSurf, Handle(Geom_Surface)& theSecondSurf, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, gp_Dir& theDirOnPlane);
+
+ //! Finds three points for the angle dimension between
+ //! two planes.
+ Standard_EXPORT static Standard_Boolean InitAngleBetweenPlanarFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False);
+
+ //! Finds three points for the angle dimension between
+ //! two curvilinear surfaces.
+ Standard_EXPORT static Standard_Boolean InitAngleBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, const PrsDim_KindOfSurface theFirstSurfType, const PrsDim_KindOfSurface theSecondSurfType, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False);
+
+ Standard_EXPORT static gp_Pnt ProjectPointOnPlane (const gp_Pnt& aPoint, const gp_Pln& aPlane);
+
+ Standard_EXPORT static gp_Pnt ProjectPointOnLine (const gp_Pnt& aPoint, const gp_Lin& aLine);
+
+ Standard_EXPORT static gp_Pnt TranslatePointToBound (const gp_Pnt& aPoint, const gp_Dir& aDir, const Bnd_Box& aBndBox);
+
+ //! returns True if point with anAttachPar is
+ //! in domain of arc
+ Standard_EXPORT static Standard_Boolean InDomain (const Standard_Real aFirstPar, const Standard_Real aLastPar, const Standard_Real anAttachPar);
+
+ //! computes nearest to ellipse arc apex
+ Standard_EXPORT static gp_Pnt NearestApex (const gp_Elips& elips, const gp_Pnt& pApex, const gp_Pnt& nApex, const Standard_Real fpara, const Standard_Real lpara, Standard_Boolean& IsInDomain);
+
+ //! computes length of ellipse arc in parametric units
+ Standard_EXPORT static Standard_Real DistanceFromApex (const gp_Elips& elips, const gp_Pnt& Apex, const Standard_Real par);
+
+ Standard_EXPORT static void ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Edge& anEdge, const Handle(Geom_Curve)& ProjCurve, const gp_Pnt& FirstP, const gp_Pnt& LastP, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfLine aProjTOL = Aspect_TOL_DASH, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
+
+ Standard_EXPORT static void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
+
+};
+
+#endif // _PrsDim_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Arnaud BOUZY/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_AngleDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <BRep_Tool.hxx>
+#include <ElCLib.hxx>
+#include <GCPnts_UniformAbscissa.hxx>
+#include <GC_MakeArcOfCircle.hxx>
+#include <gce_MakeLin2d.hxx>
+#include <gce_MakeLin.hxx>
+#include <gce_MakeCirc.hxx>
+#include <gce_MakeCone.hxx>
+#include <gce_MakePln.hxx>
+#include <gce_MakeDir.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
+#include <Geom_OffsetSurface.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <IntAna2d_AnaIntersection.hxx>
+#include <ProjLib.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Select3D_SensitiveGroup.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_ProgramError.hxx>
+#include <UnitsAPI.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_AngleDimension, PrsDim_Dimension)
+
+namespace
+{
+ static const TCollection_ExtendedString THE_EMPTY_LABEL_STRING;
+ static const Standard_Real THE_EMPTY_LABEL_WIDTH = 0.0;
+ static const Standard_ExtCharacter THE_DEGREE_SYMBOL (0x00B0);
+ static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
+
+ //! Returns true if the given points lie on a same line.
+ static Standard_Boolean isSameLine (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theCenterPoint,
+ const gp_Pnt& theSecondPoint)
+ {
+ gp_Vec aVec1 (theFirstPoint, theCenterPoint);
+ gp_Vec aVec2 (theCenterPoint, theSecondPoint);
+
+ return aVec1.IsParallel (aVec2, Precision::Angular());
+ }
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_AngleDimension::PrsDim_AngleDimension (const TopoDS_Edge& theFirstEdge,
+ const TopoDS_Edge& theSecondEdge)
+: PrsDim_Dimension (PrsDim_KOD_PLANEANGLE)
+{
+ Init();
+ SetMeasuredGeometry (theFirstEdge, theSecondEdge);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_AngleDimension::PrsDim_AngleDimension (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const gp_Pnt& theThirdPoint)
+: PrsDim_Dimension (PrsDim_KOD_PLANEANGLE)
+{
+ Init();
+ SetMeasuredGeometry (theFirstPoint, theSecondPoint, theThirdPoint);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_AngleDimension::PrsDim_AngleDimension (const TopoDS_Vertex& theFirstVertex,
+ const TopoDS_Vertex& theSecondVertex,
+ const TopoDS_Vertex& theThirdVertex)
+: PrsDim_Dimension (PrsDim_KOD_PLANEANGLE)
+{
+ Init();
+ SetMeasuredGeometry (theFirstVertex, theSecondVertex, theThirdVertex);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_AngleDimension::PrsDim_AngleDimension (const TopoDS_Face& theCone)
+: PrsDim_Dimension (PrsDim_KOD_PLANEANGLE)
+{
+ Init();
+ SetMeasuredGeometry (theCone);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_AngleDimension::PrsDim_AngleDimension (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace)
+: PrsDim_Dimension (PrsDim_KOD_PLANEANGLE)
+{
+ Init();
+ SetMeasuredGeometry (theFirstFace, theSecondFace);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_AngleDimension::PrsDim_AngleDimension (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace,
+ const gp_Pnt& thePoint)
+: PrsDim_Dimension (PrsDim_KOD_PLANEANGLE)
+{
+ Init();
+ SetMeasuredGeometry (theFirstFace, theSecondFace, thePoint);
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge,
+ const TopoDS_Edge& theSecondEdge)
+{
+ gp_Pln aComputedPlane;
+
+ myFirstShape = theFirstEdge;
+ mySecondShape = theSecondEdge;
+ myThirdShape = TopoDS_Shape();
+ myGeometryType = GeometryType_Edges;
+ myIsGeometryValid = InitTwoEdgesAngle (aComputedPlane);
+
+ if (myIsGeometryValid && !myIsPlaneCustom)
+ {
+ myPlane = aComputedPlane;
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const gp_Pnt& theThirdPoint)
+{
+ myFirstPoint = theFirstPoint;
+ myCenterPoint = theSecondPoint;
+ mySecondPoint = theThirdPoint;
+ myFirstShape = BRepLib_MakeVertex (myFirstPoint);
+ mySecondShape = BRepLib_MakeVertex (myCenterPoint);
+ myThirdShape = BRepLib_MakeVertex (mySecondPoint);
+ myGeometryType = GeometryType_Points;
+ myIsGeometryValid = IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
+
+ Standard_Boolean anIsSameLine = isSameLine (myFirstPoint, myCenterPoint, mySecondPoint);
+ if (myIsGeometryValid && !myIsPlaneCustom && !anIsSameLine)
+ {
+ ComputePlane();
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetMeasuredGeometry (const TopoDS_Vertex& theFirstVertex,
+ 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;
+ myIsGeometryValid = IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
+
+ Standard_Boolean anIsSameLine = isSameLine (myFirstPoint, myCenterPoint, mySecondPoint);
+ if (myIsGeometryValid && !myIsPlaneCustom && !anIsSameLine)
+ {
+ ComputePlane();
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theCone)
+{
+ myFirstShape = theCone;
+ mySecondShape = TopoDS_Shape();
+ myThirdShape = TopoDS_Shape();
+ myGeometryType = GeometryType_Face;
+ myIsGeometryValid = InitConeAngle();
+
+ if (myIsGeometryValid && !myIsPlaneCustom)
+ {
+ ComputePlane();
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace)
+{
+ myFirstShape = theFirstFace;
+ mySecondShape = theSecondFace;
+ myThirdShape = TopoDS_Shape();
+ myGeometryType = GeometryType_Faces;
+ myIsGeometryValid = InitTwoFacesAngle();
+
+ if (myIsGeometryValid && !myIsPlaneCustom)
+ {
+ ComputePlane();
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace,
+ const gp_Pnt& thePoint)
+{
+ myFirstShape = theFirstFace;
+ mySecondShape = theSecondFace;
+ myThirdShape = TopoDS_Shape();
+ myGeometryType = GeometryType_Faces;
+ myIsGeometryValid = InitTwoFacesAngle (thePoint);
+
+ if (myIsGeometryValid && !myIsPlaneCustom)
+ {
+ ComputePlane();
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : Init
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::Init()
+{
+ SetType (PrsDim_TypeOfAngle_Interior);
+ SetArrowsVisibility (PrsDim_TypeOfAngleArrowVisibility_Both);
+ SetSpecialSymbol (THE_DEGREE_SYMBOL);
+ SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_After);
+ SetFlyout (15.0);
+}
+
+//=======================================================================
+//function: GetCenterOnArc
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim_AngleDimension::GetCenterOnArc (const gp_Pnt& theFirstAttach,
+ const gp_Pnt& theSecondAttach,
+ const gp_Pnt& theCenter) const
+{
+ // construct plane where the circle and the arc are located
+ gce_MakePln aConstructPlane (theFirstAttach, theSecondAttach, theCenter);
+ if (!aConstructPlane.IsDone())
+ {
+ return gp::Origin();
+ }
+
+ gp_Pln aPlane = aConstructPlane.Value();
+ // to have an exterior angle presentation, a plane for further constructed circle should be reversed
+ if (myType == PrsDim_TypeOfAngle_Exterior)
+ {
+ gp_Ax1 anAxis = aPlane.Axis();
+ gp_Dir aDir = anAxis.Direction();
+ aDir.Reverse();
+ aPlane.SetAxis(gp_Ax1(anAxis.Location(), aDir));
+ }
+
+ Standard_Real aRadius = theFirstAttach.Distance (theCenter);
+
+ // construct circle forming the arc
+ gce_MakeCirc aConstructCircle (theCenter, aPlane, aRadius);
+ if (!aConstructCircle.IsDone())
+ {
+ return gp::Origin();
+ }
+
+ gp_Circ aCircle = aConstructCircle.Value();
+
+ // compute angle parameters of arc end-points on circle
+ Standard_Real aParamBeg = ElCLib::Parameter (aCircle, theFirstAttach);
+ Standard_Real aParamEnd = ElCLib::Parameter (aCircle, theSecondAttach);
+ ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd);
+
+ return ElCLib::Value ((aParamBeg + aParamEnd) * 0.5, aCircle);
+}
+
+//=======================================================================
+//function : GetNormalForMinAngle
+//purpose :
+//=======================================================================
+gp_Dir PrsDim_AngleDimension::GetNormalForMinAngle() const
+{
+ const gp_Dir& aNormal = myPlane.Axis().Direction();
+ gp_Dir aFirst (gp_Vec (myCenterPoint, myFirstPoint) );
+ gp_Dir aSecond (gp_Vec (myCenterPoint, mySecondPoint) );
+
+ return aFirst.AngleWithRef (aSecond, aNormal) < 0.0
+ ? aNormal.Reversed()
+ : aNormal;
+}
+
+//=======================================================================
+//function : DrawArc
+//purpose : draws the arc between two attach points
+//=======================================================================
+void PrsDim_AngleDimension::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)
+{
+ gp_Pln aPlane (myCenterPoint, GetNormalForMinAngle());
+
+ // to have an exterior angle presentation, a plane for further constructed circle should be reversed
+ if (myType == PrsDim_TypeOfAngle_Exterior)
+ {
+ gp_Ax1 anAxis = aPlane.Axis();
+ gp_Dir aDir = anAxis.Direction();
+ aDir.Reverse();
+ aPlane.SetAxis(gp_Ax1(anAxis.Location(), aDir));
+ }
+
+ // construct circle forming the arc
+ gce_MakeCirc aConstructCircle (theCenter, aPlane, theRadius);
+ if (!aConstructCircle.IsDone())
+ {
+ return;
+ }
+
+ gp_Circ aCircle = aConstructCircle.Value();
+
+ // construct the arc
+ GC_MakeArcOfCircle aConstructArc (aCircle, theFirstAttach, theSecondAttach, Standard_True);
+ if (!aConstructArc.IsDone())
+ {
+ return;
+ }
+
+ // generate points with specified deflection
+ const Handle(Geom_TrimmedCurve)& anArcCurve = aConstructArc.Value();
+
+ GeomAdaptor_Curve anArcAdaptor (anArcCurve, anArcCurve->FirstParameter(), anArcCurve->LastParameter());
+
+ // compute number of discretization elements in old-fanshioned way
+ gp_Vec aCenterToFirstVec (theCenter, theFirstAttach);
+ gp_Vec aCenterToSecondVec (theCenter, theSecondAttach);
+ Standard_Real anAngle = aCenterToFirstVec.Angle (aCenterToSecondVec);
+ if (myType == PrsDim_TypeOfAngle_Exterior)
+ anAngle = 2.0 * M_PI - anAngle;
+ // it sets 50 points on PI, and a part of points if angle is less
+ const Standard_Integer aNbPoints = Max (4, Standard_Integer (50.0 * anAngle / M_PI));
+
+ GCPnts_UniformAbscissa aMakePnts (anArcAdaptor, aNbPoints);
+ if (!aMakePnts.IsDone())
+ {
+ return;
+ }
+
+ // init data arrays for graphical and selection primitives
+ Handle(Graphic3d_ArrayOfPolylines) aPrimSegments = new Graphic3d_ArrayOfPolylines (aNbPoints);
+
+ SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
+
+ // load data into arrays
+ for (Standard_Integer aPntIt = 1; aPntIt <= aMakePnts.NbPoints(); ++aPntIt)
+ {
+ gp_Pnt aPnt = anArcAdaptor.Value (aMakePnts.Parameter (aPntIt));
+
+ aPrimSegments->AddVertex (aPnt);
+
+ aSensitiveCurve.Append (aPnt);
+ }
+
+ // add display presentation
+ if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
+ {
+ Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True);
+ }
+ Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
+ Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionLineStyle);
+ Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
+ if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
+ {
+ Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False);
+ }
+}
+
+//=======================================================================
+//function: DrawArcWithText
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::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)
+{
+ gp_Pln aPlane (myCenterPoint, GetNormalForMinAngle());
+
+ Standard_Real aRadius = theFirstAttach.Distance (myCenterPoint);
+
+ // construct circle forming the arc
+ gce_MakeCirc aConstructCircle (theCenter, aPlane, aRadius);
+ if (!aConstructCircle.IsDone())
+ {
+ return;
+ }
+
+ gp_Circ aCircle = aConstructCircle.Value();
+
+ // compute angle parameters of arc end-points on circle
+ Standard_Real aParamBeg = ElCLib::Parameter (aCircle, theFirstAttach);
+ Standard_Real aParamEnd = ElCLib::Parameter (aCircle, theSecondAttach);
+ ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd);
+
+ // middle point of arc parameter on circle
+ Standard_Real aParamMid = (aParamBeg + aParamEnd) * 0.5;
+
+ // add text graphical primitives
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
+ {
+ gp_Pnt aTextPos = ElCLib::Value (aParamMid, aCircle);
+ gp_Dir aTextDir = gce_MakeDir (theFirstAttach, theSecondAttach);
+
+ // Drawing text
+ drawText (thePresentation,
+ aTextPos,
+ aTextDir,
+ theText,
+ theLabelPosition);
+ }
+
+ if (theMode != ComputeMode_All && theMode != ComputeMode_Line)
+ {
+ return;
+ }
+
+ Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
+
+ Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
+ && aDimensionAspect->IsText3d();
+
+ if (isLineBreak)
+ {
+ // compute gap for label as parameteric size of sector on circle segment
+ Standard_Real aSectorOfText = theTextWidth / aRadius;
+ Standard_Real aTextBegin = aParamMid - aSectorOfText * 0.5;
+ Standard_Real aTextEnd = aParamMid + aSectorOfText * 0.5;
+ gp_Pnt aTextPntBeg = ElCLib::Value (aTextBegin, aCircle);
+ gp_Pnt aTextPntEnd = ElCLib::Value (aTextEnd, aCircle);
+
+ // Drawing arcs
+ if (aTextBegin > aParamBeg)
+ {
+ DrawArc (thePresentation, theFirstAttach, aTextPntBeg, theCenter, aRadius, theMode);
+ }
+ if (aTextEnd < aParamEnd)
+ {
+ DrawArc (thePresentation, aTextPntEnd, theSecondAttach, theCenter, aRadius, theMode);
+ }
+ }
+ else
+ {
+ DrawArc (thePresentation, theFirstAttach, theSecondAttach, theCenter, aRadius, theMode);
+ }
+}
+
+//=======================================================================
+//function : CheckPlane
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_AngleDimension::CheckPlane (const gp_Pln& thePlane)const
+{
+ if (!thePlane.Contains (myFirstPoint, Precision::Confusion()) &&
+ !thePlane.Contains (mySecondPoint, Precision::Confusion()) &&
+ !thePlane.Contains (myCenterPoint, Precision::Confusion()))
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputePlane
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::ComputePlane()
+{
+ if (!myIsGeometryValid)
+ {
+ return;
+ }
+
+ // Compute working plane so that Y axis is codirectional
+ // with Y axis of text coordinate system (necessary for text alignment)
+ gp_Vec aFirstVec = gp_Vec (myCenterPoint, myFirstPoint);
+ gp_Vec aSecondVec = gp_Vec (myCenterPoint, mySecondPoint);
+ gp_Vec aDirectionN = aSecondVec ^ aFirstVec;
+ gp_Vec aDirectionY = aFirstVec + aSecondVec;
+ gp_Vec aDirectionX = aDirectionY ^ aDirectionN;
+
+ myPlane = gp_Pln (gp_Ax3 (myCenterPoint, gp_Dir (aDirectionN), gp_Dir (aDirectionX)));
+}
+
+//=======================================================================
+//function : GetModelUnits
+//purpose :
+//=======================================================================
+const TCollection_AsciiString& PrsDim_AngleDimension::GetModelUnits() const
+{
+ return myDrawer->DimAngleModelUnits();
+}
+
+//=======================================================================
+//function : GetDisplayUnits
+//purpose :
+//=======================================================================
+const TCollection_AsciiString& PrsDim_AngleDimension::GetDisplayUnits() const
+{
+ return myDrawer->DimAngleDisplayUnits();
+}
+
+//=======================================================================
+//function : SetModelUnits
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetModelUnits (const TCollection_AsciiString& theUnits)
+{
+ myDrawer->SetDimAngleModelUnits (theUnits);
+}
+
+//=======================================================================
+//function : SetDisplayUnits
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
+{
+ myDrawer->SetDimAngleDisplayUnits (theUnits);
+}
+
+//=======================================================================
+//function : ComputeValue
+//purpose :
+//=======================================================================
+Standard_Real PrsDim_AngleDimension::ComputeValue() const
+{
+ if (!IsValid())
+ {
+ return 0.0;
+ }
+
+ gp_Vec aVec1 (myCenterPoint, myFirstPoint);
+ gp_Vec aVec2 (myCenterPoint, mySecondPoint);
+
+ Standard_Real anAngle = aVec1.AngleWithRef (aVec2, GetNormalForMinAngle());
+
+ return anAngle > 0.0 ? anAngle : (2.0 * M_PI + anAngle);
+}
+
+//=======================================================================
+//function : Compute
+//purpose : Having three gp_Pnt points compute presentation
+//=======================================================================
+void PrsDim_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode)
+{
+ mySelectionGeom.Clear (theMode);
+
+ if (!IsValid())
+ {
+ return;
+ }
+
+ // Parameters for presentation
+ Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
+
+ Prs3d_Root::CurrentGroup(thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+
+ Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
+
+ // prepare label string and compute its geometrical width
+ Standard_Real aLabelWidth;
+ TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
+
+ // add margins to label width
+ if (aDimensionAspect->IsText3d())
+ {
+ aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0;
+ }
+
+ // Get parameters from aspect or adjust it according with custom text position
+ Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
+ Prs3d_DimensionTextHorizontalPosition aHorisontalTextPos = aDimensionAspect->TextHorizontalPosition();
+
+ if (IsTextPositionCustom())
+ {
+ AdjustParameters (myFixedTextPosition,anExtensionSize, aHorisontalTextPos, myFlyout);
+ }
+
+ // Handle user-defined and automatic arrow placement
+ Standard_Boolean isArrowsExternal = Standard_False;
+ Standard_Integer aLabelPosition = LabelPosition_None;
+
+ FitTextAlignment (aHorisontalTextPos, aLabelPosition, isArrowsExternal);
+
+ gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
+ gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
+
+ //Arrows positions and directions
+ gp_Vec aWorkingPlaneDir (GetNormalForMinAngle());
+
+ gp_Dir aFirstExtensionDir = aWorkingPlaneDir.Reversed() ^ gp_Vec (myCenterPoint, aFirstAttach);
+ gp_Dir aSecondExtensionDir = aWorkingPlaneDir ^ gp_Vec (myCenterPoint, aSecondAttach);
+
+ gp_Vec aFirstArrowVec = gp_Vec (aFirstExtensionDir) * anArrowLength;
+ gp_Vec aSecondArrowVec = gp_Vec (aSecondExtensionDir) * anArrowLength;
+
+ if (isArrowsExternal)
+ {
+ aFirstArrowVec.Reverse();
+ aSecondArrowVec.Reverse();
+ }
+
+ gp_Pnt aFirstArrowBegin (0.0, 0.0, 0.0);
+ gp_Pnt aFirstArrowEnd (0.0, 0.0, 0.0);
+ gp_Pnt aSecondArrowBegin (0.0, 0.0, 0.0);
+ gp_Pnt aSecondArrowEnd (0.0, 0.0, 0.0);
+
+ aFirstArrowBegin = aFirstAttach;
+ aSecondArrowBegin = aSecondAttach;
+ aFirstArrowEnd = aFirstAttach.Translated (-aFirstArrowVec);
+ aSecondArrowEnd = aSecondAttach.Translated (-aSecondArrowVec);
+
+ // Group1: stenciling text and the angle dimension arc
+ Prs3d_Root::NewGroup (thePresentation);
+
+ Standard_Integer aHPosition = aLabelPosition & LabelPosition_HMask;
+
+ // draw text label
+ switch (aHPosition)
+ {
+ case LabelPosition_HCenter :
+ {
+ Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
+ && aDimensionAspect->IsText3d();
+
+ if (isLineBreak)
+ {
+ DrawArcWithText (thePresentation,
+ aFirstAttach,
+ aSecondAttach,
+ myCenterPoint,
+ aLabelString,
+ aLabelWidth,
+ theMode,
+ aLabelPosition);
+ break;
+ }
+
+ // compute text primitives
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
+ {
+ gp_Vec aDimensionDir (aFirstAttach, aSecondAttach);
+ gp_Pnt aTextPos = IsTextPositionCustom() ? myFixedTextPosition
+ : GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint);
+ gp_Dir aTextDir = aDimensionDir;
+
+ drawText (thePresentation,
+ aTextPos,
+ aTextDir,
+ aLabelString,
+ aLabelPosition);
+ }
+
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
+ {
+ DrawArc (thePresentation,
+ (isArrowsExternal || !isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_First)) ? aFirstAttach : aFirstArrowEnd,
+ (isArrowsExternal || !isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_Second)) ? aSecondAttach : aSecondArrowEnd,
+ myCenterPoint,
+ Abs (GetFlyout()),
+ theMode);
+ }
+ }
+ break;
+
+ case LabelPosition_Left :
+ {
+ DrawExtension (thePresentation,
+ anExtensionSize,
+ (isArrowsExternal && isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_First)) ? aFirstArrowEnd : aFirstAttach,
+ aFirstExtensionDir,
+ aLabelString,
+ aLabelWidth,
+ theMode,
+ aLabelPosition);
+ }
+ break;
+
+ case LabelPosition_Right :
+ {
+ DrawExtension (thePresentation,
+ anExtensionSize,
+ (isArrowsExternal && isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_Second)) ? aSecondArrowEnd : aSecondAttach,
+ aSecondExtensionDir,
+ aLabelString,
+ aLabelWidth,
+ theMode,
+ aLabelPosition);
+ }
+ break;
+ }
+
+ // dimension arc without text
+ if ((theMode == ComputeMode_All || theMode == ComputeMode_Line) && aHPosition != LabelPosition_HCenter)
+ {
+ Prs3d_Root::NewGroup (thePresentation);
+
+ DrawArc (thePresentation,
+ (isArrowsExternal || !isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_First)) ? aFirstAttach : aFirstArrowEnd,
+ (isArrowsExternal || !isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_Second)) ? aSecondAttach : aSecondArrowEnd,
+ myCenterPoint,
+ Abs(GetFlyout ()),
+ theMode);
+ }
+
+ // arrows and arrow extensions
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
+ {
+ Prs3d_Root::NewGroup (thePresentation);
+
+ if (isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_First))
+ DrawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec));
+ if (isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_Second))
+ DrawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec));
+ }
+
+ if ((theMode == ComputeMode_All || theMode == ComputeMode_Line) && isArrowsExternal)
+ {
+ Prs3d_Root::NewGroup (thePresentation);
+
+ if (aHPosition != LabelPosition_Left && isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_First))
+ {
+ DrawExtension (thePresentation,
+ aDimensionAspect->ArrowTailSize(),
+ aFirstArrowEnd,
+ aFirstExtensionDir,
+ THE_EMPTY_LABEL_STRING,
+ THE_EMPTY_LABEL_WIDTH,
+ theMode,
+ LabelPosition_None);
+ }
+
+ if (aHPosition != LabelPosition_Right && isArrowVisible(PrsDim_TypeOfAngleArrowVisibility_Second))
+ {
+ DrawExtension (thePresentation,
+ aDimensionAspect->ArrowTailSize(),
+ aSecondArrowEnd,
+ aSecondExtensionDir,
+ THE_EMPTY_LABEL_STRING,
+ THE_EMPTY_LABEL_WIDTH,
+ theMode,
+ LabelPosition_None);
+ }
+ }
+
+ // flyouts
+ if (theMode == ComputeMode_All)
+ {
+ Prs3d_Root::NewGroup (thePresentation);
+
+ Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (4);
+ aPrimSegments->AddVertex (myCenterPoint);
+ aPrimSegments->AddVertex (aFirstAttach);
+ aPrimSegments->AddVertex (myCenterPoint);
+ aPrimSegments->AddVertex (aSecondAttach);
+
+ Handle(Graphic3d_AspectLine3d) aFlyoutStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
+ Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aFlyoutStyle);
+ Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
+ }
+
+ mySelectionGeom.IsComputed = Standard_True;
+}
+
+//=======================================================================
+//function : ComputeFlyoutSelection
+//purpose : computes selection for flyouts
+//=======================================================================
+void PrsDim_AngleDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
+ const Handle(SelectMgr_EntityOwner)& theOwner)
+{
+ gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
+ gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
+
+ Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (theOwner);
+ aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myCenterPoint, aFirstAttach));
+ aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myCenterPoint, aSecondAttach));
+
+ theSelection->Add (aSensitiveEntity);
+}
+
+//=======================================================================
+//function : InitTwoEdgesAngle
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane)
+{
+ TopoDS_Edge aFirstEdge = TopoDS::Edge (myFirstShape);
+ TopoDS_Edge aSecondEdge = TopoDS::Edge (mySecondShape);
+
+ BRepAdaptor_Curve aMakeFirstLine (aFirstEdge);
+ BRepAdaptor_Curve aMakeSecondLine (aSecondEdge);
+
+ if (aMakeFirstLine.GetType() != GeomAbs_Line || aMakeSecondLine.GetType() != GeomAbs_Line)
+ {
+ return Standard_False;
+ }
+
+ Handle(Geom_Line) aFirstLine = new Geom_Line (aMakeFirstLine.Line());
+ Handle(Geom_Line) aSecondLine = new Geom_Line (aMakeSecondLine.Line());
+
+ gp_Lin aFirstLin = aFirstLine->Lin();
+ gp_Lin aSecondLin = aSecondLine->Lin();
+
+ Standard_Boolean isParallelLines = aFirstLin.Direction().IsParallel (aSecondLin.Direction(), Precision::Angular());
+
+ theComputedPlane = isParallelLines ? gp_Pln(gp::XOY())
+ : gp_Pln (aSecondLin.Location(), gp_Vec (aFirstLin.Direction()) ^ gp_Vec (aSecondLin.Direction()));
+
+ // Compute geometry for this plane and edges
+ Standard_Boolean isInfinite1,isInfinite2;
+ gp_Pnt aFirstPoint1, aLastPoint1, aFirstPoint2, aLastPoint2;
+ Handle(Geom_Curve) aFirstCurve = aFirstLine, aSecondCurve = aSecondLine;
+ if (!PrsDim::ComputeGeometry (aFirstEdge, aSecondEdge,
+ aFirstCurve, aSecondCurve,
+ aFirstPoint1, aLastPoint1,
+ aFirstPoint2, aLastPoint2,
+ isInfinite1, isInfinite2))
+ {
+ return Standard_False;
+ }
+
+ Standard_Boolean isSameLines = aFirstLin.Direction().IsEqual (aSecondLin.Direction(), Precision::Angular())
+ && aFirstLin.Location().IsEqual (aSecondLin.Location(),Precision::Confusion());
+
+ // It can be the same gp_Lin geometry but the different begin and end parameters
+ Standard_Boolean isSameEdges =
+ (aFirstPoint1.IsEqual (aFirstPoint2, Precision::Confusion()) && aLastPoint1.IsEqual (aLastPoint2, Precision::Confusion()))
+ || (aFirstPoint1.IsEqual (aLastPoint2, Precision::Confusion()) && aLastPoint1.IsEqual (aFirstPoint2, Precision::Confusion()));
+
+ if (isParallelLines)
+ {
+ // Zero angle, it could not handle this geometry
+ if (isSameLines && isSameEdges)
+ {
+ return Standard_False;
+ }
+
+ // Handle the case of Pi angle
+ const Standard_Real aParam11 = ElCLib::Parameter (aFirstLin, aFirstPoint1);
+ const Standard_Real aParam12 = ElCLib::Parameter (aFirstLin, aLastPoint1);
+ const Standard_Real aParam21 = ElCLib::Parameter (aFirstLin, aFirstPoint2);
+ const Standard_Real aParam22 = ElCLib::Parameter (aFirstLin, aLastPoint2);
+ myCenterPoint = ElCLib::Value ( (Min (aParam11, aParam12) + Max (aParam21, aParam22)) * 0.5, aFirstLin);
+ myFirstPoint = myCenterPoint.Translated (gp_Vec (aFirstLin.Direction()) * Abs (GetFlyout()));
+ mySecondPoint = myCenterPoint.XYZ() + (aFirstLin.Direction().IsEqual (aSecondLin.Direction(), Precision::Angular())
+ ? aFirstLin.Direction().Reversed().XYZ() * Abs (GetFlyout())
+ : aSecondLin.Direction().XYZ() * Abs (GetFlyout()));
+ }
+ else
+ {
+ // Find intersection
+ gp_Lin2d aFirstLin2d = ProjLib::Project (theComputedPlane, aFirstLin);
+ gp_Lin2d aSecondLin2d = ProjLib::Project (theComputedPlane, aSecondLin);
+
+ IntAna2d_AnaIntersection anInt2d (aFirstLin2d, aSecondLin2d);
+ gp_Pnt2d anIntersectPoint;
+ if (!anInt2d.IsDone() || anInt2d.IsEmpty())
+ {
+ return Standard_False;
+ }
+
+ anIntersectPoint = gp_Pnt2d (anInt2d.Point(1).Value());
+ myCenterPoint = ElCLib::To3d (theComputedPlane.Position().Ax2(), anIntersectPoint);
+
+ if (isInfinite1 || isInfinite2)
+ {
+ myFirstPoint = myCenterPoint.Translated (gp_Vec (aFirstLin.Direction()) * Abs (GetFlyout()));
+ mySecondPoint = myCenterPoint.Translated (gp_Vec (aSecondLin.Direction()) * Abs (GetFlyout()));
+
+ return IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
+ }
+
+ // |
+ // | <- dimension should be here
+ // *----
+ myFirstPoint = myCenterPoint.Distance (aFirstPoint1) > myCenterPoint.Distance (aLastPoint1)
+ ? aFirstPoint1
+ : aLastPoint1;
+
+ mySecondPoint = myCenterPoint.Distance (aFirstPoint2) > myCenterPoint.Distance (aLastPoint2)
+ ? aFirstPoint2
+ : aLastPoint2;
+ }
+
+ return IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
+}
+
+//=======================================================================
+//function : InitTwoFacesAngle
+//purpose : initialization of angle dimension between two faces
+//=======================================================================
+Standard_Boolean PrsDim_AngleDimension::InitTwoFacesAngle()
+{
+ TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
+ TopoDS_Face aSecondFace = TopoDS::Face (mySecondShape);
+
+ gp_Dir aFirstDir, aSecondDir;
+ gp_Pln aFirstPln, aSecondPln;
+ Handle(Geom_Surface) aFirstBasisSurf, aSecondBasisSurf;
+ PrsDim_KindOfSurface aFirstSurfType, aSecondSurfType;
+ Standard_Real aFirstOffset, aSecondOffset;
+
+ PrsDim::GetPlaneFromFace (aFirstFace, aFirstPln,
+ aFirstBasisSurf,aFirstSurfType,aFirstOffset);
+
+ PrsDim::GetPlaneFromFace (aSecondFace, aSecondPln,
+ aSecondBasisSurf, aSecondSurfType, aSecondOffset);
+
+ if (aFirstSurfType == PrsDim_KOS_Plane && aSecondSurfType == PrsDim_KOS_Plane)
+ {
+ //Planar faces angle
+ Handle(Geom_Plane) aFirstPlane = Handle(Geom_Plane)::DownCast (aFirstBasisSurf);
+ Handle(Geom_Plane) aSecondPlane = Handle(Geom_Plane)::DownCast (aSecondBasisSurf);
+ return PrsDim::InitAngleBetweenPlanarFaces (aFirstFace, aSecondFace,
+ myCenterPoint, myFirstPoint, mySecondPoint)
+ && IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
+ }
+ else
+ {
+ // Curvilinear faces angle
+ return PrsDim::InitAngleBetweenCurvilinearFaces (aFirstFace, aSecondFace,
+ aFirstSurfType, aSecondSurfType,
+ myCenterPoint, myFirstPoint, mySecondPoint)
+ && IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
+ }
+}
+
+//=======================================================================
+//function : InitTwoFacesAngle
+//purpose : initialization of angle dimension between two faces
+//=======================================================================
+Standard_Boolean PrsDim_AngleDimension::InitTwoFacesAngle (const gp_Pnt& thePointOnFirstFace)
+{
+ TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
+ TopoDS_Face aSecondFace = TopoDS::Face (mySecondShape);
+
+ gp_Dir aFirstDir, aSecondDir;
+ gp_Pln aFirstPln, aSecondPln;
+ Handle(Geom_Surface) aFirstBasisSurf, aSecondBasisSurf;
+ PrsDim_KindOfSurface aFirstSurfType, aSecondSurfType;
+ Standard_Real aFirstOffset, aSecondOffset;
+
+ PrsDim::GetPlaneFromFace (aFirstFace, aFirstPln,
+ aFirstBasisSurf,aFirstSurfType,aFirstOffset);
+
+ PrsDim::GetPlaneFromFace (aSecondFace, aSecondPln,
+ aSecondBasisSurf, aSecondSurfType, aSecondOffset);
+
+ myFirstPoint = thePointOnFirstFace;
+ if (aFirstSurfType == PrsDim_KOS_Plane && aSecondSurfType == PrsDim_KOS_Plane)
+ {
+ //Planar faces angle
+ Handle(Geom_Plane) aFirstPlane = Handle(Geom_Plane)::DownCast (aFirstBasisSurf);
+ Handle(Geom_Plane) aSecondPlane = Handle(Geom_Plane)::DownCast (aSecondBasisSurf);
+ return PrsDim::InitAngleBetweenPlanarFaces (aFirstFace, aSecondFace,
+ myCenterPoint, myFirstPoint, mySecondPoint,
+ Standard_True)
+ && IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
+ }
+ else
+ {
+ // Curvilinear faces angle
+ return PrsDim::InitAngleBetweenCurvilinearFaces (aFirstFace, aSecondFace,
+ aFirstSurfType, aSecondSurfType,
+ myCenterPoint, myFirstPoint, mySecondPoint,
+ Standard_True)
+ && IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
+ }
+}
+
+//=======================================================================
+//function : InitConeAngle
+//purpose : initialization of the cone angle
+//=======================================================================
+Standard_Boolean PrsDim_AngleDimension::InitConeAngle()
+{
+ if (myFirstShape.IsNull())
+ {
+ return Standard_False;
+ }
+
+ TopoDS_Face aConeShape = TopoDS::Face (myFirstShape);
+ gp_Pln aPln;
+ gp_Cone aCone;
+ gp_Circ aCircle;
+ // A surface from the Face
+ Handle(Geom_Surface) aSurf;
+ Handle(Geom_OffsetSurface) aOffsetSurf;
+ Handle(Geom_ConicalSurface) aConicalSurf;
+ Handle(Geom_SurfaceOfRevolution) aRevSurf;
+ Handle(Geom_Line) aLine;
+ BRepAdaptor_Surface aConeAdaptor (aConeShape);
+ TopoDS_Face aFace;
+ PrsDim_KindOfSurface aSurfType;
+ Standard_Real anOffset = 0.;
+ Handle(Standard_Type) aType;
+
+ const Standard_Real aMaxV = aConeAdaptor.FirstVParameter();
+ const Standard_Real aMinV = aConeAdaptor.LastVParameter();
+ PrsDim::GetPlaneFromFace (aConeShape, aPln, aSurf, aSurfType, anOffset);
+ if (aSurfType == PrsDim_KOS_Revolution)
+ {
+ // Surface of revolution
+ aRevSurf = Handle(Geom_SurfaceOfRevolution)::DownCast(aSurf);
+ gp_Lin aLin (aRevSurf->Axis());
+ Handle(Geom_Curve) aBasisCurve = aRevSurf->BasisCurve();
+ //Must be a part of line (basis curve should be linear)
+ if (aBasisCurve ->DynamicType() != STANDARD_TYPE(Geom_Line))
+ return Standard_False;
+
+ gp_Pnt aFirst1 = aConeAdaptor.Value (0., aMinV);
+ gp_Pnt aLast1 = aConeAdaptor.Value (0., aMaxV);
+ gp_Vec aVec1 (aFirst1, aLast1);
+
+ //Projection <aFirst> on <aLin>
+ gp_Pnt aFirst2 = ElCLib::Value (ElCLib::Parameter (aLin, aFirst1), aLin);
+ // Projection <aLast> on <aLin>
+ gp_Pnt aLast2 = ElCLib::Value (ElCLib::Parameter (aLin, aLast1), aLin);
+
+ gp_Vec aVec2 (aFirst2, aLast2);
+
+ // Check if two parts of revolution are parallel (it's a cylinder) or normal (it's a circle).
+ if (aVec1.IsParallel (aVec2, Precision::Angular())
+ || aVec1.IsNormal (aVec2,Precision::Angular()))
+ return Standard_False;
+
+ gce_MakeCone aMkCone (aRevSurf->Axis(), aFirst1, aLast1);
+ aCone = aMkCone.Value();
+ myCenterPoint = aCone.Apex();
+ }
+ else
+ {
+ aType = aSurf->DynamicType();
+ if (aType == STANDARD_TYPE(Geom_OffsetSurface) || anOffset > 0.01)
+ {
+ // Offset surface
+ aOffsetSurf = new Geom_OffsetSurface (aSurf, anOffset);
+ aSurf = aOffsetSurf->Surface();
+ BRepBuilderAPI_MakeFace aMkFace(aSurf, Precision::Confusion());
+ aMkFace.Build();
+ if (!aMkFace.IsDone())
+ return Standard_False;
+ aConeAdaptor.Initialize (aMkFace.Face());
+ }
+ aCone = aConeAdaptor.Cone();
+ aConicalSurf = Handle(Geom_ConicalSurface)::DownCast (aSurf);
+ myCenterPoint = aConicalSurf->Apex();
+ }
+
+ // A circle where the angle is drawn
+ Handle(Geom_Curve) aCurve;
+ Standard_Real aMidV = ( aMinV + aMaxV ) / 2.5;
+ aCurve = aSurf->VIso (aMidV);
+ aCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ();
+
+ aCurve = aSurf->VIso(aMaxV);
+ gp_Circ aCircVmax = Handle(Geom_Circle)::DownCast(aCurve)->Circ();
+ aCurve = aSurf->VIso(aMinV);
+ gp_Circ aCircVmin = Handle(Geom_Circle)::DownCast(aCurve)->Circ();
+
+ if (aCircVmax.Radius() < aCircVmin.Radius())
+ {
+ gp_Circ aTmpCirc = aCircVmax;
+ aCircVmax = aCircVmin;
+ aCircVmin = aTmpCirc;
+ }
+
+ myFirstPoint = ElCLib::Value (0, aCircle);
+ mySecondPoint = ElCLib::Value (M_PI, aCircle);
+ return Standard_True;
+}
+
+//=======================================================================
+//function : IsValidPoints
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_AngleDimension::IsValidPoints (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theCenterPoint,
+ const gp_Pnt& theSecondPoint) const
+{
+ return theFirstPoint.Distance (theCenterPoint) > Precision::Confusion()
+ && theSecondPoint.Distance (theCenterPoint) > Precision::Confusion()
+ && gp_Vec (theCenterPoint, theFirstPoint).Angle (
+ gp_Vec (theCenterPoint, theSecondPoint)) > Precision::Angular();
+}
+
+//=======================================================================
+//function : isArrowVisible
+//purpose : compares given and internal arrows types, returns true if the the type should be shown
+//=======================================================================
+Standard_Boolean PrsDim_AngleDimension::isArrowVisible(const PrsDim_TypeOfAngleArrowVisibility theArrowType) const
+{
+ switch (theArrowType)
+ {
+ case PrsDim_TypeOfAngleArrowVisibility_Both:
+ return myArrowsVisibility == PrsDim_TypeOfAngleArrowVisibility_Both;
+ case PrsDim_TypeOfAngleArrowVisibility_First:
+ return myArrowsVisibility == PrsDim_TypeOfAngleArrowVisibility_Both || myArrowsVisibility == PrsDim_TypeOfAngleArrowVisibility_First;
+ case PrsDim_TypeOfAngleArrowVisibility_Second:
+ return myArrowsVisibility == PrsDim_TypeOfAngleArrowVisibility_Both || myArrowsVisibility == PrsDim_TypeOfAngleArrowVisibility_Second;
+ case PrsDim_TypeOfAngleArrowVisibility_None:
+ return false;
+ }
+ return false;
+}
+
+//=======================================================================
+//function : GetTextPosition
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim_AngleDimension::GetTextPosition() const
+{
+ if (!IsValid())
+ {
+ return gp::Origin();
+ }
+
+ if (IsTextPositionCustom())
+ {
+ return myFixedTextPosition;
+ }
+
+ // Counts text position according to the dimension parameters
+ gp_Pnt aTextPosition (gp::Origin());
+
+ Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
+
+ // Prepare label string and compute its geometrical width
+ Standard_Real aLabelWidth;
+ TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
+
+ gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
+ gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
+
+ // Handle user-defined and automatic arrow placement
+ Standard_Boolean isArrowsExternal = Standard_False;
+ Standard_Integer aLabelPosition = LabelPosition_None;
+ FitTextAlignment (aDimensionAspect->TextHorizontalPosition(),
+ aLabelPosition, isArrowsExternal);
+
+ // Get text position
+ switch (aLabelPosition & LabelPosition_HMask)
+ {
+ case LabelPosition_HCenter:
+ {
+ aTextPosition = GetCenterOnArc (aFirstAttach, aSecondAttach, myCenterPoint);
+ }
+ break;
+ case LabelPosition_Left:
+ {
+ gp_Dir aPlaneNormal = gp_Vec (aFirstAttach, aSecondAttach) ^ gp_Vec (myCenterPoint, aFirstAttach);
+ gp_Dir anExtensionDir = aPlaneNormal ^ gp_Vec (myCenterPoint, aFirstAttach);
+ Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
+ Standard_Real anOffset = isArrowsExternal
+ ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length()
+ : anExtensionSize;
+ gp_Vec anExtensionVec = gp_Vec (anExtensionDir) * -anOffset;
+ aTextPosition = aFirstAttach.Translated (anExtensionVec);
+ }
+ break;
+ case LabelPosition_Right:
+ {
+ gp_Dir aPlaneNormal = gp_Vec (aFirstAttach, aSecondAttach) ^ gp_Vec (myCenterPoint, aFirstAttach);
+ gp_Dir anExtensionDir = aPlaneNormal ^ gp_Vec (myCenterPoint, aSecondAttach);
+ Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
+ Standard_Real anOffset = isArrowsExternal
+ ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length()
+ : anExtensionSize;
+ gp_Vec anExtensionVec = gp_Vec (anExtensionDir) * anOffset;
+ aTextPosition = aSecondAttach.Translated (anExtensionVec);
+ }
+ break;
+ }
+
+ return aTextPosition;
+}
+
+//=======================================================================
+//function : SetTextPosition
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::SetTextPosition (const gp_Pnt& theTextPos)
+{
+ if (!IsValid())
+ {
+ return;
+ }
+
+ // The text position point for angle dimension should belong to the working plane.
+ if (!GetPlane().Contains (theTextPos, Precision::Confusion()))
+ {
+ throw Standard_ProgramError("The text position point for angle dimension doesn't belong to the working plane.");
+ }
+
+ myIsTextPositionFixed = Standard_True;
+ myFixedTextPosition = theTextPos;
+}
+
+//=======================================================================
+//function : AdjustParameters
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::AdjustParameters (const gp_Pnt& theTextPos,
+ Standard_Real& theExtensionSize,
+ Prs3d_DimensionTextHorizontalPosition& theAlignment,
+ Standard_Real& theFlyout) const
+{
+ Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
+ Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
+
+ // Build circle with radius that is equal to distance from text position to the center point.
+ Standard_Real aRadius = gp_Vec (myCenterPoint, theTextPos).Magnitude();
+
+ // Set attach points in positive direction of the flyout.
+ gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, myFirstPoint).Normalized() * aRadius);
+ gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, mySecondPoint).Normalized() * aRadius);
+
+ gce_MakeCirc aConstructCircle (myCenterPoint, GetPlane(), aRadius);
+ if (!aConstructCircle.IsDone())
+ {
+ return;
+ }
+ gp_Circ aCircle = aConstructCircle.Value();
+
+ // Default values
+ theExtensionSize = aDimensionAspect->ArrowAspect()->Length();
+ theAlignment = Prs3d_DTHP_Center;
+
+ Standard_Real aParamBeg = ElCLib::Parameter (aCircle, aFirstAttach);
+ Standard_Real aParamEnd = ElCLib::Parameter (aCircle, aSecondAttach);
+ if (aParamEnd < aParamBeg)
+ {
+ Standard_Real aParam = aParamEnd;
+ aParamEnd = aParamBeg;
+ aParamBeg = aParam;
+ }
+
+ ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd);
+ Standard_Real aTextPar = ElCLib::Parameter (aCircle , theTextPos);
+
+ // Horizontal center
+ if (aTextPar > aParamBeg && aTextPar < aParamEnd)
+ {
+ theFlyout = aRadius;
+ return;
+ }
+
+ aParamBeg += M_PI;
+ aParamEnd += M_PI;
+ ElCLib::AdjustPeriodic (0.0, M_PI * 2, Precision::PConfusion(), aParamBeg, aParamEnd);
+
+ if (aTextPar > aParamBeg && aTextPar < aParamEnd)
+ {
+ theFlyout = -aRadius;
+ return;
+ }
+
+ // Text on the extensions
+ gp_Lin aFirstLine = gce_MakeLin (myCenterPoint, myFirstPoint);
+ gp_Lin aSecondLine = gce_MakeLin (myCenterPoint, mySecondPoint);
+ gp_Pnt aFirstTextProj = PrsDim::Nearest (aFirstLine, theTextPos);
+ gp_Pnt aSecondTextProj = PrsDim::Nearest (aSecondLine, theTextPos);
+ Standard_Real aFirstDist = aFirstTextProj.Distance (theTextPos);
+ Standard_Real aSecondDist = aSecondTextProj.Distance (theTextPos);
+
+ if (aFirstDist <= aSecondDist)
+ {
+ aRadius = myCenterPoint.Distance (aFirstTextProj);
+ Standard_Real aNewExtensionSize = aFirstDist - anArrowLength;
+ theExtensionSize = aNewExtensionSize < 0.0 ? 0.0 : aNewExtensionSize;
+
+ theAlignment = Prs3d_DTHP_Left;
+
+ gp_Vec aPosFlyoutDir = gp_Vec (myCenterPoint, myFirstPoint).Normalized().Scaled (aRadius);
+
+ theFlyout = aFirstTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()
+ ? -aRadius : aRadius;
+ }
+ else
+ {
+ aRadius = myCenterPoint.Distance (aSecondTextProj);
+
+ Standard_Real aNewExtensionSize = aSecondDist - anArrowLength;
+
+ theExtensionSize = aNewExtensionSize < 0.0 ? 0.0 : aNewExtensionSize;
+
+ theAlignment = Prs3d_DTHP_Right;
+
+ gp_Vec aPosFlyoutDir = gp_Vec (myCenterPoint, mySecondPoint).Normalized().Scaled (aRadius);
+
+ theFlyout = aSecondTextProj.Distance (myCenterPoint.Translated (aPosFlyoutDir)) > Precision::Confusion()
+ ? -aRadius : aRadius;
+ }
+}
+
+//=======================================================================
+//function : FitTextAlignment
+//purpose :
+//=======================================================================
+void PrsDim_AngleDimension::FitTextAlignment (const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
+ Standard_Integer& theLabelPosition,
+ Standard_Boolean& theIsArrowsExternal) const
+{
+ Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
+
+ Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
+
+ // Prepare label string and compute its geometrical width
+ Standard_Real aLabelWidth;
+ TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
+
+ // add margins to label width
+ if (aDimensionAspect->IsText3d())
+ {
+ aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0;
+ }
+
+ gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
+ gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec (myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
+
+ // Handle user-defined and automatic arrow placement
+ switch (aDimensionAspect->ArrowOrientation())
+ {
+ case Prs3d_DAO_External: theIsArrowsExternal = true; break;
+ case Prs3d_DAO_Internal: theIsArrowsExternal = false; break;
+ case Prs3d_DAO_Fit:
+ {
+ gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
+ Standard_Real aDimensionWidth = anAttachVector.Magnitude();
+
+ // Add margin to ensure a small tail between text and arrow
+ Standard_Real anArrowMargin = aDimensionAspect->IsText3d()
+ ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN
+ : 0.0;
+
+ Standard_Real anArrowsWidth = (anArrowLength + anArrowMargin) * 2.0;
+
+ theIsArrowsExternal = aDimensionWidth < aLabelWidth + anArrowsWidth;
+ break;
+ }
+ }
+
+ // Handle user-defined and automatic text placement
+ switch (theHorizontalTextPos)
+ {
+ case Prs3d_DTHP_Left : theLabelPosition |= LabelPosition_Left; break;
+ case Prs3d_DTHP_Right : theLabelPosition |= LabelPosition_Right; break;
+ case Prs3d_DTHP_Center: theLabelPosition |= LabelPosition_HCenter; break;
+ case Prs3d_DTHP_Fit:
+ {
+ gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
+ Standard_Real aDimensionWidth = anAttachVector.Magnitude();
+ Standard_Real anArrowsWidth = anArrowLength * 2.0;
+ Standard_Real aContentWidth = theIsArrowsExternal ? aLabelWidth : aLabelWidth + anArrowsWidth;
+
+ theLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter;
+ break;
+ }
+ }
+
+ switch (aDimensionAspect->TextVerticalPosition())
+ {
+ case Prs3d_DTVP_Above : theLabelPosition |= LabelPosition_Above; break;
+ case Prs3d_DTVP_Below : theLabelPosition |= LabelPosition_Below; break;
+ case Prs3d_DTVP_Center : theLabelPosition |= LabelPosition_VCenter; break;
+ }
+}
--- /dev/null
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2013 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_AngleDimension_HeaderFile
+#define _PrsDim_AngleDimension_HeaderFile
+
+#include <PrsDim_Dimension.hxx>
+#include <PrsDim_TypeOfAngle.hxx>
+#include <PrsDim_TypeOfAngleArrowVisibility.hxx>
+
+#include <Geom_Plane.hxx>
+#include <Geom_Line.hxx>
+#include <gp.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Type.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_AngleDimension, PrsDim_Dimension)
+
+//! Angle dimension. Can be constructed:
+//! - on two intersected edges.
+//! - on three points or vertices.
+//! - on conical face.
+//! - between two intersected faces.
+//!
+//! In case of three points or two intersected edges the dimension plane
+//! (on which dimension presentation is built) can be computed uniquely
+//! as through three defined points can be built only one plane.
+//! Therefore, if user-defined plane differs from this one, the dimension can't be built.
+//!
+//! In cases of two planes automatic plane by default is built on point of the
+//! origin of parametric space of the first face (the basis surface) so, that
+//! the working plane and two faces intersection forms minimal angle between the faces.
+//! User can define the other point which the dimension plane should pass through
+//! using the appropriate constructor. This point can lay on the one of the faces or not.
+//! Also user can define his own plane but it should pass through the three points
+//! computed on the geometry initialization step (when the constructor or SetMeasuredGeometry() method
+//! is called).
+//!
+//! In case of the conical face the center point of the angle is the apex of the conical surface.
+//! The attachment points are points of the first and the last parameter of the basis circle of the cone.
+class PrsDim_AngleDimension : public PrsDim_Dimension
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_AngleDimension, PrsDim_Dimension)
+public:
+
+ //! Constructs minimum angle dimension between two linear edges (where possible).
+ //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
+ //! @param theFirstEdge [in] the first edge.
+ //! @param theSecondEdge [in] the second edge.
+ Standard_EXPORT PrsDim_AngleDimension (const TopoDS_Edge& theFirstEdge,
+ const TopoDS_Edge& theSecondEdge);
+
+ //! Constructs the angle display object defined by three points.
+ //! @param theFirstPoint [in] the first point (point on first angle flyout).
+ //! @param theSecondPoint [in] the center point of angle dimension.
+ //! @param theThirdPoint [in] the second point (point on second angle flyout).
+ Standard_EXPORT PrsDim_AngleDimension (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const gp_Pnt& theThirdPoint);
+
+ //! Constructs the angle display object defined by three vertices.
+ //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
+ //! @param theSecondVertex [in] the center vertex of angle dimension.
+ //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
+ Standard_EXPORT PrsDim_AngleDimension (const TopoDS_Vertex& theFirstVertex,
+ const TopoDS_Vertex& theSecondVertex,
+ const TopoDS_Vertex& theThirdVertex);
+
+ //! Constructs angle dimension for the cone face.
+ //! @param theCone [in] the conical face.
+ Standard_EXPORT PrsDim_AngleDimension (const TopoDS_Face& theCone);
+
+ //! Constructs angle dimension between two planar faces.
+ //! @param theFirstFace [in] the first face.
+ //! @param theSecondFace [in] the second face.
+ Standard_EXPORT PrsDim_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 PrsDim_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 Standard_OVERRIDE;
+
+ //! @return the model units string.
+ Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
+
+ //! Principle of horizontal text alignment settings:
+ //! - divide circle into two halves according to attachment points
+ //! - if aTextPos is between attach points -> Center + positive flyout
+ //! - if aTextPos is not between attach points but in this half -> Left or Right + positive flyout
+ //! - if aTextPos is between reflections of attach points -> Center + negative flyout
+ //! - if aTextPos is not between reflections of attach points -> Left or Right + negative flyout
+ Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual gp_Pnt GetTextPosition () const Standard_OVERRIDE;
+
+ //! Sets angle type.
+ //! @param theType [in] the type value.
+ void SetType (const PrsDim_TypeOfAngle theType) { myType = theType; }
+
+ //! @return the current angle type.
+ PrsDim_TypeOfAngle GetType() const { return myType; }
+
+ //! Sets visible arrows type
+ //! @param theType [in] the type of visibility of arrows.
+ void SetArrowsVisibility (const PrsDim_TypeOfAngleArrowVisibility& theType) { myArrowsVisibility = theType; }
+
+ //! @return the type of visibility of arrows.
+ PrsDim_TypeOfAngleArrowVisibility GetArrowsVisibility() const { return myArrowsVisibility; }
+
+protected:
+
+ //! Initialization of fields that is common to all constructors.
+ Standard_EXPORT void Init();
+
+ //! Gets plane normal for minimal angle.
+ //! Dimension computation is based on three attach points and plane normal.
+ //! Based on this normal angle arc, arrows and extensions are constructed.
+ gp_Dir GetNormalForMinAngle() const;
+
+ //! @param theFirstAttach [in] the first attachment point.
+ //! @param theSecondAttach [in] the second attachment point.
+ //! @param theCenter [in] the center point (center point of the angle).
+ //! @return the center of the dimension arc (the main dimension line in case of angle).
+ Standard_EXPORT gp_Pnt GetCenterOnArc (const gp_Pnt& theFirstAttach,
+ const gp_Pnt& theSecondAttach,
+ const gp_Pnt& theCenter) const;
+
+ //! Draws main dimension line (arc).
+ //! @param thePresentation [in] the dimension presentation.
+ //! @param theFirstAttach [in] the first attachment point.
+ //! @param theSecondAttach [in] the second attachment point.
+ //! @param theCenter [in] the center point (center point of the angle).
+ //! @param theRadius [in] the radius of the dimension arc.
+ //! @param theMode [in] the display mode.
+ Standard_EXPORT void DrawArc (const Handle(Prs3d_Presentation)& thePresentation,
+ const gp_Pnt& theFirstAttach,
+ const gp_Pnt& theSecondAttach,
+ const gp_Pnt& theCenter,
+ const Standard_Real theRadius,
+ const Standard_Integer theMode);
+
+ //! Draws main dimension line (arc) with text.
+ //! @param thePresentation [in] the dimension presentation.
+ //! @param theFirstAttach [in] the first attachment point.
+ //! @param theSecondAttach [in] the second attachment point.
+ //! @param theCenter [in] the center point (center point of the angle).
+ //! @param theText [in] the text label string.
+ //! @param theTextWidth [in] the text label width.
+ //! @param theMode [in] the display mode.
+ //! @param theLabelPosition [in] the text label vertical and horizontal positioning option
+ //! respectively to the main dimension line.
+ Standard_EXPORT void DrawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
+ const gp_Pnt& theFirstAttach,
+ const gp_Pnt& theSecondAttach,
+ const gp_Pnt& theCenter,
+ const TCollection_ExtendedString& theText,
+ const Standard_Real theTextWidth,
+ const Standard_Integer theMode,
+ const Standard_Integer theLabelPosition);
+
+ //! Fits text alignment relatively to the dimension line;
+ //! it computes the value of label position and arrow orientation
+ //! according set in the aspect and dimension properties.
+ //! @param theHorizontalTextPos [in] the horizontal alignment for text position.
+ //! @param theLabelPosition [out] the label position, contains bits that defines
+ //! vertical and horizontal alignment. (for internal usage in count text position).
+ //! @param theIsArrowExternal [out] is the arrows external,
+ //! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow
+ //! orientation automatically.
+ Standard_EXPORT void FitTextAlignment (const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
+ Standard_Integer& theLabelPosition,
+ Standard_Boolean& theIsArrowsExternal) const;
+
+ //! Adjusts aspect parameters according the text position:
+ //! extension size, vertical text alignment and flyout.
+ //! @param theTextPos [in] the user defined 3d point of text position.
+ //! @param theExtensionSize [out] the adjusted extension size.
+ //! @param theAlignment [out] the horizontal label alignment.
+ //! @param theFlyout [out] the adjusted value of flyout.
+ Standard_EXPORT void AdjustParameters (const gp_Pnt& theTextPos,
+ Standard_Real& theExtensionSize,
+ Prs3d_DimensionTextHorizontalPosition& theAlignment,
+ Standard_Real& theFlyout) const;
+
+protected:
+
+ Standard_EXPORT virtual void ComputePlane();
+
+ //! Checks if the plane includes three angle points to build dimension.
+ Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
+ const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
+
+protected:
+
+ //! Init angular dimension to measure angle between two linear edges.
+ //! @return TRUE if the angular dimension can be constructured
+ //! for the passed edges.
+ Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane);
+
+ //! Init angular dimension to measure angle between two planar faces.
+ //! there is no user-defined poisitoning. So attach points are set
+ //! according to faces geometry (in origin of the first face basis surface).
+ //! @return TRUE if the angular dimension can be constructed
+ //! for the passed faces.
+ Standard_EXPORT Standard_Boolean InitTwoFacesAngle();
+
+ //! Init angular dimension to measure angle between two planar faces.
+ //! @param thePointOnFirstFace [in] the point which the dimension plane should pass through.
+ //! This point can lay on the one of the faces or not.
+ //! It will be projected on the first face and this point will be set
+ //! as the first point attach point.
+ //! It defines some kind of dimension positioning over the faces.
+ //! @return TRUE if the angular dimension can be constructed
+ //! for the passed faces.
+ Standard_EXPORT Standard_Boolean InitTwoFacesAngle (const gp_Pnt& thePointOnFirstFace);
+
+ //! Init angular dimension to measure cone face.
+ //! @return TRUE if the angular dimension can be constructed
+ //! for the passed cone.
+ Standard_EXPORT Standard_Boolean InitConeAngle();
+
+ //! Check that the points forming angle are valid.
+ //! @return TRUE if the points met the following requirements:
+ //! The (P1, Center), (P2, Center) can be built.
+ //! The angle between the vectors > Precision::Angular().
+ Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theCenterPoint,
+ const gp_Pnt& theSecondPoint) const;
+
+
+ //! Returns true if the arrow should be visible
+ //! @param theArrowType an arrow type
+ //! @return TRUE if the arrow should be visible
+ Standard_EXPORT Standard_Boolean isArrowVisible (const PrsDim_TypeOfAngleArrowVisibility theArrowType) const;
+
+private:
+ PrsDim_TypeOfAngle myType; //!< type of angle
+ PrsDim_TypeOfAngleArrowVisibility myArrowsVisibility; //!< type of arrows visibility
+
+ gp_Pnt myFirstPoint;
+ gp_Pnt mySecondPoint;
+ gp_Pnt myCenterPoint;
+ TopoDS_Shape myFirstShape;
+ TopoDS_Shape mySecondShape;
+ TopoDS_Shape myThirdShape;
+};
+
+#endif // _PrsDim_AngleDimension_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Flore Lantheaume/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_Chamf2dDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <DsgPrs_Chamf2dPresentation.hxx>
+#include <ElCLib.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Precision.hxx>
+#include <ProjLib.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopAbs_Orientation.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_Chamf2dDimension, PrsDim_Relation)
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_Chamf2dDimension::PrsDim_Chamf2dDimension(const TopoDS_Shape& aFShape,
+ const Handle(Geom_Plane)& aPlane,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText)
+:PrsDim_Relation()
+{
+ myFShape = aFShape;
+ myPlane = aPlane;
+ myVal = aVal;
+ myText = aText;
+ mySymbolPrs = DsgPrs_AS_LASTAR;
+ myAutomaticPosition = Standard_True;
+
+ myArrowSize = myVal / 100.;
+}
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_Chamf2dDimension::PrsDim_Chamf2dDimension(const TopoDS_Shape& aFShape,
+ const Handle(Geom_Plane)& aPlane,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText,
+ const gp_Pnt& aPosition,
+ const DsgPrs_ArrowSide aSymbolPrs ,
+ const Standard_Real anArrowSize)
+:PrsDim_Relation()
+{
+ myFShape = aFShape;
+ myPlane = aPlane;
+ myVal = aVal;
+ myText = aText;
+ myPosition = aPosition;
+ mySymbolPrs = aSymbolPrs;
+ SetArrowSize( anArrowSize );
+ myAutomaticPosition = Standard_False;
+}
+
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+void PrsDim_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer)
+{
+ Handle(Geom_Curve) gcurv;
+ gp_Pnt pfirst,plast;
+ const TopoDS_Edge& thechamfedge = TopoDS::Edge(myFShape);
+ if (!PrsDim::ComputeGeometry (thechamfedge, gcurv, pfirst, plast))
+ return;
+
+ Handle(Geom_Line) glin = Handle(Geom_Line)::DownCast (gcurv);
+ gp_Dir dir1 (glin->Position().Direction());
+ gp_Dir norm1 = myPlane->Pln().Axis().Direction();
+ myDir = norm1.Crossed(dir1);
+
+
+ //-------------------------------------------------
+ // calcul d'une direction orthogonale a l'edge du
+ // chanfrein et dirigee vers l'ext. du contour
+ //-------------------------------------------------
+
+
+ // recup. d'une edge adjacente a l'edge du chanfrein
+ /*TopoDS_Edge nextedge = TopoDS::Edge(mySShape);
+
+ gp_Pnt pfirstnext,plastnext;
+ Handle(Geom_Line) glinnext;
+ if (!PrsDim::ComputeGeometry(nextedge,glinnext,pfirstnext,plastnext) )
+ return;
+
+ gp_Vec v1(pfirst,plast);
+ gp_Vec v2;
+ if (pfirst.IsEqual(plastnext, Precision::Confusion()))
+ v2.SetXYZ(pfirstnext.XYZ() - pfirst.XYZ());
+ else
+ v2.SetXYZ(plastnext.XYZ() - pfirst.XYZ());
+ gp_Vec crossvec = v1.Crossed(v2);
+
+ myDir = dimserv.GetDirection().Crossed(glin->Position().Direction());
+ if (crossvec.Dot(dimserv.GetDirection()) > 0 )
+ myDir.Reverse();*/ // myDir => donne a la creation
+
+ //--------------------------------------------
+ //Calcul du point de positionnement du texte
+ //--------------------------------------------
+ gp_Pnt curpos;
+ if (myAutomaticPosition) {
+ myPntAttach.SetXYZ((pfirst.XYZ()+plast.XYZ())/2);
+ gp_Vec transVec(myDir);
+ transVec*=myVal;
+ curpos = myPntAttach.Translated(transVec);
+
+ if (myIsSetBndBox)
+ curpos = PrsDim::TranslatePointToBound( curpos, myDir, myBndBox );
+
+ myPosition = curpos;
+ }
+ else {
+
+ myPntAttach.SetXYZ((pfirst.XYZ()+plast.XYZ())/2);
+ Handle(Geom_Line) dimLin = new Geom_Line(myPntAttach, myDir);
+ Standard_Real parcurpos = ElCLib::Parameter(dimLin->Lin(),myPosition);
+ curpos = ElCLib::Value(parcurpos,dimLin->Lin());
+ //static Standard_Real minlength = 0.005;
+ //taille minimale de la dimension
+
+ if ( curpos.Distance(myPntAttach) < 5. ) {
+ gp_Vec transVec(myDir);
+ transVec*=5.;
+ curpos = myPntAttach.Translated(transVec);
+ }
+ myPosition = curpos;
+ }
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+
+ //-------------------------------------------------
+ //Calcul de la boite englobante du component pour
+ //determiner la taille de la fleche
+ //-------------------------------------------------
+
+ if( !myArrowSizeIsDefined ) {
+ Standard_Real arrsize = myArrowSize;
+ if ( (myVal/4) < arrsize)
+ arrsize = myVal/4;
+ if (arrsize > 30.)
+ arrsize = 30.;
+ else if (arrsize < 8.)
+ arrsize = 8.;
+ myArrowSize = arrsize;
+ }
+ arr->SetLength(myArrowSize);
+
+ //Calcul de la presentation
+ DsgPrs_Chamf2dPresentation::Add(aPresentation,
+ myDrawer,
+ myPntAttach,
+ curpos,
+ myText,
+ mySymbolPrs);
+
+ }
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+
+void PrsDim_Chamf2dDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer)
+{
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+ Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,myPntAttach,myPosition);
+ aSelection->Add(seg);
+
+ // Text
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
+ myPosition.X(),
+ myPosition.Y(),
+ myPosition.Z(),
+ myPosition.X() + size,
+ myPosition.Y() + size,
+ myPosition.Z() + size);
+ aSelection->Add(box);
+}
+
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Flore Lantheaume/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_Chamf2dDimension_HeaderFile
+#define _PrsDim_Chamf2dDimension_HeaderFile
+
+#include <PrsDim_KindOfDimension.hxx>
+#include <PrsDim_Relation.hxx>
+#include <DsgPrs_ArrowSide.hxx>
+#include <gp_Dir.hxx>
+
+class Geom_Plane;
+
+DEFINE_STANDARD_HANDLE(PrsDim_Chamf2dDimension, PrsDim_Relation)
+
+//! A framework to define display of 2D chamfers.
+//! A chamfer is displayed with arrows and text. The text
+//! gives the length of the chamfer if it is a symmetrical
+//! chamfer, or the angle if it is not.
+class PrsDim_Chamf2dDimension : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_Chamf2dDimension, PrsDim_Relation)
+public:
+
+ //! Constructs the display object for 2D chamfers.
+ //! This object is defined by the face aFShape, the
+ //! dimension aVal, the plane aPlane and the text aText.
+ Standard_EXPORT PrsDim_Chamf2dDimension(const TopoDS_Shape& aFShape, const Handle(Geom_Plane)& aPlane, const Standard_Real aVal, const TCollection_ExtendedString& aText);
+
+ //! Constructs the display object for 2D chamfers.
+ //! This object is defined by the face aFShape, the plane
+ //! aPlane, the dimension aVal, the position aPosition,
+ //! the type of arrow aSymbolPrs with the size
+ //! anArrowSize, and the text aText.
+ Standard_EXPORT PrsDim_Chamf2dDimension(const TopoDS_Shape& aFShape, const Handle(Geom_Plane)& aPlane, const Standard_Real aVal, const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.0);
+
+ //! Indicates that we are concerned with a 2d length.
+ virtual PrsDim_KindOfDimension KindOfDimension() const Standard_OVERRIDE { return PrsDim_KOD_LENGTH; }
+
+ //! Returns true if the 2d chamfer dimension is movable.
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+private:
+
+ gp_Pnt myPntAttach;
+ gp_Dir myDir;
+
+};
+
+#endif // _PrsDim_Chamf2dDimension_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_Chamf3dDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <DsgPrs_Chamf2dPresentation.hxx>
+#include <ElCLib.hxx>
+#include <Geom_Line.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Precision.hxx>
+#include <ProjLib.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopAbs_Orientation.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_Chamf3dDimension, PrsDim_Relation)
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_Chamf3dDimension::PrsDim_Chamf3dDimension(const TopoDS_Shape& aFShape,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText)
+:PrsDim_Relation()
+{
+ myFShape = aFShape;
+ myVal = aVal;
+ myText = aText;
+ mySymbolPrs = DsgPrs_AS_LASTAR;
+ myAutomaticPosition = Standard_True;
+
+ myArrowSize = myVal / 100.;
+}
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_Chamf3dDimension::PrsDim_Chamf3dDimension(const TopoDS_Shape& aFShape,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText,
+ const gp_Pnt& aPosition,
+ const DsgPrs_ArrowSide aSymbolPrs ,
+ const Standard_Real anArrowSize)
+:PrsDim_Relation()
+{
+ myFShape = aFShape;
+ myVal = aVal;
+ myText = aText;
+ myPosition = aPosition;
+ mySymbolPrs = aSymbolPrs;
+ SetArrowSize( anArrowSize );
+ myAutomaticPosition = Standard_False;
+}
+
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+void PrsDim_Chamf3dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer)
+{
+ //----------------------------
+ // Calcul du centre de la face
+ //----------------------------
+ BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
+ Standard_Real uFirst, uLast, vFirst, vLast;
+ uFirst = surfAlgo.FirstUParameter();
+ uLast = surfAlgo.LastUParameter();
+ vFirst = surfAlgo.FirstVParameter();
+ vLast = surfAlgo.LastVParameter();
+ Standard_Real uMoy = (uFirst + uLast)/2;
+ Standard_Real vMoy = (vFirst + vLast)/2;
+ gp_Pnt apos ;
+ gp_Vec d1u, d1v;
+ surfAlgo.D1(uMoy, vMoy, apos, d1u, d1v);
+ myPntAttach = apos;
+
+ myDir = d1u ^ d1v;
+// myDir = surfAlgo.Plane().Axis().Direction();
+
+
+
+
+ //--------------------------------------------
+ //Calcul du point de positionnement du texte
+ //--------------------------------------------
+ gp_Pnt curpos;
+ if (myAutomaticPosition) {
+ gp_Vec transVec(myDir);
+ transVec*=myVal;
+ curpos = myPntAttach.Translated(transVec);
+
+ if (myIsSetBndBox)
+ curpos = PrsDim::TranslatePointToBound( curpos, myDir, myBndBox );
+
+ myPosition = curpos;
+ }
+ else {
+
+ Handle(Geom_Line) dimLin = new Geom_Line(myPntAttach, myDir);
+ Standard_Real parcurpos = ElCLib::Parameter(dimLin->Lin(),myPosition);
+ curpos = ElCLib::Value(parcurpos,dimLin->Lin());
+
+ if ( curpos.Distance(myPntAttach) < 5. ) {
+ gp_Vec transVec(myDir);
+ transVec*=5.;
+ curpos = myPntAttach.Translated(transVec);
+ }
+ myPosition = curpos;
+ }
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+
+ //-------------------------------------------------
+ //Calcul de la boite englobante du component pour
+ //determiner la taille de la fleche
+ //-------------------------------------------------
+ if( !myArrowSizeIsDefined ) {
+ Standard_Real arrsize = myArrowSize;
+ if ( (myVal/4) < arrsize)
+ arrsize = myVal/4;
+ if (arrsize > 30.)
+ arrsize = 30.;
+ else if (arrsize < 8.)
+ arrsize = 8.;
+ myArrowSize = arrsize;
+ }
+ arr->SetLength(myArrowSize);
+
+ //Calcul de la presentation
+ DsgPrs_Chamf2dPresentation::Add(aPresentation,
+ myDrawer,
+ myPntAttach,
+ curpos,
+ myText,
+ mySymbolPrs);
+
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+
+void PrsDim_Chamf3dDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer)
+{
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+ Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,myPntAttach,myPosition);
+ aSelection->Add(seg);
+
+ // Text
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
+ myPosition.X(),
+ myPosition.Y(),
+ myPosition.Z(),
+ myPosition.X() + size,
+ myPosition.Y() + size,
+ myPosition.Z() + size);
+ aSelection->Add(box);
+}
+
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_Chamf3dDimension_HeaderFile
+#define _PrsDim_Chamf3dDimension_HeaderFile
+
+#include <PrsDim_KindOfDimension.hxx>
+#include <PrsDim_Relation.hxx>
+#include <DsgPrs_ArrowSide.hxx>
+#include <gp_Dir.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_Chamf3dDimension, PrsDim_Relation)
+
+//! A framework to define display of 3D chamfers.
+//! A chamfer is displayed with arrows and text. The text
+//! gives the length of the chamfer if it is a symmetrical
+//! chamfer, or the angle if it is not.
+class PrsDim_Chamf3dDimension : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_Chamf3dDimension, PrsDim_Relation)
+public:
+
+ //! Constructs a display object for 3D chamfers.
+ //! This object is defined by the shape aFShape, the
+ //! dimension aVal and the text aText.
+ Standard_EXPORT PrsDim_Chamf3dDimension(const TopoDS_Shape& aFShape, const Standard_Real aVal, const TCollection_ExtendedString& aText);
+
+ //! Constructs a display object for 3D chamfers.
+ //! This object is defined by the shape aFShape, the
+ //! dimension aVal, the text aText, the point of origin of
+ //! the chamfer aPosition, the type of arrow aSymbolPrs
+ //! with the size anArrowSize.
+ Standard_EXPORT PrsDim_Chamf3dDimension(const TopoDS_Shape& aFShape, const Standard_Real aVal, const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.0);
+
+ //! Indicates that we are concerned with a 3d length.
+ virtual PrsDim_KindOfDimension KindOfDimension() const Standard_OVERRIDE { return PrsDim_KOD_LENGTH; }
+
+ //! Returns true if the 3d chamfer dimension is movable.
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+private:
+
+ gp_Pnt myPntAttach;
+ gp_Dir myDir;
+
+};
+
+#endif // _PrsDim_Chamf3dDimension_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Flore Lantheaume/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_ConcentricRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <DsgPrs_ConcentricPresentation.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Plane.hxx>
+#include <GeomAbs_CurveType.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveCircle.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_ConcentricRelation, PrsDim_Relation)
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_ConcentricRelation::PrsDim_ConcentricRelation(
+ const TopoDS_Shape& aFShape,
+ const TopoDS_Shape& aSShape,
+ const Handle(Geom_Plane)& aPlane)
+{
+ myFShape = aFShape;
+ mySShape = aSShape;
+ myPlane = aPlane;
+ myDir = aPlane->Pln().Axis().Direction();
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_ConcentricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer)
+{
+ TopAbs_ShapeEnum type2(mySShape.ShapeType());
+ aPresentation->SetInfiniteState(Standard_True);
+ switch (myFShape.ShapeType()) {
+ case TopAbs_EDGE:
+ {
+ if (type2 == TopAbs_EDGE) ComputeTwoEdgesConcentric(aPresentation);
+ else if (type2 == TopAbs_VERTEX) ComputeEdgeVertexConcentric(aPresentation);
+ }
+ break;
+
+ case TopAbs_VERTEX:
+ {
+ if (type2 == TopAbs_VERTEX) ComputeTwoVerticesConcentric(aPresentation);
+ else if (type2 == TopAbs_EDGE) ComputeEdgeVertexConcentric(aPresentation);
+ }
+ break;
+ default: {return;}
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoEdgesConcentric
+//purpose :
+//=======================================================================
+void PrsDim_ConcentricRelation::ComputeEdgeVertexConcentric(const Handle(Prs3d_Presentation)& aPresentation)
+{
+ TopoDS_Edge E;
+ TopoDS_Vertex V;
+ if (myFShape.ShapeType() == TopAbs_EDGE) {
+ E = TopoDS::Edge(myFShape);
+ V = TopoDS::Vertex(mySShape);
+ }
+ else {
+ E = TopoDS::Edge(mySShape);
+ V = TopoDS::Vertex(myFShape);
+ }
+ gp_Pnt p1,p2;
+ Handle(Geom_Curve) C;
+ Handle(Geom_Curve) extCurv;
+ Standard_Boolean isInfinite;
+ Standard_Boolean isOnPlanEdge, isOnPlanVertex;
+ if (!PrsDim::ComputeGeometry(E,C,p1,p2,extCurv,isInfinite,isOnPlanEdge,myPlane)) return;
+ gp_Pnt P;
+ PrsDim::ComputeGeometry(V,P, myPlane, isOnPlanVertex);
+
+ Handle(Geom_Circle) CIRCLE (Handle(Geom_Circle)::DownCast (C));
+ myCenter = CIRCLE->Location();
+ myRad = Min(CIRCLE->Radius()/5.,15.);
+ gp_Dir vec(p1.XYZ() - myCenter.XYZ() );
+ gp_Vec vectrans(vec);
+ myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
+ DsgPrs_ConcentricPresentation::Add(aPresentation,myDrawer,myCenter,myRad,myDir,myPnt);
+ if (!isOnPlanEdge) PrsDim::ComputeProjEdgePresentation(aPresentation,myDrawer,E,CIRCLE,p1,p2);
+ if (!isOnPlanVertex) PrsDim::ComputeProjVertexPresentation(aPresentation,myDrawer,V,P);
+}
+
+//=======================================================================
+//function : ComputeTwoEdgesConcentric
+//purpose :
+//=======================================================================
+void PrsDim_ConcentricRelation::ComputeTwoVerticesConcentric(const Handle(Prs3d_Presentation)& aPresentation)
+{
+ TopoDS_Vertex V1,V2;
+ V1 = TopoDS::Vertex(myFShape);
+ V2 = TopoDS::Vertex(myFShape);
+ Standard_Boolean isOnPlanVertex1(Standard_True),isOnPlanVertex2(Standard_True);
+ gp_Pnt P1,P2;
+ PrsDim::ComputeGeometry(V1,P1, myPlane,isOnPlanVertex1);
+ PrsDim::ComputeGeometry(V2,P2, myPlane,isOnPlanVertex2);
+ myCenter = P1;
+ myRad = 15.;
+ gp_Dir vec(myPlane->Pln().Position().XDirection());
+ gp_Vec vectrans(vec);
+ myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
+ DsgPrs_ConcentricPresentation::Add(aPresentation,myDrawer,myCenter,myRad,myDir,myPnt);
+ if (!isOnPlanVertex1) PrsDim::ComputeProjVertexPresentation(aPresentation,myDrawer,V1,P1);
+ if (!isOnPlanVertex2) PrsDim::ComputeProjVertexPresentation(aPresentation,myDrawer,V2,P2);
+}
+
+//=======================================================================
+//function : ComputeTwoEdgesConcentric
+//purpose :
+//=======================================================================
+void PrsDim_ConcentricRelation::ComputeTwoEdgesConcentric(const Handle(Prs3d_Presentation)& aPresentation)
+{
+ BRepAdaptor_Curve curv1(TopoDS::Edge(myFShape));
+ BRepAdaptor_Curve curv2(TopoDS::Edge(mySShape));
+
+ gp_Pnt ptat11,ptat12,ptat21,ptat22;
+ Handle(Geom_Curve) geom1,geom2;
+ Standard_Boolean isInfinite1,isInfinite2;
+ Handle(Geom_Curve) extCurv;
+ if (!PrsDim::ComputeGeometry(TopoDS::Edge(myFShape), TopoDS::Edge(mySShape),
+ myExtShape,
+ geom1, geom2,
+ ptat11, ptat12,
+ ptat21, ptat22,
+ extCurv,
+ isInfinite1,isInfinite2,
+ myPlane)) {
+ return;
+ }
+
+ Handle(Geom_Circle) gcirc1 (Handle(Geom_Circle)::DownCast (geom1));
+ Handle(Geom_Circle) gcirc2 (Handle(Geom_Circle)::DownCast (geom2));
+
+ myCenter = gcirc1->Location();
+
+ // choose the radius equal to 1/5 of the smallest radius of
+ // 2 circles. Limit is imposed ( 0.02 by chance)
+ Standard_Real aRad1 = gcirc1->Radius();
+ Standard_Real aRad2 = gcirc2->Radius();
+ myRad = (aRad1 > aRad2 ) ? aRad2 : aRad1;
+ myRad /= 5;
+ if (myRad > 15.) myRad =15.;
+
+
+ //Calculate a point of circle of radius myRad
+ gp_Dir vec(ptat11.XYZ() - myCenter.XYZ() );
+ gp_Vec vectrans(vec);
+ myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
+
+ DsgPrs_ConcentricPresentation::Add(aPresentation,
+ myDrawer,
+ myCenter,
+ myRad,
+ myDir,
+ myPnt);
+ if ( (myExtShape != 0) && !extCurv.IsNull()) {
+ gp_Pnt pf, pl;
+ if ( myExtShape == 1 ) {
+ if (!isInfinite1) {
+ pf = ptat11;
+ pl = ptat12;
+ }
+ ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(myFShape),gcirc1,pf,pl);
+ }
+ else {
+ if (!isInfinite2) {
+ pf = ptat21;
+ pl = ptat22;
+ }
+ ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(mySShape),gcirc2,pf,pl);
+ }
+ }
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+
+void PrsDim_ConcentricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer)
+{
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+
+ //Creation of 2 sensitive circles
+ // the greater
+ gp_Ax2 ax(myCenter, myDir);
+ Handle(Geom_Circle) Circ = new Geom_Circle(ax, myRad) ;
+ Handle(Select3D_SensitiveCircle)
+ sensit = new Select3D_SensitiveCircle (own,
+ Circ);
+ aSelection->Add(sensit);
+ // the smaller
+ Circ->SetRadius(myRad/2);
+ sensit = new Select3D_SensitiveCircle (own,
+ Circ);
+ aSelection->Add(sensit);
+
+ //Creation of 2 segments sensitive for the cross
+ Handle(Select3D_SensitiveSegment) seg;
+ gp_Pnt otherPnt = myPnt.Mirrored(myCenter);
+ seg = new Select3D_SensitiveSegment(own,
+ otherPnt,
+ myPnt);
+ aSelection->Add(seg);
+
+ gp_Ax1 RotateAxis(myCenter, myDir);
+ gp_Pnt FPnt = myCenter.Rotated(RotateAxis, M_PI/2);
+ gp_Pnt SPnt = myCenter.Rotated(RotateAxis, -M_PI/2);
+ seg = new Select3D_SensitiveSegment(own,
+ FPnt,
+ SPnt);
+ aSelection->Add(seg);
+
+}
+
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Flore Lantheaume/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_ConcentricRelation_HeaderFile
+#define _PrsDim_ConcentricRelation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+#include <gp_Dir.hxx>
+
+class Geom_Plane;
+
+DEFINE_STANDARD_HANDLE(PrsDim_ConcentricRelation, PrsDim_Relation)
+
+//! A framework to define a constraint by a relation of
+//! concentricity between two or more interactive datums.
+//! The display of this constraint is also defined.
+//! A plane is used to create an axis along which the
+//! relation of concentricity can be extended.
+class PrsDim_ConcentricRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_ConcentricRelation, PrsDim_Relation)
+public:
+
+ //! Constructs the display object for concentric relations
+ //! between shapes.
+ //! This object is defined by the two shapes, aFShape
+ //! and aSShape and the plane aPlane.
+ //! aPlane is provided to create an axis along which the
+ //! relation of concentricity can be extended.
+ Standard_EXPORT PrsDim_ConcentricRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane);
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeTwoEdgesConcentric (const Handle(Prs3d_Presentation)& aPresentationManager);
+
+ Standard_EXPORT void ComputeEdgeVertexConcentric (const Handle(Prs3d_Presentation)& aPresentationManager);
+
+ Standard_EXPORT void ComputeTwoVerticesConcentric (const Handle(Prs3d_Presentation)& aPresentationManager);
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+private:
+
+ gp_Pnt myCenter;
+ Standard_Real myRad;
+ gp_Dir myDir;
+ gp_Pnt myPnt;
+
+};
+
+#endif // _PrsDim_ConcentricRelation_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Jacques MINOT/Odile Olivier/Sergey ZARITCHNY
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_DiameterDimension.hxx>
+
+#include <PrsDim.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_RTTIEXT(PrsDim_DiameterDimension, PrsDim_Dimension)
+
+namespace
+{
+ static const Standard_ExtCharacter THE_DIAMETER_SYMBOL (0x00D8);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_DiameterDimension::PrsDim_DiameterDimension (const gp_Circ& theCircle)
+: PrsDim_Dimension (PrsDim_KOD_DIAMETER)
+{
+ SetMeasuredGeometry (theCircle);
+ SetSpecialSymbol (THE_DIAMETER_SYMBOL);
+ SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_Before);
+ SetFlyout (0.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_DiameterDimension::PrsDim_DiameterDimension (const gp_Circ& theCircle,
+ const gp_Pln& thePlane)
+: PrsDim_Dimension (PrsDim_KOD_DIAMETER)
+{
+ SetCustomPlane (thePlane);
+ SetMeasuredGeometry (theCircle);
+ SetSpecialSymbol (THE_DIAMETER_SYMBOL);
+ SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_Before);
+ SetFlyout (0.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_DiameterDimension::PrsDim_DiameterDimension (const TopoDS_Shape& theShape)
+: PrsDim_Dimension (PrsDim_KOD_DIAMETER)
+{
+ SetMeasuredGeometry (theShape);
+ SetSpecialSymbol (THE_DIAMETER_SYMBOL);
+ SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_Before);
+ SetFlyout (0.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_DiameterDimension::PrsDim_DiameterDimension (const TopoDS_Shape& theShape,
+ const gp_Pln& thePlane)
+: PrsDim_Dimension (PrsDim_KOD_DIAMETER)
+{
+ SetCustomPlane (thePlane);
+ SetMeasuredGeometry (theShape);
+ SetSpecialSymbol (THE_DIAMETER_SYMBOL);
+ SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_Before);
+ SetFlyout (0.0);
+}
+
+//=======================================================================
+//function : AnchorPoint
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim_DiameterDimension::AnchorPoint()
+{
+ if (!IsValid())
+ {
+ return gp::Origin();
+ }
+
+ return myAnchorPoint;
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_DiameterDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
+{
+ myCircle = theCircle;
+ myGeometryType = GeometryType_Edge;
+ myShape = BRepLib_MakeEdge (theCircle);
+ myAnchorPoint = gp::Origin();
+ myIsGeometryValid = IsValidCircle (myCircle);
+
+ if (myIsGeometryValid && myIsPlaneCustom)
+ {
+ ComputeAnchorPoint();
+ }
+ else if (!myIsPlaneCustom)
+ {
+ ComputePlane();
+ myAnchorPoint = ElCLib::Value (0.0, myCircle);
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_DiameterDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape)
+{
+ gp_Pnt aDummyPnt (gp::Origin());
+ Standard_Boolean isClosed = Standard_False;
+
+ myGeometryType = GeometryType_UndefShapes;
+ myShape = theShape;
+ myAnchorPoint = gp::Origin();
+ myIsGeometryValid = InitCircularDimension (theShape, myCircle, aDummyPnt, isClosed)
+ && IsValidCircle (myCircle)
+ && isClosed;
+
+ if (myIsGeometryValid && myIsPlaneCustom)
+ {
+ ComputeAnchorPoint();
+ }
+ else if (!myIsPlaneCustom)
+ {
+ ComputePlane();
+ myAnchorPoint = ElCLib::Value (0.0, myCircle);
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : CheckPlane
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_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 PrsDim_DiameterDimension::ComputePlane()
+{
+ if (!myIsGeometryValid)
+ {
+ return;
+ }
+
+ myPlane = gp_Pln (gp_Ax3 (myCircle.Position()));
+}
+
+//=======================================================================
+//function : ComputeAnchorPoint
+//purpose :
+//=======================================================================
+void PrsDim_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())
+ {
+ myIsGeometryValid = Standard_False;
+ return;
+ }
+
+ // The circle lays on the plane.
+ if (anIntersector.NbPoints() != 2)
+ {
+ myAnchorPoint = ElCLib::Value (0.0, myCircle);
+ myIsGeometryValid = 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& PrsDim_DiameterDimension::GetModelUnits() const
+{
+ return myDrawer->DimLengthModelUnits();
+}
+
+//=======================================================================
+//function : GetDisplayUnits
+//purpose :
+//=======================================================================
+const TCollection_AsciiString& PrsDim_DiameterDimension::GetDisplayUnits() const
+{
+ return myDrawer->DimLengthDisplayUnits();
+}
+
+//=======================================================================
+//function : SetModelUnits
+//purpose :
+//=======================================================================
+void PrsDim_DiameterDimension::SetModelUnits (const TCollection_AsciiString& theUnits)
+{
+ myDrawer->SetDimLengthModelUnits (theUnits);
+}
+
+//=======================================================================
+//function : SetDisplayUnits
+//purpose :
+//=======================================================================
+void PrsDim_DiameterDimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
+{
+ myDrawer->SetDimLengthDisplayUnits (theUnits);
+}
+
+//=======================================================================
+//function : ComputeValue
+//purpose :
+//=======================================================================
+Standard_Real PrsDim_DiameterDimension::ComputeValue() const
+{
+ if (!IsValid())
+ {
+ return 0.0;
+ }
+
+ return myCircle.Radius() * 2.0;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode)
+{
+ mySelectionGeom.Clear (theMode);
+
+ if (!IsValid())
+ {
+ return;
+ }
+
+ gp_Pnt aFirstPnt (gp::Origin());
+ gp_Pnt aSecondPnt (gp::Origin());
+ ComputeSidePoints (myCircle, aFirstPnt, aSecondPnt);
+
+ DrawLinearDimension (thePresentation, theMode, aFirstPnt, aSecondPnt);
+}
+
+//=======================================================================
+//function : ComputeFlyoutSelection
+//purpose :
+//=======================================================================
+void PrsDim_DiameterDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
+ const Handle(SelectMgr_EntityOwner)& theEntityOwner)
+{
+ if (!IsValid())
+ {
+ return;
+ }
+
+ gp_Pnt aFirstPnt (gp::Origin());
+ gp_Pnt aSecondPnt (gp::Origin());
+ ComputeSidePoints (myCircle, aFirstPnt, aSecondPnt);
+
+ ComputeLinearFlyouts (theSelection, theEntityOwner, aFirstPnt, aSecondPnt);
+}
+
+//=======================================================================
+//function : ComputeSidePoints
+//purpose :
+//=======================================================================
+void PrsDim_DiameterDimension::ComputeSidePoints (const gp_Circ& theCircle,
+ gp_Pnt& theFirstPnt,
+ gp_Pnt& theSecondPnt)
+{
+ theFirstPnt = AnchorPoint();
+
+ gp_Vec aRadiusVector (theCircle.Location(), theFirstPnt);
+ theSecondPnt = theCircle.Location().Translated (-aRadiusVector);
+}
+
+//=======================================================================
+//function : IsValidCircle
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_DiameterDimension::IsValidCircle (const gp_Circ& theCircle) const
+{
+ return (theCircle.Radius() * 2.0) > Precision::Confusion();
+}
+
+//=======================================================================
+//function : IsValidAnchor
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_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());
+}
+
+//=======================================================================
+//function : GetTextPosition
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim_DiameterDimension::GetTextPosition() const
+{
+ if (IsTextPositionCustom())
+ {
+ return myFixedTextPosition;
+ }
+
+ // Counts text position according to the dimension parameters
+ return GetTextPositionForLinear (myAnchorPoint, myCircle.Location());
+}
+
+//=======================================================================
+//function : GetTextPosition
+//purpose :
+//=======================================================================
+void PrsDim_DiameterDimension::SetTextPosition (const gp_Pnt& theTextPos)
+{
+ if (!IsValid())
+ {
+ return;
+ }
+
+ myIsTextPositionFixed = Standard_True;
+ myFixedTextPosition = theTextPos;
+
+ SetToUpdate();
+}
--- /dev/null
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_DiameterDimension_HeaderFile
+#define _PrsDim_DiameterDimension_HeaderFile
+
+#include <PrsDim_Dimension.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Circ.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Type.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_DiameterDimension, PrsDim_Dimension)
+
+//! 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 PrsDim_DiameterDimension : public PrsDim_Dimension
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_DiameterDimension, PrsDim_Dimension)
+public:
+
+ //! Construct diameter dimension for the circle.
+ //! @param theCircle [in] the circle to measure.
+ Standard_EXPORT PrsDim_DiameterDimension (const gp_Circ& theCircle);
+
+ //! 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 PrsDim_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 PrsDim_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 PrsDim_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 Standard_OVERRIDE;
+
+ //! @return the model units string.
+ Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual gp_Pnt GetTextPosition() const Standard_OVERRIDE;
+
+protected:
+
+ //! 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();
+
+ Standard_EXPORT virtual void ComputePlane();
+
+ //! Checks if the center of the circle is on the plane.
+ Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
+ const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
+
+protected:
+
+ //! Compute points on the circle sides for the 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 theFirstPnt [out] the first point.
+ //! @param theSecondPnt [out] the second point.
+ Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle,
+ 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;
+
+private:
+
+ gp_Circ myCircle;
+ gp_Pnt myAnchorPoint;
+ TopoDS_Shape myShape;
+};
+
+#endif // _PrsDim_DiameterDimension_HeaderFile
--- /dev/null
+// Created on: 2013-11-11
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_Dimension.hxx>
+
+#include <PrsDim.hxx>
+#include <PrsDim_DimensionOwner.hxx>
+#include <Adaptor3d_HCurve.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBndLib.hxx>
+#include <Bnd_Box.hxx>
+#include <ElCLib.hxx>
+#include <Font_BRepFont.hxx>
+#include <Font_BRepTextBuilder.hxx>
+#include <GC_MakeCircle.hxx>
+#include <Geom_Line.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <gce_MakeDir.hxx>
+#include <gce_MakeLin.hxx>
+#include <gce_MakePln.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_Group.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_Text.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SequenceOfOwner.hxx>
+#include <Select3D_SensitiveCircle.hxx>
+#include <Select3D_SensitiveGroup.hxx>
+#include <Select3D_SensitiveCurve.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <Select3D_SensitiveTriangle.hxx>
+#include <Select3D_SensitiveTriangulation.hxx>
+#include <Poly_Array1OfTriangle.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Standard_CString.hxx>
+#include <Standard_ProgramError.hxx>
+#include <StdPrs_ShadedShape.hxx>
+#include <StdPrs_WFShape.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <Units.hxx>
+#include <Units_UnitsDictionary.hxx>
+#include <UnitsAPI.hxx>
+#include <UnitsAPI_SystemUnits.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_Dimension, AIS_InteractiveObject)
+
+namespace
+{
+ // default text strings
+ static const TCollection_ExtendedString THE_EMPTY_LABEL;
+ static const TCollection_AsciiString THE_UNDEFINED_UNITS;
+
+ // default text margin and resolution
+ static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
+ static const unsigned int THE_2D_TEXT_RESOLUTION = 72;
+
+ // default selection priorities
+ static const Standard_Integer THE_NEUTRAL_SEL_PRIORITY = 5;
+ static const Standard_Integer THE_LOCAL_SEL_PRIORITY = 6;
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_Dimension::PrsDim_Dimension (const PrsDim_KindOfDimension theType)
+: AIS_InteractiveObject (),
+ mySelToleranceForText2d(0.0),
+ myValueType (ValueType_Computed),
+ myCustomValue (0.0),
+ myCustomStringValue (),
+ myIsTextPositionFixed (Standard_False),
+ mySpecialSymbol (' '),
+ myDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_No),
+ myGeometryType (GeometryType_UndefShapes),
+ myIsPlaneCustom (Standard_False),
+ myFlyout (0.0),
+ myIsGeometryValid (Standard_False),
+ myKindOfDimension (theType)
+{
+}
+
+//=======================================================================
+//function : SetCustomValue
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::SetCustomValue (const Standard_Real theValue)
+{
+ if (myValueType == ValueType_CustomReal && myCustomValue == theValue)
+ {
+ return;
+ }
+
+ myValueType = ValueType_CustomReal;
+ myCustomValue = theValue;
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetCustomValue
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::SetCustomValue (const TCollection_ExtendedString& theValue)
+{
+ if (myValueType == ValueType_CustomText && myCustomStringValue == theValue)
+ {
+ return;
+ }
+
+ myValueType = ValueType_CustomText;
+ myCustomStringValue = theValue;
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetUserPlane
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::SetCustomPlane (const gp_Pln& thePlane)
+{
+ myPlane = thePlane;
+ myIsPlaneCustom = Standard_True;
+
+ // Disable fixed (custom) text position
+ UnsetFixedTextPosition();
+
+ // Check validity if geometry has been set already.
+ if (IsValid())
+ {
+ SetToUpdate();
+ }
+}
+
+//=======================================================================
+//function : SetDimensionAspect
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect)
+{
+ myDrawer->SetDimensionAspect (theDimensionAspect);
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetDisplaySpecialSymbol
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::SetDisplaySpecialSymbol (const PrsDim_DisplaySpecialSymbol theDisplaySpecSymbol)
+{
+ if (myDisplaySpecialSymbol == theDisplaySpecSymbol)
+ {
+ return;
+ }
+
+ myDisplaySpecialSymbol = theDisplaySpecSymbol;
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetSpecialSymbol
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol)
+{
+ if (mySpecialSymbol == theSpecialSymbol)
+ {
+ return;
+ }
+
+ mySpecialSymbol = theSpecialSymbol;
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetSelToleranceForText2d
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::SetSelToleranceForText2d (const Standard_Real theTol)
+{
+ if (mySelToleranceForText2d == theTol)
+ {
+ return;
+ }
+
+ mySelToleranceForText2d = theTol;
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetFlyout
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::SetFlyout (const Standard_Real theFlyout)
+{
+ if (myFlyout == theFlyout)
+ {
+ return;
+ }
+
+ myFlyout = theFlyout;
+
+ // Disable fixed text position
+ UnsetFixedTextPosition();
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : GetDisplayUnits
+//purpose :
+//=======================================================================
+const TCollection_AsciiString& PrsDim_Dimension::GetDisplayUnits() const
+{
+ return THE_UNDEFINED_UNITS;
+}
+
+//=======================================================================
+//function : GetModelUnits
+//purpose :
+//=======================================================================
+const TCollection_AsciiString& PrsDim_Dimension::GetModelUnits() const
+{
+ return THE_UNDEFINED_UNITS;
+}
+
+//=======================================================================
+//function : ValueToDisplayUnits
+//purpose :
+//=======================================================================
+Standard_Real PrsDim_Dimension::ValueToDisplayUnits() const
+{
+ return UnitsAPI::AnyToAny (GetValue(),
+ GetModelUnits().ToCString(),
+ GetDisplayUnits().ToCString());
+}
+
+//=======================================================================
+//function : GetValueString
+//purpose :
+//=======================================================================
+TCollection_ExtendedString PrsDim_Dimension::GetValueString (Standard_Real& theWidth) const
+{
+ TCollection_ExtendedString aValueStr;
+ if (myValueType == ValueType_CustomText)
+ {
+ aValueStr = myCustomStringValue;
+ }
+ else
+ {
+ // format value string using "sprintf"
+ TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
+
+ char aFmtBuffer[256];
+ sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
+ aValueStr = TCollection_ExtendedString (aFmtBuffer);
+ }
+
+ // add units to values string
+ if (myDrawer->DimensionAspect()->IsUnitsDisplayed())
+ {
+ aValueStr += " ";
+ aValueStr += TCollection_ExtendedString (GetDisplayUnits());
+ }
+
+ switch (myDisplaySpecialSymbol)
+ {
+ case PrsDim_DisplaySpecialSymbol_Before: aValueStr.Insert (1, mySpecialSymbol); break;
+ case PrsDim_DisplaySpecialSymbol_After: aValueStr.Insert (aValueStr.Length() + 1, mySpecialSymbol); break;
+ case PrsDim_DisplaySpecialSymbol_No: break;
+ }
+
+ // Get text style parameters
+ Handle(Prs3d_TextAspect) aTextAspect = myDrawer->DimensionAspect()->TextAspect();
+ NCollection_Utf8String anUTFString (aValueStr.ToExtString());
+
+ theWidth = 0.0;
+
+ if (myDrawer->DimensionAspect()->IsText3d())
+ {
+ // text width produced by BRepFont
+ Font_BRepFont aFont;
+ if (aFont.FindAndInit (aTextAspect->Aspect()->Font(), aTextAspect->Aspect()->GetTextFontAspect(), aTextAspect->Height(), Font_StrictLevel_Any))
+ {
+ for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
+ {
+ Standard_Utf32Char aCurrChar = *anIter;
+ Standard_Utf32Char aNextChar = *(++anIter);
+ theWidth += aFont.AdvanceX (aCurrChar, aNextChar);
+ }
+ }
+ }
+ else
+ {
+ // Text width for 1:1 scale 2D case
+ Font_FTFontParams aFontParams;
+ aFontParams.PointSize = (unsigned int )aTextAspect->Height();
+ aFontParams.Resolution = THE_2D_TEXT_RESOLUTION;
+ if (Handle(Font_FTFont) aFont = Font_FTFont::FindAndCreate (aTextAspect->Aspect()->Font(), aTextAspect->Aspect()->GetTextFontAspect(), aFontParams, Font_StrictLevel_Any))
+ {
+ for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
+ {
+ Standard_Utf32Char aCurrChar = *anIter;
+ Standard_Utf32Char aNextChar = *(++anIter);
+ theWidth += (Standard_Real) aFont->AdvanceX (aCurrChar, aNextChar);
+ }
+ }
+ }
+
+ return aValueStr;
+}
+
+//=======================================================================
+//function : DrawArrow
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::DrawArrow (const Handle(Prs3d_Presentation)& thePresentation,
+ const gp_Pnt& theLocation,
+ const gp_Dir& theDirection)
+{
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
+
+ Standard_Real aLength = myDrawer->DimensionAspect()->ArrowAspect()->Length();
+ Standard_Real anAngle = myDrawer->DimensionAspect()->ArrowAspect()->Angle();
+
+ if (myDrawer->DimensionAspect()->IsArrows3d())
+ {
+ Prs3d_Arrow::Draw (aGroup,
+ theLocation,
+ theDirection,
+ anAngle,
+ aLength);
+ aGroup->SetGroupPrimitivesAspect (myDrawer->DimensionAspect()->ArrowAspect()->Aspect());
+ }
+ else
+ {
+ gp_Pnt aLeftPoint (gp::Origin());
+ gp_Pnt aRightPoint (gp::Origin());
+ const gp_Dir& aPlane = GetPlane().Axis().Direction();
+
+ PointsForArrow (theLocation, theDirection, aPlane, aLength, anAngle, aLeftPoint, aRightPoint);
+
+ Handle(Graphic3d_ArrayOfTriangles) anArrow = new Graphic3d_ArrayOfTriangles(3);
+
+ anArrow->AddVertex (aLeftPoint);
+ anArrow->AddVertex (theLocation);
+ anArrow->AddVertex (aRightPoint);
+
+ // Set aspect for arrow triangles
+ Graphic3d_PolygonOffset aPolOffset;
+ aPolOffset.Mode = Aspect_POM_Off;
+ aPolOffset.Factor = 0.0f;
+ aPolOffset.Units = 0.0f;
+ Handle(Graphic3d_AspectFillArea3d) aShadingStyle = new Graphic3d_AspectFillArea3d();
+ aShadingStyle->SetInteriorStyle (Aspect_IS_SOLID);
+ aShadingStyle->SetColor (myDrawer->DimensionAspect()->ArrowAspect()->Aspect()->Color());
+ aShadingStyle->SetShadingModel (Graphic3d_TOSM_UNLIT);
+ aShadingStyle->SetPolygonOffset (aPolOffset);
+
+ aGroup->SetPrimitivesAspect (aShadingStyle);
+ aGroup->AddPrimitiveArray (anArrow);
+ }
+
+ SelectionGeometry::Arrow& aSensitiveArrow = mySelectionGeom.NewArrow();
+ aSensitiveArrow.Position = theLocation;
+ aSensitiveArrow.Direction = theDirection;
+}
+
+//=======================================================================
+//function : drawText
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation,
+ const gp_Pnt& theTextPos,
+ const gp_Dir& theTextDir,
+ const TCollection_ExtendedString& theText,
+ const Standard_Integer theLabelPosition)
+{
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ if (myDrawer->DimensionAspect()->IsText3d())
+ {
+ // getting font parameters
+ Handle(Prs3d_TextAspect) aTextAspect = myDrawer->DimensionAspect()->TextAspect();
+ Quantity_Color aColor = aTextAspect->Aspect()->Color();
+ Font_FontAspect aFontAspect = aTextAspect->Aspect()->GetTextFontAspect();
+ Standard_Real aFontHeight = aTextAspect->Height();
+
+ // creating TopoDS_Shape for text
+ Font_BRepFont aFont (aTextAspect->Aspect()->Font().ToCString(),
+ aFontAspect, aFontHeight);
+ NCollection_Utf8String anUTFString (theText.ToExtString());
+
+ Font_BRepTextBuilder aBuilder;
+ TopoDS_Shape aTextShape = aBuilder.Perform (aFont, anUTFString);
+
+ // compute text width with kerning
+ Standard_Real aTextWidth = 0.0;
+ Standard_Real aTextHeight = aFont.Ascender() + aFont.Descender();
+
+ for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
+ {
+ Standard_Utf32Char aCurrChar = *anIter;
+ Standard_Utf32Char aNextChar = *(++anIter);
+ aTextWidth += aFont.AdvanceX (aCurrChar, aNextChar);
+ }
+
+ // formating text position in XOY plane
+ Standard_Integer aHLabelPos = theLabelPosition & LabelPosition_HMask;
+ Standard_Integer aVLabelPos = theLabelPosition & LabelPosition_VMask;
+
+ gp_Dir aTextDir (aHLabelPos == LabelPosition_Left ? -theTextDir : theTextDir);
+
+ // compute label offsets
+ Standard_Real aMarginSize = aFontHeight * THE_3D_TEXT_MARGIN;
+ Standard_Real aCenterHOffset = 0.0;
+ Standard_Real aCenterVOffset = 0.0;
+ switch (aHLabelPos)
+ {
+ case LabelPosition_HCenter : aCenterHOffset = 0.0; break;
+ case LabelPosition_Right : aCenterHOffset = aTextWidth / 2.0 + aMarginSize; break;
+ case LabelPosition_Left : aCenterHOffset = -aTextWidth / 2.0 - aMarginSize; break;
+ }
+ switch (aVLabelPos)
+ {
+ case LabelPosition_VCenter : aCenterVOffset = 0.0; break;
+ case LabelPosition_Above : aCenterVOffset = aTextHeight / 2.0 + aMarginSize; break;
+ case LabelPosition_Below : aCenterVOffset = -aTextHeight / 2.0 - aMarginSize; break;
+ }
+
+ // compute shape offset transformation
+ Standard_Real aShapeHOffset = aCenterHOffset - aTextWidth / 2.0;
+ Standard_Real aShapeVOffset = aCenterVOffset - aTextHeight / 2.0;
+
+ // center shape in its bounding box (suppress border spacing added by FT_Font)
+ Bnd_Box aShapeBnd;
+ BRepBndLib::AddClose (aTextShape, aShapeBnd);
+
+ Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+ aShapeBnd.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+
+ Standard_Real aXalign = aTextWidth * 0.5 - (aXmax + aXmin) * 0.5;
+ Standard_Real aYalign = aTextHeight * 0.5 - (aYmax + aYmin) * 0.5;
+ aShapeHOffset += aXalign;
+ aShapeVOffset += aYalign;
+
+ gp_Trsf anOffsetTrsf;
+ anOffsetTrsf.SetTranslation (gp::Origin(), gp_Pnt (aShapeHOffset, aShapeVOffset, 0.0));
+ aTextShape.Move (anOffsetTrsf);
+
+ // transform text to myWorkingPlane coordinate system
+ gp_Ax3 aTextCoordSystem (theTextPos, GetPlane().Axis().Direction(), aTextDir);
+ gp_Trsf aTextPlaneTrsf;
+ aTextPlaneTrsf.SetTransformation (aTextCoordSystem, gp_Ax3 (gp::XOY()));
+ aTextShape.Move (aTextPlaneTrsf);
+
+ // set text flipping anchors
+ gp_Trsf aCenterOffsetTrsf;
+ gp_Pnt aCenterOffset (aCenterHOffset, aCenterVOffset, 0.0);
+ aCenterOffsetTrsf.SetTranslation (gp::Origin(), aCenterOffset);
+
+ gp_Pnt aCenterOfLabel (gp::Origin());
+ aCenterOfLabel.Transform (aCenterOffsetTrsf);
+ aCenterOfLabel.Transform (aTextPlaneTrsf);
+
+ gp_Ax2 aFlippingAxes (aCenterOfLabel, GetPlane().Axis().Direction(), aTextDir);
+ aGroup->SetFlippingOptions (Standard_True, aFlippingAxes);
+
+ // draw text
+ if (myDrawer->DimensionAspect()->IsTextShaded())
+ {
+ // Setting text shading and color parameters
+ if (!myDrawer->HasOwnShadingAspect())
+ {
+ myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+ }
+
+ Graphic3d_MaterialAspect aShadeMat (Graphic3d_NOM_DEFAULT);
+ aShadeMat.SetAmbientColor (Quantity_NOC_BLACK);
+ aShadeMat.SetDiffuseColor (Quantity_NOC_BLACK);
+ aShadeMat.SetSpecularColor(Quantity_NOC_BLACK);
+ myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor);
+ myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor (aColor);
+ myDrawer->ShadingAspect()->SetMaterial (aShadeMat);
+
+ // drawing text
+ StdPrs_ShadedShape::Add (thePresentation, aTextShape, myDrawer);
+ }
+ else
+ {
+ // Setting color for text
+ if (!myDrawer->HasOwnFreeBoundaryAspect())
+ {
+ myDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (aColor, Aspect_TOL_SOLID, 1.0));
+ }
+ myDrawer->FreeBoundaryAspect()->Aspect()->SetColor (aColor);
+
+ // drawing text
+ if (Handle(Graphic3d_ArrayOfPrimitives) anEdges = StdPrs_WFShape::AddAllEdges (aTextShape, myDrawer))
+ {
+ aGroup->SetGroupPrimitivesAspect (myDrawer->FreeBoundaryAspect()->Aspect());
+ aGroup->AddPrimitiveArray (anEdges);
+ }
+ }
+ Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, gp_Ax2());
+
+ mySelectionGeom.TextPos = aCenterOfLabel;
+ mySelectionGeom.TextDir = aTextDir;
+ mySelectionGeom.TextWidth = aTextWidth + aMarginSize * 2.0;
+ mySelectionGeom.TextHeight = aTextHeight;
+
+ return;
+ }
+
+ // generate primitives for 2D text
+ myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION);
+
+ Prs3d_Text::Draw (aGroup,
+ myDrawer->DimensionAspect()->TextAspect(),
+ theText,
+ theTextPos);
+
+ mySelectionGeom.TextPos = theTextPos;
+ mySelectionGeom.TextDir = theTextDir;
+ mySelectionGeom.TextWidth = 0.0;
+ mySelectionGeom.TextHeight = 0.0;
+}
+
+//=======================================================================
+//function : DrawExtension
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::DrawExtension (const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Real theExtensionSize,
+ const gp_Pnt& theExtensionStart,
+ const gp_Dir& theExtensionDir,
+ const TCollection_ExtendedString& theLabelString,
+ const Standard_Real theLabelWidth,
+ const Standard_Integer theMode,
+ const Standard_Integer theLabelPosition)
+{
+ // reference line for extension starting at its connection point
+ gp_Lin anExtensionLine (theExtensionStart, theExtensionDir);
+
+ Standard_Boolean hasLabel = theLabelString.Length() > 0;
+ if (hasLabel && (theMode == ComputeMode_All || theMode == ComputeMode_Text))
+ {
+ // compute text primitives; get its model width
+ gp_Pnt aTextPos = ElCLib::Value (theExtensionSize, anExtensionLine);
+ gp_Dir aTextDir = theExtensionDir;
+
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ drawText (thePresentation,
+ aTextPos,
+ aTextDir,
+ theLabelString,
+ theLabelPosition);
+ }
+
+ if (theMode != ComputeMode_All && theMode != ComputeMode_Line)
+ {
+ return;
+ }
+
+ Standard_Boolean isShortLine = !myDrawer->DimensionAspect()->IsText3d()
+ || theLabelPosition & LabelPosition_VCenter;
+
+ // compute graphical primitives and sensitives for extension line
+ gp_Pnt anExtStart = theExtensionStart;
+ gp_Pnt anExtEnd = !hasLabel || isShortLine
+ ? ElCLib::Value (theExtensionSize, anExtensionLine)
+ : ElCLib::Value (theExtensionSize + theLabelWidth, anExtensionLine);
+
+ // add graphical primitives
+ Handle(Graphic3d_ArrayOfSegments) anExtPrimitive = new Graphic3d_ArrayOfSegments (2);
+ anExtPrimitive->AddVertex (anExtStart);
+ anExtPrimitive->AddVertex (anExtEnd);
+
+ // add selection primitives
+ SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
+ aSensitiveCurve.Append (anExtStart);
+ aSensitiveCurve.Append (anExtEnd);
+
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
+ {
+ aGroup->SetStencilTestOptions (Standard_True);
+ }
+ Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
+ aGroup->SetPrimitivesAspect (aDimensionLineStyle);
+ aGroup->AddPrimitiveArray (anExtPrimitive);
+ if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
+ {
+ aGroup->SetStencilTestOptions (Standard_False);
+ }
+}
+
+//=======================================================================
+//function : DrawLinearDimension
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode,
+ const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const Standard_Boolean theIsOneSide)
+{
+ // do not build any dimension for equal points
+ if (theFirstPoint.IsEqual (theSecondPoint, Precision::Confusion()))
+ {
+ throw Standard_ProgramError("Can not build presentation for equal points.");
+ }
+
+ Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
+
+ // For extensions we need to know arrow size, text size and extension size: get it from aspect
+ Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
+ Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
+ // prepare label string and compute its geometrical width
+ Standard_Real aLabelWidth;
+ TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
+
+ // add margins to cut dimension lines for 3d text
+ if (aDimensionAspect->IsText3d())
+ {
+ aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0;
+ }
+
+ // handle user-defined and automatic arrow placement
+ Standard_Boolean isArrowsExternal = Standard_False;
+ Standard_Integer aLabelPosition = LabelPosition_None;
+
+ Prs3d_DimensionTextHorizontalPosition aHorisontalTextPos = aDimensionAspect->TextHorizontalPosition();
+ if (IsTextPositionCustom())
+ {
+ if (!AdjustParametersForLinear (myFixedTextPosition, theFirstPoint, theSecondPoint,
+ anExtensionSize, aHorisontalTextPos, myFlyout, myPlane, myIsPlaneCustom))
+ {
+ throw Standard_ProgramError("Can not adjust plane to the custom label position.");
+ }
+ }
+
+ FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, aHorisontalTextPos,
+ aLabelPosition, isArrowsExternal);
+
+ // compute dimension line points
+ gp_Pnt aLineBegPoint, aLineEndPoint;
+ ComputeFlyoutLinePoints (theFirstPoint, theSecondPoint, aLineBegPoint, aLineEndPoint);
+ gp_Lin aDimensionLine = gce_MakeLin (aLineBegPoint, aLineEndPoint);
+
+ // compute arrows positions and directions
+ gp_Dir aFirstArrowDir = aDimensionLine.Direction().Reversed();
+ gp_Dir aSecondArrowDir = aDimensionLine.Direction();
+ gp_Dir aFirstExtensionDir = aDimensionLine.Direction().Reversed();
+ gp_Dir aSecondExtensionDir = aDimensionLine.Direction();
+
+ gp_Pnt aFirstArrowBegin (0.0, 0.0, 0.0);
+ gp_Pnt aFirstArrowEnd (0.0, 0.0, 0.0);
+ gp_Pnt aSecondArrowBegin (0.0, 0.0, 0.0);
+ gp_Pnt aSecondArrowEnd (0.0, 0.0, 0.0);
+
+ if (isArrowsExternal)
+ {
+ aFirstArrowDir.Reverse();
+ aSecondArrowDir.Reverse();
+ }
+
+ aFirstArrowBegin = aLineBegPoint;
+ aSecondArrowBegin = aLineEndPoint;
+ aFirstArrowEnd = aLineBegPoint.Translated (-gp_Vec (aFirstArrowDir).Scaled (anArrowLength));
+ aSecondArrowEnd = aLineEndPoint.Translated (-gp_Vec (aSecondArrowDir).Scaled (anArrowLength));
+
+ gp_Pnt aCenterLineBegin = isArrowsExternal
+ ? aLineBegPoint : aFirstArrowEnd;
+
+ gp_Pnt aCenterLineEnd = isArrowsExternal || theIsOneSide
+ ? aLineEndPoint : aSecondArrowEnd;
+
+
+ switch (aLabelPosition & LabelPosition_HMask)
+ {
+ // ------------------------------------------------------------------------ //
+ // CENTER //
+ // -------------------------------------------------------------------------//
+ case LabelPosition_HCenter:
+ {
+ // add label on dimension or extension line to presentation
+ gp_Pnt aTextPos = IsTextPositionCustom() ? myFixedTextPosition
+ : (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5;
+ gp_Dir aTextDir = aDimensionLine.Direction();
+
+ // add text primitives
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
+ {
+ thePresentation->NewGroup();
+ drawText (thePresentation,
+ aTextPos,
+ aTextDir,
+ aLabelString,
+ aLabelPosition);
+ }
+
+ // add dimension line primitives
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
+ {
+ Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
+ && aDimensionAspect->IsText3d();
+
+ Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (isLineBreak ? 4 : 2);
+
+ // compute continuous or sectioned main line segments
+ if (isLineBreak)
+ {
+ Standard_Real aPTextPosition = ElCLib::Parameter (aDimensionLine, aTextPos);
+ gp_Pnt aSection1Beg = aCenterLineBegin;
+ gp_Pnt aSection1End = ElCLib::Value (aPTextPosition - (aLabelWidth * 0.5), aDimensionLine);
+ gp_Pnt aSection2Beg = ElCLib::Value (aPTextPosition + (aLabelWidth * 0.5), aDimensionLine);
+ gp_Pnt aSection2End = aCenterLineEnd;
+
+ aPrimSegments->AddVertex (aSection1Beg);
+ aPrimSegments->AddVertex (aSection1End);
+ aPrimSegments->AddVertex (aSection2Beg);
+ aPrimSegments->AddVertex (aSection2End);
+
+ SelectionGeometry::Curve& aLeftSensitiveCurve = mySelectionGeom.NewCurve();
+ SelectionGeometry::Curve& aRightSensitiveCurve = mySelectionGeom.NewCurve();
+ aLeftSensitiveCurve.Append (aSection1Beg);
+ aLeftSensitiveCurve.Append (aSection1End);
+ aRightSensitiveCurve.Append (aSection2Beg);
+ aRightSensitiveCurve.Append (aSection2End);
+ }
+ else
+ {
+ aPrimSegments->AddVertex (aCenterLineBegin);
+ aPrimSegments->AddVertex (aCenterLineEnd);
+
+ SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
+ aSensitiveCurve.Append (aCenterLineBegin);
+ aSensitiveCurve.Append (aCenterLineEnd);
+ }
+
+ // set text label justification
+ Graphic3d_VerticalTextAlignment aTextJustificaton = Graphic3d_VTA_BOTTOM;
+ switch (aLabelPosition & LabelPosition_VMask)
+ {
+ case LabelPosition_Above :
+ case LabelPosition_VCenter : aTextJustificaton = Graphic3d_VTA_BOTTOM; break;
+ case LabelPosition_Below : aTextJustificaton = Graphic3d_VTA_TOP; break;
+ }
+ aDimensionAspect->TextAspect()->SetVerticalJustification (aTextJustificaton);
+
+ // main dimension line, short extension
+ {
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
+ {
+ aGroup->SetStencilTestOptions (Standard_True);
+ }
+ aGroup->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aPrimSegments);
+ if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
+ {
+ aGroup->SetStencilTestOptions (Standard_False);
+ }
+ }
+
+ // add arrows to presentation
+ {
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
+ if (!theIsOneSide)
+ {
+ DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+ }
+ }
+
+ if (!isArrowsExternal)
+ {
+ break;
+ }
+
+ // add arrow extension lines to presentation
+ {
+ DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
+ aFirstArrowEnd, aFirstExtensionDir,
+ THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ if (!theIsOneSide)
+ {
+ DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
+ aSecondArrowEnd, aSecondExtensionDir,
+ THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ }
+ }
+ }
+ break;
+ }
+ // ------------------------------------------------------------------------ //
+ // LEFT //
+ // -------------------------------------------------------------------------//
+
+ case LabelPosition_Left:
+ {
+ // add label on dimension or extension line to presentation
+ {
+ // Left extension with the text
+ DrawExtension (thePresentation, anExtensionSize,
+ isArrowsExternal
+ ? aFirstArrowEnd
+ : aFirstArrowBegin,
+ aFirstExtensionDir,
+ aLabelString,
+ aLabelWidth,
+ theMode,
+ aLabelPosition);
+ }
+
+ // add dimension line primitives
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
+ {
+ // add central dimension line
+ {
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+
+ // add graphical primitives
+ Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
+ aPrimSegments->AddVertex (aCenterLineBegin);
+ aPrimSegments->AddVertex (aCenterLineEnd);
+
+ aGroup->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aPrimSegments);
+
+ // add selection primitives
+ SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
+ aSensitiveCurve.Append (aCenterLineBegin);
+ aSensitiveCurve.Append (aCenterLineEnd);
+ }
+
+ // add arrows to presentation
+ {
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
+ if (!theIsOneSide)
+ {
+ DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+ }
+ }
+
+ if (!isArrowsExternal || theIsOneSide)
+ {
+ break;
+ }
+
+ // add extension lines for external arrows
+ {
+ DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
+ aSecondArrowEnd, aSecondExtensionDir,
+ THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ }
+ }
+
+ break;
+ }
+ // ------------------------------------------------------------------------ //
+ // RIGHT //
+ // -------------------------------------------------------------------------//
+
+ case LabelPosition_Right:
+ {
+ // add label on dimension or extension line to presentation
+
+ // Right extension with text
+ DrawExtension (thePresentation, anExtensionSize,
+ isArrowsExternal
+ ? aSecondArrowEnd
+ : aSecondArrowBegin,
+ aSecondExtensionDir,
+ aLabelString, aLabelWidth,
+ theMode,
+ aLabelPosition);
+
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
+ {
+ // add central dimension line
+ {
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+
+ // add graphical primitives
+ Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
+ aPrimSegments->AddVertex (aCenterLineBegin);
+ aPrimSegments->AddVertex (aCenterLineEnd);
+ aGroup->SetGroupPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aPrimSegments);
+
+ // add selection primitives
+ SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
+ aSensitiveCurve.Append (aCenterLineBegin);
+ aSensitiveCurve.Append (aCenterLineEnd);
+ }
+
+ // add arrows to presentation
+ {
+ thePresentation->NewGroup();
+ DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+ if (!theIsOneSide)
+ {
+ DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
+ }
+ }
+
+ if (!isArrowsExternal || theIsOneSide)
+ {
+ break;
+ }
+
+ // add extension lines for external arrows
+ {
+ DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
+ aFirstArrowEnd, aFirstExtensionDir,
+ THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ }
+ }
+
+ break;
+ }
+ }
+
+ // add flyout lines to presentation
+ if (theMode == ComputeMode_All)
+ {
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+
+ Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4);
+ aPrimSegments->AddVertex (theFirstPoint);
+ aPrimSegments->AddVertex (aLineBegPoint);
+
+ aPrimSegments->AddVertex (theSecondPoint);
+ aPrimSegments->AddVertex (aLineEndPoint);
+
+ aGroup->SetGroupPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aPrimSegments);
+ }
+
+ mySelectionGeom.IsComputed = Standard_True;
+}
+
+//=======================================================================
+//function : ComputeFlyoutLinePoints
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
+ gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint)
+{
+ // compute dimension line points
+ gp_Ax1 aPlaneNormal = GetPlane().Axis();
+ // compute flyout direction vector
+ gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
+ gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector;
+ // create lines for layouts
+ gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
+ gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
+
+ // Get flyout end points
+ theLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
+ theLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
+}
+
+//=======================================================================
+//function : ComputeLinearFlyouts
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::ComputeLinearFlyouts (const Handle(SelectMgr_Selection)& theSelection,
+ const Handle(SelectMgr_EntityOwner)& theOwner,
+ const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint)
+{
+ // count flyout direction
+ gp_Ax1 aPlaneNormal = GetPlane().Axis();
+ gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
+
+ // count a flyout direction vector.
+ gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector;
+
+ // create lines for layouts
+ gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
+ gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
+
+ // get flyout end points
+ gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
+ gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
+
+ // fill sensitive entity for flyouts
+ Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (theOwner);
+ aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, theFirstPoint, aFlyoutEnd1));
+ aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, theSecondPoint, aFlyoutEnd2));
+ theSelection->Add (aSensitiveEntity);
+}
+
+//=======================================================================
+//function : CircleFromPlanarFace
+//purpose : if possible computes circle from planar face
+//=======================================================================
+Standard_Boolean PrsDim_Dimension::CircleFromPlanarFace (const TopoDS_Face& theFace,
+ Handle(Geom_Curve)& theCurve,
+ gp_Pnt& theFirstPoint,
+ gp_Pnt& theLastPoint)
+{
+ TopExp_Explorer anIt (theFace, TopAbs_EDGE);
+ for ( ; anIt.More(); anIt.Next())
+ {
+ TopoDS_Edge aCurEdge = TopoDS::Edge (anIt.Current());
+ if (PrsDim::ComputeGeometry (aCurEdge, theCurve, theFirstPoint, theLastPoint))
+ {
+ if (theCurve->IsInstance (STANDARD_TYPE(Geom_Circle)))
+ {
+ return Standard_True;
+ }
+ }
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : CircleFromEdge
+//purpose : if possible computes circle from edge
+//=======================================================================
+Standard_Boolean PrsDim_Dimension::CircleFromEdge (const TopoDS_Edge& theEdge,
+ gp_Circ& theCircle,
+ gp_Pnt& theFirstPoint,
+ gp_Pnt& theLastPoint)
+{
+ BRepAdaptor_Curve anAdaptedCurve (theEdge);
+ switch (anAdaptedCurve.GetType())
+ {
+ case GeomAbs_Circle:
+ {
+ theCircle = anAdaptedCurve.Circle();
+ break;
+ }
+ case GeomAbs_Ellipse:
+ {
+ gp_Elips anEll = anAdaptedCurve.Ellipse();
+ if ((anEll.MinorRadius() - anEll.MajorRadius()) >= Precision::Confusion())
+ {
+ return Standard_False;
+ }
+ theCircle = gp_Circ(anEll.Position(),anEll.MinorRadius());
+ break;
+ }
+ case GeomAbs_Line:
+ case GeomAbs_Hyperbola:
+ case GeomAbs_Parabola:
+ case GeomAbs_BezierCurve:
+ case GeomAbs_BSplineCurve:
+ case GeomAbs_OtherCurve:
+ default:
+ return Standard_False;
+ }
+
+ theFirstPoint = anAdaptedCurve.Value (anAdaptedCurve.FirstParameter());
+ theLastPoint = anAdaptedCurve.Value (anAdaptedCurve.LastParameter());
+ return Standard_True;
+}
+
+//=======================================================================
+//function : InitCircularDimension
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_Dimension::InitCircularDimension (const TopoDS_Shape& theShape,
+ gp_Circ& theCircle,
+ gp_Pnt& theMiddleArcPoint,
+ Standard_Boolean& theIsClosed)
+{
+ gp_Pln aPln;
+ Handle(Geom_Surface) aBasisSurf;
+ PrsDim_KindOfSurface aSurfType = PrsDim_KOS_OtherSurface;
+ gp_Pnt aFirstPoint, aLastPoint;
+ Standard_Real anOffset = 0.0;
+ Standard_Real aFirstParam = 0.0;
+ Standard_Real aLastParam = 0.0;
+
+ // Discover circular geometry
+ switch (theShape.ShapeType())
+ {
+ case TopAbs_FACE:
+ {
+ PrsDim::GetPlaneFromFace (TopoDS::Face (theShape), aPln, aBasisSurf, aSurfType, anOffset);
+
+ if (aSurfType == PrsDim_KOS_Plane)
+ {
+ Handle(Geom_Curve) aCurve;
+ if (!CircleFromPlanarFace (TopoDS::Face (theShape), aCurve, aFirstPoint, aLastPoint))
+ {
+ return Standard_False;
+ }
+
+ theCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ();
+ }
+ else
+ {
+ gp_Pnt aCurPos;
+ BRepAdaptor_Surface aSurf1 (TopoDS::Face (theShape));
+ Standard_Real aFirstU = aSurf1.FirstUParameter();
+ Standard_Real aLastU = aSurf1.LastUParameter();
+ Standard_Real aFirstV = aSurf1.FirstVParameter();
+ Standard_Real aLastV = aSurf1.LastVParameter();
+ Standard_Real aMidU = (aFirstU + aLastU) * 0.5;
+ Standard_Real aMidV = (aFirstV + aLastV) * 0.5;
+ aSurf1.D0 (aMidU, aMidV, aCurPos);
+ Handle (Adaptor3d_HCurve) aBasisCurve;
+ Standard_Boolean isExpectedType = Standard_False;
+ if (aSurfType == PrsDim_KOS_Cylinder)
+ {
+ isExpectedType = Standard_True;
+ }
+ else
+ {
+ if (aSurfType == PrsDim_KOS_Revolution)
+ {
+ aBasisCurve = aSurf1.BasisCurve();
+ if (aBasisCurve->GetType() == GeomAbs_Line)
+ {
+ isExpectedType = Standard_True;
+ }
+ }
+ else if (aSurfType == PrsDim_KOS_Extrusion)
+ {
+ aBasisCurve = aSurf1.BasisCurve();
+ if (aBasisCurve->GetType() == GeomAbs_Circle)
+ {
+ isExpectedType = Standard_True;
+ }
+ }
+ }
+
+ if (!isExpectedType)
+ {
+ return Standard_False;
+ }
+
+ Handle(Geom_Curve) aCurve = aBasisSurf->VIso(aMidV);
+ if (aCurve->DynamicType() == STANDARD_TYPE (Geom_Circle))
+ {
+ theCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ();
+ }
+ else if (aCurve->DynamicType() == STANDARD_TYPE (Geom_TrimmedCurve))
+ {
+ Handle(Geom_TrimmedCurve) aTrimmedCurve = Handle(Geom_TrimmedCurve)::DownCast (aCurve);
+ aFirstU = aTrimmedCurve->FirstParameter();
+ aLastU = aTrimmedCurve->LastParameter();
+ if (aTrimmedCurve->BasisCurve()->DynamicType() == STANDARD_TYPE (Geom_Circle))
+ {
+ theCircle = Handle(Geom_Circle)::DownCast(aTrimmedCurve->BasisCurve())->Circ();
+ }
+ }
+ else
+ {
+ // Compute a circle from 3 points on "aCurve"
+ gp_Pnt aP1, aP2;
+ aSurf1.D0 (aFirstU, aMidV, aP1);
+ aSurf1.D0 (aLastU, aMidV, aP2);
+ GC_MakeCircle aMkCirc (aP1, aCurPos, aP2);
+ theCircle = aMkCirc.Value()->Circ();
+ }
+
+ aFirstPoint = ElCLib::Value (aFirstU, theCircle);
+ aLastPoint = ElCLib::Value (aLastU, theCircle);
+ }
+ break;
+ }
+ case TopAbs_WIRE:
+ {
+ TopoDS_Edge anEdge;
+ TopExp_Explorer anIt (theShape, TopAbs_EDGE);
+ if (anIt.More())
+ {
+ anEdge = TopoDS::Edge (anIt.Current());
+ }
+ if (!PrsDim_Dimension::CircleFromEdge (anEdge, theCircle, aFirstPoint, aLastPoint))
+ {
+ return Standard_False;
+ }
+ break;
+ }
+ case TopAbs_EDGE:
+ {
+ TopoDS_Edge anEdge = TopoDS::Edge (theShape);
+ if (!PrsDim_Dimension::CircleFromEdge (anEdge, theCircle, aFirstPoint, aLastPoint))
+ {
+ return Standard_False;
+ }
+ break;
+ }
+ case TopAbs_COMPOUND:
+ case TopAbs_COMPSOLID:
+ case TopAbs_SOLID:
+ case TopAbs_SHELL:
+ case TopAbs_VERTEX:
+ case TopAbs_SHAPE:
+ default:
+ return Standard_False;
+ }
+
+ theIsClosed = aFirstPoint.IsEqual (aLastPoint, Precision::Confusion());
+
+ gp_Pnt aCenter = theCircle.Location();
+
+ if (theIsClosed) // Circle
+ {
+ gp_Dir anXDir = theCircle.XAxis().Direction();
+ theMiddleArcPoint = aCenter.Translated (gp_Vec (anXDir) * theCircle.Radius());
+ }
+ else // Arc
+ {
+ aFirstParam = ElCLib::Parameter (theCircle, aFirstPoint);
+ aLastParam = ElCLib::Parameter (theCircle, aLastPoint);
+ if (aFirstParam > aLastParam)
+ {
+ aFirstParam -= 2.0 * M_PI;
+ }
+
+ Standard_Real aParCurPos = (aFirstParam + aLastParam) * 0.5;
+ gp_Vec aVec = gp_Vec (aCenter, ElCLib::Value (aParCurPos, theCircle)).Normalized () * theCircle.Radius ();
+ theMiddleArcPoint = aCenter.Translated (aVec);
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+ const Standard_Integer theMode)
+{
+ if (!mySelectionGeom.IsComputed)
+ {
+ return;
+ }
+
+ PrsDim_DimensionSelectionMode aSelectionMode = (PrsDim_DimensionSelectionMode)theMode;
+
+ // init appropriate entity owner
+ Handle(SelectMgr_EntityOwner) aSensitiveOwner;
+
+ switch (aSelectionMode)
+ {
+ // neutral selection owner
+ case PrsDim_DimensionSelectionMode_All:
+ aSensitiveOwner = new SelectMgr_EntityOwner (this, THE_NEUTRAL_SEL_PRIORITY);
+ break;
+
+ // local selection owners
+ case PrsDim_DimensionSelectionMode_Line:
+ case PrsDim_DimensionSelectionMode_Text:
+ aSensitiveOwner = new PrsDim_DimensionOwner (this, aSelectionMode, THE_LOCAL_SEL_PRIORITY);
+ break;
+ }
+
+ if (aSelectionMode == PrsDim_DimensionSelectionMode_All || aSelectionMode == PrsDim_DimensionSelectionMode_Line)
+ {
+ // sensitives for dimension line segments
+ Handle(Select3D_SensitiveGroup) aGroupOfSensitives = new Select3D_SensitiveGroup (aSensitiveOwner);
+
+ SelectionGeometry::SeqOfCurves::Iterator aCurveIt (mySelectionGeom.DimensionLine);
+ for (; aCurveIt.More(); aCurveIt.Next())
+ {
+ const SelectionGeometry::HCurve& aCurveData = aCurveIt.Value();
+
+ TColgp_Array1OfPnt aSensitivePnts (1, aCurveData->Length());
+ for (Standard_Integer aPntIt = 1; aPntIt <= aCurveData->Length(); ++aPntIt)
+ {
+ aSensitivePnts.ChangeValue (aPntIt) = aCurveData->Value (aPntIt);
+ }
+
+ aGroupOfSensitives->Add (new Select3D_SensitiveCurve (aSensitiveOwner, aSensitivePnts));
+ }
+
+ Standard_Real anArrowLength = myDrawer->DimensionAspect()->ArrowAspect()->Length();
+ Standard_Real anArrowAngle = myDrawer->DimensionAspect()->ArrowAspect()->Angle();
+
+ // sensitives for arrows
+ SelectionGeometry::SeqOfArrows::Iterator anArrowIt (mySelectionGeom.Arrows);
+ for (; anArrowIt.More(); anArrowIt.Next())
+ {
+ const SelectionGeometry::HArrow& anArrow = anArrowIt.Value();
+
+ gp_Pnt aSidePnt1 (gp::Origin());
+ gp_Pnt aSidePnt2 (gp::Origin());
+ const gp_Dir& aPlane = GetPlane().Axis().Direction();
+ const gp_Pnt& aPeak = anArrow->Position;
+ const gp_Dir& aDir = anArrow->Direction;
+
+ // compute points for arrow in plane
+ PointsForArrow (aPeak, aDir, aPlane, anArrowLength, anArrowAngle, aSidePnt1, aSidePnt2);
+
+ aGroupOfSensitives->Add (new Select3D_SensitiveTriangle (aSensitiveOwner, aPeak, aSidePnt1, aSidePnt2));
+
+ if (!myDrawer->DimensionAspect()->IsArrows3d())
+ {
+ continue;
+ }
+
+ // compute points for orthogonal sensitive plane
+ gp_Dir anOrthoPlane = anArrow->Direction.Crossed (aPlane);
+
+ PointsForArrow (aPeak, aDir, anOrthoPlane, anArrowLength, anArrowAngle, aSidePnt1, aSidePnt2);
+
+ aGroupOfSensitives->Add (new Select3D_SensitiveTriangle (aSensitiveOwner, aPeak, aSidePnt1, aSidePnt2));
+ }
+
+ theSelection->Add (aGroupOfSensitives);
+ }
+
+ // sensitives for text element
+ if (aSelectionMode == PrsDim_DimensionSelectionMode_All || aSelectionMode == PrsDim_DimensionSelectionMode_Text)
+ {
+ Handle(Select3D_SensitiveEntity) aTextSensitive;
+
+ gp_Ax2 aTextAxes (mySelectionGeom.TextPos,
+ GetPlane().Axis().Direction(),
+ mySelectionGeom.TextDir);
+
+ if (myDrawer->DimensionAspect()->IsText3d())
+ {
+ // sensitive planar rectangle for text
+ Standard_Real aDx = mySelectionGeom.TextWidth * 0.5;
+ Standard_Real aDy = mySelectionGeom.TextHeight * 0.5;
+
+ gp_Trsf aLabelPlane;
+ aLabelPlane.SetTransformation (aTextAxes, gp::XOY());
+
+ TColgp_Array1OfPnt aRectanglePoints(1, 4);
+ aRectanglePoints.ChangeValue(1) = gp_Pnt (-aDx, -aDy, 0.0).Transformed (aLabelPlane);
+ aRectanglePoints.ChangeValue(2) = gp_Pnt (-aDx, aDy, 0.0).Transformed (aLabelPlane);
+ aRectanglePoints.ChangeValue(3) = gp_Pnt ( aDx, aDy, 0.0).Transformed (aLabelPlane);
+ aRectanglePoints.ChangeValue(4) = gp_Pnt ( aDx, -aDy, 0.0).Transformed (aLabelPlane);
+
+ Poly_Array1OfTriangle aTriangles(1, 2);
+ aTriangles.ChangeValue(1) = Poly_Triangle(1, 2, 3);
+ aTriangles.ChangeValue(2) = Poly_Triangle(1, 3, 4);
+
+ Handle(Poly_Triangulation) aRectanglePoly =
+ new Poly_Triangulation(aRectanglePoints, aTriangles);
+
+ aTextSensitive =
+ new Select3D_SensitiveTriangulation (aSensitiveOwner, aRectanglePoly, TopLoc_Location(), Standard_True);
+ }
+ else
+ {
+ gp_Circ aTextGeom (aTextAxes, mySelToleranceForText2d != 0.0
+ ? mySelToleranceForText2d : 1.0);
+
+ Handle(Geom_Circle) aSensGeom = new Geom_Circle (aTextGeom);
+
+ aTextSensitive = new Select3D_SensitiveCircle (aSensitiveOwner, aSensGeom, Standard_True);
+ }
+
+ theSelection->Add (aTextSensitive);
+ }
+
+ // callback for flyout sensitive calculation
+ if (aSelectionMode == PrsDim_DimensionSelectionMode_All)
+ {
+ ComputeFlyoutSelection (theSelection, aSensitiveOwner);
+ }
+}
+
+//=======================================================================
+//function : PointsForArrow
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::PointsForArrow (const gp_Pnt& thePeakPnt,
+ const gp_Dir& theDirection,
+ const gp_Dir& thePlane,
+ const Standard_Real theArrowLength,
+ const Standard_Real theArrowAngle,
+ gp_Pnt& theSidePnt1,
+ gp_Pnt& theSidePnt2)
+{
+ gp_Lin anArrowLin (thePeakPnt, theDirection.Reversed());
+ gp_Pnt anArrowEnd = ElCLib::Value (theArrowLength, anArrowLin);
+ gp_Lin anEdgeLin (anArrowEnd, theDirection.Crossed (thePlane));
+
+ Standard_Real anEdgeLength = Tan (theArrowAngle) * theArrowLength;
+
+ theSidePnt1 = ElCLib::Value ( anEdgeLength, anEdgeLin);
+ theSidePnt2 = ElCLib::Value (-anEdgeLength, anEdgeLin);
+}
+
+//=======================================================================
+//function : GetTextPositionForLinear
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim_Dimension::GetTextPositionForLinear (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const Standard_Boolean theIsOneSide) const
+{
+ if (!IsValid())
+ {
+ return gp::Origin();
+ }
+
+ gp_Pnt aTextPosition (gp::Origin());
+
+ Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
+
+ // Get label alignment and arrow orientation.
+ Standard_Integer aLabelPosition = 0;
+ Standard_Boolean isArrowsExternal = Standard_False;
+ FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide,
+ aDimensionAspect->TextHorizontalPosition(),
+ aLabelPosition, isArrowsExternal);
+
+ // Compute dimension line points.
+ gp_Dir aPlaneNormal = GetPlane().Axis().Direction();
+ gp_Vec aTargetPointsVec (theFirstPoint, theSecondPoint);
+
+ // Compute flyout direction vector
+ gp_Dir aFlyoutVector = aPlaneNormal ^ gp_Dir (aTargetPointsVec);
+
+ // create lines for layouts
+ gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
+ gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
+ // Get flyout end points
+ gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
+ gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
+
+ // Get text position.
+ switch (aLabelPosition & LabelPosition_HMask)
+ {
+ case LabelPosition_Left:
+ {
+ gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint);
+ Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
+
+ Standard_Real anOffset = isArrowsExternal
+ ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length()
+ : anExtensionSize;
+ gp_Vec anExtensionVec = gp_Vec (aTargetPointsDir) * -anOffset;
+ aTextPosition = aLineEndPoint.Translated (anExtensionVec);
+ }
+ break;
+ case LabelPosition_Right:
+ {
+ gp_Dir aTargetPointsDir = gce_MakeDir (theFirstPoint, theSecondPoint);
+ Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
+
+ Standard_Real anOffset = isArrowsExternal
+ ? anExtensionSize + aDimensionAspect->ArrowAspect()->Length()
+ : anExtensionSize;
+ gp_Vec anExtensionVec = gp_Vec (aTargetPointsDir) * anOffset;
+ aTextPosition = aLineBegPoint.Translated (anExtensionVec);
+ }
+ break;
+ case LabelPosition_HCenter:
+ {
+ aTextPosition = (aLineBegPoint.XYZ() + aLineEndPoint.XYZ()) * 0.5;
+ }
+ break;
+ }
+
+ return aTextPosition;
+}
+
+//=======================================================================
+//function : AdjustParametersForLinear
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_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();
+
+ 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);
+
+ Standard_Real aCos = aFirstToTextVec.Normalized() * gp_Vec (aTargetPointsDir);
+
+ gp_Pnt aTextPosProj = theFirstPoint.Translated
+ (gp_Vec (aTargetPointsDir) * aFirstToTextVec.Magnitude() * aCos);
+
+ // Compute flyout value and direction.
+ gp_Vec aFlyoutVector = gp_Vec (aTextPosProj, theTextPos);
+
+ 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 horizontal text alignment.
+ if (aCos < 0.0)
+ {
+ theAlignment = Prs3d_DTHP_Left;
+
+ Standard_Real aNewExtSize = theTextPos.Distance (aFirstAttach) - anArrowLength;
+ theExtensionSize = aNewExtSize < 0.0 ? 0.0 : aNewExtSize;
+ }
+ else if (aTextPosProj.Distance (theFirstPoint) > theFirstPoint.Distance (theSecondPoint))
+ {
+ theAlignment = Prs3d_DTHP_Right;
+
+ Standard_Real aNewExtSize = theTextPos.Distance (aSecondAttach) - anArrowLength;
+ theExtensionSize = aNewExtSize < 0.0 ? 0.0 : aNewExtSize;
+ }
+ else
+ {
+ theAlignment = Prs3d_DTHP_Center;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : FitTextAlignmentForLinear
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const Standard_Boolean theIsOneSide,
+ const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
+ Standard_Integer& theLabelPosition,
+ Standard_Boolean& theIsArrowsExternal) const
+{
+ theLabelPosition = LabelPosition_None;
+ theIsArrowsExternal = Standard_False;
+
+ // Compute dimension line points
+ gp_Ax1 aPlaneNormal = GetPlane().Axis();
+ gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
+
+ // compute flyout direction vector
+ gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector;
+
+ // create lines for layouts
+ gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
+ gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
+
+ // Get flyout end points
+ gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
+ gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
+
+ Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
+
+ // For extensions we need to know arrow size, text size and extension size: get it from aspect
+ Standard_Real anArrowLength = aDimensionAspect->ArrowAspect()->Length();
+
+ // prepare label string and compute its geometrical width
+ Standard_Real aLabelWidth;
+ TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
+
+ // Add margins to cut dimension lines for 3d text
+ if (aDimensionAspect->IsText3d())
+ {
+ aLabelWidth += aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN * 2.0;
+ }
+
+ // Handle user-defined and automatic arrow placement
+ switch (aDimensionAspect->ArrowOrientation())
+ {
+ case Prs3d_DAO_External: theIsArrowsExternal = true; break;
+ case Prs3d_DAO_Internal: theIsArrowsExternal = false; break;
+ case Prs3d_DAO_Fit:
+ {
+ // Add margin to ensure a small tail between text and arrow
+ Standard_Real anArrowMargin = aDimensionAspect->IsText3d()
+ ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN
+ : 0.0;
+
+ Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint);
+ Standard_Real anArrowsWidth = theIsOneSide
+ ? anArrowLength + anArrowMargin
+ : (anArrowLength + anArrowMargin) * 2.0;
+
+ theIsArrowsExternal = aDimensionWidth < aLabelWidth + anArrowsWidth;
+ break;
+ }
+ }
+
+ // Handle user-defined and automatic text placement
+ switch (theHorizontalTextPos)
+ {
+ case Prs3d_DTHP_Left : theLabelPosition |= LabelPosition_Left; break;
+ case Prs3d_DTHP_Right : theLabelPosition |= LabelPosition_Right; break;
+ case Prs3d_DTHP_Center: theLabelPosition |= LabelPosition_HCenter; break;
+ case Prs3d_DTHP_Fit:
+ {
+ Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint);
+ Standard_Real anArrowsWidth = theIsOneSide ? anArrowLength : 2.0 * anArrowLength;
+ Standard_Real aContentWidth = theIsArrowsExternal ? aLabelWidth : aLabelWidth + anArrowsWidth;
+
+ theLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter;
+ break;
+ }
+ }
+
+ // Handle vertical text placement options
+ switch (aDimensionAspect->TextVerticalPosition())
+ {
+ case Prs3d_DTVP_Above : theLabelPosition |= LabelPosition_Above; break;
+ case Prs3d_DTVP_Below : theLabelPosition |= LabelPosition_Below; break;
+ case Prs3d_DTVP_Center : theLabelPosition |= LabelPosition_VCenter; break;
+ }
+}
+
+//=======================================================================
+//function : UnsetFixedTextPosition
+//purpose :
+//=======================================================================
+void PrsDim_Dimension::UnsetFixedTextPosition()
+{
+ myIsTextPositionFixed = Standard_False;
+ myFixedTextPosition = gp::Origin();
+}
--- /dev/null
+// Created on: 2013-11-11
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_Dimension_HeaderFile
+#define _PrsDim_Dimension_HeaderFile
+
+#include <PrsDim_DimensionSelectionMode.hxx>
+#include <PrsDim_DimensionOwner.hxx>
+#include <PrsDim_DisplaySpecialSymbol.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_KindOfInteractive.hxx>
+#include <PrsDim_KindOfDimension.hxx>
+#include <PrsDim_KindOfSurface.hxx>
+#include <Geom_Curve.hxx>
+#include <gp_Pln.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_DimensionUnits.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Standard.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColgp_HSequenceOfPnt.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <NCollection_Sequence.hxx>
+#include <NCollection_Handle.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_Dimension, AIS_InteractiveObject)
+
+//! PrsDim_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:
+//! - Attachment (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 attachment points in "up" direction,
+//! and which contains text label on it with value string.
+//! - Flyouts. The lines connecting the attachment 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|
+//! | |
+//! +-----------------------------------+
+//! attachment attachment
+//! 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 highlighting in these selection modes is provided by PrsDim_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.
+//!
+//! Such set of parameters that consists of:
+//! - flyout size and direction,
+//! - user-defined dimension plane,
+//! - horizontal and vertical text alignment
+//! can be uniquely replaced with text position in 3d space. Therefore, there are methods to convert
+//! this set of parameters to the text position and vice versa:
+//!
+//! - If the fixed text position is defined by user, called SetTextPosition (theTextPos) method converts
+//! this 3d point to the set of parameters including adjusting of the dimension plane (this plane will be
+//! automatic plane, NOT user-defined one).
+//! If the fixed text position is set, the flag myIsFixedTextPosition is set to TRUE.
+//! ATTENSION! myIsFixedTextPosition fixes all parameters of the set from recomputing inside
+//! SetMeasureGeometry() methods. Parameters in dimension aspect (they are horizontal text position
+//! and extension size) are adjusted on presentation computing step, user-defined values in
+//! dimension aspect are not changed.
+//! But plane and flyout as dimension position parameters are changed by SetTextPosition() method
+//! according with user-defined text position.
+//! If parameters from the set are changed by user with calls of setters, it leads to disabling of
+//! fixed text position (myIsFixedTextPosition is set to FALSE).
+//! If the fixed text position is set and geometry is changed by user (SetMeasureGeometry() method
+//! is called) and the geometry doesn't satisfy computed dimension plane, the dimension is not valid.
+//!
+//! - If the set of parameters was set by user (may be without the user-defined plane or with it),
+//! it can be converted to the text position by calling the method GetTextPosition(). In this case
+//! the text position is NOT fixed, and SetMeasureGeometry() without user-defined plane adjusts
+//! the automatic plane according input geometry (if it is possible).
+class PrsDim_Dimension : public AIS_InteractiveObject
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_Dimension, AIS_InteractiveObject)
+protected:
+
+ //! Geometry type defines type of shapes on which the dimension is to be built.
+ //! Some type of geometry allows automatic 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,
+
+ LabelPosition_Left = 0x01,
+ LabelPosition_Right = 0x02,
+ LabelPosition_HCenter = 0x04,
+ 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
+ };
+
+ enum ValueType
+ {
+ ValueType_Computed,
+ ValueType_CustomReal,
+ ValueType_CustomText
+ };
+
+public:
+
+ //! Specifies supported presentation compute modes.
+ //! Used to compute only parts of presentation for
+ //! advanced highlighting.
+ enum ComputeMode
+ {
+ ComputeMode_All = 0, //!< "0" is reserved as neutral mode
+ ComputeMode_Line = 1, //!< corresponds to selection mode
+ ComputeMode_Text = 2 //!< corresponds to selection mode
+ };
+
+public:
+
+ //! Constructor with default parameters values.
+ //! @param theType [in] the type of dimension.
+ Standard_EXPORT PrsDim_Dimension (const PrsDim_KindOfDimension theType);
+
+ //! 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 myValueType == ValueType_CustomReal ? myCustomValue : ComputeValue();
+ }
+
+ //! Sets computed dimension value. Resets custom value mode if it was set.
+ void SetComputedValue ()
+ {
+ myValueType = ValueType_Computed;
+ }
+
+ //! 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);
+
+ //! Sets user-defined dimension value.
+ //! Unit conversion during the display is not applyed.
+ //! @param theValue [in] the user-defined value to display.
+ Standard_EXPORT void SetCustomValue (const TCollection_ExtendedString& theValue);
+
+ //! Gets user-defined dimension value.
+ //! @return dimension value string.
+ const TCollection_ExtendedString& GetCustomValue() const { return myCustomStringValue; }
+
+ //! 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 invalid (validity flag is set to false)
+ //! and dimension presentation will 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.
+ const gp_Pln& GetPlane() const { return myPlane; }
+
+ //! 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_Integer GetGeometryType () const { return myGeometryType; }
+
+ //! 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);
+
+ //! Unsets user-defined plane. Therefore the plane for dimension will be
+ //! computed automatically.
+ void UnsetCustomPlane() { myIsPlaneCustom = Standard_False; }
+
+ //! @return TRUE if text position is set by user with method SetTextPosition().
+ Standard_Boolean IsTextPositionCustom() const
+ {
+ return myIsTextPositionFixed;
+ }
+
+ //! Fixes the absolute text position and adjusts flyout, plane and text alignment
+ //! according to it. Updates presentation if the text position is valid.
+ //! ATTENTION! It does not change vertical text alignment.
+ //! @param theTextPos [in] the point of text position.
+ virtual void SetTextPosition (const gp_Pnt& /*theTextPos*/) { }
+
+ //! Computes absolute text position from dimension parameters
+ //! (flyout, plane and text alignment).
+ virtual gp_Pnt GetTextPosition () const { return gp_Pnt(); }
+
+public:
+
+ //! Gets the dimension aspect from AIS object drawer.
+ //! Dimension aspect contains aspects of line, text and arrows for dimension presentation.
+ Handle(Prs3d_DimensionAspect) DimensionAspect() const
+ {
+ return myDrawer->DimensionAspect();
+ }
+
+ //! 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);
+
+ //! @return the kind of dimension.
+ PrsDim_KindOfDimension KindOfDimension() const { return myKindOfDimension; }
+
+ //! @return the kind of interactive.
+ virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Dimension; }
+
+ //! 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.
+ virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
+ {
+ return theMode == ComputeMode_All;
+ }
+
+public:
+
+ //! @return dimension special symbol display options.
+ PrsDim_DisplaySpecialSymbol DisplaySpecialSymbol() const { return myDisplaySpecialSymbol; }
+
+ //! Specifies whether to display special symbol or not.
+ Standard_EXPORT void SetDisplaySpecialSymbol (const PrsDim_DisplaySpecialSymbol theDisplaySpecSymbol);
+
+ //! @return special symbol.
+ Standard_ExtCharacter SpecialSymbol() const
+ {
+ return mySpecialSymbol;
+ }
+
+ //! Specifies special symbol.
+ Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
+
+ Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const;
+
+ Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const;
+
+ virtual void SetDisplayUnits (const TCollection_AsciiString& /*theUnits*/) { }
+
+ virtual void SetModelUnits (const TCollection_AsciiString& /*theUnits*/) { }
+
+ //! Unsets user defined text positioning and enables text positioning
+ //! by other parameters: text alignment, extension size, flyout and custom plane.
+ Standard_EXPORT void UnsetFixedTextPosition();
+
+public:
+
+ //! 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);
+
+ //! @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 successfully computed.
+ //! @return TRUE if dimension geometry is ok.
+ virtual Standard_Boolean IsValid() const
+ {
+ return myIsGeometryValid && CheckPlane (GetPlane());
+ }
+
+protected:
+
+ Standard_EXPORT Standard_Real ValueToDisplayUnits() const;
+
+ //! 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
+ //! @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,
+ const gp_Pnt& theTextPos,
+ const gp_Dir& theTextDir,
+ const TCollection_ExtendedString& theText,
+ const Standard_Integer theLabelPosition);
+
+ //! Performs computing of dimension linear extension with text
+ //! @param thePresentation [in] the presentation to fill with graphical primitives.
+ //! @param theExtensionSize [in] the size of extension line.
+ //! @param theExtensionStart [in] the point where extension line connects to dimension.
+ //! @param theExtensionDir [in] the direction of extension line.
+ //! @param theLabelString [in] the string with value.
+ //! @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,
+ const Standard_Real theExtensionSize,
+ const gp_Pnt& theExtensionStart,
+ const gp_Dir& theExtensionDir,
+ const TCollection_ExtendedString& theLabelString,
+ const Standard_Real theLabelWidth,
+ const Standard_Integer theMode,
+ const Standard_Integer theLabelPosition);
+
+ //! 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 gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const Standard_Boolean theIsOneSide = Standard_False);
+
+ //! Computes points bounded the flyout line for linear dimension.
+ //! @param theFirstPoint [in] the first attach point of linear dimension.
+ //! @param theSecondPoint [in] the second attach point of linear dimension.
+ //! @param theLineBegPoint [out] the first attach point of linear dimension.
+ //! @param theLineEndPoint [out] the second attach point of linear dimension.
+ Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
+ gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint);
+
+ //! 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);
+
+
+ //! 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);
+
+ //! Produce points for triangular arrow face.
+ //! @param thePeakPnt [in] the arrow peak position.
+ //! @param theDirection [in] the arrow direction.
+ //! @param thePlane [in] the face plane.
+ //! @param theArrowLength [in] the length of arrow.
+ //! @param theArrowAngle [in] the angle of arrow.
+ //! @param theSidePnt1 [out] the first side point.
+ //! @param theSidePnt2 [out] the second side point.
+ Standard_EXPORT void PointsForArrow (const gp_Pnt& thePeakPnt,
+ const gp_Dir& theDirection,
+ const gp_Dir& thePlane,
+ const Standard_Real theArrowLength,
+ const Standard_Real theArrowAngle,
+ gp_Pnt& theSidePnt1,
+ gp_Pnt& theSidePnt2);
+
+ //! Compute point of text position for dimension parameters
+ //! for linear kinds of dimensions (length, radius, diameter).
+ Standard_EXPORT gp_Pnt GetTextPositionForLinear (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const Standard_Boolean theIsOneSide = Standard_False) const;
+
+ //! Fits text alignment relatively to the dimension line.
+ //! @param theFirstPoint [in] the first attachment point.
+ //! @param theSecondPoint [in] the second attachment point.
+ //! @param theIsOneSide [in] is the arrow displayed only on the one side of the dimension.
+ //! @param theHorizontalTextPos [in] the text horizontal position (alignment).
+ //! @param theLabelPosition [out] the label position, contains bits that defines
+ //! vertical and horizontal alignment. (for internal usage in count text position)
+ //! @param theIsArrowExternal [out] is the arrows external,
+ //! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow
+ //! orientation automatically.
+ Standard_EXPORT void 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.
+ //! @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.
+ //! @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 Static auxilliary methods for geometry extraction
+
+ //! 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
+ static Standard_Boolean CircleFromPlanarFace (const TopoDS_Face& theFace,
+ Handle(Geom_Curve)& theCurve,
+ gp_Pnt& theFirstPoint,
+ gp_Pnt& theLastPoint);
+
+ //! If it is possible extracts circle from the edge.
+ //! @param theEdge [in] input edge to extract circle from
+ //! @param theCircle [out] circle
+ //! @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.
+ static Standard_Boolean CircleFromEdge (const TopoDS_Edge& theEdge,
+ gp_Circ& theCircle,
+ gp_Pnt& theFirstPoint,
+ gp_Pnt& theLastPoint);
+
+protected: //! @name Behavior to implement
+
+ //! 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)&) {}
+
+
+ //! 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) Standard_OVERRIDE;
+
+protected: //! @name Selection geometry
+
+ //! Selection geometry of dimension presentation. The structure is filled with data
+ //! during compute of presentation, then this data is used to generate selection
+ //! sensitives when computing selection.
+ struct SelectionGeometry
+ {
+ //! Arrows are represented by directed triangles.
+ struct Arrow
+ {
+ gp_Pnt Position;
+ gp_Dir Direction;
+ };
+ typedef NCollection_Sequence<gp_Pnt> Curve;
+ typedef NCollection_Handle<Curve> HCurve;
+ typedef NCollection_Handle<Arrow> HArrow;
+ typedef NCollection_Sequence<HCurve> SeqOfCurves;
+ typedef NCollection_Sequence<HArrow> SeqOfArrows;
+
+ gp_Pnt TextPos; //!< Center of text label.
+ gp_Dir TextDir; //!< Direction of text label.
+ Standard_Real TextWidth; //!< Width of text label.
+ 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:
+
+ //! Clear geometry of sensitives for the specified compute mode.
+ //! @param theMode [in] the compute mode to clear.
+ void Clear (const Standard_Integer theMode)
+ {
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
+ {
+ DimensionLine.Clear();
+ Arrows.Clear();
+ }
+
+ if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
+ {
+ TextPos = gp::Origin();
+ TextDir = gp::DX();
+ TextWidth = 0.0;
+ TextHeight = 0.0;
+ }
+
+ IsComputed = Standard_False;
+ }
+
+ //! Add new curve entry and return the reference to populate it.
+ Curve& NewCurve()
+ {
+ DimensionLine.Append( new Curve );
+ HCurve& aLastCurve = DimensionLine.ChangeLast();
+ return *aLastCurve;
+ }
+
+ //! Add new arrow entry and return the reference to populate it.
+ Arrow& NewArrow()
+ {
+ Arrows.Append( new Arrow );
+ HArrow& aLastArrow = Arrows.ChangeLast();
+ return *aLastArrow;
+ }
+ } mySelectionGeom;
+
+ Standard_Real mySelToleranceForText2d; //!< Sensitive point tolerance for 2d text selection.
+
+protected: //! @name Value properties
+
+ ValueType myValueType; //! type of value (computed or user-defined)
+ Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
+
+ TCollection_ExtendedString myCustomStringValue; //!< Value of the dimension (computed or user-defined).
+
+protected: //! @name Fixed text position properties
+
+ gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user.
+ Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user.
+
+protected: //! @name Units properties
+
+ Standard_ExtCharacter mySpecialSymbol; //!< Special symbol.
+ PrsDim_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options.
+
+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 myIsGeometryValid; //!< Is dimension geometry properly defined.
+
+private:
+
+ PrsDim_KindOfDimension myKindOfDimension;
+};
+
+#endif // _PrsDim_Dimension_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_DimensionOwner.hxx>
+
+#include <PrsDim_Dimension.hxx>
+#include <PrsMgr_PresentationManager.hxx>
+#include <SelectMgr_SelectableObject.hxx>
+#include <Standard_Type.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_DimensionOwner, SelectMgr_EntityOwner)
+
+namespace
+{
+ //=======================================================================
+ //function : HighlightMode
+ //purpose : Return corresponding compute mode for selection type.
+ //=======================================================================
+ static PrsDim_Dimension::ComputeMode HighlightMode (const Standard_Integer theSelMode)
+ {
+ switch (theSelMode)
+ {
+ case PrsDim_DimensionSelectionMode_Line: return PrsDim_Dimension::ComputeMode_Line;
+ case PrsDim_DimensionSelectionMode_Text: return PrsDim_Dimension::ComputeMode_Text;
+ default:
+ return PrsDim_Dimension::ComputeMode_All;
+ }
+ }
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_DimensionOwner::PrsDim_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
+ const PrsDim_DimensionSelectionMode theMode,
+ const Standard_Integer thePriority)
+: SelectMgr_EntityOwner(theSelObject, thePriority),
+ mySelectionMode (theMode)
+{
+}
+
+//=======================================================================
+//function : IsHilighted
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
+ const Standard_Integer /*theMode*/) const
+{
+ if (!HasSelectable())
+ {
+ return Standard_False;
+ }
+
+ return thePM->IsHighlighted (Selectable(), HighlightMode (mySelectionMode));
+}
+
+//=======================================================================
+//function : Unhilight
+//purpose :
+//=======================================================================
+void PrsDim_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
+ const Standard_Integer /*theMode*/)
+{
+ if (!HasSelectable())
+ {
+ return;
+ }
+
+ thePM->Unhighlight (Selectable());
+}
+
+//=======================================================================
+//function : HilightWithColor
+//purpose :
+//=======================================================================
+void PrsDim_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+ const Handle(Prs3d_Drawer)& theStyle,
+ const Standard_Integer /*theMode*/)
+{
+ thePM->Color (Selectable(), theStyle, HighlightMode (mySelectionMode));
+}
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_DimensionOwner_HeaderFile
+#define _PrsDim_DimensionOwner_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <PrsDim_DimensionSelectionMode.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Standard_Integer.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Quantity_NameOfColor.hxx>
+#include <Standard_Boolean.hxx>
+
+class SelectMgr_SelectableObject;
+class PrsMgr_PresentationManager;
+
+DEFINE_STANDARD_HANDLE(PrsDim_DimensionOwner, SelectMgr_EntityOwner)
+
+//! The owner is the entity which makes it possible to link
+//! the sensitive primitives and the reference shapes that
+//! you want to detect. It stocks the various pieces of
+//! information which make it possible to find objects. An
+//! owner has a priority which you can modulate, so as to
+//! make one entity more selectable than another. You
+//! might want to make edges more selectable than
+//! faces, for example. In that case, you could attribute sa
+//! higher priority to the one compared to the other. An
+//! edge, could have priority 5, for example, and a face,
+//! priority 4. The default priority is 5.
+class PrsDim_DimensionOwner : public SelectMgr_EntityOwner
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_DimensionOwner, SelectMgr_EntityOwner)
+public:
+
+ //! Initializes the dimension owner, theSO, and attributes it
+ //! the priority, thePriority.
+ Standard_EXPORT PrsDim_DimensionOwner(const Handle(SelectMgr_SelectableObject)& theSelObject, const PrsDim_DimensionSelectionMode theSelMode, const Standard_Integer thePriority = 0);
+
+ PrsDim_DimensionSelectionMode SelectionMode() const { return mySelectionMode; }
+
+ Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+ const Handle(Prs3d_Drawer)& theStyle,
+ const Standard_Integer theMode = 0) Standard_OVERRIDE;
+
+ //! Returns true if an object with the selection mode
+ //! aMode is highlighted in the presentation manager aPM.
+ Standard_EXPORT virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode = 0) const Standard_OVERRIDE;
+
+ //! Removes highlighting from the selected part of dimension.
+ Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode = 0) Standard_OVERRIDE;
+
+private:
+
+ PrsDim_DimensionSelectionMode mySelectionMode;
+
+};
+
+#endif // _AIS_DimensionOwner_HeaderFile
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_DimensionSelectionMode_HeaderFile
+#define _PrsDim_DimensionSelectionMode_HeaderFile
+
+//! Specifies dimension selection modes.
+enum PrsDim_DimensionSelectionMode
+{
+ PrsDim_DimensionSelectionMode_All,
+ PrsDim_DimensionSelectionMode_Line,
+ PrsDim_DimensionSelectionMode_Text
+};
+
+#endif // _PrsDim_DimensionSelectionMode_HeaderFile
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_DisplaySpecialSymbol_HeaderFile
+#define _PrsDim_DisplaySpecialSymbol_HeaderFile
+
+//! Specifies dimension special symbol display options
+enum PrsDim_DisplaySpecialSymbol
+{
+ PrsDim_DisplaySpecialSymbol_No,
+ PrsDim_DisplaySpecialSymbol_Before,
+ PrsDim_DisplaySpecialSymbol_After
+};
+
+#endif // _PrsDim_DisplaySpecialSymbol_HeaderFile
--- /dev/null
+// Created on: 1998-01-22
+// Created by: Sergey ZARITCHNY
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_EllipseRadiusDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_OffsetCurve.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_SurfaceOfLinearExtrusion.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAPI.hxx>
+#include <GeomAPI_ExtremaCurveCurve.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Elips.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Precision.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_EllipseRadiusDimension, PrsDim_Relation)
+
+//=======================================================================
+//function : PrsDim_EllipseRadiusDimension
+//purpose :
+//=======================================================================
+PrsDim_EllipseRadiusDimension::PrsDim_EllipseRadiusDimension(const TopoDS_Shape& aShape,
+ const TCollection_ExtendedString& aText)
+:PrsDim_Relation()
+{
+ myFShape = aShape;
+ myText = aText;
+// ComputeGeometry( );
+}
+
+//=======================================================================
+//function : ComputeGeometry
+//purpose :
+//=======================================================================
+
+void PrsDim_EllipseRadiusDimension::ComputeGeometry()
+{
+
+ switch (myFShape.ShapeType()) {
+ case TopAbs_FACE :
+ {
+ // compute one face case
+ ComputeFaceGeometry ();
+ break;
+ }
+ case TopAbs_EDGE:
+ {
+ ComputeEdgeGeometry ();
+ break;
+ }
+ default:
+ break;
+ }
+ while (myFirstPar > 2*M_PI) myFirstPar -= 2*M_PI;
+ while (myLastPar > 2*M_PI) myLastPar -= 2*M_PI;
+ while (myFirstPar < 0.0) myFirstPar += 2*M_PI;
+ while (myLastPar < 0.0) myLastPar += 2*M_PI;
+}
+
+//=======================================================================
+//function : ComputeFaceGeometry
+//purpose :
+//=======================================================================
+
+void PrsDim_EllipseRadiusDimension::ComputeFaceGeometry()
+{
+
+ gp_Pln aPln;
+ Handle( Geom_Surface ) aBasisSurf;
+ PrsDim_KindOfSurface aSurfType;
+ Standard_Real Offset;
+ PrsDim::GetPlaneFromFace( TopoDS::Face( myFShape),
+ aPln,
+ aBasisSurf,
+ aSurfType,
+ Offset ) ;
+
+ if ( aSurfType == PrsDim_KOS_Plane )
+ ComputePlanarFaceGeometry( );
+ else
+ ComputeCylFaceGeometry( aSurfType, aBasisSurf, Offset );
+
+}
+
+//=======================================================================
+//function : ComputeCylFaceGeometry
+//purpose : defines Ellipse and plane of dimension
+//=======================================================================
+
+void PrsDim_EllipseRadiusDimension::ComputeCylFaceGeometry(const PrsDim_KindOfSurface aSurfType,
+ const Handle( Geom_Surface )& aBasisSurf,
+ const Standard_Real Offset)
+{
+
+ BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
+ Standard_Real vFirst, vLast;
+ vFirst = surf1.FirstVParameter();
+ vLast = surf1.LastVParameter();
+ Standard_Real vMid = (vFirst + vLast)*0.5;
+ gp_Pln aPlane;
+ gp_Ax1 Axis;
+// Standard_Real Param;
+ if (aSurfType == PrsDim_KOS_Extrusion)
+ {
+ Axis.SetDirection((Handle( Geom_SurfaceOfLinearExtrusion )::DownCast( aBasisSurf ))
+ ->Direction() );
+ Axis.SetLocation( gp_Pnt((Handle( Geom_SurfaceOfLinearExtrusion )::DownCast( aBasisSurf ))
+ ->Direction().XYZ() ) );
+
+ aPlane.SetAxis(Axis);
+ aPlane.SetLocation(myEllipse.Location());
+ myPlane = new Geom_Plane(aPlane);
+
+ Handle(Geom_Curve) aCurve;
+ aCurve = aBasisSurf->VIso(vMid);
+ if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
+ {
+ myEllipse = Handle(Geom_Ellipse)::DownCast(aCurve)-> Elips();//gp_Elips
+ myIsAnArc = Standard_False;
+ }
+ else if (aCurve->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) {
+ Handle(Geom_TrimmedCurve) tCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve);
+ aCurve = tCurve->BasisCurve();
+ myFirstPar = tCurve->FirstParameter();
+ myLastPar = tCurve->LastParameter();
+ myIsAnArc = Standard_True;
+ if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
+ {
+ myEllipse = Handle(Geom_Ellipse)::DownCast(aCurve)->Elips();//gp_Elips
+ }
+ }
+ else
+ {
+ throw Standard_ConstructionError("PrsDim:: Not expected type of surface") ;
+ return;
+ }
+
+// Offset
+
+ if(surf1.GetType() == GeomAbs_OffsetSurface)
+ {
+ if(Offset <0.0 && Abs(Offset) > myEllipse.MinorRadius ())
+ {
+ throw Standard_ConstructionError("PrsDim:: Absolute value of negative offset is larger than MinorRadius");
+ return;
+ }
+
+ myOffsetCurve = new Geom_OffsetCurve(new Geom_Ellipse(myEllipse), Offset,
+ myPlane->Pln().Axis().Direction());
+ myOffset = Offset;
+ myIsOffset = Standard_True;
+ gp_Elips elips = myEllipse;
+ Standard_Real Val = Offset + elips.MajorRadius ();//simulation
+ myEllipse.SetMajorRadius (Val);
+ Val = Offset + elips.MinorRadius ();
+ myEllipse.SetMinorRadius (Val);
+ }
+ else
+ myIsOffset = Standard_False;
+ }
+}
+
+
+//=======================================================================
+//function : ComputePlanarFaceGeometry
+//purpose :
+//=======================================================================
+
+void PrsDim_EllipseRadiusDimension::ComputePlanarFaceGeometry()
+{
+
+ Standard_Boolean find = Standard_False;
+ gp_Pnt ptfirst,ptend;
+ TopExp_Explorer ExploEd( TopoDS::Face(myFShape), TopAbs_EDGE );
+ for ( ; ExploEd.More(); ExploEd.Next())
+ {
+ TopoDS_Edge curedge = TopoDS::Edge( ExploEd.Current() );
+ Handle(Geom_Curve) curv;
+ Handle(Geom_Ellipse) ellips;
+ if (PrsDim::ComputeGeometry(curedge,curv,ptfirst,ptend))
+ {
+ if (curv->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
+ {
+ ellips = Handle(Geom_Ellipse)::DownCast(curv);
+ if ( !ellips.IsNull() ) {
+ myEllipse = ellips->Elips();
+ find = Standard_True;
+ break;
+ }
+ }
+ }
+ }
+ if( !find )
+ {
+ throw Standard_ConstructionError("PrsDim:: Curve is not an ellipsee or is Null") ;
+ return;
+ }
+
+ if ( !ptfirst.IsEqual(ptend, Precision::Confusion()) )
+ {
+ myIsAnArc = Standard_True;
+ myFirstPar = ElCLib::Parameter(myEllipse, ptfirst);
+ myLastPar = ElCLib::Parameter(myEllipse, ptend);
+ }
+ else
+ myIsAnArc = Standard_False;
+
+ BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
+ myPlane = new Geom_Plane( surfAlgo.Plane() );
+
+}
+
+//=======================================================================
+//function : ComputeEdgeGeometry
+//purpose :
+//=======================================================================
+
+void PrsDim_EllipseRadiusDimension::ComputeEdgeGeometry()
+{
+ gp_Pnt ptfirst,ptend;
+ Handle(Geom_Curve) curv;
+ if (!PrsDim::ComputeGeometry(TopoDS::Edge(myFShape),curv,ptfirst,ptend)) return;
+
+ Handle(Geom_Ellipse) elips = Handle(Geom_Ellipse)::DownCast(curv);
+ if ( elips.IsNull()) return;
+
+ myEllipse = elips->Elips();
+ gp_Pln aPlane;
+ aPlane.SetPosition(gp_Ax3(myEllipse.Position()));
+ myPlane = new Geom_Plane(aPlane);
+
+
+ if ( ptfirst.IsEqual(ptend, Precision::Confusion()) ) {
+ myIsAnArc = Standard_False;
+ }
+ else {
+ myIsAnArc = Standard_True;
+ myFirstPar = ElCLib::Parameter(myEllipse, ptfirst);
+ myLastPar = ElCLib::Parameter(myEllipse, ptend);
+ }
+}
--- /dev/null
+// Created on: 1998-01-22
+// Created by: Sergey ZARITCHNY
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_EllipseRadiusDimension_HeaderFile
+#define _PrsDim_EllipseRadiusDimension_HeaderFile
+
+#include <gp_Elips.hxx>
+#include <PrsDim_Relation.hxx>
+#include <PrsDim_KindOfSurface.hxx>
+
+class Geom_OffsetCurve;
+class TopoDS_Shape;
+class TCollection_ExtendedString;
+class Geom_Surface;
+
+DEFINE_STANDARD_HANDLE(PrsDim_EllipseRadiusDimension, PrsDim_Relation)
+
+//! Computes geometry ( basis curve and plane of dimension)
+//! for input shape aShape from TopoDS
+//! Root class for MinRadiusDimension and MaxRadiusDimension
+class PrsDim_EllipseRadiusDimension : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_EllipseRadiusDimension, PrsDim_Relation)
+public:
+
+ virtual PrsDim_KindOfDimension KindOfDimension() const Standard_OVERRIDE { return PrsDim_KOD_ELLIPSERADIUS; }
+
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+ Standard_EXPORT void ComputeGeometry();
+
+protected:
+
+ Standard_EXPORT PrsDim_EllipseRadiusDimension(const TopoDS_Shape& aShape, const TCollection_ExtendedString& aText);
+
+protected:
+
+ gp_Elips myEllipse;
+ Standard_Real myFirstPar;
+ Standard_Real myLastPar;
+ Standard_Boolean myIsAnArc;
+ Handle(Geom_OffsetCurve) myOffsetCurve;
+ Standard_Real myOffset;
+ Standard_Boolean myIsOffset;
+
+private:
+
+ Standard_EXPORT void ComputeFaceGeometry();
+
+ Standard_EXPORT void ComputeCylFaceGeometry (const PrsDim_KindOfSurface aSurfType, const Handle(Geom_Surface)& aSurf, const Standard_Real Offset);
+
+ Standard_EXPORT void ComputePlanarFaceGeometry();
+
+ Standard_EXPORT void ComputeEdgeGeometry();
+
+};
+
+#endif // _PrsDim_EllipseRadiusDimension_HeaderFile
--- /dev/null
+// Created on: 1998-01-24
+// Created by: Julia GERASIMOVA
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_EqualDistanceRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <PrsDim_LengthDimension.hxx>
+#include <Bnd_Box.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <DsgPrs_EqualDistancePresentation.hxx>
+#include <ElCLib.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pnt.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveCircle.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_EqualDistanceRelation, PrsDim_Relation)
+
+//=======================================================================
+//function : PrsDim_EqualDistanceRelation
+//purpose :
+//=======================================================================
+PrsDim_EqualDistanceRelation::PrsDim_EqualDistanceRelation( const TopoDS_Shape& aShape1,
+ const TopoDS_Shape& aShape2,
+ const TopoDS_Shape& aShape3,
+ const TopoDS_Shape& aShape4,
+ const Handle( Geom_Plane )& aPlane )
+: PrsDim_Relation()
+{
+ myFShape = aShape1;
+ mySShape = aShape2;
+ myShape3 = aShape3;
+ myShape4 = aShape4;
+ myPlane = aPlane;
+
+ //Temporary
+ myArrowSize = 3.0; //set the concrete value
+ mySymbolPrs = DsgPrs_AS_BOTHAR;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+void PrsDim_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager3d )&,
+ const Handle( Prs3d_Presentation )& aPresentation,
+ const Standard_Integer )
+{
+ gp_Pnt Position12 = myPosition, Position34 = myPosition;
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+// -- ota -- begin
+ if (!myAutomaticPosition ){
+ gp_Pnt aMiddle12 ((myPoint1.XYZ() + myPoint2.XYZ())*0.5);
+ gp_Pnt aMiddle34 ((myPoint3.XYZ() + myPoint4.XYZ())*0.5);
+
+ if (myPosition.Distance(aMiddle12) > myPosition.Distance(aMiddle34))
+ Position12.SetXYZ((myPoint1.XYZ() + myPoint2.XYZ())*0.5);
+ else
+ Position34.SetXYZ((myPoint3.XYZ() + myPoint4.XYZ())*0.5);
+
+ }
+
+ if (myFShape.ShapeType() == TopAbs_EDGE && mySShape.ShapeType() == TopAbs_EDGE)
+ PrsDim_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
+ myDrawer,
+ myArrowSize,
+ TopoDS::Edge(myFShape),
+ TopoDS::Edge(mySShape),
+ myPlane,
+ myAutomaticPosition,
+ myIsSetBndBox,
+ myBndBox,
+ Position12,
+ myAttachPoint1,
+ myAttachPoint2,
+ myPoint1,
+ myPoint2,
+ mySymbolPrs );
+
+
+ else if (myFShape.ShapeType() == TopAbs_VERTEX && mySShape.ShapeType() == TopAbs_VERTEX)
+ PrsDim_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
+ myDrawer,
+ myArrowSize,
+ TopoDS::Vertex(myFShape),
+ TopoDS::Vertex(mySShape),
+ myPlane,
+ myAutomaticPosition,
+ myIsSetBndBox,
+ myBndBox,
+ PrsDim_TypeOfDist_Unknown,
+ Position12,
+ myAttachPoint1,
+ myAttachPoint2,
+ myPoint1,
+ myPoint2,
+ mySymbolPrs );
+ else
+ PrsDim_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
+ myDrawer,
+ myArrowSize,
+ myFShape,
+ mySShape,
+ myPlane,
+ myAutomaticPosition,
+ myIsSetBndBox,
+ myBndBox,
+ Position12,
+ myAttachPoint1,
+ myAttachPoint2,
+ myPoint1,
+ myPoint2,
+ mySymbolPrs );
+
+ if (myShape3.ShapeType() == TopAbs_EDGE && myShape4.ShapeType() == TopAbs_EDGE)
+ PrsDim_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
+ myDrawer,
+ myArrowSize,
+ TopoDS::Edge(myShape3),
+ TopoDS::Edge(myShape4),
+ myPlane,
+ myAutomaticPosition,
+ myIsSetBndBox,
+ myBndBox,
+ Position34,
+ myAttachPoint3,
+ myAttachPoint4,
+ myPoint3,
+ myPoint4,
+ mySymbolPrs );
+
+ else if (myShape3.ShapeType() == TopAbs_VERTEX && myShape4.ShapeType() == TopAbs_VERTEX)
+ PrsDim_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
+ myDrawer,
+ myArrowSize,
+ TopoDS::Vertex(myShape3),
+ TopoDS::Vertex(myShape4),
+ myPlane,
+ myAutomaticPosition,
+ myIsSetBndBox,
+ myBndBox,
+ PrsDim_TypeOfDist_Unknown,
+ Position34,
+ myAttachPoint3,
+ myAttachPoint4,
+ myPoint3,
+ myPoint4,
+ mySymbolPrs );
+
+ else
+ PrsDim_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
+ myDrawer,
+ myArrowSize,
+ myShape3,
+ myShape4,
+ myPlane,
+ myAutomaticPosition,
+ myIsSetBndBox,
+ myBndBox,
+ Position34,
+ myAttachPoint3,
+ myAttachPoint4,
+ myPoint3,
+ myPoint4,
+ mySymbolPrs );
+
+ DsgPrs_EqualDistancePresentation::Add( aPresentation, myDrawer,
+ myPoint1, myPoint2, myPoint3, myPoint4, myPlane );
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+
+void PrsDim_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
+ const Standard_Integer )
+{
+ Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 );
+ Handle( Select3D_SensitiveSegment ) seg;
+
+ seg = new Select3D_SensitiveSegment( own, myPoint1, myPoint2 );
+ aSelection->Add( seg );
+
+ seg = new Select3D_SensitiveSegment( own, myPoint3, myPoint4 );
+ aSelection->Add( seg );
+
+ // Line between two middles
+ gp_Pnt Middle12( (myPoint1.XYZ() + myPoint2.XYZ()) * 0.5 ),
+ Middle34( (myPoint3.XYZ() + myPoint4.XYZ()) *0.5 );
+ seg = new Select3D_SensitiveSegment( own, Middle12, Middle34 );
+ aSelection->Add( seg );
+
+ gp_Pnt Middle((Middle12.XYZ() + Middle34.XYZ())*0.5);
+ Standard_Real SmallDist = .001;
+ Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
+ Middle.X() - SmallDist,
+ Middle.Y() - SmallDist,
+ Middle.Z() - SmallDist,
+ Middle.X() + SmallDist,
+ Middle.Y() + SmallDist,
+ Middle.Z() + SmallDist );
+ aSelection->Add(box);
+
+ if (myFShape.ShapeType() == TopAbs_EDGE){
+ BRepAdaptor_Curve aCurve(TopoDS::Edge(myFShape));
+ if (aCurve.GetType() == GeomAbs_Line){
+ //add sensetive element - line
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint1, myPoint1);
+ aSelection->Add( seg );
+ }
+ else if (aCurve.GetType() == GeomAbs_Circle){
+ Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
+ Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint1),
+ LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint1);
+ if (LastPar < FirstPar ) LastPar+=M_PI*2;
+ //add sensetive arc
+ Handle(Select3D_SensitiveCircle) circ =
+ new Select3D_SensitiveCircle( own, aCircle, FirstPar, LastPar);
+ aSelection->Add( circ );
+ }
+ }
+ else {
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint1, myPoint1);
+ aSelection->Add( seg );
+ }
+
+ if (mySShape.ShapeType() == TopAbs_EDGE){
+ BRepAdaptor_Curve aCurve(TopoDS::Edge(mySShape));
+ if (aCurve.GetType() == GeomAbs_Line) {
+ //add sensetive element - line
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint2, myPoint2);
+ aSelection->Add( seg );
+ }
+ else if (aCurve.GetType() == GeomAbs_Circle){
+ Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
+ Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint2),
+ LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint2);
+ if (LastPar < FirstPar ) LastPar+=M_PI*2;
+ //add sensetive arc
+ Handle(Select3D_SensitiveCircle) circ =
+ new Select3D_SensitiveCircle( own,aCircle, FirstPar, LastPar);
+ aSelection->Add( circ );
+ }
+ }
+ else {
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint2, myPoint2);
+ aSelection->Add( seg );
+ }
+
+ if (myShape3.ShapeType() == TopAbs_EDGE){
+ BRepAdaptor_Curve aCurve(TopoDS::Edge(myShape3));
+ if (aCurve.GetType() == GeomAbs_Line) {
+ //add sensetive element - line
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
+ aSelection->Add( seg );
+ }
+ else if (aCurve.GetType() == GeomAbs_Circle){
+ Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
+ Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint3),
+ LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint3);
+ if (LastPar < FirstPar ) LastPar+=M_PI*2;
+ Handle(Select3D_SensitiveCircle) circ =
+ new Select3D_SensitiveCircle( own, aCircle, FirstPar, LastPar);
+ aSelection->Add( circ );
+ }
+ else {
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
+ aSelection->Add( seg );
+ }
+ }
+ else {
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
+ aSelection->Add( seg );
+ }
+
+ if (myShape4.ShapeType() == TopAbs_EDGE){
+ BRepAdaptor_Curve aCurve(TopoDS::Edge(myShape4));
+ if (aCurve.GetType() == GeomAbs_Line) {
+ //add sensetive element - line
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint4, myPoint4);
+ aSelection->Add( seg );
+ }
+ else if (aCurve.GetType() == GeomAbs_Circle){
+ Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
+ Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint4),
+ LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint4);
+ if (LastPar < FirstPar ) LastPar+=M_PI*2;
+ //add sensetive arc
+ Handle(Select3D_SensitiveCircle) circ =
+ new Select3D_SensitiveCircle( own,aCircle, FirstPar, LastPar);
+ aSelection->Add( circ );
+ }
+ }
+ else {
+ seg = new Select3D_SensitiveSegment( own, myAttachPoint4, myPoint4);
+ aSelection->Add( seg );
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoEdgesLength
+//purpose :
+//=======================================================================
+void PrsDim_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Presentation )& aPresentation,
+ const Handle( Prs3d_Drawer )& aDrawer,
+ const Standard_Real ArrowSize,
+ const TopoDS_Edge & FirstEdge,
+ const TopoDS_Edge & SecondEdge,
+ const Handle( Geom_Plane )& Plane,
+ const Standard_Boolean AutomaticPos,
+ const Standard_Boolean IsSetBndBox,
+ const Bnd_Box & BndBox,
+ gp_Pnt& Position,
+ gp_Pnt& FirstAttach,
+ gp_Pnt& SecondAttach,
+ gp_Pnt& FirstExtreme,
+ gp_Pnt& SecondExtreme,
+ DsgPrs_ArrowSide & SymbolPrs )
+{
+ gp_Dir DirAttach;
+ BRepAdaptor_Curve cu1( FirstEdge );
+ BRepAdaptor_Curve cu2( SecondEdge );
+
+ // 3d lines
+ Handle(Geom_Curve) geom1,geom2;
+ gp_Pnt ptat11,ptat12,ptat21,ptat22;
+
+ Standard_Boolean isInfinite1(Standard_False),isInfinite2(Standard_False);
+ Handle(Geom_Curve) extCurv;
+ Standard_Real arrsize = ArrowSize;// size
+ Standard_Real Val=0.;
+ Standard_Boolean isInPlane1, isInPlane2;
+
+ if(!PrsDim::ComputeGeometry(FirstEdge,geom1, ptat11, ptat12,extCurv,isInfinite1,isInPlane1, Plane ))
+ return;
+ if(!PrsDim::ComputeGeometry(SecondEdge, geom2, ptat21, ptat22, extCurv, isInfinite2,isInPlane2, Plane))
+ return;
+
+ aPresentation->SetInfiniteState(isInfinite1 || isInfinite2);
+
+ if (cu1.GetType() == GeomAbs_Line && cu2.GetType() == GeomAbs_Line)
+ {
+ Handle(Geom_Line) geom_lin1 (Handle(Geom_Line)::DownCast (geom1));
+ Handle(Geom_Line) geom_lin2 (Handle(Geom_Line)::DownCast (geom2));
+ const gp_Lin& l1 = geom_lin1->Lin();
+ const gp_Lin& l2 = geom_lin2->Lin();
+
+ //Get Val value
+ Val = l1.Distance( l2 );
+
+ DirAttach = l1.Direction();
+
+ if (AutomaticPos) {
+ // compute position of offset point
+ gp_Pnt curpos;
+ Standard_Real par1=0., par2=0.;
+ if(!(isInfinite1 || isInfinite2))
+ {
+ par1 = ElCLib::Parameter(l1,ptat11);
+ par2 = ElCLib::Parameter(l1,ptat21);
+ if (par1 <par2){//project ptat11 on l2
+ gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2);
+ curpos.SetXYZ((ptat11.XYZ()+p2.XYZ())*0.5);
+ }
+ else {//project ptat21 on l1
+ gp_Pnt p2 = ElCLib::Value(par2, l1);
+ curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())*0.5);
+ }
+ }
+ else if (!isInfinite1){
+ par2 = ElCLib::Parameter(l1,ptat21);
+ gp_Pnt p2 = ElCLib::Value(par2,l1);
+ curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())/2.);
+ }
+ else if (!isInfinite2) {
+ gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2);
+ curpos.SetXYZ((ptat11.XYZ()+p2.XYZ())*0.5);
+ }
+ else
+ curpos.SetXYZ((l1.Location().XYZ()+l2.Location().XYZ())*0.5);
+
+ // compute offset
+ gp_Vec offset(DirAttach);
+ offset = offset*ArrowSize*(-10.);
+ curpos.Translate(offset);
+ Position = curpos;
+ }
+ else { // project point on the plane
+ Position = PrsDim::ProjectPointOnPlane( Position, Plane->Pln() );
+ }
+
+ // find attach points
+ if (!isInfinite1) {
+ if (Position.Distance(ptat11) > Position.Distance(ptat12)) FirstAttach = ptat12;
+ else FirstAttach = ptat11;
+ }
+ else {
+ FirstAttach = ElCLib::Value(ElCLib::Parameter(l1,Position),l1);
+ }
+
+ if (!isInfinite2) {
+ if (Position.Distance(ptat21) > Position.Distance(ptat22)) SecondAttach = ptat22;
+ else SecondAttach = ptat21;
+ }
+ else {
+ SecondAttach = ElCLib::Value(ElCLib::Parameter(l2,Position),l2);
+ }
+
+ Standard_Real confusion(Precision::Confusion());
+ if (arrsize < confusion) arrsize = Val*0.1;
+ if (Abs(Val) <= confusion) {arrsize = 0.;}
+
+ Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ arr->SetLength(arrsize);
+ arr = la->ArrowAspect();
+ arr->SetLength(arrsize);
+
+ if (AutomaticPos && IsSetBndBox)
+ Position = PrsDim::TranslatePointToBound( Position, DirAttach, BndBox );
+
+ DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
+ aDrawer,
+ FirstAttach,
+ SecondAttach,
+ DirAttach,
+ Position,
+ SymbolPrs,
+ FirstExtreme,
+ SecondExtreme);
+
+
+}
+ if (cu1.GetType() == GeomAbs_Circle && cu2.GetType() == GeomAbs_Circle){
+ //Get first and last points of circles
+ Handle(Geom_Circle) aCir1 (Handle(Geom_Circle)::DownCast(geom1));
+ Handle(Geom_Circle) aCir2 (Handle(Geom_Circle)::DownCast(geom2));
+ gp_Circ aCirc1 = aCir1->Circ();
+ gp_Circ aCirc2 = aCir2->Circ();
+
+ //To avoid circles with different orientaion
+ Standard_Real aTol = Precision::Confusion();
+ if(aCirc2.Axis().IsOpposite(aCirc1.Axis(), aTol) ||
+ aCirc2.XAxis().IsOpposite(aCirc1.XAxis(), aTol) ||
+ aCirc2.YAxis().IsOpposite(aCirc1.YAxis(), aTol) )
+ {
+ aCirc2.SetPosition(aCirc1.Position());
+ aCirc2.SetAxis(aCirc1.Axis());
+ }
+
+ if (AutomaticPos){
+ Standard_Real par1 = 0, par2 = 0;
+ gp_Pln aPln = Plane->Pln();
+ //Project ptat12 and ptat22 on constraint plane
+ gp_Pnt PrPnt12 = PrsDim::ProjectPointOnPlane(ptat12, aPln);
+ gp_Pnt PrPnt22 = PrsDim::ProjectPointOnPlane(ptat22, aPln);
+ //Project circles center on constraint plane
+ gp_Pnt PrCenter = PrsDim::ProjectPointOnPlane(aCirc1.Location(), aPln);
+
+ gp_Dir XDir = aPln.XAxis().Direction();
+ gp_Dir YDir = aPln.YAxis().Direction();
+
+
+ if (PrPnt12.Distance(PrCenter) >Precision::Confusion())
+ {
+ gp_Dir aDir1(PrPnt12.XYZ() - PrCenter.XYZ());
+ Standard_Real anAngle = aDir1.Angle(XDir); //Get the angle in range [0, M_PI]
+ if (aDir1.Dot(YDir) < 0)
+ anAngle = 2 * M_PI - anAngle;
+ par1 = anAngle;
+ }
+
+ if (PrPnt22.Distance(PrCenter) >Precision::Confusion())
+ {
+ gp_Dir aDir2(PrPnt22.XYZ() - PrCenter.XYZ());
+ Standard_Real anAngle = aDir2.Angle(XDir); //Get the angle in range [0, M_PI]
+ if (aDir2.Dot(YDir) < 0)
+ anAngle = 2 * M_PI - anAngle;
+ par2 = anAngle;
+ }
+
+
+ if(par1 > par2 ){
+ FirstExtreme = ptat12;
+ Standard_Real aPar1 = ElCLib::Parameter(aCirc2, ptat12);
+ SecondExtreme = ElCLib::Value(aPar1, aCirc2);
+ }
+ else {
+ Standard_Real aPar2 = ElCLib::Parameter(aCirc1, ptat22);
+ FirstExtreme = ElCLib::Value(aPar2, aCirc1);
+ SecondExtreme = ptat22;
+ }
+ }
+ else {
+ Standard_Real pospar = ElCLib::Parameter(aCirc1, Position);
+ FirstExtreme = ElCLib::Value(pospar, aCirc1);
+ pospar = ElCLib::Parameter(aCirc2, Position);
+ SecondExtreme = ElCLib::Value(pospar, aCirc2);
+ }
+
+ DsgPrs_EqualDistancePresentation::AddIntervalBetweenTwoArcs(aPresentation,
+ aDrawer,
+ aCirc1,
+ aCirc2,
+ ptat12,
+ FirstExtreme,
+ ptat22,
+ SecondExtreme,
+ SymbolPrs);
+
+ FirstAttach = ptat12; SecondAttach = ptat22; //assign attach points
+ Position.SetXYZ( (FirstAttach.XYZ() + SecondAttach.XYZ())*0.5);
+ }
+
+ if (arrsize < Precision::Confusion()) arrsize = Val*0.1;
+ if (Abs(Val) <= Precision::Confusion()) {arrsize = 0.;}
+
+// gp_Pnt pf, pl;
+ if (!isInPlane1) {
+ PrsDim::ComputeProjEdgePresentation( aPresentation, aDrawer, FirstEdge, geom1, ptat11, ptat12);
+ }
+ if(!isInPlane2) {
+ PrsDim::ComputeProjEdgePresentation( aPresentation, aDrawer, SecondEdge, geom2, ptat21, ptat22);
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoVerticesLength
+//purpose :
+//=======================================================================
+
+void PrsDim_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Presentation )& aPresentation,
+ const Handle( Prs3d_Drawer )& aDrawer,
+ const Standard_Real ArrowSize,
+ const TopoDS_Vertex& FirstVertex,
+ const TopoDS_Vertex& SecondVertex,
+ const Handle( Geom_Plane )& Plane,
+ const Standard_Boolean AutomaticPos,
+ const Standard_Boolean IsSetBndBox,
+ const Bnd_Box& BndBox,
+ const PrsDim_TypeOfDist TypeDist,
+ gp_Pnt& Position,
+ gp_Pnt& FirstAttach,
+ gp_Pnt& SecondAttach,
+ gp_Pnt& FirstExtreme,
+ gp_Pnt& SecondExtreme,
+ DsgPrs_ArrowSide& SymbolPrs )
+{
+ Standard_Boolean isOnPlane1, isOnPlane2;
+ gp_Dir DirAttach;
+ PrsDim::ComputeGeometry( FirstVertex, FirstAttach, Plane, isOnPlane1);
+ PrsDim::ComputeGeometry( SecondVertex, SecondAttach, Plane, isOnPlane2);
+
+ Standard_Real confusion(Precision::Confusion());
+ Standard_Boolean samePoint(FirstAttach.IsEqual(SecondAttach,confusion));
+
+ if (TypeDist == PrsDim_TypeOfDist_Vertical) DirAttach = Plane->Pln().XAxis().Direction();
+ else if (TypeDist == PrsDim_TypeOfDist_Horizontal) DirAttach = Plane->Pln().YAxis().Direction();
+ else {
+ if (!samePoint) {
+ DirAttach.SetXYZ(SecondAttach.XYZ() - FirstAttach.XYZ());
+ DirAttach.Rotate(Plane->Pln().Axis(),M_PI/2.);
+ }
+ }
+
+ // size
+ if (AutomaticPos) {
+ if (!samePoint) {
+ gp_Pnt curpos((FirstAttach.XYZ()+SecondAttach.XYZ())*0.5);
+ // make offset of curpos
+ gp_Vec offset(DirAttach);
+ offset = offset*ArrowSize*(-10.);
+ curpos.Translate(offset);
+ Position = curpos;
+ }
+ else {
+ gp_Dir aDir = Plane->Pln().Axis().Direction();
+ gp_Vec aVec (aDir.XYZ()*10*ArrowSize);
+ //Position = gp_Pnt(FirstAttach.XYZ()+gp_XYZ(1.,1.,1.)); // not correct
+ Position = FirstAttach.Translated(aVec);
+ Position = PrsDim::ProjectPointOnPlane( Position, Plane->Pln() );//not needed really
+ DirAttach.SetXYZ(Position.XYZ() - FirstAttach.XYZ());
+ }
+ }
+ else {
+ Position = PrsDim::ProjectPointOnPlane( Position, Plane->Pln() );
+ }
+
+
+ Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ arr->SetLength(ArrowSize);
+ arr = la->ArrowAspect();
+ arr->SetLength(ArrowSize);
+
+ if (AutomaticPos && IsSetBndBox)
+ Position = PrsDim::TranslatePointToBound( Position, DirAttach, BndBox );
+
+ DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
+ aDrawer,
+ FirstAttach,
+ SecondAttach,
+ DirAttach,
+ Position,
+ SymbolPrs,
+ FirstExtreme, //returned
+ SecondExtreme); //returned
+
+ // Compute projection
+ if ( !isOnPlane1)
+ PrsDim::ComputeProjVertexPresentation(aPresentation, aDrawer, FirstVertex, FirstAttach);
+ if ( !isOnPlane2)
+ PrsDim::ComputeProjVertexPresentation(aPresentation, aDrawer, SecondVertex, SecondAttach);
+
+}
+
+
+//=======================================================================
+//function : ComputeOneEdgeOneVertexLength
+//purpose :
+//=======================================================================
+
+void PrsDim_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs3d_Presentation )& aPresentation,
+ const Handle( Prs3d_Drawer )& aDrawer,
+ const Standard_Real ArrowSize,
+ const TopoDS_Shape & FirstShape,
+ const TopoDS_Shape & SecondShape,
+ const Handle( Geom_Plane )& Plane,
+ const Standard_Boolean AutomaticPos,
+ const Standard_Boolean IsSetBndBox,
+ const Bnd_Box & BndBox,
+ gp_Pnt & Position,
+ gp_Pnt & FirstAttach,
+ gp_Pnt & SecondAttach,
+ gp_Pnt& FirstExtreme,
+ gp_Pnt& SecondExtreme,
+ DsgPrs_ArrowSide & SymbolPrs )
+{
+ TopoDS_Vertex thevertex;
+ TopoDS_Edge theedge;
+
+ gp_Pnt ptonedge1,ptonedge2;
+ Handle(Geom_Curve) aCurve;
+ Handle(Geom_Curve) extCurv;
+ Standard_Boolean isInfinite;
+ Standard_Real Val;
+ Standard_Boolean isOnPlanEdge, isOnPlanVertex;
+ Standard_Integer edgenum ;
+
+ if (FirstShape.ShapeType() == TopAbs_VERTEX) {
+ thevertex = TopoDS::Vertex(FirstShape);
+ theedge = TopoDS::Edge(SecondShape);
+ edgenum = 2; //edge is the second shape
+ }
+ else {
+ thevertex = TopoDS::Vertex(SecondShape);
+ theedge = TopoDS::Edge(FirstShape);
+ edgenum = 1;//edge is the first shape
+ }
+ if (!PrsDim::ComputeGeometry(theedge,aCurve,ptonedge1,ptonedge2,extCurv,isInfinite,isOnPlanEdge,Plane))
+ return;
+ aPresentation->SetInfiniteState(isInfinite);
+ PrsDim::ComputeGeometry(thevertex, FirstAttach, Plane, isOnPlanVertex);
+
+ if ( aCurve->IsInstance(STANDARD_TYPE(Geom_Line)) )
+ {
+ Handle(Geom_Line) geom_lin (Handle(Geom_Line)::DownCast (aCurve));
+ const gp_Lin& l = geom_lin->Lin();
+
+ // computation of Val
+ Val = l.Distance( FirstAttach );
+
+ gp_Dir DirAttach = l.Direction();
+ // size
+ Standard_Real arrsize = ArrowSize;
+ if (Abs(Val) <= Precision::Confusion()) {arrsize = 0.;}
+
+ if (AutomaticPos) {
+ gp_Pnt p = ElCLib::Value(ElCLib::Parameter(l,FirstAttach),l);
+ gp_Pnt curpos((FirstAttach.XYZ()+p.XYZ())*0.5);
+ // make offset
+ gp_Vec offset(DirAttach);
+ offset = offset*ArrowSize*(-10.);
+ curpos.Translate(offset);
+ Position = curpos;
+ }
+ else { // project point on the plane
+ Position = PrsDim::ProjectPointOnPlane( Position, Plane->Pln() );
+ }
+
+ if (!isInfinite) {
+ if (Position.Distance(ptonedge1) > Position.Distance(ptonedge2)) SecondAttach = ptonedge2;
+ else SecondAttach = ptonedge1;
+ }
+ else {
+ SecondAttach = ElCLib::Value(ElCLib::Parameter(l,Position),l);
+ }
+
+ Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ arr->SetLength(arrsize);
+ arr = la->ArrowAspect();
+ arr->SetLength(arrsize);
+
+ if (AutomaticPos && IsSetBndBox)
+ Position = PrsDim::TranslatePointToBound( Position, DirAttach, BndBox );
+ DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
+ aDrawer,
+ FirstAttach,
+ SecondAttach,
+ DirAttach,
+ Position,
+ SymbolPrs,
+ FirstExtreme,
+ SecondExtreme);
+
+}
+ if (aCurve->IsInstance(STANDARD_TYPE(Geom_Circle))){
+ gp_Circ aCirc1 = (Handle(Geom_Circle)::DownCast(aCurve))->Circ();
+ gp_Circ aCirc2(aCirc1); aCirc2.SetRadius(0); //create the second formal circle
+ if(AutomaticPos)
+ {
+ SecondAttach = ptonedge2; //a vertex
+ Position.SetXYZ((SecondAttach.XYZ() + aCirc1.Location().XYZ())*0.5);
+ }
+ else {
+ Standard_Real aPar = ElCLib::Parameter(aCirc1, Position);
+ SecondAttach = ElCLib::Value(aPar, aCirc1);
+ }
+
+ Handle(Geom_Circle) aCurve2 = new Geom_Circle(aCirc2);
+ DsgPrs_EqualDistancePresentation::AddIntervalBetweenTwoArcs(aPresentation,
+ aDrawer,
+ aCirc1, //circle or arc
+ aCirc2, //really vertex
+ ptonedge2, //last point of aCirc1
+ SecondAttach,
+ FirstAttach, //vertex really
+ FirstAttach,
+ SymbolPrs);
+
+ //Assign arc points
+ if (edgenum == 1){
+ FirstExtreme = SecondAttach; SecondExtreme = FirstAttach;
+ SecondAttach = FirstAttach; FirstAttach = ptonedge2;
+ } else { //vertex is the first shape, circle is sthe last.
+ FirstExtreme = FirstAttach; SecondExtreme = SecondAttach;
+ SecondAttach = ptonedge2;
+ }
+ }
+
+ // computation of Val
+ Val = FirstAttach.Distance(SecondAttach);
+
+ //Display the pieces of attached to the curve if it is not
+ // in the WP
+ if (!isOnPlanEdge) { // add presentation of projection of the edge in WP
+ PrsDim::ComputeProjEdgePresentation(aPresentation,aDrawer,theedge,aCurve,ptonedge1,ptonedge2);
+ }
+ if (!isOnPlanVertex) { // add presentation of projection of the vertex in WP
+ PrsDim::ComputeProjVertexPresentation(aPresentation,aDrawer,thevertex,FirstAttach);
+ }
+
+}
+// -- ota -- end
--- /dev/null
+// Created on: 1998-01-24
+// Created by: Julia GERASIMOVA
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_EqualDistanceRelation_HeaderFile
+#define _PrsDim_EqualDistanceRelation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+#include <PrsDim_TypeOfDist.hxx>
+#include <DsgPrs_ArrowSide.hxx>
+
+class Geom_Plane;
+
+DEFINE_STANDARD_HANDLE(PrsDim_EqualDistanceRelation, PrsDim_Relation)
+
+//! A framework to display equivalent distances between
+//! shapes and a given plane.
+//! The distance is the length of a projection from the
+//! shape to the plane.
+//! These distances are used to compare shapes by this vector alone.
+class PrsDim_EqualDistanceRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_EqualDistanceRelation, PrsDim_Relation)
+public:
+
+ //! Constructs a framework to display equivalent
+ //! distances between the shapes aShape1, aShape2,
+ //! aShape3, aShape4 and the plane aPlane.
+ //! The distance is the length of a projection from the
+ //! shape to the plane.
+ Standard_EXPORT PrsDim_EqualDistanceRelation(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const TopoDS_Shape& aShape3, const TopoDS_Shape& aShape4, const Handle(Geom_Plane)& aPlane);
+
+ //! Sets the shape aShape to be used as the shape
+ //! aShape3 in the framework created at construction time.
+ void SetShape3 (const TopoDS_Shape& aShape) { myShape3 = aShape; }
+
+ //! Returns the shape aShape3 from the framework
+ //! created at construction time.
+ const TopoDS_Shape& Shape3() const { return myShape3; }
+
+ //! Sets the shape aShape to be used as the shape
+ //! aShape4 in the framework created at construction time.
+ void SetShape4 (const TopoDS_Shape& aShape) { myShape4 = aShape; }
+
+ //! Returns the shape aShape4 from the framework
+ //! created at construction time.
+ const TopoDS_Shape& Shape4() const { return myShape4; }
+
+public:
+
+ //! Computes the location of an intreval between
+ //! between two edges. FirstAttach , SecondAttach
+ //! are the returned extreme points of the interval.
+ Standard_EXPORT static void ComputeTwoEdgesLength (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Drawer)& aDrawer, const Standard_Real ArrowSize, const TopoDS_Edge& FirstEdge, const TopoDS_Edge& SecondEdge, const Handle(Geom_Plane)& Plane, const Standard_Boolean AutomaticPos, const Standard_Boolean IsSetBndBox, const Bnd_Box& BndBox, gp_Pnt& Position, gp_Pnt& FirstAttach, gp_Pnt& SecondAttach, gp_Pnt& FirstExtreme, gp_Pnt& SecondExtreme, DsgPrs_ArrowSide& SymbolPrs);
+
+ //! Computes the interval position between two vertexs. FirstAttach,
+ //! SecondAttach are the returned extreme points of the interval.
+ Standard_EXPORT static void ComputeTwoVerticesLength (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Drawer)& aDrawer, const Standard_Real ArrowSize, const TopoDS_Vertex& FirstVertex, const TopoDS_Vertex& SecondVertex, const Handle(Geom_Plane)& Plane, const Standard_Boolean AutomaticPos, const Standard_Boolean IsSetBndBox, const Bnd_Box& BndBox, const PrsDim_TypeOfDist TypeDist, gp_Pnt& Position, gp_Pnt& FirstAttach, gp_Pnt& SecondAttach, gp_Pnt& FirstExtreme, gp_Pnt& SecondExtreme, DsgPrs_ArrowSide& SymbolPrs);
+
+ //! Compute the interval location between a vertex and an edge. Edge may be
+ //! a line or a circle.
+ Standard_EXPORT static void ComputeOneEdgeOneVertexLength (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Drawer)& aDrawer, const Standard_Real ArrowSize, const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& Plane, const Standard_Boolean AutomaticPos, const Standard_Boolean IsSetBndBox, const Bnd_Box& BndBox, gp_Pnt& Position, gp_Pnt& FirstAttach, gp_Pnt& SecondAttach, gp_Pnt& FirstExtreme, gp_Pnt& SecondExtreme, DsgPrs_ArrowSide& SymbolPrs);
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+private:
+
+ TopoDS_Shape myShape3;
+ TopoDS_Shape myShape4;
+ gp_Pnt myAttachPoint1;
+ gp_Pnt myAttachPoint2;
+ gp_Pnt myAttachPoint3;
+ gp_Pnt myAttachPoint4;
+ gp_Pnt myPoint1;
+ gp_Pnt myPoint2;
+ gp_Pnt myPoint3;
+ gp_Pnt myPoint4;
+
+};
+
+#endif // _PrsDim_EqualDistanceRelation_HeaderFile
--- /dev/null
+// Created on: 1998-01-20
+// Created by: Julia GERASIMOVA
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_EqualRadiusRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <DsgPrs_EqualRadiusPresentation.hxx>
+#include <ElCLib.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Plane.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+#include <gp_Circ.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <Standard_Type.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_EqualRadiusRelation, PrsDim_Relation)
+
+//=======================================================================
+//function : PrsDim_EqualRadiusRelation
+//purpose :
+//=======================================================================
+PrsDim_EqualRadiusRelation::PrsDim_EqualRadiusRelation( const TopoDS_Edge& aFirstEdge,
+ const TopoDS_Edge& aSecondEdge,
+ const Handle( Geom_Plane )& aPlane )
+: PrsDim_Relation()
+{
+ myFShape = aFirstEdge;
+ mySShape = aSecondEdge;
+ myPlane = aPlane;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+void PrsDim_EqualRadiusRelation::Compute( const Handle( PrsMgr_PresentationManager3d )&,
+ const Handle( Prs3d_Presentation )& aPresentation,
+ const Standard_Integer )
+{
+ BRepAdaptor_Curve FirstCurve( TopoDS::Edge( myFShape ) ), SecondCurve( TopoDS::Edge( mySShape ) );
+
+ Standard_Real FirstPar1 = FirstCurve.FirstParameter(), LastPar1 = FirstCurve.LastParameter(),
+ FirstPar2 = SecondCurve.FirstParameter(), LastPar2 = SecondCurve.LastParameter();
+
+ Handle( Geom_Curve ) FirstProjCurve = FirstCurve.Curve().Curve(),
+ SecondProjCurve = SecondCurve.Curve().Curve();
+ gp_Pnt FirstPoint1, LastPoint1, FirstPoint2, LastPoint2;
+ Standard_Boolean isFirstOnPlane, isSecondOnPlane;
+
+ PrsDim::ComputeGeomCurve (FirstProjCurve, FirstPar1, LastPar1, FirstPoint1, LastPoint1, myPlane, isFirstOnPlane);
+ PrsDim::ComputeGeomCurve (SecondProjCurve, FirstPar2, LastPar2, FirstPoint2, LastPoint2, myPlane, isSecondOnPlane);
+
+ if (!isFirstOnPlane)
+ ComputeProjEdgePresentation( aPresentation, TopoDS::Edge( myFShape ), FirstProjCurve, FirstPoint1, LastPoint1 );
+ if (! isSecondOnPlane)
+ ComputeProjEdgePresentation( aPresentation, TopoDS::Edge( mySShape ), SecondProjCurve, FirstPoint2, LastPoint2 );
+
+ gp_Circ FirstCirc = (Handle( Geom_Circle )::DownCast( FirstProjCurve ))->Circ();
+ gp_Circ SecondCirc = (Handle( Geom_Circle )::DownCast( SecondProjCurve ))->Circ();
+
+ myFirstCenter = FirstCirc.Location();
+ mySecondCenter = SecondCirc.Location();
+
+ //ota -- begin --
+ if (myAutomaticPosition)
+ {
+ myFirstPoint = ElCLib::Value( (FirstPar1 + LastPar1)*0.5, FirstCirc );
+ mySecondPoint = ElCLib::Value( (FirstPar2 + LastPar2)*0.5, SecondCirc );
+ }
+ else {
+ Standard_Real aPar = ElCLib::Parameter(FirstCirc, myFirstPoint);
+ if (IntegerPart(0.5*LastPar1/M_PI) != 0 && aPar < FirstPar1 )
+ aPar +=2*M_PI*IntegerPart(0.5*LastPar1/M_PI);
+ Standard_Real aRadius = FirstCirc.Radius();
+
+ if (Abs(myFirstPoint.Distance(myFirstCenter) - aRadius) >= Precision::Confusion())
+ myFirstPoint = ElCLib::Value(aPar, FirstCirc);
+ if ( FirstPoint1.Distance(LastPoint1) > Precision::Confusion()){
+ //check where is myFirstPoint
+ if (aPar > LastPar1 || aPar < FirstPar1)
+ {
+ //myFirstPoint is out of Arc of FirstCircle
+ if (FirstPoint1.Distance(myFirstPoint)< LastPoint1.Distance(myFirstPoint))
+ myFirstPoint = FirstPoint1;
+ else
+ myFirstPoint = LastPoint1;
+ }
+ }
+
+
+ aPar = ElCLib::Parameter(SecondCirc, mySecondPoint);
+ if (IntegerPart(0.5*LastPar2/M_PI) != 0 && aPar < FirstPar2 )
+ aPar +=2*M_PI*IntegerPart(0.5*LastPar2/M_PI);
+
+ aRadius = SecondCirc.Radius();
+ if (Abs(mySecondPoint.Distance(mySecondCenter) - aRadius) >= Precision::Confusion())
+ mySecondPoint = ElCLib::Value(aPar, SecondCirc);
+ if (FirstPoint2.Distance(LastPoint2) > Precision::Confusion()){
+ if (aPar > LastPar2 || aPar < FirstPar2)
+ { //mySecondPoint is out of Arc of mySecondCircle
+ if (FirstPoint2.Distance(mySecondPoint)< LastPoint2.Distance(mySecondPoint))
+ mySecondPoint = FirstPoint2;
+ else
+ mySecondPoint = LastPoint2;
+ }
+ }
+ }
+ if( !myArrowSizeIsDefined )
+ myArrowSize = (Min(myFirstCenter.Distance(myFirstPoint),
+ mySecondCenter.Distance(mySecondPoint)))*0.05;
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+
+ //ota -- end --
+
+ DsgPrs_EqualRadiusPresentation::Add(aPresentation, myDrawer,
+ myFirstCenter, mySecondCenter, myFirstPoint, mySecondPoint, myPlane );
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+
+void PrsDim_EqualRadiusRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
+ const Standard_Integer )
+{
+ Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 );
+ Handle( Select3D_SensitiveSegment ) seg;
+
+ seg = new Select3D_SensitiveSegment( own, myFirstCenter, myFirstPoint );
+ aSelection->Add( seg );
+
+ if(!myAutomaticPosition)
+ ComputeRadiusPosition();
+
+ seg = new Select3D_SensitiveSegment( own, mySecondCenter, mySecondPoint );
+ aSelection->Add( seg );
+
+ seg = new Select3D_SensitiveSegment( own, myFirstCenter, mySecondCenter );
+ aSelection->Add( seg );
+
+
+ // Two small lines
+ gp_Pnt Middle( (myFirstCenter.XYZ() + mySecondCenter.XYZ())*0.5 );
+
+ Standard_Real SmallDist = .001;
+ //Should be changed as the domain of small lines could be changed.
+ Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox(own,
+ Middle.X() - SmallDist,
+ Middle.Y() - SmallDist,
+ Middle.Z() - SmallDist,
+ Middle.X() + SmallDist,
+ Middle.Y() + SmallDist,
+ Middle.Z() + SmallDist );
+ aSelection->Add(box);
+}
+
+//=================================================================
+//function : ComputeRadiusPosition
+//purpose :
+//=================================================================
+void PrsDim_EqualRadiusRelation::ComputeRadiusPosition()
+{
+ if (myAutomaticPosition ||
+ myFirstCenter.Distance(myPosition) < Precision::Confusion() ||
+ mySecondCenter.Distance(myPosition) < Precision::Confusion())
+ return;
+
+ gp_Pnt aPosition;
+
+ //project myPosition to the plane of constraint
+ GeomAPI_ProjectPointOnSurf aProj(myPosition, myPlane);
+ aPosition = aProj.NearestPoint();
+
+ Standard_Real aDist1 = myFirstPoint.Distance(aPosition);
+ Standard_Real aDist2 = mySecondPoint.Distance(aPosition);
+
+ if(aDist1<aDist2)
+ {
+ Standard_Real Rad1 = myFirstPoint.Distance(myFirstCenter);
+ const gp_Dir aNewDir1(aPosition.XYZ() - myFirstCenter.XYZ());
+ const gp_Vec aTVec (aNewDir1.XYZ()*Rad1);
+ myFirstPoint = myFirstCenter.Translated(aTVec);
+ }
+ else {
+ Standard_Real Rad2 = mySecondPoint.Distance(mySecondCenter);
+ const gp_Dir aNewDir2(aPosition.XYZ() - mySecondCenter.XYZ());
+ gp_Vec aTVec (aNewDir2.XYZ()*Rad2);
+ mySecondPoint = mySecondCenter.Translated(aTVec);
+ }
+
+}
+
--- /dev/null
+// Created on: 1998-01-17
+// Created by: Julia GERASIMOVA
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_EqualRadiusRelation_HeaderFile
+#define _PrsDim_EqualRadiusRelation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+
+class Geom_Plane;
+
+DEFINE_STANDARD_HANDLE(PrsDim_EqualRadiusRelation, PrsDim_Relation)
+
+class PrsDim_EqualRadiusRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_EqualRadiusRelation, PrsDim_Relation)
+public:
+
+ //! Creates equal relation of two arc's radiuses.
+ //! If one of edges is not in the given plane,
+ //! the presentation method projects it onto the plane.
+ Standard_EXPORT PrsDim_EqualRadiusRelation(const TopoDS_Edge& aFirstEdge, const TopoDS_Edge& aSecondEdge, const Handle(Geom_Plane)& aPlane);
+
+private:
+
+ Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeRadiusPosition();
+
+private:
+
+ gp_Pnt myFirstCenter;
+ gp_Pnt mySecondCenter;
+ gp_Pnt myFirstPoint;
+ gp_Pnt mySecondPoint;
+
+};
+
+#endif // _PrsDim_EqualRadiusRelation_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Flore Lantheaume/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_FixRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <DsgPrs_FixPresentation.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <gp_XYZ.hxx>
+#include <Precision.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_DomainError.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TColStd_ListIteratorOfListOfTransient.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_FixRelation, PrsDim_Relation)
+
+static Standard_Boolean InDomain(const Standard_Real fpar,
+ const Standard_Real lpar,
+ const Standard_Real para)
+{
+ if (fpar >= 0.) {
+ return ((para >= fpar) && (para <= lpar));
+ }
+ if (para >= (fpar+2*M_PI)) return Standard_True;
+ if (para <= lpar) return Standard_True;
+ return Standard_False;
+}
+
+//=======================================================================
+//function : Constructor
+//purpose : vertex Fix Relation
+//=======================================================================
+
+PrsDim_FixRelation::PrsDim_FixRelation(const TopoDS_Shape& aShape,
+ const Handle(Geom_Plane)& aPlane,
+ const TopoDS_Wire& aWire)
+: PrsDim_Relation(),
+ myWire(aWire)
+{
+ myFShape = aShape;
+ myPlane = aPlane;
+ myAutomaticPosition = Standard_True;
+ myArrowSize = 5.;
+}
+
+//=======================================================================
+//function : Constructor
+//purpose : vertex Fix Relation
+//=======================================================================
+
+PrsDim_FixRelation::PrsDim_FixRelation(const TopoDS_Shape& aShape,
+ const Handle(Geom_Plane)& aPlane,
+ const TopoDS_Wire& aWire,
+ const gp_Pnt& aPosition,
+ const Standard_Real anArrowSize)
+: PrsDim_Relation(),
+ myWire(aWire)
+{
+ myFShape = aShape;
+ myPlane = aPlane;
+ myPosition = aPosition;
+ SetArrowSize( anArrowSize );
+ myAutomaticPosition = Standard_False;
+}
+
+
+//=======================================================================
+//function : Constructor
+//purpose : edge (line or circle) Fix Relation
+//=======================================================================
+
+PrsDim_FixRelation::PrsDim_FixRelation (const TopoDS_Shape& aShape,
+ const Handle(Geom_Plane)& aPlane)
+{
+ myFShape = aShape;
+ myPlane = aPlane;
+ myAutomaticPosition = Standard_True;
+ myArrowSize = 5.;
+}
+
+//=======================================================================
+//function : Constructor
+//purpose : edge (line or circle) Fix Relation
+//=======================================================================
+
+PrsDim_FixRelation::PrsDim_FixRelation(
+ const TopoDS_Shape& aShape,
+ const Handle(Geom_Plane)& aPlane,
+ const gp_Pnt& aPosition,
+ const Standard_Real anArrowSize)
+{
+ myFShape = aShape;
+ myPlane = aPlane;
+ myPosition = aPosition;
+ SetArrowSize( anArrowSize );
+ myAutomaticPosition = Standard_False;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+void PrsDim_FixRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer)
+{
+ // Calculate position of the symbol and
+ // point of attach of the segment on the shape
+ gp_Pnt curpos;
+ if (myFShape.ShapeType() == TopAbs_VERTEX)
+ ComputeVertex(TopoDS::Vertex(myFShape), curpos);
+ else if (myFShape.ShapeType() == TopAbs_EDGE)
+ ComputeEdge(TopoDS::Edge(myFShape), curpos);
+
+ const gp_Dir& nor = myPlane->Axis().Direction();
+
+
+ // calculate presentation
+ // definition of the symbol size
+ if( !myArrowSizeIsDefined )
+ myArrowSize = 5.;
+
+ //creation of the presentation
+ DsgPrs_FixPresentation::Add(aPresentation,
+ myDrawer,
+ myPntAttach,
+ curpos,
+ nor,
+ myArrowSize);
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+
+void PrsDim_FixRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer)
+{
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+
+ // creation of segment sensible for the linked segment
+ // of the shape fixed to symbol 'Fix'
+ Handle(Select3D_SensitiveSegment) seg;
+ seg = new Select3D_SensitiveSegment(own,
+ myPntAttach,
+ myPosition);
+ aSelection->Add(seg);
+
+ // Creation of the sensible zone of symbol 'Fix'
+ gp_Dir norm = myPlane->Axis().Direction();
+
+ gp_Vec dirac(myPntAttach,myPosition);
+ dirac.Normalize();
+ gp_Vec norac = dirac.Crossed(gp_Vec(norm));
+ gp_Ax1 ax(myPosition, norm);
+ norac.Rotate(ax, M_PI/8);
+
+ norac*=(myArrowSize/2);
+ gp_Pnt P1 = myPosition.Translated(norac);
+ gp_Pnt P2 = myPosition.Translated(-norac);
+ seg = new Select3D_SensitiveSegment(own,
+ P1,
+ P2);
+ aSelection->Add(seg);
+
+ norac*=0.8;
+ P1 = myPosition.Translated(norac);
+ P2 = myPosition.Translated(-norac);
+ dirac*=(myArrowSize/2);
+ gp_Pnt PF(P1.XYZ());
+ gp_Pnt PL = PF.Translated(dirac);
+ PL.Translate(norac);
+ seg = new Select3D_SensitiveSegment(own,
+ PF,
+ PL);
+ aSelection->Add(seg);
+
+
+ PF.SetXYZ(P2.XYZ());
+ PL = PF.Translated(dirac);
+ PL.Translate(norac);
+ seg = new Select3D_SensitiveSegment(own,
+ PF,
+ PL);
+ aSelection->Add(seg);
+
+ PF.SetXYZ( (P1.XYZ() + P2.XYZ()) /2 );
+ PL = PF.Translated(dirac);
+ PL.Translate(norac);
+ seg = new Select3D_SensitiveSegment(own,
+ PF,
+ PL);
+}
+
+//=======================================================================
+//function : ComputeVertex
+//purpose : computes myPntAttach and the position of the presentation
+// when you fix a vertex
+//=======================================================================
+
+void PrsDim_FixRelation::ComputeVertex(const TopoDS_Vertex& /*FixVertex*/,
+ gp_Pnt& curpos)
+{
+ myPntAttach = BRep_Tool::Pnt(TopoDS::Vertex(myFShape));
+ curpos = myPosition;
+ if (myAutomaticPosition) {
+ gp_Pln pln(myPlane->Pln());
+ gp_Dir dir(pln.XAxis().Direction());
+ gp_Vec transvec = gp_Vec(dir)*myArrowSize;
+ curpos = myPntAttach.Translated(transvec);
+ myPosition = curpos;
+ myAutomaticPosition = Standard_True;
+ }
+}
+
+//=======================================================================
+//function : ComputePosition
+//purpose :
+//=======================================================================
+
+gp_Pnt PrsDim_FixRelation::ComputePosition(const Handle(Geom_Curve)& curv1,
+ const Handle(Geom_Curve)& curv2,
+ const gp_Pnt& firstp1,
+ const gp_Pnt& lastp1,
+ const gp_Pnt& firstp2,
+ const gp_Pnt& lastp2) const
+{
+ //---------------------------------------------------------
+ // calculate the point of attach
+ //---------------------------------------------------------
+ gp_Pnt curpos;
+
+ if (curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) || curv2->IsInstance(STANDARD_TYPE(Geom_Circle))) {
+ Handle(Geom_Circle) gcirc = Handle(Geom_Circle)::DownCast(curv1);
+ if (gcirc.IsNull()) gcirc = Handle(Geom_Circle)::DownCast(curv2);
+ gp_Dir dir( gcirc->Location().XYZ() + myPntAttach.XYZ() );
+ gp_Vec transvec = gp_Vec(dir)*myArrowSize;
+ curpos = myPntAttach.Translated(transvec);
+ }
+
+ else {
+ gp_Vec vec1(firstp1,lastp1);
+ gp_Vec vec2(firstp2,lastp2);
+
+ if (!vec1.IsParallel(vec2, Precision::Angular()) ) {
+ gp_Dir dir;
+ Standard_Real conf =Precision::Confusion();
+ if (lastp1.IsEqual(firstp2,conf) || firstp1.IsEqual(lastp2,conf)) dir.SetXYZ(vec1.XYZ() - vec2.XYZ());
+ else dir.SetXYZ(vec1.XYZ() + vec2.XYZ());
+ gp_Vec transvec = gp_Vec(dir)*myArrowSize;
+ curpos = myPntAttach.Translated(transvec);
+ }
+ else {
+ gp_Vec crossvec = vec1.Crossed(vec2);
+ vec1.Cross(crossvec);
+ gp_Dir dir(vec1);
+ curpos = myPntAttach.Translated(gp_Vec(dir)*myArrowSize);
+ }
+ }
+
+ return curpos;
+}
+
+//=======================================================================
+//function : ComputePosition
+//purpose : Computes the position of the "fix dimension" when the
+// fixed object is a vertex which is set at the intersection
+// of two curves.
+// The "dimension" is in the "middle" of the two edges.
+//=======================================================================
+
+gp_Pnt PrsDim_FixRelation::ComputePosition(const Handle(Geom_Curve)& curv,
+ const gp_Pnt& firstp,
+ const gp_Pnt& lastp) const
+{
+ //---------------------------------------------------------
+ // calculate the point of attach
+ //---------------------------------------------------------
+ gp_Pnt curpos;
+
+ if (curv->IsKind(STANDARD_TYPE(Geom_Circle))) {
+
+ Handle(Geom_Circle) gcirc = Handle(Geom_Circle)::DownCast(curv);
+ gp_Dir dir( gcirc->Location().XYZ() + myPntAttach.XYZ() );
+ gp_Vec transvec = gp_Vec(dir)*myArrowSize;
+ curpos = myPntAttach.Translated(transvec);
+
+ } //if (curv->IsKind(STANDARD_TYPE(Geom_Circle))
+
+ else {
+// gp_Pln pln(Component()->WorkingPlane()->Plane()->GetValue()->Pln());
+ gp_Pln pln(myPlane->Pln());
+ gp_Dir NormPln = pln.Axis().Direction();
+ gp_Vec vec(firstp,lastp);
+ vec.Cross( gp_Vec(NormPln));
+ vec.Normalize();
+ gp_Vec transvec = vec*myArrowSize;
+ curpos = myPntAttach.Translated(transvec);
+ gp_Ax1 RotAx( myPntAttach, NormPln);
+ curpos.Rotate(RotAx, M_PI/10);
+ }
+
+ return curpos;
+ }
+
+//=======================================================================
+//function : ComputeEdge
+//purpose : computes myPntAttach and the position of the presentation
+// when you fix an edge
+//=======================================================================
+
+void PrsDim_FixRelation::ComputeEdge(const TopoDS_Edge& FixEdge, gp_Pnt& curpos)
+{
+ Handle(Geom_Curve) curEdge;
+ gp_Pnt ptbeg,ptend;
+ if (!PrsDim::ComputeGeometry(FixEdge,curEdge,ptbeg,ptend)) return;
+
+ //---------------------------------------------------------
+ // calcul du point de positionnement du symbole 'fix'
+ //---------------------------------------------------------
+ //--> In case of a straight line
+ if (curEdge->IsKind(STANDARD_TYPE(Geom_Line))){
+ gp_Lin glin = Handle(Geom_Line)::DownCast(curEdge)->Lin();
+ Standard_Real pfirst(ElCLib::Parameter(glin,ptbeg));
+ Standard_Real plast(ElCLib::Parameter(glin,ptend));
+ ComputeLinePosition(glin, curpos, pfirst, plast);
+ }
+
+ //--> In case of a circle
+ else if (curEdge->IsKind(STANDARD_TYPE(Geom_Circle))) {
+ gp_Circ gcirc = Handle(Geom_Circle)::DownCast(curEdge)->Circ();
+ Standard_Real pfirst, plast;
+ BRepAdaptor_Curve cu(FixEdge);
+ pfirst = cu.FirstParameter();
+ plast = cu.LastParameter();
+ ComputeCirclePosition(gcirc, curpos, pfirst, plast);
+ }
+
+ else
+ return;
+
+}
+
+//=======================================================================
+//function : ComputeLinePosition
+//purpose : compute the values of myPntAttach and the position <pos> of
+// the symbol when the fixed edge has a geometric support equal
+// to a line.
+//=======================================================================
+
+void PrsDim_FixRelation::ComputeLinePosition(const gp_Lin& glin,
+ gp_Pnt& pos,
+ Standard_Real& pfirst,
+ Standard_Real& plast)
+{
+ if (myAutomaticPosition) {
+ // point of attach is chosen as middle of the segment
+ myPntAttach = ElCLib::Value((pfirst+ plast)/2, glin);
+
+ gp_Dir norm = myPlane ->Axis().Direction();
+
+ norm.Cross(glin.Position().Direction());
+ pos = myPntAttach.Translated(gp_Vec(norm)*myArrowSize);
+ myAutomaticPosition = Standard_True;
+ } // if (myAutomaticPosition)
+
+ else {
+ pos = myPosition;
+ Standard_Real linparam = ElCLib::Parameter(glin, pos);
+
+ // case if the projection of position is located between 2 vertices
+ // de l'edge
+ if ( (linparam >= pfirst) && (linparam <= plast) )
+ myPntAttach = ElCLib::Value(linparam,glin);
+
+ // case if the projection of Position is outside of the limits
+ // of the edge : the point closest to the projection is chosen
+ // as the attach point
+ else {
+ Standard_Real pOnLin;
+ if (linparam > plast)
+ pOnLin = plast;
+ else
+ pOnLin = pfirst;
+ myPntAttach = ElCLib::Value(pOnLin,glin);
+ gp_Dir norm = myPlane->Axis().Direction();
+
+ norm.Cross(glin.Position().Direction());
+ gp_Lin lsup(myPntAttach, norm);
+ Standard_Real parpos = ElCLib::Parameter(lsup,myPosition);
+ pos = ElCLib::Value(parpos,lsup);
+ }
+
+ }
+ myPosition = pos;
+}
+
+//=======================================================================
+//function : ComputeCirclePosition
+//purpose : compute the values of myPntAttach and the position <pos> of
+// the symbol when the fixed edge has a geometric support equal
+// to a circle.
+//=======================================================================
+
+void PrsDim_FixRelation::ComputeCirclePosition(
+ const gp_Circ& gcirc,
+ gp_Pnt& pos,
+ Standard_Real& pfirst,
+ Standard_Real& plast)
+{
+ // readjust parametres on the circle
+ if (plast > 2*M_PI ) {
+ Standard_Real nbtours = Floor(plast / (2*M_PI));
+ plast -= nbtours*2*M_PI;
+ pfirst -= nbtours*2*M_PI;
+ }
+
+ if (myAutomaticPosition) {
+ // the point attach is the "middle" of the segment (relatively
+ // to the parametres of start and end vertices of the edge
+
+ Standard_Real circparam = (pfirst + plast)/2.;
+
+ if ( !InDomain(pfirst,plast,circparam)) {
+ Standard_Real otherpar = circparam + M_PI;
+ if (otherpar > 2*M_PI) otherpar -= 2*M_PI;
+ circparam = otherpar;
+ }
+
+ myPntAttach = ElCLib::Value(circparam, gcirc );
+
+ gp_Vec dir( gcirc.Location().XYZ(), myPntAttach.XYZ() );
+ dir.Normalize();
+ gp_Vec transvec = dir*myArrowSize;
+ pos = myPntAttach.Translated(transvec);
+ myPosition = pos;
+ myAutomaticPosition = Standard_True;
+ } // if (myAutomaticPosition)
+
+ else {
+ // case if the projection of myPosition is outside of 2
+ // vertices of the edge. In this case the parameter is readjusted
+ // in the valid part of the circle
+ pos = myPosition;
+
+ Standard_Real circparam = ElCLib::Parameter(gcirc, pos);
+
+ if ( !InDomain(pfirst,plast,circparam)) {
+ Standard_Real otherpar = circparam + M_PI;
+ if (otherpar > 2*M_PI) otherpar -= 2*M_PI;
+ circparam = otherpar;
+ }
+
+ myPntAttach = ElCLib::Value(circparam,gcirc);
+ }
+}
+
+//=======================================================================
+//function : ConnectedEdges
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_FixRelation::ConnectedEdges(const TopoDS_Wire& WIRE,
+ const TopoDS_Vertex& V,
+ TopoDS_Edge& E1,
+ TopoDS_Edge& E2)
+{
+ TopTools_IndexedDataMapOfShapeListOfShape vertexMap;
+ TopExp::MapShapesAndAncestors (WIRE,TopAbs_VERTEX,TopAbs_EDGE,vertexMap);
+
+ Standard_Boolean found(Standard_False);
+ TopoDS_Vertex theVertex;
+ for (Standard_Integer i=1; i<=vertexMap.Extent() && !found; i++) {
+ if (vertexMap.FindKey(i).IsSame(V)) {
+ theVertex = TopoDS::Vertex(vertexMap.FindKey(i));
+ found = Standard_True;
+ }
+ }
+ if (!found) {
+ E1.Nullify();
+ E2.Nullify();
+ return Standard_False;
+ }
+
+ TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(theVertex));
+ if (iterator.More()) {
+ E1 = TopoDS::Edge(iterator.Value());
+ BRepAdaptor_Curve curv(E1);
+ iterator.Next();
+ }
+ else {
+ E1.Nullify();
+ return Standard_False;
+ }
+
+ if (iterator.More()) {
+ E2 = TopoDS::Edge(iterator.Value());
+ BRepAdaptor_Curve curv(E2);
+ iterator.Next();
+ }
+ else {
+ E2.Nullify();
+ return Standard_False;
+ }
+
+ if (iterator.More()) {
+ E1.Nullify();
+ E2.Nullify();
+ return Standard_False;
+ }
+ return Standard_True;
+}
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Flore Lantheaume/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_FixRelation_HeaderFile
+#define _PrsDim_FixRelation_HeaderFile
+
+#include <TopoDS_Wire.hxx>
+#include <PrsDim_Relation.hxx>
+
+class Geom_Plane;
+
+DEFINE_STANDARD_HANDLE(PrsDim_FixRelation, PrsDim_Relation)
+
+//! Constructs and manages a constraint by a fixed
+//! relation between two or more interactive datums. This
+//! constraint is represented by a wire from a shape -
+//! point, vertex, or edge - in the first datum and a
+//! corresponding shape in the second.
+//! Warning: This relation is not bound with any kind of parametric
+//! constraint : it represents the "status" of an parametric
+//! object.
+class PrsDim_FixRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_FixRelation, PrsDim_Relation)
+public:
+
+ //! initializes the vertex aShape, the
+ //! plane aPlane and the wire aWire, which connects
+ //! the two vertices in a fixed relation.
+ Standard_EXPORT PrsDim_FixRelation(const TopoDS_Shape& aShape, const Handle(Geom_Plane)& aPlane, const TopoDS_Wire& aWire);
+
+ //! initializes the vertex aShape, the
+ //! plane aPlane and the wire aWire, the position
+ //! aPosition, the arrow size anArrowSize and the
+ //! wire aWire, which connects the two vertices in a fixed relation.
+ Standard_EXPORT PrsDim_FixRelation(const TopoDS_Shape& aShape, const Handle(Geom_Plane)& aPlane, const TopoDS_Wire& aWire, const gp_Pnt& aPosition, const Standard_Real anArrowSize = 0.01);
+
+ //! initializes the edge aShape and the plane aPlane.
+ Standard_EXPORT PrsDim_FixRelation(const TopoDS_Shape& aShape, const Handle(Geom_Plane)& aPlane);
+
+ //! initializes the edge aShape, the
+ //! plane aPlane, the position aPosition and the arrow
+ //! size anArrowSize.
+ Standard_EXPORT PrsDim_FixRelation(const TopoDS_Shape& aShape, const Handle(Geom_Plane)& aPlane, const gp_Pnt& aPosition, const Standard_Real anArrowSize = 0.01);
+
+ //! Returns the wire which connects vertices in a fixed relation.
+ const TopoDS_Wire& Wire() { return myWire; }
+
+ //! Constructs the wire aWire. This connects vertices
+ //! which are in a fixed relation.
+ void SetWire (const TopoDS_Wire& aWire) { myWire = aWire; }
+
+ //! Returns true if the Interactive Objects in the relation
+ //! are movable.
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ //! computes the presentation for <myFixShape> if it's a
+ //! vertex.
+ Standard_EXPORT void ComputeVertex (const TopoDS_Vertex& FixVertex, gp_Pnt& curpos);
+
+ Standard_EXPORT gp_Pnt ComputePosition (const Handle(Geom_Curve)& curv1, const Handle(Geom_Curve)& curv2, const gp_Pnt& firstp1, const gp_Pnt& lastp1, const gp_Pnt& firstp2, const gp_Pnt& lastp2) const;
+
+ Standard_EXPORT gp_Pnt ComputePosition (const Handle(Geom_Curve)& curv, const gp_Pnt& firstp, const gp_Pnt& lastp) const;
+
+ //! computes the presentation for <myFixShape> if it's a
+ //! edge.
+ Standard_EXPORT void ComputeEdge (const TopoDS_Edge& FixEdge, gp_Pnt& curpos);
+
+ Standard_EXPORT void ComputeLinePosition (const gp_Lin& glin, gp_Pnt& pos, Standard_Real& pfirst, Standard_Real& plast);
+
+ Standard_EXPORT void ComputeCirclePosition (const gp_Circ& gcirc, gp_Pnt& pos, Standard_Real& pfirst, Standard_Real& plast);
+
+ Standard_EXPORT static Standard_Boolean ConnectedEdges (const TopoDS_Wire& aWire, const TopoDS_Vertex& aVertex, TopoDS_Edge& Edge1, TopoDS_Edge& Edge2);
+
+private:
+
+ TopoDS_Wire myWire;
+ gp_Pnt myPntAttach;
+
+};
+
+#endif // _PrsDim_FixRelation_HeaderFile
--- /dev/null
+// Created on: 1997-03-03
+// Created by: Jean-Pierre COMBE
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_IdenticRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <AIS_Shape.hxx>
+#include <BRep_Tool.hxx>
+#include <DsgPrs_IdenticPresentation.hxx>
+#include <ElCLib.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Precision.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveCurve.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_ListIteratorOfListOfTransient.hxx>
+#include <TopAbs.hxx>
+#include <TopExp.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_IdenticRelation, PrsDim_Relation)
+
+// jfa 15/10/2000
+static Standard_Real Modulo2PI(const Standard_Real ANGLE)
+{
+ if ( ANGLE < 0 ) return Modulo2PI(ANGLE + 2*M_PI);
+ else if ( ANGLE >= 2*M_PI ) return Modulo2PI(ANGLE - 2*M_PI);
+ return ANGLE;
+}
+
+static Standard_Boolean IsEqual2PI(const Standard_Real angle1,
+ const Standard_Real angle2, const Standard_Real precision)
+{
+ Standard_Real diff = Abs(angle1-angle2);
+ if ( diff < precision ) return Standard_True;
+ else if ( Abs(diff-2*M_PI) < precision ) return Standard_True;
+ return Standard_False;
+}
+// jfa 15/10/2000 end
+
+//=======================================================================
+//function : PrsDim_Sort
+//purpose : sort an array of parameters <tab1> in increasing order
+// updates <tab2> and <tab3> according to <tab1>
+//=======================================================================
+static void PrsDim_Sort(Standard_Real tab1[4],
+ gp_Pnt tab2[4],
+ Standard_Integer tab3[4])
+{
+ Standard_Boolean found = Standard_True;
+ Standard_Real cur; gp_Pnt cur1; Standard_Integer cur2;
+
+ while (found) {
+ found = Standard_False;
+ for (Standard_Integer i=0; i< 3; i++) {
+ if (tab1[i+1] < tab1[i]) {
+ found = Standard_True;
+ cur = tab1[i]; cur1 = tab2[i]; cur2 = tab3[i];
+ tab1[i] = tab1[i+1]; tab2[i] = tab2[i+1]; tab3[i] = tab3[i+1];
+ tab1[i+1] = cur; tab2[i+1] = cur1; tab3[i+1] = cur2;
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : ConnectedEdges
+//purpose :
+//=======================================================================
+static Standard_Boolean ConnectedEdges(const TopoDS_Wire& WIRE,
+ const TopoDS_Vertex& V,
+ TopoDS_Edge& E1,
+ TopoDS_Edge& E2)
+{
+ TopTools_IndexedDataMapOfShapeListOfShape vertexMap;
+ TopExp::MapShapesAndAncestors (WIRE,TopAbs_VERTEX,TopAbs_EDGE,vertexMap);
+
+ Standard_Boolean found(Standard_False);
+ TopoDS_Vertex theVertex;
+ for (Standard_Integer i=1; i<=vertexMap.Extent() && !found; i++) {
+ if (vertexMap.FindKey(i).IsSame(V)) {
+ theVertex = TopoDS::Vertex(vertexMap.FindKey(i));
+ found = Standard_True;
+ }
+ }
+ if (!found) {
+ E1.Nullify();
+ E2.Nullify();
+ return Standard_False;
+ }
+
+ TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(theVertex));
+ if (iterator.More()) {
+ E1 = TopoDS::Edge(iterator.Value());
+ iterator.Next();
+ }
+ else {
+ E1.Nullify();
+ return Standard_False;
+ }
+
+ if (iterator.More()) {
+ E2 = TopoDS::Edge(iterator.Value());
+ iterator.Next();
+ }
+ else {
+ E2.Nullify();
+ return Standard_False;
+ }
+
+ if (iterator.More()) {
+ E1.Nullify();
+ E2.Nullify();
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+// jfa 16/10/2000
+//=======================================================================
+//function : ComputeAttach
+//purpose : Compute a point on the arc of <thecirc>
+// between <aFAttach> and <aSAttach>
+// corresponding to <aPosition>
+// Returns result into <aPosition>
+// Note : This function is to be used only in the case of circles.
+// The <aPosition> parameter is in/out.
+//=======================================================================
+static Standard_Boolean ComputeAttach(const gp_Circ& thecirc,
+ const gp_Pnt& aFAttach,
+ const gp_Pnt& aSAttach,
+ gp_Pnt& aPosition)
+{
+ gp_Pnt curpos = aPosition;
+
+ // Case of confusion between the current position and the center
+ // of the circle -> we move the current position
+ Standard_Real confusion (Precision::Confusion());
+ gp_Pnt aCenter = thecirc.Location();
+ if ( aCenter.Distance(curpos) <= confusion )
+ {
+ gp_Vec vprec(aCenter, aFAttach);
+ vprec.Normalize();
+ curpos.Translate(vprec*1e-5);
+ }
+
+ Standard_Real pcurpos = ElCLib::Parameter(thecirc,curpos);
+ Standard_Real pFAttach = ElCLib::Parameter(thecirc,aFAttach);
+ Standard_Real pSAttach = ElCLib::Parameter(thecirc,aSAttach);
+
+ Standard_Real pSAttachM = pSAttach;
+ Standard_Real deltap = pSAttachM - pFAttach;
+ if ( deltap < 0 )
+ {
+ deltap += 2 * M_PI;
+ pSAttachM += 2 * M_PI;
+ }
+ pSAttachM -= pFAttach;
+
+ Standard_Real pmiddleout = pSAttachM/2.0 + M_PI;
+
+ Standard_Real pcurpos1 = pcurpos;
+ // define where curpos lays
+ if ( pcurpos1 < pFAttach )
+ {
+ pcurpos1 = pcurpos1 + 2 * M_PI - pFAttach;
+ if ( pcurpos1 > pSAttachM ) // out
+ {
+ if ( pcurpos1 > pmiddleout ) pcurpos = pFAttach;
+ else pcurpos = pSAttach;
+ }
+ }
+ else if ( pcurpos1 > (pFAttach + deltap) ) // out
+ {
+ pcurpos1 -= pFAttach;
+ if ( pcurpos1 > pmiddleout ) pcurpos = pFAttach;
+ else pcurpos = pSAttach;
+ }
+
+ aPosition = ElCLib::Value(pcurpos,thecirc);
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeAttach
+//purpose : Compute a point on the arc of ellipse <theEll>
+// between <aFAttach> and <aSAttach>
+// corresponding to <aPosition>
+// Returns result into <aPosition>
+// Note : This function is to be used only in the case of ellipses.
+// The <aPosition> parameter is in/out.
+//=======================================================================
+static Standard_Boolean ComputeAttach(const gp_Elips& theEll,
+ const gp_Pnt& aFAttach,
+ const gp_Pnt& aSAttach,
+ gp_Pnt& aPosition)
+{
+ gp_Pnt curpos = aPosition;
+
+ // Case of confusion between the current position and the center
+ // of the circle -> we move the current position
+ Standard_Real confusion (Precision::Confusion());
+ gp_Pnt aCenter = theEll.Location();
+ if ( aCenter.Distance(curpos) <= confusion )
+ {
+ gp_Vec vprec(aCenter, aFAttach);
+ vprec.Normalize();
+ curpos.Translate(vprec*1e-5);
+ }
+
+// for ellipses it's not good Standard_Real pcurpos = ElCLib::Parameter(theEll,curpos);
+ Handle(Geom_Ellipse) theEllg = new Geom_Ellipse(theEll);
+ GeomAPI_ProjectPointOnCurve aProj (curpos, theEllg);
+ Standard_Real pcurpos = aProj.LowerDistanceParameter();
+
+ Standard_Real pFAttach = ElCLib::Parameter(theEll,aFAttach);
+ Standard_Real pSAttach = ElCLib::Parameter(theEll,aSAttach);
+
+ Standard_Real pSAttachM = pSAttach;
+ Standard_Real deltap = pSAttachM - pFAttach;
+ if ( deltap < 0 )
+ {
+ deltap += 2 * M_PI;
+ pSAttachM += 2 * M_PI;
+ }
+ pSAttachM -= pFAttach;
+
+ Standard_Real pmiddleout = pSAttachM/2.0 + M_PI;
+
+ Standard_Real pcurpos1 = pcurpos;
+ // define where curpos lays
+ if ( pcurpos1 < pFAttach )
+ {
+ pcurpos1 = pcurpos1 + 2 * M_PI - pFAttach;
+ if ( pcurpos1 > pSAttachM ) // out
+ {
+ if ( pcurpos1 > pmiddleout ) pcurpos = pFAttach;
+ else pcurpos = pSAttach;
+ }
+ }
+ else if ( pcurpos1 > (pFAttach + deltap) ) // out
+ {
+ pcurpos1 -= pFAttach;
+ if ( pcurpos1 > pmiddleout ) pcurpos = pFAttach;
+ else pcurpos = pSAttach;
+ }
+
+ aPosition = ElCLib::Value(pcurpos,theEll);
+ return Standard_True;
+}
+// jfa 16/10/2000 end
+
+//=======================================================================
+//function : PrsDim_IdenticRelation
+//purpose :
+//=======================================================================
+PrsDim_IdenticRelation::PrsDim_IdenticRelation(const TopoDS_Shape& FirstShape,
+ const TopoDS_Shape& SecondShape,
+ const Handle(Geom_Plane)& aPlane)
+ :isCircle(Standard_False)
+{
+ myFShape = FirstShape;
+ mySShape = SecondShape;
+ myPlane = aPlane;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_IdenticRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aprs,
+ const Standard_Integer)
+{
+ switch ( myFShape.ShapeType() ) {
+
+ case TopAbs_VERTEX:
+ {
+ switch ( mySShape.ShapeType() ) {
+ case TopAbs_VERTEX:
+ {
+ ComputeTwoVerticesPresentation(aprs);
+ }
+ break;
+ case TopAbs_EDGE:
+ {
+ ComputeOneEdgeOVertexPresentation(aprs);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+
+ case TopAbs_EDGE:
+ {
+ switch ( mySShape.ShapeType() ) {
+ case TopAbs_VERTEX:
+ {
+ ComputeOneEdgeOVertexPresentation(aprs);
+ }
+ break;
+ case TopAbs_EDGE:
+ {
+ ComputeTwoEdgesPresentation(aprs);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ default: break;
+ }
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose : function used to compute the selection associated to the
+// "identic" presentation
+// note : if we are in the case of lines, we create a segment between
+// myFAttach and mySAttach. In the case of Circles, we create
+// an arc of circle between the sames points. We Add a segment
+// to link Position to its projection on the curve described
+// before.
+//=======================================================================
+
+void PrsDim_IdenticRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer)
+{
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+
+ Handle(Select3D_SensitiveSegment) seg;
+ // attachement point of the segment linking position to the curve
+ gp_Pnt attach;
+ Standard_Real confusion (Precision::Confusion());
+
+ if ( myFAttach.IsEqual(mySAttach, confusion) )
+ {
+ attach = myFAttach;
+ }
+ else
+ {
+// jfa 24/10/2000
+ if ( myFShape.ShapeType() == TopAbs_EDGE )
+ {
+ Handle(Geom_Curve) curv1,curv2;
+ gp_Pnt firstp1,lastp1,firstp2,lastp2;
+ Standard_Boolean isInfinite1,isInfinite2;
+ Handle(Geom_Curve) extCurv;
+ if ( !PrsDim::ComputeGeometry(TopoDS::Edge(myFShape),TopoDS::Edge(mySShape),
+ myExtShape,curv1,curv2,
+ firstp1,lastp1,firstp2,lastp2,
+ extCurv,isInfinite1,isInfinite2,myPlane) ) return;
+
+ if ( isCircle ) // case of Circles
+ {
+ Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv1);
+ Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),myFAttach);
+ Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),mySAttach);
+ Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
+
+ Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecu);
+ aSelection->Add(scurv);
+
+ attach = myPosition;
+ ComputeAttach(thecirc->Circ(),myFAttach,mySAttach,attach);
+ }
+ else if ( curv1->IsInstance(STANDARD_TYPE(Geom_Ellipse)) ) // case of ellipses
+ {
+ Handle(Geom_Ellipse) theEll = Handle(Geom_Ellipse)::DownCast (curv1);
+
+ Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),myFAttach);
+ Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),mySAttach);
+ Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
+
+ Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecu);
+ aSelection->Add(scurv);
+
+ attach = myPosition;
+ ComputeAttach(theEll->Elips(),myFAttach,mySAttach,attach);
+ }
+ else if ( curv1->IsInstance(STANDARD_TYPE(Geom_Line)) ) // case of Lines
+ {
+ seg = new Select3D_SensitiveSegment(own, myFAttach, mySAttach);
+ aSelection->Add(seg);
+
+ //attach = projection of Position() on the curve;
+ gp_Vec v1 (myFAttach, mySAttach);
+ gp_Vec v2 (myFAttach, myPosition);
+ if ( v1.IsParallel(v2, Precision::Angular()) )
+ {
+ attach = mySAttach;
+ }
+ else
+ {
+ gp_Lin ll (myFAttach, gp_Dir(v1));
+ attach = ElCLib::Value(ElCLib::Parameter(ll,myPosition), ll);
+ }
+ }
+ else return;
+ }
+// else if ( myFShape.ShapeType() == TopAbs_VERTEX )
+// {
+// }
+// jfa 24/10/2000 end
+ }
+
+ // Creation of the segment linking the attachement point with the
+ // position
+ if ( !attach.IsEqual(myPosition, confusion) )
+ {
+ seg = new Select3D_SensitiveSegment(own, attach, myPosition);
+ aSelection->Add(seg);
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoEdgesPresentation
+//purpose :
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeTwoEdgesPresentation(const Handle(Prs3d_Presentation)& aPrs)
+{
+ Handle(Geom_Curve) curv1,curv2;
+ gp_Pnt firstp1,lastp1,firstp2,lastp2;
+ Standard_Boolean isInfinite1,isInfinite2;
+
+ Handle(Geom_Curve) extCurv;
+ if (!PrsDim::ComputeGeometry(TopoDS::Edge(myFShape),
+ TopoDS::Edge(mySShape),
+ myExtShape,
+ curv1,
+ curv2,
+ firstp1,
+ lastp1,
+ firstp2,
+ lastp2,
+ extCurv,
+ isInfinite1,isInfinite2,
+ myPlane))
+ return;
+ aPrs->SetInfiniteState((isInfinite1 || isInfinite2) && myExtShape != 0);
+
+ // Treatement of the case of lines
+ if ( curv1->IsInstance(STANDARD_TYPE(Geom_Line)) && curv2->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
+ // we take the line curv1 like support
+ Handle(Geom_Line) thelin;
+ if (isInfinite1 && !isInfinite2) thelin = Handle(Geom_Line)::DownCast (curv2);
+ else if (!isInfinite1 && isInfinite2) thelin = Handle(Geom_Line)::DownCast (curv1);
+ else thelin = Handle(Geom_Line)::DownCast (curv1);
+ ComputeTwoLinesPresentation(aPrs, thelin, firstp1, lastp1, firstp2, lastp2, isInfinite1, isInfinite2);
+ }
+
+ // Treatement of the case of circles
+ else if ( curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) && curv2->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
+ //gp_Pnt curpos;
+ isCircle = Standard_True; // useful for ComputeSelection
+ Handle(Geom_Circle) thecirc (Handle(Geom_Circle)::DownCast (curv1));
+ ComputeTwoCirclesPresentation(aPrs, thecirc, firstp1, lastp1, firstp2, lastp2);
+ }
+
+ // jfa 10/10/2000
+ // Treatement of the case of ellipses
+ else if ( curv1->IsInstance(STANDARD_TYPE(Geom_Ellipse)) && curv2->IsInstance(STANDARD_TYPE(Geom_Ellipse)) )
+ {
+ Handle(Geom_Ellipse) theEll (Handle(Geom_Ellipse)::DownCast (curv1));
+ ComputeTwoEllipsesPresentation(aPrs, theEll, firstp1, lastp1, firstp2, lastp2);
+ }
+ // jfa 10/10/2000 end
+ else
+ return;
+
+ // Calculate presentation of projected edges
+ if ( (myExtShape != 0) && !extCurv.IsNull()) {
+ if (myExtShape == 1 )
+ ComputeProjEdgePresentation(aPrs, TopoDS::Edge(myFShape), curv1, firstp1, lastp1);
+ else
+ ComputeProjEdgePresentation(aPrs, TopoDS::Edge(mySShape), curv2, firstp2, lastp2);
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoLinesPresentation
+//purpose : Compute the presentation of the 'identic' constraint
+// between two lines ( which are equal)
+//input : <thelin> : the
+// <firstp1>: first extremity of the 1st curve of the constraint
+// <lastp1> : last extremity of the 1st curve of the constraint
+// <firstp2>: first extremity of the 2nd curve of the constraint
+// <lastp2> :last extremity of the 2nd curve of the constraint
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeTwoLinesPresentation(const Handle(Prs3d_Presentation)& aPrs,
+ const Handle(Geom_Line)& thelin,
+ gp_Pnt& firstp1,
+ gp_Pnt& lastp1,
+ gp_Pnt& firstp2,
+ gp_Pnt& lastp2,
+ const Standard_Boolean isInfinite1,
+ const Standard_Boolean isInfinite2)
+{
+ if (isInfinite1 && isInfinite2) {
+ if ( myAutomaticPosition ) {
+ myFAttach = mySAttach = thelin->Lin().Location();
+ gp_Pnt curpos;
+ gp_Pln pln(myPlane->Pln());
+ gp_Dir dir(pln.XAxis().Direction());
+ gp_Vec transvec = gp_Vec(dir)*myArrowSize;
+ curpos = myFAttach.Translated(transvec);
+ myPosition = curpos;
+ myAutomaticPosition = Standard_True;
+ }
+ else {
+ myFAttach = mySAttach = ElCLib::Value(ElCLib::Parameter(thelin->Lin(),myPosition),thelin->Lin());
+ }
+ TCollection_ExtendedString vals(" ==");
+ DsgPrs_IdenticPresentation::Add(aPrs,
+ myDrawer,
+ vals,
+ myFAttach,
+ myPosition);
+ }
+ else {
+ // Computation of the parameters of the 4 points on the line <thelin>
+ Standard_Real pf1, pf2, pl1, pl2;
+
+ pf1 = ElCLib::Parameter(thelin->Lin(), firstp1);
+ pl1 = ElCLib::Parameter(thelin->Lin(), lastp1);
+
+ pf2 = ElCLib::Parameter(thelin->Lin(), firstp2);
+ pl2 = ElCLib::Parameter(thelin->Lin(), lastp2);
+
+ if (isInfinite1) {
+ pf1 = pf2;
+ pl1 = pl2;
+ firstp1 = firstp2;
+ lastp1 = lastp2;
+ }
+ else if (isInfinite2) {
+ pf2 = pf1;
+ pl2 = pl1;
+ firstp2 = firstp1;
+ lastp2 = lastp1;
+ }
+
+ Standard_Real tabRang1[4]; // array taht contains the parameters of the 4 points
+ // ordered by increasing abscisses.
+
+ gp_Pnt tabRang2[4]; // array containing the points corresponding to the
+ // parameters in tabRang1
+
+ Standard_Integer tabRang3[4]; // array containing the number of the curve( 1 or 2)
+ // of which belongs each point of tabRang2
+
+ // Filling of the arrays
+ tabRang1[0] = pf1; tabRang2[0] = firstp1; tabRang3[0] = 1;
+ tabRang1[1] = pf2; tabRang2[1] = firstp2; tabRang3[1] = 2;
+ tabRang1[2] = pl1; tabRang2[2] = lastp1; tabRang3[2] = 1;
+ tabRang1[3] = pl2; tabRang2[3] = lastp2; tabRang3[3] = 2;
+
+ // Sort of the array of parameters (tabRang1)
+ PrsDim_Sort(tabRang1, tabRang2, tabRang3);
+
+ // Computation of myFAttach and mySAttach according to the
+ // position of the 2 linear edges
+ gp_Pnt curpos;
+ gp_Pnt middle;
+
+ if ( (tabRang1[0] == tabRang1[1]) && (tabRang1[2] == tabRang1[3]) ) {
+ middle.SetXYZ((tabRang2[1].XYZ() + tabRang2[2].XYZ())/2. );
+ Standard_Real pmiddle = (tabRang1[1] + tabRang1[2]) / 2.;
+ Standard_Real delta = (tabRang1[3] - tabRang1[0])/ 5.;
+ myFAttach = ElCLib::Value(pmiddle-delta, thelin->Lin());
+ mySAttach = ElCLib::Value(pmiddle+delta, thelin->Lin());
+ }
+
+ else if ( tabRang1[1] == tabRang1[2] ) {
+ middle = tabRang2[1];
+ Standard_Real delta1 = tabRang1[1] - tabRang1[0];
+ Standard_Real delta2 = tabRang1[3] - tabRang1[2];
+ if ( delta1 > delta2 ) delta1 = delta2;
+ myFAttach = ElCLib::Value(tabRang1[1]-delta1/2., thelin->Lin());
+ mySAttach = ElCLib::Value(tabRang1[1]+delta1/2., thelin->Lin());
+ }
+
+ // Case of 2 disconnected segments -> the symbol completes the gap
+ // between the 2 edges
+ //--------------------------------
+ else if ( (tabRang3[0] == tabRang3[1]) && (tabRang1[1] != tabRang1[2])) {
+ middle.SetXYZ((tabRang2[1].XYZ() + tabRang2[2].XYZ())/2. );
+ myFAttach = tabRang2[1];
+ mySAttach = tabRang2[2];
+ }
+ else if ( (tabRang3[0] != tabRang3[1])
+ && (tabRang3[1] != tabRang3[2]) // Intersection
+ && (tabRang1[1] != tabRang1[2]) ) {
+ middle.SetXYZ((tabRang2[1].XYZ() + tabRang2[2].XYZ())/2. );
+ myFAttach = tabRang2[1];
+ mySAttach = tabRang2[2];
+ }
+ else { // Inclusion
+ myFAttach.SetXYZ((tabRang2[0].XYZ() + tabRang2[1].XYZ())/2. );
+ mySAttach.SetXYZ((tabRang2[1].XYZ() + tabRang2[2].XYZ())/2. );
+ middle.SetXYZ( (myFAttach.XYZ() + mySAttach.XYZ() )/2.);
+ }
+
+
+ if ( myAutomaticPosition ) {
+
+ gp_Vec vtrans(myFAttach, mySAttach);
+ vtrans.Normalize();
+ vtrans.Cross(gp_Vec(myPlane->Pln().Axis().Direction()));
+ vtrans *= ComputeSegSize();
+ curpos = middle.Translated(vtrans);
+ myPosition = curpos;
+ myAutomaticPosition = Standard_True;
+ }
+
+ else {
+
+ curpos = myPosition;
+ Standard_Real pcurpos = ElCLib::Parameter(thelin->Lin() ,curpos);
+ Standard_Real dist = thelin->Lin().Distance(curpos);
+ gp_Pnt proj = ElCLib::Value( pcurpos, thelin->Lin());
+ gp_Vec trans;
+ Standard_Real confusion(Precision::Confusion());
+ if ( dist >= confusion ) {
+ trans = gp_Vec(proj, curpos);
+ trans.Normalize();
+ }
+ Standard_Real pf = ElCLib::Parameter(thelin->Lin() ,myFAttach);
+ Standard_Real pl = ElCLib::Parameter(thelin->Lin() ,mySAttach);
+ if ( pcurpos <= pf ) {
+ pcurpos = pf + 1e-5;
+ curpos = ElCLib::Value( pcurpos, thelin->Lin());
+ if ( dist >= confusion ) curpos.Translate(trans*dist);
+ }
+ else if ( pcurpos >= pl ) {
+ pcurpos = pl - 1e-5;
+ curpos = ElCLib::Value( pcurpos, thelin->Lin());
+ if ( dist >= confusion ) curpos.Translate(trans*dist);
+ }
+ SetPosition(curpos);
+ }
+
+ // Display of the presentation
+ TCollection_ExtendedString vals(" ==");
+ DsgPrs_IdenticPresentation::Add(aPrs,
+ myDrawer,
+ vals,
+ myFAttach,
+ mySAttach,
+ curpos);
+ }
+}
+
+// jfa 17/10/2000
+//=======================================================================
+//function : ComputeTwoCirclesPresentation
+//purpose : Compute the presentation of the 'identic' constraint
+// between two circles ( which are equal)
+//input : <thecirc>: the circle
+// <firstp1>: first extremity of the 1st curve of the constraint
+// <lastp1> : last extremity of the 1st curve of the constraint
+// <firstp2>: first extremity of the 2nd curve of the constraint
+// <lastp2> :last extremity of the 2nd curve of the constraint
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeTwoCirclesPresentation(const Handle(Prs3d_Presentation)& aPrs,
+ const Handle(Geom_Circle)& thecirc,
+ const gp_Pnt& firstp1,
+ const gp_Pnt& lastp1,
+ const gp_Pnt& firstp2,
+ const gp_Pnt& lastp2)
+{
+ Standard_Real confusion (Precision::Confusion());
+
+ // Searching of complete circles
+ Standard_Boolean circ1complete = (firstp1.IsEqual(lastp1, confusion));
+ Standard_Boolean circ2complete = (firstp2.IsEqual(lastp2, confusion));
+
+ myCenter = thecirc->Location();
+ Standard_Real aSegSize = thecirc->Radius()/5.0;
+ Standard_Real rad = M_PI / 5.0;
+
+ // I. Case of 2 complete circles
+ if ( circ1complete && circ2complete )
+ {
+ if (myAutomaticPosition)
+ {
+ Standard_Real pfirst1 = ElCLib::Parameter(thecirc->Circ(), firstp1);
+ myFAttach = ElCLib::Value(Modulo2PI(pfirst1-rad), thecirc->Circ());
+ mySAttach = ElCLib::Value(Modulo2PI(pfirst1+rad), thecirc->Circ());
+
+ gp_Pnt curpos = ElCLib::Value(pfirst1,thecirc->Circ());
+ gp_Vec vtrans(myCenter, curpos);
+ vtrans.Normalize();
+ vtrans *= aSegSize;
+ curpos.Translate(vtrans);
+ myPosition = curpos;
+ }
+ else ComputeNotAutoCircPresentation(thecirc);
+ }
+
+ // II. Case of one complete circle and one arc
+ else if ( (circ1complete && !circ2complete) || (!circ1complete && circ2complete) )
+ {
+ gp_Pnt firstp, lastp;
+ if ( circ1complete && !circ2complete)
+ {
+ firstp = firstp2;
+ lastp = lastp2;
+ }
+ else
+ {
+ firstp = firstp1;
+ lastp = lastp1;
+ }
+
+ if (myAutomaticPosition)
+ {
+ ComputeAutoArcPresentation(thecirc, firstp, lastp);
+ }
+ else
+ {
+ ComputeNotAutoArcPresentation(thecirc, firstp, lastp);
+ }
+ }
+
+ // III and IV. Case of two arcs
+ else if ( !circ1complete && !circ2complete )
+ {
+ // We project all the points on the circle
+ Standard_Real pf1, pf2, pl1, pl2;
+ pf1 = ElCLib::Parameter(thecirc->Circ(), firstp1);
+ pf2 = ElCLib::Parameter(thecirc->Circ(), firstp2);
+ pl1 = ElCLib::Parameter(thecirc->Circ(), lastp1);
+ pl2 = ElCLib::Parameter(thecirc->Circ(), lastp2);
+
+ // III. Arcs with common ends
+ // III.1. First of one and last of another
+ if ( IsEqual2PI(pl1,pf2,confusion) || IsEqual2PI(pf1,pl2,confusion) )
+ {
+ gp_Pnt curpos(0.,0.,0.);
+ Standard_Real att=0.;
+ if ( IsEqual2PI(pl1,pf2,confusion) )
+ {
+ att = pl1;
+ curpos = lastp1;
+ }
+ else if ( IsEqual2PI(pf1,pl2,confusion) )
+ {
+ att = pf1;
+ curpos = firstp1;
+ }
+ Standard_Real maxrad = Min(Modulo2PI(pl1 - pf1),Modulo2PI(pl2 - pf2))*3/4;
+ if ( rad > maxrad ) rad = maxrad;
+ Standard_Real pFAttach = Modulo2PI(att - rad);
+ Standard_Real pSAttach = Modulo2PI(att + rad);
+ myFAttach = ElCLib::Value(pFAttach, thecirc->Circ());
+ mySAttach = ElCLib::Value(pSAttach, thecirc->Circ());
+ if ( myAutomaticPosition )
+ {
+ gp_Vec vtrans(myCenter,curpos);
+ vtrans.Normalize();
+ vtrans *= aSegSize;
+ curpos.Translate(vtrans);
+ myPosition = curpos;
+ }
+ }
+ // III.2. Two first or two last
+ else if ( IsEqual2PI(pf1,pf2,confusion) || IsEqual2PI(pl1,pl2,confusion) )
+ {
+ Standard_Real l1 = Modulo2PI(pl1 - pf1);
+ Standard_Real l2 = Modulo2PI(pl2 - pf2);
+ gp_Pnt firstp,lastp;
+ if ( l1 < l2 )
+ {
+ firstp = firstp1;
+ lastp = lastp1;
+ }
+ else
+ {
+ firstp = firstp2;
+ lastp = lastp2;
+ }
+
+ if ( myAutomaticPosition )
+ {
+ ComputeAutoArcPresentation(thecirc, firstp, lastp);
+ }
+ else
+ {
+ ComputeNotAutoArcPresentation(thecirc, firstp, lastp);
+ }
+ }
+ // IV. All others arcs (without common ends)
+ else
+ {
+ // order the parameters; first will be pf1
+ Standard_Real pl1m = Modulo2PI(pl1 - pf1);
+ Standard_Real pf2m = Modulo2PI(pf2 - pf1);
+ Standard_Real pl2m = Modulo2PI(pl2 - pf1);
+
+ Standard_Boolean case1 = Standard_False;
+ // 1 - not intersecting arcs
+ // 2 - intersecting arcs, but one doesn't contain another
+ // 3a - first arc contains the second one
+ // 3b - second arc contains the first one
+ // 4 - two intersections
+
+ gp_Pnt firstp, lastp;
+
+ if ( pl1m < pf2m ) // 1 or 2b or 3b
+ {
+ if ( pl1m < pl2m ) // 1 or 3b
+ {
+ if ( pl2m < pf2m ) // 3b
+ {
+ firstp = firstp1;
+ lastp = lastp1;
+ }
+ else // 1
+ {
+ case1 = Standard_True;
+ Standard_Real deltap1 = Modulo2PI(pf1 - pl2);
+ Standard_Real deltap2 = Modulo2PI(pf2 - pl1);
+ if ( ((deltap1 < deltap2) && (deltap1 < 2*rad)) ||
+ ((deltap2 < deltap1) && (deltap2 > 2*rad)) ) // deltap2
+ {
+ firstp = lastp1;
+ lastp = firstp2;
+ }
+ else // deltap1
+ {
+ firstp = lastp2;
+ lastp = firstp1;
+ }
+ }
+ }
+ else // 2b
+ {
+ firstp = firstp1;
+ lastp = lastp2;
+ }
+ }
+ else // 2a or 3a or 4
+ {
+ if ( pl1m < pl2m ) // 2a
+ {
+ firstp = firstp2;
+ lastp = lastp1;
+ }
+ else // 3a or 4
+ {
+ if ( pl2m > pf2m ) // 3a
+ {
+ firstp = firstp2;
+ lastp = lastp2;
+ }
+ else // 4
+ {
+ Standard_Real deltap1 = Modulo2PI(pl1 - pf2);
+ Standard_Real deltap2 = Modulo2PI(pl2 - pf1);
+ if ( ((deltap1 < deltap2) && (deltap1 < 2*rad)) ||
+ ((deltap2 < deltap1) && (deltap2 > 2*rad)) ) // deltap2
+ {
+ firstp = firstp1;
+ lastp = lastp2;
+ }
+ else // deltap1
+ {
+ firstp = firstp2;
+ lastp = lastp1;
+ }
+ }
+ }
+ }
+
+ if ( myAutomaticPosition )
+ {
+ ComputeAutoArcPresentation(thecirc,firstp,lastp,case1);
+ }
+ else
+ {
+ if ( case1 )
+ {
+ myFAttach = firstp;
+ mySAttach = lastp;
+ }
+ else ComputeNotAutoArcPresentation(thecirc, firstp, lastp);
+ }
+ }
+ }
+
+ // Display of the presentation
+ TCollection_ExtendedString vals(" ==");
+ gp_Pnt attach = myPosition;
+ ComputeAttach(thecirc->Circ(),myFAttach,mySAttach,attach);
+ DsgPrs_IdenticPresentation::Add(aPrs,
+ myDrawer,
+ vals,
+ myPlane->Pln().Position().Ax2(),
+ myCenter,
+ myFAttach,
+ mySAttach,
+ myPosition,
+ attach);
+}
+
+//=======================================================================
+//function : ComputeAutoArcPresentation
+//purpose : Compute the presentation of the constraint where we are
+// not in the case of dragging.
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeAutoArcPresentation(const Handle(Geom_Circle)& thecirc,
+ const gp_Pnt& firstp,
+ const gp_Pnt& lastp,
+ const Standard_Boolean isstatic)
+{
+ Standard_Real aSegSize = thecirc->Radius()/5.0;
+ Standard_Real rad = M_PI / 5.0;
+
+ Standard_Real pFA = ElCLib::Parameter(thecirc->Circ(),firstp);
+ Standard_Real pSA = ElCLib::Parameter(thecirc->Circ(),lastp);
+ Standard_Real maxrad = Modulo2PI(pSA - pFA)/2.0;
+
+ if ( (rad > maxrad) || isstatic ) rad = maxrad;
+ Standard_Real pmiddle = Modulo2PI(pFA + Modulo2PI(pSA - pFA)/2.0);
+
+ myFAttach = ElCLib::Value(Modulo2PI(pmiddle - rad),thecirc->Circ());
+ mySAttach = ElCLib::Value(Modulo2PI(pmiddle + rad),thecirc->Circ());
+
+ gp_Pnt curpos = ElCLib::Value(pmiddle,thecirc->Circ());
+ gp_Vec vtrans(myCenter, curpos);
+ vtrans.Normalize();
+ vtrans *= aSegSize;
+ myPosition = curpos.Translated(vtrans);
+}
+
+//=======================================================================
+//function : ComputeNotAutoCircPresentation
+//purpose : Compute the presentation of the constraint where we are
+// in the case of dragging.
+// Note : This function is to be used only in the case of full circles.
+// The symbol of the constraint moves together with arc
+// representing the constraint around all the circle.
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeNotAutoCircPresentation(const Handle(Geom_Circle)& thecirc)
+{
+ gp_Pnt curpos = myPosition;
+
+ Handle(Geom_Circle) cirNotAuto = new Geom_Circle(thecirc->Circ());
+
+ // Case of confusion between the current position and the center
+ // of the circle -> we move the current position
+ Standard_Real confusion (Precision::Confusion());
+ if ( myCenter.Distance(curpos) <= confusion )
+ {
+ gp_Vec vprec(myCenter, myFAttach);
+ vprec.Normalize();
+ curpos.Translate(vprec*1e-5);
+ }
+
+ Standard_Real rad = M_PI / 5.0;
+ Standard_Real pcurpos = ElCLib::Parameter(cirNotAuto->Circ(),curpos);
+ Standard_Real pFAttach = pcurpos - rad;
+ Standard_Real pSAttach = pcurpos + rad;
+ myFAttach = ElCLib::Value(pFAttach,cirNotAuto->Circ());
+ mySAttach = ElCLib::Value(pSAttach,cirNotAuto->Circ());
+}
+
+//=======================================================================
+//function : ComputeNotAutoArcPresentation
+//purpose : Compute the presentation of the constraint where we are
+// in the case of dragging.
+// Note : This function is to be used only in the case of circles.
+// The symbol of the constraint moves only between myFAttach
+// and mySAttach.
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeNotAutoArcPresentation(const Handle(Geom_Circle)& thecirc,
+ const gp_Pnt& pntfirst,
+ const gp_Pnt& pntlast)
+{
+ gp_Pnt curpos = myPosition;
+
+ gp_Circ cirNotAuto = thecirc->Circ();
+
+ Standard_Real pFPnt = ElCLib::Parameter(cirNotAuto, pntfirst);
+ Standard_Real pSPnt = ElCLib::Parameter(cirNotAuto, pntlast);
+ Standard_Real deltap = Modulo2PI(pSPnt - pFPnt)/2.0;
+
+ Standard_Real rad = M_PI / 5;
+ if ( deltap < rad )
+ {
+ myFAttach = pntfirst;
+ mySAttach = pntlast;
+ }
+ else
+ {
+ gp_Pnt aFPnt = ElCLib::Value(Modulo2PI(pFPnt + rad), cirNotAuto);
+ gp_Pnt aSPnt = ElCLib::Value(Modulo2PI(pSPnt - rad), cirNotAuto);
+
+ ComputeAttach(cirNotAuto,aFPnt,aSPnt,curpos);
+
+ Standard_Real pcurpos = ElCLib::Parameter(cirNotAuto,curpos);
+ myFAttach = ElCLib::Value(pcurpos - rad, cirNotAuto);
+ mySAttach = ElCLib::Value(pcurpos + rad, cirNotAuto);
+ }
+}
+// jfa 17/10/2000 end
+
+// jfa 18/10/2000
+//=======================================================================
+//function : ComputeTwoEllipsesPresentation
+//purpose : Compute the presentation of the 'identic' constraint
+// between two ellipses (which are equal)
+//input : <theEll>: the ellipse
+// <firstp1>: first extremity of the 1st curve of the constraint
+// <lastp1> : last extremity of the 1st curve of the constraint
+// <firstp2>: first extremity of the 2nd curve of the constraint
+// <lastp2> :last extremity of the 2nd curve of the constraint
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeTwoEllipsesPresentation(const Handle(Prs3d_Presentation)& aPrs,
+ const Handle(Geom_Ellipse)& theEll,
+ const gp_Pnt& firstp1,
+ const gp_Pnt& lastp1,
+ const gp_Pnt& firstp2,
+ const gp_Pnt& lastp2)
+{
+ Standard_Real confusion (Precision::Confusion());
+
+ // Searching of complete ellipses
+ Standard_Boolean circ1complete = (firstp1.IsEqual(lastp1, confusion));
+ Standard_Boolean circ2complete = (firstp2.IsEqual(lastp2, confusion));
+
+ myCenter = theEll->Location();
+ Standard_Real aSegSize = theEll->MajorRadius()/5.0;
+ Standard_Real rad = M_PI / 5.0;
+
+ // I. Case of 2 complete ellipses
+ if ( circ1complete && circ2complete )
+ {
+ if (myAutomaticPosition)
+ {
+ Standard_Real pfirst1 = ElCLib::Parameter(theEll->Elips(), firstp1);
+ myFAttach = ElCLib::Value(Modulo2PI(pfirst1-rad), theEll->Elips());
+ mySAttach = ElCLib::Value(Modulo2PI(pfirst1+rad), theEll->Elips());
+
+ gp_Pnt curpos = ElCLib::Value(pfirst1,theEll->Elips());
+ gp_Vec vtrans(myCenter, curpos);
+ vtrans.Normalize();
+ vtrans *= aSegSize;
+ curpos.Translate(vtrans);
+ myPosition = curpos;
+ }
+ else ComputeNotAutoElipsPresentation(theEll);
+ }
+
+ // II. Case of one complete circle and one arc
+ else if ( (circ1complete && !circ2complete) || (!circ1complete && circ2complete) )
+ {
+ gp_Pnt firstp, lastp;
+ if ( circ1complete && !circ2complete)
+ {
+ firstp = firstp2;
+ lastp = lastp2;
+ }
+ else
+ {
+ firstp = firstp1;
+ lastp = lastp1;
+ }
+
+ if (myAutomaticPosition)
+ {
+ ComputeAutoArcPresentation(theEll, firstp, lastp);
+ }
+ else
+ {
+ ComputeNotAutoArcPresentation(theEll, firstp, lastp);
+ }
+ }
+
+ // III and IV. Case of two arcs
+ else if ( !circ1complete && !circ2complete )
+ {
+ // We project all the points on the circle
+ Standard_Real pf1, pf2, pl1, pl2;
+ pf1 = ElCLib::Parameter(theEll->Elips(), firstp1);
+ pf2 = ElCLib::Parameter(theEll->Elips(), firstp2);
+ pl1 = ElCLib::Parameter(theEll->Elips(), lastp1);
+ pl2 = ElCLib::Parameter(theEll->Elips(), lastp2);
+
+ // III. Arcs with common ends
+ // III.1. First of one and last of another
+ if ( IsEqual2PI(pl1,pf2,confusion) || IsEqual2PI(pf1,pl2,confusion) )
+ {
+ gp_Pnt curpos;
+ Standard_Real att=0.;
+ if ( IsEqual2PI(pl1,pf2,confusion) )
+ {
+ att = pl1;
+ curpos = lastp1;
+ }
+ else if ( IsEqual2PI(pf1,pl2,confusion) )
+ {
+ att = pf1;
+ curpos = firstp1;
+ }
+ Standard_Real maxrad = Min(Modulo2PI(pl1 - pf1),Modulo2PI(pl2 - pf2))*3/4;
+ if ( rad > maxrad ) rad = maxrad;
+ Standard_Real pFAttach = Modulo2PI(att - rad);
+ Standard_Real pSAttach = Modulo2PI(att + rad);
+ myFAttach = ElCLib::Value(pFAttach, theEll->Elips());
+ mySAttach = ElCLib::Value(pSAttach, theEll->Elips());
+ if ( myAutomaticPosition )
+ {
+ gp_Vec vtrans(myCenter,curpos);
+ vtrans.Normalize();
+ vtrans *= aSegSize;
+ curpos.Translate(vtrans);
+ myPosition = curpos;
+ }
+ }
+ // III.2. Two first or two last
+ else if ( IsEqual2PI(pf1,pf2,confusion) || IsEqual2PI(pl1,pl2,confusion) )
+ {
+ Standard_Real l1 = Modulo2PI(pl1 - pf1);
+ Standard_Real l2 = Modulo2PI(pl2 - pf2);
+ gp_Pnt firstp,lastp;
+ if ( l1 < l2 )
+ {
+ firstp = firstp1;
+ lastp = lastp1;
+ }
+ else
+ {
+ firstp = firstp2;
+ lastp = lastp2;
+ }
+
+ if ( myAutomaticPosition )
+ {
+ ComputeAutoArcPresentation(theEll, firstp, lastp);
+ }
+ else
+ {
+ ComputeNotAutoArcPresentation(theEll, firstp, lastp);
+ }
+ }
+ // IV. All others arcs (without common ends)
+ else
+ {
+ // order the parameters; first will be pf1
+ Standard_Real pl1m = Modulo2PI(pl1 - pf1);
+ Standard_Real pf2m = Modulo2PI(pf2 - pf1);
+ Standard_Real pl2m = Modulo2PI(pl2 - pf1);
+
+ Standard_Boolean case1 = Standard_False;
+ // 1 - not intersecting arcs
+ // 2 - intersecting arcs, but one doesn't contain another
+ // 3a - first arc contains the second one
+ // 3b - second arc contains the first one
+ // 4 - two intersections
+
+ gp_Pnt firstp, lastp;
+
+ if ( pl1m < pf2m ) // 1 or 2b or 3b
+ {
+ if ( pl1m < pl2m ) // 1 or 3b
+ {
+ if ( pl2m < pf2m ) // 3b
+ {
+ firstp = firstp1;
+ lastp = lastp1;
+ }
+ else // 1
+ {
+ case1 = Standard_True;
+ Standard_Real deltap1 = Modulo2PI(pf1 - pl2);
+ Standard_Real deltap2 = Modulo2PI(pf2 - pl1);
+ if ( ((deltap1 < deltap2) && (deltap1 < 2*rad)) ||
+ ((deltap2 < deltap1) && (deltap2 > 2*rad)) ) // deltap2
+ {
+ firstp = lastp1;
+ lastp = firstp2;
+ }
+ else // deltap1
+ {
+ firstp = lastp2;
+ lastp = firstp1;
+ }
+ }
+ }
+ else // 2b
+ {
+ firstp = firstp1;
+ lastp = lastp2;
+ }
+ }
+ else // 2a or 3a or 4
+ {
+ if ( pl1m < pl2m ) // 2a
+ {
+ firstp = firstp2;
+ lastp = lastp1;
+ }
+ else // 3a or 4
+ {
+ if ( pl2m > pf2m ) // 3a
+ {
+ firstp = firstp2;
+ lastp = lastp2;
+ }
+ else // 4
+ {
+ Standard_Real deltap1 = Modulo2PI(pl1 - pf2);
+ Standard_Real deltap2 = Modulo2PI(pl2 - pf1);
+ if ( ((deltap1 < deltap2) && (deltap1 < 2*rad)) ||
+ ((deltap2 < deltap1) && (deltap2 > 2*rad)) ) // deltap2
+ {
+ firstp = firstp1;
+ lastp = lastp2;
+ }
+ else // deltap1
+ {
+ firstp = firstp2;
+ lastp = lastp1;
+ }
+ }
+ }
+ }
+
+ if ( myAutomaticPosition )
+ {
+ ComputeAutoArcPresentation(theEll,firstp,lastp,case1);
+ }
+ else
+ {
+ if ( case1 )
+ {
+ myFAttach = firstp;
+ mySAttach = lastp;
+ }
+ else ComputeNotAutoArcPresentation(theEll, firstp, lastp);
+ }
+ }
+ }
+
+ // Display of the presentation
+ TCollection_ExtendedString vals(" ==");
+ gp_Pnt attach = myPosition;
+ ComputeAttach(theEll->Elips(),myFAttach,mySAttach,attach);
+ DsgPrs_IdenticPresentation::Add(aPrs,
+ myDrawer,
+ vals,
+ theEll->Elips(),
+ myFAttach,
+ mySAttach,
+ myPosition,
+ attach);
+}
+
+//=======================================================================
+//function : ComputeAutoArcPresentation
+//purpose : Compute the presentation of the constraint where we are
+// not in the case of dragging.
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeAutoArcPresentation(const Handle(Geom_Ellipse)& theEll,
+ const gp_Pnt& firstp,
+ const gp_Pnt& lastp,
+ const Standard_Boolean isstatic)
+{
+ Standard_Real aSegSize = theEll->MajorRadius()/5.0;
+ Standard_Real rad = M_PI / 5.0;
+
+ gp_Elips anEll = theEll->Elips();
+
+ Standard_Real pFA = ElCLib::Parameter(anEll,firstp);
+ Standard_Real pSA = ElCLib::Parameter(anEll,lastp);
+ Standard_Real maxrad = Modulo2PI(pSA - pFA)/2.0;
+
+ if ( (rad > maxrad) || isstatic ) rad = maxrad;
+ Standard_Real pmiddle = Modulo2PI(pFA + Modulo2PI(pSA - pFA)/2.0);
+
+ myFAttach = ElCLib::Value(Modulo2PI(pmiddle - rad),anEll);
+ mySAttach = ElCLib::Value(Modulo2PI(pmiddle + rad),anEll);
+
+ gp_Pnt curpos = ElCLib::Value(pmiddle,anEll);
+ gp_Vec vtrans(myCenter, curpos);
+ vtrans.Normalize();
+ vtrans *= aSegSize;
+ myPosition = curpos.Translated(vtrans);
+}
+
+//=======================================================================
+//function : ComputeNotAutoElipsPresentation
+//purpose : Compute the presentation of the constraint where we are
+// in the case of dragging.
+// Note : This function is to be used only in the case of ellipses.
+// The symbol of the constraint moves only between myFAttach
+// and mySAttach.
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeNotAutoElipsPresentation(const Handle(Geom_Ellipse)& theEll)
+{
+ gp_Pnt curpos = myPosition;
+
+ gp_Elips anEll = theEll->Elips();
+
+ // Case of confusion between the current position and the center
+ // of the ellipse -> we move the current position
+ Standard_Real confusion (Precision::Confusion());
+ if ( myCenter.Distance(curpos) <= confusion )
+ {
+ gp_Vec vprec(myCenter, myFAttach);
+ vprec.Normalize();
+ curpos.Translate(vprec*1e-5);
+ }
+
+ Standard_Real rad = M_PI / 5.0;
+// Standard_Real pcurpos = ElCLib::Parameter(anEll,curpos);
+ GeomAPI_ProjectPointOnCurve aProj (curpos, theEll);
+ Standard_Real pcurpos = aProj.LowerDistanceParameter();
+
+ Standard_Real pFAttach = pcurpos - rad;
+ Standard_Real pSAttach = pcurpos + rad;
+ myFAttach = ElCLib::Value(pFAttach,anEll);
+ mySAttach = ElCLib::Value(pSAttach,anEll);
+}
+
+//=======================================================================
+//function : ComputeNotAutoArcPresentation
+//purpose : Compute the presentation of the constraint where we are
+// in the case of dragging.
+// Note : This function is to be used only in the case of ellipses.
+// The symbol of the constraint moves only between myFAttach
+// and mySAttach.
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeNotAutoArcPresentation(const Handle(Geom_Ellipse)& theEll,
+ const gp_Pnt& pntfirst,
+ const gp_Pnt& pntlast)
+{
+ gp_Pnt curpos = myPosition;
+
+ gp_Elips anEll = theEll->Elips();
+
+ Standard_Real pFPnt = ElCLib::Parameter(anEll, pntfirst);
+ Standard_Real pSPnt = ElCLib::Parameter(anEll, pntlast);
+ Standard_Real deltap = Modulo2PI(pSPnt - pFPnt)/2.0;
+
+ Standard_Real rad = M_PI / 5;
+ if ( deltap < rad )
+ {
+ myFAttach = pntfirst;
+ mySAttach = pntlast;
+ }
+ else
+ {
+ gp_Pnt aFPnt = ElCLib::Value(Modulo2PI(pFPnt + rad), anEll);
+ gp_Pnt aSPnt = ElCLib::Value(Modulo2PI(pSPnt - rad), anEll);
+
+ ComputeAttach(anEll,aFPnt,aSPnt,curpos);
+
+// Standard_Real pcurpos = ElCLib::Parameter(anEll,curpos);
+ GeomAPI_ProjectPointOnCurve aProj (curpos, theEll);
+ Standard_Real pcurpos = aProj.LowerDistanceParameter();
+
+ myFAttach = ElCLib::Value(pcurpos - rad, anEll);
+ mySAttach = ElCLib::Value(pcurpos + rad, anEll);
+ }
+}
+// jfa 18/10/2000 end
+
+//=======================================================================
+//function : ComputeTwoVerticesPresentation
+//purpose :
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeTwoVerticesPresentation(const Handle(Prs3d_Presentation)& aPrs)
+{
+ Standard_Boolean isOnPlane1, isOnPlane2;
+ const TopoDS_Vertex& FVertex = TopoDS::Vertex(myFShape);
+ const TopoDS_Vertex& SVertex = TopoDS::Vertex(mySShape);
+
+ PrsDim::ComputeGeometry(FVertex, myFAttach, myPlane, isOnPlane1);
+ PrsDim::ComputeGeometry(SVertex, mySAttach, myPlane, isOnPlane2);
+
+ if (isOnPlane1 && isOnPlane2)
+ myExtShape = 0;
+ else if ( isOnPlane1 && !isOnPlane2)
+ myExtShape = 2;
+ else if (!isOnPlane1 && isOnPlane2)
+ myExtShape = 1;
+ else
+ return ;
+
+
+ // The attachement points are the points themselves that must be
+ //identical
+ myFAttach = BRep_Tool::Pnt(FVertex);
+ mySAttach = myFAttach;
+
+ gp_Pnt curpos;
+ if (myAutomaticPosition)
+ {
+ //Computation of the size of the symbol
+ Standard_Real symbsize = ComputeSegSize();
+ if (symbsize <= Precision::Confusion()) symbsize = 1.;
+ symbsize*=5;
+ // Computation of the direction of the segment of the presentation
+ // we take the median of the edges connected to vertices
+ gp_Dir dF, dS;
+ gp_Dir myDir;
+ TColStd_ListIteratorOfListOfTransient it(Users());
+ if (it.More())
+ {
+ Handle(AIS_Shape) USER (Handle(AIS_Shape)::DownCast(it.Value()));
+ if (!USER.IsNull())
+ {
+ const TopoDS_Shape& SH =USER->Shape();
+ if ( (!SH.IsNull()) && (SH.ShapeType() == TopAbs_WIRE) )
+ {
+ const TopoDS_Wire& WIRE = TopoDS::Wire(USER->Shape());
+ Standard_Boolean done = ComputeDirection(WIRE,FVertex,dF);
+ if (!done) return;
+ done = ComputeDirection(WIRE,SVertex,dS);
+ if (!done) return;
+ }
+ else return;
+ }
+ else return;
+
+ // computation of the segment direction like average
+ // of the 2 computed directions.
+ if ( dF.IsParallel(dS, Precision::Angular()) )
+ {
+ myDir = dF.Crossed(myPlane->Pln().Axis().Direction());
+ }
+ else
+ {
+ myDir.SetXYZ(dF.XYZ() + dS.XYZ());
+ }
+ curpos = myFAttach.Translated(gp_Vec(myDir)*symbsize) ;
+ }
+// jfa 11/10/2000
+ else
+ {
+ curpos = myFAttach;
+ }
+// jfa 11/10/2000 end
+
+ myPosition = curpos;
+ myAutomaticPosition = Standard_False;
+ }
+ else
+ {
+ curpos = myPosition;
+ }
+
+ // Presentation computation
+ TCollection_ExtendedString vals(" ++");
+ DsgPrs_IdenticPresentation::Add(aPrs,
+ myDrawer,
+ vals,
+ myFAttach,
+ curpos);
+ // Calculate the projection of vertex
+ if ( myExtShape == 1)
+ ComputeProjVertexPresentation(aPrs,FVertex,myFAttach);
+ else if ( myExtShape == 2)
+ ComputeProjVertexPresentation(aPrs,SVertex,mySAttach);
+}
+
+
+
+//=======================================================================
+//function : ComputeSegSize
+//purpose :
+//=======================================================================
+Standard_Real PrsDim_IdenticRelation::ComputeSegSize() const
+{
+ return 1.;
+}
+
+//=======================================================================
+//function : ComputeDirection
+//purpose : Compute a direction according to the different geometric
+// elements connected to the vertex <VERT>, in way to not have
+// overlap between the symbol and them.
+//=======================================================================
+Standard_Boolean PrsDim_IdenticRelation::ComputeDirection(const TopoDS_Wire& aWire,
+ const TopoDS_Vertex& VERT,
+ gp_Dir& dF) const
+{
+ // we take the median of the edges connected to vertices
+ TopoDS_Edge edg1,edg2;
+ ConnectedEdges(aWire,VERT,edg1,edg2);
+
+ if ( edg1.IsNull() && edg2.IsNull() ) {
+ return Standard_False;
+ }
+
+ Handle(Geom_Curve) curv1,curv2;
+ gp_Pnt firstp1,lastp1,firstp2,lastp2;
+
+ // Case with 2 edges connected to the vertex <VERT>
+ if ( !edg1.IsNull() && !edg2.IsNull() ) {
+ if ( !PrsDim::ComputeGeometry(edg1,edg2,
+ curv1,curv2,
+ firstp1, lastp1,
+ firstp2, lastp2,myPlane))
+ return Standard_False;
+
+ gp_Dir d1, d2;
+ if ( curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
+ d1 = ComputeCircleDirection(Handle(Geom_Circle)::DownCast (curv1), VERT);
+ }
+ else if (curv1->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
+ d1 = ComputeLineDirection(Handle(Geom_Line)::DownCast (curv1), firstp1);
+ }
+ else
+ return Standard_False;
+
+ if ( curv2->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
+ d2 = ComputeCircleDirection( Handle(Geom_Circle)::DownCast (curv2), VERT);
+ }
+ else if (curv2->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
+ d2 =ComputeLineDirection( Handle(Geom_Line)::DownCast (curv2), firstp2);
+ }
+ else
+ return Standard_False;
+
+ if ( !d1.IsParallel(d2, Precision::Angular() ))
+ dF.SetXYZ( (d1.XYZ() + d2.XYZ())/2 );
+ else {
+ dF= d1.Crossed(myPlane->Pln().Axis().Direction());
+ }
+ }
+
+ // Case where <VERT> is at an extremity of a wire.
+ else {
+ TopoDS_Edge VEdge;
+ if ( !edg1.IsNull() )
+ VEdge = edg1;
+ else if (!edg2.IsNull() )
+ VEdge = edg2;
+ else
+ return Standard_False;
+
+ if ( !PrsDim::ComputeGeometry(VEdge, curv1, firstp1, lastp1) )
+ return Standard_False;
+ if ( curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
+ dF = ComputeCircleDirection( Handle(Geom_Circle)::DownCast (curv1), VERT);
+ }
+ else if (curv1->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
+ dF = ComputeLineDirection( Handle(Geom_Line)::DownCast (curv1), firstp1);
+ }
+ else
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputeLineDirection
+//purpose :
+//=======================================================================
+gp_Dir PrsDim_IdenticRelation::ComputeLineDirection(const Handle(Geom_Line)& lin,
+ const gp_Pnt& firstP) const
+{
+ gp_Dir dir;
+ dir = lin->Lin().Direction();
+ if ( !myFAttach.IsEqual(firstP, Precision::Confusion()) )
+ dir.Reverse();
+ return dir;
+}
+
+//=======================================================================
+//function : ComputeCircleDirection
+//purpose :
+//=======================================================================
+gp_Dir PrsDim_IdenticRelation::ComputeCircleDirection(const Handle(Geom_Circle)& circ,
+ const TopoDS_Vertex& VERT) const
+{
+ gp_Vec V(circ->Location(),BRep_Tool::Pnt(VERT));
+ return gp_Dir(V);
+}
+
+//=======================================================================
+//function : ComputeOneEdgeOVertexPresentation
+//purpose :
+//=======================================================================
+void PrsDim_IdenticRelation::ComputeOneEdgeOVertexPresentation(const Handle(Prs3d_Presentation)& aPrs)
+{
+ TopoDS_Vertex V;
+ TopoDS_Edge E;
+ Standard_Integer numedge;
+
+ if (myFShape.ShapeType() == TopAbs_VERTEX) {
+ V = TopoDS::Vertex(myFShape);
+ E = TopoDS::Edge(mySShape);
+ numedge = 2;// edge = 2nd shape
+ }
+ else {
+ V = TopoDS::Vertex(mySShape);
+ E = TopoDS::Edge(myFShape);
+ numedge = 1; // edge = 1st shape
+ }
+ gp_Pnt ptonedge1,ptonedge2;
+ Handle(Geom_Curve) aCurve;
+ Handle(Geom_Curve) extCurv;
+ Standard_Boolean isInfinite;
+ Standard_Boolean isOnPlanEdge, isOnPlanVertex;
+ if (!PrsDim::ComputeGeometry(E,aCurve,ptonedge1,ptonedge2,extCurv,isInfinite,isOnPlanEdge,myPlane))
+ return;
+ aPrs->SetInfiniteState(isInfinite);
+ PrsDim::ComputeGeometry(V, myFAttach, myPlane, isOnPlanVertex);
+
+ // only the curve can be projected
+ if (!isOnPlanEdge && !isOnPlanVertex) return;
+
+ if (!isOnPlanEdge) {
+ if (numedge == 1) myExtShape = 1;
+ else myExtShape = 2;
+ }
+ else if (!isOnPlanVertex) {
+ if (numedge == 1) myExtShape = 2;
+ else myExtShape = 1;
+ }
+ // The attachement points are the point
+ myFAttach = BRep_Tool::Pnt(V);
+ mySAttach = myFAttach;
+
+ gp_Pnt curpos;
+ if (myAutomaticPosition) {
+ //Computation of the size of the symbol
+ Standard_Real symbsize = ComputeSegSize();
+ symbsize*=5;
+ // Computation of the direction of the segment of the presentation
+ // we take the median of the edges connected to vertices
+ gp_Dir myDir;
+ if ( aCurve->IsKind(STANDARD_TYPE(Geom_Line))) {
+ myDir = Handle(Geom_Line)::DownCast (aCurve)->Lin().Direction();
+ myDir.Cross(myPlane->Pln().Axis().Direction());
+ }
+ else if (aCurve->IsKind(STANDARD_TYPE(Geom_Circle))) {
+ Handle(Geom_Circle) CIR = Handle(Geom_Circle)::DownCast (aCurve);
+ myDir.SetXYZ(myFAttach.XYZ() - CIR->Location().XYZ());
+ }
+ // jfa 10/10/2000
+ else if (aCurve->IsKind(STANDARD_TYPE(Geom_Ellipse))) {
+ Handle(Geom_Ellipse) CIR = Handle(Geom_Ellipse)::DownCast (aCurve);
+ myDir.SetXYZ(myFAttach.XYZ() - CIR->Location().XYZ());
+ }
+ // jfa 10/10/2000 end
+
+ curpos = myFAttach.Translated(gp_Vec(myDir)*symbsize) ;
+ myPosition = curpos;
+ myAutomaticPosition = Standard_True;
+ }
+ else {
+ curpos = myPosition;
+ }
+
+ // Presentation computation
+ TCollection_ExtendedString vals(" -+-");
+ DsgPrs_IdenticPresentation::Add(aPrs,
+ myDrawer,
+ vals,
+ myFAttach,
+ curpos);
+ if (myExtShape != 0) {
+ if (!extCurv.IsNull()) { // the edge is not in the WP
+ ComputeProjEdgePresentation(aPrs,E,Handle(Geom_Line)::DownCast (aCurve),ptonedge1,ptonedge2);
+ }
+ }
+}
--- /dev/null
+// Created on: 1997-03-03
+// Created by: Jean-Pierre COMBE
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_IdenticRelation_HeaderFile
+#define _PrsDim_IdenticRelation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+#include <gp_Pnt.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <TColStd_ListOfTransient.hxx>
+
+class TopoDS_Shape;
+class Geom_Plane;
+class Geom_Line;
+class gp_Pnt;
+class Geom_Circle;
+class Geom_Ellipse;
+class TopoDS_Wire;
+class TopoDS_Vertex;
+class gp_Dir;
+
+DEFINE_STANDARD_HANDLE(PrsDim_IdenticRelation, PrsDim_Relation)
+
+//! Constructs a constraint by a relation of identity
+//! between two or more datums figuring in shape
+//! Interactive Objects.
+class PrsDim_IdenticRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_IdenticRelation, PrsDim_Relation)
+public:
+
+ //! Initializes the relation of identity between the two
+ //! entities, FirstShape and SecondShape. The plane
+ //! aPlane is initialized in case a visual reference is
+ //! needed to show identity.
+ Standard_EXPORT PrsDim_IdenticRelation(const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& aPlane);
+
+ Standard_Boolean HasUsers() const { return !myUsers.IsEmpty(); }
+
+ const TColStd_ListOfTransient& Users() const { return myUsers; }
+
+ void AddUser (const Handle(Standard_Transient)& theUser) { myUsers.Append (theUser); }
+
+ void ClearUsers() { myUsers.Clear(); }
+
+ //! Returns true if the interactive object is movable.
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+private:
+
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeOneEdgeOVertexPresentation (const Handle(Prs3d_Presentation)& aPresentation);
+
+ Standard_EXPORT void ComputeTwoEdgesPresentation (const Handle(Prs3d_Presentation)& aPresentation);
+
+ Standard_EXPORT void ComputeTwoLinesPresentation (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Geom_Line)& aLin, gp_Pnt& Pnt1On1, gp_Pnt& Pnt2On1, gp_Pnt& Pnt1On2, gp_Pnt& Pnt2On2, const Standard_Boolean isInf1, const Standard_Boolean isInf2);
+
+ Standard_EXPORT void ComputeTwoCirclesPresentation (const Handle(Prs3d_Presentation)& aPresentation, const Handle(Geom_Circle)& aCircle, const gp_Pnt& Pnt1On1, const gp_Pnt& Pnt2On1, const gp_Pnt& Pnt1On2, const gp_Pnt& Pnt2On2);
+
+ //! Computes the presentation of the identic constraint
+ //! between 2 arcs in the case of automatic presentation
+ Standard_EXPORT void ComputeAutoArcPresentation (const Handle(Geom_Circle)& aCircle, const gp_Pnt& firstp, const gp_Pnt& lastp, const Standard_Boolean isstatic = Standard_False);
+
+ //! Computes the presentation of the identic constraint
+ //! between 2 circles in the case of non automatic presentation
+ Standard_EXPORT void ComputeNotAutoCircPresentation (const Handle(Geom_Circle)& aCircle);
+
+ //! Computes the presentation of the identic constraint
+ //! between 2 arcs in the case of non automatic presentation
+ Standard_EXPORT void ComputeNotAutoArcPresentation (const Handle(Geom_Circle)& aCircle, const gp_Pnt& pntfirst, const gp_Pnt& pntlast);
+
+ Standard_EXPORT void ComputeTwoEllipsesPresentation (const Handle(Prs3d_Presentation)& aPrs, const Handle(Geom_Ellipse)& anEll, const gp_Pnt& Pnt1On1, const gp_Pnt& Pnt2On1, const gp_Pnt& Pnt1On2, const gp_Pnt& Pnt2On2);
+
+ //! Computes the presentation of the identic constraint
+ //! between 2 arcs in the case of automatic presentation
+ Standard_EXPORT void ComputeAutoArcPresentation (const Handle(Geom_Ellipse)& theEll, const gp_Pnt& firstp, const gp_Pnt& lastp, const Standard_Boolean isstatic = Standard_False);
+
+ //! Computes the presentation of the identic constraint
+ //! between 2 ellipses in the case of non automatic presentation
+ Standard_EXPORT void ComputeNotAutoElipsPresentation (const Handle(Geom_Ellipse)& theEll);
+
+ //! Computes the presentation of the identic constraint
+ //! between 2 arcs in the case of non automatic presentation
+ Standard_EXPORT void ComputeNotAutoArcPresentation (const Handle(Geom_Ellipse)& theEll, const gp_Pnt& pntfirst, const gp_Pnt& pntlast);
+
+ Standard_EXPORT void ComputeTwoVerticesPresentation (const Handle(Prs3d_Presentation)& aPresentation);
+
+ Standard_EXPORT Standard_Real ComputeSegSize() const;
+
+ Standard_EXPORT Standard_Boolean ComputeDirection (const TopoDS_Wire& aWire, const TopoDS_Vertex& aVertex, gp_Dir& aDir) const;
+
+ Standard_EXPORT gp_Dir ComputeLineDirection (const Handle(Geom_Line)& aLin, const gp_Pnt& anExtremity) const;
+
+ Standard_EXPORT gp_Dir ComputeCircleDirection (const Handle(Geom_Circle)& aCirc, const TopoDS_Vertex& ConnectedVertex) const;
+
+private:
+
+ TColStd_ListOfTransient myUsers;
+ Standard_Boolean isCircle;
+ gp_Pnt myFAttach;
+ gp_Pnt mySAttach;
+ gp_Pnt myCenter;
+
+};
+
+#endif // _PrsDim_IdenticRelation_HeaderFile
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_KindOfDimension_HeaderFile
+#define _PrsDim_KindOfDimension_HeaderFile
+
+//! Declares the kinds of dimensions needed in the
+//! display of Interactive Objects.
+enum PrsDim_KindOfDimension
+{
+ PrsDim_KOD_NONE,
+ PrsDim_KOD_LENGTH,
+ PrsDim_KOD_PLANEANGLE,
+ PrsDim_KOD_SOLIDANGLE,
+ PrsDim_KOD_AREA,
+ PrsDim_KOD_VOLUME,
+ PrsDim_KOD_MASS,
+ PrsDim_KOD_TIME,
+ PrsDim_KOD_RADIUS,
+ PrsDim_KOD_DIAMETER,
+ PrsDim_KOD_CHAMF2D,
+ PrsDim_KOD_CHAMF3D,
+ PrsDim_KOD_OFFSET,
+ PrsDim_KOD_ELLIPSERADIUS
+};
+
+#endif // _PrsDim_KindOfDimension_HeaderFile
--- /dev/null
+// Created on: 2016-11-25
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_KindOfRelation_HeaderFile
+#define _PrsDim_KindOfRelation_HeaderFile
+
+enum PrsDim_KindOfRelation
+{
+ PrsDim_KOR_NONE = 0,
+ PrsDim_KOR_CONCENTRIC,
+ PrsDim_KOR_EQUALDISTANCE,
+ PrsDim_KOR_EQUALRADIUS,
+ PrsDim_KOR_FIX,
+ PrsDim_KOR_IDENTIC,
+ PrsDim_KOR_OFFSET,
+ PrsDim_KOR_PARALLEL,
+ PrsDim_KOR_PERPENDICULAR,
+ PrsDim_KOR_TANGENT,
+ PrsDim_KOR_SYMMETRIC
+};
+
+#endif
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_KindOfSurface_HeaderFile
+#define _PrsDim_KindOfSurface_HeaderFile
+
+enum PrsDim_KindOfSurface
+{
+ PrsDim_KOS_Plane,
+ PrsDim_KOS_Cylinder,
+ PrsDim_KOS_Cone,
+ PrsDim_KOS_Sphere,
+ PrsDim_KOS_Torus,
+ PrsDim_KOS_Revolution,
+ PrsDim_KOS_Extrusion,
+ PrsDim_KOS_OtherSurface
+};
+
+#endif // _PrsDim_KindOfSurface_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Arnaud BOUZY/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2013 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_LengthDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepExtrema_DistShapeShape.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <BRepTools.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+#include <gce_MakeDir.hxx>
+#include <gce_MakePln.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAPI_ExtremaCurveCurve.hxx>
+#include <GeomAPI_ExtremaSurfaceSurface.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_LengthDimension, PrsDim_Dimension)
+
+//=======================================================================
+//function : Constructor
+//purpose : Dimension between two faces
+//=======================================================================
+PrsDim_LengthDimension::PrsDim_LengthDimension (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace)
+: PrsDim_Dimension (PrsDim_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
+{
+ SetMeasuredGeometry (theFirstFace, theSecondFace);
+ SetFlyout (15.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose : Dimension between two shape
+//=======================================================================
+PrsDim_LengthDimension::PrsDim_LengthDimension (const TopoDS_Face& theFace,
+ const TopoDS_Edge& theEdge)
+: PrsDim_Dimension (PrsDim_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
+{
+ SetMeasuredGeometry (theFace, theEdge);
+ SetFlyout (15.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose : Dimension between two points
+//=======================================================================
+PrsDim_LengthDimension::PrsDim_LengthDimension (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint,
+ const gp_Pln& thePlane)
+: PrsDim_Dimension (PrsDim_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
+{
+ SetMeasuredGeometry (theFirstPoint, theSecondPoint, thePlane);
+ SetFlyout (15.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose : Dimension between two shape
+//=======================================================================
+PrsDim_LengthDimension::PrsDim_LengthDimension (const TopoDS_Shape& theFirstShape,
+ const TopoDS_Shape& theSecondShape,
+ const gp_Pln& thePlane)
+: PrsDim_Dimension (PrsDim_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
+{
+ SetCustomPlane (thePlane);
+ SetMeasuredShapes (theFirstShape, theSecondShape);
+ SetFlyout (15.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose : Dimension of one edge
+//=======================================================================
+PrsDim_LengthDimension::PrsDim_LengthDimension (const TopoDS_Edge& theEdge,
+ const gp_Pln& thePlane)
+: PrsDim_Dimension (PrsDim_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
+{
+ SetMeasuredGeometry (theEdge, thePlane);
+ SetFlyout (15.0);
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_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;
+ SetCustomPlane (thePlane);
+ myIsGeometryValid = IsValidPoints (theFirstPoint, theSecondPoint);
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::SetMeasuredGeometry (const TopoDS_Edge& theEdge,
+ const gp_Pln& thePlane)
+{
+ myFirstShape = theEdge;
+ mySecondShape = TopoDS_Shape();
+ myGeometryType = GeometryType_Edge;
+ SetCustomPlane (thePlane);
+ myIsGeometryValid = InitOneShapePoints (myFirstShape);
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
+ const TopoDS_Face& theSecondFace)
+{
+ SetMeasuredShapes (theFirstFace, theSecondFace);
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::SetMeasuredGeometry (const TopoDS_Face& theFace,
+ const TopoDS_Edge& theEdge)
+{
+ SetMeasuredShapes (theFace, theEdge);
+}
+
+//=======================================================================
+//function : SetMeasuredShapes
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::SetMeasuredShapes (const TopoDS_Shape& theFirstShape,
+ const TopoDS_Shape& theSecondShape)
+{
+ gp_Pln aComputedPlane;
+ Standard_Boolean isPlaneReturned = Standard_False;
+
+ myFirstShape = theFirstShape;
+ mySecondShape = theSecondShape;
+ myIsGeometryValid = InitTwoShapesPoints (myFirstShape, mySecondShape, aComputedPlane, isPlaneReturned);
+
+ if (myIsGeometryValid && !myIsPlaneCustom)
+ {
+ if (isPlaneReturned)
+ {
+ myPlane = aComputedPlane;
+ }
+ else
+ {
+ myIsGeometryValid = Standard_False;
+ }
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : CheckPlane
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_LengthDimension::CheckPlane (const gp_Pln& thePlane) const
+{
+ Standard_Boolean anIsFaultyNormal =
+ thePlane.Axis().Direction().IsParallel(gce_MakeDir (myFirstPoint, mySecondPoint), Precision::Angular());
+
+ if ((!thePlane.Contains (myFirstPoint, Precision::Confusion()) && !thePlane.Contains (mySecondPoint, Precision::Confusion()))
+ || anIsFaultyNormal)
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ComputePlane
+//purpose :
+//=======================================================================
+gp_Pln PrsDim_LengthDimension::ComputePlane (const gp_Dir& theAttachDir) const
+{
+ if (!IsValidPoints (myFirstPoint, mySecondPoint))
+ {
+ return gp_Pln();
+ }
+
+ gp_Pnt aThirdPoint (myFirstPoint.Translated (gp_Vec(theAttachDir)));
+ gce_MakePln aPlaneConstrustor (myFirstPoint, mySecondPoint, aThirdPoint);
+ return aPlaneConstrustor.Value();
+}
+
+//=======================================================================
+//function : GetModelUnits
+//purpose :
+//=======================================================================
+const TCollection_AsciiString& PrsDim_LengthDimension::GetModelUnits() const
+{
+ return myDrawer->DimLengthModelUnits();
+}
+
+//=======================================================================
+//function : GetDisplayUnits
+//purpose :
+//=======================================================================
+const TCollection_AsciiString& PrsDim_LengthDimension::GetDisplayUnits() const
+{
+ return myDrawer->DimLengthDisplayUnits();
+}
+
+//=======================================================================
+//function : SetModelUnits
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::SetModelUnits (const TCollection_AsciiString& theUnits)
+{
+ myDrawer->SetDimLengthModelUnits (theUnits);
+}
+
+//=======================================================================
+//function : SetDisplayUnits
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
+{
+ myDrawer->SetDimLengthDisplayUnits (theUnits);
+}
+
+//=======================================================================
+//function : ComputeValue
+//purpose :
+//=======================================================================
+Standard_Real PrsDim_LengthDimension::ComputeValue() const
+{
+ if (!IsValid())
+ return 0.0;
+
+ if (!myHasCustomDirection)
+ return myFirstPoint.Distance (mySecondPoint);
+
+ return fabs (gp_Vec(myFirstPoint, mySecondPoint).Dot (myDirection));
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode)
+{
+ mySelectionGeom.Clear (theMode);
+
+ if (!IsValid())
+ {
+ return;
+ }
+
+ DrawLinearDimension (thePresentation, theMode, myFirstPoint, mySecondPoint);
+}
+
+ //=======================================================================
+//function : ComputeFlyoutLinePoints
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
+ gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint)
+{
+ if (!myHasCustomDirection)
+ {
+ PrsDim_Dimension::ComputeFlyoutLinePoints (theFirstPoint, theSecondPoint, theLineBegPoint, theLineEndPoint);
+ return;
+ }
+
+ // find scalar of projection target vector (from start to second point) to flyout vector
+ gp_Ax1 aPlaneNormal = GetPlane().Axis();
+ gp_Vec aFlyoutNormalizedDir(aPlaneNormal.Direction() ^ myDirection);
+ aFlyoutNormalizedDir.Normalize();
+ Standard_Real aTargetProjectedToFlyout = gp_Vec(theFirstPoint, theSecondPoint).Dot (aFlyoutNormalizedDir);
+
+ gp_Dir aFlyoutVector = aFlyoutNormalizedDir;
+ // create lines for layouts
+ gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
+ gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
+
+ // Get flyout end points
+ theLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout() + aTargetProjectedToFlyout, aLine1);
+ theLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
+}
+
+//=======================================================================
+//function : ComputeFlyoutSelection
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
+ const Handle(SelectMgr_EntityOwner)& theEntityOwner)
+{
+ if (!IsValid())
+ {
+ return;
+ }
+
+ ComputeLinearFlyouts (theSelection, theEntityOwner, myFirstPoint, mySecondPoint);
+}
+
+//=======================================================================
+//function : IsValidPoints
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_LengthDimension::IsValidPoints (const gp_Pnt& theFirstPoint,
+ const gp_Pnt& theSecondPoint) const
+{
+ return theFirstPoint.Distance (theSecondPoint) > Precision::Confusion();
+}
+
+//=======================================================================
+//function : InitTwoEdgesLength
+//purpose : Initialization of dimension between two linear edges
+//=======================================================================
+Standard_Boolean PrsDim_LengthDimension::InitTwoEdgesLength (const TopoDS_Edge& theFirstEdge,
+ const TopoDS_Edge& theSecondEdge,
+ gp_Dir& theDirAttach)
+{
+ BRepAdaptor_Curve aFirstCurveAdapt (theFirstEdge);
+ if (aFirstCurveAdapt.GetType() != GeomAbs_Line)
+ {
+ return Standard_False;
+ }
+
+ BRepAdaptor_Curve aSecondCurveAdapt (theSecondEdge);
+ if (aSecondCurveAdapt.GetType() != GeomAbs_Line)
+ {
+ return Standard_False;
+ }
+
+ Handle(Geom_Curve) aFirstCurve;
+ Handle(Geom_Curve) aSecondCurve;
+
+ gp_Pnt aPoint11 (gp::Origin());
+ gp_Pnt aPoint12 (gp::Origin());
+ gp_Pnt aPoint21 (gp::Origin());
+ gp_Pnt aPoint22 (gp::Origin());
+ Standard_Boolean isFirstInfinite = Standard_False;
+ Standard_Boolean isSecondInfinite = Standard_False;
+
+ if (!PrsDim::ComputeGeometry (theFirstEdge, theSecondEdge,
+ aFirstCurve, aSecondCurve,
+ aPoint11, aPoint12,
+ aPoint21, aPoint22,
+ isFirstInfinite,
+ isSecondInfinite))
+ {
+ return Standard_False;
+ }
+
+ const Handle(Geom_Line) aFirstLine = Handle(Geom_Line)::DownCast (aFirstCurve);
+ const Handle(Geom_Line) aSecondLine = Handle(Geom_Line)::DownCast (aSecondCurve);
+
+ if (!aFirstLine->Lin().Direction().IsParallel (aSecondLine->Lin().Direction(),Precision::Angular()))
+ {
+ return Standard_False;
+ }
+
+ theDirAttach = aFirstLine->Lin().Direction();
+
+ gp_Pnt aPoint;
+
+ if (!isFirstInfinite)
+ {
+ if (PrsDim::Nearest (aSecondCurve, aPoint11, aPoint21, aPoint22, aPoint))
+ {
+ myFirstPoint = aPoint11;
+ mySecondPoint = aPoint;
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+ }
+ else if (PrsDim::Nearest (aSecondCurve, aPoint12, aPoint21, aPoint22, aPoint))
+ {
+ myFirstPoint = aPoint12;
+ mySecondPoint = aPoint;
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+ }
+ }
+
+ if (!isSecondInfinite)
+ {
+ if (PrsDim::Nearest (aFirstCurve, aPoint21, aPoint11, aPoint12, aPoint))
+ {
+ myFirstPoint = aPoint;
+ mySecondPoint = aPoint21;
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+ }
+ if (PrsDim::Nearest (aFirstCurve, aPoint22, aPoint11, aPoint12, aPoint))
+ {
+ myFirstPoint = aPoint;
+ mySecondPoint = aPoint22;
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+ }
+ }
+
+ GeomAPI_ExtremaCurveCurve anExtrema (aFirstCurve, aSecondCurve);
+ anExtrema.NearestPoints (myFirstPoint, mySecondPoint);
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+}
+
+//=======================================================================
+//function : InitEdgeVertexLength
+//purpose : for first edge and second vertex shapes
+//=======================================================================
+Standard_Boolean PrsDim_LengthDimension::InitEdgeVertexLength (const TopoDS_Edge& theEdge,
+ const TopoDS_Vertex& theVertex,
+ gp_Dir& theEdgeDir,
+ Standard_Boolean isInfinite)
+{
+ gp_Pnt anEdgePoint1 (gp::Origin());
+ gp_Pnt anEdgePoint2 (gp::Origin());
+ Handle(Geom_Curve) aCurve;
+
+ if (!PrsDim::ComputeGeometry (theEdge, aCurve, anEdgePoint1, anEdgePoint2, isInfinite))
+ {
+ return Standard_False;
+ }
+
+ myFirstPoint = BRep_Tool::Pnt (theVertex);
+
+ Handle(Geom_Line) aGeomLine (Handle(Geom_Line)::DownCast (aCurve));
+ const gp_Lin& aLin = aGeomLine->Lin();
+
+ // Get direction of edge to build plane automatically.
+ theEdgeDir = aLin.Direction();
+
+ mySecondPoint = PrsDim::Nearest (aLin, myFirstPoint);
+
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+}
+
+//=======================================================================
+//function : InitEdgeFaceLength
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_LengthDimension::InitEdgeFaceLength (const TopoDS_Edge& theEdge,
+ const TopoDS_Face& theFace,
+ gp_Dir& theEdgeDir)
+{
+ theEdgeDir = gp::DX();
+
+ // Find attachment points (closest distance between the edge and the face)
+ BRepExtrema_DistShapeShape aDistAdaptor (theEdge, theFace, Extrema_ExtFlag_MIN);
+ if (!aDistAdaptor.IsDone() || aDistAdaptor.NbSolution() <1)
+ {
+ return Standard_False;
+ }
+ myFirstPoint = aDistAdaptor.PointOnShape1 (1);
+ mySecondPoint = aDistAdaptor.PointOnShape2 (1);
+
+ // Take direction for dimension line (will be orthogonalized later) parallel to edge
+ BRepAdaptor_Curve aCurveAdaptor (theEdge);
+ Standard_Real aParam;
+ if (aDistAdaptor.SupportOnShape1 (1).ShapeType() == TopAbs_EDGE)
+ {
+ aDistAdaptor.ParOnEdgeS1 (1, aParam);
+ }
+ else
+ {
+ Standard_Real aD1 = aCurveAdaptor.Value(aCurveAdaptor.FirstParameter()).SquareDistance (myFirstPoint);
+ Standard_Real aD2 = aCurveAdaptor.Value(aCurveAdaptor.LastParameter()).SquareDistance (myFirstPoint);
+ aParam = (aD1 < aD2 ? aCurveAdaptor.FirstParameter() : aCurveAdaptor.LastParameter());
+ }
+ gp_Pnt aP;
+ gp_Vec aV;
+ aCurveAdaptor.D1 (aParam, aP, aV);
+ if (aV.SquareMagnitude() > gp::Resolution())
+ {
+ theEdgeDir = aV;
+ }
+
+ // reverse direction if parameter is close to the end of the curve,
+ // to reduce chances to have overlapping between dimension line and edge
+ if (Abs (aParam - aCurveAdaptor.FirstParameter()) < Abs (aParam - aCurveAdaptor.LastParameter()))
+ {
+ theEdgeDir.Reverse();
+ }
+
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+}
+
+//=======================================================================
+//function : InitTwoShapesPoints
+//purpose : Initialization of two points where dimension layouts
+// will be attached
+//=======================================================================
+Standard_Boolean PrsDim_LengthDimension::InitTwoShapesPoints (const TopoDS_Shape& theFirstShape,
+ const TopoDS_Shape& theSecondShape,
+ gp_Pln& theComputedPlane,
+ Standard_Boolean& theIsPlaneComputed)
+{
+ theIsPlaneComputed = Standard_False;
+ gp_Dir aDirAttach;
+ Standard_Boolean isInfinite = Standard_False;
+ Standard_Boolean isSuccess = Standard_False;
+ switch (theFirstShape.ShapeType())
+ {
+ case TopAbs_FACE:
+ {
+ // Initialization for face
+ gp_Pln aFirstPlane;
+ Handle(Geom_Surface) aFirstSurface;
+ PrsDim_KindOfSurface aFirstSurfKind;
+ Standard_Real aFirstOffset;
+
+ TopoDS_Face aFirstFace = TopoDS::Face (theFirstShape);
+
+ PrsDim::InitFaceLength (TopoDS::Face (theFirstShape),
+ aFirstPlane,
+ aFirstSurface,
+ aFirstSurfKind,
+ aFirstOffset);
+
+ if (theSecondShape.ShapeType() == TopAbs_FACE)
+ {
+ // Initialization for face
+ myGeometryType = GeometryType_Faces;
+ gp_Pln aSecondPlane;
+ Handle(Geom_Surface) aSecondSurface;
+ PrsDim_KindOfSurface aSecondSurfKind;
+ Standard_Real aSecondOffset;
+
+ TopoDS_Face aSecondFace = TopoDS::Face (theSecondShape);
+
+ PrsDim::InitFaceLength (aSecondFace,
+ aSecondPlane,
+ aSecondSurface,
+ aSecondSurfKind,
+ aSecondOffset);
+
+ if (aFirstSurfKind == PrsDim_KOS_Plane)
+ {
+ if (!aFirstPlane.Axis().Direction().IsParallel (aSecondPlane.Axis().Direction(), Precision::Angular()))
+ {
+ return Standard_False;
+ }
+
+ TopExp_Explorer anExplorer (theFirstShape, TopAbs_VERTEX);
+
+ // In case of infinite planes
+ if (!anExplorer.More())
+ {
+ myFirstPoint = aFirstPlane.Location();
+ }
+ else
+ {
+ myFirstPoint = BRep_Tool::Pnt (TopoDS::Vertex (anExplorer.Current()));
+ }
+
+ mySecondPoint = PrsDim::ProjectPointOnPlane (myFirstPoint, aSecondPlane);
+
+ Standard_Real anU, aV;
+ ElSLib::Parameters (aSecondPlane, mySecondPoint, anU, aV);
+
+ BRepTopAdaptor_FClass2d aClassifier (aSecondFace, Precision::Confusion());
+ TopAbs_State aState = aClassifier.Perform (gp_Pnt2d (anU, aV), Standard_False);
+
+ if (aState == TopAbs_OUT || aState == TopAbs_UNKNOWN)
+ {
+ mySecondPoint = PrsDim::Nearest (aSecondFace, myFirstPoint);
+ }
+
+ isSuccess = IsValidPoints (myFirstPoint, mySecondPoint);
+ if (isSuccess)
+ {
+ theComputedPlane = ComputePlane (aFirstPlane.Position().XDirection());
+ theIsPlaneComputed = Standard_True;
+ }
+ }
+ else // curvilinear faces
+ {
+ Standard_Real aU1Min, aV1Min, aU1Max, aV1Max;
+ Standard_Real aU2Min, aV2Min, aU2Max, aV2Max;
+ BRepTools::UVBounds (aFirstFace, aU1Min, aU1Max, aV1Min, aV1Max);
+ BRepTools::UVBounds (aSecondFace, aU2Min, aU2Max, aV2Min, aV2Max);
+
+ GeomAPI_ExtremaSurfaceSurface anExtrema (aFirstSurface, aSecondSurface,
+ aU1Min, aU1Max, aV1Min, aV1Max,
+ aU2Min, aU2Max, aV2Min, aV2Max);
+
+ Standard_Real aU1, aV1, aU2, aV2;
+ anExtrema.LowerDistanceParameters (aU1, aV1, aU2, aV2);
+ myFirstPoint = BRep_Tool::Surface (aFirstFace)->Value (aU1, aV1);
+ mySecondPoint = BRep_Tool::Surface (aSecondFace)->Value (aU2, aV2);
+
+ // Adjust automatic plane
+ gp_Ax2 aLocalAxes (myFirstPoint, gce_MakeDir (myFirstPoint, mySecondPoint));
+ aDirAttach = gce_MakeDir (aLocalAxes.XDirection ());
+
+ // Check points
+ isSuccess = IsValidPoints (myFirstPoint, mySecondPoint);
+ if (isSuccess)
+ {
+ theComputedPlane = ComputePlane (aDirAttach);
+ theIsPlaneComputed = Standard_True;
+ }
+ }
+
+ return isSuccess && IsValidPoints (myFirstPoint, mySecondPoint);
+ }
+ else if (theSecondShape.ShapeType() == TopAbs_EDGE)
+ {
+ myGeometryType = GeometryType_EdgeFace;
+ isSuccess = InitEdgeFaceLength (TopoDS::Edge (theSecondShape),
+ TopoDS::Face (theFirstShape),
+ aDirAttach);
+
+ if (isSuccess)
+ {
+ theComputedPlane = ComputePlane (aDirAttach);
+ theIsPlaneComputed = Standard_True;
+ }
+
+ return isSuccess;
+ }
+ }
+ break;
+
+ case TopAbs_EDGE:
+ {
+ if (theSecondShape.ShapeType() == TopAbs_VERTEX)
+ {
+ myGeometryType = GeometryType_EdgeVertex;
+ isSuccess = InitEdgeVertexLength (TopoDS::Edge (theFirstShape),
+ TopoDS::Vertex (theSecondShape),
+ aDirAttach,
+ isInfinite);
+
+ if (isSuccess)
+ {
+ theComputedPlane = ComputePlane (aDirAttach);
+ theIsPlaneComputed = Standard_True;
+ }
+
+ return isSuccess;
+ }
+ else if (theSecondShape.ShapeType() == TopAbs_EDGE)
+ {
+ myGeometryType = GeometryType_Edges;
+ isSuccess = InitTwoEdgesLength (TopoDS::Edge (theFirstShape),
+ TopoDS::Edge (theSecondShape),
+ aDirAttach);
+
+ if (isSuccess)
+ {
+ theComputedPlane = ComputePlane (aDirAttach);
+ theIsPlaneComputed = Standard_True;
+ }
+
+ return isSuccess;
+ }
+ else if (theSecondShape.ShapeType() == TopAbs_FACE)
+ {
+ myGeometryType = GeometryType_EdgeFace;
+ isSuccess = InitEdgeFaceLength (TopoDS::Edge (theFirstShape),
+ TopoDS::Face (theSecondShape),
+ aDirAttach);
+
+ if (isSuccess)
+ {
+ theComputedPlane = ComputePlane (aDirAttach);
+ theIsPlaneComputed = Standard_True;
+ }
+
+ return isSuccess;
+ }
+ }
+ break;
+
+ case TopAbs_VERTEX:
+ {
+ if (theSecondShape.ShapeType() == TopAbs_VERTEX)
+ {
+ myGeometryType = GeometryType_Points;
+ myFirstPoint = BRep_Tool::Pnt (TopoDS::Vertex (theFirstShape));
+ mySecondPoint = BRep_Tool::Pnt (TopoDS::Vertex (theSecondShape));
+
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+ }
+ else if (theSecondShape.ShapeType() == TopAbs_EDGE)
+ {
+ myGeometryType = GeometryType_EdgeVertex;
+ isSuccess = InitEdgeVertexLength (TopoDS::Edge(theSecondShape),
+ TopoDS::Vertex(theFirstShape),
+ aDirAttach,
+ isInfinite);
+ if (isSuccess)
+ {
+ theComputedPlane = ComputePlane (aDirAttach);
+ theIsPlaneComputed = Standard_True;
+ }
+
+ return isSuccess;
+ }
+ }
+ break;
+
+ case TopAbs_COMPOUND:
+ case TopAbs_COMPSOLID:
+ case TopAbs_SOLID:
+ case TopAbs_SHELL:
+ case TopAbs_WIRE:
+ case TopAbs_SHAPE:
+ break;
+ }
+
+ return Standard_False;
+}
+
+//=======================================================================
+//function : InitOneShapePoints
+//purpose : Initialization of two points where dimension layouts
+// will be attached
+// Attention: 1) <theShape> can be only the edge in currect implementation
+// 2) No length for infinite edge
+//=======================================================================
+Standard_Boolean PrsDim_LengthDimension::InitOneShapePoints (const TopoDS_Shape& theShape)
+{
+ if (theShape.ShapeType() != TopAbs_EDGE)
+ {
+ return Standard_False;
+ }
+
+ TopoDS_Edge anEdge = TopoDS::Edge (theShape);
+
+ BRepAdaptor_Curve aBrepCurve(anEdge);
+ Standard_Real aFirst = aBrepCurve.FirstParameter();
+ Standard_Real aLast = aBrepCurve.LastParameter();
+
+ if (aBrepCurve.GetType() != GeomAbs_Line)
+ {
+ return Standard_False;
+ }
+
+ Standard_Boolean isInfinite = (Precision::IsInfinite (aFirst) || Precision::IsInfinite (aLast));
+ if (isInfinite)
+ {
+ return Standard_False;
+ }
+
+ myFirstPoint = aBrepCurve.Value (aBrepCurve.FirstParameter());
+ mySecondPoint = aBrepCurve.Value (aBrepCurve.LastParameter());
+
+ return IsValidPoints (myFirstPoint, mySecondPoint);
+}
+
+//=======================================================================
+//function : GetTextPosition
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim_LengthDimension::GetTextPosition() const
+{
+ if (IsTextPositionCustom())
+ {
+ return myFixedTextPosition;
+ }
+
+ // Counts text position according to the dimension parameters
+ return GetTextPositionForLinear (myFirstPoint, mySecondPoint);
+}
+
+//=======================================================================
+//function : SetTextPosition
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::SetTextPosition (const gp_Pnt& theTextPos)
+{
+ if (!IsValid())
+ {
+ return;
+ }
+
+ myIsTextPositionFixed = Standard_True;
+ myFixedTextPosition = theTextPos;
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetDirection
+//purpose :
+//=======================================================================
+void PrsDim_LengthDimension::SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection)
+{
+ myHasCustomDirection = theUseDirection;
+ if (myHasCustomDirection)
+ myDirection = theDirection;
+}
--- /dev/null
+// Copyright (c) 1999-2013 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_LengthDimension_HeaderFile
+#define _PrsDim_LengthDimension_HeaderFile
+
+#include <PrsDim_Dimension.hxx>
+#include <PrsDim_KindOfDimension.hxx>
+#include <Geom_Plane.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+
+DEFINE_STANDARD_HANDLE (PrsDim_LengthDimension, PrsDim_Dimension)
+
+//! 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 PrsDim_LengthDimension : public PrsDim_Dimension
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_LengthDimension, PrsDim_Dimension)
+public:
+
+ //! 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 PrsDim_LengthDimension (const TopoDS_Face& theFace,
+ const TopoDS_Edge& theEdge);
+
+ //! Construct length dimension between two faces.
+ //! @param theFirstFace [in] the first face (first shape).
+ //! @param theSecondFace [in] the second face (second shape).
+ Standard_EXPORT PrsDim_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 PrsDim_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 PrsDim_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 PrsDim_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 Standard_OVERRIDE;
+
+ //! @return the model units string.
+ Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual gp_Pnt GetTextPosition() const Standard_OVERRIDE;
+
+ //! Set custom direction for dimension. If it is not set, the direction is obtained
+ //! from the measured geometry (e.g. line between points of dimension)
+ //! The direction does not change flyout direction of dimension.
+ //! @param theDirection [in] the dimension direction.
+ //! @param theUseDirection [in] boolean value if custom direction should be used.
+ Standard_EXPORT void SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection = Standard_True);
+
+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_OVERRIDE;
+
+ Standard_EXPORT virtual gp_Pln ComputePlane(const gp_Dir& theAttachDir) const;
+
+ //! Computes distance between dimension points. If custom direction is defined, the distance
+ //! is a projection value of the distance between points to this direction
+ //! @return dimension value
+ Standard_EXPORT Standard_Real ComputeValue() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode = 0) Standard_OVERRIDE;
+
+ //! Computes points bounded the flyout line for linear dimension.
+ //! Direction of flyout line equal to the custom direction of dimension if defined or
+ //! parallel to the main direction line
+ //! @param theFirstPoint [in] the first attach point of linear dimension.
+ //! @param theSecondPoint [in] the second attach point of linear dimension.
+ //! @param theLineBegPoint [out] the first attach point of linear dimension.
+ //! @param theLineEndPoint [out] the second attach point of linear dimension.
+ Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
+ gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
+ const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
+
+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:
+
+ gp_Pnt myFirstPoint;
+ gp_Pnt mySecondPoint;
+ TopoDS_Shape myFirstShape;
+ TopoDS_Shape mySecondShape;
+ gp_Dir myDirection;
+ Standard_Boolean myHasCustomDirection;
+};
+
+#endif // _PrsDim_LengthDimension_HeaderFile
--- /dev/null
+// Created on: 1998-01-23
+// Created by: Sergey ZARITCHNY
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_EllipseRadiusDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <PrsDim_MaxRadiusDimension.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <DsgPrs_EllipseRadiusPresentation.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_OffsetCurve.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_SurfaceOfLinearExtrusion.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Text.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveCurve.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_MaxRadiusDimension, PrsDim_EllipseRadiusDimension)
+
+//=======================================================================
+//function : PrsDim_MaxRadiusDimension
+//purpose :
+//=======================================================================
+PrsDim_MaxRadiusDimension::PrsDim_MaxRadiusDimension(const TopoDS_Shape& aShape,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText)
+:PrsDim_EllipseRadiusDimension(aShape, aText)
+{
+ myVal = aVal;
+ mySymbolPrs = DsgPrs_AS_LASTAR;
+ myAutomaticPosition = Standard_True;
+ myArrowSize = myVal / 100.;
+}
+
+//=======================================================================
+//function : PrsDim_MaxRadiusDimension
+//purpose :
+//=======================================================================
+
+PrsDim_MaxRadiusDimension::PrsDim_MaxRadiusDimension(const TopoDS_Shape& aShape,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText,
+ const gp_Pnt& aPosition,
+ const DsgPrs_ArrowSide aSymbolPrs,
+ const Standard_Real anArrowSize)
+:PrsDim_EllipseRadiusDimension(aShape, aText)
+{
+ myVal = aVal;
+ mySymbolPrs = aSymbolPrs;
+ myPosition = aPosition;
+ myAutomaticPosition = Standard_False;
+ SetArrowSize( anArrowSize );
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+void PrsDim_MaxRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer /*aMode*/)
+{
+// if( myAutomaticPosition )
+ {//ota : recompute in any case
+ ComputeGeometry();
+ myEllipse.SetMajorRadius(myVal);
+ gp_Vec v1(myEllipse.XAxis().Direction());
+ v1 *=myVal;
+ myApexP = myEllipse.Location().Translated(v1);
+ myApexN = myEllipse.Location().Translated(-v1);
+ }
+ if(myIsAnArc) ComputeArcOfEllipse(aPresentation);
+ else
+ ComputeEllipse(aPresentation);
+}
+
+//=======================================================================
+//function : ComputeEllipse
+//purpose :
+//=======================================================================
+
+void PrsDim_MaxRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aPresentation)
+{
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+
+ // size
+ if( !myArrowSizeIsDefined ) {
+ myArrowSize = Min(myArrowSize,myVal / 5.);
+ }
+ arr->SetLength(myArrowSize);
+
+ Standard_Real U;//,V;
+ gp_Pnt curPos, Center;
+ Center = myEllipse.Location();
+ if( myAutomaticPosition )
+ {
+ myPosition = Center;
+ myEndOfArrow = myApexP;
+ myAutomaticPosition = Standard_True;
+
+ if ( myIsSetBndBox )
+ myPosition = PrsDim::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
+ myBndBox );
+ curPos = myPosition;
+ }
+ else //!AutomaticPosition
+ {
+ curPos = myPosition;
+ gp_Lin L1(myEllipse.XAxis());
+ U = ElCLib::Parameter ( L1, curPos );
+ curPos = ElCLib::Value (U, L1);
+ if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
+ myEndOfArrow = myApexP ;
+ else
+ myEndOfArrow = myApexN ;
+ }
+
+ // Presenatation
+ DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, curPos,
+ myEndOfArrow, Center, Standard_True, mySymbolPrs);
+
+}
+
+//=======================================================================
+//function : ComputeArcOfEllipse
+//purpose :
+//=======================================================================
+
+void PrsDim_MaxRadiusDimension::ComputeArcOfEllipse(const Handle(Prs3d_Presentation)& aPresentation)
+{
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+
+ // size
+ if( !myArrowSizeIsDefined ) {
+ myArrowSize = Min(myArrowSize,myVal / 5.);
+ }
+ arr->SetLength(myArrowSize);
+
+ Standard_Real par;
+ gp_Pnt curPos, Center;
+ Center = myEllipse.Location();
+ Standard_Boolean IsInDomain = Standard_True;
+ if( myAutomaticPosition )
+ {
+ myEndOfArrow = PrsDim::NearestApex(myEllipse, myApexP, myApexN,
+ myFirstPar, myLastPar, IsInDomain);
+ myPosition = Center;
+ myAutomaticPosition = Standard_True;
+ if ( myIsSetBndBox )
+ myPosition = PrsDim::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
+ myBndBox );
+ curPos = myPosition;
+ }
+ else //!AutomaticPosition
+ {
+ curPos = myPosition;
+// ElSLib::Parameters ( myPlane->Pln(), curPos, U, V );
+// curPos = ElSLib::Value (U, V, myPlane->Pln());
+ gp_Lin L1(myEllipse.XAxis());
+ par = ElCLib::Parameter ( L1, curPos );
+ curPos = ElCLib::Value (par, L1);
+ if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
+ myEndOfArrow = myApexP ;
+ else
+ myEndOfArrow = myApexN ;
+ par = ElCLib::Parameter ( myEllipse, myEndOfArrow );
+ IsInDomain = PrsDim::InDomain( myFirstPar, myLastPar, par );
+ myPosition = curPos;
+ }
+
+// Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
+ Standard_Real parStart = 0.;
+ if( !IsInDomain )
+ {
+ if(PrsDim::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
+ PrsDim::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
+ parStart = myFirstPar;
+ else
+ parStart = myLastPar;
+ }
+ if(!myIsOffset)
+ DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myEllipse,
+ curPos, myEndOfArrow, Center, parStart, IsInDomain,
+ Standard_True, mySymbolPrs);
+ else
+ DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myOffsetCurve,
+ curPos, myEndOfArrow, Center, parStart, IsInDomain,
+ Standard_True, mySymbolPrs);
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+
+void PrsDim_MaxRadiusDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer /*aMode*/)
+{
+
+ gp_Pnt center = myEllipse.Location();
+ gp_Pnt AttachmentPoint = myPosition;
+ Standard_Real dist = center.Distance(AttachmentPoint);
+ Standard_Real aRadius = myVal;
+ //Standard_Real inside = Standard_False;
+ gp_Pnt pt1;
+ if (dist > aRadius) pt1 = AttachmentPoint;
+ else
+ pt1 = myEndOfArrow;
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+ Handle(Select3D_SensitiveSegment)
+ seg = new Select3D_SensitiveSegment(own, center , pt1);
+ aSelection->Add(seg);
+
+ // Text
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
+ AttachmentPoint.X(),
+ AttachmentPoint.Y(),
+ AttachmentPoint.Z(),
+ AttachmentPoint.X()+size,
+ AttachmentPoint.Y()+size,
+ AttachmentPoint.Z()+size);
+ aSelection->Add(box);
+
+ // Arc of Ellipse
+ if(myIsAnArc)
+ {
+
+ Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
+ if(!PrsDim::InDomain(myFirstPar, myLastPar, parEnd))
+ {
+ Standard_Real parStart, par;
+ if(PrsDim::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
+ PrsDim::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
+ par = myFirstPar;
+ else
+ par = myLastPar;
+ gp_Vec Vapex(center, ElCLib::Value( parEnd, myEllipse )) ;
+ gp_Vec Vpnt (center, ElCLib::Value( par, myEllipse )) ;
+ gp_Dir dir(Vpnt ^ Vapex);
+ if(myEllipse.Position().Direction().IsOpposite( dir, Precision::Angular())) {
+ parStart = parEnd;
+ parEnd = par;
+ }
+ else
+ parStart = par;
+
+ Handle(Geom_Curve)TrimCurve;
+ if(myIsOffset)
+ {
+ Handle(Geom_Curve) aCurve = myOffsetCurve;
+ TrimCurve = new Geom_TrimmedCurve( aCurve, parStart, parEnd );
+ }
+ else
+ {
+ Handle(Geom_Ellipse) Ellipse = new Geom_Ellipse( myEllipse );
+ TrimCurve = new Geom_TrimmedCurve( Ellipse, parStart, parEnd );
+ }
+ Handle( Select3D_SensitiveCurve ) SensArc;
+ SensArc = new Select3D_SensitiveCurve( own, TrimCurve );
+ aSelection->Add( SensArc );
+ }
+ }
+
+}
--- /dev/null
+// Created on: 1998-01-22
+// Created by: Sergey ZARITCHNY
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_MaxRadiusDimension_HeaderFile
+#define _PrsDim_MaxRadiusDimension_HeaderFile
+
+#include <PrsDim_EllipseRadiusDimension.hxx>
+#include <DsgPrs_ArrowSide.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_MaxRadiusDimension, PrsDim_EllipseRadiusDimension)
+
+//! Ellipse Max radius dimension of a Shape which can be Edge
+//! or Face (planar or cylindrical(surface of extrusion or
+//! surface of offset))
+class PrsDim_MaxRadiusDimension : public PrsDim_EllipseRadiusDimension
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_MaxRadiusDimension, PrsDim_EllipseRadiusDimension)
+public:
+
+ //! Max Ellipse radius dimension
+ //! Shape can be edge , planar face or cylindrical face
+ Standard_EXPORT PrsDim_MaxRadiusDimension(const TopoDS_Shape& aShape, const Standard_Real aVal, const TCollection_ExtendedString& aText);
+
+ //! Max Ellipse radius dimension with position
+ //! Shape can be edge , planar face or cylindrical face
+ Standard_EXPORT PrsDim_MaxRadiusDimension(const TopoDS_Shape& aShape, const Standard_Real aVal, const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.0);
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeEllipse (const Handle(Prs3d_Presentation)& aPresentation);
+
+ Standard_EXPORT void ComputeArcOfEllipse (const Handle(Prs3d_Presentation)& aPresentation);
+
+private:
+
+ gp_Pnt myApexP;
+ gp_Pnt myApexN;
+ gp_Pnt myEndOfArrow;
+
+};
+
+#endif // _PrsDim_MaxRadiusDimension_HeaderFile
--- /dev/null
+// Created on: 2000-10-20
+// Created by: Julia DOROVSKIKH
+// Copyright (c) 2000-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_MidPointRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <DsgPrs_MidPointPresentation.hxx>
+#include <ElCLib.hxx>
+#include <gce_MakeLin.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Elips.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveCurve.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_MidPointRelation, PrsDim_Relation)
+
+//=======================================================================
+//function : PrsDim_MidPointRelation
+//purpose :
+//=======================================================================
+PrsDim_MidPointRelation::PrsDim_MidPointRelation(const TopoDS_Shape& aMidPointTool,
+ const TopoDS_Shape& FirstShape,
+ const TopoDS_Shape& SecondShape,
+ const Handle(Geom_Plane)& aPlane)
+:PrsDim_Relation(),
+ myTool(aMidPointTool)
+{
+ SetFirstShape(FirstShape);
+ SetSecondShape(SecondShape);
+ SetPlane(aPlane);
+ myPosition = aPlane->Pln().Location();
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aprs,
+ const Standard_Integer)
+{
+ if (myTool.ShapeType() == TopAbs_VERTEX)
+ {
+ gp_Pnt pp;
+ Standard_Boolean isonplane;
+ if ( PrsDim::ComputeGeometry(TopoDS::Vertex(myTool),pp,myPlane,isonplane) )
+ {
+ if ( !isonplane ) ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myTool),pp);
+ }
+ myMidPoint = pp;
+ }
+ else return;
+
+ if ( myAutomaticPosition ) myPosition = myMidPoint;
+
+ switch (myFShape.ShapeType())
+ {
+ case TopAbs_FACE :
+ {
+ ComputeFaceFromPnt(aprs, Standard_True);
+ }
+ break;
+ case TopAbs_EDGE :
+ {
+ ComputeEdgeFromPnt(aprs, Standard_True);
+ }
+ break;
+ case TopAbs_VERTEX :
+ {
+ ComputeVertexFromPnt(aprs, Standard_True);
+ }
+ break;
+ default:
+ break;
+ }
+
+ switch (mySShape.ShapeType())
+ {
+ case TopAbs_FACE :
+ {
+ ComputeFaceFromPnt(aprs, Standard_False);
+ }
+ break;
+ case TopAbs_EDGE :
+ {
+ ComputeEdgeFromPnt(aprs, Standard_False);
+ }
+ break;
+ case TopAbs_VERTEX :
+ {
+ ComputeVertexFromPnt(aprs, Standard_False);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
+ const Standard_Integer)
+{
+ Handle(Select3D_SensitiveSegment) seg;
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+
+ if ( !myMidPoint.IsEqual(myFAttach,Precision::Confusion()) )
+ {
+ // segment from mid point to the first geometry
+ seg = new Select3D_SensitiveSegment(own,myFAttach,myMidPoint);
+ aSel->Add(seg);
+ // segment from mid point to the second geometry
+ seg = new Select3D_SensitiveSegment(own,mySAttach,myMidPoint);
+ aSel->Add(seg);
+ }
+ if ( !myMidPoint.IsEqual(myPosition,Precision::Confusion()) )
+ {
+ // segment from mid point to the text position
+ seg = new Select3D_SensitiveSegment(own,myMidPoint,myPosition);
+ aSel->Add(seg);
+ }
+
+ // center of the symmetry - circle around the MidPoint
+ gp_Ax2 ax = myPlane->Pln().Position().Ax2();
+ ax.SetLocation(myMidPoint);
+ Standard_Real rad = myFAttach.Distance(myMidPoint)/20.0;
+ gp_Circ aCircleM (ax,rad);
+ Handle(Geom_Curve) thecir = new Geom_Circle(aCircleM);
+ Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecir);
+ aSel->Add(scurv);
+
+ Handle(Geom_Curve) curv;
+ gp_Pnt firstp,lastp;
+ Standard_Boolean isInfinite,isOnPlane;
+ Handle(Geom_Curve) extCurv;
+
+ // segment on first curve
+ if ( myFShape.ShapeType() == TopAbs_EDGE )
+ {
+ TopoDS_Edge E = TopoDS::Edge(myFShape);
+ if ( !PrsDim::ComputeGeometry(E,curv,firstp,lastp,extCurv,isInfinite,isOnPlane,myPlane) ) return;
+ if ( curv->IsInstance(STANDARD_TYPE(Geom_Line)) ) // case of line
+ {
+ // segment on line
+ seg = new Select3D_SensitiveSegment(own,myFirstPnt1,myFirstPnt2);
+ aSel->Add(seg);
+ }
+ else if ( curv->IsInstance(STANDARD_TYPE(Geom_Circle)) ) // case of circle
+ {
+ // segment on circle
+ Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv);
+ Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),myFirstPnt1);
+ Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),myFirstPnt2);
+ Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
+
+ scurv = new Select3D_SensitiveCurve(own, thecu);
+ aSel->Add(scurv);
+ }
+ else if ( curv->IsInstance(STANDARD_TYPE(Geom_Ellipse)) ) // case of ellipse
+ {
+ // segment on ellipse
+ Handle(Geom_Ellipse) theEll = Handle(Geom_Ellipse)::DownCast (curv);
+ Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),myFirstPnt1);
+ Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),myFirstPnt2);
+ Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
+
+ scurv = new Select3D_SensitiveCurve(own, thecu);
+ aSel->Add(scurv);
+ }
+ }
+
+ // segment on second curve
+ if ( mySShape.ShapeType() == TopAbs_EDGE )
+ {
+ TopoDS_Edge E = TopoDS::Edge(mySShape);
+ if ( !PrsDim::ComputeGeometry(E,curv,firstp,lastp,extCurv,isInfinite,isOnPlane,myPlane) ) return;
+ if ( curv->IsInstance(STANDARD_TYPE(Geom_Line)) ) // case of line
+ {
+ // segment on line
+ seg = new Select3D_SensitiveSegment(own,mySecondPnt1,mySecondPnt2);
+ aSel->Add(seg);
+ }
+ else if ( curv->IsInstance(STANDARD_TYPE(Geom_Circle)) ) // case of circle
+ {
+ // segment on circle
+ Handle(Geom_Circle) thecirc = Handle(Geom_Circle)::DownCast (curv);
+ Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),mySecondPnt1);
+ Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),mySecondPnt2);
+ Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
+
+ scurv = new Select3D_SensitiveCurve(own, thecu);
+ aSel->Add(scurv);
+ }
+ else if ( curv->IsInstance(STANDARD_TYPE(Geom_Ellipse)) ) // case of ellipse
+ {
+ // segment on ellipse
+ Handle(Geom_Ellipse) theEll = Handle(Geom_Ellipse)::DownCast (curv);
+ Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),mySecondPnt1);
+ Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),mySecondPnt2);
+ Handle(Geom_Curve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
+
+ scurv = new Select3D_SensitiveCurve(own, thecu);
+ aSel->Add(scurv);
+ }
+ }
+}
+
+//=======================================================================
+//function : ComputeFaceFromPnt
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::ComputeFaceFromPnt(const Handle(Prs3d_Presentation)&,
+ const Standard_Boolean /*first*/)
+{
+}
+
+//=======================================================================
+//function : ComputeEdgeFromPnt
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::ComputeEdgeFromPnt(const Handle(Prs3d_Presentation)& aprs,
+ const Standard_Boolean first)
+{
+ TopoDS_Edge E;
+ if ( first ) E = TopoDS::Edge(myFShape);
+ else E = TopoDS::Edge(mySShape);
+
+ Handle(Geom_Curve) geom;
+ gp_Pnt ptat1,ptat2;
+ Handle(Geom_Curve) extCurv;
+ Standard_Boolean isInfinite,isOnPlane;
+ if ( !PrsDim::ComputeGeometry(E, geom, ptat1, ptat2, extCurv, isInfinite, isOnPlane, myPlane) ) return;
+
+ gp_Ax2 ax = myPlane->Pln().Position().Ax2();
+
+ if ( geom->IsInstance(STANDARD_TYPE(Geom_Line)) )
+ {
+ if ( !isInfinite ) ComputePointsOnLine(ptat1,ptat2,first);
+ else
+ {
+ const gp_Lin& line = Handle(Geom_Line)::DownCast (geom)->Lin();
+ ComputePointsOnLine(line,first);
+ }
+ if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,
+ myFAttach,myFirstPnt1,myFirstPnt2,first);
+ else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,
+ mySAttach,mySecondPnt1,mySecondPnt2,first);
+ }
+ else if ( geom->IsInstance(STANDARD_TYPE(Geom_Circle)) )
+ {
+ Handle(Geom_Circle) geom_cir (Handle(Geom_Circle)::DownCast (geom));
+ gp_Circ circ (geom_cir->Circ());
+ ComputePointsOnCirc(circ,ptat1,ptat2,first);
+ if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,circ,myMidPoint,myPosition,
+ myFAttach,myFirstPnt1,myFirstPnt2,first);
+ else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,circ,myMidPoint,myPosition,
+ mySAttach,mySecondPnt1,mySecondPnt2,first);
+ }
+ else if ( geom->IsInstance(STANDARD_TYPE(Geom_Ellipse)) )
+ {
+ Handle(Geom_Ellipse) geom_ell (Handle(Geom_Ellipse)::DownCast (geom));
+ gp_Elips elips (geom_ell->Elips());
+ ComputePointsOnElips(elips,ptat1,ptat2,first);
+ if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,elips,myMidPoint,myPosition,
+ myFAttach,myFirstPnt1,myFirstPnt2,first);
+ else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,elips,myMidPoint,myPosition,
+ mySAttach,mySecondPnt1,mySecondPnt2,first);
+ }
+ else return;
+
+ // projection on myPlane
+ if ( !isOnPlane ) ComputeProjEdgePresentation(aprs,E,geom,ptat1,ptat2);
+}
+
+//=======================================================================
+//function : ComputeVertexFromPnt
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::ComputeVertexFromPnt(const Handle(Prs3d_Presentation)& aprs,
+ const Standard_Boolean first)
+{
+ gp_Ax2 ax = myPlane->Pln().Position().Ax2();
+ if ( first )
+ {
+ Standard_Boolean isOnPlane;
+ TopoDS_Vertex V = TopoDS::Vertex(myFShape);
+ PrsDim::ComputeGeometry(V, myFAttach, myPlane, isOnPlane);
+ DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,myFAttach,first);
+ if ( !isOnPlane ) ComputeProjVertexPresentation(aprs,V,myFAttach);
+ }
+ else
+ {
+ Standard_Boolean isOnPlane;
+ TopoDS_Vertex V = TopoDS::Vertex(mySShape);
+ PrsDim::ComputeGeometry(V, mySAttach, myPlane, isOnPlane);
+ DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,mySAttach,first);
+ if ( !isOnPlane ) ComputeProjVertexPresentation(aprs,V,mySAttach);
+ }
+}
+
+//=======================================================================
+//function : ComputePointsOnLine
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::ComputePointsOnLine(const gp_Lin& aLin,
+ const Standard_Boolean first)
+{
+ Standard_Real ppar = ElCLib::Parameter(aLin,myMidPoint);
+ gp_Pnt anAttach = ElCLib::Value(ppar,aLin);
+
+ Standard_Real dist = anAttach.Distance(myMidPoint)/10.0;
+ if ( dist < Precision::Confusion() ) dist = 10.0;
+
+ Standard_Real fpar = ppar + dist;
+ Standard_Real spar = ppar - dist;
+
+ gp_Pnt aPnt1 = ElCLib::Value(fpar,aLin);
+ gp_Pnt aPnt2 = ElCLib::Value(spar,aLin);
+
+ if ( first )
+ {
+ myFAttach = anAttach;
+ myFirstPnt1 = aPnt1;
+ myFirstPnt2 = aPnt2;
+ }
+ else
+ {
+ mySAttach = anAttach;
+ mySecondPnt1 = aPnt1;
+ mySecondPnt2 = aPnt2;
+ }
+}
+
+//=======================================================================
+//function : ComputePointsOnLine
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::ComputePointsOnLine(const gp_Pnt& pnt1, const gp_Pnt& pnt2,
+ const Standard_Boolean first)
+{
+ gp_Vec aVec (pnt1,pnt2);
+ gp_Lin aLin (pnt1,gp_Dir(aVec));
+
+ Standard_Real fpar = ElCLib::Parameter(aLin,pnt1);
+ Standard_Real spar = ElCLib::Parameter(aLin,pnt2);
+ Standard_Real ppar = ElCLib::Parameter(aLin,myMidPoint);
+
+ gp_Pnt aProjPnt = ElCLib::Value(ppar,aLin);
+ Standard_Real dist = myMidPoint.Distance(aProjPnt);
+ Standard_Real ll = pnt1.Distance(pnt2);
+ Standard_Real segm = Min(dist,ll)*0.75;
+ if ( dist < Precision::Confusion() ) segm = ll*0.75;
+
+ gp_Pnt anAttach,aPnt1,aPnt2;
+ anAttach = aProjPnt;
+ gp_Vec aVecTr;
+ if ( ppar <= fpar )
+ {
+ aPnt2 = pnt1;
+ aVecTr = gp_Vec(pnt2,pnt1);
+ aVecTr.Normalize();
+ aPnt1 = aProjPnt.Translated(aVecTr*segm);
+ }
+ else if ( ppar >= spar )
+ {
+ aPnt1 = pnt2;
+ aVecTr = gp_Vec(pnt1,pnt2);
+ aVecTr.Normalize();
+ aPnt2 = aProjPnt.Translated(aVecTr*segm);
+ }
+ else
+ {
+ Standard_Real dp1 = aProjPnt.Distance(pnt1);
+ Standard_Real dp2 = aProjPnt.Distance(pnt2);
+
+ segm = Min(dist,dp1)*0.75;
+ aVecTr = gp_Vec(aProjPnt,pnt1);
+ aVecTr.Normalize();
+ aPnt1 = aProjPnt.Translated(aVecTr*segm);
+
+ segm = Min(dist,dp2)*0.75;
+ aVecTr = gp_Vec(aProjPnt,pnt2);
+ aVecTr.Normalize();
+ aPnt2 = aProjPnt.Translated(aVecTr*segm);
+ }
+
+ if ( first )
+ {
+ myFAttach = anAttach;
+ myFirstPnt1 = aPnt1;
+ myFirstPnt2 = aPnt2;
+ }
+ else
+ {
+ mySAttach = anAttach;
+ mySecondPnt1 = aPnt1;
+ mySecondPnt2 = aPnt2;
+ }
+}
+
+//=======================================================================
+//function : ComputePointsOnCirc
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::ComputePointsOnCirc(const gp_Circ& aCirc,
+ const gp_Pnt& pnt1, const gp_Pnt& pnt2,
+ const Standard_Boolean first)
+{
+ gp_Pnt curpos = myMidPoint;
+
+ // Case of confusion between the current position and the center
+ // of the circle -> we move the current position
+ Standard_Real confusion (Precision::Confusion());
+ gp_Pnt aCenter = aCirc.Location();
+ if ( aCenter.Distance(curpos) <= confusion )
+ {
+ gp_Vec vprec(aCenter, pnt1);
+ vprec.Normalize();
+ curpos.Translate(vprec*1e-5);
+ }
+
+ Standard_Real pcurpos = ElCLib::Parameter(aCirc,curpos);
+
+ Standard_Real rad = M_PI / 5.0;
+ Standard_Real segm;
+
+ Standard_Real pFPnt;
+ Standard_Real pSPnt;
+
+ if ( pnt1.IsEqual(pnt2,confusion) ) // full circle
+ {
+ pFPnt = pcurpos - rad;
+ pSPnt = pcurpos + rad;
+ }
+ else
+ {
+ Standard_Real pFAttach = ElCLib::Parameter(aCirc,pnt1);
+ Standard_Real pSAttach = ElCLib::Parameter(aCirc,pnt2);
+
+ Standard_Real pSAttachM = pSAttach;
+ Standard_Real deltap = pSAttachM - pFAttach;
+ if ( deltap < 0 )
+ {
+ deltap += 2 * M_PI;
+ pSAttachM += 2 * M_PI;
+ }
+ pSAttachM -= pFAttach;
+
+ Standard_Real pmiddleout = pSAttachM/2.0 + M_PI;
+
+ Standard_Real pcurpos1 = pcurpos;
+ // define where curpos lays
+ if ( pcurpos1 < pFAttach )
+ {
+ pcurpos1 = pcurpos1 + 2 * M_PI - pFAttach;
+ if ( pcurpos1 > pSAttachM ) // out
+ {
+ segm = Min(rad,deltap*0.75);
+ if ( pcurpos1 > pmiddleout )
+ {
+ pcurpos = pFAttach;
+ pFPnt = pFAttach;
+ pSPnt = pFAttach + segm;
+ }
+ else
+ {
+ pcurpos = pSAttach;
+ pFPnt = pSAttach - segm;
+ pSPnt = pSAttach;
+ }
+ }
+ else // on arc
+ {
+ Standard_Real dp1 = pcurpos1 - pFAttach;
+ Standard_Real dp2 = pSAttachM - pcurpos1;
+
+ segm = Min(rad,dp1*0.75);
+ pFPnt = pcurpos - segm;
+
+ segm = Min(rad,dp2*0.75);
+ pSPnt = pcurpos + segm;
+ }
+ }
+ else if ( pcurpos1 > (pFAttach + deltap) ) // out
+ {
+ pcurpos1 -= pFAttach;
+ segm = Min(rad,deltap*0.75);
+ if ( pcurpos1 > pmiddleout )
+ {
+ pcurpos = pFAttach;
+ pFPnt = pFAttach;
+ pSPnt = pFAttach + segm;
+ }
+ else
+ {
+ pcurpos = pSAttach;
+ pFPnt = pSAttach - segm;
+ pSPnt = pSAttach;
+ }
+ }
+ else // on arc
+ {
+ Standard_Real dp1 = pcurpos1 - pFAttach;
+ Standard_Real dp2 = pSAttach - pcurpos1;
+
+ segm = Min(rad,dp1*0.75);
+ pFPnt = pcurpos - segm;
+
+ segm = Min(rad,dp2*0.75);
+ pSPnt = pcurpos + segm;
+ }
+ }
+
+ if ( first )
+ {
+ myFAttach = ElCLib::Value(pcurpos,aCirc);
+ myFirstPnt1 = ElCLib::Value(pFPnt,aCirc);
+ myFirstPnt2 = ElCLib::Value(pSPnt,aCirc);
+ }
+ else
+ {
+ mySAttach = ElCLib::Value(pcurpos,aCirc);
+ mySecondPnt1 = ElCLib::Value(pFPnt,aCirc);
+ mySecondPnt2 = ElCLib::Value(pSPnt,aCirc);
+ }
+}
+
+//=======================================================================
+//function : ComputePointsOnElips
+//purpose :
+//=======================================================================
+void PrsDim_MidPointRelation::ComputePointsOnElips(const gp_Elips& anEll,
+ const gp_Pnt& pnt1, const gp_Pnt& pnt2,
+ const Standard_Boolean first)
+{
+ gp_Pnt curpos = myMidPoint;
+
+ // Case of confusion between the current position and the center
+ // of the circle -> we move the current position
+ Standard_Real confusion (Precision::Confusion());
+ gp_Pnt aCenter = anEll.Location();
+ if ( aCenter.Distance(curpos) <= confusion )
+ {
+ gp_Vec vprec(aCenter, pnt1);
+ vprec.Normalize();
+ curpos.Translate(vprec*1e-5);
+ }
+
+ Standard_Real pcurpos = ElCLib::Parameter(anEll,curpos);
+
+ Standard_Real rad = M_PI / 5.0;
+ Standard_Real segm;
+
+ Standard_Real pFPnt;
+ Standard_Real pSPnt;
+
+ if ( pnt1.IsEqual(pnt2,confusion) ) // full circle
+ {
+ pFPnt = pcurpos - rad;
+ pSPnt = pcurpos + rad;
+ }
+ else
+ {
+ Standard_Real pFAttach = ElCLib::Parameter(anEll,pnt1);
+ Standard_Real pSAttach = ElCLib::Parameter(anEll,pnt2);
+
+ Standard_Real pSAttachM = pSAttach;
+ Standard_Real deltap = pSAttachM - pFAttach;
+ if ( deltap < 0 )
+ {
+ deltap += 2 * M_PI;
+ pSAttachM += 2 * M_PI;
+ }
+ pSAttachM -= pFAttach;
+
+ Standard_Real pmiddleout = pSAttachM / 2.0 + M_PI;
+
+ Standard_Real pcurpos1 = pcurpos;
+ // define where curpos lays
+ if ( pcurpos1 < pFAttach )
+ {
+ pcurpos1 = pcurpos1 + 2 * M_PI - pFAttach;
+ if ( pcurpos1 > pSAttachM ) // out
+ {
+ segm = Min(rad,deltap*0.75);
+ if ( pcurpos1 > pmiddleout )
+ {
+ pcurpos = pFAttach;
+ pFPnt = pFAttach;
+ pSPnt = pFAttach + segm;
+ }
+ else
+ {
+ pcurpos = pSAttach;
+ pFPnt = pSAttach - segm;
+ pSPnt = pSAttach;
+ }
+ }
+ else // on arc
+ {
+ Standard_Real dp1 = pcurpos1 - pFAttach;
+ Standard_Real dp2 = pSAttachM - pcurpos1;
+
+ segm = Min(rad,dp1*0.75);
+ pFPnt = pcurpos - segm;
+
+ segm = Min(rad,dp2*0.75);
+ pSPnt = pcurpos + segm;
+ }
+ }
+ else if ( pcurpos1 > (pFAttach + deltap) ) // out
+ {
+ pcurpos1 -= pFAttach;
+ segm = Min(rad,deltap*0.75);
+ if ( pcurpos1 > pmiddleout )
+ {
+ pcurpos = pFAttach;
+ pFPnt = pFAttach;
+ pSPnt = pFAttach + segm;
+ }
+ else
+ {
+ pcurpos = pSAttach;
+ pFPnt = pSAttach - segm;
+ pSPnt = pSAttach;
+ }
+ }
+ else // on arc
+ {
+ Standard_Real dp1 = pcurpos1 - pFAttach;
+ Standard_Real dp2 = pSAttach - pcurpos1;
+
+ segm = Min(rad,dp1*0.75);
+ pFPnt = pcurpos - segm;
+
+ segm = Min(rad,dp2*0.75);
+ pSPnt = pcurpos + segm;
+ }
+ }
+
+ if ( first )
+ {
+ myFAttach = ElCLib::Value(pcurpos,anEll);
+ myFirstPnt1 = ElCLib::Value(pFPnt,anEll);
+ myFirstPnt2 = ElCLib::Value(pSPnt,anEll);
+ }
+ else
+ {
+ mySAttach = ElCLib::Value(pcurpos,anEll);
+ mySecondPnt1 = ElCLib::Value(pFPnt,anEll);
+ mySecondPnt2 = ElCLib::Value(pSPnt,anEll);
+ }
+}
--- /dev/null
+// Created on: 2000-10-20
+// Created by: Julia DOROVSKIKH
+// Copyright (c) 2000-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_MidPointRelation_HeaderFile
+#define _PrsDim_MidPointRelation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+
+class Geom_Plane;
+class gp_Lin;
+class gp_Pnt;
+class gp_Circ;
+class gp_Elips;
+
+DEFINE_STANDARD_HANDLE(PrsDim_MidPointRelation, PrsDim_Relation)
+
+//! presentation of equal distance to point myMidPoint
+class PrsDim_MidPointRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_MidPointRelation, PrsDim_Relation)
+public:
+
+ Standard_EXPORT PrsDim_MidPointRelation(const TopoDS_Shape& aSymmTool, const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& aPlane);
+
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+ void SetTool (const TopoDS_Shape& aMidPointTool) { myTool = aMidPointTool; }
+
+ const TopoDS_Shape& GetTool() const { return myTool; }
+
+private:
+
+ Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeFaceFromPnt (const Handle(Prs3d_Presentation)& aprs, const Standard_Boolean first);
+
+ Standard_EXPORT void ComputeEdgeFromPnt (const Handle(Prs3d_Presentation)& aprs, const Standard_Boolean first);
+
+ Standard_EXPORT void ComputeVertexFromPnt (const Handle(Prs3d_Presentation)& aprs, const Standard_Boolean first);
+
+ Standard_EXPORT void ComputePointsOnLine (const gp_Lin& aLin, const Standard_Boolean first);
+
+ Standard_EXPORT void ComputePointsOnLine (const gp_Pnt& pnt1, const gp_Pnt& pnt2, const Standard_Boolean first);
+
+ Standard_EXPORT void ComputePointsOnCirc (const gp_Circ& aCirc, const gp_Pnt& pnt1, const gp_Pnt& pnt2, const Standard_Boolean first);
+
+ //! ComputePointsOn... methods set myFAttach, myFirstPnt and myLastPnt
+ //! from the following initial data: curve, end points, myMidPoint.
+ //! End points (pnt1 & pnt2) and curve define the trimmed curve.
+ //! If end points are equal, curve is not trimmed (line - special case).
+ //!
+ //! .------. pnt2
+ //! /
+ //! . circle . myLastPnt
+ //! | |
+ //! . pnt1 . myFAttach
+ //! \ arc / . myMidPoint
+ //! .______. myFirstPnt
+ Standard_EXPORT void ComputePointsOnElips (const gp_Elips& anEll, const gp_Pnt& pnt1, const gp_Pnt& pnt2, const Standard_Boolean first);
+
+private:
+
+ TopoDS_Shape myTool;
+ gp_Pnt myMidPoint;
+ gp_Pnt myFAttach;
+ gp_Pnt myFirstPnt1;
+ gp_Pnt myFirstPnt2;
+ gp_Pnt mySAttach;
+ gp_Pnt mySecondPnt1;
+ gp_Pnt mySecondPnt2;
+
+};
+
+#endif // _AIS_MidPointRelation_HeaderFile
--- /dev/null
+// Created on: 1998-01-27
+// Created by: Sergey ZARITCHNY
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_MinRadiusDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <PrsDim_EllipseRadiusDimension.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <DsgPrs_EllipseRadiusPresentation.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_OffsetCurve.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_SurfaceOfLinearExtrusion.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Text.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveCurve.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_MinRadiusDimension, PrsDim_EllipseRadiusDimension)
+
+//=======================================================================
+//function : PrsDim_MinRadiusDimension
+//purpose :
+//=======================================================================
+PrsDim_MinRadiusDimension::PrsDim_MinRadiusDimension(const TopoDS_Shape& aShape,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText)
+:PrsDim_EllipseRadiusDimension(aShape, aText)
+{
+ myVal = aVal;
+ mySymbolPrs = DsgPrs_AS_LASTAR;
+ myAutomaticPosition = Standard_True;
+ myArrowSize = myVal / 100.;
+}
+
+//=======================================================================
+//function : PrsDim_MinRadiusDimension
+//purpose :
+//=======================================================================
+
+PrsDim_MinRadiusDimension::PrsDim_MinRadiusDimension(const TopoDS_Shape& aShape,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText,
+ const gp_Pnt& aPosition,
+ const DsgPrs_ArrowSide aSymbolPrs,
+ const Standard_Real anArrowSize)
+:PrsDim_EllipseRadiusDimension(aShape, aText)
+{
+ myVal = aVal;
+ mySymbolPrs = aSymbolPrs;
+ myPosition = aPosition;
+ myAutomaticPosition = Standard_False;
+ SetArrowSize( anArrowSize );
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+void PrsDim_MinRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer /*aMode*/)
+{
+// if( myAutomaticPosition )
+ //{ //ota : recompute ellipse always
+ ComputeGeometry();
+ myEllipse.SetMinorRadius(myVal);
+ gp_Vec v1(myEllipse.YAxis().Direction());
+ v1 *=myVal;
+ myApexP = myEllipse.Location().Translated(v1);
+ myApexN = myEllipse.Location().Translated(-v1);
+// }
+ if(myIsAnArc) ComputeArcOfEllipse(aPresentation);
+ else
+ ComputeEllipse(aPresentation);
+}
+
+//=======================================================================
+//function : ComputeEllipse
+//purpose :
+//=======================================================================
+
+void PrsDim_MinRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aPresentation)
+{
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+
+ // size
+ if( !myArrowSizeIsDefined ) {
+ myArrowSize = Min(myArrowSize,myVal/5.);
+ }
+ arr->SetLength(myArrowSize);
+
+ Standard_Real U;//,V;
+ gp_Pnt curPos, Center;
+ Center = myEllipse.Location();
+ if( myAutomaticPosition )
+ {
+ myPosition = Center;
+ myEndOfArrow = myApexP;
+ myAutomaticPosition = Standard_True;
+
+ if ( myIsSetBndBox )
+ myPosition = PrsDim::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
+ myBndBox );
+ curPos = myPosition;
+ }
+ else //!AutomaticPosition
+ {
+ curPos = myPosition;
+ gp_Lin L1(myEllipse.YAxis());
+ U = ElCLib::Parameter ( L1, curPos );
+ curPos = ElCLib::Value (U, L1);
+ if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
+ myEndOfArrow = myApexP ;
+ else
+ myEndOfArrow = myApexN ;
+ myPosition = curPos;
+ }
+
+ // Presenatation
+ DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, curPos,
+ myEndOfArrow, Center, Standard_False, mySymbolPrs);
+
+}
+
+//=======================================================================
+//function : ComputeArcOfEllipse
+//purpose :
+//=======================================================================
+
+void PrsDim_MinRadiusDimension::ComputeArcOfEllipse(const Handle(Prs3d_Presentation)& aPresentation)
+{
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+
+ // size
+ if( !myArrowSizeIsDefined ) {
+ myArrowSize = Min(myArrowSize,myVal/5.);
+ }
+ arr->SetLength(myArrowSize);
+
+ Standard_Real par;
+ gp_Pnt curPos, Center;
+ Center = myEllipse.Location();
+ Standard_Boolean IsInDomain = Standard_True;
+ if( myAutomaticPosition )
+ {
+ myEndOfArrow = PrsDim::NearestApex(myEllipse, myApexP, myApexN,
+ myFirstPar, myLastPar, IsInDomain);
+ myPosition = Center;
+ myAutomaticPosition = Standard_True;
+ if ( myIsSetBndBox )
+ myPosition = PrsDim::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
+ myBndBox );
+ curPos = myPosition;
+
+ }
+ else //!AutomaticPosition
+ {
+ curPos = myPosition;
+ gp_Lin L1(myEllipse.YAxis());
+ par = ElCLib::Parameter ( L1, curPos );
+ curPos = ElCLib::Value (par, L1);
+ if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
+ myEndOfArrow = myApexP ;
+ else
+ myEndOfArrow = myApexN ;
+ par = ElCLib::Parameter ( myEllipse, myEndOfArrow );
+ IsInDomain = PrsDim::InDomain(myFirstPar, myLastPar, par);
+ myPosition = curPos;
+ }
+
+ Standard_Real parStart =0.;
+ if( !IsInDomain )
+ {
+ if(PrsDim::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
+ PrsDim::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
+ parStart = myFirstPar;
+ else
+ parStart = myLastPar;
+
+ }
+
+ if(!myIsOffset)
+ DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myEllipse,
+ curPos, myEndOfArrow, Center, parStart, IsInDomain,
+ Standard_True, mySymbolPrs);
+ else
+ DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myOffsetCurve,
+ curPos, myEndOfArrow, Center, parStart, IsInDomain,
+ Standard_True, mySymbolPrs);
+}
+
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+
+void PrsDim_MinRadiusDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer /*aMode*/)
+{
+
+ gp_Pnt center = myEllipse.Location();
+ gp_Pnt AttachmentPoint = myPosition;
+ Standard_Real dist = center.Distance(AttachmentPoint);
+ Standard_Real aRadius = myVal;
+ //Standard_Real inside = Standard_False;
+ gp_Pnt pt1;
+ if (dist > aRadius) pt1 = AttachmentPoint;
+ else
+ pt1 = myEndOfArrow;
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+ Handle(Select3D_SensitiveSegment)
+ seg = new Select3D_SensitiveSegment(own, center , pt1);
+ aSelection->Add(seg);
+
+ // Text
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
+ AttachmentPoint.X(),
+ AttachmentPoint.Y(),
+ AttachmentPoint.Z(),
+ AttachmentPoint.X()+size,
+ AttachmentPoint.Y()+size,
+ AttachmentPoint.Z()+size);
+ aSelection->Add(box);
+
+ // Arc of Ellipse
+ if(myIsAnArc)
+ {
+
+ Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
+ if(!PrsDim::InDomain(myFirstPar, myLastPar, parEnd))
+ {
+ Standard_Real parStart, par;
+ if(PrsDim::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
+ PrsDim::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
+ par = myFirstPar;
+ else
+ par = myLastPar;
+ gp_Vec Vapex(center, ElCLib::Value( parEnd, myEllipse )) ;
+ gp_Vec Vpnt (center, ElCLib::Value( par, myEllipse )) ;
+ gp_Dir dir(Vpnt ^ Vapex);
+ if(myEllipse.Position().Direction().IsOpposite( dir, Precision::Angular())) {
+ parStart = parEnd;
+ parEnd = par;
+ }
+ else
+ parStart = par;
+ Handle(Geom_Curve)TrimCurve;
+ if(myIsOffset)
+ {
+ Handle(Geom_Curve) aCurve = myOffsetCurve;
+ TrimCurve = new Geom_TrimmedCurve( aCurve, parStart, parEnd );
+ }
+ else
+ {
+ Handle(Geom_Ellipse) Ellipse = new Geom_Ellipse( myEllipse );
+ TrimCurve = new Geom_TrimmedCurve( Ellipse, parStart, parEnd );
+ }
+ Handle( Select3D_SensitiveCurve ) SensArc;
+ SensArc = new Select3D_SensitiveCurve( own, TrimCurve );
+ aSelection->Add( SensArc );
+ }
+ }
+
+}
--- /dev/null
+// Created on: 1998-01-22
+// Created by: Sergey ZARITCHNY
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_MinRadiusDimension_HeaderFile
+#define _PrsDim_MinRadiusDimension_HeaderFile
+
+#include <PrsDim_EllipseRadiusDimension.hxx>
+#include <DsgPrs_ArrowSide.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_MinRadiusDimension, PrsDim_EllipseRadiusDimension)
+
+//! -- Ellipse Min radius dimension of a Shape which
+//! can be Edge or Face (planar or cylindrical(surface of
+//! extrusion or surface of offset))
+class PrsDim_MinRadiusDimension : public PrsDim_EllipseRadiusDimension
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_MinRadiusDimension, PrsDim_EllipseRadiusDimension)
+public:
+
+ //! Max Ellipse radius dimension
+ //! Shape can be edge , planar face or cylindrical face
+ Standard_EXPORT PrsDim_MinRadiusDimension(const TopoDS_Shape& aShape, const Standard_Real aVal, const TCollection_ExtendedString& aText);
+
+ //! Max Ellipse radius dimension with position
+ //! Shape can be edge , planar face or cylindrical face
+ Standard_EXPORT PrsDim_MinRadiusDimension(const TopoDS_Shape& aShape, const Standard_Real aVal, const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.0);
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeEllipse (const Handle(Prs3d_Presentation)& aPresentation);
+
+ Standard_EXPORT void ComputeArcOfEllipse (const Handle(Prs3d_Presentation)& aPresentation);
+
+private:
+
+ gp_Pnt myApexP;
+ gp_Pnt myApexN;
+ gp_Pnt myEndOfArrow;
+
+};
+
+#endif // _PrsDim_MinRadiusDimension_HeaderFile
--- /dev/null
+// Created on: 1997-03-04
+// Created by: Jean-Pierre COMBE
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_OffsetDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+#include <DsgPrs_OffsetPresentation.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+#include <gce_MakeLin.hxx>
+#include <GeomAbs_SurfaceType.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Ax3.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Trsf.hxx>
+#include <gp_Vec.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <StdPrs_WFShape.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_Array2OfReal.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_OffsetDimension, PrsDim_Relation)
+
+//=======================================================================
+//function : PrsDim_OffsetDimension
+//purpose :
+//=======================================================================
+PrsDim_OffsetDimension::PrsDim_OffsetDimension(const TopoDS_Shape& FistShape,
+ const TopoDS_Shape& SecondShape,
+ const Standard_Real aVal,
+ const TCollection_ExtendedString& aText)
+:PrsDim_Relation(),
+myFAttach(0.,0.,0.),
+mySAttach(0.,0.,0.)
+{
+ myFShape = FistShape;
+ mySShape = SecondShape;
+ mySymbolPrs = DsgPrs_AS_BOTHAR;
+ myVal = aVal;
+ myText = aText;
+ //myArrowSize = fabs (myVal/5.);
+ myArrowSize = fabs (myVal/10.0);
+ if (myArrowSize > 30.) myArrowSize = 30.;
+ if (myArrowSize < 15.) myArrowSize = 15.;
+ //std::cout<<"PrsDim_OffsetDimension::PrsDim_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_OffsetDimension::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aprs,
+ const Standard_Integer)
+{
+ gp_Trsf aInvertTrsf = myRelativePos;
+ //myArrowSize = fabs (myVal/5.);
+ myArrowSize = fabs (myVal/10.0);
+ if (myArrowSize > 30.) myArrowSize = 30.;
+ if (myArrowSize < 15.) myArrowSize = 15.;
+ //std::cout<<"PrsDim_OffsetDimension::PrsDim_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
+
+ BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
+ BRepAdaptor_Surface surf2(TopoDS::Face(mySShape));
+
+ if (surf1.GetType() == GeomAbs_Cylinder ||
+ surf1.GetType() == GeomAbs_Cone ||
+ surf1.GetType() == GeomAbs_Torus) {
+ if (surf2.GetType() == GeomAbs_Cylinder ||
+ surf2.GetType() == GeomAbs_Cone ||
+ surf2.GetType() == GeomAbs_Torus) {
+ ComputeTwoAxesOffset(aprs, aInvertTrsf);
+ } else {
+ ComputeAxeFaceOffset(aprs, aInvertTrsf);
+ }
+ }
+ else {
+ //myDirAttach : oriente de myFShape vers mySShape
+ gp_Pln aPln = surf1.Plane();
+ gp_Pnt aPnt = aPln.Location();
+
+ gp_Pln bPln = surf2.Plane();
+
+ Standard_Real uPnt, vPnt;
+ ElSLib::Parameters (bPln , aPnt , uPnt, vPnt);
+ gp_Pnt bPnt = ElSLib::Value (uPnt, vPnt, bPln);
+ if (aPnt.IsEqual(bPnt,Precision::Confusion())) {
+ gp_Ax1 aAx1 = aPln.Axis();
+ myDirAttach = aAx1.Direction();
+ } else {
+ gp_Vec aVec (aPnt,bPnt);
+ myDirAttach.SetCoord(aVec.X(),aVec.Y(),aVec.Z());
+ }
+ ComputeTwoFacesOffset(aprs, aInvertTrsf);
+ }
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+void PrsDim_OffsetDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
+ const Standard_Integer)
+{
+ //myArrowSize = fabs (myVal/5.);
+ myArrowSize = fabs (myVal/10.0);
+ if (myArrowSize > 30.) myArrowSize = 30.;
+ if (myArrowSize < 15.) myArrowSize = 15.;
+ //std::cout<<"PrsDim_OffsetDimension::PrsDim_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
+ gp_Pnt myTFAttach = myFAttach.Transformed (myRelativePos);
+ gp_Pnt myTSAttach = mySAttach.Transformed (myRelativePos);
+ gp_Dir myTDirAttach = myDirAttach.Transformed (myRelativePos);
+ gp_Dir myTDirAttach2 = myDirAttach2.Transformed (myRelativePos);
+ gp_Pnt Tcurpos = myPosition.Transformed (myRelativePos);
+
+ gp_Lin L1 (myTFAttach,myTDirAttach);
+ gp_Lin L2 (myTSAttach,myTDirAttach2);
+ gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,Tcurpos),L1);
+ gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,Tcurpos),L2);
+ gp_Lin L3;
+
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+
+ if (!Proj1.IsEqual(Proj2,Precision::Confusion())) {
+ L3 = gce_MakeLin(Proj1,Proj2);
+ }
+ else { // cas ou la dimension est nulle
+ if (!Proj1.IsEqual(Tcurpos,Precision::Confusion())) {
+ gp_Vec v3 (Proj1,Tcurpos);
+ gp_Dir d3 (v3);
+ L3 = gce_MakeLin(Proj1,d3);
+ } else {
+ L3 = gce_MakeLin(Proj1,myTDirAttach);
+ }
+
+ // Text
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
+ Tcurpos.X(),
+ Tcurpos.Y(),
+ Tcurpos.Z(),
+ Tcurpos.X() + size,
+ Tcurpos.Y() + size,
+ Tcurpos.Z() + size);
+ aSel->Add(box);
+ }
+
+ Standard_Real parmin,parmax,parcur;
+ parmin = ElCLib::Parameter(L3,Proj1);
+ parmax = parmin;
+
+ parcur = ElCLib::Parameter(L3,Proj2);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ parcur = ElCLib::Parameter(L3,Tcurpos);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ gp_Pnt PointMin = ElCLib::Value(parmin,L3);
+ gp_Pnt PointMax = ElCLib::Value(parmax,L3);
+
+ Handle(Select3D_SensitiveSegment) seg;
+ if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ PointMin,
+ PointMax);
+ aSel->Add(seg);
+ }
+
+ if (!myTFAttach.IsEqual(Proj1,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ myTFAttach,
+ Proj1);
+ aSel->Add(seg);
+ }
+ if (!myTSAttach.IsEqual(Proj2,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ myTSAttach,
+ Proj2);
+ aSel->Add(seg);
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoAxesOffset
+//purpose :
+//=======================================================================
+void PrsDim_OffsetDimension::ComputeTwoAxesOffset(const Handle(Prs3d_Presentation)& aprs,
+ const gp_Trsf& aTrsf)
+{
+ BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
+ BRepAdaptor_Surface surf2(TopoDS::Face(mySShape));
+
+ gp_Ax1 Ax1Surf1, Ax1Surf2;
+
+ if (surf1.GetType() == GeomAbs_Cylinder) {
+ gp_Cylinder aCyl= surf1.Cylinder();
+ Ax1Surf1 = aCyl.Axis();
+ } else if (surf1.GetType() == GeomAbs_Cone) {
+ gp_Cone aCone= surf1.Cone();
+ Ax1Surf1 = aCone.Axis();
+ } else if (surf1.GetType() == GeomAbs_Torus) {
+ gp_Torus aTore= surf1.Torus();
+ Ax1Surf1 = aTore.Axis();
+ }
+ Standard_Real FirstUParam = surf1.FirstUParameter();
+ Standard_Real FirstVParam = surf1.FirstVParameter();
+ Standard_Real LastVParam = surf1.LastVParameter();
+ gp_Pnt P1First = surf1.Value(FirstUParam,FirstVParam);
+ gp_Pnt P1Last = surf1.Value(FirstUParam,LastVParam);
+
+
+ if (surf2.GetType() == GeomAbs_Cylinder) {
+ gp_Cylinder aCyl= surf2.Cylinder();
+ Ax1Surf2 = aCyl.Axis();
+ } else if (surf2.GetType() == GeomAbs_Cone) {
+ gp_Cone aCone= surf2.Cone();
+ Ax1Surf2 = aCone.Axis();
+ } else if (surf2.GetType() == GeomAbs_Torus) {
+ gp_Torus aTore= surf2.Torus();
+ Ax1Surf2 = aTore.Axis();
+ }
+ FirstUParam = surf2.FirstUParameter();
+ FirstVParam = surf2.FirstVParameter();
+ LastVParam = surf2.LastVParameter();
+ gp_Pnt P2First = surf2.Value(FirstUParam,FirstVParam);
+ gp_Pnt P2Last = surf2.Value(FirstUParam,LastVParam);
+
+
+
+ myFAttach = Ax1Surf1.Location();
+ mySAttach = Ax1Surf2.Location();
+ myDirAttach = Ax1Surf1.Direction();
+ myDirAttach2 = myDirAttach;
+ gp_Pnt curpos;
+ gp_Lin aProjLine = gce_MakeLin(myFAttach,myDirAttach);
+
+ if (myAutomaticPosition) {
+ curpos.SetX ( (myFAttach.X() + mySAttach.X()) /2. + 0.01);
+ curpos.SetY ( (myFAttach.Y() + mySAttach.Y()) /2. + 0.01);
+ curpos.SetZ ( (myFAttach.Z() + mySAttach.Z()) /2. + 0.01);
+ // + 0.01 pour eviter un raise de ComputeSelection...
+
+ myPosition = curpos;
+ }
+ else {
+ curpos = myPosition;
+ }
+
+ curpos = ElCLib::Value(ElCLib::Parameter(aProjLine,curpos),aProjLine);
+ // on projette pour la presentation
+
+ gp_Pnt P1FirstProj = ElCLib::Value(ElCLib::Parameter(aProjLine,P1First),aProjLine);
+ gp_Pnt P1LastProj = ElCLib::Value(ElCLib::Parameter(aProjLine,P1Last),aProjLine);
+ if (P1FirstProj.Distance(curpos) > P1LastProj.Distance(curpos))
+ myFAttach = P1FirstProj;
+ else
+ myFAttach = P1LastProj;
+
+ gp_Pnt P2FirstProj = ElCLib::Value(ElCLib::Parameter(aProjLine,P2First),aProjLine);
+ gp_Pnt P2LastProj = ElCLib::Value(ElCLib::Parameter(aProjLine,P2Last),aProjLine);
+ if (P2FirstProj.Distance(curpos) > P2LastProj.Distance(curpos))
+ mySAttach = P2FirstProj;
+ else
+ mySAttach = P2LastProj;
+
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ //std::cout<<"PrsDim_OffsetDimension::PrsDim_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
+ arr->SetLength(myArrowSize);
+ arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+
+ gp_Pnt myTFAttach = myFAttach.Transformed (aTrsf);
+ gp_Pnt myTSAttach = mySAttach.Transformed (aTrsf);
+ gp_Dir myTDirAttach = myDirAttach.Transformed (aTrsf);
+ gp_Dir myTDirAttach2 = myTDirAttach;
+ gp_Pnt Tcurpos = curpos.Transformed (aTrsf);
+
+ if (myIsSetBndBox)
+ Tcurpos = PrsDim::TranslatePointToBound( Tcurpos, myDirAttach, myBndBox );
+
+ DsgPrs_OffsetPresentation::AddAxes(aprs,
+ myDrawer,
+ myText,
+ myTFAttach,
+ myTSAttach,
+ myTDirAttach,
+ myTDirAttach2,
+ Tcurpos);
+
+ BRepBuilderAPI_Transform transform1 (myFShape, aTrsf, Standard_True);
+ TopoDS_Shape myTFShape = transform1.Shape();
+ BRepBuilderAPI_Transform transform2 (mySShape, aTrsf, Standard_True);
+ TopoDS_Shape myTSShape = transform2.Shape();
+
+ StdPrs_WFShape::Add (aprs, myTFShape, myDrawer);
+ StdPrs_WFShape::Add (aprs, myTSShape, myDrawer);
+}
+
+//=======================================================================
+//function : ComputeTwoFacesOffset
+//purpose :
+//=======================================================================
+void PrsDim_OffsetDimension::ComputeTwoFacesOffset(const Handle(Prs3d_Presentation)& aprs,
+ const gp_Trsf& aTrsf)
+{
+ gp_Dir norm1 = myDirAttach;
+ gp_Pnt curpos;
+ gp_Ax2 myax2;
+ if (myAutomaticPosition && ! myIsSetBndBox) {
+ TopExp_Explorer explo(myFShape,TopAbs_VERTEX);
+ if (explo.More()) {
+ TopoDS_Vertex vertref = TopoDS::Vertex(explo.Current());
+ myFAttach = BRep_Tool::Pnt(vertref);
+ gp_Vec trans = norm1.XYZ()*fabs(myVal/2);
+ gp_Ax2 ax2(myFAttach,norm1);
+ myDirAttach = ax2.XDirection();
+ curpos = myFAttach.Translated(trans);
+ if (myVal <= Precision::Confusion()) {
+ gp_Vec vecnorm1 = norm1.XYZ()*.001;
+ curpos.Translate(vecnorm1);
+ }
+ myPosition = curpos;
+ myax2 = ax2;
+ }
+ }
+ else {
+ if (myAutomaticPosition && myIsSetBndBox)
+ {
+ Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+ myBndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+ myPosition.SetCoord( aXmax, aYmax, aZmax );
+ }
+
+ curpos = myPosition;
+ myFAttach = PrsDim::Nearest(myFShape,curpos);
+ if (myFAttach.Distance(curpos) <= Precision::Confusion()) {
+ gp_Ax2 ax2(myFAttach,norm1);
+ myDirAttach = ax2.XDirection();
+ myax2 = ax2;
+ }
+ else {
+ gp_Dir orient(myFAttach.XYZ()-curpos.XYZ());
+ gp_Ax2 ax2(myFAttach,norm1);
+ if (orient.Angle(norm1) <= Precision::Angular()) {
+ myDirAttach = ax2.XDirection();
+ }
+ else {
+ gp_Dir adir = norm1 ^ orient;
+ myDirAttach = adir ^ norm1;
+ }
+ myax2 = ax2;
+ }
+ }
+ // en attendant mieux
+ mySAttach = PrsDim::Nearest(mySShape,curpos);
+ gp_Ax3 anax3 (myax2);
+ gp_Pln apln (anax3);
+
+ //gp_Pnt proj2;
+ Standard_Real u2,v2, uatt, vatt;
+ ElSLib::Parameters (apln , mySAttach, uatt,vatt);
+ ElSLib::Parameters (apln , curpos , u2,v2);
+
+ if (uatt== u2 && vatt == v2) {
+ myDirAttach2 = myDirAttach;
+ } else {
+ gp_Vec avec (ElSLib::Value (uatt,vatt, apln) , ElSLib::Value (u2,v2, apln));
+ myDirAttach2.SetCoord (avec.X(),avec.Y(),avec.Z());
+ }
+
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ //std::cout<<"PrsDim_OffsetDimension::PrsDim_OffsetDimension " << myArrowSize << " myArrowSize"<<std::endl;
+ arr->SetLength(myArrowSize);
+ arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+
+ gp_Pnt myTFAttach = myFAttach.Transformed (aTrsf);
+ gp_Pnt myTSAttach = mySAttach.Transformed (aTrsf);
+ gp_Dir myTDirAttach = myDirAttach.Transformed (aTrsf);
+ gp_Dir myTDirAttach2 = myDirAttach2.Transformed (aTrsf);
+ gp_Pnt Tcurpos = curpos.Transformed (aTrsf);
+
+/*
+ if (myIsSetBndBox)
+ {
+ BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
+ Tcurpos = PrsDim::TranslatePointToBound( Tcurpos, surf1.Plane().XAxis().Direction(), myBndBox );
+ }
+*/
+ DsgPrs_OffsetPresentation::Add(aprs,
+ myDrawer,
+ myText,
+ myTFAttach,
+ myTSAttach,
+ myTDirAttach,
+ myTDirAttach2,
+ Tcurpos);
+
+
+ BRepBuilderAPI_Transform transform1 (myFShape, aTrsf, Standard_True);
+ TopoDS_Shape myTFShape = transform1.Shape();
+ BRepBuilderAPI_Transform transform2 (mySShape, aTrsf, Standard_True);
+ TopoDS_Shape myTSShape = transform2.Shape();
+
+ StdPrs_WFShape::Add (aprs, myTFShape, myDrawer);
+ StdPrs_WFShape::Add (aprs, myTSShape, myDrawer);
+}
+
+//=======================================================================
+//function : ComputeAxeFaceOffset
+//purpose :
+//=======================================================================
+void PrsDim_OffsetDimension::ComputeAxeFaceOffset(const Handle(Prs3d_Presentation)& aprs,
+ const gp_Trsf& aTrsf)
+{
+ BRepBuilderAPI_Transform transform1 (myFShape, aTrsf, Standard_True);
+ TopoDS_Shape myTFShape = transform1.Shape();
+ BRepBuilderAPI_Transform transform2 (mySShape, aTrsf, Standard_True);
+ TopoDS_Shape myTSShape = transform2.Shape();
+
+ StdPrs_WFShape::Add (aprs, myTFShape, myDrawer);
+ StdPrs_WFShape::Add (aprs, myTSShape, myDrawer);
+}
+
--- /dev/null
+// Created on: 1997-03-04
+// Created by: Jean-Pierre COMBE
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_OffsetDimension_HeaderFile
+#define _PrsDim_OffsetDimension_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+#include <PrsDim_KindOfDimension.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_OffsetDimension, PrsDim_Relation)
+
+//! A framework to display dimensions of offsets.
+//! The relation between the offset and the basis shape
+//! is indicated. This relation is displayed with arrows and
+//! text. The text gives the dsitance between the offset
+//! and the basis shape.
+class PrsDim_OffsetDimension : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_OffsetDimension, PrsDim_Relation)
+public:
+
+ //! Constructs the offset display object defined by the
+ //! first shape aFShape, the second shape aSShape, the
+ //! dimension aVal, and the text aText.
+ Standard_EXPORT PrsDim_OffsetDimension(const TopoDS_Shape& FistShape, const TopoDS_Shape& SecondShape, const Standard_Real aVal, const TCollection_ExtendedString& aText);
+
+ //! Indicates that the dimension we are concerned with is an offset.
+ virtual PrsDim_KindOfDimension KindOfDimension() const Standard_OVERRIDE { return PrsDim_KOD_OFFSET; }
+
+ //! Returns true if the offset datum is movable.
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+ //! Sets a transformation aTrsf for presentation and
+ //! selection to a relative position.
+ void SetRelativePos (const gp_Trsf& aTrsf) { myRelativePos = aTrsf; }
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeTwoFacesOffset (const Handle(Prs3d_Presentation)& aPresentation, const gp_Trsf& aTrsf);
+
+ Standard_EXPORT void ComputeTwoAxesOffset (const Handle(Prs3d_Presentation)& aPresentation, const gp_Trsf& aTrsf);
+
+ Standard_EXPORT void ComputeAxeFaceOffset (const Handle(Prs3d_Presentation)& aPresentation, const gp_Trsf& aTrsf);
+
+private:
+
+ gp_Pnt myFAttach;
+ gp_Pnt mySAttach;
+ gp_Dir myDirAttach;
+ gp_Dir myDirAttach2;
+ gp_Trsf myRelativePos;
+
+};
+
+#endif // _PrsDim_OffsetDimension_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Jean-Pierre COMBE/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_ParallelRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <DsgPrs_LengthPresentation.hxx>
+#include <ElCLib.hxx>
+#include <gce_MakeLin.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_DomainError.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_ParallelRelation, PrsDim_Relation)
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_ParallelRelation::PrsDim_ParallelRelation(const TopoDS_Shape& aFShape,
+ const TopoDS_Shape& aSShape,
+ const Handle(Geom_Plane)& aPlane)
+{
+ myFShape = aFShape;
+ mySShape = aSShape;
+ myPlane = aPlane;
+ myAutomaticPosition = Standard_True;
+ myArrowSize = 0.01;
+ mySymbolPrs = DsgPrs_AS_BOTHAR;
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_ParallelRelation::PrsDim_ParallelRelation(const TopoDS_Shape& aFShape,
+ const TopoDS_Shape& aSShape,
+ const Handle(Geom_Plane)& aPlane,
+ const gp_Pnt& aPosition,
+ const DsgPrs_ArrowSide aSymbolPrs,
+ const Standard_Real anArrowSize)
+{
+ myFShape = aFShape;
+ mySShape = aSShape;
+ myPlane = aPlane;
+ myAutomaticPosition = Standard_False;
+ SetArrowSize( anArrowSize );
+ myPosition = aPosition;
+ mySymbolPrs = aSymbolPrs;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_ParallelRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer)
+{
+ switch (myFShape.ShapeType())
+ {
+ case TopAbs_FACE :
+ {
+ // cas longueur entre deux faces
+ ComputeTwoFacesParallel(aPresentation);
+ }
+ break;
+ case TopAbs_EDGE :
+ {
+ // cas longueur entre deux edges
+ ComputeTwoEdgesParallel(aPresentation);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+void PrsDim_ParallelRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer)
+{
+ gp_Lin L1 (myFAttach,myDirAttach);
+ gp_Lin L2 (mySAttach,myDirAttach);
+ gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,myPosition),L1);
+ gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,myPosition),L2);
+
+ gp_Lin L3;
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+
+ if (!Proj1.IsEqual(Proj2,Precision::Confusion()))
+ {
+ L3 = gce_MakeLin(Proj1,Proj2);
+ }
+ else
+ {
+ L3 = gce_MakeLin(Proj1,myDirAttach);
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle(Select3D_SensitiveBox) box =
+ new Select3D_SensitiveBox(own,
+ myPosition.X(),
+ myPosition.Y(),
+ myPosition.Z(),
+ myPosition.X()+size,
+ myPosition.Y()+size,
+ myPosition.Z()+size);
+ aSelection->Add(box);
+ }
+ Standard_Real parmin,parmax,parcur;
+ parmin = ElCLib::Parameter(L3,Proj1);
+ parmax = parmin;
+
+ parcur = ElCLib::Parameter(L3,Proj2);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ parcur = ElCLib::Parameter(L3,myPosition);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ gp_Pnt PointMin = ElCLib::Value(parmin,L3);
+ gp_Pnt PointMax = ElCLib::Value(parmax,L3);
+
+ Handle(Select3D_SensitiveSegment) seg;
+
+ if (!PointMin.IsEqual(PointMax,Precision::Confusion()))
+ {
+ seg = new Select3D_SensitiveSegment(own,
+ PointMin,
+ PointMax);
+ aSelection->Add(seg);
+ }
+ if (!myFAttach.IsEqual(Proj1,Precision::Confusion()))
+ {
+ seg = new Select3D_SensitiveSegment(own, myFAttach, Proj1);
+ aSelection->Add(seg);
+ }
+ if (!mySAttach.IsEqual(Proj2,Precision::Confusion()))
+ {
+ seg = new Select3D_SensitiveSegment(own, mySAttach, Proj2);
+ aSelection->Add(seg);
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoFacesParallel
+//purpose :
+//=======================================================================
+void PrsDim_ParallelRelation::ComputeTwoFacesParallel(const Handle(Prs3d_Presentation)&)
+{
+ throw Standard_NotImplemented("PrsDim_ParallelRelation::ComputeTwoFacesParallel not implemented");
+}
+
+//=======================================================================
+//function : ComputeTwoEdgesParallel
+//purpose :
+//=======================================================================
+void PrsDim_ParallelRelation::ComputeTwoEdgesParallel(const Handle(Prs3d_Presentation)& aPresentation)
+{
+ TopoDS_Edge E1 = TopoDS::Edge(myFShape);
+ TopoDS_Edge E2 = TopoDS::Edge(mySShape);
+
+ gp_Pnt ptat11,ptat12,ptat21,ptat22;//,pint3d;
+ Handle(Geom_Curve) geom1,geom2;
+ Standard_Boolean isInfinite1,isInfinite2;
+ Handle(Geom_Curve) extCurv;
+ if (!PrsDim::ComputeGeometry(E1,E2,myExtShape,
+ geom1,geom2,
+ ptat11,ptat12,ptat21,ptat22,
+ extCurv,
+ isInfinite1,isInfinite2,
+ myPlane))
+ {
+ return;
+ }
+
+ aPresentation->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape != 0));
+
+ gp_Lin l1;
+ gp_Lin l2;
+ Standard_Boolean isEl1 = Standard_False, isEl2 = Standard_False;
+
+ if (geom1->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
+ {
+ Handle(Geom_Ellipse) geom_el1 (Handle(Geom_Ellipse)::DownCast (geom1));
+ // construct lines through focuses
+ gp_Ax1 elAx = geom_el1->XAxis();
+ l1 = gp_Lin(elAx);
+ Standard_Real focex = geom_el1->MajorRadius() - geom_el1->Focal()/2.0;
+ gp_Vec transvec = gp_Vec(elAx.Direction())*focex;
+ ptat11 = geom_el1->Focus1().Translated(transvec);
+ ptat12 = geom_el1->Focus2().Translated(-transvec);
+ isEl1 = Standard_True;
+ }
+ else if (geom1->IsInstance(STANDARD_TYPE(Geom_Line)))
+ {
+ Handle(Geom_Line) geom_lin1 (Handle(Geom_Line)::DownCast (geom1));
+ l1 = geom_lin1->Lin();
+ }
+ else return;
+
+ if (geom2->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
+ {
+ Handle(Geom_Ellipse) geom_el2 (Handle(Geom_Ellipse)::DownCast (geom2));
+ // construct lines through focuses
+ gp_Ax1 elAx = geom_el2->XAxis();
+ l2 = gp_Lin(elAx);
+ Standard_Real focex = geom_el2->MajorRadius() - geom_el2->Focal()/2.0;
+ gp_Vec transvec = gp_Vec(elAx.Direction())*focex;
+ ptat21 = geom_el2->Focus1().Translated(transvec);
+ ptat22 = geom_el2->Focus2().Translated(-transvec);
+ isEl2 = Standard_True;
+ }
+ else if (geom2->IsInstance(STANDARD_TYPE(Geom_Line)))
+ {
+ Handle(Geom_Line) geom_lin2 (Handle(Geom_Line)::DownCast (geom2));
+ l2 = geom_lin2->Lin();
+ }
+ else return;
+
+ const Handle(Geom_Line)& geom_lin1 = new Geom_Line(l1);
+ const Handle(Geom_Line)& geom_lin2 = new Geom_Line(l2);
+
+ myDirAttach = l1.Direction();
+ // size
+ if( !myArrowSizeIsDefined ) {
+ Standard_Real arrSize1 (myArrowSize), arrSize2 (myArrowSize);
+ if (!isInfinite1) arrSize1 = ptat11.Distance(ptat12)/50.;
+ if (!isInfinite2) arrSize2 = ptat21.Distance(ptat22)/50.;
+ myArrowSize = Max(myArrowSize,Max(arrSize1,arrSize2));
+// myArrowSize = Min(myArrowSize,Min(arrSize1,arrSize2));
+ }
+
+ if ( myAutomaticPosition )
+ {
+ gp_Pnt curpos;
+ if ( !isInfinite1 )
+ {
+ gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2);
+ curpos.SetXYZ((ptat11.XYZ() + p2.XYZ())/2.);
+ }
+ else if ( !isInfinite2 )
+ {
+ gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l1,ptat21),l1);
+ curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())/2.);
+ }
+ else
+ {
+ curpos.SetXYZ((l1.Location().XYZ()+l2.Location().XYZ())/2.);
+ }
+ // offset pour eviter confusion Edge et Dimension
+ gp_Vec offset (myDirAttach);
+ offset = offset*myArrowSize*(-10.);
+ curpos.Translate(offset);
+ myPosition = curpos;
+ }
+
+ // recherche points attache
+ if (!isInfinite1)
+ {
+ if ( isEl1 )
+ {
+ if (myPosition.Distance(ptat11) < myPosition.Distance(ptat12)) myFAttach = ptat12;
+ else myFAttach = ptat11;
+ }
+ else
+ {
+ if (myPosition.Distance(ptat11) > myPosition.Distance(ptat12)) myFAttach = ptat12;
+ else myFAttach = ptat11;
+ }
+ }
+ else
+ {
+ myFAttach = ElCLib::Value(ElCLib::Parameter(l1,myPosition),l1);
+ }
+
+ if (!isInfinite2)
+ {
+ if ( isEl2 )
+ {
+ if (myPosition.Distance(ptat21) < myPosition.Distance(ptat22)) mySAttach = ptat22;
+ else mySAttach = ptat21;
+ }
+ else
+ {
+ if (myPosition.Distance(ptat21) > myPosition.Distance(ptat22)) mySAttach = ptat22;
+ else mySAttach = ptat21;
+ }
+ }
+ else
+ {
+ mySAttach = ElCLib::Value(ElCLib::Parameter(l2,myPosition),l2);
+ }
+ TCollection_ExtendedString aText (" //");
+
+ if (l1.Distance(l2) <= Precision::Confusion())
+ {
+ myArrowSize = 0.;
+ }
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+ arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+ if ( myExtShape == 1)
+ mySymbolPrs = DsgPrs_AS_FIRSTPT_LASTAR;
+ else if ( myExtShape == 2)
+ mySymbolPrs = DsgPrs_AS_FIRSTAR_LASTPT;
+
+ DsgPrs_LengthPresentation::Add(aPresentation,
+ myDrawer,
+ aText,
+ myFAttach,
+ mySAttach,
+ myDirAttach,
+ myPosition,
+ mySymbolPrs);
+ if ( (myExtShape != 0) && !extCurv.IsNull())
+ {
+ gp_Pnt pf, pl;
+ if ( myExtShape == 1 )
+ {
+ if (!isInfinite1)
+ {
+ pf = ptat11;
+ pl = ptat12;
+ }
+ ComputeProjEdgePresentation(aPresentation,E1,geom_lin1,pf,pl);
+ }
+ else
+ {
+ if (!isInfinite2)
+ {
+ pf = ptat21;
+ pl = ptat22;
+ }
+ ComputeProjEdgePresentation(aPresentation,E2,geom_lin2,pf,pl);
+ }
+ }
+}
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Jean-Pierre COMBE/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_ParallelRelation_HeaderFile
+#define _PrsDim_ParallelRelation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+#include <DsgPrs_ArrowSide.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_ParallelRelation, PrsDim_Relation)
+
+//! A framework to display constraints of parallelism
+//! between two or more Interactive Objects. These
+//! entities can be faces or edges.
+class PrsDim_ParallelRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_ParallelRelation, PrsDim_Relation)
+public:
+
+
+ //! Constructs an object to display parallel constraints.
+ //! This object is defined by the first shape aFShape and
+ //! the second shape aSShape and the plane aPlane.
+ Standard_EXPORT PrsDim_ParallelRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane);
+
+ //! Constructs an object to display parallel constraints.
+ //! This object is defined by the first shape aFShape and
+ //! the second shape aSShape the plane aPlane, the
+ //! position aPosition, the type of arrow, aSymbolPrs and
+ //! its size anArrowSize.
+ Standard_EXPORT PrsDim_ParallelRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane, const gp_Pnt& aPosition, const DsgPrs_ArrowSide aSymbolPrs, const Standard_Real anArrowSize = 0.01);
+
+ //! Returns true if the parallelism is movable.
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeTwoFacesParallel (const Handle(Prs3d_Presentation)& aPresentation);
+
+ Standard_EXPORT void ComputeTwoEdgesParallel (const Handle(Prs3d_Presentation)& aPresentation);
+
+private:
+
+ gp_Pnt myFAttach;
+ gp_Pnt mySAttach;
+ gp_Dir myDirAttach;
+
+};
+
+#endif // _PrsDim_ParallelRelation_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Jean-Pierre COMBE/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_PerpendicularRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <DsgPrs_PerpenPresentation.hxx>
+#include <ElCLib.hxx>
+#include <gce_MakeDir.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <GeomAPI.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Trsf.hxx>
+#include <gp_Vec.hxx>
+#include <IntAna2d_AnaIntersection.hxx>
+#include <IntAna2d_IntPoint.hxx>
+#include <Precision.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_PerpendicularRelation, PrsDim_Relation)
+
+//=======================================================================
+//function : Constructor
+//purpose : TwoEdgesPerpendicular
+//=======================================================================
+PrsDim_PerpendicularRelation::PrsDim_PerpendicularRelation(const TopoDS_Shape& aFShape,
+ const TopoDS_Shape& aSShape,
+ const Handle(Geom_Plane)& aPlane)
+:PrsDim_Relation()
+{
+ myFShape = aFShape;
+ mySShape = aSShape;
+ myPlane = aPlane;
+}
+
+//=======================================================================
+//function : Constructor
+//purpose : TwoFacesPerpendicular
+//=======================================================================
+PrsDim_PerpendicularRelation::PrsDim_PerpendicularRelation(const TopoDS_Shape& aFShape,
+ const TopoDS_Shape& aSShape)
+:PrsDim_Relation()
+{
+ myFShape = aFShape;
+ mySShape = aSShape;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_PerpendicularRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer)
+{
+ if (myFShape.ShapeType() == mySShape.ShapeType()) {
+ switch (myFShape.ShapeType()) {
+ case TopAbs_FACE :
+ {
+ // cas perpendiculaire entre deux faces
+ ComputeTwoFacesPerpendicular(aPresentation);
+ }
+ break;
+ case TopAbs_EDGE :
+ {
+ // cas perpendiculaire entre deux edges
+ ComputeTwoEdgesPerpendicular(aPresentation);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ // Cas pas traite - Edge/Face
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+void PrsDim_PerpendicularRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer)
+{
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+ const gp_Pnt& pos = myPosition;
+ Handle(Select3D_SensitiveSegment) seg;
+ Standard_Boolean ok1(Standard_False),ok2(Standard_False);
+
+ if (!myFAttach.IsEqual(pos,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ myFAttach,
+ pos);
+ aSelection->Add(seg);
+ ok1 = Standard_True;
+ }
+ if (!mySAttach.IsEqual(myPosition,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ mySAttach,
+ pos);
+ aSelection->Add(seg);
+ ok2 = Standard_True;
+ }
+
+ if (ok1 && ok2) {
+ gp_Vec vec1(gce_MakeDir(pos,myFAttach));
+ gp_Vec vec2(gce_MakeDir(pos,mySAttach));
+ Standard_Real dist1(pos.Distance(myFAttach));
+ Standard_Real dist2(pos.Distance(mySAttach));
+ vec1 *= dist1;
+ vec1 *= .2;
+ vec2 *= dist2;
+ vec2 *= .2;
+
+ gp_Pnt pAx11 = pos.Translated(vec1);
+ gp_Pnt pAx22 = pos.Translated(vec2);
+ gp_Pnt p_symb = pAx22.Translated(vec1);
+ seg = new Select3D_SensitiveSegment(own,pAx11,p_symb);
+ aSelection->Add(seg);
+ seg = new Select3D_SensitiveSegment(own,p_symb,pAx22);
+ aSelection->Add(seg);
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoFacesPerpendicular
+//purpose :
+//=======================================================================
+void PrsDim_PerpendicularRelation::ComputeTwoFacesPerpendicular
+ (const Handle(Prs3d_Presentation)& /*aPresentation*/)
+{
+}
+
+//=======================================================================
+//function : ComputeTwoEdgesPerpendicular
+//purpose :
+//=======================================================================
+void PrsDim_PerpendicularRelation::ComputeTwoEdgesPerpendicular(const Handle(Prs3d_Presentation)& aPresentation)
+{
+ // 3d lines
+ Handle(Geom_Curve) geom1,geom2;
+ gp_Pnt pint3d,p1,p2,pAx1,pAx2,ptat11,ptat12,ptat21,ptat22;
+ Standard_Boolean isInfinite1,isInfinite2;
+ Handle(Geom_Curve) extCurv;
+ if ( !PrsDim::ComputeGeometry(TopoDS::Edge(myFShape),TopoDS::Edge(mySShape),
+ myExtShape,
+ geom1,geom2,
+ ptat11,ptat12,ptat21,ptat22,
+ extCurv,
+ isInfinite1,isInfinite2,
+ myPlane) ) return;
+
+ Standard_Boolean interOut1(Standard_False),interOut2(Standard_False);
+
+ Handle(Geom_Line) geom_lin1;
+ Handle(Geom_Line) geom_lin2;
+ if ( geom1->IsInstance(STANDARD_TYPE(Geom_Ellipse)) )
+ {
+ Handle(Geom_Ellipse) geom_el (Handle(Geom_Ellipse)::DownCast (geom1));
+ // construct lines through focuses
+ gp_Ax1 elAx = geom_el->XAxis();
+ gp_Lin ll (elAx);
+ geom_lin1 = new Geom_Line(ll);
+ Standard_Real focex = geom_el->MajorRadius() - geom_el->Focal()/2.0;
+ gp_Vec transvec = gp_Vec(elAx.Direction())*focex;
+ ptat11 = geom_el->Focus1().Translated(transvec);
+ ptat12 = geom_el->Focus2().Translated(-transvec);
+ interOut1 = Standard_True;
+ }
+ else if ( geom1->IsInstance(STANDARD_TYPE(Geom_Line)) )
+ {
+ geom_lin1 = Handle(Geom_Line)::DownCast (geom1);
+ }
+ else return;
+
+ if (geom2->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
+ {
+ Handle(Geom_Ellipse) geom_el (Handle(Geom_Ellipse)::DownCast (geom2));
+ // construct lines through focuses
+ gp_Ax1 elAx = geom_el->XAxis();
+ gp_Lin ll (elAx);
+ geom_lin2 = new Geom_Line(ll);
+ Standard_Real focex = geom_el->MajorRadius() - geom_el->Focal()/2.0;
+ gp_Vec transvec = gp_Vec(elAx.Direction())*focex;
+ ptat21 = geom_el->Focus1().Translated(transvec);
+ ptat22 = geom_el->Focus2().Translated(-transvec);
+ interOut2 = Standard_True;
+ }
+ else if ( geom2->IsInstance(STANDARD_TYPE(Geom_Line)) )
+ {
+ geom_lin2 = Handle(Geom_Line)::DownCast (geom2);
+ }
+ else return;
+
+ // current face
+ BRepBuilderAPI_MakeFace makeface (myPlane->Pln());
+ TopoDS_Face face (makeface.Face());
+ BRepAdaptor_Surface adp (makeface.Face());
+
+ // 2d lines => projection of 3d on current plane
+ Handle(Geom2d_Curve) aGeom2dCurve = GeomAPI::To2d(geom_lin1,myPlane->Pln());
+ Handle(Geom2d_Line) lin1_2d = Handle(Geom2d_Line)::DownCast (aGeom2dCurve) ;
+ aGeom2dCurve = GeomAPI::To2d(geom_lin2,myPlane->Pln());
+ Handle(Geom2d_Line) lin2_2d = Handle(Geom2d_Line)::DownCast (aGeom2dCurve) ;
+ IntAna2d_AnaIntersection inter(lin1_2d->Lin2d(),lin2_2d->Lin2d());
+ if (!inter.IsDone()) return;
+ if (!inter.NbPoints()) return;
+
+ gp_Pnt2d pint(inter.Point(1).Value());
+ pint3d = adp.Value(pint.X(),pint.Y());
+
+ myPosition = pint3d;
+ // recherche points attache
+ Standard_Real par1,par2,curpar,pmin,pmax;//,dist,sign;
+ Standard_Real length(0.);
+
+ if ( isInfinite1 && isInfinite2 )
+ {
+ Standard_Real curpar1 = ElCLib::Parameter(geom_lin1->Lin(),pint3d);
+ Standard_Real curpar2 = ElCLib::Parameter(geom_lin2->Lin(),pint3d);
+ par1 = par2 = 50.;
+ p1 = p2 = pint3d;
+ myFAttach = ElCLib::Value(curpar1+par1,geom_lin1->Lin());
+ mySAttach = ElCLib::Value(curpar2+par2,geom_lin2->Lin());
+ }
+ else
+ {
+ Standard_Boolean lengthComputed (Standard_False);
+ if ( !isInfinite1 )
+ {
+ curpar = ElCLib::Parameter(geom_lin1->Lin(),pint3d);
+ par1 = ElCLib::Parameter(geom_lin1->Lin(),ptat11);
+ par2 = ElCLib::Parameter(geom_lin1->Lin(),ptat12);
+ pmin = Min(par1,par2);
+ pmax = Max(par1,par2);
+
+ if ( myPosition.SquareDistance(ptat11) > myPosition.SquareDistance(ptat12) )
+ p1 = ptat11;
+ else
+ p1 = ptat12;
+ if ( (curpar < pmin) || (curpar > pmax) )
+ {
+ interOut1 = Standard_True;
+ }
+ if ( !isInfinite2 ) length = 2.*Min(ptat11.Distance(ptat12),ptat21.Distance(ptat22))/5.;
+ else length = 2.*ptat11.Distance(ptat12)/5.;
+ lengthComputed = Standard_True;
+ gp_Vec vec1 (gce_MakeDir(myPosition,p1));
+ vec1.Multiply(length);
+ pAx1 = myPosition.Translated(vec1);
+ myFAttach = pAx1;
+ }
+ if ( !isInfinite2 )
+ {
+ curpar = ElCLib::Parameter(geom_lin2->Lin(),pint3d);
+ par1 = ElCLib::Parameter(geom_lin2->Lin(),ptat21);
+ par2 = ElCLib::Parameter(geom_lin2->Lin(),ptat22);
+ pmin = Min(par1,par2);
+ pmax = Max(par1,par2);
+
+ if ( myPosition.SquareDistance(ptat21) > myPosition.SquareDistance(ptat22) ) p2 = ptat21;
+ else p2 = ptat22;
+ if ( (curpar < pmin) || (curpar > pmax) )
+ {
+ interOut2 = Standard_True;
+ }
+ gp_Vec vec2 (gce_MakeDir(myPosition,p2));
+ if ( !lengthComputed )
+ {
+ if ( !isInfinite1 ) length = 2.*Min(ptat11.Distance(ptat12),ptat21.Distance(ptat22))/5.;
+ else length = 2.*ptat21.Distance(ptat22)/5.;
+ }
+ vec2.Multiply(length);
+ pAx2 = myPosition.Translated(vec2);
+ mySAttach = pAx2;
+ }
+ if ( isInfinite1 )
+ {
+ p1 = myPosition;
+ gp_Vec vec1(geom_lin1->Lin().Direction());
+ vec1.Multiply(length);
+ myFAttach = myPosition.Translated(vec1);
+ }
+ if ( isInfinite2 )
+ {
+ p2 = myPosition;
+ gp_Vec vec2(geom_lin2->Lin().Direction());
+ vec2.Multiply(length);
+ mySAttach = myPosition.Translated(vec2);
+ }
+ }
+ DsgPrs_PerpenPresentation::Add(aPresentation,myDrawer,
+ myFAttach,mySAttach,
+ p1,p2,
+ myPosition,
+ interOut1,interOut2);
+
+ if ( (myExtShape != 0) && !extCurv.IsNull()) {
+ gp_Pnt pf,pl;
+ if ( myExtShape == 1 ) {
+ if (!isInfinite1) {
+ pf = ptat11;
+ pl = ptat12;
+ }
+ aPresentation->SetInfiniteState(isInfinite1);
+ ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(myFShape),geom_lin1,pf,pl);
+ }
+ else {
+ if (!isInfinite2) {
+ pf = ptat21;
+ pl = ptat22;
+ }
+ aPresentation->SetInfiniteState(isInfinite2);
+ ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(mySShape),geom_lin2,pf,pl);
+ }
+ }
+}
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Jean-Pierre COMBE/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_PerpendicularRelation_HeaderFile
+#define _PrsDim_PerpendicularRelation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_PerpendicularRelation, PrsDim_Relation)
+
+//! A framework to display constraints of perpendicularity
+//! between two or more interactive datums. These
+//! datums can be edges or faces.
+class PrsDim_PerpendicularRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_PerpendicularRelation, PrsDim_Relation)
+public:
+
+ //! Constructs an object to display constraints of
+ //! perpendicularity on shapes.
+ //! This object is defined by a first shape aFShape, a
+ //! second shape aSShape, and a plane aPlane.
+ //! aPlane is the plane of reference to show and test the
+ //! perpendicular relation between two shapes, at least
+ //! one of which has a revolved surface.
+ Standard_EXPORT PrsDim_PerpendicularRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane);
+
+ //! Constructs an object to display constraints of
+ //! perpendicularity on shapes.
+ //! This object is defined by a first shape aFShape and a
+ //! second shape aSShape.
+ Standard_EXPORT PrsDim_PerpendicularRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape);
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeTwoFacesPerpendicular (const Handle(Prs3d_Presentation)& aPresentation);
+
+ Standard_EXPORT void ComputeTwoEdgesPerpendicular (const Handle(Prs3d_Presentation)& aPresentation);
+
+private:
+
+ gp_Pnt myFAttach;
+ gp_Pnt mySAttach;
+
+};
+
+#endif // _PrsDim_PerpendicularRelation_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Jean-Pierre COMBE/Odile Olivier/Serguei Zaritchny
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_RadiusDimension.hxx>
+
+#include <PrsDim.hxx>
+#include <BRepLib_MakeEdge.hxx>
+#include <ElCLib.hxx>
+#include <gce_MakeDir.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_RadiusDimension, PrsDim_Dimension)
+
+namespace
+{
+ static const Standard_ExtCharacter THE_RADIUS_SYMBOL ('R');
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_RadiusDimension::PrsDim_RadiusDimension (const gp_Circ& theCircle)
+: PrsDim_Dimension (PrsDim_KOD_RADIUS)
+{
+ SetMeasuredGeometry (theCircle);
+ SetSpecialSymbol (THE_RADIUS_SYMBOL);
+ SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_Before);
+ SetFlyout (0.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_RadiusDimension::PrsDim_RadiusDimension (const gp_Circ& theCircle,
+ const gp_Pnt& theAttachPoint)
+: PrsDim_Dimension (PrsDim_KOD_RADIUS)
+{
+ SetMeasuredGeometry (theCircle, theAttachPoint);
+ SetSpecialSymbol (THE_RADIUS_SYMBOL);
+ SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_Before);
+ SetFlyout (0.0);
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_RadiusDimension::PrsDim_RadiusDimension (const TopoDS_Shape& theShape)
+: PrsDim_Dimension (PrsDim_KOD_RADIUS)
+{
+ SetMeasuredGeometry (theShape);
+ SetSpecialSymbol (THE_RADIUS_SYMBOL);
+ SetDisplaySpecialSymbol (PrsDim_DisplaySpecialSymbol_Before);
+ SetFlyout (0.0);
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle,
+ const gp_Pnt& theAnchorPoint,
+ const Standard_Boolean theHasAnchor)
+{
+ myCircle = theCircle;
+ myGeometryType = GeometryType_Edge;
+ myShape = BRepLib_MakeEdge (theCircle);
+ myAnchorPoint = theHasAnchor ? theAnchorPoint : ElCLib::Value (0, myCircle);
+ myIsGeometryValid = IsValidCircle (myCircle) && IsValidAnchor (myCircle, myAnchorPoint);
+
+ if (myIsGeometryValid)
+ {
+ ComputePlane();
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetMeasuredGeometry
+//purpose :
+//=======================================================================
+void PrsDim_RadiusDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape,
+ const gp_Pnt& theAnchorPoint,
+ const Standard_Boolean theHasAnchor)
+{
+ Standard_Boolean isClosed = Standard_False;
+ myShape = theShape;
+ myGeometryType = GeometryType_UndefShapes;
+ myIsGeometryValid = InitCircularDimension (theShape, myCircle, myAnchorPoint, isClosed)
+ && IsValidCircle (myCircle);
+ if (theHasAnchor)
+ {
+ myAnchorPoint = theAnchorPoint;
+ myIsGeometryValid = myIsGeometryValid && IsValidAnchor (myCircle, myAnchorPoint);
+ }
+
+ if (myIsGeometryValid)
+ {
+ ComputePlane();
+ }
+
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : CheckPlane
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_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 PrsDim_RadiusDimension::ComputePlane()
+{
+ if (!myIsGeometryValid)
+ {
+ 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& PrsDim_RadiusDimension::GetModelUnits() const
+{
+ return myDrawer->DimLengthModelUnits();
+}
+
+//=======================================================================
+//function : GetDisplayUnits
+//purpose :
+//=======================================================================
+const TCollection_AsciiString& PrsDim_RadiusDimension::GetDisplayUnits() const
+{
+ return myDrawer->DimLengthDisplayUnits();
+}
+
+//=======================================================================
+//function : SetModelUnits
+//purpose :
+//=======================================================================
+void PrsDim_RadiusDimension::SetModelUnits (const TCollection_AsciiString& theUnits)
+{
+ myDrawer->SetDimLengthModelUnits (theUnits);
+}
+
+//=======================================================================
+//function : SetDisplayUnits
+//purpose :
+//=======================================================================
+void PrsDim_RadiusDimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
+{
+ myDrawer->SetDimLengthDisplayUnits(theUnits);
+}
+
+//=======================================================================
+//function : ComputeValue
+//purpose :
+//=======================================================================
+Standard_Real PrsDim_RadiusDimension::ComputeValue() const
+{
+ if (!IsValid())
+ {
+ return 0.0;
+ }
+
+ return myCircle.Radius();
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode)
+{
+ mySelectionGeom.Clear (theMode);
+
+ if (!IsValid())
+ {
+ return;
+ }
+
+ DrawLinearDimension (thePresentation, theMode, myAnchorPoint, myCircle.Location(), Standard_True);
+}
+
+//=======================================================================
+//function : IsValidCircle
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_RadiusDimension::IsValidCircle (const gp_Circ& theCircle) const
+{
+ return theCircle.Radius() > Precision::Confusion();
+}
+
+//=======================================================================
+//function : IsValidAnchor
+//purpose :
+//=======================================================================
+Standard_Boolean PrsDim_RadiusDimension::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());
+
+ return anAnchorDist > Precision::Confusion()
+ && aCirclePlane.Contains (theAnchor, Precision::Confusion());
+}
+
+//=======================================================================
+//function : GetTextPosition
+//purpose :
+//=======================================================================
+gp_Pnt PrsDim_RadiusDimension::GetTextPosition() const
+{
+ if (IsTextPositionCustom())
+ {
+ return myFixedTextPosition;
+ }
+
+ // Counts text position according to the dimension parameters
+ return GetTextPositionForLinear (myAnchorPoint, myCircle.Location(), Standard_True);
+}
+
+//=======================================================================
+//function : GetTextPosition
+//purpose :
+//=======================================================================
+void PrsDim_RadiusDimension::SetTextPosition (const gp_Pnt& theTextPos)
+{
+ if (!myIsGeometryValid)
+ {
+ return;
+ }
+
+ myIsTextPositionFixed = Standard_True;
+ myFixedTextPosition = theTextPos;
+
+ SetToUpdate();
+}
--- /dev/null
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_RadiusDimension_HeaderFile
+#define _PrsDim_RadiusDimension_HeaderFile
+
+#include <PrsDim_Dimension.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Circ.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_RadiusDimension, PrsDim_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 PrsDim_RadiusDimension : public PrsDim_Dimension
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_RadiusDimension, PrsDim_Dimension)
+public:
+
+ //! Create radius dimension for the circle geometry.
+ //! @param theCircle [in] the circle to measure.
+ Standard_EXPORT PrsDim_RadiusDimension (const gp_Circ& theCircle);
+
+ //! 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 attachment on the circle.
+ Standard_EXPORT PrsDim_RadiusDimension (const gp_Circ& theCircle,
+ const gp_Pnt& theAnchorPoint);
+
+ //! Create radius dimension for the arbitrary shape (if possible).
+ //! @param theShape [in] the shape to measure.
+ Standard_EXPORT PrsDim_RadiusDimension (const TopoDS_Shape& theShape);
+
+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.
+ void SetMeasuredGeometry (const gp_Circ& theCircle) { SetMeasuredGeometry (theCircle, gp_Pnt(), Standard_False); }
+
+ //! 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 radius 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, should be on the circle
+ //! @param theHasAnchor [in] should be set TRUE if theAnchorPoint should be used
+ Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle,
+ const gp_Pnt& theAnchorPoint,
+ const Standard_Boolean theHasAnchor = Standard_True);
+
+ //! 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.
+ void SetMeasuredGeometry (const TopoDS_Shape& theShape) { SetMeasuredGeometry (theShape, gp_Pnt(), Standard_False); }
+
+ //! 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.
+ //! @param theAnchorPoint [in] the point to attach the dimension lines, should be on the circle
+ //! @param theHasAnchor [in] should be set TRUE if theAnchorPoint should be used
+ Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape,
+ const gp_Pnt& theAnchorPoint,
+ const Standard_Boolean theHasAnchor = Standard_True);
+
+ //! @return the display units string.
+ Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE;
+
+ //! @return the model units string.
+ Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual gp_Pnt GetTextPosition() const Standard_OVERRIDE;
+
+protected:
+
+ Standard_EXPORT virtual void ComputePlane();
+
+ //! 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_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode = 0) Standard_OVERRIDE;
+
+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:
+
+ gp_Circ myCircle;
+ gp_Pnt myAnchorPoint;
+ TopoDS_Shape myShape;
+};
+
+#endif // _PrsDim_RadiusDimension_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_Relation.hxx>
+
+#include <PrsDim.hxx>
+#include <AIS_GraphicTool.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <ElCLib.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Surface.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pnt.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Precision.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Quantity_Color.hxx>
+#include <StdPrs_Point.hxx>
+#include <StdPrs_WFShape.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopExp.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_Relation, AIS_InteractiveObject)
+
+//=======================================================================
+//function : PrsDim_Relation
+//purpose :
+//=======================================================================
+PrsDim_Relation::PrsDim_Relation(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
+:AIS_InteractiveObject(aTypeOfPresentation3d),
+ myVal(1.),
+ myPosition(0.,0.,0.),
+ myArrowSize( myVal / 10. ),
+ myAutomaticPosition(Standard_True),
+ myExtShape(0),
+ myFirstOffset(0.),mySecondOffset(0.),
+ myIsSetBndBox( Standard_False ),
+ myArrowSizeIsDefined( Standard_False)
+{
+}
+
+//=======================================================================
+//function : ComputeProjEdgePresentation
+//purpose :
+//=======================================================================
+
+void PrsDim_Relation::ComputeProjEdgePresentation(const Handle(Prs3d_Presentation)& aPrs,
+ const TopoDS_Edge& anEdge,
+ const Handle(Geom_Curve)& ProjCurv,
+ const gp_Pnt& FirstP,
+ const gp_Pnt& LastP,
+ const Quantity_NameOfColor aColor,
+ const Standard_Real width,
+ const Aspect_TypeOfLine aProjTOL,
+ const Aspect_TypeOfLine aCallTOL) const
+{
+ if (!myDrawer->HasOwnWireAspect()){
+ myDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aProjTOL,2.));}
+ else {
+ const Handle(Prs3d_LineAspect)& li = myDrawer->WireAspect();
+ li->SetColor(aColor);
+ li->SetTypeOfLine(aProjTOL);
+ li->SetWidth(width);
+ }
+
+ Standard_Real pf, pl;
+ TopLoc_Location loc;
+ Handle(Geom_Curve) curve;
+ Standard_Boolean isInfinite;
+ curve = BRep_Tool::Curve(anEdge,loc,pf,pl);
+ isInfinite = (Precision::IsInfinite(pf) || Precision::IsInfinite(pl));
+
+ TopoDS_Edge E;
+
+ // Calcul de la presentation de l'edge
+ if (ProjCurv->IsInstance(STANDARD_TYPE(Geom_Line)) ) {
+ Handle(Geom_Line) gl (Handle(Geom_Line)::DownCast (ProjCurv));
+ if ( !isInfinite) {
+ pf = ElCLib::Parameter(gl->Lin(),FirstP);
+ pl = ElCLib::Parameter(gl->Lin(),LastP);
+ BRepBuilderAPI_MakeEdge MakEd(gl->Lin(), pf, pl);
+ E = MakEd.Edge();
+ }
+ else {
+ BRepBuilderAPI_MakeEdge MakEd(gl->Lin());
+ E = MakEd.Edge();
+ }
+ }
+ else if (ProjCurv->IsInstance(STANDARD_TYPE(Geom_Circle)) ) {
+ Handle(Geom_Circle) gc (Handle(Geom_Circle)::DownCast (ProjCurv));
+ pf = ElCLib::Parameter(gc->Circ(),FirstP);
+ pl = ElCLib::Parameter(gc->Circ(),LastP);
+ BRepBuilderAPI_MakeEdge MakEd(gc->Circ(),pf, pl);
+ E = MakEd.Edge();
+ }
+ StdPrs_WFShape::Add (aPrs, E, myDrawer);
+
+ //Calcul de la presentation des lignes de raccord
+ myDrawer->WireAspect()->SetTypeOfLine(aCallTOL);
+ if (!isInfinite) {
+ gp_Pnt ppf, ppl;
+ ppf = BRep_Tool::Pnt( TopExp::FirstVertex(TopoDS::Edge(anEdge)));
+ ppl = BRep_Tool::Pnt( TopExp::LastVertex(TopoDS::Edge(anEdge)));
+ if (FirstP.Distance (ppf) > gp::Resolution())
+ {
+ BRepBuilderAPI_MakeEdge MakEd1 (FirstP, ppf);
+ StdPrs_WFShape::Add (aPrs, MakEd1.Edge(), myDrawer);
+ }
+ else
+ {
+ BRepBuilderAPI_MakeVertex MakVert1 (FirstP);
+ StdPrs_WFShape::Add (aPrs, MakVert1.Vertex(), myDrawer);
+ }
+ if (LastP.Distance (ppl) > gp::Resolution())
+ {
+ BRepBuilderAPI_MakeEdge MakEd2 (LastP, ppl);
+ StdPrs_WFShape::Add (aPrs, MakEd2.Edge(), myDrawer);
+ }
+ else
+ {
+ BRepBuilderAPI_MakeVertex MakVert2 (LastP);
+ StdPrs_WFShape::Add (aPrs, MakVert2.Vertex(), myDrawer);
+ }
+/*
+ BRepBuilderAPI_MakeEdge MakEd1 (FirstP, ppf);
+ StdPrs_WFShape::Add (aPrs, MakEd1.Edge(), myDrawer);
+ BRepBuilderAPI_MakeEdge MakEd2 (LastP, ppl);
+ StdPrs_WFShape::Add (aPrs, MakEd2.Edge(), myDrawer);
+*/
+ }
+}
+
+
+//=======================================================================
+//function : ComputeProjVertexPresentation
+//purpose :
+//=======================================================================
+
+void PrsDim_Relation::ComputeProjVertexPresentation(const Handle(Prs3d_Presentation)& aPrs,
+ const TopoDS_Vertex& aVertex,
+ const gp_Pnt& ProjPoint,
+ const Quantity_NameOfColor aColor,
+ const Standard_Real width,
+ const Aspect_TypeOfMarker aProjTOM,
+ const Aspect_TypeOfLine aCallTOL) const
+{
+ if (!myDrawer->HasOwnPointAspect()){
+ myDrawer->SetPointAspect(new Prs3d_PointAspect(aProjTOM, aColor,1));}
+ else {
+ const Handle(Prs3d_PointAspect)& pa = myDrawer->PointAspect();
+ pa->SetColor(aColor);
+ pa->SetTypeOfMarker(aProjTOM);
+ }
+
+ {
+ Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
+ Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
+ anArrayOfPoints->AddVertex (ProjPoint);
+ aGroup->SetGroupPrimitivesAspect (myDrawer->PointAspect()->Aspect());
+ aGroup->AddPrimitiveArray (anArrayOfPoints);
+ }
+
+ if (!myDrawer->HasOwnWireAspect()){
+ myDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aCallTOL,2.));}
+ else {
+ const Handle(Prs3d_LineAspect)& li = myDrawer->WireAspect();
+ li->SetColor(aColor);
+ li->SetTypeOfLine(aCallTOL);
+ li->SetWidth(width);
+ }
+
+ // Si les points ne sont pas confondus...
+ if (!ProjPoint.IsEqual (BRep_Tool::Pnt(aVertex),Precision::Confusion()))
+ {
+ Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
+ Handle(Graphic3d_ArrayOfSegments) anArrayOfLines = new Graphic3d_ArrayOfSegments (2);
+ anArrayOfLines->AddVertex (ProjPoint);
+ anArrayOfLines->AddVertex (BRep_Tool::Pnt(aVertex));
+ aGroup->SetGroupPrimitivesAspect (myDrawer->WireAspect()->Aspect());
+ aGroup->AddPrimitiveArray (anArrayOfLines);
+ }
+}
+
+//=======================================================================
+//function : SetColor
+//purpose :
+//=======================================================================
+void PrsDim_Relation::SetColor(const Quantity_Color &aCol)
+{
+ if(hasOwnColor && myDrawer->Color() == aCol) return;
+
+ if (!myDrawer->HasOwnTextAspect()) myDrawer->SetTextAspect(new Prs3d_TextAspect());
+ hasOwnColor=Standard_True;
+ myDrawer->SetColor (aCol);
+ myDrawer->TextAspect()->SetColor(aCol);
+
+ Standard_Real WW = HasWidth()? Width(): myDrawer->HasLink() ?
+ AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.;
+ if (!myDrawer->HasOwnLineAspect()) {
+ myDrawer->SetLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
+ }
+ if (!myDrawer->HasOwnDimensionAspect()) {
+ myDrawer->SetDimensionAspect(new Prs3d_DimensionAspect);
+ }
+
+ myDrawer->LineAspect()->SetColor(aCol);
+ const Handle(Prs3d_DimensionAspect)& DIMENSION = myDrawer->DimensionAspect();
+ const Handle(Prs3d_LineAspect)& LINE = myDrawer->LineAspect();
+ const Handle(Prs3d_TextAspect)& TEXT = myDrawer->TextAspect();
+
+ DIMENSION->SetLineAspect(LINE);
+ DIMENSION->SetTextAspect(TEXT);
+}
+
+//=======================================================================
+//function : UnsetColor
+//purpose :
+//=======================================================================
+void PrsDim_Relation::UnsetColor()
+{
+ if (!hasOwnColor) return;
+ hasOwnColor = Standard_False;
+ const Handle(Prs3d_LineAspect)& LA = myDrawer->LineAspect();
+ Quantity_Color CC = Quantity_NOC_YELLOW;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
+ myDrawer->SetTextAspect(myDrawer->Link()->TextAspect());
+ }
+ LA->SetColor(CC);
+ myDrawer->DimensionAspect()->SetLineAspect(LA);
+}
--- /dev/null
+// Created on: 1997-02-27
+// Created by: Odile Olivier
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_Relation_HeaderFile
+#define _PrsDim_Relation_HeaderFile
+
+#include <AIS_KindOfInteractive.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <Aspect_TypeOfLine.hxx>
+#include <Aspect_TypeOfMarker.hxx>
+#include <Bnd_Box.hxx>
+#include <DsgPrs_ArrowSide.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <PrsDim_KindOfDimension.hxx>
+#include <PrsDim_KindOfSurface.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopoDS_Shape.hxx>
+
+class Geom_Curve;
+class Geom_Plane;
+class Geom_Surface;
+class TopoDS_Edge;
+class TopoDS_Vertex;
+
+//! One of the four types of interactive object in
+//! AIS,comprising dimensions and constraints. Serves
+//! as the abstract class for the seven relation classes as
+//! well as the seven dimension classes.
+//! The statuses available for relations between shapes are as follows:
+//! - 0 - there is no connection to a shape;
+//! - 1 - there is a connection to the first shape;
+//! - 2 - there is a connection to the second shape.
+//! The connection takes the form of an edge between the two shapes.
+class PrsDim_Relation : public AIS_InteractiveObject
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_Relation, AIS_InteractiveObject)
+public:
+
+ //! Allows you to provide settings for the color theColor
+ //! of the lines representing the relation between the two shapes.
+ Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
+
+ //! Allows you to remove settings for the color of the
+ //! lines representing the relation between the two shapes.
+ Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
+
+ virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Relation; }
+
+ //! Indicates that the type of dimension is unknown.
+ virtual PrsDim_KindOfDimension KindOfDimension() const { return PrsDim_KOD_NONE; }
+
+ //! Returns true if the interactive object is movable.
+ virtual Standard_Boolean IsMovable() const { return Standard_False; }
+
+ const TopoDS_Shape& FirstShape() const { return myFShape; }
+
+ virtual void SetFirstShape (const TopoDS_Shape& aFShape) { myFShape = aFShape; }
+
+ //! Returns the second shape.
+ const TopoDS_Shape& SecondShape() const { return mySShape; }
+
+ //! Allows you to identify the second shape aSShape
+ //! relative to the first.
+ virtual void SetSecondShape (const TopoDS_Shape& aSShape) { mySShape = aSShape; }
+
+ void SetBndBox (const Standard_Real theXmin, const Standard_Real theYmin, const Standard_Real theZmin,
+ const Standard_Real theXmax, const Standard_Real theYmax, const Standard_Real theZmax)
+ {
+ myBndBox.Update (theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
+ myIsSetBndBox = Standard_True;
+ }
+
+ void UnsetBndBox() { myIsSetBndBox = Standard_False; }
+
+ //! Returns the plane.
+ const Handle(Geom_Plane)& Plane() const { return myPlane; }
+
+ //! Allows you to set the plane thePlane. This is used to
+ //! define relations and dimensions in several daughter classes.
+ void SetPlane (const Handle(Geom_Plane)& thePlane) { myPlane = thePlane; }
+
+ //! Returns the value of each object in the relation.
+ Standard_Real Value() const { return myVal; }
+
+ //! Allows you to provide settings for the value theVal for each object in the relation.
+ void SetValue (const Standard_Real theVal) { myVal = theVal; }
+
+ //! Returns the position set using SetPosition.
+ const gp_Pnt& Position() const { return myPosition; }
+
+ //! Allows you to provide the objects in the relation with
+ //! settings for a non-default position.
+ void SetPosition (const gp_Pnt& thePosition)
+ {
+ myPosition = thePosition;
+ myAutomaticPosition = Standard_False;
+ }
+
+ //! Returns settings for text aspect.
+ const TCollection_ExtendedString& Text() const { return myText; }
+
+ //! Allows you to provide the settings theText for text aspect.
+ void SetText (const TCollection_ExtendedString& theText) { myText = theText; }
+
+ //! Returns the value for the size of the arrow identifying
+ //! the relation between the two shapes.
+ Standard_Real ArrowSize() const { return myArrowSize; }
+
+ //! Allows you to provide settings for the size of the
+ //! arrow theArrowSize identifying the relation between the two shapes.
+ void SetArrowSize (const Standard_Real theArrowSize)
+ {
+ myArrowSize = theArrowSize;
+ myArrowSizeIsDefined = Standard_True;
+ }
+
+ //! Returns the value of the symbol presentation. This will be one of:
+ //! - AS_NONE - none
+ //! - AS_FIRSTAR - first arrow
+ //! - AS_LASTAR - last arrow
+ //! - AS_BOTHAR - both arrows
+ //! - AS_FIRSTPT - first point
+ //! - AS_LASTPT - last point
+ //! - AS_BOTHPT - both points
+ //! - AS_FIRSTAR_LASTPT - first arrow, last point
+ //! - AS_FIRSTPT_LASTAR - first point, last arrow
+ DsgPrs_ArrowSide SymbolPrs() const { return mySymbolPrs; }
+
+ //! Allows you to provide settings for the symbol presentation.
+ void SetSymbolPrs (const DsgPrs_ArrowSide theSymbolPrs) { mySymbolPrs = theSymbolPrs; }
+
+ //! Allows you to set the status of the extension shape by
+ //! the index aIndex.
+ //! The status will be one of the following:
+ //! - 0 - there is no connection to a shape;
+ //! - 1 - there is a connection to the first shape;
+ //! - 2 - there is a connection to the second shape.
+ void SetExtShape (const Standard_Integer theIndex) { myExtShape = theIndex; }
+
+ //! Returns the status index of the extension shape.
+ Standard_Integer ExtShape() const { return myExtShape; }
+
+ //! Returns true if the display mode aMode is accepted
+ //! for the Interactive Objects in the relation.
+ //! ComputeProjPresentation(me;
+ //! aPres : Presentation from Prs3d;
+ //! Curve1 : Curve from Geom;
+ //! Curve2 : Curve from Geom;
+ //! FirstP1 : Pnt from gp;
+ //! LastP1 : Pnt from gp;
+ //! FirstP2 : Pnt from gp;
+ //! LastP2 : Pnt from gp;
+ //! aColor : NameOfColor from Quantity = Quantity_NOC_PURPLE;
+ //! aWidth : Real from Standard = 2;
+ //! aProjTOL : TypeOfLine from Aspect = Aspect_TOL_DASH;
+ //! aCallTOL : TypeOfLine from Aspect = Aspect_TOL_DOT)
+ virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
+
+ void SetAutomaticPosition (const Standard_Boolean theStatus) { myAutomaticPosition = theStatus; }
+
+ Standard_Boolean AutomaticPosition() const { return myAutomaticPosition; }
+
+protected:
+
+ Standard_EXPORT PrsDim_Relation (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
+
+ //! Calculates the presentation aPres of the the edge
+ //! anEdge and the curve it defines, ProjCurve. The later
+ //! is also specified by the first point FirstP and the last point LastP.
+ //! The presentation includes settings for color aColor,
+ //! type - aProjTOL and aCallTOL - and width of line, aWidth.
+ Standard_EXPORT void ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPres, const TopoDS_Edge& anEdge, const Handle(Geom_Curve)& ProjCurve, const gp_Pnt& FirstP, const gp_Pnt& LastP, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfLine aProjTOL = Aspect_TOL_DASH, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT) const;
+
+ //! Calculates the presentation aPres of the the vertex
+ //! aVertex and the point it defines, ProjPoint.
+ //! The presentation includes settings for color aColor,
+ //! type - aProjTOM and aCallTOL - and width of line, aWidth.
+ Standard_EXPORT void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT) const;
+
+protected:
+
+ TopoDS_Shape myFShape;
+ TopoDS_Shape mySShape;
+ Handle(Geom_Plane) myPlane;
+ Standard_Real myVal;
+ gp_Pnt myPosition;
+ TCollection_ExtendedString myText;
+ Standard_Real myArrowSize;
+ Standard_Boolean myAutomaticPosition;
+ DsgPrs_ArrowSide mySymbolPrs;
+ Standard_Integer myExtShape;
+ gp_Pln myFirstPlane;
+ gp_Pln mySecondPlane;
+ Handle(Geom_Surface) myFirstBasisSurf;
+ Handle(Geom_Surface) mySecondBasisSurf;
+ PrsDim_KindOfSurface myFirstSurfType;
+ PrsDim_KindOfSurface mySecondSurfType;
+ Standard_Real myFirstOffset;
+ Standard_Real mySecondOffset;
+ Bnd_Box myBndBox;
+ Standard_Boolean myIsSetBndBox;
+ Standard_Boolean myArrowSizeIsDefined;
+
+};
+
+DEFINE_STANDARD_HANDLE(PrsDim_Relation, AIS_InteractiveObject)
+
+#endif // _AIS_Relation_HeaderFile
--- /dev/null
+// Created on: 1997-03-03
+// Created by: Jean-Pierre COMBE
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_SymmetricRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <DsgPrs_SymmetricPresentation.hxx>
+#include <ElCLib.hxx>
+#include <gce_MakeLin.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_SymmetricRelation, PrsDim_Relation)
+
+//=======================================================================
+//function : PrsDim_SymmetricRelation
+//purpose :
+//=======================================================================
+PrsDim_SymmetricRelation::PrsDim_SymmetricRelation(const TopoDS_Shape& aSymmTool,
+ const TopoDS_Shape& FirstShape,
+ const TopoDS_Shape& SecondShape,
+ const Handle(Geom_Plane)& aPlane)
+:PrsDim_Relation(),
+ myTool(aSymmTool)
+{
+ SetFirstShape(FirstShape);
+ SetSecondShape(SecondShape);
+ SetPlane(aPlane);
+ myPosition = aPlane->Pln().Location();
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_SymmetricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aprs,
+ const Standard_Integer)
+{
+ switch (myFShape.ShapeType()) {
+ case TopAbs_FACE :
+ {
+ // cas symetrie entre deux faces
+ ComputeTwoFacesSymmetric(aprs);
+ }
+ break;
+ case TopAbs_EDGE :
+ {
+ // cas symetrie entre deux edges
+ ComputeTwoEdgesSymmetric(aprs);
+ }
+ break;
+ case TopAbs_VERTEX :
+ {
+ // cas symetrie entre deux vertexs
+ ComputeTwoVerticesSymmetric(aprs);
+ }
+ break;
+ default:
+ break;
+ }
+ if (myTool.ShapeType() == TopAbs_EDGE) {
+ Handle(Geom_Curve) aCurve,extcurve;
+ gp_Pnt p1,p2;
+ Standard_Boolean isinfinite,isonplane;
+ if (PrsDim::ComputeGeometry(TopoDS::Edge(myTool),
+ aCurve,p1,p2,
+ extcurve,
+ isinfinite,
+ isonplane,
+ myPlane)) {
+ if (!extcurve.IsNull()) {
+ gp_Pnt pf, pl;
+ if (!isinfinite) {
+ pf = p1;
+ pl = p2;
+ }
+ if (isinfinite) aprs->SetInfiniteState(Standard_True);
+ ComputeProjEdgePresentation(aprs,TopoDS::Edge(myTool),aCurve,pf,pl);
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+void PrsDim_SymmetricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
+ const Standard_Integer)
+{
+ Handle(Select3D_SensitiveSegment) seg;
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+ Standard_Real F,L;
+
+ Handle(Geom_Curve) geom_axis, extcurve;
+ gp_Pnt p1,p2;
+ Standard_Boolean isinfinite,isonplane;
+ if (!PrsDim::ComputeGeometry(TopoDS::Edge(myTool),
+ geom_axis,p1,p2,
+ extcurve,
+ isinfinite,
+ isonplane,
+ myPlane)) return;
+
+ Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
+ gp_Lin laxis (geom_line->Lin());
+
+ if(myFShape.ShapeType() != TopAbs_VERTEX){
+ BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
+
+ if(cu1.GetType() == GeomAbs_Line) {
+// gp_Lin L1 (myFAttach,myFDirAttach);
+ gp_Pnt PjAttachPnt1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
+ gp_Pnt PjOffSetPnt = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
+ Standard_Real h = fabs(PjOffSetPnt.Distance(PjAttachPnt1)/cos(myAxisDirAttach.Angle(myFDirAttach)));
+ gp_Vec VL1(myFDirAttach);
+ gp_Vec VLa(PjAttachPnt1,PjOffSetPnt);
+ Standard_Real scal = VL1.Dot(VLa);
+ if(scal < 0) VL1.Reverse();
+ VL1.Multiply(h);
+ gp_Pnt P1 = myFAttach.Translated(VL1);
+ gp_Pnt ProjAxis = ElCLib::Value(ElCLib::Parameter(laxis,P1),laxis);
+ gp_Vec v(P1,ProjAxis);
+ gp_Pnt P2 = ProjAxis.Translated(v);
+
+ gp_Lin L3;
+
+ if (!P1.IsEqual(P2,Precision::Confusion())) {
+ L3 = gce_MakeLin(P1,P2);
+ }
+ else {
+ L3 = gce_MakeLin(P1,myFDirAttach);
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle(Select3D_SensitiveBox) box =
+ new Select3D_SensitiveBox(own,
+ myPosition.X(),
+ myPosition.Y(),
+ myPosition.Z(),
+ myPosition.X()+size,
+ myPosition.Y()+size,
+ myPosition.Z()+size);
+ aSel->Add(box);
+ }
+ Standard_Real parmin,parmax,parcur;
+ parmin = ElCLib::Parameter(L3,P1);
+ parmax = parmin;
+
+ parcur = ElCLib::Parameter(L3,P2);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ parcur = ElCLib::Parameter(L3,myPosition);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ gp_Pnt PointMin = ElCLib::Value(parmin,L3);
+ gp_Pnt PointMax = ElCLib::Value(parmax,L3);
+
+ if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ PointMin,
+ PointMax);
+ aSel->Add(seg);
+ }
+ if (!myFAttach.IsEqual(P1,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ myFAttach,
+ P1);
+ aSel->Add(seg);
+ }
+ if (!mySAttach.IsEqual(P2,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ mySAttach,
+ P2);
+ aSel->Add(seg);
+ }
+ }
+
+ //=======================Pour les arcs======================
+ if(cu1.GetType() == GeomAbs_Circle) {
+ Handle(Geom_Curve) aGeomCurve = BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
+ Handle(Geom_Circle) geom_circ1 = Handle(Geom_Circle)::DownCast (aGeomCurve) ;
+// Handle(Geom_Circle) geom_circ1 = (const Handle(Geom_Circle)&) BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
+ gp_Circ circ1(geom_circ1->Circ());
+ gp_Pnt OffsetPnt(myPosition.X(),myPosition.Y(),myPosition.Z());
+ gp_Pnt Center1 = circ1.Location();
+ gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,OffsetPnt),laxis);
+ gp_Pnt ProjCenter1 = ElCLib::Value(ElCLib::Parameter(laxis,Center1),laxis);
+ gp_Vec Vp(ProjCenter1,Center1);
+ if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(laxis.Direction())^myPlane->Pln().Position().Direction();
+ Standard_Real Dt,R,h;
+ Dt = ProjCenter1.Distance(ProjOffsetPoint);
+ R = circ1.Radius();
+ if (Dt > .999*R) {
+ Dt = .999*R;
+ gp_Vec Vout(ProjCenter1,ProjOffsetPoint);
+ ProjOffsetPoint = ProjCenter1.Translated(Vout.Divided(Vout.Magnitude()).Multiplied(Dt));
+ OffsetPnt = ProjOffsetPoint;
+ }
+ h = Sqrt(R*R - Dt*Dt);
+ gp_Pnt P1 = ProjOffsetPoint.Translated(Vp.Added(Vp.Divided(Vp.Magnitude()).Multiplied(h)));
+ gp_Vec v(P1,ProjOffsetPoint);
+ gp_Pnt P2 = ProjOffsetPoint.Translated(v);
+
+ gp_Lin L3;
+ if (!P1.IsEqual(P2,Precision::Confusion())) {
+ L3 = gce_MakeLin(P1,P2);
+ }
+ else {
+ L3 = gce_MakeLin(P1,laxis.Direction());
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle(Select3D_SensitiveBox) box =
+ new Select3D_SensitiveBox(own,
+ myPosition.X(),
+ myPosition.Y(),
+ myPosition.Z(),
+ myPosition.X()+size,
+ myPosition.Y()+size,
+ myPosition.Z()+size);
+ aSel->Add(box);
+ }
+ Standard_Real parmin,parmax,parcur;
+ parmin = ElCLib::Parameter(L3,P1);
+ parmax = parmin;
+
+ parcur = ElCLib::Parameter(L3,P2);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ parcur = ElCLib::Parameter(L3,myPosition);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ gp_Pnt PointMin = ElCLib::Value(parmin,L3);
+ gp_Pnt PointMax = ElCLib::Value(parmax,L3);
+
+ if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,
+ PointMin,
+ PointMax);
+ aSel->Add(seg);
+ }
+ }
+ }
+ //=======================Pour les points======================
+ else {
+ if (myFAttach.IsEqual(mySAttach,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,myPosition,myFAttach);
+ aSel->Add(seg);
+ }
+ else{
+ gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
+ gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
+ gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,myFAttach);
+ gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1);
+ gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed());
+ gp_Lin L3;
+
+ if (!P1.IsEqual(P2,Precision::Confusion())) {
+ L3 = gce_MakeLin(P1,P2);
+ }
+ else {
+ L3 = gce_MakeLin(P1,myFDirAttach);
+ Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
+ Handle(Select3D_SensitiveBox) box =
+ new Select3D_SensitiveBox(own,
+ myPosition.X(),
+ myPosition.Y(),
+ myPosition.Z(),
+ myPosition.X()+size,
+ myPosition.Y()+size,
+ myPosition.Z()+size);
+ aSel->Add(box);
+ }
+ Standard_Real parmin,parmax,parcur;
+ parmin = ElCLib::Parameter(L3,P1);
+ parmax = parmin;
+
+ parcur = ElCLib::Parameter(L3,P2);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ parcur = ElCLib::Parameter(L3,myPosition);
+ parmin = Min(parmin,parcur);
+ parmax = Max(parmax,parcur);
+
+ gp_Pnt PointMin = ElCLib::Value(parmin,L3);
+ gp_Pnt PointMax = ElCLib::Value(parmax,L3);
+
+ if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,PointMin,PointMax);
+ aSel->Add(seg);
+ }
+ if (!myFAttach.IsEqual(P1,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,myFAttach,P1);
+ aSel->Add(seg);
+ }
+ if (!mySAttach.IsEqual(P2,Precision::Confusion())) {
+ seg = new Select3D_SensitiveSegment(own,mySAttach,P2);
+ aSel->Add(seg);
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoFacesSymmetric
+//purpose :
+//=======================================================================
+void PrsDim_SymmetricRelation::ComputeTwoFacesSymmetric(const Handle(Prs3d_Presentation)&)
+{
+}
+
+//=======================================================================
+//function : ComputeTwoEdgesSymmetric
+//purpose :
+//=======================================================================
+void PrsDim_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presentation)& aprs)
+{
+ BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
+ if (cu1.GetType() != GeomAbs_Line && cu1.GetType() != GeomAbs_Circle) return;
+ BRepAdaptor_Curve cu2(TopoDS::Edge(mySShape));
+ if (cu2.GetType() != GeomAbs_Line && cu2.GetType() != GeomAbs_Circle) return;
+// gp_Pnt pint3d,ptat11,ptat12,ptat21,ptat22;
+ gp_Pnt ptat11,ptat12,ptat21,ptat22;
+ Handle(Geom_Curve) geom1,geom2;
+ Standard_Boolean isInfinite1,isInfinite2;
+ Handle(Geom_Curve) extCurv;
+ if (!PrsDim::ComputeGeometry(TopoDS::Edge(myFShape),
+ TopoDS::Edge(mySShape),
+ myExtShape,
+ geom1,
+ geom2,
+ ptat11,
+ ptat12,
+ ptat21,
+ ptat22,
+ extCurv,
+ isInfinite1,isInfinite2,
+ myPlane)) {
+ return;
+ }
+ aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0));
+ Handle(Geom_Curve) geom_axis,extcurve;
+ gp_Pnt p1,p2;
+ Standard_Boolean isinfinite,isonplane;
+ if (!PrsDim::ComputeGeometry(TopoDS::Edge(myTool),
+ geom_axis,p1,p2,
+ extcurve,
+ isinfinite,
+ isonplane,
+ myPlane)) return;
+
+ Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
+ gp_Lin laxis (geom_line->Lin());
+ myAxisDirAttach = laxis.Direction();
+
+ if(cu1.GetType() == GeomAbs_Line){
+ Handle(Geom_Line) geom_lin1 (Handle(Geom_Line)::DownCast (geom1));
+ gp_Lin l1(geom_lin1->Lin());
+ myFDirAttach = l1.Direction();
+ }
+ gp_Circ circ;
+ if(cu1.GetType() == GeomAbs_Circle){
+ Handle(Geom_Circle) geom_cir1 (Handle(Geom_Circle)::DownCast (geom1));
+ gp_Circ c(geom_cir1->Circ());
+ circ = c;
+ }
+
+ // recherche points attache
+ gp_Pnt ProjOffset = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
+
+/*//----------------------------------------------------
+ //Quand on fait la symetrie de 2 edges consecutifs:
+ //
+ // :<-- Axe
+ // :
+ // /:\
+ // Edge n --->/ : \
+ // / : \<-- Edge n+1
+ // :
+ //----------------------------------------------------
+*/
+ Standard_Boolean idem = Standard_False;
+ if (isInfinite1 && isInfinite2) { // geom1 et geom2 sont des lignes
+ const gp_Lin& line2 = Handle(Geom_Line)::DownCast (geom2)->Lin();
+ if (myAutomaticPosition) {
+ myFAttach = Handle(Geom_Line)::DownCast (geom1)->Lin().Location();
+ mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
+ }
+ else {
+ const gp_Lin& line1 = Handle(Geom_Line)::DownCast (geom1)->Lin();
+ myFAttach = ElCLib::Value(ElCLib::Parameter(line1,myPosition),line1);
+ mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
+ }
+ }
+ else if (!isInfinite1 && !isInfinite2) {
+ if (ptat11.IsEqual(ptat21,Precision::Confusion())) {
+ myFAttach = ptat12;
+ mySAttach = ptat22;
+ idem = Standard_True;
+ }
+ if (ptat11.IsEqual(ptat22,Precision::Confusion())) {
+ myFAttach = ptat12;
+ mySAttach = ptat21;
+ idem = Standard_True;
+ }
+ if (ptat12.IsEqual(ptat21,Precision::Confusion())) {
+ myFAttach = ptat11;
+ mySAttach = ptat22;
+ idem = Standard_True;
+ }
+ if (ptat12.IsEqual(ptat22,Precision::Confusion())) {
+ myFAttach = ptat11;
+ mySAttach = ptat21;
+ idem = Standard_True;
+ }
+ if(!idem){
+ if( ProjOffset.SquareDistance(ptat11) > ProjOffset.SquareDistance(ptat12)) myFAttach = ptat12;
+ else myFAttach = ptat11;
+
+ if (ProjOffset.SquareDistance(ptat21) > ProjOffset.SquareDistance(ptat22)) mySAttach = ptat22;
+ else mySAttach = ptat21;
+ }
+ }
+ else if (isInfinite1) {// geom1 et geom2 sont des lignes
+ mySAttach = ptat21;
+ const gp_Lin& line1 = Handle(Geom_Line)::DownCast (geom1)->Lin();
+ myFAttach = ElCLib::Value(ElCLib::Parameter(line1,mySAttach),line1);
+ }
+ else if (isInfinite2) {// geom1 et geom2 sont des lignes
+ myFAttach = ptat11;
+ const gp_Lin& line2 = Handle(Geom_Line)::DownCast (geom2)->Lin();
+ mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
+ }
+
+ if( !myArrowSizeIsDefined )
+ myArrowSize = myFAttach.Distance(mySAttach)/50.;
+ //----------------------------------------------------
+
+ //----------------------------------------------------
+ // Si myFAttach <> mySAttach et PjFAttach = myFAttach
+ //----------------------------------------------------
+ gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
+
+ if (PjFAttach.IsEqual(myFAttach,Precision::Confusion())){
+ Handle(Geom_Line) geom_lin2 (Handle(Geom_Line)::DownCast (geom2));
+ gp_Lin l2(geom_lin2->Lin());
+ myFDirAttach = l2.Direction();
+ gp_Pnt PntTempo;
+ PntTempo = myFAttach;
+ myFAttach = mySAttach;
+ mySAttach = PntTempo;
+ PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
+ }
+
+ //----------------------------------------------------
+// gp_Pnt curpos;
+
+ if (myAutomaticPosition) {
+ //gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
+ // offset pour eviter confusion Edge et Dimension
+ gp_Vec offset(myAxisDirAttach);
+ offset = offset * myArrowSize * (-5);
+ gp_Vec Vt(myFAttach, PjFAttach);
+ gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15)));
+ myPosition = curpos;
+ }
+
+ gp_Pnt Pj1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
+ gp_Pnt Pj2 = ElCLib::Value(ElCLib::Parameter(laxis,mySAttach),laxis);
+ if ((myFAttach.SquareDistance(Pj1)+mySAttach.SquareDistance(Pj2)) <= Precision::Confusion()) myArrowSize = 0.;
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+ arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+ if(cu1.GetType() == GeomAbs_Line)
+ DsgPrs_SymmetricPresentation::Add(aprs,
+ myDrawer,
+ myFAttach,
+ mySAttach,
+ myFDirAttach,
+ laxis,
+ myPosition);
+
+ if(cu1.GetType() == GeomAbs_Circle)
+ DsgPrs_SymmetricPresentation::Add(aprs,
+ myDrawer,
+ myFAttach,
+ mySAttach,
+ circ,
+ laxis,
+ myPosition);
+ if ( (myExtShape != 0) && !extCurv.IsNull()) {
+ gp_Pnt pf, pl;
+ if ( myExtShape == 1 ) {
+ if (!isInfinite1) {
+ pf = ptat11;
+ pl = ptat12;
+ }
+ ComputeProjEdgePresentation(aprs,TopoDS::Edge(myFShape),geom1,pf,pl);
+ }
+ else {
+ if (!isInfinite2) {
+ pf = ptat21;
+ pl = ptat22;
+ }
+ ComputeProjEdgePresentation(aprs,TopoDS::Edge(mySShape),geom2,pf,pl);
+ }
+ }
+}
+
+//=======================================================================
+//function : ComputeTwoVertexsSymmetric
+//purpose :
+//=======================================================================
+void PrsDim_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs)
+{
+ if(myFShape.ShapeType() != TopAbs_VERTEX || mySShape.ShapeType() != TopAbs_VERTEX) return;
+ Handle(Geom_Curve) geom_axis,extcurve;
+ gp_Pnt p1,p2;
+ Standard_Boolean isinfinite,isonplane;
+ if (!PrsDim::ComputeGeometry(TopoDS::Edge(myTool),
+ geom_axis,p1,p2,
+ extcurve,
+ isinfinite,
+ isonplane,
+ myPlane)) return;
+
+ Standard_Boolean isOnPlane1, isOnPlane2;
+
+ PrsDim::ComputeGeometry(TopoDS::Vertex(myFShape), myFAttach, myPlane, isOnPlane1);
+ PrsDim::ComputeGeometry(TopoDS::Vertex(mySShape), mySAttach, myPlane, isOnPlane2);
+
+ if( !myArrowSizeIsDefined )
+ myArrowSize = myFAttach.Distance(mySAttach)/50.;
+
+ if (isOnPlane1 && isOnPlane2)
+ myExtShape = 0;
+ else if ( isOnPlane1 && !isOnPlane2)
+ myExtShape = 2;
+ else if (!isOnPlane1 && isOnPlane2)
+ myExtShape = 1;
+ else
+ return ;
+
+ Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
+ gp_Lin laxis (geom_line->Lin());
+ myAxisDirAttach = laxis.Direction();
+
+ // recherche points attache
+// gp_Pnt curpos;
+ if (myAutomaticPosition) {
+ gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
+ // offset pour eviter confusion Edge et Dimension
+ gp_Vec offset(myAxisDirAttach);
+ offset = offset * myArrowSize * (-5);
+ gp_Vec Vt(myFAttach, PjFAttach);
+ gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15)));
+ myPosition = curpos;
+ }
+ if (2*(myFAttach.Distance(mySAttach)) <= Precision::Confusion()) myArrowSize = 0.;
+ Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
+ Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+ arr = la->ArrowAspect();
+ arr->SetLength(myArrowSize);
+ DsgPrs_SymmetricPresentation::Add(aprs,
+ myDrawer,
+ myFAttach,
+ mySAttach,
+ laxis,
+ myPosition);
+ if ( myExtShape == 1)
+ ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myFShape),myFAttach);
+ else if ( myExtShape == 2)
+ ComputeProjVertexPresentation(aprs,TopoDS::Vertex(mySShape),mySAttach);
+}
+
+
+
+
+
+
--- /dev/null
+// Created on: 1997-03-03
+// Created by: Jean-Pierre COMBE
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_SymmetricRelation_HeaderFile
+#define _PrsDim_SymmetricRelation_HeaderFile
+
+#include <TopoDS_Shape.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <PrsDim_Relation.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_SymmetricRelation, PrsDim_Relation)
+
+//! A framework to display constraints of symmetricity
+//! between two or more datum Interactive Objects.
+//! A plane serves as the axis of symmetry between the
+//! shapes of which the datums are parts.
+class PrsDim_SymmetricRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_SymmetricRelation, PrsDim_Relation)
+public:
+
+ //! Constructs an object to display constraints of symmetricity.
+ //! This object is defined by a tool aSymmTool, a first
+ //! shape FirstShape, a second shape SecondShape, and a plane aPlane.
+ //! aPlane serves as the axis of symmetry.
+ //! aSymmTool is the shape composed of FirstShape
+ //! SecondShape and aPlane. It may be queried and
+ //! edited using the functions GetTool and SetTool.
+ //! The two shapes are typically two edges, two vertices or two points.
+ Standard_EXPORT PrsDim_SymmetricRelation(const TopoDS_Shape& aSymmTool, const TopoDS_Shape& FirstShape, const TopoDS_Shape& SecondShape, const Handle(Geom_Plane)& aPlane);
+
+ //! Returns true if the symmetric constraint display is movable.
+ virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
+
+ //! Sets the tool aSymmetricTool composed of a first
+ //! shape, a second shape, and a plane.
+ //! This tool is initially created at construction time.
+ void SetTool (const TopoDS_Shape& aSymmetricTool) { myTool = aSymmetricTool; }
+
+ //! Returns the tool composed of a first shape, a second
+ //! shape, and a plane. This tool is created at construction time.
+ const TopoDS_Shape& GetTool() const { return myTool; }
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeTwoFacesSymmetric (const Handle(Prs3d_Presentation)& aprs);
+
+ Standard_EXPORT void ComputeTwoEdgesSymmetric (const Handle(Prs3d_Presentation)& aprs);
+
+ Standard_EXPORT void ComputeTwoVerticesSymmetric (const Handle(Prs3d_Presentation)& aprs);
+
+private:
+
+ TopoDS_Shape myTool;
+ gp_Pnt myFAttach;
+ gp_Pnt mySAttach;
+ gp_Dir myFDirAttach;
+ gp_Dir myAxisDirAttach;
+
+};
+
+#endif // _PrsDim_SymmetricRelation_HeaderFile
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Jean-Pierre COMBE/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <PrsDim_TangentRelation.hxx>
+
+#include <PrsDim.hxx>
+#include <AIS_Shape.hxx>
+#include <Bnd_Box.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <DsgPrs_TangentPresentation.hxx>
+#include <ElCLib.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Ellipse.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <GeomAPI_ExtremaCurveCurve.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Precision.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <TColStd_ListIteratorOfListOfTransient.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_TangentRelation, PrsDim_Relation)
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+PrsDim_TangentRelation::PrsDim_TangentRelation(const TopoDS_Shape& aFShape,
+ const TopoDS_Shape& aSShape,
+ const Handle(Geom_Plane)& aPlane,
+ const Standard_Integer anExternRef)
+ :myExternRef(anExternRef)
+{
+ myFShape = aFShape;
+ mySShape = aSShape;
+ myPlane = aPlane;
+ myAutomaticPosition = Standard_False;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void PrsDim_TangentRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer)
+{
+ switch (myFShape.ShapeType())
+ {
+ case TopAbs_FACE :
+ {
+ ComputeTwoFacesTangent(aPresentation);
+ }
+ break;
+ case TopAbs_EDGE :
+ {
+ ComputeTwoEdgesTangent(aPresentation);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
+void PrsDim_TangentRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer)
+{
+ gp_Vec vec(myDir);
+ gp_Vec vec1 = vec.Multiplied(myLength);
+ gp_Vec vec2 = vec.Multiplied(-myLength);
+ gp_Pnt p1 = myPosition.Translated(vec1);
+ gp_Pnt p2 = myPosition.Translated(vec2);
+
+ Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
+ Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,p1,p2);
+ aSelection->Add(seg);
+}
+
+//=======================================================================
+//function : ComputeTwoFacesTangent
+//purpose :
+//=======================================================================
+void PrsDim_TangentRelation::ComputeTwoFacesTangent
+ (const Handle(Prs3d_Presentation)& /*aPresentation*/)
+{
+}
+
+// jfa 19/10/2000 begin
+//=======================================================================
+//function : ComputeTangencyPoint
+//purpose :
+//=======================================================================
+static Standard_Boolean ComputeTangencyPoint(const Handle(Geom_Curve)& GC1,
+ const Handle(Geom_Curve)& GC2,
+ gp_Pnt& aPoint)
+{
+ Standard_Real U1f = GC1->FirstParameter();
+ Standard_Real U1l = GC1->LastParameter();
+ Standard_Real U2f = GC2->FirstParameter();
+ Standard_Real U2l = GC2->LastParameter();
+
+ gp_Pnt PC1;
+ Standard_Real mindist=0;
+ GeomAPI_ExtremaCurveCurve Ex(GC1,GC2,U1f,U1l,U2f,U2l);
+ for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++)
+ {
+ gp_Pnt P1,P2;
+ Ex.Points(i,P1,P2);
+ Standard_Real dist = P1.Distance(P2);
+ if ( i == 1 )
+ {
+ mindist = dist;
+ PC1 = P1;
+ }
+ else
+ {
+ if ( (dist < mindist) || (dist < Precision::Confusion()) )
+ {
+ mindist = dist;
+ PC1 = P1;
+ }
+ }
+ if ( dist < Precision::Confusion() )
+ {
+ if (GC1->IsInstance(STANDARD_TYPE(Geom_Line)))
+ {
+ continue; // tangent line and conic can have only one point with zero distance
+ }
+ gp_Vec aVector1,aVector2;
+ if (GC1->IsInstance(STANDARD_TYPE(Geom_Circle)))
+ {
+ Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (GC1));
+ Standard_Real par_inter = ElCLib::Parameter(circle->Circ(), P1);
+ ElCLib::D1(par_inter,circle->Circ(),P1,aVector1);
+ }
+ else if (GC1->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
+ {
+ Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (GC1));
+ Standard_Real par_inter = ElCLib::Parameter(ellipse->Elips(), P1);
+ ElCLib::D1(par_inter,ellipse->Elips(),P1,aVector1);
+ }
+ if (GC2->IsInstance(STANDARD_TYPE(Geom_Circle)))
+ {
+ Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (GC2));
+ Standard_Real par_inter = ElCLib::Parameter(circle->Circ(), P2);
+ ElCLib::D1(par_inter,circle->Circ(),P2,aVector2);
+ }
+ else if (GC2->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
+ {
+ Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (GC2));
+ Standard_Real par_inter = ElCLib::Parameter(ellipse->Elips(), P2);
+ ElCLib::D1(par_inter,ellipse->Elips(),P2,aVector2);
+ }
+// if ( aVector1.IsParallel(aVector2, 100*Precision::Angular()) ) break;
+ if ( aVector1.IsParallel(aVector2, M_PI / 360.0) ) break; // 0.5 graduce
+ }
+ }
+ aPoint = PC1;
+ return Standard_True;
+}
+// jfa 19/10/2000 end
+
+//=======================================================================
+//function : ComputeTwoEdgesTangent
+//purpose :
+//=======================================================================
+void PrsDim_TangentRelation::ComputeTwoEdgesTangent(const Handle(Prs3d_Presentation)& aPresentation)
+{
+ Handle(Geom_Curve) copy1,copy2;
+ gp_Pnt ptat11,ptat12,ptat21,ptat22;
+ Standard_Boolean isInfinite1,isInfinite2;
+ Handle(Geom_Curve) extCurv;
+ if (!PrsDim::ComputeGeometry(TopoDS::Edge(myFShape),
+ TopoDS::Edge(mySShape),
+ myExtShape,
+ copy1,
+ copy2,
+ ptat11,
+ ptat12,
+ ptat21,
+ ptat22,
+ extCurv,
+ isInfinite1,isInfinite2,
+ myPlane))
+ {
+ return;
+ }
+
+ aPresentation->SetInfiniteState(isInfinite1 || isInfinite2);
+ // current face
+ BRepBuilderAPI_MakeFace makeface(myPlane->Pln());
+ TopoDS_Face face(makeface.Face());
+ BRepAdaptor_Surface adp(makeface.Face());
+
+ Standard_Integer typArg(0);
+
+ if (copy1->IsInstance(STANDARD_TYPE(Geom_Line)))
+ {
+ typArg = 10;
+ }
+ else if (copy1->IsInstance(STANDARD_TYPE(Geom_Circle)))
+ {
+ typArg = 20;
+ }
+ else if (copy1->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
+ {
+ typArg = 30;
+ }
+ else return;
+
+ if (copy2->IsInstance(STANDARD_TYPE(Geom_Line)))
+ {
+ typArg += 1;
+ }
+ else if (copy2->IsInstance(STANDARD_TYPE(Geom_Circle)))
+ {
+ typArg += 2;
+ }
+ else if (copy2->IsInstance(STANDARD_TYPE(Geom_Ellipse)))
+ {
+ typArg += 3;
+ }
+ else return;
+
+ //First find the tangengy vector if exists
+ TopoDS_Vertex VCom;
+ TopExp_Explorer expF(TopoDS::Edge(myFShape),TopAbs_VERTEX);
+ TopExp_Explorer expS(TopoDS::Edge(mySShape),TopAbs_VERTEX);
+ TopoDS_Shape tab[2];
+ Standard_Integer p ;
+ for (p = 0; expF.More(); expF.Next(),p++)
+ {
+ tab[p] = TopoDS::Vertex(expF.Current());
+ }
+ Standard_Boolean found(Standard_False);
+ for ( ; expS.More() && !found; expS.Next())
+ {
+ for ( Standard_Integer l = 0; l<=p && !found; l++)
+ {
+ found = ( expS.Current().IsSame(tab[l]));
+ if (found) VCom = TopoDS::Vertex(expS.Current());
+ }
+ }
+
+ gp_Vec theVector;
+ gp_Pnt pint3d; // tangency point
+ gp_Dir theDir; // tangency direction
+ Standard_Real par_inter = 0.0; // parameter of tangency point
+
+ if (found)
+ {
+ pint3d = BRep_Tool::Pnt(VCom);
+ }
+
+ // Otherwise it is found as if it was known that 2 curves
+ // are tangents (which must be the cases)
+ switch (typArg)
+ {
+ case 12: // circle line
+ {
+ Handle(Geom_Line) line (Handle(Geom_Line)::DownCast (copy1));
+ Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (copy2));
+
+ if ( !found )
+ {
+ // it is enough to project the circus center on the straight line
+ par_inter = ElCLib::Parameter(line->Lin(), circle->Location());
+ pint3d = ElCLib::Value(par_inter, line->Lin());
+ }
+
+ theDir = line->Lin().Direction();
+ myLength = circle->Radius()/5.;
+ if ( !isInfinite1 )
+ {
+ Standard_Real copy1Length = ptat12.Distance(ptat11);
+ if ( copy1Length < myLength )
+ myLength = copy1Length/3.;
+ }
+ }
+ break;
+ case 21: // circle line
+ {
+ Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (copy1));
+ Handle(Geom_Line) line (Handle(Geom_Line)::DownCast (copy2));
+
+ if (!found)
+ {
+ // it is enough to project the circus center on the straight line
+ par_inter = ElCLib::Parameter(line->Lin(), circle->Location());
+ pint3d = ElCLib::Value(par_inter, line->Lin());
+ }
+
+ theDir = line->Lin().Direction();
+ myLength = circle->Radius()/5.;
+ if (!isInfinite2)
+ {
+ Standard_Real copy2Length = ptat21.Distance(ptat22);
+ if ( copy2Length < myLength )
+ myLength = copy2Length/3.;
+ }
+ }
+ break;
+ // jfa 19/10/2000 begin
+ case 13: // line ellipse
+ {
+ Handle(Geom_Line) line (Handle(Geom_Line)::DownCast (copy1));
+ Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (copy2));
+
+ if (!found)
+ {
+ ComputeTangencyPoint(line,ellipse,pint3d);
+ }
+
+ theDir = line->Lin().Direction();
+ myLength = ellipse->MajorRadius()/5.;
+
+ if (!isInfinite1)
+ {
+ Standard_Real copy1Length = ptat12.Distance(ptat11);
+ if ( copy1Length < myLength )
+ myLength = copy1Length/3.;
+ }
+ }
+ break;
+ case 31: // ellipse line
+ {
+ Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (copy1));
+ Handle(Geom_Line) line (Handle(Geom_Line)::DownCast (copy2));
+
+ if (!found)
+ {
+ ComputeTangencyPoint(line,ellipse,pint3d);
+ }
+
+ theDir = line->Lin().Direction();
+ myLength = ellipse->MajorRadius()/5.;
+
+ if (!isInfinite2)
+ {
+ Standard_Real copy2Length = ptat21.Distance(ptat22);
+ if ( copy2Length < myLength )
+ myLength = copy2Length/3.;
+ }
+ }
+ break;
+ case 22: // circle circle
+ {
+ Handle(Geom_Circle) circle1 (Handle(Geom_Circle)::DownCast (copy1));
+ Handle(Geom_Circle) circle2 (Handle(Geom_Circle)::DownCast (copy2));
+ Standard_Real R1 = circle1->Radius();
+ Standard_Real R2 = circle2->Radius();
+ myLength = Max(R1,R2)/5.0;
+ if ( !found )
+ {
+ if ( (circle1->Location()).IsEqual(circle2->Location(),Precision::Confusion()) )
+ {
+ if ( R1 >= R2 )
+ {
+ ElCLib::D1(par_inter,circle1->Circ(),pint3d,theVector);
+ }
+ else
+ {
+ ElCLib::D1(par_inter,circle2->Circ(),pint3d,theVector);
+ }
+ }
+ else
+ {
+ if ( R1 >= R2 )
+ {
+ par_inter = ElCLib::Parameter(circle1->Circ(), circle2->Location());
+ ElCLib::D1(par_inter,circle1->Circ(),pint3d,theVector);
+ }
+ else
+ {
+ par_inter = ElCLib::Parameter(circle2->Circ(), circle1->Location());
+ ElCLib::D1(par_inter,circle2->Circ(),pint3d,theVector);
+ }
+ }
+ }
+ else
+ {
+ par_inter = ElCLib::Parameter(circle1->Circ(), pint3d);
+ ElCLib::D1(par_inter,circle1->Circ(),pint3d,theVector);
+ }
+ theDir = gp_Dir(theVector);
+ }
+ break;
+ case 23: // circle ellipse
+ {
+ Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (copy1));
+ Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (copy2));
+ Standard_Real R1 = circle->Radius();
+ Standard_Real R2 = ellipse->MajorRadius();
+ myLength = Max(R1,R2)/5.0;
+ if (!found)
+ {
+ if ( R1 >= R2 )
+ {
+ ComputeTangencyPoint(circle,ellipse,pint3d);
+ par_inter = ElCLib::Parameter(circle->Circ(), pint3d);
+ ElCLib::D1(par_inter,circle->Circ(),pint3d,theVector);
+ }
+ else
+ {
+ ComputeTangencyPoint(ellipse,circle,pint3d);
+ par_inter = ElCLib::Parameter(ellipse->Elips(), pint3d);
+ ElCLib::D1(par_inter,ellipse->Elips(),pint3d,theVector);
+ }
+ }
+ else
+ {
+ par_inter = ElCLib::Parameter(circle->Circ(), pint3d);
+ ElCLib::D1(par_inter,circle->Circ(),pint3d,theVector);
+ }
+ theDir = gp_Dir(theVector);
+ }
+ break;
+ case 32: // ellipse circle
+ {
+ Handle(Geom_Ellipse) ellipse (Handle(Geom_Ellipse)::DownCast (copy1));
+ Handle(Geom_Circle) circle (Handle(Geom_Circle)::DownCast (copy2));
+ Standard_Real R1 = ellipse->MajorRadius();
+ Standard_Real R2 = circle->Radius();
+ myLength = Max(R1,R2)/5.0;
+ if (!found)
+ {
+ if ( R1 >= R2 )
+ {
+ ComputeTangencyPoint(ellipse,circle,pint3d);
+ par_inter = ElCLib::Parameter( ellipse->Elips(), pint3d);
+ ElCLib::D1(par_inter,ellipse->Elips(),pint3d,theVector);
+ }
+ else
+ {
+ ComputeTangencyPoint(circle,ellipse,pint3d);
+ par_inter = ElCLib::Parameter( circle->Circ(), pint3d);
+ ElCLib::D1(par_inter,circle->Circ(),pint3d,theVector);
+ }
+ }
+ else
+ {
+ par_inter = ElCLib::Parameter(circle->Circ(), pint3d);
+ ElCLib::D1(par_inter,circle->Circ(),pint3d,theVector);
+ }
+ theDir = gp_Dir(theVector);
+ }
+ break;
+ case 33: // ellipse ellipse
+ {
+ Handle(Geom_Ellipse) ellipse1 (Handle(Geom_Ellipse)::DownCast (copy1));
+ Handle(Geom_Ellipse) ellipse2 (Handle(Geom_Ellipse)::DownCast (copy2));
+ Standard_Real R1 = ellipse1->MajorRadius();
+ Standard_Real R2 = ellipse2->MajorRadius();
+ myLength = Max(R1,R2)/5.0;
+ if (!found)
+ {
+ if ( R1 > R2 )
+ {
+ ComputeTangencyPoint(ellipse1,ellipse2,pint3d);
+ par_inter = ElCLib::Parameter( ellipse1->Elips(), pint3d);
+ ElCLib::D1(par_inter,ellipse1->Elips(),pint3d,theVector);
+ }
+ else
+ {
+ ComputeTangencyPoint(ellipse2,ellipse1,pint3d);
+ par_inter = ElCLib::Parameter( ellipse2->Elips(), pint3d);
+ ElCLib::D1(par_inter,ellipse2->Elips(),pint3d,theVector);
+ }
+ }
+ else
+ {
+ par_inter = ElCLib::Parameter(ellipse1->Elips(), pint3d);
+ ElCLib::D1(par_inter,ellipse1->Elips(),pint3d,theVector);
+ }
+ theDir = gp_Dir(theVector);
+ }
+ break;
+ // jfa 19/10/2000 end
+ default:
+ return;
+ }
+
+ myAttach = pint3d;
+ myDir = theDir;
+ myPosition = pint3d;
+ myLength = Min(myLength,myArrowSize);
+
+ DsgPrs_TangentPresentation::Add(aPresentation,myDrawer,myAttach,myDir,myLength);
+ if ( (myExtShape != 0) && !extCurv.IsNull())
+ {
+ gp_Pnt pf, pl;
+ if ( myExtShape == 1 )
+ {
+ if (!isInfinite1)
+ {
+ pf = ptat11;
+ pl = ptat12;
+ }
+ ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(myFShape),copy1,pf,pl);
+ }
+ else
+ {
+ if (!isInfinite2)
+ {
+ pf = ptat21;
+ pl = ptat22;
+ }
+ ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(mySShape),copy2,pf,pl);
+ }
+ }
+}
--- /dev/null
+// Created on: 1996-12-05
+// Created by: Jean-Pierre COMBE/Odile Olivier
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_TangentRelation_HeaderFile
+#define _PrsDim_TangentRelation_HeaderFile
+
+#include <PrsDim_Relation.hxx>
+
+DEFINE_STANDARD_HANDLE(PrsDim_TangentRelation, PrsDim_Relation)
+
+//! A framework to display tangency constraints between
+//! two or more Interactive Objects of the datum type.
+//! The datums are normally faces or edges.
+class PrsDim_TangentRelation : public PrsDim_Relation
+{
+ DEFINE_STANDARD_RTTIEXT(PrsDim_TangentRelation, PrsDim_Relation)
+public:
+
+ //! TwoFacesTangent or TwoEdgesTangent relation
+ //! Constructs an object to display tangency constraints.
+ //! This object is defined by the first shape aFShape, the
+ //! second shape aSShape, the plane aPlane and the index anExternRef.
+ //! aPlane serves as an optional axis.
+ //! anExternRef set to 0 indicates that there is no relation.
+ Standard_EXPORT PrsDim_TangentRelation(const TopoDS_Shape& aFShape, const TopoDS_Shape& aSShape, const Handle(Geom_Plane)& aPlane, const Standard_Integer anExternRef = 0);
+
+ //! Returns the external reference for tangency.
+ //! The values are as follows:
+ //! - 0 - there is no connection;
+ //! - 1 - there is a connection to the first shape;
+ //! - 2 - there is a connection to the second shape.
+ //! This reference is defined at construction time.
+ Standard_Integer ExternRef() { return myExternRef; }
+
+ //! Sets the external reference for tangency, aRef.
+ //! The values are as follows:
+ //! - 0 - there is no connection;
+ //! - 1 - there is a connection to the first shape;
+ //! - 2 - there is a connection to the second shape.
+ //! This reference is initially defined at construction time.
+ void SetExternRef (const Standard_Integer aRef) { myExternRef = aRef; }
+
+private:
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+
+ Standard_EXPORT void ComputeTwoFacesTangent (const Handle(Prs3d_Presentation)& aPresentation);
+
+ Standard_EXPORT void ComputeTwoEdgesTangent (const Handle(Prs3d_Presentation)& aPresentation);
+
+private:
+
+ gp_Pnt myAttach;
+ gp_Dir myDir;
+ Standard_Real myLength;
+ Standard_Integer myExternRef;
+
+};
+
+#endif // _PrsDim_TangentRelation_HeaderFile
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_TypeOfAngle_HeaderFile
+#define _PrsDim_TypeOfAngle_HeaderFile
+
+//! Declares the type of angle.
+enum PrsDim_TypeOfAngle
+{
+ PrsDim_TypeOfAngle_Interior, //!< the angle between two lines built on geometry parameters
+ PrsDim_TypeOfAngle_Exterior, //!< the angle equal 2 PI minus the interior angle
+};
+
+#endif // _PrsDim_TypeOfAngle_HeaderFile
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_TypeOfAngleArrowVisibility_HeaderFile
+#define _PrsDim_TypeOfAngleArrowVisibility_HeaderFile
+
+//! Declares what arrows are visible on angle presentation
+enum PrsDim_TypeOfAngleArrowVisibility
+{
+ PrsDim_TypeOfAngleArrowVisibility_Both, //!< both arrows of the first and the second angle tips
+ PrsDim_TypeOfAngleArrowVisibility_First, //!< only first point arrow
+ PrsDim_TypeOfAngleArrowVisibility_Second, //!< only second point arrow
+ PrsDim_TypeOfAngleArrowVisibility_None, //!< arrows are not visible
+};
+
+#endif // _PrsDim_TypeOfAngleArrowVisibility_HeaderFile
--- /dev/null
+// Created on: 1996-12-11
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _PrsDim_TypeOfDist_HeaderFile
+#define _PrsDim_TypeOfDist_HeaderFile
+
+//! To declare the type of distance.
+enum PrsDim_TypeOfDist
+{
+ PrsDim_TypeOfDist_Unknown,
+ PrsDim_TypeOfDist_Horizontal,
+ PrsDim_TypeOfDist_Vertical
+};
+
+#endif // _PrsDim_TypeOfDist_HeaderFile
#include <TopoDS.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pln.hxx>
-#include <AIS_AngleDimension.hxx>
+#include <PrsDim_AngleDimension.hxx>
#include <Aspect_Window.hxx>
#include <V3d_View.hxx>
//di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n";
di << argv[5] << " " << Draw::Atof(argv[4]) << "\n";
- Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond);
+ Handle(PrsDim_AngleDimension) aDim = new PrsDim_AngleDimension(aFirst, aSecond);
aContext->Display (aDim, Standard_True);
return 0;
gp_Dir plndir(0, 0, 1);
Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
- Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3);
+ Handle(PrsDim_AngleDimension) anAngleDimension = new PrsDim_AngleDimension (p1.Mirrored (p2), p2, p3);
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
anAspect->MakeArrows3d (Standard_True);
#include <Geom_Axis2Placement.hxx>
#include <V3d_View.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <AIS_LengthDimension.hxx>
-#include <AIS_RadiusDimension.hxx>
+#include <PrsDim_LengthDimension.hxx>
+#include <PrsDim_RadiusDimension.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Extrema_ExtPS.hxx>
/***************************************/
//dimension "L 502.51"
/***************************************/
- Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln->Pln());
+ Handle(PrsDim_LengthDimension) len = new PrsDim_LengthDimension(V2, V3, pln->Pln());
anAspect->ArrowAspect()->SetLength (30.0);
len->SetDimensionAspect (anAspect);
context->Display (len, Standard_False);
/***************************************/
//dimension "L 90"
/***************************************/
- Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V7, V4, pln->Pln());
+ Handle(PrsDim_LengthDimension) len1 = new PrsDim_LengthDimension(V7, V4, pln->Pln());
len1->SetDimensionAspect (anAspect);
len1->SetFlyout (30.0);
anAspect->ArrowAspect()->SetLength (100.0);
/***************************************/
//dimension "L 150"
/***************************************/
- Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln->Pln());
+ Handle(PrsDim_LengthDimension) len2 = new PrsDim_LengthDimension(V1, V2, pln->Pln());
len2->SetDimensionAspect (anAspect);
context->Display (len2, Standard_False);
/***************************************/
/***************************************/
gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
- Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1);
+ Handle(PrsDim_RadiusDimension) dim1 = new PrsDim_RadiusDimension(E1);
dim1->SetDimensionAspect (anAspect);
context->Display (dim1, Standard_False);
/***************************************/
/***************************************/
gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
- dim1 = new AIS_RadiusDimension(E_cir1);
+ dim1 = new PrsDim_RadiusDimension(E_cir1);
anAspect->ArrowAspect()->SetLength (60.0);
dim1->SetDimensionAspect (anAspect);
context->Display (dim1, Standard_False);
/***************************************/
gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
- dim1 = new AIS_RadiusDimension(E_cir2);
+ dim1 = new PrsDim_RadiusDimension(E_cir2);
anAspect->ArrowAspect()->SetLength (40.0);
dim1->SetDimensionAspect (anAspect);
context->Display (dim1, Standard_True);
#include<BRepBuilderAPI_MakeVertex.hxx>
#include<TCollection_ExtendedString.hxx>
#include<AIS_InteractiveContext.hxx>
-#include<AIS_LengthDimension.hxx>
+#include<PrsDim_LengthDimension.hxx>
static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
{
Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
TCollection_ExtendedString Ext1("Dim1");
- Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln());
+ Handle(PrsDim_LengthDimension) Dim1 = new PrsDim_LengthDimension(V1,V2,Plane1->Pln());
Dim1->SetCustomValue (Draw::Atof(a[2]));
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
SelectMgr
PrsMgr
AIS
-DsgPrs
StdSelect
+DsgPrs
+PrsDim
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
-#include <AIS_Relation.hxx>
+#include <PrsDim_Relation.hxx>
#include <Standard_GUID.hxx>
#include <Standard_ProgramError.hxx>
#include <Standard_Type.hxx>
Handle(TDataXtd_Position) Position;
if (aLabel.FindAttribute(TDataXtd_Position::GetID(),Position)) {
- Handle(AIS_Relation)::DownCast(anAISObject)->SetPosition(Position->GetPosition());
+ Handle(PrsDim_Relation)::DownCast(anAISObject)->SetPosition(Position->GetPosition());
}
if (anAISObject->HasInteractiveContext()) {
// Purpose: Update AIS object from a TDataXtd_Constraint.
// Modified Mon 30 10:15:43 1998 by SZY
-#include <AIS_AngleDimension.hxx>
-#include <AIS_ConcentricRelation.hxx>
-#include <AIS_DiameterDimension.hxx>
-#include <AIS_EqualDistanceRelation.hxx>
-#include <AIS_EqualRadiusRelation.hxx>
-#include <AIS_FixRelation.hxx>
-#include <AIS_IdenticRelation.hxx>
+#include <TPrsStd_ConstraintTools.hxx>
+
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
-#include <AIS_LengthDimension.hxx>
-#include <AIS_MaxRadiusDimension.hxx>
-#include <AIS_MidPointRelation.hxx>
-#include <AIS_MinRadiusDimension.hxx>
-#include <AIS_OffsetDimension.hxx>
-#include <AIS_ParallelRelation.hxx>
-#include <AIS_PerpendicularRelation.hxx>
-#include <AIS_RadiusDimension.hxx>
-#include <AIS_Relation.hxx>
-#include <AIS_SymmetricRelation.hxx>
-#include <AIS_TangentRelation.hxx>
+#include <PrsDim_AngleDimension.hxx>
+#include <PrsDim_ConcentricRelation.hxx>
+#include <PrsDim_DiameterDimension.hxx>
+#include <PrsDim_EqualDistanceRelation.hxx>
+#include <PrsDim_EqualRadiusRelation.hxx>
+#include <PrsDim_FixRelation.hxx>
+#include <PrsDim_IdenticRelation.hxx>
+#include <PrsDim_LengthDimension.hxx>
+#include <PrsDim_MaxRadiusDimension.hxx>
+#include <PrsDim_MidPointRelation.hxx>
+#include <PrsDim_MinRadiusDimension.hxx>
+#include <PrsDim_OffsetDimension.hxx>
+#include <PrsDim_ParallelRelation.hxx>
+#include <PrsDim_PerpendicularRelation.hxx>
+#include <PrsDim_RadiusDimension.hxx>
+#include <PrsDim_Relation.hxx>
+#include <PrsDim_SymmetricRelation.hxx>
+#include <PrsDim_TangentRelation.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
-#include <TPrsStd_ConstraintTools.hxx>
#include <UnitsAPI.hxx>
#include <stdio.h>
Standard_Real val;
TCollection_ExtendedString txt;
TPrsStd_ConstraintTools:: ComputeTextAndValue(aConst,val,txt,aConst->GetType() == TDataXtd_ANGLE);
- Handle(AIS_Relation) rel = Handle(AIS_Relation)::DownCast(anAIS);
+ Handle(PrsDim_Relation) rel = Handle(PrsDim_Relation)::DownCast(anAIS);
if (!rel.IsNull()) rel->SetText(txt);
}
Standard_Boolean SaveDrw = Standard_False;
Handle(Prs3d_Drawer) aDrawer;
- Handle(AIS_LengthDimension) aDim;
+ Handle(PrsDim_LengthDimension) aDim;
if (!theAIS.IsNull())
{
- aDim = Handle(AIS_LengthDimension)::DownCast (theAIS);
+ aDim = Handle(PrsDim_LengthDimension)::DownCast (theAIS);
}
// Check shapes for AIS dimension
{
if (isEdge)
{
- aDim = new AIS_LengthDimension (GetEdge (aShape1), aPlane->Pln());
+ aDim = new PrsDim_LengthDimension (GetEdge (aShape1), aPlane->Pln());
}
else if (isFaces)
{
- aDim = new AIS_LengthDimension (GetFace (aShape1), GetFace (aShape2));
+ aDim = new PrsDim_LengthDimension (GetFace (aShape1), GetFace (aShape2));
}
else
{
- aDim = new AIS_LengthDimension (aShape1, aShape2, aPlane->Pln());
+ aDim = new PrsDim_LengthDimension (aShape1, aShape2, aPlane->Pln());
}
if (SaveDrw)
GetGoodShape(shape1);
GetGoodShape(shape2);
// Update de l'AIS
- Handle(AIS_PerpendicularRelation) ais;
- if (anAIS.IsNull()) ais = new AIS_PerpendicularRelation(shape1,shape2);
+ Handle(PrsDim_PerpendicularRelation) ais;
+ if (anAIS.IsNull()) ais = new PrsDim_PerpendicularRelation(shape1,shape2);
else {
- ais = Handle(AIS_PerpendicularRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_PerpendicularRelation)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_PerpendicularRelation(shape1,shape2);
+ ais = new PrsDim_PerpendicularRelation(shape1,shape2);
}
else {
ais->SetFirstShape(shape1);
// Update de l'AIS
GetGoodShape(shape1);
GetGoodShape(shape2);
- Handle(AIS_ParallelRelation) ais;
- if (anAIS.IsNull()) ais = new AIS_ParallelRelation(shape1,shape2,aplane);
+ Handle(PrsDim_ParallelRelation) ais;
+ if (anAIS.IsNull()) ais = new PrsDim_ParallelRelation(shape1,shape2,aplane);
else {
- ais = Handle(AIS_ParallelRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_ParallelRelation)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_ParallelRelation(shape1,shape2,aplane);
+ ais = new PrsDim_ParallelRelation(shape1,shape2,aplane);
}
else {
ais->SetFirstShape(shape1);
return;
}
// Update de l'AIS
- Handle(AIS_SymmetricRelation) ais;
- if (anAIS.IsNull()) ais = new AIS_SymmetricRelation(shape3,shape1,shape2,aplane);
+ Handle(PrsDim_SymmetricRelation) ais;
+ if (anAIS.IsNull()) ais = new PrsDim_SymmetricRelation(shape3,shape1,shape2,aplane);
else {
- ais = Handle(AIS_SymmetricRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_SymmetricRelation)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_SymmetricRelation(shape3,shape1,shape2,aplane);
+ ais = new PrsDim_SymmetricRelation(shape3,shape1,shape2,aplane);
}
else {
ais->SetFirstShape(shape1);
}
// Update de l'AIS
- Handle(AIS_MidPointRelation) ais;
- if ( anAIS.IsNull() ) ais = new AIS_MidPointRelation(shape3,shape1,shape2,aplane);
+ Handle(PrsDim_MidPointRelation) ais;
+ if ( anAIS.IsNull() ) ais = new PrsDim_MidPointRelation(shape3,shape1,shape2,aplane);
else
{
- ais = Handle(AIS_MidPointRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_MidPointRelation)::DownCast(anAIS);
if (ais.IsNull())
{
- ais = new AIS_MidPointRelation(shape3,shape1,shape2,aplane);
+ ais = new PrsDim_MidPointRelation(shape3,shape1,shape2,aplane);
}
else
{
return;
}
// Update de l'AIS
- Handle(AIS_TangentRelation) ais;
+ Handle(PrsDim_TangentRelation) ais;
if (anAIS.IsNull())
{
- ais = new AIS_TangentRelation(shape1,shape2,aplane);
+ ais = new PrsDim_TangentRelation(shape1,shape2,aplane);
ais->SetArrowSize(10000000); // jfa 9/10/2000
}
else
{
- ais = Handle(AIS_TangentRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_TangentRelation)::DownCast(anAIS);
if (ais.IsNull())
{
- ais = new AIS_TangentRelation(shape1,shape2,aplane);
+ ais = new PrsDim_TangentRelation(shape1,shape2,aplane);
ais->SetArrowSize(10000000); // jfa 9/10/2000
}
else
TCollection_ExtendedString txt;
TPrsStd_ConstraintTools::ComputeTextAndValue (aConst,val1,txt,Standard_True);
- Handle(AIS_AngleDimension) ais;
+ Handle(PrsDim_AngleDimension) ais;
TopoDS_Face face;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_AngleDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_AngleDimension)::DownCast(anAIS);
if(ais.IsNull()) {
face = TopoDS::Face( shape );
- ais = new AIS_AngleDimension (face);
+ ais = new PrsDim_AngleDimension (face);
}
else {
ais->SetMeasuredGeometry(TopoDS::Face( shape ));
}
else {
face = TopoDS::Face (shape);
- ais = new AIS_AngleDimension (face);
+ ais = new PrsDim_AngleDimension (face);
}
anAIS = ais;
Standard_Boolean toCreate (Standard_True);
Standard_Boolean isface(shape1.ShapeType()==TopAbs_FACE);
- Handle(AIS_AngleDimension) ais;
+ Handle(PrsDim_AngleDimension) ais;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_AngleDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_AngleDimension)::DownCast(anAIS);
if( ais.IsNull() ) {
toCreate = Standard_True;
}
FindExternalShape(aConst,ExtShape);
GetGoodShape(shape1);
GetGoodShape(shape2);
- ais = new AIS_AngleDimension (TopoDS::Edge(shape1),
+ ais = new PrsDim_AngleDimension (TopoDS::Edge(shape1),
TopoDS::Edge(shape2));
}
}
else {
if (isCurvilinear) {
- ais = new AIS_AngleDimension (TopoDS::Face(shape1),
+ ais = new PrsDim_AngleDimension (TopoDS::Face(shape1),
TopoDS::Face(shape2));
}
else if (isface) {
- ais = new AIS_AngleDimension (TopoDS::Face(shape1),
+ ais = new PrsDim_AngleDimension (TopoDS::Face(shape1),
TopoDS::Face(shape2));
}
}
return;
}
// Update de l'AIS
- Handle(AIS_ConcentricRelation) ais;
+ Handle(PrsDim_ConcentricRelation) ais;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_ConcentricRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_ConcentricRelation)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_ConcentricRelation (shape1,shape2,aplane);
+ ais = new PrsDim_ConcentricRelation (shape1,shape2,aplane);
}
else {
ais->SetFirstShape(shape1);
}
}
else {
- ais = new AIS_ConcentricRelation (shape1,shape2,aplane);
+ ais = new PrsDim_ConcentricRelation (shape1,shape2,aplane);
}
anAIS = ais;
Standard_Boolean isplanar(aConst->IsPlanar());
if (isplanar) GetGoodShape(shape1);
- Handle(AIS_RadiusDimension) ais;
+ Handle(PrsDim_RadiusDimension) ais;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_RadiusDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_RadiusDimension)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_RadiusDimension (shape1);
+ ais = new PrsDim_RadiusDimension (shape1);
}
else {
ais->SetMeasuredGeometry(shape1);
}
}
- else ais = new AIS_RadiusDimension (shape1);
+ else ais = new PrsDim_RadiusDimension (shape1);
if (isplanar) {
Handle(Geom_Geometry) ageom2;
Standard_Boolean isplanar(aConst->IsPlanar());
if (isplanar) GetGoodShape(shape1);
- Handle(AIS_MinRadiusDimension) ais;
+ Handle(PrsDim_MinRadiusDimension) ais;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_MinRadiusDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_MinRadiusDimension)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_MinRadiusDimension (shape1,val1,txt);
+ ais = new PrsDim_MinRadiusDimension (shape1,val1,txt);
}
else {
ais->SetValue(val1);
ais->SetText(txt);
}
}
- else ais = new AIS_MinRadiusDimension (shape1,val1,txt);
+ else ais = new PrsDim_MinRadiusDimension (shape1,val1,txt);
if (isplanar) {
Handle(Geom_Geometry) ageom2;
Standard_Boolean isplanar(aConst->IsPlanar());
if (isplanar) GetGoodShape(shape1);
- Handle(AIS_MaxRadiusDimension) ais;
+ Handle(PrsDim_MaxRadiusDimension) ais;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_MaxRadiusDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_MaxRadiusDimension)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_MaxRadiusDimension (shape1,val1,txt);
+ ais = new PrsDim_MaxRadiusDimension (shape1,val1,txt);
}
else {
ais->SetValue(val1);
ais->SetText(txt);
}
}
- else ais = new AIS_MaxRadiusDimension (shape1,val1,txt);
+ else ais = new PrsDim_MaxRadiusDimension (shape1,val1,txt);
if (isplanar) {
Handle(Geom_Geometry) ageom2;
}
//Update AIS
- Handle(AIS_EqualDistanceRelation) ais;
+ Handle(PrsDim_EqualDistanceRelation) ais;
if (!anAIS.IsNull()) {
{
- ais = Handle(AIS_EqualDistanceRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_EqualDistanceRelation)::DownCast(anAIS);
if (ais.IsNull())
- ais = new AIS_EqualDistanceRelation(aShape1, aShape2, aShape3, aShape4, aPlane);
+ ais = new PrsDim_EqualDistanceRelation(aShape1, aShape2, aShape3, aShape4, aPlane);
else {
ais->SetFirstShape(aShape1);
}
}
}
- else ais = new AIS_EqualDistanceRelation(aShape1, aShape2, aShape3, aShape4, aPlane);
+ else ais = new PrsDim_EqualDistanceRelation(aShape1, aShape2, aShape3, aShape4, aPlane);
anAIS = ais;
return;
}
}
- Handle(AIS_EqualRadiusRelation) ais;
+ Handle(PrsDim_EqualRadiusRelation) ais;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_EqualRadiusRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_EqualRadiusRelation)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_EqualRadiusRelation(edge1, edge2, aplane);
+ ais = new PrsDim_EqualRadiusRelation(edge1, edge2, aplane);
}
else {
ais->SetFirstShape(shape1);
}
}
else {
- ais = new AIS_EqualRadiusRelation(edge1, edge2, aplane);
+ ais = new PrsDim_EqualRadiusRelation(edge1, edge2, aplane);
}
anAIS = ais;
// Update de l'AIS
Standard_Boolean IsPlanar(aConst->IsPlanar());
if (IsPlanar) GetGoodShape(shape1);
- Handle(AIS_DiameterDimension) ais;
+ Handle(PrsDim_DiameterDimension) ais;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_DiameterDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_DiameterDimension)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_DiameterDimension (shape1);
+ ais = new PrsDim_DiameterDimension (shape1);
}
else {
ais->SetMeasuredGeometry(shape1);
}
}
- else ais = new AIS_DiameterDimension (shape1);
+ else ais = new PrsDim_DiameterDimension (shape1);
if (IsPlanar) {
Handle(Geom_Geometry) ageom2;
return;
}
// Update de l'AIS
- Handle(AIS_FixRelation) ais;
+ Handle(PrsDim_FixRelation) ais;
if (!anAIS.IsNull()) {
- ais = Handle(AIS_FixRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_FixRelation)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_FixRelation (shape1,aplane);
+ ais = new PrsDim_FixRelation (shape1,aplane);
}
else {
ais->SetFirstShape(shape1);
ais->SetPlane(aplane);
}
}
- else ais = new AIS_FixRelation (shape1,aplane);
+ else ais = new PrsDim_FixRelation (shape1,aplane);
anAIS = ais;
}
Standard_Real val1;
TCollection_ExtendedString txt;
- Handle(AIS_LengthDimension) ais;
+ Handle(PrsDim_LengthDimension) ais;
//Handle(Prs3d_Drawer) aDrawer;
if (nbgeom == 1)
ComputeTextAndValue (aConst,val1,txt,Standard_False);
if (!anAIS.IsNull())
{
- ais = Handle(AIS_LengthDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_LengthDimension)::DownCast(anAIS);
}
if (S1.ShapeType() == TopAbs_FACE && S2.ShapeType() == TopAbs_FACE)
{
if (ais.IsNull())
{
- ais = new AIS_LengthDimension (TopoDS::Face(S1),TopoDS::Face(S2));
+ ais = new PrsDim_LengthDimension (TopoDS::Face(S1),TopoDS::Face(S2));
}
else
{
aplane = new Geom_Plane (NLin.Location(),NLin.Direction()^TDir);
if (ais.IsNull()) {
- ais = new AIS_LengthDimension (S1,S2,aplane->Pln());
+ ais = new PrsDim_LengthDimension (S1,S2,aplane->Pln());
}
else {
ais->SetMeasuredShapes (S1, S2);
}
}
S2 = nearest;
- ais = Handle(AIS_LengthDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_LengthDimension)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_LengthDimension (S1,S2,aplane->Pln());
+ ais = new PrsDim_LengthDimension (S1,S2,aplane->Pln());
}
else {
ais->SetMeasuredShapes (S1, S2);
ComputeTextAndValue(aConst,val1,txt,Standard_False);
}
// Update de l'AIS
- Handle(AIS_OffsetDimension) ais;
+ Handle(PrsDim_OffsetDimension) ais;
if (anAIS.IsNull()) {
- ais = new AIS_OffsetDimension(GetFace(shape1),GetFace(shape2),val1,txt);
+ ais = new PrsDim_OffsetDimension(GetFace(shape1),GetFace(shape2),val1,txt);
ais->SetArrowSize(val1/20.);
} else {
- ais = Handle(AIS_OffsetDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_OffsetDimension)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_OffsetDimension(GetFace(shape1),GetFace(shape2),val1,txt);
+ ais = new PrsDim_OffsetDimension(GetFace(shape1),GetFace(shape2),val1,txt);
ais->SetArrowSize(val1/20.);
} else {
ais->SetFirstShape(GetFace(shape1));
}
// Update de l'AIS
- Handle(AIS_IdenticRelation) ais;
- if (anAIS.IsNull()) ais = new AIS_IdenticRelation(shape1,shape2,aplane);
+ Handle(PrsDim_IdenticRelation) ais;
+ if (anAIS.IsNull()) ais = new PrsDim_IdenticRelation(shape1,shape2,aplane);
else {
- ais = Handle(AIS_IdenticRelation)::DownCast(anAIS);
+ ais = Handle(PrsDim_IdenticRelation)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_IdenticRelation(shape1,shape2,aplane);
+ ais = new PrsDim_IdenticRelation(shape1,shape2,aplane);
}
else {
ais->SetFirstShape(shape1);
ComputeTextAndValue(aConst,val1,txt,Standard_False);
// Update de l'AIS
- Handle(AIS_RadiusDimension) ais;
+ Handle(PrsDim_RadiusDimension) ais;
{
try {
OCC_CATCH_SIGNALS
if (anAIS.IsNull()) ais =
- new AIS_RadiusDimension(shape1);
+ new PrsDim_RadiusDimension(shape1);
else {
- ais = Handle(AIS_RadiusDimension)::DownCast(anAIS);
+ ais = Handle(PrsDim_RadiusDimension)::DownCast(anAIS);
if (ais.IsNull()) {
- ais = new AIS_RadiusDimension(shape1);
+ ais = new PrsDim_RadiusDimension(shape1);
}
else {
ais->SetMeasuredGeometry(shape1);
#include <TopExp_Explorer.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <StdSelect_ShapeTypeFilter.hxx>
-#include <AIS.hxx>
#include <AIS_ColoredShape.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_Trihedron.hxx>
#include <AIS_Axis.hxx>
-#include <AIS_Relation.hxx>
+#include <PrsDim.hxx>
+#include <PrsDim_Relation.hxx>
#include <AIS_TypeFilter.hxx>
#include <AIS_SignatureFilter.hxx>
#include <AIS_ListOfInteractive.hxx>
}
else if (theObj->Type() == AIS_KOI_Relation)
{
- // AIS_Dimention and AIS_Relation
- Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (theObj);
+ // PrsDim_Dimention and AIS_Relation
+ Handle(PrsDim_Relation) aRelation = Handle(PrsDim_Relation)::DownCast (theObj);
switch (aRelation->KindOfDimension())
{
- case AIS_KOD_PLANEANGLE: theDI << " AIS_AngleDimension"; break;
- case AIS_KOD_LENGTH: theDI << " AIS_Chamf2/3dDimension/AIS_LengthDimension"; break;
- case AIS_KOD_DIAMETER: theDI << " AIS_DiameterDimension"; break;
- case AIS_KOD_ELLIPSERADIUS: theDI << " AIS_EllipseRadiusDimension"; break;
- //case AIS_KOD_FILLETRADIUS: theDI << " AIS_FilletRadiusDimension "; break;
- case AIS_KOD_OFFSET: theDI << " AIS_OffsetDimension"; break;
- case AIS_KOD_RADIUS: theDI << " AIS_RadiusDimension"; break;
+ case PrsDim_KOD_PLANEANGLE: theDI << " PrsDim_AngleDimension"; break;
+ case PrsDim_KOD_LENGTH: theDI << " PrsDim_Chamf2/3dDimension/PrsDim_LengthDimension"; break;
+ case PrsDim_KOD_DIAMETER: theDI << " PrsDim_DiameterDimension"; break;
+ case PrsDim_KOD_ELLIPSERADIUS: theDI << " PrsDim_EllipseRadiusDimension"; break;
+ //case PrsDim_KOD_FILLETRADIUS: theDI << " PrsDim_FilletRadiusDimension "; break;
+ case PrsDim_KOD_OFFSET: theDI << " PrsDim_OffsetDimension"; break;
+ case PrsDim_KOD_RADIUS: theDI << " PrsDim_RadiusDimension"; break;
default: theDI << " UNKNOWN dimension"; break;
}
}
if(dimension_status == -1)
TheAISContext()->Erase(curio,Standard_False);
else {
- AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
- if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
- (dimension_status==1 && KOD != AIS_KOD_NONE))
+ PrsDim_KindOfDimension KOD = Handle(PrsDim_Relation)::DownCast (curio)->KindOfDimension();
+ if ((dimension_status==0 && KOD == PrsDim_KOD_NONE)||
+ (dimension_status==1 && KOD != PrsDim_KOD_NONE))
TheAISContext()->Erase(curio,Standard_False);
}
}
if(dimension_status == -1)
TheAISContext()->Display(curio,Standard_False);
else {
- AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
- if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
- (dimension_status==1 && KOD != AIS_KOD_NONE))
+ PrsDim_KindOfDimension KOD = Handle(PrsDim_Relation)::DownCast (curio)->KindOfDimension();
+ if ((dimension_status==0 && KOD == PrsDim_KOD_NONE)||
+ (dimension_status==1 && KOD != PrsDim_KOD_NONE))
TheAISContext()->Display(curio,Standard_False);
}
#include <DBRep.hxx>
#include <TopoDS_Face.hxx>
#include <gp_Pln.hxx>
-#include <AIS_KindOfSurface.hxx>
#include <BRepOffsetAPI_DraftAngle.hxx>
#include <Precision.hxx>
#include <BRepAlgo.hxx>
#include <OSD_Environment.hxx>
#include <DrawTrSurf.hxx>
-//#include <DbgTools.hxx>
-//#include <FeatAlgo_MakeLinearForm.hxx>
-
-
-
//=======================================================================
//function : IsValid
anAngle = 2*M_PI * anAngle / 360.0;
gp_Pln aPln;
Handle( Geom_Surface )aSurf;
- AIS_KindOfSurface aSurfType;
+ PrsDim_KindOfSurface aSurfType;
Standard_Real Offset;
gp_Dir aDir;
if(argc > 4) { // == 5
}
TopoDS_Face face2 = TopoDS::Face(Plane);
- if(!AIS::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset))
+ if(!PrsDim::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset))
{
di << "TEST : Can't find plane\n";
return 1;
#include <ViewerTest.hxx>
-#include <AIS_AngleDimension.hxx>
#include <AIS_Circle.hxx>
-#include <AIS_ConcentricRelation.hxx>
-#include <AIS_DiameterDimension.hxx>
#include <AIS_DisplayMode.hxx>
-#include <AIS_EqualDistanceRelation.hxx>
-#include <AIS_EqualRadiusRelation.hxx>
-#include <AIS_FixRelation.hxx>
-#include <AIS_IdenticRelation.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <AIS_KindOfRelation.hxx>
-#include <AIS_LengthDimension.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_MapOfInteractive.hxx>
-#include <AIS_OffsetDimension.hxx>
-#include <AIS_ParallelRelation.hxx>
-#include <AIS_PerpendicularRelation.hxx>
#include <AIS_Point.hxx>
-#include <AIS_RadiusDimension.hxx>
-#include <AIS_Relation.hxx>
#include <AIS_Shape.hxx>
-#include <AIS_SymmetricRelation.hxx>
-#include <AIS_TangentRelation.hxx>
+#include <PrsDim_AngleDimension.hxx>
+#include <PrsDim_ConcentricRelation.hxx>
+#include <PrsDim_DiameterDimension.hxx>
+#include <PrsDim_EqualDistanceRelation.hxx>
+#include <PrsDim_EqualRadiusRelation.hxx>
+#include <PrsDim_FixRelation.hxx>
+#include <PrsDim_IdenticRelation.hxx>
+#include <PrsDim_KindOfRelation.hxx>
+#include <PrsDim_LengthDimension.hxx>
+#include <PrsDim_OffsetDimension.hxx>
+#include <PrsDim_ParallelRelation.hxx>
+#include <PrsDim_PerpendicularRelation.hxx>
+#include <PrsDim_RadiusDimension.hxx>
+#include <PrsDim_Relation.hxx>
+#include <PrsDim_SymmetricRelation.hxx>
+#include <PrsDim_TangentRelation.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
#include <ViewerTest_EventManager.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_Dimension.hxx>
extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
const Handle(AIS_InteractiveObject)& theAISObj,
//function : SetDimensionParams
//purpose : Sets parameters for dimension
//=======================================================================
-static void SetDimensionParams (const Handle(AIS_Dimension)& theDim,
+static void SetDimensionParams (const Handle(PrsDim_Dimension)& theDim,
const NCollection_DataMap<TCollection_AsciiString, Standard_Real>& theRealParams,
const NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theStringParams)
{
//function : SetAngleDimensionParams
//purpose : Sets parameters for angle dimension
//=======================================================================
-static void SetAngleDimensionParams (const Handle(AIS_Dimension)& theDim,
+static void SetAngleDimensionParams (const Handle(PrsDim_Dimension)& theDim,
const NCollection_DataMap<TCollection_AsciiString,
TCollection_AsciiString>& theStringParams)
{
- Handle(AIS_AngleDimension) anAngleDim = Handle(AIS_AngleDimension)::DownCast (theDim);
+ Handle(PrsDim_AngleDimension) anAngleDim = Handle(PrsDim_AngleDimension)::DownCast (theDim);
if (anAngleDim.IsNull())
{
return;
if (theStringParams.IsBound ("type"))
{
- AIS_TypeOfAngle anAngleType = AIS_TOA_Interior;
+ PrsDim_TypeOfAngle anAngleType = PrsDim_TypeOfAngle_Interior;
TCollection_AsciiString anAngleTypeStr = theStringParams.Find ("type");
if (anAngleTypeStr.IsEqual("interior"))
{
- anAngleType = AIS_TOA_Interior;
+ anAngleType = PrsDim_TypeOfAngle_Interior;
}
else if (anAngleTypeStr.IsEqual("exterior"))
{
- anAngleType = AIS_TOA_Exterior;
+ anAngleType = PrsDim_TypeOfAngle_Exterior;
}
else
{
if (theStringParams.IsBound ("showarrow"))
{
- AIS_TypeOfAngleArrowVisibility anArrowType = AIS_TOAV_Both;
+ PrsDim_TypeOfAngleArrowVisibility anArrowType = PrsDim_TypeOfAngleArrowVisibility_Both;
TCollection_AsciiString anArrowTypeStr = theStringParams.Find ("showarrow");
if (anArrowTypeStr.IsEqual("both"))
{
- anArrowType = AIS_TOAV_Both;
+ anArrowType = PrsDim_TypeOfAngleArrowVisibility_Both;
}
else if (anArrowTypeStr.IsEqual("first"))
{
- anArrowType = AIS_TOAV_First;
+ anArrowType = PrsDim_TypeOfAngleArrowVisibility_First;
}
else if (anArrowTypeStr.IsEqual("second"))
{
- anArrowType = AIS_TOAV_Second;
+ anArrowType = PrsDim_TypeOfAngleArrowVisibility_Second;
}
else if (anArrowTypeStr.IsEqual("none"))
{
- anArrowType = AIS_TOAV_None;
+ anArrowType = PrsDim_TypeOfAngleArrowVisibility_None;
}
else
{
TCollection_AsciiString aDimType(theArgs[2]);
aDimType.LowerCase();
- AIS_KindOfDimension aKindOfDimension;
+ PrsDim_KindOfDimension aKindOfDimension;
if (aDimType == "-length")
{
- aKindOfDimension = AIS_KOD_LENGTH;
+ aKindOfDimension = PrsDim_KOD_LENGTH;
}
else if (aDimType == "-angle")
{
- aKindOfDimension = AIS_KOD_PLANEANGLE;
+ aKindOfDimension = PrsDim_KOD_PLANEANGLE;
}
else if (aDimType == "-radius")
{
- aKindOfDimension = AIS_KOD_RADIUS;
+ aKindOfDimension = PrsDim_KOD_RADIUS;
}
else if (aDimType == "-diameter" || aDimType == "-diam")
{
- aKindOfDimension = AIS_KOD_DIAMETER;
+ aKindOfDimension = PrsDim_KOD_DIAMETER;
}
else
{
}
// Build dimension
- Handle(AIS_Dimension) aDim;
+ Handle(PrsDim_Dimension) aDim;
switch (aKindOfDimension)
{
- case AIS_KOD_LENGTH:
+ case PrsDim_KOD_LENGTH:
{
if (aShapes.Extent() == 1)
{
TopoDS_Edge anEdge = TopoDS::Edge ((Handle(AIS_Shape)::DownCast(aShapes.First()))->Shape());
TopoDS_Vertex aFirst, aSecond;
TopExp::Vertices (anEdge, aFirst, aSecond);
- aDim = new AIS_LengthDimension (anEdge, aWorkingPlane);
+ aDim = new PrsDim_LengthDimension (anEdge, aWorkingPlane);
// Move standard plane (XOY, YOZ or ZOX) to the first point to make it working for dimension
- aWorkingPlane.SetLocation (Handle(AIS_LengthDimension)::DownCast (aDim)->FirstPoint());
+ aWorkingPlane.SetLocation (Handle(PrsDim_LengthDimension)::DownCast (aDim)->FirstPoint());
}
else if (aShapes.Extent() == 2)
{
// Face-Face case
if (aShape1.ShapeType() == TopAbs_FACE && aShape2.ShapeType() == TopAbs_FACE)
{
- aDim = new AIS_LengthDimension (TopoDS::Face (aShape1), TopoDS::Face (aShape2));
+ aDim = new PrsDim_LengthDimension (TopoDS::Face (aShape1), TopoDS::Face (aShape2));
}
else if (aShape1.ShapeType() == TopAbs_FACE && aShape2.ShapeType() == TopAbs_EDGE)
{
- aDim = new AIS_LengthDimension (TopoDS::Face (aShape1), TopoDS::Edge (aShape2));
+ aDim = new PrsDim_LengthDimension (TopoDS::Face (aShape1), TopoDS::Edge (aShape2));
}
else if (aShape1.ShapeType() == TopAbs_EDGE && aShape2.ShapeType() == TopAbs_FACE)
{
- aDim = new AIS_LengthDimension (TopoDS::Face (aShape2), TopoDS::Edge (aShape1));
+ aDim = new PrsDim_LengthDimension (TopoDS::Face (aShape2), TopoDS::Edge (aShape1));
}
else
{
aWorkingPlane.SetLocation (BRep_Tool::Pnt (TopoDS::Vertex (aShape2)));
}
- aDim = new AIS_LengthDimension (aShape1, aShape2, aWorkingPlane);
+ aDim = new PrsDim_LengthDimension (aShape1, aShape2, aWorkingPlane);
}
}
else
break;
}
- case AIS_KOD_PLANEANGLE:
+ case PrsDim_KOD_PLANEANGLE:
{
if (aShapes.Extent() == 1 && aShapes.First()->Type()==AIS_KOI_Shape)
{
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aShapes.First());
if (aShape->Shape().ShapeType() == TopAbs_FACE)
- aDim = new AIS_AngleDimension (TopoDS::Face(aShape->Shape()));
+ aDim = new PrsDim_AngleDimension (TopoDS::Face(aShape->Shape()));
}
if (aShapes.Extent() == 2)
{
if (!aShape1.IsNull() && !aShape2.IsNull()
&& aShape1->Shape().ShapeType() == TopAbs_EDGE
&& aShape2->Shape().ShapeType() == TopAbs_EDGE)
- aDim = new AIS_AngleDimension (TopoDS::Edge(aShape1->Shape()),TopoDS::Edge(aShape2->Shape()));
+ aDim = new PrsDim_AngleDimension (TopoDS::Edge(aShape1->Shape()),TopoDS::Edge(aShape2->Shape()));
else
{
std::cerr << theArgs[0] << ": wrong shapes for angle dimension.\n";
if (aPoint.IsNull())
return 1;
aP3 = aPoint->Component()->Pnt();
- aDim = new AIS_AngleDimension (aP1, aP2, aP3);
+ aDim = new PrsDim_AngleDimension (aP1, aP2, aP3);
}
else
{
break;
}
- case AIS_KOD_RADIUS: // radius of the circle
+ case PrsDim_KOD_RADIUS: // radius of the circle
{
gp_Pnt anAnchor;
bool hasAnchor = false;
gp_Circ aCircle = aShapeCirc->Circle()->Circ();
if (hasAnchor)
{
- aDim = new AIS_RadiusDimension (aCircle, anAnchor);
+ aDim = new PrsDim_RadiusDimension (aCircle, anAnchor);
}
else
{
- aDim = new AIS_RadiusDimension (aCircle);
+ aDim = new PrsDim_RadiusDimension (aCircle);
}
}
else if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aShapes.First()))
{
- Handle(AIS_RadiusDimension) aRadDim = new AIS_RadiusDimension (aShape->Shape());
+ Handle(PrsDim_RadiusDimension) aRadDim = new PrsDim_RadiusDimension (aShape->Shape());
if (hasAnchor)
{
aRadDim->SetMeasuredGeometry (aShape->Shape(), anAnchor);
}
break;
}
- case AIS_KOD_DIAMETER:
+ case PrsDim_KOD_DIAMETER:
{
if (aShapes.Extent() == 1)
{
{
Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First());
gp_Circ aCircle = aShape->Circle()->Circ();
- aDim = new AIS_DiameterDimension (aCircle);
+ aDim = new PrsDim_DiameterDimension (aCircle);
}
else
{
std::cerr << "Error: shape for radius is of wrong type.\n";
return 1;
}
- aDim = new AIS_DiameterDimension (aShape->Shape());
+ aDim = new PrsDim_DiameterDimension (aShape->Shape());
}
}
else
TCollection_AsciiString aName (theArgs[1]);
TCollection_AsciiString aType (theArgs[2]);
- AIS_KindOfRelation aKindOfRelation = AIS_KOR_NONE;
+ PrsDim_KindOfRelation aKindOfRelation = PrsDim_KOR_NONE;
if (aType == "-concentric")
{
- aKindOfRelation = AIS_KOR_CONCENTRIC;
+ aKindOfRelation = PrsDim_KOR_CONCENTRIC;
}
else if (aType == "-equaldistance")
{
- aKindOfRelation = AIS_KOR_EQUALDISTANCE;
+ aKindOfRelation = PrsDim_KOR_EQUALDISTANCE;
}
else if (aType == "-equalradius")
{
- aKindOfRelation = AIS_KOR_EQUALRADIUS;
+ aKindOfRelation = PrsDim_KOR_EQUALRADIUS;
}
else if (aType == "-fix")
{
- aKindOfRelation = AIS_KOR_FIX;
+ aKindOfRelation = PrsDim_KOR_FIX;
}
else if (aType == "-identic")
{
- aKindOfRelation = AIS_KOR_IDENTIC;
+ aKindOfRelation = PrsDim_KOR_IDENTIC;
}
else if (aType == "-offset")
{
- aKindOfRelation = AIS_KOR_OFFSET;
+ aKindOfRelation = PrsDim_KOR_OFFSET;
}
else if (aType == "-parallel")
{
- aKindOfRelation = AIS_KOR_PARALLEL;
+ aKindOfRelation = PrsDim_KOR_PARALLEL;
}
else if (aType == "-perpendicular")
{
- aKindOfRelation = AIS_KOR_PERPENDICULAR;
+ aKindOfRelation = PrsDim_KOR_PERPENDICULAR;
}
else if (aType == "-tangent")
{
- aKindOfRelation = AIS_KOR_TANGENT;
+ aKindOfRelation = PrsDim_KOR_TANGENT;
}
else if (aType == "-symmetric")
{
- aKindOfRelation = AIS_KOR_SYMMETRIC;
+ aKindOfRelation = PrsDim_KOR_SYMMETRIC;
}
TopTools_ListOfShape aShapes;
ViewerTest::GetSelectedShapes (aShapes);
// Build relation.
- Handle(AIS_Relation) aRelation;
+ Handle(PrsDim_Relation) aRelation;
switch (aKindOfRelation)
{
- case AIS_KOR_CONCENTRIC:
+ case PrsDim_KOR_CONCENTRIC:
{
if (aShapes.Extent() != 2)
{
gp_Pnt C = aCurve1.Value (0.75);
GC_MakePlane aMkPlane (aCenter1, B, C);
- aRelation = new AIS_ConcentricRelation (aShape1, aShape2, aMkPlane.Value());
+ aRelation = new PrsDim_ConcentricRelation (aShape1, aShape2, aMkPlane.Value());
break;
}
-
- case AIS_KOR_EQUALDISTANCE:
+ case PrsDim_KOR_EQUALDISTANCE:
{
if (aShapes.Extent() != 4)
{
}
GC_MakePlane aMkPlane (A, B, C);
- aRelation = new AIS_EqualDistanceRelation (aSelectedShapes[0],
- aSelectedShapes[1],
- aSelectedShapes[2],
- aSelectedShapes[3],
- aMkPlane.Value());
+ aRelation = new PrsDim_EqualDistanceRelation (aSelectedShapes[0], aSelectedShapes[1], aSelectedShapes[2], aSelectedShapes[3], aMkPlane.Value());
break;
}
-
- case AIS_KOR_EQUALRADIUS:
+ case PrsDim_KOR_EQUALRADIUS:
{
if (aShapes.Extent() != 2 && aShapes.Extent() != 1)
{
gp_Pnt C = aCurve1.Value (0.9);
GC_MakePlane aMkPlane (A, B, C);
- aRelation = new AIS_EqualRadiusRelation (anEdge1, anEdge2, aMkPlane.Value());
+ aRelation = new PrsDim_EqualRadiusRelation (anEdge1, anEdge2, aMkPlane.Value());
break;
}
-
- case AIS_KOR_FIX:
+ case PrsDim_KOR_FIX:
{
if (aShapes.Extent() != 1)
{
gp_Pnt C (B.X() + 5.0, B.Y() + 5.0, B.Z() + 5.0);
GC_MakePlane aMkPlane (A, D, C);
- aRelation = new AIS_FixRelation (anEdge, aMkPlane.Value());
+ aRelation = new PrsDim_FixRelation (anEdge, aMkPlane.Value());
break;
}
-
- case AIS_KOR_IDENTIC:
+ case PrsDim_KOR_IDENTIC:
{
if (aShapes.Extent() != 2)
{
}
GC_MakePlane aMkPlane (A ,B ,C);
- aRelation = new AIS_IdenticRelation (aShapeA, aShapeB, aMkPlane.Value());
+ aRelation = new PrsDim_IdenticRelation (aShapeA, aShapeB, aMkPlane.Value());
break;
}
-
- case AIS_KOR_OFFSET:
+ case PrsDim_KOR_OFFSET:
{
if (aShapes.Extent() != 2)
{
Standard_Real aDist = Round (sqrt (aDelta.SquareDistance (1)) * 10.0) / 10.0;
TCollection_ExtendedString aMessage (TCollection_ExtendedString ("offset=") + TCollection_ExtendedString (aDist));
-
- aRelation = new AIS_OffsetDimension (aFace1, aFace2, aDist, aMessage);
-
+ aRelation = new PrsDim_OffsetDimension (aFace1, aFace2, aDist, aMessage);
break;
}
-
- case AIS_KOR_PARALLEL:
+ case PrsDim_KOR_PARALLEL:
{
if (aShapes.Extent() != 2)
{
GC_MakePlane aMkPlane (A, B, C);
- aRelation = new AIS_ParallelRelation (anEdgeA, anEdgeB, aMkPlane.Value());
+ aRelation = new PrsDim_ParallelRelation (anEdgeA, anEdgeB, aMkPlane.Value());
}
else
{
GC_MakePlane aMkPlane (A, B, C);
- aRelation = new AIS_ParallelRelation (aFaceA, aFaceB, aMkPlane.Value());
+ aRelation = new PrsDim_ParallelRelation (aFaceA, aFaceB, aMkPlane.Value());
}
break;
}
-
- case AIS_KOR_PERPENDICULAR:
+ case PrsDim_KOR_PERPENDICULAR:
{
if (aShapes.Extent() != 2)
{
GC_MakePlane aMkPlane (A, B, C);
- aRelation = new AIS_PerpendicularRelation (anEdgeA, anEdgeB, aMkPlane.Value());
+ aRelation = new PrsDim_PerpendicularRelation (anEdgeA, anEdgeB, aMkPlane.Value());
}
else
{
GC_MakePlane aMkPlane (A, B, C);
- aRelation = new AIS_PerpendicularRelation (aFaceA, aFaceB);
+ aRelation = new PrsDim_PerpendicularRelation (aFaceA, aFaceB);
}
break;
}
-
- case AIS_KOR_TANGENT:
+ case PrsDim_KOR_TANGENT:
{
if (aShapes.Extent() != 2)
{
GC_MakePlane aMkPlane (A,B,C);
- aRelation = new AIS_TangentRelation (anEdgeA, anEdgeB, aMkPlane.Value());
+ aRelation = new PrsDim_TangentRelation (anEdgeA, anEdgeB, aMkPlane.Value());
}
else
{
GC_MakePlane aMkPlane (A,B,C);
- aRelation = new AIS_TangentRelation (aFaceA, aFaceB, aMkPlane.Value());
+ aRelation = new PrsDim_TangentRelation (aFaceA, aFaceB, aMkPlane.Value());
}
break;
}
-
- case AIS_KOR_SYMMETRIC:
+ case PrsDim_KOR_SYMMETRIC:
{
if (aShapes.Extent() != 3)
{
GC_MakePlane aMkPlane (A, B, C);
- aRelation = new AIS_SymmetricRelation (anEdgeA, anEdgeB, anEdgeC, aMkPlane.Value());
+ aRelation = new PrsDim_SymmetricRelation (anEdgeA, anEdgeB, anEdgeC, aMkPlane.Value());
}
else
{
gp_Pnt A = BRep_Tool::Pnt (Va);
GC_MakePlane aMkPlane(A, B, C);
- aRelation = new AIS_SymmetricRelation (anEdgeA, aVertexB, aVertexC, aMkPlane.Value());
+ aRelation = new PrsDim_SymmetricRelation (anEdgeA, aVertexB, aVertexC, aMkPlane.Value());
}
break;
}
-
- case AIS_KOR_NONE:
+ case PrsDim_KOR_NONE:
{
std::cerr << "Error: Unknown type of relation!\n";
return 1;
theDi << theArgVec[0] << "error: no object with this name.\n";
return 1;
}
- Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast (anObject);
+ Handle(PrsDim_Dimension) aDim = Handle(PrsDim_Dimension)::DownCast (anObject);
if (aDim.IsNull())
{
theDi << theArgVec[0] << "error: no dimension with this name.\n";
return 1;
}
- Handle(AIS_LengthDimension) aLengthDim = Handle(AIS_LengthDimension)::DownCast (anObject);
+ Handle(PrsDim_LengthDimension) aLengthDim = Handle(PrsDim_LengthDimension)::DownCast (anObject);
if (aLengthDim.IsNull())
{
std::cout << theArgVec[0] << "error: no length dimension with this name.\n";
return 1;
}
- Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast (anObject);
+ Handle(PrsDim_Dimension) aDim = Handle(PrsDim_Dimension)::DownCast (anObject);
if (aDim.IsNull())
{
theDi << theArgVec[0] << "error: no dimension with this name.\n";
// Set text position, update relation or dimension.
if (aPickedObj->Type() == AIS_KOI_Relation)
{
- Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (aPickedObj);
+ Handle(PrsDim_Relation) aRelation = Handle(PrsDim_Relation)::DownCast (aPickedObj);
aPoint = Get3DPointAtMousePosition();
aRelation->SetPosition (aPoint);
TheAISContext()->Redisplay (aRelation, Standard_True);
}
else
{
- Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast (aPickedObj);
+ Handle(PrsDim_Dimension) aDim = Handle(PrsDim_Dimension)::DownCast (aPickedObj);
gp_Pnt aFirstPoint, aSecondPoint;
- if (aDim->KindOfDimension() == AIS_KOD_PLANEANGLE)
+ if (aDim->KindOfDimension() == PrsDim_KOD_PLANEANGLE)
{
- Handle(AIS_AngleDimension) anAngleDim = Handle(AIS_AngleDimension)::DownCast (aDim);
+ Handle(PrsDim_AngleDimension) anAngleDim = Handle(PrsDim_AngleDimension)::DownCast (aDim);
aFirstPoint = anAngleDim->FirstPoint();
aSecondPoint = anAngleDim->SecondPoint();
}
- else if (aDim->KindOfDimension() == AIS_KOD_LENGTH)
+ else if (aDim->KindOfDimension() == PrsDim_KOD_LENGTH)
{
- Handle(AIS_LengthDimension) aLengthDim = Handle(AIS_LengthDimension)::DownCast (aDim);
+ Handle(PrsDim_LengthDimension) aLengthDim = Handle(PrsDim_LengthDimension)::DownCast (aDim);
aFirstPoint = aLengthDim->FirstPoint();
aSecondPoint = aLengthDim->SecondPoint();
}
- else if (aDim->KindOfDimension() == AIS_KOD_RADIUS)
+ else if (aDim->KindOfDimension() == PrsDim_KOD_RADIUS)
{
- Handle(AIS_RadiusDimension) aRadiusDim = Handle(AIS_RadiusDimension)::DownCast (aDim);
+ Handle(PrsDim_RadiusDimension) aRadiusDim = Handle(PrsDim_RadiusDimension)::DownCast (aDim);
aFirstPoint = aRadiusDim->AnchorPoint();
aSecondPoint = aRadiusDim->Circle().Location();
}
- else if (aDim->KindOfDimension() == AIS_KOD_DIAMETER)
+ else if (aDim->KindOfDimension() == PrsDim_KOD_DIAMETER)
{
- Handle(AIS_DiameterDimension) aDiameterDim = Handle(AIS_DiameterDimension)::DownCast (aDim);
+ Handle(PrsDim_DiameterDimension) aDiameterDim = Handle(PrsDim_DiameterDimension)::DownCast (aDim);
aFirstPoint = aDiameterDim->AnchorPoint();
aSecondPoint = aDiameterDim->Circle().Location();
}
// Set text position, update relation or dimension.
if (aPickedObj->Type() == AIS_KOI_Relation)
{
- Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (aPickedObj);
+ Handle(PrsDim_Relation) aRelation = Handle(PrsDim_Relation)::DownCast (aPickedObj);
aRelation->SetPosition (aPoint);
TheAISContext()->Redisplay (aRelation, Standard_True);
}
else
{
- Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast (aPickedObj);
+ Handle(PrsDim_Dimension) aDim = Handle(PrsDim_Dimension)::DownCast (aPickedObj);
aDim->SetTextPosition (aPoint);
TheAISContext()->Redisplay (aDim, Standard_True);
}