@@ -147,7 +147,7 @@ gp_Pnt computeShapeCenter(const TopoDS_Shape& shape)
147
147
const MeasureCircle circle = MeasureToolBRep::brepCircle (shape);
148
148
return circle.value .Location ();
149
149
}
150
- catch (const BRepMeasureError<ErrorCode::NotCircularEdge> &) {
150
+ catch (const IMeasureError &) {
151
151
BRepGProp::LinearProperties (shape, shapeProps);
152
152
}
153
153
}
@@ -276,10 +276,10 @@ MeasureCircle MeasureToolBRep::brepCircleFromGeometricEdge(const TopoDS_Edge& ed
276
276
const GCPnts_QuasiUniformAbscissa pnts (curve, 4 ); // More points to avoid confusion
277
277
throwErrorIf<ErrorCode::NotCircularEdge>(!pnts.IsDone () || pnts.NbPoints () < 3 );
278
278
const GC_MakeCircle makeCirc (
279
- GeomUtils::d0 (curve, pnts.Parameter (1 )),
280
- GeomUtils::d0 (curve, pnts.Parameter (2 )),
281
- GeomUtils::d0 (curve, pnts.Parameter (3 ))
282
- );
279
+ GeomUtils::d0 (curve, pnts.Parameter (1 )),
280
+ GeomUtils::d0 (curve, pnts.Parameter (2 )),
281
+ GeomUtils::d0 (curve, pnts.Parameter (3 ))
282
+ );
283
283
throwErrorIf<ErrorCode::NotCircularEdge>(!makeCirc.IsDone ());
284
284
circle = makeCirc.Value ()->Circ ();
285
285
}
@@ -312,10 +312,10 @@ MeasureCircle MeasureToolBRep::brepCircleFromPolygonEdge(const TopoDS_Edge& edge
312
312
throwErrorIf<ErrorCode::NotGeometricOrPolygonEdge>(polyline.IsNull () || polyline->NbNodes () < 7 );
313
313
// Try to create a circle from 3 sample points
314
314
const GC_MakeCircle makeCirc (
315
- polyline->Nodes ().First (),
316
- polyline->Nodes ().Value (1 + polyline->NbNodes () / 3 ),
317
- polyline->Nodes ().Value (1 + 2 * polyline->NbNodes () / 3 )
318
- );
315
+ polyline->Nodes ().First (),
316
+ polyline->Nodes ().Value (1 + polyline->NbNodes () / 3 ),
317
+ polyline->Nodes ().Value (1 + 2 * polyline->NbNodes () / 3 )
318
+ );
319
319
throwErrorIf<ErrorCode::NotCircularEdge>(!makeCirc.IsDone ());
320
320
const gp_Circ circle = makeCirc.Value ()->Circ ();
321
321
@@ -345,12 +345,21 @@ MeasureCircle MeasureToolBRep::brepCircle(const TopoDS_Shape& shape)
345
345
}
346
346
347
347
MeasureDistance MeasureToolBRep::brepMinDistance (
348
- const TopoDS_Shape& shape1, const TopoDS_Shape& shape2)
348
+ const TopoDS_Shape& shape1, const TopoDS_Shape& shape2
349
+ )
349
350
{
350
351
throwErrorIf<ErrorCode::NotBRepShape>(shape1.IsNull ());
351
352
throwErrorIf<ErrorCode::NotBRepShape>(shape2.IsNull ());
352
353
353
- const BRepExtrema_DistShapeShape dist (shape1, shape2);
354
+ BRepExtrema_DistShapeShape dist;
355
+ try {
356
+ dist.LoadS1 (shape1);
357
+ dist.LoadS2 (shape2);
358
+ dist.Perform ();
359
+ } catch (...) {
360
+ throw BRepMeasureError<ErrorCode::MinDistanceFailure>();
361
+ }
362
+
354
363
throwErrorIf<ErrorCode::MinDistanceFailure>(!dist.IsDone ());
355
364
356
365
MeasureDistance distResult;
@@ -362,7 +371,8 @@ MeasureDistance MeasureToolBRep::brepMinDistance(
362
371
}
363
372
364
373
MeasureDistance MeasureToolBRep::brepCenterDistance (
365
- const TopoDS_Shape& shape1, const TopoDS_Shape& shape2)
374
+ const TopoDS_Shape& shape1, const TopoDS_Shape& shape2
375
+ )
366
376
{
367
377
throwErrorIf<ErrorCode::NotBRepShape>(shape1.IsNull ());
368
378
throwErrorIf<ErrorCode::NotBRepShape>(shape2.IsNull ());
@@ -507,8 +517,8 @@ MeasureArea MeasureToolBRep::brepArea(const TopoDS_Shape& shape)
507
517
508
518
const BRepAdaptor_Surface surface (face);
509
519
areaResult.middlePnt = surface.Value (
510
- (surface.FirstUParameter () + surface.LastUParameter ()) / 2 .,
511
- (surface.FirstVParameter () + surface.LastVParameter ()) / 2 .
520
+ (surface.FirstUParameter () + surface.LastUParameter ()) / 2 .,
521
+ (surface.FirstVParameter () + surface.LastVParameter ()) / 2 .
512
522
);
513
523
}
514
524
else {
0 commit comments