Merge branch 'master' into master
This commit is contained in:
@@ -95,13 +95,8 @@ class Fillet(gui_base_original.Creator):
|
||||
"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.
|
||||
|
||||
@@ -1059,6 +1059,19 @@ class gridTracker(Tracker):
|
||||
"""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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -244,7 +244,7 @@ private:
|
||||
|
||||
// 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() );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -121,9 +121,9 @@ public:
|
||||
*/
|
||||
//@{
|
||||
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
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
bool IsValid () const
|
||||
{ return !IsFlag(INVALID); }
|
||||
void SetProperty(unsigned long uP) const
|
||||
{ const_cast<MeshPoint*>(this)->_ulProp = uP; }
|
||||
{ _ulProp = uP; }
|
||||
//@}
|
||||
|
||||
// Assignment
|
||||
@@ -145,8 +145,8 @@ public:
|
||||
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 */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -250,15 +250,15 @@ public:
|
||||
*/
|
||||
//@{
|
||||
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.
|
||||
@@ -346,8 +346,8 @@ public:
|
||||
}
|
||||
|
||||
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. */
|
||||
};
|
||||
@@ -427,7 +427,7 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -552,8 +552,8 @@ public:
|
||||
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. */
|
||||
@@ -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();
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ protected:
|
||||
protected:
|
||||
const MeshKernel& _rclMesh;
|
||||
const MeshPointArray& _rclPAry;
|
||||
MeshPoint _clPoint;
|
||||
mutable MeshPoint _clPoint;
|
||||
MeshPointArray::_TConstIterator _clIter;
|
||||
bool _bApply;
|
||||
Base::Matrix4D _clTrf;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,10 @@ struct Point3d
|
||||
{
|
||||
}
|
||||
|
||||
Point3d(Point3d&& pnt) : p(pnt.p), i(pnt.i)
|
||||
{
|
||||
}
|
||||
|
||||
~Point3d()
|
||||
{
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -57,39 +57,7 @@
|
||||
|
||||
using namespace MeshCore;
|
||||
|
||||
char *upper(char * string)
|
||||
{
|
||||
int i;
|
||||
int l;
|
||||
|
||||
if (string != nullptr) {
|
||||
l = std::strlen(string);
|
||||
for (i=0; i<l; i++)
|
||||
string[i] = toupper(string[i]);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
char *ltrim (char *psz)
|
||||
{
|
||||
int i, sl;
|
||||
|
||||
if (psz) {
|
||||
for (i = 0; (psz[i] == 0x20) || (psz[i] == 0x09); i++);
|
||||
sl = std::strlen (psz + i);
|
||||
memmove (psz, psz + i, sl);
|
||||
psz[sl] = 0;
|
||||
}
|
||||
return psz;
|
||||
}
|
||||
|
||||
std::string& upper(std::string& str)
|
||||
{
|
||||
for (std::string::iterator it = str.begin(); it != str.end(); ++it)
|
||||
*it = toupper(*it);
|
||||
return str;
|
||||
}
|
||||
namespace MeshCore {
|
||||
|
||||
std::string& ltrim(std::string& str)
|
||||
{
|
||||
@@ -121,8 +89,6 @@ struct NODE {float x, y, z;};
|
||||
struct TRIA {int iV[3];};
|
||||
struct QUAD {int iV[4];};
|
||||
|
||||
namespace MeshCore {
|
||||
|
||||
struct Color_Less
|
||||
{
|
||||
bool operator()(const App::Color& x,
|
||||
@@ -157,6 +123,35 @@ std::vector<std::string> MeshInput::supportedMeshFormats()
|
||||
return fmt;
|
||||
}
|
||||
|
||||
MeshIO::Format MeshInput::getFormat(const char* FileName)
|
||||
{
|
||||
Base::FileInfo fi(FileName);
|
||||
if (fi.hasExtension("bms")) {
|
||||
return MeshIO::Format::BMS;
|
||||
}
|
||||
else if (fi.hasExtension("ply")) {
|
||||
return MeshIO::Format::PLY;
|
||||
}
|
||||
else if (fi.hasExtension("stl")) {
|
||||
return MeshIO::Format::STL;
|
||||
}
|
||||
else if (fi.hasExtension("ast")) {
|
||||
return MeshIO::Format::ASTL;
|
||||
}
|
||||
else if (fi.hasExtension("obj")) {
|
||||
return MeshIO::Format::OBJ;
|
||||
}
|
||||
else if (fi.hasExtension("off")) {
|
||||
return MeshIO::Format::OFF;
|
||||
}
|
||||
else if (fi.hasExtension("smf")) {
|
||||
return MeshIO::Format::SMF;
|
||||
}
|
||||
else {
|
||||
throw Base::FileException("File extension not supported",FileName);
|
||||
}
|
||||
}
|
||||
|
||||
bool MeshInput::LoadAny(const char* FileName)
|
||||
{
|
||||
// ask for read permission
|
||||
@@ -219,6 +214,8 @@ bool MeshInput::LoadFormat(std::istream &str, MeshIO::Format fmt)
|
||||
return LoadAsciiSTL(str);
|
||||
case MeshIO::BSTL:
|
||||
return LoadBinarySTL(str);
|
||||
case MeshIO::STL:
|
||||
return LoadSTL(str);
|
||||
case MeshIO::OBJ:
|
||||
return LoadOBJ(str);
|
||||
case MeshIO::SMF:
|
||||
@@ -262,7 +259,7 @@ bool MeshInput::LoadSTL (std::istream &rstrIn)
|
||||
if (!rstrIn.read(szBuf, ulBytes))
|
||||
return (ulCt==0);
|
||||
szBuf[ulBytes] = 0;
|
||||
upper(szBuf);
|
||||
boost::algorithm::to_upper(szBuf);
|
||||
|
||||
try {
|
||||
if ((strstr(szBuf, "SOLID") == nullptr) && (strstr(szBuf, "FACET") == nullptr) && (strstr(szBuf, "NORMAL") == nullptr) &&
|
||||
@@ -300,7 +297,7 @@ bool MeshInput::LoadSTL (std::istream &rstrIn)
|
||||
/** Loads an OBJ file. */
|
||||
bool MeshInput::LoadOBJ (std::istream &rstrIn)
|
||||
{
|
||||
boost::regex rx_m("^mtllib\\s+([\\x21-\\x7E]+)\\s*$");
|
||||
boost::regex rx_m("^mtllib\\s+(.+)\\s*$");
|
||||
boost::regex rx_u("^usemtl\\s+([\\x21-\\x7E]+)\\s*$");
|
||||
boost::regex rx_g("^g\\s+([\\x21-\\x7E]+)\\s*$");
|
||||
boost::regex rx_p("^v\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||
@@ -1343,8 +1340,7 @@ bool MeshInput::LoadAsciiSTL (std::istream &rstrIn)
|
||||
|
||||
// count facets
|
||||
while (std::getline(rstrIn, line)) {
|
||||
for (std::string::iterator it = line.begin(); it != line.end(); ++it)
|
||||
*it = toupper(*it);
|
||||
boost::algorithm::to_upper(line);
|
||||
if (line.find("ENDFACET") != std::string::npos)
|
||||
ulFacetCt++;
|
||||
// prevent from reading EOF (as I don't know how to reread the file then)
|
||||
@@ -1366,8 +1362,7 @@ bool MeshInput::LoadAsciiSTL (std::istream &rstrIn)
|
||||
|
||||
ulVertexCt = 0;
|
||||
while (std::getline(rstrIn, line)) {
|
||||
for (std::string::iterator it = line.begin(); it != line.end(); ++it)
|
||||
*it = toupper(*it);
|
||||
boost::algorithm::to_upper(line);
|
||||
if (boost::regex_match(line.c_str(), what, rx_f)) {
|
||||
fX = (float)std::atof(what[1].first);
|
||||
fY = (float)std::atof(what[4].first);
|
||||
@@ -1527,8 +1522,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn)
|
||||
bool points = false;
|
||||
bool facets = false;
|
||||
while (std::getline(rstrIn, line) && !facets) {
|
||||
for (std::string::iterator it = line.begin(); it != line.end(); ++it)
|
||||
*it = toupper(*it);
|
||||
boost::algorithm::to_upper(line);
|
||||
|
||||
// read the normals if they are defined
|
||||
if (!normals && line.find("NORMAL {") != std::string::npos) {
|
||||
@@ -1540,8 +1534,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn)
|
||||
// This is a special case to support also file formats directly written by
|
||||
// Inventor 2.1 classes.
|
||||
std::getline(rstrIn, line);
|
||||
for (std::string::iterator it = line.begin(); it != line.end(); ++it)
|
||||
*it = toupper(*it);
|
||||
boost::algorithm::to_upper(line);
|
||||
std::string::size_type pos = line.find("VECTOR [");
|
||||
if (pos != std::string::npos)
|
||||
line = line.substr(pos+8); // 8 = length of 'VECTOR ['
|
||||
@@ -1567,8 +1560,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn)
|
||||
// This is a special case to support also file formats directly written by
|
||||
// Inventor 2.1 classes.
|
||||
std::getline(rstrIn, line);
|
||||
for (std::string::iterator it = line.begin(); it != line.end(); ++it)
|
||||
*it = toupper(*it);
|
||||
boost::algorithm::to_upper(line);
|
||||
std::string::size_type pos = line.find("POINT [");
|
||||
if (pos != std::string::npos)
|
||||
line = line.substr(pos+7); // 7 = length of 'POINT ['
|
||||
@@ -1595,8 +1587,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn)
|
||||
// Furthermore we must check whether more than one triple is given per line, which
|
||||
// is handled in the while-loop.
|
||||
std::getline(rstrIn, line);
|
||||
for (std::string::iterator it = line.begin(); it != line.end(); ++it)
|
||||
*it = toupper(*it);
|
||||
boost::algorithm::to_upper(line);
|
||||
std::string::size_type pos = line.find("COORDINDEX [");
|
||||
if (pos != std::string::npos)
|
||||
line = line.substr(pos+12); // 12 = length of 'COORDINDEX ['
|
||||
@@ -1660,7 +1651,7 @@ bool MeshInput::LoadNastran (std::istream &rstrIn)
|
||||
int badElementCounter = 0;
|
||||
|
||||
while (std::getline(rstrIn, line)) {
|
||||
upper(ltrim(line));
|
||||
boost::algorithm::to_upper(ltrim(line));
|
||||
if (line.empty()) {
|
||||
// Skip all the following tests
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace MeshIO {
|
||||
BMS,
|
||||
ASTL,
|
||||
BSTL,
|
||||
STL,
|
||||
OBJ,
|
||||
OFF,
|
||||
IDTF,
|
||||
@@ -74,7 +75,7 @@ struct MeshExport Material
|
||||
{
|
||||
Material() : binding(MeshIO::OVERALL) {}
|
||||
MeshIO::Binding binding;
|
||||
std::string library;
|
||||
mutable std::string library;
|
||||
std::vector<App::Color> diffuseColor;
|
||||
};
|
||||
|
||||
@@ -134,6 +135,7 @@ public:
|
||||
bool LoadCadmouldFE (std::ifstream &rstrIn);
|
||||
|
||||
static std::vector<std::string> supportedMeshFormats();
|
||||
static MeshIO::Format getFormat(const char* FileName);
|
||||
|
||||
protected:
|
||||
MeshKernel &_rclMesh; /**< reference to mesh data structure */
|
||||
|
||||
@@ -1053,7 +1053,7 @@ void MeshKernel::Smooth(int iterations, float stepsize)
|
||||
LaplaceSmoothing(*this).Smooth(iterations);
|
||||
}
|
||||
|
||||
void MeshKernel::RecalcBoundBox ()
|
||||
void MeshKernel::RecalcBoundBox () const
|
||||
{
|
||||
_clBoundBox.SetVoid();
|
||||
for (MeshPointArray::_TConstIterator pI = _aclPointArray.begin(); pI != _aclPointArray.end(); pI++)
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
/** Forces a recalculation of the bounding box. This method should be called after
|
||||
* the removal of points.or after a transformation of the data structure.
|
||||
*/
|
||||
void RecalcBoundBox ();
|
||||
void RecalcBoundBox () const;
|
||||
|
||||
/** Returns the point at the given index. This method is rather slow and should be
|
||||
* called occasionally only. For fast access the MeshPointIterator interfsce should
|
||||
@@ -124,6 +124,9 @@ public:
|
||||
/** Returns the point indices of the given facet index. */
|
||||
inline void GetFacetPoints (FacetIndex ulFaIndex, PointIndex &rclP0,
|
||||
PointIndex &rclP1, PointIndex &rclP2) const;
|
||||
/** Returns the point indices of the given facet index. */
|
||||
inline void SetFacetPoints (FacetIndex ulFaIndex, PointIndex rclP0,
|
||||
PointIndex rclP1, PointIndex rclP2);
|
||||
/** Returns the point indices of the given facet indices. */
|
||||
std::vector<PointIndex> GetFacetPoints(const std::vector<FacetIndex>&) const;
|
||||
/** Returns the facet indices that share the given point indices. */
|
||||
@@ -446,7 +449,7 @@ protected:
|
||||
|
||||
MeshPointArray _aclPointArray; /**< Holds the array of geometric points. */
|
||||
MeshFacetArray _aclFacetArray; /**< Holds the array of facets. */
|
||||
Base::BoundBox3f _clBoundBox; /**< The current calculated bounding box. */
|
||||
mutable Base::BoundBox3f _clBoundBox; /**< The current calculated bounding box. */
|
||||
bool _bValid; /**< Current state of validality. */
|
||||
|
||||
// friends
|
||||
@@ -555,9 +558,19 @@ inline void MeshKernel::GetFacetPoints (FacetIndex ulFaIndex, PointIndex &rclP0,
|
||||
{
|
||||
assert(ulFaIndex < _aclFacetArray.size());
|
||||
const MeshFacet& rclFacet = _aclFacetArray[ulFaIndex];
|
||||
rclP0 = rclFacet._aulPoints[0];
|
||||
rclP1 = rclFacet._aulPoints[1];
|
||||
rclP2 = rclFacet._aulPoints[2];
|
||||
rclP0 = rclFacet._aulPoints[0];
|
||||
rclP1 = rclFacet._aulPoints[1];
|
||||
rclP2 = rclFacet._aulPoints[2];
|
||||
}
|
||||
|
||||
inline void MeshKernel::SetFacetPoints (FacetIndex ulFaIndex, PointIndex rclP0,
|
||||
PointIndex rclP1, PointIndex rclP2)
|
||||
{
|
||||
assert(ulFaIndex < _aclFacetArray.size());
|
||||
MeshFacet& rclFacet = _aclFacetArray[ulFaIndex];
|
||||
rclFacet._aulPoints[0] = rclP0;
|
||||
rclFacet._aulPoints[1] = rclP1;
|
||||
rclFacet._aulPoints[2] = rclP2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -606,10 +606,16 @@ struct Vertex2d_Less
|
||||
bool operator()(const Base::Vector3f& p, const Base::Vector3f& q) const
|
||||
{
|
||||
if (fabs(p.x - q.x) < MeshDefinitions::_fMinPointDistanceD1) {
|
||||
if (fabs(p.y - q.y) < MeshDefinitions::_fMinPointDistanceD1) {
|
||||
return false;
|
||||
} else return p.y < q.y;
|
||||
} else return p.x < q.x;
|
||||
if (fabs(p.y - q.y) < MeshDefinitions::_fMinPointDistanceD1) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return p.y < q.y;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return p.x < q.x;
|
||||
}
|
||||
}
|
||||
};
|
||||
struct Vertex2d_EqualTo
|
||||
|
||||
@@ -107,7 +107,7 @@ bool DlgSmoothing::smoothSelection() const
|
||||
|
||||
void DlgSmoothing::on_checkBoxSelection_toggled(bool on)
|
||||
{
|
||||
/*emit*/ toggledSelection(on);
|
||||
Q_EMIT toggledSelection(on);
|
||||
}
|
||||
|
||||
// ------------------------------------------------
|
||||
|
||||
@@ -342,9 +342,9 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp)
|
||||
|
||||
void MeshFaceAddition::addFacetCallback(void * ud, SoEventCallback * n)
|
||||
{
|
||||
MeshFaceAddition* that = reinterpret_cast<MeshFaceAddition*>(ud);
|
||||
MeshFaceAddition* that = static_cast<MeshFaceAddition*>(ud);
|
||||
ViewProviderFace* face = that->faceView;
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
|
||||
const SoEvent* ev = n->getEvent();
|
||||
// If we are in navigation mode then ignore all but key events
|
||||
@@ -653,8 +653,8 @@ float MeshFillHole::findClosestPoint(const SbLine& ray, const TBoundary& polygon
|
||||
|
||||
void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
|
||||
{
|
||||
MeshFillHole* self = reinterpret_cast<MeshFillHole*>(ud);
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
MeshFillHole* self = static_cast<MeshFillHole*>(ud);
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
|
||||
const SoEvent* ev = n->getEvent();
|
||||
if (ev->getTypeId() == SoLocation2Event::getClassTypeId()) {
|
||||
|
||||
@@ -453,8 +453,8 @@ void MeshSelection::setRemoveComponentOnClick(bool on)
|
||||
void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
|
||||
{
|
||||
// When this callback function is invoked we must leave the edit mode
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
MeshSelection* self = reinterpret_cast<MeshSelection*>(ud);
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
MeshSelection* self = static_cast<MeshSelection*>(ud);
|
||||
self->stopInteractiveCallback(view);
|
||||
n->setHandled();
|
||||
std::vector<SbVec2f> polygon = view->getGLPolygon();
|
||||
@@ -534,7 +534,7 @@ void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n)
|
||||
// handle only mouse button events
|
||||
if (n->getEvent()->isOfType(SoMouseButtonEvent::getClassTypeId())) {
|
||||
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent*>(n->getEvent());
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
|
||||
n->getAction()->setHandled();
|
||||
@@ -553,7 +553,7 @@ void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n)
|
||||
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId()))
|
||||
return;
|
||||
ViewProviderMesh* mesh = static_cast<ViewProviderMesh*>(vp);
|
||||
MeshSelection* self = reinterpret_cast<MeshSelection*>(ud);
|
||||
MeshSelection* self = static_cast<MeshSelection*>(ud);
|
||||
std::list<ViewProviderMesh*> views = self->getViewProviders();
|
||||
if (std::find(views.begin(), views.end(), mesh) == views.end())
|
||||
return;
|
||||
|
||||
@@ -741,14 +741,20 @@ void ViewProviderMesh::setupContextMenu(QMenu* menu, QObject* receiver, const ch
|
||||
QAction* act = menu->addAction(QObject::tr("Display components"));
|
||||
act->setCheckable(true);
|
||||
act->setChecked(pcMatBinding->value.getValue() == SoMaterialBinding::PER_FACE &&
|
||||
highlightMode == "Component");
|
||||
highlightMode == HighlighMode::Component);
|
||||
func->toggle(act, boost::bind(&ViewProviderMesh::setHighlightedComponents, this, bp::_1));
|
||||
|
||||
QAction* seg = menu->addAction(QObject::tr("Display segments"));
|
||||
seg->setCheckable(true);
|
||||
seg->setChecked(pcMatBinding->value.getValue() == SoMaterialBinding::PER_FACE &&
|
||||
highlightMode == "Segment");
|
||||
highlightMode == HighlighMode::Segment);
|
||||
func->toggle(seg, boost::bind(&ViewProviderMesh::setHighlightedSegments, this, bp::_1));
|
||||
|
||||
QAction* col = menu->addAction(QObject::tr("Display colors"));
|
||||
col->setVisible(canHighlightColors());
|
||||
col->setCheckable(true);
|
||||
col->setChecked(highlightMode == HighlighMode::Color);
|
||||
func->toggle(col, boost::bind(&ViewProviderMesh::setHighlightedColors, this, bp::_1));
|
||||
}
|
||||
|
||||
bool ViewProviderMesh::setEdit(int ModNum)
|
||||
@@ -913,7 +919,7 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n)
|
||||
Gui::WaitCursor wc;
|
||||
|
||||
// When this callback function is invoked we must in either case leave the edit mode
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
view->setEditing(false);
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), clipMeshCallback,ud);
|
||||
n->setHandled();
|
||||
@@ -974,7 +980,7 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n)
|
||||
Gui::WaitCursor wc;
|
||||
|
||||
// When this callback function is invoked we must in either case leave the edit mode
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
view->setEditing(false);
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), trimMeshCallback,ud);
|
||||
n->setHandled();
|
||||
@@ -1035,7 +1041,7 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb)
|
||||
Gui::WaitCursor wc;
|
||||
|
||||
// When this callback function is invoked we must in either case leave the edit mode
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(cb->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(cb->getUserData());
|
||||
view->setEditing(false);
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), partMeshCallback,ud);
|
||||
cb->setHandled();
|
||||
@@ -1099,7 +1105,7 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb)
|
||||
Gui::WaitCursor wc;
|
||||
|
||||
// When this callback function is invoked we must in either case leave the edit mode
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(cb->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(cb->getUserData());
|
||||
view->setEditing(false);
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), segmMeshCallback,ud);
|
||||
cb->setHandled();
|
||||
@@ -1160,7 +1166,7 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb)
|
||||
void ViewProviderMesh::selectGLCallback(void * ud, SoEventCallback * n)
|
||||
{
|
||||
// When this callback function is invoked we must in either case leave the edit mode
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
view->setEditing(false);
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectGLCallback,ud);
|
||||
n->setHandled();
|
||||
@@ -1332,7 +1338,7 @@ std::vector<Mesh::FacetIndex> ViewProviderMesh::getVisibleFacetsAfterZoom(const
|
||||
void ViewProviderMesh::renderGLCallback(void * ud, SoAction * action)
|
||||
{
|
||||
if (action->isOfType(SoGLRenderAction::getClassTypeId())) {
|
||||
ViewProviderMesh* mesh = reinterpret_cast<ViewProviderMesh*>(ud);
|
||||
ViewProviderMesh* mesh = static_cast<ViewProviderMesh*>(ud);
|
||||
Gui::SoVisibleFaceAction fa;
|
||||
fa.apply(mesh->getRoot());
|
||||
}
|
||||
@@ -1411,11 +1417,6 @@ std::vector<Mesh::FacetIndex> ViewProviderMesh::getVisibleFacets(const SbViewpor
|
||||
root->ref();
|
||||
root->addChild(camera);
|
||||
|
||||
#if 0
|
||||
SoCallback* cb = new SoCallback;
|
||||
cb->setCallback(renderGLCallback, const_cast<ViewProviderMesh*>(this));
|
||||
root->addChild(cb);
|
||||
#else
|
||||
SoLightModel* lm = new SoLightModel();
|
||||
lm->model = SoLightModel::BASE_COLOR;
|
||||
root->addChild(lm);
|
||||
@@ -1438,20 +1439,13 @@ std::vector<Mesh::FacetIndex> ViewProviderMesh::getVisibleFacets(const SbViewpor
|
||||
//root->addChild(hints);
|
||||
root->addChild(mat);
|
||||
root->addChild(bind);
|
||||
#endif
|
||||
root->addChild(this->getCoordNode());
|
||||
root->addChild(this->getShapeNode());
|
||||
|
||||
// Coin3d's off-screen renderer doesn't work out-of-the-box any more on most recent Linux systems.
|
||||
// So, use FreeCAD's offscreen renderer now.
|
||||
#if 0
|
||||
Gui::SoFCOffscreenRenderer& renderer = Gui::SoFCOffscreenRenderer::instance();
|
||||
renderer.setViewportRegion(vp);
|
||||
renderer.setBackgroundColor(SbColor(0.0f, 0.0f, 0.0f));
|
||||
#else
|
||||
Gui::SoQtOffscreenRenderer renderer(vp);
|
||||
renderer.setBackgroundColor(SbColor4f(0.0f, 0.0f, 0.0f));
|
||||
#endif
|
||||
|
||||
QImage img;
|
||||
renderer.render(root);
|
||||
@@ -1569,7 +1563,7 @@ void ViewProviderMesh::segmentMesh(const MeshCore::MeshKernel& toolMesh, const B
|
||||
void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n)
|
||||
{
|
||||
const SoMouseButtonEvent * mbe = (SoMouseButtonEvent *)n->getEvent();
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
|
||||
n->getAction()->setHandled();
|
||||
@@ -1651,7 +1645,7 @@ void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n)
|
||||
void ViewProviderMesh::fillHoleCallback(void * ud, SoEventCallback * n)
|
||||
{
|
||||
const SoMouseButtonEvent * mbe = (SoMouseButtonEvent *)n->getEvent();
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
|
||||
n->getAction()->setHandled();
|
||||
@@ -1697,7 +1691,7 @@ void ViewProviderMesh::markPartCallback(void * ud, SoEventCallback * n)
|
||||
// handle only mouse button events
|
||||
if (n->getEvent()->isOfType(SoMouseButtonEvent::getClassTypeId())) {
|
||||
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent*>(n->getEvent());
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
|
||||
n->getAction()->setHandled();
|
||||
@@ -1786,7 +1780,7 @@ void ViewProviderMesh::fillHole(Mesh::FacetIndex uFacet)
|
||||
|
||||
// get the boundary to the picked facet
|
||||
std::list<Mesh::PointIndex> aBorder;
|
||||
Mesh::Feature* fea = reinterpret_cast<Mesh::Feature*>(this->getObject());
|
||||
Mesh::Feature* fea = static_cast<Mesh::Feature*>(this->getObject());
|
||||
const MeshCore::MeshKernel& rKernel = fea->Mesh.getValue().getKernel();
|
||||
MeshCore::MeshRefPointToFacets cPt2Fac(rKernel);
|
||||
MeshCore::MeshAlgorithm meshAlg(rKernel);
|
||||
@@ -2148,11 +2142,11 @@ void ViewProviderMesh::unhighlightSelection()
|
||||
void ViewProviderMesh::setHighlightedComponents(bool on)
|
||||
{
|
||||
if (on) {
|
||||
highlightMode = "Component";
|
||||
highlightMode = HighlighMode::Component;
|
||||
highlightComponents();
|
||||
}
|
||||
else {
|
||||
highlightMode.clear();
|
||||
highlightMode = HighlighMode::None;
|
||||
unhighlightSelection();
|
||||
}
|
||||
}
|
||||
@@ -2183,11 +2177,11 @@ void ViewProviderMesh::highlightComponents()
|
||||
void ViewProviderMesh::setHighlightedSegments(bool on)
|
||||
{
|
||||
if (on) {
|
||||
highlightMode = "Segment";
|
||||
highlightMode = HighlighMode::Segment;
|
||||
highlightSegments();
|
||||
}
|
||||
else {
|
||||
highlightMode.clear();
|
||||
highlightMode = HighlighMode::None;
|
||||
unhighlightSelection();
|
||||
}
|
||||
}
|
||||
@@ -2239,6 +2233,52 @@ void ViewProviderMesh::highlightSegments(const std::vector<App::Color>& colors)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderMesh::setHighlightedColors(bool on)
|
||||
{
|
||||
if (on) {
|
||||
highlightMode = HighlighMode::Color;
|
||||
highlightColors();
|
||||
}
|
||||
else {
|
||||
highlightMode = HighlighMode::None;
|
||||
unhighlightSelection();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderMesh::highlightColors()
|
||||
{
|
||||
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
|
||||
{
|
||||
App::PropertyColorList* prop = Base::freecad_dynamic_cast<App::PropertyColorList>(pcObject->getPropertyByName("FaceColors"));
|
||||
if (prop && prop->getSize() == int(rMesh.countFacets())) {
|
||||
setColorPerFace(prop);
|
||||
}
|
||||
}
|
||||
{
|
||||
App::PropertyColorList* prop = Base::freecad_dynamic_cast<App::PropertyColorList>(pcObject->getPropertyByName("VertexColors"));
|
||||
if (prop && prop->getSize() == int(rMesh.countPoints())) {
|
||||
setColorPerVertex(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderMesh::canHighlightColors() const
|
||||
{
|
||||
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
|
||||
{
|
||||
App::PropertyColorList* prop = Base::freecad_dynamic_cast<App::PropertyColorList>(pcObject->getPropertyByName("FaceColors"));
|
||||
if (prop && prop->getSize() == int(rMesh.countFacets()))
|
||||
return true;
|
||||
}
|
||||
{
|
||||
App::PropertyColorList* prop = Base::freecad_dynamic_cast<App::PropertyColorList>(pcObject->getPropertyByName("VertexColors"));
|
||||
if (prop && prop->getSize() == int(rMesh.countPoints()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderMesh::getPyObject()
|
||||
{
|
||||
if (!pyViewObject)
|
||||
|
||||
@@ -191,6 +191,9 @@ protected:
|
||||
void setHighlightedComponents(bool);
|
||||
void highlightSegments();
|
||||
void setHighlightedSegments(bool);
|
||||
void setHighlightedColors(bool);
|
||||
void highlightColors();
|
||||
bool canHighlightColors() const;
|
||||
App::PropertyColorList* getColorProperty() const;
|
||||
void tryColorPerVertexOrFace(bool);
|
||||
void setColorPerVertex(const App::PropertyColorList*);
|
||||
@@ -218,7 +221,13 @@ private:
|
||||
static void panCamera(SoCamera*, float, const SbPlane&, const SbVec2f&, const SbVec2f&);
|
||||
|
||||
protected:
|
||||
std::string highlightMode;
|
||||
enum class HighlighMode {
|
||||
None,
|
||||
Component,
|
||||
Segment,
|
||||
Color
|
||||
};
|
||||
HighlighMode highlightMode;
|
||||
Gui::SoFCSelection * pcHighlight;
|
||||
SoGroup * pcShapeGroup;
|
||||
SoDrawStyle * pcLineStyle;
|
||||
|
||||
@@ -447,7 +447,7 @@ public:
|
||||
|
||||
static void run(void * data, SoSensor * sensor)
|
||||
{
|
||||
Annotation* self = reinterpret_cast<Annotation*>(data);
|
||||
Annotation* self = static_cast<Annotation*>(data);
|
||||
self->show();
|
||||
delete self;
|
||||
delete sensor;
|
||||
@@ -497,7 +497,7 @@ private:
|
||||
|
||||
void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback * n)
|
||||
{
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
const SoEvent* ev = n->getEvent();
|
||||
if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
|
||||
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
# FreeCAD init script of the Mesh module
|
||||
# (c) 2004 Werner Mayer LGPL
|
||||
|
||||
# Append the open handler
|
||||
FreeCAD.addImportType("STL Mesh (*.stl *.ast)", "Mesh")
|
||||
FreeCAD.addImportType("Binary Mesh (*.bms)","Mesh")
|
||||
FreeCAD.addImportType("Alias Mesh (*.obj)","Mesh")
|
||||
FreeCAD.addImportType("Object File Format Mesh (*.off)","Mesh")
|
||||
FreeCAD.addImportType("Stanford Triangle Mesh (*.ply)","Mesh")
|
||||
FreeCAD.addImportType("Simple Model Format (*.smf)","Mesh")
|
||||
|
||||
FreeCAD.addExportType("STL Mesh (*.stl *.ast)", "Mesh")
|
||||
FreeCAD.addExportType("Binary Mesh (*.bms)","Mesh")
|
||||
FreeCAD.addExportType("Alias Mesh (*.obj)","Mesh")
|
||||
FreeCAD.addExportType("Object File Format Mesh (*.off)","Mesh")
|
||||
FreeCAD.addExportType("Stanford Triangle Mesh (*.ply)","Mesh")
|
||||
FreeCAD.addExportType("Additive Manufacturing Format (*.amf)","Mesh")
|
||||
FreeCAD.addExportType("Simple Model Format (*.smf)","Mesh")
|
||||
|
||||
FreeCAD.__unit_test__ += [ "MeshTestsApp" ]
|
||||
# FreeCAD init script of the Mesh module
|
||||
# (c) 2004 Werner Mayer LGPL
|
||||
|
||||
import FreeCAD
|
||||
|
||||
# Append the open handler
|
||||
FreeCAD.addImportType("STL Mesh (*.stl *.ast)", "Mesh")
|
||||
FreeCAD.addImportType("Binary Mesh (*.bms)", "Mesh")
|
||||
FreeCAD.addImportType("Alias Mesh (*.obj)", "Mesh")
|
||||
FreeCAD.addImportType("Object File Format Mesh (*.off)", "Mesh")
|
||||
FreeCAD.addImportType("Stanford Triangle Mesh (*.ply)", "Mesh")
|
||||
FreeCAD.addImportType("Simple Model Format (*.smf)", "Mesh")
|
||||
|
||||
FreeCAD.addExportType("STL Mesh (*.stl *.ast)", "Mesh")
|
||||
FreeCAD.addExportType("Binary Mesh (*.bms)", "Mesh")
|
||||
FreeCAD.addExportType("Alias Mesh (*.obj)", "Mesh")
|
||||
FreeCAD.addExportType("Object File Format Mesh (*.off)", "Mesh")
|
||||
FreeCAD.addExportType("Stanford Triangle Mesh (*.ply)", "Mesh")
|
||||
FreeCAD.addExportType("Additive Manufacturing Format (*.amf)", "Mesh")
|
||||
FreeCAD.addExportType("Simple Model Format (*.smf)", "Mesh")
|
||||
|
||||
FreeCAD.__unit_test__ += [ "MeshTestsApp" ]
|
||||
|
||||
@@ -380,7 +380,7 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
if ((refs[r] == selObj) && (refnames[r] == subname))
|
||||
return;
|
||||
|
||||
if (autoNext && iActiveRef > 0 && iActiveRef == (ssize_t) refnames.size()){
|
||||
if (autoNext && iActiveRef > 0 && iActiveRef == static_cast<int>(refnames.size())){
|
||||
if (refs[iActiveRef-1] == selObj
|
||||
&& refnames[iActiveRef-1].length() != 0 && subname.length() == 0){
|
||||
//A whole object was selected by clicking it twice. Fill it
|
||||
@@ -390,7 +390,7 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
iActiveRef--;
|
||||
}
|
||||
}
|
||||
if (iActiveRef < (ssize_t) refs.size()) {
|
||||
if (iActiveRef < static_cast<int>(refs.size())) {
|
||||
refs[iActiveRef] = selObj;
|
||||
refnames[iActiveRef] = subname;
|
||||
} else {
|
||||
|
||||
@@ -527,7 +527,7 @@ void ComboLinks::clear()
|
||||
|
||||
App::PropertyLinkSub &ComboLinks::getLink(int index) const
|
||||
{
|
||||
if (index < 0 || index > (ssize_t) linksInList.size()-1)
|
||||
if (index < 0 || index > static_cast<int>(linksInList.size())-1)
|
||||
throw Base::IndexError("ComboLinks::getLink:Index out of range");
|
||||
if (linksInList[index]->getValue() && doc && !(doc->isIn(linksInList[index]->getValue())))
|
||||
throw Base::ValueError("Linked object is not in the document; it may have been deleted");
|
||||
|
||||
@@ -165,13 +165,13 @@ void ViewProviderShapeBinder::highlightReferences(const bool on, bool /*auxiliar
|
||||
if (e.compare(0, 4, "Edge") == 0) {
|
||||
int idx = std::stoi(e.substr(4)) - 1;
|
||||
assert(idx >= 0);
|
||||
if (idx < (ssize_t)lcolors.size())
|
||||
if (idx < static_cast<int>(lcolors.size()))
|
||||
lcolors[idx] = App::Color(1.0, 0.0, 1.0); // magenta
|
||||
}
|
||||
else if (e.compare(0, 4, "Face") == 0) {
|
||||
int idx = std::stoi(e.substr(4)) - 1;
|
||||
assert(idx >= 0);
|
||||
if (idx < (ssize_t)fcolors.size())
|
||||
if (idx < static_cast<int>(fcolors.size()))
|
||||
fcolors[idx] = App::Color(1.0, 0.0, 1.0); // magenta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,19 +213,25 @@ void AscReader::read(const std::string& filename)
|
||||
namespace Points {
|
||||
class Converter {
|
||||
public:
|
||||
virtual ~Converter() {
|
||||
}
|
||||
virtual std::string toString(float) const = 0;
|
||||
Converter() = default;
|
||||
virtual ~Converter() = default;
|
||||
virtual std::string toString(double) const = 0;
|
||||
virtual double toDouble(Base::InputStream&) const = 0;
|
||||
virtual int getSizeOf() const = 0;
|
||||
|
||||
private:
|
||||
Converter(const Converter&) = delete;
|
||||
Converter(Converter&&) = delete;
|
||||
Converter& operator= (const Converter&) = delete;
|
||||
Converter& operator= (Converter&&) = delete;
|
||||
};
|
||||
template <typename T>
|
||||
class ConverterT : public Converter {
|
||||
public:
|
||||
virtual std::string toString(float f) const {
|
||||
virtual std::string toString(double f) const {
|
||||
T c = static_cast<T>(f);
|
||||
std::ostringstream oss;
|
||||
oss.precision(6);
|
||||
oss.precision(7);
|
||||
oss.setf(std::ostringstream::showpoint);
|
||||
oss << c;
|
||||
return oss.str();
|
||||
@@ -1818,7 +1824,7 @@ void PcdWriter::write(const std::string& filename)
|
||||
std::size_t numPoints = points.size();
|
||||
const std::vector<Base::Vector3f>& pts = points.getBasicPoints();
|
||||
|
||||
Eigen::MatrixXf data(numPoints, fields.size());
|
||||
Eigen::MatrixXd data(numPoints, fields.size());
|
||||
|
||||
if (placement.isIdentity()) {
|
||||
for (std::size_t i=0; i<numPoints; i++) {
|
||||
@@ -1929,7 +1935,7 @@ void PcdWriter::write(const std::string& filename)
|
||||
|
||||
for (std::size_t r=0; r<numPoints; r++) {
|
||||
for (std::size_t c=0; c<col; c++) {
|
||||
float value = data(r,c);
|
||||
double value = data(r,c);
|
||||
if (boost::math::isnan(value))
|
||||
out << "nan ";
|
||||
else
|
||||
|
||||
@@ -436,11 +436,9 @@ void TaskSectionView::createSectionView(void)
|
||||
Command::doCommand(Command::Doc,"App.ActiveDocument.%s.Scale = %0.6f",
|
||||
m_sectionName.c_str(),
|
||||
ui->sbScale->value().getValue());
|
||||
QString qScaleType = ui->cmbScaleType->currentText();
|
||||
std::string sScaleType = Base::Tools::toStdString(qScaleType);
|
||||
Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = '%s'",
|
||||
m_sectionName.c_str(),
|
||||
sScaleType.c_str());
|
||||
int scaleType = ui->cmbScaleType->currentIndex();
|
||||
Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = %d",
|
||||
m_sectionName.c_str(), scaleType);
|
||||
|
||||
App::DocumentObject* newObj = m_base->getDocument()->getObject(m_sectionName.c_str());
|
||||
m_section = dynamic_cast<TechDraw::DrawViewSection*>(newObj);
|
||||
@@ -487,11 +485,9 @@ void TaskSectionView::updateSectionView(void)
|
||||
Command::doCommand(Command::Doc,"App.ActiveDocument.%s.Scale = %0.6f",
|
||||
m_sectionName.c_str(),
|
||||
ui->sbScale->value().getValue());
|
||||
QString qScaleType = ui->cmbScaleType->currentText();
|
||||
std::string sScaleType = Base::Tools::toStdString(qScaleType);
|
||||
Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = '%s'",
|
||||
m_sectionName.c_str(),
|
||||
sScaleType.c_str());
|
||||
int scaleType = ui->cmbScaleType->currentIndex();
|
||||
Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = %d",
|
||||
m_sectionName.c_str(), scaleType);
|
||||
m_section->setCSFromBase(m_dirName.c_str());
|
||||
}
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
@@ -369,6 +369,13 @@ class MatrixTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.mat = FreeCAD.Matrix()
|
||||
|
||||
def testOrder(self):
|
||||
self.mat = FreeCAD.Matrix(1.0,2.0,3.0,4.0)
|
||||
self.assertEqual(self.mat.A11, 1.0)
|
||||
self.assertEqual(self.mat.A12, 2.0)
|
||||
self.assertEqual(self.mat.A13, 3.0)
|
||||
self.assertEqual(self.mat.A14, 4.0)
|
||||
|
||||
def testScalar(self):
|
||||
res = self.mat * 0.0
|
||||
for i in range(16):
|
||||
|
||||
Reference in New Issue
Block a user