-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 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() );
- break;
- }
+ Handle(Geom_Surface) aBasisSurface = Handle(Geom_Surface)::DownCast(
+ aSurf.Surface().Surface()->Transformed( aSurf.Trsf() ) );
+ Handle(Geom_Curve) aCurve = aBasisSurface->VIso( 0.0 );
- // get arguments of closed torus
- if ( aSurf.GetType() == GeomAbs_Torus )
- {
- if ( !aSurf.IsUClosed() || !aSurf.IsVClosed() )
+ if ( aCurve->IsKind( STANDARD_TYPE( Geom_Circle ) ) )
{
- return NULL;
+ 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();
- gp_Torus aTorus = aSurf.Torus();
- gp_Ax2 anAx2 = aTorus.Position().Ax2();
- aCircle = new Geom_Circle( anAx2, aTorus.MinorRadius() );
+ aCircle = Handle(Geom_Circle)::DownCast( aTrimmedCurve );
+ }
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();
break;
}
- // get arguments of closed/opened cylinder
- if ( aSurf.GetType() == GeomAbs_Cylinder )
+ // get arguments of closed torus or cylinder
+ if ( aSurf.GetType() == GeomAbs_Torus || aSurf.GetType() == GeomAbs_Cylinder )
{
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 ) ) )
TopTools_ListIteratorOfListOfShape aFaceIt( aFaces );
for ( ; aFaceIt.More(); aFaceIt.Next() )
{
- Handle(Geom_Surface) aSurface = BRep_Tool::Surface( TopoDS::Face( aFaceIt.Value() ) );
+ TopoDS_Face aFace = TopoDS::Face( aFaceIt.Value() );
+
+ Handle(Geom_Surface) aSurface = BRep_Tool::Surface( TopoDS::Face( aFace ) );
gp_Pnt aCircCenter = aCircle->Circ().Location();
Standard_Real aCircU = 0.0, aCircV = 0.0;
continue;
}
- aFaceN = gp_Vec( aNorm );
+ aFaceN = gp_Vec( aFace.Orientation() == TopAbs_REVERSED ? -aNorm : aNorm );
}
}
break;
Standard_Real aCircR = aCircle->Circ().Radius();
// construct closed circle as base for the diameter dimension
- gp_Circ aRuledCirc = gce_MakeCirc( gp_Ax2( aCircP, aCircN, aCircX ), aCircR );
+ Standard_Boolean isReversed = ( ( aPln.Axis().Direction() ^ aCircX ) * aCircN ) < 0.0;
+
+ gp_Circ aRuledCirc = gce_MakeCirc( gp_Ax2( aCircP, isReversed ? -aCircN : aCircN, aCircX ), aCircR );
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);
return NULL;
}
+ aDimension->SetFlyout( Settings.DefaultFlyout );
+
return aDimension;
}
// 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] );