Exemple #1
0
	int Tree::choiceBestSplitEdge( IndexVec const& idxEdges )
	{
		int minVal = INT_MAX;
		int result = -1;

		//return result;
		for( IndexVec::const_iterator iter ( idxEdges.begin() ) , itEnd( idxEdges.end() ) ; 
			iter != itEnd ; ++iter  )
		{
			int numFront = 0;
			int numBack = 0;
			int numSplit = 0;
			int numOnPlane = 0;

			Edge& edge = mEdges[ *iter ];
			Plane& plane = edge.plane;

			for( IndexVec::const_iterator iter2 ( idxEdges.begin() )  ; 
				iter2 != itEnd ; ++iter2  )
			{
				Edge& edgeTest = mEdges[ *iter2 ];
				switch( plane.testSegment( edgeTest.v ) )
				{
				case SIDE_FRONT: ++numFront; break;
				case SIDE_BACK:  ++numBack;  break;
				case SIDE_SPLIT: ++numSplit; break;
				case SIDE_IN:    ++numOnPlane; break;
				}
			}

			if ( ( numSplit == 0 ) &&
				( numBack == 0 || numFront == 0) )
				continue;

			int val = abs( numFront - numBack ) + 8 * numSplit;
			if ( val < minVal )
			{
				result = *iter;
				minVal = val;
			}
		}
		return result;
	}
Exemple #2
0
  CassError set(StringRef name, const T value) {
    IndexVec indices;

    if (get_indices(name, &indices) == 0) {
      return CASS_ERROR_LIB_NAME_DOES_NOT_EXIST;
    }

    for (IndexVec::const_iterator it = indices.begin(),
         end = indices.end(); it != end; ++it) {
      size_t index = *it;
      CassError rc = set(index, value);
      if (rc != CASS_OK) return rc;
    }

    return CASS_OK;
  }