-// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2015-2022 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// purpose : gets measures of the given type for list of shapes in the range
//=================================================================================
std::map<int,double> ComputeMeasures( std::list<TopoDS_Shape> shapes,
- TopAbs_ShapeEnum entity,
- Range &range)
+ TopAbs_ShapeEnum entity,
+ Range &range)
{
bool hasRange = (range.min != -1.0); // -1.0 means that range must not be used
if ( !hasRange )
//Get the measure: length, area or volume
GProp_GProps LProps, SProps, VProps;
if ( entity == TopAbs_EDGE ) {
- BRepGProp::LinearProperties( aSubShape, LProps );
- aMeasure = LProps.Mass();
+ BRepGProp::LinearProperties( aSubShape, LProps );
+ aMeasure = LProps.Mass();
} else if ( entity == TopAbs_FACE ) {
- BRepGProp::SurfaceProperties( aSubShape, SProps );
- aMeasure = SProps.Mass();
+ BRepGProp::SurfaceProperties( aSubShape, SProps );
+ aMeasure = SProps.Mass();
} else if ( entity == TopAbs_SOLID ) {
- BRepGProp::VolumeProperties( aSubShape, VProps );
- aMeasure = VProps.Mass();
+ BRepGProp::VolumeProperties( aSubShape, VProps );
+ aMeasure = VProps.Mass();
}
// Don't pass sub-shapes with out of range measure, if range is used
if ( hasRange ) {
- if ( aMeasure < range.min || aMeasure > range.max )
- continue;
+ if ( aMeasure < range.min || aMeasure > range.max )
+ continue;
} else {
- // get range min and max
- if ( aMeasure < range.min ) range.min = aMeasure;
- if ( aMeasure > range.max ) range.max = aMeasure;
+ // get range min and max
+ if ( aMeasure < range.min ) range.min = aMeasure;
+ if ( aMeasure > range.max ) range.max = aMeasure;
}
// get global index of sub-shape
index = aSubShapesMap.FindIndex( aSubShape );
// keep measures to distribute it
measures[shift+index] = aMeasure;
}
- shift += aNbS;
+ shift += aSubShapesMap.Extent();
}
return measures;
}
// purpose : gets distribution data for single shape
//=================================================================================
Distribution ComputeDistribution( TopoDS_Shape shape,
- TopAbs_ShapeEnum entity,
- int intervals,
- Range range)
+ TopAbs_ShapeEnum entity,
+ int intervals,
+ Range range)
{
std::list<TopoDS_Shape> aShapes;
aShapes.push_back( shape );
// purpose : gets distribution data for list of shapes
//=================================================================================
Distribution ComputeDistribution( std::list<TopoDS_Shape> shapes,
- TopAbs_ShapeEnum entity,
- int nbIntervals,
- Range range)
+ TopAbs_ShapeEnum entity,
+ int nbIntervals,
+ Range range)
{
// get list of measures and compute range (if it was not specified)
std::map<int,double> measures = ComputeMeasures( shapes, entity, range );
std::vector<int> indicesToErase;
for ( dit = measures.begin(); dit != measures.end(); dit++ ) {
if ( ( dit->second >= localRange.min && dit->second < localRange.max ) ||
- ( i == nbIntervals-1 && dit->second == localRange.max ) ) {
- localRange.count++;
- localRange.indices.push_back( dit->first );
- // measure is in interval, so remove it from map of search
- indicesToErase.push_back( dit->first );
+ ( i == nbIntervals-1 && dit->second == localRange.max ) ) {
+ localRange.count++;
+ localRange.indices.push_back( dit->first );
+ // measure is in interval, so remove it from map of search
+ indicesToErase.push_back( dit->first );
}
}
aDistr.push_back( localRange );
- for( int j=0; j < indicesToErase.size(); j++ )
+ for( size_t j=0; j < indicesToErase.size(); j++ )
measures.erase( indicesToErase[j] );
}