3 #include "GEOMImpl_IMeasureOperations.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOMImpl_MeasureDriver.hxx"
7 #include "GEOMImpl_IMeasure.hxx"
9 #include "GEOM_Function.hxx"
10 #include "GEOM_PythonDump.hxx"
12 #include "utilities.h"
14 #include "Utils_ExceptHandlers.hxx"
16 #include <TFunction_DriverTable.hxx>
17 #include <TFunction_Driver.hxx>
18 #include <TFunction_Logbook.hxx>
19 #include <TDF_Tool.hxx>
21 #include <BRep_Tool.hxx>
22 #include <BRepCheck.hxx>
23 #include <BRepCheck_Result.hxx>
24 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
25 #include <BRepGProp.hxx>
26 #include <BRepBndLib.hxx>
27 #include <BRepExtrema_DistShapeShape.hxx>
29 #include <Bnd_Box.hxx>
31 #include <GProp_GProps.hxx>
32 #include <GProp_PrincipalProps.hxx>
36 #include <TopoDS_Edge.hxx>
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Shape.hxx>
39 #include <TopoDS_Vertex.hxx>
40 #include <TopoDS_Iterator.hxx>
41 #include <TopExp_Explorer.hxx>
42 #include <TopTools_MapOfShape.hxx>
43 #include <TopTools_ListOfShape.hxx>
44 #include <TopTools_ListIteratorOfListOfShape.hxx>
46 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
48 //=============================================================================
52 //=============================================================================
53 GEOMImpl_IMeasureOperations::GEOMImpl_IMeasureOperations (GEOM_Engine* theEngine, int theDocID)
54 : GEOM_IOperations(theEngine, theDocID)
56 MESSAGE("GEOMImpl_IMeasureOperations::GEOMImpl_IMeasureOperations");
59 //=============================================================================
63 //=============================================================================
64 GEOMImpl_IMeasureOperations::~GEOMImpl_IMeasureOperations()
66 MESSAGE("GEOMImpl_IMeasureOperations::~GEOMImpl_IMeasureOperations");
70 //=============================================================================
74 //=============================================================================
75 Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass
76 (Handle(GEOM_Object) theShape)
80 if (theShape.IsNull()) return NULL;
82 //Add a new CentreOfMass object
83 Handle(GEOM_Object) aCDG = GetEngine()->AddObject(GetDocID(), GEOM_CDG);
85 //Add a new CentreOfMass function
86 Handle(GEOM_Function) aFunction =
87 aCDG->AddFunction(GEOMImpl_MeasureDriver::GetID(), CDG_MEASURE);
88 if (aFunction.IsNull()) return NULL;
90 //Check if the function is set correctly
91 if (aFunction->GetDriverGUID() != GEOMImpl_MeasureDriver::GetID()) return NULL;
93 GEOMImpl_IMeasure aCI (aFunction);
95 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
96 if (aRefShape.IsNull()) return NULL;
98 aCI.SetBase(aRefShape);
100 //Compute the CentreOfMass value
102 if (!GetSolver()->ComputeFunction(aFunction)) {
103 SetErrorCode("Measure driver failed to compute centre of mass");
107 catch (Standard_Failure) {
108 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
109 SetErrorCode(aFail->GetMessageString());
113 //Make a Python command
114 GEOM::TPythonDump(aFunction) << aCDG << " = geompy.MakeCDG(" << theShape << ")";
120 //=============================================================================
124 //=============================================================================
125 void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theShape,
126 Standard_Real& theLength,
127 Standard_Real& theSurfArea,
128 Standard_Real& theVolume)
132 if (theShape.IsNull()) return;
134 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
135 if (aRefShape.IsNull()) return;
137 TopoDS_Shape aShape = aRefShape->GetValue();
138 if (aShape.IsNull()) {
139 SetErrorCode("The Objects has NULL Shape");
143 //Compute the parameters
144 GProp_GProps LProps, SProps;
146 BRepGProp::LinearProperties(aShape, LProps);
147 theLength = LProps.Mass();
149 BRepGProp::SurfaceProperties(aShape, SProps);
150 theSurfArea = SProps.Mass();
153 if (aShape.ShapeType() < TopAbs_SHELL) {
154 for (TopExp_Explorer Exp (aShape, TopAbs_SOLID); Exp.More(); Exp.Next()) {
156 BRepGProp::VolumeProperties(Exp.Current(), VProps);
157 theVolume += VProps.Mass();
161 catch (Standard_Failure) {
162 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
163 SetErrorCode(aFail->GetMessageString());
170 //=============================================================================
174 //=============================================================================
175 void GEOMImpl_IMeasureOperations::GetInertia
176 (Handle(GEOM_Object) theShape,
177 Standard_Real& I11, Standard_Real& I12, Standard_Real& I13,
178 Standard_Real& I21, Standard_Real& I22, Standard_Real& I23,
179 Standard_Real& I31, Standard_Real& I32, Standard_Real& I33,
180 Standard_Real& Ix , Standard_Real& Iy , Standard_Real& Iz)
184 if (theShape.IsNull()) return;
186 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
187 if (aRefShape.IsNull()) return;
189 TopoDS_Shape aShape = aRefShape->GetValue();
190 if (aShape.IsNull()) {
191 SetErrorCode("The Objects has NULL Shape");
195 //Compute the parameters
199 if (aShape.ShapeType() == TopAbs_VERTEX ||
200 aShape.ShapeType() == TopAbs_EDGE ||
201 aShape.ShapeType() == TopAbs_WIRE) {
202 BRepGProp::LinearProperties(aShape, System);
203 } else if (aShape.ShapeType() == TopAbs_FACE ||
204 aShape.ShapeType() == TopAbs_SHELL) {
205 BRepGProp::SurfaceProperties(aShape, System);
207 BRepGProp::VolumeProperties(aShape, System);
209 gp_Mat I = System.MatrixOfInertia();
223 GProp_PrincipalProps Pr = System.PrincipalProperties();
224 Pr.Moments(Ix,Iy,Iz);
226 catch (Standard_Failure) {
227 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
228 SetErrorCode(aFail->GetMessageString());
235 //=============================================================================
239 //=============================================================================
240 void GEOMImpl_IMeasureOperations::GetBoundingBox
241 (Handle(GEOM_Object) theShape,
242 Standard_Real& Xmin, Standard_Real& Xmax,
243 Standard_Real& Ymin, Standard_Real& Ymax,
244 Standard_Real& Zmin, Standard_Real& Zmax)
248 if (theShape.IsNull()) return;
250 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
251 if (aRefShape.IsNull()) return;
253 TopoDS_Shape aShape = aRefShape->GetValue();
254 if (aShape.IsNull()) {
255 SetErrorCode("The Objects has NULL Shape");
259 //Compute the parameters
263 BRepBndLib::Add(aShape, B);
264 B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
266 catch (Standard_Failure) {
267 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
268 SetErrorCode(aFail->GetMessageString());
275 //=============================================================================
279 //=============================================================================
280 void GEOMImpl_IMeasureOperations::GetTolerance
281 (Handle(GEOM_Object) theShape,
282 Standard_Real& FaceMin, Standard_Real& FaceMax,
283 Standard_Real& EdgeMin, Standard_Real& EdgeMax,
284 Standard_Real& VertMin, Standard_Real& VertMax)
288 if (theShape.IsNull()) return;
290 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
291 if (aRefShape.IsNull()) return;
293 TopoDS_Shape aShape = aRefShape->GetValue();
294 if (aShape.IsNull()) {
295 SetErrorCode("The Objects has NULL Shape");
299 //Compute the parameters
301 FaceMin = EdgeMin = VertMin = RealLast();
302 FaceMax = EdgeMax = VertMax = -RealLast();
305 for (TopExp_Explorer ExF (aShape, TopAbs_FACE); ExF.More(); ExF.Next()) {
306 TopoDS_Face Face = TopoDS::Face(ExF.Current());
307 T = BRep_Tool::Tolerance(Face);
313 for (TopExp_Explorer ExE (aShape, TopAbs_EDGE); ExE.More(); ExE.Next()) {
314 TopoDS_Edge Edge = TopoDS::Edge(ExE.Current());
315 T = BRep_Tool::Tolerance(Edge);
321 for (TopExp_Explorer ExV (aShape, TopAbs_VERTEX); ExV.More(); ExV.Next()) {
322 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV.Current());
323 T = BRep_Tool::Tolerance(Vertex);
330 catch (Standard_Failure) {
331 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
332 SetErrorCode(aFail->GetMessageString());
339 //=============================================================================
343 //=============================================================================
344 bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape,
345 TCollection_AsciiString& theDump)
349 if (theShape.IsNull()) return false;
351 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
352 if (aRefShape.IsNull()) return false;
354 TopoDS_Shape aShape = aRefShape->GetValue();
355 if (aShape.IsNull()) {
356 SetErrorCode("The Objects has NULL Shape");
360 //Compute the parameters
361 bool isValid = false;
363 BRepCheck_Analyzer ana (aShape, false);
368 StructuralDump(ana, aShape, theDump);
371 catch (Standard_Failure) {
372 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
373 SetErrorCode(aFail->GetMessageString());
381 //=============================================================================
385 //=============================================================================
386 TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object) theShape)
390 TCollection_AsciiString Astr;
392 if (theShape.IsNull()) return Astr;
394 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
395 if (aRefShape.IsNull()) return Astr;
397 TopoDS_Shape aShape = aRefShape->GetValue();
398 if (aShape.IsNull()) {
399 SetErrorCode("The Objects has NULL Shape");
403 //Compute the parameters
404 if (aShape.ShapeType() == TopAbs_EDGE) {
405 if (BRep_Tool::Degenerated(TopoDS::Edge(aShape))) {
406 Astr = Astr + " It is a degenerated edge \n";
410 Astr = Astr + " Number of sub-shapes : \n";
413 int iType, nbTypes [TopAbs_SHAPE];
414 for (iType = 0; iType < TopAbs_SHAPE; ++iType)
416 nbTypes[aShape.ShapeType()]++;
418 TopTools_MapOfShape aMapOfShape;
419 aMapOfShape.Add(aShape);
420 TopTools_ListOfShape aListOfShape;
421 aListOfShape.Append(aShape);
423 TopTools_ListIteratorOfListOfShape itL (aListOfShape);
424 for (; itL.More(); itL.Next()) {
425 TopoDS_Iterator it (itL.Value());
426 for (; it.More(); it.Next()) {
427 TopoDS_Shape s = it.Value();
428 if (aMapOfShape.Add(s)) {
429 aListOfShape.Append(s);
430 nbTypes[s.ShapeType()]++;
435 Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbTypes[TopAbs_VERTEX]) + "\n";
436 Astr = Astr + " EDGE : " + TCollection_AsciiString(nbTypes[TopAbs_EDGE]) + "\n";
437 Astr = Astr + " WIRE : " + TCollection_AsciiString(nbTypes[TopAbs_WIRE]) + "\n";
438 Astr = Astr + " FACE : " + TCollection_AsciiString(nbTypes[TopAbs_FACE]) + "\n";
439 Astr = Astr + " SHELL : " + TCollection_AsciiString(nbTypes[TopAbs_SHELL]) + "\n";
440 Astr = Astr + " SOLID : " + TCollection_AsciiString(nbTypes[TopAbs_SOLID]) + "\n";
441 Astr = Astr + " COMPSOLID : " + TCollection_AsciiString(nbTypes[TopAbs_COMPSOLID]) + "\n";
442 Astr = Astr + " COMPOUND : " + TCollection_AsciiString(nbTypes[TopAbs_COMPOUND]) + "\n";
443 Astr = Astr + " SHAPE : " + TCollection_AsciiString(aMapOfShape.Extent());
445 catch (Standard_Failure) {
446 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
447 SetErrorCode(aFail->GetMessageString());
455 //=============================================================================
459 //=============================================================================
460 Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance
461 (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2,
462 Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1,
463 Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2)
466 Standard_Real MinDist = 1.e9;
468 if (theShape1.IsNull() || theShape2.IsNull()) return MinDist;
470 Handle(GEOM_Function) aRefShape1 = theShape1->GetLastFunction();
471 Handle(GEOM_Function) aRefShape2 = theShape2->GetLastFunction();
472 if (aRefShape1.IsNull() || aRefShape2.IsNull()) return MinDist;
474 TopoDS_Shape aShape1 = aRefShape1->GetValue();
475 TopoDS_Shape aShape2 = aRefShape2->GetValue();
476 if (aShape1.IsNull() || aShape2.IsNull()) {
477 SetErrorCode("One of Objects has NULL Shape");
481 //Compute the parameters
483 BRepExtrema_DistShapeShape dst (aShape1, aShape2);
485 gp_Pnt PMin1, PMin2, P1, P2;
487 for (int i = 1; i <= dst.NbSolution(); i++) {
488 P1 = dst.PointOnShape1(i);
489 P2 = dst.PointOnShape2(i);
491 Standard_Real Dist = P1.Distance(P2);
492 if (MinDist > Dist) {
499 PMin1.Coord(X1, Y1, Z1);
500 PMin2.Coord(X2, Y2, Z2);
503 catch (Standard_Failure) {
504 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
505 SetErrorCode(aFail->GetMessageString());
513 //=======================================================================
514 //function : PointCoordinates
515 //purpose : Get coordinates of point
516 //=======================================================================
517 void GEOMImpl_IMeasureOperations::PointCoordinates( Handle(GEOM_Object) theShape,
518 Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ )
522 if ( theShape.IsNull() )
525 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
526 if ( aRefShape.IsNull() )
529 TopoDS_Shape aShape = aRefShape->GetValue();
530 if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX )
532 SetErrorCode( "Shape must be a vertex" );
538 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
544 catch ( Standard_Failure )
546 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
547 SetErrorCode( aFail->GetMessageString() );
551 //=======================================================================
552 //function : StructuralDump
553 //purpose : Structural (data exchange) style of output.
554 //=======================================================================
555 void GEOMImpl_IMeasureOperations::StructuralDump (const BRepCheck_Analyzer& theAna,
556 const TopoDS_Shape& theShape,
557 TCollection_AsciiString& theDump)
561 theDump += " -- The Shape has problems :\n";
562 theDump += " Check Count\n";
563 theDump += " ------------------------------------------------\n";
565 Standard_Integer last_stat = (Standard_Integer)BRepCheck_CheckFail;
566 Handle(TColStd_HArray1OfInteger) NbProblems =
567 new TColStd_HArray1OfInteger(1, last_stat);
568 for (i = 1; i <= last_stat; i++)
569 NbProblems->SetValue(i,0);
571 Handle(TopTools_HSequenceOfShape) sl;
572 sl = new TopTools_HSequenceOfShape();
573 TopTools_DataMapOfShapeListOfShape theMap;
575 GetProblemShapes(theAna, theShape, sl, NbProblems, theMap);
578 Standard_Integer count = 0;
579 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurve);
581 theDump += " Invalid Point on Curve ................... ";
582 theDump += TCollection_AsciiString(count) + "\n";
584 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurveOnSurface);
586 theDump += " Invalid Point on CurveOnSurface .......... ";
587 theDump += TCollection_AsciiString(count) + "\n";
589 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnSurface);
591 theDump += " Invalid Point on Surface ................. ";
592 theDump += TCollection_AsciiString(count) + "\n";
594 count = NbProblems->Value((Standard_Integer)BRepCheck_No3DCurve);
596 theDump += " No 3D Curve .............................. ";
597 theDump += TCollection_AsciiString(count) + "\n";
599 count = NbProblems->Value((Standard_Integer)BRepCheck_Multiple3DCurve);
601 theDump += " Multiple 3D Curve ........................ ";
602 theDump += TCollection_AsciiString(count) + "\n";
604 count = NbProblems->Value((Standard_Integer)BRepCheck_Invalid3DCurve);
606 theDump += " Invalid 3D Curve ......................... ";
607 theDump += TCollection_AsciiString(count) + "\n";
609 count = NbProblems->Value((Standard_Integer)BRepCheck_NoCurveOnSurface);
611 theDump += " No Curve on Surface ...................... ";
612 theDump += TCollection_AsciiString(count) + "\n";
614 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidCurveOnSurface);
616 theDump += " Invalid Curve on Surface ................. ";
617 theDump += TCollection_AsciiString(count) + "\n";
619 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidCurveOnClosedSurface);
621 theDump += " Invalid Curve on closed Surface .......... ";
622 theDump += TCollection_AsciiString(count) + "\n";
624 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidSameRangeFlag);
626 theDump += " Invalid SameRange Flag ................... ";
627 theDump += TCollection_AsciiString(count) + "\n";
629 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidSameParameterFlag);
631 theDump += " Invalid SameParameter Flag ............... ";
632 theDump += TCollection_AsciiString(count) + "\n";
634 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidDegeneratedFlag);
636 theDump += " Invalid Degenerated Flag ................. ";
637 theDump += TCollection_AsciiString(count) + "\n";
639 count = NbProblems->Value((Standard_Integer)BRepCheck_FreeEdge);
641 theDump += " Free Edge ................................ ";
642 theDump += TCollection_AsciiString(count) + "\n";
644 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidMultiConnexity);
646 theDump += " Invalid MultiConnexity ................... ";
647 theDump += TCollection_AsciiString(count) + "\n";
649 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidRange);
651 theDump += " Invalid Range ............................ ";
652 theDump += TCollection_AsciiString(count) + "\n";
654 count = NbProblems->Value((Standard_Integer)BRepCheck_EmptyWire);
656 theDump += " Empty Wire ............................... ";
657 theDump += TCollection_AsciiString(count) + "\n";
659 count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantEdge);
661 theDump += " Redundant Edge ........................... ";
662 theDump += TCollection_AsciiString(count) + "\n";
664 count = NbProblems->Value((Standard_Integer)BRepCheck_SelfIntersectingWire);
666 theDump += " Self Intersecting Wire ................... ";
667 theDump += TCollection_AsciiString(count) + "\n";
669 count = NbProblems->Value((Standard_Integer)BRepCheck_NoSurface);
671 theDump += " No Surface ............................... ";
672 theDump += TCollection_AsciiString(count) + "\n";
674 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidWire);
676 theDump += " Invalid Wire ............................. ";
677 theDump += TCollection_AsciiString(count) + "\n";
679 count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantWire);
681 theDump += " Redundant Wire ........................... ";
682 theDump += TCollection_AsciiString(count) + "\n";
684 count = NbProblems->Value((Standard_Integer)BRepCheck_IntersectingWires);
686 theDump += " Intersecting Wires ....................... ";
687 theDump += TCollection_AsciiString(count) + "\n";
689 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidImbricationOfWires);
691 theDump += " Invalid Imbrication of Wires ............. ";
692 theDump += TCollection_AsciiString(count) + "\n";
694 count = NbProblems->Value((Standard_Integer)BRepCheck_EmptyShell);
696 theDump += " Empty Shell .............................. ";
697 theDump += TCollection_AsciiString(count) + "\n";
699 count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantFace);
701 theDump += " Redundant Face ........................... ";
702 theDump += TCollection_AsciiString(count) + "\n";
704 count = NbProblems->Value((Standard_Integer)BRepCheck_UnorientableShape);
706 theDump += " Unorientable Shape ....................... ";
707 theDump += TCollection_AsciiString(count) + "\n";
709 count = NbProblems->Value((Standard_Integer)BRepCheck_NotClosed);
711 theDump += " Not Closed ............................... ";
712 theDump += TCollection_AsciiString(count) + "\n";
714 count = NbProblems->Value((Standard_Integer)BRepCheck_NotConnected);
716 theDump += " Not Connected ............................ ";
717 theDump += TCollection_AsciiString(count) + "\n";
719 count = NbProblems->Value((Standard_Integer)BRepCheck_SubshapeNotInShape);
721 theDump += " Subshape not in Shape .................... ";
722 theDump += TCollection_AsciiString(count) + "\n";
724 count = NbProblems->Value((Standard_Integer)BRepCheck_BadOrientation);
726 theDump += " Bad Orientation .......................... ";
727 theDump += TCollection_AsciiString(count) + "\n";
729 count = NbProblems->Value((Standard_Integer)BRepCheck_BadOrientationOfSubshape);
731 theDump += " Bad Orientation of Subshape .............. ";
732 theDump += TCollection_AsciiString(count) + "\n";
734 count = NbProblems->Value((Standard_Integer)BRepCheck_CheckFail);
736 theDump += " checkshape failure ....................... ";
737 theDump += TCollection_AsciiString(count) + "\n";
740 theDump += " ------------------------------------------------\n";
741 theDump += "*** Shapes with problems : ";
742 theDump += TCollection_AsciiString(sl->Length()) + "\n";
744 Standard_Integer nbv, nbe, nbw, nbf, nbs, nbo;
745 nbv = nbe = nbw = nbf = nbs = nbo = 0;
747 for (i = 1; i <= sl->Length(); i++) {
748 TopoDS_Shape shi = sl->Value(i);
749 TopAbs_ShapeEnum sti = shi.ShapeType();
751 case TopAbs_VERTEX : nbv++; break;
752 case TopAbs_EDGE : nbe++; break;
753 case TopAbs_WIRE : nbw++; break;
754 case TopAbs_FACE : nbf++; break;
755 case TopAbs_SHELL : nbs++; break;
756 case TopAbs_SOLID : nbo++; break;
762 theDump += "VERTEX : ";
763 if (nbv < 10) theDump += " ";
764 theDump += TCollection_AsciiString(nbv) + "\n";
767 theDump += "EDGE : ";
768 if (nbe < 10) theDump += " ";
769 theDump += TCollection_AsciiString(nbe) + "\n";
772 theDump += "WIRE : ";
773 if (nbw < 10) theDump += " ";
774 theDump += TCollection_AsciiString(nbw) + "\n";
777 theDump += "FACE : ";
778 if (nbf < 10) theDump += " ";
779 theDump += TCollection_AsciiString(nbf) + "\n";
782 theDump += "SHELL : ";
783 if (nbs < 10) theDump += " ";
784 theDump += TCollection_AsciiString(nbs) + "\n";
787 theDump += "SOLID : ";
788 if (nbo < 10) theDump += " ";
789 theDump += TCollection_AsciiString(nbo) + "\n";
793 //=======================================================================
794 //function : GetProblemShapes
795 // purpose : for StructuralDump
796 //=======================================================================
797 void GEOMImpl_IMeasureOperations::GetProblemShapes (const BRepCheck_Analyzer& theAna,
798 const TopoDS_Shape& theShape,
799 Handle(TopTools_HSequenceOfShape)& sl,
800 Handle(TColStd_HArray1OfInteger)& NbProblems,
801 TopTools_DataMapOfShapeListOfShape& theMap)
803 for (TopoDS_Iterator iter(theShape); iter.More(); iter.Next()) {
804 GetProblemShapes(theAna, iter.Value(), sl, NbProblems, theMap);
806 TopAbs_ShapeEnum styp = theShape.ShapeType();
807 BRepCheck_ListIteratorOfListOfStatus itl;
808 TopTools_ListOfShape empty;
809 if (!theMap.IsBound(theShape)) {
810 theMap.Bind(theShape,empty);
812 if (!theAna.Result(theShape).IsNull()) {
813 itl.Initialize(theAna.Result(theShape)->Status());
814 // !!! May be, we have to print all the problems, not only the first one ?
815 if (itl.Value() != BRepCheck_NoError) {
816 sl->Append(theShape);
817 BRepCheck_Status stat = itl.Value();
818 NbProblems->SetValue((Standard_Integer)stat,
819 NbProblems->Value((Standard_Integer)stat) + 1);
826 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_VERTEX, theMap);
829 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_WIRE, theMap);
830 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_EDGE, theMap);
831 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_VERTEX, theMap);
836 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_SHELL, theMap);
843 //=======================================================================
844 //function : Contains
845 //=======================================================================
846 static Standard_Boolean Contains (const TopTools_ListOfShape& L,
847 const TopoDS_Shape& S)
849 TopTools_ListIteratorOfListOfShape it;
850 for (it.Initialize(L); it.More(); it.Next()) {
851 if (it.Value().IsSame(S)) {
852 return Standard_True;
855 return Standard_False;
858 //=======================================================================
859 //function : GetProblemSub
860 // purpose : for StructuralDump
861 //=======================================================================
862 void GEOMImpl_IMeasureOperations::GetProblemSub (const BRepCheck_Analyzer& theAna,
863 const TopoDS_Shape& theShape,
864 Handle(TopTools_HSequenceOfShape)& sl,
865 Handle(TColStd_HArray1OfInteger)& NbProblems,
866 const TopAbs_ShapeEnum Subtype,
867 TopTools_DataMapOfShapeListOfShape& theMap)
869 BRepCheck_ListIteratorOfListOfStatus itl;
871 for (exp.Init(theShape, Subtype); exp.More(); exp.Next()) {
872 const TopoDS_Shape& sub = exp.Current();
874 const Handle(BRepCheck_Result)& res = theAna.Result(sub);
875 for (res->InitContextIterator();
876 res->MoreShapeInContext();
877 res->NextShapeInContext()) {
878 if (res->ContextualShape().IsSame(theShape) && !Contains(theMap(sub), theShape)) {
879 theMap(sub).Append(theShape);
880 itl.Initialize(res->StatusOnShape());
882 if (itl.Value() != BRepCheck_NoError) {
883 Standard_Integer ii = 0;
885 for (ii = 1; ii <= sl->Length(); ii++)
886 if (sl->Value(ii).IsSame(sub)) break;
888 if (ii > sl->Length()) {
890 BRepCheck_Status stat = itl.Value();
891 NbProblems->SetValue((Standard_Integer)stat,
892 NbProblems->Value((Standard_Integer)stat) + 1);
894 for (ii = 1; ii <= sl->Length(); ii++)
895 if (sl->Value(ii).IsSame(theShape)) break;
896 if (ii > sl->Length()) {
897 sl->Append(theShape);
898 BRepCheck_Status stat = itl.Value();
899 NbProblems->SetValue((Standard_Integer)stat,
900 NbProblems->Value((Standard_Integer)stat) + 1);