def getIntersectionPoints(self,listOfPlines): '''Returns the intersection of a list of polylines with the plane.''' retval= geom.Polyline3d() for pline in listOfPlines: lp= pline.getIntersection(self.plane) retval.appendVertex(lp[0]) return retval
def createElementSet(self): '''Create the attributes 'length' and 'elemSet' that represent the length of the beam and the set of elements included in it.''' prep = self.getPreprocessor() if self.lstLines: lstLn = self.lstLines lstP3d = gu.lstP3d_from_lstLns(lstLn) elif self.lstPoints: lstP3d = [p.getPos for p in self.lstPoints] lstLn = gu.lstLns_from_lstPnts(self.lstPoints) else: lmsg.warning( 'Incomplete member definition: list of lines or points required' ) #set of elements included in the member s = prep.getSets.defSet(self.name + 'Set') self.elemSet = s.elements for l in lstLn: for e in l.elements: self.elemSet.append(e) pol = geom.Polyline3d() for p in lstP3d: pol.append(p) self.length = pol.getLength() return pol
def get_polygon_axis(points, tol): '''Compute the polygon axis on the assumption that they all the sides are orthogonal.''' pline= geom.Polyline3d() for p in points: pline.appendVertex(geom.Pos3d(p[0],p[1],p[2])) pline.simplify(tol) pt0= pline[1] pt1= pline[2] pt2= pline[3] v1= pt0-pt1 v2= pt2-pt1 return geom.Ref3d3d(pt1,v1,v2)
def importPolylines(self): ''' Import polylines from DXF.''' for obj in self.dxfFile.entities: type= obj.dxftype plineName= obj.handle layerName= obj.layer if(layerName in self.layersToImport): if((type == 'POLYLINE') or (type == 'LWPOLYLINE')): polyline= geom.Polyline3d() for p in obj.points: rCoo= self.getPoint3d(p) polyline.append(self.getIndexNearestPoint(rCoo)) self.labelDict[plineName]= [layerName]
def setControlPoints(self): '''Set the five equally spaced points in the beam where the moment Mz will be evaluated in order to obtain the moment gradient factor involved in the calculation of the lateral-torsional buckling reduction factor. That moment gradient factor will be calculated following the general expression proposed by A. López, D. J. Yong, M. A. Serna. An attribute of EC3Beam is created, named 'contrPnt' that contains a list of five tuples (elem,relativDist), each of which contains the element of the beam nearest to one control-point and the relative distance from this control point to the first node of the element. The method also creates the attributes 'length' and 'elemSet' that represent the lenght of the beam and the set of elements included in it. ''' prep = self.getPreprocessor() if self.lstLines: lstLn = self.lstLines lstP3d = gu.lstP3d_from_lstLns(lstLn) elif self.lstPoints: lstP3d = [p.getPos for p in self.lstPoints] lstLn = gu.lstLns_from_lstPnts(self.lstPoints) else: lmsg.warning( 'Beam insufficiently defined: list of lines or points required' ) #set of elements included in the EC3beam s = prep.getSets.defSet(self.name + 'Set') self.elemSet = s.getElements for l in lstLn: for e in l.getElements(): self.elemSet.append(e) pol = geom.Polyline3d() for p in lstP3d: pol.append(p) self.length = pol.getLength() lstEqPos3d = gu.lstEquPnts_from_polyline( pol, nDiv=4) #(five points equally spaced) lstEqElem = [self.elemSet.getNearestElement(p) for p in lstEqPos3d] self.contrPnt = list() for i in range(5): elem = lstEqElem[i] elSegm = elem.getLineSegment(0) relDistPointInElem = (lstEqPos3d[i] - elSegm.getOrigen() ).getModulo() / elSegm.getLength() self.contrPnt.append((elem, relDistPointInElem)) return
# -*- coding: utf-8 -*- from __future__ import print_function import xc_base import geom import math pol1 = geom.Polyline3d() pol2 = geom.Polyline3d() pol1.appendVertex(geom.Pos3d(0, 0, 0)) pol1.appendVertex(geom.Pos3d(1, 0, 0)) pol1.appendVertex(geom.Pos3d(1, 1, 0)) pol1.appendVertex(geom.Pos3d(0, 1, 0)) longPol1 = pol1.getLength() o = geom.Pos3d(0.5, 0, 0) p1 = geom.Pos3d(0.5, 1, 0) p2 = geom.Pos3d(0.5, 0, 1) plane = geom.Plane3d(o, p1, p2) lp = pol1.getIntersection(plane) ptInt = lp[0] ratio1 = (longPol1 - 3) / 3. ratio2 = ptInt.dist(o) # print("ratio1= ", ratio1) # print("ratio2= ", ratio2)
def setControlPoints(self): '''Set the five equally spaced points in the beam where the moment Mz will be evaluated in order to obtain the moment gradient factor involved in the calculation of the lateral-torsional buckling reduction factor. That moment gradient factor will be calculated following the general expression proposed by A. López, D. J. Yong, M. A. Serna. An attribute of EC3Beam is created, named 'contrPnt' that contains a list of five tuples (elem,relativDist), each of which contains the element of the beam nearest to one control-point and the relative distance from this control point to the first node of the element. The method also creates the attributes 'length' and 'elemSet' that represent the lenght of the beam and the set of elements included in it. ''' if self.lstLines: lstLn = self.lstLines pointsHandler = lstLn[ 0].getPreprocessor.getMultiBlockTopology.getPoints lstP3d = [ pointsHandler.get(l.getKPoints()[0]).getPos for l in lstLn ] lstP3d.append(pointsHandler.get(lstLn[-1].getKPoints()[1]).getPos) elif self.lstPoints: lstP3d = [p.getPos for p in self.lstPoints] lstLn = [ smg.get_lin_2Pts(self.lstPoints[i], self.lstPoints[i + 1]) for i in range(len(self.lstPoints) - 1) ] lstLn.append( smg.get_lin_2Pts(self.lstPoints[-2], self.lstPoints[-1])) else: lmsg.warning( 'Beam insufficiently defined: list of lines or points required' ) #set of elements included in the EC3beam s = lstLn[0].getPreprocessor.getSets.defSet(self.name + 'Set') self.elemSet = s.getElements for l in lstLn: for e in l.getElements(): self.elemSet.append(e) nmbSpac = 4 # number of divisions (five points equally spaced) pol = geom.Polyline3d() for p in lstP3d: pol.append(p) self.length = pol.getLength() nTotSegm = pol.getNumSegments() eqDistCP = .25 * self.length #equidistance between control points nmbCP = nmbSpac - 1 #number of intermediate control points cumLength = 0 #cumulate length in the polyline nmbSegm = 1 #starting number of segment self.contrPnt = list() firstPnt = lstP3d[0] self.contrPnt.append((lstLn[0].getNearestElement(firstPnt), 0)) for i in range(1, nmbCP + 1): #intermediate points lengthCP = i * eqDistCP - cumLength for j in range(nmbSegm, nTotSegm + 1): sg = pol.getSegment(j) LSegm = sg.getLength() if lengthCP < LSegm: pnt = sg.getPoint(lengthCP / LSegm) elem = lstLn[nmbSegm - 1].getNearestElement(pnt) elSegm = elem.getLineSegment(0) relDistPointInElem = (pnt - elSegm.getOrigen() ).getModulo() / elSegm.getLength() self.contrPnt.append((elem, relDistPointInElem)) break else: nmbSegm += 1 cumLength += LSegm lengthCP -= LSegm lastPnt = lstP3d[-1] self.contrPnt.append((lstLn[-1].getNearestElement(lastPnt), 1)) return
# -*- coding: utf-8 -*- #Home made test. Verification of Douglas Peucker algorithm implementation. import xc_base import geom import math polA=geom.Polyline3d() polA.appendVertex(geom.Pos3d(0,0,0)) #1 polA.appendVertex(geom.Pos3d(0.001,0.5,0.09)) #2 (to erase) polA.appendVertex(geom.Pos3d(0,1,0)) #3 polA.appendVertex(geom.Pos3d(0.002,1.001,0.5)) #4 (to erase) polA.appendVertex(geom.Pos3d(0,1,1)) #5 polA.appendVertex(geom.Pos3d(0,2,1)) #6 polA.appendVertex(geom.Pos3d(0,2,2)) #7 polA.appendVertex(geom.Pos3d(0,1,2)) #8 polA.appendVertex(geom.Pos3d(0,1,1)) #9 polA.appendVertex(geom.Pos3d(0,0,1)) #10 polB= geom.Polyline3d(polA) polB.appendVertex(geom.Pos3d(0,0,0)) #11 CAN BE CLOSED. nv0A= polA.getNumVertices() polA.simplify(0.1) nv1A= polA.getNumVertices() nv0B= polB.getNumVertices() polB.simplify(0.1) nv1B= polB.getNumVertices()