void ShapeVisitor_Comparator::visit (Shape_Composite & shape) { QSharedPointer<Shape_Composite> otherShape = otherShape_.dynamicCast<Shape_Composite> (); if (! otherShape.isNull ()) { Shape_Composite::ShapesListType & list1 = shape.getShapes (); Shape_Composite::ShapesListType & list2 = otherShape->getShapes (); if (list1.size () == list2.size()) { Shape_Composite::ShapesListType::iterator it1 = list1.begin (); Shape_Composite::ShapesListType::iterator it2 = list2.begin (); for (; it1 != list1.end (); ++it1, ++it2) { otherShape_ = *it2; (*it1)->accept (*this); if (!comparisonResult_) { return; } } } else { comparisonResult_ = false; } } else { comparisonResult_ = false; } }
void ShapeVisitor_RestrictedPositionGetter::visit( Shape_Composite& shape ) { Shape_Composite::ShapesListType& shapes = shape.getShapes(); if ( !shapes.empty() ) { osg::Vec3f restrictedPositionWithMinDistance; float minDistanceFound = 0; for ( Shape_Composite::ShapesListType::const_iterator it = shapes.begin(); it != shapes.end(); ++it ) { ( *it )->accept( *this ); // restrictedPosition_ changes here float currentDistance = ( mOriginalPosition - mRestrictedPosition ).length(); if ( ( it == shapes.begin() ) || ( ( currentDistance < minDistanceFound ) || ( it == shapes.begin() ) ) ) { restrictedPositionWithMinDistance = mRestrictedPosition; minDistanceFound = currentDistance; } } mRestrictedPosition = restrictedPositionWithMinDistance; } else { mRestrictedPosition = mOriginalPosition; } }