231 lines
5.6 KiB
Python
231 lines
5.6 KiB
Python
|
|
#-------关联C++库---------------
|
|||
|
|
import ctypes
|
|||
|
|
from ctypes import *
|
|||
|
|
import platform
|
|||
|
|
system = platform.system()
|
|||
|
|
if system == "Windows":
|
|||
|
|
pre = "./"
|
|||
|
|
suff = ".dll"
|
|||
|
|
else:
|
|||
|
|
pre = "./lib"
|
|||
|
|
suff = ".so"
|
|||
|
|
|
|||
|
|
libfile = ctypes.cdll.LoadLibrary
|
|||
|
|
filename = pre+"MeshCommand"+suff
|
|||
|
|
lib = libfile(filename)
|
|||
|
|
|
|||
|
|
#lib.getKernalNameByIndexPy.restype=ctypes.c_char_p
|
|||
|
|
#lib.getKernalNameByKidPy.restype=ctypes.c_char_p
|
|||
|
|
#lib.getSetNameByIndexPy.restype=ctypes.c_char_p
|
|||
|
|
#lib.getSetNameBySidPy.restype=ctypes.c_char_p
|
|||
|
|
|
|||
|
|
def getKernalCount():
|
|||
|
|
count = lib.getKernalCountPy()
|
|||
|
|
return count
|
|||
|
|
|
|||
|
|
def getKernalNameByIndex(index):
|
|||
|
|
name = lib.getKernalNameByIndexPy(index)
|
|||
|
|
pyname = name.decode()
|
|||
|
|
return pyname
|
|||
|
|
|
|||
|
|
def getKernalNameByKid(kid):
|
|||
|
|
name = lib.getKernalNameByKidPy(kid)
|
|||
|
|
pyname = name.decode()
|
|||
|
|
return pyname
|
|||
|
|
|
|||
|
|
def removeKernalByIndex(index):
|
|||
|
|
lib.removeKernalByIndexPy(index)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def removeKernalByKid(kid):
|
|||
|
|
lib.removeKernalByKidPy(kid)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def getSetCount():
|
|||
|
|
count = lib.getSetCountPy()
|
|||
|
|
return count
|
|||
|
|
|
|||
|
|
def getSetNameByIndex(index):
|
|||
|
|
name = lib.getSetNameByIndexPy(index)
|
|||
|
|
pyname = name.decode()
|
|||
|
|
return pyname
|
|||
|
|
|
|||
|
|
def getSetNameBySid(sid):
|
|||
|
|
name = lib.getSetNameBySidPy(sid)
|
|||
|
|
pyname = name.decode()
|
|||
|
|
return pyname
|
|||
|
|
|
|||
|
|
def removeSetByIndex(index):
|
|||
|
|
lib.removeSetByIndexPy(index)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def clear():
|
|||
|
|
lib.clearPy()
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def generateDisplayDataSet():
|
|||
|
|
lib.generateDisplayDataSetPy()
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def DeleteMeshKernal(idString):
|
|||
|
|
idstr = bytes(idString, encoding="utf-8")
|
|||
|
|
lib.DeleteMeshKernal(
|
|||
|
|
idstr,
|
|||
|
|
)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def DeleteMeshGroup(idString):
|
|||
|
|
idstr = bytes(idString, encoding="utf-8")
|
|||
|
|
lib.DeleteMeshGroup(
|
|||
|
|
idstr,
|
|||
|
|
)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def DeleteMeshCell(idString):
|
|||
|
|
idstr = bytes(idString, encoding="utf-8")
|
|||
|
|
lib.DeleteMeshCell(
|
|||
|
|
idstr,
|
|||
|
|
)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def GroupSetColor(colorName, kernalGroupIDQstring):
|
|||
|
|
colornamestr = bytes(colorName, encoding="utf-8")
|
|||
|
|
kernalGroupIDString = bytes(kernalGroupIDQstring, encoding="utf-8")
|
|||
|
|
lib.GroupSetColor(colornamestr, kernalGroupIDString)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def ImportMesh(filename,suffix,modelID):
|
|||
|
|
str = bytes(filename,encoding='utf-8')
|
|||
|
|
suf = bytes(suffix,encoding='utf-8')
|
|||
|
|
lib.ImportMesh(str,suf,modelID)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def RenameGroup(nameString, kernalGroupIDListString):
|
|||
|
|
namestr = bytes(nameString, encoding="utf-8")
|
|||
|
|
kernalGroupIDListstr = bytes(kernalGroupIDListString, encoding="utf-8")
|
|||
|
|
lib.RenameGroup(namestr, kernalGroupIDListstr)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def RenameKernal(nameString, kernalIDListString):
|
|||
|
|
namestr = bytes(nameString, encoding="utf-8")
|
|||
|
|
kernalIDListstr = bytes(kernalIDListString, encoding="utf-8")
|
|||
|
|
lib.RenameKernal(namestr, kernalIDListstr)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def ShowHideMeshKernal(kernalIDString):
|
|||
|
|
idstr = bytes(kernalIDString, encoding="utf-8")
|
|||
|
|
lib.ShowHideMeshKernal(
|
|||
|
|
idstr,
|
|||
|
|
)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
def ShowHideMeshGroup(groupsIDString):
|
|||
|
|
idstr = bytes(groupsIDString, encoding="utf-8")
|
|||
|
|
lib.ShowHideMeshGroup(
|
|||
|
|
idstr,
|
|||
|
|
)
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
class MeshMove:
|
|||
|
|
def __init__(self):
|
|||
|
|
self.startpt0 = 0
|
|||
|
|
self.startpt1 = 0
|
|||
|
|
self.startpt2 = 0
|
|||
|
|
self.endpt0 = 0
|
|||
|
|
self.endpt1 = 0
|
|||
|
|
self.endpt2 = 0
|
|||
|
|
self.length = 10
|
|||
|
|
self.dir0 = 0
|
|||
|
|
self.dir1 = 0
|
|||
|
|
self.dir2 = 0
|
|||
|
|
self.reverse = "false"
|
|||
|
|
|
|||
|
|
def setStartPoint(self, startpt0, startpt1, startpt2):
|
|||
|
|
self.startpt0 = startpt0
|
|||
|
|
self.startpt1 = startpt1
|
|||
|
|
self.startpt2 = startpt2
|
|||
|
|
|
|||
|
|
def setEndPoint(self, endpt0, endpt1, endpt2):
|
|||
|
|
self.endpt0 = endpt0
|
|||
|
|
self.endpt1 = endpt1
|
|||
|
|
self.endpt2 = endpt2
|
|||
|
|
|
|||
|
|
def setReverse(self, reverse):
|
|||
|
|
self.reverse = reverse
|
|||
|
|
|
|||
|
|
def setLength(self, length):
|
|||
|
|
self.length = length
|
|||
|
|
|
|||
|
|
def setDirection(self, dir0, dir1, dir2):
|
|||
|
|
self.dir0 = dir0
|
|||
|
|
self.dir1 = dir1
|
|||
|
|
self.dir2 = dir2
|
|||
|
|
|
|||
|
|
def create(self):
|
|||
|
|
reversestr = bytes(self.reverse, encoding="utf-8")
|
|||
|
|
lib.CreateMoveFeature(
|
|||
|
|
c_double(self.startpt0),
|
|||
|
|
c_double(self.startpt1),
|
|||
|
|
c_double(self.startpt2),
|
|||
|
|
c_double(self.endpt0),
|
|||
|
|
c_double(self.endpt1),
|
|||
|
|
c_double(self.endpt2),
|
|||
|
|
reversestr,
|
|||
|
|
c_double(self.length),
|
|||
|
|
c_double(self.dir0),
|
|||
|
|
c_double(self.dir1),
|
|||
|
|
c_double(self.dir2),
|
|||
|
|
)
|
|||
|
|
del self
|
|||
|
|
|
|||
|
|
def edit(self):
|
|||
|
|
reversestr = bytes(self.reverse, encoding="utf-8")
|
|||
|
|
lib.EditMoveFeature(
|
|||
|
|
c_double(self.startpt0),
|
|||
|
|
c_double(self.startpt1),
|
|||
|
|
c_double(self.startpt2),
|
|||
|
|
c_double(self.endpt0),
|
|||
|
|
c_double(self.endpt1),
|
|||
|
|
c_double(self.endpt2),
|
|||
|
|
reversestr,
|
|||
|
|
c_double(self.length),
|
|||
|
|
c_double(self.dir0),
|
|||
|
|
c_double(self.dir1),
|
|||
|
|
c_double(self.dir2),
|
|||
|
|
)
|
|||
|
|
del self
|
|||
|
|
|
|||
|
|
class MeshFindDistortionCell:
|
|||
|
|
def __init__(self):
|
|||
|
|
self.type = 0
|
|||
|
|
self.angle = 0
|
|||
|
|
self.IDs = dict()
|
|||
|
|
|
|||
|
|
def setType(self, meshtype):
|
|||
|
|
self.type = meshtype
|
|||
|
|
|
|||
|
|
def setAngle(self, angle):
|
|||
|
|
self.angle = angle
|
|||
|
|
|
|||
|
|
def setKernalGroupID(self, mainID, subID):
|
|||
|
|
self.IDs.setdefault(mainID, set()).add(subID)
|
|||
|
|
|
|||
|
|
def create(self):
|
|||
|
|
keyList = self.IDs.keys()
|
|||
|
|
strcom = ""
|
|||
|
|
for key in keyList:
|
|||
|
|
setstr = ""
|
|||
|
|
values = self.IDs.get(key)
|
|||
|
|
for v in values:
|
|||
|
|
setstr = setstr + str(v) + ","
|
|||
|
|
setstr = str(key) + ":" + setstr[:-1]
|
|||
|
|
strcom = strcom + setstr + ";"
|
|||
|
|
strcom = strcom[:-1]
|
|||
|
|
IDsstr = bytes(strcom, encoding="utf-8")
|
|||
|
|
lib.FindMeshDistortionCell(
|
|||
|
|
c_int(self.type),
|
|||
|
|
c_double(self.angle),
|
|||
|
|
IDsstr,
|
|||
|
|
)
|
|||
|
|
del self
|