コード例 #1
0
 def findSomeGroupRecursively(self, prim, setNotDestroyed, setPartiallyDestroyed, setTotDestroyed):
     currentPartiallyDestroyed = list(setPartiallyDestroyed)
     '''
     h = HouInterface.HouInterface()
     h.showPoint(GeoMath.primBoundingBox(prim).center(), name='prim_' + str(prim.number()), color=[1, 0, 0])
     '''
     matchNotDes = prim in setNotDestroyed
     matchTotDes = prim in setTotDestroyed
     if(not matchNotDes):
         findInNotDestroyed = GeoMath.getConnectedPrims(prim, setNotDestroyed)
         matchNotDes = (findInNotDestroyed != [])
     if(not matchTotDes):
         findInTotDestroyed = GeoMath.getConnectedPrims(prim, setTotDestroyed)
         matchTotDes = (findInTotDestroyed != [])
     logging.debug("With prim %s, matchNotDes: %s, matchTotDes: %s", str(prim.number()), str(matchNotDes), str(matchTotDes))
     if(matchNotDes or matchTotDes):
         return matchNotDes, matchTotDes
     else:
         tempfind = []
         findInPartiallyDestroyed = GeoMath.getConnectedPrims(prim, currentPartiallyDestroyed)
         for primInPartiallyDestroyed in findInPartiallyDestroyed:
             if(primInPartiallyDestroyed not in self.path):
                 tempfind.append(primInPartiallyDestroyed)
         findInPartiallyDestroyed = list(tempfind)
         index = 0
         while(index < len(findInPartiallyDestroyed) and not matchNotDes and not matchTotDes):
             curPrim = findInPartiallyDestroyed[index]
             if(curPrim in currentPartiallyDestroyed):
                 logging.debug("with prim %s pass to %s", str(prim.number()), str(curPrim.number()))
                 currentPartiallyDestroyed.remove(curPrim)
                 matchNotDes, matchTotDes = self.findSomeGroupRecursively(curPrim, setNotDestroyed, currentPartiallyDestroyed, setTotDestroyed)
             index += 1
     return matchNotDes, matchTotDes
コード例 #2
0
 def isThisPrimMaybeValid(self, prim):
     # Has each edge of prim a connected prim? if not, track edges will not work!, so the prim
     # will not valid
     allGroups = []
     allGroups.extend(self.setNotDestroyed)
     allGroups.extend(self.setPartiallyDestroyed)
     allGroups.extend(self.setTotDestroyed)
     edgesHavingPrimitiveConnected = len(
         GeoMath.getConnectedPrimsOneForEachEdge(prim, allGroups))
     connectedWithNot = len(
         GeoMath.getConnectedPrims(prim, self.setNotDestroyed, 1))
     connectedWithTot = len(
         GeoMath.getConnectedPrims(prim, self.setTotDestroyed, 1))
     connectedWithPartially = len(
         GeoMath.getConnectedPrimsOneForEachEdge(
             prim, self.setPartiallyDestroyed))
     connectedWithPath = len(
         GeoMath.getConnectedPrimsOneForEachEdge(prim, self.path))
     # Prim must to acomplished that the number of connected with partially destroyed plus
     # connected with not destroyed plus connected with totally destroyed minus connecte with path
     # must to be greater than 2 primitives (at least two wanted primitives to do recursion after)
     logging.debug("Method isThisPrimMaybeValid, prim %s , with:",
                   str(prim.number()))
     logging.debug(
         "Connected with not: %s, connected with tot: %s, connected with partially: %s, connected with path: %s, edges having primitive: %s",
         str(connectedWithNot), str(connectedWithTot),
         str(connectedWithPartially), str(connectedWithPath),
         str(edgesHavingPrimitiveConnected))
     return (((connectedWithPartially + connectedWithTot +
               connectedWithNot - connectedWithPath) >= 2)
             and (edgesHavingPrimitiveConnected == len(
                 GeoMath.getEdgesFromPrim(prim))))
    def growing(self, thisPrim, previousPrim, allPrims, primsWithLine,
                volumeNode, sweepingNode):
        logging.debug(
            "Start method growing, class BoolIntersection_RegionGrowing")
        # Base case, prim matched
        if (thisPrim in primsWithLine.keys()
                and thisPrim not in self.primitivesDivided.keys()):
            # Divide prim in two prims with boolean intersection
            primDivided = PrimDivided.PrimDivided(thisPrim, previousPrim,
                                                  self.primitivesDivided,
                                                  primsWithLine, volumeNode,
                                                  sweepingNode)
            # "thisPrim" doesn't exists anymore(it was converted into two prims, contained in "primDivided"
            if (primDivided.prim):
                logging.debug("Divided prim de %s",
                              str(primDivided.prim.number()))
                self.primitivesDivided[thisPrim] = primDivided
            else:
                logging.debug("NO prim divided de %s", str(thisPrim.number()))
                logging.debug(
                    "End method growing, class BoolIntersection_RegionGrowing. State: good, no prim divided"
                )
                return
        inside = True
        # Only put in "already visited" the prims totally destroyed, the others remain in "primitivesDivided"
        if (thisPrim not in self.primitivesDivided.keys()):
            self.alreadyVisited.append(thisPrim)
            if (previousPrim in self.primitivesDivided.keys()):
                inside = self.testInsideOutside(
                    thisPrim, self.primitivesDivided[previousPrim])
        # Next recursivity
        if (inside):
            connectedPrims = GeoMath.getConnectedPrims(thisPrim, allPrims)
            logging.debug("CONNECTED PRIMS:")
            logging.debug(str([p.number() for p in connectedPrims]))
            for nextPrim in connectedPrims:
                if (nextPrim not in self.alreadyVisited
                        and nextPrim not in self.primitivesDivided.keys()):
                    logging.debug("Siguiente growing con: %s",
                                  str(nextPrim.number()), " viene de %s",
                                  str(thisPrim.number()))
                    self.growing(nextPrim, thisPrim, allPrims, primsWithLine,
                                 volumeNode, sweepingNode)
                else:
                    if (nextPrim in self.alreadyVisited):
                        logging.debug("Visitada %s", str(nextPrim.number()),
                                      " viene de %s", str(thisPrim.number()))
                    if (nextPrim in self.primitivesDivided.keys()):
                        logging.debug("Divided prim %s",
                                      str(nextPrim.number()), " viene de %s",
                                      str(thisPrim.number()))

        else:
            # It's not inside, so we have to conserve it
            self.alreadyVisited.pop()
        logging.debug(
            "End method growing, class BoolIntersection_RegionGrowing.  State: good"
        )
        return
コード例 #4
0
    def getPrimsSharingGroupOfEdges(self, prim, setNotDestroyed, setPartiallyDestroyed, setTotDestroyed):
        validPrim1 = None
        validPrim2 = None
        if(self.isThisPrimMaybeValid(prim)):
            primsSharedInPathSet = GeoMath.getConnectedPrims(prim, self.path)
            primsSharedInGeneral = GeoMath.getConnectedPrims(prim, setPartiallyDestroyed)
            primsSharedInGeneral.extend(GeoMath.getConnectedPrims(prim, setNotDestroyed))
            primsSharedInGeneral.extend(GeoMath.getConnectedPrims(prim, setTotDestroyed))
            setOfEdgesToTrack = []
            for primSharedInGeneral in primsSharedInGeneral:
                setOfEdgesToTrack.extend(GeoMath.getEdgesBetweenPrims(prim, primSharedInGeneral))
            excluded = []
            for primSharedPath in primsSharedInPathSet:
                edgesSharedWithPrim = GeoMath.getEdgesBetweenPrims(primSharedPath, prim)
                excluded.extend(edgesSharedWithPrim)

            # We need some first edge and last edge for track edges between this edges, excluding edges
            # (included in group "excluded") in other prims that share some edge with central prim
            indexPrim = self.path.index(prim)
            if(indexPrim == 0):
                prevIndexPrim = len(self.path) - 1
            else:
                prevIndexPrim = indexPrim - 1
            edgesSharedWithPrim1 = GeoMath.getEdgesBetweenPrims(self.path[(indexPrim + 1) % len(self.path)], prim)
            edgesSharedWithPrim2 = GeoMath.getEdgesBetweenPrims(self.path[prevIndexPrim], prim)
            logging.debug("edges shared curPrim1: %s with prim: %s, edges: %s", str(self.path[(indexPrim + 1) % len(self.path)].number()), str(prim.number()), str(edgesSharedWithPrim1))
            logging.debug("edges shared curPrim2: %s with prim: %s, edges: %s", str(self.path[prevIndexPrim].number()), str(prim.number()), str(edgesSharedWithPrim2))
            groupEdges1, groupEdges2 = GeoMath.trackEdges(edgesSharedWithPrim1[0], setOfEdgesToTrack, edgesSharedWithPrim2[0], excluded)

            # Find two good prims containing one of the group of edges
            index = 0
            while(index < len(primsSharedInGeneral) and not (validPrim1 and validPrim2)):
                curPrim = primsSharedInGeneral[index]
                conEdges = GeoMath.getEdgesBetweenPrims(curPrim, prim)
                if(not validPrim1):
                    for edge in groupEdges1:
                        if(GeoMath.sameEdge(conEdges[0], edge)):
                            validPrim1 = curPrim
                        break
                if (not validPrim2):
                    for edge in groupEdges2:
                        if(GeoMath.sameEdge(conEdges[0], edge)):
                            validPrim2 = curPrim
                        break
                index += 1
        return validPrim1, validPrim2
コード例 #5
0
 def isThisPrimMaybeValid(self, prim):
     # Has each edge of prim a connected prim? if not, track edges will not work!, so the prim
     # will not valid
     allGroups = []
     allGroups.extend(self.setNotDestroyed)
     allGroups.extend(self.setPartiallyDestroyed)
     allGroups.extend(self.setTotDestroyed)
     edgesHavingPrimitiveConnected = len(GeoMath.getConnectedPrimsOneForEachEdge(prim, allGroups))
     connectedWithNot = len(GeoMath.getConnectedPrims(prim, self.setNotDestroyed, 1))
     connectedWithTot = len(GeoMath.getConnectedPrims(prim, self.setTotDestroyed, 1))
     connectedWithPartially = len(GeoMath.getConnectedPrimsOneForEachEdge(prim, self.setPartiallyDestroyed))
     connectedWithPath = len(GeoMath.getConnectedPrimsOneForEachEdge(prim, self.path))
     # Prim must to acomplished that the number of connected with partially destroyed plus
     # connected with not destroyed plus connected with totally destroyed minus connecte with path
     # must to be greater than 2 primitives (at least two wanted primitives to do recursion after)
     logging.debug("Method isThisPrimMaybeValid, prim %s , with:", str(prim.number()))
     logging.debug("Connected with not: %s, connected with tot: %s, connected with partially: %s, connected with path: %s, edges having primitive: %s",
                   str(connectedWithNot), str(connectedWithTot), str(connectedWithPartially), str(connectedWithPath), str(edgesHavingPrimitiveConnected))
     return (((connectedWithPartially + connectedWithTot + connectedWithNot - connectedWithPath) >= 2) and (edgesHavingPrimitiveConnected == len(GeoMath.getEdgesFromPrim(prim))))
コード例 #6
0
 def findSomeGroupRecursively(self, prim, setNotDestroyed,
                              setPartiallyDestroyed, setTotDestroyed):
     currentPartiallyDestroyed = list(setPartiallyDestroyed)
     '''
     h = HouInterface.HouInterface()
     h.showPoint(GeoMath.primBoundingBox(prim).center(), name='prim_' + str(prim.number()), color=[1, 0, 0])
     '''
     matchNotDes = prim in setNotDestroyed
     matchTotDes = prim in setTotDestroyed
     if (not matchNotDes):
         findInNotDestroyed = GeoMath.getConnectedPrims(
             prim, setNotDestroyed)
         matchNotDes = (findInNotDestroyed != [])
     if (not matchTotDes):
         findInTotDestroyed = GeoMath.getConnectedPrims(
             prim, setTotDestroyed)
         matchTotDes = (findInTotDestroyed != [])
     logging.debug("With prim %s, matchNotDes: %s, matchTotDes: %s",
                   str(prim.number()), str(matchNotDes), str(matchTotDes))
     if (matchNotDes or matchTotDes):
         return matchNotDes, matchTotDes
     else:
         tempfind = []
         findInPartiallyDestroyed = GeoMath.getConnectedPrims(
             prim, currentPartiallyDestroyed)
         for primInPartiallyDestroyed in findInPartiallyDestroyed:
             if (primInPartiallyDestroyed not in self.path):
                 tempfind.append(primInPartiallyDestroyed)
         findInPartiallyDestroyed = list(tempfind)
         index = 0
         while (index < len(findInPartiallyDestroyed) and not matchNotDes
                and not matchTotDes):
             curPrim = findInPartiallyDestroyed[index]
             if (curPrim in currentPartiallyDestroyed):
                 logging.debug("with prim %s pass to %s",
                               str(prim.number()), str(curPrim.number()))
                 currentPartiallyDestroyed.remove(curPrim)
                 matchNotDes, matchTotDes = self.findSomeGroupRecursively(
                     curPrim, setNotDestroyed, currentPartiallyDestroyed,
                     setTotDestroyed)
             index += 1
     return matchNotDes, matchTotDes
コード例 #7
0
    def patternPrimWithNeigborsPatternsPrims(pat, prim, groupOfPrims):
        reload(GeoMath)
        reload(BoundingBox)
        prims = groupOfPrims.keys()
        primsConected = GeoMath.getConnectedPrims(prim, prims)
        pattern_bounding_box = BoundingBox.BoundingBox2D(pat.getPoints(), prim)
        for primConected in primsConected:
            if(primConected != prim):
                gr = groupOfPrims[primConected]
                for patInGr in gr:
                    param_pattern_bounding_box = BoundingBox.BoundingBox2D(patInGr.getPoints(), prim)
                    intersections, shared_prims_edges = pattern_bounding_box.intersect_bounding_box_with_limits_3D(param_pattern_bounding_box)  # @UnusedVariable
                    if (intersections):
                        # Check if it is true that intersect
                        edges = GeoMath.getEdgesBetweenPoints(patInGr.getPoints(), pat.getPoints(), 1)

                        if(edges):
                            return False
        return True
コード例 #8
0
    def growing(self, thisPrim, previousPrim, allPrims, primsWithLine, volumeNode, sweepingNode):
        logging.debug("Start method growing, class BoolIntersection_RegionGrowing")
        # Base case, prim matched
        if (thisPrim in primsWithLine.keys() and thisPrim not in self.primitivesDivided.keys()):
            # Divide prim in two prims with boolean intersection
            primDivided = PrimDivided.PrimDivided(thisPrim, previousPrim, self.primitivesDivided, primsWithLine, volumeNode, sweepingNode)
            # "thisPrim" doesn't exists anymore(it was converted into two prims, contained in "primDivided"
            if(primDivided.prim):
                logging.debug("Divided prim de %s", str(primDivided.prim.number()))
                self.primitivesDivided[thisPrim] = primDivided
            else:
                logging.debug("NO prim divided de %s", str(thisPrim.number()))
                logging.debug("End method growing, class BoolIntersection_RegionGrowing. State: good, no prim divided")
                return
        inside = True
        # Only put in "already visited" the prims totally destroyed, the others remain in "primitivesDivided"
        if(thisPrim not in self.primitivesDivided.keys()):
            self.alreadyVisited.append(thisPrim)
            if(previousPrim in self.primitivesDivided.keys()):
                inside = self.testInsideOutside(thisPrim, self.primitivesDivided[previousPrim])
        # Next recursivity
        if(inside):
            connectedPrims = GeoMath.getConnectedPrims(thisPrim, allPrims)
            logging.debug("CONNECTED PRIMS:")
            logging.debug(str([p.number() for p in connectedPrims]))
            for nextPrim in connectedPrims:
                if(nextPrim not in self.alreadyVisited and nextPrim not in self.primitivesDivided.keys()):
                    logging.debug("Siguiente growing con: %s", str(nextPrim.number()), " viene de %s", str(thisPrim.number()))
                    self.growing(nextPrim, thisPrim, allPrims, primsWithLine, volumeNode, sweepingNode)
                else:
                    if(nextPrim in self.alreadyVisited):
                        logging.debug("Visitada %s", str(nextPrim.number()), " viene de %s", str(thisPrim.number()))
                    if(nextPrim in self.primitivesDivided.keys()):
                        logging.debug("Divided prim %s", str(nextPrim.number()), " viene de %s", str(thisPrim.number()))

        else:
            # It's not inside, so we have to conserve it
            self.alreadyVisited.pop()
        logging.debug("End method growing, class BoolIntersection_RegionGrowing.  State: good")
        return
コード例 #9
0
    def patternPrimWithNeigborsPatternsPrims(pat, prim, groupOfPrims):
        reload(GeoMath)
        reload(BoundingBox)
        prims = groupOfPrims.keys()
        primsConected = GeoMath.getConnectedPrims(prim, prims)
        pattern_bounding_box = BoundingBox.BoundingBox2D(pat.getPoints(), prim)
        for primConected in primsConected:
            if (primConected != prim):
                gr = groupOfPrims[primConected]
                for patInGr in gr:
                    param_pattern_bounding_box = BoundingBox.BoundingBox2D(
                        patInGr.getPoints(), prim)
                    intersections, shared_prims_edges = pattern_bounding_box.intersect_bounding_box_with_limits_3D(
                        param_pattern_bounding_box)  # @UnusedVariable
                    if (intersections):
                        # Check if it is true that intersect
                        edges = GeoMath.getEdgesBetweenPoints(
                            patInGr.getPoints(), pat.getPoints(), 1)

                        if (edges):
                            return False
        return True
コード例 #10
0
    def getPrimsSharingGroupOfEdges(self, prim, setNotDestroyed,
                                    setPartiallyDestroyed, setTotDestroyed):
        validPrim1 = None
        validPrim2 = None
        if (self.isThisPrimMaybeValid(prim)):
            primsSharedInPathSet = GeoMath.getConnectedPrims(prim, self.path)
            primsSharedInGeneral = GeoMath.getConnectedPrims(
                prim, setPartiallyDestroyed)
            primsSharedInGeneral.extend(
                GeoMath.getConnectedPrims(prim, setNotDestroyed))
            primsSharedInGeneral.extend(
                GeoMath.getConnectedPrims(prim, setTotDestroyed))
            setOfEdgesToTrack = []
            for primSharedInGeneral in primsSharedInGeneral:
                setOfEdgesToTrack.extend(
                    GeoMath.getEdgesBetweenPrims(prim, primSharedInGeneral))
            excluded = []
            for primSharedPath in primsSharedInPathSet:
                edgesSharedWithPrim = GeoMath.getEdgesBetweenPrims(
                    primSharedPath, prim)
                excluded.extend(edgesSharedWithPrim)

            # We need some first edge and last edge for track edges between this edges, excluding edges
            # (included in group "excluded") in other prims that share some edge with central prim
            indexPrim = self.path.index(prim)
            if (indexPrim == 0):
                prevIndexPrim = len(self.path) - 1
            else:
                prevIndexPrim = indexPrim - 1
            edgesSharedWithPrim1 = GeoMath.getEdgesBetweenPrims(
                self.path[(indexPrim + 1) % len(self.path)], prim)
            edgesSharedWithPrim2 = GeoMath.getEdgesBetweenPrims(
                self.path[prevIndexPrim], prim)
            logging.debug(
                "edges shared curPrim1: %s with prim: %s, edges: %s",
                str(self.path[(indexPrim + 1) % len(self.path)].number()),
                str(prim.number()), str(edgesSharedWithPrim1))
            logging.debug("edges shared curPrim2: %s with prim: %s, edges: %s",
                          str(self.path[prevIndexPrim].number()),
                          str(prim.number()), str(edgesSharedWithPrim2))
            groupEdges1, groupEdges2 = GeoMath.trackEdges(
                edgesSharedWithPrim1[0], setOfEdgesToTrack,
                edgesSharedWithPrim2[0], excluded)

            # Find two good prims containing one of the group of edges
            index = 0
            while (index < len(primsSharedInGeneral)
                   and not (validPrim1 and validPrim2)):
                curPrim = primsSharedInGeneral[index]
                conEdges = GeoMath.getEdgesBetweenPrims(curPrim, prim)
                if (not validPrim1):
                    for edge in groupEdges1:
                        if (GeoMath.sameEdge(conEdges[0], edge)):
                            validPrim1 = curPrim
                        break
                if (not validPrim2):
                    for edge in groupEdges2:
                        if (GeoMath.sameEdge(conEdges[0], edge)):
                            validPrim2 = curPrim
                        break
                index += 1
        return validPrim1, validPrim2
コード例 #11
0
 def getExtremPrims(self,
                    Ipoint,
                    primOfIpoint,
                    partDes,
                    refPrim,
                    notDes,
                    volume=None):
     '''
     We can't ensure that the primitives have a posible path, but we ensure that last primitive
     have at least 2 adjacent primitives and first primitive is connected with the last primitive
     '''
     logging.debug("Start method getExtremPrims, class DefPath")
     firstPrim = None
     lastPrim = None
     if (primOfIpoint and Ipoint):
         # NOT YET TOTALLY IMPLEMENTED
         edge = GeoMath.getEdgeWithPointInPrim(primOfIpoint, Ipoint)
         lastPrim = primOfIpoint
         for prim in partDes:
             if (prim != lastPrim):
                 sharedEdges = GeoMath.getSharedEdgesPrims(lastPrim, prim)
                 rs_lP_fP = False
                 if (volume):
                     for edge in sharedEdges:
                         rs = RejectionSampling.RejectionSampling(
                             edge, volume)
                         rs.do()
                         point = rs.getValue()
                         if (point):
                             rs_lP_fP = True
                             break
                 if (len(sharedEdges >= 1) and (edge in sharedEdges)
                         and (volume == None or rs_lP_fP)):
                     firstPrim = prim
     else:
         # Automatically decision of extrem prims.
         # Ensure that 2 prims is connected to another primitive in
         # group of partially destroyed.
         # Didn't use "getConnectedPrims" because need ramdonless in choice of prims.
         stopSearch = False
         tempList1 = list(partDes)
         # minimum of 4 prims to get a path
         while (len(tempList1) > 4 and not stopSearch):
             numPrim1 = random.randint(0, len(tempList1) - 1)
             prim1 = tempList1[numPrim1]
             del tempList1[numPrim1]
             # We have to ensure that first prim has at least two conected prims
             if (True):  # prim1.number()>17 and prim1.number()<27
                 while (
                     (len(GeoMath.getConnectedPrims(prim1, list(partDes),
                                                    2)) < 2)
                         and (len(tempList1) > 4)):
                     numPrim1 = random.randint(0, len(tempList1) - 1)
                     prim1 = tempList1[numPrim1]
                     del tempList1[numPrim1]
                 # If prim1 has at least two conected prims
                 if (len(tempList1) > 4):
                     conectedToPrim1 = GeoMath.getConnectedPrims(
                         prim1, list(tempList1))
                     while (len(conectedToPrim1) > 0 and not stopSearch):
                         numPrim2 = random.randint(0,
                                                   len(conectedToPrim1) - 1)
                         prim2 = conectedToPrim1[numPrim2]
                         if (prim2 != prim1):
                             # If prim2 has at least 2 conected prims
                             if (len(
                                     GeoMath.getConnectedPrims(
                                         prim2, list(tempList1), 2)) >= 2):
                                 stopSearch = True
                                 if (volume):
                                     rs_lP_fP = False
                                     for edge in GeoMath.getEdgesBetweenPrims(
                                             prim1, prim2):
                                         logging.debug(
                                             "Edge: %s", str(edge))
                                         rs = RejectionSampling.RejectionSampling(
                                             edge, volume)
                                         rs.do()
                                         point = rs.getValue()
                                         if (point):
                                             rs_lP_fP = True
                                             break
                                     if (not rs_lP_fP):
                                         stopSearch = False
                                 if (stopSearch):
                                     # Assign the last evaluate because we have it now in a variable.
                                     firstPrim = InfoPathPrim.InfoPathPrim(
                                         prim2)
                                     # Last prim sure has two adjacent primitives.
                                     lastPrim = InfoPathPrim.InfoPathPrim(
                                         prim1)
                                     firstPrim.setiPoint(list(point))
                                     lastPrim.setfPoint(list(point))
                         del conectedToPrim1[numPrim2]
         if (firstPrim and lastPrim):
             logging.debug(
                 "End method getExtremPrims, class DefPath. State: good")
         else:
             logging.debug(
                 "End method getExtremPrims, class DefPath. State: no extrem prims"
             )
         return firstPrim, lastPrim
コード例 #12
0
 def getExtremPrims(self, Ipoint, primOfIpoint, partDes, refPrim, notDes, volume=None):
     '''
     We can't ensure that the primitives have a posible path, but we ensure that last primitive
     have at least 2 adjacent primitives and first primitive is connected with the last primitive
     '''
     logging.debug("Start method getExtremPrims, class DefPath")
     firstPrim = None
     lastPrim = None
     if(primOfIpoint and Ipoint):
         # NOT YET TOTALLY IMPLEMENTED
         edge = GeoMath.getEdgeWithPointInPrim(primOfIpoint, Ipoint)
         lastPrim = primOfIpoint
         for prim in partDes:
             if(prim != lastPrim):
                 sharedEdges = GeoMath.getSharedEdgesPrims(lastPrim, prim)
                 rs_lP_fP = False
                 if(volume):
                     for edge in sharedEdges:
                         rs = RejectionSampling.RejectionSampling(edge, volume)
                         rs.do()
                         point = rs.getValue()
                         if(point):
                             rs_lP_fP = True
                             break
                 if (len(sharedEdges >= 1) and  (edge in sharedEdges) and (volume == None or rs_lP_fP)):
                     firstPrim = prim
     else:
         # Automatically decision of extrem prims.
         # Ensure that 2 prims is connected to another primitive in
         # group of partially destroyed.
         # Didn't use "getConnectedPrims" because need ramdonless in choice of prims.
         stopSearch = False
         tempList1 = list(partDes)
         # minimum of 4 prims to get a path
         while (len(tempList1) > 4 and not stopSearch):
             numPrim1 = random.randint(0, len(tempList1) - 1)
             prim1 = tempList1[numPrim1]
             del tempList1[numPrim1]
             # We have to ensure that first prim has at least two conected prims
             if(True):  # prim1.number()>17 and prim1.number()<27
                 while((len(GeoMath.getConnectedPrims(prim1, list(partDes), 2)) < 2) and (len(tempList1) > 4)):
                     numPrim1 = random.randint(0, len(tempList1) - 1)
                     prim1 = tempList1[numPrim1]
                     del tempList1[numPrim1]
                 # If prim1 has at least two conected prims
                 if(len(tempList1) > 4):
                     conectedToPrim1 = GeoMath.getConnectedPrims(prim1, list(tempList1))
                     while (len(conectedToPrim1) > 0 and not stopSearch):
                         numPrim2 = random.randint(0, len(conectedToPrim1) - 1)
                         prim2 = conectedToPrim1[numPrim2]
                         if(prim2 != prim1):
                             # If prim2 has at least 2 conected prims
                             if(len(GeoMath.getConnectedPrims(prim2, list(tempList1), 2)) >= 2):
                                 stopSearch = True
                                 if(volume):
                                     rs_lP_fP = False
                                     for edge in GeoMath.getEdgesBetweenPrims(prim1, prim2):
                                         logging.debug("Edge: %s", str(edge))
                                         rs = RejectionSampling.RejectionSampling(edge, volume)
                                         rs.do()
                                         point = rs.getValue()
                                         if(point):
                                             rs_lP_fP = True
                                             break
                                     if(not rs_lP_fP):
                                         stopSearch = False
                                 if(stopSearch):
                                     # Assign the last evaluate because we have it now in a variable.
                                     firstPrim = InfoPathPrim.InfoPathPrim(prim2)
                                     # Last prim sure has two adjacent primitives.
                                     lastPrim = InfoPathPrim.InfoPathPrim(prim1)
                                     firstPrim.setiPoint(list(point))
                                     lastPrim.setfPoint(list(point))
                         del conectedToPrim1[numPrim2]
         if(firstPrim and lastPrim):
             logging.debug("End method getExtremPrims, class DefPath. State: good")
         else:
             logging.debug("End method getExtremPrims, class DefPath. State: no extrem prims")
         return firstPrim, lastPrim