#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 <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>
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);
}
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)
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;
}
}
#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>
#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>
{
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
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;
// 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)
{
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)
{
return 1;
}
- // Adjust working plane
- if (aShape1.ShapeType() == TopAbs_VERTEX)
+ // 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)
{
- aWorkingPlane.SetLocation (BRep_Tool::Pnt (TopoDS::Vertex (aShape1)));
+ aDim = new AIS_LengthDimension (TopoDS::Face (aShape1), TopoDS::Edge (aShape2));
}
- else if (aShape2.ShapeType() == TopAbs_VERTEX)
+ else if (aShape1.ShapeType() == TopAbs_EDGE && aShape2.ShapeType() == TopAbs_FACE)
{
- aWorkingPlane.SetLocation (BRep_Tool::Pnt (TopoDS::Vertex (aShape2)));
+ 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)));
+ }
+ else if (aShape2.ShapeType() == TopAbs_VERTEX)
+ {
+ aWorkingPlane.SetLocation (BRep_Tool::Pnt (TopoDS::Vertex (aShape2)));
+ }
- aDim = new AIS_LengthDimension (aShape1, aShape2, aWorkingPlane);
+ aDim = new AIS_LengthDimension (aShape1, aShape2, aWorkingPlane);
+ }
}
else
{
//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
//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
//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
//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
//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
//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
//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
//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
//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
//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
//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
//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