-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <TColgp_SequenceOfDir.hxx>
#include <V3d_View.hxx>
-
// plane associated with custom data
struct PlaneAndSegment
{
return NULL;
}
+ if( aFirstSh == aSecondSh )
+ return NULL;
+
TopoDS_Edge aFirstEdge = TopoDS::Edge( aFirstSh );
TopoDS_Edge aSecondEdge = TopoDS::Edge( aSecondSh );
BRepAdaptor_Surface aSurf( aMeasuredFace );
+ Standard_Real aUmin = aSurf.FirstUParameter();
+ Standard_Real aUmax = aSurf.LastUParameter();
Standard_Real aVmin = aSurf.FirstVParameter();
Standard_Real aVmax = aSurf.LastVParameter();
- // get arguments of closed sphere
+ // get arguments of sphere (the sphere should not be cutted at v-center)
if ( aSurf.GetType() == GeomAbs_Sphere )
{
- if ( !aSurf.IsUClosed() || !aSurf.IsVClosed() )
+ if ( aVmax <= Precision::PConfusion() || aVmin >= Precision::PConfusion() )
{
return NULL;
}
- // take circle in XOY plane from sphere
- gp_Sphere aSphere = aSurf.Sphere();
- gp_Ax2 anAx2 = gp_Ax2( aSphere.Location(), gp::DZ() );
- aCircle = new Geom_Circle( anAx2, aSphere.Radius() );
+ Handle(Geom_Surface) aBasisSurface = Handle(Geom_Surface)::DownCast(
+ aSurf.Surface().Surface()->Transformed( aSurf.Trsf() ) );
+
+ Handle(Geom_Curve) aCurve = aBasisSurface->VIso( 0.0 );
+
+ if ( aCurve->IsKind( STANDARD_TYPE( Geom_Circle ) ) )
+ {
+ aPmin = aUmin;
+ aPmax = aUmax;
+ aCircle = Handle(Geom_Circle)::DownCast( aCurve );
+ }
+ else if ( aCurve->IsKind( STANDARD_TYPE( Geom_TrimmedCurve ) ) )
+ {
+ Handle(Geom_TrimmedCurve) aTrimmedCurve = Handle(Geom_TrimmedCurve)::DownCast( aCurve );
+ aPmin = aTrimmedCurve->FirstParameter();
+ aPmax = aTrimmedCurve->LastParameter();
+
+ aCircle = Handle(Geom_Circle)::DownCast( aTrimmedCurve ); // todo: useless downcast: aCircle always NULL
+ }
break;
}
- // get arguments of closed cone
+ // get arguments of cone
if ( aSurf.GetType() == GeomAbs_Cone )
{
- if ( !aSurf.IsUClosed() || !aSurf.IsVClosed() )
- {
- return NULL;
- }
+ aPmin = aUmin;
+ aPmax = aUmax;
gp_Cone aCone = aSurf.Cone();
gp_Ax2 anAx2 = aCone.Position().Ax2();
// get arguments of closed torus or cylinder
if ( aSurf.GetType() == GeomAbs_Torus || aSurf.GetType() == GeomAbs_Cylinder )
{
- if ( !aSurf.IsUClosed() || !aSurf.IsVClosed() )
- {
- return NULL;
- }
-
Handle(Geom_Surface) aBasisSurface = Handle(Geom_Surface)::DownCast(
aSurf.Surface().Surface()->Transformed( aSurf.Trsf() ) );
if ( aCurve->IsKind( STANDARD_TYPE( Geom_Circle ) ) )
{
- aPmin = aSurf.FirstUParameter();
- aPmax = aSurf.LastUParameter();
+ aPmin = aUmin;
+ aPmax = aUmax;
aCircle = Handle(Geom_Circle)::DownCast( aCurve );
}
else if ( aCurve->IsKind( STANDARD_TYPE( Geom_TrimmedCurve ) ) )
aPmin = aTrimmedCurve->FirstParameter();
aPmax = aTrimmedCurve->LastParameter();
- aCircle = Handle(Geom_Circle)::DownCast( aTrimmedCurve );
+ aCircle = Handle(Geom_Circle)::DownCast( aTrimmedCurve ); // todo: useless downcast: aCircle always NULL
}
break;
// do not break, go to edge checking
aMeasuredShape = anExpEdge;
}
+ // fall through!
case TopAbs_EDGE:
{
}
}
break;
+ default:
+ break;
}
if ( aCircle.IsNull() )
Handle(AIS_DiameterDimension) aDimension = new AIS_DiameterDimension( aRuledCirc, aPln );
// if flyout is extended in tangent direction to circle, the default flyout value is used
- // if flyout is extended in plane of circle, the zero flyout value is choosen initially
+ // if flyout is extended in plane of circle, the zero flyout value is chosen initially
Standard_Real aFlyout = aCircN.IsParallel( aPln.Axis().Direction(), Precision::Angular() ) ? 0.0 : Settings.DefaultFlyout;
aDimension->SetFlyout(aFlyout);
// flyout plane to best match the current view projection (if any)
// The points are aligned to XOY, YOZ, ZOX planes.
// The flyout takes into account bounding box of main shape of face normal
-// vector. The flyouts tangetial to the circle plane are directed in
+// vector. The flyouts tangential to the circle plane are directed in
// accordance with the face normal (if not-null), otherwise the flyouts
// are turned to direct to the closest border of bounding box.
//=================================================================================
{
const gp_Pln& aPlane = aPlaneIt.Value();
- // transform bounding box to orthogonal coordiantes relative to
+ // transform bounding box to orthogonal coordinates relative to
// dimension points P1, P2 (x-axis) and plane direction (z-axis),
// where y coordinates will correspond to flyout direction against
// the dimension point line
TPlane MeasureGUI_DimensionCreateTool::SelectPlaneForProjection( const NCollection_Sequence<TPlane>& thePlanes,
const Handle(V3d_View)& theView ) const
{
- Quantity_Parameter U[3];
- Quantity_Parameter N[3];
+ Standard_Real U[3];
+ Standard_Real N[3];
theView->Up( U[0], U[1], U[2] );
theView->Proj( N[0], N[1], N[2] );