[TD]fix wrong calculation of 3d two edge angle

This commit is contained in:
wandererfan
2023-01-07 07:17:15 -05:00
committed by WandererFan
parent 63be8da664
commit 664b2560ad
6 changed files with 987 additions and 849 deletions

View File

@@ -30,8 +30,8 @@
#include <Base/Console.h>
#include "DrawViewPart.h"
#include "DrawUtil.h"
#include "DrawViewPart.h"
#include "DimensionGeometry.h"
@@ -44,12 +44,14 @@ pointPair::pointPair(const pointPair& pp)
second(pp.second());
}
//move the points by offset
void pointPair::move(Base::Vector3d offset)
{
m_first = m_first - offset;
m_second = m_second - offset;
}
// project the points onto the dvp's paper plane. Points are still in R3 coords.
void pointPair::project(DrawViewPart* dvp)
{
Base::Vector3d normal = DrawUtil::toVector3d(dvp->getProjectionCS().Direction());
@@ -58,11 +60,12 @@ void pointPair::project(DrawViewPart* dvp)
m_second = m_second.ProjectToPlane(stdOrigin, normal) * dvp->getScale();
}
// map the points onto the dvp's XY coordinate system
void pointPair::mapToPage(DrawViewPart* dvp)
{
gp_Trsf xOXYZ;
gp_Ax3 OXYZ;
xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getProjectionCS()));
xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getRotatedCS()));
gp_Vec gvFirst = DU::togp_Vec(m_first).Transformed(xOXYZ);
m_first = DU::toVector3d(gvFirst);
@@ -80,8 +83,7 @@ void pointPair::dump(std::string text) const
{
Base::Console().Message("pointPair - %s\n", text.c_str());
Base::Console().Message("pointPair - first: %s second: %s\n",
DU::formatVector(first()).c_str(),
DU::formatVector(second()).c_str());
DU::formatVector(first()).c_str(), DU::formatVector(second()).c_str());
}
anglePoints::anglePoints()
@@ -91,26 +93,23 @@ anglePoints::anglePoints()
m_vertex = Base::Vector3d(0.0, 0.0, 0.0);
}
anglePoints::anglePoints(const anglePoints& ap)
: m_ends(ap.ends()),
m_vertex(ap.vertex())
{
anglePoints::anglePoints(const anglePoints& ap) : m_ends(ap.ends()), m_vertex(ap.vertex()) {}
}
anglePoints& anglePoints::operator= (const anglePoints& ap)
anglePoints& anglePoints::operator=(const anglePoints& ap)
{
m_ends = ap.ends();
m_vertex = ap.vertex();
return *this;
}
// move the points by offset
void anglePoints::move(Base::Vector3d offset)
{
m_ends.move(offset);
m_vertex = m_vertex - offset;
}
// project the points onto the dvp's paper plane. Points are still in R3 coords.
void anglePoints::project(DrawViewPart* dvp)
{
Base::Vector3d normal = DrawUtil::toVector3d(dvp->getProjectionCS().Direction());
@@ -119,17 +118,19 @@ void anglePoints::project(DrawViewPart* dvp)
m_vertex = m_vertex.ProjectToPlane(stdOrigin, normal) * dvp->getScale();
}
// map the points onto the dvp's XY coordinate system
void anglePoints::mapToPage(DrawViewPart* dvp)
{
m_ends.mapToPage(dvp);
gp_Trsf xOXYZ;
gp_Ax3 OXYZ;
xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getProjectionCS()));
xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getRotatedCS()));
gp_Vec gvVertex = DU::togp_Vec(m_vertex).Transformed(xOXYZ);
m_vertex = DU::toVector3d(gvVertex);
}
// map the points onto the coordinate system used for drawing where -Y direction is "up"
void anglePoints::invertY()
{
m_ends.invertY();
@@ -140,38 +141,29 @@ void anglePoints::dump(std::string text) const
{
Base::Console().Message("anglePoints - %s\n", text.c_str());
Base::Console().Message("anglePoints - ends - first: %s second: %s\n",
DU::formatVector(first()).c_str(),
DU::formatVector(second()).c_str());
Base::Console().Message("anglePoints - vertex: %s\n",
DU::formatVector(vertex()).c_str());
DU::formatVector(first()).c_str(), DU::formatVector(second()).c_str());
Base::Console().Message("anglePoints - vertex: %s\n", DU::formatVector(vertex()).c_str());
}
arcPoints::arcPoints()
{
isArc = false;
radius = 0.0;
center = Base::Vector3d(0.0, 0.0, 0.0);
onCurve.first(Base::Vector3d(0.0, 0.0, 0.0));
onCurve.second(Base::Vector3d(0.0, 0.0, 0.0));
arcEnds.first(Base::Vector3d(0.0, 0.0, 0.0));
arcEnds.second(Base::Vector3d(0.0, 0.0, 0.0));
midArc = Base::Vector3d(0.0, 0.0, 0.0);
arcCW = false;
isArc = false;
radius = 0.0;
center = Base::Vector3d(0.0, 0.0, 0.0);
onCurve.first(Base::Vector3d(0.0, 0.0, 0.0));
onCurve.second(Base::Vector3d(0.0, 0.0, 0.0));
arcEnds.first(Base::Vector3d(0.0, 0.0, 0.0));
arcEnds.second(Base::Vector3d(0.0, 0.0, 0.0));
midArc = Base::Vector3d(0.0, 0.0, 0.0);
arcCW = false;
}
arcPoints::arcPoints(const arcPoints& ap)
: isArc(ap.isArc)
, radius(ap.radius)
, center(ap.center)
, onCurve(ap.onCurve)
, arcEnds(ap.arcEnds)
, midArc(ap.midArc)
, arcCW(ap.arcCW)
{
: isArc(ap.isArc), radius(ap.radius), center(ap.center), onCurve(ap.onCurve),
arcEnds(ap.arcEnds), midArc(ap.midArc), arcCW(ap.arcCW)
{}
}
arcPoints& arcPoints::operator= (const arcPoints& ap)
arcPoints& arcPoints::operator=(const arcPoints& ap)
{
isArc = ap.isArc;
radius = ap.radius;
@@ -210,7 +202,7 @@ void arcPoints::mapToPage(DrawViewPart* dvp)
{
gp_Trsf xOXYZ;
gp_Ax3 OXYZ;
xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getProjectionCS()));
xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getRotatedCS()));
gp_Vec gvCenter = DU::togp_Vec(center).Transformed(xOXYZ);
center = DU::toVector3d(gvCenter);
@@ -237,7 +229,8 @@ void arcPoints::invertY()
void arcPoints::dump(std::string text) const
{
Base::Console().Message("arcPoints - %s\n", text.c_str());
Base::Console().Message("arcPoints - radius: %.3f center: %s\n", radius, DrawUtil::formatVector(center).c_str());
Base::Console().Message("arcPoints - radius: %.3f center: %s\n", radius,
DrawUtil::formatVector(center).c_str());
Base::Console().Message("arcPoints - isArc: %d arcCW: %d\n", isArc, arcCW);
Base::Console().Message("arcPoints - onCurve: %s %s\n",
DrawUtil::formatVector(onCurve.first()).c_str(),
@@ -245,7 +238,5 @@ void arcPoints::dump(std::string text) const
Base::Console().Message("arcPoints - arcEnds: %s %s\n",
DrawUtil::formatVector(arcEnds.first()).c_str(),
DrawUtil::formatVector(arcEnds.second()).c_str());
Base::Console().Message("arcPoints - midArc: %s\n",
DrawUtil::formatVector(midArc).c_str());
Base::Console().Message("arcPoints - midArc: %s\n", DrawUtil::formatVector(midArc).c_str());
}