Merge branch 'master' of github.com:FreeCAD/FreeCAD

This commit is contained in:
Yorik van Havre 2015-09-01 10:47:47 -03:00
commit d38863538c
10 changed files with 64 additions and 27 deletions

View File

@ -117,24 +117,9 @@ public:
*/ */
virtual ~PropertyVectorDistance(); virtual ~PropertyVectorDistance();
/** Sets the property
*/
void setValue(const Base::Vector3d &vec);
void setValue(double x, double y, double z);
/** This method returns a string representation of the property
*/
const Base::Vector3d &getValue(void) const;
const char* getEditorName(void) const { const char* getEditorName(void) const {
return "Gui::PropertyEditor::PropertyVectorDistanceItem"; return "Gui::PropertyEditor::PropertyVectorDistanceItem";
} }
virtual unsigned int getMemSize (void) const {
return sizeof(Base::Vector3d);
}
private:
Base::Vector3d _cVec;
}; };

View File

@ -1,5 +1,5 @@
if(MSVC) if(MSVC)
add_definitions(-DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH) add_definitions(-DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH -D_CRT_SECURE_NO_WARNINGS)
else(MSVC) else(MSVC)
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H) add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
endif(MSVC) endif(MSVC)

View File

@ -37,6 +37,10 @@
# define BaseExport # define BaseExport
#endif #endif
#ifdef _MSC_VER
# pragma warning(disable : 4275)
#endif
#ifdef _PreComp_ #ifdef _PreComp_
// standard // standard

View File

@ -1419,10 +1419,10 @@ void CDxfRead::get_line()
m_ifs->getline(m_str, 1024); m_ifs->getline(m_str, 1024);
char str[1024]; char str[1024];
int len = strlen(m_str); size_t len = strlen(m_str);
int j = 0; int j = 0;
bool non_white_found = false; bool non_white_found = false;
for(int i = 0; i<len; i++){ for(size_t i = 0; i<len; i++){
if(non_white_found || (m_str[i] != ' ' && m_str[i] != '\t')){ if(non_white_found || (m_str[i] != ' ' && m_str[i] != '\t')){
if(m_str[i] != '\r') if(m_str[i] != '\r')
{ {

View File

@ -834,6 +834,26 @@ Base::Vector3d MeshObject::getPointNormal(unsigned long index) const
return normal; return normal;
} }
std::vector<Base::Vector3d> MeshObject::getPointNormals() const
{
std::vector<Base::Vector3f> temp = _kernel.CalcVertexNormals();
std::vector<Base::Vector3d> normals;
normals.reserve(temp.size());
for (std::vector<Base::Vector3f>::iterator it = temp.begin(); it != temp.end(); ++it) {
Base::Vector3d normal = transformToOutside(*it);
// the normal is a vector, hence we must not apply the translation part
// of the transformation to the vector
normal.x -= _Mtrx[0][3];
normal.y -= _Mtrx[1][3];
normal.z -= _Mtrx[2][3];
normal.Normalize();
normals.push_back(normal);
}
return normals;
}
void MeshObject::crossSections(const std::vector<MeshObject::TPlane>& planes, std::vector<MeshObject::TPolylines> &sections, void MeshObject::crossSections(const std::vector<MeshObject::TPlane>& planes, std::vector<MeshObject::TPolylines> &sections,
float fMinEps, bool bConnectPolygons) const float fMinEps, bool bConnectPolygons) const
{ {

View File

@ -205,6 +205,7 @@ public:
void setPoint(unsigned long, const Base::Vector3d& v); void setPoint(unsigned long, const Base::Vector3d& v);
void smooth(int iterations, float d_max); void smooth(int iterations, float d_max);
Base::Vector3d getPointNormal(unsigned long) const; Base::Vector3d getPointNormal(unsigned long) const;
std::vector<Base::Vector3d> getPointNormals() const;
void crossSections(const std::vector<TPlane>&, std::vector<TPolylines> &sections, void crossSections(const std::vector<TPlane>&, std::vector<TPolylines> &sections,
float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const; float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const;
void cut(const Base::Polygon2D& polygon, const Base::ViewProjMethod& proj, CutType); void cut(const Base::Polygon2D& polygon, const Base::ViewProjMethod& proj, CutType);

View File

@ -155,6 +155,14 @@ Example:
</UserDocu> </UserDocu>
</Documentation> </Documentation>
</Methode> </Methode>
<Methode Name="getPointNormals" Const="true">
<Documentation>
<UserDocu>
getPointNormals()
Get the normals of the points.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="countSegments" Const="true"> <Methode Name="countSegments" Const="true">
<Documentation> <Documentation>
<UserDocu>Get the number of segments which may also be 0</UserDocu> <UserDocu>Get the number of segments which may also be 0</UserDocu>

View File

@ -685,6 +685,22 @@ PyObject* MeshPy::setPoint(PyObject *args)
Py_Return; Py_Return;
} }
PyObject* MeshPy::getPointNormals(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
PY_TRY {
std::vector<Base::Vector3d> normals = getMeshObjectPtr()->getPointNormals();
Py::Tuple ary(normals.size());
std::size_t numNormals = normals.size();
for (std::size_t i=0; i<numNormals; i++) {
ary.setItem(i, Py::Vector(normals[i]));
}
return Py::new_reference_to(ary);
} PY_CATCH;
}
PyObject* MeshPy::countSegments(PyObject *args) PyObject* MeshPy::countSegments(PyObject *args)
{ {
if (!PyArg_ParseTuple(args, "")) if (!PyArg_ParseTuple(args, ""))

View File

@ -138,11 +138,14 @@ static bool IsPolygonClockwise(const TPolygon& p)
{ {
#if 1 #if 1
double area = 0.0; double area = 0.0;
unsigned int s = p.size(); std::size_t s = p.size();
for(unsigned int i = 0; i<s; i++) for(std::size_t i = 0; i<s; i++)
{ {
int im1 = i-1; std::size_t im1;
if(im1 < 0)im1 += s; if (i == 0)
im1 = s - 1;
else
im1 = i - 1;
DoubleAreaPoint pt0(p[im1]); DoubleAreaPoint pt0(p[im1]);
DoubleAreaPoint pt1(p[i]); DoubleAreaPoint pt1(p[i]);
@ -216,7 +219,7 @@ static void OffsetWithLoops(const TPolyPolygon &pp, TPolyPolygon &pp_new, double
{ {
if(reverse) if(reverse)
{ {
for(unsigned int j = p.size()-1; j > 1; j--)MakeLoop(p[j], p[j-1], p[j-2], radius); for(std::size_t j = p.size()-1; j > 1; j--)MakeLoop(p[j], p[j-1], p[j-2], radius);
MakeLoop(p[1], p[0], p[p.size()-1], radius); MakeLoop(p[1], p[0], p[p.size()-1], radius);
MakeLoop(p[0], p[p.size()-1], p[p.size()-2], radius); MakeLoop(p[0], p[p.size()-1], p[p.size()-2], radius);
} }
@ -260,7 +263,7 @@ static void OffsetWithLoops(const TPolyPolygon &pp, TPolyPolygon &pp_new, double
const TPolygon& p = copy[i]; const TPolygon& p = copy[i];
TPolygon p_new; TPolygon p_new;
p_new.resize(p.size()); p_new.resize(p.size());
int size_minus_one = p.size() - 1; std::size_t size_minus_one = p.size() - 1;
for(unsigned int j = 0; j < p.size(); j++)p_new[j] = p[size_minus_one - j]; for(unsigned int j = 0; j < p.size(); j++)p_new[j] = p[size_minus_one - j];
pp_new[i] = p_new; pp_new[i] = p_new;
} }
@ -337,7 +340,7 @@ static void OffsetSpansWithObrounds(const CArea& area, TPolyPolygon &pp_new, dou
const TPolygon& p = copy[i]; const TPolygon& p = copy[i];
TPolygon p_new; TPolygon p_new;
p_new.resize(p.size()); p_new.resize(p.size());
int size_minus_one = p.size() - 1; std::size_t size_minus_one = p.size() - 1;
for(unsigned int j = 0; j < p.size(); j++)p_new[j] = p[size_minus_one - j]; for(unsigned int j = 0; j < p.size(); j++)p_new[j] = p[size_minus_one - j];
pp_new[i] = p_new; pp_new[i] = p_new;
} }
@ -362,7 +365,7 @@ static void MakePolyPoly( const CArea& area, TPolyPolygon &pp, bool reverse = tr
p.resize(pts_for_AddVertex.size()); p.resize(pts_for_AddVertex.size());
if(reverse) if(reverse)
{ {
unsigned int i = pts_for_AddVertex.size() - 1;// clipper wants them the opposite way to CArea std::size_t i = pts_for_AddVertex.size() - 1;// clipper wants them the opposite way to CArea
for(std::list<DoubleAreaPoint>::iterator It = pts_for_AddVertex.begin(); It != pts_for_AddVertex.end(); It++, i--) for(std::list<DoubleAreaPoint>::iterator It = pts_for_AddVertex.begin(); It != pts_for_AddVertex.end(); It++, i--)
{ {
p[i] = It->int_point(); p[i] = It->int_point();

View File

@ -55,7 +55,7 @@ DeriVector2 DeriVector2::getNormalized() const
{ {
double l=length(); double l=length();
if(l==0.0) { if(l==0.0) {
return DeriVector2(0, 0, dx/0.0, dy/0.0); return DeriVector2(0, 0, dx, dy);
} else { } else {
DeriVector2 rtn; DeriVector2 rtn;
rtn.x = x/l; rtn.x = x/l;