1 // Created on: 2000-05-18
2 // Created by: Peter KURNEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <BOPTest.hxx>
18 #include <BRepTest.hxx>
20 #include <Draw_Interpretor.hxx>
21 #include <Draw_PluginMacro.hxx>
22 #include <GeometryTest.hxx>
23 #include <GeomliteTest.hxx>
24 #include <HLRTest.hxx>
25 #include <NCollection_Map.hxx>
26 #include <MeshTest.hxx>
27 #include <Message.hxx>
28 #include <Message_Alert.hxx>
29 #include <Message_Msg.hxx>
30 #include <Message_Messenger.hxx>
31 #include <Message_Report.hxx>
33 #include <TopoDS_AlertWithShape.hxx>
35 #include <BOPAlgo_Alerts.hxx>
36 #include <BOPTest_Objects.hxx>
38 //=======================================================================
39 //function : AllCommands
41 //=======================================================================
42 void BOPTest::AllCommands(Draw_Interpretor& theCommands)
44 static Standard_Boolean done = Standard_False;
48 BOPTest::BOPCommands (theCommands);
49 BOPTest::CheckCommands (theCommands);
50 BOPTest::LowCommands (theCommands);
51 BOPTest::TolerCommands (theCommands);
52 BOPTest::ObjCommands (theCommands);
53 BOPTest::PartitionCommands (theCommands);
54 BOPTest::APICommands (theCommands);
55 BOPTest::OptionCommands (theCommands);
56 BOPTest::DebugCommands (theCommands);
57 BOPTest::CellsCommands (theCommands);
58 BOPTest::UtilityCommands (theCommands);
59 BOPTest::RemoveFeaturesCommands(theCommands);
61 //=======================================================================
64 //=======================================================================
65 void BOPTest::Factory(Draw_Interpretor& theCommands)
67 static Standard_Boolean FactoryDone = Standard_False;
68 if (FactoryDone) return;
70 FactoryDone = Standard_True;
72 DBRep::BasicCommands(theCommands);
73 GeomliteTest::AllCommands(theCommands);
74 GeometryTest::AllCommands(theCommands);
75 BRepTest::AllCommands(theCommands);
76 MeshTest::Commands(theCommands);
77 HLRTest::Commands(theCommands);
78 BOPTest::AllCommands(theCommands);
79 SWDRAW::Init (theCommands);
81 // Declare entry point PLUGINFACTORY
84 //=======================================================================
85 //function : ReportAlerts
87 //=======================================================================
89 void BOPTest::ReportAlerts(const Handle(Message_Report)& theReport)
91 // first report warnings, then errors
92 Message_Gravity anAlertTypes[2] = { Message_Warning, Message_Fail };
93 for (int iGravity = 0; iGravity < 2; iGravity++)
95 // report shapes for the same type of alert together
96 NCollection_Map<Handle(Standard_Transient)> aPassedTypes;
97 const Message_ListOfAlert& aList = theReport->GetAlerts (anAlertTypes[iGravity]);
98 for (Message_ListOfAlert::Iterator aIt (aList); aIt.More(); aIt.Next())
100 // check that this type of warnings has not yet been processed
101 const Handle(Standard_Type)& aType = aIt.Value()->DynamicType();
102 if (!aPassedTypes.Add(aType))
106 Message_Msg aMsg (aIt.Value()->GetMessageKey());
107 TCollection_ExtendedString aText = aMsg.Get();
109 // collect all shapes if any attached to this alert
110 if (BOPTest_Objects::DrawWarnShapes())
112 TCollection_AsciiString aShapeList;
113 Standard_Integer aNbShapes = 0;
114 for (Message_ListOfAlert::Iterator aIt2 (aIt); aIt2.More(); aIt2.Next())
116 Handle(TopoDS_AlertWithShape) aShapeAlert = Handle(TopoDS_AlertWithShape)::DownCast (aIt2.Value());
118 if (!aShapeAlert.IsNull() &&
119 (aType == aShapeAlert->DynamicType()) &&
120 !aShapeAlert->GetShape().IsNull())
124 Sprintf(aName, "%ss_%d_%d", (iGravity ? "e" : "w"), aPassedTypes.Extent(), ++aNbShapes);
125 DBRep::Set(aName, aShapeAlert->GetShape());
131 aText += (aNbShapes ? ": " : "(no shapes attached)");
135 // output message with list of shapes
136 Message::DefaultMessenger()->Send (aText, anAlertTypes[iGravity]);