Skip to content

Commit

Permalink
Misc. typos and whitespace fixes
Browse files Browse the repository at this point in the history
Found via `codespell -q 3 -L vertexes`
  • Loading branch information
luzpaz committed Nov 3, 2018
1 parent 13e8f69 commit dbfb0f4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 79 deletions.
4 changes: 2 additions & 2 deletions GuiA2p/Resources/ui/a2p_prefs.ui
Expand Up @@ -109,7 +109,7 @@
<item>
<widget class="Gui::PrefRadioButton" name="radioButton_3">
<property name="text">
<string>use relative pathes for imported parts</string>
<string>use relative paths for imported parts</string>
</property>
<property name="checked">
<bool>true</bool>
Expand All @@ -125,7 +125,7 @@
<item>
<widget class="Gui::PrefRadioButton" name="radioButton_4">
<property name="text">
<string>use absolute pathes for imported parts</string>
<string>use absolute paths for imported parts</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>useAbsolutePathes</cstring>
Expand Down
10 changes: 5 additions & 5 deletions a2p_importpart.py
Expand Up @@ -172,7 +172,7 @@ def importPartFromFile(_doc, filename, importToCache=False):
# Get the importDocument
#-------------------------------------------

# look only for filenames, not pathes, as there are problems on WIN10 (Address-translation??)
# look only for filenames, not paths, as there are problems on WIN10 (Address-translation??)
importDoc = None
importDocIsOpen = False
requestedFile = os.path.split(filename)[1]
Expand Down Expand Up @@ -283,7 +283,7 @@ def importPartFromFile(_doc, filename, importToCache=False):
withColor=True
)
else:
# TopoMapper manages import of non A2p-Files. It generates the shapes and appropiate topo names...
# TopoMapper manages import of non A2p-Files. It generates the shapes and appropriate topo names...
newObj.muxInfo, newObj.Shape, newObj.ViewObject.DiffuseColor = topoMapper.createTopoNames(withColor=True)


Expand Down Expand Up @@ -1121,8 +1121,8 @@ def Activated(self):

def GetResources(self):
return {
'MenuText': 'convert absolute pathes of importParts to relative ones',
'ToolTip': 'convert absolute pathes of importParts to relative ones'
'MenuText': 'convert absolute paths of importParts to relative ones',
'ToolTip': 'convert absolute paths of importParts to relative ones'
}
FreeCADGui.addCommand('a2p_absPath_to_relPath_Command', a2p_absPath_to_relPath_Command())

Expand All @@ -1140,7 +1140,7 @@ def importUpdateConstraintSubobjects( doc, oldObject, newObject ):
return


# check, wether object is an assembly with muxInformations.
# check, whether object is an assembly with muxInformations.
# Then find edgenames with mapping in muxinfo...
deletionList = [] #for broken constraints
if hasattr(oldObject, 'muxInfo'):
Expand Down
94 changes: 25 additions & 69 deletions a2p_topomapper.py
Expand Up @@ -29,7 +29,7 @@
Working principle:
- History of toplevel shapes within the fcstd doc is analyzed starting from
the very first basefeature (found recursively from toplevel shapes)
- The algorithm analyses the vertexes/edges/faces of each shape in history
- Each topo element is described by geometrical values (position,axis,etc)
- A dictionary is build, the geometrical values are used as keys and the
Expand All @@ -43,10 +43,10 @@
- Some geometry causes multiple keys. So for plane faces there are stored
two keys per vertex. One with positive axis value, one with neg.axis value.
This is necessary because normals can flip during build history.
Key-generation:
keys for vertexes: "xvalue;yvalue;zvalue"
keys for edges: (different ones for different edge types)
straight lines
2 keys are uses, each consists of:
Expand All @@ -57,18 +57,18 @@
- key consisting of center-vertex and positive axis data + radius
- key consisting of center-vertex and negative axis data + radius
- both marked with "CIRC" at the beginning
other edge types are put to dict with dummy entries.
keys for faces:
Plane faces are described by vertex/normal for each vertex.
Additionally a second entry by vertex/neg.normal for each vertex.
Spheres are described by center-vertex + radius
Cylindrical faces are described by vertex/pos.axis+radius and second one
with neg.axis per vertex.
Newer shapes in history can delete geo elements of previous ones. If the algorithm
finds one relicting key of an old shape in the dict, it assumes that the geo element
belongs to the old shape. Newly created geo elements, which belong together, then get
Expand Down Expand Up @@ -111,10 +111,10 @@ def __init__(self,doc):
self.totalNumVertexes = 0
self.totalNumEdges = 0
self.totalNumFaces = 0

def calcFloatKey(self,val):
return "%014.3f;" % val

def calcVertexKey(self,inOb):
'''
create a unique key defined by vertex-position,
Expand All @@ -138,7 +138,7 @@ def calcVertexKey(self,inOb):
if keyPartial == "-000000000.000;": keyPartial = "0000000000.000;"
key += keyPartial
return key

def calcAxisKey(self,axis):
'''
create a unique key defined by axis-direction
Expand All @@ -159,10 +159,10 @@ def calcEdgeKeys(self, edge, pl):
keys = []
#circular edge #hasattr(edge,"Curve") because of spheres...
if (
hasattr(edge,"Curve") and
hasattr(edge,"Curve") and
hasattr(edge.Curve,'Axis') and
hasattr(edge.Curve,'Radius')
):
):
axisStart = pl.multVec(edge.Curve.Center)
axisEnd = pl.multVec(edge.Curve.Center.add(edge.Curve.Axis))
axis = axisEnd.sub(axisStart)
Expand Down Expand Up @@ -191,7 +191,7 @@ def calcEdgeKeys(self, edge, pl):
self.calcAxisKey(direction2)
)
return keys

def calcFaceKeys(self, face, pl):
keys = []
# A sphere...
Expand Down Expand Up @@ -254,8 +254,8 @@ def calcFaceKeys(self, face, pl):
else:
keys.append("NOTRACE")
return keys #FIXME


def filterShapeObs(self,_list):
lst = []
for ob in _list:
Expand Down Expand Up @@ -296,7 +296,7 @@ def populateShapeDict(self,objName):
edgeNameSuffix = str(numNewlyCreatedEdges)+';'
i = 1 # do not enumerate the following, count new Edges !
for edge in edges:
edgeKeys = self.calcEdgeKeys(edge, pl) # 2 keys for a linear edge, 1 key per circular egde
edgeKeys = self.calcEdgeKeys(edge, pl) # 2 keys for a linear edge, 1 key per circular edge
entryFound=False
for k in edgeKeys:
tmp = self.shapeDict.get(k,False)
Expand Down Expand Up @@ -335,7 +335,7 @@ def populateShapeDict(self,objName):
faceName = tmp # the old face name...
for k in faceKeys:
self.shapeDict[k] = faceName

def processTopoData(self,objName,level=0):
'''
Recursive function which populates the
Expand All @@ -350,7 +350,7 @@ def processTopoData(self,objName,level=0):
objName not in self.doneObjects
):
self.populateShapeDict(objName)

def makePlacedShape(self,obj):
'''
return a copy of obj.Shape with proper placement applied
Expand All @@ -363,7 +363,7 @@ def makePlacedShape(self,obj):
pass
tempShape.Placement = plmGlobal
return tempShape

def getTopLevelObjects(self):
#-------------------------------------------
# Create treenodes of the importable Objects with a shape
Expand Down Expand Up @@ -406,12 +406,12 @@ def getTopLevelObjects(self):
for objName in self.topLevelShapes:
outObs.append(self.doc.getObject(objName))
return outObs


def createTopoNames(self,withColor=False):
'''
creates a combined shell of all toplevel objects and
assignes toponames to it's geometry if toponaming is
assigns toponames to its geometry if toponaming is
enabled.
'''
self.getTopLevelObjects()
Expand All @@ -430,7 +430,7 @@ def createTopoNames(self,withColor=False):
#-------------------------------------------
faces = []
faceColors = []

for objName in self.topLevelShapes:
ob = self.doc.getObject(objName)
colorFlag = ( len(ob.ViewObject.DiffuseColor) < len(ob.Shape.Faces) )
Expand All @@ -441,7 +441,7 @@ def createTopoNames(self,withColor=False):
# now start the loop with use of the stored values..(much faster)
for i, face in enumerate(tempShape.Faces):
faces.append(face)

if withColor:
if colorFlag:
faceColors.append(shapeCol)
Expand Down Expand Up @@ -486,47 +486,3 @@ def createTopoNames(self,withColor=False):
return muxInfo, shell, faceColors
else:
return muxInfo, shell












































6 changes: 3 additions & 3 deletions a2plib.py
Expand Up @@ -188,20 +188,20 @@ def findFile(name, path):
def findSourceFileInProject(pathImportPart, assemblyPath):
'''
#------------------------------------------------------------------------------------
# interprete the sourcefile name of imported part
# interpret the sourcefile name of imported part
# if working with preference "useProjectFolder:
# - path of sourcefile is ignored
# - filename is looked up beneath projectFolder
#
# if not working with preference "useProjectFolder":
# - path of sourcefile is checked for being relative to assembly or absolute
# - path is interpreted in appropiate way
# - path is interpreted in appropriate way
#------------------------------------------------------------------------------------
'''
preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/A2plus")
if not preferences.GetBool('useProjectFolder', False):
# not working with useProjectFolder preference,
# check wether path is relative or absolute...
# check whether path is relative or absolute...
if (
pathImportPart.startswith('../') or
pathImportPart.startswith('..\\') or
Expand Down

0 comments on commit dbfb0f4

Please sign in to comment.