Пример #1
0
 public static function divideAllMembersByExistingNodes()
 {
     // SORT NODES
     \Classes\Utils\Timer\Timer::start('SORT_NODES');
     \Classes\Factory\Model\Model::sortNodes();
     \Classes\Utils\Timer\Timer::start('SORT_NODES');
     // Get nodes and members
     $nodes = \Classes\Factory\Model\Model::getNodes();
     $hashTable = \Classes\Factory\Model\Model::getHashTable();
     // Array [uin] => [0 - 1st point, 1 - 2nd point]
     $actualMemberUins = array();
     foreach ($nodes as $node) {
         // Get $node coordinates
         $point = \Classes\Utils\AbstractInstance\Point::createFromNode($node);
         $nodeUin = $node->getUin();
         $connections = $hashTable->getConnection($nodeUin);
         //            echo "NODE (" . $node->getProperty('x')->get() . ", " .
         //                            $node->getProperty('y')->get() . ", " .
         //                            $node->getProperty('z')->get() . ")   ";
         //
         //            echo "ACTUAL MEMBERS COUNT = " . count($actualMemberUins) . "<br/>";
         //            echo "CONNECTIONS: " . implode('; ', array_keys($connections)) . "<br/>";
         //Change $actualMemberUins array
         if (count($connections) > 0) {
             foreach ($connections as $uin => $c) {
                 // Here $uin is uin of member connected with node
                 if (isset($actualMemberUins[$uin])) {
                     // If member is already included in $actualMemberUins -> delete it
                     unset($actualMemberUins[$uin]);
                 } else {
                     // If member is NOT included in $actualMemberUins -> add it
                     $keys = array_keys($hashTable->getConnection($uin));
                     $endNumber = array_search($nodeUin, $keys);
                     $actualMemberUins[$uin] = $endNumber;
                 }
             }
         }
         // Divide $actualMemberUins by $node
         foreach ($actualMemberUins as $memberUin => $endNumber) {
             //                var_dump($actualMemberUins);
             // Get coordinates of members' ends
             $memberEndUins = array_keys($hashTable->getConnection($memberUin));
             $node1 = $nodes[$memberEndUins[0]];
             $node2 = $nodes[$memberEndUins[1]];
             $line = \Classes\Utils\AbstractInstance\Line::createFromTwoNodes($node1, $node2);
             // If point is inside line
             if (\Classes\Utils\Math\Points::isPointOnLine($point, $line) == 3) {
                 // Divide member by node
                 $newMemberUin = self::divideMemberByNode($memberUin, $nodeUin);
                 // If intersection found AND member's begin before sweep line
                 if ($newMemberUin != FALSE && $endNumber == 0) {
                     // Delete old member from actual array
                     unset($actualMemberUins[$memberUin]);
                     // Add new member to actual array (member's begin also before sweep line)
                     $actualMemberUins[$newMemberUin] = 0;
                 }
                 // If intersection found AND member's begin after sweep line
                 // it's necessary to do nothing, because divided member is
                 // still located after sweep line
             }
         }
     }
 }
 private static function addDistributedCommonMemberLoad($node, $commonMemberLoad, $commonMemberLoadEndNumber, $actualMemberUins)
 {
     $isFound = FALSE;
     // Get Nodes of Common Member Load
     $loadConnections = array_keys(self::$commonMemberLoadTable->getConnection($commonMemberLoad->getUin()));
     $loadNode1 = self::$nodes[$loadConnections[0]];
     $loadNode2 = self::$nodes[$loadConnections[1]];
     // Prepare Load Point
     $loadPoint1 = \Classes\Utils\AbstractInstance\Point::createFromNode($loadNode1);
     $loadPoint2 = \Classes\Utils\AbstractInstance\Point::createFromNode($loadNode2);
     // Prepare Load Line
     $loadLine = new \Classes\Utils\AbstractInstance\Line($loadPoint1, $loadPoint2);
     $loadLineLength = $loadLine->length();
     // Try to find member with necessary coordinates
     while ((list($memberUin, $memberEndNumber) = each($actualMemberUins)) && $isFound === FALSE) {
         $memberConnections = array_keys(self::$hashTable->getConnection($memberUin));
         $memberNode1 = self::$nodes[$memberConnections[0]];
         $memberNode2 = self::$nodes[$memberConnections[1]];
         // Prepare Node Point
         $memberPoint1 = \Classes\Utils\AbstractInstance\Point::createFromNode($memberNode1);
         $memberPoint2 = \Classes\Utils\AbstractInstance\Point::createFromNode($memberNode2);
         // Prepare Line
         $memberLine = new \Classes\Utils\AbstractInstance\Line($memberPoint1, $memberPoint2);
         // Array for arrays with overlapping coordinates
         $loadOverlap = array();
         $memberOverlap = array();
         // Find overlapping of lines
         if (\Classes\Utils\Math\Lines::findOverlappingOfTwoLines($loadLine, $memberLine, $loadOverlap, $memberOverlap)) {
             $isFound = TRUE;
             // Make new node load
             $load = new \Classes\Instance\Load\Member\DistributedMemberLoad();
             // Get LOAD Positions
             $loadPos1 = new \Classes\Value\FloatValue($memberOverlap[0]);
             $loadPos2 = new \Classes\Value\FloatValue($memberOverlap[1]);
             $load->setProperty('position1', $loadPos1);
             $load->setProperty('position2', $loadPos2);
             // Get LOAD Values
             $value1 = self::$value1->get();
             $value2 = self::$value2->get();
             $loadValue1 = new \Classes\Value\FloatValue($value1 + ($value2 - $value1) * $loadOverlap[0] / $loadLineLength);
             $loadValue2 = new \Classes\Value\FloatValue($value1 + ($value2 - $value1) * $loadOverlap[1] / $loadLineLength);
             $isLoadAndMemberSameDirection = \Classes\Utils\Math\Lines::areTwoVectorHaveSameDirection($loadLine, $memberLine);
             if ($isLoadAndMemberSameDirection) {
                 $load->setProperty('value1', $loadValue1);
                 $load->setProperty('value2', $loadValue2);
             } else {
                 $load->setProperty('value1', $loadValue2);
                 $load->setProperty('value2', $loadValue1);
             }
             // Add connection
             self::$loadTable->setConnection($load->getUin(), $memberUin, new \Classes\Factory\Connection\LoadConnection\GlobalCoordinateSystem());
             // Add new load
             self::setLoadProperties($load);
             $isBeginPartExist = !\Classes\Utils\Math\Constant::isNumbersEqual($loadOverlap[0], 0);
             $isEndPartExist = !\Classes\Utils\Math\Constant::isNumbersEqual($loadOverlap[1], $loadLineLength);
             // Get Uin of member's node, which is more far from sweep line
             switch ($memberEndNumber) {
                 case 0:
                     $memberEdgeUin = $memberNode2->getUin();
                     break;
                 case 1:
                     $memberEdgeUin = $memberNode1->getUin();
                     break;
             }
             // Check remainig parts of $loadLine
             // Begin part
             if ($isBeginPartExist) {
                 // Find end point of begin part
                 $endPoint = \Classes\Utils\Math\Lines::getPointOnLineWithOffset($loadLine, $loadOverlap[0]);
                 // Make new object
                 $beginObject = clone $commonMemberLoad;
                 //Set Properties
                 $beginObject->setProperty('x2', new \Classes\Value\FloatValue($endPoint->x));
                 $beginObject->setProperty('y2', new \Classes\Value\FloatValue($endPoint->y));
                 $beginObject->setProperty('z2', new \Classes\Value\FloatValue($endPoint->z));
                 $beginObject->setProperty('value2', $loadValue1);
                 self::$commonMemberLoadArray[$beginObject->getUin()] = $beginObject;
                 //If begin part is near sweep line
                 if ($commonMemberLoadEndNumber == 0) {
                     self::$notFoundObjects[] = $beginObject->getUin();
                 }
                 //If begin part is far from sweep line
                 if ($commonMemberLoadEndNumber == 1) {
                     // Set connection btw 1st node of CommonMemberLoad and beginObject
                     self::$commonMemberLoadTable->setConnection($beginObject->getUin(), $loadNode1->getUin(), self::$emptyConnection);
                     // Set connection between end of member anв beginObject
                     self::$commonMemberLoadTable->setConnection($beginObject->getUin(), $memberEdgeUin, self::$emptyConnection);
                 }
             }
             // End part
             if ($isEndPartExist) {
                 // Find begin point of end part
                 $beginPoint = \Classes\Utils\Math\Lines::getPointOnLineWithOffset($loadLine, $loadOverlap[1]);
                 // Make new object
                 $endObject = clone $commonMemberLoad;
                 //Set Properties
                 $endObject->setProperty('x1', new \Classes\Value\FloatValue($beginPoint->x));
                 $endObject->setProperty('y1', new \Classes\Value\FloatValue($beginPoint->y));
                 $endObject->setProperty('z1', new \Classes\Value\FloatValue($beginPoint->z));
                 $endObject->setProperty('value1', $loadValue2);
                 self::$commonMemberLoadArray[$endObject->getUin()] = $endObject;
                 //If begin part is near sweep line
                 if ($commonMemberLoadEndNumber == 0) {
                     // Set connection between end of member anв beginObject
                     self::$commonMemberLoadTable->setConnection($endObject->getUin(), $memberEdgeUin, self::$emptyConnection);
                     // Set connection btw 2nd node of CommonMemberLoad and beginObject
                     self::$commonMemberLoadTable->setConnection($endObject->getUin(), $loadNode2->getUin(), self::$emptyConnection);
                 }
                 //If begin part is far from sweep line
                 if ($commonMemberLoadEndNumber == 1) {
                     self::$notFoundObjects[] = $endObject->getUin();
                 }
             }
             // Delete Common Member Load
             self::$commonMemberLoadTable->removeConnection($commonMemberLoad->getUin(), $loadNode1->getUin());
             self::$commonMemberLoadTable->removeConnection($commonMemberLoad->getUin(), $loadNode2->getUin());
             unset(self::$commonMemberLoadArray[$commonMemberLoad->getUin()]);
         }
     }
     return $isFound;
 }