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