[TD]fix horizontal/vertical test for dimensions
This commit is contained in:
committed by
Chris Hennes
parent
55b3ab0489
commit
3f84a7695a
@@ -386,14 +386,7 @@ DimensionGeometry TechDraw::isValidSingleEdge(const ReferenceEntry& ref)
|
||||
if (gen1->points.size() < 2) {
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
Base::Vector3d line = gen1->points.at(1) - gen1->points.at(0);
|
||||
if (fabs(line.y) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isVertical;
|
||||
}
|
||||
if (fabs(line.x) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isHorizontal;
|
||||
}
|
||||
return DimensionGeometry::isDiagonal;
|
||||
return lineOrientation(gen1->points.at(0), gen1->points.at(1));
|
||||
}
|
||||
|
||||
if (geom->getGeomType() == GeomType::CIRCLE || geom->getGeomType() == GeomType::ARCOFCIRCLE) {
|
||||
@@ -437,21 +430,7 @@ DimensionGeometry TechDraw::isValidSingleEdge3d(DrawViewPart* dvp, const Referen
|
||||
point0 = dvp->projectPoint(point0);
|
||||
auto point1 = Base::convertTo<Base::Vector3d>(BRep_Tool::Pnt(TopExp::LastVertex(occEdge)));
|
||||
point1 = dvp->projectPoint(point1);
|
||||
Base::Vector3d line = point1 - point0;
|
||||
if (fabs(line.y) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isVertical;
|
||||
}
|
||||
|
||||
if (fabs(line.x) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isHorizontal;
|
||||
}
|
||||
|
||||
// we don't support Z direction dimensions
|
||||
// else if (fabs(line.z) < std::numeric_limits<float>::epsilon()) {
|
||||
// return TechDraw::isZLimited;
|
||||
// }
|
||||
|
||||
return DimensionGeometry::isDiagonal;
|
||||
return lineOrientation(point0, point1);
|
||||
}
|
||||
|
||||
if (adapt.GetType() == GeomAbs_Circle) {
|
||||
@@ -461,7 +440,8 @@ DimensionGeometry TechDraw::isValidSingleEdge3d(DrawViewPart* dvp, const Referen
|
||||
if (adapt.GetType() == GeomAbs_Ellipse) {
|
||||
return DimensionGeometry::isEllipse;
|
||||
}
|
||||
else if (adapt.GetType() == GeomAbs_BSplineCurve) {
|
||||
|
||||
if (adapt.GetType() == GeomAbs_BSplineCurve) {
|
||||
if (GeometryUtils::isCircle(occEdge)) {
|
||||
return DimensionGeometry::isBSplineCircle;
|
||||
}
|
||||
@@ -649,16 +629,7 @@ DimensionGeometry TechDraw::isValidVertexes(const ReferenceVector& refs)
|
||||
//2 vertices can only make a distance dimension
|
||||
TechDraw::VertexPtr v0 = dvp->getVertex(refs.at(0).getSubName());
|
||||
TechDraw::VertexPtr v1 = dvp->getVertex(refs.at(1).getSubName());
|
||||
Base::Vector3d line = v1->point() - v0->point();
|
||||
if (fabs(line.y) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isHorizontal;
|
||||
}
|
||||
|
||||
if (fabs(line.x) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isVertical;
|
||||
}
|
||||
return DimensionGeometry::isDiagonal;
|
||||
|
||||
return lineOrientation(v0->point(), v1->point());
|
||||
} else if (refs.size() == 3) {
|
||||
//three vertices make an angle dimension
|
||||
return DimensionGeometry::isAngle3Pt;
|
||||
@@ -689,18 +660,10 @@ DimensionGeometry TechDraw::isValidVertexes3d(DrawViewPart* dvp, const Reference
|
||||
point0 = dvp->projectPoint(point0);
|
||||
auto point1 = Base::convertTo<Base::Vector3d>(BRep_Tool::Pnt(TopoDS::Vertex(geometry1)));
|
||||
point1 = dvp->projectPoint(point1);
|
||||
Base::Vector3d line = point1 - point0;
|
||||
if (fabs(line.y) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isVertical;
|
||||
}
|
||||
if (fabs(line.x) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isHorizontal;
|
||||
// } else if(fabs(line.z) < std::numeric_limits<float>::epsilon()) {
|
||||
// return isZLimited;
|
||||
}
|
||||
return DimensionGeometry::isDiagonal;
|
||||
return lineOrientation(point0, point1);
|
||||
}
|
||||
|
||||
} else if (refs.size() == 3) {
|
||||
if (refs.size() == 3) {
|
||||
//three vertices make an angle dimension
|
||||
//we could check here that all the geometries are Vertex
|
||||
return DimensionGeometry::isAngle3Pt;
|
||||
@@ -802,3 +765,24 @@ bool TechDraw::refsMatchToken(const ReferenceVector& refs, const std::string& m
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
DimensionGeometry TechDraw::lineOrientation(const Base::Vector3d& point0,
|
||||
const Base::Vector3d& point1)
|
||||
{
|
||||
Base::Vector3d line = point1 - point0;
|
||||
if (fabs(line.y) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isHorizontal;
|
||||
}
|
||||
|
||||
if (fabs(line.x) < std::numeric_limits<float>::epsilon()) {
|
||||
return DimensionGeometry::isVertical;
|
||||
}
|
||||
|
||||
// we don't support Z direction dimensions
|
||||
// else if (fabs(line.z) < std::numeric_limits<float>::epsilon()) {
|
||||
// return TechDraw::isZLimited;
|
||||
// }
|
||||
|
||||
return DimensionGeometry::isDiagonal;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,10 @@ long int mapGeometryTypeToDimType(long int dimType, DimensionGeometry geometry2d
|
||||
|
||||
bool refsMatchToken(const ReferenceVector& refs, const std::string& matchToken);
|
||||
|
||||
DimensionGeometry lineOrientation(const Base::Vector3d& point0,
|
||||
const Base::Vector3d& point1);
|
||||
|
||||
|
||||
}
|
||||
#endif //TECHDRAW_DIMENSIONVALIDATORS_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user