Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/FreeCAD/FreeCAD
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jul 24, 2015
2 parents de63624 + 6bd0501 commit b045896
Show file tree
Hide file tree
Showing 35 changed files with 14,872 additions and 11 deletions.
53 changes: 53 additions & 0 deletions .travis.yml
@@ -0,0 +1,53 @@
language: cpp

before_install:
- sudo apt-get update -qq
- sudo apt-get install -y doxygen
- sudo apt-get install -y libboost-dev
- sudo apt-get install -y libboost-filesystem-dev
- sudo apt-get install -y libboost-program-options-dev
- sudo apt-get install -y libboost-python-dev
- sudo apt-get install -y libboost-regex-dev
- sudo apt-get install -y libboost-signals-dev
- sudo apt-get install -y libboost-system-dev
- sudo apt-get install -y libboost-thread-dev
- sudo apt-get install -y libcoin60
- sudo apt-get install -y libcoin60-dev
- sudo apt-get install -y libeigen3-dev
- sudo apt-get install -y liboce-foundation-dev
- sudo apt-get install -y liboce-foundation1
- sudo apt-get install -y liboce-modeling-dev
- sudo apt-get install -y liboce-modeling1
- sudo apt-get install -y liboce-ocaf-dev
- sudo apt-get install -y liboce-ocaf-lite-dev
- sudo apt-get install -y liboce-ocaf-lite1
- sudo apt-get install -y liboce-ocaf1
- sudo apt-get install -y liboce-visualization-dev
- sudo apt-get install -y liboce-visualization1
- sudo apt-get install -y libopencascade-modeling-6.5.0
- sudo apt-get install -y libpyside-dev
- sudo apt-get install -y libqtcore4
- sudo apt-get install -y libshiboken-dev
- sudo apt-get install -y libxerces-c-dev
- sudo apt-get install -y libxmu-dev
- sudo apt-get install -y libxmu-headers
- sudo apt-get install -y libxmu6
- sudo apt-get install -y libxmuu-dev
- sudo apt-get install -y libxmuu1
- sudo apt-get install -y oce-draw
- sudo apt-get install -y pyside-tools
- sudo apt-get install -y python-dev
- sudo apt-get install -y python-pyside
- sudo apt-get install -y qt4-dev-tools
- sudo apt-get install -y qt4-qmake
- sudo apt-get install -y shiboken
- sudo apt-get install -y swig
#Patch the system - there is a bug related to invalid location of libs on ubuntu 12.04
- sudo ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib/i386-linux-gnu

install:
- mkdir build && cd build && cmake ../

script:
- make
- PYTHONPATH=$(pwd)/lib/ python -c "import sys, unittest, FreeCAD, TestApp; sys.exit(0 if unittest.TextTestRunner().run(TestApp.All()).wasSuccessful() else 1)"
16 changes: 10 additions & 6 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -253,8 +253,11 @@ def explore(filename=None):

def open(filename,skip=[],only=[],root=None):
"opens an IFC file in a new document"

docname = os.path.splitext(os.path.basename(filename))[0]
if isinstance(docname,unicode):
import sys #workaround since newDocument currently can't handle unicode filenames
docname = docname.encode(sys.getfilesystemencoding())
doc = FreeCAD.newDocument(docname)
doc.Label = docname
doc = insert(filename,doc.Name,skip,only,root)
Expand Down Expand Up @@ -666,10 +669,6 @@ def export(exportList,filename):
except:
FreeCAD.Console.PrintError("IfcOpenShell was not found on this system. IFC support is disabled\n")
return

if isinstance(filename,unicode):
import sys #workaround since ifcopenshell currently can't handle unicode filenames
filename = filename.encode(sys.getfilesystemencoding())

version = FreeCAD.Version()
owner = FreeCAD.ActiveDocument.CreatedBy
Expand All @@ -690,7 +689,7 @@ def export(exportList,filename):
ifctemplate = ifctemplate.replace("$timestamp",str(time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime())))
template = tempfile.mkstemp(suffix=".ifc")[1]
of = pyopen(template,"wb")
of.write(ifctemplate)
of.write(ifctemplate.encode("utf8"))
of.close()
global ifcfile, surfstyles
ifcfile = ifcopenshell.open(template)
Expand Down Expand Up @@ -877,6 +876,11 @@ def export(exportList,filename):
ifcfile.createIfcRelAssociatesMaterial(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'MaterialLink','',relobjs,mat)

if DEBUG: print "writing ",filename,"..."

if isinstance(filename,unicode):
import sys #workaround since ifcopenshell currently can't handle unicode filenames
filename = filename.encode(sys.getfilesystemencoding())

ifcfile.write(filename)


Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Draft/importDXF.py
Expand Up @@ -1467,6 +1467,9 @@ def open(filename):
readPreferences()
if dxfReader:
docname = os.path.splitext(os.path.basename(filename))[0]
if isinstance(docname,unicode):
import sys #workaround since newDocument currently can't handle unicode filenames
docname = docname.encode(sys.getfilesystemencoding())
doc = FreeCAD.newDocument(docname)
doc.Label = decodeName(docname)
processdxf(doc,filename)
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Path/CMakeLists.txt
@@ -1,4 +1,5 @@
add_subdirectory(App)
add_subdirectory(libarea)

if(BUILD_GUI)
add_subdirectory(Gui)
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Path/PathScripts/PathMachine.py
Expand Up @@ -44,6 +44,7 @@ def __init__(self,obj):
obj.addProperty("App::PropertyString", "MachineName","Base",translate("Machine Name","Name of the Machine that will use the CNC program"))

obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", translate("Post Processor","Select the Post Processor file for this machine"))
obj.setEditorMode("PostProcessor",1) #set to read only
obj.addProperty("App::PropertyEnumeration", "MachineUnits","CodeOutput", translate( "Machine Units", "Units that the machine works in, ie Metric or Inch"))
obj.MachineUnits=['Metric', 'Inch']

Expand Down
1 change: 1 addition & 0 deletions src/Mod/Path/PathScripts/PathProject.py
Expand Up @@ -43,6 +43,7 @@ class ObjectPathProject:
def __init__(self,obj):
# obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", translate("PostProcessor","Select the Post Processor file for this project"))
obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", translate("OutputFile","The NC output file for this project"))
obj.setEditorMode("OutputFile",0) #set to default mode
# obj.addProperty("App::PropertyBool","Editor","CodeOutput",translate("Show Editor","Show G-Code in simple editor after posting code"))
# obj.addProperty("Path::PropertyTooltable","Tooltable", "Path",translate("PathProject","The tooltable of this feature"))
obj.addProperty("App::PropertyString", "Description","Path",translate("PathProject","An optional description for this project"))
Expand Down
23 changes: 18 additions & 5 deletions src/Mod/Path/PathScripts/PathSelection.py
Expand Up @@ -27,9 +27,22 @@
import Part
from FreeCAD import Vector

def equals(p1,p2):
'''returns True if vertexes have same coordinates within precision amount of digits '''
precision = 12 #hardcoded
p=precision
u = Vector(p1.X,p1.Y,p1.Z)
v = Vector(p2.X,p2.Y,p2.Z)
vector = (u.sub(v))
isNull = (round(vector.x,p)==0 and round(vector.y,p)==0 and round(vector.z,p)==0)
return isNull



def Sort2Edges(edgelist):
'''Sort2Edges(edgelist) simple function to reorder the start and end pts of two edges based on their selection order. Returns the list, the start point, and their common point, => edgelist, vertex, vertex'''
'''Sort2Edges(edgelist) simple function to reorder the start and end pts of two edges
based on their selection order. Returns the list, the start point,
and their common point, => edgelist, vertex, vertex'''
if len(edgelist)>=2:
vlist = []
e0 = edgelist[0]
Expand All @@ -39,22 +52,22 @@ def Sort2Edges(edgelist):
b0 = e1.Vertexes[0]
b1 = e1.Vertexes[1]
# comparison routine to order two edges:
if a1.isSame(b0):
if equals(a1,b0):
vlist.append((a0.Point.x,a0.Point.y))
vlist.append((a1.Point.x,a1.Point.y))
vlist.append((b1.Point.x,b1.Point.y))

elif a0.isSame(b0):
if equals(a0,b0):
vlist.append((a1.Point.x,a1.Point.y))
vlist.append((a0.Point.x,a0.Point.y))
vlist.append((b1.Point.x,b1.Point.y))

elif a0.isSame(b1):
if equals(a0,b1):
vlist.append((a1.Point.x,a1.Point.y))
vlist.append((a0.Point.x,a0.Point.y))
vlist.append((b0.Point.x,b0.Point.y))

elif a1.isSame(b1):
if equals(a1,b1):
vlist.append((a0.Point.x,a0.Point.y))
vlist.append((a1.Point.x,a1.Point.y))
vlist.append((b0.Point.x,b0.Point.y))
Expand Down
147 changes: 147 additions & 0 deletions src/Mod/Path/libarea/Arc.cpp
@@ -0,0 +1,147 @@
// Arc.cpp

/*==============================
Copyright (c) 2011-2015 Dan Heeks
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
==============================*/



#include "Arc.h"
#include "Curve.h"

void CArc::SetDirWithPoint(const Point& p)
{
double angs = atan2(m_s.y - m_c.y, m_s.x - m_c.x);
double ange = atan2(m_e.y - m_c.y, m_e.x - m_c.x);
double angp = atan2(p.y - m_c.y, p.x - m_c.x);
if(ange < angs)ange += 6.2831853071795864;
if(angp < angs - 0.0000000000001)angp += 6.2831853071795864;
if(angp > ange + 0.0000000000001)m_dir = false;
else m_dir = true;
}

double CArc::IncludedAngle()const
{
double angs = atan2(m_s.y - m_c.y, m_s.x - m_c.x);
double ange = atan2(m_e.y - m_c.y, m_e.x - m_c.x);
if(m_dir)
{
// make sure ange > angs
if(ange < angs)ange += 6.2831853071795864;
}
else
{
// make sure angs > ange
if(angs < ange)angs += 6.2831853071795864;
}

return fabs(ange - angs);
}

bool CArc::AlmostALine()const
{
Point mid_point = MidParam(0.5);
if(Line(m_s, m_e - m_s).Dist(mid_point) <= Point::tolerance)
return true;

const double max_arc_radius = 1.0 / Point::tolerance;
double radius = m_c.dist(m_s);
if (radius > max_arc_radius)
{
return true; // We don't want to produce an arc whose radius is too large.
}

return false;
}

Point CArc::MidParam(double param)const {
/// returns a point which is 0-1 along arc
if(fabs(param) < 0.00000000000001)return m_s;
if(fabs(param - 1.0) < 0.00000000000001)return m_e;

Point p;
Point v = m_s - m_c;
v.Rotate(param * IncludedAngle());
p = v + m_c;

return p;
}

//segments - number of segments per full revolution!
//d_angle - determines the direction and the ammount of the arc to draw
void CArc::GetSegments(void(*callbackfunc)(const double *p), double pixels_per_mm, bool want_start_point)const
{
if(m_s == m_e)
return;

Point Va = m_s - m_c;
Point Vb = m_e - m_c;

double start_angle = atan2(Va.y, Va.x);
double end_angle = atan2(Vb.y, Vb.x);

if(m_dir)
{
if(start_angle > end_angle)end_angle += 6.28318530717958;
}
else
{
if(start_angle < end_angle)end_angle -= 6.28318530717958;
}

double radius = m_c.dist(m_s);
double d_angle = end_angle - start_angle;
int segments = (int)(fabs(pixels_per_mm * radius * d_angle / 6.28318530717958 + 1));

double theta = d_angle / (double)segments;
while(theta>1.0){segments*=2;theta = d_angle / (double)segments;}
double tangetial_factor = tan(theta);
double radial_factor = 1 - cos(theta);

double x = radius * cos(start_angle);
double y = radius * sin(start_angle);

double pp[3] = {0.0, 0.0, 0.0};

for(int i = 0; i < segments + 1; i++)
{
Point p = m_c + Point(x, y);
pp[0] = p.x;
pp[1] = p.y;
(*callbackfunc)(pp);

double tx = -y;
double ty = x;

x += tx * tangetial_factor;
y += ty * tangetial_factor;

double rx = - x;
double ry = - y;

x += rx * radial_factor;
y += ry * radial_factor;
}
}
48 changes: 48 additions & 0 deletions src/Mod/Path/libarea/Arc.h
@@ -0,0 +1,48 @@
// Arc.h
/*==============================
Copyright (c) 2011-2015 Dan Heeks
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
==============================*/

#pragma once

#include "Point.h"

class CArc{
public:
Point m_s;
Point m_e;
Point m_c;
bool m_dir; // true - anti-clockwise, false - clockwise
int m_user_data;

CArc():m_dir(true), m_user_data(0){}
CArc(const Point& s, const Point& e, const Point& c, bool dir, int user_data):m_s(s), m_e(e), m_c(c), m_dir(dir), m_user_data(user_data){}

void SetDirWithPoint(const Point& p); // set m_dir, such that this point lies between m_s and m_e
double IncludedAngle()const; // always > 0
bool AlmostALine()const;
Point MidParam(double param)const;
void GetSegments(void(*callbackfunc)(const double *p), double pixels_per_mm, bool want_start_point = true)const;
};

0 comments on commit b045896

Please sign in to comment.