+ rename methods in Vector3 class
+ add convenience methods Cross and Dot to Vector3 class + fix bug in DistanceToLineSegment in Vector3 class
This commit is contained in:
parent
5c095de599
commit
1e2e24b652
|
@ -29,7 +29,7 @@
|
||||||
#include "ViewProj.h"
|
#include "ViewProj.h"
|
||||||
#include "Tools2D.h"
|
#include "Tools2D.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace Base {
|
namespace Base {
|
||||||
|
|
||||||
|
@ -833,7 +833,7 @@ inline Vector3<_Precision> BoundBox3<_Precision>::ClosestPoint (const Vector3<_P
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
Vector3<_Precision> clTemp = rclPt;
|
Vector3<_Precision> clTemp = rclPt;
|
||||||
CalcPlane(i, cBase, cNormal);
|
CalcPlane(i, cBase, cNormal);
|
||||||
clTemp.ProjToPlane(cBase, cNormal);
|
clTemp.ProjectToPlane(cBase, cNormal);
|
||||||
_Precision fDist = (clTemp - rclPt).Length();
|
_Precision fDist = (clTemp - rclPt).Length();
|
||||||
if (fDist < fMinDist) {
|
if (fDist < fMinDist) {
|
||||||
fMinDist = fDist;
|
fMinDist = fDist;
|
||||||
|
@ -843,31 +843,31 @@ inline Vector3<_Precision> BoundBox3<_Precision>::ClosestPoint (const Vector3<_P
|
||||||
|
|
||||||
return clRet;
|
return clRet;
|
||||||
#else
|
#else
|
||||||
Vector3<_Precision> closest = rclPt;
|
Vector3<_Precision> closest = rclPt;
|
||||||
|
|
||||||
Vector3<_Precision> center = GetCenter();
|
Vector3<_Precision> center = GetCenter();
|
||||||
_Precision devx = closest.x - center.x;
|
_Precision devx = closest.x - center.x;
|
||||||
_Precision devy = closest.y - center.y;
|
_Precision devy = closest.y - center.y;
|
||||||
_Precision devz = closest.z - center.z;
|
_Precision devz = closest.z - center.z;
|
||||||
|
|
||||||
_Precision halfwidth = (MaxX - MinX) / 2;
|
_Precision halfwidth = (MaxX - MinX) / 2;
|
||||||
_Precision halfheight = (MaxY - MinY) / 2;
|
_Precision halfheight = (MaxY - MinY) / 2;
|
||||||
_Precision halfdepth = (MaxZ - MinZ) / 2;
|
_Precision halfdepth = (MaxZ - MinZ) / 2;
|
||||||
|
|
||||||
// Move point to be on the nearest plane of the box.
|
// Move point to be on the nearest plane of the box.
|
||||||
if ((fabs(devx) > fabs(devy)) && (fabs(devx) > fabs(devz)))
|
if ((fabs(devx) > fabs(devy)) && (fabs(devx) > fabs(devz)))
|
||||||
closest.x = center.x + halfwidth * ((devx < 0.0) ? -1.0 : 1.0);
|
closest.x = center.x + halfwidth * ((devx < 0.0) ? -1.0 : 1.0);
|
||||||
else if (fabs(devy) > fabs(devz))
|
else if (fabs(devy) > fabs(devz))
|
||||||
closest.y = center.y + halfheight * ((devy < 0.0) ? -1.0 : 1.0);
|
closest.y = center.y + halfheight * ((devy < 0.0) ? -1.0 : 1.0);
|
||||||
else
|
else
|
||||||
closest.z = center.z + halfdepth * ((devz < 0.0) ? -1.0 : 1.0);
|
closest.z = center.z + halfdepth * ((devz < 0.0) ? -1.0 : 1.0);
|
||||||
|
|
||||||
// Clamp to be inside box.
|
// Clamp to be inside box.
|
||||||
closest.x = std::min<_Precision>(std::max<_Precision>(closest.x, MinX), MaxX);
|
closest.x = std::min<_Precision>(std::max<_Precision>(closest.x, MinX), MaxX);
|
||||||
closest.y = std::min<_Precision>(std::max<_Precision>(closest.y, MinY), MaxY);
|
closest.y = std::min<_Precision>(std::max<_Precision>(closest.y, MinY), MaxY);
|
||||||
closest.z = std::min<_Precision>(std::max<_Precision>(closest.z, MinZ), MaxZ);
|
closest.z = std::min<_Precision>(std::max<_Precision>(closest.z, MinZ), MaxZ);
|
||||||
|
|
||||||
return closest;
|
return closest;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ double Vector2D::GetAngle (const Vector2D &rclVect) const
|
||||||
return -FLOAT_MAX; // division by zero
|
return -FLOAT_MAX; // division by zero
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2D::ProjToLine (const Vector2D &rclPt, const Vector2D &rclLine)
|
void Vector2D::ProjectToLine (const Vector2D &rclPt, const Vector2D &rclLine)
|
||||||
{
|
{
|
||||||
double l = rclLine.Length();
|
double l = rclLine.Length();
|
||||||
double t1 = (rclPt * rclLine) / l;
|
double t1 = (rclPt * rclLine) / l;
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
inline void Scale (double fS);
|
inline void Scale (double fS);
|
||||||
inline void Normalize (void);
|
inline void Normalize (void);
|
||||||
double GetAngle (const Vector2D &rclVect) const;
|
double GetAngle (const Vector2D &rclVect) const;
|
||||||
void ProjToLine (const Vector2D &rclPt, const Vector2D &rclLine);
|
void ProjectToLine (const Vector2D &rclPt, const Vector2D &rclLine);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** BoundBox2D ********************************************/
|
/** BoundBox2D ********************************************/
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "PreCompiled.h"
|
#include "PreCompiled.h"
|
||||||
|
#include "Tools.h"
|
||||||
#include "Vector3D.h"
|
#include "Vector3D.h"
|
||||||
|
|
||||||
using namespace Base;
|
using namespace Base;
|
||||||
|
@ -116,7 +117,7 @@ Vector3<_Precision>& Vector3<_Precision>::operator -= (const Vector3<_Precision>
|
||||||
{
|
{
|
||||||
x -= rcVct.x;
|
x -= rcVct.x;
|
||||||
y -= rcVct.y;
|
y -= rcVct.y;
|
||||||
z -= rcVct.z;
|
z -= rcVct.z;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +166,12 @@ _Precision Vector3<_Precision>::operator * (const Vector3<_Precision>& rcVct) c
|
||||||
return (x * rcVct.x) + (y * rcVct.y) + (z * rcVct.z);
|
return (x * rcVct.x) + (y * rcVct.y) + (z * rcVct.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class _Precision>
|
||||||
|
_Precision Vector3<_Precision>::Dot (const Vector3<_Precision>& rcVct) const
|
||||||
|
{
|
||||||
|
return (x * rcVct.x) + (y * rcVct.y) + (z * rcVct.z);
|
||||||
|
}
|
||||||
|
|
||||||
template <class _Precision>
|
template <class _Precision>
|
||||||
Vector3<_Precision> Vector3<_Precision>::operator % (const Vector3<_Precision>& rcVct) const
|
Vector3<_Precision> Vector3<_Precision>::operator % (const Vector3<_Precision>& rcVct) const
|
||||||
{
|
{
|
||||||
|
@ -175,6 +182,16 @@ Vector3<_Precision> Vector3<_Precision>::operator % (const Vector3<_Precision>&
|
||||||
return cVctRes;
|
return cVctRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class _Precision>
|
||||||
|
Vector3<_Precision> Vector3<_Precision>::Cross(const Vector3<_Precision>& rcVct) const
|
||||||
|
{
|
||||||
|
Vector3<_Precision> cVctRes;
|
||||||
|
cVctRes.x = (y * rcVct.z) - (z * rcVct.y);
|
||||||
|
cVctRes.y = (z * rcVct.x) - (x * rcVct.z);
|
||||||
|
cVctRes.z = (x * rcVct.y) - (y * rcVct.x);
|
||||||
|
return cVctRes;
|
||||||
|
}
|
||||||
|
|
||||||
template <class _Precision>
|
template <class _Precision>
|
||||||
bool Vector3<_Precision>::operator != (const Vector3<_Precision>& rcVct) const
|
bool Vector3<_Precision>::operator != (const Vector3<_Precision>& rcVct) const
|
||||||
{
|
{
|
||||||
|
@ -190,14 +207,23 @@ bool Vector3<_Precision>::operator == (const Vector3<_Precision>& rcVct) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Precision>
|
template <class _Precision>
|
||||||
Vector3<_Precision>& Vector3<_Precision>::ProjToPlane (const Vector3<_Precision> &rclBase,
|
Vector3<_Precision>& Vector3<_Precision>::ProjectToPlane (const Vector3<_Precision> &rclBase,
|
||||||
const Vector3<_Precision> &rclNorm)
|
const Vector3<_Precision> &rclNorm)
|
||||||
{
|
{
|
||||||
Vector3<_Precision> clTemp(rclNorm);
|
Vector3<_Precision> clTemp(rclNorm);
|
||||||
*this = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr());
|
*this = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class _Precision>
|
||||||
|
void Vector3<_Precision>::ProjectToPlane (const Vector3 &rclBase,
|
||||||
|
const Vector3 &rclNorm,
|
||||||
|
Vector3 &rclProj) const
|
||||||
|
{
|
||||||
|
Vector3<_Precision> clTemp(rclNorm);
|
||||||
|
rclProj = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr());
|
||||||
|
}
|
||||||
|
|
||||||
template <class _Precision>
|
template <class _Precision>
|
||||||
_Precision Vector3<_Precision>::DistanceToPlane (const Vector3<_Precision> &rclBase,
|
_Precision Vector3<_Precision>::DistanceToPlane (const Vector3<_Precision> &rclBase,
|
||||||
const Vector3<_Precision> &rclNorm) const
|
const Vector3<_Precision> &rclNorm) const
|
||||||
|
@ -219,30 +245,24 @@ _Precision Vector3<_Precision>::DistanceToLine (const Vector3<_Precision> &rclBa
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Precision>
|
template <class _Precision>
|
||||||
Vector3<_Precision> Vector3<_Precision>::DistanceToLineSegment (const Vector3& rclP1,
|
Vector3<_Precision> Vector3<_Precision>::DistanceToLineSegment(const Vector3& rclP1,
|
||||||
const Vector3& rclP2) const
|
const Vector3& rclP2) const
|
||||||
{
|
{
|
||||||
Vector3<_Precision> dir = rclP2-rclP1;
|
_Precision len2 = Base::DistanceP2(rclP1, rclP2);
|
||||||
Vector3<_Precision> beg = *this-rclP1;
|
if (len2 == 0)
|
||||||
Vector3<_Precision> end = beg+dir;
|
return rclP1;
|
||||||
|
|
||||||
Vector3<_Precision> proj, len;
|
Vector3<_Precision> p2p1 = rclP2-rclP1;
|
||||||
proj.ProjToLine(beg, dir);
|
Vector3<_Precision> pXp1 = *this-rclP1;
|
||||||
len = proj + beg;
|
_Precision dot = pXp1 * p2p1;
|
||||||
if (len * dir < 0 || len.Length() > dir.Length()) {
|
_Precision t = clamp<_Precision>(dot/len2, 0, 1);
|
||||||
if (beg.Length() < end.Length())
|
Vector3<_Precision> dist = t * p2p1 - pXp1;
|
||||||
return beg;
|
return dist;
|
||||||
else
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return proj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Precision>
|
template <class _Precision>
|
||||||
Vector3<_Precision>& Vector3<_Precision>::ProjToLine (const Vector3<_Precision> &rclPoint,
|
Vector3<_Precision>& Vector3<_Precision>::ProjectToLine (const Vector3<_Precision> &rclPoint,
|
||||||
const Vector3<_Precision> &rclLine)
|
const Vector3<_Precision> &rclLine)
|
||||||
{
|
{
|
||||||
return (*this = ((((rclPoint * rclLine) / rclLine.Sqr()) * rclLine) - rclPoint));
|
return (*this = ((((rclPoint * rclLine) / rclLine.Sqr()) * rclLine) - rclPoint));
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,12 @@ public:
|
||||||
Vector3 & operator = (const Vector3<_Precision>& rcVct);
|
Vector3 & operator = (const Vector3<_Precision>& rcVct);
|
||||||
/// Scalar product
|
/// Scalar product
|
||||||
_Precision operator * (const Vector3<_Precision>& rcVct) const;
|
_Precision operator * (const Vector3<_Precision>& rcVct) const;
|
||||||
|
/// Scalar product
|
||||||
|
_Precision Dot (const Vector3<_Precision>& rcVct) const;
|
||||||
/// Cross product
|
/// Cross product
|
||||||
Vector3 operator % (const Vector3<_Precision>& rcVct) const;
|
Vector3 operator % (const Vector3<_Precision>& rcVct) const;
|
||||||
|
/// Cross product
|
||||||
|
Vector3 Cross (const Vector3<_Precision>& rcVct) const;
|
||||||
/// Comparing for inequality
|
/// Comparing for inequality
|
||||||
bool operator != (const Vector3<_Precision>& rcVct) const;
|
bool operator != (const Vector3<_Precision>& rcVct) const;
|
||||||
/// Comparing for equality
|
/// Comparing for equality
|
||||||
|
@ -159,7 +163,12 @@ public:
|
||||||
void TransformToCoordinateSystem (const Vector3 &rclBase, const Vector3 &rclDirX, const Vector3 &rclDirY);
|
void TransformToCoordinateSystem (const Vector3 &rclBase, const Vector3 &rclDirX, const Vector3 &rclDirY);
|
||||||
//bool Equal(const Vector3 &rclVect) const;
|
//bool Equal(const Vector3 &rclVect) const;
|
||||||
/// Projects this point onto the plane given by the base \a rclBase and the normal \a rclNorm.
|
/// Projects this point onto the plane given by the base \a rclBase and the normal \a rclNorm.
|
||||||
Vector3 & ProjToPlane (const Vector3 &rclBase, const Vector3 &rclNorm);
|
Vector3 & ProjectToPlane (const Vector3 &rclBase, const Vector3 &rclNorm);
|
||||||
|
/**
|
||||||
|
* Projects this point onto the plane given by the base \a rclBase and the normal \a rclNorm
|
||||||
|
* and stores the result in rclProj.
|
||||||
|
*/
|
||||||
|
void ProjectToPlane (const Vector3 &rclBase, const Vector3 &rclNorm, Vector3 &rclProj) const;
|
||||||
/// Projects this point onto the line given by the base \a rclPoint and the direction \a rclLine.
|
/// Projects this point onto the line given by the base \a rclPoint and the direction \a rclLine.
|
||||||
/**
|
/**
|
||||||
* Projects a point \a rclPoint onto the line defined by the origin and the direction \a rclLine.
|
* Projects a point \a rclPoint onto the line defined by the origin and the direction \a rclLine.
|
||||||
|
@ -167,10 +176,10 @@ public:
|
||||||
* is the distance from \a rclPoint to the line.
|
* is the distance from \a rclPoint to the line.
|
||||||
* Note: The resulting vector does not depend on the current vector.
|
* Note: The resulting vector does not depend on the current vector.
|
||||||
*/
|
*/
|
||||||
Vector3 & ProjToLine (const Vector3 &rclPoint, const Vector3 &rclLine);
|
Vector3 & ProjectToLine (const Vector3 &rclPoint, const Vector3 &rclLine);
|
||||||
/**
|
/**
|
||||||
* Get the perpendicular of this point to the line defined by rclBase and rclDir.
|
* Get the perpendicular of this point to the line defined by rclBase and rclDir.
|
||||||
* Note: Do not mix up this method with ProjToLine.
|
* Note: Do not mix up this method with ProjectToLine.
|
||||||
*/
|
*/
|
||||||
Vector3 Perpendicular(const Vector3 &rclBase, const Vector3 &rclDir) const;
|
Vector3 Perpendicular(const Vector3 &rclBase, const Vector3 &rclDir) const;
|
||||||
/** Computes the distance to the given plane. Depending on the side this point is located
|
/** Computes the distance to the given plane. Depending on the side this point is located
|
||||||
|
|
|
@ -364,7 +364,7 @@ PyObject* VectorPy::projectToLine(PyObject *args)
|
||||||
VectorPy::PointerType base_ptr = reinterpret_cast<VectorPy::PointerType>(base_vec->_pcTwinPointer);
|
VectorPy::PointerType base_ptr = reinterpret_cast<VectorPy::PointerType>(base_vec->_pcTwinPointer);
|
||||||
VectorPy::PointerType line_ptr = reinterpret_cast<VectorPy::PointerType>(line_vec->_pcTwinPointer);
|
VectorPy::PointerType line_ptr = reinterpret_cast<VectorPy::PointerType>(line_vec->_pcTwinPointer);
|
||||||
|
|
||||||
this_ptr->ProjToLine(*base_ptr, *line_ptr);
|
this_ptr->ProjectToLine(*base_ptr, *line_ptr);
|
||||||
|
|
||||||
return Py::new_reference_to(this);
|
return Py::new_reference_to(this);
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ PyObject* VectorPy::projectToPlane(PyObject *args)
|
||||||
VectorPy::PointerType base_ptr = reinterpret_cast<VectorPy::PointerType>(base_vec->_pcTwinPointer);
|
VectorPy::PointerType base_ptr = reinterpret_cast<VectorPy::PointerType>(base_vec->_pcTwinPointer);
|
||||||
VectorPy::PointerType line_ptr = reinterpret_cast<VectorPy::PointerType>(line_vec->_pcTwinPointer);
|
VectorPy::PointerType line_ptr = reinterpret_cast<VectorPy::PointerType>(line_vec->_pcTwinPointer);
|
||||||
|
|
||||||
this_ptr->ProjToPlane(*base_ptr, *line_ptr);
|
this_ptr->ProjectToPlane(*base_ptr, *line_ptr);
|
||||||
|
|
||||||
return Py::new_reference_to(this);
|
return Py::new_reference_to(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@ bool MeshGeomFacet::IsPointOf (const Base::Vector3f &rclPoint, float fDistance)
|
||||||
float fLP, fLE;
|
float fLP, fLE;
|
||||||
|
|
||||||
clNorm.Normalize();
|
clNorm.Normalize();
|
||||||
clProjPt.ProjToPlane(_aclPoints[0], clNorm);
|
clProjPt.ProjectToPlane(_aclPoints[0], clNorm);
|
||||||
|
|
||||||
|
|
||||||
// Kante P0 --> P1
|
// Kante P0 --> P1
|
||||||
|
@ -351,7 +351,7 @@ bool MeshGeomFacet::Weights(const Base::Vector3f& rclP, float& w0, float& w1, fl
|
||||||
|
|
||||||
void MeshGeomFacet::ProjectPointToPlane (Base::Vector3f &rclPoint) const
|
void MeshGeomFacet::ProjectPointToPlane (Base::Vector3f &rclPoint) const
|
||||||
{
|
{
|
||||||
rclPoint.ProjToPlane(_aclPoints[0], GetNormal());
|
rclPoint.ProjectToPlane(_aclPoints[0], GetNormal());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshGeomFacet::ProjectFacetToPlane (MeshGeomFacet &rclFacet) const
|
void MeshGeomFacet::ProjectFacetToPlane (MeshGeomFacet &rclFacet) const
|
||||||
|
|
|
@ -81,8 +81,8 @@ bool MeshOrientationCollector::Visit (const MeshFacet &rclFacet, const MeshFacet
|
||||||
// mark this facet as false oriented
|
// mark this facet as false oriented
|
||||||
rclFacet.SetFlag(MeshFacet::TMP0);
|
rclFacet.SetFlag(MeshFacet::TMP0);
|
||||||
_aulIndices.push_back( ulFInd );
|
_aulIndices.push_back( ulFInd );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_aulComplement.push_back( ulFInd );
|
_aulComplement.push_back( ulFInd );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -93,8 +93,8 @@ bool MeshOrientationCollector::Visit (const MeshFacet &rclFacet, const MeshFacet
|
||||||
rclFacet.SetFlag(MeshFacet::TMP0);
|
rclFacet.SetFlag(MeshFacet::TMP0);
|
||||||
_aulIndices.push_back(ulFInd);
|
_aulIndices.push_back(ulFInd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_aulComplement.push_back( ulFInd );
|
_aulComplement.push_back( ulFInd );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -129,26 +129,26 @@ MeshEvalOrientation::~MeshEvalOrientation()
|
||||||
|
|
||||||
bool MeshEvalOrientation::Evaluate ()
|
bool MeshEvalOrientation::Evaluate ()
|
||||||
{
|
{
|
||||||
const MeshFacetArray& rFAry = _rclMesh.GetFacets();
|
const MeshFacetArray& rFAry = _rclMesh.GetFacets();
|
||||||
MeshFacetArray::_TConstIterator iBeg = rFAry.begin();
|
MeshFacetArray::_TConstIterator iBeg = rFAry.begin();
|
||||||
MeshFacetArray::_TConstIterator iEnd = rFAry.end();
|
MeshFacetArray::_TConstIterator iEnd = rFAry.end();
|
||||||
for (MeshFacetArray::_TConstIterator it = iBeg; it != iEnd; ++it) {
|
for (MeshFacetArray::_TConstIterator it = iBeg; it != iEnd; ++it) {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (it->_aulNeighbours[i] != ULONG_MAX) {
|
if (it->_aulNeighbours[i] != ULONG_MAX) {
|
||||||
const MeshFacet& rclFacet = iBeg[it->_aulNeighbours[i]];
|
const MeshFacet& rclFacet = iBeg[it->_aulNeighbours[i]];
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
if (it->_aulPoints[i] == rclFacet._aulPoints[j]) {
|
if (it->_aulPoints[i] == rclFacet._aulPoints[j]) {
|
||||||
if ((it->_aulPoints[(i+1)%3] == rclFacet._aulPoints[(j+1)%3]) ||
|
if ((it->_aulPoints[(i+1)%3] == rclFacet._aulPoints[(j+1)%3]) ||
|
||||||
(it->_aulPoints[(i+2)%3] == rclFacet._aulPoints[(j+2)%3])) {
|
(it->_aulPoints[(i+2)%3] == rclFacet._aulPoints[(j+2)%3])) {
|
||||||
return false; // adjacent face with wrong orientation
|
return false; // adjacent face with wrong orientation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector<unsigned long>& inds) const
|
unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector<unsigned long>& inds) const
|
||||||
|
@ -159,26 +159,26 @@ unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector<unsigned
|
||||||
// a false positive.
|
// a false positive.
|
||||||
// False-positives can occur if the mesh structure has some defects which let the region-grow
|
// False-positives can occur if the mesh structure has some defects which let the region-grow
|
||||||
// algorithm fail to detect the faces with wrong orientation.
|
// algorithm fail to detect the faces with wrong orientation.
|
||||||
const MeshFacetArray& rFAry = _rclMesh.GetFacets();
|
const MeshFacetArray& rFAry = _rclMesh.GetFacets();
|
||||||
MeshFacetArray::_TConstIterator iBeg = rFAry.begin();
|
MeshFacetArray::_TConstIterator iBeg = rFAry.begin();
|
||||||
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
|
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
|
||||||
const MeshFacet& f = iBeg[*it];
|
const MeshFacet& f = iBeg[*it];
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (f._aulNeighbours[i] != ULONG_MAX) {
|
if (f._aulNeighbours[i] != ULONG_MAX) {
|
||||||
const MeshFacet& n = iBeg[f._aulNeighbours[i]];
|
const MeshFacet& n = iBeg[f._aulNeighbours[i]];
|
||||||
if (f.IsFlag(MeshFacet::TMP0) && !n.IsFlag(MeshFacet::TMP0)) {
|
if (f.IsFlag(MeshFacet::TMP0) && !n.IsFlag(MeshFacet::TMP0)) {
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
if (f.HasSameOrientation(n)) {
|
if (f.HasSameOrientation(n)) {
|
||||||
// adjacent face with same orientation => false positive
|
// adjacent face with same orientation => false positive
|
||||||
return f._aulNeighbours[i];
|
return f._aulNeighbours[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ULONG_MAX;
|
return ULONG_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned long> MeshEvalOrientation::GetIndices() const
|
std::vector<unsigned long> MeshEvalOrientation::GetIndices() const
|
||||||
|
@ -204,19 +204,19 @@ std::vector<unsigned long> MeshEvalOrientation::GetIndices() const
|
||||||
MeshOrientationCollector clHarmonizer(uIndices, uComplement);
|
MeshOrientationCollector clHarmonizer(uIndices, uComplement);
|
||||||
|
|
||||||
while (ulStartFacet != ULONG_MAX) {
|
while (ulStartFacet != ULONG_MAX) {
|
||||||
unsigned long wrongFacets = uIndices.size();
|
unsigned long wrongFacets = uIndices.size();
|
||||||
|
|
||||||
uComplement.clear();
|
uComplement.clear();
|
||||||
uComplement.push_back( ulStartFacet );
|
uComplement.push_back( ulStartFacet );
|
||||||
ulVisited = _rclMesh.VisitNeighbourFacets(clHarmonizer, ulStartFacet) + 1;
|
ulVisited = _rclMesh.VisitNeighbourFacets(clHarmonizer, ulStartFacet) + 1;
|
||||||
|
|
||||||
// In the currently visited component we have found less than 40% as correct
|
// In the currently visited component we have found less than 40% as correct
|
||||||
// oriented and the rest as false oriented. So, we decide that it should be the other
|
// oriented and the rest as false oriented. So, we decide that it should be the other
|
||||||
// way round and swap the indices of this component.
|
// way round and swap the indices of this component.
|
||||||
if (uComplement.size() < (unsigned long)(0.4f*(float)ulVisited)) {
|
if (uComplement.size() < (unsigned long)(0.4f*(float)ulVisited)) {
|
||||||
uIndices.erase(uIndices.begin()+wrongFacets, uIndices.end());
|
uIndices.erase(uIndices.begin()+wrongFacets, uIndices.end());
|
||||||
uIndices.insert(uIndices.end(), uComplement.begin(), uComplement.end());
|
uIndices.insert(uIndices.end(), uComplement.begin(), uComplement.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the mesh consists of several topologic independent components
|
// if the mesh consists of several topologic independent components
|
||||||
// We can search from position 'iTri' on because all elements _before_ are already visited
|
// We can search from position 'iTri' on because all elements _before_ are already visited
|
||||||
|
@ -240,14 +240,14 @@ std::vector<unsigned long> MeshEvalOrientation::GetIndices() const
|
||||||
MeshSameOrientationCollector coll(falsePos);
|
MeshSameOrientationCollector coll(falsePos);
|
||||||
_rclMesh.VisitNeighbourFacets(coll, ulStartFacet);
|
_rclMesh.VisitNeighbourFacets(coll, ulStartFacet);
|
||||||
|
|
||||||
std::sort(uIndices.begin(), uIndices.end());
|
std::sort(uIndices.begin(), uIndices.end());
|
||||||
std::sort(falsePos.begin(), falsePos.end());
|
std::sort(falsePos.begin(), falsePos.end());
|
||||||
|
|
||||||
std::vector<unsigned long> diff;
|
std::vector<unsigned long> diff;
|
||||||
std::back_insert_iterator<std::vector<unsigned long> > biit(diff);
|
std::back_insert_iterator<std::vector<unsigned long> > biit(diff);
|
||||||
std::set_difference(uIndices.begin(), uIndices.end(), falsePos.begin(), falsePos.end(), biit);
|
std::set_difference(uIndices.begin(), uIndices.end(), falsePos.begin(), falsePos.end(), biit);
|
||||||
uIndices = diff;
|
uIndices = diff;
|
||||||
|
|
||||||
cAlg.ResetFacetFlag(MeshFacet::TMP0);
|
cAlg.ResetFacetFlag(MeshFacet::TMP0);
|
||||||
cAlg.SetFacetsFlag(uIndices, MeshFacet::TMP0);
|
cAlg.SetFacetsFlag(uIndices, MeshFacet::TMP0);
|
||||||
unsigned long current = ulStartFacet;
|
unsigned long current = ulStartFacet;
|
||||||
|
@ -299,32 +299,32 @@ bool MeshEvalSolid::Evaluate ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------
|
// ----------------------------------------------------
|
||||||
|
|
||||||
namespace MeshCore {
|
namespace MeshCore {
|
||||||
|
|
||||||
struct Edge_Index
|
struct Edge_Index
|
||||||
{
|
{
|
||||||
unsigned long p0, p1, f;
|
unsigned long p0, p1, f;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Edge_Less : public std::binary_function<const Edge_Index&,
|
struct Edge_Less : public std::binary_function<const Edge_Index&,
|
||||||
const Edge_Index&, bool>
|
const Edge_Index&, bool>
|
||||||
{
|
{
|
||||||
bool operator()(const Edge_Index& x, const Edge_Index& y) const
|
bool operator()(const Edge_Index& x, const Edge_Index& y) const
|
||||||
{
|
{
|
||||||
if (x.p0 < y.p0)
|
if (x.p0 < y.p0)
|
||||||
return true;
|
return true;
|
||||||
else if (x.p0 > y.p0)
|
else if (x.p0 > y.p0)
|
||||||
return false;
|
return false;
|
||||||
else if (x.p1 < y.p1)
|
else if (x.p1 < y.p1)
|
||||||
return true;
|
return true;
|
||||||
else if (x.p1 > y.p1)
|
else if (x.p1 > y.p1)
|
||||||
return false;
|
return false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MeshEvalTopology::Evaluate ()
|
bool MeshEvalTopology::Evaluate ()
|
||||||
{
|
{
|
||||||
|
@ -463,29 +463,29 @@ bool MeshEvalPointManifolds::Evaluate ()
|
||||||
this->nonManifoldPoints.clear();
|
this->nonManifoldPoints.clear();
|
||||||
this->facetsOfNonManifoldPoints.clear();
|
this->facetsOfNonManifoldPoints.clear();
|
||||||
|
|
||||||
MeshCore::MeshRefPointToPoints vv_it(_rclMesh);
|
MeshCore::MeshRefPointToPoints vv_it(_rclMesh);
|
||||||
MeshCore::MeshRefPointToFacets vf_it(_rclMesh);
|
MeshCore::MeshRefPointToFacets vf_it(_rclMesh);
|
||||||
|
|
||||||
unsigned long ctPoints = _rclMesh.CountPoints();
|
unsigned long ctPoints = _rclMesh.CountPoints();
|
||||||
for (unsigned long index=0; index < ctPoints; index++) {
|
for (unsigned long index=0; index < ctPoints; index++) {
|
||||||
// get the local neighbourhood of the point
|
// get the local neighbourhood of the point
|
||||||
const std::set<unsigned long>& nf = vf_it[index];
|
const std::set<unsigned long>& nf = vf_it[index];
|
||||||
const std::set<unsigned long>& np = vv_it[index];
|
const std::set<unsigned long>& np = vv_it[index];
|
||||||
|
|
||||||
std::set<unsigned long>::size_type sp, sf;
|
std::set<unsigned long>::size_type sp, sf;
|
||||||
sp = np.size();
|
sp = np.size();
|
||||||
sf = nf.size();
|
sf = nf.size();
|
||||||
// for an inner point the number of adjacent points is equal to the number of shared faces
|
// for an inner point the number of adjacent points is equal to the number of shared faces
|
||||||
// for a boundary point the number of adjacent points is higher by one than the number of shared faces
|
// for a boundary point the number of adjacent points is higher by one than the number of shared faces
|
||||||
// for a non-manifold point the number of adjacent points is higher by more than one than the number of shared faces
|
// for a non-manifold point the number of adjacent points is higher by more than one than the number of shared faces
|
||||||
if (sp > sf + 1) {
|
if (sp > sf + 1) {
|
||||||
nonManifoldPoints.push_back(index);
|
nonManifoldPoints.push_back(index);
|
||||||
std::vector<unsigned long> faces;
|
std::vector<unsigned long> faces;
|
||||||
faces.insert(faces.end(), nf.begin(), nf.end());
|
faces.insert(faces.end(), nf.begin(), nf.end());
|
||||||
this->facetsOfNonManifoldPoints.push_back(faces);
|
this->facetsOfNonManifoldPoints.push_back(faces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->nonManifoldPoints.empty();
|
return this->nonManifoldPoints.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,8 +658,8 @@ bool MeshEvalSelfIntersection::Evaluate ()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshEvalSelfIntersection::GetIntersections(const std::vector<std::pair<unsigned long, unsigned long> >& indices,
|
void MeshEvalSelfIntersection::GetIntersections(const std::vector<std::pair<unsigned long, unsigned long> >& indices,
|
||||||
std::vector<std::pair<Base::Vector3f, Base::Vector3f> >& intersection) const
|
std::vector<std::pair<Base::Vector3f, Base::Vector3f> >& intersection) const
|
||||||
{
|
{
|
||||||
intersection.reserve(indices.size());
|
intersection.reserve(indices.size());
|
||||||
MeshFacetIterator cMF1(_rclMesh);
|
MeshFacetIterator cMF1(_rclMesh);
|
||||||
|
@ -682,7 +682,7 @@ void MeshEvalSelfIntersection::GetIntersections(const std::vector<std::pair<unsi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<unsigned long, unsigned long> >& intersection) const
|
void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<unsigned long, unsigned long> >& intersection) const
|
||||||
{
|
{
|
||||||
// Contains bounding boxes for every facet
|
// Contains bounding boxes for every facet
|
||||||
std::vector<Base::BoundBox3f> boxes;
|
std::vector<Base::BoundBox3f> boxes;
|
||||||
|
@ -751,8 +751,8 @@ void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<unsigned l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned long> MeshFixSelfIntersection::GetFacets() const
|
std::vector<unsigned long> MeshFixSelfIntersection::GetFacets() const
|
||||||
{
|
{
|
||||||
std::vector<unsigned long> indices;
|
std::vector<unsigned long> indices;
|
||||||
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
|
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
|
||||||
|
@ -780,9 +780,9 @@ std::vector<unsigned long> MeshFixSelfIntersection::GetFacets() const
|
||||||
indices.erase(std::unique(indices.begin(), indices.end()), indices.end());
|
indices.erase(std::unique(indices.begin(), indices.end()), indices.end());
|
||||||
|
|
||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MeshFixSelfIntersection::Fixup()
|
bool MeshFixSelfIntersection::Fixup()
|
||||||
{
|
{
|
||||||
_rclMesh.DeleteFacets(GetFacets());
|
_rclMesh.DeleteFacets(GetFacets());
|
||||||
return true;
|
return true;
|
||||||
|
@ -942,9 +942,9 @@ bool MeshFixNeighbourhood::Fixup()
|
||||||
_rclMesh.RebuildNeighbours();
|
_rclMesh.RebuildNeighbours();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernel::RebuildNeighbours (unsigned long index)
|
void MeshKernel::RebuildNeighbours (unsigned long index)
|
||||||
{
|
{
|
||||||
std::vector<Edge_Index> edges;
|
std::vector<Edge_Index> edges;
|
||||||
edges.reserve(3 * (this->_aclFacetArray.size() - index));
|
edges.reserve(3 * (this->_aclFacetArray.size() - index));
|
||||||
|
|
||||||
|
@ -1012,13 +1012,13 @@ void MeshKernel::RebuildNeighbours (unsigned long index)
|
||||||
unsigned short side = rFace.Side(p0,p1);
|
unsigned short side = rFace.Side(p0,p1);
|
||||||
rFace._aulNeighbours[side] = ULONG_MAX;
|
rFace._aulNeighbours[side] = ULONG_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernel::RebuildNeighbours (void)
|
void MeshKernel::RebuildNeighbours (void)
|
||||||
{
|
{
|
||||||
// complete rebuild
|
// complete rebuild
|
||||||
RebuildNeighbours(0);
|
RebuildNeighbours(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1070,7 +1070,7 @@ bool MeshEigensystem::Evaluate()
|
||||||
for (MeshPointArray::_TConstIterator it = aclPoints.begin(); it!=aclPoints.end(); ++it) {
|
for (MeshPointArray::_TConstIterator it = aclPoints.begin(); it!=aclPoints.end(); ++it) {
|
||||||
// u-Richtung
|
// u-Richtung
|
||||||
clVect = *it - _cC;
|
clVect = *it - _cC;
|
||||||
clProj.ProjToLine(clVect, _cU);
|
clProj.ProjectToLine(clVect, _cU);
|
||||||
clVect = clVect + clProj;
|
clVect = clVect + clProj;
|
||||||
fH = clVect.Length();
|
fH = clVect.Length();
|
||||||
|
|
||||||
|
@ -1083,7 +1083,7 @@ bool MeshEigensystem::Evaluate()
|
||||||
|
|
||||||
// v-Richtung
|
// v-Richtung
|
||||||
clVect = *it - _cC;
|
clVect = *it - _cC;
|
||||||
clProj.ProjToLine(clVect, _cV);
|
clProj.ProjectToLine(clVect, _cV);
|
||||||
clVect = clVect + clProj;
|
clVect = clVect + clProj;
|
||||||
fH = clVect.Length();
|
fH = clVect.Length();
|
||||||
|
|
||||||
|
@ -1096,7 +1096,7 @@ bool MeshEigensystem::Evaluate()
|
||||||
|
|
||||||
// w-Richtung
|
// w-Richtung
|
||||||
clVect = *it - _cC;
|
clVect = *it - _cC;
|
||||||
clProj.ProjToLine(clVect, _cW);
|
clProj.ProjectToLine(clVect, _cW);
|
||||||
clVect = clVect + clProj;
|
clVect = clVect + clProj;
|
||||||
fH = clVect.Length();
|
fH = clVect.Length();
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ bool MeshProjection::isPointInsideDistance (const Base::Vector3f& p1,
|
||||||
// project point on line
|
// project point on line
|
||||||
Base::Vector3f proj, dir(p2 - p1);
|
Base::Vector3f proj, dir(p2 - p1);
|
||||||
Base::Vector3f move(pt - p1);
|
Base::Vector3f move(pt - p1);
|
||||||
proj.ProjToLine(move, dir);
|
proj.ProjectToLine(move, dir);
|
||||||
proj = pt + proj;
|
proj = pt + proj;
|
||||||
return (((p1 - proj) * (p2 - proj)) < 0.0f);
|
return (((p1 - proj) * (p2 - proj)) < 0.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3537,8 +3537,8 @@ bool findFilletCenter(const GeomLineSegment *lineSeg1, const GeomLineSegment *li
|
||||||
|
|
||||||
// Just project the given reference points onto the lines, just in case they are not already lying on
|
// Just project the given reference points onto the lines, just in case they are not already lying on
|
||||||
Base::Vector3d normPnt1, normPnt2;
|
Base::Vector3d normPnt1, normPnt2;
|
||||||
normPnt1.ProjToLine(refPnt1-l1p1, l1p2-l1p1);
|
normPnt1.ProjectToLine(refPnt1-l1p1, l1p2-l1p1);
|
||||||
normPnt2.ProjToLine(refPnt2-l2p1, l2p2-l2p1);
|
normPnt2.ProjectToLine(refPnt2-l2p1, l2p2-l2p1);
|
||||||
normPnt1 += refPnt1;
|
normPnt1 += refPnt1;
|
||||||
normPnt2 += refPnt2;
|
normPnt2 += refPnt2;
|
||||||
|
|
||||||
|
@ -3587,8 +3587,8 @@ double suggestFilletRadius(const GeomLineSegment *lineSeg1, const GeomLineSegmen
|
||||||
Base::Vector3d dirBisect = (dir1.Normalize() + dir2.Normalize()).Normalize();
|
Base::Vector3d dirBisect = (dir1.Normalize() + dir2.Normalize()).Normalize();
|
||||||
|
|
||||||
Base::Vector3d projPnt1, projPnt2;
|
Base::Vector3d projPnt1, projPnt2;
|
||||||
projPnt1.ProjToLine(refPnt1-corner, dir1);
|
projPnt1.ProjectToLine(refPnt1-corner, dir1);
|
||||||
projPnt2.ProjToLine(refPnt2-corner, dir2);
|
projPnt2.ProjectToLine(refPnt2-corner, dir2);
|
||||||
projPnt1 += refPnt1;
|
projPnt1 += refPnt1;
|
||||||
projPnt2 += refPnt2;
|
projPnt2 += refPnt2;
|
||||||
|
|
||||||
|
@ -3617,8 +3617,8 @@ GeomArcOfCircle *createFilletGeometry(const GeomLineSegment *lineSeg1, const Geo
|
||||||
Base::Vector3d dir2 = lineSeg2->getEndPoint() - lineSeg2->getStartPoint();
|
Base::Vector3d dir2 = lineSeg2->getEndPoint() - lineSeg2->getStartPoint();
|
||||||
|
|
||||||
Base::Vector3d radDir1, radDir2;
|
Base::Vector3d radDir1, radDir2;
|
||||||
radDir1.ProjToLine(center - corner, dir1);
|
radDir1.ProjectToLine(center - corner, dir1);
|
||||||
radDir2.ProjToLine(center - corner, dir2);
|
radDir2.ProjectToLine(center - corner, dir2);
|
||||||
|
|
||||||
// Angle Variables
|
// Angle Variables
|
||||||
double startAngle, endAngle, range;
|
double startAngle, endAngle, range;
|
||||||
|
|
|
@ -89,7 +89,7 @@ bool ViewProviderMirror::setEdit(int ModNum)
|
||||||
Base::Vector3d base = mf->Base.getValue();
|
Base::Vector3d base = mf->Base.getValue();
|
||||||
Base::Vector3d norm = mf->Normal.getValue();
|
Base::Vector3d norm = mf->Normal.getValue();
|
||||||
Base::Vector3d cent = bbox.GetCenter();
|
Base::Vector3d cent = bbox.GetCenter();
|
||||||
base = cent.ProjToPlane(base, norm);
|
base = cent.ProjectToPlane(base, norm);
|
||||||
|
|
||||||
// setup the graph for editing the mirror plane
|
// setup the graph for editing the mirror plane
|
||||||
SoTransform* trans = new SoTransform;
|
SoTransform* trans = new SoTransform;
|
||||||
|
|
|
@ -702,7 +702,7 @@ void ParameterCorrection::ProjectControlPointsOnPlane()
|
||||||
for (unsigned k=0;k<_usVCtrlpoints;k++) {
|
for (unsigned k=0;k<_usVCtrlpoints;k++) {
|
||||||
gp_Pnt pole = _vCtrlPntsOfSurf(j,k);
|
gp_Pnt pole = _vCtrlPntsOfSurf(j,k);
|
||||||
Base::Vector3d pnt(pole.X(), pole.Y(), pole.Z());
|
Base::Vector3d pnt(pole.X(), pole.Y(), pole.Z());
|
||||||
pnt.ProjToPlane(base, _clW);
|
pnt.ProjectToPlane(base, _clW);
|
||||||
pole.SetX(pnt.x);
|
pole.SetX(pnt.x);
|
||||||
pole.SetY(pnt.y);
|
pole.SetY(pnt.y);
|
||||||
pole.SetZ(pnt.z);
|
pole.SetZ(pnt.z);
|
||||||
|
|
|
@ -962,8 +962,8 @@ int SketchObject::fillet(int GeoId1, int GeoId2,
|
||||||
delete arc;
|
delete arc;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
dist1.ProjToLine(arc->getStartPoint(/*emulateCCW=*/true)-intersection, dir1);
|
dist1.ProjectToLine(arc->getStartPoint(/*emulateCCW=*/true)-intersection, dir1);
|
||||||
dist2.ProjToLine(arc->getStartPoint(/*emulateCCW=*/true)-intersection, dir2);
|
dist2.ProjectToLine(arc->getStartPoint(/*emulateCCW=*/true)-intersection, dir2);
|
||||||
Part::Geometry *newgeo = dynamic_cast<Part::Geometry* >(arc);
|
Part::Geometry *newgeo = dynamic_cast<Part::Geometry* >(arc);
|
||||||
filletId = addGeometry(newgeo);
|
filletId = addGeometry(newgeo);
|
||||||
if (filletId < 0) {
|
if (filletId < 0) {
|
||||||
|
|
|
@ -759,7 +759,7 @@ public:
|
||||||
EditCurve[EditCurve.size()-1] = onSketchPos;
|
EditCurve[EditCurve.size()-1] = onSketchPos;
|
||||||
if (TransitionMode == TRANSITION_MODE_Tangent) {
|
if (TransitionMode == TRANSITION_MODE_Tangent) {
|
||||||
Base::Vector2D Tangent(dirVec.x,dirVec.y);
|
Base::Vector2D Tangent(dirVec.x,dirVec.y);
|
||||||
EditCurve[1].ProjToLine(EditCurve[2] - EditCurve[0], Tangent);
|
EditCurve[1].ProjectToLine(EditCurve[2] - EditCurve[0], Tangent);
|
||||||
if (EditCurve[1] * Tangent < 0) {
|
if (EditCurve[1] * Tangent < 0) {
|
||||||
EditCurve[1] = EditCurve[2];
|
EditCurve[1] = EditCurve[2];
|
||||||
suppressTransition = true;
|
suppressTransition = true;
|
||||||
|
@ -770,7 +770,7 @@ public:
|
||||||
else if (TransitionMode == TRANSITION_MODE_Perpendicular_L ||
|
else if (TransitionMode == TRANSITION_MODE_Perpendicular_L ||
|
||||||
TransitionMode == TRANSITION_MODE_Perpendicular_R) {
|
TransitionMode == TRANSITION_MODE_Perpendicular_R) {
|
||||||
Base::Vector2D Perpendicular(-dirVec.y,dirVec.x);
|
Base::Vector2D Perpendicular(-dirVec.y,dirVec.x);
|
||||||
EditCurve[1].ProjToLine(EditCurve[2] - EditCurve[0], Perpendicular);
|
EditCurve[1].ProjectToLine(EditCurve[2] - EditCurve[0], Perpendicular);
|
||||||
EditCurve[1] = EditCurve[0] + EditCurve[1];
|
EditCurve[1] = EditCurve[0] + EditCurve[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2452,7 +2452,7 @@ private:
|
||||||
Base::Vector2D cursor = Base::Vector2D(onSketchPos - f); // vector from f to cursor pos
|
Base::Vector2D cursor = Base::Vector2D(onSketchPos - f); // vector from f to cursor pos
|
||||||
// decompose cursor with a projection, then length of w_2 will give us b
|
// decompose cursor with a projection, then length of w_2 will give us b
|
||||||
Base::Vector2D w_1 = cursor;
|
Base::Vector2D w_1 = cursor;
|
||||||
w_1.ProjToLine(cursor, (periapsis - apoapsis)); // projection of cursor line onto apse line
|
w_1.ProjectToLine(cursor, (periapsis - apoapsis)); // projection of cursor line onto apse line
|
||||||
Base::Vector2D w_2 = (cursor - w_1);
|
Base::Vector2D w_2 = (cursor - w_1);
|
||||||
b = w_2.Length();
|
b = w_2.Length();
|
||||||
|
|
||||||
|
@ -2512,7 +2512,7 @@ private:
|
||||||
Base::Vector2D cursor = Base::Vector2D(onSketchPos - centroid); // vector from centroid to cursor pos
|
Base::Vector2D cursor = Base::Vector2D(onSketchPos - centroid); // vector from centroid to cursor pos
|
||||||
// decompose cursor with a projection, then length of w_2 will give us b
|
// decompose cursor with a projection, then length of w_2 will give us b
|
||||||
Base::Vector2D w_1 = cursor;
|
Base::Vector2D w_1 = cursor;
|
||||||
w_1.ProjToLine(cursor, (fixedAxis - centroid)); // projection of cursor line onto fixed axis line
|
w_1.ProjectToLine(cursor, (fixedAxis - centroid)); // projection of cursor line onto fixed axis line
|
||||||
Base::Vector2D w_2 = (cursor - w_1);
|
Base::Vector2D w_2 = (cursor - w_1);
|
||||||
if (w_2.Length() > fixedAxisLength) {
|
if (w_2.Length() > fixedAxisLength) {
|
||||||
// b is fixed, we are seeking a
|
// b is fixed, we are seeking a
|
||||||
|
|
|
@ -263,7 +263,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Base::Vector3d projPnt(0.f, 0.f, 0.f);
|
Base::Vector3d projPnt(0.f, 0.f, 0.f);
|
||||||
projPnt = projPnt.ProjToLine(center - tmpPos, tmpDir);
|
projPnt = projPnt.ProjectToLine(center - tmpPos, tmpDir);
|
||||||
double projDist = std::abs(projPnt.Length() - radius);
|
double projDist = std::abs(projPnt.Length() - radius);
|
||||||
|
|
||||||
// Find if nearest
|
// Find if nearest
|
||||||
|
@ -311,7 +311,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Base::Vector3d projPnt(0.f, 0.f, 0.f);
|
Base::Vector3d projPnt(0.f, 0.f, 0.f);
|
||||||
projPnt = projPnt.ProjToLine(center - tmpPos, tmpDir);
|
projPnt = projPnt.ProjectToLine(center - tmpPos, tmpDir);
|
||||||
double projDist = std::abs(projPnt.Length() - radius);
|
double projDist = std::abs(projPnt.Length() - radius);
|
||||||
|
|
||||||
if (projDist < tangDeviation) {
|
if (projDist < tangDeviation) {
|
||||||
|
|
|
@ -1204,7 +1204,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo
|
||||||
Base::Vector3d l2p1 = lineSeg->getStartPoint();
|
Base::Vector3d l2p1 = lineSeg->getStartPoint();
|
||||||
Base::Vector3d l2p2 = lineSeg->getEndPoint();
|
Base::Vector3d l2p2 = lineSeg->getEndPoint();
|
||||||
// calculate the projection of p1 onto line2
|
// calculate the projection of p1 onto line2
|
||||||
p2.ProjToLine(p1-l2p1, l2p2-l2p1);
|
p2.ProjectToLine(p1-l2p1, l2p2-l2p1);
|
||||||
p2 += p1;
|
p2 += p1;
|
||||||
} else
|
} else
|
||||||
return;
|
return;
|
||||||
|
@ -3516,7 +3516,7 @@ Restart:
|
||||||
Base::Vector3d l2p1 = lineSeg->getStartPoint();
|
Base::Vector3d l2p1 = lineSeg->getStartPoint();
|
||||||
Base::Vector3d l2p2 = lineSeg->getEndPoint();
|
Base::Vector3d l2p2 = lineSeg->getEndPoint();
|
||||||
// calculate the projection of p1 onto line2
|
// calculate the projection of p1 onto line2
|
||||||
pnt2.ProjToLine(pnt1-l2p1, l2p2-l2p1);
|
pnt2.ProjectToLine(pnt1-l2p1, l2p2-l2p1);
|
||||||
pnt2 += pnt1;
|
pnt2 += pnt1;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -164,7 +164,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||||
// Project each bounding box point onto projection plane and find larges u,v values
|
// Project each bounding box point onto projection plane and find larges u,v values
|
||||||
|
|
||||||
Base::Vector3d pnt = (*it);
|
Base::Vector3d pnt = (*it);
|
||||||
pnt.ProjToPlane(plnPnt, plnNorm);
|
pnt.ProjectToPlane(plnPnt, plnNorm);
|
||||||
|
|
||||||
uMax = std::max(uMax, std::abs(plnPnt[0] - pnt[0]));
|
uMax = std::max(uMax, std::abs(plnPnt[0] - pnt[0]));
|
||||||
vMax = std::max(vMax, std::abs(plnPnt[1] - pnt[1]));
|
vMax = std::max(vMax, std::abs(plnPnt[1] - pnt[1]));
|
||||||
|
|
|
@ -1190,8 +1190,8 @@ void QGIViewDimension::draw()
|
||||||
|
|
||||||
Base::Vector3d avg = (norm1 + norm2) / 2.;
|
Base::Vector3d avg = (norm1 + norm2) / 2.;
|
||||||
|
|
||||||
norm1 = norm1.ProjToLine(avg, norm1);
|
norm1 = norm1.ProjectToLine(avg, norm1);
|
||||||
norm2 = norm2.ProjToLine(avg, norm2);
|
norm2 = norm2.ProjectToLine(avg, norm2);
|
||||||
|
|
||||||
ar1->setPos(ar1Pos.x,ar1Pos.y );
|
ar1->setPos(ar1Pos.x,ar1Pos.y );
|
||||||
ar2->setPos(ar2Pos.x,ar2Pos.y );
|
ar2->setPos(ar2Pos.x,ar2Pos.y );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user