當前位置: 首頁>>代碼示例>>Python>>正文


Python GeoMath.getSharedEdges方法代碼示例

本文整理匯總了Python中lib.GeoMath.getSharedEdges方法的典型用法代碼示例。如果您正苦於以下問題:Python GeoMath.getSharedEdges方法的具體用法?Python GeoMath.getSharedEdges怎麽用?Python GeoMath.getSharedEdges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在lib.GeoMath的用法示例。


在下文中一共展示了GeoMath.getSharedEdges方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: houDoBooleanOperation

# 需要導入模塊: from lib import GeoMath [as 別名]
# 或者: from lib.GeoMath import getSharedEdges [as 別名]
    def houDoBooleanOperation(self, prim, previousPrim, listOfDividedPrims, crack, volumeNode, sweepingNode):
        logging.debug("Start method houDoBooleanOperation, class PrimDivided")
        global epsilon
        logging.debug("This prim: %s", str(prim))
        logging.debug("Previous prim: %s", str(previousPrim))
        if previousPrim in listOfDividedPrims.keys():
            edgeToValidate = GeoMath.getSharedEdges(
                listOfDividedPrims[previousPrim].pointsOutside,
                [list(po.point().position()) for po in prim.vertices()],
                1,
            )
            if not edgeToValidate:
                self.prim = None
                logging.error("No edge to validate")
                logging.debug(
                    "Start method houDoBooleanOperation, class PrimDivided. State: No edge to valide in prim %s",
                    str(prim.number()),
                )
                return False
            edgeToValidate = edgeToValidate[0]
        else:
            edgeToValidate = GeoMath.getSharedEdgesPrims(previousPrim, prim, 1)[0]
            if not edgeToValidate:
                logging.error("No edge to validate")
                logging.debug(
                    "Start method houDoBooleanOperation, class PrimDivided. State: No edge to valide in prim %s",
                    str(prim.number()),
                )
                self.prim = None
                return False

        logging.debug("Edge to validate: %s", str(edgeToValidate))
        edgeToValidate = [list(edgeToValidate[0]), list(edgeToValidate[1])]

        firstPointCrack = crack[prim][0]
        lastPointCrack = crack[prim][len(crack[prim]) - 1]
        matched = False
        # Points ordered by prim
        points = [list(p.point().position()) for p in prim.vertices()]
        edgeFirst = GeoMath.getEdgeWithPointInPrim(prim, firstPointCrack)
        edgeFirst = [list(edgeFirst[0]), list(edgeFirst[1])]
        # Put the edge in clockwise direction
        if GeoMath.determineDirEdge(edgeFirst, prim, True):
            curEdge = [firstPointCrack, edgeFirst[1]]
        else:
            curEdge = [firstPointCrack, edgeFirst[0]]
        index = 0
        logging.debug("Points: %s", str(points))
        logging.debug("Current edge: %s", str(curEdge))
        count = 0
        while points[index] != curEdge[1]:
            count += 1
            if count == 10:
                logging.error("First edge not found")
                logging.debug("End method houDoBooleanOperation, class PrimDivided. State: first edge not found")
                return
            index += 1
        nextIndex = (index + 1) % len(points)
        nextEdge = [curEdge[1], points[nextIndex]]
        edgeLast = GeoMath.getEdgeWithPointInPrim(prim, lastPointCrack)
        edgeLast = [list(edgeLast[0]), list(edgeLast[1])]
        if not GeoMath.determineDirEdge(edgeLast, prim, True):
            edgeLast = [list(edgeLast[1]), list(edgeLast[0])]
        pointsDisplaced = []

        # Normal iteration over points
        count = 0
        logging.debug("Last edge where the 'to validate edge' lies: %s", str(edgeLast))
        self.pointsOutside = []
        logging.debug("Normal iteration over points")
        while len(GeoMath.getSharedEdges(curEdge, edgeLast, 1)) == 0:
            logging.debug("Current edge: %s", str(curEdge))
            count += 1
            if count == 10:
                logging.error("Last edge not found")
                logging.debug("End method houDoBooleanOperation, class PrimDivided. State: Last edge not found")
                return
            # Calcule the displacement
            vecDis = self.calculateDisplacement(curEdge, nextEdge)
            pointDisplaced = self.applyDisplacement(curEdge[1], vecDis)
            # Add displace point
            pointsDisplaced.append(pointDisplaced)
            self.pointsOutside.append(curEdge[1])
            if len(GeoMath.getSharedEdges(curEdge, edgeToValidate, 1)) > 0:
                matched = True
            curEdge = [curEdge[1], points[nextIndex]]
            nextIndex = (nextIndex + 1) % len(points)
            nextEdge = [nextEdge[1], points[nextIndex]]
        logging.debug("Ha salido del segundo bucle con: %s", str(curEdge))
        curEdge = [curEdge[0], lastPointCrack]
        # Last comprovation
        if not matched and (len(GeoMath.getSharedEdges(curEdge, edgeToValidate, 1)) > 0):
            logging.debug("Final comprovation edge: %s", str(curEdge))
            matched = True
        if not matched:
            logging.debug("Not matched at normal iteration over points, trying in inverse mode")
            # Do inverse
            # Put the edge in not clockwise direction
            if GeoMath.determineDirEdge(edgeFirst, prim, False):
                curEdge = [firstPointCrack, edgeFirst[1]]
#.........這裏部分代碼省略.........
開發者ID:csoriano89,項目名稱:BuildingDestruction,代碼行數:103,代碼來源:PrimDivided.py

示例2: testInsideOutside

# 需要導入模塊: from lib import GeoMath [as 別名]
# 或者: from lib.GeoMath import getSharedEdges [as 別名]
 def testInsideOutside(self, prim, primDivided):
     edgeToValidate = GeoMath.getSharedEdges(primDivided.pointsOutside, [list(po.point().position()) for po in prim.vertices()], 1)
     if(len(edgeToValidate) > 0):
         return True
     else:
         return False
開發者ID:csoriano89,項目名稱:BuildingDestruction,代碼行數:8,代碼來源:BoolIntersection_RegionGrowing.py


注:本文中的lib.GeoMath.getSharedEdges方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。