Renamed Draft fcvec and fcgeo modules

Draft/draftlibs/fcvec becomes Draft/DraftVecUtils
Draft/draftlibs/fcgeo becomes Draft/DraftGeomUtils
This commit is contained in:
Yorik van Havre
2012-05-22 11:45:40 -03:00
parent e607ddf55f
commit 7086b80cb3
24 changed files with 413 additions and 451 deletions

View File

@@ -21,9 +21,7 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Draft,math
from draftlibs import fcvec
import FreeCAD,FreeCADGui,Draft,math,DraftVecUtils
from FreeCAD import Vector
from PyQt4 import QtCore, QtGui
from pivy import coin

View File

@@ -21,8 +21,7 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent,DraftVecUtils
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -170,7 +169,7 @@ def makeFace(wires,method=2,cleanup=False):
# cleaning up rubbish in wires
if cleanup:
for i in range(len(wires)):
wires[i] = fcgeo.removeInterVertices(wires[i])
wires[i] = DraftGeomUtils.removeInterVertices(wires[i])
print "garbage removed"
for w in wires:
# we assume that the exterior boundary is that one with
@@ -210,8 +209,7 @@ def meshToShape(obj,mark=True):
mark is True (default), non-solid objects will be marked in red'''
name = obj.Name
import Part,MeshPart
from draftlibs import fcgeo
import Part, MeshPart, DraftGeomUtils
if "Mesh" in obj.PropertiesList:
faces = []
mesh = obj.Mesh
@@ -249,12 +247,12 @@ def meshToShape(obj,mark=True):
def removeShape(objs,mark=True):
'''takes an arch object (wall or structure) built on a cubic shape, and removes
the inner shape, keeping its length, width and height as parameters.'''
from draftlibs import fcgeo
import DraftGeomUtils
if not isinstance(objs,list):
objs = [objs]
for obj in objs:
if fcgeo.isCubic(obj.Shape):
dims = fcgeo.getCubicDimensions(obj.Shape)
if DraftGeomUtils.isCubic(obj.Shape):
dims = DraftGeomUtils.getCubicDimensions(obj.Shape)
if dims:
name = obj.Name
tp = Draft.getType(obj)
@@ -270,7 +268,7 @@ def removeShape(objs,mark=True):
length = dims[1]
width = dims[2]
v1 = Vector(length/2,0,0)
v2 = fcvec.neg(v1)
v2 = DraftVecUtils.neg(v1)
v1 = dims[0].multVec(v1)
v2 = dims[0].multVec(v2)
line = Draft.makeLine(v1,v2)

View File

@@ -21,8 +21,7 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent, DraftVecUtils
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -104,8 +103,7 @@ class _Roof(ArchComponent.Component):
self.createGeometry(obj)
def createGeometry(self,obj):
import Part,math
from draftlibs import fcgeo
import Part, math, DraftGeomUtils
pl = obj.Placement
if obj.Base and obj.Face and obj.Angle:
@@ -116,14 +114,14 @@ class _Roof(ArchComponent.Component):
c = round(math.tan(math.radians(obj.Angle)),Draft.precision())
norm = f.normalAt(0,0)
d = f.BoundBox.DiagonalLength
edges = fcgeo.sortEdges(f.Edges)
edges = DraftGeomUtils.sortEdges(f.Edges)
l = len(edges)
edges.append(edges[0])
shps = []
for i in range(l):
v = fcgeo.vec(fcgeo.angleBisection(edges[i],edges[i+1]))
v = DraftGeomUtils.vec(DraftGeomUtils.angleBisection(edges[i],edges[i+1]))
v.normalize()
bis = v.getAngle(fcgeo.vec(edges[i]))
bis = v.getAngle(DraftGeomUtils.vec(edges[i]))
delta = 1/math.cos(bis)
v.multiply(delta)
n = (FreeCAD.Vector(norm)).multiply(c)
@@ -137,7 +135,7 @@ class _Roof(ArchComponent.Component):
c = c.removeSplitter()
if not c.isNull():
obj.Shape = c
if not fcgeo.isNull(pl):
if not DraftGeomUtils.isNull(pl):
obj.Placement = pl
class _ViewProviderRoof(ArchComponent.ViewProviderComponent):

View File

@@ -21,11 +21,10 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,ArchComponent,WorkingPlane,Drawing,math,Draft,ArchCommands
import FreeCAD,FreeCADGui,ArchComponent,WorkingPlane,Drawing,math,Draft,ArchCommands, DraftVecUtils
from FreeCAD import Vector
from PyQt4 import QtCore
from pivy import coin
from draftlibs import fcvec
class _CommandSectionPlane:
@@ -176,8 +175,7 @@ class _ArchDrawingView:
def updateSVG(self, obj,join=False):
"encapsulates a svg fragment into a transformation node"
import Part
from draftlibs import fcgeo
import Part, DraftGeomUtils
if hasattr(obj,"Source"):
if obj.Source:
if obj.Source.Objects:
@@ -207,7 +205,7 @@ class _ArchDrawingView:
base = shape.pop()
for sh in shapes:
base = base.fuse(sh)
svgf = Drawing.projectToSVG(base,fcvec.neg(direction))
svgf = Drawing.projectToSVG(base,DraftVecUtils.neg(direction))
if svgf:
svgf = svgf.replace('stroke-width="0.35"','stroke-width="' + str(linewidth) + 'px"')
svg += svgf

View File

@@ -21,8 +21,7 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent,DraftVecUtils
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -99,7 +98,7 @@ class _Structure(ArchComponent.Component):
def getAxisPoints(self,obj):
"returns the gridpoints of linked axes"
from draftlibs import fcgeo
import DraftGeomUtils
pts = []
if len(obj.Axes) == 1:
for e in obj.Axes[0].Shape.Edges:
@@ -109,12 +108,11 @@ class _Structure(ArchComponent.Component):
set2 = obj.Axes[1].Shape.Edges
for e1 in set1:
for e2 in set2:
pts.extend(fcgeo.findIntersection(e1,e2))
pts.extend(DraftGeomUtils.findIntersection(e1,e2))
return pts
def createGeometry(self,obj):
import Part
from draftlibs import fcgeo
import Part, DraftGeomUtils
# getting default values
height = normal = None
if obj.Length:
@@ -187,7 +185,7 @@ class _Structure(ArchComponent.Component):
obj.Shape = Part.makeCompound(fsh)
else:
obj.Shape = base
if not fcgeo.isNull(pl): obj.Placement = pl
if not DraftGeomUtils.isNull(pl): obj.Placement = pl
class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
"A View Provider for the Structure object"

View File

@@ -23,8 +23,7 @@
"The FreeCAD Arch Vector Rendering Module"
import FreeCAD,math,Part,ArchCommands
from draftlibs import fcvec,fcgeo
import FreeCAD,math,Part,ArchCommands,DraftVecUtils,DraftGeomUtils
DEBUG = True # if we want debug messages
MAXLOOP = 10 # the max number of loop before abort
@@ -171,7 +170,7 @@ class Renderer:
norm = face[0].normalAt(0,0)
for w in face[0].Wires:
verts = []
edges = fcgeo.sortEdges(w.Edges)
edges = DraftGeomUtils.sortEdges(w.Edges)
for e in edges:
v = e.Vertexes[0].Point
v = self.wp.getLocalCoords(v)
@@ -196,7 +195,7 @@ class Renderer:
wires = []
for w in face[0].Wires:
verts = []
edges = fcgeo.sortEdges(w.Edges)
edges = DraftGeomUtils.sortEdges(w.Edges)
for e in edges:
v = e.Vertexes[0].Point
verts.append(FreeCAD.Vector(v.x,v.y,0))
@@ -239,11 +238,11 @@ class Renderer:
FreeCAD.Vector(bb.XMax,bb.YMax,bb.ZMax)]
for c in corners:
dv = c.sub(placement.Base)
um1 = fcvec.project(dv,self.wp.u).Length
um1 = DraftVecUtils.project(dv,self.wp.u).Length
um = max(um,um1)
vm1 = fcvec.project(dv,self.wp.v).Length
vm1 = DraftVecUtils.project(dv,self.wp.v).Length
vm = max(vm,vm1)
wm1 = fcvec.project(dv,self.wp.axis).Length
wm1 = DraftVecUtils.project(dv,self.wp.axis).Length
wm = max(wm,wm1)
p1 = FreeCAD.Vector(-um,vm,0)
p2 = FreeCAD.Vector(um,vm,0)
@@ -252,7 +251,7 @@ class Renderer:
cutface = Part.makePolygon([p1,p2,p3,p4,p1])
cutface = Part.Face(cutface)
cutface.Placement = placement
cutnormal = fcvec.scaleTo(self.wp.axis,wm)
cutnormal = DraftVecUtils.scaleTo(self.wp.axis,wm)
cutvolume = cutface.extrude(cutnormal)
shapes = []
faces = []
@@ -265,7 +264,7 @@ class Renderer:
faces.append([f]+sh[1:])
sec = sol.section(cutface)
if sec.Edges:
wires = fcgeo.findWires(sec.Edges)
wires = DraftGeomUtils.findWires(sec.Edges)
for w in wires:
sec = Part.Face(w)
sections.append([sec,fill])
@@ -313,7 +312,7 @@ class Renderer:
# even so, faces can still overlap if their edges cross each other
for e1 in face1[0].Edges:
for e2 in face2[0].Edges:
if fcgeo.findIntersection(e1,e2):
if DraftGeomUtils.findIntersection(e1,e2):
return True
return False
@@ -354,8 +353,8 @@ class Renderer:
front = 0
for v in face1[0].Vertexes:
dv = v.Point.sub(face2[0].Vertexes[0].Point)
dv = fcvec.project(dv,norm)
if fcvec.isNull(dv):
dv = DraftVecUtils.project(dv,norm)
if DraftVecUtils.isNull(dv):
behind += 1
front += 1
else:
@@ -377,8 +376,8 @@ class Renderer:
front = 0
for v in face2[0].Vertexes:
dv = v.Point.sub(face1[0].Vertexes[0].Point)
dv = fcvec.project(dv,norm)
if fcvec.isNull(dv):
dv = DraftVecUtils.project(dv,norm)
if DraftVecUtils.isNull(dv):
behind += 1
front += 1
else:
@@ -545,7 +544,7 @@ class Renderer:
def getPathData(self,w):
"Returns a SVG path data string from a 2D wire"
edges = fcgeo.sortEdges(w.Edges)
edges = DraftGeomUtils.sortEdges(w.Edges)
v = edges[0].Vertexes[0].Point
svg = 'M '+ str(v.x) +' '+ str(v.y) + ' '
for e in edges:

View File

@@ -21,8 +21,7 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent,DraftVecUtils
from FreeCAD import Vector
from PyQt4 import QtCore
@@ -180,13 +179,13 @@ class _CommandWall:
n = FreeCAD.DraftWorkingPlane.axis
bv = point.sub(b)
dv = bv.cross(n)
dv = fcvec.scaleTo(dv,self.Width/2)
dv = DraftVecUtils.scaleTo(dv,self.Width/2)
if self.Align == "Center":
self.tracker.update([b,point])
elif self.Align == "Left":
self.tracker.update([b.add(dv),point.add(dv)])
else:
dv = fcvec.neg(dv)
dv = DraftVecUtils.neg(dv)
self.tracker.update([b.add(dv),point.add(dv)])
def taskbox(self):
@@ -275,10 +274,10 @@ class _Wall(ArchComponent.Component):
f = w
f = Part.Face(f)
n = f.normalAt(0,0)
v1 = fcvec.scaleTo(n,width)
v1 = DraftVecUtils.scaleTo(n,width)
f.translate(v1)
v2 = fcvec.neg(v1)
v2 = fcvec.scale(v1,-2)
v2 = DraftVecUtils.neg(v1)
v2 = DraftVecUtils.scale(v1,-2)
f = f.extrude(v2)
if delta:
f.translate(delta)
@@ -290,8 +289,7 @@ class _Wall(ArchComponent.Component):
if not obj.Base:
return
import Part
from draftlibs import fcgeo
import Part, DraftGeomUtils
flat = False
if hasattr(obj.ViewObject,"DisplayMode"):
@@ -304,25 +302,25 @@ class _Wall(ArchComponent.Component):
def getbase(wire):
"returns a full shape from a base wire"
dvec = fcgeo.vec(wire.Edges[0]).cross(normal)
dvec = DraftGeomUtils.vec(wire.Edges[0]).cross(normal)
dvec.normalize()
if obj.Align == "Left":
dvec = dvec.multiply(width)
w2 = fcgeo.offsetWire(wire,dvec)
w1 = Part.Wire(fcgeo.sortEdges(wire.Edges))
sh = fcgeo.bind(w1,w2)
w2 = DraftGeomUtils.offsetWire(wire,dvec)
w1 = Part.Wire(DraftGeomUtils.sortEdges(wire.Edges))
sh = DraftGeomUtils.bind(w1,w2)
elif obj.Align == "Right":
dvec = dvec.multiply(width)
dvec = fcvec.neg(dvec)
w2 = fcgeo.offsetWire(wire,dvec)
w1 = Part.Wire(fcgeo.sortEdges(wire.Edges))
sh = fcgeo.bind(w1,w2)
dvec = DraftVecUtils.neg(dvec)
w2 = DraftGeomUtils.offsetWire(wire,dvec)
w1 = Part.Wire(DraftGeomUtils.sortEdges(wire.Edges))
sh = DraftGeomUtils.bind(w1,w2)
elif obj.Align == "Center":
dvec = dvec.multiply(width/2)
w1 = fcgeo.offsetWire(wire,dvec)
dvec = fcvec.neg(dvec)
w2 = fcgeo.offsetWire(wire,dvec)
sh = fcgeo.bind(w1,w2)
w1 = DraftGeomUtils.offsetWire(wire,dvec)
dvec = DraftVecUtils.neg(dvec)
w2 = DraftGeomUtils.offsetWire(wire,dvec)
sh = DraftGeomUtils.bind(w1,w2)
# fixing self-intersections
sh.fix(0.1,0,1)
if height and (not flat):
@@ -388,7 +386,7 @@ class _Wall(ArchComponent.Component):
if base:
obj.Shape = base
if not fcgeo.isNull(pl):
if not DraftGeomUtils.isNull(pl):
obj.Placement = pl
class _ViewProviderWall(ArchComponent.ViewProviderComponent):

View File

@@ -21,8 +21,7 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Draft,ArchComponent
from draftlibs import fcvec
import FreeCAD,FreeCADGui,Draft,ArchComponent,DraftVecUtils
from FreeCAD import Vector
from PyQt4 import QtCore,QtGui
@@ -109,8 +108,7 @@ class _Window(ArchComponent.Component):
self.createGeometry(obj)
def createGeometry(self,obj):
import Part
from draftlibs import fcgeo
import Part, DraftGeomUtils
pl = obj.Placement
if obj.Base:
if obj.Base.isDerivedFrom("Part::Feature"):
@@ -135,7 +133,7 @@ class _Window(ArchComponent.Component):
norm = shape.normalAt(0,0)
thk = float(obj.WindowParts[(i*5)+3])
if thk:
exv = fcvec.scaleTo(norm,thk)
exv = DraftVecUtils.scaleTo(norm,thk)
shape = shape.extrude(exv)
for w in wires:
f = Part.Face(w)
@@ -144,12 +142,12 @@ class _Window(ArchComponent.Component):
if obj.WindowParts[(i*5)+4]:
zof = float(obj.WindowParts[(i*5)+4])
if zof:
zov = fcvec.scaleTo(norm,zof)
zov = DraftVecUtils.scaleTo(norm,zof)
shape.translate(zov)
print shape
shapes.append(shape)
obj.Shape = Part.makeCompound(shapes)
if not fcgeo.isNull(pl):
if not DraftGeomUtils.isNull(pl):
obj.Placement = pl
class _ViewProviderWindow(ArchComponent.ViewProviderComponent):

View File

@@ -21,8 +21,7 @@
#* *
#***************************************************************************
import ifcReader, FreeCAD, Arch, Draft, os, sys, time, Part
from draftlibs import fcvec
import ifcReader, FreeCAD, Arch, Draft, os, sys, time, Part, DraftVecUtils
__title__="FreeCAD IFC importer"
__author__ = "Yorik van Havre"
@@ -448,7 +447,7 @@ def getPlacement(entity):
z = getVector(entity.Axis)
y = z.cross(x)
loc = getVector(entity.Location)
m = fcvec.getPlaneRotation(x,y,z)
m = DraftVecUtils.getPlaneRotation(x,y,z)
pl = FreeCAD.Placement(m)
pl.move(loc)
elif entity.type == "IFCLOCALPLACEMENT":

View File

@@ -21,8 +21,7 @@
#* *
#***************************************************************************
import FreeCAD
from draftlibs import fcgeo
import FreeCAD, DraftGeomUtils
if open.__module__ == '__builtin__':
pythonopen = open
@@ -42,7 +41,7 @@ def getIndices(shape,offset):
for f in shape.Faces:
fi = ""
# OCC vertices are unsorted. We need to sort in the right order...
edges = fcgeo.sortEdges(f.Wire.Edges)
edges = DraftGeomUtils.sortEdges(f.Wire.Edges)
print edges
for e in edges:
print e.Vertexes[0].Point,e.Vertexes[1].Point