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>
21 #include <Draw_Interpretor.hxx>
22 #include <Draw_PluginMacro.hxx>
23 #include <GeometryTest.hxx>
24 #include <GeomliteTest.hxx>
25 #include <HLRTest.hxx>
26 #include <NCollection_Map.hxx>
27 #include <MeshTest.hxx>
28 #include <Message.hxx>
29 #include <Message_Alert.hxx>
30 #include <Message_Msg.hxx>
31 #include <Message_Messenger.hxx>
32 #include <Message_Report.hxx>
34 #include <TopoDS_AlertWithShape.hxx>
36 #include <BOPAlgo_Alerts.hxx>
37 #include <BOPTest_Objects.hxx>
39 //=======================================================================
40 //function : AllCommands
42 //=======================================================================
43 void BOPTest::AllCommands(Draw_Interpretor& theCommands)
45 static Standard_Boolean done = Standard_False;
49 BOPTest::BOPCommands (theCommands);
50 BOPTest::CheckCommands (theCommands);
51 BOPTest::LowCommands (theCommands);
52 BOPTest::TolerCommands (theCommands);
53 BOPTest::ObjCommands (theCommands);
54 BOPTest::PartitionCommands (theCommands);
55 BOPTest::APICommands (theCommands);
56 BOPTest::OptionCommands (theCommands);
57 BOPTest::DebugCommands (theCommands);
58 BOPTest::CellsCommands (theCommands);
59 BOPTest::UtilityCommands (theCommands);
60 BOPTest::RemoveFeaturesCommands(theCommands);
61 BOPTest::PeriodicityCommands(theCommands);
62 BOPTest::MkConnectedCommands(theCommands);
64 //=======================================================================
67 //=======================================================================
68 void BOPTest::Factory(Draw_Interpretor& theCommands)
70 static Standard_Boolean FactoryDone = Standard_False;
71 if (FactoryDone) return;
73 FactoryDone = Standard_True;
75 DBRep::BasicCommands(theCommands);
76 GeomliteTest::AllCommands(theCommands);
77 GeometryTest::AllCommands(theCommands);
78 BRepTest::AllCommands(theCommands);
79 MeshTest::Commands(theCommands);
80 HLRTest::Commands(theCommands);
81 BOPTest::AllCommands(theCommands);
82 SWDRAW::Init (theCommands);
84 // Declare entry point PLUGINFACTORY
87 //=======================================================================
88 //function : ReportAlerts
90 //=======================================================================
92 void BOPTest::ReportAlerts(const Handle(Message_Report)& theReport)
94 // first report warnings, then errors
95 Message_Gravity anAlertTypes[2] = { Message_Warning, Message_Fail };
96 TCollection_ExtendedString aMsgType[2] = { "Warning: ", "Error: " };
97 for (int iGravity = 0; iGravity < 2; iGravity++)
99 // report shapes for the same type of alert together
100 NCollection_Map<Handle(Standard_Transient)> aPassedTypes;
101 const Message_ListOfAlert& aList = theReport->GetAlerts (anAlertTypes[iGravity]);
102 for (Message_ListOfAlert::Iterator aIt (aList); aIt.More(); aIt.Next())
104 // check that this type of warnings has not yet been processed
105 const Handle(Standard_Type)& aType = aIt.Value()->DynamicType();
106 if (!aPassedTypes.Add(aType))
110 Message_Msg aMsg (aIt.Value()->GetMessageKey());
111 TCollection_ExtendedString aText = aMsgType[iGravity] + aMsg.Get();
113 // collect all shapes if any attached to this alert
114 if (BOPTest_Objects::DrawWarnShapes())
116 TCollection_AsciiString aShapeList;
117 Standard_Integer aNbShapes = 0;
118 for (Message_ListOfAlert::Iterator aIt2 (aIt); aIt2.More(); aIt2.Next())
120 Handle(TopoDS_AlertWithShape) aShapeAlert = Handle(TopoDS_AlertWithShape)::DownCast (aIt2.Value());
122 if (!aShapeAlert.IsNull() &&
123 (aType == aShapeAlert->DynamicType()) &&
124 !aShapeAlert->GetShape().IsNull())
128 Sprintf(aName, "%ss_%d_%d", (iGravity ? "e" : "w"), aPassedTypes.Extent(), ++aNbShapes);
129 DBRep::Set(aName, aShapeAlert->GetShape());
135 aText += (aNbShapes ? ": " : "(no shapes attached)");
139 // output message with list of shapes
140 Draw_Interpretor& aDrawInterpretor = Draw::GetInterpretor();
141 aDrawInterpretor << aText << "\n";
146 //=======================================================================
147 //function : GetOperationType
149 //=======================================================================
150 BOPAlgo_Operation BOPTest::GetOperationType(const Standard_CString theOp)
152 TCollection_AsciiString anOp(theOp);
155 if (anOp.IsIntegerValue())
157 // Check if the given value satisfies the enumeration.
158 Standard_Integer iOp = anOp.IntegerValue();
159 if (iOp >= 0 && iOp <= 4)
161 return static_cast<BOPAlgo_Operation>(iOp);
163 return BOPAlgo_UNKNOWN;
166 // Check for the meaningful symbolic operation parameter
167 if (anOp == "common")
169 return BOPAlgo_COMMON;
171 else if (anOp == "fuse")
175 else if (anOp == "cut")
179 else if (anOp == "tuc" || anOp == "cut21")
181 return BOPAlgo_CUT21;
183 else if (anOp == "section")
185 return BOPAlgo_SECTION;
188 return BOPAlgo_UNKNOWN;