Exemple #1
0
    def importSurfaces(self):
      ''' Import surfaces from DXF.'''

      for obj in self.dxfFile.entities:
        type= obj.dxftype
        layerName= obj.layer
        if(layerName in self.layersToImport):
            if(type == '3DFACE'):
                polygon= geom.Polygon3d()
                for pt in obj.points:
                    p= self.getPoint3d(pt)
                    polygon.append(p)
                self.labelDict[obj.handle]= [layerName]
            elif(type == 'POLYFACE'):
                lmsg.warning('Import of polyface objects not implemented yet.')
 def getGeomObject(self, pointDict):
     ''' Return the geometric object that represents this
         line, surface or volume.'''
     retval = None
     vertices = self.getVertices(pointDict)
     if (self.cellType == 'line'):
         p1 = vertices[0]
         retval = geom.Segment3d(vertices[0], vertices[1])
     elif (self.cellType == 'face'):
         retval = geom.Polygon3d(vertices)
     else:
         lmsg.error(
             'BlockRecord::getGeomObject not implemented for blocks of type: '
             + self.cellType)
     return retval
Exemple #3
0
def getIntermediatePoints(corners, nDiv):
    ''' Return a series of intermediate points uniformly distributed
        on the sides of the polygon argument.

        corners: list of point that define the original contour.
        nDiv: number of divisions on each side.
    '''
    pts = list()
    p0 = corners[0]
    for p in corners[1:]:
        sg = geom.Segment3d(p0, p)
        pts.extend(sg.Divide(nDiv)[:-1])
        p0 = p
    sg = geom.Segment3d(corners[-1], corners[0])
    pts.extend(sg.Divide(nDiv)[:-1])
    return geom.Polygon3d(pts)
Exemple #4
0
def getIntermediatePoints(corners, elemSide):
    ''' Return a series of intermediate points uniformly distributed
        on the sides of the polygon argument.

        corners: list of point that define the original contour.
        elemSide: length of the element side.
    ''' 
    pts= list()
    p0= corners[0]
    for p in corners[1:]:
        sg= geom.Segment3d(p0,p)
        nDiv= int(round_up_to_even(sg.getLength()/elemSide))
        pts.extend(sg.Divide(nDiv)[:-1])
        p0= p
    sg= geom.Segment3d(corners[-1],corners[0])
    nDiv= int(round_up_to_even(sg.getLength()/elemSide))
    pts.extend(sg.Divide(nDiv)[:-1])
    return geom.Polygon3d(pts)
Exemple #5
0
# yhB= list()
# for p in holeBPoints:
#     xhB.append(p.x)
#     yhB.append(p.y)

# plt.figure()
# plt.plot(xs,ys) 
# plt.scatter(xs, ys)
# plt.plot(xhA,yhA) 
# plt.scatter(xhA, yhA)
# plt.plot(xhB,yhB) 
# plt.scatter(xhB, yhB)
# plt.show()


plgExt= geom.Polygon3d(points)
plgIntA= geom.Polygon3d(holeAPoints)
plgIntB= geom.Polygon3d(holeBPoints)

paver= xc.Paver()

paver.mesh(plgExt,[plgIntA, plgIntB])

nodPos= paver.getNodePositions()
quads= paver.getQuads()

nNodPos= len(nodPos)
ratio1= (nNodPos-136)
nquads= len(quads)
ratio2= (nquads-88)
Exemple #6
0
from __future__ import division
from __future__ import print_function

__author__ = "Luis C. Pérez Tato (LCPT) and Ana Ortega (AOO)"
__copyright__ = "Copyright 2015, LCPT and AOO"
__license__ = "GPL"
__version__ = "3.0"
__email__ = "*****@*****.**"

import xc_base
import geom

plg = geom.Polygon3d([
    geom.Pos3d(0, 0, 0),
    geom.Pos3d(1, 0, 0),
    geom.Pos3d(1, 1, 0),
    geom.Pos3d(0, 1, 0)
])
center = plg.getCenterOfMass()

inside = plg.In(center, 1e-4)
'''
print('center: ', center, 'inside: ', inside)
'''

import os
fname = os.path.basename(__file__)
if inside:
    print("test " + fname + ": ok.")
else:
    print("test " + fname + ": ERROR.")
Exemple #7
0
import geom

vPoint = geom.Pos3d(0, 0, 100)
L = 10
skew = 0.999
p1 = geom.Pos3d(L, 0, 0)
p2 = geom.Pos3d(2 * L, 0, skew * L)
p3 = geom.Pos3d(2 * L, L, skew * L)
p4 = geom.Pos3d(L, L, 0)
skew = 1.001
p11 = geom.Pos3d(L, 0, 0)
p12 = geom.Pos3d(2 * L, 0, skew * L)
p13 = geom.Pos3d(2 * L, L, skew * L)
p14 = geom.Pos3d(L, L, 0)

plgA = geom.Polygon3d([p1, p2, p3, p4])
plgAK = plgA.getKVector()
plgAOrientation = plgA.orientation(vPoint)

plgB = geom.Polygon3d([p11, p12, p13, p14])
plgBK = plgB.getKVector()
plgBOrientation = plgB.orientation(vPoint)

plgC = geom.Polygon3d([p4, p3, p2, p1])
plgCK = plgC.getKVector()
plgCOrientation = plgC.orientation(vPoint)

ok = (plgAOrientation == "counterclockwise") and (
    plgBOrientation == "counterclockwise") and (plgCOrientation == "clockwise")
'''
print('polygon A k vector: ',plgAK, ' orientation: ', plgAOrientation)
Exemple #8
0
    
xh= list()
yh= list()
for p in holePoints:
    xh.append(p.x)
    yh.append(p.y)

plt.figure()
plt.plot(xs,ys) 
plt.scatter(xs, ys)
plt.plot(xh,yh) 
plt.scatter(xh, yh)
plt.show()
'''

plgExt = geom.Polygon3d(points)
plgInt = geom.Polygon3d(holePoints)

paver = xc.Paver()

paver.mesh(plgExt, [plgInt])

nodPos = paver.getNodePositions()
quads = paver.getQuads()

nNodPos = len(nodPos)
ratio1 = (nNodPos - 135)
nquads = len(quads)
ratio2 = (nquads - 99)
'''
# Draw quads
Exemple #9
0
points= getPoints(corners, nDiv= nDiv)

# # Draw polygon
# xs= list()
# ys= list()
# for p in points:
#     xs.append(p.x)
#     ys.append(p.y)

# plt.figure()
# plt.scatter(xs, ys)
# plt.plot(xs,ys) 
# plt.show()

plgExt= geom.Polygon3d(points)

paver= xc.Paver()

paver.mesh(plgExt,[])

nodPos= paver.getNodePositions()
quads= paver.getQuads()

nNodPos= len(nodPos)
ratio1= (nNodPos-81)
nquads= len(quads)
ratio2= (nquads-64)

# # Draw elements
# plg= list()
Exemple #10
0
__copyright__ = "Copyright 2015, LCPT and AOO"
__license__ = "GPL"
__version__ = "3.0"
__email__ = "*****@*****.**"

import xc_base
import geom

pointsA = [
    geom.Pos3d(0, 0, 0),
    geom.Pos3d(0, 1, 0),
    geom.Pos3d(0, 1, 1),
    geom.Pos3d(0, 0, 1)
]

plgA = geom.Polygon3d(pointsA)
centerA = plgA.getCenterOfMass()

dcA = plgA.dist(centerA)
ratio1 = dcA

dvA = -1e6
for p in pointsA:
    dvA = max(dvA, plgA.dist(p))

ratio2 = dvA

pointsB = [
    geom.Pos3d(1.97898, -2.045, 0.271598),
    geom.Pos3d(2.045, -2.045, 0.271598),
    geom.Pos3d(2.045, -2.045, 0),