void StringToCurve::UpdateCurve() { // Remove any existing curves while ( !m_OutCurveList->getCurveList().empty() ) { delete m_OutCurveList->getCurveList().back(); m_OutCurveList->getCurveList().pop_back(); } std::string dataString = f_CurveString->getStringValue(); dataString.append( f_CurveSeparator->getStringValue() ); std::string indexString = f_IndexString->getStringValue(); std::vector< float > indexValues; if (indexString.length() != 0 ){ StringToVector(indexString, indexValues ); } if ( dataString.length() > 0 ){ // Split string into curves std::vector<std::string> curves; boost::split(curves, dataString, boost::is_any_of(f_CurveSeparator->getStringValue() )); // Iterate over curves std::vector<std::string>::iterator stringIt = curves.begin(); for (;stringIt < curves.end(); ++stringIt ){ std::string curCurve = *stringIt; if (curCurve.length() == 0) {continue;} // Remove leading and trailing spaces boost::trim( curCurve ); std::vector< MLfloat > curveValues; StringToVector( curCurve, curveValues ); CurveData *outputCurve = new CurveData; outputCurve->setY( curveValues.size(),&curveValues[0], 1 ); if ( f_IndexString->getStringValue().length() != 0 ){ outputCurve->setX( indexValues.size(),&indexValues[0], 1 ); } m_OutCurveList->getCurveList().push_back( outputCurve ); } } }
void CSODistance::_process() { ML_TRACE_IN("void CSODistance::_process()"); _outputXMarkerList->clearList(); // Delete all created CurveData objects while ( !_outputCurveList->getCurveList().empty() ) { ML_DELETE( _outputCurveList->getCurveList().back() ); _outputCurveList->getCurveList().pop_back(); } if (_csoList0 != NULL) { int nCSOs = _csoList0->numCSO(); double minDistance = 0.0; double maxDistance = 0.0; double avgDistance = 0.0; double stdDevDistance = 0.0; std::stringstream distances; distances << _tableHeader << std::endl; switch ( _modeFld->getEnumValue() ){ case FIRST2 : { if ((nCSOs >= 2) && (_csoList0->getCSOAt(0)->getIsFinished()) && (_csoList0->getCSOAt(1)->getIsFinished())) { std::vector<vec3>pointSet1; std::vector<vec3>pointSet2; _csoList0->getCSOAt(0)->fillPathPointCoordinatesFlattened(pointSet1); _csoList0->getCSOAt(1)->fillPathPointCoordinatesFlattened(pointSet2); Vector3 minPoint1,minPoint2,maxPoint1,maxPoint2; MinimalDistancePointClouds* pointSetsMinDist = NULL; ML_CHECK_NEW(pointSetsMinDist, MinimalDistancePointClouds); pointSetsMinDist->setPointSets(pointSet1, pointSet2); pointSetsMinDist->setNumEntries(200); pointSetsMinDist->computeDistance(minPoint1,minPoint2); minDistance = sqrt((minPoint1[0]-minPoint2[0])*(minPoint1[0]-minPoint2[0]) + (minPoint1[1]-minPoint2[1])*(minPoint1[1]-minPoint2[1]) + (minPoint1[2]-minPoint2[2])*(minPoint1[2]-minPoint2[2])); _minimumDistanceFld->setFloatValue( static_cast<float>(minDistance)); _outputXMarkerList->appendItem(XMarker( vec6(minPoint1[0],minPoint1[1],minPoint1[2],0.5f,0.0f,0.0f), vec3(minPoint2[0]-minPoint1[0],minPoint2[1]-minPoint1[1],minPoint2[2]-minPoint1[2]), 0,"")); distances << _csoList0->getCSOAt(0)->getId() << "," << _csoList0->getCSOAt(1)->getId() << "," << minDistance << "," << maxDistance << "," << avgDistance << "," << stdDevDistance << std::endl; } else { _minimumDistancePoint1Fld->setVec3fValue(vec3(0.0,0.0,0.0)); _minimumDistancePoint2Fld->setVec3fValue(vec3(0.0,0.0,0.0)); _minimumDistanceFld->setFloatValue(0.0f); _distancesFld->setStringValue( _tableHeader ); } break; } case INPLANE: case INDEX: { CurveData *outputCurve = new CurveData; double *yValues = new double[ nCSOs ]; double minDist = ML_DOUBLE_MAX; vec3 point1; vec3 point2; double averageMinDistance = 0.0; double averageMeanDistance = 0.0; double averageMaxDistance = 0.0; for ( int iCSO = 0; iCSO<nCSOs; ++iCSO ){ CSO* currentCSO = _csoList0->getCSOAt( iCSO ); CSO* matchingCSO = _findMatchingCSO(iCSO); if (!matchingCSO) {continue;} std::vector<vec3>pointSet1; std::vector<vec3>pointSet2; currentCSO->fillPathPointCoordinatesFlattened(pointSet1); matchingCSO->fillPathPointCoordinatesFlattened(pointSet2); Vector3 minPoint1,minPoint2,maxPoint1,maxPoint2; _getDistances( pointSet1, pointSet2, minDistance,maxDistance,avgDistance,stdDevDistance, minPoint1,minPoint2,maxPoint1,maxPoint2); averageMinDistance += minDistance; averageMeanDistance += avgDistance; averageMaxDistance += maxDistance; distances << currentCSO->getId() << "," << matchingCSO->getId() << "," << minDistance << "," << maxDistance << "," << avgDistance << "," << stdDevDistance << std::endl; if ( minDistance < minDist ){ minDist = minDistance; point1 = minPoint1; point2 = minPoint2; } _outputXMarkerList->appendItem(XMarker( vec6(minPoint1[0],minPoint1[1],minPoint1[2],0.5f,0.0f,0.0f), vec3(minPoint2[0]-minPoint1[0],minPoint2[1]-minPoint1[1],minPoint2[2]-minPoint1[2]), currentCSO->getId(),"")); switch ( _curveStatistic->getEnumValue() ){ case MIN: yValues[ iCSO ] = minDistance; break; case MAX: yValues[ iCSO ] = maxDistance; break; case MEAN: yValues[ iCSO ] = avgDistance; break; case STDEV: yValues[ iCSO ] = stdDevDistance; break; default: break; } } // iCSO averageMinDistance /= (nCSOs != 0 ? nCSOs : 1.0); averageMeanDistance /= (nCSOs != 0 ? nCSOs : 1.0); averageMaxDistance /= (nCSOs != 0 ? nCSOs : 1.0); outputCurve->setY( nCSOs, yValues); delete[] yValues; _outputCurveList->getCurveList().push_back( outputCurve ); _distancesFld->setStringValue( distances.str() ); _minimumDistancePoint1Fld->setVec3fValue(point1); _minimumDistancePoint2Fld->setVec3fValue(point2); _minimumDistanceFld->setFloatValue( static_cast<float>(minDistance) ); _AverageMinimumDistanceFld->setDoubleValue( averageMinDistance ); _AverageMeanDistanceFld->setDoubleValue( averageMeanDistance ); _AverageMaxDistanceFld->setDoubleValue( averageMaxDistance ); break; } default: break; } } else { _minimumDistancePoint1Fld->setVec3fValue(vec3(0.0,0.0,0.0)); _minimumDistancePoint2Fld->setVec3fValue(vec3(0.0,0.0,0.0)); _minimumDistanceFld->setFloatValue(0.0f); _distancesFld->setStringValue( _tableHeader ); } _outputXMarkerListFld->setBaseValue(_outputXMarkerList); _outputCurveListFld->touch(); }