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

0026056: AIS_LengthDimension can not build dimension for face-edge or edge-face

- Correct AIS_LengthDimension::InitEdgeFaceLength() method to support face-edge and edge-face cases
- Correct test command to support face-edge and edge-face input geomerty without custom plane
This commit is contained in:
aba 2015-11-11 13:41:59 +03:00 committed by bugmaster
parent a144d7770f
commit 1c078d3b39
4 changed files with 118 additions and 113 deletions

View File

@ -19,6 +19,7 @@
#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>
@ -26,8 +27,8 @@
#include <ElSLib.hxx>
#include <gce_MakeDir.hxx>
#include <gce_MakePln.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomAPI_ExtremaCurveCurve.hxx>
#include <GeomAPI_ExtremaCurveSurface.hxx>
#include <GeomAPI_ExtremaSurfaceSurface.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
@ -433,28 +434,32 @@ Standard_Boolean AIS_LengthDimension::InitEdgeFaceLength (const TopoDS_Edge& the
const TopoDS_Face& theFace,
gp_Dir& theEdgeDir)
{
Handle(Geom_Curve) aCurve;
gp_Pnt aFirstPoint, aSecondPoint;
Standard_Boolean isInfinite = Standard_False;
if (!AIS::ComputeGeometry (theEdge, aCurve, aFirstPoint, aSecondPoint, isInfinite))
// Compute edge direction
BRepAdaptor_Curve aCurveAdaptor (theEdge);
Handle(Geom_Curve) aCurve = Handle(Geom_Curve)::DownCast (aCurveAdaptor.Curve().Curve()->Transformed (aCurveAdaptor.Trsf()));
if (aCurve.IsNull())
{
return Standard_False;
}
theEdgeDir = gce_MakeDir (aFirstPoint, aSecondPoint);
gp_Pln aPlane;
Handle(Geom_Surface) aSurface;
AIS_KindOfSurface aSurfType;
Standard_Real anOffset;
if (!AIS::GetPlaneFromFace (theFace, aPlane, aSurface, aSurfType, anOffset))
Standard_Real aFirst = aCurveAdaptor.FirstParameter();
Standard_Real aLast = aCurveAdaptor.LastParameter();
gp_Pnt aFirstPoint = !Precision::IsInfinite (aFirst) ? aCurve->Value (aFirst) : gp::Origin();
gp_Pnt aSecondPoint = !Precision::IsInfinite (aLast) ? aCurve->Value (aLast) : gp::Origin();
gce_MakeDir aMakeDir (aFirstPoint, aSecondPoint);
if (!aMakeDir.IsDone())
{
return Standard_False;
}
theEdgeDir = aMakeDir.Value();
GeomAPI_ExtremaCurveSurface aDistAdaptor (aCurve, aSurface);
aDistAdaptor.NearestPoints (myFirstPoint, mySecondPoint);
// Find attachment points
BRepExtrema_DistShapeShape aDistAdaptor (theEdge, theFace, Extrema_ExtFlag_MIN);
if (!aDistAdaptor.IsDone())
{
return Standard_False;
}
myFirstPoint = aDistAdaptor.PointOnShape1 (1);
mySecondPoint = aDistAdaptor.PointOnShape2 (1);
return IsValidPoints (myFirstPoint, mySecondPoint);
}
@ -578,11 +583,11 @@ Standard_Boolean AIS_LengthDimension::InitTwoShapesPoints (const TopoDS_Shape& t
return isSuccess && IsValidPoints (myFirstPoint, mySecondPoint);
}
else if (theFirstShape.ShapeType() == TopAbs_EDGE)
else if (theSecondShape.ShapeType() == TopAbs_EDGE)
{
myGeometryType = GeometryType_EdgeFace;
isSuccess = InitEdgeFaceLength (TopoDS::Edge (theFirstShape),
TopoDS::Face (theSecondShape),
isSuccess = InitEdgeFaceLength (TopoDS::Edge (theSecondShape),
TopoDS::Face (theFirstShape),
aDirAttach);
if (isSuccess)
@ -627,6 +632,21 @@ Standard_Boolean AIS_LengthDimension::InitTwoShapesPoints (const TopoDS_Shape& t
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;
}
}

View File

@ -81,8 +81,6 @@ public:
Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge);
public:
//! Construct length dimension between two faces.
//! @param theFirstFace [in] the first face (first shape).
//! @param theSecondFace [in] the second face (second shape).

View File

@ -18,20 +18,36 @@
#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_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 <BRepAdaptor_Curve.hxx>
#include <AIS_SymmetricRelation.hxx>
#include <AIS_TangentRelation.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepExtrema_ExtCC.hxx>
#include <BRepExtrema_ExtPC.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRepExtrema_ExtPF.hxx>
#include <BRepExtrema_ExtFF.hxx>
#include <BRepTools.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw.hxx>
@ -60,6 +76,7 @@
#include <TopAbs.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Solid.hxx>
@ -537,11 +554,6 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
{
case AIS_KOD_LENGTH:
{
if (!isPlaneCustom)
{
std::cerr << theArgs[0] << ": can not build dimension without working plane.\n";
return 1;
}
if (aShapes.Extent() == 1)
{
if (aShapes.First()->Type() == AIS_KOI_Shape
@ -550,6 +562,12 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
std::cerr << theArgs[0] << ": wrong shape type.\n";
return 1;
}
if (!isPlaneCustom)
{
std::cerr << theArgs[0] << ": can not build dimension without working plane.\n";
return 1;
}
// Adjust working plane
TopoDS_Edge anEdge = TopoDS::Edge ((Handle(AIS_Shape)::DownCast(aShapes.First()))->Shape());
TopoDS_Vertex aFirst, aSecond;
@ -566,8 +584,7 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
// Getting shapes
if (aShapes.First()->DynamicType() == STANDARD_TYPE (AIS_Point))
{
Handle(AIS_Point) aPoint1 = Handle(AIS_Point)::DownCast (aShapes.First ());
aShape1 = aPoint1->Vertex();
aShape1 = Handle(AIS_Point)::DownCast (aShapes.First ())->Vertex();
}
else if (aShapes.First()->Type() == AIS_KOI_Shape)
{
@ -576,8 +593,7 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
if (aShapes.Last()->DynamicType() == STANDARD_TYPE (AIS_Point))
{
Handle(AIS_Point) aPoint2 = Handle(AIS_Point)::DownCast (aShapes.Last ());
aShape2 = aPoint2->Vertex();
aShape2 = Handle(AIS_Point)::DownCast (aShapes.Last ())->Vertex();
}
else if (aShapes.Last()->Type() == AIS_KOI_Shape)
{
@ -590,7 +606,27 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
return 1;
}
// Adjust working plane
// Face-Face case
if (aShape1.ShapeType() == TopAbs_FACE && aShape2.ShapeType() == TopAbs_FACE)
{
aDim = new AIS_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));
}
else if (aShape1.ShapeType() == TopAbs_EDGE && aShape2.ShapeType() == TopAbs_FACE)
{
aDim = new AIS_LengthDimension (TopoDS::Face (aShape2), TopoDS::Edge (aShape1));
}
else
{
if (!isPlaneCustom)
{
std::cerr << theArgs[0] << ": can not build dimension without working plane.\n";
return 1;
}
// Vertex-Vertex case
if (aShape1.ShapeType() == TopAbs_VERTEX)
{
aWorkingPlane.SetLocation (BRep_Tool::Pnt (TopoDS::Vertex (aShape1)));
@ -602,6 +638,7 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
aDim = new AIS_LengthDimension (aShape1, aShape2, aWorkingPlane);
}
}
else
{
std::cerr << theArgs[0] << ": wrong number of shapes to build dimension.\n";
@ -896,14 +933,6 @@ static int VDiameterDimBuilder(Draw_Interpretor& di, Standard_Integer argc, cons
//purpose : Display the concentric relation between two surfaces.
//Draw arg : vconcentric Name
//==============================================================================
#include <AIS_ConcentricRelation.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pln.hxx>
#include <GC_MakePlane.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopExp_Explorer.hxx>
static int VConcentricBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -990,11 +1019,6 @@ static int VConcentricBuilder(Draw_Interpretor& di, Standard_Integer argc, const
//purpose :
//Draw arg : vdiameterdim Name DiameterValue
//==============================================================================
#include <AIS_EqualDistanceRelation.hxx>
#include <BRepExtrema_ExtCC.hxx>
#include <GC_MakePlane.hxx>
static int VEqualDistRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -1152,11 +1176,6 @@ static int VEqualDistRelation(Draw_Interpretor& di, Standard_Integer argc, const
//purpose :
//Draw arg : vdiameterdim Name DiameterValue
//==============================================================================
#include <AIS_EqualRadiusRelation.hxx>
#include <GC_MakePlane.hxx>
#include <BRepAdaptor_Curve.hxx>
static int VEqualRadiusRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -1230,10 +1249,6 @@ static int VEqualRadiusRelation(Draw_Interpretor& di, Standard_Integer argc, con
//purpose :
//Draw arg : vdiameterdim Name DiameterValue
//==============================================================================
#include <AIS_FixRelation.hxx>
#include <GC_MakePlane.hxx>
#include <BRepAdaptor_Curve.hxx>
static int VFixRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -1295,11 +1310,6 @@ static int VFixRelation(Draw_Interpretor& di, Standard_Integer argc, const char*
//purpose :
//Draw arg : vdiameterdim Name DiameterValue
//==============================================================================
#include <AIS_IdenticRelation.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopExp_Explorer.hxx>
static int VIdenticRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -1436,18 +1446,6 @@ static int VIdenticRelation(Draw_Interpretor& di, Standard_Integer argc, const c
//purpose : Display the diameter dimension of a face or an edge.
//Draw arg : vdiameterdim Name DiameterValue
//==============================================================================
#include <AIS_LengthDimension.hxx>
#include <BRepExtrema_ExtCC.hxx>
#include <BRepExtrema_ExtPC.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRepExtrema_ExtPF.hxx>
#include <BRepExtrema_ExtFF.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <gce_MakePln.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -1738,12 +1736,6 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c
//purpose : Display the radius dimension of a face or an edge.
//Draw arg : vradiusdim Name
//==============================================================================
#include <AIS_RadiusDimension.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <gp_Circ.hxx>
static int VRadiusDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -1831,11 +1823,6 @@ static int VRadiusDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const
//purpose : Display the offset dimension
//Draw arg : voffsetdim Name
//==============================================================================
#include <AIS_OffsetDimension.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BRepExtrema_ExtFF.hxx>
static int VOffsetDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -1924,15 +1911,6 @@ static int VOffsetDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const
//purpose : Display the parallel relation
//Draw arg : vparallel Name
//==============================================================================
#include <AIS_ParallelRelation.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BRepExtrema_ExtFF.hxx>
#include <BRepExtrema_ExtCC.hxx>
#include <GC_MakePlane.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopExp_Explorer.hxx>
static int VParallelBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -2081,14 +2059,6 @@ static int VParallelBuilder(Draw_Interpretor& di, Standard_Integer argc, const c
//purpose : Display the Perpendicular Relation
//Draw arg : vperpendicular Name
//==============================================================================
#include <AIS_PerpendicularRelation.hxx>
#include <TCollection_ExtendedString.hxx>
#include <GC_MakePlane.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopExp_Explorer.hxx>
static int VPerpendicularBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -2231,9 +2201,6 @@ static int VPerpendicularBuilder(Draw_Interpretor& di, Standard_Integer argc, co
//purpose : Display the tangent Relation
//Draw arg : vtangent Name
//==============================================================================
#include <AIS_TangentRelation.hxx>
static int VTangentBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations
@ -2372,11 +2339,6 @@ static int VTangentBuilder(Draw_Interpretor& di, Standard_Integer argc, const ch
//purpose : Display the Symetrical Relation
//Draw arg : vsymetric Name
//==============================================================================
#include <AIS_SymmetricRelation.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_Dimension.hxx>
static int VSymmetricBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// Declarations

25
tests/bugs/vis/bug26056 Normal file
View File

@ -0,0 +1,25 @@
puts "============"
puts "CR26056"
puts "AIS_LengthDimension can not build dimension for face-edge or edge-face"
puts "============"
puts ""
puts "Tests case of edge-face and face-edge input geometry for dimension"
pload MODELING VISUALIZATION
line aLine 0 -100 0 1 0 0
mkedge anEdge aLine -100 100
plane aPlane 0 0 50 0 0 1
mkface aFace aPlane -100 100 -100 100
line aLine2 0 0 100 1 1 0
mkedge anEdge2 aLine2 -150 150
vinit View1
vclear
vaxo
vdisplay anEdge anEdge2 aFace
vdimension aDim1 -length -shapes anEdge aFace -text 15 3d sh
vdimension aDim2 -length -shapes aFace anEdge2 -text 15 3d sh
vfit
set only_screen 1