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"
11 #include "utilities.h"
13 #include "Utils_ExceptHandlers.hxx"
15 #include <TFunction_DriverTable.hxx>
16 #include <TFunction_Driver.hxx>
17 #include <TFunction_Logbook.hxx>
18 #include <TDF_Tool.hxx>
20 #include <BRep_Tool.hxx>
21 #include <BRepCheck.hxx>
22 #include <BRepCheck_Result.hxx>
23 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
24 #include <BRepGProp.hxx>
25 #include <BRepBndLib.hxx>
26 #include <BRepExtrema_DistShapeShape.hxx>
28 #include <Bnd_Box.hxx>
30 #include <GProp_GProps.hxx>
31 #include <GProp_PrincipalProps.hxx>
35 #include <TopoDS_Edge.hxx>
36 #include <TopoDS_Face.hxx>
37 #include <TopoDS_Shape.hxx>
38 #include <TopoDS_Vertex.hxx>
39 #include <TopoDS_Iterator.hxx>
40 #include <TopExp_Explorer.hxx>
41 #include <TopTools_MapOfShape.hxx>
42 #include <TopTools_ListOfShape.hxx>
43 #include <TopTools_ListIteratorOfListOfShape.hxx>
45 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
47 //=============================================================================
51 //=============================================================================
52 GEOMImpl_IMeasureOperations::GEOMImpl_IMeasureOperations (GEOM_Engine* theEngine, int theDocID)
53 : GEOM_IOperations(theEngine, theDocID)
55 MESSAGE("GEOMImpl_IMeasureOperations::GEOMImpl_IMeasureOperations");
58 //=============================================================================
62 //=============================================================================
63 GEOMImpl_IMeasureOperations::~GEOMImpl_IMeasureOperations()
65 MESSAGE("GEOMImpl_IMeasureOperations::~GEOMImpl_IMeasureOperations");
69 //=============================================================================
73 //=============================================================================
74 Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass
75 (Handle(GEOM_Object) theShape)
79 if (theShape.IsNull()) return NULL;
81 //Add a new CentreOfMass object
82 Handle(GEOM_Object) aCDG = GetEngine()->AddObject(GetDocID(), GEOM_CDG);
84 //Add a new CentreOfMass function
85 Handle(GEOM_Function) aFunction =
86 aCDG->AddFunction(GEOMImpl_MeasureDriver::GetID(), CDG_MEASURE);
87 if (aFunction.IsNull()) return NULL;
89 //Check if the function is set correctly
90 if (aFunction->GetDriverGUID() != GEOMImpl_MeasureDriver::GetID()) return NULL;
92 GEOMImpl_IMeasure aCI (aFunction);
94 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
95 if (aRefShape.IsNull()) return NULL;
97 aCI.SetBase(aRefShape);
99 //Compute the CentreOfMass value
101 if (!GetSolver()->ComputeFunction(aFunction)) {
102 SetErrorCode("Measure driver failed to compute centre of mass");
106 catch (Standard_Failure) {
107 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
108 SetErrorCode(aFail->GetMessageString());
112 //Make a Python command
113 TCollection_AsciiString anEntry, aDescr;
114 TDF_Tool::Entry(aCDG->GetEntry(), anEntry);
115 aDescr += anEntry + " = IMeasureOperations.MakeCentreOfMass(";
116 TDF_Tool::Entry(theShape->GetEntry(), anEntry);
117 aDescr += anEntry + ")";
119 aFunction->SetDescription(aDescr);
125 //=============================================================================
129 //=============================================================================
130 void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theShape,
131 Standard_Real& theLength,
132 Standard_Real& theSurfArea,
133 Standard_Real& theVolume)
137 if (theShape.IsNull()) return;
139 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
140 if (aRefShape.IsNull()) return;
142 TopoDS_Shape aShape = aRefShape->GetValue();
143 if (aShape.IsNull()) {
144 SetErrorCode("The Objects has NULL Shape");
148 //Compute the parameters
149 GProp_GProps LProps, SProps;
151 BRepGProp::LinearProperties(aShape, LProps);
152 theLength = LProps.Mass();
154 BRepGProp::SurfaceProperties(aShape, SProps);
155 theSurfArea = SProps.Mass();
158 if (aShape.ShapeType() < TopAbs_SHELL) {
159 for (TopExp_Explorer Exp (aShape, TopAbs_SOLID); Exp.More(); Exp.Next()) {
161 BRepGProp::VolumeProperties(Exp.Current(), VProps);
162 theVolume += VProps.Mass();
166 catch (Standard_Failure) {
167 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
168 SetErrorCode(aFail->GetMessageString());
175 //=============================================================================
179 //=============================================================================
180 void GEOMImpl_IMeasureOperations::GetInertia
181 (Handle(GEOM_Object) theShape,
182 Standard_Real& I11, Standard_Real& I12, Standard_Real& I13,
183 Standard_Real& I21, Standard_Real& I22, Standard_Real& I23,
184 Standard_Real& I31, Standard_Real& I32, Standard_Real& I33,
185 Standard_Real& Ix , Standard_Real& Iy , Standard_Real& Iz)
189 if (theShape.IsNull()) return;
191 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
192 if (aRefShape.IsNull()) return;
194 TopoDS_Shape aShape = aRefShape->GetValue();
195 if (aShape.IsNull()) {
196 SetErrorCode("The Objects has NULL Shape");
200 //Compute the parameters
204 if (aShape.ShapeType() == TopAbs_VERTEX ||
205 aShape.ShapeType() == TopAbs_EDGE ||
206 aShape.ShapeType() == TopAbs_WIRE) {
207 BRepGProp::LinearProperties(aShape, System);
208 } else if (aShape.ShapeType() == TopAbs_FACE ||
209 aShape.ShapeType() == TopAbs_SHELL) {
210 BRepGProp::SurfaceProperties(aShape, System);
212 BRepGProp::VolumeProperties(aShape, System);
214 gp_Mat I = System.MatrixOfInertia();
228 GProp_PrincipalProps Pr = System.PrincipalProperties();
229 Pr.Moments(Ix,Iy,Iz);
231 catch (Standard_Failure) {
232 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
233 SetErrorCode(aFail->GetMessageString());
240 //=============================================================================
244 //=============================================================================
245 void GEOMImpl_IMeasureOperations::GetBoundingBox
246 (Handle(GEOM_Object) theShape,
247 Standard_Real& Xmin, Standard_Real& Xmax,
248 Standard_Real& Ymin, Standard_Real& Ymax,
249 Standard_Real& Zmin, Standard_Real& Zmax)
253 if (theShape.IsNull()) return;
255 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
256 if (aRefShape.IsNull()) return;
258 TopoDS_Shape aShape = aRefShape->GetValue();
259 if (aShape.IsNull()) {
260 SetErrorCode("The Objects has NULL Shape");
264 //Compute the parameters
268 BRepBndLib::Add(aShape, B);
269 B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
271 catch (Standard_Failure) {
272 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
273 SetErrorCode(aFail->GetMessageString());
280 //=============================================================================
284 //=============================================================================
285 void GEOMImpl_IMeasureOperations::GetTolerance
286 (Handle(GEOM_Object) theShape,
287 Standard_Real& FaceMin, Standard_Real& FaceMax,
288 Standard_Real& EdgeMin, Standard_Real& EdgeMax,
289 Standard_Real& VertMin, Standard_Real& VertMax)
293 if (theShape.IsNull()) return;
295 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
296 if (aRefShape.IsNull()) return;
298 TopoDS_Shape aShape = aRefShape->GetValue();
299 if (aShape.IsNull()) {
300 SetErrorCode("The Objects has NULL Shape");
304 //Compute the parameters
306 FaceMin = EdgeMin = VertMin = RealLast();
307 FaceMax = EdgeMax = VertMax = -RealLast();
310 for (TopExp_Explorer ExF (aShape, TopAbs_FACE); ExF.More(); ExF.Next()) {
311 TopoDS_Face Face = TopoDS::Face(ExF.Current());
312 T = BRep_Tool::Tolerance(Face);
318 for (TopExp_Explorer ExE (aShape, TopAbs_EDGE); ExE.More(); ExE.Next()) {
319 TopoDS_Edge Edge = TopoDS::Edge(ExE.Current());
320 T = BRep_Tool::Tolerance(Edge);
326 for (TopExp_Explorer ExV (aShape, TopAbs_VERTEX); ExV.More(); ExV.Next()) {
327 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV.Current());
328 T = BRep_Tool::Tolerance(Vertex);
335 catch (Standard_Failure) {
336 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
337 SetErrorCode(aFail->GetMessageString());
344 //=============================================================================
348 //=============================================================================
349 bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape,
350 TCollection_AsciiString& theDump)
354 if (theShape.IsNull()) return false;
356 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
357 if (aRefShape.IsNull()) return false;
359 TopoDS_Shape aShape = aRefShape->GetValue();
360 if (aShape.IsNull()) {
361 SetErrorCode("The Objects has NULL Shape");
365 //Compute the parameters
366 bool isValid = false;
368 BRepCheck_Analyzer ana (aShape, false);
373 StructuralDump(ana, aShape, theDump);
376 catch (Standard_Failure) {
377 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
378 SetErrorCode(aFail->GetMessageString());
386 //=============================================================================
390 //=============================================================================
391 TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object) theShape)
395 TCollection_AsciiString Astr;
397 if (theShape.IsNull()) return Astr;
399 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
400 if (aRefShape.IsNull()) return Astr;
402 TopoDS_Shape aShape = aRefShape->GetValue();
403 if (aShape.IsNull()) {
404 SetErrorCode("The Objects has NULL Shape");
408 //Compute the parameters
409 if (aShape.ShapeType() == TopAbs_EDGE) {
410 if (BRep_Tool::Degenerated(TopoDS::Edge(aShape))) {
411 Astr = Astr + " It is a degenerated edge \n";
415 Astr = Astr + " Number of sub-shapes : \n";
418 int iType, nbTypes [TopAbs_SHAPE];
419 for (iType = 0; iType < TopAbs_SHAPE; ++iType)
421 nbTypes[aShape.ShapeType()]++;
423 TopTools_MapOfShape aMapOfShape;
424 aMapOfShape.Add(aShape);
425 TopTools_ListOfShape aListOfShape;
426 aListOfShape.Append(aShape);
428 TopTools_ListIteratorOfListOfShape itL (aListOfShape);
429 for (; itL.More(); itL.Next()) {
430 TopoDS_Iterator it (itL.Value());
431 for (; it.More(); it.Next()) {
432 TopoDS_Shape s = it.Value();
433 if (aMapOfShape.Add(s)) {
434 aListOfShape.Append(s);
435 nbTypes[s.ShapeType()]++;
440 Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbTypes[TopAbs_VERTEX]) + "\n";
441 Astr = Astr + " EDGE : " + TCollection_AsciiString(nbTypes[TopAbs_EDGE]) + "\n";
442 Astr = Astr + " WIRE : " + TCollection_AsciiString(nbTypes[TopAbs_WIRE]) + "\n";
443 Astr = Astr + " FACE : " + TCollection_AsciiString(nbTypes[TopAbs_FACE]) + "\n";
444 Astr = Astr + " SHELL : " + TCollection_AsciiString(nbTypes[TopAbs_SHELL]) + "\n";
445 Astr = Astr + " SOLID : " + TCollection_AsciiString(nbTypes[TopAbs_SOLID]) + "\n";
446 Astr = Astr + " COMPSOLID : " + TCollection_AsciiString(nbTypes[TopAbs_COMPSOLID]) + "\n";
447 Astr = Astr + " COMPOUND : " + TCollection_AsciiString(nbTypes[TopAbs_COMPOUND]) + "\n";
448 Astr = Astr + " SHAPE : " + TCollection_AsciiString(aMapOfShape.Extent());
450 catch (Standard_Failure) {
451 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
452 SetErrorCode(aFail->GetMessageString());
460 //=============================================================================
464 //=============================================================================
465 Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance
466 (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2,
467 Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1,
468 Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2)
471 Standard_Real MinDist = 1.e9;
473 if (theShape1.IsNull() || theShape2.IsNull()) return MinDist;
475 Handle(GEOM_Function) aRefShape1 = theShape1->GetLastFunction();
476 Handle(GEOM_Function) aRefShape2 = theShape2->GetLastFunction();
477 if (aRefShape1.IsNull() || aRefShape2.IsNull()) return MinDist;
479 TopoDS_Shape aShape1 = aRefShape1->GetValue();
480 TopoDS_Shape aShape2 = aRefShape2->GetValue();
481 if (aShape1.IsNull() || aShape2.IsNull()) {
482 SetErrorCode("One of Objects has NULL Shape");
486 //Compute the parameters
488 BRepExtrema_DistShapeShape dst (aShape1, aShape2);
490 gp_Pnt PMin1, PMin2, P1, P2;
492 for (int i = 1; i <= dst.NbSolution(); i++) {
493 P1 = dst.PointOnShape1(i);
494 P2 = dst.PointOnShape2(i);
496 Standard_Real Dist = P1.Distance(P2);
497 if (MinDist > Dist) {
504 PMin1.Coord(X1, Y1, Z1);
505 PMin2.Coord(X2, Y2, Z2);
508 catch (Standard_Failure) {
509 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
510 SetErrorCode(aFail->GetMessageString());
518 //=======================================================================
519 //function : PointCoordinates
520 //purpose : Get coordinates of point
521 //=======================================================================
522 void GEOMImpl_IMeasureOperations::PointCoordinates( Handle(GEOM_Object) theShape,
523 Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ )
527 if ( theShape.IsNull() )
530 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
531 if ( aRefShape.IsNull() )
534 TopoDS_Shape aShape = aRefShape->GetValue();
535 if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX )
537 SetErrorCode( "Shape must be a vertex" );
543 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
549 catch ( Standard_Failure )
551 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
552 SetErrorCode( aFail->GetMessageString() );
556 //=======================================================================
557 //function : StructuralDump
558 //purpose : Structural (data exchange) style of output.
559 //=======================================================================
560 void GEOMImpl_IMeasureOperations::StructuralDump (const BRepCheck_Analyzer& theAna,
561 const TopoDS_Shape& theShape,
562 TCollection_AsciiString& theDump)
566 theDump += " -- The Shape has problems :\n";
567 theDump += " Check Count\n";
568 theDump += " ------------------------------------------------\n";
570 Standard_Integer last_stat = (Standard_Integer)BRepCheck_CheckFail;
571 Handle(TColStd_HArray1OfInteger) NbProblems =
572 new TColStd_HArray1OfInteger(1, last_stat);
573 for (i = 1; i <= last_stat; i++)
574 NbProblems->SetValue(i,0);
576 Handle(TopTools_HSequenceOfShape) sl;
577 sl = new TopTools_HSequenceOfShape();
578 TopTools_DataMapOfShapeListOfShape theMap;
580 GetProblemShapes(theAna, theShape, sl, NbProblems, theMap);
583 Standard_Integer count = 0;
584 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurve);
586 theDump += " Invalid Point on Curve ................... ";
587 theDump += TCollection_AsciiString(count) + "\n";
589 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurveOnSurface);
591 theDump += " Invalid Point on CurveOnSurface .......... ";
592 theDump += TCollection_AsciiString(count) + "\n";
594 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnSurface);
596 theDump += " Invalid Point on Surface ................. ";
597 theDump += TCollection_AsciiString(count) + "\n";
599 count = NbProblems->Value((Standard_Integer)BRepCheck_No3DCurve);
601 theDump += " No 3D Curve .............................. ";
602 theDump += TCollection_AsciiString(count) + "\n";
604 count = NbProblems->Value((Standard_Integer)BRepCheck_Multiple3DCurve);
606 theDump += " Multiple 3D Curve ........................ ";
607 theDump += TCollection_AsciiString(count) + "\n";
609 count = NbProblems->Value((Standard_Integer)BRepCheck_Invalid3DCurve);
611 theDump += " Invalid 3D Curve ......................... ";
612 theDump += TCollection_AsciiString(count) + "\n";
614 count = NbProblems->Value((Standard_Integer)BRepCheck_NoCurveOnSurface);
616 theDump += " No Curve on Surface ...................... ";
617 theDump += TCollection_AsciiString(count) + "\n";
619 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidCurveOnSurface);
621 theDump += " Invalid Curve on Surface ................. ";
622 theDump += TCollection_AsciiString(count) + "\n";
624 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidCurveOnClosedSurface);
626 theDump += " Invalid Curve on closed Surface .......... ";
627 theDump += TCollection_AsciiString(count) + "\n";
629 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidSameRangeFlag);
631 theDump += " Invalid SameRange Flag ................... ";
632 theDump += TCollection_AsciiString(count) + "\n";
634 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidSameParameterFlag);
636 theDump += " Invalid SameParameter Flag ............... ";
637 theDump += TCollection_AsciiString(count) + "\n";
639 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidDegeneratedFlag);
641 theDump += " Invalid Degenerated Flag ................. ";
642 theDump += TCollection_AsciiString(count) + "\n";
644 count = NbProblems->Value((Standard_Integer)BRepCheck_FreeEdge);
646 theDump += " Free Edge ................................ ";
647 theDump += TCollection_AsciiString(count) + "\n";
649 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidMultiConnexity);
651 theDump += " Invalid MultiConnexity ................... ";
652 theDump += TCollection_AsciiString(count) + "\n";
654 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidRange);
656 theDump += " Invalid Range ............................ ";
657 theDump += TCollection_AsciiString(count) + "\n";
659 count = NbProblems->Value((Standard_Integer)BRepCheck_EmptyWire);
661 theDump += " Empty Wire ............................... ";
662 theDump += TCollection_AsciiString(count) + "\n";
664 count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantEdge);
666 theDump += " Redundant Edge ........................... ";
667 theDump += TCollection_AsciiString(count) + "\n";
669 count = NbProblems->Value((Standard_Integer)BRepCheck_SelfIntersectingWire);
671 theDump += " Self Intersecting Wire ................... ";
672 theDump += TCollection_AsciiString(count) + "\n";
674 count = NbProblems->Value((Standard_Integer)BRepCheck_NoSurface);
676 theDump += " No Surface ............................... ";
677 theDump += TCollection_AsciiString(count) + "\n";
679 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidWire);
681 theDump += " Invalid Wire ............................. ";
682 theDump += TCollection_AsciiString(count) + "\n";
684 count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantWire);
686 theDump += " Redundant Wire ........................... ";
687 theDump += TCollection_AsciiString(count) + "\n";
689 count = NbProblems->Value((Standard_Integer)BRepCheck_IntersectingWires);
691 theDump += " Intersecting Wires ....................... ";
692 theDump += TCollection_AsciiString(count) + "\n";
694 count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidImbricationOfWires);
696 theDump += " Invalid Imbrication of Wires ............. ";
697 theDump += TCollection_AsciiString(count) + "\n";
699 count = NbProblems->Value((Standard_Integer)BRepCheck_EmptyShell);
701 theDump += " Empty Shell .............................. ";
702 theDump += TCollection_AsciiString(count) + "\n";
704 count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantFace);
706 theDump += " Redundant Face ........................... ";
707 theDump += TCollection_AsciiString(count) + "\n";
709 count = NbProblems->Value((Standard_Integer)BRepCheck_UnorientableShape);
711 theDump += " Unorientable Shape ....................... ";
712 theDump += TCollection_AsciiString(count) + "\n";
714 count = NbProblems->Value((Standard_Integer)BRepCheck_NotClosed);
716 theDump += " Not Closed ............................... ";
717 theDump += TCollection_AsciiString(count) + "\n";
719 count = NbProblems->Value((Standard_Integer)BRepCheck_NotConnected);
721 theDump += " Not Connected ............................ ";
722 theDump += TCollection_AsciiString(count) + "\n";
724 count = NbProblems->Value((Standard_Integer)BRepCheck_SubshapeNotInShape);
726 theDump += " Subshape not in Shape .................... ";
727 theDump += TCollection_AsciiString(count) + "\n";
729 count = NbProblems->Value((Standard_Integer)BRepCheck_BadOrientation);
731 theDump += " Bad Orientation .......................... ";
732 theDump += TCollection_AsciiString(count) + "\n";
734 count = NbProblems->Value((Standard_Integer)BRepCheck_BadOrientationOfSubshape);
736 theDump += " Bad Orientation of Subshape .............. ";
737 theDump += TCollection_AsciiString(count) + "\n";
739 count = NbProblems->Value((Standard_Integer)BRepCheck_CheckFail);
741 theDump += " checkshape failure ....................... ";
742 theDump += TCollection_AsciiString(count) + "\n";
745 theDump += " ------------------------------------------------\n";
746 theDump += "*** Shapes with problems : ";
747 theDump += TCollection_AsciiString(sl->Length()) + "\n";
749 Standard_Integer nbv, nbe, nbw, nbf, nbs, nbo;
750 nbv = nbe = nbw = nbf = nbs = nbo = 0;
752 for (i = 1; i <= sl->Length(); i++) {
753 TopoDS_Shape shi = sl->Value(i);
754 TopAbs_ShapeEnum sti = shi.ShapeType();
756 case TopAbs_VERTEX : nbv++; break;
757 case TopAbs_EDGE : nbe++; break;
758 case TopAbs_WIRE : nbw++; break;
759 case TopAbs_FACE : nbf++; break;
760 case TopAbs_SHELL : nbs++; break;
761 case TopAbs_SOLID : nbo++; break;
767 theDump += "VERTEX : ";
768 if (nbv < 10) theDump += " ";
769 theDump += TCollection_AsciiString(nbv) + "\n";
772 theDump += "EDGE : ";
773 if (nbe < 10) theDump += " ";
774 theDump += TCollection_AsciiString(nbe) + "\n";
777 theDump += "WIRE : ";
778 if (nbw < 10) theDump += " ";
779 theDump += TCollection_AsciiString(nbw) + "\n";
782 theDump += "FACE : ";
783 if (nbf < 10) theDump += " ";
784 theDump += TCollection_AsciiString(nbf) + "\n";
787 theDump += "SHELL : ";
788 if (nbs < 10) theDump += " ";
789 theDump += TCollection_AsciiString(nbs) + "\n";
792 theDump += "SOLID : ";
793 if (nbo < 10) theDump += " ";
794 theDump += TCollection_AsciiString(nbo) + "\n";
798 //=======================================================================
799 //function : GetProblemShapes
800 // purpose : for StructuralDump
801 //=======================================================================
802 void GEOMImpl_IMeasureOperations::GetProblemShapes (const BRepCheck_Analyzer& theAna,
803 const TopoDS_Shape& theShape,
804 Handle(TopTools_HSequenceOfShape)& sl,
805 Handle(TColStd_HArray1OfInteger)& NbProblems,
806 TopTools_DataMapOfShapeListOfShape& theMap)
808 for (TopoDS_Iterator iter(theShape); iter.More(); iter.Next()) {
809 GetProblemShapes(theAna, iter.Value(), sl, NbProblems, theMap);
811 TopAbs_ShapeEnum styp = theShape.ShapeType();
812 BRepCheck_ListIteratorOfListOfStatus itl;
813 if (!theMap.IsBound(theShape)) {
814 theMap.Bind(theShape,TopTools_ListOfShape());
816 if (!theAna.Result(theShape).IsNull()) {
817 itl.Initialize(theAna.Result(theShape)->Status());
818 // !!! May be, we have to print all the problems, not only the first one ?
819 if (itl.Value() != BRepCheck_NoError) {
820 sl->Append(theShape);
821 BRepCheck_Status stat = itl.Value();
822 NbProblems->SetValue((Standard_Integer)stat,
823 NbProblems->Value((Standard_Integer)stat) + 1);
830 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_VERTEX, theMap);
833 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_WIRE, theMap);
834 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_EDGE, theMap);
835 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_VERTEX, theMap);
840 GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_SHELL, theMap);
847 //=======================================================================
848 //function : Contains
849 //=======================================================================
850 static Standard_Boolean Contains (const TopTools_ListOfShape& L,
851 const TopoDS_Shape& S)
853 TopTools_ListIteratorOfListOfShape it;
854 for (it.Initialize(L); it.More(); it.Next()) {
855 if (it.Value().IsSame(S)) {
856 return Standard_True;
859 return Standard_False;
862 //=======================================================================
863 //function : GetProblemSub
864 // purpose : for StructuralDump
865 //=======================================================================
866 void GEOMImpl_IMeasureOperations::GetProblemSub (const BRepCheck_Analyzer& theAna,
867 const TopoDS_Shape& theShape,
868 Handle(TopTools_HSequenceOfShape)& sl,
869 Handle(TColStd_HArray1OfInteger)& NbProblems,
870 const TopAbs_ShapeEnum Subtype,
871 TopTools_DataMapOfShapeListOfShape& theMap)
873 BRepCheck_ListIteratorOfListOfStatus itl;
875 for (exp.Init(theShape, Subtype); exp.More(); exp.Next()) {
876 const TopoDS_Shape& sub = exp.Current();
878 const Handle(BRepCheck_Result)& res = theAna.Result(sub);
879 for (res->InitContextIterator();
880 res->MoreShapeInContext();
881 res->NextShapeInContext()) {
882 if (res->ContextualShape().IsSame(theShape) && !Contains(theMap(sub), theShape)) {
883 theMap(sub).Append(theShape);
884 itl.Initialize(res->StatusOnShape());
886 if (itl.Value() != BRepCheck_NoError) {
887 Standard_Integer ii = 0;
889 for (ii = 1; ii <= sl->Length(); ii++)
890 if (sl->Value(ii).IsSame(sub)) break;
892 if (ii > sl->Length()) {
894 BRepCheck_Status stat = itl.Value();
895 NbProblems->SetValue((Standard_Integer)stat,
896 NbProblems->Value((Standard_Integer)stat) + 1);
898 for (ii = 1; ii <= sl->Length(); ii++)
899 if (sl->Value(ii).IsSame(theShape)) break;
900 if (ii > sl->Length()) {
901 sl->Append(theShape);
902 BRepCheck_Status stat = itl.Value();
903 NbProblems->SetValue((Standard_Integer)stat,
904 NbProblems->Value((Standard_Integer)stat) + 1);