示例#1
0
def PointsDistance(aPoint1, aPoint2):
    point1Coords = geompy.PointCoordinates(aPoint1)
    point2Coords = geompy.PointCoordinates(aPoint2)
    diffCoords = 0
    for jCoord in range(0, 3):
        diffCoords = diffCoords + math.pow(
            (point1Coords[jCoord] - point2Coords[jCoord]), 2)
    diffCoords = math.sqrt(diffCoords)
    return diffCoords
示例#2
0
def EdgeEndsOnCoordinate(aEdge, aCoordValue, aCoord, aTol):
    edgePoints = geompy.SubShapeAll(aEdge, geompy.ShapeType["EDGE"])
    edgeCoord1 = geompy.PointCoordinates(edgePoints[0])
    edgeCoord2 = geompy.PointCoordinates(edgePoints[1])
    tol = math.fabs(aCoordValue -
                    edgeCoord1[aCoord]) + fabs(aCoordValue -
                                               edgeCoord2[aCoord])
    if aTol >= tol:
        return 1
    return 0
示例#3
0
def PointLessRadius(aPoint, aCenter, aRadius, aTol):
    pointCoords = geompy.PointCoordinates(aPoint)
    centrCoords = geompy.PointCoordinates(aCenter)
    radVect = [0, 0, 0]
    rad = 0
    for jC in range(0, 3):
        radVect[jC] = math.pow(pointCoords[jC] - centrCoords[jC], 2)
        rad = rad + radVect[jC]
    rad = math.sqrt(rad)
    if rad < aRadius:
        return 1
    return 0
示例#4
0
def VectorNorm(aVector):
    vectorNorm = [1., 1., 1.]
    vectorMag = 0.
    edgePoints = geompy.SubShapeAll(aVector, geompy.ShapeType["VERTEX"])
    pointCoords0 = geompy.PointCoordinates(edgePoints[0])
    pointCoords1 = geompy.PointCoordinates(edgePoints[1])
    vLen = len(pointCoords0)
    for j in range(0, vLen):
        vectorNorm[j] = pointCoords1[j] - pointCoords0[j]
    for j in range(0, vLen):
        vectorMag = vectorMag + vectorNorm[j] * vectorNorm[j]
    vectorMag = math.sqrt(vectorMag)
    if vectorMag > 1.0E-30:
        for j in range(0, vLen):
            vectorNorm[j] = vectorNorm[j] / vectorMag
    return vectorNorm
示例#5
0
def CreateGEOM(injLens, injRads, injAngs, wallS):
	L1 = injLens[0]
	L2 = injLens[1]
	L3 = injLens[2]
	L4 = injLens[3]
	L5 = injLens[4]
	L6 = injLens[5]
	#
	R0 = injRads[0]
	R1 = injRads[1]
	R2 = injRads[2]
	R3 = injRads[3]
	R4 = injRads[4]
	#
	A1 = injAngs[0]
	#
	S  = wallS
	#
	# Printing input
	#
	LSUMM = L1 + L2 + L3 + L4 + L5 + L6
	DX1= math.tan(A1*math.pi/180.)*L3 + R3 - R0
	#
	print "Input Data"
	print "L1, L2, L3, L4, L5, L6"
	print L1, L2, L3, L4, L5, L6
	print "R0, R1, R2, R3, R4"
	print R0, R1, R2, R3, R4
	print "A1 = ", A1
	print "S = ", S
	#
	print "Intermediate variables: "
	print "LSUMM = ", LSUMM
	print "DX1 = ", DX1
	#
	#
	#
	#
	oXYZ = geompy.MakeVertex(0, 0, 0)
	xPnt = geompy.MakeVertex(1, 0, 0)
	yPnt = geompy.MakeVertex(0, 1, 0)
	zPnt = geompy.MakeVertex(0, 0, 1)
	oX   = geompy.MakeVector(oXYZ, xPnt)
	oY   = geompy.MakeVector(oXYZ, yPnt)
	oZ   = geompy.MakeVector(oXYZ, zPnt)
	#
	# Inlet and nozzle points and faces
	#
	P000 = geompy.MakeVertexWithRef(oXYZ, -(L1+L2), R1, 0)
	P001 = geompy.MakeVertexWithRef(oXYZ, -L2, R1, 0)
	P002 = geompy.MakeVertexWithRef(oXYZ, -L2, 0, 0)
	P003 = geompy.MakeVertexWithRef(oXYZ, -(L1+L2), 0, 0)
	#
	P004 = geompy.MakeVertexWithRef(oXYZ, 0, R2, 0)
	P005 = geompy.MakeVertexWithRef(oXYZ, 0, 0, 0)
	#
	P006 = geompy.MakeVertexWithRef(P000, 0, S, 0)
	P007 = geompy.MakeVertexWithRef(P006, L1,0, 0)
	P008 = geompy.MakeVertexWithRef(oXYZ, DX1,R0,0)
	P009 = geompy.MakeVertexWithRef(oXYZ, -(L1+L2), R0, 0)
	#
	F000 = geompy.MakeQuad4Vertices(P000, P001, P002, P003)
	F001 = geompy.MakeQuad4Vertices(P001, P002, P005, P004)
	F002 = geompy.MakeQuad4Vertices(P006, P007, P008, P009)
	#
	# Mixing chamber
	#
	P009 = geompy.MakeVertexWithRef(P004, 0, S, 0)
	P010 = geompy.MakeVertexWithRef(P005, L3,0, 0)
	P011 = geompy.MakeVertexWithRef(P010, 0,R3, 0)
	E000 = geompy.MakeLineTwoPnt(P008, P011)
	P012 = geompy.MakeVertexOnCurve(E000,0.9)
	P013 = geompy.MakeVertexWithRef(P010, L4, 0, 0)
	P014 = geompy.MakeVertexWithRef(P013, 0, R3, 0)
	#
	F003 = geompy.MakeQuad4Vertices(P009, P007, P008, P012)
	F004 = geompy.MakeQuad4Vertices(P004, P009, P012, P011)
	F005 = geompy.MakeQuad4Vertices(P004, P005, P010, P011)
	F006 = geompy.MakeQuad4Vertices(P010, P011, P014, P013)
	#
	# Diffusor and out tube
	#
	P015 = geompy.MakeVertexWithRef(P013, L5, 0, 0)
	P016 = geompy.MakeVertexWithRef(P015, 0, R4, 0)
	P017 = geompy.MakeVertexWithRef(P016, L6, 0, 0)
	P018 = geompy.MakeVertexWithRef(P017, 0, -R4,0)
	#
	F007 = geompy.MakeQuad4Vertices(P013, P014, P016, P015)
	F008 = geompy.MakeQuad4Vertices(P015, P016, P017, P018)
	#
	faceComp = geompy.MakeShell([F000, F001, F002, F003, F004, F005, F006, F007, F008])
	# 
	# Solid geomtry
	#
	sBase1 = geompy.MakeRotation(faceComp, oX, 0)
	sBase2 = geompy.MakeRotation(sBase1, oX, 45.*math.pi/180.)
	sBase3 = geompy.MakeRotation(sBase2, oX, 90.*math.pi/180.)
	#
	solid1 = geompy.MakeRevolution(sBase1, oX, 45.*math.pi/180.)
	solid2 = geompy.MakeRevolution(sBase2, oX, 90.*math.pi/180.)
	solid3 = geompy.MakeRevolution(sBase3, oX, 45.*math.pi/180.)
	#
	# Cutters
	#
	E002 = geompy.MakeLineTwoPnt(P005, P004)
	E003 = geompy.MakeRotation(E002, oX, 45.*math.pi/180.)
	E004 = geompy.MakeRotation(E003, oX, 90.*math.pi/180.)
	E005 = geompy.MakeRotation(E004, oX, 45.*math.pi/180.)
	P019 = geompy.MakeVertexOnCurve(E002,0.5)
	P020 = geompy.MakeVertexOnCurve(E003,0.5)
	P021 = geompy.MakeVertexOnCurve(E004,0.5)
	P022 = geompy.MakeVertexOnCurve(E005,0.5)
	zmin = geompy.PointCoordinates(oXYZ)[2]
	zmax = geompy.PointCoordinates(P020)[2]
	ymin = geompy.PointCoordinates(P022)[1]
	ymax = geompy.PointCoordinates(P019)[1]
	print "ymin, ymax, zmin, zmax"
	print ymin, ymax, zmin, zmax
	#
	E006 = geompy.MakeLineTwoPnt(P019, P020)
	E007 = geompy.MakeLineTwoPnt(P020, P021)
	E008 = geompy.MakeLineTwoPnt(P021, P022)
	E009 = geompy.MakeLineTwoPnt(P021, P022)
	edgeComp1 = geompy.MakeCompound([E006, E007, E008, E009])
	edgeComp2 = geompy.MakeTranslation(edgeComp1, -(2*L1 + 2*L2), 0, 0)
	cutter1 = geompy.MakePrismVecH(edgeComp2, oX, LSUMM*2)
	#
	# Hexa solid
	#
	solid1_hex_v1 = geompy.MakePartition([solid1], [cutter1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
	solid2_hex_v1 = geompy.MakePartition([solid2], [cutter1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
	solid3_hex_v1 = geompy.MakePartition([solid3], [cutter1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
	dom_v1 = geompy.MakeCompound([solid1_hex_v1, solid2_hex_v1, solid3_hex_v1])
	hsolids1 = geompy.SubShapeAll(dom_v1, geompy.ShapeType["SOLID"])
	nSolids = len(hsolids1)
	hsolids2 = []
	for jSolid in xrange(0,nSolids):
		solidCDG = geompy.MakeCDG(hsolids1[jSolid])
		coordCDG = geompy.PointCoordinates(solidCDG)
		ys = coordCDG[1]
		zs = coordCDG[2]
		zOk = (zs >= zmin) * (zs <= zmax)
		yOk = (ys >= ymin) * (ys <= ymax)
		if not(zOk and yOk):
			hsolids2.append(hsolids1[jSolid])
	
	# Creasting hexahedrons near the center
	sBase4 = geompy.MakeQuad4Vertices(P019, P020, P021, P022)
	sBase5 = geompy.MakeTranslation(sBase4, -(L1 + L2), 0, 0)
	hsolids2.append(geompy.MakePrismVecH(sBase5, oX, L1))
	sBase6 = geompy.MakeTranslation(sBase5, L1, 0, 0)
	hsolids2.append(geompy.MakePrismVecH(sBase6, oX, L2))
	sBase7 = geompy.MakeTranslation(sBase6, L2, 0, 0)
	hsolids2.append(geompy.MakePrismVecH(sBase7, oX, L3))
	sBase8 = geompy.MakeTranslation(sBase7, L3, 0, 0)
	hsolids2.append(geompy.MakePrismVecH(sBase8, oX, L4))
	sBase9 = geompy.MakeTranslation(sBase8, L4, 0, 0)
	hsolids2.append(geompy.MakePrismVecH(sBase9, oX, L5))
	sBase10= geompy.MakeTranslation(sBase9,L5, 0, 0)
	hsolids2.append(geompy.MakePrismVecH(sBase10, oX, L6))
	#
	# Domain 
	#
	dom_v2   = geompy.MakeCompound(hsolids2)
	dom_comp = geompy.MakeGlueFaces(dom_v2,1.0E-6)
	return dom_comp
示例#6
0
def injectorFaceGroups (injGeom, aInjLens, aInjRads, aWallS ,aTol):
	#
	L1=     aInjLens[0]
	L2=     aInjLens[1]
	L3=     aInjLens[2]
	L4=     aInjLens[3]
	L5=     aInjLens[4]
	L6=     aInjLens[5]
	#
	R0=     aInjRads[0]
	R1=     aInjRads[1]
	R2=     aInjRads[2]
	R3=     aInjRads[3]
	R4=     aInjRads[4]
	#
	S =     aWallS
	#
	RMAX  = R0
	LSUMM = L1 + L2 + L3 + L4 + L5 + L6
	XMIN  = -L1 -L2
	XMAX  = LSUMM + XMIN
	HALFR2= R2*0.5
	#
	vertex1 = geompy.MakeVertex(0, 0, 0)
	vertex2 = geompy.MakeVertex(0, 0, 1)
	vector1 = geompy.MakeVector(vertex1, vertex2)
	#
	vertex3 = geompy.MakeVertex(1, 0, 0)
	vertex4 = geompy.MakeVertex(XMIN, 0, 0)
	Xvector = geompy.MakeVector(vertex1, vertex3)
	#
	symmWalls = faceSelect.SelectFacesWithNormalParallelToVec(injGeom, [vector1], aTol)
	#
	# now, remove all faces which are in small quadrangle 
	#
	selGroup0faces = []
	selGroup0faces = geompy.SubShapeAll(symmWalls, geompy.ShapeType["FACE"])
	nFaces = len(selGroup0faces)
	idsToRemove = []
	nToRemove=0
	for jFace in range(0,nFaces):
		jFaceCOM  = geompy.MakeCDG(selGroup0faces[jFace])
		COMCoords = geompy.PointCoordinates(jFaceCOM)
		jFaceID   = geompy.GetSubShapeID(injGeom, selGroup0faces[jFace])
		ZCoord = COMCoords[2]
		Cond   = (ZCoord >= aTol)
		if Cond:
			idsToRemove.append (jFaceID)
			nToRemove = nToRemove + 1
	print  "---"
	print nToRemove
	print  "---"
	#
	for jFace in range(0,nToRemove):
		geompy.RemoveObject(symmWalls, idsToRemove[jFace])
	#
	id_symmWalls = geompy.addToStudyInFather(injGeom,symmWalls,"symm-walls")
	#
	activeInlet    = faceSelect.SelectFacesWithCoordinateAndLessRadius(injGeom,XMIN,0,vertex4,R1, aTol)
	id_activeInlet = geompy.addToStudyInFather(injGeom,activeInlet,"active-inlet")
	#
	passiveInlet    = faceSelect.SelectFacesWithCoordinateAndGreaterRadius(injGeom,XMIN,0,vertex4,R1+S, aTol)
	id_passiveInlet = geompy.addToStudyInFather(injGeom,passiveInlet,"passive-inlet")
	
	Outlet = faceSelect.SelectFacesWithCOM_OnCoordinate(injGeom, XMAX, 0, aTol)
	id_Outlet = geompy.addToStudyInFather(injGeom,Outlet,"outlet")
	#
	faceGroups = [symmWalls, activeInlet, passiveInlet, Outlet]
	return faceGroups
示例#7
0
    def getnodebyintersection(shape,
                              porigine,
                              vect,
                              default=(0, 0, 0),
                              extend=10,
                              tolerance=0.1):
        p0 = geompy.MakeVertex(porigine[0] + extend * vect[0],
                               porigine[1] + extend * vect[1],
                               porigine[2] + extend * vect[2])
        p1 = geompy.MakeVertex(porigine[0] - extend * vect[0],
                               porigine[1] - extend * vect[1],
                               porigine[2] - extend * vect[2])
        line = geompy.MakeLineTwoPnt(p0, p1)
        partition = geompy.MakeHalfPartition(line, shape)

        # recherche du point de la partition par difference avec les premiers points
        #remplir les localisation des points
        subnew = geompy.SubShapeAllSorted(partition,
                                          geompy.ShapeType["VERTEX"])
        subnewp = []
        for a in subnew:
            subnewp.append(geompy.PointCoordinates(a))
        subold = geompy.SubShapeAllSorted(line, geompy.ShapeType["VERTEX"])
        #recuperarion des deux extremite existante de la ligne
        suboldp = []
        for a in subold:
            suboldp.append(geompy.PointCoordinates(a))

        #    #affichage pour debug
        #gg = salome.ImportComponentGUI("GEOM")
        #id_partition= geompy.addToStudy(partition,"Partitionfun")
        #gg.createAndDisplayGO(id_partition)
        #id_line= geompy.addToStudy(line,"linefun")
        #gg.createAndDisplayGO(id_line)
        #gg.setDisplayMode(id_partition,1)
        #
        #print subnewp
        #print suboldp

        if (len(subnew) == len(subold)):
            print "default", default
            return default
        else:
            couple = []
            for i in range(0, len(subold)):
                oldpts = suboldp[i]
                ii = 0
                poursuite = True
                while (ii < len(subnew) and poursuite):
                    newpts = subnewp[ii]
                    if not (ii in couple):
                        #print "i",i,"ii",ii
                        #print "match",newpts,oldpts
                        #print "test",abs(oldpts[0]-newpts[0])+abs(oldpts[1]-newpts[1])+abs(oldpts[2]-newpts[2])
                        if (abs(oldpts[0] - newpts[0]) +
                                abs(oldpts[1] - newpts[1]) +
                                abs(oldpts[2] - newpts[2]) < tolerance):
                            #print "match",newpts,oldpts
                            poursuite = False
                            couple.append(ii)
                    ii += 1
            for i in range(0, len(subnew)):
                if (not (i in couple)):
                    #print "subnewp[i]",subnewp[i]
                    return subnewp[i]
        print "default", default
        return default
示例#8
0
def PointOnCoordinate(aPoint, aCoordValue, aCoord, aTol):
    pointCoords = geompy.PointCoordinates(aPoint)
    if math.fabs(pointCoords[aCoord] - aCoordValue) <= aTol:
        return 1
    return 0