Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
younghang committed May 18, 2022
2 parents a21a5a2 + 10888e7 commit 18120f8
Show file tree
Hide file tree
Showing 28 changed files with 285 additions and 190 deletions.
8 changes: 4 additions & 4 deletions src/Gui/ExpressionCompleter.cpp
Expand Up @@ -488,7 +488,7 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos)
trim = prefixEnd - pos;

// Extract last tokens that can be rebuilt to a variable
ssize_t i = static_cast<ssize_t>(tokens.size()) - 1;
long i = static_cast<long>(tokens.size()) - 1;

// First, check if we have unclosing string starting from the end
bool stringing = false;
Expand All @@ -515,7 +515,7 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos)
}

if(!stringing) {
i = static_cast<ssize_t>(tokens.size()) - 1;
i = static_cast<long>(tokens.size()) - 1;
for(;i>=0;--i) {
int token = get<0>(tokens[i]);
if (token != '.' && token != '#' &&
Expand All @@ -529,13 +529,13 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos)
}

// Set prefix start for use when replacing later
if (i == static_cast<ssize_t>(tokens.size()))
if (i == static_cast<long>(tokens.size()))
prefixStart = prefixEnd;
else
prefixStart = start + get<1>(tokens[i]);

// Build prefix from tokens
while (i < static_cast<ssize_t>(tokens.size())) {
while (i < static_cast<long>(tokens.size())) {
completionPrefix += get<2>(tokens[i]);
++i;
}
Expand Down
9 changes: 2 additions & 7 deletions src/Mod/Draft/draftguitools/gui_fillets.py
Expand Up @@ -95,13 +95,8 @@ def Activated(self, name="Fillet"):
"Create chamfer"))
self.ui.check_chamfer.show()

# TODO: change to Qt5 style
QtCore.QObject.connect(self.ui.check_delete,
QtCore.SIGNAL("stateChanged(int)"),
self.set_delete)
QtCore.QObject.connect(self.ui.check_chamfer,
QtCore.SIGNAL("stateChanged(int)"),
self.set_chamfer)
self.ui.check_delete.stateChanged.connect(self.set_delete)
self.ui.check_chamfer.stateChanged.connect(self.set_chamfer)

# TODO: somehow we need to set up the trackers
# to show a preview of the fillet.
Expand Down
13 changes: 13 additions & 0 deletions src/Mod/Draft/draftguitools/gui_trackers.py
Expand Up @@ -1059,6 +1059,19 @@ def update(self):
"""Redraw the grid."""
# Resize the grid to make sure it fits
# an exact pair number of main lines
if self.space == 0:
self.lines1.numVertices.deleteValues(0)
self.lines2.numVertices.deleteValues(0)
FreeCAD.Console.PrintWarning("Draft Grid: Spacing value is zero\n")
return
if self.mainlines == 0:
self.lines1.numVertices.deleteValues(0)
self.lines2.numVertices.deleteValues(0)
return
if self.numlines == 0:
self.lines1.numVertices.deleteValues(0)
self.lines2.numVertices.deleteValues(0)
return
numlines = self.numlines // self.mainlines // 2 * 2 * self.mainlines
bound = (numlines // 2) * self.space
border = (numlines//2 + self.mainlines/2) * self.space
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Image/Gui/ViewProviderImagePlane.cpp
Expand Up @@ -23,7 +23,7 @@
#include "PreCompiled.h"

#ifndef _PreComp_
#include <sstream>
# include <sstream>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoFaceSet.h>
# include <Inventor/nodes/SoMaterial.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Mesh/App/AppMeshPy.cpp
Expand Up @@ -244,7 +244,7 @@ class Module : public Py::ExtensionModule<Module>

// collect all object types that can be exported as mesh
std::vector<App::DocumentObject*> objectList;
for (auto it : list) {
for (const auto& it : list) {
PyObject *item = it.ptr();
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
auto obj( static_cast<App::DocumentObjectPy *>(item)->getDocumentObjectPtr() );
Expand Down
11 changes: 7 additions & 4 deletions src/Mod/Mesh/App/Core/Builder.cpp
Expand Up @@ -275,11 +275,14 @@ struct MeshFastBuilder::Private {
}
bool operator<(const Vertex& rhs) const
{
if (x != rhs.x)
if (x != rhs.x)
return x < rhs.x;
else if (y != rhs.y) return y < rhs.y;
else if (z != rhs.z) return z < rhs.z;
else return false;
else if (y != rhs.y)
return y < rhs.y;
else if (z != rhs.z)
return z < rhs.z;
else
return false;
}
};

Expand Down
23 changes: 12 additions & 11 deletions src/Mod/Mesh/App/Core/Degeneration.cpp
Expand Up @@ -301,13 +301,18 @@ struct MeshFacet_Less
if (y1 > y2)
{ tmp = y1; y1 = y2; y2 = tmp; }

if (x0 < y0)
if (x0 < y0)
return true;
else if (x0 > y0) return false;
else if (x1 < y1) return true;
else if (x1 > y1) return false;
else if (x2 < y2) return true;
else return false;
else if (x0 > y0)
return false;
else if (x1 < y1)
return true;
else if (x1 > y1)
return false;
else if (x2 < y2)
return true;
else
return false;
}
};

Expand Down Expand Up @@ -1104,12 +1109,8 @@ bool MeshFixRangePoint::Fixup()
// 'DeleteFacets' will segfault. But setting all point indices to 0 works.
std::vector<PointIndex> invalid = eval.GetIndices();
if (!invalid.empty()) {
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
for (std::vector<PointIndex>::iterator it = invalid.begin(); it != invalid.end(); ++it) {
MeshFacet& face = const_cast<MeshFacet&>(rFaces[*it]);
face._aulPoints[0] = 0;
face._aulPoints[1] = 0;
face._aulPoints[2] = 0;
_rclMesh.SetFacetPoints(*it, 0, 0, 0);
}

_rclMesh.DeleteFacets(invalid);
Expand Down
30 changes: 15 additions & 15 deletions src/Mod/Mesh/App/Core/Elements.h
Expand Up @@ -121,9 +121,9 @@ class MeshExport MeshPoint: public Base::Vector3f
*/
//@{
void SetFlag (TFlagType tF) const
{ const_cast<MeshPoint*>(this)->_ucFlag |= static_cast<unsigned char>(tF); }
{ _ucFlag |= static_cast<unsigned char>(tF); }
void ResetFlag (TFlagType tF) const
{ const_cast<MeshPoint*>(this)->_ucFlag &= ~static_cast<unsigned char>(tF); }
{ _ucFlag &= ~static_cast<unsigned char>(tF); }
bool IsFlag (TFlagType tF) const
{ return (_ucFlag & static_cast<unsigned char>(tF)) == static_cast<unsigned char>(tF); }
void ResetInvalid () const
Expand All @@ -133,7 +133,7 @@ class MeshExport MeshPoint: public Base::Vector3f
bool IsValid () const
{ return !IsFlag(INVALID); }
void SetProperty(unsigned long uP) const
{ const_cast<MeshPoint*>(this)->_ulProp = uP; }
{ _ulProp = uP; }
//@}

// Assignment
Expand All @@ -145,8 +145,8 @@ class MeshExport MeshPoint: public Base::Vector3f
inline bool operator < (const MeshPoint &rclPt) const;

public:
unsigned char _ucFlag; /**< Flag member */
unsigned long _ulProp; /**< Free usable property */
mutable unsigned char _ucFlag; /**< Flag member */
mutable unsigned long _ulProp; /**< Free usable property */
};

/**
Expand Down Expand Up @@ -250,15 +250,15 @@ class MeshFacet
*/
//@{
void SetFlag (TFlagType tF) const
{ const_cast<MeshFacet*>(this)->_ucFlag |= static_cast<unsigned char>(tF); }
{ _ucFlag |= static_cast<unsigned char>(tF); }
void ResetFlag (TFlagType tF) const
{ const_cast<MeshFacet*>(this)->_ucFlag &= ~static_cast<unsigned char>(tF); }
{ _ucFlag &= ~static_cast<unsigned char>(tF); }
bool IsFlag (TFlagType tF) const
{ return (_ucFlag & static_cast<unsigned char>(tF)) == static_cast<unsigned char>(tF); }
void ResetInvalid () const
{ ResetFlag(INVALID); }
void SetProperty(unsigned long uP) const
{ const_cast<MeshFacet*>(this)->_ulProp = uP; }
{ _ulProp = uP; }
/**
* Marks a facet as invalid. Should be used only temporary from within an algorithm
* (e.g. deletion of several facets) but must not be set permanently.
Expand Down Expand Up @@ -346,8 +346,8 @@ class MeshFacet
}

public:
unsigned char _ucFlag; /**< Flag member. */
unsigned long _ulProp; /**< Free usable property. */
mutable unsigned char _ucFlag; /**< Flag member. */
mutable unsigned long _ulProp; /**< Free usable property. */
PointIndex _aulPoints[3]; /**< Indices of corner points. */
FacetIndex _aulNeighbours[3]; /**< Indices of neighbour facets. */
};
Expand Down Expand Up @@ -427,7 +427,7 @@ class MeshExport MeshGeomFacet
/**
* Calculates the facet normal for storing internally.
*/
inline void CalcNormal ();
inline void CalcNormal () const;
/**
* Arrange the facet normal so the both vectors have the same orientation.
*/
Expand Down Expand Up @@ -552,8 +552,8 @@ class MeshExport MeshGeomFacet
bool IsCoplanar(const MeshGeomFacet &facet) const;

protected:
Base::Vector3f _clNormal; /**< Normal of the facet. */
bool _bNormalCalculated; /**< True if the normal is already calculated. */
mutable Base::Vector3f _clNormal; /**< Normal of the facet. */
mutable bool _bNormalCalculated; /**< True if the normal is already calculated. */

public:
Base::Vector3f _aclPoints[3]; /**< Geometric corner points. */
Expand Down Expand Up @@ -795,7 +795,7 @@ inline float MeshGeomFacet::DistancePlaneToPoint (const Base::Vector3f &rclPoint
return float(fabs(rclPoint.DistanceToPlane(_aclPoints[0], GetNormal())));
}

inline void MeshGeomFacet::CalcNormal ()
inline void MeshGeomFacet::CalcNormal () const
{
_clNormal = (_aclPoints[1] - _aclPoints[0]) % (_aclPoints[2] - _aclPoints[0]);
_clNormal.Normalize();
Expand All @@ -805,7 +805,7 @@ inline void MeshGeomFacet::CalcNormal ()
inline Base::Vector3f MeshGeomFacet::GetNormal () const
{
if (_bNormalCalculated == false)
const_cast<MeshGeomFacet*>(this)->CalcNormal();
CalcNormal();
return _clNormal;
}

Expand Down
9 changes: 5 additions & 4 deletions src/Mod/Mesh/App/Core/Iterator.h
Expand Up @@ -259,7 +259,7 @@ class MeshExport MeshPointIterator
protected:
const MeshKernel& _rclMesh;
const MeshPointArray& _rclPAry;
MeshPoint _clPoint;
mutable MeshPoint _clPoint;
MeshPointArray::_TConstIterator _clIter;
bool _bApply;
Base::Matrix4D _clTrf;
Expand Down Expand Up @@ -443,10 +443,11 @@ inline void MeshPointIterator::Transform( const Base::Matrix4D& rclTrf )
}

inline const MeshPoint& MeshPointIterator::Dereference () const
{ // We change only the value of the point but not the actual iterator
const_cast<MeshPointIterator*>(this)->_clPoint = *_clIter;
{
// We change only the value of the point but not the actual iterator
_clPoint = *_clIter;
if ( _bApply )
const_cast<MeshPointIterator*>(this)->_clPoint = _clTrf * _clPoint;
_clPoint = _clTrf * _clPoint;
return _clPoint;
}

Expand Down
10 changes: 10 additions & 0 deletions src/Mod/Mesh/App/Core/KDTree.cpp
Expand Up @@ -45,6 +45,10 @@ struct Point3d
{
}

Point3d(Point3d&& pnt) : p(pnt.p), i(pnt.i)
{
}

~Point3d()
{
}
Expand All @@ -70,6 +74,12 @@ struct Point3d
this->i = other.i;
}

inline void operator=(Point3d&& other)
{
this->p = other.p;
this->i = other.i;
}

Base::Vector3f p;
PointIndex i;
};
Expand Down

0 comments on commit 18120f8

Please sign in to comment.