b311480e |
1 | // Created on: 2000-05-18 |
2 | // Created by: Peter KURNEV |
973c2be1 |
3 | // Copyright (c) 2000-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
42cf5bc1 |
16 | |
17 | #include <BOPTest.hxx> |
18 | #include <BRepTest.hxx> |
7fd59977 |
19 | #include <DBRep.hxx> |
20 | #include <Draw_Interpretor.hxx> |
7868210d |
21 | #include <Draw_PluginMacro.hxx> |
7fd59977 |
22 | #include <GeometryTest.hxx> |
42cf5bc1 |
23 | #include <GeomliteTest.hxx> |
7fd59977 |
24 | #include <HLRTest.hxx> |
33ba8565 |
25 | #include <NCollection_Map.hxx> |
42cf5bc1 |
26 | #include <MeshTest.hxx> |
33ba8565 |
27 | #include <Message.hxx> |
d9ca2e0c |
28 | #include <Message_Alert.hxx> |
33ba8565 |
29 | #include <Message_Msg.hxx> |
30 | #include <Message_Messenger.hxx> |
d9ca2e0c |
31 | #include <Message_Report.hxx> |
7868210d |
32 | #include <SWDRAW.hxx> |
33ba8565 |
33 | #include <TopoDS_AlertWithShape.hxx> |
34 | |
d9ca2e0c |
35 | #include <BOPAlgo_Alerts.hxx> |
33ba8565 |
36 | #include <BOPTest_Objects.hxx> |
7fd59977 |
37 | |
38 | //======================================================================= |
39 | //function : AllCommands |
40 | //purpose : |
41 | //======================================================================= |
b311480e |
42 | void BOPTest::AllCommands(Draw_Interpretor& theCommands) |
7fd59977 |
43 | { |
44 | static Standard_Boolean done = Standard_False; |
45 | if (done) return; |
7fd59977 |
46 | done = Standard_True; |
4e57c75e |
47 | // |
48 | BOPTest::BOPCommands (theCommands); |
49 | BOPTest::CheckCommands (theCommands); |
50 | BOPTest::LowCommands (theCommands); |
51 | BOPTest::TolerCommands (theCommands); |
52 | BOPTest::ObjCommands (theCommands); |
53 | BOPTest::PartitionCommands (theCommands); |
a493b4a1 |
54 | BOPTest::APICommands (theCommands); |
55 | BOPTest::OptionCommands (theCommands); |
b1682e23 |
56 | BOPTest::DebugCommands (theCommands); |
338434c7 |
57 | BOPTest::CellsCommands (theCommands); |
6ca1c746 |
58 | BOPTest::UtilityCommands (theCommands); |
d9ca2e0c |
59 | BOPTest::RemoveFeaturesCommands(theCommands); |
7fd59977 |
60 | } |
4e57c75e |
61 | //======================================================================= |
62 | //function : Factory |
63 | //purpose : |
64 | //======================================================================= |
65 | void BOPTest::Factory(Draw_Interpretor& theCommands) |
7fd59977 |
66 | { |
67 | static Standard_Boolean FactoryDone = Standard_False; |
68 | if (FactoryDone) return; |
69 | |
70 | FactoryDone = Standard_True; |
7fd59977 |
71 | |
4e57c75e |
72 | DBRep::BasicCommands(theCommands); |
73 | GeomliteTest::AllCommands(theCommands); |
74 | GeometryTest::AllCommands(theCommands); |
75 | BRepTest::AllCommands(theCommands); |
76 | MeshTest::Commands(theCommands); |
4e57c75e |
77 | HLRTest::Commands(theCommands); |
78 | BOPTest::AllCommands(theCommands); |
7868210d |
79 | SWDRAW::Init (theCommands); |
7fd59977 |
80 | } |
7868210d |
81 | // Declare entry point PLUGINFACTORY |
82 | DPLUGIN(BOPTest) |
33ba8565 |
83 | |
84 | //======================================================================= |
85 | //function : ReportAlerts |
86 | //purpose : |
87 | //======================================================================= |
88 | |
d9ca2e0c |
89 | void BOPTest::ReportAlerts(const Handle(Message_Report)& theReport) |
33ba8565 |
90 | { |
91 | // first report warnings, then errors |
92 | Message_Gravity anAlertTypes[2] = { Message_Warning, Message_Fail }; |
93 | for (int iGravity = 0; iGravity < 2; iGravity++) |
94 | { |
95 | // report shapes for the same type of alert together |
96 | NCollection_Map<Handle(Standard_Transient)> aPassedTypes; |
d9ca2e0c |
97 | const Message_ListOfAlert& aList = theReport->GetAlerts (anAlertTypes[iGravity]); |
33ba8565 |
98 | for (Message_ListOfAlert::Iterator aIt (aList); aIt.More(); aIt.Next()) |
99 | { |
100 | // check that this type of warnings has not yet been processed |
d9ca2e0c |
101 | const Handle(Standard_Type)& aType = aIt.Value()->DynamicType(); |
102 | if (!aPassedTypes.Add(aType)) |
33ba8565 |
103 | continue; |
104 | |
105 | // get alert message |
106 | Message_Msg aMsg (aIt.Value()->GetMessageKey()); |
107 | TCollection_ExtendedString aText = aMsg.Get(); |
108 | |
109 | // collect all shapes if any attached to this alert |
110 | if (BOPTest_Objects::DrawWarnShapes()) |
111 | { |
112 | TCollection_AsciiString aShapeList; |
113 | Standard_Integer aNbShapes = 0; |
114 | for (Message_ListOfAlert::Iterator aIt2 (aIt); aIt2.More(); aIt2.Next()) |
115 | { |
116 | Handle(TopoDS_AlertWithShape) aShapeAlert = Handle(TopoDS_AlertWithShape)::DownCast (aIt2.Value()); |
117 | |
d9ca2e0c |
118 | if (!aShapeAlert.IsNull() && |
119 | (aType == aShapeAlert->DynamicType()) && |
120 | !aShapeAlert->GetShape().IsNull()) |
33ba8565 |
121 | { |
122 | // |
123 | char aName[80]; |
124 | Sprintf(aName, "%ss_%d_%d", (iGravity ? "e" : "w"), aPassedTypes.Extent(), ++aNbShapes); |
125 | DBRep::Set(aName, aShapeAlert->GetShape()); |
126 | // |
127 | aShapeList += " "; |
128 | aShapeList += aName; |
129 | } |
130 | } |
131 | aText += (aNbShapes ? ": " : "(no shapes attached)"); |
132 | aText += aShapeList; |
133 | } |
134 | |
135 | // output message with list of shapes |
136 | Message::DefaultMessenger()->Send (aText, anAlertTypes[iGravity]); |
137 | } |
138 | } |
139 | } |