1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

// update code style and error messages on each providers

// fixed problems with IGES provider
This commit is contained in:
dpasukhi
2023-01-04 15:14:18 +00:00
parent 669c9841b2
commit 93a6d4548d
7 changed files with 235 additions and 166 deletions

View File

@@ -53,8 +53,8 @@ bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
Message::SendFail() << "Error: DEBRepCascade_Provider : "
<< "Null document";
return false;
}
TopoDS_Shape aShape;
@@ -62,7 +62,8 @@ bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
{
return false;
}
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
Handle(XCAFDoc_ShapeTool) aShTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShTool->AddShape(aShape);
return true;
}
@@ -79,12 +80,13 @@ bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
(void)theWS;
TopoDS_Shape aShape;
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
Handle(XCAFDoc_ShapeTool) aSTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aSTool->GetFreeShapes(aLabels);
if (aLabels.Length() <= 0)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Document contain no shapes";
Message::SendFail() << "Error: DEBRepCascade_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
@@ -120,46 +122,42 @@ bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
bool isBinaryFormat = true;
{
// probe file header to recognize format
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
const Handle(OSD_FileSystem)& aFileSystem =
OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::istream> aFile =
aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
if (aFile.get() == NULL)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read the file";
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot open the file";
return false;
}
char aStringBuf[255] = {};
aFile->read(aStringBuf, 255);
if (aFile->fail())
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read the file";
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot open the file";
return false;
}
isBinaryFormat = !(::strncmp(aStringBuf, "DBRep_DrawableShape", 19) == 0);
}
Standard_Boolean aReadStatus = Standard_True;
if (isBinaryFormat)
{
if (!BinTools::Read(theShape, thePath.ToCString(), theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read from the file";
return false;
}
aReadStatus = BinTools::Read(theShape, thePath.ToCString(), theProgress);
}
else
{
if (!BRepTools::Read(theShape, thePath.ToCString(), BRep_Builder(), theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read from the file";
return false;
}
aReadStatus =
BRepTools::Read(theShape, thePath.ToCString(), BRep_Builder(), theProgress);
}
return true;
if (!aReadStatus)
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot read data from the file";
}
return aReadStatus;
}
//=======================================================================
@@ -172,59 +170,69 @@ bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEBRepCascade_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(DEBRepCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: DEBRepCascade_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(DEBRepCascade_ConfigurationNode) aNode = Handle(DEBRepCascade_ConfigurationNode)::DownCast(GetNode());
Handle(DEBRepCascade_ConfigurationNode) aNode =
Handle(DEBRepCascade_ConfigurationNode)::DownCast(GetNode());
if (aNode->InternalParameters.WriteBinary)
{
if (aNode->InternalParameters.WriteVersionBin > static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionBin < static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_LOWER))
if (aNode->InternalParameters.WriteVersionBin >
static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionBin <
static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_LOWER))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Unknown format version";
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Unknown format version";
return false;
}
if (aNode->InternalParameters.WriteNormals &&
aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Vertex normals require binary format version 4 or later";
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Vertex normals require binary format version 4 or later";
return false;
}
if (!BinTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionBin, theProgress))
if (!BinTools::Write(theShape, thePath.ToCString(),
aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals,
aNode->InternalParameters.WriteVersionBin, theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Cannot write the file";
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot write the file";
return false;
}
}
else
{
if (aNode->InternalParameters.WriteVersionAscii > static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionAscii < static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_LOWER))
if (aNode->InternalParameters.WriteVersionAscii >
static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionAscii <
static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_LOWER))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Unknown format version";
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Unknown format version";
return false;
}
if (aNode->InternalParameters.WriteNormals &&
aNode->InternalParameters.WriteVersionAscii < TopTools_FormatVersion_VERSION_3)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Error: vertex normals require ascii format version 3 or later";
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Vertex normals require ascii format version 3 or later";
return false;
}
if (!BRepTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionAscii, theProgress))
if (!BRepTools::Write(theShape, thePath.ToCString(),
aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals,
aNode->InternalParameters.WriteVersionAscii, theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Cannot write the file";
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot write the file";
return false;
}
}

View File

@@ -61,17 +61,19 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
Message::SendFail() << "Error: DEXCAFCascade_Provider : "
<< "Null document";
return false;
}
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
<< "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: DEXCAFCascade_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(DEXCAFCascade_ConfigurationNode) aNode = Handle(DEXCAFCascade_ConfigurationNode)::DownCast(GetNode());
Handle(DEXCAFCascade_ConfigurationNode) aNode =
Handle(DEXCAFCascade_ConfigurationNode)::DownCast(GetNode());
Handle(TDocStd_Document) aDocument;
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinDrivers::DefineFormat(anApp);
@@ -84,12 +86,15 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
XmlLDrivers::DefineFormat(anApp);
XmlTObjDrivers::DefineFormat(anApp);
XmlXCAFDrivers::DefineFormat(anApp);
Handle(PCDM_ReaderFilter) aFilter = new PCDM_ReaderFilter(aNode->InternalParameters.ReadAppendMode);
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadSkipValues); anIt.More(); anIt.Next())
Handle(PCDM_ReaderFilter) aFilter =
new PCDM_ReaderFilter(aNode->InternalParameters.ReadAppendMode);
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadSkipValues);
anIt.More(); anIt.Next())
{
aFilter->AddSkipped(anIt.Value());
}
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadValues); anIt.More(); anIt.Next())
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadValues);
anIt.More(); anIt.Next())
{
if (anIt.Value().StartsWith("0"))
{
@@ -103,8 +108,8 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
if (anApp->Open(thePath, aDocument, aFilter, theProgress) != PCDM_RS_OK)
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
<< "\t: Cannot open XDE document";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Cannot open XDE document";
return false;
}
theDocument->SetData(aDocument->GetData());
@@ -130,50 +135,50 @@ bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
}
else if (!theDocument->IsSaved())
{
Message::SendFail() << "Storage error in the DEXCAFCascade_Provider during writing the file " <<
thePath << "\t: Storage error : this document has never been saved";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : Document has never been saved";
return false;
}
else
{
aStatus = anApp->Save(theDocument, theProgress);
}
switch (aStatus)
{
case PCDM_SS_OK:
return true;
case PCDM_SS_DriverFailure:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : driver failure";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : driver failure";
break;
case PCDM_SS_WriteFailure:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during the writing the file : " << thePath
<< "\t: Storage error : write failure";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : write failure";
break;
case PCDM_SS_Failure:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : general failure";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : general failure";
break;
case PCDM_SS_Doc_IsNull:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error :: document is NULL";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : document is NULL";
break;
case PCDM_SS_No_Obj:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : no object";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : no object";
break;
case PCDM_SS_Info_Section_Error:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : section error";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : section error";
break;
case PCDM_SS_UserBreak:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : user break";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : user break";
break;
case PCDM_SS_UnrecognizedFormat:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : unrecognized document storage format : " << theDocument->StorageFormat();
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : unrecognized document storage format : "
<< theDocument->StorageFormat();
break;
}
return false;
@@ -189,10 +194,11 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
<< "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: DEXCAFCascade_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(TDocStd_Document) aDocument;
@@ -205,8 +211,8 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
aSTool->GetFreeShapes(aLabels);
if (aLabels.Length() <= 0)
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
<< "\t: Document contain no shapes";
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : Document contain no shapes";
return false;
}

View File

@@ -141,13 +141,12 @@ void IGESCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& the
myOldValues.WriteOffsetMode =
Interface_Static::IVal("write.iges.offset.mode") == 1;
myOldGlobalValues.LengthUnit = Interface_Static::IVal("xstep.cascade.unit");
myOldGlobalValues.LengthUnit = 0.001 *
UnitsMethods::GetLengthFactorValue(Interface_Static::IVal("xstep.cascade.unit"));
// Set new values
UnitsMethods::SetCasCadeLengthUnit(aNode->GlobalParameters.LengthUnit,
UnitsMethods_LengthUnit_Millimeter);
TCollection_AsciiString aStrUnit(
UnitsMethods::DumpLengthUnit(aNode->GlobalParameters.LengthUnit));
UnitsMethods::DumpLengthUnit(aNode->GlobalParameters.LengthUnit,
UnitsMethods_LengthUnit_Meter));
aStrUnit.UpperCase();
Interface_Static::SetCVal("xstep.cascade.unit", aStrUnit.ToCString());
setStatic(aNode->InternalParameters);
@@ -225,8 +224,12 @@ void IGESCAFControl_Provider::resetStatic()
{
return;
}
Interface_Static::SetIVal("xstep.cascade.unit", myOldGlobalValues.LengthUnit);
UnitsMethods::SetCasCadeLengthUnit(myOldGlobalValues.LengthUnit);
// Set new values
TCollection_AsciiString aStrUnit(
UnitsMethods::DumpLengthUnit(myOldGlobalValues.LengthUnit,
UnitsMethods_LengthUnit_Meter));
aStrUnit.UpperCase();
Interface_Static::SetCVal("xstep.cascade.unit", aStrUnit.ToCString());
setStatic(myOldValues);
}
@@ -326,10 +329,28 @@ bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
initStatic(aNode);
personizeWS(theWS);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
aNode->InternalParameters.WriteUnit,
UnitsMethods_LengthUnit_Millimeter);
TCollection_AsciiString aUnit(
UnitsMethods::DumpLengthUnit(aNode->InternalParameters.WriteUnit));
aUnit.UpperCase();
IGESCAFControl_Writer aWriter(theWS, Standard_True);
if (aNode->InternalParameters.WriteUnit > UnitsMethods_LengthUnit_Undefined &&
aNode->InternalParameters.WriteUnit <= UnitsMethods_LengthUnit_Microinch)
{
Handle(IGESData_IGESModel) aModel = aWriter.Model();
IGESData_GlobalSection aGSesction = aModel->GlobalSection();
Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(
IGESData_BasicEditor::UnitFlagName(aNode->InternalParameters.WriteUnit));
if (aGSesction.UnitFlag() == 3)
{
aGSesction.SetUnitName(aName);
}
else if (aGSesction.UnitFlag() > 0)
{
aGSesction.SetUnitFlag(aNode->InternalParameters.WriteUnit);
}
aModel->SetGlobalSection(aGSesction);
}
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);

View File

@@ -26,7 +26,8 @@ namespace
// function : SetReaderParameters
// purpose :
//=======================================================================
static void SetReaderParameters(RWGltf_CafReader& theReader, const Handle(RWGltf_ConfigurationNode) theNode)
static void SetReaderParameters(RWGltf_CafReader& theReader,
const Handle(RWGltf_ConfigurationNode) theNode)
{
theReader.SetDoublePrecision(!theNode->InternalParameters.ReadSinglePrecision);
theReader.SetSystemLengthUnit(theNode->GlobalParameters.LengthUnit / 1000);
@@ -75,24 +76,29 @@ bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
Message::SendFail() << "Error: RWGltf_Provider : "
<< "Null document";
return false;
}
if (GetNode().IsNull() || (!GetNode().IsNull() && !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode))))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: RWGltf_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
Handle(RWGltf_ConfigurationNode) aNode =
Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
RWGltf_CafReader aReader;
aReader.SetDocument(theDocument);
SetReaderParameters(aReader, aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
aNode->GlobalParameters.LengthUnit,
UnitsMethods_LengthUnit_Millimeter);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " << thePath;
Message::SendFail() << "Error: RWGltf_Provider : [" <<
thePath << "] : Cannot read any relevant data from the GLTF file";
return false;
}
@@ -109,13 +115,15 @@ bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWGltf_Provider during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: RWGltf_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
Handle(RWGltf_ConfigurationNode) aNode =
Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetInputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
@@ -146,7 +154,8 @@ bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
aWriter.SetSplitIndices16(aNode->InternalParameters.WriteSplitIndices16);
if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
{
Message::SendFail() << "Error in the RWGltf_Provider during writing the file " << thePath;
Message::SendFail() << "Error: RWGltf_Provider : [" <<
thePath << "] : Cannot write any relevant data to the GLTF file";
return false;
}
return true;
@@ -162,18 +171,21 @@ bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: RWGltf_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
Handle(RWGltf_ConfigurationNode) aNode =
Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
RWGltf_CafReader aReader;
SetReaderParameters(aReader, aNode);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " << thePath;
Message::SendFail() << "Error: RWGltf_Provider : [" <<
thePath << "] : Cannot read any relevant data from the GLTF file";
return false;
}
theShape = aReader.SingleShape();

View File

@@ -51,17 +51,19 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the RWObj_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
Message::SendFail() << "Error: RWObj_Provider : "
<< "Null document";
return false;
}
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: RWObj_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
Handle(RWObj_ConfigurationNode) aNode =
Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
RWObj_CafReader aReader;
aReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
aReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
@@ -73,10 +75,13 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
aReader.SetMemoryLimitMiB(aNode->InternalParameters.ReadMemoryLimitMiB);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " << thePath;
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot read any relevant data from the Obj file";
return false;
}
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
aNode->GlobalParameters.LengthUnit,
UnitsMethods_LengthUnit_Millimeter);
return true;
}
@@ -90,13 +95,15 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: RWObj_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
Handle(RWObj_ConfigurationNode) aNode =
Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
TColStd_IndexedDataMapOfStringString aFileInfo;
if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
@@ -107,7 +114,6 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
{
aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
}
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetInputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
@@ -118,7 +124,8 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
aWriter.SetCoordinateSystemConverter(aConverter);
if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " << thePath;
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot write any relevant data to the Obj file";
return false;
}
return true;
@@ -134,13 +141,15 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: RWObj_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
Handle(RWObj_ConfigurationNode) aNode =
Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.SystemCS);
@@ -155,7 +164,8 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
aSimpleReader.SetMemoryLimit(aNode->InternalParameters.ReadMemoryLimitMiB);
if (!aSimpleReader.Read(thePath, theProgress))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " << thePath;
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot read any relevant data from the Obj file";
return false;
}
Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
@@ -178,7 +188,8 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
{
(void)theWS;
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
Handle(XCAFDoc_ShapeTool) aShTool =
XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
return Write(thePath, aDoc, theWS, theProgress);
}

View File

@@ -52,22 +52,24 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWPly_ConfigurationNode)))
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWPly_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWPly_Provider during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: RWPly_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWPly_ConfigurationNode) aNode = Handle(RWPly_ConfigurationNode)::DownCast(GetNode());
Handle(RWPly_ConfigurationNode) aNode =
Handle(RWPly_ConfigurationNode)::DownCast(GetNode());
TDF_LabelSequence aRootLabels;
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
Handle(XCAFDoc_ShapeTool) aShapeTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShapeTool->GetFreeShapes(aRootLabels);
if (aRootLabels.IsEmpty())
{
return Standard_True;
}
TColStd_IndexedDataMapOfStringString aFileInfo;
if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
{
@@ -91,8 +93,8 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
{
Message::SendFail() << "Error in the RWPly_Provider during writing the file "
<< thePath << "\t: Cannot perform the document";
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot write any relevant data to the Ply file";
return false;
}

View File

@@ -53,8 +53,8 @@ bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
Message::SendFail() << "Error: RWStl_Provider : "
<< "Null document";
return false;
}
TopoDS_Shape aShape;
@@ -62,7 +62,8 @@ bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
{
return false;
}
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
Handle(XCAFDoc_ShapeTool) aShapeTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShapeTool->AddShape(aShape);
return true;
}
@@ -79,12 +80,13 @@ bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
(void)theWS;
TopoDS_Shape aShape;
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
Handle(XCAFDoc_ShapeTool) aSTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aSTool->GetFreeShapes(aLabels);
if (aLabels.Length() <= 0)
{
Message::SendFail() << "Error in the RWStl_Provider during writing the file " <<
thePath << "\t: Document contain no shapes";
Message::SendFail() << "Error: RWStl_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
@@ -117,27 +119,30 @@ bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
Message::SendWarning() << "OCCT Stl reader does not support model scaling according to custom length unit";
Message::SendWarning()
<< "OCCT Stl reader does not support model scaling according to custom length unit";
if (!GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return true;
Message::SendFail() << "Error: RWStl_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWStl_ConfigurationNode) aNode = Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
Handle(RWStl_ConfigurationNode) aNode =
Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
double aMergeAngle = aNode->InternalParameters.ReadMergeAngle * M_PI / 180.0;
if (aMergeAngle != M_PI_2)
{
if (aMergeAngle < 0.0 || aMergeAngle > M_PI_2)
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: The merge angle is out of the valid range";
Message::SendFail() << "Error: RWStl_Provider : ["
<< aMergeAngle << "] The merge angle is out of the valid range";
return false;
}
}
if (!aNode->InternalParameters.ReadBRep)
{
Handle(Poly_Triangulation) aTriangulation = RWStl::ReadFile(thePath.ToCString(), aMergeAngle, theProgress);
Handle(Poly_Triangulation) aTriangulation =
RWStl::ReadFile(thePath.ToCString(), aMergeAngle, theProgress);
TopoDS_Face aFace;
BRep_Builder aB;
@@ -150,7 +155,8 @@ bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
Standard_DISABLE_DEPRECATION_WARNINGS
if (!StlAPI::Read(theShape, thePath.ToCString()))
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " << thePath;
Message::SendFail() << "Error: RWStl_Provider : [" <<
thePath << "] : Cannot read any relevant data from the STL file";
return false;
}
Standard_ENABLE_DEPRECATION_WARNINGS
@@ -168,21 +174,24 @@ bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
Message::SendWarning() << "OCCT Stl writer does not support model scaling according to custom length unit";
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
Message::SendWarning() <<
"OCCT Stl writer does not support model scaling according to custom length unit";
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
Message::SendFail() << "Error: RWStl_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWStl_ConfigurationNode) aNode = Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
Handle(RWStl_ConfigurationNode) aNode =
Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
StlAPI_Writer aWriter;
aWriter.ASCIIMode() = aNode->InternalParameters.WriteAscii;
if (!aWriter.Write(theShape, thePath.ToCString(), theProgress))
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: Mesh writing has been failed";
Message::SendFail() << "Error: RWStl_Provider : [" <<
thePath << "] : Mesh writing has been failed";
return false;
}
return true;