1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-09 18:50:54 +03:00
occt/src/BOPTest/BOPTest.cxx
mzernova caee80f39f 0030697: Draw Harness - Draw_Printer should not be set to Message::DefaultMessenger() by default
Fixed bugs that occurred when using the default std::cout from Message::DefaultMessenger() instead of Draw_Printer

A dedicated option was added to Draw_ProgressIndicator, for outputting data to the tcl when performing tests

Added -tclOutput parameter to XProgress command
2019-11-23 16:09:07 +03:00

145 lines
5.1 KiB
C++

// Created on: 2000-05-18
// Created by: Peter KURNEV
// Copyright (c) 2000-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BOPTest.hxx>
#include <BRepTest.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_PluginMacro.hxx>
#include <GeometryTest.hxx>
#include <GeomliteTest.hxx>
#include <HLRTest.hxx>
#include <NCollection_Map.hxx>
#include <MeshTest.hxx>
#include <Message.hxx>
#include <Message_Alert.hxx>
#include <Message_Msg.hxx>
#include <Message_Messenger.hxx>
#include <Message_Report.hxx>
#include <SWDRAW.hxx>
#include <TopoDS_AlertWithShape.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPTest_Objects.hxx>
//=======================================================================
//function : AllCommands
//purpose :
//=======================================================================
void BOPTest::AllCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
//
BOPTest::BOPCommands (theCommands);
BOPTest::CheckCommands (theCommands);
BOPTest::LowCommands (theCommands);
BOPTest::TolerCommands (theCommands);
BOPTest::ObjCommands (theCommands);
BOPTest::PartitionCommands (theCommands);
BOPTest::APICommands (theCommands);
BOPTest::OptionCommands (theCommands);
BOPTest::DebugCommands (theCommands);
BOPTest::CellsCommands (theCommands);
BOPTest::UtilityCommands (theCommands);
BOPTest::RemoveFeaturesCommands(theCommands);
BOPTest::PeriodicityCommands(theCommands);
BOPTest::MkConnectedCommands(theCommands);
}
//=======================================================================
//function : Factory
//purpose :
//=======================================================================
void BOPTest::Factory(Draw_Interpretor& theCommands)
{
static Standard_Boolean FactoryDone = Standard_False;
if (FactoryDone) return;
FactoryDone = Standard_True;
DBRep::BasicCommands(theCommands);
GeomliteTest::AllCommands(theCommands);
GeometryTest::AllCommands(theCommands);
BRepTest::AllCommands(theCommands);
MeshTest::Commands(theCommands);
HLRTest::Commands(theCommands);
BOPTest::AllCommands(theCommands);
SWDRAW::Init (theCommands);
}
// Declare entry point PLUGINFACTORY
DPLUGIN(BOPTest)
//=======================================================================
//function : ReportAlerts
//purpose :
//=======================================================================
void BOPTest::ReportAlerts(const Handle(Message_Report)& theReport)
{
// first report warnings, then errors
Message_Gravity anAlertTypes[2] = { Message_Warning, Message_Fail };
TCollection_ExtendedString aMsgType[2] = { "Warning: ", "Error: " };
for (int iGravity = 0; iGravity < 2; iGravity++)
{
// report shapes for the same type of alert together
NCollection_Map<Handle(Standard_Transient)> aPassedTypes;
const Message_ListOfAlert& aList = theReport->GetAlerts (anAlertTypes[iGravity]);
for (Message_ListOfAlert::Iterator aIt (aList); aIt.More(); aIt.Next())
{
// check that this type of warnings has not yet been processed
const Handle(Standard_Type)& aType = aIt.Value()->DynamicType();
if (!aPassedTypes.Add(aType))
continue;
// get alert message
Message_Msg aMsg (aIt.Value()->GetMessageKey());
TCollection_ExtendedString aText = aMsgType[iGravity] + aMsg.Get();
// collect all shapes if any attached to this alert
if (BOPTest_Objects::DrawWarnShapes())
{
TCollection_AsciiString aShapeList;
Standard_Integer aNbShapes = 0;
for (Message_ListOfAlert::Iterator aIt2 (aIt); aIt2.More(); aIt2.Next())
{
Handle(TopoDS_AlertWithShape) aShapeAlert = Handle(TopoDS_AlertWithShape)::DownCast (aIt2.Value());
if (!aShapeAlert.IsNull() &&
(aType == aShapeAlert->DynamicType()) &&
!aShapeAlert->GetShape().IsNull())
{
//
char aName[80];
Sprintf(aName, "%ss_%d_%d", (iGravity ? "e" : "w"), aPassedTypes.Extent(), ++aNbShapes);
DBRep::Set(aName, aShapeAlert->GetShape());
//
aShapeList += " ";
aShapeList += aName;
}
}
aText += (aNbShapes ? ": " : "(no shapes attached)");
aText += aShapeList;
}
// output message with list of shapes
Draw_Interpretor& aDrawInterpretor = Draw::GetInterpretor();
aDrawInterpretor << aText << "\n";
}
}
}